//==========================================//
//					    //
//	  Do not edit this file		    //
//					    //
//==========================================//


if (isNull player) exitwith{};

player removeaction action1;
player removeaction action2;
player removeaction action3;
player removeaction action4;
player removeaction action5;
player removeaction action6;
player removeaction action7;
player removeaction action8;
player removeaction action9;
player removeaction action10;
player removeaction action11;


if battery_1 then
{
	if (mission_b1_c == "timed") then
	{
		player sidechat format ["%5 - %3 %2 Suppression with %1 Rate of Fire and %4 Meters Dispersion", mission_b1_dialog, ammo_b1_c, duration_dialog_b1, dispersion_b1_c, bat_menu1];
	}
	else
	{
		if (rof_b1_c <= 1) then
		{
			player sidechat format ["%5 - %1 %3 Round %2 with %4 meters dispersion.", mission_b1_dialog, ammo_b1_c, duration_b1_c, dispersion_b1_c, bat_menu1];
		}
		else
		{
			player sidechat format ["%5 - %1 %3 Round %2 with %4 meters dispersion.", mission_b1_dialog, ammo_b1_c, duration_b1_c, dispersion_b1_c, bat_menu1];
		};
	}; //closed dialog

	sleep random 5;

	sleep 5;
	if mission exitwith
	{
		headquarters sidechat "we're already on a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if processing_b1 exitwith
	{
		headquarters sidechat "we're already Processing a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if not ([battery1] call fireMissionTemplate) exitwith
	{
		headquarters sidechat "we're already Executing a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if not ([battery1]  call BIS_ARTY_F_StillViable) exitwith
	{
		headquarters sidechat "The Battery is not responding";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Viable
	if resupply_b1 exitwith
	{
		headquarters sidechat "The Battery is currently being resupplied. please stand by";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Resupply

	Cease_dialog = false;
	mission = true;
	processing_b1 = true;
	publicvariable "processing_b1";
	b1_pos_x = getmarkerpos "arty_marker" select 0;
	publicvariable "b1_pos_x";
	b1_pos_y = getmarkerpos "arty_marker" select 1;
	publicvariable "b1_pos_y";
	sleep 1;
	set_target_b1 = true;
	publicvariable "set_target_b1";
	sleep 1;
	set_target_b1 = false;
	publicvariable "set_target_b1";

	if not ([battery1, getPosASL arty_target_b1, ammo_b1_c]  call BIS_ARTY_F_PosInRange) exitwith
	{
		headquarters sidechat "Check Range on Target";
		player sideradio "arty_outside_target";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
		mission = false;
		processing_b1 = false;
		publicvariable "processing_b1"
	}; //closed range

	ammo = [] execvm "artillery_ssp\ammo\set_ammo.sqf";
	b1_supply_ammo = [] execvm "artillery_ssp\ammo_supply\b1_ammo_supply.sqf";
	sleep 2;


	if out_of_ammo exitwith
	{
		headquarters sidechat "The Battery is out of the Currently Selected Ammo Type and is Awaiting Resupply";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
		out_of_ammo = false;
		out_of_ammo2 = false;
		resupply_b1 = true;
		publicvariable "resupply_b1";
		sleep 1;
		mission = false;
		processing_b1 = false;
		publicvariable "processing_b1";
	}; //closed Ammo Count

	radio_dialog = [] execvm "artillery_ssp\fire\dialog.sqf";

	sleep 8;

	fire_b1 = true;
	publicvariable "fire_b1";
	sleep 1;
	fire_b1 = false;
	publicvariable "fire_b1";
	shot_called = [] execvm "artillery_ssp\fire\shot.sqf";
	processing_b1 = false;
	publicvariable "processing_b1";

	splash_called = [] execvm "artillery_ssp\fire\splash.sqf";
	rounds_complete_called = [] execvm "artillery_ssp\fire\rounds_complete.sqf";
	cancel = [] execvm "artillery_ssp\fire\cancel.sqf";

	waituntil {(battery1 getVariable "arty_shotcalled")};
	action1 = player addaction ["Cease Fire!", "artillery_ssp\fire\Cease_fire_c.sqf", [], 1, false, false, "", ""];

	waituntil {(battery1 getVariable "arty_complete")};

	reloading = [] execvm "artillery_ssp\menu\reloading.sqf";

	waituntil {(battery1 getVariable "arty_splash")};

	sleep 3;
	if out_of_ammo2 exitwith
	{
		headquarters sidechat "The Battery is out of the Currently Selected Ammo Type and is Awaiting Resupply";
		out_of_ammo = false;
		out_of_ammo2 = false;
		resupply_b1 = true;
		publicvariable "resupply_b1";
		sleep 1;
		mission = false;
		processing_b1 = false;
		publicvariable "processing_b1";
	}; //closed Ammo Count;
	mission = false;
	headquarters sidechat format ["%1 is Ready to Recieve your next fire mission",bat_menu1];
};

if battery_2 then
{
	if (mission_b2_c == "timed") then
	{
		player sidechat format ["%5 - %3 %2 Suppression with %1 Rate of Fire and %4 Dispersion", mission_b2_dialog, ammo_b2_c, duration_dialog_b2, dispersion_b2_c, bat_menu2];
	}
	else
	{
		if (rof_b2_c <= 1) then
		{
			player sidechat format ["%5 - %1 %3 Round %2 with %4 meters dispersion.", mission_b2_dialog, ammo_b2_c, duration_b2_c, dispersion_b2_c, bat_menu2];
		}
		else
		{
			player sidechat format ["%5 - %1 %3 Round %2 with %4 meters dispersion.", mission_b2_dialog, ammo_b2_c, duration_b2_c, dispersion_b2_c, bat_menu2];
		};
	}; //closed dialog

	sleep random 5;
	sleep 5;
	if mission exitwith
	{
		headquarters sidechat "we're already on a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if processing_b2 exitwith
	{
		headquarters sidechat "we're already Processing a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if not ([battery2] call fireMissionTemplate) exitwith
	{
		headquarters sidechat "we're already Executing a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if not ([battery2]  call BIS_ARTY_F_StillViable) exitwith
	{
		headquarters sidechat "The Battery is not responding";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Viable
	if resupply_b2 exitwith
	{
		headquarters sidechat "The Battery is currently being resupplied. please stand by";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Resupply

	Cease_dialog = false;
	mission = true;
	processing_b2 = true;
	publicvariable "processing_b2";
	b2_pos_x = getmarkerpos "arty_marker" select 0;
	publicvariable "b2_pos_x";
	b2_pos_y = getmarkerpos "arty_marker" select 1;
	publicvariable "b2_pos_y";
	sleep 1;
	set_target_b2 = true;
	publicvariable "set_target_b2";
	sleep 1;
	set_target_b2 = false;
	publicvariable "set_target_b2";

	if not ([battery2, getPosASL arty_target_b2, ammo_b2_c]  call BIS_ARTY_F_PosInRange) exitwith
	{
		headquarters sidechat "Check Range on Target";
		player sideradio "arty_outside_target";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
		mission = false;
		processing_b2 = false;
		publicvariable "processing_b2"
	}; //closed range


	ammo = [] execvm "artillery_ssp\ammo\set_ammo.sqf";
	b2_supply_ammo = [] execvm "artillery_ssp\ammo_supply\b2_ammo_supply.sqf";
	sleep 2;

	if out_of_ammo exitwith
	{
		headquarters sidechat "The Battery is out of the Currently Selected Ammo Type and is Awaiting Resupply";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
		out_of_ammo = false;
		out_of_ammo2 = false;
		resupply_b2 = true;
		publicvariable "resupply_b2";
		sleep 1;
		mission = false;
		processing_b2 = false;
		publicvariable "processing_b2";
	}; //closed Ammo Count

	radio_dialog = [] execvm "artillery_ssp\fire\dialog.sqf";

	sleep 8;

	fire_b2 = true;
	publicvariable "fire_b2";
	sleep 1;
	fire_b2 = false;
	publicvariable "fire_b2";
	shot_called = [] execvm "artillery_ssp\fire\shot.sqf";
	processing_b2 = false;
	publicvariable "processing_b2";

	splash_called = [] execvm "artillery_ssp\fire\splash.sqf";
	rounds_complete_called = [] execvm "artillery_ssp\fire\rounds_complete.sqf";

	waituntil {(battery2 getVariable "arty_shotcalled")};
	action1 = player addaction ["Cease Fire!", "artillery_ssp\fire\Cease_fire_c.sqf", [], 1, false, false, "", ""];

	waituntil {(battery2 getVariable "arty_complete")};

	reloading = [] execvm "artillery_ssp\menu\reloading.sqf";

	waituntil {(battery2 getVariable "arty_splash")};

	sleep 3;

	if out_of_ammo2 exitwith
	{
		headquarters sidechat "The Battery is out of the Currently Selected Ammo Type and is Awaiting Resupply";
		out_of_ammo = false;
		out_of_ammo2 = false;
		resupply_b2 = true;
		publicvariable "resupply_b2";
		sleep 1;
		mission = false;
		processing_b2 = false;
		publicvariable "processing_b2";
	}; //closed Ammo Count;
	mission = false;
	headquarters sidechat format ["%1 is Ready to Recieve your next fire mission",bat_menu2];
};

if battery_3 then
{
	if (mission_b3_c == "timed") then
	{
		player sidechat format ["%5 - %3 %2 Suppression with %1 Rate of Fire and %4 Dispersion", mission_b3_dialog, ammo_b3_c, duration_dialog_b3, dispersion_b3_c, bat_menu3];
	}
	else
	{
		if (rof_b3_c <= 1) then
		{
			player sidechat format ["%5 - %1 %3 Round %2 with %4 meters dispersion.", mission_b3_dialog, ammo_b3_c, duration_b3_c, dispersion_b3_c, bat_menu3];
		}
		else
		{
			player sidechat format ["%5 - %1 %3 Round %2 with %4 meters dispersion.", mission_b3_dialog, ammo_b3_c, duration_b3_c, dispersion_b3_c, bat_menu3];
		};
	}; //closed dialog

	sleep random 5;
	sleep 5;
	if mission exitwith
	{
		headquarters sidechat "we're already on a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if processing_b3 exitwith
	{
		headquarters sidechat "we're already Processing a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if not ([battery3] call fireMissionTemplate) exitwith
	{
		headquarters sidechat "we're already Executing a Fire Mission";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Available
	if not ([battery3]  call BIS_ARTY_F_StillViable) exitwith
	{
		headquarters sidechat "The Battery is not responding";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Viable
	if resupply_b3 exitwith
	{
		headquarters sidechat "The Battery is currently being resupplied. please stand by";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
	}; //closed Resupply

	Cease_dialog = false;
	mission = true;
	processing_b3 = true;
	publicvariable "processing_b3";
	b3_pos_x = getmarkerpos "arty_marker" select 0;
	publicvariable "b3_pos_x";
	b3_pos_y = getmarkerpos "arty_marker" select 1;
	publicvariable "b3_pos_y";
	sleep 1;
	set_target_b3 = true;
	publicvariable "set_target_b3";
	sleep 1;
	set_target_b3 = false;
	publicvariable "set_target_b3";

	if not ([battery3, getPosASL arty_target_b3, ammo_b3_c]  call BIS_ARTY_F_PosInRange) exitwith
	{
		headquarters sidechat "Check Range on Target";
		player sideradio "arty_outside_target";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
		mission = false;
		processing_b3 = false;
		publicvariable "processing_b3"
	}; //closed range

	ammo = [] execvm "artillery_ssp\ammo\set_ammo.sqf";
	b3_supply_ammo = [] execvm "artillery_ssp\ammo_supply\b3_ammo_supply.sqf";
	sleep 2;

	if out_of_ammo exitwith
	{
		headquarters sidechat "The Battery is out of the Currently Selected Ammo Type and is Awaiting Resupply";
		action1 = player addaction ["Open Menu", "artillery_ssp\menu\support.sqf", [], 1, false, false, "", ""];
		out_of_ammo = false;
		out_of_ammo2 = false;
		resupply_b3 = true;
		publicvariable "resupply_b3";
		sleep 1;
		mission = false;
		processing_b3 = false;
		publicvariable "processing_b3";
	}; //closed Ammo Count

	radio_dialog = [] execvm "artillery_ssp\fire\dialog.sqf";

	sleep 8;

	fire_b3 = true;
	publicvariable "fire_b3";
	sleep 1;
	fire_b3 = false;
	publicvariable "fire_b3";
	shot_called = [] execvm "artillery_ssp\fire\shot.sqf";
	processing_b3 = false;
	publicvariable "processing_b3";

	splash_called = [] execvm "artillery_ssp\fire\splash.sqf";
	rounds_complete_called = [] execvm "artillery_ssp\fire\rounds_complete.sqf";

	waituntil {(battery3 getVariable "arty_shotcalled")};
	action1 = player addaction ["Cease Fire!", "artillery_ssp\fire\Cease_fire_c.sqf", [], 1, false, false, "", ""];

	waituntil {(battery3 getVariable "arty_complete")};

	reloading = [] execvm "artillery_ssp\menu\reloading.sqf";

	waituntil {(battery3 getVariable "arty_splash")};

	sleep 3;

	if out_of_ammo2 exitwith
	{
		headquarters sidechat "The Battery is out of the Currently Selected Ammo Type and is Awaiting Resupply";
		out_of_ammo = false;
		out_of_ammo2 = false;
		resupply_b3 = true;
		publicvariable "resupply_b3";
		sleep 1;
		mission = false;
		processing_b3 = false;
		publicvariable "processing_b3";
	}; //closed Ammo Count;
	mission = false;
	headquarters sidechat format ["%1 is Ready to Recieve your next fire mission",bat_menu3];
};