• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Weapon Mutator Problem

Witzig

Grizzled Veteran
Jan 16, 2006
2,189
52
Germany
Well i just started my first Mutator, and got it working in itself just fine, but now the Mutator has one Problem, when the Mutator is active you can no longer switch Weapons. Even if the changed Weapon is dropped it is not possible.

Code:
class MutWitzigsWeapon extends Mutator;

//=============================================================================

function BeginPlay()
{
     local RORoleInfo RORole;
     local int j;
     super.BeginPlay();

    foreach AllActors(class'RORoleInfo',RORole)
       {
            if(RORole != None)
            {
                 for(j = 0;j < 3; j++)
                {
                        if(RORole.PrimaryWeapons[j].Item == class'ROInventory.PPD40Weapon')
                          RORole.PrimaryWeapons[j].Item = class'MutWitzigsWeapon.PPD40WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.G43Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.G43WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.G43ScopedWeapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.G43WScopedWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.DP28Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.DP28WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.Kar98ScopedWeapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.Kar98WScopedWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.MN9130ScopedWeapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.MN9130WScopedWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.MP40Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.MP40WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.MP41Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.MP41WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.PPS43Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.PPS43WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.PPSH41Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.PPSH41WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.STG44Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.STG44WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.SVT40Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.SVT40WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.SVT40ScopedWeapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.SVT40WScopedWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.MG34Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.MG34WWeapon';

                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.MG42Weapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.MG42WWeapon';
                                                
                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.SatchelCharge10lb10sWeapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.SatchelCharge10lb10sWWeapon';
                        
                        if(RORole.PrimaryWeapons[j].Item==class'ROInventory.PanzerFaustWeapon')
                          RORole.PrimaryWeapons[j].Item=class'MutWitzigsWeapon.PanzerFaustWWeapon';
                }
             
             }   

        }
    }
    
defaultproperties
    {
    GroupName="Weapon Mut"
         FriendlyName="WeaponMut"
         Description="blah blah"
}

All Changes to the Weapon were just some changes to the Fire Modes. Does anyone have a Clue why the Weapons would no longer switch ?

In an earlier Version i made the Error that dropped Version would be the Standard RO Weapons, after the modded Weapon was dropped Weapon switching worked again.

Or if someone could point me to the Class controlling Weapon switching i might find the Error myself.
 
MG34WWeapon
Code:
class MG34WWeapon extends MG34Weapon;

#exec OBJ LOAD FILE=..\Animations\Axis_Mg34_1st.ukx

defaultproperties
{
    FireModeClass(0)=MG34WAutoFire
    FireModeClass(1)=MG34WSemiAutoFire
    
    //** Inventory/Ammo **//
    PickupClass=class'MG34WPickup'
}

MG34WPickup
Code:
class MG34WPickup extends MG34Pickup
   notplaceable;
   
   defaultproperties
{
    InventoryType=class'MG34WWeapon'
    }

MG34WAutoFire
Code:
defaultproperties
{
    //** Projectile Firing Modded **//
    Spread = 75
    
    //** Recoil **//
    maxVerticalRecoilAngle=650
    maxHorizontalRecoilAngle=450
    
    //** View shake **//
    ShakeOffsetTime=1.0
    ShakeRotTime=0.5
    
    //** Recoil modifiers **//
    RecoilRate=0.04
    PctHipMGPenalty=1.1

}

MG34WSemiAutoFire
Code:
defaultproperties
{
    //** Projectile Firing Modded **//
    Spread = 75
    
    //** Recoil **//
    maxVerticalRecoilAngle=350
      maxHorizontalRecoilAngle=250
    
    //** View shake **//
    ShakeOffsetTime=1.0
    ShakeRotTime=0.5
    
    //** Recoil modifiers **//
    RecoilRate=0.06
    PctHipMGPenalty=1.3

}
I know there is a different Way to replace the Weapons, though i haven't tested this online, worked in Practice Mode.

Its like this:

Code:
function string GetInventoryClassOverride(string InventoryClassName)
{
             
    if(InventoryClassName=="ROInventory.MG34Weapon")
        return "MutWitzigsWeapon.MG34WWeapon";

all other Weapons....
}
 
Upvote 0