/*
CREDITS:
Sprites - LucasArts (Star Wars: Dark Forces)
Pickup - Made by me from mashup of Scuba Steve's bits (Action Doom)

Fire - Running with Scissors (Postal)
Add Fire - ?
Fire2, Shell Launch, Nope, Bounce - Epic Games, People can Fly (Bulletstorm)
Music - Tchaikovsky, Overture 1812
*/

ACTOR Pantokrator : DoomWeapon 24517
{
   //$Category Weapons
   //$Title Pantokrator
   //$Sprite PANTX0
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "Omfg'ed by the sight of ''Pantokrator'' cannon shotgun! If there's thing that spews more HE shells at once than... well, there isn't. (3)"
   Obituary "%o couldn't deny %k's worldview. Destructionism goes pretty well with ''Pantokrator''."
   Weapon.UpSound "Weapons/PantokratorUp"
   Weapon.SelectionOrder 6
   Weapon.AmmoType "ErasusAmmo"
   Weapon.AmmoGive 30
   Weapon.AmmoUse 10
   Weapon.Kickback 55
   Weapon.SlotNumber 3
   Scale 1.1
   +NOAUTOFIRE
   +NOALERT
   States
   {
   Spawn:
      PANT X -1
      Loop
   Ready:
      PANT A 1 A_WeaponReady
      Loop
   Deselect:
      PANT A 0 A_ZoomFactor(1)
      PANT A 1 A_Lower
      PANT A 0 A_Lower
      Loop
   Select:
      PANT A 1 A_Raise
      PANT A 0 A_Raise
      Loop
   Fire:
      PANT A 0 A_GunFlash
      PANT A 0 A_AlertMonsters
      PANT A 0 A_Recoil(9)
      PANT A 0 A_GiveInventory("ErasusCasing",10)
      PANT A 0 A_ZoomFactor(0.7)

      PANT B 0 A_PlaySound("Weapons/PantokratorAddFire",1,0.6)
      PANT B 0 A_PlaySound("Weapons/PantokratorFire",5,0.9)
      PANT B 0 A_PlaySound("Weapons/Pantokrator2Fire",6,0.7)
      PANT B 0 A_JumpIfInventory("QuadUpgrade",1,2)
      PANT B 0 A_FireBullets(21, 4.25, 150, 18, "ErasusPuff")
      Goto Gesundheit
      PANT B 0 A_SetBlend("Blue",0.175,18)
      PANT B 0 A_PlaySoundEx("Weapons/QuadShot","Auto")
      PANT B 0 A_FireBullets(21, 4.25, 150, 36, "QuadPuff")
   Gesundheit:
      PANT B 1 Bright ACS_Execute(851,0,45+random(20,5),25+random(5,-5),0)
      PANT B 0 A_ZoomFactor(0.8)
      PANT B 1 Bright ACS_Execute(851,0,75+random(20,5),45+random(5,-5),0)
      PANT B 0 A_ZoomFactor(0.9)
      PANT C 1 Bright ACS_Execute(851,0,65+random(20,5),35+random(5,-5),0)
      PANT C 1 A_ZoomFactor(0.925)
      PANT D 1 A_ZoomFactor(0.95)
      PANT D 1 A_ZoomFactor(0.975)
      PANT A 1 A_ZoomFactor(1)
      PANT A 2
      PANT A 9 A_ReFire
      Goto Ready
   AltFire:
      PANT A 0 A_JumpIfInventory("ErasusCasing",200,1)
      Goto Nope
      PANT A 0 A_JumpIfInventory("MegaShellOut",1,"Nope")
      PANT A 0 A_GiveInventory("MegaShellOut",1)
      PANT A 0 A_GunFlash
      PANT A 0 A_AlertMonsters
      PANT A 0 A_Recoil(18)
      PANT A 0 A_ZoomFactor(0.7)
      PANT A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadAltFire")
   BollocksOfSteel:
      PANT B 0 A_PlaySound("Weapons/PantokratorAddFire",1,0.6)
      PANT B 0 A_PlaySound("Weapons/MegaShellFire",5,0.9)
      PANT B 0 A_FireCustomMissile("MegaShell",0,0,10)
      PANT B 0 A_TakeInventory("ErasusCasing",200)
      Goto Gesundheit
   QuadAltFire:
      PANT B 0 A_SetBlend("Blue",0.225,24)
      PANT B 0 A_PlaySoundEx("Weapons/QuadShot","Auto")
   Goto BollocksOfSteel
   Nope:
      PANT A 0 A_PlaySoundEx("Weapons/MegaShellNope","SoundSlot6")
      PANT A 20 A_WeaponReady(WRF_NOSECONDARY)
      Goto Ready
   Flash:
       TNT1 A 4 Bright A_Light2
       TNT1 A 2 Bright A_Light1
       Goto LightDone
   }
}

actor MegaShellOut : Inventory
{
  Inventory.MaxAmount 1
}

ACTOR MegaShell
{
   Obituary "%o was killed by direct impact with %k's ''Mega Shell 1812''!"
   Radius 18
   Height 20
   Speed 20
   Damage 120
   Scale 2.5
   BounceSound "Weapons/MegaShellBounce"
   PROJECTILE
   +THRUGHOST
   -NOGRAVITY
   +BOUNCEONACTORS
   +CANBOUNCEWATER
   Gravity 0.35
   BounceType Hexen
   BounceFactor 1
   ReactionTime 29
   States
   {
   Spawn:
      SHLP A 0
      SHLP A 0 ACS_Execute(705)
      SHLP A 0 A_PlaySoundEx("Weapons/OvertureLoop","SoundSlot5",1,2)
      SHLP A 0 ThrustThingZ(0, 25, 0, 1)
   Roflcopter:
      SHLP A 0
      SHLP A 0 A_Countdown
	  SHLP A 0 A_JumpIfInTargetInventory("QuadUpgrade",1,"QRoflcopter")
      SHLP AAABBBCCCDDDEEEFFFGGGHHH 1 A_SpawnItemEx("ShellOverture",0,0,0,0,0,0,0,0,0)
      Loop
   QRoflcopter:
      QHLP AAABBBCCCDDDEEEFFFGGGHHH 1 A_SpawnItemEx("ShellOverture",0,0,0,0,0,0,0,0,0)
	  Goto Roflcopter
   Death:
      TNT1 A 3 A_SpawnItemEx("TheEndCasing",0,0,0,velx,vely,velz,0,SXF_ABSOLUTEMOMENTUM|SXF_TRANSFERPITCH|SXF_TRANSFERPOINTERS,0)
      TNT1 A 228 A_PlaySoundEx("Weapons/OvertureEnd","SoundSlot5",0,2)
      TNT1 A 1 ACS_Execute(706)
      stop
   }
}

ACTOR TheEndCasing
{
   Obituary "%o was killed by direct impact with %k's ''Mega Shell 1812''!"
   Radius 18
   Height 20
   Speed 20
   Damage 120
   Scale 2.5
   PROJECTILE
   +THRUGHOST
   -NOGRAVITY
   +EXPLODEONWATER
   Gravity 0.35
   States
   {
   Spawn:
      SHLP A 0
      SHLP A 0 A_JumpIfInventory("QuadUpgrade",1,"QRoflcopter")
   Roflcopter:
      SHLP AAABBBCCCDDDEEEFFFGGGHHH 1 A_SpawnItemEx("ShellOverture",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
      Loop
   QRoflcopter:
      QHLP AAABBBCCCDDDEEEFFFGGGHHH 1 A_SpawnItemEx("ShellOverture",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
      Loop
   Death:
      TNT1 A 0 A_SpawnItemEx("MegaCasing",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
      stop
   }
}

ACTOR ShellOverture
{
   +NOINTERACTION
   +NOGRAVITY
   States
   {
      Spawn:
      TNT1 A 0
      TNT1 A 0 A_JumpIfInTargetInventory("QuadUpgrade",1,"QSpawn")
      TNT1 AA 0 A_SpawnItemEx("NoPickShellProjectile",random(5,-5),random(5,-5),random(5,-5),random(25,30),random(25,30),random(-15,20),random(0,359),SXF_TRANSFERPOINTERS,0)
      TNT1 A 0 A_SpawnItemEx("ShellProjectile",random(5,-5),random(5,-5),random(5,-5),random(25,30),random(25,30),random(-15,20),random(0,359),SXF_TRANSFERPOINTERS,0)
      stop
	  QSpawn:
      TNT1 AA 0 A_SpawnItemEx("QuadNoPickShellProjectile",random(5,-5),random(5,-5),random(5,-5),random(25,30),random(25,30),random(-15,20),random(0,359),SXF_TRANSFERPOINTERS,0)
      TNT1 A 0 A_SpawnItemEx("QuadShellProjectile",random(5,-5),random(5,-5),random(5,-5),random(25,30),random(25,30),random(-15,20),random(0,359),SXF_TRANSFERPOINTERS,0)
      stop
   }
}

actor MegaCasing
{
	Radius 25
	Height 30
	Scale 2.5
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_JumpIfInTargetInventory("QuadUpgrade",1,"QSpawn")
	  TNT1 A 0 A_Jump(255,"Spawn1","Spawn2","Spawn3","Spawn4","Spawn5","Spawn6")
	  stop
	Spawn1:
	  SHLP I 236
	  SHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  SHLP I 72
	  SHLP I 1 A_FadeOut(0.05)
	  Wait
	Spawn2:
	  SHLP J 236
	  SHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  SHLP J 72
	  SHLP J 1 A_FadeOut(0.05)
	  Wait
	Spawn3:
	  SHLP K 236
	  SHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  SHLP K 72
	  SHLP K 1 A_FadeOut(0.05)
	  Wait
	Spawn4:
	  SHLP L 236
	  SHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  SHLP L 72
	  SHLP L 1 A_FadeOut(0.05)
	  Wait
	Spawn5:
	  SHLP M 236
	  SHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  SHLP M 72
	  SHLP M 1 A_FadeOut(0.05)
	  Wait
	Spawn6:
	  SHLP N 236
	  SHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  SHLP N 72
	  SHLP N 1 A_FadeOut(0.05)
	  Wait
	 
	QSpawn:
	  TNT1 A 0 A_Jump(255,"QSpawn1","QSpawn2","QSpawn3","QSpawn4","QSpawn5","QSpawn6")
	  stop
	QSpawn1:
	  QHLP I 236
	  QHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  QHLP I 72
	  QHLP I 1 A_FadeOut(0.05)
	  Wait
	QSpawn2:
	  QHLP J 236
	  QHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  QHLP J 72
	  QHLP J 1 A_FadeOut(0.05)
	  Wait
	QSpawn3:
	  QHLP K 236
	  QHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  QHLP K 72
	  QHLP K 1 A_FadeOut(0.05)
	  Wait
	QSpawn4:
	  QHLP L 236
	  QHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  QHLP L 72
	  QHLP L 1 A_FadeOut(0.05)
	  Wait
	QSpawn5:
	  QHLP M 236
	  QHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  QHLP M 72
	  QHLP M 1 A_FadeOut(0.05)
	  Wait
	QSpawn6:
	  QHLP N 236
	  QHLP A 0 A_TakeFromTarget("MegaShellOut",1)
	  QHLP N 72
	  QHLP N 1 A_FadeOut(0.05)
	  Wait
	}
}

ACTOR NoPickShellProjectile : ShellProjectile
{
   States
   {
   Death:
      TNT1 A 0 A_SpawnItemEx("ErasusCasingInstant")
      stop
   }
}

ACTOR QuadNoPickShellProjectile : QuadShellProjectile
{
   States
   {
   Death:
      TNT1 A 0 A_SpawnItemEx("QuadCasingInstant")
      stop
   }
}

actor ErasusCasingInstant
{
	+NOINTERACTION
	+CLIENTSIDEONLY
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_Jump(255,"Spawn1","Spawn2","Spawn3","Spawn4","Spawn5","Spawn6")
	  stop
	Spawn1:
	  SHLP I 1 A_FadeOut(0.1)
	  Wait
	Spawn2:
	  SHLP J 1 A_FadeOut(0.1)
	  Wait
	Spawn3:
	  SHLP K 1 A_FadeOut(0.1)
	  Wait
	Spawn4:
	  SHLP L 1 A_FadeOut(0.1)
	  Wait
	Spawn5:
	  SHLP M 1 A_FadeOut(0.1)
	  Wait
	Spawn6:
	  SHLP N 1 A_FadeOut(0.1)
	  Wait
	}
}

actor QuadCasingInstant
{
	+NOINTERACTION
	+CLIENTSIDEONLY
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_Jump(255,"Spawn1","Spawn2","Spawn3","Spawn4","Spawn5","Spawn6")
	  stop
	Spawn1:
	  QHLP I 1 A_FadeOut(0.1)
	  Wait
	Spawn2:
	  QHLP J 1 A_FadeOut(0.1)
	  Wait
	Spawn3:
	  QHLP K 1 A_FadeOut(0.1)
	  Wait
	Spawn4:
	  QHLP L 1 A_FadeOut(0.1)
	  Wait
	Spawn5:
	  QHLP M 1 A_FadeOut(0.1)
	  Wait
	Spawn6:
	  QHLP N 1 A_FadeOut(0.1)
	  Wait
	}
}
