actor Raygun : Weapon
{
  Game Doom
  Weapon.SelectionOrder 1500
  weapon.ammotype "RaygunClip"
  weapon.ammouse 1
  weapon.ammogive2 400
  weapon.ammogive1 999
  weapon.ammotype2 "RaygunAmmo"
  Obituary "$OB_MPPISTOL" // "%o was tickled by %k's pea shooter."
  Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED" // "Picked up a pistol."
  +noautofire
  States
  {
  Ready:
	RAYG A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
    RAYG A 0 A_JumpIfInventory("IsReloading",1,"Reload")
	AK47 A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")  
    RAYG A 1 A_WeaponReady
    Loop
  Deselect: 
    RAYG A 0 A_Lower
    RAYG A 0 A_Lower
    RAYG A 1 A_Lower
    loop
  Select:
    RAYG A 0 A_Raise
    RAYG A 0 A_Raise
    RAYG A 1 A_Raise
    loop
  Fire:
    RAYG A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RAYG A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletap")
    RAYG A 0 A_jumpifnoammo("Reload")
	RAYG A 0 A_FireCustomMissile("RaygunShot")
	RAYG A 0 A_playsound("Ray/fire") 
	RAYG BCDEF 3
    RAYG A 0 A_jumpifnoammo("Reload")
	RAYG A 4
	RAYG A 0 A_Refire
    RAYG A 0 A_jumpifnoammo("Reload")
	goto ready
  Fire_Doubletap:
    RAYG A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    RAYG A 0 A_jumpifnoammo("Reload")
	RAYG A 0 A_FireCustomMissile("RaygunShot")
	RAYG A 0 A_playsound("Ray/fire") 
	RAYG BCDEF 2
    RAYG A 0 A_jumpifnoammo("Reload")
	RAYG A 2
	RAYG A 0 A_Refire
    RAYG A 0 A_jumpifnoammo("Reload")
	goto ready
  Reload:
	RAYG A 0 A_TakeInventory("IsReloading",1)
    RAYG A 0 A_jumpifinventory("Speedcola", 1,"Reload_speed")
    RAYG A 0 A_jumpifinventory("RaygunClip", 20,"ready")
	RAYG A 0 A_jumpifinventory("Raygunammo", 1, 1)
	goto ready
    RAYG A 0 A_playsoundEX("ray/clipout","Weapon")
	RAYG A 0 A_playsound("Ray/reload")
	RAYG A 2 offset(0,40)
	RAYG A 2 offset(0,44)
	RAYG A 2 offset(0,48)
	RAYG A 2 offset(0,52)
	RAYG A 2 offset(0,56)
	RAYG A 2 offset(0,60)
	RAYG A 2 offset(0,64)
	RAYG A 20 offset(0,64)
    Goto Reload2
  Reload2:
    AKRE A 0 A_Giveinventory("RaygunClip",1)
	AKRE A 0 A_Takeinventory("Raygunammo",1)
    AKRE A 0 A_jumpifinventory("RaygunClip",20,"reloaddone")
	AKRE A 0 A_jumpifinventory("Raygunammo",1,"reload2")
	goto reloaddone
  Reloaddone:
    RAYG A 0 A_playsoundEX("ray/clipin","Weapon")
	RAYG A 20 offset(0,64)
	RAYG A 2 offset(0,64)
	RAYG A 2 offset(0,60)
	RAYG A 2 offset(0,56)
	RAYG A 2 offset(0,52)
	RAYG A 2 offset(0,48)
	RAYG A 2 offset(0,44)
	RAYG A 2 offset(0,40)
	goto ready
  Reload_speed:
	RAYG A 0 A_TakeInventory("IsReloading",1)
    RAYG A 0 A_jumpifinventory("RaygunClip", 20,"ready")
	RAYG A 0 A_jumpifinventory("Raygunammo", 1, 1)
	goto ready
    RAYG A 0 A_playsoundEX("ray/clipout","Weapon")
	RAYG A 1 offset(0,40)
	RAYG A 1 offset(0,44)
	RAYG A 1 offset(0,48)
	RAYG A 1 offset(0,52)
	RAYG A 1 offset(0,56)
	RAYG A 1 offset(0,60)
	RAYG A 1 offset(0,64)
	RAYG A 10 offset(0,64)
    Goto Reload2_speed
  Reload2_speed:
    AKRE A 0 A_Giveinventory("RaygunClip",1)
	AKRE A 0 A_Takeinventory("Raygunammo",1)
    AKRE A 0 A_jumpifinventory("RaygunClip",20,"reloaddone_speed")
	AKRE A 0 A_jumpifinventory("Raygunammo",1,"reload2_speed")
	goto reloaddone_speed
  Reloaddone_speed:
    RAYG A 0 A_playsoundEX("ray/clipin","Weapon")
	RAYG A 10 offset(0,64)
	RAYG A 1 offset(0,64)
	RAYG A 1 offset(0,60)
	RAYG A 1 offset(0,56)
	RAYG A 1 offset(0,52)
	RAYG A 1 offset(0,48)
	RAYG A 1 offset(0,44)
	RAYG A 1 offset(0,40)
	goto ready
  ThrowGrenade:
     HNDG BCD 1
     HNDG E 1 A_PlaySound("weapons/grenadepin")
     HNDG FGHH 1
     HNDG I 1 A_PlaySound("weapons/grenadethr") 
     HNDG J 0 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
     HNDG J 0 A_PlaySound("weapons/grenadethr")
     HNDG JKLMNOPQ 1
     HNDG Q 0 A_TakeInventory("thrownade")
     Goto Ready
  Useknife:
     KNFG A 0 A_jumpifinventory("Machete",1,"UseMachete")
     KNFG ABC 2
	 KNFG C 0 A_CustomPunch (110,1,0,"KnifePuff")
	 KNFG DEF 2
	 KNFG F 0 A_TakeInventory("Kinfeammo")
	 goto ready
  UseMachete:
     MHT4 ABC 2
	 MHT4 C 0 A_CustomPunch (450,1,0,"Machetepuff")
	 MHT4 DEFG 2
	 MHT4 G 0 A_TakeInventory("Kinfeammo")
	 goto ready
  Flash:
    TNTT A 0
	stop
  Spawn:
    RAYP A -1
	stop
  }
}


actor RaygunClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 20
    ammo.backpackamount 0
    ammo.backpackmaxamount 20
    +IGNORESKILL
}

actor RaygunAmmo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 20
    inventory.maxamount 160
    ammo.backpackamount 20
    ammo.backpackmaxamount 160
    +IGNORESKILL
    inventory.pickupmessage "Got Colt45 rounds!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
}
actor RaygunShot
{
  Radius 6
  Height 8
  Speed 30
  Damage (random(70700,70700))
  DamageType PHD
  Projectile
  SeeSound "Raygun/Fire"
  +BLOODLESSIMPACT
  +NODAMAGETHRUST
  +NOEXTREMEDEATH
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 1 A_SpawnItem ("RaygunTrail")
    loop
  Death:
    TNT1 A 0 A_Explode(Random(500,500),32)
    TNT1 A 1 A_SpawnItemEx("RaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("RaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("RaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("RaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("RaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("RaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    stop
  }
}

Actor RaygunSplash
{
   Radius 4
   Height 4
   Speed 0
   Gravity 0.5
   Scale 0.25
   Translation "0:255=112:120"
   
   PROJECTILE
   -NOGRAVITY
   +NOBLOCKMAP
   +FORCEXYBILLBOARD
   States
   {
   Spawn:
      DTEL JKLM 4 bright
      Goto Death
   Death:
      DTEL M 0
      Stop
   }
}

actor RaygunTrail
{
  Radius 2
  Height 2
  Renderstyle Add
  Scale 0.6
  +NOINTERACTION
  +CLIENTSIDEONLY
  
  States
  {
  Spawn:
    RAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("RaygunTrail2")
    stop
  }
}

actor RaygunTrail2 : RaygunTrail
{
  Scale 0.5
  
  States
  {
  Spawn:
    RAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("RaygunTrail3")
    stop
  }
}

actor RaygunTrail3 : RaygunTrail
{
  Scale 0.4
  
  States
  {
  Spawn:
    RAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("RaygunTrail4")
    stop
  }
}

actor RaygunTrail4 : RaygunTrail
{
  Scale 0.3
  
  States
  {
  Spawn:
    RAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("RaygunTrail5")
    stop
  }
}

actor RaygunTrail5 : RaygunTrail
{
  Scale 0.2
  
  States
  {
  Spawn:
    RAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("RaygunTrail6")
    stop
  }
}

actor RaygunTrail6 : RaygunTrail
{
  Scale 0.1
  
  States
  {
  Spawn:
    RAYL A 3 bright
    stop
  }
}

actor PAPRaygun : Weapon
{
  Game Doom
  Weapon.SelectionOrder 1900
  weapon.ammotype "PAPRaygunClip"
  weapon.ammouse 1
  weapon.ammogive2 200
  weapon.ammogive1 999
  weapon.ammotype2 "PAPRaygunAmmo"
  Obituary "$OB_MPPISTOL" // "%o was tickled by %k's pea shooter."
  Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED" // "Picked up a pistol."
  +noautofire
  States
  {
  Ready:
	PAYG A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
    PAYG A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
	AK47 A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")
    PAYG A 1 A_WeaponReady
    Loop
  Deselect: 
    RAYG A 0 A_Lower
    RAYG A 0 A_Lower
    RAYG A 1 A_Lower
    loop
  Select:
    RAYG A 0 A_Raise
    RAYG A 0 A_Raise
    RAYG A 1 A_Raise
    loop
  Useknife:
     KNFG A 0 A_jumpifinventory("Machete",1,"UseMachete")
     KNFG ABC 2
	 KNFG C 0 A_CustomPunch (110,1,0,"KnifePuff")
	 KNFG DEF 2
	 KNFG F 0 A_TakeInventory("Kinfeammo")
	 goto ready
  UseMachete:
     MHT4 ABC 2
	 MHT4 C 0 A_CustomPunch (450,1,0,"Machetepuff")
	 MHT4 DEFG 2
	 MHT4 G 0 A_TakeInventory("Kinfeammo")
	 goto ready
  Fire:
    PAYG A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    PAYG A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletap")
    PAYG A 0 A_jumpifnoammo("Reload")
	PAYG A 0 A_FireCustomMissile("PAPRaygunShot")
	PAYG A 0 A_playsound("Ray/fire") 
	PAYG BCDEF 3
    PAYG A 0 A_jumpifnoammo("Reload")
	PAYG A 4
	PAYG A 0 A_Refire
    PAYG A 0 A_jumpifnoammo("Reload")
	goto ready
  Fire_Doubletap:
    PAYG A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    PAYG A 0 A_jumpifnoammo("Reload")
	PAYG A 0 A_FireCustomMissile("PAPRaygunShot")
	PAYG A 0 A_playsound("Ray/fire") 
	PAYG BCDEF 2
    PAYG A 0 A_jumpifnoammo("Reload")
	PAYG A 2
	PAYG A 0 A_Refire
    PAYG A 0 A_jumpifnoammo("Reload")
	goto ready
  Reload:
	PAYG A 0 A_TakeInventory("IsReloading",1)
    PAYG A 0 A_jumpifinventory("Speedcola", 1,"Reload_speed")
    PAYG A 0 A_jumpifinventory("PAPRaygunClip", 40,"ready")
	PAYG A 0 A_jumpifinventory("PAPRaygunammo", 1, 1)
	goto ready
    PAYG A 0 A_playsoundEX("ray/clipout","Weapon")
	PAYG A 2 offset(0,40)
	PAYG A 2 offset(0,44)
	PAYG A 2 offset(0,48)
	PAYG A 2 offset(0,52)
	PAYG A 2 offset(0,56)
	PAYG A 2 offset(0,60)
	PAYG A 2 offset(0,64)
	PAYG A 20 offset(0,64)
    Goto Reload2
  Reload2:
    AKRE A 0 A_Giveinventory("PAPRaygunClip",1)
	AKRE A 0 A_Takeinventory("PAPRaygunammo",1)
    AKRE A 0 A_jumpifinventory("PAPRaygunClip",40,"reloaddone")
	AKRE A 0 A_jumpifinventory("PAPRaygunammo",1,"reload2")
	goto reloaddone
  Reloaddone:
    PAYG A 0 A_playsoundEX("ray/clipin","Weapon")
	PAYG A 20 offset(0,64)
	PAYG A 2 offset(0,64)
	PAYG A 2 offset(0,60)
	PAYG A 2 offset(0,56)
	PAYG A 2 offset(0,52)
	PAYG A 2 offset(0,48)
	PAYG A 2 offset(0,44)
	PAYG A 2 offset(0,40)
	goto ready
  Reload_speed:
	PAYG A 0 A_TakeInventory("IsReloading",1)
    PAYG A 0 A_jumpifinventory("PAPRaygunClip", 40,"ready")
	PAYG A 0 A_jumpifinventory("PAPRaygunammo", 1, 1)
	goto ready
    PAYG A 0 A_playsoundEX("ray/clipout","Weapon")
	PAYG A 1 offset(0,40)
	PAYG A 1 offset(0,44)
	PAYG A 1 offset(0,48)
	PAYG A 1 offset(0,52)
	PAYG A 1 offset(0,56)
	PAYG A 1 offset(0,60)
	PAYG A 1 offset(0,64)
	PAYG A 10 offset(0,64)
    Goto Reload2_speed
  Reload2_speed:
    AKRE A 0 A_Giveinventory("PAPRaygunClip",1)
	AKRE A 0 A_Takeinventory("PAPRaygunammo",1)
    AKRE A 0 A_jumpifinventory("PAPRaygunClip",40,"reloaddone_speed")
	AKRE A 0 A_jumpifinventory("PAPRaygunammo",1,"reload2_speed")
	goto reloaddone_speed
  Reloaddone_speed:
    PAYG A 0 A_playsoundEX("ray/clipin","Weapon")
	PAYG A 10 offset(0,64)
	PAYG A 1 offset(0,64)
	PAYG A 1 offset(0,60)
	PAYG A 1 offset(0,56)
	PAYG A 1 offset(0,52)
	PAYG A 1 offset(0,48)
	PAYG A 1 offset(0,44)
	PAYG A 1 offset(0,40)
	goto ready
  ThrowGrenade:
     HNDG BCD 1
     HNDG E 1 A_PlaySound("weapons/grenadepin")
     HNDG FGHH 1
     HNDG I 1 A_PlaySound("weapons/grenadethr") 
     HNDG J 0 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
     HNDG J 0 A_PlaySound("weapons/grenadethr")
     HNDG JKLMNOPQ 1
     HNDG Q 0 A_TakeInventory("thrownade")
     Goto Ready
  Flash:
    TNTT A 0
	stop
  Spawn:
    RAYP A -1
	stop
  }
}


actor PAPRaygunClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 40
    ammo.backpackamount 0
    ammo.backpackmaxamount 40
    +IGNORESKILL
}

actor PAPRaygunAmmo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 40
    inventory.maxamount 200
    ammo.backpackamount 40
    ammo.backpackmaxamount 200
    +IGNORESKILL
    inventory.pickupmessage "Got Colt45 rounds!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
}
actor PAPRaygunShot
{
  Radius 6
  Height 8
  Speed 25
  Damage (random(82400,82400))
  DamageType PHD
  Projectile
  SeeSound "Raygun/Fire"
  +BLOODLESSIMPACT
  +NODAMAGETHRUST
  +NOEXTREMEDEATH
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 1 A_SpawnItem ("PAPRaygunTrail")
    loop
  Death:
    TNT1 A 0 A_Explode(Random(1000,100),32)
    TNT1 A 1 A_SpawnItemEx("PAPRaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("PAPRaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("PAPRaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("PAPRaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("PAPRaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    TNT1 A 1 A_SpawnItemEx("PAPRaygunSplash",0,0,0,random(-3,3),random(-3,3),random(0,3),SXF_CLIENTSIDE)
    stop
  }
}

Actor PAPRaygunSplash
{
   Radius 4
   Height 4
   Speed 0
   Gravity 0.5
   Scale 0.25
   Translation "0:255=112:60"
   
   PROJECTILE
   -NOGRAVITY
   +NOBLOCKMAP
   +FORCEXYBILLBOARD
   States
   {
   Spawn:
      DTEL JKLM 4 bright
      Goto Death
   Death:
      DTEL M 0
      Stop
   }
}

actor PAPRaygunTrail
{
  Radius 2
  Height 2
  Renderstyle Add
  Scale 0.6
  +NOINTERACTION
  +CLIENTSIDEONLY
  
  States
  {
  Spawn:
    PAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("PAPRaygunTrail2")
    stop
  }
}

actor PAPRaygunTrail2 : PAPRaygunTrail
{
  Scale 0.5
  
  States
  {
  Spawn:
    PAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("PAPRaygunTrail3")
    stop
  }
}

actor PAPRaygunTrail3 : PAPRaygunTrail
{
  Scale 0.4
  
  States
  {
  Spawn:
    PAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("PAPRaygunTrail4")
    stop
  }
}

actor PAPRaygunTrail4 : PAPRaygunTrail
{
  Scale 0.3
  
  States
  {
  Spawn:
    PAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("PAPRaygunTrail5")
    stop
  }
}

actor PAPRaygunTrail5 : PAPRaygunTrail
{
  Scale 0.2
  
  States
  {
  Spawn:
    PAYL A 3 bright
    TNT1 A 1 bright A_SpawnItem ("PAPRaygunTrail6")
    stop
  }
}

actor PAPRaygunTrail6 : PAPRaygunTrail
{
  Scale 0.1
  
  States
  {
  Spawn:
    PAYL A 3 bright
    stop
  }
}
