ACTOR Punisher : Weapon Replaces Pistol 25402
{
    Tag "ASP-36c Punisher"
    Inventory.PickupMessage "You got the ASP-36C 'Punisher' Assault Pistol."
    Inventory.PickupSound "misc/w_pkup"
    Weapon.UpSound "Weapons/PunisherUp"
    Weapon.AmmoGive2 1
    Weapon.AmmoType "PunisherClip"
    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 Pistol."
    decal "BlazeChip"
    Scale 0.8
	+NOAUTOAIM
    +Weapon.NoAutoFire
    +Weapon.Ammo_Optional
    +CHEATNOTWEAPON
    +NOALERT
    States
    {
    Spawn:
        KNSP A -1
        loop
    Ready:
        KNSG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
        loop
    ReadyEmpty:
        KUSR D 1 A_WeaponReady(WRF_ALLOWRELOAD)
        loop
    Deselect:
        TNT1 A 0 SetPlayerProperty(0,1,2)
        TNT1 A 0 A_SetCrosshair(1)
        KNSS ABCDE 1
        Goto DeselectLoop
    DeselectLoop:
        TNT1 A 1 A_Lower
        Loop
    Select:
        TNT1 A 0 A_JumpIfInventory("BurstToken",1,"SelectBurst")
        TNT1 A 0 SetPlayerProperty(0,0,2)
        TNT1 A 0 A_SetCrosshair(2)
        KNSS EDCBA 1
        Goto SelectLoop
    SelectBurst:
        TNT1 A 0 SetPlayerProperty(0,0,2)
        TNT1 A 0 A_SetCrosshair(3)
        KNSS EDCBA 1
        Goto SelectLoop
    SelectLoop:
        KNSG A 1 A_Raise
        loop
    Fire: //Semi Auto, Spam the mouse button.
        TNT1 A 0 A_JumpIfInventory("BurstToken", 1, "FireBurst")
    FireSemi:
		TNT1 A 0 A_JumpIfInventory("PunisherClip",18, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",17, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",16, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",15, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",14, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",13, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",12, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",11, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",10, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",9, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",8, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",7, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",6, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",5, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",4, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",3, "FireSemiTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",2, "FireSemiTrue")
        TNT1 A 0 A_JumpIfInventory("PunisherClip",1, "FireSemiLast")
        Goto DryFire
	FireSemiTrue:
        TNT1 A 0 A_AlertMonsters
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        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))
        KNSF A 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KNSF B 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.98)
        KNSG C 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KNSG D 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(1.00)
        KNSG E 1 A_WeaponReady
        Goto Ready
    FireSemiLast: //Semi Auto, Spam the mouse button.
        TNT1 A 0 A_AlertMonsters
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        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))
        KNSF A 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KNSF B 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.98)
        KNSG C 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KUSR A 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(1.00)
        KUSR BCD 1 A_WeaponReady(WRF_NOFIRE)
        KUSR D 1
        Goto ReadyEmpty
    FireBurst:
		TNT1 A 0 A_JumpIfInventory("PunisherClip",18, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",17, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",16, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",15, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",14, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",13, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",12, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",11, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",10, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",9, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",8, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",7, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",6, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",5, "FireBurstTrue")
		TNT1 A 0 A_JumpIfInventory("PunisherClip",4, "FireBurstTrue")
        TNT1 A 0 A_JumpIfInventory("PunisherClip",3, "FireBurstLast")
        TNT1 A 0 A_JumpIfInventory("PunisherClip",2, "FireBurst2")
        TNT1 A 0 A_JumpIfInventory("PunisherClip",1, "FireSemiLast")
        Goto DryFire
	FireBurstTrue:
        TNT1 A 0 A_AlertMonsters
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
        TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-1.25, 1.25), 1, 2.5, 5, 0,random(-1.25, 1.25))
        KNSF A 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KNSG C 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
        TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-1.25, 1.25), 1, 2.5, 5, 0,random(-1.25, 1.25))
        KNSF B 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.98)
        KNSG C 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
        TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-1.25, 1.25), 1, 2.5, 5, 0,random(-1.25, 1.25))
        KNSF A 1 Bright A_WeaponReady(WRF_NOFIRE)
        KNSG C 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KNSG D 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(1.00)
        KNSG E 1 A_WeaponReady(WRF_NOFIRE)
        Goto Ready
    FireBurstLast: //Semi Auto, Spam the mouse button.
        TNT1 A 0 A_AlertMonsters
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
        TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-1.25, 1.25), 1, 2.5, 5, 0,random(-1.25, 1.25))
        KNSF A 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KNSG C 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
        TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-1.25, 1.25), 1, 2.5, 5, 0,random(-1.25, 1.25))
        KNSF B 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.98)
        KNSG C 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
        TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-1.25, 1.25), 1, 2.5, 5, 0,random(-1.25, 1.25))
        KNSF A 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KUSR A 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(1.00)
        KUSR BCD 1 A_WeaponReady(WRF_NOFIRE)
        KUSR D 1
        Goto ReadyEmpty
    FireBurst2: //Semi Auto, Spam the mouse button.
        TNT1 A 0 A_AlertMonsters
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
        TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-1.25, 1.25), 1, 2.5, 5, 0,random(-1.25, 1.25))
        KNSF A 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.98)
        KNSG C 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_SetPitch(pitch - 0.6)
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
        TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFire",81,0.66)
        TNT1 A 0 A_PlaySound("Weapons/PunisherFireAdd",82,0.99)
        TNT1 A 0 A_FireCustomMissile("pcasing_spawner",0,0,1,3,0)
        TNT1 A 0 A_FireCustomMissile("p_pistol_tracer", random(-1.25, 1.25), 1, 2.5, 5, 0,random(-1.25, 1.25))
        KNSF B 1 Bright A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(0.99)
        KUSR A 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_ZoomFactor(1.00)
        KUSR BCD 1 A_WeaponReady(WRF_NOFIRE)
        KUSR D 1
        Goto ReadyEmpty
    AltFire: //Does checks, if you have no dummy actors, select slugs
        TNT1 A 0 A_PlaySoundEX("Weapons/FireSelector","Body",0,0)
        TNT1 A 0 A_JumpIfInventory("BurstToken", 1, "AltFire2")
        TNT1 A 0 A_GiveInventory("BurstToken", 1)
        TNT1 A 0 A_SetCrosshair(3)
        KNSG A 10 A_WeaponReady(WRF_NOFIRE)
        Goto Ready
    AltFire2: //Clears dummy actors, to use normal mode
        TNT1 A 0 A_PlaySoundEX("Weapons/FireSelector","Body",0,0)
        TNT1 A 0 A_TakeInventory("BurstToken", 1)
        TNT1 A 0 A_SetCrosshair(2)
        KNSG A 10 A_WeaponReady(WRF_NOFIRE)
        Goto Ready
    DryFire:
        TNT1 A 0 A_PlaySound("Pistol/Empty",199,1.0,0,1) // Play the clicky noise.
        KUSR D 5 A_WeaponReady(WRF_NOFIRE)
        Goto ReadyEmpty
    Reload:
    ReloadBegin:
        TNT1 A 0 A_JumpIfInventory("PunisherClip",18,"Ready")
        TNT1 A 0 A_JumpIfInventory("Pistol_Magazine",1,1)
        Goto DryFire
        KNSR A 1 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_PlaySound("Weapons/PunMagOut",83,1.0,0,1)
        KNSR B 3 A_WeaponReady(WRF_NOFIRE)
        KNSR C 10 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_SpawnItemEx("PunisherClipDrop",0,0,20)
    ReloadWork:
        TNT1 A 0 A_TakeInventory("Pistol_Magazine",1)
        TNT1 A 0 A_GiveInventory("PunisherClip",18)
        TNT1 A 0 A_JumpIfInventory("PunisherClip",18,"ReloadFinish")
        TNT1 A 0 A_JumpIfInventory("Pistol_Magazine",1,"ReloadWork")
    ReloadFinish:
        KNSR D 2 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_PlaySound("Weapons/PunMagIn",84,1.0,0,1)
        KNSR E 2 A_WeaponReady(WRF_NOFIRE)
        KNSR FGHI 1 A_WeaponReady(WRF_NOFIRE)
        KNSR I 10 A_WeaponReady(WRF_NOFIRE)
        TNT1 A 0 A_PlaySound("Weapons/PunMagLock",85,1.0,0,1)
        KNSR JKLMNO 1 A_WeaponReady(WRF_NOFIRE)
        KNSG A 1 A_WeaponReady(WRF_NOFIRE)
        Goto Ready
    }
}

ACTOR BurstToken : Inventory {Inventory.MaxAmount 1}

ACTOR PunisherClip : Ammo
{
Inventory.Amount 0
Inventory.MaxAmount 18
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 18
+IGNORESKILL
}

actor pistol_magazine : Ammo 26102 {
  radius 16
  height 8
  scale 0.2
  ConversationID 506
  inventory.pickupmessage "picked up a Magazine of .50 AE ammo for the pistols"
  inventory.amount 1
  inventory.maxamount 5
  inventory.pickupsound "Weapons/PunMagUp"
  ammo.backpackamount 2
  ammo.backpackmaxamount 10
  states
  {
  Spawn:
    CLP1 K -1
    stop
  }
}

actor pcasing_spawner {
	speed 15
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 1 A_SpawnItemEx("pistol_casing", 0, 10, 3, 1, random(4,5), random(1,2), 0) 
			stop
	}

}

actor pcasing_spawner2 {
	speed 15
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 1 A_SpawnItemEx("pistol_casing", 0, -10, 3, -1, random(-4,-5), random(-1,-2), 0) 
			stop
	}

}

ACTOR Pistol_Casing
{
   Radius 2
   Height 4
   Speed 8
   Scale 0.13
   BounceSound "Weapons/PistolCasing"
   PROJECTILE
   -NOGRAVITY
   +BOUNCEONACTORS
   +BOUNCEONCEILINGS
   +DONTSPLASH
   +CLIENTSIDEONLY
   Gravity 0.75
   BounceType Doom
   BounceCount 6
   BounceFactor 0.6
   DamageType Nope
   States
   {
   Spawn:
      PBCS A 0
      PBCS ABCDEF 1
      Goto Roflcopter
   Roflcopter:
      PBCS A 0 A_Jump(128,1,3,5,7)
      PBCS ABCDEF 1
      Loop
   Death:
      PBCS A 0 A_SpawnItemEx("Pistol_Casing_Liedown")
      stop
   }
}

actor Pistol_Casing_Liedown
{
	-NOGRAVITY
    Scale 0.13
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_Jump(255,"Spawn1","Spawn2","Spawn3")
	  stop
	Spawn1:
	  PBCS F 1
	  Goto Ded
	Spawn2:
	  PBCS C 1
	  Goto Ded
	Spawn3:
	  PBCS E 1
	  Goto Ded
	Ded:
	  "####" "#" 210 A_CheckSight("Fadying")
	  Loop
	Fadying:
	  "####" "#" 1 A_FadeOut(0.1)
	  Wait
   }
}

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

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