Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: Weapon replacement mutator 4 U 2 use

  1. #1
    pingfreak
    Guest

    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. #2
    ~{MFD}~Mordred
    Guest
    Dude THANK YOU!! No one has replied but I will Thanks!

  3. #3
    gämmö
    Guest
    Thanks, kool info.

  4. #4
    ~{MFD}~Mordred
    Guest
    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.

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

  6. #6
    THE_SPELUNKER
    Guest
    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.

  7. #7
    ZippyDSMlee
    Guest
    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

  8. #8
    pingfreak
    Guest
    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.

  9. #9
    THE_SPELUNKER
    Guest
    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.

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •