A_JumpIfInventory
From ZDoom Wiki
A_JumpIfInventory (string inventorytype, int amount, int offset)
A_JumpIfInventory (string inventorytype, int amount, str state)
| Warning: Using state labels as arguments without quotation marks has been deprecated and will no longer work. Make sure to enclose all your string arguments with quotation marks to ensure full compatibility with future ZDoom versions. Refer to the available example(s) for proper usage |
Checks the amount of inventorytype items in the actor's inventory. If there are at least amount, the jump is performed. The offset parameter specifies how many frames ahead to jump.
Note that if amount is 0, the jump is only performed if the actor is carrying the maximum number of that item. This is useful for checking whether the player has the maximum amount of ammo for a particular weapon, regardless of whether or not he's found a backpack.
If this function is placed on a weapon, it will check the player's inventory. It can also be used on monsters which are carrying inventory items.
Examples
Here's a shotgun with a Counterstrike (or whatever the hell you want to call it)-style reloading system.
ACTOR DukeShotgun : Weapon 22009 //The shotgun from Duke Nukem 3D. The newly added
{ reloading state is mostly finished. Although this
Weapon.AmmoType "InsertedShell" state is effective, it also continues if there are no
Weapon.AmmoType2 "Shell" shells in your inventory. It'll be fixed.
Weapon.AmmoGive 0
Weapon.AmmoGive2 30
Weapon.AmmoUse 1
Scale 0.625
Inventory.PickupSound "misc/w_pkup"
Inventory.PickupMessage "Shotgun!"
ATTACKSOUND "duke/shotgun"
OBITUARY "%o got punctured with Duke's Shotgun."
states
{
Spawn:
SHG3 A 1
Loop
Ready:
SHT3 A 1 A_WeaponReady
Loop
DeSelect:
SHT3 A 1 A_Lower
Loop
Select:
SHT3 A 1 A_Raise
Loop
Fire:
SHT3 A 2 A_Gunflash
SHT3 F 2 A_FireBullets(2,1,8,4)
SHT3 KFABCD 3
SHT3 E 5 A_FireCustomMissile("ShotgunShell",90,0)
SHT3 DCB 4
SHT3 A 6 A_JumpIfNoAmmo(2)
SHT3 A 0 A_Refire
Goto Ready
SHT3 GH 3 //This creates a reloading state which
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,39) replaces any used shells with new
SHT3 I 3 A_TakeInventory("Shell",1) ones. For example: if you have 4 out
SHT3 J 0 A_PlaySound("weapons/sshotl") of 10 shells, this will give you 6,
SHT3 J 3 A_GiveInventory("InsertedShell",1) not 10.
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,35)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,31)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,27)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,23)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,19)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,15)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,11)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,7)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,3)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 HG 4
Goto Ready
Flash:
SH3F AB 2 BRIGHT
Stop
AltFire: //The reloading state, but can be done manually.
SHT3 GH 3
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,39)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,35)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,31)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,27)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,23)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,19)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,15)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,11)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,7)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 J 0 A_JumpIfInventory("InsertedShell",10,3)
SHT3 I 3 A_TakeInventory("Shell",1)
SHT3 J 0 A_PlaySound("weapons/sshotl")
SHT3 J 3 A_GiveInventory("InsertedShell",1)
SHT3 HG 3
Goto Ready
}
}

