Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Mutator that adds custom weapon to existing UT3 maps

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    As said before, the red lines in the GitHub changes view are the ones from the older version of the file (which got removed/changed). The greeon ones are from the newer version.

    You don't need to clear the default weapon. But you can. As long as you specifiy your desired weapon in a placed weapon factory, the default WeaponPickupClass isn't used in any way.

    Comment


      #32
      Okay, I get it now. The red lines are from the older file and should be deleted. That is why they have a minus next to them. The green lines are new lines of code which I need to add to the file to update it.

      I fixed up the WeaponAddLocationInfo.uc file and modified it accordingly and recompiled everything again. No compiling script errors. I opened up the editor and put 2 XWeaponAddFactories in the Biohazard map. One with the shock rifle and the other with a custom weapon the Ripper and pressed the editor saver button. I tested the mutator in game again and the two pickup factories were there with the correct weapons assigned. Success!

      There is one other thing I wanted to do I just remembered, I wanted to be able to store custom ammo pickups the same way. I will have a look at decompiled uc file again to see if it already has a function for that. I can't remember.

      Comment


        #33
        The workflow for creating ammo pickups is a bit different. You can't just set a ammo class how it works for weapons. Ammo pickups are just like weapon factories. These factories need to have bNoDelete and bStatic both set to false in order to be created on runtime (when the map is played in the game). Ripper might come with such ammo pickup, but it is likely a "static" factory which can be placed into maps and stored in their (just like every original factory in original maps).

        However, you can create a ammo pickup class and transform it to any ammo pickup you want. Let me know if you need help with that.

        Comment


          #34
          This is what I have done so far.

          Created file XAmmoAddFactory.uc with content below:

          Code:
          /** 
           * Basic ammo factory to spawn in the level on runtime
           */
           
           class XAmmoAddFactory extends UTAmmoPickupFactory;
           
           DefaultProperties
          {
          	// allow dynamic spawn
              bStatic=false
              bNoDelete=false
          
          	// allow basing on moveable actors (such as lifts)
          	bMovable=true
          
              AmmoPickupClass=class'UTAmmo_ShockRifle'
          
          	// replicate initial rotation
          	bNetInitialRotation=true
          	bNeverReplicateRotation=false // just set is for safety
          
          	// replicate all other props (not only the 'hidden' flag)
          	bOnlyReplicateHidden=false
          }
          Created file XAmmoAddMutator.uc with content below:

          Code:
          /**
           * Mutator to initialize the map profile containing the locations 
           * for the new ammo factories
           */
           
           class XAmmoAddMutator extends UTMutator;
           
          var class<PickupFactory> AmmoFactoryClass;
          
          function PostBeginPlay()
          {
              super.PostBeginPlay();
          	LoadAmmo();
          }
          
          function LoadAmmo(optional string ProfileName = "")
          {
          	local XAmmoAddLocationInfo LocInfo;
          	if (class'XAmmoAddLocationInfo'.static.Exists(LocInfo, ProfileName))
          	{
          		LocInfo.RestoreFactories(AmmoFactoryClass);
          	}
          }
          
          Defaultproperties
          {
          	AmmoFactoryClass=class'XAmmoAddFactory'
          }

          How am I going so far?

          Comment


            #35
            Looking good so far. But that's the easiest part of it . The important part would be how to store and restore ammo classes. A weapon factory has set the Weapon to spawn in its properties. A ammo factory doesn't have such property. A ammo factor is a single class for each specific ammo item. It wouldn't work the same way. The ammo mutator is actually more complex than this. Not sure if you will get that far; let me have a look on how to implement that mutator (I actually had it in mind previously, it's just a matter of writing it down and testing, testing and testing ).

            Comment


              #36
              Oh, I think I see what you mean. That is why in the editor all the ammo pickups are under the UTAmmoPickupFactory class and the UTAmmoPickupFactory must transform into the ammo you select to place into the map. Which is totally different to how the UTWeaponPickupFactory works. Should of though of that earlier.

              Comment


                #37
                Yep. And also, as I wrote down my initial idea, I ran into problems regarding "transforming ammo factories". Which is working but the native transforming code somehow manipulates the original ammo factorty in a way that it won't work after the item is picked up once. This is strange but I already found the origin of that problem, a material gets applied which seems like is not working for these non-static factories. I ran several tests to notice that (with debugging).

                Comment


                  #38
                  Late reply. But here we go. i just uploaded the working code for storing and restoring ammo pickups. It works similar to weapon factories. You create the factories in the level editor and select an ammo type. Save the profile with the toolbar button (in case of the editor script is installed) or the PIE mutator. Check the source code here:
                  https://github.com/RattleSN4K3/UT3-S...r-Ammos-AddNew

                  Comment


                    #39
                    thanks you

                    Comment


                      #40
                      Thanks RattleSN4K3

                      Sorry for the late reply. I have downloaded the source code. Will have a look at it later and test it. Cheers!

                      Comment


                        #41
                        I tested it using the second method and it doesn't seem to work in game.

                        Comment


                          #42
                          What 2nd method?

                          Looks like it is not loading. Strange. Gonna check it real quick and fix it.

                          Comment


                            #43
                            The shipped mutator XMutatorAmmoAdd_REV2_PC.zip works out of the box now. It can be seen with opening a Instant action game, select DM-Deck and add the mutator "Test Ammo-Add-Mutator". A ShockRifle and Flak ammo pickup should be created on the bridge in Deck (near Stinger).

                            Only at the end, I polished the code and removed a passed parameter in the restore function (which is used in the weapon code). With that change, I missed using the right class to spawn custom pickups . Therefore the engine tries to spawn an abstract class (and non-spawnable one) which isn't working. I made some changes, which now fully works in edito, in-game, local and network sessions.


                            Keep in mind: This mutator should be an example mutator. Do not create a mutator package with the same name... also preferably, renaming classes.

                            Comment


                              #44
                              Originally posted by RattleSN4K3 View Post
                              What 2nd method?

                              Looks like it is not loading. Strange. Gonna check it real quick and fix it.

                              Second method is using the UI not the play in editor. I also forgot to mention that there is a problem with the XMutatorAmmoAdd Loader button function in the editor. It comes up with an error failed to load or retrieve materials when I use that button to call the stored ammo location in the same map. Don't know if you already know this.

                              Comment


                                #45
                                Originally posted by RattleSN4K3 View Post
                                The shipped mutator XMutatorAmmoAdd_REV2_PC.zip works out of the box now. It can be seen with opening a Instant action game, select DM-Deck and add the mutator "Test Ammo-Add-Mutator". A ShockRifle and Flak ammo pickup should be created on the bridge in Deck (near Stinger).

                                Only at the end, I polished the code and removed a passed parameter in the restore function (which is used in the weapon code). With that change, I missed using the right class to spawn custom pickups . Therefore the engine tries to spawn an abstract class (and non-spawnable one) which isn't working. I made some changes, which now fully works in edito, in-game, local and network sessions.
                                Okay, I will try the Test Ammo Add Mutator. Should I uninstall /remove the previous ammo mutator example you did?



                                Originally posted by RattleSN4K3 View Post
                                Do not create a mutator package with the same name... also preferably, renaming classes.
                                Not sure what you mean by renaming classes?

                                Comment

                                Working...
                                X