//Sergeant Mark IV's vehicles.
//If you want to modify and reuse this on your wad, please ask me first.

Actor MechBaseNotReal
{
+THRUACTORS
Scale 1.0
+NOTIMEFREEZE
+CLIENTSIDEONLY
+FLOORCLIP
+NOGRAVITY
+FLOAT
+NOBLOCKMAP
+NEVERTARGET
+CANTSEEK
Mass 22700//25 ton
Radius 0
Height 0
Gravity 0
States
{
Spawn:
TNT1 A 0
MECH A 8
Stop
}}

ACTOR Mech: Tank 7263
{
	//$Category BD Vehicles
	//$Colour rgb(200, 200, 200)
	//$Sprite MECHA1
	Scale 1.0
	Radius 49
	Height 120
	+SOLID
	+USESPECIAL
	MONSTER
	-COUNTKILL
	+SHOOTABLE
	+THRUACTORS
	+NOINFIGHTING
	+NORADIUSDMG
	+NEVERTARGET
	MaxTargetRange 120
	BloodType "TankBlood", "TankBlood", "TankBlood"
	Activation THINGSPEC_Activate | THINGSPEC_ThingTargets | THINGSPEC_NoDeathSpecial
	Mass 22700//25 ton
	Speed 0
	Health 1000
    States
    {
    Spawn:
	    TNT1 A 1
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 0 ACS_NamedExecuteAlways("BDSetNewTankDirection", 0, 0, 0, 0)//Check vehicle initial angle.
		TNT1 A 1 A_ChangeFlag("FRIENDLY", 0)
		TNT1 A 0 A_SpawnItem("MechBaseNotReal")
		TNT1 A 5
		TNT1 A 0 Thing_ChangeTID(0, 0)
		TNK1 C 0 A_ChangeFlag("THRUACTORS", 0)
		TNT1 A 0 A_ChangeFlag("FRIENDLY", 1)
		Goto StandingHere

	  StandingHere:
		MECH A 7
		TNT1 A 0 A_SpawnItem("MechBaseNotReal")
		//TNT1 A 0 A_SpawnItem("StationedVehicleCheckRepairs")
		Loop

	Active:
		TNT1 A 0
		TNT1 A 0 A_ChangeFLag("NOPAIN", 1)
		TNT1 A 0 A_TakeFromTarget("PowerInvulnerable", 1)
		TNT1 A 0 A_GiveToTarget("CeaseMorph", 1)
		MECH A 0 A_ChangeFlag("FRIENDLY", 0)
		//TNT1 A 0 A_Look
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 0 ACS_NamedExecuteAlways("GetVehiclePreviousHealth", 0, 0, 0, 0)//Check Vehicle Health
		//TNT1 A 0 A_Chase("","",CHF_DONTMOVE )
		TNT1 A 0 A_GiveToTarget("CheckingMorphingPlayerHealth", 1)
		TNT1 A 0 A_SpawnItem("MechBaseNotReal")
		TNT1 A 3
		TNT1 A 0 A_GiveToTarget("MechMorpher", 1)
		TNT1 A 0 A_GiveToTarget("HeavyMachinegunAmmo", 2000)
		TNT1 A 0 A_GiveToTarget("MechRocketAmmo", 60)
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 0 A_NoBlocking
		TNT1 A 1
		TNT1 A 0 A_ChangeFlag("USESPECIAL", 0)
		TNT1 A 10
		TNT1 A 0 Thing_ChangeTID(0, 0)
		TNT1 A 1
		Stop
	Death:
	TNT1 A 1
	TNT1 A 0 A_ChangeFlag("USESPECIAL", 0)
	TNT1 A 0 A_SpawnItem("BigExplosion1112")
	TNT1 A 0 A_PlaySound("weapons/explode")
	TNT1 A 0 A_PlaySound("EXPLOSIO", 3)
	TNT1 A 0 A_NoBlocking
	NULL AAAAAA 0 A_CustomMissile ("MetalShard1", 96, 0, random (0, 360), 2, random (0, 180))
	NULL AAAAAA 0 A_CustomMissile ("MetalShard2", 96, 0, random (0, 360), 2, random (0, 180))
	NULL AAAAAAAAA 0 A_CustomMissile ("BDGlassShard", 96, 0, random (0, 360), 2, random (0, 360))
	TNT1 A 0 A_SpawnItem("DestroyedArmouredVehicleTemp")
	ELEC A 0 A_Explode(100, 250)
	TNT1 A 15
	TNT1 A 0
	Stop

	Pain.Repair:
		TNT1 A 0
		TNT1 A 0 A_ChangeFLag("NOPAIN", 1)
		TNT1 A 0 HealThing(80)
		TNT1 A 0 A_JumpIfInventory("HeavyMachinegunAmmo", 2000, 2)
		TNT1 A 0 A_GiveInventory("HeavyMachinegunAmmo", 133)
		TNT1 A 0 A_JumpIfInventory("MechRocketAmmo", 60, 2)
		TNT1 A 0 A_GiveInventory("MechRocketAmmo", 4)
		MECH A 1
		TNT1 A 0 A_ChangeFLag("NOPAIN", 0)
		Goto StandingHere
	}
}

ACTOR MechUsed: Mech
{
    States
    {
	Spawn:
		TNT1 A 0
	    TNT1 A 1
		TNT1 A 0 ACS_NamedExecuteAlways("BDSetBaseAngle", 0, 0, 0, 0)//SpawnVehicleBase
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 1 A_ChangeFlag("FRIENDLY", 0)
		TNT1 A 5
		TNT1 A 0 Thing_ChangeTID(0, 0)
		TNK1 C 0 A_ChangeFlag("THRUACTORS", 0)
		TNT1 A 0 A_ChangeFlag("FRIENDLY", 1)
		TNT1 A 0 ACS_NamedExecuteAlways("BDCheckOnline")
		Goto StandingHere

	IsOnline:
		TNT1 A 0
		TNT1 A 1
		//TNT1 A 0 A_TAkeInventory("MechBaseDirection", 500)
		Goto StandingHere

	Active:
		TNT1 A 0
		TNT1 A 0 A_ChangeFLag("NOPAIN", 1)
		TNT1 A 0 A_TakeFromTarget("PowerInvulnerable", 1)
		TNT1 A 0 A_GiveToTarget("CeaseMorph", 1)
		TTR1 A 0 A_ChangeFlag("FRIENDLY", 0)
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 0 ACS_NamedExecuteAlways("GetVehiclePreviousHealth", 0, 0, 0, 0)//Check Vehicle Health
		//TNT1 A 0 A_Chase("","",CHF_DONTMOVE )
		TNT1 A 0 A_GiveToTarget("CheckingMorphingPlayerHealth", 1)
		TNT1 A 3
		TNT1 A 0 A_GiveToTarget("MechMorpher", 1)
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 0 A_NoBlocking
		TNT1 A 1
		TNT1 A 0 A_ChangeFlag("USESPECIAL", 0)
		TNT1 A 10
		TNT1 A 0 Thing_ChangeTID(0, 0)
		Stop
	}
}

ACTOR PowerMechSwitch : PowerMorph {PowerMorph.PlayerClass "PlayerMech"}

ACTOR MechMorpher : CustomInventory
{
  States
  {
  PickUp:
  TNT1 A 1
  TNT1 A 0 ACS_NamedExecuteAlways("BDEnterTank", 0, 0, 0, 0)//Get into Mech
  TNT1 A 0 A_GiveInventory("MechMorphActivation")
  TNT1 A 0 A_SpawnItem("CancelTeleportFog")
  TNT1 A 1
  Stop
  }
 }

ACTOR MechMorphActivation : PowerupGiver
{
  Powerup.Type "PowerMechSwitch"
  Powerup.Duration 252000
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 1
  Health 100
  GibHealth 1
  Mass 9999
  Height 96
  Radius 32
  States
  {
  Spawn:
  TNT1 A 100
  Stop

  PickUp:
  TNT1 A 1
  TNT1 A 1
  Stop
  }
 }

ACTOR PlayerMech : PlayerTank
{
	Speed 1.0
	Player.ForwardMove 1.83, 1.3725
	Player.SideMove 1.83, 1.3725
	Scale 1.0
	Radius 49
	Height 120
	Mass 22700//25 ton
	PainChance 0
	Health 1000
	-PICKUP
	player.viewheight 94
    player.attackzoffset 34//94 high = 0 z-offset
	MaxStepHeight 40
	Player.MorphWeapon "MechGun"
	States
	{

	ExitVehicle:
	TNT1 A 1 A_Stop
	TNT1 A 0 A_ChangeFlag(NOPAIN, 1)
	TNT1 A 0 A_TakeInventory("PressedUse", 1)

	TNT1 A 0 A_SpawnItemEx ("TransferPlayerOutOfVehicle", 128, 0, 4)

	TNT1 A 3
	TNT1 A 0 A_JumpIfInventory("CanLeaveVehicle", 1, "CanExit")
	TNT1 A 0 A_ChangeFlag(NOPAIN, 0)
	TNT1 A 0 A_Print("Can't leave from this direction", 1)
	Goto Stay

	CanExit:
	TNT1 A 0
	TNT1 A 2 A_TakeInventory("IsInATank", 1)
	TNT1 A 0 A_TakeInventory("PressedUse", 1)
	TNT1 A 0 A_TakeInventory("CanLeaveVehicle", 1)
	TNT1 A 0 A_TakeInventory("TankZoom", 1)
	TNT1 A 0 A_Takeinventory("FlashlightOn",1)
	TNT1 A 0 A_TakEinventory("PowerLightAmp", 1)
	TNT1 A 0 ACS_NamedExecuteAlways("BDLeaveTank")
	TNT1 A 0 A_SpawnItemEx ("MechUsed", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
	Goto FinishExit

	FinishExit:
	TNT1 A 0 A_TakeInventory("PressedUse", 1)
	TNT1 AAA 10 A_TakeInventory("PressedUse", 1)
	TNT1 A 0 A_TakeInventory("PressedUse", 1)
	Goto Stay

	Spawn:
	Spawn2:
		MECH A 4
		TNT1 A 0 ACS_NamedExecuteAlways("BDVehicleInputs", 0, 0, 0, 0)//Button-checker for vehicle actions
		MARN A 0 ACS_NamedExecuteAlways("CheckIfDM", 0, 0, 0, 0)//Check if Deathmatch
		TNT1 A 0 A_PlaySound("REPAIR")
	    TNT1 A 0 A_TakeInventory("PressedUse", 1)
		TNT1 A 0 A_TakeInventory("PressedJump", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_TakeInventory("BackPedal", 1)
		MECH A 15
		TNT1 A 0 A_TakeInventory("PressedJump", 1)
		TNT1 A 0 A_TakeInventory("PressedUse", 1)
		TNT1 A 0 A_Print ("A", 2, "TUTO4")
	Goto Stay

	Stay:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(velz < 0, "FallingNoJump")
		TNT1 A 0 A_JumpIf(velz > 0, "FallingNoJump")
		MECH G 1
		TNT1 A 0 A_JumpIfInventory("PressedJump", 1, "Jump")
		TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "MoveForward")
		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "MoveForward")
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")

		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "MoveForward")
		TNT1 A 0 A_JumpIfInventory("Backpedal", 1, "MoveBackward")
		Loop

	MoveForward:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(velz < 0, "FallingNoJump")
		TNT1 A 0 A_JumpIf(velz > 0, "FallingNoJump")
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_TakeInventory("Backpedal", 1)
		MECH BC 4 A_SetPitch(pitch -0.1)
		TNT1 A 0 A_JumpIfInventory("PressedJump", 1, "Jump")
		TNT1 A 0 A_JumpIf(velz < 0, "FallingNoJump")
		TNT1 A 0 A_JumpIf(velz > 0, "FallingNoJump")
		TNT1 A 0 A_SpawnItem("MechStomp")
		TNT1 A 0 A_PlaySound("MECHWLK", 15)
		MECH D 4 A_SetPitch(pitch +0.2)
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_JumpIfInventory("Backpedal", 1, "MoveBackward")
		MECH EF 4 A_SetPitch(pitch -0.1)
		TNT1 A 0 A_JumpIfInventory("PressedJump", 1, "Jump")
		TNT1 A 0 A_JumpIf(velz < 0, "FallingNoJump")
		TNT1 A 0 A_JumpIf(velz > 0, "FallingNoJump")
		TNT1 A 0 A_SpawnItem("MechStomp")
		TNT1 A 0 A_PlaySound("MECHWLK", 15)
		MECH G 4 A_SetPitch(pitch +0.2)
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_JumpIfInventory("Backpedal", 1, "MoveBackward")
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_TakeInventory("Backpedal", 1)
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		Goto Stay

	MoveBackward:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(velz < 0, "FallingNoJump")
		TNT1 A 0 A_JumpIf(velz > 0, "FallingNoJump")
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_TakeInventory("Backpedal", 1)
		MECH GF 4 A_SetPitch(pitch -0.1)
		TNT1 A 0 A_JumpIfInventory("PressedJump", 1, "Jump")
		TNT1 A 0 A_JumpIf(velz < 0, "FallingNoJump")
		TNT1 A 0 A_JumpIf(velz > 0, "FallingNoJump")
		TNT1 A 0 A_SpawnItem("MechStomp")
		TNT1 A 0 A_PlaySound("MECHWLK", 15)
		MECH E 4 A_SetPitch(pitch +0.2)
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_JumpIfInventory("Backpedal", 1, "MoveBackward")
		MECH DC 4 A_SetPitch(pitch -0.1)
		TNT1 A 0 A_JumpIfInventory("PressedJump", 1, "Jump")
		TNT1 A 0 A_JumpIf(velz < 0, "FallingNoJump")
		TNT1 A 0 A_JumpIf(velz > 0, "FallingNoJump")
		TNT1 A 0 A_SpawnItem("MechStomp")
		TNT1 A 0 A_PlaySound("MECHWLK", 15)
		MECH B 4 A_SetPitch(pitch +0.2)
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_JumpIfInventory("Backpedal", 1, "MoveBackward")
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_TakeInventory("Backpedal", 1)
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		Goto Stay

	//See:
		MECH BCDEFG 4
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		Goto Stay

	FallingNoJump:
		MECH HHH 2 A_JumpIf(velz == 0, "Stay")
		MECH HHHHHH 2 A_JumpIf(velz == 0, "HitGroundEasy")
		MECH HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH 2 A_JumpIf(velz == 0, "HitGround")
		MECH HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH 2 A_JumpIf(velz == 0, "HitGround")
		Loop

	HitGroundEasy:
		TNT1 A 0
		TNT1 A 0 A_SpawnItem("MechStompLand")
		TNT1 A 0 A_Stop
		TNT1 A 0 A_TakeInventory("PressedJump", 1)
		Goto Stay

	Jump:
		TNT1 A 0
		TNT1 A 0 ThrustThingZ(0,96,0,1)
		TNT1 A 0 A_PlaySound("MECHJUMP")
		TNT1 A 0 A_TakeInventory("PressedJump", 1)

	JumpAnimation:
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		MECH H 2
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, 25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_SpawnItemEx("BlueFlameTrails", -49, -25, 0, 0, 0, -3, 180)
		TNT1 A 0 A_TakeInventory("PressedJump", 1)
		Goto Falling

	Falling:
		MECH H 2
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_TakeiNVENTORY("PowerFlight", 1)
		TNT1 A 0 A_TakeiNVENTORY("PressedJump", 1)
		TNT1 A 0 A_JumpIf(velz == 0, "HitGround")
		Loop

	HitGround:
		TNT1 A 0
		TNT1 A 0 A_SpawnItem("MechStompLand")
		TNT1 A 0 A_SpawnItem("MechStompLand2")
		TNT1 A 0 A_Stop
		TNT1 A 0 A_SpawnItem("CrashTankIntotheGround1")
		TNT1 A 0 A_SpawnItem("CrashTankIntotheGround2")
		TNT1 A 0 Radius_Quake(2, 35, 0, 5, 0)
		TNT1 A 0 A_PlaySound("BIKECLW", 1)
		TNT1 A 0 A_PlaySound("EBIKECLS", 2)
		MECH A 20
		TNT1 A 0 A_TakeInventory("PressedJump", 1)
		Goto Stay

	Death:
	XDeath:
    TNT1 A 1
	TNT1 A 0 A_SpawnItem("BigExplosion1112")
	TNT1 A 0 A_PlaySound("weapons/explode")
	TNT1 A 0 A_PlaySound("EXPLOSIO", 3)
	TNT1 A 0 A_Scream
	TNT1 A 0 A_NoBlocking
	NULL AAAAAA 0 A_CustomMissile ("MetalShard1", 96, 0, random (0, 360), 2, random (0, 180))
	NULL AAAAAA 0 A_CustomMissile ("MetalShard2", 96, 0, random (0, 360), 2, random (0, 180))
	NULL AAAAAAAAA 0 A_CustomMissile ("BDGlassShard", 96, 0, random (0, 360), 2, random (0, 360))
	ELEC A 0 A_Explode(100, 250)
	TNT1 A 0 A_SpawnItem("DestroyedArmouredVehicleTemp")
	8762 A 5
	TNT1 A 0 A_TakeInventory("MechGun", 1)
	8762 A 100
	8762 A -1
	Stop

	Pain.Repair:
		TNT1 A 0
		MECH A 1 A_PlaySound("vehicle/pain")
		TNT1 A 0 HealThing(80)
		TNT1 A 0 A_JumpIfInventory("HeavyMachinegunAmmo", 2000, 2)
		TNT1 A 0 A_GiveInventory("HeavyMachinegunAmmo", 133)
		TNT1 A 0 A_JumpIfInventory("MechRocketAmmo", 60, 2)
		TNT1 A 0 A_GiveInventory("MechRocketAmmo", 4)
		MECH A 1
		Goto Stay

	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Vehicle's weapons and misc
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ACTOR MechGun : DoomWeapon
{
	Game Doom
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Obituary "%o was destroyed by a mech."
	Weapon.SelectionOrder 9999
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.ALT_AMMO_OPTIONAL
	+WEAPON.NOAUTOAIM
	+WEAPON.EXPLOSIVE
	+WEAPON.CHEATNOTWEAPON
	+WEAPON.BFG
	+WEAPON.NO_AUTO_SWITCH
	Weapon.BobRangeX 0.2
	Weapon.BobRangeY 0.4
	Weapon.BobSpeed 2.9
	Weapon.BobStyle Smooth
	Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED"
	Tag "Mech"
	States
	{
	Ready:
	    TNT1 A 0
		MEKH A 7
		TNT1 A 0 A_TakeInventory("PressedUse", 9)
		TNT1 A 0 A_TakeInventory("PressedJump", 9)
		TNT1 A 0 A_TakeInventory("TankZoom", 1)
		MEKH A 1 A_GunFlash
		TNT1 A 0 A_SetCrossHair(22)
		Goto ReadyToFire

	ReadyToFire:
		TNT1 A 0 A_JumpIfinventory("TankZoom", 1, "ReadyZoom")
		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"SwitchFlashlight")
		TNT1 A 0 A_JumpIfInventory("Kicking", 1, "ZoomMode")
		MEKH A 2 A_WeaponReady(1)
		Loop

	ReadyZoom:
		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"SwitchFlashlight")
		TNT1 A 0 A_JumpIfInventory("Kicking", 1, "ZoomMode")
		TNT1 A 2 A_WeaponReady(1)
		Loop

	ZoomMode:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 A_JumpIfinventory("TankZoom", 1, "StopZoom")
		TNT1 A 0 A_ZoomFactor(5.0)
		TNT1 A 0 A_GiveInventory("TankZoom")
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("Kicking", 1)
		Goto ReadyZoom

	StopZoom:
		TNT1 A 0
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_TakeInventory("TankZoom", 1)
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("Kicking", 1)
		Goto ReadyToFire

	Deselect:
		TNT1 A 1 A_Lower
		TNT1 A 0 SetPlayerProperty(0,0,4)
		TNT1 A 0 A_TakeInventory("MechGun")
		Loop
	Select:
		TNT1 A 1 A_Raise
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
		TNT1 A 1 A_Raise
		Goto Ready

	NoAmmo:
		MEKH A 7
		TNT1 A 0 A_Print("Ammunition Depleted", 2)
		Goto ReadyToFire

	NoAmmoZoom:
		TNT1 A 7
		TNT1 A 0 A_Print("Ammunition Depleted", 2)
		Goto ReadyZoom

	RechargingZoom:
		TNT1 A 7
		TNT1 A 0 A_Print("Recharging", 2)
		TNT1 A 0 A_PlaySound("BEPBEP")
		Goto ReadyZoom

	ReloadingZoom:
		TNT1 A 7
		TNT1 A 0 A_Print("Reloading", 2)
		Goto ReadyZoom

	Fire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("MechFireMode", 2, "Rocket")
		TNT1 A 0 A_JumpIfInventory("MechFireMode", 1, "Laser")

	Machinegun:
		MEKH A 0
		MEKH A 0 A_JumpIfinventory("TankZoom", 1, "MachinegunZoom")
		MEKH A 0 A_PlaySound("CHAINSTA", 3)
		MEKH A 5
	FireContinue:
		MEKH A 0 A_JumpIfInventory("HeavyMachinegunAmmo", 2, 2)
		MEKH A 0 A_PlaySound("CHAINSTO", 3)
		Goto NoAmmo
		MEKH A 0 A_PlaySound("TANKMG", 1)
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundHMG", random(-1,1), 0, 0, -12, 0, random(-1,1))
		MEKH A 0 A_FireCustomMissile("Alerter", 0, 0, 0, 0)

		MEKH A 0 A_FireCustomMissile("HeavyMachinegunProjectile", 0.5, 0, 64, -8, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("HeavyMachinegunProjectile", -0.5, 0, -64, -8, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("HeavyMachinegunFlash", 0, 0, 64, -8, 0, 0)
		MEKH A 0 A_FireCustomMissile("HeavyMachinegunFlash", 0, 0, -64, -8, 0, 0)
		MEKH A 0 A_TakeInventory("HeavyMachinegunAmmo", 2)
		MEKH A 3 BRIGHT

		MEKH A 0 A_ReFire("FireContinue")
		MEKH A 0 A_PlaySound("CHAINSTO", 3)
		Goto ReadyToFire

	MachinegunZoom:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("CHAINSTA", 3)
		TNT1 A 5
	MachinegunZoomContinue:
		TNT1 A 0 A_JumpIfInventory("HeavyMachinegunAmmo", 2, 2)
		TNT1 A 0 A_PlaySound("CHAINSTO", 3)
		Goto NoAmmoZoom
		TNT1 A 0 A_PlaySound("TANKMG", 1)
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundHMG", random(-1,1), 0, 0, -12, 0, random(-1,1))
		TNT1 A 0 A_FireCustomMissile("Alerter", 0, 0, 0, 0)

		MEKH A 0 A_FireCustomMissile("HeavyMachinegunProjectile", 0.5, 0, 64, -8, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("HeavyMachinegunProjectile", -0.5, 0, -64, -8, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("HeavyMachinegunFlash", 0, 0, 64, -8, 0, 0)
		MEKH A 0 A_FireCustomMissile("HeavyMachinegunFlash", 0, 0, -64, -8, 0, 0)
		TNT1 A 0 A_TakeInventory("HeavyMachinegunAmmo", 2)
		TNT1 A 3 BRIGHT

		TNT1 A 0 A_ReFire("MachinegunZoomContinue")
		TNT1 A 0 A_PlaySound("CHAINSTO", 3)
		Goto ReadyZoom

	Laser:
		TNT1 A 0
		MEKH A 0 A_JumpIfinventory("TankZoom", 1, "LaserZoom")
	LaserContinue:
		TNT1 A 0 A_PlaySound("PAILGF2",1)
		TNT1 A 0 A_FireCustomMissile("Alerter", 0, 0)
		MEKH A 0 A_FireCustomMissile("LaserBolt", 0.1, 0, 16, -16, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("LaserBolt", -0.1, 0, -16, -16, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("LaserBolt", 0.2, 0, 32, -16, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("LaserBolt", -0.2, 0, -32, -16, 0, 0.1)
		MEKH A 8 BRIGHT

		MEKH A 0 A_Refire("LaserContinue")
		Goto ReadyToFire

	LaserZoom:
		TNT1 A 0 A_PlaySound("PAILGF2",1)
		TNT1 A 0 A_FireCustomMissile("Alerter", 0, 0)
		MEKH A 0 A_FireCustomMissile("LaserBolt", 0.1, 0, 16, -16, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("LaserBolt", -0.1, 0, -16, -16, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("LaserBolt", 0.2, 0, 32, -16, 0, 0.1)
		MEKH A 0 A_FireCustomMissile("LaserBolt", -0.2, 0, -32, -16, 0, 0.1)
		TNT1 A 8 BRIGHT

		TNT1 A 0 A_Refire("LaserZoom")
		Goto ReadyZoom

	Rocket:
		TNT1 A 0
		MEKH A 0 A_JumpIfInventory("TankZoom", 1, "RocketZoom")
		MEKH A 0 A_JumpIfInventory("MechRocketAmmo", 2, 1)
		Goto NoAmmo
		TNT1 A 0 A_FireCustomMissile("Alerter", 0, 0)
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundRocket", random(-1,1), 0, 0, -12, 0, random(-1,1))
		MEKH A 0 A_FireCustomMissile("MechRocket", 0.3, 0, random(40,56), random(56,72), 0, -0.5)
		MEKH A 7 BRIGHT
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundRocket", random(-1,1), 0, 0, -12, 0, random(-1,1))
		MEKH A 0 A_FireCustomMissile("MechRocket", -0.3, 0, random(-56,-40), random(56,72), 0, -0.5)
		MEKH A 7 BRIGHT
		TNT1 A 0 A_TakeInventory("MechRocketAmmo", 2)
		Goto ReadyToFire

	RocketZoom:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("MechRocketAmmo", 2, 1)
		Goto NoAmmoZoom
		TNT1 A 0 A_FireCustomMissile("Alerter", 0, 0)
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundRocket", random(-1,1), 0, 0, -12, 0, random(-1,1))
		MEKH A 0 A_FireCustomMissile("MechRocket", 0.3, 0, random(40,56), random(56,72), 0, -0.5)
		TNT1 A 7 BRIGHT
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundRocket", random(-1,1), 0, 0, -12, 0, random(-1,1))
		MEKH A 0 A_FireCustomMissile("MechRocket", -0.3, 0, random(-56,-40), random(56,72), 0, -0.5)
		TNT1 A 7 BRIGHT
		TNT1 A 0 A_TakeInventory("MechRocketAmmo", 2)
		Goto ReadyZoom

	AltFire:
		TNT1 A 0 A_JumpIfInventory("TankZoom", 1, "AltFireZoom")
		MEKH A 14
		TNT1 A 0 A_JumpIfInventory("MechFireMode", 2, "Switch0")
		TNT1 A 0 A_GiveInventory("MechFireMode", 1)

	Switch1://Laser
		TNT1 A 0 A_JumpIfInventory("MechFireMode", 2, "Switch2")
		TNT1 A 0 A_SetCrosshair(25)
		Goto ReadyToFire

	Switch2://MechRocket
		TNT1 A 0 A_SetCrosshair(33)
		Goto ReadyToFire

	Switch0://MG
		TNT1 A 0 A_TakeInventory("MechFireMode", 3)
		TNT1 A 0 A_SetCrosshair(22)
		Goto ReadyToFire

	AltFireZoom:
		TNT1 A 14
		TNT1 A 0 A_JumpIfInventory("MechFireMode", 2, "Switch0Zoom")
		TNT1 A 0 A_GiveInventory("MechFireMode", 1)

	Switch1Zoom://Laser
		TNT1 A 0 A_JumpIfInventory("MechFireMode", 2, "Switch2Zoom")
		TNT1 A 0 A_SetCrosshair(25)
		Goto ReadyZoom

	Switch2Zoom://MechRocket
		TNT1 A 0 A_SetCrosshair(33)
		Goto ReadyZoom

	Switch0Zoom://MG
		TNT1 A 0 A_TakeInventory("MechFireMode", 3)
		TNT1 A 0 A_SetCrosshair(22)
		Goto ReadyZoom

	Flash:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("BDMechHUD", 0, 0, 0, 0)//SHOWHUD
		TNT1 A 1 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		NULL A 0 A_JumpIf (pitch < -57, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 33, "TooLowCheck")
		TNT1 A 0 ACS_NamedExecuteAlways("BDMechHUD", 0, 0, 0, 0)//SHOWHUD
		TNT1 A 1 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		NULL A 0 A_JumpIf (pitch < -57, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 33, "TooLowCheck")
		TNT1 A 0 ACS_NamedExecuteAlways("BDMechHUD", 0, 0, 0, 0)//SHOWHUD
		TNT1 A 1 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		NULL A 0 A_JumpIf (pitch < -57, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 33, "TooLowCheck")
		Goto Flash

	TooHigh:
		TNT1 A 0 A_SetPitch(304)
		Goto Flash

	TooLowCheck:
		TNT1 A 0 A_SetPitch(32)
		Goto Flash

	TooHighCheck:
		TNT1 A 0
		NULL A 0 A_JumpIf (pitch < 303, "TooHigh")
		Goto Flash

	TooHighCheckGZD:
		TNT1 A 0
		NULL A 0 A_SetPitch(-56)
		Goto Flash

	SwitchFlashlight:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("SwitchFlashlight", 1)
		TNT1 A 0 A_JumpIfInventory("FlashlightOn",1,"TurnFlashOff")
		TNT1 A 0 A_Giveinventory("FlashlightOn",1)
		TNT1 A 0 A_giveinventory("VehicleInfraredGiver", 1)
		TNT1 A 0 A_PlaySound("INFRARED", 3)
        Goto ReadyToFire

	TurnFlashOff:
		TNT1 A 0 A_Takeinventory("FlashlightOn",1)
		TNT1 A 0 A_TakEinventory("PowerLightAmp", 1)
		TNT1 A 0 A_PlaySound("FLASHOFF", 3)
        Goto ReadyToFire

	LightEnd:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("BDMechHUD", 0, 0, 0, 0)//SHOWHUD
		TNT1 A 1
		NULL A 0 A_JumpIf (pitch < -57, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 33, "TooLowCheck")
		TNT1 A 0 ACS_NamedExecuteAlways("BDMechHUD", 0, 0, 0, 0)//SHOWHUD
		TNT1 A 1
		NULL A 0 A_JumpIf (pitch < -57, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 33, "TooLowCheck")
		TNT1 A 0 ACS_NamedExecuteAlways("BDMechHUD", 0, 0, 0, 0)//SHOWHUD
		TNT1 A 1
		NULL A 0 A_JumpIf (pitch < -57, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 33, "TooLowCheck")
		TNT1 A 0 A_JumpIfInventory("CanLeaveVehicle",1,1)
		Goto Flash
		TNT1 A 0 A_TakeInventory("TankZoom", 1)
		TNT1 A 0 A_TakeInventory("MechFireMode", 3)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("FlashlightOn",1)
		TNT1 A 0 A_TakEinventory("PowerLightAmp", 1)
		TNT1 A 10
		Stop

	Spawn:
		LAUN A -1
		Stop
	}
}

ACTOR MechRocket: Rocket2
{
	Speed 50
	Damage (random (300, 300))
	SeeSound "MISLFIRE"
	Radius 4
	Height 8
}

ACTOR MechRocket2: MechRocket
{
	Speed 30
	Damage (random (120, 120))
	Species "EnemyTank"
	DamageType ExplosiveImpact
}

actor MechStomp
{
	+NOTARGET
	Radius 1
	Height 1
	DamageType Stomp
	+NOGRAVITY
	+NOTELEPORT
	+NODAMAGETHRUST
	+THRUGHOST
	+NORADIUSDMG
	+FORCERADIUSDMG
	PROJECTILE
	+DEHEXPLOSION
	+ACTIVATEMCROSS
	+EXPLODEONWATER
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_Explode(200,50,0)
	TNT1 A 1 A_Noblocking
	PLAY A 0
	Stop
	}
}

actor MechStompLand: MechStomp
{
DamageType Stomp
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Explode(200,50,0)
TNT1 A 1
Stop
}
}

actor MechStompLand2: MechStomp
{
DamageType Stomp
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Explode(100,100,0)
TNT1 A 1
Stop
}
}

ACTOR LaserBolt : FastProjectile
{
	Speed 120
	Damage (random(40, 40))
    DamageType Plasma
	Decal "SmallerScorch"
	Projectile
	+RANDOMIZE
	+THRUSPECIES
	+FORCEXYBILLBOARD
	Species "Marines"
	Scale 1.0
	renderstyle ADD
	alpha 0.75
    SeeSound "PAILGF3"
	DeathSound "PAILGD3"
	Obituary "$OB_MPPLASMARIFLE"
	States
	{

	Spawn:
		LASR A 1 Bright A_SpawnItem("BlueFlareSmall")
		Loop
	Death:
	    PLSN A 0
		PLSN A 0 A_CustomMissile ("BluePlasmaFire", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 1 Bright A_SpawnItem("BlueFlareSmall")
		TNT1 AAA 9 A_CustomMissile ("PlasmaSmoke", 1, 0, random (0, 360), 2, random (0, 160))
		Stop

	XDeath:
	    PLSN A 0
		PLSN A 0 A_CustomMissile ("BluePlasmaFire", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 1 Bright A_SpawnItem("BlueFlareSmall")
		Stop
	}
}

ACTOR LaserBolt2 : FastProjectile
{
	Speed 60
	Damage (random(20, 20))
    DamageType Plasma
	Decal "SmallerScorch"
	Projectile
	+RANDOMIZE
	+THRUSPECIES
	+FORCEXYBILLBOARD
	Species "EnemyTank"
	Scale 1.0
	renderstyle ADD
	alpha 0.75
    SeeSound "PAILGF3"
	DeathSound "PAILGD3"
	Obituary "$OB_MPPLASMARIFLE"
	States
	{

	Spawn:
		LASR A 1 Bright A_SpawnItem("BlueFlareSmall")
		Loop
	Death:
	    PLSN A 0
		PLSN A 0 A_CustomMissile ("BluePlasmaFire", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 1 Bright A_SpawnItem("BlueFlareSmall")
		TNT1 AAA 9 A_CustomMissile ("PlasmaSmoke", 1, 0, random (0, 360), 2, random (0, 160))
		Stop

	XDeath:
	    PLSN A 0
		PLSN A 0 A_CustomMissile ("BluePlasmaFire", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 1 Bright A_SpawnItem("BlueFlareSmall")
		Stop
	}
}