//Super Berserker Fists
//Credits:
//Donald Duck for hugeass doomguy arms!
//Xenogenocide for metalized Tank theme from Left 4 Dead
//Valve for sounds and general idea
//I made pickup from Cage's missile ammo box

ACTOR BerserkerFist : Weapon 24529
{
   //$Category Weapons
   //$Title Berserker Pack
   //$Sprite BERYA0
   Tag "Berserker Pack"
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "Interesting berserk pack... (1)"
   Obituary "%o was obliterated by %k's berserker rage."
   Weapon.UpSound ""
   Weapon.SelectionOrder 7
   Weapon.SlotNumber 1
   Weapon.Kickback 10000
   AttackSound ""
   +NOALERT
   +NOAUTOAIM
   +DONTBOB
   States
   {
   Spawn:
      BERY A -1
      Loop
   Ready:
      TNT1 A 0 A_GiveInventory("BerserkerRoarCounter",1)
	  TNT1 A 0 A_JumpIfInventory("BerserkerRoarCounter",210,"CheckScream")
      TNT1 A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
	  TNT1 A 0 A_JumpIfInventory("RO_GotoZoom", 1, "Zoom")
      Loop
   Zoom:
      TNT1 A 0 A_JumpIfInventory("MusicTrigger",1,"TakeReload")
      TNT1 A 0 A_GiveInventory("MusicTrigger",1)
      TNT1 A 0 ACS_Execute(705)
      TNT1 A 0 A_PlaySound("Tank/Theme",7,0.9,1,ATTN_NORM)
	  TNT1 A 7 A_WeaponReady
      Goto Ready
   TakeReload:
      TNT1 A 0 A_TakeInventory("MusicTrigger",1)
      TNT1 A 0 ACS_Execute(706)
	  TNT1 A 0 A_StopSound(7)
	  TNT1 A 7 A_WeaponReady
      Goto Ready
   CheckScream:
      TNT1 A 0 A_TakeInventory("BerserkerRoarCounter",999)
	  TNT1 A 0 A_Jump(128,3)
	  TNT1 A 0 A_AlertMonsters
	  TNT1 A 0 A_Playsound("Tank/Rumble",5)
	  TNT1 A 0
	  Goto Ready
   Deselect:
      TNT1 A 0 ACS_Execute(711,0,100,0,0)
      TNT1 A 0 A_TakeInventory("PowerFrightener",1)
      TNT1 A 0 A_TakeInventory("PowerTankDamage",1)
      TNT1 A 0 A_TakeInventory("BerserkerTrigger",1)
      TNT1 A 0 A_TakeInventory("BerserkerRoarCounter",999)
      TNT1 A 0 A_TakeInventory("BerserkerAttackCounter",9)
      TNT1 A 0 ACS_Execute(706)
	  TNT1 A 0 A_StopSound(7)
      TNT1 A 1 A_Lower
      TNT1 A 0 A_Lower
      TNT1 A 0 A_Lower
      Loop
   Select:
      TNT1 A 0 A_ZoomFactor(0.9)
      TNT1 A 0 ACS_Execute(711,0,50,0,0)
      TNT1 A 0 A_GiveInventory("TankProtector",1)
      TNT1 A 0 A_GiveInventory("BerserkerTrigger",1)
      TNT1 A 0 A_JumpIfInventory("MusicTrigger",1,"DAMUZAK")
   Sniff:
      TNT1 AAAAAAAAAAAAAA 0 A_Raise
      TNT1 A 1 A_Raise
      Loop
   DAMUZAK:
      TNT1 A 0 ACS_Execute(705)
      TNT1 A 0 A_PlaySound("Tank/Theme",7,0.9,1,ATTN_NORM)
      Goto Sniff
   CheckAttack:
      TNT1 A 0 A_Jump(128,3)
	  TNT1 A 0 A_PlaySound("Tank/Attack",6)
	  TNT1 A 0 A_AlertMonsters
	  TNT1 A 0 A_TakeInventory("BerserkerAttackCounter",9)
	  Goto Fire+2
   Fire:
      TNT1 A 0 A_GiveInventory("BerserkerAttackCounter",1)
      TNT1 A 0 A_JumpIfInventory("BerserkerAttackCounter",5,"CheckAttack")
      TNT1 A 0 A_PlaySound("Tank/Swing",1)
      TNT1 A 0 A_Jump(255,"Punch1","Punch2")
   Punch1:
      TFSR ABCDEFGH 1 A_SetAngle(Angle+0.25)
      TNT1 A 0 A_FireCustomMissile("TankExplosivePunch")
      //TNT1 A 0 A_CustomPunch(200,0,0,"TankPunchPuff",200)
      TFSR IJKLM 1 A_SetAngle(Angle+1)
	  TNT1 A 14
	  TNT1 A 10 A_WeaponReady(WRF_NOSECONDARY)
	  Goto Ready
   Punch2:
      TFSL ABCDEFGH 1 A_SetAngle(Angle-0.25)
      TNT1 A 0 A_FireCustomMissile("TankExplosivePunch")
      //TNT1 A 0 A_CustomPunch(200,0,0,"TankPunchPuff",200)
      TFSL IJKLM 1 A_SetAngle(Angle-1)
	  TNT1 A 14
	  TNT1 A 10 A_WeaponReady(WRF_NOSECONDARY)
	  Goto Ready
   Reload:
      TNT1 A 0 A_GiveInventory("TankChickeningOut",1)
      TNT1 A 0 A_AlertMonsters
      TNT1 A 0 A_Playsound("Tank/Roar",5)
      TNT1 A 65 A_Quake(4, 60, 0, 256, none)
      TNT1 A 15 A_WeaponReady(WRF_NOSECONDARY|WRF_NOSWITCH)
      Goto Ready
   AltFire:
      TNT1 A 0 SetPlayerProperty(0,1,0)
	  TNT1 A 10
	  TNT1 A 0 A_PlaySound("Tank/Rock/Lift",5)
	  TNT1 A 0 A_FireCustomMissile("TankRockLift")
      TNT1 A 25 A_Quake(4, 40, 0, 256, none)
      TNT1 A 0 SetPlayerProperty(0,0,0)
      TNT1 A 35
      TNT1 A 0 A_PlaySound("Tank/Swing",1)
	  TNT1 A 0 A_PlaySound("Tank/Attack",6)
      TFSR ABCDEFGH 1 A_SetAngle(Angle+0.25)
      TNT1 A 0 A_FireCustomMissile("TankRock",0,0,15)
      //TNT1 A 0 A_CustomPunch(200,0,0,"TankPunchPuff",200)
      TFSR IJKLM 1 A_SetAngle(Angle+1)
	  TNT1 A 15
	  TNT1 A 10 A_WeaponReady(WRF_NOSECONDARY)
	  Goto Ready
   }
}

ACTOR MusicTrigger : Inventory
{
	Inventory.MaxAmount 1
}

ACTOR BerserkerRoarCounter : Inventory
{
	Inventory.MaxAmount 999
}

ACTOR BerserkerAttackCounter : Inventory
{
	Inventory.MaxAmount 9
}

ACTOR TankExplosivePunch
{
  Radius 10
  Height 16
  Speed 50
  Damage 200
  Projectile
  Obituary "%o was obliterated by %k's berserker rage."
  DeathSound "Tank/Hit"
  +FORCERADIUSDMG
  States
  {
  Spawn:
    TNT1 A 3
    Stop
  Death:
    TNT1 A 0 A_PlaySound("Tank/Impact",5)
    TNT1 A 0 A_Explode(250,128,0)
    TNT1 A 0 A_Quake(3, 10, 0, 256, none)
    TNT1 AA 0 A_SpawnItemEx("DeathHeadSmoke", 0, random(35,-35), random(35,-35), 0.1*random(4,6), 0.1*random(4,6), 0.1*random(3,5), random(0,360),0,0)
    TNT1 A 10
	Stop
  XDeath:
    TNT1 A 0 A_PlaySound("Tank/Impact",5)
    TNT1 A 0 A_Explode(250,128,0)
    TNT1 A 0 A_Quake(3, 10, 0, 256, none)
    TNT1 A 10
	Stop
  }
}

actor TankProtector : PowerupGiver
{
  inventory.pickupmessage "TAAAAAAAAANK!!!"
  powerup.duration 0x7FFFFFFF
  powerup.type "TankDamage"
  +INVENTORY.ALWAYSPICKUP
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.PERSISTENTPOWER
  states
  {
  Spawn:
    TNT1 A -1
    Stop
  }
}

actor PowerTankDamage : PowerProtection
{
damagefactor "normal", 0.5
inventory.icon "TNT1A0"
}

actor TankChickeningOut : PowerupGiver
{
  inventory.pickupmessage "TAAAAAAAAANK!!!"
  powerup.duration -14
  powerup.type "Frightener"
  +INVENTORY.ALWAYSPICKUP
  +INVENTORY.AUTOACTIVATE
  states
  {
  Spawn:
    TNT1 A -1
    Stop
  }
}
actor TankRockLift
{
	+NOINTERACTION
	+CLIENTSIDEONLY
	Scale 0.7
	states
	{
	Spawn:
	TNT1 A 0
	TNT1 A 1 A_ChangeVelocity(80,0,-26,CVF_REPLACE|CVF_RELATIVE)
	TNT1 A 0 A_ChangeVelocity(-7,0,2,CVF_REPLACE|CVF_RELATIVE)
	RCKF BCDEFGHIJKLMN 1
	TNT1 A 0 A_ChangeVelocity(0,0,1,CVF_REPLACE|CVF_RELATIVE)
	RCKF OPQRST 1 //UVWXYZ
	Stop
	}
}

actor TankRock
{
	Radius 24
	Height 32
	Projectile
	Speed 50
	Gravity 0.6
	Damage 100
	-NOGRAVITY
	+THRUGHOST
	+DONTSPLASH
	+EXPLODEONWATER
    +FORCERADIUSDMG
	Scale 0.7
	States
	{
	Spawn:
	TNT1 A 0
    TNT1 A 0 ThrustThingZ(0,random(14,16),0,1)
	TNT1 A 0 A_PlaySound("Tank/Rock/Flight",5,1.0,1)
	Looplo:
	RCKF BCDEFGHIJKLMNOPQRSTUVWXYZ 1
	Loop
	Death:
	TNT1 A 0 A_StopSound(5)
    TNT1 A 0 A_Explode(400,192,0)
	TNT1 A 0 A_PlaySound("Tank/Rock/Impact",6,1.0,0)
	TNT1 A 0 A_Quake (6, 35, 0, 768, "none") 
	TNT1 A 0 A_SpawnItemEx("StoneExplode",0,0,0,0,0,0,0,128,0)
	Stop
	}
}