/*
CREDITS:
Sprites - Marty Kirra
Pickup by me.

Sounds:
Up Sound - Lucas Arts, Raven (JK2: Jedi Outcast)
Fire sound - ?
Pumping - ID (ET: Quake Wars)
Hammerspace Casing charge, launch - Epic Games (UT99)
*/

ACTOR Erasus : Weapon 24502
{
   //$Category Weapons
   //$Title Erasus
   //$Sprite ERAGX0
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "Fraked out by punch-loading ''Erasus'' anti-tank shotgun! Lead is my bread, explosions replaces emotions! (3)"
   Obituary "%o was blasted with explosive lead by %k's ''Erasus''."
   Weapon.UpSound "Weapons/ErasusUp"
   Weapon.SelectionOrder 6
   Weapon.AmmoType "ErasusAmmo"
   Weapon.AmmoGive 10
   Weapon.AmmoUse 2
   Weapon.AmmoType2 "ErasusCounter"
   Weapon.AmmoGive2 0
   Weapon.AmmoUse2 1
   Weapon.Kickback 35
   Weapon.SlotNumber 3
   Scale 0.9
   //+WEAPON.CHEATNOTWEAPON
   //+NOAUTOFIRE
   +NOALERT
   +ALT_AMMO_OPTIONAL
   +NOAUTOFIRE
   States
   {
   Spawn:
      ERAG X -1
      Stop
   Ready:
      ERAG A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
      Loop
   ReadyFull:
      ERAG A 2
      Goto Ready
   Deselect:
      ERAG A 0 A_StopSound(6)
      ERAG A 0 A_ZoomFactor(1)
      ERAG A 0 A_Lower
      ERAG A 1 A_Lower
      Loop
   Select:
      ERAG A 0 A_Raise
      ERAG A 1 A_Raise
      Loop
   Fire:
      ERAF A 0 A_JumpIfInventory("ErasusTrigger",1,"LoadStop")
      ERAF A 0 A_GunFlash
      ERAF A 0 A_AlertMonsters
      ERAF A 0 A_Recoil(5)
      ERAF A 0 A_ZoomFactor(0.98)
      ERAF A 0 A_GiveInventory("ErasusCasing",2)

      ERAF A 0 A_PlayWeaponSound("Weapons/ErasusFire")
      ERAF A 0 A_PlaySound("Weapons/ErasusAmbient",5)
      ERAF A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadFire")
      ERAF A 0 A_FireBullets(14.5, 2.75, 30, 18, "ErasusPuff")
      Goto Refraction
   QuadFire:
      ERAF A 0 A_SetBlend("Blue",0.05,12)
      ERAF A 0 A_PlaySound("Weapons/QuadShot",0)
      ERAF A 0 A_FireBullets(14.5, 2.75, 30, 36, "QuadPuff")
      Goto Refraction
   Refraction:
      ERAF AB 1 Bright ACS_Execute(851,0,20+random(4,-4),10+random(2,-2),0)
      ERAF C 0 Bright A_ZoomFactor(1)
      ERAF C 1 Bright ACS_Execute(851,0,20+random(4,-4),10+random(2,-2),0)
      ERAG B 1
      ERAR A 0 A_PlaySound("Weapons/ErasusPump",6)
      ERAR ABCDE 1 ACS_Execute(851,0,-12+random(4,-4),-6+random(2,-2),0)
      ERAR FFEDCBA 1
      ERAG C 1
      ERAG A 5
      ERAG A 0 A_ReFire
      Goto Ready
   Reload:
      ERAG A 0 A_JumpIfInventory ("ErasusCasing", 0, "HellNope")
      ERAG A 0 A_JumpIfInventory ("ErasusCounter", 1, 2)
      ERAG A 0 A_Print("There are no casings to unload.")
	  Goto Ready
      ERAG A 0 A_Print("Unloading casings...")
   ReloadLoop:
      ERAG A 0 A_JumpIfInventory ("ErasusCounter", 1, 1)
	  Goto ReturnShells
      ERAG A 0 A_JumpIfInventory ("ErasusCasing", 0 ,"ReturnShells")
      ERAG A 0 A_TakeInventory("ErasusCounter",1)
      ERAG A 0 A_GiveInventory("ErasusCasing",1)
	  Goto ReloadLoop
   ReturnShells:
      ERAR A 0 A_PlaySound("Weapons/ErasusPump",6)
      ERAR ABCDE 1
      ERAR FFEDCBA 1
      ERAG C 1
      ERAG A 10
      Goto Ready
   AltFire:
      ERAG A 0 A_JumpIfInventory ("ErasusCounter", 0, "Unload")
      ERAG A 0 A_JumpIfInventory ("ErasusCasing", 2, 1)
      goto Ready
   PoweringAnimation:
      ERA1 A 0 A_PlaySound("Weapons/ErasusHammerStart",6)
      CSGF A 0 A_GiveInventory("ErasusTrigger")
      ERAG A 2 A_Quake(3,16,0,6,none)
      ERA1 A 0 A_PlaySound("Weapons/ErasusPump",5)
      ERAR ABCDE 1
      ERAR FFEDCBA 1
      ERAG A 2
   Powering:
      ERA1 A 0 A_PlaySound("Weapons/ErasusHammerLoop",6,1.0,1)
      ERAG A 0 A_JumpIfInventory ("ErasusCounter", 0, "LoadStop")
      ERAG A 0 A_JumpIfInventory ("ErasusCasing", 2, 1)
      goto Unload
      ERAG A 0 A_GiveInventory ("ErasusCounter", 2)
      ERAG A 0 A_TakeInventory ("ErasusCasing", 2)
      ERAG A 0 A_Quake(5,2,0,6,none)
      ERAG A 2 A_WeaponReady(WRF_NOBOB|WRF_NOSECONDARY)
      ERAG A 0 A_ReFire("Powering")
   Unload:
      ERAG A 0 A_JumpIfInventory("QuadUpgrade", 1, "QuadUnload")
      ERA1 A 0 A_PlaySound("Weapons/ErasusHammerFire",6)
   Derp:
      ERAG A 0 A_JumpIfInventory("ErasusCounter", 2, 1)
      goto UnloadAnimation
      ERAG A 0 A_TakeInventory ("ErasusCounter", 2)
      ERAG AA 0 A_FireCustomMissile ("ShellProjectile", frandom(-12, 12), 0, 8, -3, 0, random(-5, 5))
      loop
   QuadUnload:
      ERAF A 0 A_SetBlend("Blue",0.1,16)
      ERAF A 0 A_PlaySound("Weapons/QuadShot",0)
      ERA1 A 0 A_PlaySound("Weapons/ErasusHammerFire",6)
   Twerp:
      ERAG A 0 A_JumpIfInventory("ErasusCounter", 2, 1)
      goto UnloadAnimation
      ERAG A 0 A_TakeInventory ("ErasusCounter", 2)
      ERAG AA 0 A_FireCustomMissile ("QuadShellProjectile", frandom(-12, 12), 0, 8, -3, 0, random(-5, 5))
      Loop
   UnloadAnimation:
      ERAG A 2 A_Quake(8,6,0,12,none)
      CSGF A 0 A_TakeInventory("ErasusTrigger")
      ER2F A 0 A_AlertMonsters
      ER2F A 0 A_Recoil(3)
      ER2F A 0 A_ZoomFactor(0.999)
      ER2F A 0 A_PlayWeaponSound("Weapons/ErasusAltFire")

      ER2F ABC 1 ACS_Execute(851,0,15+random(4,-4),3+random(2,-2),0)
      ER2F C 0 Bright A_ZoomFactor(1)
      ER2F CBA 1 ACS_Execute(851,0,-15+random(4,-4),-3+random(2,-2),0)
      ERAG A 10
      Goto Ready
   LoadStop:
      ERA1 A 0 A_PlaySound("Weapons/ErasusHammerStop",6)
      CSGF A 0 A_TakeInventory("ErasusTrigger")
      ERAG A 2 A_Quake(3,16,0,6,none)
      ERA1 A 0 A_PlaySound("Weapons/ErasusPump",5)
      ERAR ABCDE 1
      ERAR FFEDCBA 1
      ERAG A 2
      Goto Ready
   HellNope:
      ERAG A 0 A_Print("Unable to start operation; shells are at full capacity.")
      ERAG A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	  Goto Ready
   Flash:
       TNT1 A 2 A_Light2
       TNT1 A 1 A_Light1
       TNT1 A 0 A_Light0
       Stop
   }
}

actor ErasusCounter : Ammo
{
	Inventory.Amount 1
	Inventory.MaxAmount 400
	ammo.backpackamount 0
	ammo.backpackmaxamount 400
	Inventory.Icon "ERAGX0"
}

actor ErasusTrigger : Inventory
{
	Inventory.MaxAmount 1
}

ACTOR ErasusPuff : BulletPuff
{
  +PUFFONACTORS
  Renderstyle Add
  Alpha 0.75
  Scale 1.1
  states
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx("ErasusSmokeSpawner",0.2*random(6,-6),0.3*random(14,-14),0.3*random(14,-14),0,0,0,0,128,0)
    TNT1 A 0 A_SpawnItemEx("ErasusExp",0.2*random(6,-6),0.3*random(14,-14),0.3*random(14,-14),0,0,0,0,128,0)
    TNT1 BC 3
    TNT1 D 2
    Stop
  }
}

ACTOR ErasusExp
{
  +NOINTERACTION
  +NOGRAVITY
  +CLIENTSIDEONLY
  Renderstyle Add
  Alpha 0.75
  Scale 1.1
  states
  {
  Spawn:
    TNT1 A 1
    TNT1 A 0 A_Jump(255,"Exp1","Exp2","Exp3","Exp4","Exp5")
    stop
  Exp1:
    EXP6 ABCDEFGH 1 Bright //A_SetScale(ScaleX -0.01, ScaleY -0.01)
    Goto Death
  Exp2:
    EXP7 ABCDEFGH 1 Bright //A_SetScale(ScaleX -0.01, ScaleY -0.01)
    Goto Death
  Exp3:
    EXP8 ABCDEFGH 1 Bright //A_SetScale(ScaleX -0.01, ScaleY -0.01)
    Goto Death
  Exp4:
    EXP9 ABCDEFGH 1 Bright //A_SetScale(ScaleX -0.01, ScaleY -0.01)
    Goto Death
  Exp5:
    EXP0 ABCDEFGH 1 Bright //A_SetScale(ScaleX -0.01, ScaleY -0.01)
    Goto Death
  Death:
    TNT1 A 1
    stop
  }
}

ACTOR QuadPuff : ErasusPuff
{
  states
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx("QuadSmokeSpawner",0.2*random(6,-6),0.3*random(14,-14),0.3*random(14,-14),0,0,0,0,128,0)
    TNT1 A 0 A_SpawnItemEx("ErasusExp",0.2*random(6,-6),0.3*random(14,-14),0.3*random(14,-14),0,0,0,0,128,0)
    TNT1 BC 3
    TNT1 D 2
    Stop
  }
}

ACTOR ErasusSmokeSpawner
{
 +NOINTERACTION
 +NOGRAVITY
 states
 {
 Spawn:
 TNT1 AAA 4 A_SpawnItemEx("ErasusSmoke",0,0,0,0.01*random(10,15),0.01*random(10,15),0.01*random(10,15),random(0,359),128,0)
 Stop
 }
}

ACTOR ErasusSmoke
{
 +NOINTERACTION
 +NOGRAVITY
 +CLIENTSIDEONLY
 Renderstyle Normal
 Scale 0.35
 Alpha 0.28
 states
 {
 Spawn:
 TNT1 A 0
 TNT1 A 0 A_FadeOut(0.025)
 TNT1 A 1 A_Jump(255,"SmokeA","SmokeB","SmokeC","SmokeD","SmokeE","SmokeF","SmokeG","SmokeH")
 SmokeA:
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 A_FadeOut(0.025)
 SMKE A 2
 Loop
 SmokeB:
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 A_FadeOut(0.025)
 SMKE B 2
 Loop
 SmokeC:
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 A_FadeOut(0.025)
 SMKE C 2
 Loop
 SmokeD:
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 A_FadeOut(0.025)
 SMKE D 2
 Loop
 SmokeE:
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 A_FadeOut(0.025)
 SMKE E 2
 Loop
 SmokeF:
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 A_FadeOut(0.025)
 SMKE F 2
 Loop
 SmokeG:
 SMKE A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 SMKE G 2 A_FadeOut(0.025)
 Loop
 SmokeH:
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 SMKE A 0 A_Jump(164,2)
 SMKE A 0 A_FadeOut(0.025)
 SMKE H 2
 Loop
 }
}

ACTOR QuadSmokeSpawner
{
 +NOINTERACTION
 +CLIENTSIDEONLY
 +NOGRAVITY
 states
 {
 Spawn:
 TNT1 AAAA 3 A_SpawnItemEx("QuadSmoke",0,0,0,0.01*random(10,15),0.01*random(10,15),0.01*random(10,15),random(0,359),128,0)
 Stop
 }
}

ACTOR QuadSmoke : ErasusSmoke
{
 states
 {
 Spawn:
 TNT1 A 0
 TNT1 A 0 A_FadeOut(0.025)
 TNT1 A 1 A_Jump(255,"SmokeA","SmokeB","SmokeC","SmokeD","SmokeE","SmokeF","SmokeG","SmokeH")
 SmokeA:
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 A_FadeOut(0.025)
 ISMK A 2
 Loop
 SmokeB:
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 A_FadeOut(0.025)
 ISMK B 2
 Loop
 SmokeC:
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 A_FadeOut(0.025)
 ISMK C 2
 Loop
 SmokeD:
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 A_FadeOut(0.025)
 ISMK D 2
 Loop
 SmokeE:
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 A_FadeOut(0.025)
 ISMK E 2
 Loop
 SmokeF:
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 A_FadeOut(0.025)
 ISMK F 2
 Loop
 SmokeG:
 ISMK A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 ISMK G 2 A_FadeOut(0.025)
 Loop
 SmokeH:
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 //A_SetScale(ScaleX -0.0075, ScaleY -0.0075)
 ISMK A 0 A_Jump(164,2)
 ISMK A 0 A_FadeOut(0.025)
 ISMK H 2
 Loop
 }
}

//Alt-Fire

ACTOR ShellProjectile
{
   Obituary "%o was humiliated by %k's HE shell casing galore."
   Radius 6
   Height 10
   Speed 30
   Damage 10
   Scale 0.6
   BounceSound "Weapons/ErasusBounce"
   PROJECTILE
   +THRUGHOST
   -NOGRAVITY
   +BOUNCEONACTORS
   +BOUNCEONCEILINGS
   Gravity 0.75
   BounceType Doom
   BounceCount 7
   BounceFactor 0.7
   DamageType Nope
   States
   {
   Spawn:
      SHLP A 0
      SHLP A 0 A_ChangeVelocity (frandom(-8, 8), frandom(-8, 8), frandom(-8, 8), 0)
      SHLP A 0 ThrustThingZ(0, 20, 0, 1)
      SHLP ABCDEFGH 1
      Goto Roflcopter
   Roflcopter:
      SHLP A 0 A_Jump(128,1,3,5,7)
      SHLP ABCDEFGH 1 //A_ChangeVelocity (frandom(-1.6, 1.6), frandom(-1.6, 1.6), frandom(-0.9, 0.9), 0) now in O.G.U.R.
      Loop
   Death:
      TNT1 A 0 A_SpawnItemEx("ErasusCasing")
      stop
   }
}

ACTOR QuadShellProjectile : ShellProjectile
{
   Damage 20
   States
   {
   Spawn:
      QHLP A 0
      QHLP A 0 A_ChangeVelocity (frandom(-8, 8), frandom(-8, 8), frandom(-8, 8), 0)
      QHLP A 0 ThrustThingZ(0, 20, 0, 1)
      QHLP ABCDEFGH 1
      Goto Roflcopter
   Roflcopter:
      QHLP A 0 A_Jump(128,1,3,5,7)
      QHLP ABCDEFGH 1 //A_ChangeVelocity (frandom(-1.6, 1.6), frandom(-1.6, 1.6), frandom(-0.9, 0.9), 0) now in O.G.U.R.
      Loop
   Death:
      TNT1 A 0 A_SpawnItemEx("ErasusCasing",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS)
      stop
   }
}