Double ammo-type weapon activates Altfire after short delay

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
User avatar
DenTheUA
Posts: 41
Joined: Fri Jun 09, 2017 4:06 am
Location: Land of salo, gorilka and borsch (a.k.a. Ukraine)

Double ammo-type weapon activates Altfire after short delay

Post by DenTheUA »

Alright, so I was scripting a weapon and I got a problem.
Shortly after firing with primary fire, the secondary fire option is activated.
Here's the code:

Code: Select all

States
		{
			Ready:
				RIFL A 2 A_WeaponReady 
				RIFL A 0 A_GiveInventory("RocketIn",1)
				loop
			Select:
				RIFL A 1 A_Raise
				loop
			Deselect:
				RIFL A 1 A_Lower
				loop
			Fire:
				RIFL A 1 bright A_FireBullets(5,5,1,15)
				RIFL A 0 bright A_PlaySound("Automat/fire")
				RIFL B 1 bright A_FireCustomMissile("Projectile") 
				RIFL A 1 Offset(3,0) bright A_TakeInventory("Clip",1)
				RIFL A 1 Offset(6,0) bright 
				RIFL A 1 Offset(9,0) bright
				RIFL A 1 Offset(12,0) bright
				RIFL A 1 Offset(9,0) bright
				RIFL A 1 Offset(6,0) bright
				RIFL A 1 Offset(3,0) bright
				RIFL A 1 A_Refire
			Altfire:
				RIFL A 1 A_JumpIfInventory("RocketIn",100,"Rocket")
				RIFL A 1
				goto Ready
			Rocket:
				SRIF ABCD 2 bright
				RIF2 A 2 bright A_TakeInventory("RocketIn",100)
				RIF2 B 2 bright A_FireMissile
				RIF2 A 2 bright
				SRIF DCBA 2 bright
				goto Ready
			}
"RocketIn" is a countdown dummy item.
"Projectile" is a projectile related to alerting monsters.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Double ammo-type weapon activates Altfire after short de

Post by Blue Shadow »

You're missing a 'Goto Ready' at the end of the Fire state sequence. Without it, it falls through to the Altfire state sequence.
User avatar
DenTheUA
Posts: 41
Joined: Fri Jun 09, 2017 4:06 am
Location: Land of salo, gorilka and borsch (a.k.a. Ukraine)

Re: Double ammo-type weapon activates Altfire after short de

Post by DenTheUA »

Blue Shadow wrote:You're missing a 'Goto Ready' at the end of the Fire state sequence. Without it, it falls through to the Altfire state sequence.
Aha, the problem's really in missing goto.
Thank you for pointing that out

Return to “Scripting”