Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
So, I'm making this player class that loses a bunch of random weapons when he enters a new map.
To do this, I'm making multiple actor, one for each weapon, that actually take the weapon from you.
Actor SSGtaker : CustomInventory
{
Inventory.PickupMessage "\cGWho said that break action \cFSAWED OFF \cGSHOTGUNS never break? I think someone said that. Well he was wrong. Especially when it gets crushed by demons."
States
{
Spawn:
TNT1 A 0
TNT1 A 1
Loop
Pickup:
TNT1 A 0
TNT1 A 0 A_TakeInventory("SSG",1)
TNT1 A 0 A_TakeInventory("SSGAmmo",2)
TNT1 A 0 A_GiveInventory("AmmoShell",2)
Stop
}
}
And everything works like a charm, but I don't quite like it. This way I should spawn the items right under the player's feet, and make him pick them up. Furthermore, the message will show whether the player has the weapon or not.
So I tried this:
Actor Shotguntaker : CustomInventory
{
+INVENTORY.QUIET
States
{
Spawn:
TNT1 A 0
TNT1 A 1
TNT1 A 1 A_JumpIfInventory("Shot_Gun",1,"Loss")
Loop
Loss:
TNT1 A 0
TNT1 A 0 A_Log("\cGYour trusted \cFSHOTGUN \cGfailed you. With it malfunctioning, You'll have to find another one...")
TNT1 A 0 A_TakeInventory("Shot_Gun",1)
TNT1 A 0 A_TakeInventory("SlugShotgun",1)
TNT1 A 0 A_TakeInventory("ShotgunAmmo",9)
Stop
}
}
But it seems like the jump is not performed even If I have the shotgun in inventory. What did I do wrong?
Actor Shotguntaker : CustomInventory
{
+INVENTORY.QUIET
States
{
Spawn:
TNT1 A 0
TNT1 A 1
Loop
Pickup:
TNT1 A 1 A_JumpIfInventory("Shot_Gun",1,"Loss")
Stop //no message
Loss:
TNT1 A 0
TNT1 A 0 A_Log("\cGYour trusted \cFSHOTGUN \cGfailed you. With it malfunctioning, You'll have to find another one...")
TNT1 A 0 A_TakeInventory("Shot_Gun",1)
TNT1 A 0 A_TakeInventory("SlugShotgun",1)
TNT1 A 0 A_TakeInventory("ShotgunAmmo",9)
Stop
}
}
I know, it's pretty basic, but I'm still learning, and form me it's still a good surprise when things go as planned XD
Should be noted that the Pickup state runs even if the actor is given the item via [wiki]A_GiveInventory[/wiki] or similar direct inventory manipulation functions. So, there's no need to spawn the item under the player's feet - which should generally be avoided with this kind of thing, anyway, as items on the map can only be picked up by player movement.
I'm using Spawn Item because the actor that takes the weapons away is actually a random spawner that picks between 16 spawn states that removes various combinations of weapons and ammo. I don't think that using A_GiveInventory to give the spawner to the player would work. Or would it?