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

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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!)
Post Reply
User avatar
::Bloodfury::
Posts: 332
Joined: Mon Aug 01, 2011 7:39 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

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

Post 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. :)
Gez
 
 
Posts: 17938
Joined: Fri Jul 06, 2007 3:22 pm

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

Post 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.
User avatar
::Bloodfury::
Posts: 332
Joined: Mon Aug 01, 2011 7:39 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

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

Post 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() ?
Gez
 
 
Posts: 17938
Joined: Fri Jul 06, 2007 3:22 pm

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

Post 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.
User avatar
::Bloodfury::
Posts: 332
Joined: Mon Aug 01, 2011 7:39 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

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

Post by ::Bloodfury:: »

I see. I shall look into that. Thank you. :)
Post Reply

Return to “Scripting”