ACTOR Storm : Weapon 25302
{
  Tag "APS-EX60 Storm"
   Inventory.PickupMessage "You got the APS-EX60 'Storm' Auto Pistol."
    Inventory.PickupSound "misc/w_pkup"
	Weapon.UpSound "Weapons/StormUp"
    Weapon.AmmoGive2 1
    Weapon.AmmoType "StormClip"
    Weapon.AmmoType2 "Pistol_Magazine"
    Weapon.AmmoUse 1
    Weapon.Kickback 100
    Weapon.Slotnumber 2
	Weapon.PreferredSkin "Pistol"
	weapon.bobstyle inversesmooth
   weapon.bobrangeX 0.4
   weapon.bobrangeY 0.6
   weapon.bobspeed 2.5
    Obituary "%o was picked off by %k and %p Auto Pistol."
    decal "BlazeChip"
    Scale 0.8
    +Weapon.NoAutoFire
	+Weapon.Ammo_Optional
	+CHEATNOTWEAPON
	+NOAUTOAIM
    States
    {
    Spawn:
        APSP X -1
        loop
    Ready:
        APSG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
        loop
	ReadyEmpty:
        APSE A 1 A_WeaponReady(WRF_ALLOWRELOAD)
        loop
    Deselect:
        TNT1 A 0 SetPlayerProperty(0,1,2)
		TNT1 A 0 A_SetCrosshair(1)
		TNT1 A 0 A_StopSoundEX("Weapon")
	    APSS ABCDE 1
	    Goto DeselectLoop
    DeselectLoop:
        TNT1 A 1 A_Lower
        Loop
    Select:
	    TNT1 A 0 A_JumpIfInventory("SemiToken",1,"SelectSemi")
        TNT1 A 0 SetPlayerProperty(0,0,2)
		TNT1 A 0 A_SetCrosshair(12)
        APSS EDCBA 1
        Goto SelectLoop
	SelectSemi:
        TNT1 A 0 SetPlayerProperty(0,0,2)
		TNT1 A 0 A_SetCrosshair(13)
        APSS EDCBA 1
        Goto SelectLoop
    SelectLoop:
        APSG A 1 A_Raise
	    loop
    Fire: //Semi Auto, Spam the mouse button.
		TNT1 A 0 A_JumpIfInventory("APSDryFireToken", 1, "DryFireTrue")
		TNT1 A 0 A_JumpIfInventory("StormClip", 1, 1)
		Goto DryFire
		TNT1 A 0 A_JumpIfInventory("SemiToken", 1, "FireSemi")
		TNT1 A 0 A_Jump(255,"FireAuto1","FireAuto2")
	FireAuto1:
	    TNT1 A 0 A_JumpIfInventory("StormClip", 1, 1)
		Goto DryFire
		TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
		TNT1 A 0 A_PlaySoundEX("Weapons/StormFireLoop","Weapon",1)
		TNT1 A 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
		TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
		TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-3, 3), 1, 2.5, 5, 0,random(-3, 3))
		APSG A 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
		TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,4,0)
		TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-3, 3), 0, 2.5, 5, 0,random(-3, 3))
		APSF B 1 BRIGHT A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
		TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,5,0)
		TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-3, 3), 1, 2.5, 5, 0,random(-3, 3))
		APSG B 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ReFire
		TNT1 A 0 A_PlaySoundEX("Weapons/StormFireStop","Weapon",0)
		APSG A 1 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	FireAuto2:
		TNT1 A 0 A_JumpIfInventory("StormClip", 1, 1)
		Goto DryFire
		TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
		TNT1 A 0 A_PlaySoundEX("Weapons/StormFireLoop","Weapon",1)
		TNT1 A 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
		TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
		TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-3, 3), 1, 2.5, 5, 0,random(-3, 3))
		APSF C 1 BRIGHT A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
		TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,4,0)
		TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-3, 3), 0, 2.5, 5, 0,random(-3, 3))
		APSG C 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
		TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,5,0)
		TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-3, 3), 1, 2.5, 5, 0,random(-3, 3))
		APSF A 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ReFire
		TNT1 A 0 A_PlaySoundEX("Weapons/StormFireStop","Weapon",0)
		APSG A 1 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	FireSemi:
	    TNT1 A 0 A_JumpIfInventory("StormClip", 1, 1)
		Goto DryFireTrue
		TNT1 A 0 A_JumpIfInventory("StormClip", 2, 1)
		Goto FireSemiLast
		TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
		TNT1 A 0 A_PlaySound("Weapons/StormFireSemi",81,1.0,0,1)
		TNT1 AAAAAAAAAA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
		TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
		TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-0.5, 0.5), 1, 2.5, 5, 0,random(-0.5, 0.5))
		APSF A 1 A_WeaponReady(WRF_NOFIRE)
		APSG C 0 A_ZoomFactor(0.99)
		APSF BC 1 Bright A_WeaponReady(WRF_NOFIRE)
		APSG B 0 A_ZoomFactor(0.98)
		APSG B 1 A_WeaponReady(WRF_NOFIRE)
		APSG C 0 A_ZoomFactor(0.99)
	    APSG A 1 A_WeaponReady(WRF_NOFIRE)
	    APSG D 0 A_ZoomFactor(1.00)
		Goto Ready
	FireSemiLast: //Semi Auto, Spam the mouse button.
		TNT1 A 0 A_JumpIfInventory("StormClip", 1, 1)
		Goto DryFireTrue
		TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
		TNT1 A 0 A_PlaySound("Weapons/StormFireSemi",81,1.0,0,1)
		TNT1 A 0 A_PlaySound("Weapons/OmenBolt",83,1.5,0,1)
		TNT1 AAAAAAAAAA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
		TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
		TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-0.5, 0.5), 1, 2.5, 5, 0,random(-0.5, 0.5))
		APSF A 1 A_WeaponReady(WRF_NOFIRE)
		APSF BC 1 Bright A_WeaponReady(WRF_NOFIRE)
		APSF A 0 A_ZoomFactor(0.99)
		APSE D 1 A_WeaponReady(WRF_NOFIRE)
		KNSF B 0 A_ZoomFactor(0.98)
		APSE C 1 A_WeaponReady(WRF_NOFIRE)
		KNSF C 0 A_ZoomFactor(0.99)
		APSE B 1 A_WeaponReady(WRF_NOFIRE)
	    KNSF D 0 A_ZoomFactor(1.00)
		APSE A 1 A_WeaponReady(WRF_NOFIRE)
		Goto ReadyEmpty
	AltFire: //Does checks, if you have no dummy actors, select semi auto
		TNT1 A 0 A_PlaySoundEX("Weapons/FireSelector","Body",0,0)
		SHTG A 0 A_JumpIfInventory("SemiToken", 1, "AltFire2")
		SHTG A 0 A_GiveInventory("SemiToken", 1)
		TNT1 A 0 A_SetCrosshair(13)
		APSG A 10 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	AltFire2: //Clears dummy actors, to use full auto
		TNT1 A 0 A_PlaySoundEX("Weapons/FireSelector","Body",0,0)
		SHTG A 0 A_TakeInventory("SemiToken", 1)
		TNT1 A 0 A_SetCrosshair(12)
		APSG A 10 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	DryFire:
		TNT1 A 0 A_PlaySoundEX("Weapons/StormFireStop","Weapon",0)
		TNT1 A 0 A_PlaySound("Weapons/OmenBolt",83,1.5,0,1)
		KNSG A 0 A_PlayWeaponSound("Pistol/Empty") // Play the clicky noise.
		TNT1 A 0 A_GiveInventory("APSDryFireToken",1)
		APSE A 5 A_WeaponReady(WRF_NOFIRE)
		Goto ReadyEmpty
	DryFireTrue:
		KNSG A 0 A_PlayWeaponSound("Pistol/Empty") // Play the clicky noise.
		APSE A 5 A_WeaponReady(WRF_NOFIRE)
		Goto ReadyEmpty
	Reload:
	ReloadBegin:
		TNT1 A 0 A_TakeInventory("APSDryFireToken", 1)
		TNT1 A 0 A_JumpIfInventory("StormClip",60,"Ready")
		TNT1 A 0 A_JumpIfInventory("Pistol_Magazine",1,1)
		Goto DryFireTrue
		TNT1 A 0 A_PlaySound("Weapons/StormMagOut",83,1.0,0,1)
		APSR A 2 A_WeaponReady(WRF_NOFIRE)
		APSR BCDDCC 1 A_WeaponReady(WRF_NOFIRE)
		APSR C 5 A_WeaponReady(WRF_NOFIRE)
		APSR DDEEFF 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_SpawnItemEx("StormClipDrop",0,0,20)
	ReloadWork:
		TNT1 A 0 A_TakeInventory("Pistol_Magazine",1)
		TNT1 A 0 A_GiveInventory("StormClip",60)
		TNT1 A 0 A_JumpIfInventory("StormClip",60,"ReloadFinish")
		TNT1 A 0 A_JumpIfInventory("Pistol_Magazine",1,"ReloadWork")
	ReloadFinish:
		TNT1 A 0 A_PlaySound("Weapons/StormMagIn",84,1.0,0,1)
		APSR GH 2 A_WeaponReady(WRF_NOFIRE)
		APSR IIJKL 1 A_WeaponReady(WRF_NOFIRE)
		APSR L 8 A_WeaponReady(WRF_NOFIRE)
		APSR M 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("Weapons/StormMagLock",85,1.0,0,1)
		APSR OP 1 A_WeaponReady(WRF_NOFIRE)
		APSG A 3 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	}
}

ACTOR SemiToken : Inventory {Inventory.MaxAmount 1}

ACTOR APSDryFireToken : Inventory {Inventory.MaxAmount 1}

ACTOR StormClip : Ammo
{
Inventory.Amount 0
Inventory.MaxAmount 60
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 60
+IGNORESKILL
}

ACTOR StormClipDrop
{
   Radius 3
   Height 5
   Speed 0
   Scale 0.2
   BounceSound "Clip/PST"
   PROJECTILE
   -NOGRAVITY
   +BOUNCEONACTORS
   +BOUNCEONCEILINGS
   Gravity 0.75
   BounceType Doom
   BounceCount 3
   BounceFactor 0.6
   States
   {
   Spawn:
      CLPX A 0
      CLPX ABCDEFGH 1
      Loop
   Death:
      CLPX A 0 A_SpawnItemEx("StormClipLiedown")
      stop
   }
}

actor StormClipLiedown
{
	-NOGRAVITY
	+FLOORCLIP
    Scale 0.2
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_Jump(255,"Spawn1","Spawn2")
	  stop
	Spawn1:
	  CLPX J 1
	  Goto Ded
	Spawn2:
	  CLPX I 1
	  Goto Ded
	Ded:
	  "####" "#" 210 A_CheckSight("Fadying")
	  Loop
	Fadying:
	  "####" "#" 1 A_FadeOut(0.1)
	  Wait
   }
}