[DECORATE] Switching weapons if there's no ammo

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
Guest

[DECORATE] Switching weapons if there's no ammo

Post by Guest »

I've successfully updated the Mancubus Arm from Realm667 so that it has an alt fire. I've also written code so that if there's not enough for one type of fire the other type of fire is checked as well. All that is missing is the the weapon switching to another weapon when no ammo is available. Currently I simply use Goto Ready when this condition is met.

Relevant code:

Fire:
MARG A 0 A_JumpIfInventory("DemonBlood", 1, "RealFire") //check for regular ammo
MARG A 0 A_JumpIfInventory("HectePlasma", 1, "RealAltFire") //check for alt ammo
Goto Ready
AltFire:
MARG A 0 A_JumpIfInventory("HectePlasma", 1, "RealAltFire") //check for alt ammo
MARG A 0 A_JumpIfInventory("DemonBlood", 1, "RealFire") //check for regular ammo
Goto Ready

Note that I'm after ZDoom (not GZDoom) compatibility. You can download the weapon wad here:

https://drive.google.com/file/d/1c4Q1BY ... sp=sharing

I've tried playing with A_SelectWeapon but I haven't had much success. I'll admit that there's a lot about DECORATE I don't understand.
NaturalTvventy
Posts: 92
Joined: Sat May 22, 2010 9:38 am

Re: [DECORATE] Switching weapons if there's no ammo

Post by NaturalTvventy »

I made this post! I guess I forgot to log in prior.
User avatar
Player701
 
 
Posts: 1707
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: [DECORATE] Switching weapons if there's no ammo

Post by Player701 »

Molly Lightway wrote:Note that I'm after ZDoom (not GZDoom) compatibility.
Please note that the last version of ZDoom was released in 2016. GZDoom can do everything ZDoom can and more, and it still has the software renderer. If you're having problems running GZDoom on your machine, you could make a thread in the technical issues subforum. You could also try LZDoom instead, which has most of the features available in the latest GZDoom release but should work better than GZDoom if the latter doesn't work properly (or at all) for you.

Regarding your DECORATE issue in question, you could try calling A_SelectWeapon("None", SWF_SELECTPRIORITY) before jumping to the Ready state, e.g.:

Code: Select all

Fire:
    MARG A 0 A_JumpIfInventory("DemonBlood", 1, "RealFire") //check for regular ammo
    MARG A 0 A_JumpIfInventory("HectePlasma", 1, "RealAltFire") //check for alt ammo
    TNT1 A 0 A_SelectWeapon("None", SWF_SELECTPRIORITY)
    Goto Ready
This should take care of the case when the player attempts to fire the weapon with no ammo. However, since you've set AmmoUse to 0, it will still be possible to select the weapon again when the player does not have any ammo for it. This cannot be solved in DECORATE.

I also wanted to say you look at this thread where a similar issue was discussed, but it turned out that it was you who started it. Okay, then. :P
Post Reply

Return to “Scripting”