/*
CREDITS:

Sprites:
Weapon sprites by Marty Kirra (Base by Kronos, Doom 2.5 - Original by ID, Doom 3)
Pickup by me.

Sounds:
Up, Zoom in, Zoom out - ID (ET:WQ)
Fire - Blizzard (Starcraft 2)
Rod impact - Valve (Half-Life 2)
Sizzling - Raven (Wolfenstein 3)
Alt-Fire - Mashup. Part by Epic Games and People can Fly (Bulletstorm)
Flak - Epic Games (Unreal)
*/

ACTOR Okudzhava : DoomWeapon 24520
{
   //$Category Weapons
   //$Title  Okudzhava
   //$Sprite GSGGX0
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "Picked up a ''Okudzhava'' gauss cannon! Lemme sing you a song of you... being penetrated by a super-heated steel rod! (5)"
   Obituary "%o was ripped open and roasted like a chicken by %k's ''Okudzhava''. Now, time for the song!"
   Weapon.UpSound "weapons/OkudzhavaUp"
   Weapon.SelectionOrder 4
   Weapon.AmmoType "100MMAmmo"
   Weapon.AmmoUse 1
   Weapon.AmmoGive 6
   Weapon.AmmoType2 "100MMAmmo"
   Weapon.AmmoUse2 1
   Weapon.Kickback 35
   Weapon.SlotNumber 5
   +NOALERT
   +NOAUTOFIRE
   States
   {
   Spawn:
      GSGG X -1
      Loop
   UnZoom:
      GAUZ A 0 A_PlaySoundEx("weapons/OkudzhavaZoomOut","SoundSlot5")
      GAUZ A 0 A_TakeInventory("Zoomed",999)

      GAUZ A 0 A_SetTranslucent(0.9,0)
      GAUZ A 0 A_SetBlend("Cyan",0.2,3)
      GAUZ A 1 A_SetBlend("Black",0.15,3) 
      
      GAUZ A 0 A_SetTranslucent(0.92,0)
      GAUZ A 0 A_SetBlend("Cyan",0.18,3)
      GAUZ A 1 A_SetBlend("Black",0.3,3)
      
      GAUZ A 0 A_SetTranslucent(0.94,0)
      GAUZ A 0 A_SetBlend("Cyan",0.16,3)
      GAUZ A 1 A_SetBlend("Black",0.45,3)
      GAUZ A 0 A_ZoomFactor(1.00)
      
      GAUZ A 0 A_SetTranslucent(0.96,0)
      GAUZ A 0 A_SetBlend("Cyan",0.14,3)
      GAUZ A 1 A_SetBlend("Black",0.6,3)
      
      GAUZ A 0 A_SetTranslucent(0.98,0)
      GAUZ A 0 A_SetBlend("Cyan",0.12,3)
      GAUZ A 1 A_SetBlend("Black",0.75,3)
      
      GAUZ A 0 A_SetTranslucent(1,0)
      GAUZ A 0 A_SetBlend("Cyan",0.1,3)
      GAUZ A 1 A_SetBlend("Black",0.9,3)
      
      GAUZ AAAAAA 1 A_SetBlend("Black",1,11)
      
      GSGG A 15 A_SetBlend("Black",0.9,10)
      GSGG A 1
   Ready:
      GSGG A 0
      GSGG A 0 A_JumpIfInventory("Zoomed",1,"ZoomedReady")
	  
      GSGG A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoZoom", 1, "Zoom")
      Loop
   ZoomedReady:
      GAUZ A 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_SetBlend("Cyan",0.1,2)
	  
      GAUZ A 1 A_WeaponReady(WRF_NOBOB)
	  TNT1 A 0 A_JumpIfInventory("RO_GotoZoom", 1, "Zoom")
      Goto Ready
   Select:
      GSGG A 0 A_TakeInventory("Zoomed",999)
      GSGG A 1 A_Raise
      GSGG A 0 A_Raise
      Loop
   Deselect:
      GSGG A 0 A_ZoomFactor(1)
      GSGG A 0 A_JumpIfInventory("Zoomed",1,"ZoomedDeselect")
      GSGG A 0 A_SetTranslucent(1,0)
      GSGG A 1 A_Lower
      GSGG A 0 A_Lower
      Loop
  ZoomedDeselect:
      GAUZ A 0 A_PlaySoundEx("weapons/OkudzhavaZoomOut","SoundSlot5")
      GAUZ A 0 A_TakeInventory("Zoomed",999)

      GAUZ A 0 A_SetTranslucent(0.9,0)
      GAUZ A 0 A_SetBlend("Cyan",0.1,3)
      GAUZ A 1 A_SetBlend("Black",0.35,3) 
      
      GAUZ A 0 A_SetTranslucent(0.92,0)
      GAUZ A 0 A_SetBlend("Cyan",0.9,3)
      GAUZ A 1 A_SetBlend("Black",0.40,3)
      
      GAUZ A 0 A_SetTranslucent(0.94,0)
      GAUZ A 0 A_SetBlend("Cyan",0.08,3)
      GAUZ A 1 A_SetBlend("Black",0.45,3)
      GAUZ A 0 A_ZoomFactor(1.00)
      
      GAUZ A 0 A_SetTranslucent(0.96,0)
      GAUZ A 0 A_SetBlend("Cyan",0.06,3)
      GAUZ A 1 A_SetBlend("Black",0.6,3)
      
      GAUZ A 0 A_SetTranslucent(0.98,0)
      GAUZ A 0 A_SetBlend("Cyan",0.04,3)
      GAUZ A 1 A_SetBlend("Black",0.75,3)
      
      GAUZ A 0 A_SetTranslucent(1,0)
      GAUZ A 0 A_SetBlend("Cyan",0.2,3)
      GAUZ A 1 A_SetBlend("Black",0.9,3)
      
      GAUZ AAAAAA 1 A_SetBlend("Black",1,11)
      
      GSGG A 15 A_SetBlend("Black",0.9,10)
      GSGG A 1
  ZoomedDeselectMain:
      GSGG A 0 A_Lower
      GSGG A 1 A_Lower
      Loop
   Fire:
      GSGF A 0 A_JumpIfInventory("Zoomed",1,"ZoomedFire")
      GSGF A 0 A_GunFlash
      GSGF A 0 A_Recoil(8)
      GSGF A 0 A_AlertMonsters
      GSGF A 0 A_PlaySound("Weapons/OkudzhavaFire",1)
      GSGF A 0 A_PlaySound("Weapons/ErasusAmbient",6)
      GSGF A 0 A_FireCustomMissile("GaussProjectile",0,1,6,-1,0,0)
      GSGF A 1 BRIGHT A_ZoomFactor(0.95)
      GSGF B 1 BRIGHT A_ZoomFactor(0.92)
      
      GSGF C 1 A_ZoomFactor(0.915)
      GSGF D 1 A_ZoomFactor(0.91)
      GSGF D 1
      GSGF E 1 A_ZoomFactor(0.92)
      GSGF E 1 A_ZoomFactor(0.94)
      GSGF E 1 A_ZoomFactor(0.96)
      GSGF D 1 A_ZoomFactor(0.98)
      GSGF D 1 A_ZoomFactor(0.99)
      GSGF C 1 A_ZoomFactor(0.995)
      
      GSGB A 1 A_ZoomFactor(1)
      GSGB BCDEF 1
      
      GSGG A 1
      GSGG A 15
      goto Ready
   ZoomedFire:
      GAUZ A 0 A_JumpIfNoAmmo("UnZoom")
      GSGF A 0 A_Recoil(4)
      GAUZ A 0 A_PlaySound("Weapons/OkudzhavaFire",1)
      GAUZ A 0 A_PlaySound("Weapons/ErasusAmbient",6)
      GAUZ A 0 A_FireCustomMissile("GaussProjectile",0,1,0,-3,0,0)
   Herp:
      GAUZ A 0 A_AlertMonsters
      GAUZ A 0 A_GunFlash
      GAUZ A 0 A_SetBlend("White",0.15,30)
      GAUZ A 0 A_SetBlend("Cyan",0.35,30)

      GAUZ B 1 BRIGHT A_ZoomFactor(0.995)
      GAUZ B 1 BRIGHT A_ZoomFactor(0.985)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.96)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.975)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.955)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.97)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.95)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.965)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.955)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.97)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      
      GAUZ B 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.96)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.975)
      
      GAUZ C 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.965)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.98)
      
      GAUZ D 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.97)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.985)
      
      GAUZ E 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.975)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.99)
      
      GAUZ F 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.98)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(2.995)
      
      GAUZ A 1 A_SetBlend("Cyan",0.1,3) // A_ZoomFactor(0.985)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_ZoomFactor(3)
      
      GAUZ A 1 A_SetBlend("Cyan",0.1,3) //A_ZoomFactor(0.995)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 1 A_SetBlend("Cyan",0.1,3) //A_ZoomFactor(0.995)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      
      GAUZ A 0 A_GiveInventory("GaussCooldown",15)
      
   Cooldown:
      GAUZ A 0 A_TakeInventory("GaussCooldown",1)
      GAUZ A 1 A_SetBlend("Cyan",0.1,3)
      GAUZ B 0 A_SetBlend("Black",0.3,3)
      GAUZ A 0 A_JumpIfInventory("GaussCooldown",1,"Cooldown")
      Goto Ready
   Zoom:
      GSGG A 0 A_JumpIfInventory("Zoomed",1,"UnZoom")

      GSGG A 0 A_GiveInventory("Zoomed",1)
      GSGG A 0 A_PlaySoundEx("weapons/OkudzhavaZoomIn","SoundSlot5")
      GSGG A 0 A_ZoomFactor(1.00)
      GSGG A 1 A_SetBlend("Black",0.15,3)
      GSGG A 1 A_SetBlend("Black",0.3,3)
      GSGG A 1 A_SetBlend("Black",0.45,3)
      GSGG A 1 A_SetBlend("Black",0.6,3)
      GSGG A 1 A_SetBlend("Black",0.75,3)
      GSGG A 1 A_SetBlend("Black",0.9,3)

      GAUZ AAAAA 1 A_SetBlend("Black",1,11)
      
      GAUZ A 0 A_ZoomFactor(3.00)
      GAUZ A 0 A_SetTranslucent(0.98,0)
      GAUZ A 1 A_SetBlend("Black",0.9,3)
      
      GAUZ A 0 A_SetTranslucent(0.96,0)
      GAUZ A 1 A_SetBlend("Black",0.85,3)
      
      GAUZ A 0 A_SetTranslucent(0.84,0)
      GAUZ A 1 A_SetBlend("Black",0.75,3)
      
      GAUZ A 0 A_SetTranslucent(0.82,0)
      GAUZ A 1 A_SetBlend("Black",0.65,3)
      
      GAUZ A 0 A_SetTranslucent(0.81,0)
      GAUZ A 1 A_SetBlend("Black",0.55,3)
      
      GAUZ A 0 A_SetTranslucent(0.8,0)
      GAUZ A 1 A_SetBlend("Black",0.40,3)
      
      GAUZ A 1 A_SetBlend("Black",0.38,3)
      GAUZ A 1 A_SetBlend("Black",0.36,3)
      GAUZ A 1 A_SetBlend("Black",0.34,3)
      GAUZ A 1 A_SetBlend("Black",0.32,3)
      Goto ZoomedReady
   AltFire:
      GSGF A 0 A_JumpIfInventory("Zoomed",1,"ZoomedAltFire")
      GSGF A 0 A_GunFlash
      GSGF A 0 A_Recoil(6)
      GSGF A 0 A_AlertMonsters
      GSGF A 0 A_PlaySound("Weapons/FlakFire",1)
      GSGF A 0 A_PlaySound("Weapons/FlakShot",5)
      //GSGF A 0 A_PlaySound("Weapons/ErasusAmbient",6)
      GSGF A 0 A_FireCustomMissile("FlakProjectile",0.1*random(40,-40),1,6,-1,0,0.1*random(20,-20))
      GSGF AAAAAAAAAAAAAAAAAAAAAAAA 0 A_FireCustomMissile("FlakProjectile",0.1*random(40,-40),0,6,-1,0,0.1*random(20,-20))
      GSGF A 1 BRIGHT A_ZoomFactor(0.95)
      GSGF B 1 BRIGHT A_ZoomFactor(0.92)
      
      GSGF C 1 A_ZoomFactor(0.915)
      GSGF D 1 A_ZoomFactor(0.91)
      GSGF D 1
      //GSGF E 0 A_PlaySound("Weapons/FlakReload")
      GSGF E 1 A_ZoomFactor(0.92)
      GSGF E 1 A_ZoomFactor(0.94)
      GSGF E 1 A_ZoomFactor(0.96)
      GSGF D 1 A_ZoomFactor(0.98)
      GSGF D 1 A_ZoomFactor(0.99)
      GSGF C 1 A_ZoomFactor(0.995)
      
      GSGB A 1 A_ZoomFactor(1)
      GSGB BCDEF 1
      
      GSGG A 1
      GSGG A 15
      goto Ready
   ZoomedAltFire:
      GAUZ A 0 A_JumpIfNoAmmo("UnZoom")
      GSGF A 0 A_GunFlash
      GSGF A 0 A_Recoil(7)
      GSGF A 0 A_AlertMonsters
      GSGF A 0 A_PlaySound("Weapons/FlakFire",1)
      GSGF A 0 A_PlaySound("Weapons/FlakBomb",5)
      GSGF A 0 A_PlaySound("Weapons/ErasusAmbient",6)
      GSGF A 0 A_FireCustomMissile("FlakBombProjectile",0,1,0,-3,0,0)
      Goto Herp
  Flash:
      TNT1 A 2 bright A_Light2
      TNT1 A 4 bright A_Light1
      Goto LightDone
   }
}

ACTOR GaussCooldown : Inventory
{
     Inventory.MaxAmount 15
}

//Projectile

ACTOR GaussProjectile : FastProjectile
{
  Speed 300
  Radius 10
  Height 7
  Damage 100
  Renderstyle Add
  DamageType Fire
  +RIPPER
  //-CANNOTPUSH
  +EXTREMEDEATH
  +NODAMAGETHRUST
  +DONTBLAST
  MissileType "GaussTrailCalibrator"
  states
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 ThrustThingZ(0,10,0,1)
  Looplet:
    TNT1 A 0 ThrustThingZ(0,-2,0,1)
    TNT1 A 1 A_PlaySoundEx("Weapons/OkudzhavaLoop","SoundSlot5",1,-1)
    Loop
  Death:
    TNT1 A 0 A_SpawnItemEx("GaussWallRod",0,0,0,0,0,0,0,128,0)
  XDeath:
    TNT1 AAAAAAAAAA 0 A_SpawnItemEx("GaussHotSpark",random(2,-2),random(2,-2),random(2,-2),random(4,-4),random(4,-4),random(7,-1),random(0,359),128,0)
    TNT1 A 1 A_PlaySound("weapons/OkudzhavaRod")
    stop
  }
}

ACTOR GaussHit
{
  +NOINTERACTION
  +CLIENTSIDEONLY
  +NOGRAVITY
  Renderstyle Add
  Scale 0.175
  states
  {
  Spawn:
     BIGB ABCDEFGHIJKLMNOPQRSTU 1 Bright
     Stop
  }
}

ACTOR GaussTrailCalibrator
{
  +NOINTERACTION
  +CLIENTSIDEONLY
  +NOGRAVITY
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx("GaussHotRod",0,0,7,frandom(-2,2),frandom(-2,2),frandom(1,3),0,0,0)
    TNT1 A 0 A_SpawnItemEx("GaussHotSpark",0,0,7,frandom(-2,2),frandom(-2,2),frandom(1,3),0,0,0)
    TNT1 A 0 A_SpawnItemEx("GaussTrail",0,0,7,0,0,0,0,0,0)
    Stop
  }
}

ACTOR GaussHotRod
{
  +NOINTERACTION
  +CLIENTSIDEONLY
  +NOGRAVITY
  Renderstyle Add
  Scale 0.85
  States
  {
  Spawn:
    TNT1 A 0
    HROD A 1 A_FadeOut(0.2)
    Wait
  }
}

ACTOR GaussWallRod
{
  +NOINTERACTION
  +NOGRAVITY
  +BLOODLESSIMPACT
  DamageType Fire
  ReactionTime 50
  Scale 0.85
  States
  {
  Spawn:
    HROD A 0
    TNT1 A 0 A_PlaySoundEx("Weapons/OkudzhavaLoop","SoundSlot5",1,-1)
    HROD A 6 A_Explode(1,18)
    HROD A 0 A_Jump(128,1)
    HROD A 0 A_SpawnItemEx("GaussHotSpark",random(24,-24),3+frandom(1,-1),frandom(1,-1),frandom(-1,1),frandom(-1,1),frandom(2,3),0,0,0)
    HROD A 0 A_Jump(128,1)
    HROD A 0 A_SpawnItemEx("GaussHotSpark",random(24,-24),3+frandom(1,-1),frandom(1,-1),frandom(-1,1),frandom(-1,1),frandom(2,3),0,0,0)
    HROD A 0 A_Countdown
    Loop
  Death:
    TNT1 A 0
    TNT1 A 0 A_PlaySoundEx("Weapons/OkudzhavaEnd","SoundSlot5",0,-1)
    HROD A 35
    HROD A 1 A_FadeOut(0.1)
    Wait
  }
}

ACTOR GaussHotSpark
{
  -NOGRAVITY
  +NOTELEPORT
  +DONTBLAST
  +CLIENTSIDEONLY
  Gravity 0.15
  Scale 0.2
  Alpha 0.9
  Renderstyle Add
  States
  {
  Spawn:
    TNT1 A 0
    HROD E 1 A_FadeOut(0.05)
    Wait
  }
}

ACTOR GaussTrail
{
  +NOINTERACTION
  +CLIENTSIDEONLY
  +NOGRAVITY
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx("GaussTrailMain",0.1*random(15,-15),0.1*random(15,-15),0.1*random(15,-15),0,0,0,0,0,0)
    Stop
  }
}

ACTOR GaussTrailMain
{
  RenderStyle Normal
  Scale 0.075
  Alpha 0.35
  +NOINTERACTION
  +CLIENTSIDEONLY
  +NOGRAVITY
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_FadeOut(0.01)
    TNT1 A 0 A_Jump(255,"TrailA","TrailB","TrailC","TrailD")
  TrailA:
    NSMK A 3
  Looper:
    NSMK A 0 //A_SetScale(ScaleX +0.005, ScaleY +0.005)
    NSMK A 1 A_FadeOut(0.01)
    Loop
  TrailB:
    NSMK B 3
  Looper:
    NSMK B 0 //A_SetScale(ScaleX +0.005, ScaleY +0.005)
    NSMK B 1 A_FadeOut(0.01)
    Loop
  TrailC:
    NSMK C 3
  Looper:
    NSMK C 0 //A_SetScale(ScaleX +0.005, ScaleY +0.005)
    NSMK C 1 A_FadeOut(0.01)
    Loop
  TrailD:
    NSMK D 3
  Looper:
    NSMK D 0 //A_SetScale(ScaleX +0.005, ScaleY +0.005)
    NSMK D 1 A_FadeOut(0.01)
    Loop
  }
}

//Alt-Fire

ACTOR FlakProjectile
{
  Speed 40
  Radius 6
  Height 3
  Damage 4
  PROJECTILE
  Obituary "%o was ripped open and made medium-rare by %k's hot, shredded metal."
  DamageType Fire
  BounceType Hexen
  BounceFactor 0.6
  BounceCount 8
  Scale 0.8
  +RIPPER
  -NOGRAVITY
  Gravity 0.75
  states
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_Jump(164,2)
    TNT1 A 0 A_PlaySound("Weapons/OkudzhavaLoop",5,0.2,1,2)
    TNT1 A 0 ThrustThingZ(0, 8, 0, 1)
    TNT1 A 0 A_ChangeVelocity (frandom(-6, 6), frandom(-6, 6), frandom(-6, 6), 0)
    TNT1 A 0 A_Jump(255,"Flak1","Flak2","Flak3")
  Flak1:
    TNT1 A 0 A_GiveInventory("DeathTokenA",1)
    FLAK A 0 A_Jump(217,2)
    FLAK A 0 A_SpawnItemEx("GaussHotSpark",random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(5,-1),random(0,359),128,0)
    FLAK A 1 Bright A_SpawnItemEx("FlakTrailA",0,0,0,0,0,0,0,128,0)
    Loop
  Flak2:
    TNT1 A 0 A_GiveInventory("DeathTokenB",1)
    FLAK A 0 A_Jump(217,2)
    FLAK A 0 A_SpawnItemEx("GaussHotSpark",random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(5,-1),random(0,359),128,0)
    FLAK B 1 Bright A_SpawnItemEx("FlakTrailB",0,0,0,0,0,0,0,128,0)
    Loop
  Flak3:
    TNT1 A 0 A_GiveInventory("DeathTokenC",1)
    FLAK A 0 A_Jump(217,2)
    FLAK A 0 A_SpawnItemEx("GaussHotSpark",random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(5,-1),random(0,359),128,0)
    FLAK C 1 Bright A_SpawnItemEx("FlakTrailC",0,0,0,0,0,0,0,128,0)
    Loop
  Death:
    TNT1 A 0 A_StopSound(5)
    TNT1 A 0 A_JumpIfInventory("DeathTokenA",1,"DeathA")
    TNT1 A 0 A_JumpIfInventory("DeathTokenB",1,"DeathB")
    TNT1 A 0 A_JumpIfInventory("DeathTokenC",1,"DeathC")
  DeathA:
    FLAK A 0 A_SpawnItemEx("FlakProjectileDeadA",0,0,0,0,0,0,0,128,0)
    Stop
  DeathB:
    FLAK B 0 A_SpawnItemEx("FlakProjectileDeadB",0,0,0,0,0,0,0,128,0)
    Stop
  DeathC:
    FLAK C 0 A_SpawnItemEx("FlakProjectileDeadC",0,0,0,0,0,0,0,128,0)
    Stop
  XDeath:
    TNT1 A 1
    Stop
  }
}

ACTOR DeathTokenA : Inventory
{
  Inventory.MaxAmount 1
}

ACTOR DeathTokenB : Inventory
{
  Inventory.MaxAmount 1
}

ACTOR DeathTokenC : Inventory
{
  Inventory.MaxAmount 1
}

ACTOR OkudzhavaFlakTrail
{
  +NOINTERACTION
  +CLIENTSIDEONLY
  +NOGRAVITY
  Renderstyle Normal
  Scale 0.8
  Alpha 0.75
}

ACTOR FlakTrailA : OkudzhavaFlakTrail
{
  States
  {
  Spawn:
  FLAK AA 1 A_FadeOut(0.2)
  Wait
  }
}

ACTOR FlakTrailB : OkudzhavaFlakTrail
{
  States
  {
  Spawn:
  FLAK BB 1 A_FadeOut(0.2)
  Wait
  }
}

ACTOR FlakTrailC : OkudzhavaFlakTrail
{
  States
  {
  Spawn:
  FLAK CC 1 A_FadeOut(0.2)
  Wait
  }
}

ACTOR FlakProjectileDeadA : OkudzhavaFlakTrail
{
  ReactionTime 70
  +FLOORCLIP
  +CLIENTSIDEONLY
  States
  {
  Spawn:
  FLAK A 0
  FLAK A 0 A_Jump(128,2)
  FLAK A 0 A_PlaySound("Weapons/OkudzhavaLoop",5,0.2,1,3)
  Looplet:
  FLAK A 0 A_Countdown
  FLAK A 0 A_Jump(217,2)
  FLAK A 0 A_SpawnItemEx("GaussHotSpark",random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(5,-1),random(0,359),128,0)
  FLAK A 1 Bright
  Loop
  Death:
  FLAK A 0 A_StopSound(5)
  FLAK A 105 Bright
  FLAK A 1 Bright A_FadeOut(0.1)
  Wait
  }
}

ACTOR FlakProjectileDeadB : OkudzhavaFlakTrail
{
  ReactionTime 70
  +FLOORCLIP
  States
  {
  Spawn:
  FLAK B 0
  FLAK B 0 A_Jump(128,2)
  FLAK B 0 A_PlaySound("Weapons/OkudzhavaLoop",5,0.2,1,3)
  Looplet:
  FLAK B 0 A_Countdown
  FLAK B 0 A_Jump(217,2)
  FLAK B 0 A_SpawnItemEx("GaussHotSpark",random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(5,-1),random(0,359),128,0)
  FLAK B 1 Bright
  Loop
  Death:
  FLAK B 0 A_StopSound(5)
  FLAK B 105 Bright
  FLAK B 1 Bright A_FadeOut(0.1)
  Wait
  }
}

ACTOR FlakProjectileDeadC : OkudzhavaFlakTrail
{
  ReactionTime 70
  +FLOORCLIP
  States
  {
  Spawn:
  FLAK C 0
  FLAK C 0 A_Jump(128,2)
  FLAK C 0 A_PlaySound("Weapons/OkudzhavaLoop",5,0.2,1,3)
  Looplet:
  FLAK C 0 A_Countdown
  FLAK C 0 A_Jump(217,2)
  FLAK C 0 A_SpawnItemEx("GaussHotSpark",random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(2,-2),random(5,-1),random(0,359),128,0)
  FLAK C 1 Bright
  Loop
  Death:
  FLAK C 0 A_StopSound(5)
  FLAK C 105 Bright
  FLAK C 1 Bright A_FadeOut(0.1)
  Wait
  }
}

ACTOR FlakBombProjectile
{
  Speed 60
  Radius 6
  Height 3
  Damage 275
  PROJECTILE
  Obituary "%o was blasted by %k's ''hot potato grasshopper''."
  //+BOUNCEONWALLS
  +BOUNCEONFLOORS
  +BOUNCEONCEILINGS
  +EXPLODEONWATER
  BounceFactor 1
  BounceCount 5
  BounceSound "Weapons/FlakBomb"
  -NOGRAVITY
  Gravity 1
  states
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 ThrustThingZ(0, 15, 0, 1)
  Looplet:
    CANB B 0 A_Jump(32,2)
    CANB B 0 A_SpawnItemEx("GaussHotSpark",random(2,-2),random(2,-2),10+random(2,-2),random(2,-2),random(2,-2),random(5,-1),random(0,359),128,0)
    CANB B 0 A_SpawnItemEx("GaussTrail",0,0,10,0,0,0,0,0,0)
    CANB B 1 A_SpawnItemEx("FlakBombSmokeTrail",-5+random(3,-3),random(3,-3),10+random(3,-3),frandom(0.05,-0.05),frandom(0.05,-0.05),frandom(0.75,0.025),random(0,359),128,0)
    Loop
  Death:
    TNT1 A 0 A_PlaySound("Weapons/PushkaExp")
    TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("FlakBombShard",random(5,-5),random(5,-5),random(5,-5),random(50,-50),random(50,-50),random(15,-15),random(0,359),128,0)
    TNT1 A 0 A_JumpIfInTargetInventory("NukerUpgrade",1,"NukerDeath")
    TNT1 B 0 A_Explode(150,164)
    TNT1 A 0 A_SpawnItemEx("PushkaExplode",0,0,0,0,0,0,0,128,0)
    TNT1 A 0 A_Explode(150,256,0)
    TNT1 BCD 6
    stop
  NukerDeath:
    TNT1 B 0 A_Explode(300,192)
    TNT1 A 0 A_SpawnItemEx("NukerPushkaExplode",0,0,0,0,0,0,0,128,0)
    TNT1 A 0 A_Explode(300,384,0)
    TNT1 BCD 6
    stop
  }
}

ACTOR FlakBombTrail
{
  +NOINTERACTION
  +NOGRAVITY
  +CLIENTSIDEONLY
  States
  {
  Spawn:
  CANB BB 1 A_FadeOut(0.15)
  Wait
  }
}

ACTOR FlakBombSmokeTrail : GaussTrailMain
{
  Scale 0.175
  +CLIENTSIDEONLY
}

ACTOR FlakBombShard : FlakProjectile
{
  +CLIENTSIDEONLY
  states
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 ThrustThingZ(0, 8, 0, 1)
    TNT1 A 0 A_ChangeVelocity (frandom(-6, 6), frandom(-6, 6), frandom(-6, 6), 0)
  Selection:
    SRHP A 0 A_Jump(255,"A","B","D","E","F","G","H","I","J")
  A:
    SRHP A 0
    Goto Looplet
  B:
    SRHP B 0
    Goto Looplet
  C:
    SRHP C 0
    Goto Looplet
  D:
    SRHP D 0
    Goto Looplet
  E:
    SRHP E 0
    Goto Looplet
  F:
    SRHP F 0
    Goto Looplet
  G:
    SRHP G 0
    Goto Looplet
  H:
    SRHP H 0
    Goto Looplet
  I:
    SRHP I 0
    Goto Looplet
  J:
    SRHP J 0
    Goto Looplet
  Looplet:
    "####" "#" 3 Bright A_SpawnItemEx("FlakShardTrail",0,0,0,0,0,0,0,128,0)
    Goto Selection
  Death:
    "####" "#" 105
    "####" "#" 1 A_FadeOut(0.1)
    Wait
  }
}

ACTOR FlakShardTrail
{
  +NOINTERACTION
  +CLIENTSIDEONLY
  +NOGRAVITY
  States
  {
  Spawn:
  Selection:
    SRHP A 0 A_Jump(255,"A","B","D","E","F","G","H","I","J")
  A:
    SRHP A 0
    Goto Looplet
  B:
    SRHP B 0
    Goto Looplet
  C:
    SRHP C 0
    Goto Looplet
  D:
    SRHP D 0
    Goto Looplet
  E:
    SRHP E 0
    Goto Looplet
  F:
    SRHP F 0
    Goto Looplet
  G:
    SRHP G 0
    Goto Looplet
  H:
    SRHP H 0
    Goto Looplet
  I:
    SRHP I 0
    Goto Looplet
  J:
    SRHP J 0
    Goto Looplet
  Looplet:
    "####" "#####" 1 A_FadeOut(0.175)
    Stop
  }
}
