// Mastodon mech
  Actor Mastodon : MechPlayer_Base
  {
		Health 2500
	Radius 60
	Height 76
	PainChance 0
	Player.DisplayName "Mastodon"
	Player.Forwardmove 0.63
	Player.Sidemove 0
	Player.Maxhealth 2500
	Player.ViewHeight 75
	Player.MorphWeapon "MastodonWeapons"
	Scale 1.5
	States 
	{
	Spawn:
		MDON I 0
		MDON A 0 SetPlayerProperty(0, 0, 3)
		MDON A 0 ACS_ExecuteAlways (SC_STEALTH, 0, STEALTH_FORCEOFF)
		MDON A 0 ACS_Execute(315, 0)
		MDON A 0 A_GiveInventory("MechEjectButton", 1)
		MDON A 0 A_GiveInventory("IsMech", 1)
		MDON A 35
		MDON AAAA 35
		MDON A 35
		Loop
	See:
		TNT1 A 0 SetPlayerProperty (0, 0, 3)
		TNT1 A 0 A_JumpIfHealthLower (500, "SeeD") // Damaged
		TNT1 A 0 A_JumpIf(CallACS("MastodonInput", 0, 0, 0) == 1, "Seebackward")
	SeeForward:
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", 52, 32, 8)
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", 52, -32, 8)
		TNT1 A 0 A_SpawnItemEx ("MechStepSmokePuff", 0, 0, 4)
		MDON B 1
		MDON C 1
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", 52, 32, 8)
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", 52, -32, 8)
		TNT1 A 0 A_SpawnItemEx ("MechStepSmokePuff", 0, 0, 4)
		MDON D 1
		MDON A 1
		TNT1 C 0 A_JumpIf(WaterLevel >= 1, "Drown")
		Goto Spawn
	Seebackward:
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", -52, 32, 8)
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", -52, -32, 8)
		TNT1 A 0 A_SpawnItemEx ("MechStepSmokePuff", 0, 0, 4)
		MDON B 1
		MDON C 1
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", -52, 32, 8)
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", -52, -32, 8)
		TNT1 A 0 A_SpawnItemEx ("MechStepSmokePuff", 0, 0, 4)
		MDON D 1
		MDON A 1
		TNT1 C 0 A_JumpIf(WaterLevel >= 1, "Drown")
		Goto Spawn
	SeeD:
		TNT1 A 0 A_JumpIf(CallACS("MastodonInput", 0, 0, 0) == 1, "SeeDbackward")
	SeeDForward:
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", 52, 32, 8)
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", 52, -32, 8)
		TNT1 A 0 A_SpawnItemEx ("MechStepSmokePuff", 0, 0, 4)
		MDON B 1
		TNT1 A 0 A_SpawnItemEx ("EjectedMechSmokePuff", random(-32,32),random(-32,32),random(96,128), 0,0,3)
		MDON C 1
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", 52, 32, 8)
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", 52, -32, 8)
		TNT1 A 0 A_SpawnItemEx ("MechStepSmokePuff", 0, 0, 4)
		MDON D 1
		MDON A 1
		TNT1 C 0 A_JumpIf(WaterLevel >= 1, "Drown")
		Goto Spawn
	SeeDbackward:
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", -52, 32, 8)
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", -52, -32, 8)
		TNT1 A 0 A_SpawnItemEx ("MechStepSmokePuff", 0, 0, 4)
		MDON B 1
		TNT1 A 0 A_SpawnItemEx ("EjectedMechSmokePuff", random(-32,32),random(-32,32),random(96,128), 0,0,3)
		MDON C 1
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", -52, 32, 8)
		TNT1 A 0 A_SpawnItemEx ("MastodonStepDamage", -52, -32, 8)
		TNT1 A 0 A_SpawnItemEx ("MechStepSmokePuff", 0, 0, 4)
		MDON D 1
		MDON A 1
		TNT1 C 0 A_JumpIf(WaterLevel >= 1, "Drown")
		Goto Spawn

	Melee:
		MDON A 10 bright
		Goto Spawn

	Drown:
		TNT1 A 0 Thing_Damage (0, 300, 12)
		Goto Spawn

	Death:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("IsKamikaze",1,"Death.IonExplosion")
		TNT1 A 0 A_JumpIfInventory("IsBombCrate", 1, "Death.BombExplosion")
		Goto DeathGo

	DeathGo:
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_StopSound (6)
		TNT1 A 0 A_StopSound (CHAN_WEAPON)
		MDON A 1
		MDON A 1 A_SpawnItemEx ("MechExplosionSmall", 0,0,0,0,0,0,0, SXF_NOCHECKPOSITION)
		MDON A 10 Bright
		DISR Z -1 A_SetTranslucent(0,0.0)
		Stop

	Death.IonExplosion:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory ("IsRed", 1, "Death.NukeExplosion")
		TNT1 A 0 A_SpawnItemEx ("BlueStrikeKamikaze", 0, 0, 32)
		Goto DeathGo

	Death.NukeExplosion:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("NukeKamikaze", 0, 0, 32)
		Goto DeathGo

	Death.BombExplosion:
		MDON A 0
		MDON A 0 A_SpawnItemEx("BombExplosion")
		Goto DeathGo
	}
  }


  Actor MastodonStepDamage
  {
	RenderStyle None
	+RANDOMIZE
	+NOCLIP
	+NODAMAGETHRUST
	-TELESTOMP
	PROJECTILE
	Speed 1
	Damage 0
	Scale 0.7
	Damagetype "MechStomp"
	States
	{
	  Spawn:
	  TNT1 A 0
	  ROB1 D 0 Radius_Quake(2,2,0,2,0)
	  PUFF A 0 A_SpawnItemEx("MastodonStepSound", 0, 0, 0, 0, 0, 0, 0, 128, 0)
	  TNT1 A 10 bright A_Explode(52,52,0)
	  Stop
	}
  }


  Actor MastodonStepSound
  {
	+CLIENTSIDEONLY
	-TELESTOMP
	Radius 1
	Height 1
	+NoClip
	States
	{
	  Spawn:
	  TNT1 A 0
	  TNT1 A 1 A_PlaySound("tanktr", 6, 0.25)
	  Stop
	}
  }


  Actor MastodonUsed : Mastodon { Health 1000 }

actor PowerMastodon : AOWMorph {powermorph.playerclass "Mastodon"}
actor PowerMastodon2 : AOWMorph {PowerMorph.PlayerClass "MastodonUsed"}
actor MastodonSwitch : PermanentPowerup {Powerup.Type "Mastodon"}
actor MastodonSwitch2 : PermanentPowerup {Powerup.Type "Mastodon2"}

  Actor MastodonSwitchPickup : CustomInventory
  {
	Inventory.Pickupsound "mech/start"
	+INVENTORY.AUTOACTIVATE
	Scale 1.5
	States
	{
	  Spawn:
	  MDON E -1
	  Stop
	  
	  Pickup:
	  TNT1 A 0 ACS_ExecuteWithResult (353, 0)
	  Stop
	  
	  Use:
	  TNT1 A 0 A_GiveInventory ("MastodonSwitch2", 1)
	  TNT1 A 0 A_GiveInventory ("IsMech", 1)
	  TNT1 A 0 A_GiveInventory("MechEjectButton",1)
	  Stop
	}
  }


  Actor MastodonWeapons : AOWWeapon
  {
	Weapon.SelectionOrder 1
	Obituary "%o was destroyed by %k's Mastodon."
	-NOAUTOAIM
	+WEAPON.CHEATNOTWEAPON
	+WEAPON.DONTBOB
	Weapon.AmmoType "DonRocketAmmo"
	Weapon.AmmoType2 "DonFireAmmo"
	States
	{
	  Ready:
	  MHUD A 1 A_WeaponReady
	  Wait
	  
	  Deselect:
	  MHUD A 0 A_JumpIfHealthLower(1,1)
	  Goto Ready
	  MHUD CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 0 A_Lower
	  TNT1 A 1 A_Lower
	  Wait
	  
	  Select:
	  MHUD C 0
	  MHUD CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 0 A_Raise
	  MHUD C 1 A_Raise
	  Goto Select+31
	  
	  WaitReload:
	  MHUD A 0
	  MHUD A 2
	  MHUD A 2 A_ReFire
	  Goto Ready
	  
	  Fire:
	  NHUD A 0
	  MHUD A 0 A_JumpIfInventory ("DonRocketAmmo", 2, "FireMissiles")
	  Goto Ready
	  
	  FireMissiles:
	  MHUD A 2 A_PlayWeaponSound ("tanksh")
	  MHUD B 0 Radius_Quake (2, 25, 0, 1, 0)
	  MHUD A 0 A_TakeInventory ("DonRocketAmmo", 2)
	  MHUD B 0 Bright A_GunFlash
	  MHUD B 2
	  TNT1 A 0 A_FireCustomMissile ("DonHomingMissile", 0, 0, 16, 36)
	  TNT1 A 0 A_FireCustomMissile ("OrcaFireFlame", 0, 0, 16, 36)
	  TNT1 A 0 A_FireCustomMissile ("DonHomingMissile", 0, 0, -16, 36)
	  TNT1 A 0 A_FireCustomMissile ("OrcaFireFlame", 0, 0, -16, 36)
	  MHUD A 30
	  TNT1 A 0 A_PlaySound("lrm/reload", 7)
	  MHUD A 20
	  MHUD A 2 A_Refire
	  Goto Ready
	  
	  AltFire:
	  NHUD A 0
	  MHUD A 0 A_JumpIfInventory ("DonFireAmmo", 2, "FireMissiles2")
	  Goto Ready
	  
	  FireMissiles2:
	  MHUD A 2 A_PlayWeaponSound ("tanksh")
	  MHUD B 0 Radius_Quake (2, 25, 0, 1, 0)
	  MHUD A 0 A_TakeInventory ("DonFireAmmo", 2)
	  MHUD B 0 Bright A_GunFlash
	  MHUD B 2
	  TNT1 A 0 A_FireCustomMissile ("DonFireGrenade", 0, 0, 16, 32)
	  TNT1 A 0 A_FireCustomMissile ("OrcaFireFlame", 0, 0, -16, 32)
	  TNT1 A 0 A_FireCustomMissile ("DonFireGrenade", 0, 0, -16, 32)
	  TNT1 A 0 A_FireCustomMissile ("OrcaFireFlame", 0, 0, -16, 32)
	  MHUD A 30
	  TNT1 A 0 A_PlaySound("lrm/reload", 7)
	  MHUD A 20
	  MHUD A 2 A_Refire
	  Goto Ready
	  
	  Flash:
	  TNT1 A 1 Bright A_Light2
	  TNT1 A 2 Bright A_Light1
	  Goto LightDone
	  	  
	  Spawn:
	  TNT1 A 0
	  Stop
	}
  }


  Actor DonHomingMissile : HeavyMissile
  {
   //+SEEKERMISSILE
	Damage(50)
	Speed 50
	Obituary "$OB_SEEKERMISSILE"
	States
	{
	  Spawn:
	  TNT1 A 4 Bright
	  //TNT1 A 0 Bright A_PlaySound ("seeker/beep", CHAN_ITEM, 0.5, True)
	  TNT1 A 0 bright A_PlaySound ("ambient/rocket", CHAN_BODY, 0.5, True)
	  Goto Fly
	  
	  Fly:
	  MISR A 0 A_SpawnItemEx ("HeavyMissileSmoke", -16)
	  MISR A 8 Bright //A_SeekerMissile (30, 60)
	  Loop
	  
	  TNT1 A 0 A_StopSound (CHAN_ITEM)
	  Goto Super::Death
	}
  }
  
  
  Actor DonFireGrenade
  {
	Radius 13
	Height 13
	Damage (30)
	Speed 30
	Projectile
	Gravity .5
	-NOGRAVITY
	DeathSound "tankflame"
	DamageType "Explosion"
	States
	{
	  Spawn:
	  TNT1 A 3
	  Goto Fly
	  
	  Fly:
	  MCGR AB 3
	  Loop
	  
	  Death:
	  TNT1 A 0 A_Explode(64, 128)
	  TNT1 A 0 A_SpawnItem("DonFlameDecay")
	  TNT1 A 0 A_SpawnItem("ExplosionSmall")
	  Stop
	}
  }

Actor DonFlameFX : FlameFX {
	Radius 24
	Height 60
	States
	{
	Spawn:
	  TNT1 A 0
	  MFLM A 4 Bright
	  MFLM BCDEFGH 4 Bright
	  MFLM ABCDEFGHABCDEFGH 4 Bright A_FadeOut(0.1)
	  Stop
	Death:
	  MFLM A 2 Bright
	  MFLM BCDEFGH 4 Bright
	  MFLM ABCDEFGHABCDEFGH 4 Bright A_FadeOut(0.1)
	  Stop
	}
  }


  Actor DonFlameDecay : FlameDecay {
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_SpawnItemEx ("DonFlameDecayFX")
	  TNT1 A 0 A_PlaySoundEx("fire/fire","SoundSlot6",1)
	Idle:
	  TNT1 A 15 Bright A_Explode (32, 128)
	  TNT1 A 0 A_CountDown
	  Loop
	}
  }


  Actor DonFlameDecayFX : FlameDecayFX {
	States
	{
	Spawn:
	  TNT1 AAAAAAAAAAA 5 A_SpawnItemEx("DonFlameFX", random(-16,16), random(-16,16), random(0,8), 0, 0, random(1,2), 0, 128, 0)
	  TNT1 AAAAAAAAAAA 5 A_SpawnItemEx("DonFlameFX", random(-16,16), random(-16,16), random(0,8), 0, 0, random(1,2), 0, 128, 0)
	  TNT1 AAAAAAAAAAA 5 A_SpawnItemEx("DonFlameFX", random(-16,16), random(-16,16), random(0,8), 0, 0, random(1,2), 0, 128, 0)
	  Stop
	}
  }

  Actor DamagedMastodon
  {
	Health 300
	Radius 58
	Height 128
	Mass 2000
	Scale 1.5
	-SOLID
	-NOBLOCKMAP
	-NOCLIP
	+SHOOTABLE
	PainChance 0
	Bloodtype "HHMetalHit"
	Bloodcolor "White"
	Obituary "%o went boom."
	Translation "112:127=[255,255,255]:[0,0,0]"
	DamageFactor "Disarm", 0.0
	States
	{
	  Spawn:
	  MDON EEEE 35
	  MDON E 35 
	  MDON EEEE 5 A_SpawnItemEx("EjectedMechSmokePuff",random(-32,32),random(-32,32),random(96,128),0,0,3,0,128,0)
	  MDON E 5 A_SpawnItemEx("EjectedMechSmokePuff",random(-32,32),random(-32,32),random(96,128),0,0,3,0,128,0)
	  Goto Spawn+5
	  
	  Death:
	  MDON E 0
	  MDON E 10 A_NoBlocking
	  MDON E 10 A_SpawnItemEx ("MechExplosionSmall", 0,0,0,0,0,0,0, SXF_NOCHECKPOSITION)
	  DISR K -1
	  Stop
	}
  }


  Actor EjectedMastodon
  {
    Scale 1.5
	Translation "112:127=[255,255,255]:[0,0,0]"
	States
	{
	  Spawn:
	  MDON EEEE 35
	  MDON A 0 A_SpawnItemEx ("MastodonSwitchPickup")
	  Stop
	}
  }


  Actor DonRocketAmmo : Ammo
  {
    Inventory.amount 2
	Inventory.maxamount 80
	Ammo.backpackamount 10
	Ammo.backpackmaxamount 80
  }


  Actor DonFireAmmo : Ammo
  {
    Inventory.amount 2
	Inventory.maxamount 80
	Ammo.backpackamount 10
	Ammo.backpackmaxamount 80
  }
  

  Actor MastodonAmmoPackage : CustomInventory
  {
	+AUTOACTIVATE
	Inventory.Maxamount 0
	States
	{
	  Pickup:
	  TNT1 A 0 A_GiveInventory ("DonRocketAmmo", 40)
	  TNT1 A 0 A_GiveInventory ("DonFireAmmo", 40)
	  Stop
	}
  }
