AmmoType2 does not increment, unless picking up another copy of the weapon associated with it.
Picking up "MyNewAmmo" increments nothing.
Picking up a backpack increments only AmmoType1, not AmmoType2.
The FULL code below, for debug purposes, try it yourself.
To test, load the code then do "summon mynewgun" and "summon mynewammo" and "summon backpack"
Remember that full screen shows the secondary ammo type in the bottom right corner (if you decide to help) as a way to see how much secondary ammo you have
Code: Select all
version "4.8.0"
// MyBaseWeapon is never used directly
class MyBaseWeapon : Weapon
{
Default
{
Weapon.AmmoType1 "Clip";
Weapon.AmmoType2 ""; // we set this in beginplay()
Weapon.AmmoGive1 1;
Weapon.AmmoGive2 1;
Weapon.AmmoUse1 0;
Weapon.AmmoUse2 0;
Weapon.SlotNumber 2;
}
States
{
// just default pistol states for testing purposes, nothing special here
Ready:
PISG A 1 A_WeaponReady;
Loop;
Deselect:
PISG A 1 A_Lower;
Loop;
Select:
PISG A 1 A_Raise;
Loop;
Fire:
PISG A 4;
PISG B 6 A_FirePistol;
PISG C 4;
PISG B 5 A_ReFire;
Goto Ready;
Flash:
PISF A 7 Bright A_Light1;
Goto LightDone;
PISF A 7 Bright A_Light1;
Goto LightDone;
Spawn:
PIST A -1;
Stop;
}
override void BeginPlay()
{
Super.BeginPlay();
// The new gun and new ammo are named similarly "MyNewGun" and "MyNewAmmo"
// Allowing us to easily get the associated ammo, by stripping off the word "Gun" and inserting "Ammo"
String className = GetClassName();
className = className.Left(className.Length() - 3);
AmmoType2 = className.."Ammo";
}
}
Class MyNewGun : MyBaseWeapon
{
Default
{
Inventory.PickupMessage "picked up MyNewGun";
}
// This is just to show that when you summon it in console, the ammotypes are properly set
override void BeginPlay()
{
Super.BeginPlay();
console.printf(GetClassName().." ammo1type is "..AmmoType1.GetClassName());
console.printf(GetClassName().." ammo2type is "..AmmoType2.GetClassName());
}
}
// MyBaseAmmo is never used directly
Class MyBaseAmmo : Ammo
{
Default
{
Inventory.Amount 1;
Inventory.MaxAmount 999;
Inventory.InterHubAmount 999;
Ammo.BackpackAmount 1;
Ammo.BackpackMaxAmount 999;
}
States
{
Spawn:
CELL A -1;
Stop;
}
}
Class MyNewAmmo : MyBaseAmmo
{
Default
{
Inventory.PickupMessage "picked up MyNewAmmo";
}
}