A_JumpIfInventory
A_JumpIfInventory (string "inventorytype", int amount, int offset)
A_JumpIfInventory (string "inventorytype", int amount, str "state")
A_JumpIfInventory (string "inventorytype", int amount, int offset[, int owner]) (development version r3222+ only)
A_JumpIfInventory (string "inventorytype", int amount, str "state"[, int owner]) (development version r3222+ only)
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.
If amount is greater than the maximum amount, the jump will be performed.
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 one of the actor pointers is specified, it will check their inventory instead of the calling actor's own. By default, AAPTR_DEFAULT refers to itself and is used when left unspecified or blank. (development version r3222+ only)
Examples
Shotgun reload
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
}
}
Armor Addon
This is an armor shard that is supposed to increase your armor if you are wearing one. But it does not work: if you pick a GreenArmor, then try to pick this item up, you will not succeed. The GreenArmor set the maximum amount for BasicArmor to 100, so the first jump is executed despite falling 50 points short of the 150 value requested.
ACTOR ArmorShard : CustomInventory { States { Spawn: BON2 A -1 Stop Pickup: TNT1 A 0 A_JumpIfInventory("BasicArmor", 150, "NoNeed") TNT1 A 0 A_JumpIfInventory("BasicArmor", 1, "CanAdd") NoNeed: TNT1 A 0 Stop CanAdd: TNT1 A 0 A_GiveInventory("ArmorBonus") Stop } }
And here is the fixed version: it involves using a workaround by putting the maximum of 150 in a variant armor bonus.
ACTOR ShardBonus : ArmorBonus { -INVENTORY.ALWAYSPICKUP Armor.MaxSaveAmount 150 } ACTOR ArmorShard : CustomInventory { States { Spawn: BON2 A -1 Stop Pickup: TNT1 A 0 A_JumpIfInventory("BasicArmor", 1, "CanAdd") Stop CanAdd: TNT1 A 0 A_GiveInventory("ShardBonus") Stop } }
A test for at least 80 rockets would likewise have to find a similar workaround, probably by checking first for the presence of a Backpack. This is not a fool-proof solution, however, as the maximum ammo capacity can be modified with ACS or by picking up another type of BackpackItem.