Weapon "condition"s

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Jimmy
 
 
Posts: 4726
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Weapon "condition"s

Post by Jimmy »

For one of my mods I have a system in which weapons degrade over time until they become less and less reliable and eventually cannot be used or sold. I also want the player to be able to drop these weapons (with a script calling UseInventory to use an item which drops said weapon) if they become unusable.

But then a problem arises. How do I keep the weapon in its unusable state if/when it's picked backed up (perhaps by another player)? I have a set of inventory items which track how many times the player has fired each weapon, and if the player has a certain amount of the corresponding "WeaponShots" item the weapon degrades to the next stage of disuse (which are Mint, Excellent, Good, Fine, Poor, and Valueless). When the player picks up a "Mint" new weapon of the same type the number of these items returns to zero, but I have yet to find a way of making this number of items return to what it was before the weapon was dropped. :?

I figured I might be able to do something involving [wiki]A_SetUserVar[/wiki] and/or [wiki]GetUserVariable[/wiki], but this project is for Skulltag which IIRC doesn't have these functions yet. :(

If worse comes to worst I should probably just change the system to make the dropping script drop a dummy weapon that can't be picked up and fades away after a while - if the player WANTS to drop one of his weapons why allow him to pick it up again? (Although since this mod is to be as multiplayer-compatible as I can make it, I would like some way of allowing players to exchange weaponry, though it won't be a crucial asset to the mod's online gameplay.)
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Weapon "condition"s

Post by NeuralStunner »

How do User Vars work when used in weapon definitions? (IIRC it just references the "owning" Player. :| )

I think weapons can have an Ammo value... You could set one of each weapon's ammo type to indicate its quality/durability. However, I'm not certain how to spawn a weapon with a specific ammo amount, or even if you can...

Another idea: Give each Player all the weapons they can use to start with, but no ammo for the ones they shouldn't have yet. Each weapon would have a unique required ammo type to represent its quality. Then, instead of weapon pickups, use CustomInventory pickups - You could use its Args[0] to indicate its current quality value. Thanks to Decorate Expressions, that would be usable directly in codepointers. First, check to make sure the player already has 0 of that ammo before collecting the new "weapon".

Also use INVENTORY.UNDROPPABLE on the weapons, and add a new command/keybind to remove the ammo after dropping the CustomInventory (with Args[0] set correctly) instead.

Another advantage to this method: by giving WEAPON.CHEATNOTWEAPON to each, you can limit the ones certain classes can use! Just check for the weapon in its corrosponding CustomInventory.

Hopefully I explained that clearly enough. :)
User avatar
Jimmy
 
 
Posts: 4726
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Re: Weapon "condition"s

Post by Jimmy »

That might just work, although I'm a bit dubious about using ammo, since of my some weapons have altfires and therefore need a second ammo type defined. Would you care to throw together a quick example of how I'd set that up, please?
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Weapon "condition"s

Post by NeuralStunner »

Actually you could technically use any regular Inventory, you can do manual checks in the weapon's code.

Example? Whew, okay...
Spoiler:
User avatar
Jimmy
 
 
Posts: 4726
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Re: Weapon "condition"s

Post by Jimmy »

I'll give that a go. Cheers! :D Looks simple enough. :P
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Weapon "condition"s

Post by NeuralStunner »

jimmy91 wrote:Looks simple enough. :P
"It all made sense, like a mermaid on a bicycle." :P

Heh, my ACS probably sucks. I'm not just rusty, I've just hardly done a thing with it.

Oh, and yet another advantage to the Args[0] method: It's simple as heck to put "pre-damaged" weapons on a Hexen/UDMF map. :)
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Weapon "condition"s

Post by Nash »

Well I was messing around with user variables to create a similar system (and no, I'm not copying from you; I've been wanting to do such a thing ever since I played Fallout 3, which was quite a while ago :)) and I have a feeling that the user variable system in ZDoom just isn't working as expected when used from a weapon which is in the player's inventory.

Either that, or I'm doing something wrong.

The following example is supposed to increment the user variable user_weaponcondition everytime the Custom Shotgun is fired.

1) Assuming that calling ACS_Execute from the shotgun should make it the activator, it should properly print the user variable. But it keeps saying 0.

2) Calling [wiki]A_LogInt[/wiki] reveals 65536... huh?

3) I've set it up to jump to a "WeaponBroken" state after 2 shots. It's not making the jump regardless of the amount of shots.

Any ideas?

[EDIT: Fixed a sentence to make it less offensive]
Attachments
weaponconditions.zip
(1.31 KiB) Downloaded 63 times
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Weapon "condition"s

Post by Gez »

Nash wrote:2) Calling [wiki]A_LogInt[/wiki] reveals 65536... huh?
It does seem a reasonable value. 65536 is how 1.0 is encoded in [wiki=Data_types#Fixed_point]fixed point[/wiki] format.
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Weapon "condition"s

Post by Nash »

It still doesn't change the fact that this isn't really working (it's supposed to make a jump after 2 shots, yet it's not jumping)
Locked

Return to “Editing (Archive)”