//Scripts of my old bike. Required to make the tank work.


#library "VEHICLECONTROL"
#include "zcommon.acs"

int arrayHealth[32];
int arrayArmor[32];
str arrayArmorClass[32];
int vehicleprevioushealth;

//FORWARD
script "BDForwardInput" ENTER
{
 int buttons;

 while (TRUE)
 {
   buttons = GetPlayerInput(-1, INPUT_BUTTONS);
   
   
if (buttons & BT_FORWARD)
{
   GiveInventory("Accelerate", 1);
   //giveinventory("HealthBonus", GetActorProperty(0, APROP_HEALTH));
   
   delay(1);
}
   delay(1);
   TakeInventory("Accelerate", 1);
 }
}


//BACKPEDAL
script "BDBackInput" ENTER
{
 int buttons;

 while (TRUE)
 {
   buttons = GetPlayerInput(-1, INPUT_BUTTONS);
   
if (buttons & BT_BACK)
{
    GiveInventory("BackPedal", 1);
	delay(2);
}

   delay(2);
   TakeInventory("BackPedal", 1);
 }
}


//LEFT
script "BDLeftInput" ENTER
{
 int buttons;

 while (TRUE)
 {
   buttons = GetPlayerInput(-1, INPUT_BUTTONS);
   
if (buttons & BT_MOVELEFT)
{
    GiveInventory("TurnLeft", 1);
	//if (checkinventory("IsRunning2") == 1) { GiveInventory("RollLeft", 1); }
	//if (checkinventory("IsRunning2") == 1) { GiveInventory("GoSpecial", 1); }
}
   delay(1);
   TakeInventory("TurnLeft", 1);
 }
}



//RIGHT
script "BDRightInput" ENTER
{
 int buttons;

 while (TRUE)
 {
   buttons = GetPlayerInput(-1, INPUT_BUTTONS);
   
   
if (buttons & BT_MOVERIGHT)
{
    GiveInventory("TurnRight", 1);
	
	//if (checkinventory("IsRunning2") == 1) { GiveInventory("RollRight", 1); }
	//if (checkinventory("IsRunning2") == 1) { GiveInventory("GoSpecial", 1); }
}

   delay(1);
   
   TakeInventory("TurnRight", 1);
 }
}

//USE
script "BDUseInput" ENTER
{
 int buttons;

 while (TRUE)
 {
   buttons = GetPlayerInput(-1, INPUT_BUTTONS);
   
if (buttons & BT_USE)
{
    GiveInventory("PressedUse", 1);
}

   delay(1);
 }
}

//JUMP
script "BDJumpInput" ENTER
{
 int buttons;

 while (TRUE)
 {
   buttons = GetPlayerInput(-1, INPUT_BUTTONS);
   
if (buttons & BT_JUMP)
{
    GiveInventory("PressedJump", 1);
}

   delay(1);
 }
}


Script "HeliRollRight" (VOID)
{
ChangeActorRoll (0, 0.005, 1); delay (1);
ChangeActorRoll (0, 0.010, 1); delay (1);
ChangeActorRoll (0, 0.015, 1); delay (1);
ChangeActorRoll (0, 0.02, 1); delay (1);
ChangeActorRoll (0, 0.03, 1); delay (1);
ChangeActorRoll (0, 0.05, 1); delay (1);
ChangeActorRoll (0, 0.06, 1); delay (1);
ChangeActorRoll (0, 0.07, 1); delay (1);
ChangeActorRoll (0, 0.075, 1); delay (1);
ChangeActorRoll (0, 0.08, 1); delay (1);
ChangeActorRoll (0, 0.085, 1); delay (1);
ChangeActorRoll (0, 0.09, 1); delay (1);
}

Script "HeliRollLeft" (VOID)
{
ChangeActorRoll (0, -0.005, 1); delay (1);
ChangeActorRoll (0, -0.010, 1); delay (1);
ChangeActorRoll (0, -0.015, 1); delay (1);
ChangeActorRoll (0, -0.02, 1); delay (1);
ChangeActorRoll (0, -0.03, 1); delay (1);
ChangeActorRoll (0, -0.05, 1); delay (1);
ChangeActorRoll (0, -0.06, 1); delay (1);
ChangeActorRoll (0, -0.07, 1); delay (1);
ChangeActorRoll (0, -0.075, 1); delay (1);
ChangeActorRoll (0, -0.08, 1); delay (1);
ChangeActorRoll (0, -0.085, 1); delay (1);
ChangeActorRoll (0, -0.09, 1); delay (1);
}




Script "HeliStopRight" (VOID)
{
ChangeActorRoll (0, 0.09, 1); delay (1);
ChangeActorRoll (0, 0.085, 1); delay (1);
ChangeActorRoll (0, 0.08, 1); delay (1);
ChangeActorRoll (0, 0.075, 1); delay (1);
ChangeActorRoll (0, 0.07, 1); delay (1);
ChangeActorRoll (0, 0.06, 1); delay (1);
ChangeActorRoll (0, 0.05, 1); delay (1);
ChangeActorRoll (0, 0.03, 1); delay (1);
ChangeActorRoll (0, 0.02, 1); delay (1);
ChangeActorRoll (0, 0.015, 1); delay (1);
ChangeActorRoll (0, 0.007, 1); delay (1);
ChangeActorRoll (0, 0, 1); delay (1);
}

Script "HeliStopLeft" (VOID)
{
ChangeActorRoll (0, -0.09, 1); delay (1);
ChangeActorRoll (0, -0.085, 1); delay (1);
ChangeActorRoll (0, -0.08, 1); delay (1);
ChangeActorRoll (0, -0.075, 1); delay (1);
ChangeActorRoll (0, -0.07, 1); delay (1);
ChangeActorRoll (0, -0.06, 1); delay (1);
ChangeActorRoll (0, -0.05, 1); delay (1);
ChangeActorRoll (0, -0.03, 1); delay (1);
ChangeActorRoll (0, -0.02, 1); delay (1);
ChangeActorRoll (0, -0.015, 1); delay (1);
ChangeActorRoll (0, -0.007, 1); delay (1);
ChangeActorRoll (0, 0, 1); delay (1);
}


//Bike


Script "BikeRollRight" (VOID)
{
ChangeActorRoll (0, 0.005, 1); delay (1);
ChangeActorRoll (0, 0.010, 1); delay (1);
ChangeActorRoll (0, 0.015, 1); delay (1);
ChangeActorRoll (0, 0.02, 1); delay (1);
ChangeActorRoll (0, 0.03, 1); delay (1);
ChangeActorRoll (0, 0.05, 1); delay (1);
}

Script "BikeRollLeft" (VOID)
{
ChangeActorRoll (0, -0.005, 1); delay (1);
ChangeActorRoll (0, -0.010, 1); delay (1);
ChangeActorRoll (0, -0.015, 1); delay (1);
ChangeActorRoll (0, -0.02, 1); delay (1);
ChangeActorRoll (0, -0.03, 1); delay (1);
ChangeActorRoll (0, -0.05, 1); delay (1);
}

Script "BikeStopRight" (VOID)
{
ChangeActorRoll (0, 0.04, 1); delay (1);
ChangeActorRoll (0, 0.03, 1); delay (1);
ChangeActorRoll (0, 0.02, 1); delay (1);
ChangeActorRoll (0, 0.015, 1); delay (1);
ChangeActorRoll (0, 0, 1); delay (1);
}

Script "BikeStopLeft" (VOID)
{
ChangeActorRoll (0, -0.04, 1); delay (1);
ChangeActorRoll (0, -0.03, 1); delay (1);
ChangeActorRoll (0, -0.02, 1); delay (1);
ChangeActorRoll (0, -0.015, 1); delay (1);
ChangeActorRoll (0, 0, 1); delay (1);
}




Script "BDFiredTankMainGun" (VOID) NET
{
 delay (90);
 TakeInventory("FiredTankMainGun", 1);
}


Script "BDUnMorph" (VOID) NET
{
 delay (1);
 UnMorphActor(0, 0);
}

Script "BDCHeckOnline" (VOID)//Check if player is online.
{
if	(GameType () > 0) 
	SetActorState(0,"IsOnline"); 
}

script "GetVehiclePreviousHealth" (VOID) NET
{
 vehicleprevioushealth = GetActorProperty(261, APROP_Health);
  delay(1);
}

script "GetVehiclePreviousHealth2" (VOID) NET
{
	delay(1);
	arrayHealth[PlayerNumber()] = GetActorProperty(0, APROP_HEALTH);
	arrayArmor[PlayerNumber()] = CheckInventory("BasicArmor");
	arrayArmorClass[PlayerNumber()] = GetArmorInfo(ARMORINFO_CLASSNAME);
	//Log(s:"Health= ", i: arrayHealth[PlayerNumber()]);
	//Log(s:"Armor#= ", i: arrayArmor[PlayerNumber()]);
	//Log(s:"ArmorClass= ", s: arrayArmorClass[PlayerNumber()]);
}


//Entering Heavy Machinegun
script "BDEnterHMG" (VOID) NET
{
	delay(6);
	TakeInventory("PowerInvisibility",1);
	SetActorAngle (0, GetActorAngle (261));
	Thing_Move(0, 261, 1);
	//Return ArmorClass and # of Armor Points
	if (arrayArmorClass[PlayerNumber()] != "None")
	{
		GiveInventory(arrayArmorClass[PlayerNumber()], 1);
		//Log(s:"Returned ArmorClass= ", s:GetArmorInfo(ARMORINFO_CLASSNAME));
		//Log(s:"Returned InitialArmor= ", i:CheckInventory("BasicArmor"));
		
		if (CheckInventory("BasicArmor") > arrayArmor[PlayerNumber()])
		{
			While(CheckInventory("BasicArmor") > arrayArmor[PlayerNumber()])
			{
				TakeInventory("BasicArmor",1);
			}
		}
		else if (CheckInventory("BasicArmor") < arrayArmor[PlayerNumber()])
		{
			While (CheckInventory("BasicArmor") < arrayArmor[PlayerNumber()])
			{
				GiveInventory("GiveArmor",1);
			}
		}
	}
	//Log(s:"Enter ArmorPoints= ", i:CheckInventory("BasicArmor"));
	SetActorProperty(0, APROP_HEALTH, arrayHealth[PlayerNumber()]);
	//Log(s:"Enter Health= ", i: GetActorProperty(0, APROP_HEALTH));
	int thisgunmachinegunammo = CheckActorInventory(261, "HeavyMachinegunAmmo");
	GiveInventory("HeavyMachinegunAmmo", thisgunmachinegunammo);
	delay(1);
}



//leaving Heavy Machinegun
script "BDLeaveHMG" (VOID) NET
{
	delay (1);
	arrayHealth[PlayerNumber()] = GetActorProperty(0, APROP_HEALTH);
	arrayArmor[PlayerNumber()] = CheckInventory("BasicArmor");
	arrayArmorClass[PlayerNumber()] = GetArmorInfo(ARMORINFO_CLASSNAME);
	delay (1);
	//Log(s:"Health= ", i: arrayHealth[PlayerNumber()]);
	//Log(s:"Armor#= ", i: arrayArmor[PlayerNumber()]);
	//Log(s:"ArmorClass= ", s: arrayArmorClass[PlayerNumber()]);
	int thisgunmachinegunammo = CheckInventory("HeavyMachinegunAmmo");
	GiveActorInventory(261, "HeavyMachinegunAmmo", thisgunmachinegunammo);
	TakeInventory("HeavyMachinegunAmmo", 400);
	Thing_Move(0, 264, 1);
	UnMorphActor(0, 0);
	delay (1);
	if (arrayArmorClass[PlayerNumber()] != "None")
	{
		GiveInventory(arrayArmorClass[PlayerNumber()], 1);
		//Log(s:"Returned ArmorClass= ", s:GetArmorInfo(ARMORINFO_CLASSNAME));
		//Log(s:"Returned InitialArmor#= ", i:CheckInventory("BasicArmor"));
		
		if (CheckInventory("BasicArmor") > arrayArmor[PlayerNumber()])
		{
			While(CheckInventory("BasicArmor") > arrayArmor[PlayerNumber()])
			{
				TakeInventory("BasicArmor",1);
			}
		}
		else if (CheckInventory("BasicArmor") < arrayArmor[PlayerNumber()])
		{
			While (CheckInventory("BasicArmor") < arrayArmor[PlayerNumber()])
			{
				GiveInventory("GiveArmor",1);
			}
		}
	}
	//Log(s:"Post ArmorPoints= ", i: CheckInventory("BasicArmor"));
	SetActorProperty(0, APROP_HEALTH, arrayHealth[PlayerNumber()]);
	//Log(s:"Post Health= ", i: GetActorProperty(0, APROP_HEALTH));
}


//Entering Tank
script "BDEnterTank" (VOID) NET
{
	delay(6);
	TakeInventory("PowerInvisibility",1);
	SetActorAngle (0, GetActorAngle (261));
	Thing_Move(0, 261, 1);
	vehicleprevioushealth = GetActorProperty(261, APROP_Health);
	SetActorProperty(0, APROP_Health, vehicleprevioushealth);
	int thisgunmachinegunammo = CheckActorInventory(261, "HeavyMachinegunAmmo");
	int thistankammo = CheckActorInventory(261, "TankAmmo");
	int thisvehicleHelicopterRocketAmmo = CheckActorInventory(261, "HelicopterRocketAmmo");
	int thisvehicleMechMortarAmmo = CheckActorInventory(261, "MechMortarAmmo");
	int thisvehicleMechLaserAmmo = CheckActorInventory(261, "MechLaserAmmo");
	int thisvehicleMechRocketAmmo = CheckActorInventory(261, "MechRocketAmmo");
	int vehiclepreviousbaseangle = CheckActorInventory(261, "TankBaseDirection");
	GiveInventory("HeavyMachinegunAmmo", thisgunmachinegunammo);
	GiveInventory("TankAmmo", thistankammo);
	GiveInventory("HelicopterRocketAmmo", thisvehicleHelicopterRocketAmmo);
	GiveInventory("MechMortarAmmo", thisvehicleMechMortarAmmo);
	GiveInventory("MechLaserAmmo", thisvehicleMechLaserAmmo);
	GiveInventory("MechRocketAmmo", thisvehicleMechRocketAmmo);
	SetUserVariable(0, "user_tankbasedirection", vehiclepreviousbaseangle);
	delay(1);
}

//leaving Tank
script "BDLeaveTank" (VOID) NET
{
	vehicleprevioushealth = GetActorProperty(0, APROP_Health);
	int thisgunmachinegunammo = CheckInventory("HeavyMachinegunAmmo");
	int thistankammo = CheckInventory("TankAmmo");
	int thisvehicleHelicopterRocketAmmo = CheckInventory("HelicopterRocketAmmo");
	int thisvehicleMechMortarAmmo = CheckInventory("MechMortarAmmo");
	int thisvehicleMechLaserAmmo = CheckInventory("MechLaserAmmo");
	int thisvehicleMechRocketAmmo = CheckInventory("MechRocketAmmo");
	int vehiclepreviousbaseangle = GetUserVariable(0, "user_tankbasedirection");
	TakeInventory("HeavyMachinegunAmmo", 9999);
	TakeInventory("TankAmmo", 9999);
	TakeInventory("HelicopterRocketAmmo", 9999);
	TakeInventory("MechRocketAmmo", 9999);
	TakeInventory("MechLaserAmmo", 9999);
	TakeInventory("MechMortarAmmo", 9999);
	Thing_Move(0, 264, 1);
	UnMorphActor(0, 0);
	delay (1);
	if (arrayArmorClass[PlayerNumber()] != "None")
	{
		GiveInventory(arrayArmorClass[PlayerNumber()], 1);
		//Log(s:"Returned ArmorClass= ", s:GetArmorInfo(ARMORINFO_CLASSNAME));
		//Log(s:"Returned InitialArmor#= ", i:CheckInventory("BasicArmor"));
		
		if (CheckInventory("BasicArmor") > arrayArmor[PlayerNumber()])
		{
			While(CheckInventory("BasicArmor") > arrayArmor[PlayerNumber()])
			{
				TakeInventory("BasicArmor",1);
			}
		}
		else if (CheckInventory("BasicArmor") < arrayArmor[PlayerNumber()])
		{
			While (CheckInventory("BasicArmor") < arrayArmor[PlayerNumber()])
			{
				GiveInventory("GiveArmor",1);
			}
		}
	}
	SetActorProperty(0, APROP_HEALTH, arrayHealth[PlayerNumber()]);
	//Log(s:"Post Health= ", i: GetActorProperty(0, APROP_HEALTH));
	//Log(s:"Post ArmorPoints= ", i: CheckInventory("BasicArmor"));
	SetActorProperty(261, APROP_Health, vehicleprevioushealth);
	GiveActorInventory(261, "HeavyMachinegunAmmo", thisgunmachinegunammo);
	GiveActorInventory(261, "TankAmmo", thistankammo);
	GiveActorInventory(261, "HelicopterRocketAmmo", thisvehicleHelicopterRocketAmmo);
	GiveActorInventory(261, "MechMortarAmmo", thisvehicleMechMortarAmmo);
	GiveActorInventory(261, "MechLaserAmmo", thisvehicleMechLaserAmmo);
	GiveActorInventory(261, "MechRocketAmmo", thisvehicleMechRocketAmmo);
	GiveActorInventory(261, "TankBaseDirection", vehiclepreviousbaseangle);
}

script "BDForceUnmorph" (VOID) NET
{
 UnMorphActor(0, 0);
}


//Set Tank's new base angle after you leave it.
script "BDSetBaseAngle" (VOID) NET
{
 delay (1);
 int thisvehiclecurrentbaseangle = CheckInventory("TankBaseDirection");
 delay (1);
 SpawnSpot("TankBaseStationed", 0, 0, thisvehiclecurrentbaseangle*256/360);
 delay (1);
}


//Set the current direction of a newly spawned tank.
script "BDSetNewTankDirection" (VOID) NET
{
 delay (1);
 int thisvehicleinitialbaseangle = GetActorAngle(0);
 int angleformulacalculation = thisvehicleinitialbaseangle >> 8;
 int angleformulacalculationlastpart = angleformulacalculation*360/256;
 delay (1);
 GiveInventory("TankBaseDirection", angleformulacalculationlastpart);
 delay (1);
}

Script "BDEnterTankInfo"(VOID)
{
setfont("TNHSA0");
	hudmessage(s:"A"; 
				HUDMSG_PLAIN, 0, CR_UNTRANSLATED, 0.5, 0.57, 1.0);
	delay(40 * 6);
}

Script "BDTankHUD" (VOID)
{
	int ammoTank = CheckInventory("TankAmmo");
	int readyTank = CheckInventory("TankReady");
	hudmessage(s: "CANNON HE-AT"; HUDMSG_PLAIN, 0, CR_WHITE, 0.5, 0.925, 0.06);
	If(ammoTank >= 1 && readyTank == 100)
	{
		hudmessage(s: "READY"; HUDMSG_PLAIN, 0, CR_WHITE, 0.5, 0.95, 0.06);
	}
	Else If(ammoTank >=1 && readyTank <= 99)
	{
		hudmessage(s: "RELOADING"; HUDMSG_PLAIN, 0, CR_YELLOW, 0.5, 0.95, 0.06);
	}
	Else
	{
		hudmessage(s: "EMPTY"; HUDMSG_PLAIN, 0, CR_RED, 0.5, 0.95, 0.06);
	}
	
	int ammoHMG = CheckInventory("HeavyMachinegunAmmo");
	hudmessage(s: "MACHINEGUN"; HUDMSG_PLAIN, 0, CR_WHITE, -0.1, 0.5, 0.06);
	If(ammoHMG >= 1)
	{
		hudmessage(s: "READY"; HUDMSG_PLAIN, 0, CR_WHITE, -0.1, 0.525, 0.06);
	}
	Else
	{
		hudmessage(s: "EMPTY"; HUDMSG_PLAIN, 0, CR_RED, -0.1, 0.525, 0.06);
	}
	
	bool checkZoom = CheckInventory("TankZoom");
	If(checkZoom == 1)
	{
		hudmessage(s: "x5"; HUDMSG_PLAIN, 0, CR_WHITE, -0.875, 0.5, 0.06);
	}
	Else
	{
		hudmessage(s: "x1"; HUDMSG_PLAIN, 0, CR_WHITE, -0.875, 0.5, 0.06);
	}
	
	Int angleTurret = (GetActorAngle(0)/(65536/360));
	//log(s:"Turret= ",i:angleTurret);//Left(0 to 180CCW) Right(360 to 180CW)
	Int angleTracks = GetUserVariable(0,"user_tankbasedirection");
	//log(s:"Tracks= ",i:angleTracks);//Left(0 to 180CCW) Right(360 to 180CW)
	Int angleSeparation = angleTurret - angleTracks;
	//log(s:"Separation= ",f:angleSeparation);
	Setfont("TURR0");
	Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	If ((angleSeparation >= 293 && angleSeparation <= 337) ||
				(angleSeparation >= -68 && angleSeparation <= -22))
	{
		SetFont("BASE7");//10:30
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 248 && angleSeparation <= 292) ||
				(angleSeparation >= -113 && angleSeparation <= -67))
	{
		SetFont("BASE6");//9:00
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 203 && angleSeparation <= 247) ||
				(angleSeparation >= -158 && angleSeparation <= -112))
	{
		SetFont("BASE5");//7:30
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 158 && angleSeparation <= 202) ||
				(angleSeparation >= -203 && angleSeparation <= -157))
	{
		SetFont("BASE4");//6:00
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 113 && angleSeparation <= 157) ||
				(angleSeparation >= -248 && angleSeparation <= -202))
	{
		SetFont("BASE3");//4:30
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 68 && angleSeparation <= 112) ||
				(angleSeparation >= -293 && angleSeparation <= -247))
	{
		SetFont("BASE2");//3:00
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 23 && angleSeparation <= 67) ||
				(angleSeparation >= -338 && angleSeparation <= -292))
	{
		SetFont("BASE1");//1:30
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else
	{
		SetFont("BASE0");//12:00
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	delay(2);
}

Script "BDATHUD" (VOID)
{
	int ammoHMG = CheckInventory("HeavyMachinegunAmmo");
		hudmessage(s: "40MM AUTO"; HUDMSG_PLAIN, 0, CR_WHITE, 0.5, 0.925, 0.06);
		If(ammoHMG >= 1)
		{
			hudmessage(s: "READY"; HUDMSG_PLAIN, 0, CR_WHITE, 0.5, 0.95, 0.06);
		}
		Else
		{
			hudmessage(s: "EMPTY"; HUDMSG_PLAIN, 0, CR_RED, 0.5, 0.95, 0.06);
		}
		
	int ammoRocket = CheckInventory("HelicopterRocketAmmo");
		hudmessage(s: "ROCKETS"; HUDMSG_PLAIN, 0, CR_WHITE, -0.1, 0.5, 0.06);
		If(ammoRocket >= 1)
		{
			hudmessage(s: "READY"; HUDMSG_PLAIN, 0, CR_WHITE, -0.1, 0.525, 0.06);
		}
		Else
		{
			hudmessage(s: "EMPTY"; HUDMSG_PLAIN, 0, CR_RED, -0.1, 0.525, 0.06);
		}
		
	bool checkZoom = CheckInventory("TankZoom");
		If(checkZoom == 1)
		{
			hudmessage(s: "x5"; HUDMSG_PLAIN, 0, CR_WHITE, -0.875, 0.5, 0.06);
		}
		Else
		{
			hudmessage(s: "x1"; HUDMSG_PLAIN, 0, CR_WHITE, -0.875, 0.5, 0.06);
		}
	
	Int angleTurret = (GetActorAngle(0)/(65536/360));
	//log(s:"Turret= ",i:angleTurret);//Left(0 to 180CCW) Right(360 to 180CW)
	Int angleTracks = GetUserVariable(0,"user_tankbasedirection");
	//log(s:"Tracks= ",i:angleTracks);//Left(0 to 180CCW) Right(360 to 180CW)
	Int angleSeparation = angleTurret - angleTracks;
	//log(s:"Separation= ",f:angleSeparation);
	Setfont("TURR0");
	Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	If ((angleSeparation >= 293 && angleSeparation <= 337) ||
				(angleSeparation >= -68 && angleSeparation <= -22))
	{
		SetFont("BASE7");//10:30
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 248 && angleSeparation <= 292) ||
				(angleSeparation >= -113 && angleSeparation <= -67))
	{
		SetFont("BASE6");//9:00
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 203 && angleSeparation <= 247) ||
				(angleSeparation >= -158 && angleSeparation <= -112))
	{
		SetFont("BASE5");//7:30
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 158 && angleSeparation <= 202) ||
				(angleSeparation >= -203 && angleSeparation <= -157))
	{
		SetFont("BASE4");//6:00
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 113 && angleSeparation <= 157) ||
				(angleSeparation >= -248 && angleSeparation <= -202))
	{
		SetFont("BASE3");//4:30
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 68 && angleSeparation <= 112) ||
				(angleSeparation >= -293 && angleSeparation <= -247))
	{
		SetFont("BASE2");//3:00
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else If ((angleSeparation >= 23 && angleSeparation <= 67) ||
				(angleSeparation >= -338 && angleSeparation <= -292))
	{
		SetFont("BASE1");//1:30
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	Else
	{
		SetFont("BASE0");//12:00
		Hudmessage(s:"A"; HUDMSG_PLAIN, 0, 0, 0.5, 0.05, 0.06);
	}
	delay(2);
}

Script "BDHelicopterHUD"(VOID)
{
	int ammoHMG = CheckInventory("HeavyMachinegunAmmo");
		hudmessage(s: "MACHINEGUN"; HUDMSG_PLAIN, 0, CR_WHITE, 0.5, 0.8, 0.06);
		If(ammoHMG >= 1)
		{
			hudmessage(s: "READY"; HUDMSG_PLAIN, 0, CR_WHITE, 0.5, 0.825, 0.06);
		}
		Else
		{
			hudmessage(s: "EMPTY"; HUDMSG_PLAIN, 0, CR_RED, 0.5, 0.825, 0.06);
		}
		
	int ammoRocket = CheckInventory("HelicopterRocketAmmo");
		hudmessage(s: "ROCKETS"; HUDMSG_PLAIN, 0, CR_WHITE, -0.3, 0.8, 0.06);
		If(ammoRocket >= 1)
		{
			hudmessage(s: "READY"; HUDMSG_PLAIN, 0, CR_WHITE, -0.3, 0.825, 0.06);
		}
		Else
		{
			hudmessage(s: "EMPTY"; HUDMSG_PLAIN, 0, CR_RED, -0.3, 0.825, 0.06);
		}
		
	int ammoMissile = CheckInventory("HelicopterMissileAmmo");
		hudmessage(s: "MISSILES"; HUDMSG_PLAIN, 0, CR_WHITE, -0.65, 0.8, 0.06);
		If(ammoMissile >= 1)
		{
			hudmessage(i: ammoMissile; HUDMSG_PLAIN, 0, CR_WHITE, -0.65, 0.825, 0.06);
		}
		Else
		{
			hudmessage(s: "EMPTY"; HUDMSG_PLAIN, 0, CR_RED, -0.65, 0.825, 0.06);
		}
	
	int elevationZ = ((GetActorZ(0) - GetActorFloorZ(0))/65536);
		Hudmessage(s:"ELEVATION"; HUDMSG_PLAIN, 0, CR_WHITE, -0.65, 0.5, 0.06);
		Hudmessage(i:elevationZ; HUDMSG_PLAIN, 0, CR_WHITE, -0.65, 0.525, 0.06);
	
	int anglePitch = (GetActorPitch(0)/(65536/360));//from -32 to +56 Zand | -90 to +90 GZDoom
	//LOG(s: "Pitch= ", i: anglePitch);
	int posY = (153.0/65536) - (anglePitch*3);
		SetHudSize(544,306,false);
		Setfont("PTCH0");//150px up, 100px down
		Hudmessage(s:"A"; HUDMSG_PLAIN | HUDMSG_LAYER_UNDERHUD, 0, 0, 272.0, (posY * 65536), 0.06);
	
	delay(2);
}

Script "BDMechAmmoHUD"(VOID)
{
setfont("CONFONT");
 int mgunammo = CheckInventory("HeavyMachinegunAmmo");
	hudmessage(d: mgunammo; HUDMSG_PLAIN, 0, CR_LIGHTBLUE, 0.38, 0.80, 0.06);
 int rocketammo = CheckInventory("MechRocketAmmo");
	hudmessage(d: rocketammo; HUDMSG_PLAIN, 0, CR_LIGHTBLUE, 0.65, 0.80, 0.06);
int laserammo = CheckInventory("MechLaserAmmo");
	hudmessage(d: laserammo; HUDMSG_PLAIN, 0, CR_LIGHTBLUE, 0.38, 0.94, 0.06);	
int mortarammo = CheckInventory("MechMortarAmmo");
	hudmessage(d: mortarammo; HUDMSG_PLAIN, 0, CR_LIGHTBLUE, 0.65, 0.94, 0.06);	
int mechhealth = GetActorProperty(0, APROP_HEALTH);
	hudmessage(d: mechhealth; HUDMSG_PLAIN, 0, CR_LIGHTBLUE, 0.50, 0.96, 0.06);		
	delay(2);
}