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

Actor TankBaseNotReal
{
+THRUACTORS
XScale 1.94
YScale 1.47
+NOTIMEFREEZE
-FLOORCLIP
+NOGRAVITY
-FLOAT
+NEVERTARGET
+CANTSEEK
Mass 31700//35 Tons
Radius 0
Height 0
Gravity 0
States
{
Spawn:
TNT1 A 0
TNK1 B 6
TNT1 A 0 A_SPawnItemEx("TankEngineWeakSpot", -44, 0, 6)
Stop
}}

Actor TankBaseNotRealMoving1: TankBaseNotReal
{
Radius 0
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SPawnItemEx("TankEngineWeakSpot", -44, 0, 6)
TNT1 A 0 A_CustomMissile("CheckPitchCenter", -12, 0, 0, 2, 0)
TNT1 A 0 A_CustomMissile("CheckPitchCenter", -12, 0, 180, 2, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, 0, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, -64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, 4, -2, 0, 0, 0, 0)
TNT1 A 0 A_CustomMissile("CheckIfOn3DFloor", -64, 0, 0, 2, 0)
TNT1 A 0 A_CustomMissile("CheckIfOn3DFloor", -160, 0, 0, 2, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, 64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, -64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, 0, -2, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, 64, 4, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, -64, 4, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, 0, 4, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 0, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, -64, -2, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 0, -10, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 64, -10, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, -64, -10, 0, 0, 0, 0)

TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("PitchBackToken", 6, "PitchFront2")
TNT1 A 0 A_JumpIfInventory("PitchBackToken", 3, "PitchFront")
TNT1 A 0 A_JumpIfInventory("PitchFrontToken", 6, "PitchBack2")
TNT1 A 0 A_JumpIfInventory("PitchFrontToken", 3, "PitchBack")
TNT1 A 1
Normal:
TNT1 A 0
TNK1 B 3
Stop

PitchFront:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("ShotgunAmmo", 3, "PitchBack")
TNT1 A 0 A_SPawnItemEx("PushWeak", 64, 0, -2, 0, 0, 0, 0)
TNK4 B 3
Stop

PitchFront2:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("ShotgunAmmo", 3, "PitchBack")
TNT1 A 0 A_SPawnItemEx("PushFront", 64, 0, -2, 0, 0, 0, 0)
TNK2 B 3
Stop

PitchBack:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNK5 B 3 A_SPawnItemEx("PushWeak", -16, 0, -2, 0, 0, 0, 0)
Stop

PitchBack2:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 AA 0 A_SPawnItemEx("PushFront", -64, 0, -2, 0, 0, 0, 0)
TNK3 B 3
Stop
}}

Actor TankBaseNotRealMoving2: TankBaseNotRealMoving1
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SPawnItemEx("TankEngineWeakSpot", -44, 0, 6)
TNT1 A 0 A_CustomMissile("CheckPitchCenter", -12, 0, 0, 2, 0)
TNT1 A 0 A_CustomMissile("CheckPitchCenter", -12, 0, 180, 2, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, 0, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, -64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, 4, -2, 0, 0, 0, 0)
TNT1 A 0 A_CustomMissile("CheckIfOn3DFloor", -64, 0, 0, 2, 0)
TNT1 A 0 A_CustomMissile("CheckIfOn3DFloor", -160, 0, 0, 2, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, 64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, -64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, 0, -2, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, 64, 4, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, -64, 4, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, 0, 4, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 0, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, -64, -2, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 0, -10, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 64, -10, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, -64, -10, 0, 0, 0, 0)

TNT1 A 0 A_JumpIfInventory("PitchBackToken", 6, "PitchFront2")
TNT1 A 0 A_JumpIfInventory("PitchBackToken", 3, "PitchFront")
TNT1 A 0 A_JumpIfInventory("PitchFrontToken", 6, "PitchBack2")
TNT1 A 0 A_JumpIfInventory("PitchFrontToken", 3, "PitchBack")
TNT1 A 1
Normal:
TNT1 A 0
TNK1 D 3
Stop

PitchFront:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("ShotgunAmmo", 3, "PitchBack")
TNT1 A 0 A_SPawnItemEx("PushWeak", 64, 0, -2, 0, 0, 0, 0)
TNK4 D 3
Stop

PitchFront2:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("ShotgunAmmo", 3, "PitchBack")
TNT1 A 0 A_SPawnItemEx("PushFront", 64, 0, -2, 0, 0, 0, 0)
TNK2 D 3
Stop

PitchBack:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNK5 D 3 A_SPawnItemEx("PushWeak", -16, 0, -2, 0, 0, 0, 0)
Stop

PitchBack2:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 AA 0 A_SPawnItemEx("PushFront", -64, 0, -2, 0, 0, 0, 0)
TNK3 D 3
Stop
}}

Actor TankBaseNotRealMoving3: TankBaseNotRealMoving1
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SPawnItemEx("TankEngineWeakSpot", -44, 0, 6)
TNT1 A 0 A_CustomMissile("CheckPitchCenter", -12, 0, 0, 2, 0)
TNT1 A 0 A_CustomMissile("CheckPitchCenter", -12, 0, 180, 2, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, 0, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, -64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, 4, -2, 0, 0, 0, 0)
TNT1 A 0 A_CustomMissile("CheckIfOn3DFloor", -64, 0, 0, 2, 0)
TNT1 A 0 A_CustomMissile("CheckIfOn3DFloor", -160, 0, 0, 2, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, 64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, -64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, 0, -2, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, 64, 4, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, -64, 4, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, 0, 4, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 0, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, -64, -2, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 0, -10, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 64, -10, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, -64, -10, 0, 0, 0, 0)

TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("PitchBackToken", 6, "PitchFront2")
TNT1 A 0 A_JumpIfInventory("PitchBackToken", 3, "PitchFront")
TNT1 A 0 A_JumpIfInventory("PitchFrontToken", 6, "PitchBack2")
TNT1 A 0 A_JumpIfInventory("PitchFrontToken", 3, "PitchBack")
TNT1 A 1
Normal:
TNT1 A 0
TNK1 E 3
Stop

PitchFront:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("ShotgunAmmo", 3, "PitchBack")
TNT1 A 0 A_SPawnItemEx("PushWeak", 64, 0, -2, 0, 0, 0, 0)
TNK4 E 3
Stop

PitchFront2:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("ShotgunAmmo", 3, "PitchBack")
TNT1 A 0 A_SPawnItemEx("PushFront", 64, 0, -2, 0, 0, 0, 0)
TNK2 E 3
Stop

PitchBack:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNK5 E 3 A_SPawnItemEx("PushWeak", -16, 0, -2, 0, 0, 0, 0)
Stop

PitchBack2:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 AA 0 A_SPawnItemEx("PushFront", -64, 0, -2, 0, 0, 0, 0)
TNK3 E 3
Stop

}}

Actor TankBaseStationed: TankBaseNotRealMoving1
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SPawnItemEx("TankEngineWeakSpot", -44, 0, 6)
TNT1 A 0 A_CustomMissile("CheckPitchCenter", -12, 0, 0, 2, 0)
TNT1 A 0 A_CustomMissile("CheckPitchCenter", -12, 0, 180, 2, 0)
TNT1 A 0 A_CustomMissile("CheckIfOn3DFloor", -64, 0, 0, 2, 0)
TNT1 A 0 A_CustomMissile("CheckIfOn3DFloor", -160, 0, 0, 2, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, 0, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, -64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckIfFloating", 96, 4, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, 64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, -64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchFront", 76, 0, -2, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, 64, 4, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, -64, 4, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchRunOver", 100, 0, 4, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 0, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 64, -2, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, -64, -2, 0, 0, 0, 0)

TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 0, -10, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, 64, -10, 0, 0, 0, 0)
TNT1 A 0 A_SPawnItemEx("CheckPitchBack", -70, -64, -10, 0, 0, 0, 0)

TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("PitchBackToken", 6, "PitchFront2")
TNT1 A 0 A_JumpIfInventory("PitchBackToken", 3, "PitchFront")
TNT1 A 0 A_JumpIfInventory("PitchFrontToken", 6, "PitchBack2")
TNT1 A 0 A_JumpIfInventory("PitchFrontToken", 3, "PitchBack")
TNT1 A 1
Normal:
TNT1 A 0
TNK1 D 3
Stop

PitchFront:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("ShotgunAmmo", 3, "PitchBack")
TNT1 A 0 A_SPawnItemEx("PushWeak", 64, 0, -2, 0, 0, 0, 0)
TNK4 D 3
Stop

PitchFront2:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 A 0 A_JumpIfInventory("ShotgunAmmo", 3, "PitchBack")
TNT1 A 0 A_SPawnItemEx("PushFront", 64, 0, -2, 0, 0, 0, 0)
TNK2 D 3
Stop

PitchBack:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNK5 D 3 A_SPawnItemEx("PushWeak", -16, 0, -2, 0, 0, 0, 0)
Stop

PitchBack2:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("MP40Ammo", 1, "Normal")
TNT1 AA 0 A_SPawnItemEx("PushFront", -64, 0, -2, 0, 0, 0, 0)
TNK3 D 3
Stop
}}

Actor CheckPitchFront
{
PROJECTILE
+MISSILE

Radius 12
Height 12
Speed 0
+THRUSPECIES
+MTHRUSPECIES
Species "Marines"
+DONTSPLASH
-EXPLODEONWATER
States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveToTarget("PitchFrontToken")
			SARG A 0
			Stop
		IsOverSOmething:
		Death:
		Xdeath:
			TNT1 A 0
			HEAD A 0
			Stop
			}
}

Actor CheckPitchBack: CheckPitchFront
{
States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveToTarget("PitchBackToken")
			SARG A 0
			Stop
		IsOverSOmething:
		Death:
		Xdeath:
			TNT1 A 0
			HEAD A 0
			Stop
		}
}

Actor CheckPitchFront2: CheckPitchFront
{
States
	{
		Spawn:
			TNT1 A 0
			SARG A 0
			Stop
		Death:
		Xdeath:
			TNT1 A 0
			HEAD A 0
			TNT1 A 0 A_GiveToTarget("PitchFrontToken")
			Stop
		}
}

Actor CheckPitchBack2: CheckPitchFront
{
States
	{
		Spawn:
			TNT1 A 0
			SARG A 0
			Stop
		Death:
		Xdeath:
			TNT1 A 0
			HEAD A 0
			TNT1 A 0 A_GiveToTarget("PitchBackToken")
			Stop
		}
}

Actor CheckPitchFront2b: CheckPitchFront
{
States
	{
		Spawn:
			TNT1 A 0
			SARG A 0
			Stop
		Death:
		Xdeath:
			TNT1 A 0
			HEAD A 0
			TNT1 A 0 A_GiveToTarget("PitchFrontToken2")
			Stop
		}
}

Actor CheckPitchBack2b: CheckPitchFront
{
States
	{
		Spawn:
			TNT1 A 0
			SARG A 0
			Stop
		Death:
		Xdeath:
			TNT1 A 0
			HEAD A 0
			TNT1 A 0 A_GiveToTarget("PitchBackToken2")
			Stop
		}
}

Actor CheckIfFloating: CheckPitchFront
{
States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveToTarget("ShotgunAmmo")
			SARG A 0
			Stop
		IsOverSOmething:
		Death:
		Xdeath:
			TNT1 A 0
			HEAD A 0
			Stop
		}
}

Actor CheckPitchCenter: CheckPitchFront
{
Radius 32
Height 2
Speed 30
Damage 0
Scale 1.0
States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveToTarget("ShotgunAmmo")
			TNT1 A 1
			Stop
		Death:
			TNT1 A 0
			Stop
		Xdeath:
			TNT1 A 0
			TNT1 A 0 A_GiveToTarget("MP40Ammo")
			HEAD A 0
			Stop
			}
}

Actor CheckPitchRunOver: CheckPitchCenter
{
Speed 50
States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 1
			Stop
		Death:
			TNT1 A 0
			Stop
		Xdeath:
			TNT1 A 0
			TNT1 A 0 A_GiveToTarget("PitchBackToken", 6)
			TNT1 A 0
			Stop
			}
}

Actor CheckIfOn3DFloor: CheckPitchCenter
{
Speed 9
States
	{
		Spawn:
			TNT1 A 0

			TNT1 A 0
			TNT1 A 0 A_GiveToTarget("MP40AMmo", 1)
			Stop
		XDeath:
			TNT1 A 0
			Stop
		Death:
			TNT1 A 0
			Stop
			}
}

Actor PushFront: CheckPitchFront
{
+FORCERADIUSDMG
+NOTIMEFREEZE
States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_RadiusThrust(5000, 100, RTF_AFFECTSOURCE  | RTF_NOIMPACTDAMAGE , 1)
			SARG A 0
			Stop
		IsOverSOmething:
		Death:
		Xdeath:
			TNT1 A 0
			TNT1 A 0 A_RadiusThrust(5000, 100, RTF_AFFECTSOURCE  | RTF_NOIMPACTDAMAGE  , 1)
			HEAD A 0
			Stop
			}
}

Actor PushWeak: CheckPitchFront
{
+FORCERADIUSDMG
+NOTIMEFREEZE
States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_RadiusThrust(2500, 100, RTF_AFFECTSOURCE  | RTF_NOIMPACTDAMAGE , 1)
			SARG A 0
			Stop
		IsOverSOmething:
		Death:
		Xdeath:
			TNT1 A 0
			TNT1 A 0 A_RadiusThrust(2500, 100, RTF_AFFECTSOURCE  | RTF_NOIMPACTDAMAGE  , 1)
			HEAD A 0
			Stop
			}
}

Actor TankTurretNotReal: TankBaseNotReal
{
Scale 1.0
States
{
Spawn:
TNT1 A 0
TNK1 T 1
Stop
}}

Actor TankTurretNotReal2: TankTurretNotReal
{
States
{
Spawn:
TNT1 A 0
TNK1 T 2
Stop
}}

Actor TankTurretNotReal4: TankTurretNotReal
{
States
{
Spawn:
TNT1 A 0
TNK1 T 4
Stop
}}

Actor TankTurretNotReal8: TankTurretNotReal
{
States
{
Spawn:
TNT1 A 0
TNK1 T 8
Stop
}}

ACTOR Tank: SwitchableDecoration 7261
{
	var int user_stationedtankbasedirection;
    Radius 64
	Height 100
	+SOLID
	+USESPECIAL
	MONSTER
	-COUNTKILL
	+SHOOTABLE
	+THRUACTORS
	+NOINFIGHTING
	+NOBLOODDECALS
	+DONTRIP
	+NOTIMEFREEZE
	+NEVERTARGET
	+CANTSEEK
	//$Category BD Vehicles
	//$Colour rgb(200, 200, 200)
	//$Sprite TNK1B1
	MaxTargetRange 120
	BloodType "TankBlood", "TankBlood", "TankBlood"
	Activation THINGSPEC_Activate | THINGSPEC_ThingTargets | THINGSPEC_NoDeathSpecial
	Mass 31700//35 ton
	Speed 0
	health 4000
	Scale 1.0
	Damagefactor "Avoid", 0.0	Damagefactor "BHFTOnBarrel", 0.0	Damagefactor "Blood", 0.0
	Damagefactor "CancelTeleportFog", 0.0	Damagefactor "CauseWaterSplash", 0.0
	Damagefactor "Cut", 0.5	Damagefactor "Extremepunches", 0.0	Damagefactor "Fatality", 0.0
	Damagefactor "FriendBullet", 0.0	Damagefactor "GibRemoving", 0.0	Damagefactor "Glass", 0.0
	Damagefactor "HangingHook", 0.0	Damagefactor "Head", 0.0	Damagefactor "HeadKick", 0.0
	Damagefactor "HelperMarineFatallity", 0.0	Damagefactor "KillMe", 0.0	Damagefactor "Leg", 0.0
	Damagefactor "Slide", 0.0	Damagefactor "MonsterKnocked", 0.0	Damagefactor "PussyGrab", 0.0
	Damagefactor "Repair", 1.0	Damagefactor "RevenantHitStomach", 0.0	Damagefactor "Saw", 0.5
	Damagefactor "Slide", 0.0	Damagefactor "SpawnMarine", 0.0	Damagefactor "Taunt", 1.0
	Damagefactor "TeleportRemover", 0.0	Damagefactor "Use", 0.0	Damagefactor "Kick", 0.0
	Damagefactor "Melee", 0.0	Damagefactor "Shrapnel", 0.5	Damagefactor "Slime", 0.0
	Damagefactor "Stealth", 0.0	Damagefactor "Stomp", 0.0	Damagefactor "Trample", 0.0
	Damagefactor "Burn", 0.0	Damagefactor "Fire", 0.0	Damagefactor "Flames", 0.0
	Damagefactor "GreenFire", 0.0	Damagefactor "HumanBBQ", 0.0	Damagefactor "Bullet", 0.5
	Damagefactor "Minigun", 0.5	Damagefactor "Minor", 0.5	Damagefactor "MonsterBullet", 0.5
	Damagefactor "MonsterMinigun", 0.5	Damagefactor "MonsterShotgunBullet", 0.5	Damagefactor "Shotgun", 0.5
	Damagefactor "SSG", 0.5	Damagefactor "HitGround", 3.0
	Damagefactor "TankWeakSpot", 3.0	Damagefactor "CheckRepair", 0.0

	PainChance "Avoid", 0	PainChance "HitGround", 255	PainChance "Repair", 255
    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 5
		TNT1 A 0 A_SpawnItem("TankTurretNotReal8")
		TNT1 A 0 Thing_ChangeTID(0, 0)
		TNK1 C 0 A_ChangeFlag("THRUACTORS", 0)
		TNT1 A 0 A_ChangeFlag("FRIENDLY", 1)
		Goto StandingHere

	  StandingHere:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("BDSetBaseAngle", 0, 0, 0, 0)//SpawnVehicleBase
		TNT1 A 2
		TNT1 A 0 A_SpawnItem("TankTurretNotReal8")
		//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)
		TNK1 C 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_GiveToTarget("CheckingMorphingPlayerHealth", 1)
		TNT1 A 0 A_SpawnItem("TankTurretNotReal8")
		NULL A 3
		TNT1 A 0 A_GiveToTarget("TankMorpher", 1)
		TNT1 A 0 A_GiveToTarget("HeavyMachinegunAmmo", 1000)
		TNT1 A 0 A_GiveToTarget("TankAmmo", 40)
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 0 A_NoBlocking
		NULL A 1
		TNT1 A 0 A_ChangeFlag("USESPECIAL", 0)
		NULL A 10
		TNT1 A 0 Thing_ChangeTID(0, 0)
		NULL A 1
		Stop

	Death:
		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_ChangeFlag("USESPECIAL", 0)
		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(320)
			TNT1 A 0 A_JumpIfInventory("HeavyMachinegunAmmo", 1000, 2)
			TNT1 A 0 A_GiveInventory("HeavyMachinegunAmmo", 67)
			TNT1 A 0 A_JumpIfInventory("TankAmmo", 40, 2)
			TNT1 A 0 A_GiveInventory("TankAmmo", 3)
			TNK1 T 1
			TNT1 A 0 A_ChangeFLag("NOPAIN", 0)
			Goto StandingHere
	}
}

ACTOR TankUsed: Tank
{
    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("TankBaseDirection", 500)
		Goto StandingHere

	Active:
		TNT1 A 0
		TNT1 A 0 A_ChangeFLag("NOPAIN", 1)
		//TNT1 A 0 A_JumpIfInTargetInventory("PowerInvulnerable", 1, "StandingHere")
		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)
		NULL A 3
		TNT1 A 0 A_GiveToTarget("TankMorpher", 1)
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 0 A_NoBlocking
		NULL A 1
		TNT1 A 0 A_ChangeFlag("USESPECIAL", 0)
		NULL A 10
		TNT1 A 0 Thing_ChangeTID(0, 0)
		Stop
	}
}

ACTOR TankRealism: Tank
{
Health 16000
}

ACTOR PowerTankSwitch : PowerMorph {PowerMorph.PlayerClass "PlayerTank"}

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

ACTOR TankMorphActivation : PowerupGiver
{
  Powerup.Type "PowerTankSwitch"
  Powerup.Duration 252000
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 1
  Health 100
  GibHealth 1
  Mass 6000
  Height 72
  Radius 32
  States
  {
  Spawn:
  TNT1 A 100
  Stop

  PickUp:
  TNT1 A 1
  TNT1 A 1
  Stop
  }
 }

ACTOR PlayerTank : PlayerPawn
{
var int user_tankbasedirection;
	Speed 0
	Scale 1.0
	Radius 64
	Height 100
	Mass 31700//35 Tons
	Health 4000
	-PICKUP
	player.viewheight 72
	Player.AttackZOffset 22
	MaxStepHeight 32
	Player.MorphWeapon "TankGun"
    Player.JumpZ 0
	Species "Marines"
	+NOSKIN
	+FORCERADIUSDMG
	+FIXMAPTHINGPOS
	+NORADIUSDMG
	+DONTRIP
	-CANUSEWALLS
	+NOBLOODDECALS
	+DONTHARMSPECIES
	+THRUSPECIES
	+NOTELEPORT
	BloodType "TankBlood", "TankBlood", "TankBlood"

	Damagefactor "Avoid", 0.0	Damagefactor "BHFTOnBarrel", 0.0	Damagefactor "Blood", 0.0
	Damagefactor "CancelTeleportFog", 0.0	Damagefactor "CauseWaterSplash", 0.0
	Damagefactor "Cut", 0.5	Damagefactor "Extremepunches", 0.0	Damagefactor "Fatality", 0.0
	Damagefactor "FriendBullet", 0.0	Damagefactor "GibRemoving", 0.0	Damagefactor "Glass", 0.0
	Damagefactor "HangingHook", 0.0	Damagefactor "Head", 0.0	Damagefactor "HeadKick", 0.0
	Damagefactor "HelperMarineFatallity", 0.0	Damagefactor "KillMe", 0.0	Damagefactor "Leg", 0.0
	Damagefactor "Slide", 0.0	Damagefactor "MonsterKnocked", 0.0	Damagefactor "PussyGrab", 0.0
	Damagefactor "Repair", 1.0	Damagefactor "RevenantHitStomach", 0.0	Damagefactor "Saw", 0.5
	Damagefactor "Slide", 0.0	Damagefactor "SpawnMarine", 0.0	Damagefactor "Taunt", 1.0
	Damagefactor "TeleportRemover", 0.0	Damagefactor "Use", 0.0	Damagefactor "Kick", 0.0
	Damagefactor "Melee", 0.0	Damagefactor "Shrapnel", 0.5	Damagefactor "Slime", 0.0
	Damagefactor "Stealth", 0.0	Damagefactor "Stomp", 0.0	Damagefactor "Trample", 0.0
	Damagefactor "Burn", 0.0	Damagefactor "Fire", 0.0	Damagefactor "Flames", 0.0
	Damagefactor "GreenFire", 0.0	Damagefactor "HumanBBQ", 0.0	Damagefactor "Bullet", 0.5
	Damagefactor "Minigun", 0.5	Damagefactor "Minor", 0.5	Damagefactor "MonsterBullet", 0.5
	Damagefactor "MonsterMinigun", 0.5	Damagefactor "MonsterShotgunBullet", 0.5	Damagefactor "Shotgun", 0.5
	Damagefactor "SSG", 0.5	Damagefactor "HitGround", 3.0
	Damagefactor "TankWeakSpot", 3.0	Damagefactor "CheckRepair", 0.0

	PainChance "Avoid", 0	PainChance "HitGround", 255	PainChance "Repair", 255
	States
	{

	Spawn:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("PressedUse", 1)
		TNT1 A 0 ThrustTHingZ(0, 100, -1, 1)
		TNK1 T 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
	Spawn2:
	    TNT1 A 0 A_GiveInventory("IsInATank", 1)
		TNT1 A 0 A_TakeInventory("PressedUse", 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)

		TNT1 A 0 SetPlayerProperty(0, 1, PROP_BUDDHA)
		TNK1 T 1
		TNK1 TTTT 1 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, -90, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNK1 TTTT 1 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, -90, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_TakeInventory("PressedUse", 1)
		TNT1 A 0 A_TakeInventory("FiredTankMainGun", 1)
		TNT1 A 0 A_Print ("A", 2, "TUTO1")
	Goto Stay

	ExitVehicle:
	TNT1 A 1
	TNT1 A 0 A_ChangeFlag(NOPAIN, 1)
	TNT1 A 0 A_TakeInventory("PressedUse", 1)
	TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
	TNT1 A 0 A_SpawnItemEx ("TransferPlayerOutOfVehicle", 0, 0, 104)

	TNK1 T 1
	TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
	TNK1 T 1
	TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
	TNK1 T 1
	TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

	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 SetPlayerProperty(0, 0, PROP_BUDDHA)
	TNT1 A 0 ACS_NamedExecuteAlways("BDLeaveTank")
	TNT1 A 0 A_SpawnItemEx ("TankUsed", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
	Goto FinishExit

	EmergencyExit:
	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 ThrustThingZ(0,120,0,1)
	TNT1 A 0 A_SpawnItem("TankExplode")
	PLA1 J 2
	TNT1 A 0 A_StopSound(1)
	TNT1 A 0 SetPlayerProperty(0, 0, PROP_BUDDHA)
	TNT1 A 0 SetPlayerProperty(0, 0, PROP_FLIGHT)
	TNT1 A 0 ACS_NamedExecuteAlways("BDLeaveTank")
	PLA1 J 100
	Goto Stay

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

	TurnLeft:
		TNT1 A 0
		TNK1 T 2
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_JumpIf(waterlevel > 1, "Stay")
		TNT1 A 0 A_PlaySound("TANK1", 5, 1, 1)
		TNT1 A 0 A_SpawnItemEx ("TnkTreadsDamage" , 100, 0, 0, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE | SXF_ABSOLUTEVELOCITY)
		TNT1 A 0 A_SpawnItemEx("TnkStep", 0, 0, 8, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection > 359, "TurnLeft2")
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+4)

		TNK1 T 2
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection > 359, "TurnLeft2")
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+4)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)

		TNK1 T 2
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving3" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection > 359, "TurnLeft2")
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+4)
		Goto CheckIfStillMoves

	TurnLeft2:
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", 0)
		TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "TurnLeftAccel")
		TNT1 A 0 A_JumpIfInventory("Backpedal", 1, "TurnLeftBackpedal")
		Goto TurnLeft

	TurnLeftAccel:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection > 359, "TurnLeft2")

		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+2)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 2, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving3" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_PlaySound("TANK1", 5, 1, 1)
		TNT1 A 0 A_SpawnItemEx ("TnkTreadsDamage" , 100, 0, 0, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE | SXF_ABSOLUTEVELOCITY)

		TNT1 A 0 A_SpawnItemEx("TnkStep", 0, 0, 8, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 2, 1)
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+2)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 2, 1)
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+2)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIF(velz < 0, "Falling")
		Goto CheckIfStillMoves

	TurnRight:
		TNT1 A 0
		TNK1 T 2
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_JumpIf(waterlevel > 1, "Stay")
		TNT1 A 0 A_PlaySound("TANK1", 5, 1, 1)
		TNT1 A 0 A_SpawnItemEx ("TnkTreadsDamage" , 100, 0, 0, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE | SXF_ABSOLUTEVELOCITY)
		TNT1 A 0 A_SpawnItemEx("TnkStep", 0, 0, 8, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection == 0, "TurnRIght2")
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-4)

		TNK1 T 2
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection == 0, "TurnRIght2")
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-4)

		TNK1 T 2
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving3" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection == 0, "TurnRIght2")
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-4)
		Goto CheckIfStillMoves

	TurnRight2:
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", 360)
		TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "TurnRightAccel")
		TNT1 A 0 A_JumpIfInventory("Backpedal", 1, "TurnRightBackpedal")
		Goto TurnRight

	TurnRightAccel:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection == 0, "TurnRIght2")

		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-2)

		TNT1 A 0 A_PlaySound("TANK1", 5, 1, 1)
		TNT1 A 0 A_SpawnItemEx ("TnkTreadsDamage" , 100, 0, 0, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE | SXF_ABSOLUTEVELOCITY)

		TNT1 A 0 A_SpawnItemEx("TnkStep", 0, 0, 8, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 2, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving3" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-2)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 2, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-2)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 2, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIF(velz < 0, "Falling")
		Goto CheckIfStillMoves

	CheckIfStillMoves:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "Accelerate")
		TNT1 A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeft")
		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRight")
		TNT1 A 0 A_StopSound(2)
		TNT1 A 0 A_PlaySound("TANK2", 5, 1, 1)
		TNT1 A 0 A_PlaySound("TANK3", 2)

	Stay:
	    TNT1 A 0
		TNT1 A 0 A_PlaySound("TANK2", 5, 1, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
		TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "Accelerate")
		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeft")
		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRight")
		TNK1 T 1
		TNT1 A 0 A_JumpIF(velz < 0, "Falling")
		Goto Stay

	Pain.TracksDamaged:
	    TNT1 A 0
		TNT1 A 0

		TNT1 A 0 A_Jump(32, "DestroyTracks")
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
		TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "Accelerate")
		TNK1 T 1
		Goto Stay

	Pain.Repair:
		TNT1 A 0
		TNK1 T 1 A_PlaySound("vehicle/pain")
		TNT1 A 0 HealThing(320)
		TNT1 A 0 A_JumpIfInventory("HeavyMachinegunAmmo", 1000, 2)
		TNT1 A 0 A_GiveInventory("HeavyMachinegunAmmo", 67)
		TNT1 A 0 A_JumpIfInventory("TankAmmo", 40, 2)
		TNT1 A 0 A_GiveInventory("TankAmmo", 3)
		TNK1 T 1
		Goto Stay

	Accelerate:

		TNT1 A 0 A_PlaySound("TANK1", 5, 1, 1)
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_SpawnItemEx ("TnkTreadsDamage" , 100, 0, 0, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE | SXF_ABSOLUTEVELOCITY)

		TNK1 T 2
		TNT1 A 0 A_JumpIf(waterlevel > 1, "Stay")
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 3, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving3" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeftAccel")
		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRightAccel")

		TNT1 A 0 A_SpawnItemEx("TnkStep", 0, 0, 8, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 3, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeftAccel")
		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRightAccel")

		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360, 3, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeftAccel")
		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRightAccel")

		TNT1 A 0 A_JumpIF(velz < 0, "Falling")
		Goto CheckIfStillMoves

	Backpedal:
		TNT1 A 0 A_PlaySound("TANK1", 5, 1, 1)
		TNT1 A 0 A_SpawnItemEx("TnkStep", 0, 0, 8, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_SpawnItemEx ("TnkTreadsDamage" , -100, 0, 0, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE | SXF_ABSOLUTEVELOCITY)
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)

		TNK1 T 2
		TNT1 A 0 A_JumpIf(waterlevel > 1, "Stay")
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 3, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving3" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRightBackpedal")
		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeftBackpedal")

		TNK1 T 2
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 3, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnLeftBackpedal")
		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnRightBackpedal")

		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 3, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRightBackpedal")
		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeftBackpedal")

		TNT1 A 0 A_JumpIF(velz < 0, "Falling")
		Goto CheckIfStillMoves

	TurnLeftBackpedal:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection > 359, "TurnLeft2")

		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+2)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 2, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving3" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_PlaySound("TANK1", 5, 1, 1)
		TNT1 A 0 A_SpawnItemEx ("TnkTreadsDamage" , 100, 0, 0, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE | SXF_ABSOLUTEVELOCITY)

		TNT1 A 0 A_SpawnItemEx("TnkStep", 0, 0, 8, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 2, 1)
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+2)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 2, 1)
		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection+2)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIF(velz < 0, "Falling")
		Goto CheckIfStillMoves

	TurnRightBackpedal:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("TurnLeft", 1)
		TNT1 A 0 A_TakeInventory("TurnRight", 1)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIf(user_tankbasedirection == 0, "TurnRIght2")

		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-2)

		TNT1 A 0 A_PlaySound("TANK1", 5, 1, 1)
		TNT1 A 0 A_SpawnItemEx ("TnkTreadsDamage" , 100, 0, 0, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE | SXF_ABSOLUTEVELOCITY)

		TNT1 A 0 A_SpawnItemEx("TnkStep", 0, 0, 8, 0, 0, 0, user_tankbasedirection, SXF_ABSOLUTEANGLE)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 2, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving3" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-2)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 2, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving2" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_SetUserVar("user_tankbasedirection", user_tankbasedirection-2)
		TNK1 T 2
		TNT1 A 0 ThrustThing(user_tankbasedirection*256/360+128, 2, 1)
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)

		TNT1 A 0 A_JumpIF(velz < 0, "Falling")
		Goto CheckIfStillMoves

	Falling:
		TNT1 A 0
		TNT1 A 0 A_CheckFloor("CheckIfStillMoves")

	FallingForReal:
		TNT1 A 0
		TNK1 T 1
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_JumpIF(velz == 0, "CrashIntoGround")
		TNT1 A 0 A_GiveInventory("VehicleFallingCount", 1)
		Loop

	CrashIntoGround:
		TNT1 A 0
		TNT1 A 0 A_JumpIfinventory("VehicleFallingCount", 6, "CrashIntoGroundViolently")
		TNK1 T 1
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_SpawnItem("CrashTankIntotheGround1")
		TNT1 A 0 A_SpawnItem("CrashTankIntotheGround2")
		TNT1 A 0 A_SpawnItemEx ("LargeMassWaterImpact", 0, 0, -10)
		TNT1 A 0 Radius_Quake(2, 35, 0, 5, 0)
		TNT1 A 0 A_PlaySound("EBIKEBNC", 2)
		TNT1 A 0 A_TakeInventory("VehicleFallingCount", 100)
		Goto Stay

	CrashIntoGroundViolently:
		TNT1 A 0
		TNK1 T 1
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_SpawnItem("CrashTankIntotheGround1")
		TNT1 A 0 A_SpawnItem("CrashTankIntotheGround2")

		TNT1 A 0 A_SpawnItemEx ("ExplosionSplashSpawner", 0, 0, -10)

		TNT1 A 0 Radius_Quake(4, 35, 0, 10, 0)
		TNT1 A 0 A_PlaySound("BIKECLW", 1)
		TNT1 A 0 A_PlaySound("EBIKECLS", 2)
		TNT1 AAAA 0 A_CustomMissile ("ExplosionSmoke", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 0 A_TakeInventory("VehicleFallingCount", 100)
		TNT1 A 0 A_SetPitch(-8.0 + pitch)
		TNK1 T 1
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_SetPitch(4.0 + pitch)
		TNK1 T 1
		TNT1 A 0 A_SpawnItemEx ("TankBaseNotRealMoving1" , 0, 0, 0, momx, momy, momz, user_tankbasedirection, SXF_ABSOLUTEVELOCITY | SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_SetPitch(4.0 + pitch)
		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("TankGun", 1)
	TNT1 A 0 A_TakeInventory("IsInATank", 1)
	8762 A 100
	Stop
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Vehicle's weapons and misc
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ACTOR TankReady : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 140
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 140
   Inventory.Icon TNT1A0
}

ACTOR TankGun : DoomWeapon
{
	Game Doom
	Weapon.AmmoUse1 1
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 1
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "TankAmmo"
	Weapon.AmmoType2 "HeavyMachinegunAmmo"
	Obituary "%o was gibbed by a tank."
	Weapon.SelectionOrder 9999
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.ALT_AMMO_OPTIONAL
	+WEAPON.NOAUTOAIM
	+WEAPON.EXPLOSIVE
	+WEAPON.CHEATNOTWEAPON
	+WEAPON.NO_AUTO_SWITCH
	Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED"
	Tag "Main Battle Tank"
	States
	{
	Ready:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("TNKENGS", 4)
		TNHD W 10
		TNT1 A 0 A_PlaySound("INFRARED", 1)
		TNHD XYZXYZXYZXYZXYZXYZXYZ 1 BRIGHT
		TNT1 A 0 A_GiveInventory("TankReady", 140)
		TNT1 A 0 A_TakeInventory("PressedUse", 1)
		TNT1 A 0 A_TakeInventory("PressedJump", 2)
		TNHD Y 0 A_TakeInventory("PressedJump", 2)
		TNT1 A 0 A_TakeInventory("TankZoom", 1)
		TNHD X 1 A_GunFlash
		TNT1 A 0 A_SetCrosshair(30)
		Goto ReadyToFire

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

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

	NotReady:
		TNHD A 1
		Goto ReadyToFire

	NotReadyZoom:
		TNT1 A 1
		Goto Ready2

	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 Ready2

	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:
		TNHD Z 1 A_Lower
		TNT1 A 0 SetPlayerProperty(0,0,4)
		Loop

	Select:
		TNT1 A 0
		TNHD z 1 A_Raise
		TNHD zzzzzzzzzzzzzzzzzzzzzz 0 A_Raise
		TNHD z 1 A_Raise
		Goto Ready

	EmergencyExit:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("CARSTE", 1)
		TNT1 A 0 A_GiveInventory("PressedUse")

		TNT1 A 5
		Goto LightEnd

	Fire:
	    TNT1 A 0
		TNT1 A 0 A_JumpIfinventory("TankZoom", 1, "FireZoom")
		TNT1 A 0 A_JumpIfInventory("TankAmmo", 1, 1)
		Goto NoAmmo
		TNT1 A 0 A_JumpIfInventory("TankReady", 139, 1)
		Goto NotReady
		TNT1 A 0 A_TakeInventory("TankReady", 140, 1)
		TNT1 A 0 A_PlaySound("TANKF", 1)
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundCannon", random(-1,1), 0, 0, -12, 0, random(-1,1))
		TNT1 A 0 A_FireCustomMissile("Alerter",0,0)
		MISG A 0 A_FireCustomMissile("TankShell", 0, 1)
		MISG A 0 A_FireCustomMissile("TankFireEffect",0,0)
		TNHD B 2 BRIGHT
		TNT1 A 0 A_SetPitch(pitch - 8.0)
		TNHD C 2 BRIGHT
		TNHD B 2 BRIGHT
		TNHD DD 2 A_SetPitch(pitch + 2.0)
		TNHD AA 2 A_SetPitch(pitch + 2.0)
		TNT1 A 0 A_GiveInventory("FiredTankMainGun", 1)
		TNT1 A 0 A_PlaySound("TANKEJ", 3)
		TNHD A 2
		Goto ReadyToFire

	FireZoom:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("TankAmmo", 1, 1)
		Goto NoAmmoZoom
		TNT1 A 0 A_JumpIfInventory("TankReady", 139, 1)
		Goto NotReadyZoom
		TNT1 A 0 A_TakeInventory("TankReady", 140, 1)
		TNT1 A 0 A_PlaySound("TANKF", 1)
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundCannon", random(-1,1), 0, 0, -12, 0, random(-1,1))
		TNT1 A 0 A_FireCustomMissile("Alerter",0,0)
		MISG A 0 A_FireCustomMissile("TankShell",0,1)
		MISG A 0 A_FireCustomMissile("TankFireEffect",0,0)
		TNT1 I 2 BRIGHT
		TNT1 A 0 A_SetPitch(pitch - 8.0)
		TNT1 II 2 BRIGHT
		TNT1 IIII 2 A_SetPitch(pitch + 2.0)
		TNT1 A 0 A_GiveInventory("FiredTankMainGun", 1)
		TNT1 A 0 A_PlaySound("TANKEJ", 3)
		TNT1 I 2
		Goto Ready2

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

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

	AltFire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfinventory("TankZoom", 1, "AltFire2")
		TNT1 A 0 A_PlaySound("CHAINSTA", 3)
		TNHD A 5
	AltFireContinue:
		TNT1 A 0 A_JumpIfInventory("HeavyMachinegunAmmo", 1, 2)
		TNT1 A 0 A_PlaySound("CHAINSTO", 3)
		Goto NoAmmo
		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)
		TNT1 A 0 A_FireCustomMissile("HeavyMachinegunProjectile", 0.2, 1, 32, 32, 0, -0.2)
		TNT1 A 0 A_FireCustomMissile("HeavyMachinegunFlash", 0, 0, 32, 32)

		TNHD AAA 1 BRIGHT
		TNT1 A 0 A_ReFire("AltFireContinue")
		TNT1 A 0 A_PlaySound("CHAINSTO", 3)
		Goto ReadyToFire

	AltFire2:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("CHAINSTA", 3)
		TNT1 A 5
		TNT1 A 0 A_StopSound(3)
	AltFire2Continue:
		TNT1 A 0 A_JumpIfInventory("HeavyMachinegunAmmo", 1, 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)
		TNT1 A 0 A_FireCustomMissile("HeavyMachinegunProjectile", 0.2, 1, 32, 32, 0, -0.2)
		TNT1 A 0 A_FireCustomMissile("HeavyMachinegunFlash", 0, 0, 32, 32)

		TNT1 AAA 1 BRIGHT
		TNT1 A 0 A_ReFire("AltFire2Continue")
		TNT1 A 0 A_PlaySound("CHAINSTO", 3)
		Goto Ready2

	Flash:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("BDTankHUD")
		TNHD J 1 BRIGHT
		TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		NULL A 0 A_JumpIf (pitch < -36, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 16, "TooLowCheck")
		TNT1 A 0 ACS_NamedExecuteAlways("BDTankHUD")
		TNHD J 1 BRIGHT
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		NULL A 0 A_JumpIf (pitch < -36, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 16, "TooLowCheck")
		TNT1 A 0 ACS_NamedExecuteAlways("BDTankHUD")
		TNHD J 1 BRIGHT
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		NULL A 0 A_JumpIf (pitch < -36, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 16, "TooLowCheck")
		Goto Flash

	TooHigh:
		TNT1 A 0
		TNT1 A 0 A_SetPitch(325)
		Goto Flash

	TooLowCheck:
		TNT1 A 0
		TNT1 A 0 A_SetPitch(15)
		Goto Flash

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

	TooHighCheckGZD:
		TNT1 A 0
		NULL A 0 A_SetPitch(-35)
		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("BDTankHUD")
		TNHD J 1 BRIGHT
		NULL A 0 A_JumpIf (pitch < -36, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 16, "TooLowCheck")
		TNT1 A 0 ACS_NamedExecuteAlways("BDTankHUD")
		TNHD J 1 BRIGHT
		NULL A 0 A_JumpIf (pitch < -36, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 16, "TooLowCheck")
		TNT1 A 0 ACS_NamedExecuteAlways("BDTankHUD")
		TNHD J 1 BRIGHT
		NULL A 0 A_JumpIf (pitch < -36, "TooHighCheckGZD")
		NULL A 0 A_JumpIf (pitch > 220, "TooHighCheck")
		NULL A 0 A_JumpIf (pitch > 16, "TooLowCheck")
		TNT1 A 0 A_JumpIfInventory("CanLeaveVehicle",1,1)
		Goto Flash
		TNT1 A 0 A_TakeInventory("TankZoom", 1)
		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

	}
}