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

server_done = false;
sleep 1;

"min_range" setmarkerpos [0,0];
"max_range" setmarkerpos [0,0];

if isServer then
{
	batteries = synchronizedobjects arty_detect;
	sleep 0.1;

	battery1 = batteries select 0;
	publicvariable "battery1";
	battery2 = batteries select 1;
	publicvariable "battery2";
	battery3 = batteries select 2;
	publicvariable "battery3";
	sleep 0.1;

	battery1_vehicle = synchronizedobjects battery1;
	battery2_vehicle = synchronizedobjects battery2;
	battery3_vehicle = synchronizedobjects battery3;
	sleep 1;

	battery_vehicle1 = battery1_vehicle select 0;
	publicvariable "battery_vehicle1";
	battery_vehicle2 = battery2_vehicle select 0;
	publicvariable "battery_vehicle2";
	battery_vehicle3 = battery3_vehicle select 0;
	publicvariable "battery_vehicle3";

	sleep 0.5;
	unit_count1 = count units battery_vehicle1;
	unit_count2 = count units battery_vehicle2;
	unit_count3 = count units battery_vehicle3;
	sleep 0.1;
	unit_count1 = unit_count1 - 1;
	unit_count2 = unit_count2 - 1;
	unit_count3 = unit_count3 - 1;

	_battery1_array = units group battery_vehicle1;
	_battery2_array = units group battery_vehicle2;
	_battery3_array = units group battery_vehicle3;

	sleep 0.1;

	weapon1 = currentweapon (vehicle battery_vehicle1);
	publicvariable "weapon1";
	weapon2 = currentweapon (vehicle battery_vehicle2);
	publicvariable "weapon2";
	weapon3 = currentweapon (vehicle battery_vehicle3);
	publicvariable "weapon3";


	while {unit_count1 > -1} do
	{
		eh_bat1 = _battery1_array select unit_count1;
		eh_battery1 = vehicle eh_bat1;
		_fired_event1 = eh_battery1 addEventHandler ["fired", {ammo_sub = [] execvm "artillery_ssp\ammo_supply\ammo_sub_b1.sqf"}];
		unit_count1 = unit_count1 - 1;
		sleep 0.1;
	};

	while {unit_count2 > -1} do
	{
		eh_bat2 = _battery2_array select unit_count2;
		eh_battery2 = vehicle eh_bat2;
		_fired_event2 = eh_battery2 addEventHandler ["fired", {ammo_sub = [] execvm "artillery_ssp\ammo_supply\ammo_sub_b2.sqf"}];
		unit_count2 = unit_count2 - 1;
		sleep 0.1;
	};

	while {unit_count3 > -1} do
	{
		eh_bat3 = _battery3_array select unit_count3;
		eh_battery3 = vehicle eh_bat3;
		_fired_event3 = eh_battery3 addEventHandler ["fired", {ammo_sub = [] execvm "artillery_ssp\ammo_supply\ammo_sub_b3.sqf"}];
		unit_count3 = unit_count3 - 1;
		sleep 0.1;
	};
	
	server_done = true;
	publicvariable "server_done";
};
waituntil {server_done};

if (weapon1 == "m119") then {bat_menu1 = "M119 Battery 1";};
if (weapon1 == "m252") then {bat_menu1 = "M252 Battery 1";};
if (weapon1 == "mlrs") then {bat_menu1 = "M270 Battery 1";};

if (weapon2 == "m119") then {bat_menu2 = "M119 Battery 2";};
if (weapon2 == "m252") then {bat_menu2 = "M252 Battery 2";};
if (weapon2 == "mlrs") then {bat_menu2 = "M270 Battery 2";};

if (weapon3 == "m119") then {bat_menu3 = "M119 Battery 3";};
if (weapon3 == "m252") then {bat_menu3 = "M252 Battery 3";};
if (weapon3 == "mlrs") then {bat_menu3 = "M270 Battery 3";};

working_a10 = 0;
working_ah1 = 0;
working_av8 = 0;
working_f35 = 0;

a10_number_c = a10_number;
ah1_number_c = ah1_number;
av8_number_c = av8_number;

mission_av8_s = "cas";

created_a10 = false;
created_ah1 = false;
created_av8 = false;

b1_he_ammo_current = b1_he_ammo;
b1_illum_ammo_current = b1_illum_ammo;
b1_wp_ammo_current = b1_wp_ammo;
b1_sadarm_ammo_current = b1_sadarm_ammo;
b1_smoke_ammo_current = b1_smoke_ammo;
b1_laser_ammo_current = b1_laser_ammo;

b2_he_ammo_current = b2_he_ammo;
b2_illum_ammo_current = b2_illum_ammo;
b2_wp_ammo_current = b2_wp_ammo;
b2_sadarm_ammo_current = b2_sadarm_ammo;
b2_smoke_ammo_current = b2_smoke_ammo;
b2_laser_ammo_current = b2_laser_ammo;

b3_he_ammo_current = b3_he_ammo;
b3_illum_ammo_current = b3_illum_ammo;
b3_wp_ammo_current = b3_wp_ammo;
b3_sadarm_ammo_current = b3_sadarm_ammo;
b3_smoke_ammo_current = b3_smoke_ammo;
b3_laser_ammo_current = b3_laser_ammo;

out_of_ammo = false;
out_of_ammo2 = false;
processing = false;
resupply_b1 = false;
resupply_b2 = false;
resupply_b3 = false;
resupply_script_b1 = false;
resupply_script_b2 = false;
resupply_script_b3 = false;

mission = false;

b1_target_set = false;
b2_target_set = false;
b3_target_set = false;

mission_b1_dialog = "Immediate";
duration_dialog_b1 = "Short";
duration_b1_c = 1;
rof_b1_c = 0;
mission_b1_c = "Immediate";
ammo_b1_c = "HE";
dispersion_b1_c = 100;

mission_b2_dialog = "Immediate";
duration_dialog_b2 = "Short";
duration_b2_c = 1;
rof_b2_c = 0;
mission_b2_c = "Immediate";
ammo_b2_c = "HE";
dispersion_b2_c = 100;

mission_b3_dialog = "Immediate";
duration_dialog_b3 = "Short";
duration_b3_c = 1;
rof_b3_c = 0;
mission_b3_c = "Immediate";
ammo_b3_c = "HE";
dispersion_b3_c = 100;

mission_b1 = mission_b1_c;
ammo_b1 = ammo_b1_c;
rof_b1 = rof_b1_c;
duration_b1 = duration_b1_c;
dispersion_b1 = dispersion_b1_c;

mission_b2 = mission_b2_c;
ammo_b2 = ammo_b2_c;
rof_b2 = rof_b2_c;
duration_b2 = duration_b2_c;
dispersion_b2 = dispersion_b2_c;

mission_b3 = mission_b3_c;
ammo_b3 = ammo_b3_c;
rof_b3 = rof_b3_c;
duration_b3 = duration_b3_c;
dispersion_b3 = dispersion_b3_c;

if not (isnull battery1) then
{ 
	_marker = createMarkerlocal ["artillery1", [0,0]];
	"artillery1" setMarkerShapelocal "ICON";
	"artillery1" setMarkerColorlocal "Colorblue";
	"artillery1" setmarkerposlocal getpos battery_vehicle1;
	"artillery1" setMarkerTextLocal "1";
	if (weapon1 == "m252") then
	{
		"artillery1" setMarkerTypelocal "b_mortar";
	}
	else
	{
		"artillery1" setMarkerTypelocal "b_art";
	};
};

if not (isnull battery2) then
{
	_marker = createMarkerlocal ["artillery2", [0,0]];
	"artillery2" setMarkerShapelocal "ICON";
	"artillery2" setMarkerColorlocal "Colorblue";
	"artillery2" setmarkerposlocal getpos battery_vehicle2;
	"artillery2" setMarkerTextLocal "2";
	if (weapon2 == "m252") then
	{
		"artillery2" setMarkerTypelocal "b_mortar";
	}
	else
	{
		"artillery2" setMarkerTypelocal "b_art";
	};
};

if not (isnull battery3) then
{
	_marker = createMarkerlocal ["artillery3", [0,0]];
	"artillery3" setMarkerShapelocal "ICON";
	"artillery3" setMarkerColorlocal "Colorblue";
	"artillery3" setmarkerposlocal getpos battery_vehicle3;
	"artillery3" setMarkerTextLocal "3";
	if (weapon3 == "m252") then
	{
		"artillery3" setMarkerTypelocal "b_mortar";
	}
	else
	{
		"artillery3" setMarkerTypelocal "b_art";
	};
};

headquarters=[West,"hq"];