A_Refire problem

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
DBThanatos
Posts: 3101
Joined: Fri Apr 14, 2006 3:17 pm
Location: in "the darkness that lurks in our mind"

A_Refire problem

Post by DBThanatos »

Im trying to recreate the powered PhoenixRod behaviour as secondary fire for the regular one, but Im having a single problem

Code: Select all

ACTOR AEoDFPhoenixRod : Weapon 6014
{ 
	+FLOORCLIP
	Weapon.AmmoType "RocketAmmo"
	Weapon.AmmoType2 "RocketAmmo"
	Weapon.AmmoGive 18
	Weapon.AmmoUse 1
	Weapon.AmmoUse2 1
	Inventory.PickupSound "weaponbuild" 
	Inventory.PickupMessage "Picked up the Phoenix rod."
	Obituary "%o saw a fire bird rising from %k's Rod."
	AttackSound "weapons/pistol"
	States 
	{ 
	Spawn: 
		WPHX A -1 
		Loop 
	Ready: 
		TNT1 A 0 A_TakeInventory("PhoenixAltFCheck",8)
		PHNX A 1 A_WeaponReady 
		Loop 
	Deselect: 
		TNT1 A 0 A_TakeInventory("PhoenixAltFCheck",8)
		PHNX A 1 A_Lower 
		NULL AA 0 A_Lower
		Goto Deselect+1
	Select: 
		TNT1 A 0 A_TakeInventory("PhoenixAltFCheck",8)
		PHNX A 1 A_Raise
		NULL AA 0 A_Raise 
		Goto Select+1
	Fire: 
		PHNX B 0 A_PlayWeaponSound("weapons/phoenixshoot")
		PHNX B 8 Bright 
		PHNX C 0 A_GunFlash
		DPIS A 0 A_Recoil(6)
		PHNX C 7 Bright A_FireCustomMissile("PhoenixShot", 0, 1, 0, 0) 
		PHNX D 8 Bright
		goto Ready 
	AltFire: 
		PHNX B 3 Bright 
		PHNX C 1 Bright A_FireCustomMissile("PhoenixFX2", 0, 1, 0, 0)   //only the start is what consumes ammo
		PHNX C 1 Bright A_FireCustomMissile("PhoenixFX2", 0, 0, 0, 0) 
		TNT1 A 0 A_Refire
		TNT1 A 0 A_TakeInventory("PhoenixAltFCheck",8)
		PHNX D 3 Bright
		goto Ready 
	AltHold:
		TNT1 A 0 A_JumpIfInventory("PhoenixAltFCheck",8,"HoldEnd")
		TNT1 A 0 A_GiveInventory("PhoenixAltFCheck",1)
		PHNX C 1 Bright A_FireCustomMissile("PhoenixFX2", 0, 0, 0, 0) 
		TNT1 A 0 A_Refire		
	HoldEnd:
		TNT1 A 0 A_TakeInventory("PhoenixAltFCheck",8)
		PHNX D 3 Bright
		goto Ready 				
	Flash: 
		CRBW W 3 BRIGHT A_Light1 
		CRBW W 2 BRIGHT A_Light0
		Stop 
	}
} 

actor PhoenixAltFCheck : Inventory
{
	Inventory.MaxAmount 8
	Inventory.Amount 1
}
The problem lies (i think) between the AltFire AltHold and HoldEnd. In theory, this should work. If the AltHold sequence is repeated 8 times, then it should go to the HoldEnd (for the inventory jump), take all the checks, and go to Ready. And repeat. It works, except if you keep pressing the altfire key, it will do what I want, except that will not consume ammo.

After a couple revisions, I understood this is what's happening: Seems like even when it reaches the HoldEnd state, and it is told to go to Ready, if you keep pressing your altfire key, the weapon will go again to the AltHold instead of going to the AltFire (as it should because I told the weapon to "goto ready"). I seriously consider this a Bug, but maybe is intentional behaviour. Anyway, is there a better method to replicate the powered phoenix rod behaviour? or a way to fix this one?

(of course in the final version of this weapon you'll fire more than 8 little flames, i just used that number to count them ingame)

Thanks in advance.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: A_Refire problem

Post by Ghastly »

Hold states and inventory jumps really don't work too well together. If a weapon jumps out of the hold state, as soon as you press fire again, it skips the Fire state and goes directly to Hold (or, in this case, AltFire and AltHold).

Might be a ZDoom bug. You can work around it with a fake inventory item in the Ready state (checks for it in the Hold state which goes to the Fire state, and the Fire state takes it away). I can send you the reloading chaingun from Abyss Below, which had roughly the same problem, if you want, but the decorate for it is a mess.
User avatar
DBThanatos
Posts: 3101
Joined: Fri Apr 14, 2006 3:17 pm
Location: in "the darkness that lurks in our mind"

Re: A_Refire problem

Post by DBThanatos »

Oh i see. Thanks for the info. I have just reported it as a bug, let's see if I get [not a bug] :P. If that's the case, I'll thank you if you send me the code you mentioned :)
Locked

Return to “Editing (Archive)”