[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.

[DECORATE] Switching weapons if there's no ammo

Postby Molly Lightway » Sun Jan 03, 2021 3:52 pm

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.
Molly Lightway
 

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

Postby NaturalTvventy » Sun Jan 03, 2021 6:48 pm

I made this post! I guess I forgot to log in prior.
NaturalTvventy
 
Joined: 22 May 2010

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

Postby Player701 » Tue Jan 05, 2021 3:22 am

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 allExpand view
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
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Scripting

Who is online

Users browsing this forum: Player701 and 1 guest