/*
CREDITS:
Gun, turret sprites - 3DRealms (LameDuke)
Explosion - Kronos (Doom 2.5)

Sounds:
Up, Down - Blizzard (Starcraft 1)
Trigger - ?
Fire - Team17 (Worms Armageddon)
Add Fire - ?
Explode - ID (Quake 2)
Hold - ID (RTCW)
Lock, Servo, Drop - Epic Games (Unreal)
Load - Raven (Wolfenstein 3)
*/

ACTOR BeefSupreme : Weapon 24521
{
   //$Category Weapons
   //$Title Beef Supreme
   //$Sprite RPGGX0
   Tag "Beef Supreme"
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "You got the ''Beef Supreme'' Massive Explosion Projectile Launcher MkII! A must-have for any resocialisation officer! (5)"
   Obituary "%o was brought back to society in form of gibs, thanks to %k's ''Beef Supreme''."
   Weapon.UpSound "Weapons/BeefUp"
   Weapon.SelectionOrder 4
   Weapon.AmmoGive 0
   Weapon.AmmoType "BeefClip"
   Weapon.AmmoUse 1
   Weapon.AmmoGive2 12
   Weapon.AmmoType2 "100MMAmmo"
   Weapon.AmmoUse2 0
   Weapon.Kickback 50
   Weapon.SlotNumber 5
   +NOALERT
   +AMMO_OPTIONAL
   States
   {
   Spawn:
      RPGG X -1
      Stop
   Ready:
      RPGG A 0 A_PlayWeaponSound("Weapons/BeefHold")
      Goto ReadyMain
   ReadyMain:
      RPGG A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
      Loop
   Deselect:
      RPGG A 0 A_ZoomFactor(1)
      RPGG A 0 A_Lower
      RPGG A 1 A_Lower
      Loop
   Select:
      TNT1 AAAAAAAAAAAAAAA 0 A_Raise
      RPGT HGFEDCBA 1
      RPGR YXWVUTSRQPONMLKJIHGFEDCBA 1
      Goto Select
   Fire:
      RPGG A 0 A_JumpIfInventory("BeefClip",1,1)
      Goto DryFire
      RPGF A 0 A_AlertMonsters
      RPGF A 0 A_Recoil(22)
      RPGF A 0 A_PlayWeaponSound("Weapons/BeefFire")
      RPGF A 0 A_PlaySoundEx("Weapons/BeefAFire","SoundSlot6")
      RPGF A 0 A_GunFlash
      RPGF A 0 A_FireCustomMissile("BeefProjectile",0,1,10,0)
      RPGF A 0 ACS_Execute(851,0,80+random(20,-20),60+random(15,-15))
      RPGF A 1 Bright A_ZoomFactor(0.85)
      RPGF B 1 Bright A_ZoomFactor(0.9)
      RPGF C 1 Bright A_ZoomFactor(0.925)
      RPGF D 1 Bright A_ZoomFactor(0.93)
      RPGF E 1 Bright A_ZoomFactor(0.94)
      RPGF F 1 Bright A_ZoomFactor(0.95)
      RPGE A 1 A_ZoomFactor(0.96)
      RPGE B 1 A_ZoomFactor(0.97)
      RPGE C 1 A_ZoomFactor(0.98)
      RPGE D 1 A_ZoomFactor(0.99)
      RPGE E 1 A_ZoomFactor(0.995)
      RPGE F 1 A_ZoomFactor(1)
      RPGE GHIJ 1
      RPGG A 5
      Goto ReadyMain
   DryFire:
      RPGG A 0 A_PlaySound("Weapons/BeefTrigger")
      RPGR A 3
      RPGG A 12
      Goto ReadyMain
   Reload:
      RPGG A 0 A_JumpIfInventory("BeefReloading",1,"ReloadMain")
      RPGG A 0 A_JumpIfInventory("BeefClip",9,"ReadyMain")
      RPGG A 0 A_JumpIfInventory("100MMAmmo",2,1)
      Goto ReadyMain
      RPGR A 0 A_GiveInventory("BeefReloading",1)
      RPGR A 0 A_PlaySoundEx("Weapons/BeefDown","SoundSlot5")
      RPGR ABCDEFGHIJKLMNOPQRSTUVWXY 1
      RPGT ABCDEF 1
      RPGR A 0 A_PlaySoundEx("Weapons/BeefLock","SoundSlot5")
   ReloadMain:
      RPG5 A 0 A_JumpIfInventory("100MMAmmo",2,1)
      goto ReloadDone
      RPGT G 8
      RPGT G 0 A_PlaySoundEx("Weapons/BeefLoad","SoundSlot6")
      RPGT HIJ 1
      RPGT G 9
      RPGT G 0 A_Quake (1, 6, 0, 3, none)
      RPGT G 9
      RPGT G 0 A_PlayWeaponSound("weapons/haloload")
   InnerSequence:
      RPGR A 0 A_JumpifInventory("BeefClip",9,"Reset")
      RPGR A 0 A_JumpifInventory("100MMAmmo",2,1)
      Goto Reset
      RPGR A 0 A_GiveInventory("BeefSequence",1)
      RPGR A 0 A_GiveInventory("BeefClip",1)
      RPGR A 0 A_TakeInventory("100MMAmmo",2,TIF_NOTAKEINFINITE)
      RPGR A 0 A_JumpifInventory("BeefSequence",3,"Reset")
      Goto InnerSequence
   Reset:
      RPGR A 0 A_TakeInventory("BeefSequence",3)
      RPGG A 0 A_JumpIfInventory("BeefClip",9,"ReloadDone")
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
      RPGT G 1 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE|WRF_NOSWITCH)
      Goto ReloadDone
   ReloadDone:
      STIG A 0 A_TakeInventory("BeefReloading",1)
      RPGR A 0 A_PlaySound("Weapons/BeefServo")
      RPGT G 10
      RPGR A 0 A_PlaySoundEx("Weapons/BeefUp","SoundSlot6")
      RPGT FEDCBA 1
      RPGR YXWVUTSRQPONMLKJIHGFEDCBA 1
      RPGR A 0 A_PlaySoundEx("Weapons/BeefHold","SoundSlot6")
      RPGG A 5
      Goto ReadyMain
   AltFire:
      RPGR A 0 A_JumpIfInventory("100MMAmmo",36,1)
	  Goto ReadyMain
      RPGR A 0 A_PlaySoundEx("Weapons/BeefDown","SoundSlot5")
      RPGR ABCDEFGHIJKLMNOPQRSTUVWXY 1
      RPGT ABCDEF 1
      RPGR A 0 A_TakeInventory("100MMAmmo",36,TIF_NOTAKEINFINITE)
      RPGR A 0 A_PlaySoundEx("Weapons/BeefDrop","SoundSlot6")
      RPGR A 0 A_JumpIfInventory("NukerUpgrade",1,2)
      RPGR A 0 A_SpawnItemEx("BeefTurret",88,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	  Goto Herp
      RPGR A 0 A_SpawnItemEx("BeefNukerTurret",88,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
   Herp:
      TNT1 A 0 A_TakeInventory("BeefSupreme",1)
   Deselecting:
      TNT1 AAAAAAAAAAAA 0 A_Lower
      RPGT H 1 A_Lower
      Loop
   }
}

ACTOR BeefClip : Ammo
{
   Inventory.MaxAmount 9
   Inventory.Icon RPGGX0
   +IGNORESKILL
}

ACTOR BeefSequence : Inventory
{
   Inventory.MaxAmount 3
}

ACTOR BeefReloading : Inventory
{
   Inventory.MaxAmount 1
}

ACTOR BeefProjectile : FastProjectile
{
   Radius 12
   Height 8
   Damage 400
   Speed 175
   Projectile
   Obituary "%o was brought back to society in form of gibs, thanks to %k's ''Beef Supreme''."
   +FORCERADIUSDMG
   MissileType "BeefTrailSpawner"
   States
   {
   Spawn:
      HMIS A 0
      HMIS A 0 ThrustThingZ(0,15,0,1)
   Looplet:
      HMIS A 0 A_PlaySound("Weapons/MopankuLoop",5,1.0,1)
      HMIS A 1 ThrustThingZ(0,random(-4,-5),0,1)
      Loop
   Death:
      TNT1 A 0 A_PlaySound("Weapons/BeefExplode",5)
      TNT1 B 0 A_SpawnItemEx("DeathHeadShock",0,0,20,0,0,0,0,SXF_CLIENTSIDE,0)
      TNT1 A 0 A_SpawnItemEx("BeefExploder",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
      
      TNT1 A 0 A_JumpIfInTargetInventory("NukerUpgrade",1,"NukerDeath")
      TNT1 A 0 A_Explode(400,256,0)
      TNT1 A 0 A_SpawnItemEx("BeefShockBoomSpawner",0,0,20,0,0,0,0,SXF_TRANSFERPOINTERS,0)
      TNT1 A 0 A_SpawnItemEx("BeefShockSmokeSpawner",0,0,20,0,0,0,0,SXF_CLIENTSIDE,0)
      TNT1 BCD 6
      Stop
   NukerDeath:
      TNT1 A 0 A_Explode(800,384,0)
      TNT1 A 0 A_SpawnItemEx("BeefShockNukerFlashSpawner",0,0,20,0,0,0,0,SXF_CLIENTSIDE,0)
      TNT1 A 0 A_SpawnItemEx("BeefShockNukerBoomSpawner",0,0,20,0,0,0,0,SXF_TRANSFERPOINTERS,0)
      TNT1 A 0 A_SpawnItemEx("BeefShockNukerSmokeSpawner",0,0,20,0,0,0,0,SXF_CLIENTSIDE,0)
      TNT1 BCD 6
      Stop
   }
}

ACTOR BeefTrailSpawner
{ 
    +NOGRAVITY
    +NOINTERACTION
	+CLIENTSIDEONLY
    States
    {
    Spawn:
      TNT1 A 0
      TNT1 A 0 A_SpawnItemEx("BeefTrail",-19,0.4*random(10,-10),8,frandom(-1,-0.5),0,0,0,128,0)
      TNT1 A 1
      Stop
    }
}

ACTOR BeefTrail
{
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	Renderstyle Normal
	Alpha 0.15
	Scale 0.2
	States
	{
	Spawn:
	SMKE ABCDEFGHJIKLMNOPQ 1 A_FadeOut(0.01)
	Stop
	}
}

ACTOR BeefExploder
{
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	ReactionTime 7
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_Countdown
	TNT1 A 3 A_SpawnItemEx("BeefExplode",random(4,-4),random(4,-4),random(4,-4),frandom(0.15,0.25),frandom(0.15,0.25),frandom(0.25,0.35),random(0,359),128,0)
	Loop
	Death:
	TNT1 A 42
	Stop
	}
}

ACTOR BeefExplode
{ 
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	Renderstyle Add
	Scale 2.75
	States
	{
	Spawn:
	GRXP ABCDEFGHIJKLMNOPQRSTUVWXYZ 2 Bright //A_SetScale(ScaleX+0.01,ScaleY+0.01)
	Stop
	}
}

ACTOR BeefShockBoomSpawner
{
	+NOINTERACTION
	+NOGRAVITY
	ReactionTime 125
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_Countdown
	TNT1 A 0 A_SpawnItemEx("BeefBoom",frandom(12,-12),frandom(12,-12),frandom(12,-12),frandom(9,8.5),frandom(9,8.5),frandom(1.2,-1.2),random(0,359),SXF_TRANSFERPOINTERS,0)
	Loop
	Death:
	TNT1 A 1
	Stop
	}
}

ACTOR BeefBoom
{
	+NOINTERACTION
	+NOGRAVITY
	+FORCERADIUSDMG
	Renderstyle Add
	States
	{
	Spawn:
	GLX1 ABCDE 3 Bright A_Explode(20,128,0,0)
	GLX2 FGHI 3 Bright A_Explode(20,128,0,0)
	GLX3 JJJKKKLLL 1 A_FadeOut(0.075)
	Stop
	}
}

ACTOR BeefShockSmokeSpawner
{
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	ReactionTime 55
	States
	{
	Spawn:
	TNT1 A 0 A_Countdown
	TNT1 A 0 A_SpawnItemEx("BeefSmokeTrailer",frandom(2,-2),frandom(2,-2),frandom(2,-2),frandom(8,7.5),frandom(8,7.5),frandom(1.2,-1.2),random(0,359),128,0)
	Loop
	Death:
	TNT1 A 1
	Stop
	}
}

ACTOR BeefSmokeTrailer
{
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	ReactionTime 4
	States
	{
	Spawn:
	TNT1 A 8
	Looplet:
	TNT1 A 0 A_Countdown
	TNT1 A 8 A_SpawnItemEx("DeathHeadSmoke",random(15,-15),random(15,-15),random(15,-15),frandom(2,1),frandom(2,1),frandom(1.2,-1.2),random(0,359),128,0)
	Loop
	Death:
	TNT1 A 1
	Stop
	}
}

//NUKER UPGRADE

ACTOR BeefShockNukerFlashSpawner
{
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	ReactionTime 25
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_Countdown
	TNT1 A 0 A_SpawnItemEx("NukerPushkaFlash",frandom(12,-12),frandom(12,-12),frandom(12,-12),frandom(15,15.5),frandom(15,15.5),frandom(1.2,-1.2),random(0,359),128,0)
	Loop
	Death:
	TNT1 A 1
	Stop
	}
}

ACTOR BeefShockNukerBoomSpawner
{
	+NOINTERACTION
	+NOGRAVITY
	ReactionTime 75
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_Countdown
	TNT1 A 0 A_SpawnItemEx("NukerPushkaExploder",frandom(12,-12),frandom(12,-12),frandom(12,-12),frandom(15,15.5),frandom(15,15.5),frandom(1.2,-1.2),random(0,359),SXF_TRANSFERPOINTERS,0)
	Loop
	Death:
	TNT1 A 1
	Stop
	}
}

ACTOR BeefShockNukerSmokeSpawner
{
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	ReactionTime 45
	States
	{
	Spawn:
	TNT1 A 0 A_Countdown
	TNT1 A 0 A_SpawnItemEx("NukerPushkaSmoker",frandom(2,-2),frandom(2,-2),frandom(2,-2),frandom(13,13.5),frandom(13,13.5),frandom(1.2,-1.2),random(0,359),128,0)
	Loop
	Death:
	TNT1 A 1
	Stop
	}
}

actor BeefTurret : WeaponGiver
{
  obituary "%o didn't foresaw the consequences of treading near deployed ''Beef Supreme'' turret."
  inventory.pickupmessage "Packed the turret into the ''Beef Supreme''!"
  radius 15
  height 56
  weapon.ammogive2 0
  mass 1000000
  speed 0
  MaxTargetRange 4096
  dropitem "BeefSupreme"
  MONSTER
  +FLOORCLIP
  +FRIENDLY
  +NOBLOOD
  +CANPASS
  +LOOKALLAROUND
  +NEVERRESPAWN
  +STANDSTILL
  +INVULNERABLE
  +NODAMAGE
  //+MISSILEMORE
  //+MISSILEEVENMORE
  states
  {
  Spawn:
    BFTR A 1 A_Look
    loop
  See:
	//so if there is a target that it can't reach, it will
	//change it's mind after 2 secs and look for another one.
    BFTR A 0 A_JumpIfInventory("BeefCounter",70,"ForgetIt")
    BFTR A 0 A_GiveInventory("BeefCounter",1)
    BFTR A 1 A_Chase
    loop
  ForgetIt:
    BFTR A 0 A_TakeInventory("BeefCounter",999)
    BFTR A 0 A_ClearTarget
	Goto Spawn
  Missile:
    BFTR A 0 A_TakeInventory("BeefCounter",999)
    BFTR A 16 A_FaceTarget
    BFTR A 0 A_AlertMonsters
    BFTR A 0 A_PlayWeaponSound("Weapons/BeefFire")
    BFTR A 0 A_PlaySoundEx("Weapons/BeefAFire","SoundSlot6")
    BFTR B 4 Bright A_CustomMissile("BeefProjectile", 28) 
    BFTR A 8 A_ClearTarget
    goto Spawn
  }
}

actor BeefCounter : Inventory { Inventory.MaxAmount 999 }

actor BeefNukerTurret : BeefTurret
{
  states
  {
  Missile:
    BFTR A 16 A_FaceTarget
    BFTR A 0 A_AlertMonsters
    BFTR A 0 A_PlayWeaponSound("Weapons/BeefFire")
    BFTR A 0 A_PlaySoundEx("Weapons/BeefAFire","SoundSlot6")
    BFTR B 4 Bright A_CustomMissile("BeefNukerProjectile", 28) 
    BFTR A 8 A_ClearTarget
    goto Spawn
  }
}

ACTOR BeefNukerProjectile : BeefProjectile
{
   DamageType Nope
   States
   {
   Death:
      TNT1 A 0 A_PlaySound("Weapons/BeefExplode",5)
      TNT1 B 0 A_SpawnItemEx("DeathHeadShock",0,0,20,0,0,0,0,128,0)
      TNT1 A 0 A_SpawnItemEx("BeefExploder",0,0,0,0,0,0,0,128,0)
      TNT1 A 0 A_Explode(800,384)
      TNT1 A 0 A_SpawnItemEx("BeefShockNukerFlashSpawner",0,0,20,0,0,0,0,128,0)
      TNT1 A 0 A_SpawnItemEx("BeefShockNukerBoomSpawner2",0,0,20,0,0,0,0,128,0)
      TNT1 A 0 A_SpawnItemEx("BeefShockNukerSmokeSpawner",0,0,20,0,0,0,0,128,0)
      TNT1 BCD 6
      Stop
   }
}

ACTOR BeefProjectile2 : BeefProjectile
{
   DamageType Nope
   States
   {
   Death:
      TNT1 A 0 A_PlaySound("Weapons/BeefExplode",5)
      TNT1 B 0 A_SpawnItemEx("DeathHeadShock",0,0,20,0,0,0,0,128,0)
      TNT1 A 0 A_SpawnItemEx("BeefExploder",0,0,0,0,0,0,0,128,0)
      
      TNT1 A 0 A_JumpIfInTargetInventory("NukerUpgrade",1,"NukerDeath")
      TNT1 A 0 A_Explode(400,256)
      TNT1 A 0 A_SpawnItemEx("BeefShockBoomSpawner2",0,0,20,0,0,0,0,SXF_TRANSFERPOINTERS,0)
      TNT1 A 0 A_SpawnItemEx("BeefShockSmokeSpawner",0,0,20,0,0,0,0,SXF_CLIENTSIDE,0)
      TNT1 BCD 6
      Stop
   }
}

ACTOR BeefShockBoomSpawner2 : BeefShockBoomSpawner
{
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_Countdown
	TNT1 A 0 A_SpawnItemEx("BeefBoom2",frandom(12,-12),frandom(12,-12),frandom(12,-12),frandom(9,8.5),frandom(9,8.5),frandom(1.2,-1.2),random(0,359),SXF_TRANSFERPOINTERS,0)
	Loop
	}
}

ACTOR BeefBoom2 : BeefBoom
{
	DamageType Nope
}

ACTOR BeefShockNukerBoomSpawner2 : BeefShockNukerBoomSpawner
{
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_Countdown
	TNT1 A 0 A_SpawnItemEx("NukerPushkaExploder2",frandom(12,-12),frandom(12,-12),frandom(12,-12),frandom(15,15.5),frandom(15,15.5),frandom(1.2,-1.2),random(0,359),SXF_TRANSFERPOINTERS,0)
	Loop
	}
}