Is this doable in decorate? (removing from player inventory)

Sun Oct 31, 2021 4:18 pm

Is there a way to, in a monster's code, remove an item from the player's inventory (the player that's activating them) before giving them that item? I'm somewhat new to decorate and don't know the first thing about scripting.

I have a friendly marine monster that is a SwitchableDecoration type actor. They spawn with a certain amount of ammo and a certain number of magazines. When they run out of magazines they go into a NoAmmo state that displays a floating message (out of ammunition) and then immediately goes to See.

What I'm trying to do is to be able to give them the type of ammo they need from the player's inventory with the "use" button. Currently the "use" button inactivates them (makes them go into holding/inactive state, where they can shoot but not move), and can switch back if you press again. If I do something like this:
Code:
           Active:
                TNT1 A 0
                TNT1 A 0 A_JumpIfInventory("Magazine",1,1)
                Goto Resupply
                (rest of the code)

It should work right? When pressing "use" it should take precedence over the rest and jump them into Resupply state instead of reactivating it? The Resupply state is currently like this:
Code:
           Resupply:
           TNT1 A 0
           TNT1 A 0 A_JumpIfInventory("Magazine",1,"See",AAPTR_MASTER)
           TNT1 A 0 A_TakeInventory("Magazine",1,0,AAPTR_MASTER)
           TNT1 A 0 A_GiveInventory("Magazine",1)
           Goto See

But it doesn't work. These actor pointers are stumping me. Since I'm the one who summoned it, shouldn't I be its master? Everything else works except this.

EDIT: Just had another idea. What if I made a weapon in slot0 that when shot gave the target monster one magazine, and use one magazine as ammo? It's probably not doable in the weapon itself, but I could give it a special damagetype (say, Damagetype ammoreplenisher) and then make a Pain.ammoreplenisher state for the monster, givem him 256 chance of pain, and give him the item whenever he goes into that state. Think it could work? It's hacky but I don't know how else to do this.

Re: Is this doable in decorate? (removing from player invent

Mon Nov 01, 2021 7:41 pm

Could you post the entire code of the marine, as well as the code that spawns it.

Re: Is this doable in decorate? (removing from player invent

Tue Nov 02, 2021 7:46 am

Just realized that I messed up badly in that second state there. It's telling it to jump to See if the master has at least one mag, instead of jumping the Goto
Should have been:
Code:
     Resupply:
           TNT1 A 0 A_JumpIfInventory("Magazine",1,1,AAPTR_MASTER)
           Goto See
           TNT1 A 0 A_TakeInventory("Magazine",1,0,AAPTR_MASTER)
           TNT1 A 0 A_GiveInventory("Magazine",1)

That's probably why it wasn't working.
And sorry but I don't think I can post the whole code, it's very long and only partly mine. I used BrutalFriends as a basis, and I didn't mess with any of the pathfinding stuff.