Page 1 of 1

Weapons that cannot be picked up if one already in possession?

Posted: Sat Oct 19, 2024 5:59 am
by ::Bloodfury::
Hello.

This is probably quite simple to do. But I just don't know where to start.

I have this idea that player could use various items for melee. Wrenches, crowbars, pipes etc.
Now the idea is that the player may have only one melee weapon at a time. And would need to drop
the current one in order to switch to another.

Is there something in states or action functions that would prevent a weapon pickup when some defined
variable is true?

With inventory items this can be done. But how would one approach this with weapons?

Thx in advance. :)

Re: Weapons that cannot be picked up if one already in possession?

Posted: Sat Oct 19, 2024 8:00 am
by Gez
With DECORATE, you'd use a CustomInventory so as to run the checks you want and fail so that it doesn't pick up.


With ZScript, you can do that in a weapon, or in any other type of inventory item, by overriding TryPickup() and doing your checks in there.

Re: Weapons that cannot be picked up if one already in possession?

Posted: Sat Oct 19, 2024 4:52 pm
by ::Bloodfury::
Thank you. I shall try this. :)
What function to override for dropping the item? as when you drop the item I need to set the variable so that
the dropped weapon or another melee weapon could be picked up?

DetachFromOwner() ?

Re: Weapons that cannot be picked up if one already in possession?

Posted: Sun Oct 20, 2024 7:11 am
by Gez
For dropping weapons, the main issue is how do you drop weapons? I suppose you could implement a "drop" key with a keypress event listener, find whichever is the player's current weapon, and then use the same logic as the drop command to drop it. That'd also allow the player to manually use the console command for that. This way would not require doing anything special on the weapons themselves.

Re: Weapons that cannot be picked up if one already in possession?

Posted: Thu Oct 24, 2024 3:18 pm
by ::Bloodfury::
I see. I shall look into that. Thank you. :)