Tertiary ammo type?

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!)
XASSASSINX
Posts: 379
Joined: Tue Dec 20, 2016 4:53 pm
Location: MURICAA BROTHER! Just kidding, Brazil.

Tertiary ammo type?

Post by XASSASSINX »

I'm trying to make a weapon that uses as primary ammo Clips, as secundary it shoots rockets. BUT i wanna ALSO that when shooting the rockets, it uses 10 cells to do that too. So how would i do that? A_JumpIfInventory didn't work for me. Here's the code:

Code: Select all

	AltFire:
		TNT1 A 0 A_JumpIfInventory("Cell", 0, "NoAmmo")
		TNT1 A 0 A_TakeInventory("Cell", 10)
		HCGG A 3 A_PlaySound("terminator/hmissile")
		TNT1 A 0 A_FireCustomMissile("PlayerHomingMissile")
		HCCT AB 4 BRIGHT
		Goto Ready
(The weapon just go to the "No Ammo" state everytime, but i don't have 0 cells)
User avatar
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

Re: Tertiary ammo type?

Post by Ichor »

Code: Select all

   AltFire:
      TNT1 A 0 A_JumpIfInventory("Cell", 1, 1)
      Goto NoAmmo
      TNT1 A 0 A_TakeInventory("Cell", 10)
      HCGG A 3 A_PlaySound("terminator/hmissile")
      TNT1 A 0 A_FireCustomMissile("PlayerHomingMissile")
      HCCT AB 4 BRIGHT
      Goto Ready
It's jumping to NoAmmo all the time because JumpIfInventory checks for at least that amount. In this case, 0. This change here will skip across the Goto NoAmmo if you have at least one 1 cell.
XASSASSINX
Posts: 379
Joined: Tue Dec 20, 2016 4:53 pm
Location: MURICAA BROTHER! Just kidding, Brazil.

Re: Tertiary ammo type?

Post by XASSASSINX »

[quote=ichor]It's jumping to NoAmmo all the time because JumpIfInventory checks for at least that amount. In this case, 0. This change here will skip across the Goto NoAmmo if you have at least one 1 cell.[/quote]

So... How should i put it?

EDIT: Wait, i put 1? I remember putting 0! But even with 0, it still doens't work.

EDIT 2: Hold on i forgot to create the missile projectile. DUH

EDIT 3: Well it works, EXCEPT if i'm full of cells. Weird.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm

Re: Tertiary ammo type?

Post by Arctangent »

A_JumpIfInventory with an amount of 0 jumps if you have the max amount of the item, not if you have 0.
XASSASSINX
Posts: 379
Joined: Tue Dec 20, 2016 4:53 pm
Location: MURICAA BROTHER! Just kidding, Brazil.

Re: Tertiary ammo type?

Post by XASSASSINX »

Arctangent wrote:A_JumpIfInventory with an amount of 0 jumps if you have the max amount of the item, not if you have 0.
Again, how should i put it then?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm

Re: Tertiary ammo type?

Post by Arctangent »

Ichor has an example right there in his post, where instead of going to NoAmmo if you don't have ammo, you go to the rest of the AltFire state if you do have ammo.
XASSASSINX
Posts: 379
Joined: Tue Dec 20, 2016 4:53 pm
Location: MURICAA BROTHER! Just kidding, Brazil.

Re: Tertiary ammo type?

Post by XASSASSINX »

Arctangent wrote:Ichor has an example right there in his post, where instead of going to NoAmmo if you don't have ammo, you go to the rest of the AltFire state if you do have ammo.
yeah yeah... I already fixed it. Thanks!

Return to “Scripting”