/*
CREDITS:
Sprites:
Original - Epic Games (UT99)
Rip - AEoD Team

Sounds:
Up - A mix, soo... one part is surely from Epic Games (UT99)
Fire, Add, Reload - ?
Flight, nuke explosion - Westwood (C&C Renegade)
*/

ACTOR Deathhead : Weapon 24512
{
   //$Category Weapons
   //$Title Death's Head
   //$Sprite HEDGX0
   Tag "Death's Head"
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "You got the ''Death Head'' MIRV missile launcher! Let's spread the joy... (8)"
   Obituary "%o was blasted by %k's ''Death Head''."
   Weapon.UpSound "Weapons/DeathheadUp"
   Weapon.SelectionOrder 1
   Weapon.AmmoType "HeadAmmo"
   Weapon.AmmoGive 5
   Weapon.AmmoUse 1
   Weapon.AmmoType2 "HeadAmmo"
   Weapon.AmmoUse2 5
   Weapon.Kickback 100
   Weapon.SlotNumber 8
   +ALT_AMMO_OPTIONAL
   +NOAUTOFIRE
   States
   {
   Spawn:
      HEDG X -1
      Loop
   Ready:
      //HEDT A 0 A_JumpIfInventory("HeadMode",1,"Ready2")
      HEDG A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
      Loop
   Ready2:
	  HEDG A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
	  Loop
   Deselect:
      HEDG A 1 A_Lower
      HEDG A 0 A_Lower
      HEDG A 0 SetPlayerProperty(0,0,0)
      Loop
   Select:
      HEDG A 0
      HEDG A 0 A_Jump(128,2)
      HEDG A 0 A_PlaySoundEx("Weapons/DeathheadAim","Voice")
      HEDG A 1 A_Raise
      HEDG A 0 A_Raise
      Goto Select+3
	Nope:
		HEDF A 1	// Dummy state to prevent crashing
		Goto Ready
   Fire:
	  HEDF A 0 A_JumpIfInventory("CameraTrigger", 1, "Nope")
      HEDF A 0 A_FireCustomMissile("DeathheadWarhead",0,1,15,0)
   BoomKa:
      HEDF A 0 A_GunFlash
      HEDF A 0 A_Recoil(20)

      HEDF A 0 A_PlaySound("Weapons/DeathheadFire",1)
      HEDF A 0 A_PlaySound("Weapons/DeathheadAddFire",6,0.8)
      HEDF A 0 A_PlaySound("Weapons/DeathheadReload",5,0.8)
   StalinTheKart:
      HEDF A 0 ACS_Execute(851,0,160+random(10,-10),80+random(4,-4),0)
      HEDF A 2 Bright A_ZoomFactor(0.8)

      HEDF A 0 ACS_Execute(851,0,50+random(5,-5),20+random(2,-2),0)
      HEDF B 2 Bright A_ZoomFactor(0.84)

      HEDF A 0 ACS_Execute(851,0,50+random(5,-5),20+random(2,-2),0)
      HEDF C 2 Bright A_ZoomFactor(0.88)

      HEDF A 0 ACS_Execute(851,0,50+random(5,-5),20+random(2,-2),0)
      HEDF D 2 Bright A_ZoomFactor(0.92)

      HEDF A 0 ACS_Execute(851,0,50+random(5,-5),20+random(2,-2),0)
      HEDF E 2 Bright A_ZoomFactor(0.96)

      HEDF A 0 ACS_Execute(851,0,50+random(5,-5),20+random(2,-2),0)
      HEDF F 2 Bright A_ZoomFactor(0.99)  
      HEDG BBB 1 ACS_Execute(851,0,-12.962+random(1,-1),-5.185+random(0.15,-0.15),0)
      HEDG A 0 A_ZoomFactor(1)
      HEDG CCCDDDEEEFFFGGGHHHIIIJJJ 1 ACS_Execute(851,0,-12.962+random(1,-1),-5.185+random(0.15,-0.15),0)
      HEDG A 20
      Goto Ready

   AltFire:
      TNT1 A 0 A_JumpIfInventory("StalinActive",1,"StalinLaunch")

      TNT1 A 0 A_JumpIfInventory("CameraTrigger",1,"Detonate")		// if so, "fire" was pressed while in bullet time
      TNT1 A 0 A_JumpIfInventory("HeadAmmo",5,"Wolololo")		// Makes sure there's enough ammo to launch
      HEDG A 5 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)			// So you can detonate missile in flight with alt-fire, even w/o ammo
      Goto Ready
   Wolololo:
      // HEDF A 0 A_GiveInventory("CameraTrigger",1)
      HEDG A 0 A_FireCustomMissile("GuidedNuclearMissile",0,1,0,0)
	  //HEDG A 0 A_JumpIfInventory("HeadMode",1,"BoomKa")
	  Goto BoomKa
      HEDF A 0 A_PlaySound("Weapons/DeathheadFire",1)
      HEDF A 0 A_PlaySound("Weapons/DeathheadAddFire",6,0.8)
      HEDF A 0 A_PlaySound("Weapons/DeathheadReload",5,0.8)
      TNT1 A 0 SetPlayerProperty(0,1,0)
      TNT1 A 0 A_AlertMonsters
      Goto OnTheRoll
   OnTheRoll:
      HEDG A 2	//it needs this delay for the ACS to kick in when the thing is shot
      TNT1 A 0
      HEDG A 1 A_JumpIfInventory("CameraTrigger",1,"KeepRolling")	//if has this item, means the rocket is flying still

      //if it reaches this part is because the rocket died and player needs to be restored
      TNT1 A 0 SetPlayerProperty(0,0,0)
      TNT1 A 0
      Goto Ready
   KeepRolling:
      HEDG A 1 A_WeaponReady(WRF_NOSWITCH|WRF_NOPRIMARY)
      Goto OnTheRoll+1
   Detonate:	//KABOOM, BABE!
      // HEDG A 0 ACS_Execute(963,0,0,0,0)
      // HEDG A 0 A_TakeInventory("CameraTrigger",1)
      HEDG A 0 // was 70
      Goto OnTheRoll+1

   StalinLaunch:
      TNT1 A 0
	  Goto Staleen
	  //HEDG A 0 A_JumpIfInventory("HeadMode",1,"Staleen")
      TNT1 A 0 A_JumpIfInventory("CameraTrigger",1,"Detonate")		// if so, "fire" was pressed while in flight
      HEDG A 0 ACS_Execute(708)
      HEDG A 5 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)				// if the condition above wasnt met, it lies here for a few tics doing nothing
	  HEDF A 0 A_JumpIfInventory("InfiniteAmplifier",1,3)
      HEDF A 0 A_TakeInventory("StalinActive")
      HEDF A 0 A_TakeInventory("Stalin",1)
      HEDF A 0 A_PlaySound("Weapons/DeathheadFire",1)
      HEDF A 0 A_PlaySound("Weapons/DeathheadReload",5,0.8)
      HEDF A 0 A_PlaySound("Weapons/StalinowiczWarn",6,1.0,0,ATTN_NONE)
      HEDF A 0 A_PlaySound("Weapons/StalinowiczFire",0)
      HEDF A 0 A_GunFlash
      //HEDF A 0 A_GiveInventory("CameraTrigger",1)
      // Leaving that to scripts TNT1 A 0 SetPlayerProperty(0,1,PROP_FROZEN)
      TNT1 A 0 A_AlertMonsters
      HEDF A 0 A_FireCustomMissile("GuidedStalinWarhead",0,0,0,0)
      Goto OnTheRoll
   Staleen:
      HEDG A 0 ACS_Execute(708)
	  HEDF A 0 A_JumpIfInventory("InfiniteAmplifier",1,3)
      HEDF A 0 A_TakeInventory("StalinActive")
      HEDF A 0 A_TakeInventory("Stalin",1)
      HEDF A 0 A_PlaySound("Weapons/DeathheadFire",1)
      HEDF A 0 A_PlaySound("Weapons/DeathheadReload",5,0.8)
      HEDF A 0 A_PlaySound("Weapons/StalinowiczWarn",6,1.0,0,ATTN_NONE)
      HEDF A 0 A_PlaySound("Weapons/StalinowiczFire",0)
      HEDF A 0 A_GunFlash
      HEDF A 0 A_Recoil(20)
      TNT1 A 0 A_AlertMonsters
      HEDF A 0 A_FireCustomMissile("GuidedStalinWarhead",0,0,0,0)
	  Goto StalinTheKart
   Reload:
	  TNT1 A 0 A_Print("Sorry, but guided missiles don't quite work on this weapon for some reason I cannot comprehend, so I disabled it")
	  Goto Ready
	  /*TNT1 A 0 A_JumpIfInventory("HeadMode",1,"UnReload")
	  TNT1 A 0 A_GiveInventory("HeadMode",1)
	  HEDG A 0 A_Print("Dumb mode.")
	  Goto Modlet
   UnReload:
	  TNT1 A 0 A_TakeInventory("HeadMode",1)
	  HEDT A 0 A_Print("Guided mode.")
	  Goto Modlet*/
   Modlet:
	  "####" "#" 0 A_PlaySound("Deathhead/Mode",6,0.9)
	  "####" "#" 0 A_Quake(2,8,0,2,none)
	  "####" "#" 15 A_Weaponready(WRF_NOSWITCH|WRF_NOBOB|WRF_NOFIRE)
	  "####" "#" 10 A_Weaponready(WRF_NOSWITCH|WRF_NOBOB)
	  Goto Ready
   Flash:
      TNT1 A 6 Bright A_Light2
      TNT1 A 1 Bright A_Light1
      TNT1 A 0 Bright A_Light0
      Stop
   }
}

ACTOR HeadMode : Inventory { Inventory.MaxAmount 1 }

//FIRE

actor DeathheadWarhead
{
  Scale 1.15
  Radius 11
  Height 8
  Speed 30
  Damage 30
  Projectile
  +RANDOMIZE
  +ROCKETTRAIL
  +FORCERADIUSDMG
  +THRUGHOST
  +DONTSPLASH
  +EXPLODEONWATER
  DamageType "Superweapon"
  SeeSound ""
  DeathSound "Weapons/DeathheadExplode"
  Obituary "%o was directly blasted by %k's deathhead warhead."
  States
  {
  Spawn:
    DHED A 0
    HEDM A 0 A_PlaySoundEx("Weapons/DeathHeadLoop2","Soundslot5",1)
    DHED A 0 A_JumpIfInventory("DeathheadCount",13,"SRU")
    DHED A 0 A_GiveInventory("DeathheadCount",1)
    DHED A 0 A_SpawnItemEx("DeathHeadFlameTrail", -30, random(2,-2), random(2,-2), 0, 0, 0, 0, 128, 0)
    DHED AAA 0 A_SpawnItemEx("DeathHeadSmokeTrail", -30, random(3,-3), random(3,-3), 0 ,0, 0, 0, 128, 0)
    DHED A 1 bright A_SpawnItemEx("DeathHeadSmokeTrail", -30, random(2,-2), random(2,-2), random(1,-1), random(1,-1), 2, 0, 128, 0)
    loop
  Sru:
    DHED A 0 A_PlaySound("Weapons/DeathheadOff")
    DHED AAAAAAAAAAAA 0 A_SpawnItemEx("DeathHeadSmokeTrail",0,0,0,random(2,-2),random(2,-2),random(2,-2),random(0,360),128,0)
    DHED AAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("DeatheadCluster",0,0,0,velx+random(14,-14),vely+random(14,-14),velz+random(11,-11),0,SXF_ABSOLUTEMOMENTUM|SXF_TRANSFERPITCH|SXF_TRANSFERPOINTERS,0)
    TNT1 A 1
    Stop
  Death:
    TNT1 A 0 A_JumpIfInTargetInventory("NukerUpgrade",1,"NukerDeath")
    TNT1 A 0 A_StopSoundEx("SoundSlot5")
    TNT1 A 0 A_SpawnItemEx("DeathheadExplode",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
    TNT1 A 0 A_Explode(150,384,0,1)
    TNT1 A 0 A_Explode(300,192,1,1)
    TNT1 BCD 6
    Goto Sru
  NukerDeath:
    TNT1 A 0 A_StopSoundEx("SoundSlot5")
    TNT1 A 0 A_SpawnItemEx("NukerDeathheadExplode",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
    TNT1 A 0 A_Explode(300,576,0,1)
    TNT1 A 0 A_Explode(600,288,1,1)
    TNT1 BCD 6
    Goto Sru
  }
}

ACTOR DeathheadCount : Inventory //Cluster Counter
{
     Inventory.MaxAmount 100
}

actor DeatheadCluster : Rocket
{
  Damage 40
  Obituary "%o was exploded by %k's deathhead clusters rain."
  SeeSound ""
  DeathSound "Weapons/DeathheadExplode"
  DamageType "Superweapon"
  -NOGRAVITY
  +FORCERADIUSDMG
  +SEEKERMISSILE
  +DONTSEEKINVISIBLE
  +THRUGHOST
  +DONTSPLASH
  +EXPLODEONWATER
  +FORCERADIUSDMG
  Gravity 0.35
  Scale 0.75
  States
  {
  Spawn:
    TNT1 A 0
    HEDM A 0 A_PlaySoundEx("Weapons/DeathheadLoop","Soundslot5",1)
    HEDM AABB 1 bright A_SpawnItemEx("DeatheadMissileTrail", -20, random(1,-1), random(1,-1), random(1,-1), random(1,-1), 0, 0, 128, 0)
    Loop
  Death:
    TNT1 A 0 A_JumpIfInTargetInventory("NukerUpgrade",1,"NukerDeath")
    TNT1 A 0 A_StopSoundEx("SoundSlot5")
    TNT1 A 0 A_SpawnItemEx("DeathheadExplode",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
    TNT1 A 0 A_Explode(150,256,1,1)
    TNT1 A 0 A_Explode(300,256,0,0)
    TNT1 B 6 A_SpawnItemEx("DeathHeadShock",0,0,0,0,0,0,0,128,0)
    TNT1 C 6 A_SpawnItemEx("DeathHeadShock",0,0,0,0,0,0,0,128,0)
    TNT1 D 6 A_SpawnItemEx("DeathHeadShock",0,0,0,0,0,0,0,128,0)
    TNT1 A 0 A_SpawnItemEx("DeathHeadMissileExplode",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
    stop
  NukerDeath:
    TNT1 A 0 
    TNT1 A 0 A_StopSoundEx("SoundSlot5")
    TNT1 A 0 A_SpawnItemEx("NukerDeathheadExplode",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
    TNT1 A 0 A_Explode(300,384,1,1)
    TNT1 A 0 A_Explode(600,384,0,0)
    TNT1 B 6 A_SpawnItemEx("DeathHeadShock",0,0,0,0,0,0,0,128,0)
    TNT1 C 6 A_SpawnItemEx("DeathHeadShock",0,0,0,0,0,0,0,128,0)
    TNT1 D 6 A_SpawnItemEx("DeathHeadShock",0,0,0,0,0,0,0,128,0)
    TNT1 A 0 A_SpawnItemEx("NukerPushkaExploder",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
    TNT1 A 0 A_SpawnItemEx("NukerPushkaSmoker",0,0,0,0,0,0,0,0,0)
    stop
  }
}

ACTOR DeatheadMissileTrail
{ 
    Scale 0.15
    Alpha 0.18
    RenderStyle Normal
    +NOINTERACTION
    +NOGRAVITY
    +THRUGHOST
    +DONTSPLASH
	+CLIENTSIDEONLY
    +DONTBLAST
    States
    {
    Spawn:
      SMKE A 0
      SMKE A 0 A_FadeOut(0.01)
      SMKE ABCDEFGHIJKLMNOPQ 1 A_FadeOut(0.01)
      Stop
    }
}

ACTOR DeathHeadSmokeTrail : DeatheadMissileTrail
{ 
    Scale 0.2
    Alpha 0.21
    States
    {
    Spawn:
      SMKE A 0
      SMKE A 0 A_FadeOut(0.01)
      SMKE ABCDEFGHIJKLMNOPQ 2 A_FadeOut(0.013)
      Stop
    }
}

ACTOR DeathHeadFlameTrail : DeathHeadExp
{
  Scale 0.6
}

//ALT-FIRE

//Triggers

ACTOR DieToken : Inventory { Inventory.MaxAmount 1 }

ACTOR CameraTrigger : Inventory { Inventory.MaxAmount 1 }

ACTOR GuidedNuclearMissile //Single Nuke
{
 Damage 1000
 Speed 15
 PROJECTILE
 +THRUGHOST
 +DONTSPLASH
 +SKYEXPLODE
 +EXPLODEONWATER
 DamageType "Superweapon"
 Obituary "%o surely couldn't run away from %k's guided nuclear missile!"
 Scale 0.55
 states
 {
 Spawn:
 HED3 A 0
 
 Goto Looplet2
 HED3 A 0 A_JumpIfInTargetInventory("HeadMode",1,"Looplet2")
 HED3 A 0 A_PlaySound("Weapons/StalinowiczFlew",5|CHAN_NOPAUSE,1,0,ATTN_NONE)
 HED3 A 0 A_PlaySound("Weapons/DeathheadLoop3",6|CHAN_NOPAUSE,1,1,ATTN_NONE)
 
  // Why the delay? Because zdoom is full-retard and doesn't register the
  // Tid change until after ten years. @_@ - KeksDose
  HED3 A 2 ACS_ExecuteAlways(709, 0, 0.02 * 65535)
  HED3 A 2 ACS_ExecuteAlways(710, 0, Tid)

 Looplet:
 HED3 A 1 A_SpawnItemEx("StalinTrail",-30,0,0,0,0,0,0,128,0)
 HED3 A 0 A_SpawnItemEx("DeathHeadFlameTrail", -30, random(2,-2), random(2,-2), 0, 0, 0, 0, 128, 0)
 HED3 A 0 A_JumpIfInventory("DieToken",1,"Kaboom")
 HED3 B 0 A_SpawnItemEx("DeathHeadFlameTrail", -30, random(2,-2), random(2,-2), 0, 0, 0, 0, 128, 0)
 HED3 B 1 A_SpawnItemEx("StalinTrail",-30,0,0,0,0,0,0,128,0)
 HED3 B 0 A_JumpIfInventory("DieToken",1,"Kaboom")
 Loop
 Looplet2:
 HED3 A 0 A_PlaySound("Weapons/StalinowiczFlew",5|CHAN_NOPAUSE,1,0)
 HED3 A 0 A_PlaySound("Weapons/DeathheadLoop3",6|CHAN_NOPAUSE,1,1)
 Goto Looplet
 Kaboom:
 TNT1 A 0 A_Die
 TNT1 A 0 A_PlaySound("Weapons/StalinowiczExplode",5|CHAN_NOPAUSE,1,0)
 TNT1 A 0 A_ChangeFlag("Missile",0)
 TNT1 A 0 A_ChangeFlag("NOGRAVITY",1)
 Goto Death
 Death:
 TNT1 A 0 A_TakeFromTarget("CameraTrigger", 1)
 TNT1 A 0 A_StopSound(6)
 TNT1 A 0 A_SpawnItemEx("Nuke", 0, 0, 5, 0, 0, 0, 0,SXF_TRANSFERPOINTERS|SXF_NOCHECKPOSITION)
 TNT1 A 1 A_SpawnItemEx("KaBoomer",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
 Stop 
 }
}

//Cluster Nuke Item

actor StalinPickup : CustomInventory
{
	Inventory.PickupMessage "Picked up a ''Stalin'' MIRV nuclear warhead!"
	Inventory.PickupSound "Ammo/Stalin"
	Scale 0.7
	States
	{
		Spawn:
		STAL A -1
		Stop
		Pickup:
		TNT1 A 0 A_JumpIfInventory("Stalin",0,"Bailure")
		TNT1 A 0 A_GiveInventory("Stalin")
		Stop
		Bailure:
		STAL A 1
		Fail
	}
}

actor Stalin : CustomInventory
{
  Inventory.PickupMessage "Picked up a ''Stalin'' MIRV nuclear warhead!"
  Inventory.Amount 1
  Inventory.MaxAmount 2
  Inventory.InterHubAmount 2
  Inventory.PickupSound "Ammo/Stalin"
  Inventory.Icon ARTISTAL
  +INVENTORY.FANCYPICKUPSOUND
  +INVBAR
   Scale 0.7
  states
  {
  Spawn:
	STAL A -1
	Stop
  Use:
   	TNT1 A 0 A_JumpIfInventory("StalinActive",1,"Use2")

	TNT1 A 0 A_SetBlend("Green",0.1,15)
	TNT1 A 0 A_PlaySoundEx("weapons/RedeemerPick","Item")
	TNT1 A 0 A_GiveInventory("StalinActive")
	TNT1 A 1 A_Print("MIRV nuclear warhead activated.")
	Fail
  Use2:
	TNT1 A 0 A_SetBlend("Red",0.1,15)
	TNT1 A 0 A_PlaySoundEx("weapons/RedeemerPick","Item")
 	TNT1 A 0 A_TakeInventory("StalinActive")
	TNT1 A 1 A_Print("MIRV nuclear warhead deactivated.")
	Fail
  }
}

ACTOR GuidedStalinWarhead //Cluster Nuke
{
 Damage 1000
 Speed 15
 PROJECTILE
 +THRUGHOST
 +DONTSPLASH
 +SKYEXPLODE
 +EXPLODEONWATER
 DamageType "Superweapon"
 Obituary "%o surely couldn't run away from %k's guided nuclear missile!"
 Scale 0.55
 states
 {
 Spawn:
 HED3 A 0
 Goto Looplet2
 //HED3 A 0 A_JumpIfInTargetInventory("HeadMode",1,"Looplet2")
 HED3 A 0 A_PlaySound("Weapons/StalinowiczFlew",5|CHAN_NOPAUSE,1,0,ATTN_NONE)
 HED3 A 0 A_PlaySound("Weapons/DeathheadLoop3",6|CHAN_NOPAUSE,1,1,ATTN_NONE)

 HED3 A 2 ACS_ExecuteAlways(709, 0, 0.02 * 65535)
 HED3 A 2 ACS_ExecuteAlways(710, 0, Tid)
 Looplet:
 HED1 A 0 A_JumpIfInventory("DieToken",1,"Kaboom")
 HED1 A 0 A_SpawnItemEx("DeathHeadFlameTrail", -30, random(2,-2), random(2,-2), 0, 0, 0, 0, 128, 0)
 HED1 AAA 0 A_SpawnItemEx("DeathHeadSmokeTrail", -30, random(3,-3), random(3,-3), 0 ,0, 0, 0, 128, 0)
 HED1 A 0 bright A_SpawnItemEx("DeathHeadSmokeTrail", -30, random(2,-2), random(2,-2), random(1,-1), random(1,-1), 2, 0, 128, 0)
 HED1 A 1 A_SpawnItemEx("StalinTrail",-15,0,0,0,0,0,0,128,0)
 HED1 A 0 A_JumpIfInventory("DieToken",1,"Kaboom")
 HED1 A 0 A_SpawnItemEx("DeathHeadFlameTrail", -30, random(2,-2), random(2,-2), 0, 0, 0, 0, 128, 0)
 HED1 AAA 0 A_SpawnItemEx("DeathHeadSmokeTrail", -30, random(3,-3), random(3,-3), 0 ,0, 0, 0, 128, 0)
 HED1 A 0 bright A_SpawnItemEx("DeathHeadSmokeTrail", -30, random(2,-2), random(2,-2), random(1,-1), random(1,-1), 2, 0, 128, 0)
 HED1 B 1 A_SpawnItemEx("StalinTrail",-15,0,0,0,0,0,0,128,0)
 Loop
 Looplet2:
 HED3 A 0 A_PlaySound("Weapons/StalinowiczFlew",5|CHAN_NOPAUSE,1,0)
 HED3 A 0 A_PlaySound("Weapons/DeathheadLoop3",6|CHAN_NOPAUSE,1,1)
 Goto Looplet
 Kaboom:
 TNT1 A 0 A_Die
 TNT1 A 0 A_PlaySound("Weapons/StalinowiczExplode",5|CHAN_NOPAUSE,1,0)
 TNT1 A 0 A_ChangeFlag("Missile",0)
 TNT1 A 0 A_ChangeFlag("NOGRAVITY",1)
 Goto Death
 Death:
 TNT1 A 0 A_TakeFromTarget("CameraTrigger", 1)
 TNT1 A 0 A_StopSound(6)
 TNT1 A 0 A_Stop
 TNT1 A 0 A_PlaySound("Weapons/StalinowiczExplode",5|CHAN_NOPAUSE,1,0)
 TNT1 AAAAAAAAAA 0 A_SpawnItemEx("StalinCluster",0,0,0,velx+random(20,-20),vely+random(20,-20),velz+random(14,-14),0,SXF_ABSOLUTEMOMENTUM|SXF_TRANSFERPITCH|SXF_TRANSFERPOINTERS,0)
 TNT1 A 0 A_SpawnItemEx("Nuke",0,0,5,0,0,0,0,SXF_TRANSFERPOINTERS|SXF_NOCHECKPOSITION)
 TNT1 A 1 A_SpawnItemEx("KaBoomer",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
 Stop 
 }
}

ACTOR StalinCluster
{
 Damage 1000
 Speed 35
 PROJECTILE
 -NOGRAVITY
 +THRUGHOST
 +DONTSPLASH
 +EXPLODEONWATER
 Gravity 0.35
 DamageType "Superweapon"
 Obituary "%o surely couldn't run away from %k's nuclear missile rain!"
 SeeSound "Weapons/StalinowiczFlew"
 Scale 0.55
 states
 {
 Spawn:
 HED3 AA 0 A_PlaySound("Weapons/DeathheadLoop2",5|CHAN_NOPAUSE,1,1)
 HED3 AB 1 Bright A_CustomMissile("StalinTrail",0,0,0)
 Loop
 Death:
 TNT1 A 0 A_PlaySound("Weapons/StalinowiczExplode",5|CHAN_NOPAUSE,1,0)
 TNT1 A 0 A_SpawnItemEx("Nuke",0,0,5,0,0,0,0,SXF_TRANSFERPOINTERS|SXF_NOCHECKPOSITION)
 TNT1 A 1 A_SpawnItemEx("KaBoomer",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
 Stop 
 Stop 
 }
}

actor StalinActive : Inventory
{
  Inventory.MaxAmount 1
}

ACTOR StalinTrail
{ 
    Scale 0.2
    Alpha 0.2
    Renderstyle Add
    +NOGRAVITY
    +NOINTERACTION
	+CLIENTSIDEONLY
    +THRUGHOST
    +DONTSPLASH
    States
   {
    Spawn:
      SMKE A 0
      SMKE A 0 A_FadeOut(0.01)
      SMKE ABCDEFGHIJKLMNOPQ 1
      Stop
   }
}


