• 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 Secondary Ammo Type

StuKKa

Grizzled Veteran
Mar 20, 2010
65
10
Hi Guys,
i want to create a gun with a secondary ammo type, but I'm not sure if it is possible to do. I'm not talking about a gun with to firemodes, I mean a gun with to types of projectiles. Could someone please help me to get this done?
 
Or if you don't want seperate ammo counts you could do it like WTFMut does with the Boomstick (Switches from regular rounds to slugs and back). The ammo is switched when you reload with a full clip.

WeaponBoomStick:

Code:
function bool AllowReload()
{
    local KFPlayerReplicationInfo KFPRI;
    local WTFEquipBoomStickAltFire FM0;
    local WTFEquipBoomStickFire FM1;
    
    if (super(KFWeapon).AllowReload())
    {
        SetPendingReload();
        return true;
    }
    else if (!bIsReloading && (MagAmmoRemaining >= MagCapacity) && !IsFiring())
    {
        KFPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
        if (KFPRI == none || KFPRI.ClientVeteranSkill != Class'WTFPerksSupportSpec')
            return false;
            
        FM0 = WTFEquipBoomStickAltFire(FireMode[0]);
        FM1 = WTFEquipBoomStickFire(FireMode[1]);
        
        if ( FM0.GetShellType() == 1 )
        {
            PlayerController(Instigator.Controller).ReceiveLocalizedMessage(class'WTF.WTFEquipBoomstickSwitchMessage',0); //loading slugs
            FM0.SetShellType(0);
            FM1.SetShellType(0);
        }
        else
        {
            PlayerController(Instigator.Controller).ReceiveLocalizedMessage(class'WTF.WTFEquipBoomstickSwitchMessage',1); //loading shot
            FM0.SetShellType(1);
            FM1.SetShellType(1);
        }
        SetPendingReload();
        return true;
    }
    return false;
}
BoomStickFire

Code:
function SetShellType(int type)
{
    ShellType = type;
    if (ShellType == 0) //slugs
    {
        ProjPerFire=1;
        ProjectileClass=Class'WTF.WTFEquipBoomStickSlug';
        Weapon.ItemName=Weapon.default.ItemName $ "(Slugs)";
    }
    else
    {
        ProjPerFire=24;
        ProjectileClass=Class'WTF.WTFEquipBoomStickPellet';
        Weapon.ItemName=Weapon.default.ItemName $ "(Shot)";
    }
}

function int GetShellType()
{
    return ShellType;
}
BoomStickAltFire

Code:
function SetShellType(int type)
{
    ShellType = type;
    if (ShellType == 0) //slugs
    {
        ProjPerFire=1;
        ProjectileClass=Class'WTF.WTFEquipBoomStickSlug';
        Weapon.ItemName=Weapon.default.ItemName $ "(Slugs)";
    }
    else
    {
        ProjPerFire=12;
        ProjectileClass=Class'WTF.WTFEquipBoomStickPellet';
        Weapon.ItemName=Weapon.default.ItemName $ "(Shot)";
    }
}

function int GetShellType()
{
    return ShellType;
}
 
Upvote 0