//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
	SpawnID 11
	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 1
	Health 100
	Radius 16
	Height 56
	Mass 100
	PainChance 255
	Scale 1.0
	Speed 0
	damagefactor "slime", 0.0	damagefactor "Repair", 1.0 damagefactor "CheckRepair", 0.0
	damagefactor "Head", 0.0	damagefactor "FriendBullet", 0.0    damagefactor "Taunt", 0.0    damagefactor "KillMe", 0.0
	damagefactor "Shrapnel", 0.0    damagefactor "Blood", 0.0    damagefactor "BlueBlood", 0.0
	damagefactor "GreenBlood", 0.0    damagefactor "MinorHead", 0.0    damagefactor "Decaptate", 0.0	damagefactor "MonsterKnocked", 0.0
    damagefactor "CancelTeleportFog", 0.0	damagefactor "BHFTOnBarrel", 0.0	damagefactor "GibRemoving", 0.0	damagefactor "SuperPunch", 5.0
	damagefactor "HelperMarineFatallity", 0.0	damagefactor "Leg", 0.0	damagefactor "SpawnMarine", 0.0	damagefactor "TeleportRemover", 0.0
	DamageFactor "CauseObjectsToSplash", 0.0 DamageFactor "Trample", 0.0 DamageFactor "Minigun", 0.1 damageFactor "Machinegun", 0.1
	DamageFactor "TankWeakSpot", 3.0 damagefactor "Plasma", 1.3 damagefactor "Plasma2", 1.3
	damagefactor "Desintegrate", 3.0 damagefactor "Railgun", 2.0 damagefactor "Fire", 0.0
	Damagefactor "Stealth", 0.0 Damagefactor "Slide", 0.0 Damagefactor "Use", 0.0 Damagefactor "PussyGrab", 0.0
	damagefactor "stomp", 0 damagefactor "Shotgun", 0.02 damagefactor "kick", 0.05 damagefactor "extremepunches", 0.05 damagefactor "taunt", 0 damagefactor "avoid", 0
	damagefactor "melee", 0.2 damagefactor "minigun", 0.05 damagefactor "minor", 0.02 damagefactor "saw", 0.2 damagefactor "cut", 0.2
	damagefactor "Explosive", 0.46 damagefactor "bullet", 0.1 damagefactor "monsterbullet", 0.25 damagefactor "monstershotgun", 0.2 damagefactor "monsterminigun", 0.2
	
	DamageFactor "Normal", 0.4
	DamageFactor "Extreme", 1.0
	DamageFactor "CrashLeft", 1.0
	DamageFactor "CrashRight", 1.0
	DamageFactor "KnockoutBike", 1.0
	DamageFactor "BikeHealthCalculation", 1.0
	DamageType "BikeHealthCalculation"
	//Player.StartItem "BikeHUD"
	Player.MorphWeapon "BikeHUD"
	-PICKUP
	+SLIDESONWALLS
	+NOSKIN
	-PICKUP
	+FORCERADIUSDMG
	+THRUGHOST
	GibHealth 10
	
	//***Che:
	Player.Face YMB
	Player.SoundClass "fbd_vehicle_override" //just to remove the gender-inappropriate *land sounds
	
	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)
			//***Che
			TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			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:
		StartBike:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("IsAVehicle", 1)
			TNT1 A 0 A_TakeInventory("PressedUse", 1)
			BIKE A 1
			
			//***Che:
			TNT1 A 0 SetPlayerProperty(0, 1, PROP_BUDDHA)
			
			TNT1 A 0 A_AlertMonsters
			TNT1 A 0 A_TakeInventory("Speed", 200)
			TNT1 A 0 A_TakeInventory("PressedUse", 1)
			TNT1 A 0 A_TakeInventory("Crashed", 1)
			TNT1 A 0 A_PlaySound("BIKESTRT")
			BIKE A 20
			TNT1 A 0 A_TakeInventory("Speed", 200)
			TNT1 A 0 A_TakeInventory("PressedUse", 1)
			TNT1 A 0 A_TakeInventory("Crashed", 1)
			Goto Stay
		
		Stay:
			BIKE A 0
			TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			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
			//TNT1 A 0 A_GiveInventory("BikeHUD", 1)
			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_JumpIfInventory("Speed", 5, "Accelerate")
			BIKE A 0 A_TakeInventory("Speed", 1)
			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 1
			TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			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", 9)
			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	
			
		Brake:
			//BIKE A 1 A_Recoil(FIXED_TO_FLOAT * CallAcs("FBD_MotorcycleThrust"))
			BIKE A 0 A_JumpIfInventory("TurnRight", 1, "TurnRightBrake")
			BIKE A 0 A_JumpIfInventory("TurnLeft", 1, "TurnRightBrake")
			
			BIKE A 0 A_JumpIfInventory("Speed", 100, "Brake100kph")
			
			BIKE A 0 A_JumpIfInventory("Speed", 50, "Brake50kph")
			
			BIKE A 0 A_TakeInventory("Speed", 5)
			BIKE A 0 A_PlaySound("BIKE1", 2, 1, 1)
			TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			BIKE A 1	
			BIKE A 0 A_JumpIfInventory("Speed", 1, "Speed")
			Goto StartBackpedal
			BIKE A 0 A_JumpIfInventory("BackPedal", 1, "Brake")
			Goto Stay	
		
		Brake50kph:
			BIKE A 0 A_TakeInventory("Speed", 2)
			BIKE A 0 A_PlaySound("BIKESK", 2, 1, 1)
			//BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
			TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			
			BIKE A 0 A_JumpIfInventory("Speed", 1, 1)
			Goto StartBackpedal
			
			BIKE A 1
			BIKE A 0 A_TakeInventory("Speed", 2)
			BIKE A 0 A_PlaySound("BIKESK", 2, 1, 1)
			//BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
			//aBIKE A 0 A_PlaySound("BIKESK", 3)
			TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			BIKE A 0 A_JumpIfInventory("Speed", 1, "Speed")
			Goto StartBackpedal
			BIKE A 0 A_JumpIfInventory("BackPedal", 1, "Brake")
			Goto Stay	
		
		Brake100kph:
			BIKE A 1
			BIKE A 0 A_TakeInventory("Speed", 2)
			BIKE A 0 A_PlaySound("BIKESK", 2, 1, 1)
			BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
			//aBIKE A 0 A_PlaySound("BIKESK", 3)
			BIKE A 0 A_JumpIfInventory("Speed", 1, "Speed")
			Goto StartBackpedal
			BIKE A 0 A_JumpIfInventory("BackPedal", 1, "Brake")
			Goto Stay
			
		StartBackpedal:
			BIKE A 0
			BIKE A 0 A_JumpIfInventory("AlreadyStoped", 1, "BackPedal")
			//BIKE A 12
			//***Che
			BIKE AAA 4 A_JumpIfHealthLower(2, "EmergencyExit")
			BIKE A 0 A_GiveInventory("AlreadyStoped", 1)
			Goto Backpedal
		
		NoTurn:
		   BIKE A 0
		   BIKE A 0 A_TakeInventory("Speed", 100)
		   BIKE A 0 A_TakeInventory("Accelerate", 1)
		   BIKE AA 1 A_JumpIfHealthLower(2, "EmergencyExit")
		   BIKE A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
		   BIKE A 0 A_JumpIfInventory("Accelerate", 1, "Accelerate")
		   Goto Stay
			
			
		TurnRight:
			BIKE A 0 
			//***Che
			BIKE A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			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_GiveInventory("Speed", 1)
			
			TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "TurnRightActuallyAccelerate")
			Goto EasyTurnRightSlow
		
		TurnRightActuallyAccelerate:	
			BIKE A 0 A_JumpIfInventory("Speed", 40, 2)
			BIKE A 0 A_GiveInventory("Speed", 1)
			BIKE A 0 A_JumpIfInventory("Speed", 60, 2)
			BIKE A 0 A_GiveInventory("Speed", 1)
			BIKE A 0 A_JumpIfInventory("Speed", 80, 2)
			BIKE A 0 A_GiveInventory("Speed", 1)
			BIKE A 0 A_CustomMissile ("TireSmoke", 1, 0, random (0, 360), 2, random (30, 170))
			Goto EasyTurnRightSlow
			
		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 A_JumpIfHealthLower(2, "EmergencyExit")
			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 
			//***Che
			BIKE A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			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_GiveInventory("Speed", 1)
			TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "TurnLeftActuallyAccelerate")
			Goto EasyTurnLeftSlow
		
		TurnLeftActuallyAccelerate:				

			BIKE A 0 A_JumpIfInventory("Speed", 40, 2)
			BIKE A 0 A_GiveInventory("Speed", 1)
			BIKE A 0 A_JumpIfInventory("Speed", 60, 2)
			BIKE A 0 A_GiveInventory("Speed", 1)
			BIKE A 0 A_JumpIfInventory("Speed", 80, 2)
			BIKE A 0 A_GiveInventory("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 A_JumpIfHealthLower(2, "EmergencyExit")
			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", 1)
			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 NoTurn
			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", 1)
			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 A_JumpIfHealthLower(2, "EmergencyExit")
			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", 1)
			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 NoTurn
			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", 1)
			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 A_JumpIfHealthLower(2, "EmergencyExit")
			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", 5)
			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 A_JumpIfHealthLower(2, "EmergencyExit")
			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 A_JumpIfHealthLower(2, "EmergencyExit")
			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", 5)
			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 A_JumpIfHealthLower(2, "EmergencyExit")
			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 A_JumpIfHealthLower(2, "EmergencyExit")
			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
			//***Che
			BIKE A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			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)
		
		SendFlyingAuto:
			BIKE A 0 A_Recoil(FIXED_TO_FLOAT * CallAcs("FBD_MotorcycleThrust"))
			Goto Fly
/*			
			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 A_JumpIfHealthLower(2, "EmergencyExit")
			//***Che
			BIKE A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			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")
			BIKE A 0 A_TakeInventory("Accelerate", 1)
			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 AAA 1 A_JumpIfHealthLower(2, "EmergencyExit")
			TNT1 A 0 A_JumpIfHealthLower(2, "EmergencyExit")
			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 //NOPE, they start fighting each other and stop you dead! Because this script relies on velocity vector instead of actual velocity! A_Recoil(FIXED_TO_FLOAT * CallAcs("FBD_MotorcycleThrust")) //A_Recoil(-3)
			
			
			
			TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "ActuallyAccelerate")
			TNT1 A 0 A_JumpIfInventory("Speed", 40, "PlayRunningSound")
			BIKE A 0 A_PlaySound("BIKE1", 2, 1, 1) // below 40kph and not accelerating = idling sound
			Goto Speed
			
		PlayRunningSound:
			BIKE A 0 A_PlaySound("BIKE1A", 2, 1, 1)
			Goto Speed
			
		ActuallyAccelerate:	
			BIKE A 0 A_PlaySound("BIKE1A", 2, 1, 1)
			BIKE A 0 A_GiveInventory("Speed", 1)
			BIKE A 0 A_JumpIfInventory("Speed", 40, 2)
			BIKE A 0 A_GiveInventory("Speed", 1)
			BIKE A 0 A_JumpIfInventory("Speed", 60, 2)
			BIKE A 0 A_GiveInventory("Speed", 1)
			BIKE A 0 A_JumpIfInventory("Speed", 80, 2)
			BIKE A 0 A_GiveInventory("Speed", 1)
			TNT1 A 0 A_TakeInventory("Accelerate", 1)
			Goto Speed
			
			
		
		Speed:
			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)
		
			//***Che
			TNT1 A 0 A_Recoil(FIXED_TO_FLOAT * CallAcs("FBD_MotorcycleThrust")) // adaptive feedback to stabilize speed at what inventory says
			//BIKE A 0 A_CustomMissile ("HitFrontWeak", 30, 0, 0, 2, 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(-2)
			BIKE A 0 A_CustomMissile ("HitFront", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed3:
			//TNT1 A 0 A_Recoil(-3)
			BIKE A 0 A_CustomMissile ("HitFront", 30, 0, 0, 2, 0)
			Goto FinishSpeed
		Speed4:
			//TNT1 A 0 A_Recoil(-4)
			BIKE A 0 A_CustomMissile ("HitFrontStrong", 30, 0, 0, 2, 0)
			Goto FinishSpeed
		Speed5:
			//TNT1 A 0 A_Recoil(-5)
			BIKE A 0 A_CustomMissile ("HitFrontStrong", 30, 0, 0, 2, 0)
			Goto FinishSpeed
		Speed6:
			//TNT1 A 0 A_Recoil(-6)
			BIKE A 0 A_CustomMissile ("HitFrontStrong", 30, 0, 0, 2, 0)
			Goto FinishSpeed
		Speed7:
			//TNT1 A 0 A_Recoil(-7)
			BIKE A 0 A_CustomMissile ("HitFrontDevastative", 30, 0, 0, 2, 0)
			Goto FinishSpeed
		Speed8:
			//TNT1 A 0 A_Recoil(-8)
			BIKE A 0 A_CustomMissile ("HitFrontDevastative", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed9:
			//TNT1 A 0 A_Recoil(-9)
			TNT1 AA 0 A_CustomMissile ("HitFrontSuicidal", 30, 0, 0, 2, 0)
			Goto FinishSpeed
		Speed10:
			//TNT1 A 0 A_Recoil(-10)
			TNT1 AA 0 A_CustomMissile ("HitFrontSuicidal", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed11:
			//TNT1 A 0 A_Recoil(-11)
			TNT1 AA 0 A_CustomMissile ("HitFrontSuicidal", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed12:
			//TNT1 A 0 A_Recoil(-12)
			TNT1 AA 0 A_CustomMissile ("HitFrontSuicidal", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed13:
			//TNT1 A 0 A_Recoil(-13)
			TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed14:
			//TNT1 A 0 A_Recoil(-14)
			TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed15:
			//TNT1 A 0 A_Recoil(-15)
			TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed16:
			//TNT1 A 0 A_Recoil(-16)
			TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed17:
			//TNT1 A 0 A_Recoil(-17)
			TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed18:
			//TNT1 A 0 A_Recoil(-18)
			TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed19:
			//TNT1 A 0 A_Recoil(-19)
			TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		Speed20:
			//TNT1 A 0 A_Recoil(-20)
			TNT1 AAA 0 A_CustomMissile ("HitFrontTerminalSpeed", 30, 0, 0, 2, 0)
			Goto FinishSpeed	
		
		FinishSpeed:
			BIKE A 0 A_TakeInventory("Accelerate", 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 
			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))
			
			// *cap* the velocity because 200 kph is somewhere around 64, double the player's diameter!
			// P.S. Nested trinary operators -- Zandronum can do them!
			TNT1 A 0 A_ChangeVelocity(velx < -31.0 ? -31.0 : (velx > 31.0 ? 31.0 : velx), vely < -31.0 ? -31.0 : (vely > 31.0 ? 31.0 : vely), velz, CVF_REPLACE)
			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
			//***Che
			//TNT1 A 0 A_SpawnItemEx ("TransferPlayerOutOfVehicle", 0, 0, 76)
			TNT1 A 0 A_TakeInventory("CanLeaveVehicle", 1)
			TNT1 A 0 A_SpawnItemEx ("FBD_TransferPlayerOutOfVehicle", 0, -48, 16)
			TNT1 A 0 A_SpawnItemEx ("FBD_TransferPlayerOutOfVehicle", 32, -48, 32)
			TNT1 A 0 A_SpawnItemEx ("FBD_TransferPlayerOutOfVehicle", -32, -48, 32)
			TNT1 A 0 A_SpawnItemEx ("FBD_TransferPlayerOutOfVehicle", 0, 48, 16)
			TNT1 A 0 A_SpawnItemEx ("FBD_TransferPlayerOutOfVehicle", 32, 48, 32)
			TNT1 A 0 A_SpawnItemEx ("FBD_TransferPlayerOutOfVehicle", -32, 48, 32)
			
			//wtf this leads to you being stuck inside the motorcycle :(
			//TNT1 A 0 A_SpawnItemEx ("FBD_TransferPlayerOutOfVehicle", 0, 0, 80)
			TNT1 A 0 A_TakeInventory("PressedUse", 1)
			BIKE A 4
			
			TNT1 A 0 A_JumpIfInventory("CanLeaveVehicle", 1, "CanExit")
			TNT1 A 0 A_Print("$EXITVEH_CANT", 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 SetPlayerProperty(0, 0, PROP_BUDDHA)
			TNT1 A 0 ACS_NamedExecuteAlways("BDStopCamera")
			
			//***Che
			//TNT1 A 0 ACS_NamedExecuteAlways("BDLeaveTank")
			//TNT1 A 0 A_SpawnItemEx ("Bike", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
			"----" A 0 ACS_NamedExecuteWithResult("FBD_LeaveVehicle", 4) // 4 = motorcycle
			Goto FinishExit
			
		//***Che
		EmergencyExit:
			//TNT1 A 0 A_TakeInventory("BikeHUD", 1)
			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))		
			
			// *cap* the velocity because 200 kph is somewhere around 64, double the player's diameter!
			// P.S. Nested trinary operators -- Zandronum can do them!
			TNT1 A 0 A_ChangeVelocity(velx < -31.0 ? -31.0 : (velx > 31.0 ? 31.0 : velx), vely < -31.0 ? -31.0 : (vely > 31.0 ? 31.0 : vely), velz, CVF_REPLACE)
			
			TNT1 A 2 A_TakeInventory("IsInATank", 1)
			TNT1 A 0 A_TakeInventory("PressedUse", 1)
			TNT1 A 0 A_TakeInventory("CanLeaveVehicle", 1)
			TNT1 A 0 SetPlayerProperty(0, 0, PROP_BUDDHA)
			TNT1 A 0 ACS_NamedExecuteAlways("BDStopCamera")
			
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_RegisterPlayerVehicleExit",0,0,46)
			
			// player is penalized with -50 health by the script, on top of the usual penalty for speeding
			TNT1 A 0 ACS_NamedExecuteWithResult("FBD_LeaveVehicle", 4, 1) // 4 = motorcycle
			
			TNT1 AAA 10 A_TakeInventory("PressedUse", 1)
			TNT1 A 0 A_TakeInventory("PressedUse", 1)
			TNT1 A 100
			Stop
			
		FInishExit:
			TNT1 A 0 A_TakeInventory("PressedUse", 1)
			TNT1 A 0 ACS_NamedExecuteAlways("BDStopCamera")
			TNT1 AAA 10 A_TakeInventory("PressedUse", 1)
			TNT1 A 0 A_TakeInventory("PressedUse", 1)
			Goto Stay
	}
}



ACTOR BikeHUD : DoomWeapon
{
	Weapon.AmmoUse 0
	Weapon.AmmoGive 0
	Weapon.AmmoType "Speed"
	Weapon.AmmoUse2 1
	Weapon.AmmoGive2 0
	Weapon.AmmoType2 "Shell"
	States
	{
	Select:
		BKHU A 1 A_Raise
		TNT1 AAAAAAA 0 A_Raise
		Goto Ready
	Ready:
	    BKHU A 1
		BIKE A 0 A_SetPitch(0)
		BIKE A 0 SetPlayerProperty(0,1,4)
		TNT1 A 0 A_TAkeInventory("PressedUse", 1)
		TNT1 A 0 A_GunFlash
	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")
		BKHU A 1 A_WeaponReady
		BIKE A 0 A_JumpIfInventory("PressedUse",1, "Leaving")
		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
		TNT1 A 0 A_TakeInventory("Speed", 200)
		Loop
 	Spawn:
		PIST A -1
		Stop
	Leaving:
	    BIKE A 0
		BIKE A 0 SetPlayerProperty(0,0,4)
		BKHL A 10
		TNT1 A 0 A_TakeInventory("PressedUse", 1)
		Goto Ready
		
	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 Ready
	
	Fire:
		TNT1 A 1
		Goto Ready
		
	Flash:
		TNT1 A 2
		TNT1 A 0 A_JumpIfInventory("PressedUse", 1, "LightEnd")
		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)
		Loop
	
	PitChFront:
		TNT1 A 1
		TNT1 A 1 A_SetPitch(-6)
		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
		
	PitChBack:
		TNT1 A 1
		TNT1 A 1 A_SetPitch(6)
		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	
	
	
	Cannon:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("ACANO1", 1)
		TNT1 A 0 A_PlaySound("FARCAN1", 4)
		TNT1 A 0 A_TakeInventory("HeavyMachinegunAmmo", 1)
		TNT1 A 0 A_SpawnItemEx("AutoCannonCaseSpawn", 0, 0, 0, 0, 0, 0, 0)
		TNT1 A 0 A_FireCustomMissile("AutoCannonProjectile", 0, 0, 0, -35, 0, 1)
		TNT1 AA 0 A_FireCustomMissile("HeavyMachinegunFlash", 0, 0, 0, -35)
		HELH A 1 A_GiveInventory("TankReady", 1)
		HELH AA 1 A_GiveInventory("TankReady", 1)
		NULL A 0 A_JumpIf (pitch > 40, "TooLowCheck1")
		Goto Flash
		
	TooLowCheck1:
		TNT1 A 1
		TNT1 A 0 A_JumpIf(pitch < 90, "TooLow")
		Goto Flash
		
		
	TooLow:
		TNT1 A 1 A_SetPitch(39)
		NULL A 0 A_JumpIf (pitch > 40, "TooLowCheck1")
		Goto Flash	
		
		
	
	LightEnd:
		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 ("GlassShard", 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
{
	Health 100
	GibHealth 1
	Scale 0.5
	Height 32
	Radius 16 //32
	Mass 1000
	
	//***Che
	+FRIENDLY
	
    States
    {
		Spawn:
			BIKP 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
		
		//***Che
		Active:
		Inactive:
			TNT1 A 0 A_JumpIf(!CallAcs("FBD_EnterVehicle", 4), "StandingHere") // 4 = motorcycle
			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
/*			
		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_Scream
			NULL AAAAAAAAA 0 A_CustomMissile ("GlassShard", 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 -1
			Stop
		
		Pain.Repair:
			TNT1 A 0
			TNT1 A 0 A_ChangeFLag("NOPAIN", 1)
			TNT1 A 0 HealThing(5)
			TNK1 T 1
			TNT1 A 0 HealThing(5)
			TNT1 A 0 A_ChangeFLag("NOPAIN", 0)
			Goto StandingHere
	}
}

ACTOR PowerBikeSwitch : PowerMorph {
	PowerMorph.PlayerClass "PlayerBike"
	
	//***Che otherwise morphing fails breaking the usage of any vehicles permanently
	PowerMorph.MorphStyle MRF_WHENINVULNERABLE
}


/*
//***Che obsoleted
ACTOR BikeMorpher : CustomInventory 
{
  States
  {
  PickUp:
	//***Che: EXPERIMENT, try and see if works
	//TNT1 A 0 A_GiveInventory("BikePowerup", 1)  
  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 ACS_NamedExecuteWithResult("TelefogExclusionZone") //A_SpawnItem("CancelTeleportFog")
  TNT1 A 1
  Stop
  }
 }
*/ 