Hi everyone, I'm wondering if there's a way in DECORATE to have a custom weapon which does its normal shot if the alt fire button if pressed but the ammo for the alt fire is zero.
What I can think of is performing some sort of check, but I don't think there's IF statements in DECORATE....
AltFire:
if "AltAmmoCount" > 0:
MARG B 0 A_FireCustomMissile("AltMissile")
else:
goto Fire
Is this doable, with something like my method or any other method?
EDIT: I see that A_JumpIf is what I'm after. Now I just need to figure out how to get an ammo count for the expression.
[DECORATE] Weapon alt fire is normal fire if no ammo for alt
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!)
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!)
-
NaturalTvventy
- Posts: 92
- Joined: Sat May 22, 2010 9:38 am
- Player701
-

- Posts: 1710
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: [DECORATE] Weapon alt fire is normal fire if no ammo for
You could use A_JumpIfInventory, but what you're attempting will not work properly in DECORATE without gross hacks. This is because when you press any of the fire buttons, the engine checks if the weapon has enough ammo for the corresponding fire mode (normal/alt), and if it doesn't, the weapon will not jump to its Fire/AltFire state but will get deselected instead.
The one way to avoid this problem without using advanced features is to set +WEAPON.AMMO_OPTIONAL / +WEAPON.ALT_AMMO_OPTIONAL to bypass ammo checks on the engine side. You will then have to manually check that you have enough ammo before firing, this can also be done via A_JumpIfInventory. However, you will lose the auto-switching functionality (though you could also try to hack it in via A_JumpIfInventory and A_SelectWeapon), and it will also be possible to switch to your weapon even when you don't have enough ammo for it, regardless of the gameplay options. Unfortunately, there is no way to mitigate the latter issue in DECORATE.
The one way to avoid this problem without using advanced features is to set +WEAPON.AMMO_OPTIONAL / +WEAPON.ALT_AMMO_OPTIONAL to bypass ammo checks on the engine side. You will then have to manually check that you have enough ammo before firing, this can also be done via A_JumpIfInventory. However, you will lose the auto-switching functionality (though you could also try to hack it in via A_JumpIfInventory and A_SelectWeapon), and it will also be possible to switch to your weapon even when you don't have enough ammo for it, regardless of the gameplay options. Unfortunately, there is no way to mitigate the latter issue in DECORATE.
Code: Select all
AltFire:
MARG A 0 A_JumpIfInventory("YourAmmoType", 1, "RealAltFire") // <-- Replace YourAmmoType with the actual name of your ammo type class
Goto Fire
RealAltFire:
// TODO: Your alt fire code here
Goto Ready- Dan_The_Noob
- Posts: 880
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: [DECORATE] Weapon alt fire is normal fire if no ammo for
can you describe the wepaon to us so maybe we can offer an alternative route altogether? as Player701 said, it's kind of messy because of limitations/restrictions in the engine itself.
-
NaturalTvventy
- Posts: 92
- Joined: Sat May 22, 2010 9:38 am
Re: [DECORATE] Weapon alt fire is normal fire if no ammo for
Thanks for getting me pointed in the right direction! I believe I have it working. Here's relevant code:
Code: Select all
Weapon.AmmoUse1 0 //remove ammo later with A_TakeInventory
Weapon.AmmoUse2 0 //remove ammo later with A_TakeInventory
Weapon.AmmoType1 "DemonBlood"
Weapon.AmmoType2 "HectePlasma"
+AMMO_OPTIONAL //not needed since AmmoUse = 0?
+ALT_AMMO_OPTIONAL //not needed since AmmoUse = 0?
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 NoAmmo //no ammo
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 NoAmmo //no ammo
RealFire:
MARG B 0 A_FireCustomMissile("MancubusShot")
TNT1 A 8 A_GunFlash
MARG B 10
Goto Ready
RealAltFire:
MARG B 0 A_FireCustomMissile("HectebusShot")
TNT1 A 8 A_GunFlash
MARG B 10
Goto Ready
NoAmmo:
Goto Ready //will update with weapon switching
Flash:
MARG A 0 A_JumpIfInventory("DemonBlood", 1, "RealFlash") //check for regular ammo
MARG A 0 A_JumpIfInventory("HectePlasma", 1, "RealAltFlash") //check for alt ammo
AltFlash:
MARG A 0 A_JumpIfInventory("HectePlasma", 1, "RealAltFlash") //check for alt ammo
MARG A 0 A_JumpIfInventory("DemonBlood", 1, "RealFlash") //check for regular ammo
RealFlash:
MARF A 0 A_TakeInventory ("DemonBlood", 1) //remove 1 ammo
MARF A 3 Bright A_Light1
MARF B 5 Bright A_Light2
Goto LightDone
RealAltFlash:
GRNA A 0 A_TakeInventory ("HectePlasma", 1) //remove 1 ammo
GRNA A 3 Bright A_Light1
GRNA B 5 Bright A_Light2
Goto LightDone- Player701
-

- Posts: 1710
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: [DECORATE] Weapon alt fire is normal fire if no ammo for
Indeed, I believe you do not need to set AmmoUse to 0 if you have AMMO_OPTIONAL. You can then also get rid of A_TakeInventory. By itself, AMMO_OPTIONAL does not prevent ammo from being deducted automatically (if you have any).NaturalTvventy wrote:Code: Select all
//not needed since AmmoUse = 0?