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

Weapon replacement mutator 4 U 2 use

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

  • Weapon replacement mutator 4 U 2 use

    Just want to let you all know this is EPIC's code// I'm just adding defaults.

    Code:
    /////////////////////////////////////////////////////
    // Mutator: Copy and Paste from EPIC
    // Assembled By: *PingFre@K*
    /////////////////////////////////////////////////////
    
    class ExampleYourMutatorName extends UTMutator
       config(ExampleYourMutatorName);
    
    struct ReplacementInfo
    {
    	/** class name of the weapon we want to get rid of */
    	var name OldClassName;
    	/** fully qualified path of the class to replace it with */
    	var string NewClassPath;
    };
    
    var config array<ReplacementInfo> WeaponsToReplace;
    var config array<ReplacementInfo> AmmoToReplace;
    
    function PostBeginPlay()
    {
    	local UTGame Game;
    	local int i, Index;
    
    	Super.PostBeginPlay();
    
    	// replace default weapons
    	Game = UTGame(WorldInfo.Game);
    	if (Game != None)
    	{
    		for (i = 0; i < Game.DefaultInventory.length; i++)
    		{
    			if (Game.DefaultInventory[i] != None)
    			{
    				Index = WeaponsToReplace.Find('OldClassName', Game.DefaultInventory[i].Name);
    				if (Index != INDEX_NONE)
    				{
    					if (WeaponsToReplace[Index].NewClassPath == "")
    					{
    						// replace with nothing
    						Game.DefaultInventory.Remove(i, 1);
    						i--;
    					}
    					Game.DefaultInventory[i] = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'));
    				}
    			}
    		}
    
    		if (Game.TranslocatorClass != None)
    		{
    			Index = WeaponsToReplace.Find('OldClassName', Game.TranslocatorClass.Name);
    			if (Index != INDEX_NONE)
    			{
    				if (WeaponsToReplace[Index].NewClassPath == "")
    				{
    					// replace with nothing
    					Game.TranslocatorClass = None;
    				}
    				else
    				{
    					Game.TranslocatorClass = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'));
    				}
    			}
    		}
    	}
    }
    
    function bool CheckReplacement(Actor Other)
    {
    	local UTWeaponPickupFactory WeaponPickup;
    	local UTWeaponLocker Locker;
    	local UTAmmoPickupFactory AmmoPickup, NewAmmo;
    	local int i, Index;
    	local class<UTAmmoPickupFactory> NewAmmoClass;
    
    	WeaponPickup = UTWeaponPickupFactory(Other);
    	if (WeaponPickup != None)
    	{
    		if (WeaponPickup.WeaponPickupClass != None)
    		{
    			Index = WeaponsToReplace.Find('OldClassName', WeaponPickup.WeaponPickupClass.Name);
    			if (Index != INDEX_NONE)
    			{
    				if (WeaponsToReplace[Index].NewClassPath == "")
    				{
    					// replace with nothing
    					return false;
    				}
    				WeaponPickup.WeaponPickupClass = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'));
    				WeaponPickup.InitializePickup();
    			}
    		}
    	}
    	else
    	{
    		Locker = UTWeaponLocker(Other);
    		if (Locker != None)
    		{
    			for (i = 0; i < Locker.Weapons.length; i++)
    			{
    				if (Locker.Weapons[i].WeaponClass != None)
    				{
    					Index = WeaponsToReplace.Find('OldClassName', Locker.Weapons[i].WeaponClass.Name);
    					if (Index != INDEX_NONE)
    					{
    						if (WeaponsToReplace[Index].NewClassPath == "")
    						{
    							// replace with nothing
    							Locker.ReplaceWeapon(i, None);
    						}
    						else
    						{
    							Locker.ReplaceWeapon(i, class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class')));
    						}
    					}
    				}
    			}
    		}
    		else
    		{
    			AmmoPickup = UTAmmoPickupFactory(Other);
    			if (AmmoPickup != None)
    			{
    				Index = AmmoToReplace.Find('OldClassName', AmmoPickup.Class.Name);
    				if (Index != INDEX_NONE)
    				{
    					if (AmmoToReplace[Index].NewClassPath == "")
    					{
    						// replace with nothing
    						return false;
    					}
    					NewAmmoClass = class<UTAmmoPickupFactory>(DynamicLoadObject(AmmoToReplace[Index].NewClassPath, class'Class'));
    					if (NewAmmoClass == None)
    					{
    						// replace with nothing
    						return false;
    					}
    					else if (NewAmmoClass.default.bStatic || NewAmmoClass.default.bNoDelete)
    					{
    						// transform the current ammo into the desired class
    						AmmoPickup.TransformAmmoType(NewAmmoClass);
    						return true;
    					}
    					else
    					{
    						// spawn the new ammo, link it to the old, then disable the old one
    						NewAmmo = AmmoPickup.Spawn(NewAmmoClass);
    						NewAmmo.OriginalFactory = AmmoPickup;
    						AmmoPickup.ReplacementFactory = NewAmmo;
    						return false;
    					}
    				}
    			}
    		}
    	}
    
    	return true;
    }
    
    
    defaultproperties
    {
    // Fill in the blanks
       WeaponsToReplace(0)=(OldClassName="UTWeap_Enforcer",NewClassPath="ExamplePackageName.ExampleWeaponClassName")
       AmmoToReplace(0)=(OldClassName="UTAmmo_Enforcer",NewClassPath="ExamplePackageName.ExampleAmmoClassName")
    
       WeaponsToReplace(1)=(OldClassName="UTWeap_BioRifle_Content",NewClassPath="")
       AmmoToReplace(1)=(OldClassName="UTAmmo_BioRifle_Content",NewClassPath="")
    
       WeaponsToReplace(2)=(OldClassName="UTWeap_FlakCannon",NewClassPath="")
       AmmoToReplace(2)=(OldClassName="UTAmmo_FlakCannon",NewClassPath="")
    
       WeaponsToReplace(3)=(OldClassName="UTWeap_LinkGun",NewClassPath="")
       AmmoToReplace(3)=(OldClassName="UTAmmo_LinkGun",NewClassPath="")
    
       WeaponsToReplace(4)=(OldClassName="UTWeap_Redeemer_Content",NewClassPath="")
    
       WeaponsToReplace(5)=(OldClassName="UTWeap_RocketLauncher",NewClassPath="")
       AmmoToReplace(5)=(OldClassName="UTAmmo_RocketLauncher",NewClassPath="")
    
       WeaponsToReplace(6)=(OldClassName="UTWeap_ShockRifle",NewClassPath="")
       AmmoToReplace(6)=(OldClassName="UTAmmo_ShockRifle",NewClassPath="")
    
       WeaponsToReplace(7)=(OldClassName="UTWeap_SniperRifle",NewClassPath="")
       AmmoToReplace(7)=(OldClassName="UTAmmo_SniperRifle",NewClassPath="")
    
       WeaponsToReplace(8)=(OldClassName="UTWeap_Stinger",NewClassPath="")
       AmmoToReplace(8)=(OldClassName="UTAmmo_Stinger",NewClassPath="")
    
       GroupNames(0)=""
       Name=""
    }
    After struggling to wright a weapon replacemnt mutator.. And seeing things done over these forums to incorrectly wright one.. I thought I should share this bit of 'should of known' knowledge for weapon replacement.
    You can use this code in your mutator to have your weapon or weapon Pack replacements. Don't know if something like this gets stickied or not but it's definitely good info.

  • #2
    Dude THANK YOU!! No one has replied but I will Thanks!

    Comment


    • #3
      Thanks, kool info.

      Comment


      • #4
        i have got to report, this works like a charm. No error (which I was getting when I was trying to do mine...) in the server window... now if we could get compression, we'd be all set

        Thanks Pinkfreak.

        Comment


        • #5
          Is there a way to get the PS3's source? That way you could see how they did the configuration menues.

          Comment


          • #6
            Thanks for this. I would think replacing 1 class name with 1 other class name multiple times could be simpler...

            Altering the Default Properties is easier anyway.

            Comment


            • #7
              function PostBeginPlay()
              {
              local UTGame Game;
              local int i, Index;

              Super.PostBeginPlay();

              // replace default weapons
              Game = UTGame(WorldInfo.Game);
              if (Game != None)
              {
              for (i = 0; i < Game.DefaultInventory.length; i++)
              {
              if (Game.DefaultInventory[i] != None)
              {
              Index = WeaponsToReplace.Find('OldClassName', Game.DefaultInventory[i].Name);
              if (Index != INDEX_NONE)
              {
              if (WeaponsToReplace[Index].NewClassPath == "")
              {
              // replace with nothing
              Game.DefaultInventory.Remove(i, 1);
              i--;
              }
              Game.DefaultInventory[i] = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'));
              }
              }
              }


              if (Game.TranslocatorClass != None)
              {
              Index = WeaponsToReplace.Find('OldClassName', Game.TranslocatorClass.Name);
              if (Index != INDEX_NONE)
              {
              if (WeaponsToReplace[Index].NewClassPath == "")
              {
              // replace with nothing
              Game.TranslocatorClass = None;
              }
              else
              {
              Game.TranslocatorClass = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'));
              }
              }
              }
              }
              }
              The blue I am not sure what is, but red is the translocator, so i can just blank that(//), don't need the ammo codes yet so I can blank them and the vars to them.

              WeaponsToReplace(0)=(OldClassName="UTWeap_Enforcer",NewClassPath="ExamplePackageName.ExampleWeaponClassName")
              AmmoToReplace(0)=(OldClassName="UTAmmo_Enforcer",NewClassPath="ExamplePackageName.ExampleAmmoClassName")
              Now these I fill in with whatever I am replacing the item stated in blue right?(if new ammo I need to add it to the ammo code too)

              Sorry if I am drooling a bit I is a code nawer after all :P

              Comment


              • #8
                The blue area of your quote, removes the default inventory and gives the option to replace with the new class path. The red area on top is for the trans yes.. you could add another default to replace the trans using that area. Your bottom quote is correct. leave the blue and change the red.

                Comment


                • #9
                  when I tried to compile this the compiler said "f you, you don't get mod!" or something to that effect...

                  The compiler wasn't happy, so for now I'm just using the default Weapon Replacer to bring my custom weapons in.

                  Comment


                  • #10
                    Double check your example texts.. and revert back to the origional post.

                    Comment


                    • #11
                      ever heard of subclassing?

                      Comment


                      • #12
                        /////////////////////////////////////////////////////
                        // Mutator: Copy and Paste from EPIC
                        // Assembled By: *PingFre@K*
                        /////////////////////////////////////////////////////

                        class FirstMutator extends UTMutator
                        config(FirstMutator);

                        struct ReplacementInfo
                        {
                        /** class name of the weapon we want to get rid of */
                        var name OldClassName;
                        /** fully qualified path of the class to replace it with */
                        var string NewClassPath;
                        };

                        var config array<ReplacementInfo> WeaponsToReplace;
                        //var config array<ReplacementInfo> AmmoToReplace;

                        function PostBeginPlay()
                        {
                        local UTGame Game;
                        local int i, Index;

                        Super.PostBeginPlay();

                        // replace default weapons
                        Game = UTGame(WorldInfo.Game);
                        if (Game != None)
                        {
                        for (i = 0; i < Game.DefaultInventory.length; i++)
                        {
                        if (Game.DefaultInventory[i] != None)
                        {
                        Index = WeaponsToReplace.Find('OldClassName', Game.DefaultInventory[i].Name);
                        if (Index != INDEX_NONE)
                        {
                        if (WeaponsToReplace[Index].NewClassPath == "")
                        {
                        // replace with nothing
                        Game.DefaultInventory.Remove(i, 1);
                        i--;
                        }
                        Game.DefaultInventory[i] = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'));
                        }
                        }
                        }

                        if (Game.TranslocatorClass != None)
                        {
                        Index = WeaponsToReplace.Find('OldClassName', Game.TranslocatorClass.Name);
                        if (Index != INDEX_NONE)
                        {
                        if (WeaponsToReplace[Index].NewClassPath == "")
                        {
                        // replace with nothing
                        Game.TranslocatorClass = None;
                        }
                        else
                        {
                        Game.TranslocatorClass = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'));
                        }
                        }
                        }
                        }
                        }

                        function bool CheckReplacement(Actor Other)
                        {
                        local UTWeaponPickupFactory WeaponPickup;
                        local UTWeaponLocker Locker;
                        // local UTAmmoPickupFactory AmmoPickup, NewAmmo;
                        local int i, Index;
                        // local class<UTAmmoPickupFactory> NewAmmoClass;

                        WeaponPickup = UTWeaponPickupFactory(Other);
                        if (WeaponPickup != None)
                        {
                        if (WeaponPickup.WeaponPickupClass != None)
                        {
                        Index = WeaponsToReplace.Find('OldClassName', WeaponPickup.WeaponPickupClass.Name);
                        if (Index != INDEX_NONE)
                        {
                        if (WeaponsToReplace[Index].NewClassPath == "")
                        {
                        // replace with nothing
                        return false;
                        }
                        WeaponPickup.WeaponPickupClass = class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class'));
                        WeaponPickup.InitializePickup();
                        }
                        }
                        }
                        else
                        {
                        Locker = UTWeaponLocker(Other);
                        if (Locker != None)
                        {
                        for (i = 0; i < Locker.Weapons.length; i++)
                        {
                        if (Locker.Weapons[i].WeaponClass != None)
                        {
                        Index = WeaponsToReplace.Find('OldClassName', Locker.Weapons[i].WeaponClass.Name);
                        if (Index != INDEX_NONE)
                        {
                        if (WeaponsToReplace[Index].NewClassPath == "")
                        {
                        // replace with nothing
                        Locker.ReplaceWeapon(i, None);
                        }
                        else
                        {
                        Locker.ReplaceWeapon(i, class<UTWeapon>(DynamicLoadObject(WeaponsToReplace[Index].NewClassPath, class'Class')));
                        }
                        }
                        }
                        }
                        }
                        // else
                        // {
                        // AmmoPickup = UTAmmoPickupFactory(Other);
                        // if (AmmoPickup != None)
                        // {
                        // Index = AmmoToReplace.Find('OldClassName', AmmoPickup.Class.Name);
                        // if (Index != INDEX_NONE)
                        // {
                        // if (AmmoToReplace[Index].NewClassPath == "")
                        // {
                        // // replace with nothing
                        // return false;
                        // }
                        // NewAmmoClass = class<UTAmmoPickupFactory>(DynamicLoadObject(AmmoT oReplace[Index].NewClassPath, class'Class'));
                        // if (NewAmmoClass == None)
                        // {
                        // // replace with nothing
                        // return false;
                        // }
                        // else if (NewAmmoClass.default.bStatic || NewAmmoClass.default.bNoDelete)
                        // {
                        // // transform the current ammo into the desired class
                        // AmmoPickup.TransformAmmoType(NewAmmoClass);
                        // return true;
                        // }
                        // else
                        // {
                        // // spawn the new ammo, link it to the old, then disable the old one
                        // NewAmmo = AmmoPickup.Spawn(NewAmmoClass);
                        // NewAmmo.OriginalFactory = AmmoPickup;
                        // AmmoPickup.ReplacementFactory = NewAmmo;
                        // return false;
                        // }
                        // }
                        // }
                        // }
                        // }

                        // return true;
                        //}


                        defaultproperties
                        {
                        // Fill in the blanks
                        WeaponsToReplace(0)=(OldClassName="UTWeap_Enforcer ",NewClassPath="FirstMutator.UTWeap_Enforcer")
                        AmmoToReplace(0)=(OldClassName="UTAmmo_Enforcer",N ewClassPath="UTAmmo_Enforcer")

                        // WeaponsToReplace(1)=(OldClassName="UTWeap_BioRifle _Content",NewClassPath="")
                        // AmmoToReplace(1)=(OldClassName="UTAmmo_BioRifle_Co ntent",NewClassPath="")

                        //WeaponsToReplace(2)=(OldClassName="UTWeap_FlakCann on",NewClassPath="")
                        // AmmoToReplace(2)=(OldClassName="UTAmmo_FlakCannon" ,NewClassPath="")

                        // WeaponsToReplace(3)=(OldClassName="UTWeap_LinkGun" ,NewClassPath="")
                        // AmmoToReplace(3)=(OldClassName="UTAmmo_LinkGun",Ne wClassPath="")

                        // WeaponsToReplace(4)=(OldClassName="UTWeap_Redeemer _Content",NewClassPath="")

                        // WeaponsToReplace(5)=(OldClassName="UTWeap_RocketLa uncher",NewClassPath="")
                        // AmmoToReplace(5)=(OldClassName="UTAmmo_RocketLaunc her",NewClassPath="")

                        // WeaponsToReplace(6)=(OldClassName="UTWeap_ShockRif le",NewClassPath="")
                        // AmmoToReplace(6)=(OldClassName="UTAmmo_ShockRifle" ,NewClassPath="")

                        // WeaponsToReplace(7)=(OldClassName="UTWeap_SniperRi fle",NewClassPath="")
                        // AmmoToReplace(7)=(OldClassName="UTAmmo_SniperRifle ",NewClassPath="")

                        WeaponsToReplace(8)=(OldClassName="UTWeap_Stinger" ,NewClassPath="FirstMutator.UTWeap_Stoner")
                        AmmoToReplace(8)=(OldClassName="UTAmmo_Stinger",Ne wClassPath="UTAmmo_Stinger")

                        GroupNames(0)="Zippylabs"
                        Name="ZippyLabs"







                        DefaultProperties
                        {
                        }
                        Warning/Error Summary
                        ---------------------
                        C:\Program Files\Unreal Tournament 3\Development\Src\FirstMutator\Classes\FirstMutato r.uc(162) : Error, Unexpected end of file at end of Class

                        Failure - 1 error(s), 0 warning(s)
                        ----------------------------

                        I missed something, unsure what it is I missed.

                        Comment


                        • #13
                          I see several problems above, That's not going to be your only error... just use the origional post script and fill in your weapon class for each weapon instance in the default properties. or put back the original class name of the weapon you don't want to replace.
                          Errors are for instance.. to many
                          Code:
                          }
                          }
                          }
                          }
                          }
                          There is an open
                          {
                          Insert code
                          and a close
                          }

                          also.. instead of using // in front of every line just use /* then */ at the end

                          Don't forget you'll need a } on a previous line before default properties

                          go read some code elsewhere.

                          Comment


                          • #14
                            Originally posted by pingfreak View Post
                            I see several problems above, That's not going to be your only error... just use the origional post script and fill in your weapon class for each weapon instance in the default properties. or put back the original class name of the weapon you don't want to replace.
                            Errors are for instance.. to many
                            Code:
                            }
                            }
                            }
                            }
                            }
                            There is an open
                            {
                            Insert code
                            and a close
                            }

                            also.. instead of using // in front of every line just use /* then */ at the end

                            Don't forget you'll need a } on a previous line before default properties

                            go read some code elsewhere.
                            ah thank you, I'll get a mop and bucket an clean up ze drool. ^^

                            I can still use // now and then as a way to disable code or is it better to use /* */ ? and is there a proper name for them?

                            Comment


                            • #15
                              Use /* */. They nest so you don't have the problems like in e.g. Java or PHP where the first */ will end the comment and leave behind a mess.

                              Names: // is EOL comment, end-of-line comment or just line comment, /* */ is multi-line comment or block comment, /** */ is called a doc comment and behaves exactly like block comments in terms of nesting.

                              Originally posted by elmuerte View Post
                              ever heard of subclassing?
                              ...of of [code] tags? [quote] trashes indenting.

                              Comment

                              Working...
                              X