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

Actor LongFly : Inventory
{
inventory.maxamount 20
}

Actor TurnCounter : Inventory
{
inventory.maxamount 6
}

Actor AlreadyStoped : Inventory
{
inventory.maxamount 1
}

ACTOR Speed : Ammo
{
	Game Doom
	Inventory.PickupMessage "$GOTCLIP"
	Inventory.Amount 0
	Inventory.MaxAmount 202
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 202
	Inventory.Icon "KMPHA0"
	States
	{
	Spawn:
		KMPH A -1
		Stop
	}
}

ACTOR PlayerBike : PlayerPawn
{
	Speed 0
	Health 100
	Radius 16
	Height 56
	Mass 300
	PainChance 255
	Scale 1.0

	Damagefactor "Avoid", 0.0	Damagefactor "BHFTOnBarrel", 0.0	Damagefactor "Blood", 0.0
	Damagefactor "CancelTeleportFog", 0.0	Damagefactor "CauseWaterSplash", 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 "MonsterKnocked", 0.0	Damagefactor "PussyGrab", 100.0	Damagefactor "Repair", 0.0
	Damagefactor "RevenantHitStomach", 0.0	Damagefactor "SpawnMarine", 0.0	Damagefactor "Stealth", 0.0
	Damagefactor "SSG", 5.0	DamageFactor "TankWeakSpot", 0.0
	Damagefactor "Taunt", 0.0	Damagefactor "TeleportRemover", 0.0	Damagefactor "Use", 0.0
	Species "Marines"
	DamageType "BikeHealthCalculation"
	Player.MorphWeapon "BikeHUD"
	+SOLID
	+DONTHURTSPECIES
	+THRUGHOST
	+THRUSPECIES
	-NOSKIN
	-PICKUP
	+FORCERADIUSDMG
	+DONTHARMSPECIES
	+NOTELEPORT
	GibHealth 10
	States
	{
	Sentback:
	TNT1 A 0
	TNT1 A 0 A_Recoil(10)
	TNT1 A 0 A_TakeInventory("Speed", 200)
	BIKE A 15
	BIKE A 0 A_ChangeFlag("NOPAIN", 0)
	TNT1 A 0 A_TakeInventory("Accelerate", 1)
	Goto Stay

	Pain.CrashStrong:
	Pain.Kick:
		BIKE A 0
		TNT1 A 0
		//TNT1 A 0 A_JumpIfInventory("Speed", 60, "CrashOut")
		BIKE A 0 A_ChangeFlag("NOPAIN", 1)
		BIKE A 0 A_TakeInventory("Speed", 64)
		BIKE A 0 A_PlaySOund("EBIKECLS", 3)
		BIKE A 0 A_CustomMissile ("TireSmoke", 36, 0, random (0, 360), 2, random (30, 170))
		TNT1 A 0 A_JumpIfInventory("Speed", 10, 1)
		Goto SentBack
		TNT1 A 0 A_Recoil(20)
		BIKE A 15
		BIKE A 0 A_ChangeFlag("NOPAIN", 0)
		TNT1 A 0 A_TakeInventory("Accelerate", 1)
		Goto Stay

	FullRepairs:
	    TNT1 A 0
		TNT1 A 0 A_Print("Bike Repaired!")
		TNT1 A 0 HealThing(100)
		BIKE A 1
		GOto Stay

	Pain.CrashLeft:
		BIKE A 0
		BIKE A 0 A_TakeInventory("Speed", 2)
		BIKE A 0 A_SetAngle(-5 + angle)
		BIKE A 1
		BIKE A 0 A_PlaySOund("BIKECLW", 3)
		TNT1 A 0 A_ChangeFLag("NOPAIN", 1)
		TNT1 A 0 ThrustThing(angle*256/360+192, 5, 0, 0) // (angle, force, nolimit, tid)

		TNT1 A 0 A_JumpIfInventory("Speed", 15, 2)
		Goto SentBack
		TNT1 A 0
		TNT1 A 0 A_ChangeFLag("NOPAIN", 0)
		BIKE A 0 A_JumpIfInventory("Speed", 30, "Accelerate")
		Goto Stay

	Pain.CrashRight:
		BIKE A 0
		TNT1 A 0 HealThing(1)
		BIKE A 1 A_SetAngle(5 + angle)
		BIKE A 0 A_TakeInventory("Speed", 2)
		BIKE A 0 A_PlaySOund("BIKECLW", 3)
		TNT1 A 0 A_ChangeFLag("NOPAIN", 1)

		TNT1 A 0 ThrustThing(angle*256/360+64, 5, 0, 0) // (angle, force, nolimit, tid)

		BIKE A 0 A_SetAngle(5 + angle)
		TNT1 A 0 A_JumpIfInventory("Speed", 15, 1)
		Goto SentBack
		TNT1 A 0 A_ChangeFLag("NOPAIN", 0)

		BIKE A 0 A_JumpIfInventory("Speed", 30, "Accelerate")
		Goto Stay

	Spawn:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("IsAVehicle", 1)
	    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)
		BIKE A 1

	StartBike:
		BIKE A 4
		TNT1 A 0 ACS_NamedExecuteAlways("BDVehicleInputs", 0, 0, 0, 0)//Button-checker for vehicle actions
		TNT1 A 0 SetPlayerProperty(0,1,4)
		TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		TNT1 A 0 A_PlaySound("BIKESTRT")
		TNT1 A 0 A_AlertMonsters
		BIKE A 20
		TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
		Goto Stay

	Stay:
	    BIKE A 0
		TNT1 A 0 A_SPawnItemEx("CheckPitchFront2", 32, 0, 1, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchBack2", -32, 0, 1, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchFront2b", 32, 0, 15, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchBack2b", -32, 0, 15, 0, 0, 0, 0)
		BIKE A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		BIKE A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeft")
		BIKE A 0 A_JumpIfInventory("TurnRight", 1, "TurnRight")
		BIKE A 0 A_TakeInventory("Accelerate", 1)
		BIKE A 2
		BIKE A 0 A_TakeInventory("TurnCounter", 3)
		BIKE A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
		BIKE A 0 A_JumpIfInventory("Accelerate", 1, "Accelerate")
		BIKE A 0 A_TakeInventory("Speed", 3)
		BIKE A 0 A_JumpIfInventory("Speed", 2, "Accelerate")
		BIKE A 0 A_PlaySound("BIKE1", 2, 1, 1)
		BIKE A 0 A_TakeInventory("MaxLeft", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
		Loop
	BackPedal:
	    BIKE A 2
		BIKE A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		BIKE A 0 A_JumpIfInventory("Speed", 1, "Brake")
	    BIKE A 0 A_Recoil(1)
		BIKE A 0 A_TakeInventory("Speed", 1)
		BIKE A 0 A_PlaySound("BIKE1", 2, 1, 1)
		BIKE A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeftBackPedal")
		BIKE A 0 A_JumpIfInventory("TurnRight", 1, "TurnRightBackPedal")
		BIKE A 0 A_JumpIfInventory("Backpedal", 1, "BackPedal")
		Goto Stay

	TurnRightBackPedal:
	    BIKE A 0
		TNT1 A 0 A_SetAngle(1 + angle)
		BIKE A 0 A_TakeInventory("Speed", 1)
		Goto Stay

	TurnLeftBackPedal:
	    BIKE A 0
		TNT1 A 0 A_SetAngle(-1 + angle)
		BIKE A 0 A_TakeInventory("Speed", 1)
		Goto Stay

	TurnRightPedal:
		BIKE A 2
		BIKE A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
	    BIKE A 0 A_Recoil(-1)
		BIKE A 0 A_TakeInventory("Speed", 1)
		BIKE A 0 A_PlaySound("BIKE1", 2, 1, 1)
		TNT1 A 0 A_SetAngle(-1 + angle)
		BIKE A 0 A_TakeInventory("Speed", 1)
		Goto Stay

	TurnLeftPedal:
		BIKE A 2
		BIKE A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
	    BIKE A 0 A_Recoil(-1)
		BIKE A 0 A_TakeInventory("Speed", 1)
		BIKE A 0 A_PlaySound("BIKE1", 2, 1, 1)
		TNT1 A 0 A_SetAngle(1 + angle)
		BIKE A 0 A_TakeInventory("Speed", 1)
		Goto Stay

	Brake:
	    BIKE A 0
		BIKE A 0 A_JumpIfInventory("TurnRight", 1, "TurnRightBrake")
		BIKE A 0 A_JumpIfInventory("TurnLeft", 1, "TurnRightBrake")
		BIKE A 0 A_TakeInventory("Speed", 20)
		BIKE A 0 A_PlaySound("BIKESK", 2, 1, 1)
		BIKE A 3
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
		BIKE A 0 A_JumpIfInventory("Speed", 1, 1)
		Goto StartBackpedal
		BIKE A 0
		Goto Accelerate

	StartBackpedal:
		BIKE A 0
		BIKE A 0 A_JumpIfInventory("AlreadyStoped", 1, "BackPedal")
		BIKE A 12
		BIKE A 0 A_GiveInventory("AlreadyStoped", 1)
		Goto Backpedal

	NoTurn:
	   BIKE A 0
	   BIKE A 0 A_TakeInventory("Speed", 100)
	   BIKE A 2
	   BIKE A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
	   BIKE A 0 A_JumpIfInventory("Accelerate", 1, "Accelerate")
	   Goto Stay

	TurnRight:
	    BIKE A 0

		BIKE A 0 A_GiveInventory("TurnCounter", 1)
		//BIKE A 0 A_TakeInventory("Speed", 1)
		//BIKE A 0 A_jumpIfInventory("Speed", 1,1)
		//BIKE A 0 A_JumpIfInventory("Backpedal", 1, "TurnRightBackPedal")
		BIKE A 0 A_JumpIfInventory("Accelerate", 1, 1)
		Goto TurnRightNoAcceleration

		BIKE A 0 A_JumpIFInventory("TurnCounter", 8, 1)
		Goto EasyTurnRightSlow
		BIKE A 0 A_PlaySound("BIKESK3", 3)
		TNT1 A 0 A_SetAngle(-2 + angle)
		//BIKE A 0 A_TakeInventory("Speed", 1)
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
		EasyTurnRightSlow:

		BIKE A 0 A_JumpIfInventory("Backpedal", 1, "TurnRightBrake")
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
		BIKE A 0 A_TakeInventory("MaxLeft", 1)
		BIKE A 0 A_JumpIfInventory("Speed", 1, 1)
		Goto NoTurn
	    TNT1 A 0 A_SetAngle(-2 + angle)

		BIKE C 1

		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
	    TNT1 A 0 A_SetAngle(-2 + angle)
		BIKE C 1
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
	    TNT1 A 0 A_SetAngle(-2 + angle)
		BIKE A 0 A_TakeInventory("Speed", 1)
		Goto Accelerate
	TurnLeft:
	    BIKE A 0
		BIKE A 0 A_GiveInventory("TurnCounter", 1)
		//BIKE A 0 A_jumpIfInventory("Speed", 1,1)
		//BIKE A 0 A_JumpIfInventory("Backpedal", 1, "TurnLeftBackPedal")
		BIKE A 0 A_JumpIfInventory("Accelerate", 1, 1)
		Goto TurnLeftNoAcceleration

		BIKE A 0 A_JumpIFInventory("TurnCounter", 8, 1)
		Goto EasyTurnLeftSlow
		BIKE A 0 A_PlaySound("BIKESK3", 3)
		TNT1 A 0 A_SetAngle(2 + angle)
		//BIKE A 0 A_TakeInventory("Speed", 1)
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
		EasyTurnLeftSlow:

		BIKE A 0 A_JumpIfInventory("Backpedal", 1, "TurnLeftBrake")
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
		BIKE A 0 A_JumpIfInventory("Speed", 1, 1)
		Goto NoTurn

	    TNT1 A 0 A_SetAngle(2 + angle)

		BIKE B 1
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)

		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
	    TNT1 A 0 A_SetAngle(2 + angle)

		BIKE B 1
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
	    TNT1 A 0 A_SetAngle(2 + angle)
		BIKE A 0 A_TakeInventory("Speed", 1)
		Goto Accelerate

	TurnRightNoAcceleration:
	    BIKE A 0
		BIKE A 0 A_JumpIfInventory("Backpedal", 1, "TurnRightBrake")
		BIKE A 0 A_TakeInventory("Speed", 4)
		BIKE A 0 A_JumpIfInventory("Accelerate", 1, "TurnRight")
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
		BIKE A 0 A_TakeInventory("MaxLeft", 1)
		BIKE A 0 A_JumpIfInventory("Speed", 1, 1)
		Goto TurnRightPedal
	    TNT1 A 0 A_SetAngle(-3 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////

		BIKE A 0 A_JumpIFInventory("TurnCounter", 8, 1)
		Goto EasyTurnRightNoAcceleration
		BIKE A 0 A_PlaySound("BIKESK3", 3)
		TNT1 A 0 A_SetAngle(-3 + angle)
		BIKE A 0 A_TakeInventory("Speed", 4)
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))

		EasyTurnRightNoAcceleration:
		BIKE C 1
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
	    TNT1 A 0 A_SetAngle(-3 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		BIKE C 1
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
	    BIKE A 0 A_SetAngle(-3 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		Goto Accelerate

	TurnLeftNoAcceleration:
	    BIKE A 0
		BIKE A 0 A_JumpIfInventory("Backpedal", 1, "TurnLeftBrake")
		BIKE A 0 A_TakeInventory("Speed", 4)
		BIKE A 0 A_JumpIfInventory("Accelerate", 1, "TurnLeft")
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
		BIKE A 0 A_JumpIfInventory("Speed", 1, 1)
		Goto TurnLeftPedal
	    TNT1 A 0 A_SetAngle(3 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////

		BIKE A 0 A_JumpIFInventory("TurnCounter", 8, 1)
		Goto EasyTurnLeftNoAcceleration
		BIKE A 0 A_PlaySound("BIKESK3", 3)
		TNT1 A 0 A_SetAngle(3 + angle)
		BIKE A 0 A_TakeInventory("Speed", 4)
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))

	EasyTurnLeftNoAcceleration:
		BIKE B 1
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
	    TNT1 A 0 A_SetAngle(3 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		BIKE B 1
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
	    BIKE A 0 A_SetAngle(3 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		Goto Accelerate

	TurnRightBrake:
	    BIKE A 0
		BIKE A 0 A_TakeInventory("Speed", 14)
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
		BIKE A 0 A_TakeInventory("MaxLeft", 1)
		BIKE A 0 A_JumpIfInventory("Speed", 1, 1)
		Goto StartBackPedal
	    TNT1 A 0 A_SetAngle(-4 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////

		BIKE A 0 A_PlaySound("BIKESK1", 3)
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))

		BIKE C 1
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
	    TNT1 A 0 A_SetAngle(-4 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		BIKE C 1
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
	    TNT1 A 0 A_SetAngle(-4 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		BIKE C 1
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
		BIKE A 0 A_TakeInventory("TurnLeft", 1)
	    TNT1 A 0 A_SetAngle(-4 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		Goto Accelerate

	TurnLeftBrake:
	    BIKE A 0
		BIKE A 0 A_TakeInventory("Speed", 14)
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
		BIKE A 0 A_JumpIfInventory("Speed", 1, 1)
		Goto StartBackPedal
	    TNT1 A 0 A_SetAngle(4 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////

		BIKE A 0 A_PlaySound("BIKESK1", 3)
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))

		BIKE B 1
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
	    TNT1 A 0 A_SetAngle(4 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		BIKE B 1
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
	    TNT1 A 0 A_SetAngle(4 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		BIKE B 1
		BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
		BIKE A 0 A_TakeInventory("TurnRight", 1)
		BIKE A 0 A_TakeInventory("MaxRight", 1)
	    TNT1 A 0 A_SetAngle(4 + angle)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)/////
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)/////
		Goto Accelerate

	Accelerate:
	    BIKE A 0
		TNT1 A 0 A_SPawnItemEx("CheckPitchFront2", 32, 0, 1, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchBack2", -32, 0, 1, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchFront2b", 32, 0, 15, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchBack2b", -32, 0, 15, 0, 0, 0, 0)
		TNT1 A 0 A_AlertMonsters
		BIKE A 1
		BIKE A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		BIKE A 0 A_TakeInventory("AlreadyStoped")
		BIKE A 0 A_CheckFloor("StartAcceleration")
		TNT1 A 0 A_ChangeFlag("NOPAIN", 1)
		TNT1 A 0
		TNT1 AAAAAA 0 A_SetPitch(-0.3 + pitch)
		BIKE A 0 A_JumpIfInventory("Speed", 90, "SendFlying3")
		BIKE A 0 A_JumpIfInventory("Speed", 60, "SendFlying2")

	SendFlying1:
		BIKE A 0 A_Recoil(-12)
		Goto Fly
	SendFlying2:
		BIKE A 0 A_Recoil(-16)
		Goto Fly
	SendFlying3:
		BIKE A 0 A_Recoil(-20)
		Goto Fly

	Fly:
	    TNT1 A 0
		BIKE A 1
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "ExitVehicle")
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 10, 2, 0)
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -10, 2, 0)
		BIKE A 0 A_CustomMissile ("HitFront", 30, 0, 0, 2, 0)
		BIKE A 0 A_GiveInventory("LongFly", 1)
		BIKE A 0 A_PlaySound("BIKE1D", 2, 1, 1)
		BIKE A 0 A_CheckFloor("Land")
		Loop

	Land:
	    BIKE A 0

		BOLE A 0 A_SetPitch(0)
		BIKE A 0 A_SpawnItem("BikeBounceSound")
		TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
		BIKE A 0 A_JumpIfInventory("LongFly", 7, 6)
		BIKE A 0 A_TakeInventory("LongFly", 20)
		Goto StartAcceleration
		TNT1 AAAAA 0
		BIKE A 0 A_TakeInventory("LongFly", 20)
		BIKE A 0 A_SpawnItem("QuakeCamera")
		BIKE A 0 A_SpawnItem("BikeBounceSound2")

		TNT1 AAAA 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
		TNT1 AAAAAA 0 A_SetPitch(+1.5 + pitch)
		BIKE A 3
		TNT1 AAAAAA 0 A_SetPitch(-1.5 + pitch)
		BIKE A 1 A_SetPitch(0)
		Goto StartAcceleration

	StartAcceleration:
	    BIKE A 0
		BIKE A 0 ThrustThingZ(0,-15,0,1)
		TNT1 A 0 A_Recoil(-1)
		BIKE A 0 A_GiveInventory("Speed", 2)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 20, 2, 0)
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -20, 2, 0)
		BIKE A 0 A_CustomMissile ("HitLeft", 30, 0, 30, 2, 0)
		BIKE A 0 A_CustomMissile ("HitRight", 30, 0, -30, 2, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchFront2", 32, 0, 1, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchBack2", -32, 0, 1, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchFront2b", 32, 0, 15, 0, 0, 0, 0)
		TNT1 A 0 A_SPawnItemEx("CheckPitchBack2b", -32, 0, 15, 0, 0, 0, 0)
		TNT1 A 0 A_JumpIfInventory("Speed", 200, "Speed20")
		TNT1 A 0 A_JumpIfInventory("Speed", 190, "Speed19")
		TNT1 A 0 A_JumpIfInventory("Speed", 180, "Speed18")
		TNT1 A 0 A_JumpIfInventory("Speed", 170, "Speed17")
		TNT1 A 0 A_JumpIfInventory("Speed", 160, "Speed16")
		TNT1 A 0 A_JumpIfInventory("Speed", 150, "Speed15")
		TNT1 A 0 A_JumpIfInventory("Speed", 140, "Speed14")
		TNT1 A 0 A_JumpIfInventory("Speed", 130, "Speed13")
		TNT1 A 0 A_JumpIfInventory("Speed", 120, "Speed12")
		TNT1 A 0 A_JumpIfInventory("Speed", 110, "Speed11")
		TNT1 A 0 A_JumpIfInventory("Speed", 100, "Speed10")
		TNT1 A 0 A_JumpIfInventory("Speed", 90, "Speed9")
		TNT1 A 0 A_JumpIfInventory("Speed", 80, "Speed8")
		TNT1 A 0 A_JumpIfInventory("Speed", 70, "Speed7")
		TNT1 A 0 A_JumpIfInventory("Speed", 60, "Speed6")
		TNT1 A 0 A_JumpIfInventory("Speed", 50, "Speed5")
		TNT1 A 0 A_JumpIfInventory("Speed", 40, "Speed4")
		TNT1 A 0 A_JumpIfInventory("Speed", 30, "Speed3")
		TNT1 A 0 A_JumpIfInventory("Speed", 20, "Speed2")
		TNT1 A 0 A_JumpIfInventory("Speed", 10, "Speed1")
		BIKE A 0 A_CustomMissile ("HitFrontWeak", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed1:
		TNT1 A 0 A_Recoil(-1)
		BIKE A 0 A_CustomMissile ("HitFrontWeak", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed2:
		TNT1 A 0 A_Recoil(-3)
		BIKE A 0 A_CustomMissile ("HitFront", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed3:
		TNT1 A 0 A_Recoil(-4)
		BIKE A 0 A_CustomMissile ("HitFront", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed4:
		TNT1 A 0 A_Recoil(-5)
		BIKE A 0 A_CustomMissile ("HitFrontStrong", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed5:
		TNT1 A 0 A_Recoil(-6)
		BIKE A 0 A_CustomMissile ("HitFrontStrong", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed6:
		TNT1 A 0 A_Recoil(-8)
		BIKE A 0 A_CustomMissile ("HitFrontStrong", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed7:
		TNT1 A 0 A_Recoil(-9)
		BIKE A 0 A_CustomMissile ("HitFrontDevastative", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed8:
		TNT1 A 0 A_Recoil(-10)
		BIKE A 0 A_CustomMissile ("HitFrontDevastative", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed9:
		TNT1 A 0 A_Recoil(-11)
		TNT1 AA 0 A_CustomMissile ("HitFrontSuicidal", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed10:
		TNT1 A 0 A_Recoil(-13)
		TNT1 AA 0 A_CustomMissile ("HitFrontSuicidal", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed11:
		TNT1 A 0 A_Recoil(-14)
		TNT1 AA 0 A_CustomMissile ("HitFrontSuicidal", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed12:
		TNT1 A 0 A_Recoil(-15)
		TNT1 AA 0 A_CustomMissile ("HitFrontSuicidal", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed13:
		TNT1 A 0 A_Recoil(-17)
		TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed14:
		TNT1 A 0 A_Recoil(-18)
		TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed15:
		TNT1 A 0 A_Recoil(-19)
		TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed16:
		TNT1 A 0 A_Recoil(-20)
		TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed17:
		TNT1 A 0 A_Recoil(-22)
		TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed18:
		TNT1 A 0 A_Recoil(-23)
		TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed19:
		TNT1 A 0 A_Recoil(-24)
		TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	Speed20:
		TNT1 A 0 A_Recoil(-25)
		TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
		Goto FinishSpeed
	FinishSpeed:
		BIKE A 0 A_JumpIfInventory("Accelerate", 1, 2)
		BIKE A 0 A_PlaySound("BIKE1", 2, 1, 1)
		Goto FinishSpeed+3
		BIKE A 0 A_PlaySound("BIKE1A", 2, 1, 1)
		BIKE A 0 A_CustomMissile ("HitFrontWeak", 30, 0, 0, 2, 0)
		BIKE A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeft")
		BIKE A 0 A_JumpIfInventory("TurnRight", 1, "TurnRight")
		BIKE A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
		BIKE A 0
		Goto Stay

	Pain.BikeHealthCalculation:
	BIKE A 1
	Goto StartBike

	Pain:
		PLAY G 0
		BIKE A 1 A_Pain
		TNT1 A 0 A_JumpIfInventory("LongFly", 1, "Fly")
		Goto Stay
	Death:
		TNT1 A 0
		Goto XDeath
		TNT1 A 0 A_TakeInventory("BikeHUD", 1)
		TNT1 A 0 A_GiveInventory("PressedUSE", 1)
		TNT1 A 0 A_jumpIfInventory("Speed", 10, "DieFast")
		TNT1 A 0 A_PlayerScream
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItem("KnockBike")
		PLAY IJKLM 6
		PLAY N -1
		Stop

	DieFast:
		TNT1 A 0 A_PlayerScream
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItem("KnockBike")
		BIKE A 0 ThrustThingZ(0,15,0,1)
		BKX2 ABCDEFGHI 4 A_Recoil(-3)
		PLAY N -1
		Stop
	XDeath:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("BikeHUD", 1)
		TNT1 A 0 A_GiveInventory("PressedUSE", 1)
		TNT1 A 0 A_JumpIfInventory("Crashed", 1, "DieFast")
		TNT1 AAAAA 0 A_CustomMissile ("CrashMetalShards", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0 A_CustomMissile ("BikePieces1", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0 A_CustomMissile ("BikePieces2", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0 A_CustomMissile ("BikePieces3", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0 A_CustomMissile ("BikePieces4", 32, 0, random (0, 360), 2, random (20, 50))
		BKX1 A 2
		TNT1 A 0 A_TakeInventory("Speed", 200)
		BIKE A 0 SetPlayerProperty(0,0,4)
		BIKE A 0 ThrustThingZ(0,100,0,1)
		BIKE A 0 A_PlaySound("DSXDTH2E", 2)
		BKX1 ABCDEFGHIJKLMNOP 1
		Goto XDeathSentFlying

	XDeathSentFlying:
	    BKX1 ABCDEFGHIJKLMNOP 2 A_CheckFloor("XDeathLand")
		Loop

	XDeathLand:
	    BIKE A 0 ThrustThingZ(0,40,0,1)
	XDeathLand1:
	    BKX2 AB 2
		BIKE A 0 A_PlaySound("DSXDTH2E", 2)
		BKX2 CEDFGHI 2 A_CheckFloor("XdeathLand2")
		Loop

	XDeathLand2:
		BIKE A 0 ThrustThingZ(0,20,0,1)
		BIKE A 0 A_PlaySound("DSXDTH2E", 2)
		BKX2 ABCDEF 4
		BIKE A 0 A_PlaySound("DSXDTH2E", 2)
		PLAY N 25 A_NoBlocking
		PLAY N -1
		Stop

	ExitVehicle:
	BIKE A 1
	TNT1 A 0 A_TakeInventory("PressedUse", 1)
	TNT1 A 0 A_SpawnItemEx ("TransferPlayerOutOfVehicle", -64, 0, 4)
	BIKE A 4
	TNT1 A 0 A_JumpIfInventory("CanLeaveVehicle", 1, "CanExit")
	TNT1 A 0 A_Print("Can't leave from this direction", 1)
	Goto Stay

	CanExit:
	TNT1 A 0
	TNT1 A 2 A_TakeInventory("IsAVehicle", 1)
	TNT1 A 0 A_TakeInventory("PressedUse", 1)
	TNT1 A 0 A_TakeInventory("CanLeaveVehicle", 1)
	TNT1 A 0 SetPlayerProperty(0,0,4)
	TNT1 A 0 ACS_NamedExecuteAlways("BDLeaveTank")
	TNT1 A 0 A_SpawnItemEx ("Bike", 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
	}
}

ACTOR BikeHUD : BrutalWeapon
{
	Weapon.AmmoUse 0
	Weapon.AmmoGive 0
	Weapon.AmmoType "Speed"
	Weapon.SelectionOrder 9999
	+WEAPON.ALT_AMMO_OPTIONAL
	+WEAPON.NOAUTOAIM
	+WEAPON.CHEATNOTWEAPON
	+WEAPON.NO_AUTO_SWITCH
	Tag "Bike"
	States
	{
	Select:
		BKHU A 1 A_Raise
		TNT1 AAAAAAA 0 A_Raise
		TNT1 A 0 A_TakeInventory("PressedUse", 1)
		Goto Ready
	Ready:
	    TNT1 A 0
		BIKE A 0 A_SetPitch(0)
		BIKE A 0 SetPlayerProperty(0,1,4)
		TNT1 A 0 A_GunFlash
		BKHU A 1
	Ready2:
		BIKE A 0 A_JumpIfInventory("Crashed",1, "Crashed")
		BIKE A 0 A_JumpIfInventory("MaxLeft",1, "MaxLeft")
		BIKE A 0 A_JumpIfInventory("MaxRight",1, "MaxRight")
		BIKE A 0 A_JumpIfInventory("TurnLeft",1, "TurnLeft")
		BIKE A 0 A_JumpIfInventory("TurnRight",1, "TurnRight")
		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"SwitchFlashlight")
		BKHU A 1 A_WeaponReady
		Loop
	TurnLeft:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("BikeRollLeft", 0, 0, 0, 0)
		BKHL AB 1
		BIKE A 0 A_GiveInventory("MaxLeft", 1)
		BKHL C 1
		Goto MaxLeft

	MaxLeft:
	    BIKE A 0
		//BIKE A 0 A_TakeInventory("MaxRight", 1)
		BIKE A 0 A_JumpIfInventory("TurnLeft", 1, 1)
		Goto StopTurningLeft

		BKHL C 1
		Goto Ready2

	StopTurningLeft:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("BikeStopLeft", 0, 0, 0, 0)
		BKHL BA 1
		BIKE A 0 A_TakeInventory("MaxLeft", 1)
		BIKE A 0 A_TakeInventory("TurnCounter", 3)
		BKHU A 2
		Goto Ready2

	TurnRight:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("BikeRollRight", 0, 0, 0, 0)
		BKHR AB 1
		BIKE A 0 A_GiveInventory("MaxRight", 1)
		BKHR C 1
		Goto MaxRight

	MaxRight:
	    BIKE A 0
		//BIKE A 0 A_TakeInventory("MaxLeft", 1)
		BIKE A 0 A_JumpIfInventory("TurnRight", 1, 1)
		Goto StopTurningRight
		BKHR C 1
		Goto Ready2

	StopTurningRight:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("BikeStopRight", 0, 0, 0, 0)
		BKHR BA 1
		BIKE A 0 A_TakeInventory("MaxRight", 1)
		BIKE A 0 A_TakeInventory("TurnCounter", 3)
		BKHU A 2
		Goto Ready2

	StopTurning:
	BIKE A 0
	BIKE A 0 A_TakeInventory("MaxLeft", 1)
	BIKE A 0 A_TakeInventory("MaxRight", 1)
	BIKE A 0 A_TakeInventory("TurnLeft", 1)
	BIKE A 0 A_TakeInventory("TurnRight", 1)
	Goto Ready2

	Deselect:
		BKHL A 1 A_Lower
		BIKE A 0 SetPlayerProperty(0,0,4)
		TNT1 A 0 A_TakeInventory("Speed", 200)
		Loop
 	Spawn:
		PIST A -1
		Stop

	Crashed:
	    TNT1 A 1
		TNT1 A 0 A_GiveInventory("PressedUse", 1)
		BIKE A 0 SetPlayerProperty(0,0,4)
		TNT1 A 4
		TNT1 A 0 A_TakeInventory("PressedUse", 1)
		TNT1 A 100
		TNT1 A 0 A_TakeInventory("PressedUse", 1)
		Goto Ready2

	Fire:
		TNT1 A 1
		Goto Ready2

	Flash:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"SwitchFlashlight")
		TNT1 A 0 A_JumpIfInventory("FlashlightOn", 1, "FlashOn")
		TNT1 A 1
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		TNT1 A 1
		NULL A 0 A_JumpIfInventory("PitchFrontToken2", 1, "PitchFrontHard")
		NULL A 0 A_JumpIfInventory("PitchFrontToken", 1, "PitChFront")
		NULL A 0 A_JumpIfInventory("PitchBackToken2", 1, "PitchBackHard")
		NULL A 0 A_JumpIfInventory("PitchBackToken", 1, "PitChBack")
		TNT1 A 0 A_SetPitch(0)
		Goto Flash

	PitChFront:
		TNT1 A 1
		TNT1 A 1 A_SetPitch(-6)
		TNT1 A 0 A_TakeInventory("PitchFrontToken", 20)
		Goto Flash

	LampPitChFront:
		TNT1 A 1 BRIGHT
		TNT1 A 0 A_SetPitch(-6)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile2", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile3", 0, 0, 0, 0, 0, 0)
		TNT1 A 0 A_TakeInventory("PitchFrontToken", 20)
		Goto Flash

	PitChFrontHard:
		TNT1 A 1
		TNT1 A 1 A_SetPitch(-12)
		TNT1 A 0 A_TakeInventory("PitchFrontToken2", 20)
		Goto Flash

	LampPitChFrontHard:
		TNT1 A 1 BRIGHT
		TNT1 A 0 A_SetPitch(-12)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile2", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile3", 0, 0, 0, 0, 0, 0)
		TNT1 A 0 A_TakeInventory("PitchFrontToken2", 20)
		Goto Flash

	PitChBack:
		TNT1 A 1
		TNT1 A 1 A_SetPitch(6)
		TNT1 A 0 A_TakeInventory("PitchBackToken", 20)
		Goto Flash

	LampPitChBack:
		TNT1 A 1 BRIGHT
		TNT1 A 0 A_SetPitch(6)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile2", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile3", 0, 0, 0, 0, 0, 0)
		TNT1 A 0 A_TakeInventory("PitchBackToken", 20)
		Goto Flash

	PitChBackHard:
		TNT1 A 1
		TNT1 A 1 A_SetPitch(12)
		TNT1 A 0 A_TakeInventory("PitchBackToken2", 20)
		Goto Flash

	LampPitChBackHard:
		TNT1 A 1 BRIGHT
		TNT1 A 0 A_SetPitch(12)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile2", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile3", 0, 0, 0, 0, 0, 0)
		TNT1 A 0 A_TakeInventory("PitchBackToken2", 20)
		Goto Flash

	FlashOn:
	    TNT1 A 1 BRIGHT
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile2", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile3", 0, 0, 0, 0, 0, 0)
		NULL A 0 A_JumpIfInventory("PitchFrontToken2", 1, "LampPitchFrontHard")
		NULL A 0 A_JumpIfInventory("PitchFrontToken", 1, "LampPitChFront")
		NULL A 0 A_JumpIfInventory("PitchBackToken2", 1, "LampPitchBackHard")
		NULL A 0 A_JumpIfInventory("PitchBackToken", 1, "LampPitChBack")
		TNT1 A 0 A_SetPitch(0)

		TNT1 A 1 BRIGHT
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile2", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile3", 0, 0, 0, 0, 0, 0)
		NULL A 0 A_JumpIfInventory("PitchFrontToken2", 1, "LampPitchFrontHard")
		NULL A 0 A_JumpIfInventory("PitchFrontToken", 1, "LampPitChFront")
		NULL A 0 A_JumpIfInventory("PitchBackToken2", 1, "LampPitchBackHard")
		NULL A 0 A_JumpIfInventory("PitchBackToken", 1, "LampPitChBack")
		TNT1 A 0 A_SetPitch(0)

		TNT1 A 1 BRIGHT
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile2", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile3", 0, 0, 0, 0, 0, 0)
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		NULL A 0 A_JumpIfInventory("PitchFrontToken2", 1, "LampPitchFrontHard")
		NULL A 0 A_JumpIfInventory("PitchFrontToken", 1, "LampPitChFront")
		NULL A 0 A_JumpIfInventory("PitchBackToken2", 1, "LampPitchBackHard")
		NULL A 0 A_JumpIfInventory("PitchBackToken", 1, "LampPitChBack")
		TNT1 A 0 A_SetPitch(0)
		TNT1 A 1 BRIGHT
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile2", 0, 0, 0, 0, 0, 0)
		RIFF A 0 A_FireCustomMissile("FlashlightProjectile3", 0, 0, 0, 0, 0, 0)
		NULL A 0 A_JumpIfInventory("PitchFrontToken2", 1, "LampPitchFrontHard")
		NULL A 0 A_JumpIfInventory("PitchFrontToken", 1, "LampPitChFront")
		NULL A 0 A_JumpIfInventory("PitchBackToken2", 1, "LampPitchBackHard")
		NULL A 0 A_JumpIfInventory("PitchBackToken", 1, "LampPitChBack")
		TNT1 A 0 A_SetPitch(0)
		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_PlaySound("FLASHON", 5)
        Goto Ready

	TurnFlashOff:
		TNT1 A 0 A_Takeinventory("FlashlightOn",1)
		TNT1 A 0 A_Light0
		TNT1 A 0 A_PlaySound("FLASHOFF", 5)
        Goto Ready

	LightEnd:
		TNT1 A 0
		TNT1 A 3
		TNT1 A 0 A_JumpIfInventory("CanLeaveVehicle",1,1)
		Goto Flash
		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
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Base vehicle Actor

ACTOR BikePowerup : PowerupGiver
{
  Powerup.Type "BikeSwitch"
  Powerup.Duration 252000
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 1
  Health 100
  GibHealth 1
  Scale 0.7
  +SHOOTABLE
  +NOBLOOD
  +FIXMAPTHINGPOS
  +NORADIUSDMG
  Mass 999999999
  Height 96
  Radius 32
  damagefactor "stomp", 0
  damagefactor "normal", 0.5
  painchance 255
  GibHealth 10
  States
  {

    Spawn:
    BIKP A 10
	BIKE A 0 A_ChangeFlag("THRUACTORS", 0)
    NULL A 0 A_JumpIf (momZ == 0, "Spawn2")
	BIKE A 0 A_ChangeFlag("THRUACTORS", 1)
    TNT1 A 1
	BIKP A 1
    BIKP ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB 1
	BIKP A 1 A_ChangeFlag("THRUACTORS", 0)
	Goto Spawn2

 Spawn2:
	BIKP A 2
	BIKE A 0 A_jumpifhealthlower(20, 2)
	BIKE A 0 A_Jump(256, 6)
	TNT1 AA 0
	BIKE A 0 A_Jump(256, 10)
	TNT1 AAA 0
	BIKE A 0 A_jumpifhealthlower(50, 2)
	BIKE A 0 A_Jump(256, 6)
	TNT1 AA 0
	TNT1 AAAAAA 0
	Loop
	BIKE A 0

 Death:
 XDeath:
    TNT1 A 1
	BIKE A 0 A_SpawnItem("BigExplosion1112")
	BIKE A 0 A_PlaySound("weapons/explode")
	BIKE A 0 A_PlaySound("EXPLOSIO", 3)
	BIKE A 0 A_Scream
	NULL AAAAAAAAA 0 A_CustomMissile ("BDGlassShard", 96, 0, random (0, 360), 2, random (0, 360))
	ELEC A 0 A_Explode(100, 250)
	TNK1 B 500
	TNK1 B 2000
	TNT1 A -1
	Stop

}
}

ACTOR Bike: Tank 7265
{
	//$Category BD Vehicles
	//$Colour rgb(200, 200, 200)
	//$Sprite BIKPA1
	Health 100
	GibHealth 1
	Scale 0.5
	Height 32
	Radius 32
	Mass 200
    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 Thing_ChangeTID(0, 0)
		TNK1 C 0 A_ChangeFlag("THRUACTORS", 0)
		TNT1 A 0 A_ChangeFlag("FRIENDLY", 1)
		Goto StandingHere

	  StandingHere:
		BIKP A 1
		Loop

	Active:
		TNT1 A 0
		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)
		BIKP A 3
		TNT1 A 0 A_GiveToTarget("BikePowerup", 1)
		TNT1 A 0 A_GiveToTarget("BikeMorpher", 1)
		TNT1 A 0 Thing_ChangeTID(0, 261)
		TNT1 A 0 A_NoBlocking
		BIKP A 1
		TNT1 A 0 A_ChangeFlag("USESPECIAL", 0)
		BIKP A 10
		TNT1 A 0 Thing_ChangeTID(0, 0)
		BIKP A 1
		Stop

	Death:
		TNT1 A 1
		BIKE A 0 A_NoBlocking
		NULL AAAAAAAAA 0 A_CustomMissile ("BDGlassShard", 96, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("CrashMetalShards", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0 A_CustomMissile ("BikePieces1", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0 A_CustomMissile ("BikePieces2", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0 A_CustomMissile ("BikePieces3", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0 A_CustomMissile ("BikePieces4", 32, 0, random (0, 360), 2, random (20, 50))
		TNT1 A 0
		Stop

		Pain.Repair:
		 TNT1 A 0
		 TNT1 A 0 A_ChangeFLag("NOPAIN", 1)
		 TNT1 A 0 HealThing(7)
		 TNK1 T 1
		 TNT1 A 0 A_ChangeFLag("NOPAIN", 0)
		 Goto StandingHere
	}
}

ACTOR PowerBikeSwitch : PowerMorph {PowerMorph.PlayerClass "PlayerBike"}

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