ACTOR DUalPlasmaRifles : BrutalWeapon
{
	Weapon.SelectionOrder 100
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
    Inventory.PickupSound "PLSDRAW"
	Weapon.AmmoType1 "AmmoCell"
	Weapon.AmmoType2 "DoublePlasmaAmmo"
    +WEAPON.NOAUTOAIM
	+FORCEXYBILLBOARD
	Tag "Dual Plasma Rifles"
	Inventory.PickupMessage "Plasma Gun"
	States
	{
	
	PuristGun:
		TNT1 A 1
		DUPL A 0 A_GiveInventory("ClassicPlasmaRifle", 1)
		DUPL A 0 A_TakeInventory("Plasma_Gun", 1)
		DUPL A 0 A_TakeInventory("DualPlasmaRifles", 1)
		
		TNT1 A 10
		Goto Ready	
		
	NoAmmoOnSecondGun:
		DUPL A 3
	Ready3:
	Ready:
        DUPL A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		DUPL A 0 A_JumpIfInventory("Unloading",1,"Unload")
        DUPL A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        DUPL A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		DUPL A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		DUPL A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        DUPL A 0 A_JumpIfInventory("Reloading",1,"Reload")
		DUPL A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		DUPL A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		DUPL A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		
		Loop
		
	DualWield:
		DUPL A 1
		DUPL A 0 A_Takeinventory("StartDualWield",1)
		DUPL A 0 A_SelectWEapon("Plasma_Gun")
		Goto Ready	
		
	CheckSprint:
		DUPL A 1 A_WeaponReady(WRF_NOFIRE)
		DUPL A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		DUPL A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready
		
	StartSprint:
		DUPL A 1 A_WeaponReady(WRF_NOFIRE)
		DUPL A 0 A_Takeinventory("Zoomed",1)
		DUPL A 0 A_Takeinventory("ADSmode",1)
		DUPL A 0 A_ZoomFactor(1.0)
		DUPL A 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
		
	Sprinting:	
		DUPL A 0 offset(-9,32) 
		DUPL A 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		DUPL A 0 offset(-9,32) A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		PLAY A 0 offset(-9,32) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
		DUPL A 0 offset(-9,32) A_JumpIfInventory("PowerStrength", 1, 2)
		DUPL A 0 offset(-9,32) A_GiveInventory("UsedStamina", 8)
		DUPL A 0 offset(-9,32)
		DUPL A 1 offset(-9,34) A_SetPitch(pitch -0.5)
		DUPL A 1 offset(-6,36) A_SetPitch(pitch -0.5)
		DUPL A 1 offset(-3,38) A_SetPitch(pitch -0.5)
		DUPL A 1 offset(0,38) A_SetPitch(pitch -0.5)
		DUPL A 1 offset(3,36) A_SetPitch(pitch -0.5)
		DUPL A 1 offset(6,34) A_SetPitch(pitch -0.5)
		DUPL A 1 offset(9,32) A_SetPitch(pitch -0.5)
		DUPL A 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
		DUPL A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        DUPL A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        DUPL A 0 A_JumpIfInventory("Reloading",1,"Reload")
		DUPL A 0 offset(-9,32) A_GiveInventory("UsedStamina", 8)
		DUPL A 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
		DUPL A 1 offset(9,34) A_SetPitch(pitch +0.5)
		DUPL A 1 offset(6,36) A_SetPitch(pitch +0.5)
		DUPL A 1 offset(3,38) A_SetPitch(pitch +0.5)
		DUPL A 1 offset(0,38) A_SetPitch(pitch +0.5)
		DUPL A 1 offset(-3,36) A_SetPitch(pitch +0.5)
		DUPL A 1 offset(-6,34) A_SetPitch(pitch +0.5)
		DUPL A 1 offset(-9,32) A_SetPitch(pitch +0.5)
		DUPL A 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
		DUPL A 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint
		
	StopSprintTired:
		DUPL A 1
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		DUPL A 0 A_PlaySound("Tired", 2)
		DUPL A 0 A_TakeInventory("UsedStamina", 2)
		DUPL A 5 A_WeaponReady
		DUPL A 0 A_TakeInventory("UsedStamina", 2)
		DUPL A 5 A_WeaponReady
		DUPL A 0 A_TakeInventory("UsedStamina", 2)
		DUPL A 5 A_WeaponReady
		DUPL A 0 A_TakeInventory("UsedStamina", 2)
		DUPL A 5 A_WeaponReady
		DUPL A 0 A_TakeInventory("UsedStamina", 2)
		DUPL A 5 A_WeaponReady
		Goto Ready
	StopSprint:
		DUPL A 1
		DUPL A 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		Goto Ready	
		
	Deselect:
		DUPL A 0 A_Takeinventory("Reloading",1)
		DUPL A 0 A_Takeinventory("HasPlasmaWeapon",1)
		DUPL A 0 A_TakeInventory("TossGrenade", 1)
        DUPL A 1 Offset(0, 34)
		DUPL A 1 Offset(0, 38)
		DUPL A 1 Offset(0, 42)
		DUPL A 1 Offset(0, 50)
		DUPL A 0 Offset(0, 32)
		TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
		TNT1 A 1 A_Lower
		Wait
		
	Select:
		DUPL A 0
	    DUPL A 0 A_Giveinventory("HasPlasmaWeapon",1)
		DUPL A 0 A_Takeinventory("FistsSelected",1)
		DUPL A 0 A_Takeinventory("SawSelected",1)
		DUPL A 0 A_Takeinventory("ShotgunSelected",1)
		DUPL A 0 A_Takeinventory("SSGSelected",1)
		DUPL A 0 A_Takeinventory("MinigunSelected",1)
		DUPL A 0 A_Giveinventory("PlasmaGunSelected",1)
		DUPL A 0 A_Takeinventory("RocketLauncherSelected",1)
		DUPL A 0 A_Takeinventory("GrenadeLauncherSelected",1)
		DUPL A 0 A_Takeinventory("BFGSelected",1)
		DUPL A 0 A_Takeinventory("BFG10kSelected",1)
		DUPL A 0 A_Takeinventory("RailGunSelected",1)
		DUPL A 0 A_Takeinventory("SubMachineGunSelected",1)
		DUPL A 0 A_Takeinventory("RevenantLauncherSelected",1)
		DUPL A 0 A_Takeinventory("LostSoulSelected",1)
		DUPL A 0 A_Takeinventory("FlameCannonSelected",1)
		DUPL A 0 A_Takeinventory("HasBarrel",1)
		DUPL A 0 A_TakeInventory("TossGrenade", 1)
		
		TNT1 A 1 A_Raise
		TNT1 AAAAAA 0 A_Raise
		DUPL A 0 A_GunFlash
	    DUPL A 0 A_JumpIfInventory("IsPlayingAsPurist", 1, "PuristGun")
		DUPL A 0 A_PlaySound("PLSDRAW")
		SelectAnimation:
        DUPL A 1 Offset(0, 50)
		DUPL A 1 Offset(0, 42)
		DUPL A 1 Offset(0, 38)
		DUPL A 1 Offset(0, 34)
		DUPL A 0 Offset(0, 32)
		DUPL A 0 A_Takeinventory("StartDualWield",1)
		DUPL A 0 A_GunFlash
		Goto Ready
		
	Fire:
		DUPL A 0
        DUPL A 0 A_JumpIfInventory("Reloading",1,"Reload")
        DUPL A 0 A_JumpIfInventory("DoublePlasmaAmmo",1,2)
        Goto NoAmmo
        TNT1 AAAA 0
        DUPL A 0 A_PlaySound("PLSM9", CHAN_WEAPON)
		DUPL A 0 A_FireCustomMissile("PlasmaFlareSpawn", 12, 0, 0, 0)
		
		DUPL A 0 A_JumpIfInventory("DMgame", 1, "FireDM")
		DUPL A 0 A_ZoomFactor(0.98)
		DUPL B 1 BRIGHT A_FireCustomMissile("Plasma_Ball", random(-8, 4), 1, 8, -3, 0, random(-3, 3))
		DUPL A 0 A_ZoomFactor(1.0)
		DUPL A 0 A_Takeinventory("PlasmaAmmo",1)
		DUPL A 0 A_Takeinventory("DoublePlasmaAmmo",1)
		DUPL B 1
		
		DUPL A 0 A_JumpIfInventory("PlasmaAmmo",1,1)//Checks if single gun is not depleted
        Goto NoAmmoOnSecondGun
		
		DUPL A 0 A_JumpIfInventory("Reloading",1,"Reload")
        DUPL A 0 A_JumpIfInventory("DoublePlasmaAmmo",1,1)
        Goto NoAmmo
        DUPL A 0 A_PlaySound("PLSM9", CHAN_WEAPON)
		DUPL A 0 A_FireCustomMissile("PlasmaFlareSpawn", -12, 0, 0, 0)
		
		DUPL A 0 A_ZoomFactor(0.98)
		DUPL D 1 BRIGHT A_FireCustomMissile("Plasma_Ball", random(-4, 8), 1, -8, -3, 0, random(-3, 3))
		DUPL A 0 A_ZoomFactor(1.0)
		DUPL A 0 A_Takeinventory("DoublePlasmaAmmo",1)
		DUPL E 1
		Goto Ready
		
	FireDM:	
		DUPL A 0 A_ZoomFactor(0.98)
		DUPL B 1 BRIGHT A_FireCustomMissile("PlasmaBallDM", random(-8, 4), 1, 8, -3, 0, random(-3, 3))
		DUPL A 0 A_ZoomFactor(1.0)
		DUPL A 0 A_Takeinventory("PlasmaAmmo",1)
		DUPL A 0 A_Takeinventory("DoublePlasmaAmmo",1)
		DUPL B 1
		
		DUPL A 0 A_JumpIfInventory("Reloading",1,"Reload")
        DUPL A 0 A_JumpIfInventory("DoublePlasmaAmmo",1,2)
        Goto NoAmmo
        TNT1 AAAA 0
        DUPL A 0 A_PlaySound("PLSM9", CHAN_WEAPON)
		DUPL A 0 A_FireCustomMissile("PlasmaFlareSpawn", -12, 0, 0, 0)
		
		DUPL A 0 A_ZoomFactor(0.98)
		DUPL D 1 BRIGHT A_FireCustomMissile("PlasmaBallDM", random(-4, 8), 1, -8, -3, 0, random(-3, 3))
		DUPL A 0 A_ZoomFactor(1.0)
		DUPL A 0 A_Takeinventory("DoublePlasmaAmmo",1)
		DUPL E 1
		Goto Ready


	Spawn:
	    DUPL A 0
		DUPL A 0 A_ChangeFLag("THRUACTORS", 1)
		PLAS A 20
		DUPL A 0 A_SpawnItem("DropedPlasmaGun")
		Stop

    Reload:

		DUPL A 0 A_Takeinventory("Reloading",1)
		DUPL A 0
		DUPL A 0 A_JumpIfInventory("AmmoCell",1,1)
		Goto Ready
		DUPL A 0
		DUPL A 0 A_JumpIfInventory("DoublePlasmaAmmo",100,"Ready")
		DUPL A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		DUPL A 0 A_JumpIfInventory("AmmoCell",1,7)

		DUPL A 1 Offset(0, 34)
		DUPL A 1 Offset(0, 38)
		DUPL A 1 Offset(0, 42)
		DUPL A 1 Offset(0, 50)
		DUPL A 0 Offset(0, 32)
		
		
		
		TNT1 A 5
		PLSR B 1
		DUPL A 0 A_PlaySound("PLREADY", 1)
		DUPL A 0 A_FireCustomMissile("PlasmaCaseSpawn",-210,0,20,-20)
		PLSR CDEEEEEEEEEEEEEEEF 1
        PLSR GHHIIIJJJJJJJJIKLB 1
		TNT1 A 10
		P2SR B 1
		DUPL A 0 A_PlaySound("PLREADY", 3)
		DUPL A 0 A_FireCustomMissile("PlasmaCaseSpawn",-210,0,20,-20)
		P2SR CDEEEEEEEEEEEEEEEF 1
        P2SR GHHIIIJJJJJJJJIKLB 1
		DUPL A 0 A_TakeInventory("StopDualWield", 1)
		DUPL A 0 A_TakeInventory("FiredPrimary", 1)
		DUPL A 0 A_TakeInventory("FiredSecondary", 1)
		TNT1 A 5
		
		
		DUPL A 1 Offset(0, 50)
		DUPL A 1 Offset(0, 42)
		DUPL A 1 Offset(0, 38)
		DUPL A 1 Offset(0, 34)
		DUPL A 0 Offset(0, 32)
		
		
		
		ReloadingSequence:
		TNT1 AAAAAAAAAA 0
		DUPL A 0 A_JumpIfInventory("DoublePlasmaAmmo",100,15)
		DUPL A 0 A_JumpIfInventory("AmmoCell",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		DUPL A 0 A_Giveinventory("PlasmaAmmo",1)
		DUPL A 0 A_Giveinventory("DoublePlasmaAmmo",1)
		DUPL A 0 A_Takeinventory("AmmoCell",1)
		Goto ReloadingSequence
		TNT1 AAAAAAAA 0
		
		DUPL A 0 A_Takeinventory("Reloading",1)
        Goto Ready
		
		
		
	TurboReload:
		PLSG BCDE 0
		PLSG E 0 A_FireCustomMissile("PlasmaCaseSpawn",-210,0,20,-20)
		PLSG EDCB 0
		Goto ReloadingSequence
		
		
	Unload:

		DUPL A 0 A_Takeinventory("Unloading",1)
		DUPL A 0 A_JumpIfInventory("DoublePlasmaAmmo",1,7)
		Goto Ready
		TNT1 AAAAA 0
        PLSR AB 1
		PLSR CDJJJJJJ 1
		PLSR IHGFDECBA 2
		TNT1 A 5
		P2SR AB 1
		P2SR CDJJJJJJ 1
		P2SR IHGFDECBA 2
		
	UnloadingSequence:
		DUPL A 0
		DUPL A 0 A_Takeinventory("Unloading",1)
		DUPL A 0 A_JumpIfInventory("DoublePlasmaAmmo",1,3)
		Goto Ready
        TNT1 AAAAAAA 0
		DUPL A 0 A_Takeinventory("PlasmaAmmo",1)
		DUPL A 0 A_Takeinventory("DoublePlasmaAmmo",1)
		DUPL A 0 A_Giveinventory("AmmoCell",1)
		Goto UnloadingSequence	
		
	NoAmmo:
		RIFG A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
		NoAmmo2:
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
	    RIFG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		RIFG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		RIFG A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		DUPL A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "NoAmmo2")
		RIFG A 0 A_JumpIfInventory("AmmoCell",1,"Reload")
		RIFG A 0 A_JumpIfInventory("FiredPrimary",1,"NoAmmo2")
		Goto Ready3	
	}
}



