Dual pistols - can't switch weapons after reloading

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
Electronic Samurai
Posts: 177
Joined: Mon Mar 27, 2006 1:54 am
Location: Wandering the open plains

Dual pistols - can't switch weapons after reloading

Post by Electronic Samurai »

Hello, all! I'm working on a set of dual pistols that make heavy use of the Flash state (based on a set of dual pistols that were submitted for the Mutator contest a little ways back, but for the life of me I can't remember whose they were). However, I've hit a bit of a brick wall with them - whenever I reload the weapons, but have no ammunition available, the sprite for the pistol disappears and I become unable to switch to a different weapon.

In addition, SetOffset doesn't appear to work for the right pistol, but that's probably because it's contained in the Flash state.

Code: Select all

ACTOR DualSidearm: Pistol
{
	Game Doom
	Weapon.SelectionOrder 90
	Weapon.AmmoUse 0
	Weapon.AmmoGive 0
	Weapon.AmmoType1 "ClipPistolLeft"
	Weapon.AmmoType2 "ClipPistolRight"
	Weapon.AmmoUse2 0
	Weapon.Slotnumber 2

	Decal "BulletChip"
	-WEAPON.WIMPY_WEAPON
	+WEAPON.NOAUTOFIRE
	+WEAPON.AMMO_CHECKBOTH
	+WEAPON.NOALERT
	Inventory.Pickupmessage "Picked up a 9mm sidearm with a left-handed grip."
	States
	{
	Spawn:
		9MMS A -1
		Loop
	Deselect:
		9MML A 0 A_TakeInventory("SynthFireActive",1)
		9MML A 0 A_TakeInventory("SynthFireLeft",1)
		9MML A 0 A_TakeInventory("SynthFireRight",1)
    DS:
		9MML A 0 A_Lower 
		9MML A 1 A_Lower
		Loop
	Select:
		9MML A 0 A_GunFlash
		9MML A 0 A_PlaySound("weapons/up")
	    9MML T 1 offset(-80,72)
        9MML T 1 offset(-60,62)
        9MML T 1 offset(-40,57)
        9MML T 1 offset(-30,52)
        9MML T 1 offset(-20,47)
        9MML S 1 offset(-15,42)
        9MML S 1 offset(-12,37)
        9MML A 1 offset(-9,32)
        9MML A 1 offset(-6,32)
        9MML A 1 offset(-3,32)
	Ready:
		9MML A 0 A_GiveInventory("SynthFireActive",1)
		9MML A 1
		9MML A 0 ACS_ExecuteAlways(251,0,0,0,0) //act.synth-fire LEFT(pri)
		9MML A 0 ACS_ExecuteAlways(252,0,0,0,0) //act.synth-fire RIGHT(sec)
		
	// Left Pistol
	LIdle:
		9MML A 1 A_WeaponReady(12)
		9MML A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
    	9MML A 0 A_JumpIfInventory("Reload",1,"LReload")
    	Loop
	LReload:
		PISL A 0 A_JumpIfInventory("ClipPistolLeft",0,"LIdle")
		PISL A 0 A_JumpIfInventory("Clip",1,1)
		Goto LIdle
		PISL H 2 A_PlaySound("weapons/sshotl")
		PISL D 2
		PISL D 12
	LRStart:
		TNT1 A 0 A_JumpIfInventory("ClipPistolLeft",0,"LREnd")
		TNT1 A 0 A_JumpIfInventory("Clip",1,1)
		Goto LREnd
		TNT1 A 0 A_TakeInventory("Clip",1,1)
		TNT1 A 0 A_GiveInventory("ClipPistolLeft",1)
		goto LRStart
	LREnd:
		PISL E 2 A_PlaySound("weapons/sshotc")
		PISL FE 2
		Goto LF2
	LDryFire:
		9MML A 0 A_PlaySound("sidearm/dryfire")
	    9MML A 3 Offset(1,34) A_WeaponReady(14)
	    9MML A 1 Offset(2,37) A_WeaponReady(14)
	    9MML A 1 Offset(1,36) A_WeaponReady(14)
	    9MML A 1 Offset(0,33) A_WeaponReady(14)
		9MML A 0 A_TakeInventory("SynthFireLeft",1)
		Goto LF1
    LFire:
    	9MML A 0 A_JumpIfInventory("ClipPistolLeft",1,1)
		Goto LDryFire
    	9MML A 0 A_AlertMonsters
		9MML A 0 A_Light2
		9MML A 0 A_TakeInventory("ClipPistolLeft",1,1)
		9MML A 0 A_PlaySound("sidearm/fire")
		9MML A 0 A_FireBullets(0.7,0.7,-1,5,"BulletPuffSmall") //DMG was 2.5
		9MML B 1 A_WeaponReady(14)
	    9MML B 0 A_SetPitch(pitch-2)
        9MML B 0 A_FireCustomMissile("PistolSmokeSpawner",0,0,0,0)
        9MML B 0 A_FireCustomMissile("CheapAlert",0,0,0,0)
		9MML C 1 A_WeaponReady(14)
        9MML C 0 A_Light0
        9MML C 0 A_FireCustomMissile("SidearmCasingSpawnerLeft",0,0,0,0)
		9MML A 1 BRIGHT Offset(2,37) A_WeaponReady(14)
		9MML A 0 A_TakeInventory("SynthFireLeft",1)
		9MML A 1 Offset(0,33) A_WeaponReady(14)
		9MML A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
		9MML A 1 A_WeaponReady(14)
		9MML A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
	LF2:
		9MML A 1 A_WeaponReady(14)
		9MML A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
    	9MML A 0 A_JumpIfInventory("Reload",1,"LReload")
		9MML A 1 A_WeaponReady(14)
		9MML A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
    	9MML A 0 A_JumpIfInventory("Reload",1,"LReload")
		9MML A 1 A_WeaponReady(14)
		9MML A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
    	9MML A 0 A_JumpIfInventory("Reload",1,"LReload")
		9MML A 1 A_WeaponReady(14)
		9MML A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
    	9MML A 0 A_JumpIfInventory("Reload",1,"LReload")
		Goto LIdle
		
	// Right Pistol
	Flash:
		TNT1 A 15
		9MMR A 0 A_PlaySound("weapons/up")
	    9MMR T 1 offset(-80,72)
        9MMR T 1 offset(-60,62)
        9MMR T 1 offset(-40,57)
        9MMR T 1 offset(-30,52)
        9MMR T 1 offset(-20,47)
        9MMR S 1 offset(-15,42)
        9MMR S 1 offset(-12,37)
        9MMR A 1 offset(-9,32)
        9MMR A 1 offset(-6,32)
        9MMR A 1 offset(-3,32)
	RIdle:
		9MMR A 1
		9MMR A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
    	9MMR A 0 A_JumpIfInventory("Reload",1,"RReload")
    	Loop
	RReload:
		PISR A 0 A_JumpIfInventory("ClipPistolRight",0,"RIdle")
		PISR A 0 A_JumpIfInventory("Clip",1,1)
		Goto RIdle
		PISR A 2 
		PISR H 2 A_PlaySound("weapons/sshotl")
		PISR D 2
		PISR D 12
	RRStart:
		TNT1 A 0 A_JumpIfInventory("ClipPistolRight",0,"RREnd")
		TNT1 A 0 A_JumpIfInventory("Clip",1,1)
		Goto RREnd
		TNT1 A 0 A_TakeInventory("Clip",1,1)
		TNT1 A 0 A_GiveInventory("ClipPistolRight",1)
		goto RRStart
	RREnd:
		PISR E 2 A_PlaySound("weapons/sshotc")
		PISR FE 2
		Goto RF2
	RDryFire:
		9MMR A 0 A_PlaySound("sidearm/dryfire")
	    9MMR A 3 Offset(1,34) A_WeaponReady(14)
	    9MMR A 1 Offset(2,37) A_WeaponReady(14)
	    9MMR A 1 Offset(1,36) A_WeaponReady(14)
	    9MMR A 1 Offset(0,33) A_WeaponReady(14)
		9MMR A 0 A_TakeInventory("SynthFireLeft",1)
		Goto RF1
    RFire:
    	9MMR A 0 A_JumpIfInventory("ClipPistolRight",1,1)
		Goto RDryFire
    	9MMR A 0 A_AlertMonsters
		9MMR A 0 A_Light2
		9MMR A 0 A_TakeInventory("ClipPistolRight",1,1)
		9MMR A 0 A_PlaySound("sidearm/fire")
		9MMR A 0 A_FireBullets(0.7,0.7,-1,5,"BulletPuffSmall") //DMG was 2.5
		9MMR B 1 A_WeaponReady(14)
	    9MMR B 0 A_SetPitch(pitch-2)
        9MMR B 0 A_FireCustomMissile("PistolSmokeSpawner",0,0,0,0)
        9MMR B 0 A_FireCustomMissile("CheapAlert",0,0,0,0)
		9MMR C 1 A_WeaponReady(14)
        9MMR C 0 A_Light0
        9MMR C 0 A_FireCustomMissile("SidearmCasingSpawnerRight",0,0,0,0)
		9MMR A 1 BRIGHT Offset(2,37) A_WeaponReady(14)
		9MMR A 0 A_TakeInventory("SynthFireRight",1)
		9MMR A 1 Offset(0,33) A_WeaponReady(14)
		9MMR A 0 A_JumpIfInventory("SynthFireRight",1,"LFire")
		9MMR A 1 A_WeaponReady(14)
		9MMR A 0 A_JumpIfInventory("SynthFireRight",1,"LFire")
	   RF2:
		9MMR A 1 A_WeaponReady(14)
		9MMR A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
    	9MMR A 0 A_JumpIfInventory("Reload",1,"RReload")
		9MMR A 1 A_WeaponReady(14)
		9MMR A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
    	9MMR A 0 A_JumpIfInventory("Reload",1,"RReload")
		9MMR A 1 A_WeaponReady(14)
		9MMR A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
    	9MMR A 0 A_JumpIfInventory("Reload",1,"RReload")
		9MMR A 1 A_WeaponReady(14)
		9MMR A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
    	9MMR A 0 A_JumpIfInventory("Reload",1,"RReload")
		Goto RIdle
	Fire:
		TNT1 A 0 
		Goto Ready
	AltFire:
		Stop
	}
}

ACTOR ClipPistolLeft : Ammo { Inventory.MaxAmount 20 +IGNORESKILL }

ACTOR ClipPistolRight : Ammo { Inventory.MaxAmount 20 +IGNORESKILL }

Code: Select all

// Left (primary) weapon.
script 251 (void)
{
	while(checkinventory("SynthFireActive")>0)
	{
		if(getplayerinput(-1, INPUT_BUTTONS) & BT_ATTACK)
		{
			giveinventory("SynthFireLeft",1);
			while(checkinventory("SynthFireLeft">0) || getplayerinput(-1, INPUT_BUTTONS) & BT_ATTACK) { delay(1); }
			takeinventory("SynthFireLeft",1);
		}
		delay(1);
	}
}

// Right (secondary) weapon.
script 252 (void)
{
	while(CheckInventory("SynthFireActive")>0)
	{
		if(GetPlayerInput(-1, INPUT_BUTTONS) & BT_ALTATTACK)
		{
			GiveInventory("SynthFireRight",1);
			while(GetPlayerInput(-1, INPUT_BUTTONS) & BT_ALTATTACK) { delay(1); }
			TakeInventory("SynthFireRight",1);
		}
		delay(1);
	}
}
Locked

Return to “Editing (Archive)”