diff --git a/sarge/SAR_AI_despawn.sqf b/sarge/SAR_AI_despawn.sqf
new file mode 100644
index 0000000..207cc46
--- /dev/null
+++ b/sarge/SAR_AI_despawn.sqf
@@ -0,0 +1,79 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_timeout","_triggername","_tmparr","_markername","_valuearray","_grps_band","_grps_sold","_grps_surv","_trigger"];
+
+if (!isServer) exitWith {};
+
+_timeout = SAR_DESPAWN_TIMEOUT;
+
+_trigger = _this select 1;
+_triggername = _this select 2;
+
+_tmparr = toArray (_triggername);
+
+_tmparr set [4,97];
+_tmparr set [5,114];
+_tmparr set [6,101];
+_tmparr set [7,97];
+
+_markername = toString _tmparr;
+
+sleep _timeout;
+
+if !(triggerActivated _trigger) then {
+
+ if (SAR_DEBUG) then {
+ diag_log format["Sarge's AI System: Despawning groups in: %1", _markername];
+ };
+
+ if (SAR_EXTREME_DEBUG) then {
+ diag_log "SAR EXTREME DEBUG: Content of the Monitor before despawn deletion";
+ call SAR_DEBUG_mon;
+ };
+
+ // get all groups in that area
+ _valuearray = [["grps_band","grps_sold","grps_surv"],_markername] call SAR_AI_mon_read;
+
+ _grps_band = _valuearray select 0;
+ _grps_sold = _valuearray select 1;
+ _grps_surv = _valuearray select 2;
+
+ {
+ {deleteVehicle _x} forEach (units _x);
+ sleep 0.5;
+ deleteGroup _x;
+ } forEach (_grps_band);
+
+ {
+ {deleteVehicle _x} forEach (units _x);
+ sleep 0.5;
+ deleteGroup _x;
+ } forEach (_grps_sold);
+
+ {
+ {deleteVehicle _x} forEach (units _x);
+ sleep 0.5;
+ deleteGroup _x;
+ } forEach (_grps_surv);
+
+ // update SAR_AI_monitor
+ [["grps_band","grps_sold","grps_surv"],[[],[],[]],_markername] call SAR_AI_mon_upd;
+
+ if (SAR_EXTREME_DEBUG) then {
+ diag_log "SAR EXTREME DEBUG: Content of the Monitor after despawn deletion";
+ call SAR_DEBUG_mon;
+ };
+
+};
diff --git a/sarge/SAR_AI_init.sqf b/sarge/SAR_AI_init.sqf
new file mode 100644
index 0000000..28e3c96
--- /dev/null
+++ b/sarge/SAR_AI_init.sqf
@@ -0,0 +1,166 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_worldname","_startx","_starty","_gridsize_x","_gridsize_y","_gridwidth","_markername","_triggername","_trig_act_stmnt","_trig_deact_stmnt","_trig_cond","_check","_script_handler","_legendname"];
+
+if (!isNil "A3XAI_isActive") exitWith {diag_log format ["Sarge's AI System: A3XAI has been detected. Sarge AI is not compatibale with A3XAI. Sarge AI is now exiting!"];};
+
+call compile preprocessFileLineNumbers "sarge\SAR_config.sqf";
+
+diag_log format["Sarge's AI System: Starting Sarge AI version %1",SAR_version];
+
+if (!isServer && hasInterface) then {
+ "adjustrating" addPublicVariableEventHandler {((_this select 1) select 0) addRating ((_this select 1) select 1);};
+};
+
+SAR_AI_hit = compile preprocessFileLineNumbers "sarge\SAR_aihit.sqf";
+SAR_AI_trace = compile preprocessFileLineNumbers "sarge\SAR_trace_entities.sqf";
+SAR_AI_base_trace = compile preprocessFileLineNumbers "sarge\SAR_trace_base_entities.sqf";
+
+if (!isServer) exitWith {};
+
+SAR_AI = compile preprocessFileLineNumbers "sarge\SAR_setup_AI_patrol.sqf";
+SAR_AI_heli = compile preprocessFileLineNumbers "sarge\SAR_setup_AI_patrol_heli.sqf";
+SAR_AI_land = compile preprocessFileLineNumbers "sarge\SAR_setup_AI_patrol_land.sqf";
+SAR_AI_trace_veh = compile preprocessFileLineNumbers "sarge\SAR_trace_from_vehicle.sqf";
+SAR_AI_reammo = compile preprocessFileLineNumbers "sarge\SAR_reammo_refuel_AI.sqf";
+SAR_AI_spawn = compile preprocessFileLineNumbers "sarge\SAR_AI_spawn.sqf";
+SAR_AI_despawn = compile preprocessFileLineNumbers "sarge\SAR_AI_despawn.sqf";
+SAR_AI_killed = compile preprocessFileLineNumbers "sarge\SAR_aikilled.sqf";
+SAR_AI_VEH_HIT = compile preprocessFileLineNumbers "sarge\SAR_ai_vehicle_hit.sqf";
+SAR_AI_GUARDS = compile preprocessFileLineNumbers "sarge\SAR_setup_AI_patrol_guards.sqf";
+
+call compile preprocessFileLineNumbers "sarge\SAR_functions.sqf";
+
+publicvariable "SAR_surv_kill_value";
+publicvariable "SAR_band_kill_value";
+publicvariable "SAR_DEBUG";
+publicvariable "SAR_EXTREME_DEBUG";
+publicvariable "SAR_DETECT_HOSTILE";
+publicvariable "SAR_DETECT_INTERVAL";
+publicvariable "SAR_RESPECT_HOSTILE_LIMIT";
+
+createCenter EAST;
+createCenter WEST;
+
+// unfriendly AI bandits
+EAST setFriend [EAST, 1];
+EAST setFriend [WEST, 0];
+EAST setFriend [RESISTANCE, 0];
+
+// Players
+RESISTANCE setFriend [EAST, 0];
+RESISTANCE setFriend [WEST, 1];
+
+// friendly AI
+WEST setFriend [EAST, 0];
+WEST setFriend [RESISTANCE, 1];
+
+SAR_AI_friendly_side = RESISTANCE;
+SAR_AI_unfriendly_side = EAST;
+
+SAR_leader_number = 0;
+SAR_AI_monitor = [];
+
+_worldname = toLower worldName;
+diag_log format["Sarge's AI System: Setting up SAR_AI for %1",_worldname];
+
+waituntil {PublicServerIsLoaded};
+
+if (SAR_dynamic_spawning) then {
+
+ scopeName "SAR_AI_DYNAI";
+
+ try {
+ if (!(_worldname in ["altis","chernarus","taviana","namalsk","lingor3","mbg_celle2","takistan","fallujah","panthera2"])) then {throw _worldName};
+ call compile preprocessFileLineNumbers (format ["sarge\map_config\SAR_cfg_grid_%1.sqf",_worldname]);
+ } catch {
+ diag_log format ["Sarge's AI System: %1 does not currently support dynamic AI spawning! Dynamic AI spawning has been disabled!",_worldName];
+ breakOut "SAR_AI_DYNAI";
+ };
+
+ diag_log format ["Sarge's AI System: Now generating dynamic map grid for %1.",_worldname];
+
+ // Create grid system and triggers
+ SAR_area_ = text format ["SAR_area_%1","x"];
+ for "_i" from 0 to (_gridsize_y - 1) do
+ {
+ for "_ii" from 0 to (_gridsize_x - 1) do
+ {
+ // Marker Creation
+ _markername = format["SAR_area_%1_%2",_ii,_i];
+ _legendname = format["SAR_area_legend_%1_%2",_ii,_i];
+
+ _this = createMarker[_markername,[_startx + (_ii * _gridwidth * 2),_starty + (_i * _gridwidth * 2)]];
+ if (SAR_EXTREME_DEBUG) then {
+ _this setMarkerAlpha 1;
+ } else {
+ _this setMarkerAlpha 0;
+ };
+ _this setMarkerShape "RECTANGLE";
+ _this setMarkerType "mil_flag";
+ _this setMarkerBrush "BORDER";
+ _this setMarkerSize [_gridwidth, _gridwidth];
+
+ call compile format ["SAR_area_%1_%2 = _this",_ii,_i];
+
+ _this = createMarker[_legendname,[_startx + (_ii * _gridwidth * 2) + (_gridwidth - (_gridwidth/2)),_starty + (_i * _gridwidth * 2) - (_gridwidth - (_gridwidth/10))]];
+ if(SAR_EXTREME_DEBUG) then {
+ _this setMarkerAlpha 1;
+ } else {
+ _this setMarkerAlpha 0;
+ };
+
+ _this setMarkerShape "ICON";
+ _this setMarkerType "mil_flag";
+ _this setMarkerColor "ColorBlack";
+
+ _this setMarkerText format["%1/%2",_ii,_i];
+ _this setMarkerSize [.1, .1];
+
+ // Trigger Statements
+ _triggername = format["SAR_trig_%1_%2",_ii,_i];
+
+ _this = createTrigger ["EmptyDetector", [_startx + (_ii * _gridwidth * 2),_starty + (_i * _gridwidth * 2)]];
+ _this setTriggerArea [_gridwidth, _gridwidth, 0, true];
+ _this setTriggerActivation ["ANY", "PRESENT", true];
+
+ call compile format ["SAR_trig_%1_%2 = _this",_ii,_i];
+
+ _trig_act_stmnt = format["if (SAR_DEBUG) then {diag_log 'SAR DEBUG: trigger on in %1';};[thislist,'%1'] spawn SAR_AI_spawn;",_triggername];
+ _trig_deact_stmnt = format["if (SAR_DEBUG) then {diag_log 'SAR DEBUG: trigger off in %1';};[thislist,thisTrigger,'%1'] spawn SAR_AI_despawn;",_triggername];
+
+ _trig_cond = "{isPlayer _x} count thisList > 0;";
+
+ call compile format ["SAR_trig_%1_%2 ",_ii,_i] setTriggerStatements [_trig_cond,_trig_act_stmnt , _trig_deact_stmnt];
+
+ // standard grid definition - maxgroups (ba,so,su) - probability (ba,so,su) - max group members (ba,so,su)
+ SAR_AI_monitor set[count SAR_AI_monitor, [_markername,[SAR_max_grps_bandits,SAR_max_grps_soldiers,SAR_max_grps_survivors],[SAR_chance_bandits,SAR_chance_soldiers,SAR_chance_survivors],[SAR_max_grpsize_bandits,SAR_max_grpsize_soldiers,SAR_max_grpsize_survivors],[],[],[]]];
+
+ };
+ };
+ diag_log format["Sarge's AI System: Map grid has now been established."];
+
+ diag_log format["Sarge's AI System: Now initializing spawn definitions for %1.",_worldname];
+ ["dynamic"] call compile preprocessFileLineNumbers (format ["sarge\map_config\SAR_cfg_grps_%1.sqf",_worldname]);
+ diag_log format["Sarge's AI System: Spawn definitions have been configured."];
+};
+
+diag_log format["Sarge's AI System: Now initializing spawn definitions for %1.",_worldname];
+["static"] call compile preprocessFileLineNumbers (format ["sarge\map_config\SAR_cfg_grps_%1.sqf",_worldname]);
+diag_log format["Sarge's AI System: Spawn definitions have been configured."];
+
+if (SAR_Base_Gaurds) then {
+ [] execVM "sarge\SAR_init_Base_guards.sqf";
+};
diff --git a/sarge/SAR_AI_spawn.sqf b/sarge/SAR_AI_spawn.sqf
new file mode 100644
index 0000000..17f38b7
--- /dev/null
+++ b/sarge/SAR_AI_spawn.sqf
@@ -0,0 +1,115 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_snipers","_soldiers","_group","_check","_probability","_chance","_playerlist","_triggername","_tmparr","_markername","_player","_valuearray","_max_grps","_rnd_grps","_max_p_grp","_grps_band","_grps_sold","_grps_surv","_grps_upd","_respawn"];
+
+if (!isServer) exitWith {};
+
+_playerlist = _this select 0;
+_triggername = _this select 1;
+
+_tmparr = toArray (_triggername);
+
+_tmparr set[4,97];
+_tmparr set[5,114];
+_tmparr set[6,101];
+_tmparr set[7,97];
+
+_markername = toString _tmparr;
+
+{if(isPlayer _x) then {_player = _x;};} foreach _playerlist;
+
+if (SAR_DEBUG) then {diag_log format["Sarge's AI System: Triggered by: %1", _player];};
+
+if (SAR_EXTREME_DEBUG) then {
+ diag_log "SAR EXTREME DEBUG: Content of the Monitor before adding spawned groups.";
+ call SAR_DEBUG_mon;
+};
+
+if (SAR_dynamic_group_respawn) then {
+ _respawn = true;
+};
+
+_valuearray= [["max_grps","rnd_grps","max_p_grp","grps_band","grps_sold","grps_surv"],_markername] call SAR_AI_mon_read;
+
+_max_grps = _valuearray select 0;
+_rnd_grps = _valuearray select 1;
+_max_p_grp = _valuearray select 2;
+_grps_band = _valuearray select 3;
+_grps_sold = _valuearray select 4;
+_grps_surv = _valuearray select 5;
+_grps_upd = [];
+
+_grps_upd = _grps_band;
+
+//for [{_i = (count _grps_band)},{_i < (_max_grps select 0)}, {_i=_i+1}] do
+for "_i" from (count _grps_band) to ((_max_grps select 0) - 1) do
+{
+ if(_max_p_grp select 0 > 0) then {
+ _probability = _rnd_grps select 0;
+ _chance = (random 100);
+ if(_chance < _probability) then {
+ _snipers=floor (random ((_max_p_grp select 0)-1));
+ _soldiers =((_max_p_grp select 0)-1) - _snipers;
+ _group = [_markername,3,_snipers,_soldiers,"",_respawn] call SAR_AI;
+ _grps_upd set [count _grps_upd,_group];
+ // update AI monitor
+ _check = [["grps_band"],[_grps_upd],_markername] call SAR_AI_mon_upd;
+ };
+ };
+};
+
+_grps_upd = _grps_sold;
+
+//for [{_i = (count _grps_sold)},{_i < (_max_grps select 1)}, {_i=_i+1}] do
+for "_i" from (count _grps_sold) to ((_max_grps select 1) - 1) do
+{
+ if(_max_p_grp select 1 > 0) then {
+ _probability = _rnd_grps select 1;
+ _chance = (random 100);
+ if(_chance < _probability) then {
+ _snipers=floor (random ((_max_p_grp select 1)-1));
+ _soldiers =((_max_p_grp select 1)-1) - _snipers;
+ _group = [_markername,1,_snipers,_soldiers,"",_respawn] call SAR_AI;
+ _grps_upd set [count _grps_upd,_group];
+ // update AI monitor
+ _check = [["grps_sold"],[_grps_upd],_markername] call SAR_AI_mon_upd;
+ };
+ };
+};
+
+_grps_upd = _grps_surv;
+
+//for [{_i = (count _grps_surv)},{_i < (_max_grps select 2)}, {_i=_i+1}] do
+for "_i" from (count _grps_surv) to ((_max_grps select 2) - 1) do
+{
+ if(_max_p_grp select 2 > 0) then {
+ _probability = _rnd_grps select 2;
+ _chance = (random 100);
+ if(_chance < _probability) then {
+ _snipers=floor (random ((_max_p_grp select 2)-1));
+ _soldiers =((_max_p_grp select 2)-1) - _snipers;
+ _group = [_markername,2,_snipers,_soldiers,"",_respawn] call SAR_AI;
+ _grps_upd set [count _grps_upd,_group];
+ // update AI monitor
+ _check = [["grps_surv"],[_grps_upd],_markername] call SAR_AI_mon_upd;
+ };
+ };
+};
+
+// DEBUG
+if (SAR_EXTREME_DEBUG) then {
+ diag_log "SAR EXTREME DEBUG: Content of the Monitor after adding spawned groups.";
+ call SAR_DEBUG_mon;
+};
diff --git a/sarge/SAR_ai_vehicle_hit.sqf b/sarge/SAR_ai_vehicle_hit.sqf
new file mode 100644
index 0000000..8b6adff
--- /dev/null
+++ b/sarge/SAR_ai_vehicle_hit.sqf
@@ -0,0 +1,99 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_ai_veh_dmg","_ai_veh","_ai_veh_hitsource","_ai_veh_type","_ai_veh_side","_ai_veh_group_side","_ai_veh_hitsource_group_side","_ai_veh_hitsource_type","_ai_veh_hitsource_name","_ai_veh_hitsource_side","_clientmachine","_player_rating","_shot_veh","_ai_part","_ai_veh_projectile","_message"];
+
+if (!isServer) exitWith {};
+
+_ai_veh = _this select 0;
+_ai_part = _this select 1;
+_ai_veh_dmg = _this select 2;
+_ai_veh_hitsource = _this select 3;
+_ai_veh_projectile = _this select 4;
+
+_ai_veh_type = typeof _ai_veh;
+
+
+_ai_veh_side = side _ai_veh;
+_ai_veh_group_side = side (group _ai_veh);
+
+_ai_veh_hitsource_type = typeof _ai_veh_hitsource;
+_ai_veh_hitsource_side = side _ai_veh_hitsource;
+_ai_veh_hitsource_group_side = side (group _ai_veh_hitsource);
+
+
+if(isPlayer _ai_veh_hitsource ) then {
+
+ _ai_veh_hitsource_name = name _ai_veh_hitsource;
+
+ if(_ai_veh_projectile iskindof "B_9x18_Ball") then {
+
+ if ((random 100) < 5) then {
+ [nil,_ai_veh_hitsource,rTITLETEXT,"Are you serious? Shooting at a vehicle with a toy? Get a decent weapon ...","PLAIN DOWN",3] call RE;
+ };
+
+ if ((random 100) < 5) then {
+ _message = format["Player %1 throws tincans at vehicles again :-)",_ai_veh_hitsource_name];
+ [nil, nil, rspawn, [[West,"airbase"], _message], { (_this select 0) sideChat (_this select 1) }] call RE;
+ } else {
+ if ((random 100) < 5) then {
+ _message = format["%1, stop tickling my vehicle!",_ai_veh_hitsource_name];
+ [nil, nil, rspawn, [[West,"airbase"], _message], { (_this select 0) sideChat (_this select 1) }] call RE;
+ };
+ };
+
+
+ };
+
+ if (SAR_HITKILL_DEBUG && {isServer || !hasInterface}) then {
+ diag_log format["SAR_HITKILL_DEBUG: AI vehicle hit - Type: %1 Side: %2 Group Side: %3 - Part: %4 with ammo: %5 Damage: %6",_ai_veh_type,_ai_veh_side,_ai_veh_group_side,_ai_part,_ai_veh_projectile,_ai_veh_dmg];
+ diag_log format["SAR_HITKILL_DEBUG: AI vehicle attacker - Type: %1 Name: %2 Side: %3 Group Side: %4",_ai_veh_hitsource_type,_ai_veh_hitsource_name, _ai_veh_hitsource_side,_ai_veh_hitsource_group_side];
+ };
+
+
+ if(_ai_veh_group_side == SAR_AI_friendly_side) then { // was it a friendly vehcile ?
+
+ _shot_veh = _ai_veh_hitsource getVariable ["SAR_veh_hit",""];
+
+ if( str(_shot_veh) != str(_ai_veh)) then { // check if the vehicle that was shot was shot the first time
+
+ _ai_veh_hitsource setVariable ["SAR_veh_hit",_ai_veh,true];
+
+ _player_rating = rating _ai_veh_hitsource;
+
+ if((_player_rating > -10000)) then {
+
+ //define global variable
+ adjustrating = [_ai_veh_hitsource,(0 - (10000+_player_rating))];
+
+ // get the players machine ID
+ _clientmachine = owner _ai_veh_hitsource;
+
+ // transmit the global variable to this client machine
+ _clientmachine publicVariableClient "adjustrating";
+
+ if(SAR_HITKILL_DEBUG) then {
+ diag_log format["SAR HITKILL DEBUG: reduced rating (shot a friendly vehicle) for player: %1", _ai_veh_hitsource];
+ };
+
+ };
+ };
+
+ };
+
+ (group _ai_veh) reveal [_ai_veh_hitsource,4];
+
+};
+
+_ai_veh_dmg;
\ No newline at end of file
diff --git a/sarge/SAR_aihit.sqf b/sarge/SAR_aihit.sqf
new file mode 100644
index 0000000..3d1ec3e
--- /dev/null
+++ b/sarge/SAR_aihit.sqf
@@ -0,0 +1,118 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_ai","_aikiller","_aikilled_type","_aikilled_side","_aikilled_group_side","_aikiller_group_side","_aikiller_type","_aikiller_name","_aikiller_side","_respect","_message"];
+
+_ai = _this select 0;
+_aikiller = _this select 1;
+
+_aikilled_type = typeof _ai;
+_aikilled_side = side _ai;
+_aikilled_group_side = side (group _ai);
+
+_aikiller_type = typeof _aikiller;
+
+if (!(_aikiller_type in SAR_heli_type) && !("LandVehicle" countType [vehicle _aikiller]>0)) then {
+ _aikiller_name = name _aikiller;
+} else {
+ _aikiller_name = _aikiller_type;
+};
+
+_aikiller_side = side _aikiller;
+_aikiller_group_side = side (group _aikiller);
+
+if (SAR_HITKILL_DEBUG && {isServer}) then {
+ diag_log format["SAR_HITKILL_DEBUG: AI hit - %2 - Type: %1 Side: %3 Group Side: %4",_aikilled_type,_ai,_aikilled_side,_aikilled_group_side];
+ diag_log format["SAR_HITKILL_DEBUG: AI attacker - Type: %1 Name: %2 Side: %3 Group Side: %4",_aikiller_type,_aikiller_name, _aikiller_side,_aikiller_group_side];
+};
+
+if((!isNull _aikiller) && (isPlayer _aikiller) && (_aikiller isKindOf "Exile_Unit_Player")) then {
+
+ _playerUID = getPlayerUID _aikiller;
+
+ if (_aikilled_group_side isEqualTo SAR_AI_friendly_side) then { // hit a friendly AI
+
+ if (SAR_HITKILL_DEBUG && {isServer}) then {
+ diag_log format["SAR_HITKILL_DEBUG: friendly AI was hit by Player %1",_aikiller];
+ };
+
+ if ((random 100) > 5) then {
+ _message = format["Sarge AI: Dammit %1! You are firing on a friendly group check your fire!",_aikiller_name];
+ if (isServer) then {systemchat _message;};
+ } else {
+ if ((random 100) < 5) then {
+ _message = format["Sarge AI: %1, this was the last time you shot one of our team! We are coming for you!",_aikiller_name];
+ if (isServer) then {systemchat _message;};
+ };
+ };
+
+ _playerRespect = _aikiller getVariable ["ExileScore", 0];
+ _playerMoney = _aikiller getVariable ["ExileMoney", 0];
+
+ _repChange = SAR_surv_kill_value / 10;
+
+ _playerRespect = _playerRespect - _repChange;
+ _aikiller setVariable ["ExileScore",_playerRespect];
+
+ ExileClientPlayerScore = _playerRespect;
+ (owner _aikiller) publicVariableClient "ExileClientPlayerScore";
+ ExileClientPlayerScore = nil;
+
+ format ["setAccountMoneyAndRespect:%1:%2:%3", _playerMoney, _playerRespect, _playerUID] call ExileServer_system_database_query_fireAndForget;
+
+ if (SAR_HITKILL_DEBUG && {isServer}) then {
+ diag_log format["SAR_HITKILL_DEBUG: Adjusting respect for survivor hit by %2 for %1",_aikiller,(SAR_surv_kill_value/10)];
+ };
+
+ if (rating _aikiller > -10000) then { //check if shooter is not already marked as enemy
+
+ if (SAR_HITKILL_DEBUG && {isServer}) then {
+ diag_log format["SAR_HITKILL_DEBUG: Marking Player %1 as an enemy for a friendly AI hit!",_aikiller];
+ };
+ _aikiller addRating -10000;
+ };
+
+ group _ai reveal _aikiller;
+
+ {
+ _x doTarget _aikiller;
+ _x doFire _aikiller;
+ } foreach units group _ai;
+ };
+
+ if (_aikilled_group_side isEqualTo SAR_AI_unfriendly_side) then { // hit an unfriendly AI
+
+ if (SAR_HITKILL_DEBUG && {isServer}) then {
+ diag_log format["SAR_HITKILL_DEBUG: unfriendly AI was hit by Player %1",_aikiller];
+ };
+
+ _playerRespect = _aikiller getVariable ["ExileScore", 0];
+ _playerMoney = _aikiller getVariable ["ExileMoney", 0];
+
+ _repChange = SAR_surv_kill_value / 10;
+
+ _playerRespect = _playerRespect + _repChange;
+ _aikiller setVariable ["ExileScore",_playerRespect];
+
+ ExileClientPlayerScore = _playerRespect;
+ (owner _aikiller) publicVariableClient "ExileClientPlayerScore";
+ ExileClientPlayerScore = nil;
+
+ format ["setAccountMoneyAndRespect:%1:%2:%3", _playerMoney, _playerRespect, _playerUID] call ExileServer_system_database_query_fireAndForget;
+
+ if (SAR_HITKILL_DEBUG && {isServer}) then {
+ diag_log format["SAR_HITKILL_DEBUG: Adjusting respect for bandit hit by %2 for %1",_aikiller,(SAR_band_kill_value/10)];
+ };
+ };
+};
diff --git a/sarge/SAR_aikilled.sqf b/sarge/SAR_aikilled.sqf
new file mode 100644
index 0000000..7521817
--- /dev/null
+++ b/sarge/SAR_aikilled.sqf
@@ -0,0 +1,131 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_message","_ai","_aikiller","_aikilled_type","_aikilled_side","_aikilled_group_side","_aikiller_group_side","_aikiller_type","_aikiller_name","_aikiller_side","_respect","_humankills","_banditkills","_ai_xp_type","_xp_gain","_tmp","_sphere_alpha","_sphere_red","_sphere_green","_sphere_blue","_obj_text_string","_ai_killer_xp","_ai_killer_xp_new","_ai_type","_ai_xp","_ai_killer_xp_type","_ai_killer_type"];
+
+if (!isServer) exitWith {};
+
+_ai = _this select 0;
+_aikiller = _this select 1;
+
+_aikilled_type = typeof _ai;
+_aikilled_side = side _ai;
+_aikilled_group_side = side (group _ai);
+
+_aikiller_type = typeof _aikiller;
+
+if (!(_aikiller_type in SAR_heli_type) && !("LandVehicle" countType [vehicle _aikiller]>0)) then {
+ _aikiller_name = name _aikiller;
+} else {
+ _aikiller_name = _aikiller_type;
+};
+
+_aikiller_side = side _aikiller;
+_aikiller_group_side = side (group _aikiller);
+
+// retrieve AI type from the killed AI
+_ai_type = _ai getVariable ["SAR_AI_type",""];
+
+// retrieve AI type from the killer AI
+_ai_killer_type = _aikiller getVariable ["SAR_AI_type",""];
+
+if (SAR_KILL_MSG) then {
+ if(isPlayer _aikiller) then {
+ _message = format["A %3 %2 was killed by Player: %1",_aikiller_name,_ai_type,_ai_xp_type];
+ diag_log _message;
+
+ //[nil, nil, rspawn, [[West,"airbase"], _message], { (_this select 0) sideChat (_this select 1) }] call RE;
+ [[[West,"airbase"], _message],{(_this select 0) sideChat (_this select 1)}] call BIS_fnc_MP;
+ };
+};
+
+if (SAR_HITKILL_DEBUG) then {
+ diag_log format["SAR_HITKILL_DEBUG: AI killed - Type: %1 Side: %2 Group Side: %3",_aikilled_type, _aikilled_side,_aikilled_group_side];
+ diag_log format["SAR_HITKILL_DEBUG: AI Killer - Type: %1 Name: %2 Side: %3 Group Side: %4",_aikiller_type,_aikiller_name, _aikiller_side,_aikiller_group_side];
+};
+
+if ((!isNull _aikiller) && (_aikiller isKindOf "Exile_Unit_Player")) then {
+
+ _playerUID = getPlayerUID _aikiller;
+
+ if (_aikilled_group_side isEqualTo SAR_AI_friendly_side) then {
+
+ if (SAR_DEBUG) then {diag_log format ["Sarge's AI System: Adjusting respect for survivor or soldier kill by %2 for %1",_aikiller,SAR_surv_kill_value];};
+
+ _playerRespect = _aikiller getVariable ["ExileScore", 0];
+ _playerMoney = _aikiller getVariable ["ExileMoney", 0];
+
+ _repChange = SAR_surv_kill_value / 10;
+
+ _playerRespect = _playerRespect - _repChange;
+ _aikiller setVariable ["ExileScore",_playerRespect];
+
+ ExileClientPlayerScore = _playerRespect;
+ (owner _aikiller) publicVariableClient "ExileClientPlayerScore";
+ ExileClientPlayerScore = nil;
+
+ format ["setAccountMoneyAndRespect:%1:%2:%3", _playerMoney, _playerRespect, _playerUID] call ExileServer_system_database_query_fireAndForget;
+
+ if (SAR_log_AI_kills) then {
+ _humankills = _aikiller getVariable["humanKills",0];
+ _aikiller setVariable["humanKills",_humankills+1,true];
+ };
+ if ((random 100) > 3) then {
+ _message = format["%1 killed a friendly AI - sending reinforcements!",_aikiller_name];
+ //[nil, nil, rspawn, [[West,"airbase"], _message], { (_this select 0) sideChat (_this select 1) }] call RE;
+ [[[West,"airbase"], _message],{(_this select 0) sideChat (_this select 1)}] call BIS_fnc_MP;
+ } else {
+ if ((random 100) < 3) then {
+ _message = format["Tango down ... we offer a decent reward for the head of %1!",_aikiller_name];
+ //[nil, nil, rspawn, [[West,"airbase"], _message], { (_this select 0) sideChat (_this select 1) }] call RE;
+ [[[West,"airbase"], _message],{(_this select 0) sideChat (_this select 1)}] call BIS_fnc_MP;
+ };
+ };
+ };
+ if (_aikilled_group_side isEqualTo SAR_AI_unfriendly_side) then {
+
+ if (SAR_DEBUG) then {diag_log format ["Sarge's AI System: Adjusting respect for bandit kill by %2 for %1",_aikiller,SAR_band_kill_value];};
+
+ _playerRespect = _aikiller getVariable ["ExileScore", 0];
+ _playerMoney = _aikiller getVariable ["ExileMoney", 0];
+
+ _repChange = SAR_surv_kill_value / 10;
+
+ _playerRespect = _playerRespect + _repChange;
+ _aikiller setVariable ["ExileScore",_playerRespect];
+
+ ExileClientPlayerScore = _playerRespect;
+ (owner _aikiller) publicVariableClient "ExileClientPlayerScore";
+ ExileClientPlayerScore = nil;
+
+ format ["setAccountMoneyAndRespect:%1:%2:%3", _playerMoney, _playerRespect, _playerUID] call ExileServer_system_database_query_fireAndForget;
+
+ if(SAR_log_AI_kills) then {
+ _banditkills = _aikiller getVariable["banditKills",0];
+ _aikiller setVariable["banditKills",_banditkills+1,true];
+ };
+
+ if ((random 100) < 3) then {
+ _message = format["nice bandit kill %1!",_aikiller_name];
+ //[nil, nil, rspawn, [[West,"airbase"], _message], { (_this select 0) sideChat (_this select 1) }] call RE;
+ [_message,"(_this select 0) sideChat (_this select 1)",true,false] call BIS_fnc_MP;
+ } else {
+ if ((random 100) < 3) then {
+ _message = format["another bandit down ... %1 is going to be the root cause of bandit extinction :-)",_aikiller_name];
+ //[nil, nil, rspawn, [[West,"airbase"], _message], { (_this select 0) sideChat (_this select 1) }] call RE;
+ [_message,"(_this select 0) sideChat (_this select 1)",true,false] call BIS_fnc_MP;
+ };
+ };
+ };
+};
diff --git a/sarge/SAR_config.sqf b/sarge/SAR_config.sqf
new file mode 100644
index 0000000..6048e69
--- /dev/null
+++ b/sarge/SAR_config.sqf
@@ -0,0 +1,132 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+
+SAR_version = "2.1.0";
+
+/* Debug & RPT Settings */
+SAR_DEBUG = false; // Set to true for RPT info on AI
+SAR_EXTREME_DEBUG = false; // Set to true for RPT info on damn near everything
+SAR_HITKILL_DEBUG = false; // Set to true for RPT info on AI shooting and killing
+SAR_log_AI_kills = false; // Set to true for kill logging by variable. *These variables do not save to the database currently*
+SAR_KILL_MSG = false; // Set to true for announcing AI kills to the server *This is still in development*
+
+/* Dynamic AI Settings */
+SAR_dynamic_spawning = true; // Turn dynamic grid spawns on or off
+SAR_Base_Gaurds = true; // Turn AI territory gurads on or off
+SAR_dynamic_group_respawn = true; // Turn dynamic grid AI respawn on or off
+SAR_AI_STEAL_VEHICLE = true; // Turn the option for AI using vehicles to reach their destination on or off
+SAR_AI_disable_UPSMON_AI = false; // Turning this off could have unintended consequences
+SAR_respawn_waittime = 300; // How long to wait before dynamic IA respawns
+SAR_DESPAWN_TIMEOUT = 120; // How long to wait before despawning dynamic AI
+SAR_DELETE_TIMEOUT = 300; // How long to wait before deleting dead AI
+SAR_surv_kill_value = 250; // How much respect players lose if killing friendly AI
+SAR_band_kill_value = 50; // How much respect players lose if killing hostile AI
+SAR_RESPECT_HOSTILE_LIMIT = -2500; // Friendly AI will shoot at players with respect below this number
+SAR_REAMMO_INTERVAL = 30; // How often AI will replenish their ammo count
+SAR_DETECT_HOSTILE = 200; // How far away AI can detect hostile AI & players
+SAR_DETECT_INTERVAL = 15; // How often AI can detect AI & players
+SAR_DETECT_HOSTILE_FROM_VEHICLE = 500; // How far AI can detect hostile AI & players while in a vehicle
+SAR_DETECT_FROM_VEHICLE_INTERVAL = 5; // How often AI can detect hostile AI & players while in a vehicle
+
+SAR_chance_bandits = 75; // Chance to spawn 1-100%
+SAR_chance_soldiers = 25; // Chance to spawn 1-100%
+SAR_chance_survivors = 50; // Chance to spawn 1-100%
+SAR_max_grps_bandits = 2; // Total groups per grid
+SAR_max_grps_soldiers = 2; // Total groups per grid
+SAR_max_grps_survivors = 2; // Total groups per grid
+SAR_max_grpsize_bandits = 2; // Size of the group
+SAR_max_grpsize_soldiers = 2; // Size of the group
+SAR_max_grpsize_survivors = 2; // Size of the group
+
+// Military AI ----------------------------------------------------------
+// ----------------------------------------------------------------------
+SAR_leader_sold_list = ["B_officer_F"];
+SAR_sniper_sold_list = ["B_ghillie_lsh_F","B_sniper_F"];
+SAR_soldier_sold_list = ["B_G_medic_F","B_G_engineer_F","b_soldier_survival_F","B_G_Soldier_TL_F"];
+
+SAR_sold_leader_weapon_list = ["arifle_Katiba_F","arifle_Mk20_F","arifle_MXC_F","arifle_MX_F","arifle_TRG21_F","arifle_TRG20_F"];
+SAR_sold_leader_pistol_list = [];
+
+SAR_sold_leader_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60],["Exile_Item_InstaDoc",100]];
+SAR_sold_leader_tools = [["ItemMap",50],["ItemCompass",30],["NVGoggles",5],["ItemRadio",100]];
+
+SAR_sold_rifleman_weapon_list = ["arifle_Katiba_F","arifle_Mk20_F","arifle_MXC_F","arifle_MX_F","arifle_TRG21_F","arifle_TRG20_F"];
+SAR_sold_rifleman_pistol_list = [];
+
+SAR_sold_rifleman_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60]];
+SAR_sold_rifleman_tools = [["ItemMap",50],["ItemCompass",30]];
+
+SAR_sold_sniper_weapon_list = ["srifle_DMR_02_F","arifle_MXM_F","srifle_DMR_04_F"];
+SAR_sold_sniper_pistol_list = [];
+
+SAR_sold_sniper_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60]];
+SAR_sold_sniper_tools = [["ItemMap",50],["ItemCompass",30]];
+
+// Survivor AI ----------------------------------------------------------
+// ---------------------------------------------------------------------
+SAR_leader_surv_list = ["B_G_Soldier_A_F"];
+SAR_sniper_surv_list = ["B_G_Soldier_LAT_F"];
+SAR_soldier_surv_list = ["B_G_Soldier_M_F"];
+
+SAR_surv_leader_weapon_list = ["arifle_Katiba_F","arifle_Mk20_F","arifle_MXC_F","arifle_MX_F","arifle_TRG21_F","arifle_TRG20_F"];
+SAR_surv_leader_pistol_list = [];
+
+SAR_surv_leader_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60]];
+SAR_surv_leader_tools = [["ItemMap",50],["ItemCompass",30],["NVGoggles",5],["ItemRadio",100]];
+
+SAR_surv_rifleman_weapon_list = ["arifle_Katiba_F","arifle_Mk20_F","arifle_MXC_F","arifle_MX_F","arifle_TRG21_F","arifle_TRG20_F"];
+SAR_surv_rifleman_pistol_list = [];
+
+SAR_surv_rifleman_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60]];
+SAR_surv_rifleman_tools = [["ItemMap",50],["ItemCompass",30]];
+
+SAR_surv_sniper_weapon_list = ["srifle_DMR_02_F","arifle_MXM_F","srifle_DMR_04_F"];
+SAR_surv_sniper_pistol_list = [];
+
+SAR_surv_sniper_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60]];
+SAR_surv_sniper_tools = [["ItemMap",50],["ItemCompass",30]];
+
+// Hostile AI ----------------------------------------------------------
+// ---------------------------------------------------------------------
+SAR_leader_band_list = ["O_G_Soldier_lite_F"];
+SAR_sniper_band_list = ["O_G_Soldier_lite_F"];
+SAR_soldier_band_list = ["O_G_Soldier_lite_F"];
+
+SAR_band_leader_weapon_list = ["arifle_Katiba_F","arifle_Mk20_F","arifle_MXC_F","arifle_MX_F","arifle_TRG21_F","arifle_TRG20_F"];
+SAR_band_leader_pistol_list = [];
+
+SAR_band_leader_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60]];
+SAR_band_leader_tools = [["ItemMap",50],["ItemCompass",30],["NVGoggles",5],["ItemRadio",100]];
+
+SAR_band_rifleman_weapon_list = ["arifle_Katiba_F","arifle_Mk20_F","arifle_MXC_F","arifle_MX_F","arifle_TRG21_F","arifle_TRG20_F"];
+SAR_band_rifleman_pistol_list = [];
+
+SAR_band_rifleman_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60]];
+SAR_band_rifleman_tools = [["ItemMap",50],["ItemCompass",30]];
+
+SAR_band_sniper_weapon_list = ["srifle_DMR_02_F","arifle_MXM_F","srifle_DMR_04_F"];
+SAR_band_sniper_pistol_list = [];
+
+SAR_band_sniper_items = [["Exile_Item_PlasticBottleFreshWater",75],["Exile_Item_Catfood_Cooked",60]];
+SAR_band_sniper_tools = [["ItemMap",50],["ItemCompass",30]];
+
+
+// Helicopter Types ----------------------------------------------------
+// ---------------------------------------------------------------------
+SAR_heli_type = ["B_Heli_Light_01_stripped_F"];
+
+
+/* -------------------------------- Do Not Edit Below. If you do the AI will not work properly. -------------------------------- */
+SAR_HC = false;
diff --git a/sarge/SAR_define.hpp b/sarge/SAR_define.hpp
new file mode 100644
index 0000000..c559bc1
--- /dev/null
+++ b/sarge/SAR_define.hpp
@@ -0,0 +1,43 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+class CfgIdentities {
+ class id_SAR {
+ name = "id_SAR";
+ face = "WhiteHead_06";
+ glasses = "None";
+ speaker = "NoVoice";
+ pitch = 1.00;
+ };
+ class id_SAR_band : id_SAR {
+ name = "id_SAR_band";
+ face = "PersianHead_A3_02";
+ };
+ class id_SAR_sold_lead : id_SAR {
+ name = "id_SAR_sold_lead";
+ face = "WhiteHead_02";
+ };
+ class id_SAR_sold_man : id_SAR {
+ name = "id_SAR_sold_man";
+ face = "WhiteHead_02";
+ };
+ class id_SAR_surv_lead : id_SAR {
+ name = "id_SAR_surv_lead";
+ face = "WhiteHead_02";
+ };
+ class id_SAR_surv_man : id_SAR {
+ name = "id_SAR_surv_man";
+ face = "WhiteHead_04";
+ };
+};
\ No newline at end of file
diff --git a/sarge/SAR_functions.sqf b/sarge/SAR_functions.sqf
new file mode 100644
index 0000000..b4ac305
--- /dev/null
+++ b/sarge/SAR_functions.sqf
@@ -0,0 +1,516 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0pushBack
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+SAR_get_road_pos = {
+ /*
+ Parameters:
+ _areaname = the markername where the position should be choosen
+ */
+ private ["_targetPosTemp","_newpos","_loop2","_tries2","_roads","_area_name","_centerpos","_centerX","_centerY","_areasize","_rangeX","_rangeY","_areadir","_cosdir","_sindir"];
+
+ _area_name = _this select 0;
+
+ // remember center position of area marker
+ _centerpos = getMarkerPos _area_name;
+ _centerX = abs(_centerpos select 0);
+ _centerY = abs(_centerpos select 1);
+
+ // X/Y range of target area
+ _areasize = getMarkerSize _area_name;
+ _rangeX = _areasize select 0;
+ _rangeY = _areasize select 1;
+
+ // marker orientation (needed as negative value!)
+ _areadir = (markerDir _area_name) * -1;
+
+ // store some trig calculations
+ _cosdir=cos(_areadir);
+ _sindir=sin(_areadir);
+
+ _tries2=0;
+ _loop2 = false;
+
+ while {(!_loop2) && (_tries2 <100)} do {
+ _tries2=_tries2pushBack1;
+ _targetPosTemp = [_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos;
+ _roads = (_targetPosTemp nearRoads 50);
+ if ((count _roads) > 0) then {
+ _targetPosTemp = getpos (_roads select 0);
+ _newpos = _targetPosTemp;
+ _loop2 = TRUE;
+ };
+ sleep 0.05;
+ };
+ _newpos;
+};
+
+SAR_break_circle = {
+ /*
+ Parameters:
+ _group = the group
+ */
+ private ["_group"];
+
+ _group = _this select 0;
+ _group setBehaviour "AWARE";
+ {
+ _x enableAI "TARGET";
+ _x forceSpeed 1;
+ } foreach units _group;
+};
+
+SAR_move_to_circle_pos = {
+ //Parameters:
+ //_unit = the unit to move
+ //_newpos = the position the unit should move to
+ private ["_unit","_centerpos","_newpos","_viewangle","_defend"];
+
+ _unit = _this select 0;
+ _centerpos = _this select 1;
+ _newpos = _this select 2;
+ _viewangle = _this select 3;
+ _defend = _this select 4;
+
+ _unit forceSpeed 1;
+
+ _unit moveTo _newpos;
+ _unit doMove _newpos;
+
+ waituntil {moveToCompleted _unit};
+ _unit forceSpeed 0;
+
+ //_unit doWatch (_veh modelToWorld [(sin (_foreachindex * _angle))*SAR_sit_radius, (cos (_foreachindex * _angle))*SAR_sit_radius, 0]);
+ //_unit doWatch _veh;
+
+ //diag_log format["Unit: %1 Angle to look at: %2",_unit,_viewangle];
+
+ _unit setDir _viewangle;
+ _unit setpos getPos _unit;
+
+ if(!_defend) then {
+ _unit playActionNow "SitDown";
+ sleep 1;
+ } else{
+ _unit setUnitPos "Middle";
+ sleep 1;
+ };
+
+ _unit disableAI "TARGET";
+ //_unit disableAI "FSM";
+};
+
+SAR_circle_static = {
+ //Parameters:
+ //_leader = the leader of the group
+ //_action = the action to execute while forming a circle
+ //_radius = the radius of the circle
+ private ["_center","_defend","_veh","_angle","_dir","_newpos","_forEachIndex","_leader","_action","_grp","_pos","_units","_count","_viewangle","_radius"];
+
+ _count = 0;
+
+ //diag_log "SAR_AI: Group should form a circle";
+
+ _leader = _this select 0;
+ _action = _this select 1;
+ _radius = _this select 2;
+
+ _grp = group _leader;
+ _defend = false;
+ _units = units _grp;
+ _count = count _units;
+
+ if(_count > 1) then { // only do this for groups > 1 unit
+
+ _pos = getposASL _leader;
+ _pos = (_leader) modelToWorld[0,0,0];
+
+ doStop _leader;
+ sleep .5;
+
+ //play leader stop animation
+ _leader playAction "gestureFreeze";
+ sleep 2;
+
+ if(_action == "defend") then {
+ _center = _leader;
+ _leader forceSpeed 0;
+ _defend = true;
+ };
+
+ if(_action == "campfire") then {
+ _veh = createvehicle["Land_Campfire_burning",_pos,[],0,"NONE"];
+ _center = _veh;
+ };
+
+ if(_defend) then {
+ _angle = 360/(_count-1);
+ }else{
+ _angle = 360/(_count);
+ };
+
+ _grp enableGunLights "AUTO";
+ _grp setBehaviour "CARELESS";
+
+ {
+ if(_x != _leader || {_x == _leader && !_defend}) then {
+
+ _newpos = (_center modelToWorld [(sin (_forEachIndex * _angle))*_radius, (cos (_forEachIndex *_angle))*_radius, 0]);
+
+ //diag_log format["Newpos %1: %2",_foreachindex,_newpos];
+
+ if(_defend) then {
+ _dir = 0;
+ }else{
+ _dir = 180;
+ };
+
+ _viewangle = (_foreachIndex * _angle) pushBack _dir;
+
+ [_x,_pos,_newpos,_viewangle,_defend]spawn SAR_move_to_circle_pos;
+ };
+ } foreach _units;
+ //_leader disableAI "MOVE";
+ };
+};
+
+SAR_isKindOf_weapon = {
+ // own function because the BiS one does only search vehicle config
+ // parameters:
+ //_weapon = the weapon for which we search the parent class
+ //_class = class to search for
+ //return value: true if found, otherwise false
+
+ private ["_class","_weapon","_cfg_entry","_found","_search_class"];
+
+ _weapon = _this select 0;
+ _class = _this select 1;
+
+ _cfg_entry = configFile >> "CfgWeapons" >> _weapon;
+ _search_class = configFile >> "CfgWeapons" >> _class;
+
+ _found = false;
+ while {isClass _cfg_entry} do
+ {
+ if (_cfg_entry == _search_class) exitWith { _found = true; };
+
+ _cfg_entry = inheritsFrom _cfg_entry;
+ };
+
+ _found;
+};
+
+SAR_AI_is_unfriendly_group = {
+ // parameters
+ // _trig_player_list = list of players in the trigger array
+
+ private ["_trig_player_list","_bandits_in_trigger","_player_respect"];
+
+ _trig_player_list = _this select 0;
+
+ _bandits_in_trigger = false;
+ {
+ _player_respect = _x getVariable ["ExileScore",0];
+
+ if(_player_respect < SAR_RESPECT_HOSTILE_LIMIT) then {
+ _bandits_in_trigger = true;
+ };
+ } foreach _trig_player_list;
+
+ _bandits_in_trigger;
+};
+
+SAR_unit_loadout_tools = {
+ // Parameters:
+ // _unittype (leader, soldier, sniper)
+ // _side (mili, surv, band
+ // return value: tools array
+
+ private ["_unittype","_side","_unit_tools_list","_unit_tools","_tool","_probability","_chance"];
+
+ _unittype = _this select 0;
+ _side = _this select 1;
+
+ _unit_tools_list = call compile format["SAR_%2_%1_tools",_unittype,_side];
+
+ _unit_tools = [];
+ {
+ _tool = _x select 0;
+ _probability = _x select 1;
+ _chance = (random 100);
+ if(_chance < _probability) then {
+ _unit_tools set [count _unit_tools, _tool];
+ };
+ } foreach _unit_tools_list;
+
+ _unit_tools;
+};
+
+SAR_unit_loadout_items = {
+ // Parameters:
+ // _unittype (leader, soldier, sniper)
+ // _side (mili, surv, band)
+ // return value: items array
+
+ private ["_unittype","_unit_items_list","_unit_items","_item","_probability","_chance","_side"];
+
+ _unittype = _this select 0;
+ _side = _this select 1;
+
+ _unit_items_list = call compile format["SAR_%2_%1_items",_unittype,_side];
+
+ _unit_items = [];
+ {
+ _item = _x select 0;
+ _probability = _x select 1;
+ _chance = (random 100);
+ if(_chance < _probability) then {
+ _unit_items set [count _unit_items, _item];
+ };
+ } foreach _unit_items_list;
+
+ _unit_items;
+};
+
+SAR_unit_loadout_weapons = {
+ // Parameters:
+ // _unittype (leader, rifleman, sniper)
+ // _side (sold,surv,band)
+ // return value: weapons array
+
+ private ["_unittype","_side","_unit_weapon_list","_unit_pistol_list","_unit_pistol_name","_unit_weapon_name","_unit_weapon_names"];
+
+ _unittype = _this select 0;
+ _side = _this select 1;
+
+ _unit_weapon_list = call compile format["SAR_%2_%1_weapon_list",_unittype,_side];
+ _unit_pistol_list = call compile format["SAR_%2_%1_pistol_list",_unittype,_side];
+
+ _unit_weapon_names = [];
+ _unit_weapon_name = "";
+ _unit_pistol_name = "";
+
+ if(count _unit_weapon_list > 0) then {
+ _unit_weapon_name = _unit_weapon_list select (floor(random (count _unit_weapon_list)));
+ };
+ if(count _unit_pistol_list > 0) then {
+ _unit_pistol_name = _unit_pistol_list select (floor(random (count _unit_pistol_list)));
+ };
+ _unit_weapon_names set [0, _unit_weapon_name];
+ _unit_weapon_names set [1, _unit_pistol_name];
+
+ _unit_weapon_names;
+};
+
+SAR_unit_loadout = {
+ // Parameters:
+ // _unit (Unit to apply the loadout to)
+ // _weapons (array with weapons for the loadout)
+ // _items (array with items for the loadout)
+ // _tools (array with tools for the loadout)
+
+ private ["_unit","_weapons","_weapon","_items","_unit_magazine_name","_item","_tool","_tools","_forEachIndex"];
+
+ _unit = _this select 0;
+ _weapons = _this select 1;
+ _items = _this select 2;
+ _tools = _this select 3;
+
+ removeAllWeapons _unit;
+ removeAllAssignedItems _unit;
+ removeAllItems _unit;
+ removeBackpack _unit;
+ removeGoggles _unit;
+ removeVest _unit;
+ if (_unit isKindOf "O_G_Soldier_lite_F") then {removeHeadgear _unit; sleep 1; _unit addHeadGear "H_Shemag_olive";};
+
+ _unit enableFatigue false;
+ _unit allowDamage true;
+
+ {
+ _weapon = _weapons select _forEachIndex;
+
+ if (_weapon !="") then
+ {
+ _unit_magazine_name = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines") select 0;
+ _unit addMagazine _unit_magazine_name;
+ _unit addWeapon _weapon;
+ };
+ } foreach _weapons;
+
+ {
+ _item = _items select _forEachIndex;
+ _unit addMagazine _item;
+ } foreach _items;
+
+ {
+ _tool = _tools select _forEachIndex;
+ _unit addWeapon _tool;
+ } foreach _tools;
+};
+
+SAR_AI_mon_upd = {
+ // Parameters:
+ // _typearray (possible values = "max_grps", "rnd_grps", "max_p_grp", "grps_band","grps_sold","grps_surv")
+ // _valuearray (must be an array)
+ // _gridname (is the areaname of the grid for this change)
+
+ private ["_typearray","_valuearray","_gridname","_path","_success","_forEachIndex"];
+
+ _typearray = _this select 0;
+ _valuearray =_this select 1;
+ _gridname = _this select 2;
+
+ _path = [SAR_AI_monitor, _gridname] call BIS_fnc_findNestedElement;
+
+ {
+ switch (_x) do
+ {
+ case "max_grps":
+ {
+ _path set [1,1];
+ };
+ case "rnd_grps":
+ {
+ _path set [1,2];
+ };
+ case "max_p_grp":
+ {
+ _path set [1,3];
+ };
+ case "grps_band":
+ {
+ _path set [1,4];
+ };
+ case "grps_sold":
+ {
+ _path set [1,5];
+ };
+ case "grps_surv":
+ {
+ _path set [1,6];
+ };
+ };
+
+ _success = [SAR_AI_monitor, _path, _valuearray select _forEachIndex] call BIS_fnc_setNestedElement;
+
+ } foreach _typearray;
+
+ _success;
+};
+
+SAR_AI_mon_read = {
+ // Parameters:
+ // _typearray (possible values = "max_grps", "rnd_grps", "max_p_grp", "grps_band","grps_sold","grps_surv")
+ // _gridname (is the areaname of the grid for this change)
+
+ private ["_typearray","_gridname","_path","_resultarray"];
+
+ _typearray = _this select 0;
+ _gridname = _this select 1;
+ _resultarray = [];
+
+ _path = [SAR_AI_monitor, _gridname] call BIS_fnc_findNestedElement;
+
+ {
+ switch (_x) do
+ {
+ case "max_grps":
+ {
+ _path set [1,1];
+ };
+ case "rnd_grps":
+ {
+ _path set [1,2];
+ };
+ case "max_p_grp":
+ {
+ _path set [1,3];
+ };
+ case "grps_band":
+ {
+ _path set [1,4];
+ };
+ case "grps_sold":
+ {
+ _path set [1,5];
+ };
+ case "grps_surv":
+ {
+ _path set [1,6];
+ };
+ };
+ _resultarray set [count _resultarray,[SAR_AI_monitor, _path] call BIS_fnc_returnNestedElement];
+ } foreach _typearray;
+
+ _resultarray;
+};
+
+SAR_DEBUG_mon = {
+ diag_log "--------------------Start of AI monitor values -------------------------";
+ {
+ diag_log format["SAR EXTREME DEBUG: %1",_x];
+ }foreach SAR_AI_monitor;
+
+ diag_log "--------------------End of AI monitor values -------------------------";
+};
+
+
+SAR_fnc_returnConfigEntry = {
+ private ["_config", "_entryName","_entry", "_value"];
+
+ _config = _this select 0;
+ _entryName = _this select 1;
+ _entry = _config >> _entryName;
+
+ //If the entry is not found and we are not yet at the config root, explore the class' parent.
+ if (((configName (_config >> _entryName)) == "") && {!((configName _config) in ["CfgVehicles", "CfgWeapons", ""])}) then {
+ [inheritsFrom _config, _entryName] call SAR_fnc_returnConfigEntry;
+ }
+ else { if (isNumber _entry) then { _value = getNumber _entry; } else { if (isText _entry) then { _value = getText _entry; }; }; };
+ //Make sure returning 'nil' works.
+ if (isNil "_value") exitWith {nil};
+
+ _value;
+};
+
+// *WARNING* BIS FUNCTION RIPOFF - Taken from fn_fnc_returnVehicleTurrets and shortened a bit
+SAR_fnc_returnVehicleTurrets = {
+ private ["_entry","_turrets","_turretIndex"];
+
+ _entry = _this select 0;
+ _turrets = [];
+ _turretIndex = 0;
+
+ //Explore all turrets and sub-turrets recursively.
+ for "_i" from 0 to ((count _entry) - 1) do {
+ private ["_subEntry"];
+ _subEntry = _entry select _i;
+ if (isClass _subEntry) then {
+ private ["_hasGunner"];
+ _hasGunner = [_subEntry, "hasGunner"] call SAR_fnc_returnConfigEntry;
+ //Make sure the entry was found.
+ if (!(isNil "_hasGunner")) then {
+ if (_hasGunner == 1) then {
+ _turrets = _turrets pushBack [_turretIndex];
+ //Include sub-turrets, if present.
+ if (isClass (_subEntry >> "Turrets")) then { _turrets = _turrets pushBack [[_subEntry >> "Turrets"] call SAR_fnc_returnVehicleTurrets]; }
+ else { _turrets = _turrets pushBack [[]]; };
+ };
+ };
+ _turretIndex = _turretIndex + 1;
+ };
+ sleep 0.01;
+ };
+ _turrets;
+};
diff --git a/sarge/SAR_init_Base_guards.sqf b/sarge/SAR_init_Base_guards.sqf
new file mode 100644
index 0000000..ee268b5
--- /dev/null
+++ b/sarge/SAR_init_Base_guards.sqf
@@ -0,0 +1,68 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private["_sizeX","_sizeY","_snipers","_rifleMen","_sizeOfBase","_marker","_markername","_tMark","_flagPoles","_baseLevel","_baseName"];
+
+if (!isServer) exitWith {};
+
+_flagPoles = nearestObjects [getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition"), ["Exile_Construction_Flag_Static"], 25000];
+
+diag_log "Sarge AI System: Territory Base Gaurds Are Now Initializing";
+
+diag_log format["Sarge AI System: Total Territory Locations Query Returned With: %1",(count _flagPoles)];
+
+{
+ _baseName = _x getVariable ["ExileTerritoryName",""];
+ _sizeOfBase = _x getVariable ["ExileTerritorySize",""];
+
+ _padding = 5;
+ _spawnRadius = _sizeOfBase + _padding;
+
+ switch (_sizeOfBase) do {
+ case default {_rifleMen = 1; _snipers = 0; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 15: {_rifleMen = 1; _snipers = 0; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 30: {_rifleMen = 1; _snipers = 0; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 45: {_rifleMen = 2; _snipers = 0; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 60: {_rifleMen = 2; _snipers = 0; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 75: {_rifleMen = 1; _snipers = 1; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 90: {_rifleMen = 1; _snipers = 1; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 105: {_rifleMen = 2; _snipers = 1; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 120: {_rifleMen = 2; _snipers = 1; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 135: {_rifleMen = 2; _snipers = 2; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ case 150: {_rifleMen = 2; _snipers = 2; _sizeX = _spawnRadius; _sizeY = _spawnRadius;};
+ };
+ sleep 1;
+
+ if (SAR_debug) then {
+ diag_log format ["Sarge AI System: Now Processing Territory %1 at Location %2 with a size of %3.",_baseName,(getPosATL _x),_sizeOfBase];
+ };
+
+ _baseMarker = format["Gaurd_Marker_%1",_baseName];
+ _spawnMark = createMarkerLocal [_baseMarker,(getPosATL _x)];
+ _spawnMark setMarkerShape "ELLIPSE";
+ _spawnMark setMarkerType "Flag";
+ _spawnMark setMarkerBrush "Solid";
+ _spawnMark setMarkerSize [_sizeX,_sizeY];
+ _spawnMark setMarkeralpha 0;
+
+ _behaviors = ["patrol"]; // Do not change this!
+ _behavior = _behaviors call BIS_fnc_selectRandom;
+
+ [_x,_spawnMark,2,_snipers,_rifleMen,_behavior,false,5200] call SAR_AI_GUARDS;
+
+ s_player_guardToggle = _x addaction [format[("" + ("Toggle Guards to Kill all non-base owners") +""),""],"dayz_code\actions\toggle_base_guards.sqf",_x,1,false,true,"",""];
+
+} foreach _flagPoles;
+
+diag_log "Sarge AI System: Territory base gaurds have now completed spawning.";
diff --git a/sarge/SAR_interact.sqf b/sarge/SAR_interact.sqf
new file mode 100644
index 0000000..dcc7b8f
--- /dev/null
+++ b/sarge/SAR_interact.sqf
@@ -0,0 +1,76 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_targetAI","_actingPlayer","_animState","_started","_finished","_isMedic","_leadername"];
+
+
+if (isServer || !hasInterface) exitWith {}; // only run this on the client
+
+_targetAI = _this select 0;
+_actingPlayer = _this select 1;
+
+_leadername = _targetAI getVariable ["SAR_leader_name",false];
+
+// suspend UPSMON
+call compile format ["KRON_UPS_%1=2",_leadername];
+
+publicVariable format["KRON_UPS_%1",_leadername];
+sleep 5;
+
+[_targetAI,"defend",15] spawn SAR_circle_static;
+
+
+
+
+if (vehicle _targetAI == _targetAI) then {
+ doMedicAnim = [_targetAI,"Medic"];
+ publicVariable "doMedicAnim";
+};
+
+r_interrupt = false;
+_animState = animationState _targetAI;
+r_doLoop = true;
+_started = false;
+_finished = false;
+while {r_doLoop} do {
+ _animState = animationState _targetAI;
+ _isMedic = ["medic",_animState] call fnc_inString;
+ if (_isMedic) then {
+ _started = true;
+ };
+ if (_started && {!_isMedic}) then {
+ r_doLoop = false;
+ _finished = true;
+ };
+ if (r_interrupt) then {
+ r_doLoop = false;
+ };
+ sleep 0.1;
+};
+r_doLoop = false;
+
+if (_finished) then {
+ _actingPlayer setVariable["LastTransfusion",time,true];
+ _actingPlayer setVariable["USEC_lowBlood",false,true];
+ _actingPlayer removeMagazine "ItemBloodbag";
+ ["usecTransfuse",[_actingPlayer,_targetAI]] call broadcastRpcCallAll;
+
+} else {
+ r_interrupt = false;
+ doMedicAnim = [_targetAI,"Stop"];
+ publicVariable "doMedicAnim";
+};
+
+// resume UPSMON
+call compile format ["KRON_UPS_%1=1",_leadername];
diff --git a/sarge/SAR_reammo_refuel_AI.sqf b/sarge/SAR_reammo_refuel_AI.sqf
new file mode 100644
index 0000000..082c33c
--- /dev/null
+++ b/sarge/SAR_reammo_refuel_AI.sqf
@@ -0,0 +1,102 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_ai","_sleeptime","_veh_weapons","_vehicle","_weapons","_reloadmag","_magazintypes","_legit_weapon","_weap_obj"];
+
+if (!isServer) exitWith {};
+
+_ai = _this select 0;
+
+_magazintypes =[];
+_reloadmag = false;
+_weapons = weapons _ai;
+
+_sleeptime = SAR_REAMMO_INTERVAL;
+
+while {alive _ai} do {
+
+ _vehicle = vehicle _ai;
+ if(_vehicle != _ai) then { // NPC in vehicle, we are only reloading vehicle ammo and refueling the vehicle if needed
+
+ // check if low on ammo & fuel
+ _veh_weapons = weapons _vehicle;
+
+ _legit_weapon = false;
+ {
+ if (!([_x,"CarHorn"] call SAR_isKindOf_weapon)) then {
+ _legit_weapon = true;
+ _weap_obj = _x;
+ };
+ } foreach _veh_weapons;
+
+ if(_legit_weapon) then {
+
+ if(_vehicle ammo _weap_obj < 11) then {
+ _vehicle setVehicleAmmo 1;
+ if (SAR_EXTREME_DEBUG) then {diag_log "SAR EXTREME DEBUG: Vehicle got new ammo";};
+ };
+
+ };
+
+ if(fuel _vehicle < 0.2) then {
+ _vehicle setFuel 1;
+ if (SAR_EXTREME_DEBUG) then {diag_log "SAR_EXTREME_DEBUG: Vehicle refueled";};
+ };
+
+ } else { // NPC not in a vehicle
+
+ // loop through weapons array
+ {
+ // check if weapon rifle exists on AI
+ if([_x,"Rifle"] call SAR_isKindOf_weapon) then {
+
+ _reloadmag = true;
+ _magazintypes = getArray (configFile >> "CfgWeapons" >> _x >> "magazines");
+
+ // loop through valid magazines of weapon and check if there is a magazine for that weapon on the AI
+ {
+ if (_x in magazines _ai) then {
+ _reloadmag = false;
+ };
+ } foreach _magazintypes;
+
+ if (!(someAmmo _ai) || {_reloadmag}) then {
+ _ai removeMagazines (_magazintypes select 0);
+ _ai addMagazine (_magazintypes select 0);
+ if (SAR_EXTREME_DEBUG) then {diag_log format["SAR_EXTREME_DEBUG: Infantry reloaded a magazine (%1) for a rifle (%2).",(_magazintypes select 0),_x];};
+ };
+ };
+
+ if([_x,"Pistol"] call SAR_isKindOf_weapon) then {
+
+ _reloadmag = true;
+ _magazintypes = getArray (configFile >> "CfgWeapons" >> _x >> "magazines");
+ // loop through valid magazines of weapon and check if there is a magazine for that weapon on the AI
+ {
+ if (_x in magazines _ai) then {
+ _reloadmag = false;
+ };
+ } foreach _magazintypes;
+
+ if (!(someAmmo _ai) || {_reloadmag}) then {
+ _ai removeMagazines (_magazintypes select 0);
+ _ai addMagazine (_magazintypes select 0);
+ if (SAR_EXTREME_DEBUG) then {diag_log "SAR_EXTREME_DEBUG: Infantry reloaded a magazine for a pistol.";};
+ };
+ };
+
+ } foreach _weapons;
+ };
+ sleep _sleeptime;
+};
\ No newline at end of file
diff --git a/sarge/SAR_setup_AI_patrol.sqf b/sarge/SAR_setup_AI_patrol.sqf
new file mode 100644
index 0000000..47cb3bc
--- /dev/null
+++ b/sarge/SAR_setup_AI_patrol.sqf
@@ -0,0 +1,234 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_leadername","_type","_patrol_area_name","_grouptype","_snipers","_riflemen","_action","_side","_leaderList","_riflemenlist","_sniperlist","_rndpos","_group","_leader","_cond","_respawn","_leader_weapon_names","_leader_items","_leader_tools","_soldier_weapon_names","_soldier_items","_soldier_tools","_sniper_weapon_names","_sniper_items","_sniper_tools","_leaderskills","_riflemanskills","_sniperskills","_ups_para_list","_respawn_time","_argc","_ai_type"];
+
+if (!isServer) exitWith {};
+
+_patrol_area_name = _this select 0;
+_grouptype = _this select 1;
+_snipers = _this select 2;
+_riflemen = _this select 3;
+_action = toLower (_this select 4);
+_respawn = _this select 5;
+
+_argc = count _this;
+if (_argc > 6) then {
+ _respawn_time = _this select 6;
+} else {
+ _respawn_time = SAR_respawn_waittime;
+};
+
+switch (_grouptype) do
+{
+ case 1: // military
+ {
+ _side = SAR_AI_friendly_side;
+ _type = "sold";
+ _ai_type = "AI Military";
+ };
+ case 2: // survivors
+ {
+ _side = SAR_AI_friendly_side;
+ _type = "surv";
+ _ai_type = "AI Survivor";
+ };
+ case 3: // bandits
+ {
+ _side = SAR_AI_unfriendly_side;
+ _type = "band";
+ _ai_type = "AI Bandit";
+ };
+};
+
+_leaderList = call compile format ["SAR_leader_%1_list", _type];
+//_leaderskills = call compile format ["SAR_leader_%1_skills", _type];
+
+// get a random starting position that is on land
+_rndpos = [_patrol_area_name] call UPSMON_pos;
+
+_group = createGroup _side;
+
+// create leader of the group
+_leader = _group createunit [_leaderList call BIS_fnc_selectRandom, [(_rndpos select 0) , _rndpos select 1, 0], [], 0.5, "NONE"];
+
+_leader_weapon_names = ["leader",_type] call SAR_unit_loadout_weapons;
+_leader_items = ["leader",_type] call SAR_unit_loadout_items;
+_leader_tools = ["leader",_type] call SAR_unit_loadout_tools;
+
+[_leader,_leader_weapon_names,_leader_items,_leader_tools] call SAR_unit_loadout;
+
+[_leader] spawn SAR_AI_trace;
+_leader setIdentity "id_SAR_sold_lead";
+[_leader] spawn SAR_AI_reammo;
+
+_leader addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+_leader addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+[_leader] joinSilent _group;
+/*
+// set skills of the leader
+{
+ _leader setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+} foreach _leaderskills;
+
+// define and store the leadername
+SAR_leader_number = SAR_leader_number + 1;
+_leadername = format ["SAR_leader_%1",SAR_leader_number];
+
+_leader setVehicleVarname _leadername;
+_leader setVariable ["SAR_leader_name",_leadername,false];
+*/
+// store AI type on the AI
+_leader setVariable ["SAR_AI_type",_ai_type + " Leader",false];
+/*
+// set behaviour & speedmode
+_leader setspeedmode "FULL";
+_leader setBehaviour "AWARE";
+
+// if needed broadcast to the clients **I believe the new UPSMON does this already
+//_leader Call Compile Format ["%1=_This ; PublicVariable ""%1""",_leadername];
+ */
+// Establish siper unit type and skills
+_sniperlist = call compile format ["SAR_sniper_%1_list", _type];
+//_sniperskills = call compile format ["SAR_sniper_%1_skills", _type];
+
+// create crew
+for "_i" from 0 to (_snipers - 1) do
+{
+ _this = _group createunit [_sniperlist call BIS_fnc_selectRandom, [(_rndpos select 0), _rndpos select 1, 0], [], 0.5, "NONE"];
+
+ _sniper_weapon_names = ["sniper",_type] call SAR_unit_loadout_weapons;
+ _sniper_items = ["sniper",_type] call SAR_unit_loadout_items;
+ _sniper_tools = ["sniper",_type] call SAR_unit_loadout_tools;
+
+ [_this,_sniper_weapon_names,_sniper_items,_sniper_tools] call SAR_unit_loadout;
+
+ [_this] spawn SAR_AI_trace;
+ _this setIdentity "id_SAR";
+ [_this] spawn SAR_AI_reammo;
+
+ _this addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+ _this addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+ [_this] joinSilent _group;
+ /*
+ // set skills
+ {
+ _this setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+ } foreach _sniperskills;
+ */
+ // store AI type on the AI
+ _this setVariable ["SAR_AI_type",_ai_type,false];
+};
+
+// Establish rifleman unit type and skills
+_riflemenlist = call compile format ["SAR_soldier_%1_list", _type];
+//_riflemanskills = call compile format ["SAR_soldier_%1_skills", _type];
+
+for "_i" from 0 to (_riflemen - 1) do
+{
+ _this = _group createunit [_riflemenlist call BIS_fnc_selectRandom, [(_rndpos select 0) , _rndpos select 1, 0], [], 0.5, "NONE"];
+
+ _soldier_items = ["rifleman",_type] call SAR_unit_loadout_items;
+ _soldier_tools = ["rifleman",_type] call SAR_unit_loadout_tools;
+ _soldier_weapon_names = ["rifleman",_type] call SAR_unit_loadout_weapons;
+
+ [_this,_soldier_weapon_names,_soldier_items,_soldier_tools] call SAR_unit_loadout;
+
+ [_this] spawn SAR_AI_trace;
+ _this setIdentity "id_SAR_sold_man";
+ [_this] spawn SAR_AI_reammo;
+
+ _this addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+ _this addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+ [_this] joinSilent _group;
+/*
+ // set skills
+ {
+ _this setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+ } foreach _riflemanskills;
+ */
+ // store AI type on the AI
+ _this setVariable ["SAR_AI_type",_ai_type,false];
+};
+
+// initialize upsmon for the group
+_ups_para_list = [_leader,_patrol_area_name,'NOFOLLOW','AWARE','SPAWNED','DELETE:',SAR_DELETE_TIMEOUT];
+
+if (_respawn) then {
+ _ups_para_list pushBack ['RESPAWN'];
+ _ups_para_list pushBack ['RESPAWNTIME:'];
+ _ups_para_list pushBack [_respawn_time];
+};
+
+if(!SAR_AI_STEAL_VEHICLE) then {
+ _ups_para_list pushBack ['NOVEH'];
+};
+
+if(SAR_AI_disable_UPSMON_AI) then {
+ _ups_para_list pushBack ['NOAI'];
+};
+
+if(_action == "") then {_action = "PATROL";};
+
+switch (_action) do {
+
+ case "NOUPSMON":
+ {
+ };
+ case "FORTIFY":
+ {
+ _ups_para_list pushBack ['FORTIFY'];
+ _ups_para_list spawn UPSMON;
+ };
+ case "PATROL":
+ {
+ _ups_para_list spawn UPSMON;
+ };
+ case "AMBUSH":
+ {
+ _ups_para_list pushBack ['AMBUSH'];
+ _ups_para_list spawn UPSMON;
+ };
+ default
+ {
+ _ups_para_list spawn UPSMON;
+ };
+};
+
+if (SAR_HC) then {
+ {
+ _hcID = getPlayerUID _x;
+ if(_hcID select [0,2] isEqualTo 'HC')then {
+ _SAIS_HC = _group setGroupOwner (owner _x);
+ if (_SAIS_HC) then {
+ if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Moved group %1 to Headless Client %2",_group,_hcID];
+ };
+ } else {
+ if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Moving group %1 to Headless Client %2 has failed",_group,_hcID];
+ };
+ };
+ };
+ } forEach allPlayers;
+};
+
+if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Infantry group (%3) spawned in: %1 with action: %2 on side: %4",_patrol_area_name,_action,_group,(side _group)];
+};
+
+_group;
\ No newline at end of file
diff --git a/sarge/SAR_setup_AI_patrol_guards.sqf b/sarge/SAR_setup_AI_patrol_guards.sqf
new file mode 100644
index 0000000..52a8466
--- /dev/null
+++ b/sarge/SAR_setup_AI_patrol_guards.sqf
@@ -0,0 +1,267 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_sizeOfBase","_authorizedGateCodes","_authorizedUID","_flagPole","_leadername","_type","_patrol_area_name","_grouptype","_snipers","_riflemen","_action","_side","_leaderList","_riflemenlist","_sniperlist","_rndpos","_group","_leader","_cond","_respawn","_leader_weapon_names","_leader_items","_leader_tools","_soldier_weapon_names","_soldier_items","_soldier_tools","_sniper_weapon_names","_sniper_items","_sniper_tools","_leaderskills","_riflemanskills","_sniperskills","_ups_para_list","_respawn_time","_argc","_ai_type"];
+
+if (!isServer) exitWith {};
+
+diag_log "Sarge AI System: Territory gaurds are initializing now.";
+
+_argc = count _this;
+_flagPole = _this select 0;
+_patrol_area_name = _this select 1;
+_grouptype = _this select 2;
+_snipers = _this select 3;
+_riflemen = _this select 4;
+_action = tolower (_this select 5);
+_respawn = _this select 6;
+if (_argc > 7) then {
+ _respawn_time = _this select 7;
+} else {
+ _respawn_time = SAR_respawn_waittime;
+};
+
+_authorizedUID = _flagPole getVariable ["ExileTerritoryBuildRights", []];
+
+switch (_grouptype) do
+{
+ case 1: // military
+ {
+ _side = SAR_AI_friendly_side;
+ _type = "sold";
+ _ai_type = "AI Military";
+ };
+ case 2: // survivors
+ {
+ _side = SAR_AI_friendly_side;
+ _type = "surv";
+ _ai_type = "AI Survivor";
+ };
+ case 3: // bandits
+ {
+ _side = SAR_AI_unfriendly_side;
+ _type = "band";
+ _ai_type = "AI Bandit";
+ };
+};
+
+_leaderList = call compile format ["SAR_leader_%1_list",_type];
+/*
+_leaderskills = call compile format ["SAR_leader_%1_skills",_type];
+_riflemanskills = call compile format ["SAR_soldier_%1_skills",_type];
+_sniperskills = call compile format ["SAR_sniper_%1_skills",_type];
+ */
+_rndpos = [_patrol_area_name] call UPSMON_pos;
+
+_group = createGroup _side;
+
+_group setVariable ["SAR_protect",true,true];
+
+_sizeOfBase = _flagPole getVariable ["ExileTerritorySize",""];
+
+// create leader of the group
+_leader = _group createunit [_leaderList call BIS_fnc_selectRandom, [getPosATL _flagPole,1,_sizeOfBase,5,0,10,0] call BIS_fnc_findSafePos, [], 0.5, "NONE"];
+
+_leader_weapon_names = ["leader",_type] call SAR_unit_loadout_weapons;
+_leader_items = ["leader",_type] call SAR_unit_loadout_items;
+_leader_tools = ["leader",_type] call SAR_unit_loadout_tools;
+
+[_leader,_leader_weapon_names,_leader_items,_leader_tools] call SAR_unit_loadout;
+
+[_leader] spawn SAR_AI_base_trace;
+_leader setIdentity "id_SAR_sold_lead";
+[_leader] spawn SAR_AI_reammo;
+
+_leader addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+_leader addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+/*
+// TODO: Convert to Exile friendly action
+_cond="(side _this == west) && (side _target == resistance) && ('ItemBloodbag' in magazines _this)";
+[nil,_leader,rADDACTION,"Give me a blood transfusion!", "sarge\SAR_interact.sqf","",1,true,true,"",_cond] call RE;
+ */
+[_leader] joinSilent _group;
+/*
+// set skills of the leader
+{
+ _leader setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+} foreach _leaderskills;
+
+// define and store the leadername
+SAR_leader_number = SAR_leader_number + 1;
+_leadername = format["SAR_leader_%1",SAR_leader_number];
+
+_leader setVehicleVarname _leadername;
+_leader setVariable ["SAR_leader_name",_leadername,false];
+ */
+// store AI type on the AI
+_leader setVariable ["SAR_AI_type",_ai_type + " Leader",false];
+
+_leader setVariable ["SAR_FLAG_FRIENDLY", _authorizedUID, true];
+_leader setVariable ["ATTACK_ALL", false, true];
+/*
+// set behaviour & speedmode
+_leader setspeedmode "FULL";
+_leader setBehaviour "AWARE";
+
+// Lets broadcast this to be sure.
+//_leader Call Compile Format ["%1=_This ; PublicVariable ""%1""",_leadername];
+ */
+_sniperlist = call compile format ["SAR_sniper_%1_list",_type];
+
+// create crew
+for "_i" from 0 to (_snipers - 1) do
+{
+
+ _this = _group createunit [_sniperlist call BIS_fnc_selectRandom, [getPosATL _flagPole,1,_sizeOfBase,5,0,10,0] call BIS_fnc_findSafePos, [], 0.5, "NONE"];
+ sleep 0.5;
+
+ _sniper_weapon_names = ["sniper",_type] call SAR_unit_loadout_weapons;
+ _sniper_items = ["sniper",_type] call SAR_unit_loadout_items;
+ _sniper_tools = ["sniper",_type] call SAR_unit_loadout_tools;
+
+ [_this,_sniper_weapon_names,_sniper_items,_sniper_tools] call SAR_unit_loadout;
+
+ [_this] spawn SAR_AI_base_trace;
+ _this setIdentity "id_SAR";
+ [_this] spawn SAR_AI_reammo;
+
+ _this addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+ _this addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+ [_this] joinSilent _group;
+ /*
+ // set skills
+ {
+ _this setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+ } foreach _sniperskills;
+
+ //[nil,_this,rADDACTION,"Give me a blood transfusion!", "sarge\SAR_interact.sqf","",1,true,true,"",_cond] call RE;
+ */
+ // store AI type on the AI
+ _this setVariable ["SAR_AI_type",_ai_type,false];
+
+ _this setVariable ["SAR_FLAG_FRIENDLY", _authorizedUID, true];
+ _this setVariable ["ATTACK_ALL", false, true];
+
+ //Distinguish AI
+ _this setVariable ["Sarge",1,true];
+};
+
+_riflemenlist = call compile format ["SAR_soldier_%1_list",_type];
+
+for "_i" from 0 to (_riflemen - 1) do
+{
+ _this = _group createunit [_riflemenlist call BIS_fnc_selectRandom, [getPosATL _flagPole,1,_sizeOfBase,5,0,10,0] call BIS_fnc_findSafePos, [], 0.5, "NONE"];
+ sleep 0.5;
+
+ _soldier_items = ["rifleman",_type] call SAR_unit_loadout_items;
+ _soldier_tools = ["rifleman",_type] call SAR_unit_loadout_tools;
+ _soldier_weapon_names = ["rifleman",_type] call SAR_unit_loadout_weapons;
+
+ [_this,_soldier_weapon_names,_soldier_items,_soldier_tools] call SAR_unit_loadout;
+
+ [_this] spawn SAR_AI_base_trace;
+ _this setIdentity "id_SAR_sold_man";
+ [_this] spawn SAR_AI_reammo;
+
+ _this addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+ _this addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+ [_this] joinSilent _group;
+/*
+ // set skills
+ {
+ _this setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+ } foreach _riflemanskills;
+
+ //[nil,_this,rADDACTION,"Give me a blood transfusion!", "sarge\SAR_interact.sqf","",1,true,true,"",_cond] call RE;
+ */
+ // store AI type on the AI
+ _this setVariable ["SAR_AI_type",_ai_type,false];
+
+ //flagpole settings
+ _this setVariable ["SAR_FLAG_FRIENDLY", _authorizedUID, true];
+ _this setVariable ["ATTACK_ALL", false, true];
+
+ //Distinguish AI
+ _this setVariable ["Sarge",1,true];
+};
+
+// initialize upsmon for the group
+_ups_para_list = [_leader,_patrol_area_name,'NOFOLLOW','AWARE','SPAWNED','DELETE:',SAR_DELETE_TIMEOUT];
+
+if (_respawn) then {
+ _ups_para_list pushBack ['RESPAWN'];
+ _ups_para_list pushBack ['RESPAWN TIME:'];
+ _ups_para_list pushBack [_respawn_time];
+};
+
+if(!SAR_AI_STEAL_VEHICLE) then {
+ _ups_para_list pushBack ['NOVEH'];
+};
+
+if(SAR_AI_disable_UPSMON_AI) then {
+ _ups_para_list pushBack ['NOAI'];
+};
+
+if(_action == "") then {_action = "PATROL";};
+
+switch (_action) do {
+
+ case "NOUPSMON":
+ {
+ };
+ case "FORTIFY":
+ {
+ _ups_para_list pushBack ['FORTIFY'];
+ _ups_para_list spawn UPSMON;
+ };
+ case "PATROL":
+ {
+ _ups_para_list spawn UPSMON;
+ };
+ case "AMBUSH":
+ {
+ _ups_para_list pushBack ['AMBUSH'];
+ _ups_para_list spawn UPSMON;
+ };
+ default
+ {
+ _ups_para_list spawn UPSMON;
+ };
+};
+
+if (SAR_HC) then {
+ {
+ _hcID = getPlayerUID _x;
+ if(_hcID select [0,2] isEqualTo 'HC')then {
+ _SAIS_HC = _group setGroupOwner (owner _x);
+ if (_SAIS_HC) then {
+ if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Moved group %1 to Headless Client %2",_group,_hcID];
+ };
+ } else {
+ if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Moving group %1 to Headless Client %2 has failed",_group,_hcID];
+ };
+ };
+ };
+ } forEach allPlayers;
+};
+
+if(SAR_DEBUG) then {
+ diag_log format["Sarge's AI System: Territory group (%3) spawned in: %1 with action: %2 on side: %4",_patrol_area_name,_action,_group,(side _group)];
+};
+
+_group;
\ No newline at end of file
diff --git a/sarge/SAR_setup_AI_patrol_heli.sqf b/sarge/SAR_setup_AI_patrol_heli.sqf
new file mode 100644
index 0000000..648dd37
--- /dev/null
+++ b/sarge/SAR_setup_AI_patrol_heli.sqf
@@ -0,0 +1,218 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_ai_type","_riflemenlist","_side","_leader_group","_patrol_area_name","_rndpos","_groupheli","_heli","_leader","_man2heli","_man3heli","_argc","_grouptype","_respawn","_leader_weapon_names","_leader_items","_leader_tools","_soldier_weapon_names","_soldier_items","_soldier_tools","_leaderskills","_sniperskills","_ups_para_list","_type","_error","_respawn_time","_leadername"];
+
+if (!isServer) exitWith {};
+
+_patrol_area_name = _this select 0;
+_argc = count _this;
+_error = false;
+
+if (_argc > 1) then {
+ _grouptype = _this select 1;
+ switch (_grouptype) do
+ {
+ case 1:
+ {
+ _side = SAR_AI_friendly_side;
+ _type = "sold";
+ _ai_type = "AI Military";
+ _ai_id = "id_SAR_sold_man"
+ };
+ case 2:
+ {
+ _side = SAR_AI_friendly_side;
+ _type = "surv";
+ _ai_type = "AI Survivor";
+ _ai_id = "id_SAR_surv_lead"
+ };
+ case 3:
+ {
+ _side = SAR_AI_unfriendly_side;
+ _type = "band";
+ _ai_type = "AI Bandit";
+ _ai_id = "id_SAR_band"
+ };
+ };
+} else {
+ _error = true;
+};
+
+if (_argc > 2) then {
+ _respawn = _this select 2;
+} else {
+ _respawn = false;
+};
+
+if (_argc > 3) then {
+ _respawn_time = _this select 3;
+} else {
+ _respawn_time = SAR_respawn_waittime;
+};
+
+if (_error) exitWith {diag_log "SAR_AI: Heli patrol setup failed, wrong parameters passed!";};
+
+_leaderNPC = call compile format ["SAR_leader_%1_list",_type];
+_riflemenlist = call compile format ["SAR_soldier_%1_list",_type];
+/*
+_leaderskills = call compile format ["SAR_leader_%1_skills",_type];
+_sniperskills = call compile format ["SAR_sniper_%1_skills",_type];
+ */
+_leader_weapon_names = ["leader",_type] call SAR_unit_loadout_weapons;
+_leader_items = ["leader",_type] call SAR_unit_loadout_items;
+_leader_tools = ["leader",_type] call SAR_unit_loadout_tools;
+
+// get a random starting position, UPSMON will handle the rest
+_rndpos = [_patrol_area_name] call UPSMON_pos;
+
+_groupheli = createGroup _side;
+
+// protect group from being deleted by DayZ
+_groupheli setVariable ["SAR_protect",true,true];
+
+// create the vehicle
+_heli = createVehicle [(SAR_heli_type call BIS_fnc_selectRandom), [(_rndpos select 0) + 10, _rndpos select 1, 80], [], 0, "FLY"];
+_heli setFuel 1;
+_heli setVariable ["Sarge",1,true];
+_heli engineon true;
+_heli setVehicleAmmo 1;
+
+[_heli] joinSilent _groupheli;
+sleep 1;
+
+_leader = _groupheli createunit [_leaderNPC call BIS_fnc_selectRandom, [(_rndpos select 0) + 10, _rndpos select 1, 0], [], 0.5, "NONE"];
+
+[_leader,_leader_weapon_names,_leader_items,_leader_tools] call SAR_unit_loadout;
+
+[_leader] spawn SAR_AI_trace_veh;
+_leader setIdentity _ai_id;
+[_leader] spawn SAR_AI_reammo;
+
+_leader addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+_leader addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+_leader moveInDriver _heli;
+_leader assignAsDriver _heli;
+
+[_leader] joinSilent _groupheli;
+
+/*
+{
+ _leader setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+} foreach _leaderskills;
+
+SAR_leader_number = SAR_leader_number + 1;
+_leadername = format["SAR_leader_%1",SAR_leader_number];
+
+_leader setVehicleVarname _leadername;
+_leader setVariable ["SAR_leader_name",_leadername,false];
+ */
+// store AI type on the AI
+_leader setVariable ["SAR_AI_type",_ai_type pushBack " Leader",false];
+/*
+// set behaviour & speedmode
+_leader setspeedmode "FULL";
+_leader setBehaviour "AWARE";
+ */
+// Gunner 1
+_man2heli = _groupheli createunit [_riflemenlist call BIS_fnc_selectRandom, [(_rndpos select 0) - 30, _rndpos select 1, 0], [], 0.5, "NONE"];
+
+_soldier_weapon_names = ["rifleman",_type] call SAR_unit_loadout_weapons;
+_soldier_items = ["rifleman",_type] call SAR_unit_loadout_items;
+_soldier_tools = ["rifleman",_type] call SAR_unit_loadout_tools;
+[_man2heli,_soldier_weapon_names,_soldier_items,_soldier_tools] call SAR_unit_loadout;
+
+_man2heli moveInTurret [_heli,[0]];
+
+[_man2heli] spawn SAR_AI_trace_veh;
+_man2heli setIdentity _ai_id;
+[_man2heli] spawn SAR_AI_reammo;
+
+_man2heli addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+_man2heli addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+[_man2heli] joinSilent _groupheli;
+/*
+// set skills
+{
+ _man2heli setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+} foreach _sniperskills;
+ */
+// store AI type on the AI
+_man2heli setVariable ["SAR_AI_type",_ai_type,false];
+
+
+//Gunner 2
+_man3heli = _groupheli createunit [_riflemenlist call BIS_fnc_selectRandom, [_rndpos select 0, (_rndpos select 1) + 30, 0], [], 0.5, "NONE"];
+
+_soldier_weapon_names = ["rifleman",_type] call SAR_unit_loadout_weapons;
+_soldier_items = ["rifleman",_type] call SAR_unit_loadout_items;
+_soldier_tools = ["rifleman",_type] call SAR_unit_loadout_tools;
+
+[_man3heli,_soldier_weapon_names,_soldier_items,_soldier_tools] call SAR_unit_loadout;
+
+_man3heli moveInTurret [_heli,[1]];
+
+[_man3heli] spawn SAR_AI_trace_veh;
+_man3heli setIdentity _ai_id;
+[_man3heli] spawn SAR_AI_reammo;
+
+_man3heli addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+_man3heli addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+[_man3heli] joinSilent _groupheli;
+/*
+// set skills
+{
+ _man3heli setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+} foreach _sniperskills;
+ */
+// store AI type on the AI
+_man3heli setVariable ["SAR_AI_type",_ai_type,false];
+
+// initialize upsmon for the group
+_ups_para_list = [_leader,_patrol_area_name,'NOFOLLOW','AWARE','SPAWNED','DELETE:',SAR_DELETE_TIMEOUT];
+
+if (_respawn) then {
+ _ups_para_list pushBack ['RESPAWN'];
+ _ups_para_list pushBack ['RESPAWNTIME:'];
+ _ups_para_list pushBack [_respawn_time];
+};
+
+_ups_para_list spawn UPSMON;
+
+if (SAR_HC) then {
+ {
+ _hcID = getPlayerUID _x;
+ if(_hcID select [0,2] isEqualTo 'HC')then {
+ _SAIS_HC = _groupheli setGroupOwner (owner _x);
+ if (_SAIS_HC) then {
+ if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Moved group %1 to Headless Client %2",_groupheli,_hcID];
+ };
+ } else {
+ if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Moving group %1 to Headless Client %2 has failed",_groupheli,_hcID];
+ };
+ };
+ };
+ } forEach allPlayers;
+};
+
+if(SAR_DEBUG) then {
+ diag_log format["Sarge's AI System: AI Heli patrol (%2) spawned in: %1.",_patrol_area_name,_groupheli];
+};
+
+_groupheli;
\ No newline at end of file
diff --git a/sarge/SAR_setup_AI_patrol_land.sqf b/sarge/SAR_setup_AI_patrol_land.sqf
new file mode 100644
index 0000000..e35782b
--- /dev/null
+++ b/sarge/SAR_setup_AI_patrol_land.sqf
@@ -0,0 +1,276 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_riflemenlist","_side","_leader_group","_patrol_area_name","_rndpos","_argc","_grouptype","_respawn","_leader_weapon_names","_leader_items","_leader_tools","_soldier_weapon_names","_soldier_items","_soldier_tools","_leaderskills","_sniperskills","_ups_para_list","_sniperlist","_riflemanskills","_vehicles","_error","_vehicles_crews","_leader","_leadername","_snipers","_riflemen","_veh","_veh_setup","_forEachIndex","_groupvehicles","_sniper_weapon_names","_sniper_items","_sniper_tools","_leader_veh_crew","_type","_respawn_time","_ai_type"];
+
+if (!isServer) exitWith {};
+
+_patrol_area_name = _this select 0;
+
+_error = false;
+_argc = count _this;
+
+if (_argc > 1) then {
+
+ _grouptype = _this select 1;
+
+ switch (_grouptype) do
+ {
+ case 1:
+ {
+ _side = SAR_AI_friendly_side;
+ _type = "sold";
+ _ai_type = "AI Military";
+ _ai_id = "id_SAR_sold_man"
+ };
+ case 2:
+ {
+ _side = SAR_AI_friendly_side;
+ _type = "surv";
+ _ai_type = "AI Survivor";
+ _ai_id = "id_SAR_surv_lead"
+ };
+ case 3:
+ {
+ _side = SAR_AI_unfriendly_side;
+ _type = "band";
+ _ai_type = "AI Bandit";
+ _ai_id = "id_SAR_band"
+ };
+ };
+} else {
+ _error = true;
+};
+
+if (_argc > 2) then {
+ _vehicles = _this select 2;
+} else {
+ diag_log "SAR_AI: Error, you need to define vehicles for this land AI group";
+ _error = true;
+};
+
+if (_argc > 3) then {
+ _vehicles_crews = _this select 3;
+} else {
+ diag_log "SAR_AI: Error, you need to define crews for vehicles for this land AI group";
+ _error = true;
+};
+
+if (_argc > 4) then {
+ _respawn = _this select 4;
+} else {
+ _respawn = false;
+};
+
+if (_argc > 5) then {
+ _respawn_time = _this select 5;
+} else {
+ _respawn_time = SAR_respawn_waittime;
+};
+
+{
+ if (_x isKindof "Air" || _x isKindof "Ship") then {
+ diag_log "SAR_AI: Error, you need to define land vehicles only for this land AI group";
+ _error = true;
+ };
+} foreach _vehicles;
+
+if(_error) exitWith {diag_log "SAR_AI: Vehicle patrol setup failed, wrong parameters passed!";};
+
+/*
+_leaderskills = call compile format ["SAR_leader_%1_skills",_type];
+_riflemanskills = call compile format ["SAR_soldier_%1_skills",_type];
+_sniperskills = call compile format ["SAR_sniper_%1_skills",_type];
+ */
+// get a random starting position, UPSMON will handle the rest
+_rndpos = [_patrol_area_name] call UPSMON_pos;
+
+// create the group
+_groupvehicles = createGroup _side;
+
+// create the vehicle and assign crew
+{
+ // create the vehicle
+ _veh = createVehicle [_x, [_rndpos select 0, _rndpos select 1, 0], [], 0, "NONE"];
+ _veh setFuel 1;
+ //_veh setVariable ["Sarge",1,true];
+ _veh engineon true;
+
+ _veh addMPEventHandler ["HandleDamage", {_this spawn SAR_AI_VEH_HIT;_this select 2;}];
+
+ [_veh] joinSilent _groupvehicles;
+
+ // read the crew definition
+ _veh_setup = _vehicles_crews select _forEachIndex;
+
+ _leaderNPC = call compile format ["SAR_leader_%1_list",_type];
+
+ // vehicle is defined to carry the group leader
+ if((_veh_setup select 0) == 1) then {
+
+ _leader = _groupvehicles createunit [_leaderNPC call BIS_fnc_selectRandom, [(_rndpos select 0) + 10, _rndpos select 1, 0], [], 0.5, "NONE"];
+
+ _leader_weapon_names = ["leader",_type] call SAR_unit_loadout_weapons;
+ _leader_items = ["leader",_type] call SAR_unit_loadout_items;
+ _leader_tools = ["leader",_type] call SAR_unit_loadout_tools;
+
+ [_leader,_leader_weapon_names,_leader_items,_leader_tools] call SAR_unit_loadout;
+
+ [_leader] spawn SAR_AI_trace_veh;
+ _leader setIdentity _ai_id;
+ [_leader] spawn SAR_AI_reammo;
+
+ _leader addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+ _leader addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+ _leader moveInDriver _veh;
+ _leader assignAsDriver _veh;
+
+ [_leader] joinSilent _groupvehicles;
+ /*
+ // set skills of the leader
+ {
+ _leader setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+ } foreach _leaderskills;
+ */
+ // store AI type on the AI
+ _leader setVariable ["SAR_AI_type",_ai_type + " Leader",false];
+/*
+ SAR_leader_number = SAR_leader_number + 1;
+
+ _leadername = format["SAR_leader_%1",SAR_leader_number];
+
+ _leader setVehicleVarname _leadername;
+ _leader setVariable ["SAR_leader_name",_leadername,false];
+
+ // set behaviour & speedmode
+ _leader setspeedmode "FULL";
+ _leader setBehaviour "SAFE";
+ */
+ };
+
+ _snipers = _veh_setup select 1;
+ _sniperlist = call compile format ["SAR_sniper_%1_list",_type];
+
+ for "_i" from 0 to (_snipers - 1) do
+ {
+ _this = _groupvehicles createunit [_sniperlist call BIS_fnc_selectRandom, [(_rndpos select 0) - 30, _rndpos select 1, 0], [], 0.5, "FORM"];
+
+ _sniper_weapon_names = ["sniper",_type] call SAR_unit_loadout_weapons;
+ _sniper_items = ["sniper",_type] call SAR_unit_loadout_items;
+ _sniper_tools = ["sniper",_type] call SAR_unit_loadout_tools;
+
+ [_this,_sniper_weapon_names,_sniper_items,_sniper_tools] call SAR_unit_loadout;
+
+ [_this] spawn SAR_AI_trace_veh;
+ _this setIdentity _ai_id;
+ [_this] spawn SAR_AI_reammo;
+
+ _this addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+ _this addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+ [_this] joinSilent _groupvehicles;
+
+ if (isnull (assignedDriver _veh)) then {
+ _this moveInDriver _veh;
+ _this assignAsDriver _veh;
+ } else {
+ //move in vehicle
+ _this moveInCargo _veh;
+ _this assignAsCargo _veh;
+ };
+/*
+ // set skills
+ {
+ _this setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+ } foreach _sniperskills;
+ */
+ // store AI type on the AI
+ _this setVariable ["SAR_AI_type",_ai_type,false];
+ };
+
+ _riflemen = _veh_setup select 2;
+ _riflemenlist = call compile format ["SAR_soldier_%1_list",_type];
+
+ for "_i" from 0 to (_riflemen - 1) do
+ {
+ _this = _groupvehicles createunit [_riflemenlist call BIS_fnc_selectRandom, [(_rndpos select 0) + 30, _rndpos select 1, 0], [], 0.5, "FORM"];
+
+ _soldier_items = ["rifleman",_type] call SAR_unit_loadout_items;
+ _soldier_tools = ["rifleman",_type] call SAR_unit_loadout_tools;
+ _soldier_weapon_names = ["rifleman",_type] call SAR_unit_loadout_weapons;
+
+ [_this,_soldier_weapon_names,_soldier_items,_soldier_tools] call SAR_unit_loadout;
+
+ [_this] spawn SAR_AI_trace_veh;
+ _this setIdentity _ai_id;
+ [_this] spawn SAR_AI_reammo;
+
+ _this addMPEventHandler ["MPkilled", {Null = _this spawn SAR_AI_killed;}];
+ _this addMPEventHandler ["MPHit", {Null = _this spawn SAR_AI_hit;}];
+
+ [_this] joinSilent _groupvehicles;
+
+ // move in vehicle
+ _this moveInCargo _veh;
+ _this assignAsCargo _veh;
+/*
+ // set skills
+ {
+ _this setskill [_x select 0,(_x select 1 +(floor(random 2) * (_x select 2)))];
+ } foreach _riflemanskills;
+ */
+ // store AI type on the AI
+ _this setVariable ["SAR_AI_type",_ai_type,false];
+ };
+} foreach _vehicles;
+
+if (SAR_HC) then {
+ {
+ _hcID = getPlayerUID _x;
+ if(_hcID select [0,2] isEqualTo 'HC')then {
+ _SAIS_HC = _groupvehicles setGroupOwner (owner _x);
+ if (_SAIS_HC) then {
+ if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Moved group %1 to Headless Client %2",_groupvehicles,_hcID];
+ };
+ } else {
+ if (SAR_DEBUG) then {
+ diag_log format ["Sarge's AI System: Moving group %1 to Headless Client %2 has failed",_groupvehicles,_hcID];
+ };
+ };
+ };
+ } forEach allPlayers;
+};
+
+// initialize upsmon for the group
+_ups_para_list = [_leader,_patrol_area_name,'ONROAD','NOFOLLOW','SAFE','SPAWNED','DELETE:',SAR_DELETE_TIMEOUT];
+
+if (_respawn) then {
+ _ups_para_list pushBack ['RESPAWN'];
+ _ups_para_list pushBack ['RESPAWNTIME:'];
+ _ups_para_list pushBack [_respawn_time];
+};
+
+if(SAR_AI_disable_UPSMON_AI) then {
+ _ups_para_list pushBack ['NOAI'];
+};
+
+_ups_para_list spawn UPSMON;
+
+if(SAR_DEBUG) then {
+ diag_log format["Sarge's AI System: Land vehicle group (%2), side %3 spawned in %1 in a %4, side %5.",_patrol_area_name,_groupvehicles, _side, typeOf _veh, side _veh];
+};
+
+_groupvehicles;
\ No newline at end of file
diff --git a/sarge/SAR_trace_base_entities.sqf b/sarge/SAR_trace_base_entities.sqf
new file mode 100644
index 0000000..202b982
--- /dev/null
+++ b/sarge/SAR_trace_base_entities.sqf
@@ -0,0 +1,69 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_baseOwner","_attackAll","_friendlyPlayers","_ai","_entity_array"];
+
+if (isServer or !hasInterface) exitWith {}; // Do not execute on server or any headless client(s)
+
+_ai = _this select 0;
+
+_friendlyPlayers = _ai getVariable ["SAR_FLAG_FRIENDLY", []];
+_attackAll = _ai getVariable ["ATTACK_ALL", true];
+
+_baseOwner = 0;
+
+while {alive _ai || !isNull _ai} do {
+ _friendlyPlayers = _ai getVariable ["SAR_FLAG_FRIENDLY", []];
+ _attackAll = _ai getVariable ["ATTACK_ALL", false];
+ _entity_array = (getPosATL _ai) nearEntities [["CAManBase","Air","Car","Motorcycle","Tank"],SAR_DETECT_HOSTILE + 200];
+
+ if (SAR_EXTREME_DEBUG) then {
+ diag_log format ["Sarge AI System: Territory patrol gaurds ready. Friendly base UID array is: %1",_friendlyPlayers];
+ };
+
+ if (_attackAll) then {
+ {
+ if (isPlayer _x) then {
+ _baseOwner = 0;
+ if (_baseOwner == 0) then {
+ if ((getPlayerUID _x) in _friendlyPlayers) then {
+ _x addrating 50000;
+ _x setVariable ["BaseOwner", 1, true];
+ if (SAR_EXTREME_DEBUG) then {
+ diag_log format ["Sarge AI System: Rating has been adjusted for authorized player with UID %1",(getPlayerUID _x)];
+ };
+ } else {
+ _x addrating -50000;
+ if (SAR_EXTREME_DEBUG) then {
+ diag_log format ["Sarge AI System: Rating has been adjusted for unauthorized player with UID %1",(getPlayerUID _x)];
+ };
+ };
+ } else {
+ if (_baseOwner == 1 && rating _x < 50000) then {
+ _x addrating 50000;
+ };
+ };
+ } else {
+ _tFriendlyPlayers = _x getVariable ["SAR_FLAG_FRIENDLY", []];
+ _result = [_tFriendlyPlayers, _friendlyPlayers] call BIS_fnc_arrayCompare;
+ if (_result) then {
+ _x addrating 50000;
+ } else {
+ _x addrating -50000;
+ };
+ };
+ } forEach _entity_array;
+ };
+ sleep 5;
+};
diff --git a/sarge/SAR_trace_entities.sqf b/sarge/SAR_trace_entities.sqf
new file mode 100644
index 0000000..6a787ad
--- /dev/null
+++ b/sarge/SAR_trace_entities.sqf
@@ -0,0 +1,49 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_ai","_entity_array","_sleeptime","_detectrange"];
+
+if (isServer or !hasInterface) exitWith {}; // Do not execute on server or any headless client(s)
+
+_ai = _this select 0;
+
+_detectrange = SAR_DETECT_HOSTILE;
+_respectlimit = SAR_RESPECT_HOSTILE_LIMIT;
+_sleeptime = SAR_DETECT_INTERVAL;
+
+while {alive _ai} do {
+ _entity_array = (position _ai) nearEntities ["CAManBase",_detectrange];
+ {
+ if(vehicle _ai == _ai) then { // AI is not in a vehicle, so we trace Zeds
+ if (_x isKindof "civilclass") then {
+ if(rating _x > -10000) then {
+ _x addrating -10000;
+ if(SAR_EXTREME_DEBUG) then {
+ diag_log "SAR EXTREME DEBUG: Zombie rated down";
+ };
+ };
+ };
+ };
+ if(isPlayer _x && {vehicle _x == _x}) then { // only do this for players not in vehicles
+ _respect = _x getVariable ["ExileScore",0];
+ If (_respect < _respectlimit && {rating _x > -10000}) then {
+ if(SAR_EXTREME_DEBUG) then {
+ diag_log format["SAR EXTREME DEBUG: reducing rating (trace_entities) for player: %1", _x];
+ };
+ _x addrating -10000;
+ };
+ };
+ } forEach _entity_array;
+ sleep _sleeptime;
+};
diff --git a/sarge/SAR_trace_from_vehicle.sqf b/sarge/SAR_trace_from_vehicle.sqf
new file mode 100644
index 0000000..2b346b0
--- /dev/null
+++ b/sarge/SAR_trace_from_vehicle.sqf
@@ -0,0 +1,54 @@
+/*
+ # Original #
+ Sarge AI System 1.5
+ Created for Arma 2: DayZ Mod
+ Author: Sarge
+ https://github.com/Swiss-Sarge
+
+ # Fork #
+ Sarge AI System 2.0+
+ Modded for Arma 3: Exile Mod
+ Changes: Dango
+ http://www.hod-servers.com
+
+*/
+private ["_ai","_entity_array","_humanity","_humanitylimit","_sleeptime","_detectrange","_tracewhat","_player_rating","_clientmachine"];
+
+if (!isServer) exitWith {};
+
+_ai = _this select 0;
+_tracewhat = "CAManBase";
+
+_detectrange = SAR_DETECT_HOSTILE_FROM_VEHICLE;
+_respectlimit = SAR_RESPECT_HOSTILE_LIMIT;
+_sleeptime = SAR_DETECT_FROM_VEHICLE_INTERVAL;
+
+while {alive _ai} do {
+ _entity_array = (position _ai) nearEntities [_tracewhat, _detectrange];
+ {
+ if(isPlayer _x && {vehicle _x == _x}) then { // only do that for players that are not in a vehicle
+
+ _player_rating = rating _x;
+ _respect = _x getVariable ["ExileScore",0];
+ If (_respect < _respectlimit && {_player_rating > -10000}) then {
+
+ if(SAR_EXTREME_DEBUG) then {
+ diag_log format["SAR EXTREME DEBUG: reducing rating (trace_from_vehicle) for player: %1", _x];
+ };
+
+ //define global variable
+ adjustrating = [_x,(0 - (10000+_player_rating))];
+
+ // get the players machine ID
+ _clientmachine = owner _x;
+
+ // transmit the global variable to this client machine
+ _clientmachine publicVariableClient "adjustrating";
+
+ // reveal player to vehicle group
+ _ai reveal [_x,4];
+ };
+ };
+ } forEach _entity_array;
+ sleep _sleeptime;
+};
diff --git a/sarge/map_config/SAR_cfg_grid_altis.sqf b/sarge/map_config/SAR_cfg_grid_altis.sqf
new file mode 100644
index 0000000..9c023b2
--- /dev/null
+++ b/sarge/map_config/SAR_cfg_grid_altis.sqf
@@ -0,0 +1,33 @@
+// =========================================================================================================
+// SAR_AI - DayZ AI library
+// Version: 1.0.0
+// Author: Sarge (sarge@krumeich.ch)
+//
+// Wiki: to come
+// Forum: to come
+//
+// ---------------------------------------------------------------------------------------------------------
+// Required:
+// UPSMon
+// SHK_pos
+//
+// ---------------------------------------------------------------------------------------------------------
+// grid cfg file for Chernarus
+// last modified: 5.3.2013
+// ---------------------------------------------------------------------------------------------------------
+
+// x coordinate of the first, bottom left grid center point
+_startx=2500;
+
+
+// y coordinate of the first, bottom left grid center point
+_starty=8000;
+
+// gridsize x (how many single squares in the grid) for the x-axis
+_gridsize_x=14;
+
+// gridsize y (how many single squares in the grid) for the y-axis
+_gridsize_y=9;
+
+// distance from the center of one square of the grid to the border of that square. so overall size of a square in the grid is 2x gridwidth / 2x gridwidth
+_gridwidth = 1000;
diff --git a/sarge/map_config/SAR_cfg_grps_altis.sqf b/sarge/map_config/SAR_cfg_grps_altis.sqf
new file mode 100644
index 0000000..f726af4
--- /dev/null
+++ b/sarge/map_config/SAR_cfg_grps_altis.sqf
@@ -0,0 +1,326 @@
+/*
+IMPORTANT: The grid squares are named like : SAR_area_0_0
+
+where the first 0 is the x counter, and the second 0 the y counter.
+
+So to adress the bottom left square in the grid, you use SAR_area_0_0.
+The square above that one would be: SAR_area_0_1
+the square one to the right of the bottom left square is SAR_area_1_0
+
+You want to change the number arrays in the below lines:
+
+The order for these numbers is always [BANDIT, SURVIVOR, SOLDIER]
+
+Lets take an example for Chernarus
+
+// Kamenka, 0 bandit groups, 1 soldier groups, 2 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
+_check = [["max_grps","rnd_grps","max_p_grp"],[[0,1,2],[0,75,100],[0,4,3]],"SAR_area_0_0"] call SAR_AI_mon_upd;
+
+ [[0,1,2],[0,75,100],[0,4,3]]
+
+the first set of numbers : 0,1,2
+stands for
+0 bandit groups
+1 soldier group
+2 surivors groups
+thats the max that can spawn in this grid
+
+the second set of numbers : 0,75,100
+that means:
+0% probability to spawn bandit groups
+75% for soldiers
+100% for survivors
+
+the last set of numbers : 0,4,3
+thats the maximum number of ppl in the group (plus 1 leader)
+0 bandits
+max 4 (+1 leader) soldiers
+max 3 (+1 leader) survivors
+this number is randomized
+*/
+
+_type = _this select 0;
+
+// grid definition for the automatic spawn system
+if ((_type isEqualTo "dynamic") && SAR_dynamic_spawning) then {
+
+ diag_log format["SAR_AI: Dynamic spawning definition / adjustments started"];
+
+ // Blacklist using 0s
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_0_0"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_1_0"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_2_0"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_11_0"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_12_0"] call SAR_AI_mon_upd;
+
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_0_1"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_11_1"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_12_1"] call SAR_AI_mon_upd;
+
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_0_2"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_11_2"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_12_2"] call SAR_AI_mon_upd;
+
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_0_3"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_11_3"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_12_3"] call SAR_AI_mon_upd;
+
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_0_4"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_11_4"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_12_4"] call SAR_AI_mon_upd;
+
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_0_5"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_1_5"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_11_5"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_12_5"] call SAR_AI_mon_upd;
+
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_0_6"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_1_6"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_11_6"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_12_6"] call SAR_AI_mon_upd;
+
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_7_7"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_8_7"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_9_7"] call SAR_AI_mon_upd;
+
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_0_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_1_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_2_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_3_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_4_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_5_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_6_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_7_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_8_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_9_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_10_8"] call SAR_AI_mon_upd;
+ [["max_grps","rnd_grps","max_p_grp"],[[0,0,0],[0,0,0],[0,0,0]],"SAR_area_11_8"] call SAR_AI_mon_upd;
+
+ diag_log format["SAR_AI: Dynamic spawning definition / adjustments finished"];
+};
+
+if (_type isEqualTo "static") then {
+ // Definition of area markers for static spawns
+ diag_log format["SAR_AI: Static spawning area definition started"];
+
+ // soutcoast, heli patrol area
+ _this = createMarker ["SAR_marker_helipatrol_southcoast", [7997.2837, 2687.6707]];
+ _this setMarkerShape "RECTANGLE";
+ _this setMarkeralpha 0;
+ _this setMarkerType "Flag";
+ _this setMarkerBrush "Solid";
+ _this setMarkerSize [6500, 1200];
+ SAR_marker_helipatrol_southcoast = _this;
+
+ // eastcoast, heli patrol area
+ _this = createMarker ["SAR_marker_helipatrol_eastcoast", [13304.196, 8220.9795]];
+ _this setMarkerShape "RECTANGLE";
+ _this setMarkeralpha 0;
+ _this setMarkerType "Flag";
+ _this setMarkerBrush "Solid";
+ _this setMarkerSize [1200, 6000];
+ SAR_marker_helipatrol_eastcoast = _this;
+
+ // NWAF, heli patrol area
+ _this = createMarker ["SAR_marker_helipatrol_nwaf", [4525.3335, 10292.299]];
+ _this setMarkerShape "RECTANGLE";
+ _this setMarkeralpha 0;
+ _this setMarkerType "Flag";
+ _this setMarkerBrush "Solid";
+ _this setMarkerSize [1500, 500];
+ _this setMarkerDir 59.354115;
+ SAR_marker_helipatrol_nwaf = _this;
+
+ // NEAF, heli patrol area
+ _this = createMarker ["SAR_marker_helipatrol_neaf", [12034.16, 12725.376, 0]];
+ _this setMarkerShape "RECTANGLE";
+ _this setMarkeralpha 0;
+ _this setMarkerType "Flag";
+ _this setMarkerBrush "Solid";
+ _this setMarkerSize [1000, 600];
+ SAR_marker_helipatrol_neaf = _this;
+
+
+ _this = createMarker ["SAR_marker_DEBUG_veh", [11514.385,11679.752]];
+ _this setMarkerShape "RECTANGLE";
+ _this setMarkeralpha 0;
+ _this setMarkerType "Flag";
+ _this setMarkerBrush "Solid";
+ _this setMarkerSize [300, 1000];
+ _this setMarkerDir -19.085985;
+ SAR_marker_DEBUG_veh = _this;
+
+ _this = createMarker ["SAR_marker_DEBUG_devilscastle", [6913.47,11437.2,0.001]];
+ _this setMarkerShape "RECTANGLE";
+ _this setMarkeralpha 0;
+ _this setMarkerType "Flag";
+ _this setMarkerBrush "Solid";
+ _this setMarkerSize [10, 10];
+ SAR_marker_DEBUG_devilscastle = _this;
+
+ diag_log format["SAR_AI: Static spawning area definition finished"];
+ // ----------------------------------------------------------------------------------------
+ // End of area marker definition section
+ // ----------------------------------------------------------------------------------------
+
+
+ //---------------------------------------------------------------------------------
+ // Static, predefined heli patrol areas with configurable units
+ //---------------------------------------------------------------------------------
+ //
+ // format: [areamarker,type_of_group,(respawn),(respawntime)] call SAR_AI;
+ //
+ // areamarker : Name of an area, as defined in your area definitions (MUST NOT BE similar to SAR_area_ ! THIS IS IMPORTANT!)
+ // type_of_group : 1 = military, 2 = survivors, 3 = bandits
+ //
+ // respawn : true or false (optional)
+ // respawntime : time in secs until group respawns (optional)
+ // air_vehicle_type : classnema of the air vehicle you want to use
+ //
+ //
+ // Note: The crew will be automatically seized to man any available gun in the airplane / heli.
+ //
+ // Examples:
+ //
+ // A) military air group patrolling, respawning, respawn time = default configured time, using default randomized vehicles
+ //
+ // [SAR_marker_DEBUG,1,true] call SAR_AI_heli;
+ //
+ // B) bandit air group patrolling, not respawning,
+ //
+ // [SAR_marker_DEBUG,3] call SAR_AI_heli;
+ //
+ // C) survivor air group patrolling, respawning, respawn time = 120 seconds
+ //
+ // [SAR_marker_DEBUG,true,120] call SAR_AI_heli;
+ //
+ //---------------------------------------------------------------------------------
+ diag_log format["SAR_AI: Static Spawning for Helicopter patrols started"];
+
+ // define your static air patrols here
+
+ /* //Heli Patrol NWAF
+ [SAR_marker_DEBUG_veh,1,true] call SAR_AI_heli;
+
+ //Heli Patrol NEAF
+ [SAR_marker_DEBUG_veh,1,true] call SAR_AI_heli;
+
+ // Heli patrol south coast
+ [SAR_marker_DEBUG_veh,1,true] call SAR_AI_heli;
+ [SAR_marker_DEBUG_veh,1,true] call SAR_AI_heli;
+
+ // heli patrol east coast
+ [SAR_marker_DEBUG_veh,1,true] call SAR_AI_heli;
+ [SAR_marker_DEBUG_veh,1,true] call SAR_AI_heli;
+
+ // example war scenario in the northwest. Comment OUT after having had a look at it!
+ [SAR_marker_DEBUG_veh,1,true,30] call SAR_AI_heli;
+ [SAR_marker_DEBUG_veh,1,true,30] call SAR_AI_heli;
+ [SAR_marker_DEBUG_veh,3,true,30] call SAR_AI_heli;
+ [SAR_marker_DEBUG_veh,3,true,30] call SAR_AI_heli; */
+
+
+ diag_log format["SAR_AI: Static Spawning for Helicopter patrols finished"];
+ //---------------------------------------------------------------------------------
+ // Static, predefined infantry patrols in defined areas with configurable units
+ //---------------------------------------------------------------------------------
+ //
+ // format: [areamarker,type_of_group,number_of_snipers,number_of_riflemen,action_to_do,(respawn),(respawntime)] call SAR_AI;
+ //
+ // areamarker : Name of an area, as defined in your area definitions (MUST NOT BE similar to SAR_area_ ! THIS IS IMPORTANT!)
+ // type_of_group : 1 = military, 2 = survivors, 3 = bandits
+ // number_of_snipers : amount of snipers in the group
+ // number_of_riflemen : amount of riflemen in the group
+ //
+ // action_to_do : groupaction (optional, default is "patrol")
+ // possible values:
+ // "fortify" -> the group will search for nearby buildings and move in them. They will stay there until an enemy spotted, then they will chase him.
+ // "ambush" -> the group will look for a nearby road, and setup an ambush. They will not move until an enemy was spotted.
+ // "patrol" -> the group will patrol random waypoints in the area, and engage any enemy they see.
+ //
+ // respawn : true or false (optional)
+ // respawntime : time in secs until group respawns (optional)
+ //
+ // Examples:
+ //
+ // A) military group patrolling, with 1 leader and 1 rifleman, respawning, respawn time = default configured time
+ //
+ // [SAR_marker_DEBUG,1,0,1,"patrol",true] call SAR_AI;
+ //
+ // B) bandit group patrolling, with 1 leader, 2 snipers and 1 rifleman, respawning, respawn time = 30 seconds
+ //
+ // [SAR_marker_DEBUG,3,2,1,"patrol",true,30] call SAR_AI;
+ //
+ // C) survivor group fortifying, with 1 leader, 1 sniper and 3 riflemen, not respawning
+ //
+ // [SAR_marker_DEBUG,2,1,3,"fortify",false] call SAR_AI;
+ //
+ //---------------------------------------------------------------------------------
+ diag_log format["SAR_AI: Static Spawning for infantry patrols started"];
+
+ // define your static infantry patrols here
+
+ /* [SAR_marker_DEBUG_devilscastle,1,0,6,"fortify",true] call SAR_AI; */
+
+ // example war scenario in the northwest. Comment OUT after having had a look at it!
+ /* [SAR_marker_DEBUG_veh,1,0,9,"patrol",true] call SAR_AI;
+ [SAR_marker_DEBUG_veh,2,0,9,"patrol",true] call SAR_AI;
+ [SAR_marker_DEBUG_veh,3,0,9,"patrol",true] call SAR_AI;
+ [SAR_marker_DEBUG_veh,3,0,9,"patrol",true] call SAR_AI; */
+
+ diag_log format["SAR_AI: Static Spawning for infantry patrols finished"];
+ // -------------------------------------------------------------------------------------
+ //
+ // Static spawns for vehicle groups
+ //
+ // format: [areamarker,type_of_group,vehicle array,crew array,(respawn),(respawntime)] call SAR_AI_land;
+ //
+ //
+ // areamarker : Name of an area, as defined in your area definitions
+ // type_of_group : 1 = military, 2 = survivors, 3 = bandits
+ // vehicle array : e.g. ["car1"], MUST be enclosed by [], and MUST be valid vehicle classnames. multiple vehicles are possible, like this: ["car1","car1","car1"]
+ // crew array : e.g. [[1,2,3]] -> the first entry in the array element sets if the leader travels in that vehicle, the second is the number of snipers in the vehicle, the third is the number of riflemen.
+ // must match to the number of defined vehicles, so for the above example, you need: [[1,2,3],[0,1,2],[0,1,1]]
+ //
+ //
+ // respawn : true or false (optional)
+ // respawntime : time in secs until group respawns (optional)
+ //
+ //
+ //
+ // Examples:
+ //
+ // A) This will spawn an AI group with 1 vehicle(UAZ), and 3 AI in it
+ /*
+ [
+ SAR_marker_DEBUG_veh_1, // Name of the area that the vehicle patrol will spawn in
+ 1, // type of group
+ ["UAZ_Unarmed_TK_EP1"], // used vehicles
+ [[1,1,1]], // Vehicle initial crew
+ false // if this group should respawn or not
+ ] call SAR_AI_land;
+ */
+ //
+ // B) This will spawn an AI group with 1 vehicle, 3 AI in the UAZ, and this group will respawn after 60 seconds
+ /*
+ [
+ SAR_marker_DEBUG_veh_1, // Name of the area that the vehicle patrol will spawn in
+ 1, // type of group
+ ["UAZ_Unarmed_TK_EP1"], // used vehicle
+ [[1,1,1]], // Vehicle initial crews
+ true, // if this group should respawn or not
+ 60 // waittime until this group will respawn
+ ] call SAR_AI_land;
+ */
+ //
+ // -------------------------------------------------------------------------------------
+ diag_log format["SAR_AI: Static Spawning for vehicle patrols started"];
+
+ // define your static vehicle patrols here
+ /* [SAR_marker_DEBUG_veh,1,["SUV_Base"],[[1,1,1]],true,60] call SAR_AI_land;
+ [SAR_marker_DEBUG_veh,2,["SUV_Base"],[[1,1,1]],true,60] call SAR_AI_land;
+ [SAR_marker_DEBUG_veh,3,["SUV_Base"],[[1,1,1]],true,60] call SAR_AI_land; */
+
+ diag_log format["SAR_AI: Static Spawning for vehicle patrols finished"];
+ // ---- end of configuration area ----
+};
diff --git a/sarge/toggle_base_guards.sqf b/sarge/toggle_base_guards.sqf
new file mode 100644
index 0000000..66d9657
--- /dev/null
+++ b/sarge/toggle_base_guards.sqf
@@ -0,0 +1,44 @@
+private["_authorizedUID","_authorizedPUID","_flagRadius","_attackAllToggle","_tGuard","_isBaseGuard","_flag","_nearestGuards","_friendlyPlayers"];
+_flag = _this select 0;
+_authorizedUID = _flag getVariable ["ExileTerritoryBuildRights", []];
+_authorizedPUID = _authorizedUID select 0;
+_flagRadius = _flag getVariable ["ExileTerritorySize",""];;
+_isBaseGuard = false;
+if (!(isNull _flag)) then {
+ _nearestGuards = (getPosATL _flag) nearEntities [["AllVehicles","CAManBase"], _flagRadius + 100];
+} else {
+ _nearestGuards = (getPosATL player) nearEntities [["AllVehicles","CAManBase"], _flagRadius + 100];
+};
+if (count _nearestGuards > 0) then {
+ {
+ _tGuard = _x;
+ if (!(isPlayer _tGuard)) then {
+ _friendlyPlayers = _tGuard getVariable ["SAR_FLAG_FRIENDLY", []];
+ // If group has array
+ if (count _friendlyPlayers > 0) then {
+ {
+ if (_x in _friendlyPlayers) exitWith {
+ _isBaseGuard = true; // Guard is part of the base owners guards
+ };
+ } foreach _authorizedPUID;
+ // Toggle his attack mode
+ if (_isBaseGuard) then {
+ _attackAllToggle = _tGuard getVariable ["ATTACK_ALL", true];
+ if (_attackAllToggle) then {
+ _tGuard setVariable ["ATTACK_ALL", false, true];
+ cutText ["Guards will only attack those who attack it.\nGive them 15-20 seconds to receive orders.", "PLAIN DOWN"];
+ hintsilent "Guards will only attack those who attack it.\nGive them 15-20 seconds to receive orders.";
+ Breakout "exit";
+ } else {
+ _tGuard setVariable ["ATTACK_ALL", true, true];
+ cutText ["Guards will attack any players or npcs that is not tied to FlagPole.\nGive them 15-20 seconds to receive orders.", "PLAIN DOWN"];
+ hintsilent "Guards will attack any players or npcs that is not tied to FlagPole.\nGive them 15-20 seconds to receive orders.";
+ Breakout "exit";
+ };
+ };
+ };
+ };
+ } forEach _nearestGuards;
+ cutText ["No guards were found in the area", "PLAIN DOWN"];
+ hintsilent "No guards were found in the area";
+} else {cutText ["No guards in the area", "PLAIN DOWN"]; hintsilent "No guards were found in the area";};
diff --git a/scripts/Init_UPSMON.sqf b/scripts/Init_UPSMON.sqf
new file mode 100644
index 0000000..c120531
--- /dev/null
+++ b/scripts/Init_UPSMON.sqf
@@ -0,0 +1,214 @@
+// only run on server (including SP, MP, Dedicated) and Headless Client
+if (!isServer && hasInterface ) exitWith {};
+
+
+//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// These Variables should be checked and set as required, to make the mission runs properly.
+//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+//1=Enable or 0=disable debug. In debug could see a mark positioning de leader and another mark of the destination of movement, very useful for editing mission
+UPSMON_Debug = 0;
+
+//Max waiting is the maximum time patrol groups will wait when arrived to target for doing another target.
+UPSMON_maxwaiting = 10;
+
+// Set How many time a unit will search around a suspect position
+UPSMON_SRCHTIME = 90;
+
+// if you are spotted by AI group, how close the other AI group have to be to You , to be informed about your present position. over this, will lose target
+UPSMON_sharedist = 800; // org value 800 => increased for ArmA3 map sizes for less predictable missions..
+
+// knowsAbout 0.5 1.03 , 1.49 to add this enemy to "target list" (1-4) the higher number the less detect ability (original in 5.0.7 was 0.5)
+// it does not mean the AI will not shoot at you. This means: what must be knowsAbout you to UPSMON adds you to the list of targets (UPSMON list of target)
+UPSMON_knowsAboutEnemy = 1.5; // 5
+
+//////////////////////// MODULES ////////////////////////////////////////////
+//Enable it to send reinforcements, better done it in a trigger inside your mission.
+UPSMON_reinforcement = false; // ToDo Set to true if UPSMON reinf is going ot be used
+
+//Artillery support, better control if set in trigger
+UPSMON_ARTILLERY_EAST_FIRE = false; //set to true for doing east to fire //ToDo verify if needed
+UPSMON_ARTILLERY_WEST_FIRE = false; //set to true for doing west to fire
+UPSMON_ARTILLERY_GUER_FIRE = false; //set to true for doing resistance to fire
+
+// Can the group surrender?
+UPSMON_SURRENDER = false;
+
+// Chance of Surrender/100
+UPSMON_WEST_SURRENDER = 10;
+UPSMON_EAST_SURRENDER = 10;
+UPSMON_GUER_SURRENDER = 10;
+
+// Chance of Retreating/100
+UPSMON_WEST_RETREAT = 0;
+UPSMON_EAST_RETREAT = 0;
+UPSMON_GUER_RETREAT = 0;
+
+/// Civilian Hostility (Set to 0 if you want to disable the function)
+UPSMON_Ammountofhostility = 0;
+
+UPSMON_WEST_HM = 10;
+UPSMON_EAST_HM = 100;
+UPSMON_GUER_HM = 100;
+
+//////////////////////// ////////////////////////////////////////////
+
+//Height that heli will fly this input will be randomised in a 10%
+UPSMON_flyInHeight = 40; //80;
+
+//Max distance to target for doing para-drop, will be randomised between 0 and 100% of this value.
+UPSMON_paradropdist = 400;
+
+//Height that heli will fly if his mission is paradroping.
+UPSMON_paraflyinheight = 110;
+
+// Distance from destination for searching vehicles. (Search area is about 200m),
+// If your destination point is further than UPSMON_searchVehicledist, AI will try to find a vehicle to go there.
+UPSMON_searchVehicledist = 900; // 700, 900
+
+// How far opfor disembark from non armoured vehicle
+UPSMON_closeenoughV = 800;
+
+// how close unit has to be to target to generate a new one target or to enter stealth mode
+UPSMON_closeenough = 300; // ToDo investigate effect of decrease of this value to e.g. 50 // 300
+
+//Do the unit react to near dead bodies;
+UPSMON_deadBodiesReact = true;
+
+//Do unit can lay down mine (ambush and defense module)
+UPSMON_useMines = true;
+
+//Distance from ambush point
+UPSMON_ambushdist = 100;
+
+//% of chance to use smoke by team members when someone wounded or killed in the group in %(default 13 & 35).
+// set both to 0 -> to switch off this function
+UPSMON_USE_SMOKE = 20; // org 13: decreased while AI is popping smoke a bit too often
+
+//Allow Relax units during nightime to create fireplace
+UPSMON_Allowfireplace = false;
+
+//Allow Units to Rearm
+UPSMON_AllowRearm = false;
+
+//=============================================================================================================================
+//=============================== DO NOT TOUCH THESE VARIABLES ================================================================
+
+//UPSMON_Version
+UPSMON_Version = "UPSMON 6.0.9.5";
+//Misc Array
+UPSMON_Total = 0;
+UPSMON_Instances = 0;
+UPSMON_Exited = 0;
+UPSMON_AllWest = 0;
+UPSMON_AllEast = 0;
+UPSMON_AllRes = 0;
+upsmon_west_total = 0;
+upsmon_east_total = 0;
+UPSMON_GUER_Total = 0;
+//Reinforcement group array
+UPSMON_REINFORCEMENT_WEST_UNITS = [];
+UPSMON_REINFORCEMENT_EAST_UNITS = [];
+UPSMON_REINFORCEMENT_GUER_UNITS = [];
+//Artillery group array
+UPSMON_ARTILLERY_WEST_UNITS = [];
+UPSMON_ARTILLERY_EAST_UNITS = [];
+UPSMON_ARTILLERY_GUER_UNITS = [];
+//Transport group array
+UPSMON_TRANSPORT_WEST_UNITS = [];
+UPSMON_TRANSPORT_EAST_UNITS = [];
+UPSMON_TRANSPORT_GUER_UNITS = [];
+//Supply group array
+UPSMON_SUPPLY_WEST_UNITS = [];
+UPSMON_SUPPLY_EAST_UNITS = [];
+UPSMON_SUPPLY_GUER_UNITS = [];
+//Supply group array
+UPSMON_SUPPORT_WEST_UNITS = [];
+UPSMON_SUPPORT_EAST_UNITS = [];
+UPSMON_SUPPORT_GUER_UNITS = [];
+//tracked units array
+UPSMON_Trackednpcs = [];
+//Targetpos of groups
+UPSMON_targetsPos = [];
+//Units array by sides
+UPSMON_AllWest = [];
+UPSMON_AllEast = [];
+UPSMON_AllRes = [];
+//UPSMON Array groups
+UPSMON_NPCs = [];
+UPSMON_Civs = [];
+//Markers Array
+UPSMON_Markers = [];
+//Template Array
+UPSMON_TEMPLATES = [];
+//EH Killed Civ
+KILLED_CIV_COUNTER = [];
+
+UPSMON_FlareInTheAir = false;
+
+UPSMON_GOTKILL_ARRAY = [];
+UPSMON_GOTHIT_ARRAY = [];
+
+//===============================================================================
+//======================== =====================================
+
+// logic is needed to display rGlobalChat
+private ["_center","_group","_UPSMON_Minesclassname","_m"];
+_center = createCenter sideLogic; _group = createGroup _center;
+UPSMON_Logic_civkill = _group createUnit ["LOGIC", [1,1,1], [], 0, "NONE"];
+_group = nil;
+_center = nil;
+
+UPSMON = compile preProcessFileLineNumbers "Scripts\UPSMON.sqf";
+UPSMON_CreateGroup = compile preProcessFileLineNumbers "Scripts\UPSMON\UPSMON_CreateGroup.sqf";
+
+//Core
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\init.sqf";
+call compile preprocessFileLineNumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_init.sqf";
+//Params
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\target\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\cover\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\terrain\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\MP\init.sqf";
+//Modules
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\FORTIFY\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\AMBUSH\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\init.sqf";
+//Orders
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_PATROL\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_REINFORCEMENT\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_PATROLSRCH\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_FLANK\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_ASSAULT\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_DEFEND\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_RELAX\init.sqf";
+call compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_SUPPLY\init.sqf";
+
+[] execvm "Scripts\UPSMON\COMMON\CORE\fnc\UPSMON_TRACK.sqf";
+[] execvm "Scripts\UPSMON\UPSMON_MAINLOOP.sqf";
+[] execvm "Scripts\UPSMON\UPSMON_MAINLOOPCiv.sqf";
+
+//get all mines types
+_UPSMON_Minesclassname = [] call UPSMON_getminesclass;
+UPSMON_Minestype1 = _UPSMON_Minesclassname select 0; // ATmines
+UPSMON_Minestype2 = _UPSMON_Minesclassname select 1; // APmines
+
+
+_m = createMarker ["DummyUPSMONMarker",[0,0]];
+_m setmarkerColor "Colorblack";
+_m setMarkerShape "ELLIPSE";
+_m setMarkerSize [100,100];
+_m setMarkerBrush "Solid";
+_m setmarkerAlpha 0;
+
+
+
+//Initialization done
+UPSMON_INIT=1;
diff --git a/scripts/UPSMON.sqf b/scripts/UPSMON.sqf
new file mode 100644
index 0000000..0a816b1
--- /dev/null
+++ b/scripts/UPSMON.sqf
@@ -0,0 +1,391 @@
+// SERVER OR HEADLESS CLIENT CHECK
+//if (!isServer) exitWith {};
+if (!isServer && hasInterface ) exitWith {};
+
+if (isNil("UPSMON_INIT")) then {
+ UPSMON_INIT=0;
+};
+
+if (isNil("UPSMON_Night")) then {
+ UPSMON_Night = false;
+};
+
+waitUntil {UPSMON_INIT==1};
+
+if ((count _this)<2) exitWith
+{
+ If (UPSMON_Debug > 0) then {hint "UPSMON: Unit and marker name have to be defined!"};
+};
+
+//=================== Group ======================================
+//================================================================
+
+private ["_obj","_npc","_Ucthis","_grpid","_side","_grpname","_grp","_currpos","_behaviour","_formation","_speed","_members","_grptype","_areamarker","_centerpos","_centerX","_centerY","_areasize","_area","_rangeX","_rangeY","_grpmission","_spawned","_unitstypes","_respawn","_respawnpos","_respawntime","_respawndelay","_template","_issoldier","_hostility","_onroad","_shareinfos","_noveh","_fortify","_nowpType","_ambush","_radiorange","_initpos","_bldpositions","_positiontoambush","_wait","_time"];
+//group or leader
+_obj = _this select 0;
+
+If ((typename _obj != "OBJECT" && typename _obj != "GROUP") || IsNil "_obj" || IsNull _obj) exitwith
+{
+ If (UPSMON_Debug > 0) then {Hint "UPSMON: Unit not defined!"};
+};
+
+// Get leader
+_npc = [_obj] call UPSMON_SetLeaderGrp;
+
+If (!alive _npc) exitwith
+{
+ If (UPSMON_Debug > 0) then {Hint "UPSMON: Leader is dead!"};
+};
+
+// Get parameters
+_Ucthis = [_this] call UPSMON_GetParams;
+
+// give this group a unique index
+UPSMON_Instances = UPSMON_Instances + 1;
+_grpid = UPSMON_Instances;
+
+// group infos
+_side = side _npc;
+_grpname = format["%1_%2",_side,_grpid];
+_grp = group _npc;
+_currpos = GetposATL _npc;
+_behaviour = [_npc,_Ucthis] call UPSMON_GetGroupbehaviour;
+_formation = [_npc,_Ucthis] call UPSMON_GetGroupformation;
+_speed = [_npc,_Ucthis] call UPSMON_GetGroupspeed;
+_members = units _grp;
+
+// what type of "vehicle" is _npc ?
+_grptype = [_npc] call UPSMON_grptype;
+
+//Set EH
+[_members,_Ucthis,_grpid] spawn UPSMON_SetEventhandlers;
+
+_grp setVariable ["UPSMON_Ucthis", _Ucthis, false];
+_grp setVariable ["UPSMON_grpid", _grpid, false];
+_grp setvariable ["UPSMON_Origin",[_currpos,_behaviour,_speed,_formation,_members,_side]];
+
+// == get the name of area marker ==============================================
+_areamarker = _this select 1;
+if (typename _areamarker != "STRING" || isNil ("_areamarker")) exitWith
+{
+ hint "UPSMON: Area marker not defined.\n(Typo, or name not enclosed in quotation marks?)";
+};
+
+[_grp,_areamarker,_Ucthis] spawn UPSMON_SetMarkerArea;
+_grp setVariable ["UPSMON_Marker", _areamarker, false];
+
+// remember center position of area marker
+_centerpos = getMarkerPos _areamarker;
+_centerX = abs(_centerpos select 0);
+_centerY = abs(_centerpos select 1);
+_centerpos = [_centerX,_centerY];
+
+// X/Y range of target area
+_areasize = getMarkerSize _areamarker;
+_rangeX = _areasize select 0;
+_rangeY = _areasize select 1;
+_area = abs((_rangeX * _rangeY) ^ 0.5);
+
+// ===============================================
+
+if (UPSMON_Debug>0) then {player sidechat format["%1: New instance %2",_grpname,_grpid]};
+
+//To not run all at the same time we hope to have as many seconds as id's
+sleep (random 0.8);
+
+_grpmission = "PATROL";
+
+UPSMON_Total = UPSMON_Total + (count _members);
+
+
+if (UPSMON_Debug>0 && !alive _npc) then {player sidechat format["%1 There is no alive members %1 %2 %3",_grpid,typename _npc,typeof _npc, count units _npc]};
+
+///================= Optional parameters ===================================
+//Track Option
+If ("TRACK" in _UCthis || UPSMON_Debug > 0) then {UPSMON_Trackednpcs pushback _grp;};
+
+ // Spawn part ===================================
+ //spawned for squads created in runtime
+ _spawned= if ("SPAWNED" in _UCthis) then {true} else {false};
+ if (_spawned) then
+ {
+ //if (UPSMON_Debug>0) then {player sidechat format["%1: squad has been spawned, respawns %2",_grpid,_respawnmax]};
+ switch (side _grp) do
+ {
+ case west:
+ {
+ UPSMON_AllWest=UPSMON_AllWest + units _npc;
+ };
+ case east:
+ {
+ UPSMON_AllEast=UPSMON_AllEast + units _npc;
+ };
+ case resistance:
+ {
+ UPSMON_AllRes=UPSMON_AllRes + units _npc;
+ };
+ };
+
+ if (side _grp != civilian) then {call (compile format ["UPSMON_%1_Total = UPSMON_%1_Total + count (units _npc)",side _npc]);};
+ };
+ //
+ _unitstypes = [_members] call UPSMON_Getmemberstype;
+ _grp setvariable ["UPSMON_RESPAWNUNITS",_unitstypes];
+
+ //Respawn
+ _respawn = if ("RESPAWN" in _UCthis || "RESPAWN:" in _UCthis) then {true} else {false};
+ _respawnpos = [_Ucthis,_npc] call UPSMON_GetRespawnpos;
+ _respawntime = [_Ucthis] call UPSMON_GetRespawntime;
+ _respawndelay = [_Ucthis] call UPSMON_GetRespawndelay;
+
+ _grp setvariable ["UPSMON_RESPAWN",_respawn];
+ _grp setvariable ["UPSMON_RESPAWNPOS",_respawnpos];
+ _grp setvariable ["UPSMON_RESPAWNTIME",_respawntime];
+ _grp setvariable ["UPSMON_RESPAWNDELAY",_respawndelay];
+
+ //Template
+ _template = ["TEMPLATE:",0,_UCthis] call UPSMON_getArg;
+ [_spawned,_template,_side,_unitstypes] spawn UPSMON_SetTemplate;
+
+ //Clones
+ [_Ucthis,_unitstypes] spawn UPSMON_SetClones;
+ //===================================================
+
+// suppress fight behaviour
+_isSoldier = if ("NOAI" in _UCthis || _side == CIVILIAN) then {false} else {true};
+_grp setvariable ["UPSMON_NOAI",_isSoldier];
+
+If (_side == CIVILIAN) then
+{
+ _hostility = ["Hostility:",0,_UCthis] call UPSMON_getArg;
+ _grp setvariable ["UPSMON_GrpHostility",_hostility]
+};
+// create _targerpoint on the roads only (by this group)
+_onroad = if ("ONROAD" in _UCthis) then {true} else {false};
+_grp setvariable ["UPSMON_ONROAD",_onroad];
+
+// Group will not throw smoke
+if ("NOSMOKE" in _UCthis) then {_grp setvariable ["UPSMON_NOSMOKE",true]};
+
+//Do group share infos ?
+_shareinfos = If ("NOSHARE" in _UCthis) then {false} else {true};
+_grp setvariable ["UPSMON_Shareinfos",_shareinfos];
+
+// Group will not call artillery support
+if ("NOARTILLERY" in _UCthis) then {_grp setvariable ["UPSMON_NOARTILLERY",true];};
+
+
+// Squad will not leave his marker area
+if ("NOFOLLOW" in _UCthis) then {_grp setvariable ["UPSMON_NOFOLLOW",true];};
+
+// do not search for vehicles (unless in fight and combat vehicles)
+_noveh = if ("NOVEH" in _UCthis) then {1} else {0};
+_noveh = if ("NOVEH2" in _UCthis) then {2} else {_noveh}; // Ajout
+_grp setvariable ["UPSMON_NOVEH",_noveh];
+
+[_grp,_Ucthis] call UPSMON_SetRenfParam;
+
+//fortify group in near places
+_fortify= if ("FORTIFY" in _UCthis) then {true} else {false};
+_fortifyorig = if ("FORTIFY" in _UCthis) then {true} else {false};
+
+//TRANSPORT group
+if ("TRANSPORT" in _UCthis) then
+{
+ _grp setvariable ["UPSMON_TRANSPORT",true];
+ If (count (_grp getvariable ["UPSMON_Transportmission",[]]) == 0) then {_grp getvariable ["UPSMON_Transportmission",["WAITING",_currpos,Objnull]]};
+ If (_grptype == "IsAir") then {_h1 = createVehicle ["Land_HelipadEmpty_F",_currpos, [], 0, "NONE"];};
+ switch (_side) do {
+ case West: {
+ if (isnil "UPSMON_TRANSPORT_WEST_UNITS") then {UPSMON_TRANSPORT_WEST_UNITS = []};
+ UPSMON_TRANSPORT_WEST_UNITS pushback _grp;
+ };
+ case EAST: {
+ if (isnil "UPSMON_TRANSPORT_EAST_UNITS") then {UPSMON_TRANSPORT_EAST_UNITS = []};
+ UPSMON_TRANSPORT_EAST_UNITS pushback _grp;
+ };
+ case RESISTANCE: {
+ if (isnil "UPSMON_TRANSPORT_GUER_UNITS") then {UPSMON_TRANSPORT_GUER_UNITS = []};
+ UPSMON_TRANSPORT_GUER_UNITS pushback _grp;
+ };
+ };
+};
+
+//Patrol in building
+If ("LANDDROP" in _UCthis) then {_grp setvariable ["UPSMON_LANDDROP",true];};
+
+// don't make waypoints
+_nowpType = if ("NOWP" in _UCthis) then {1} else {0};
+_nowpType = if ("NOWP2" in _UCthis) then {2} else {_nowpType};
+_nowpType = if ("NOWP3" in _UCthis) then {3} else {_nowpType};
+_grp setvariable ["UPSMON_NOWP",_nowpType];
+
+//Ambush squad will no move until in combat or so close enemy
+_ambush= if (("AMBUSH" in _UCthis) || ("AMBUSHDIR:" in _UCthis) || ("AMBUSH2" in _UCthis) || ("AMBUSHDIR2:" in _UCthis)) then {true} else {false};
+
+// Range of AI radio so AI can call Arty or Reinforcement
+_RadioRange = ["RADIORANGE:",8000,_UCthis] call UPSMON_getArg; // ajout
+
+// set drop units at random positions
+_initpos = "ORIGINAL";
+if ("RANDOM" in _UCthis) then {_initpos = "RANDOM"};
+if ("RANDOMUP" in _UCthis) then {_initpos = "RANDOMUP"};
+if ("RANDOMDN" in _UCthis) then {_initpos = "RANDOMDN"};
+if ("RANDOMA" in _UCthis) then {_initpos = "RANDOMA"};
+// don't position groups or vehicles on rooftops
+if ((_initpos!="ORIGINAL") && (_grptype != "IsMan")) then {_initpos="RANDOM"};
+
+
+
+
+//=================================================================================
+//============== initialization Random / Ambush / Fortify ======================
+
+// make start position random
+if (_initpos!="ORIGINAL") then
+{
+ // find a random position (try a max of 20 positions)
+ _try=0;
+ _bldpositions = [];
+ _currPos = [];
+ _range = _rangeX;
+ if (_rangeX < _rangeY) then {_range = _rangeY};
+
+ if (_initpos=="RANDOM") then
+ {
+ while {_try<20} do
+ {
+ if (_grptype == "Isboat" || _grptype == "Isdiver") then
+ {
+ _currPos = [_areamarker,2,[],1] call UPSMON_pos;
+ }
+ else
+ {
+ _currPos=[_areamarker,0,[],1] call UPSMON_pos;
+ };
+
+ if (count _currPos > 0) then {_try=99};
+ _try=_try+1;
+ sleep .01;
+ };
+ }
+ else
+ {
+ //(_initpos=="RANDOMUP") || (_initpos=="RANDOMDN") || (_initpos=="RANDOMA")
+ _bldpositions = [[_centerX,_centerY,0],_initpos,_range,_areamarker,true] call UPSMON_GetNearestBuildings;
+ };
+
+ if (count _bldpositions == 0) then
+ {
+ if (count _currPos == 0) then {_currPos = getPosATL _npc;};
+ { //man
+ if (vehicle _x == _x) then
+ {
+ _targetpos = _currPos findEmptyPosition [0, 50];
+ sleep .05;
+ if (count _targetpos == 0) then {_targetpos = _currpos};
+ _x setpos _targetpos;
+ }
+ else
+ {
+ _targetpos = [];
+ If (_grptype != "Isboat") then {_targetpos = _currPos findEmptyPosition [10,50];};
+ sleep .05;
+ if (count _targetpos == 0) then {_targetpos = _currpos};
+ _x setPos _targetpos;
+ };
+ } foreach units _npc;
+ }
+ else
+ {
+ // put the unit on top of a building
+ _units = [units _npc] call UPSMON_getunits;
+ _grpmission = "STATIC";
+ If (_nowpType == 3) then
+ {
+ _unitsin = [_npc,["static"],_range,true,_areamarker] call UPSMON_GetIn_NearestVehicles;
+ _units = _units - _unitsin;
+ _grpmission = "FORTIFY";
+ [_grp,[0,0],"HOLD","LINE","LIMITED","AWARE","YELLOW",1] call UPSMON_DocreateWP;
+ }
+ else
+ {
+ _nowpType = 1; // don't move if on roof
+ };
+ If (count _units > 0) then {_units = [_units,_bldpositions] call UPSMON_SpawninBuildings;};
+ _currPos = getPosATL _npc;
+ };
+};
+
+_combatmode = "YELLOW";
+// AMBUSH
+If (_ambush) then
+{
+ [_grp,[0,0],"HOLD","LINE","LIMITED","STEALTH","BLUE",1] call UPSMON_DocreateWP;
+ _grp setvariable ["UPSMON_AMBUSHFIRE",false];
+
+ {
+ If !(isNil "bdetect_enable") then {_x setVariable ["bcombat_task", [ "", "mydummytask", 100, [] ] ];};
+ } foreach units _npc;
+ _positiontoambush = [_grp,_Ucthis,_currpos] call UPSMON_getAmbushpos;
+ _grpmission = "AMBUSH";
+ _grp setvariable ["UPSMON_Positiontoambush",_positiontoambush];
+ _wait = ["AMBUSHWAIT:",500,_UCthis] call UPSMON_getArg;
+ _time = time + _wait;
+ _grp setvariable ["UPSMON_AMBUSHWAIT",_time];
+ _linkdistance = ["LINKED:",0,_UCthis] call UPSMON_getArg;
+ _grp setvariable ["UPSMON_LINKED",_linkdistance];
+
+ _Behaviour = "STEALTH";
+ _combatmode = "BLUE";
+};
+
+if (_fortify) then
+{
+ [_grp,[0,0],"HOLD","LINE","LIMITED","AWARE","YELLOW",1] call UPSMON_DocreateWP;
+ _unitsin = [_npc,["static"],50,false,""] call UPSMON_GetIn_NearestVehicles;
+ _units = (units _grp) - _unitsin;
+ if ( count _units > 0 ) then
+ {
+ _units = [_npc,_units,70,9999] call UPSMON_moveNearestBuildings;
+ If (count _units > 0) then
+ {
+ _lookpos = [getposATL _npc,getdir _npc, 20] call UPSMON_GetPos2D;
+ [getposATL _npc,_lookpos,50,false,_units] call UPSMON_fnc_find_cover;
+ };
+
+ };
+ _grpmission = "FORTIFY";
+};
+
+If ("RELAX" in _Ucthis) then {_grpmission = "RELAX";_nowtype = 2;};
+
+If (_nowpType > 0 && _grpmission != "FORTIFY") then {_grpmission = "STATIC"};
+
+{_x allowfleeing 0;} foreach units _grp;
+_grp enableAttack false;
+_npc setbehaviour _Behaviour;
+_npc setspeedmode _speed;
+_grp setformation _formation;
+_grp setcombatmode _combatmode;
+
+// did the leader die?
+_npc = [_npc,_grp] call UPSMON_getleader;
+if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {};
+
+_grp setvariable ["UPSMON_GrpStatus","GREEN"];
+_grp setvariable ["UPSMON_GrpMission",_grpmission];
+_grp setvariable ["UPSMON_OrgGrpMission",_grpmission];
+_grp setvariable ["UPSMON_Lastinfos",[[0,0,0],[0,0,0]]];
+_grp setvariable ["UPSMON_NOWP",_nowpType];
+_grp setvariable ["UPSMON_Removegroup",false];
+
+//Assign the current group in the array of UPSMON Groups
+If (_side != civilian) then
+{
+ If (!(_grp in UPSMON_NPCs)) then {UPSMON_NPCs pushback _grp;};
+}
+else
+{
+ If (!(_grp in UPSMON_Civs)) then {UPSMON_Civs pushback _grp;};
+};
diff --git a/scripts/UPSMON/COMMON/Core/fnc/Nouveau document texte.txt b/scripts/UPSMON/COMMON/Core/fnc/Nouveau document texte.txt
new file mode 100644
index 0000000..e69de29
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_AddtoArray.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_AddtoArray.sqf
new file mode 100644
index 0000000..bd7ec3b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_AddtoArray.sqf
@@ -0,0 +1,111 @@
+/****************************************************************
+File:
+Author:
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_grp","_typeofgrp","_side"];
+
+_grp = _this select 0;
+_typeofgrp = _this select 1;
+
+_side = side _grp;
+
+
+switch (_side) do
+{
+ case "WEST":
+ {
+ If ("arti" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_ARTILLERY_WEST_UNITS)) then {UPSMON_ARTILLERY_WEST_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_ARTILLERY_WEST_UNITS) then {UPSMON_ARTILLERY_WEST_UNITS = UPSMON_ARTILLERY_WEST_UNITS - [_grp];};
+ };
+
+ If ("plane" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_SUPPORT_WEST_UNITS)) then {UPSMON_SUPPORT_WEST_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_SUPPORT_WEST_UNITS) then {UPSMON_SUPPORT_WEST_UNITS = UPSMON_SUPPORT_WEST_UNITS - [_grp];};
+ };
+
+ If ("supply" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_SUPPLY_WEST_UNITS)) then {UPSMON_SUPPLY_WEST_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_SUPPLY_WEST_UNITS) then {UPSMON_SUPPLY_WEST_UNITS = UPSMON_SUPPLY_WEST_UNITS - [_grp];};
+ };
+ };
+
+ case "EAST":
+ {
+ If ("arti" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_ARTILLERY_EAST_UNITS)) then {UPSMON_ARTILLERY_EAST_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_ARTILLERY_EAST_UNITS) then {UPSMON_ARTILLERY_EAST_UNITS = UPSMON_ARTILLERY_EAST_UNITS - [_grp];};
+ };
+
+ If ("plane" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_SUPPORT_EAST_UNITS)) then {UPSMON_SUPPORT_EAST_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_SUPPORT_EAST_UNITS) then {UPSMON_SUPPORT_EAST_UNITS = UPSMON_SUPPORT_EAST_UNITS - [_grp];};
+ };
+
+ If ("supply" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_SUPPLY_EAST_UNITS)) then {UPSMON_SUPPLY_EAST_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_SUPPLY_EAST_UNITS) then {UPSMON_SUPPLY_EAST_UNITS = UPSMON_SUPPLY_EAST_UNITS - [_grp];};
+ };
+ };
+
+ case "RESISTANCE":
+ {
+ If ("arti" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_ARTILLERY_GUER_UNITS)) then {UPSMON_ARTILLERY_GUER_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_ARTILLERY_GUER_UNITS) then {UPSMON_ARTILLERY_GUER_UNITS = UPSMON_ARTILLERY_GUER_UNITS - [_grp];};
+ };
+
+ If ("plane" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_SUPPORT_GUER_UNITS)) then {UPSMON_SUPPORT_GUER_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_SUPPORT_GUER_UNITS) then {UPSMON_SUPPORT_GUER_UNITS = UPSMON_SUPPORT_GUER_UNITS - [_grp];};
+ };
+
+ If ("supply" in _typeofgrp) then
+ {
+ If (!(_grp in UPSMON_SUPPLY_GUER_UNITS)) then {UPSMON_SUPPLY_GUER_UNITS pushback _grp;};
+ }
+ else
+ {
+ If (_grp in UPSMON_SUPPLY_GUER_UNITS) then {UPSMON_SUPPLY_GUER_UNITS = UPSMON_SUPPLY_GUER_UNITS - [_grp];};
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_CanSee.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_CanSee.sqf
new file mode 100644
index 0000000..dba0d02
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_CanSee.sqf
@@ -0,0 +1,40 @@
+//****************************************************************
+//File: UPSMON_CanSee.sqf
+//Author: Azroul13
+
+//Description:
+// Check if the unit not facing something that block his view
+//Parameter(s):
+// <--- Unit
+// <--- unit direction
+// <--- Height
+//Returns:
+// boolean
+//****************************************************************
+private ["_see","_infront","_uposASL","_opp","_adj","_hyp","_eyes","_obstruction","_angle"];
+
+_unit = _this select 0;
+_angle = _this select 1;
+_hyp = _this select 2;
+
+
+_eyes = eyepos _unit;
+
+_adj = _hyp * (cos _angle);
+_opp = sqrt ((_hyp*_hyp) - (_adj * _adj));
+
+_infront = if ((_angle) >= 180) then
+{
+ [(_eyes select 0) - _opp,(_eyes select 1) + _adj,(_eyes select 2)]
+}
+else
+{
+ [(_eyes select 0) + _opp,(_eyes select 1) + _adj,(_eyes select 2)]
+};
+
+_obstruction = (lineintersectswith [_eyes,_infront,_unit]) select 0;
+
+
+_see = if (isnil("_obstruction")) then {true} else {false};
+
+_see
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DeleteWP.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DeleteWP.sqf
new file mode 100644
index 0000000..b0bd2e6
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DeleteWP.sqf
@@ -0,0 +1,19 @@
+/****************************************************************
+File: UPSMON_DeleteWP.sqf
+Author: Azroul13
+
+Description:
+ delete waypoint for group
+Parameter(s):
+ <--- group
+Returns:
+ Nothing
+****************************************************************/
+private [];
+
+while {(count (waypoints _this)) > 0} do
+{
+ deleteWaypoint ((waypoints _this) select 0);
+ sleep 0.25;
+};
+
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DoaddWP.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DoaddWP.sqf
new file mode 100644
index 0000000..ecd0516
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DoaddWP.sqf
@@ -0,0 +1,38 @@
+/****************************************************************
+File: UPSMON_DocreateWP.sqf
+Author: Azroul13
+
+Description:
+ Create waypoint for group
+Parameter(s):
+ <--- group
+ <--- position of the waypoint
+ <--- type of the waypoint
+ <--- Formation of the waypoint
+ <--- Behaviour of the waypoint
+ <--- Combatmode of the waypoint
+ <--- Radius of the waypoint
+Returns:
+ Nothing
+****************************************************************/
+private ["_grp","_targetpos","_wptype","_wpformation","_speedmode","_wp1","_radius","_CombatMode"];
+
+_grp = _this select 0;
+_targetpos = _this select 1;
+_wptype = _this select 2;
+_wpformation = _this select 3;
+_speedmode = _this select 4;
+_Behaviour = _this select 5;
+_CombatMode = _this select 6;
+_radius = _this select 7;
+
+
+_wp1 = _grp addWaypoint [_targetPos,count (waypoints _grp)];
+_wp1 setWaypointPosition [_targetPos,count (waypoints _grp)];
+_wp1 setWaypointType _wptype;
+_wp1 setWaypointFormation _wpformation;
+_wp1 setWaypointSpeed _speedmode;
+_wp1 setwaypointbehaviour _Behaviour;
+_wp1 setwaypointCombatMode _CombatMode;
+_wp1 setWaypointLoiterRadius _radius;
+if (count _this > 8) then {sleep 3; (vehicle (leader _grp)) flyinheight (_this select 8)};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DocreateWP.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DocreateWP.sqf
new file mode 100644
index 0000000..7559dbd
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_DocreateWP.sqf
@@ -0,0 +1,41 @@
+/****************************************************************
+File: UPSMON_DocreateWP.sqf
+Author: Azroul13
+
+Description:
+ Create waypoint for group
+Parameter(s):
+ <--- group
+ <--- position of the waypoint
+ <--- type of the waypoint
+ <--- Formation of the waypoint
+ <--- Behaviour of the waypoint
+ <--- Combatmode of the waypoint
+ <--- Radius of the waypoint
+Returns:
+ Nothing
+****************************************************************/
+private ["_grp","_targetpos","_wptype","_wpformation","_speedmode","_wp1","_radius","_CombatMode"];
+
+_grp = _this select 0;
+_targetpos = _this select 1;
+_wptype = _this select 2;
+_wpformation = _this select 3;
+_speedmode = _this select 4;
+_Behaviour = _this select 5;
+_CombatMode = _this select 6;
+_radius = _this select 7;
+
+_grp call UPSMON_DeleteWP;
+
+_wp1 = _grp addWaypoint [_targetPos,0];
+_wp1 setWaypointPosition [_targetPos,0];
+_wp1 setWaypointType _wptype;
+_wp1 setWaypointFormation _wpformation;
+_wp1 setWaypointSpeed _speedmode;
+_wp1 setwaypointbehaviour _Behaviour;
+_wp1 setwaypointCombatMode _CombatMode;
+_wp1 setWaypointLoiterRadius _radius;
+//if (count _this > 8) then {sleep 3; (vehicle (leader _grp)) flyinheight (_this select 8)};
+
+_grp setCurrentWaypoint [_grp,(_wp1 select 1)];
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetCOS.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetCOS.sqf
new file mode 100644
index 0000000..21f98b5
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetCOS.sqf
@@ -0,0 +1,38 @@
+/****************************************************************
+File: UPSMON_GetSIN.sqf
+Author: MONSADA
+
+Description:
+ Función que devuelve el valor negativo o positivo del coseno en base a un angulo
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_dir","_cos"];
+
+_dir=_this select 0;
+if (isnil "_dir") exitWith {};
+if (_dir<90) then
+{
+ _cos=1;
+}
+else
+{
+ if (_dir<180) then
+ {
+ _cos=1;
+ }
+ else
+ {
+ if (_dir<270) then
+ {
+ _cos=-1;
+ }
+ else
+ {
+ _cos=-1;
+ };
+ };
+};
+_cos
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetOut.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetOut.sqf
new file mode 100644
index 0000000..ee8d3b2
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetOut.sqf
@@ -0,0 +1,29 @@
+/****************************************************************
+File: UPSMON_GetOut.sqf
+Author: MONSADA
+
+Description:
+ Function for order a unit to exit if no gunner
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_vehicle","_npc","_getout" ,"_gunner"];
+
+_npc = _this;
+_vehicle = vehicle (_npc);
+_gunner = objnull;
+_gunner = gunner _vehicle;
+
+sleep 0.05;
+if (!alive _npc) exitwith{};
+
+//If no leave the vehicle gunner
+if ( isnull _gunner || !alive _gunner || !canmove _gunner || (_gunner != _npc && driver _vehicle != _npc && commander _vehicle != _npc) ) then {
+ [_npc] allowGetIn false;
+ _npc spawn UPSMON_doGetOut;
+ unassignVehicle _npc;
+
+ //sleep 0.2;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetPos2D.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetPos2D.sqf
new file mode 100644
index 0000000..a6c56e5
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetPos2D.sqf
@@ -0,0 +1,29 @@
+/****************************************************************
+File: UPSMON_GetPos2D.sqf
+Author: MONSADA
+
+Description:
+ Función que devuelve una posición en 2D a partir de otra, una dirección y una distancia
+Parameter(s):
+ <--- Position
+ <--- Direction
+ <--- Distance
+Returns:
+ Position
+****************************************************************/
+private ["_pos","_dir","_dist","_cosU","_cosT","_relTX","_sinU","_sinT","_relTY","_newPos","_newPosX","_newPosY" ];
+
+_pos = _this select 0;
+_dir = _this select 1;
+_dist = _this select 2;
+
+if (isnil "_pos") exitWith {};
+_targetX = _pos select 0; _targetY = _pos select 1;
+
+//Calculamos posición
+_cosU = [_dir] call UPSMON_GetCOS; _sinU = [_dir] call UPSMON_GetSIN;
+_cosT = abs cos(_dir); _sinT = abs sin(_dir);
+_relTX = _sinT * _dist * _cosU; _relTY = _cosT * _dist * _sinU;
+_newPosX = _targetX + _relTX; _newPosY = _targetY + _relTY;
+_newPos = [_newPosX,_newPosY];
+_newPos;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetSIN.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetSIN.sqf
new file mode 100644
index 0000000..76a0461
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_GetSIN.sqf
@@ -0,0 +1,38 @@
+/****************************************************************
+File: UPSMON_GetSIN.sqf
+Author: MONSADA
+
+Description:
+ Función que devuelve el valor negativo o positivo del seno en base a un angulo
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_dir","_sin","_cos"];
+
+_dir=_this select 0;
+if (isnil "_dir") exitWith {};
+if (_dir<90) then
+{
+ _sin=1;
+}
+else
+{
+ if (_dir<180) then
+ {
+ _sin=-1;
+ }
+ else
+ {
+ if (_dir<270) then
+ {
+ _sin=-1;
+ }
+ else
+ {
+ _sin=1;
+ };
+ };
+};
+_sin
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Getnearestplayer.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Getnearestplayer.sqf
new file mode 100644
index 0000000..9420f3c
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Getnearestplayer.sqf
@@ -0,0 +1,34 @@
+/****************************************************************
+File: UPSMON_Getnearestplayer.sqf
+Author: Azroul13
+
+Description:
+ Get the nearest player near the position.
+Parameter(s):
+ <--- Position
+ <--- Distance
+Returns:
+ Nearest unit or ObjNull
+****************************************************************/
+private ["_position","_nearestdist","_height","_nearest","_haslos"];
+
+_position = _this select 0;
+_nearestdist = _this select 1;
+
+_nearest = objNull;
+
+{
+ if (isPlayer _x) then
+ {
+ If ((getposATL _x) select 2 <= 100) then
+ {
+ If ((getposATL _x vectorDistance [_position select 0,_position select 1,0]) <= _nearestdist) exitwith
+ {
+ _nearest=_x;
+ };
+ };
+ };
+} forEach playableUnits;
+
+//playableUnits;
+_nearest
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Getunitsincargo.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Getunitsincargo.sqf
new file mode 100644
index 0000000..e407829
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Getunitsincargo.sqf
@@ -0,0 +1,30 @@
+/****************************************************************
+File: UPSMON_Getunitsincargo.sqf
+Author: Azroul13
+
+Description:
+ Function for order a unit to exit if no gunner
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_vehicle","_unitsincargo","_crew"];
+
+_vehicle = _this select 0;
+
+_unitsincargo = [];
+
+_crew = crew _vehicle;
+
+{
+ If (alive _x) then
+ {
+ If () then
+ {
+ _unitsincargo pushback _x;
+ };
+ };
+} foreach _crew;
+
+_unitsincargo
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Haslos.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Haslos.sqf
new file mode 100644
index 0000000..bc86c0e
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Haslos.sqf
@@ -0,0 +1,49 @@
+/****************************************************************
+File: UPSMON_Haslos.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- unit
+ <--- Target
+ <--- Max distance the unit can see the target
+ <--- Field of view of the unit
+Returns:
+ Boolean
+****************************************************************/
+
+private ["_unit", "_target", "_range", "_fov","_eyeVector","_eyeDirection","_eyePosition","_targetPosition", "_inRange", "_result"];
+
+_unit = [_this,0] call BIS_fnc_param;
+_target = [_this,1] call BIS_fnc_param;
+_range = [_this,2,100,[0]] call BIS_fnc_param;
+_fov = [_this,3,130,[0]] call BIS_fnc_param;
+
+_result = false;
+_inRange = ((getposATL _unit) vectordistance (getposATL _target)) < _range;
+_eyeVector = eyeDirection _unit;
+_eyeDirection = ((_eyeVector select 0) atan2 (_eyeVector select 1));
+_eyePosition = eyePos _unit;
+_targetPosition = eyePos _target;
+
+If (!(_target iskindof "CAManBase")) then
+{
+ _targetPosition = aimpos _target;
+};
+
+if (_inRange) then
+{
+ if ([_eyePosition, _eyeDirection, _fov, _targetPosition] call BIS_fnc_inAngleSector) then
+ {
+ if (!lineIntersects[_eyePosition, _targetPosition, vehicle _unit, vehicle _target]) then
+ {
+ if (!terrainIntersectASL[_eyePosition, _targetPosition]) then
+ {
+ _result = true;
+ };
+ };
+ };
+};
+
+_result;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_LOS.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_LOS.sqf
new file mode 100644
index 0000000..78b7029
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_LOS.sqf
@@ -0,0 +1,32 @@
+/****************************************************************
+File: UPSMON_LOS.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- position to check
+ <--- Target position
+Returns:
+ Boolean
+****************************************************************/
+
+private ["_poso","_posd","_los_ok"];
+
+_poso = _this select 0;
+_posd = _this select 1;
+
+_poso = [_poso select 0, _poso select 1, (getTerrainHeightASL [_poso select 0, _poso select 1]) +1];
+_posd = [_posd select 0, _posd select 1, (getTerrainHeightASL [_posd select 0, _posd select 1]) +1];
+
+_los_ok = false;
+If (!terrainIntersectASL [_poso,_posd]) then
+{
+ //lineIntersects [_poso, _posd]
+ If (count (lineintersectsobjs [_poso,_posd,objnull,objnull,false]) == 0) then
+ {
+ _los_ok = true;
+ };
+};
+
+_los_ok;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Nighttime.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Nighttime.sqf
new file mode 100644
index 0000000..e7100ec
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Nighttime.sqf
@@ -0,0 +1,24 @@
+/****************************************************************
+File: UPSMON_timeloop.sqf
+Author: CarlGustav
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+
+private ["_lat","_day","_hour","_sunangle","_Night"];
+
+_Night = false;
+_lat = -1 * getNumber(configFile >> "CfgWorlds" >> worldName >> "latitude");
+_day = 360 * (dateToNumber date);
+_hour = (daytime / 24) * 360;
+_sunangle = ((12 * cos(_day) - 78) * cos(_lat) * cos(_hour)) - (24 * sin(_lat) * cos(_day));
+
+If (_sunangle < 0) then {_Night = true;};
+If (_sunangle > 0) then {_Night = False;};
+
+_Night;
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Nowp.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Nowp.sqf
new file mode 100644
index 0000000..da851e6
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Nowp.sqf
@@ -0,0 +1,62 @@
+/****************************************************************
+File: UPSMON_Nowp.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+
+private ["_grp","_target","_supstatus","_nowp"];
+
+_grp = _this select 0;
+_target = _this select 1;
+_supstatus = _this select 2;
+
+_nowp = true;
+
+If (_grp getvariable ["UPSMON_NOWP",0] == 0) then
+{
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "AMBUSH") then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "FORTIFY") then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "RETREAT") then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "SURRENDER") then
+ {
+ _nowp = false;
+ };
+ }
+ };
+ };
+}
+else
+{
+ switch (_grp getvariable ["UPSMON_NOWP",0]) do
+ {
+ case 1:
+ {
+ If (!IsNull _target) then
+ {
+ _nowp = false;
+ };
+ };
+ case 2:
+ {
+ If (_supstatus == "INCAPACITED") then
+ {
+ _nowp = false;
+ };
+ };
+ case 3:
+ {
+ //Always Nowp = true
+ };
+ };
+};
+
+_nowp
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Replace.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Replace.sqf
new file mode 100644
index 0000000..ee8480e
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_Replace.sqf
@@ -0,0 +1,37 @@
+/****************************************************************
+File: UPSMON_Replace.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_str","_old","_new","_out","_tmp","_jm","_la","_lo","_ln","_i"];
+
+_str=_this select 0;
+_arr=toArray(_str);
+_la=count _arr;
+_old=_this select 1;
+_new=_this select 2;
+_na=[_new] call UPSMON_StrToArray;
+_lo=[_old] call UPSMON_StrLen;
+_ln=[_new] call UPSMON_StrLen;
+_out="";
+for "_i" from 0 to (count _arr)-1 do {
+ _tmp="";
+ if (_i <= _la-_lo) then {
+ for "_j" from _i to (_i+_lo-1) do {
+ _tmp=_tmp + toString([_arr select _j]);
+ };
+ };
+ if (_tmp==_old) then {
+ _out=_out+_new;
+ _i=_i+_lo-1;
+ } else {
+ _out=_out+toString([_arr select _i]);
+ };
+};
+_out
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHFIREDNEAR.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHFIREDNEAR.sqf
new file mode 100644
index 0000000..a77fd0e
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHFIREDNEAR.sqf
@@ -0,0 +1,24 @@
+/****************************************************************
+File: UPSMON_SN_EHFIREDNEAR.sqf
+Author: Rafalsky
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_unit","_shooter","_dist"];
+
+_unit = _this select 0;
+_shooter = _this select 1;
+_dist = _this select 2;
+
+If (alive _unit) then
+{
+ If (!(_unit getvariable ["UPSMON_Civfleeing",false])) then
+ {
+ ["FLEE",_unit,_shooter,_dist] spawn UPSMON_Civaction;
+ };
+};
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHHIT.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHHIT.sqf
new file mode 100644
index 0000000..b82cd2f
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHHIT.sqf
@@ -0,0 +1,24 @@
+/****************************************************************
+File: UPSMON_SN_EHHIT.sqf
+Author: Rafalsky
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_unit","_shooter","_grpId"];
+_unit = _this select 0;
+_shooter = _this select 1;
+_grp = group _unit;
+
+if (!(_unit in UPSMON_GOTHIT_ARRAY)) then
+{
+ if (side _unit != side _shooter) then
+ {
+ UPSMON_GOTHIT_ARRAY pushback _unit;
+ if (UPSMON_Debug > 0) then {player globalchat format["UNIT: %1, SHOOTER :%2 %3",_unit,_shooter,side _shooter]};
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHKILLED.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHKILLED.sqf
new file mode 100644
index 0000000..2cb5819
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHKILLED.sqf
@@ -0,0 +1,40 @@
+/****************************************************************
+File: UPSMON_SN_EHHIT.sqf
+Author: Rafalsky
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_unit","_shooter","_grpId"];
+_unit = _this select 0;
+_shooter = _this select 1;
+_grp = group _unit;
+
+
+if (!(_unit in UPSMON_GOTKILL_ARRAY)) then
+{
+ if (side _unit != side _shooter) then
+ {
+ _alliednear = false;
+
+ {
+ if (alive _x) then
+ {
+ if (getposATL _unit vectordistance getposATL _x <= 30) exitwith
+ {
+ _alliednear = true;
+ };
+ };
+ } foreach units _grp;
+
+ If (_alliednear) then
+ {
+ UPSMON_GOTKILL_ARRAY pushback _unit;
+ //if (UPSMON_Debug > 0) then {player globalchat format["UNIT: %1, SHOOTER :%2 %3",_unit,_shooter,side _shooter]};
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHKILLEDCIV.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHKILLEDCIV.sqf
new file mode 100644
index 0000000..5af50c1
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_SN_EHKILLEDCIV.sqf
@@ -0,0 +1,51 @@
+/****************************************************************
+File: R_SN_EHKILLEDCIV.sqf
+Author: Rafalsky
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_killer","_side"];
+
+_killer = _this select 1;
+
+//only if player killed a civilian
+if (isPlayer _killer) then
+{
+ KILLED_CIV_COUNTER set [0,(KILLED_CIV_COUNTER select 0) + 1];
+
+ // if (UPSMON_Debug > 0) then {player globalchat format["KILLER: %1, %2", side _killer,KILLED_CIV_COUNTER ]};
+ switch (side _killer) do
+ {
+ case west:
+ {
+ KILLED_CIV_COUNTER set [1,(KILLED_CIV_COUNTER select 1) + 1];
+ UPSMON_WEST_HM = UPSMON_WEST_HM - UPSMON_Ammountofhostility;
+ };
+
+ case east:
+ {
+ KILLED_CIV_COUNTER set [2,(KILLED_CIV_COUNTER select 2) + 1];
+ UPSMON_EAST_HM = UPSMON_EAST_HM - UPSMON_Ammountofhostility;
+ };
+
+ case resistance:
+ {
+ KILLED_CIV_COUNTER set [3,(KILLED_CIV_COUNTER select 3) + 1];
+ UPSMON_GUER_HM = UPSMON_GUER_HM - UPSMON_Ammountofhostility;
+ };
+ };
+
+ KILLED_CIV_COUNTER set [4,_killer];
+
+ //if (UPSMON_Debug > 0) then {player globalchat format["KILLER: %1", side _killer ]};
+ if (UPSMON_Debug > 0) then {player globalchat format["KILLED_CIV_COUNTER: %1",KILLED_CIV_COUNTER]};
+ if (R_WHO_IS_CIV_KILLER_INFO > 0) then
+ {
+ call compile format ["[{UPSMON_Logic_civkill globalChat ""A CIVILIAN WAS KILLED BY %1"";},""BIS_fnc_spawn""] call BIS_fnc_MP;",name _killer];
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrInStr.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrInStr.sqf
new file mode 100644
index 0000000..245c303
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrInStr.sqf
@@ -0,0 +1,16 @@
+/****************************************************************
+File: UPSMON_StrInStr.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_out"];
+
+_in=_this select 0;
+_out=if (([_this select 0,_this select 1] call UPSMON_StrIndex)==-1) then {false} else {true};
+_out
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrIndex.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrIndex.sqf
new file mode 100644
index 0000000..4844118
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrIndex.sqf
@@ -0,0 +1,31 @@
+/****************************************************************
+File: UPSMON_StrIndex.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_hay","_ndl","_lh","_ln","_arr","_tmp","_i","_j","_out"];
+
+_hay=_this select 0;
+_ndl=_this select 1;
+_out=-1;
+_i=0;
+if (_hay == _ndl) exitWith {0};
+_lh=[_hay] call UPSMON_StrLen;
+_ln=[_ndl] call UPSMON_StrLen;
+if (_lh < _ln) exitWith {-1};
+_arr=[_hay] call UPSMON_StrToArray;
+for "_i" from 0 to (_lh-_ln) do
+{
+ _tmp="";
+ for "_j" from _i to (_i+_ln-1) do {
+ _tmp=_tmp + (_arr select _j);
+ };
+ if (_tmp==_ndl) exitWith {_out=_i};
+};
+_out
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrLen.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrLen.sqf
new file mode 100644
index 0000000..9d807b5
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrLen.sqf
@@ -0,0 +1,17 @@
+/****************************************************************
+File: UPSMON_StrLen.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_in","_arr","_len"];
+
+_in=_this select 0;
+_arr=[_in] call UPSMON_StrToArray;
+_len=count (_arr);
+_len
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrToArray.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrToArray.sqf
new file mode 100644
index 0000000..4123b9d
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_StrToArray.sqf
@@ -0,0 +1,20 @@
+/****************************************************************
+File: UPSMON_StrToArray.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_in","_i","_arr","_out"];
+
+_in=_this select 0;
+_arr = toArray(_in);
+_out=[];
+for "_i" from 0 to (count _arr)-1 do {
+ _out=_out+[toString([_arr select _i])];
+};
+_out
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_TRACK.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_TRACK.sqf
new file mode 100644
index 0000000..6066d34
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_TRACK.sqf
@@ -0,0 +1,107 @@
+/****************************************************************
+File: UPSMON_TRACK.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_grpid","_leader","_pos","_rankshort","_lastname","_wppos","_markercolor","_grptype","_drawicon","_text","_trackername","_destname"];
+
+
+While {true} do
+{
+ {
+ If (!IsNull _x) then
+ {
+ If (alive (leader _x)) then
+ {
+ _grpid = _x getvariable ["UPSMON_grpid",0];
+ _leader = leader _x;
+ _pos = getposATL _leader;
+ _rankshort = [rank _leader,"displayNameShort"] call BIS_fnc_rankparams;
+ _lastname = name _leader;
+ _units = (units _x) - [_leader];
+
+ _wppos = waypointPosition [_x,count(waypoints _x)-1];
+
+ _markercolor = switch (side _leader) do {
+ case west: {"ColorBlue"};
+ case east: {"ColorRed"};
+ case resistance: {"ColorGreen"};
+ default {"ColorBlack"};
+ };
+
+ _grptype = [_leader] call UPSMON_grptype;
+ _drawicon = "b_inf";
+ If (_grptype == "Iscar") then {_drawicon = "b_motor_inf"};
+ If (_grptype == "IsAir") then {_drawicon = "b_plane";};
+ If (_grptype == "Isboat") then {_drawicon = "b_naval";};
+
+ _text = format ["%1. %2 - Grpcount: %3 - Mission: %4 Status: %5 - Target: %6",_rankshort, _lastname,count units _x,_x getvariable ["UPSMON_Grpmission","PATROL"],_x getvariable ["UPSMON_Grpstatus","GREEN"],_x getvariable ["UPSMON_GrpTarget",ObjNull]];
+
+ _trackername = format["trk_%1",_grpid];
+
+ if (getMarkerColor _trackername == "") then
+ {
+ _markerlead = createMarker [_trackername,[0,0]];
+ };
+ _trackername setMarkerShape "ICON";
+ _trackername setMarkerType _drawicon;
+ _trackername setmarkerpos _pos;
+ _trackername setmarkercolor _markercolor;
+ _trackername setMarkerText _text;
+
+ If (count(waypoints _x) != 0) then
+ {
+ _destname = format["dest_%1",_grpid];
+ _wptext = format ["%1. %2",_rankshort, _lastname];
+ if (getMarkerColor _destname == "") then
+ {
+ _markerobj = createMarker[_destname,[0,0]];
+ };
+ _destname setMarkerShape "ICON";
+ _destname setMarkerType "mil_objective";
+ _destname setmarkerpos _wppos;
+ _destname setmarkercolor _markercolor;
+ _destname setMarkerText _wptext;
+ };
+
+ If (count _units > 0) then
+ {
+ _i = 0;
+ {
+ _i = _i + 1;
+ _trackerunit = format["trk_%1_%2",_grpid,_i];
+ _unit = _x;
+ If (alive _unit) then
+ {
+ _pos2 = getposATL _unit;
+ if (getMarkerColor _trackerunit == "") then
+ {
+ _markerunit = createMarker [_trackerunit,[0,0]];
+ };
+ _trackerunit setMarkerShape "ICON";
+ _trackerunit setMarkerType "mil_triangle";
+ _trackerunit setmarkerpos _pos2;
+ _trackerunit setmarkercolor _markercolor;
+ _trackerunit setmarkerdir (getdir _unit);
+ }
+ else
+ {
+ if (getMarkerColor _trackerunit == "") then
+ {
+ Deletemarker _trackerunit;
+ };
+ };
+ } foreach _units;
+ };
+ };
+ };
+ } foreach UPSMON_Trackednpcs;
+
+ sleep 0.5;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_TRACK2.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_TRACK2.sqf
new file mode 100644
index 0000000..4a5ac9c
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_TRACK2.sqf
@@ -0,0 +1,132 @@
+/****************************************************************
+File: UPSMON_TRACK.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_grp"];
+
+
+_grp = _this select 0;
+If !(_grp in UPSMON_Trackednpcs) then {UPSMON_Trackednpcs set [count UPSMON_Trackednpcs,_grp];};
+_eh = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler
+["Draw",
+'
+ {
+ If (!IsNull _x) then
+ {
+ if (count units _x > 0) then
+ {
+ _leader = leader _x;
+ _rankshort = [rank _leader,"displayNameShort"] call BIS_fnc_rankparams;
+ _lastname = name _leader;
+ _scale = (sizeof typeof _leader) / 30;
+ _units = (units _x) - [_leader];
+ _colorblufor = [(profilenamespace getvariable ["Map_BLUFOR_R",0]),(profilenamespace getvariable ["Map_BLUFOR_G",1]),(profilenamespace getvariable ["Map_BLUFOR_B",1]),(profilenamespace getvariable ["Map_BLUFOR_A",0.8])];
+ _coloropfor = [(profilenamespace getvariable ["Map_OPFOR_R",0]),(profilenamespace getvariable ["Map_OPFOR_G",1]),(profilenamespace getvariable ["Map_OPFOR_B",1]),(profilenamespace getvariable ["Map_OPFOR_A",0.8])];
+ _colorindfor = [(profilenamespace getvariable ["Map_Independent_R",0]),(profilenamespace getvariable ["Map_Independent_G",1]),(profilenamespace getvariable ["Map_Independent_B",1]),(profilenamespace getvariable ["Map_Independent_A",0.8])];
+ _colorciv = [(profilenamespace getvariable ["Map_Civilian_R",0]),(profilenamespace getvariable ["Map_Civilian_G",1]),(profilenamespace getvariable ["Map_Civilian_B",1]),(profilenamespace getvariable ["Map_Civilian_A",0.8])];
+ _color = [];
+ if (side _leader == west) then {_color = _colorblufor;};
+ if (side _leader == east) then {_color = _coloropfor;};
+ if (side _leader == resistance) then {_color = _colorindfor;};
+ if (side _leader == civilian) then {_color = _colorciv;};
+
+ _align = "right";
+ _fontsize = 0.04;
+
+ _grptype = [_leader] call UPSMON_grptype;
+ _drawicon = configfile >> "CfgMarkers" >> "b_inf" >> "icon";
+ _drawwpicon = configfile >> "CfgMarkers" >> "mil_objective" >> "icon";
+ If (_grptype == "Iscar") then {_drawicon = configfile >> "CfgMarkers" >> "b_motor_inf" >> "icon";};
+ If (_grptype == "IsAir") then {_drawicon = configfile >> "CfgMarkers" >> "b_plane" >> "icon";};
+ If (_grptype == "Isboat") then {_drawicon = configfile >> "CfgMarkers" >> "b_naval" >> "icon";};
+
+ _align = "left";
+ _textwp = "";
+ _text = format ["%1. %2 - Grpcount: %3 - Mission: %4 Status: %5 - Target: %6",_rankshort, _lastname,count units _x,_x getvariable ["UPSMON_Grpmission","PATROL"],_x getvariable ["UPSMON_Grpstatus","GREEN"],_x getvariable ["UPSMON_GrpTarget",ObjNull]];
+
+ (_this select 0) drawIcon [
+ getText _drawicon,
+ _color,
+ visiblePosition _leader,
+ 0.5/ctrlMapScale (_this select 0),
+ 0.5/ctrlMapScale (_this select 0),
+ direction _leader,
+ --,
+ 1,
+ _fontsize,
+ "TahomaB",
+ _align
+ ];
+ If (count(waypoints _x) != 0) then
+ {
+ _wppos = waypointPosition [_x,count(waypoints _x)-1];
+ (_this select 0) drawIcon [getText (_drawwpicon), _color,_wppos, 0.5/ctrlMapScale (_this select 0), 0.5/ctrlMapScale (_this select 0), direction _leader, _textwp, 1, _fontsize, "TahomaB", _align];
+ };
+ _behcolor = [1,1,1,1];
+ if (behaviour _leader == "SAFE") then {_behcolor = [0,0.8,0,1]};
+ if (behaviour _leader == "AWARE") then {_behcolor = [0.85,0.85,0,1]};
+ if (behaviour _leader == "COMBAT") then {_behcolor = [0.9,0,0,1]};
+ if (behaviour _leader == "STEALTH") then {_behcolor = [0,0,1,1]};
+ if !(((expectedDestination _leader) select 0) select 0 < 1 AND ((expectedDestination _leader) select 0) select 1 < 1) then
+ {
+ (_this select 0) drawArrow [
+ visiblePosition _leader,
+ ((expectedDestination _leader) select 0),
+ _behcolor
+ ];
+ };
+ };
+ };
+ } foreach UPSMON_Trackednpcs
+'
+];
+
+/****************************************************************
+_eh = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler
+[
+ "Draw"
+,'
+ _leader = leader _grp;
+ _rankshort = [rank _leader,"displayNameShort"] call BIS_fnc_rankparams;
+ _lastname = name _leader;
+ _scale = (sizeof typeof _leader) / 30;
+ _colorblufor = [(profilenamespace getvariable ["Map_BLUFOR_R",0]),(profilenamespace getvariable ["Map_BLUFOR_G",1]),(profilenamespace getvariable ["Map_BLUFOR_B",1]),(profilenamespace getvariable ["Map_BLUFOR_A",0.8])];
+ _coloropfor = [(profilenamespace getvariable ["Map_OPFOR_R",0]),(profilenamespace getvariable ["Map_OPFOR_G",1]),(profilenamespace getvariable ["Map_OPFOR_B",1]),(profilenamespace getvariable ["Map_OPFOR_A",0.8])];
+ _colorindfor = [(profilenamespace getvariable ["Map_Independent_R",0]),(profilenamespace getvariable ["Map_Independent_G",1]),(profilenamespace getvariable ["Map_Independent_B",1]),(profilenamespace getvariable ["Map_Independent_A",0.8])];
+ _colorciv = [(profilenamespace getvariable ["Map_Civilian_R",0]),(profilenamespace getvariable ["Map_Civilian_G",1]),(profilenamespace getvariable ["Map_Civilian_B",1]),(profilenamespace getvariable ["Map_Civilian_A",0.8])];
+ _color = [];
+ if (side _leader == west) then {_color = _colorblufor;};
+ if (side _leader == east) then {_color = _coloropfor;};
+ if (side _leader == resistance) then {_color = _colorindfor;};
+ if (side _leader == civilian) then {_color = _colorciv;};
+
+ _align = "right";
+ _fontsize = 0.04;
+
+ _grptype = [_leader] call UPSMON_grptype;
+ _drawicon = configfile >> "CfgMarkers" >> "b_inf" >> "icon";
+ If (_grptype == "Iscar") then {_drawicon = configfile >> "CfgMarkers" >> "b_motor_inf" >> "icon";};
+ If (_grptype == "IsAir") then {_drawicon = configfile >> "CfgMarkers" >> "b_plane" >> "icon";};
+ If (_grptype == "Isboat") then {_drawicon = configfile >> "CfgMarkers" >> "b_naval" >> "icon";};
+
+ _align = "left";
+ _unitshit = [];
+ {if (damage _x >= 0.65) then {_unitshit set [count _unitshit,_x];}}foreach units _leader;
+ _text = format ["%1. %2 - Grpcount: %3 - Wounding units: %4",_rankshort, _lastname,count units group _leader,count _unitshit];
+
+ (_this select 0) drawIcon [getText (_drawicon), _color, visiblePosition _leader, 0.5/ctrlMapScale (_this select 0), 0.5/ctrlMapScale (_this select 0), direction _leader, _text, 1, _fontsize, "TahomaB", _align];
+ _behcolor = [1,1,1,1];
+ if (behaviour _leader == "SAFE") then {_behcolor = [0.85,0.85,0,1]};
+ if (behaviour _leader == "AWARE") then {_behcolor = [0,0.8,0,1]};
+ if (behaviour _leader == "COMBAT") then {_behcolor = [0.9,0,0,1]};
+ if (behaviour _leader == "STEALTH") then {_behcolor = [0,0,1,1]};
+ if !(((expectedDestination _leader) select 0) select 0 < 1 AND ((expectedDestination _leader) select 0) select 1 < 1) then { (_this select 0) drawArrow [visiblePosition _leader, ((expectedDestination _leader) select 0), _behcolor];};'
+];
+****************************************************************/
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_arrayShufflePlus.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_arrayShufflePlus.sqf
new file mode 100644
index 0000000..db9b807
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_arrayShufflePlus.sqf
@@ -0,0 +1,26 @@
+/****************************************************************
+File: UPSMON_arrayShufflePlus.sqf
+Author: KillZoneKid
+
+Description:
+
+Parameter(s):
+ <--- Array
+Returns:
+ Array
+****************************************************************/
+
+private ["_cnt","_el1","_rnd","_indx","_el2"];
+
+_cnt = count _this - 1;
+_el1 = _this select _cnt;
+_this resize _cnt;
+_rnd = random diag_tickTime * _cnt;
+for "_i" from 0 to _cnt do {
+ _indx = floor random _rnd % _cnt;
+ _el2 = _this select _indx;
+ _this set [_indx, _el1];
+ _el1 = _el2;
+};
+_this set [_cnt, _el1];
+_this
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_checkbackpack.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_checkbackpack.sqf
new file mode 100644
index 0000000..1bcf3b8
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_checkbackpack.sqf
@@ -0,0 +1,30 @@
+/****************************************************************
+File: UPSMON_checkbackpack.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- bagpack
+Returns:
+ ---> Gun type classname
+ ---> tripod type classname
+****************************************************************/
+private ["_bagpack","_cfg","_parents","_result","_gun","_tripod","_gun"];
+
+_bagpack = _this select 0;
+_cfg = (configFile >> "cfgVehicles" >> _bagpack);
+_parents = [_cfg,true] call BIS_fnc_returnParents;
+
+_result = [];
+_gun = "";
+_tripod = [];
+
+if ("Weapon_Bag_Base" in _parents) then
+{
+ _gun = gettext (configFile >> "cfgVehicles" >> _bagpack >> "assembleInfo" >> "assembleTo");
+ _tripod = getarray (configFile >> "cfgVehicles" >> _bagpack >> "assembleInfo" >> "base");
+ _result = [_gun,_tripod];
+};
+
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_createmarker.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_createmarker.sqf
new file mode 100644
index 0000000..89b2824
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_createmarker.sqf
@@ -0,0 +1,33 @@
+/****************************************************************
+File: UPSMON_createmarker.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_pos","_m","_shape","_type","_color","_size"];
+
+_pos = _this select 0;
+_shape = _this select 1;
+_type = _this select 2;
+_color = _this select 3;
+_size = 1;
+If (count _this > 4) then {_size = _this select 4;};
+
+_m = createMarker [format["mPos%1%2",(floor(_pos select 0)),(floor(_pos select 1))],_pos];
+_m setmarkerColor _color;
+_m setMarkerShape _shape;
+If (_shape != "ICON") then
+{
+ _m setMarkerSize _size;
+ _m setMarkerBrush _type
+}
+else
+{
+ _m setMarkerType _type;
+ If (count _this > 4) then {_m setMarkerText (_this select 4);};
+};
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_createsign.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_createsign.sqf
new file mode 100644
index 0000000..e4b1278
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_createsign.sqf
@@ -0,0 +1,18 @@
+/****************************************************************
+File: UPSMON_createmarker.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_pos","_sign","_type"];
+
+_pos = _this select 0;
+_type = _this select 1;
+
+_sign = _type createvehicle [0,0,0];
+_sign setpos _pos;
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_deleteDead.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_deleteDead.sqf
new file mode 100644
index 0000000..f76b7ec
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_deleteDead.sqf
@@ -0,0 +1,18 @@
+/****************************************************************
+File: UPSMON_deleteDead.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_u","_s"];
+
+_u=_this select 0;
+_s= _this select 1;
+_u removeAllEventHandlers "killed";
+sleep _s;
+deletevehicle _u
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_distancePosSqr.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_distancePosSqr.sqf
new file mode 100644
index 0000000..e1769ef
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_distancePosSqr.sqf
@@ -0,0 +1,12 @@
+/****************************************************************
+File: UPSMON_distancePosSqr.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+round(((((_this select 0) select 0)-((_this select 1) select 0))^2 + (((_this select 0) select 1)-((_this select 1) select 1))^2)^0.5)
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getArg.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getArg.sqf
new file mode 100644
index 0000000..69e9365
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getArg.sqf
@@ -0,0 +1,21 @@
+/****************************************************************
+File: UPSMON_getArg.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_cmd","_arg","_list","_a","_v"];
+
+_cmd=_this select 0;
+_arg=_this select 1;
+_list=_this select 2;
+_a=-1;
+{_a=_a+1; _v=format["%1",_list select _a];
+if (_v==_cmd) then {_arg=(_list select _a+1)}} foreach _list;
+
+_arg
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getDirPos.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getDirPos.sqf
new file mode 100644
index 0000000..529aca5
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getDirPos.sqf
@@ -0,0 +1,23 @@
+/****************************************************************
+File: UPSMON_randomPos.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_a","_b","_from","_to","_return"];
+
+_from = _this select 0;
+_to = _this select 1;
+_return = 0;
+
+_a = ((_to select 0) - (_from select 0));
+_b = ((_to select 1) - (_from select 1));
+if (_a != 0 || _b != 0) then {_return = _a atan2 _b};
+if ( _return < 0 ) then { _return = _return + 360 };
+
+_return
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getminesclass.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getminesclass.sqf
new file mode 100644
index 0000000..4e96d26
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_getminesclass.sqf
@@ -0,0 +1,52 @@
+/****************************************************************
+File: UPSMON_getminesclass.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ Nothing
+Returns:
+ Array of mines types
+****************************************************************/
+
+private ["_minesclassname","_minetype1","_minetype2","_cfgvehicles","_cfgvehicle","_inherit","_vehicle"];
+
+_minesclassname = [];
+_minetype1 = [];
+_minetype2 = [];
+_minetype3 = [];
+
+_APMines = [];
+_ATMines = [];
+_underwatermines = [];
+
+
+{
+ _mineTriggerType = tolower gettext (_x >> "mineTriggerType");
+ if (_mineTriggerType in ["radius","wire"]) then
+ {
+ _mineMagnetic = getnumber (_x >> "mineMagnetic");
+ _array = if (_mineMagnetic > 0) then {_ATMines} else {_APMines};
+ _underwatermine=[tolower configname _x,"underwater"] call UPSMON_StrInStr;
+ if (_underwatermine) then {_array=_underwatermines;};
+ _array set [count _array,tolower configname _x];
+ };
+} foreach ((configfile >> "CfgMineTriggers") call bis_fnc_returnchildren);
+
+{
+ _cfgvehicle = _x;
+ _inherit = inheritsFrom _cfgvehicle;
+ If ((configName _inherit) == "MineBase") then
+ {
+ _vehicle = configName _cfgvehicle;
+ _ammo = tolower gettext (_cfgvehicle >> "ammo");
+ _trigger = tolower gettext (configfile >> "cfgAmmo" >> _ammo >> "mineTrigger");
+ if (_trigger in _ATMines) then {_minetype1 set [count _minetype1,_vehicle];};
+ if (_trigger in _APMines) then {_minetype2 set [count _minetype2,_vehicle];};
+ if (_trigger in _underwatermines) then {_minetype3 set [count _minetype3,_vehicle];};
+ };
+} foreach ((configfile >> "CfgVehicles") call bis_fnc_returnchildren);
+
+_minesclassname = [_minetype1,_minetype2,_minetype3];
+_minesclassname
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_overwatch.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_overwatch.sqf
new file mode 100644
index 0000000..21a2a44
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_overwatch.sqf
@@ -0,0 +1,71 @@
+/*
+ File: fn_findOverwatch.sqf
+ Author: Dean "Rocket" Hall
+
+ Description:
+ Function which selects a position that provides overwatch
+ onto another position.
+
+ Parameter(s):
+ _this select 0: the target position (position)
+ _this select 1: maximum distance from target in meters (optional)
+ _this select 2: minimum distance from target in meters (optional)
+ _this select 3: minimum height in relation to target in meters (optional)
+ _this select 4: position to start looking from, if different from target pos (optional)
+*/
+private ["_unit","_dir","_targetPos","_distance","_pool","_i","_flankAngle","_scan","_points","_targetPosTemp","_terrainscan","_los_ok","_final"];
+
+_unit = _this select 0;
+_dir = _this select 1;
+
+_targetPos = getposATL _unit;
+
+_pool = [];
+
+_i = 0;
+_scan = true;
+
+while {_scan} do
+{
+ _i = _i + 1;
+ _targetPosTemp = [_targetPos,[0,50],[_dir +70,_dir +220],0,[0,100],5] call UPSMON_pos;
+ If (!surfaceIsWater _targetPosTemp) then
+ {
+ _points = 0;
+ _targetPosTemp = [_targetPosTemp select 0,_targetPosTemp select 1,0];
+ If (_unit != vehicle _unit) then
+ {
+ If (isOnRoad _targetPosTemp) then
+ {
+ _points = _points +20;
+ };
+ _value = [_targetPosTemp,1,1] call UPSMON_TerraCognita;
+ _meadow = _value select 3;
+ _terr = _meadow * 100;
+ _elev = getTerrainHeightASL [_targetPosTemp select 0,_targetPosTemp select 1];
+ _points = _points + _terr + _elev;
+ }
+ else
+ {
+ _value = [_targetPosTemp,1,1] call UPSMON_TerraCognita;
+ _urban = _value select 0;
+ _forest = _value select 1;
+ _terr = (_urban + _forest) * 100;
+ _elev = getTerrainHeightASL [_targetPosTemp select 0,_targetPosTemp select 1];
+ _points = _points +_terr + _elev;
+ };
+
+ _los_ok = [_targetPos,_targetPosTemp] call UPSMON_LOS;
+ If (_los_ok) then {_points = _points + 200;};
+ _targetpostemp pushback _points;
+ _pool pushback _targetPosTemp;
+ };
+ If (count _pool > 10 || _i > 50) then {_scan = false};
+};
+
+
+_pool = [_pool, [], {_x select 3}, "DESCEND"] call BIS_fnc_sortBy;
+
+If (count _pool > 0) then {_targetpos = [(_pool select 0) select 0,(_pool select 0) select 1,0];};
+
+_targetPos;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_randomPos.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_randomPos.sqf
new file mode 100644
index 0000000..737c79d
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_randomPos.sqf
@@ -0,0 +1,25 @@
+/****************************************************************
+File: UPSMON_randomPos.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_cx","_cy","_rx","_ry","_cd","_sd","_ad","_tx","_ty","_xout","_yout"];
+
+_cx=_this select 0;
+_cy=_this select 1;
+_rx=_this select 2;
+_ry=_this select 3;
+_cd=_this select 4;
+_sd=_this select 5;
+_ad=_this select 6;
+_tx=random (_rx*2)-_rx;
+_ty=random (_ry*2)-_ry;
+_xout=if (_ad!=0) then {_cx+ (_cd*_tx - _sd*_ty)} else {_cx+_tx};
+_yout=if (_ad!=0) then {_cy+ (_sd*_tx + _cd*_ty)} else {_cy+_ty};
+[_xout,_yout]
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_rotpoint.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_rotpoint.sqf
new file mode 100644
index 0000000..ae41ef8
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_rotpoint.sqf
@@ -0,0 +1,31 @@
+/****************************************************************
+File: UPSMON_rotpoint.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_cp","_a","_tx","_ty","_cd","_sd","_cx","_cy","_xout","_yout"];
+
+_cp=_this select 0;
+_cx=_cp select 0;
+_cy=_cp select 1;
+_a=_this select 1;
+_cd=cos(_a*-1);
+_sd=sin(_a*-1);
+_tx=_this select 2;
+_ty=_this select 3;
+_xout=if (_a!=0) then
+{
+ _cx+ (_cd*_tx - _sd*_ty)
+} else
+{
+ _cx+_tx
+};
+_yout=if (_a!=0) then {_cy+ (_sd*_tx + _cd*_ty)} else {_cy+_ty};
+
+[_xout,_yout,0]
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_setArg.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_setArg.sqf
new file mode 100644
index 0000000..6cc7315
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_setArg.sqf
@@ -0,0 +1,27 @@
+/****************************************************************
+File: UPSMON_setArg.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_cmd","_arg","_list","_a","_v"];
+
+_cmd=_this select 0;
+_arg=_this select 1;
+_list=_this select 2;
+_a=-1;
+{
+ _a=_a+1;
+ _v= format ["%1", _list select _a];
+ if (_v==_cmd) then
+ {
+ _a=_a+1;
+ _list set [_a,_arg];
+ };
+} foreach _list;
+_list
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_spawnmines.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_spawnmines.sqf
new file mode 100644
index 0000000..01eb8c0
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_spawnmines.sqf
@@ -0,0 +1,65 @@
+/****************************************************************
+File: UPSMON_spawnmines.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+
+private ["_minesnbr","_minetype1","_minetype2","_positiontoambush","_minetype","_mineposition","_max","_min","_ang","_dir","_orgX","_orgY","_posX","_posY","_mineposition","_Mine"];
+
+_minesnbr = _this select 0;
+_minetype1 = _this select 1;
+_minetype2 = _this select 2;
+_positiontoambush = _this select 3;
+_diramb = _this select 4;
+_side = _this select 5;
+
+for [{_i=0}, {_i < _minesnbr}, {_i=_i+1}] do
+{
+ _minetype= _minetype1;
+ _mineposition = _positiontoambush;
+
+ If (_i > 0) then
+ {
+ _minetype = _minetype2;
+ // Many thanks Shuko ...
+ _max = 0; _min = 0;
+ if (floor (random 4) < 2) then
+ {
+ _min = _diramb + 270;
+ _max = _diramb + 335;
+ }
+ else
+ {
+ _min = _diramb + 25;
+ _max = _diramb + 90;
+ };
+
+ _ang = _max - _min;
+ // Min bigger than max, can happen with directions around north
+ if (_ang < 0) then { _ang = _ang + 360 };
+ if (_ang > 360) then { _ang = _ang - 360 };
+ _dir = (_min + random _ang);
+
+ _orgX = _positiontoambush select 0;
+ _orgY = _positiontoambush select 1;
+ _posX = _orgX + (((random 10) + (random 30 +5)) * sin _dir);
+ _posY = _orgY + (((random 10) + (random 30 +5)) * cos _dir);
+ _mineposition = [_posX,_posY,0];
+ };
+
+
+ _Mine=createMine [_minetype,_mineposition, [], 0];
+ _side revealMine _Mine;
+ if (UPSMON_Debug>0) then
+ {
+ [_mineposition,"Sign_Arrow_Large_GREEN_F"] spawn UPSMON_createsign;
+ [_mineposition,"Icon","Minefield","Colorred"] spawn UPSMON_createmarker
+ };
+ sleep 0.01;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/fnc/UPSMON_stayInside.sqf b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_stayInside.sqf
new file mode 100644
index 0000000..1559aa8
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/fnc/UPSMON_stayInside.sqf
@@ -0,0 +1,25 @@
+/****************************************************************
+File: UPSMON_stayInside.sqf
+Author: KRONZKY
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_np","_nx","_ny","_cp","_cx","_cy","_rx","_ry","_d","_tp","_tx","_ty","_fx","_fy"];
+
+_np=_this select 0; _nx=_np select 0; _ny=_np select 1;
+_cp=_this select 1; _cx=_cp select 0; _cy=_cp select 1;
+_rx=_this select 2; _ry=_this select 3; _d=_this select 4;
+_tp = [_cp,_d,(_nx-_cx),(_ny-_cy)] call UPSMON_rotpoint;
+_tx = _tp select 0; _fx=_tx;
+_ty = _tp select 1; _fy=_ty;
+if (_tx<(_cx-_rx)) then {_fx=_cx-_rx};
+if (_tx>(_cx+_rx)) then {_fx=_cx+_rx};
+if (_ty<(_cy-_ry)) then {_fy=_cy-_ry};
+if (_ty>(_cy+_ry)) then {_fy=_cy+_ry};
+if ((_fx!=_tx) || (_fy!=_ty)) then {_np = [_cp,_d*-1,(_fx-_cx),(_fy-_cy)] call UPSMON_rotpoint};
+_np;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Core/init.sqf b/scripts/UPSMON/COMMON/Core/init.sqf
new file mode 100644
index 0000000..f906a61
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Core/init.sqf
@@ -0,0 +1,43 @@
+
+UPSMON_Getnearestplayer = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_Getnearestplayer.sqf";
+UPSMON_Nighttime = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_Nighttime.sqf";
+
+UPSMON_arrayShufflePlus = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_arrayShufflePlus.sqf";
+UPSMON_getArg = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_getArg.sqf";
+UPSMON_setArg = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_setArg.sqf";
+UPSMON_distancePosSqr = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_distancePosSqr.sqf";
+
+UPSMON_GetPos2D = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_GetPos2D.sqf";
+UPSMON_GetCOS = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_GetCOS.sqf";
+UPSMON_GetSIN = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_GetSIN.sqf";
+
+UPSMON_Replace = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_Replace.sqf";
+UPSMON_rotpoint = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_rotpoint.sqf";
+UPSMON_StrIndex = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_StrIndex.sqf";
+UPSMON_StrInStr = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_StrInStr.sqf";
+UPSMON_StrLen = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_StrLen.sqf";
+UPSMON_StrToArray = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_StrToArray.sqf";
+
+UPSMON_CanSee = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_CanSee.sqf";
+UPSMON_LOS = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_LOS.sqf";
+UPSMON_Haslos = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_Haslos.sqf";
+UPSMON_overwatch = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_overwatch.sqf";
+
+UPSMON_DeleteWP = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_DeleteWP.sqf";
+UPSMON_DocreateWP = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_DocreateWP.sqf";
+UPSMON_DoaddWP = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_DoaddWP.sqf";
+UPSMON_createmarker = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_createmarker.sqf";
+UPSMON_createsign = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_createsign.sqf";
+UPSMON_TRACK = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_TRACK.sqf";
+
+UPSMON_checkbackpack = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_checkbackpack.sqf";
+UPSMON_getminesclass = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_getminesclass.sqf";
+UPSMON_spawnmines = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_spawnmines.sqf";
+
+UPSMON_SN_EHHIT = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_SN_EHHIT.sqf";
+UPSMON_SN_EHKILLED = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_SN_EHKILLED.sqf";
+UPSMON_SN_EHFIREDNEAR = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_SN_EHFIREDNEAR.sqf";
+UPSMON_deleteDead = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_deleteDead.sqf";
+UPSMON_Nowp = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_Nowp.sqf";
+
+UPSMON_AddtoArray = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Core\fnc\UPSMON_AddtoArray.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_filter.sqf b/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_filter.sqf
new file mode 100644
index 0000000..2e5f512
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_filter.sqf
@@ -0,0 +1,45 @@
+/****************************************************************
+File: UPSMON_fnc_filter.sqf
+Author: Robalo
+
+Description:
+ Filter cover objects
+Parameter(s):
+ <--- Object
+Returns:
+ boolean
+****************************************************************/
+private ["_type","_z","_bbox","_dz","_dy"];
+
+if (_this isKindOf "Man") exitWith {false};
+if (_this isKindOf "STATICWEAPON") exitWith {false};
+if (_this isKindOf "Bird") exitWith {false};
+if (_this isKindOf "BulletCore") exitWith {false};
+if (_this isKindOf "Grenade") exitWith {false};
+if (_this isKindOf "WeaponHolder") exitWith {false};
+if (_this isKindOf "WeaponHolderSimulated") exitWith {false};
+if (_this isKindOf "Sound") exitWith {false};
+//if (!isTouchingGround _this) exitWith {false};
+if (isBurning _this) exitWith {false};
+if (["slop", (format ["%1", _this])] call BIS_fnc_inString) exitWith {false};
+if (["fence", (format ["%1", _this])] call BIS_fnc_inString) then
+{
+ If (!(_this isKindOf "Strategic")) exitwith {false};
+};
+
+_type = typeOf _this;
+if (_type == "") then
+{
+ if (damage _this == 1) exitWith {false};
+} else {
+ //if (_type in ["#soundonvehicle","#mark","#crater","#crateronvehicle","#soundonvehicle","#particlesource","#lightpoint","#slop"]) exitWith {false};
+};
+
+_z = (getPosATL _this) select 2;
+if (_z > 0.3) exitWith {false};
+_bbox = boundingBoxReal _this;
+_dz = ((_bbox select 1) select 2) - ((_bbox select 0) select 2);
+_dy = abs(((_bbox select 1) select 0) - ((_bbox select 0) select 0));//width
+if ((_dz > 0.35) && (_dy > 0.35) ) exitWith {true};
+
+false
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_find_cover.sqf b/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_find_cover.sqf
new file mode 100644
index 0000000..9466771
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_find_cover.sqf
@@ -0,0 +1,89 @@
+/****************************************************************
+File: UPSMON_fnc_find_cover.sqf
+Author: OLLEM
+
+Description:
+ Make a group move to cover
+Parameter(s):
+ <--- Leader position
+ <--- Position to watch
+ <--- Radius searching
+ <--- Do the unit move or spawn to the cover position ?
+ <--- Array of group units
+Returns:
+ Nothing
+****************************************************************/
+
+private ["_unitpos","_lookpos","_dist","_spawn","_units","_i","_objects","_vdir","_cpos","_object","_coverPosition"];
+
+_unitpos = _this select 0;
+_lookpos = _this select 1;
+_dist = _this select 2;
+_spawn = _this select 3;
+_units = _this select 4;
+
+_i = 0;
+If (count _this > 5) then {_i = _this select 5;};
+
+If (_i > 3) exitwith {_units};
+
+if (_spawn) then
+{
+ {
+ _pos2 = _unitpos findEmptyPosition [1,25];
+ _x setposATL _pos2;
+ }foreach _units;
+};
+
+_movetocover = [];
+
+(group (_units select 0)) setvariable ["UPSMON_Cover",true];
+if (UPSMON_Debug>0) then {player sidechat "Cover"};
+//potential cover objects list
+_objects = [(nearestObjects [_unitpos, [], _dist]), { _x call UPSMON_fnc_filter } ] call BIS_fnc_conditionalSelect;
+
+_vdir = [_unitpos, _lookpos] call BIS_fnc_DirTo;
+
+{
+ If (alive _x) then
+ {
+ If (count _objects > 0) then
+ {
+ _object = _objects select 0;
+ _objects = _objects - [_object];
+ If (!IsNull _object) then
+ {
+ //_x is potential cover object
+ _cPos = (getPosATL _object);
+
+ //set coverposition to 1.3 m behind the found cover
+ _coverPosition = [(_cPos select 0) - (sin(_vdir)*1.5), (_cPos select 1) - (cos(_vdir)*1.5), 0];
+
+ //Any object which is high and wide enough is potential cover position, excluding water
+ if (!(surfaceIsWater _coverPosition)) exitwith
+ {
+
+ if (UPSMON_Debug>0) then
+ {
+ _ballCover = "sign_sphere100cm_F" createvehicle _coverPosition;
+ _ballCover setpos _coverPosition;
+ diag_log format ["object: %1",_object];
+ };
+
+ _movetocover pushback _x;
+ [_x,[_object, _coverPosition],_lookpos,_spawn] spawn UPSMON_fnc_move_to_cover;
+ };
+ };
+ };
+ };
+} foreach _units;
+
+_units = _units - _movetocover;
+
+If (count _units > 0) then
+{
+ _i = _i + 1;
+ _units = [_unitpos,_lookpos,_dist,_spawn,_units] call UPSMON_fnc_find_cover;
+};
+
+_units;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_move_to_cover.sqf b/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_move_to_cover.sqf
new file mode 100644
index 0000000..f605d07
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Cover/fnc/UPSMON_fnc_move_to_cover.sqf
@@ -0,0 +1,88 @@
+/****************************************************************
+File: UPSMON_fnc_move_to_cover.sqf
+Author: OLLEM
+
+Description:
+ Make a group move to cover
+Parameter(s):
+ <--- unit
+ <--- Cover Array
+ <--- Cover object
+ <--- Cover position
+ <--- Position to watch
+ <--- Do the unit move or spawn to the cover position ?
+Returns:
+ Nothing
+****************************************************************/
+
+private ["_unit","_coverArray","_lookpos","_spawn","_cover","_coverPosition","_coverDist","_stopped","_continue","_checkTime","_dist","_sight"];
+
+_unit = _this select 0;
+_coverArray = _this select 1;
+_lookpos = _this select 2;
+_spawn = _this select 3;
+
+_cover = _coverArray select 0;
+_coverPosition = _coverArray select 1;
+
+if (_spawn) then
+{
+ _unit setposATL _coverPosition;
+ doStop _unit;
+
+ if (_unit == leader (group _unit) || random 100 < 50) then
+ {
+ [_unit,_lookpos] call UPSMON_dowatch;
+ };
+}
+else
+{
+ Dostop _unit;
+ _unit domove _coverPosition;
+ _unit forceSpeed 100;
+ _unit setDestination [_coverPosition, "LEADER PLANNED", true];
+
+ _coverDist = round ([getposATL _unit,_coverPosition] call UPSMON_distancePosSqr);
+
+ _stopped = true;
+ _continue = true;
+
+ _checkTime = (time + (1.7 * _coverDist) + 20);
+
+ while { _continue } do
+ {
+
+ _dist = ([getposATL _unit,_coverPosition] call UPSMON_distancePosSqr);
+
+ if (!(unitReady _unit) && (alive _unit) && (_dist > 1.25) && (_unit getvariable ["UPSMON_SUPSTATUS",""] == "")) then
+ {
+ //if unit takes too long to reach cover or moves too far out stop at current location
+ if (time <= _checkTime) then
+ {
+ _continue = false;
+ }
+ else
+ {
+ //_coverPosition = getPosATL _unit;
+ //_unit doMove _coverPosition;
+
+ //_continue = true;
+ };
+ }
+ else
+ {
+ _continue = false;
+ _stopped = false;
+ };
+ };
+
+ _unit forcespeed -1;
+ if (!( _stopped)) then
+ {
+ doStop _unit;
+ _unit setBehaviour "STEALTH";
+ _sight = [_unit,getdir _unit, 50] call UPSMON_CanSee;
+ If (!_sight) then {_unit setUnitPos "MIDDLE";};
+ };
+};
+
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Cover/init.sqf b/scripts/UPSMON/COMMON/Cover/init.sqf
new file mode 100644
index 0000000..ee43903
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Cover/init.sqf
@@ -0,0 +1,5 @@
+
+UPSMON_fnc_move_to_cover = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Cover\fnc\UPSMON_fnc_move_to_cover.sqf";
+
+UPSMON_fnc_find_cover = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Cover\fnc\UPSMON_fnc_find_cover.sqf";
+UPSMON_fnc_filter = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Cover\fnc\UPSMON_fnc_filter.sqf";
diff --git a/scripts/UPSMON/COMMON/Group/Init.sqf b/scripts/UPSMON/COMMON/Group/Init.sqf
new file mode 100644
index 0000000..58cd59a
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/Init.sqf
@@ -0,0 +1,20 @@
+
+UPSMON_getleader = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_getleader.sqf";
+UPSMON_SetLeaderGrp = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_SetLeaderGrp.sqf";
+UPSMON_getunits = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_getunits.sqf";
+UPSMON_getNearestSoldier = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_getNearestSoldier.sqf";
+
+UPSMON_grptype = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_grptype.sqf";
+UPSMON_GetStaticTeam = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_GetStaticTeam.sqf";
+UPSMON_composeteam = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_composeteam.sqf";
+UPSMON_analysegrp = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_analysegrp.sqf";
+UPSMON_supstatestatus = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_supstatestatus.sqf";
+UPSMON_checkmunition = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_checkmunition.sqf";
+
+UPSMON_Isgrpstuck = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_Isgrpstuck.sqf";
+UPSMON_IsRetreating = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_IsRetreating.sqf";
+UPSMON_IsSurrending = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_IsSurrending.sqf";
+UPSMON_Cangrpmaneuver = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_Cangrpmaneuver.sqf";
+UPSMON_Supressfire = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_Supressfire.sqf";
+
+UPSMON_ChangeFormation = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\fnc\UPSMON_ChangeFormation.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Cangrpmaneuver.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Cangrpmaneuver.sqf
new file mode 100644
index 0000000..6d800c0
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Cangrpmaneuver.sqf
@@ -0,0 +1,34 @@
+
+private ["_grp","_nowp","_attackpos","_typeofgrp","_maneuver"];
+
+_grp = _this select 0;
+_nowp = _this select 1;
+_attackpos = _this select 2;
+_typeofgrp = _this select 3;
+
+_maneuver = false;
+
+If (!_nowp) then
+{
+ If (count _attackpos > 0) then
+ {
+ If (!("static" in _typeofgrp)) then
+ {
+ If (!("arti" in _typeofgrp)) then
+ {
+ If (!("supply" in _typeofgrp)) then
+ {
+ If (_grp getvariable ["UPSMON_TIMEORDER",time] <= time) then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "TRANSPORT") then
+ {
+ _maneuver = true;
+ };
+ };
+ };
+ };
+ };
+ };
+};
+
+_maneuver;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_ChangeFormation.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_ChangeFormation.sqf
new file mode 100644
index 0000000..4ebfd80
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_ChangeFormation.sqf
@@ -0,0 +1,171 @@
+/****************************************************************
+File: UPSMON_SetStances.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+
+private ["_grp","_supstatus","_attackpos","_dist","_terrainscan","_haslos","_time"];
+
+_grp = _this select 0;
+_supstatus = _this select 1;
+_attackpos = _this select 2;
+_dist = _this select 3;
+_terrainscan = _this select 4;
+_haslos = _this select 5;
+_typeofgrp = _this select 6;
+
+If (!(_grp getvariable ["UPSMON_haschangedformation",false])) then
+{
+ _grp setvariable ["UPSMON_haschangedformation",true];
+ If ("air" in _typeofgrp) then
+ {
+ If ((Speedmode _grp) != "FULL") then
+ {
+ _grp setspeedmode "FULL";
+ };
+ }
+ else
+ {
+ If (_supstatus != "SUPRESSED") then
+ {
+ If (count _attackpos > 0) then
+ {
+ If (_dist > 500 || !_haslos) then
+ {
+ If (vehicle (leader _grp) == (leader _grp)) then
+ {
+ If ((Speedmode _grp) != "NORMAL") then
+ {
+ _grp setspeedmode "NORMAL";
+ };
+ If (_dist < 200) then
+ {
+ If ((Formation _grp) != "LINE") then
+ {
+ _grp setformation "LINE";
+ };
+ }
+ else
+ {
+ If ((Formation _grp) != "STAG COLUMN") then
+ {
+ _grp setformation "STAG COLUMN";
+ };
+ };
+ };
+ }
+ else
+ {
+ If (_dist > 150) then
+ {
+ If (!(Behaviour (leader _grp) in ["COMBAT","STEALTH"])) then
+ {
+ _grp setBehaviour "COMBAT";
+ };
+
+ If ((Formation _grp) != "WEDGE") then
+ {
+ _grp setformation "WEDGE";
+ };
+ };
+
+ If (_dist <= 150) then
+ {
+ If ((_terrainscan select 0) == "forest" || (_terrainscan select 0) == "inhabited") then
+ {
+ If ((Speedmode _grp) != "LIMITED") then
+ {
+ _grp setspeedmode "LIMITED";
+ };
+
+ if ((_terrainscan select 0) == "inhabited") then
+ {
+ If ((_terrainscan select 1) > 230) then
+ {
+ If ((Formation _grp) != "STAG COLUMN") then
+ {
+ _grp setformation "STAG COLUMN";
+ };
+ };
+ };
+ };
+
+ If ((_terrainscan select 0) == "meadow") then
+ {
+ If ((Speedmode _grp) != "FULL") then
+ {
+ _grp setspeedmode "FULL";
+ };
+ If ((Formation _grp) != "LINE") then
+ {
+ _grp setformation "LINE";
+ };
+ };
+ };
+ };
+ };
+ }
+ else
+ {
+ If (_supstatus != "") then
+ {
+ If ((behaviour (leader _grp)) != "COMBAT") then
+ {
+ (leader _grp) setbehaviour "COMBAT";
+ };
+
+ If ((_terrainscan select 0) == "meadow") then
+ {
+ If (Speedmode _grp != "NORMAL") then
+ {
+ _grp setspeedmode "NORMAL";
+ };
+ };
+
+ If ((_terrainscan select 0) == "forest" || (_terrainscan select 0) == "inhabited") then
+ {
+ If ((Speedmode _grp) != "LIMITED") then
+ {
+ _grp setspeedmode "LIMITED";
+ };
+
+ If ((Formation _grp) != "DIAMOND") then
+ {
+ _grp setformation "DIAMOND";
+ };
+ };
+ }
+ else
+ {
+ If ((Speedmode _grp) != "LIMITED") then
+ {
+ _grp setSpeedmode "LIMITED";
+ };
+
+ If ((Behaviour (leader _grp)) != "STEALTH") then
+ {
+ _grp setBehaviour "STEALTH";
+ };
+ };
+ };
+ };
+};
+
+[_grp] spawn
+{
+ private ["_grp"];
+
+ _grp = _this select 0;
+
+ sleep 20;
+ If (!IsNull _grp) then
+ {
+ _grp setvariable ["UPSMON_haschangedformation",false];
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_GetStaticTeam.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_GetStaticTeam.sqf
new file mode 100644
index 0000000..601cb91
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_GetStaticTeam.sqf
@@ -0,0 +1,54 @@
+/****************************************************************
+File: UPSMON_GetStaticTeam.sqf
+Author: Azroul13
+
+Description:
+ Check if group has weapon in bag (gun barrel and tripod)
+Parameter(s):
+ <--- group
+Returns:
+ ---> Static Team [Gunner,Assistant]
+ ---> Class of the static
+****************************************************************/
+
+private ["_grp","_position","_targetpos","_result","_staticTeam","_vehicle","_tripods","_unit","_backpack","_lots"];
+
+_grp = _this select 0;
+
+_result = [];
+_staticTeam = [];
+_vehicle = [];
+_tripods = [];
+
+{
+ if (alive _x) then
+ {
+ _unit = _x;
+ _backpack = backpack _Unit;
+ If (_backpack != "") then
+ {
+ _lots = [_backpack] call UPSMON_checkbackpack;
+ if (count _lots > 0) exitwith {_vehicle = _lots select 0; _tripods = _lots select 1; _staticTeam pushback _x;};
+ };
+ };
+} foreach units _grp;
+
+if (count _staticTeam > 0) then
+{
+
+ {
+ if (alive _x) then
+ {
+ _unit = _x;
+ _backpack = backpack _Unit;
+ If (_backpack != "") then
+ {
+ if (_backpack in _tripods) exitwith {_staticTeam pushback _x;};
+ };
+ };
+
+ } foreach units _grp;
+};
+
+_result = [_staticTeam,_vehicle];
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_GothitParam.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_GothitParam.sqf
new file mode 100644
index 0000000..b2f440f
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_GothitParam.sqf
@@ -0,0 +1,35 @@
+/****************************************************************
+File: UPSMON_GothitParam.sqf
+Author: Azroul13
+
+Description:
+ Is the unit hit ? Or Does it under fire ?
+
+Parameter(s):
+ <--- unit
+Returns:
+ Boolean
+****************************************************************/
+
+private ["_npc","_gothit"];
+
+_npc = _this select 0;
+_gothit = false;
+
+If (isNil "tpwcas_running") then
+{
+ if (group _npc in UPSMON_GOTHIT_ARRAY || group _npc in UPSMON_GOTKILL_ARRAY) then
+ {
+ _gothit = true;
+ };
+}
+else
+{
+ _Supstate = [_npc] call UPSMON_supstatestatus;
+ if (group _npc in UPSMON_GOTHIT_ARRAY || group _npc in UPSMON_GOTKILL_ARRAY || _Supstate >= 2) then
+ {
+ _gothit = true;
+ };
+};
+
+_gothit
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_IsRetreating.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_IsRetreating.sqf
new file mode 100644
index 0000000..9bb2e9c
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_IsRetreating.sqf
@@ -0,0 +1,37 @@
+
+private ["_grp","_dist","_ratio","_supstatus","_unitsneedammo","_typeofgrp","_assignedvehicles","_attackpos"];
+
+_grp = _this select 0;
+_dist = _this select 1;
+_ratio = _this select 2;
+_supstatus = _this select 3;
+_unitsneedammo = _this select 4;
+_typeofgrp = _this select 5;
+_attackpos = _this select 6;
+_assignedvehicles = _this select 7;
+
+
+If (_grp getvariable ["UPSMON_Grpmission",""] != "RETREAT") then
+{
+ If (!("static" in _typeofgrp)) then
+ {
+ If (_ratio > 2 || (count units _grp) == count _unitsneedammo || (_supstatus != "INCAPACITED") || ("arti" in _typeofgrp) || ("support" in _typeofgrp)) then
+ {
+ If (_dist >= 300) then
+ {
+ If (_supstatus != "SUPRESSED") then
+ {
+ If (!(fleeing (leader _grp))) then
+ {
+ If ((random 100) <= (call (compile format ["UPSMON_%1_RETREAT",(_grp getvariable ["UPSMON_Origin",[]]) select 5]))) then
+ {
+ [_grp,_attackpos,_typeofgrp,_assignedvehicles] spawn UPSMON_DORETREAT;
+ _grp setvariable ["UPSMON_Grpmission","RETREAT"];
+ _grpstatus = "BLUE";
+ };
+ };
+ };
+ };
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_IsSurrending.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_IsSurrending.sqf
new file mode 100644
index 0000000..2bacf8f
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_IsSurrending.sqf
@@ -0,0 +1,38 @@
+
+private ["_grp","_dist","_ratio","_supstatus","_unitsneedammo","_typeofgrp","_haslos"];
+
+_grp = _this select 0;
+_dist = _this select 1;
+_ratio = _this select 2;
+_supstatus = _this select 3;
+_unitsneedammo = _this select 4;
+_typeofgrp = _this select 5;
+_haslos = _this select 6;
+
+
+If (_grp getvariable ["UPSMON_Grpmission",""] != "RETREAT") then
+{
+ If (UPSMON_SURRENDER) then
+ {
+ If ((random 100) <= (call (compile format ["UPSMON_%1_SURRENDER",(_grp getvariable ["UPSMON_Origin",[]]) select 5]))) then
+ {
+ If (!("air" in _typeofgrp)) then
+ {
+ If (_ratio > 2 || ((count units _grp) == count _unitsneedammo) || (_supstatus != "")) then
+ {
+ If (_supstatus == "SUPRESSED") then
+ {
+ If (_dist < 300) then
+ {
+ If (_haslos) then
+ {
+ _grp setvariable ["UPSMON_Grpmission","SURRENDER"];
+ _grpstatus = "BLUE";
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Isgrpstuck.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Isgrpstuck.sqf
new file mode 100644
index 0000000..0d00caa
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Isgrpstuck.sqf
@@ -0,0 +1,73 @@
+/****************************************************************
+File: UPSMON_Isgrpstuck.sqf
+Author: Azroul13
+
+Description:
+ Check if the group is stuck
+Parameter(s):
+
+Returns:
+ boolean
+****************************************************************/
+
+private ["_npc","_lastcurrpos","_currpos","_grp","_stuck","_rstuckControl"];
+
+_npc = _this select 0;
+_lastcurrpos = _this select 1;
+_currpos = _this select 2;
+_grp = group _npc;
+_stuck = false;
+
+//Stuck control
+If (alive _npc) then
+{
+ If (canmove _npc) then
+ {
+ If (!((vehicle _npc) iskindof "air")) then
+ {
+ If (_grp getvariable ["UPSMON_NOWP",0] == 0) then
+ {
+ If (_lastcurrpos select 0 == _currpos select 0 && _lastcurrpos select 1 == _currpos select 1) then
+ {
+ //time > _grp getvariable ["UPSMON_TIMEONTARGET",time]
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "DEFEND") then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "FORTIFY") then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "AMBUSH") then
+ {
+ If (!(_npc getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (!(_grp getVariable ["UPSMON_movetolanding",false])) then
+ {
+ If (!(_grp getvariable ["UPSMON_embarking",false])) then
+ {
+ If (!((vehicle _npc) getvariable ["UPSMON_disembarking",false])) then
+ {
+ _rstuckControl = (_grp getvariable ["UPSMON_RSTUCKCONTROL",0]) + 1;
+ _grp setvariable ["UPSMON_RSTUCKCONTROL",_rstuckControl];
+
+ If (_rstuckControl >= 10) then
+ {
+ //[_npc] call UPSMON_cancelstop;
+ //{if (alive _x && leader _x != _x) then {_x dofollow (leader _x)};} foreach units _grp;
+ _grp setvariable ["UPSMON_RSTUCKCONTROL",0];
+ _stuck = true;
+
+ if (UPSMON_Debug>0) then {player sidechat format["%1 stucked, moving",_grp getvariable ["UPSMON_Grpid",0]]};
+ if (UPSMON_Debug>0) then {diag_log format["%1 stuck for %2 seconds - trying to move again",_grp getvariable ["UPSMON_Grpid",0]]};
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
+
+_stuck
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_SetLeaderGrp.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_SetLeaderGrp.sqf
new file mode 100644
index 0000000..a299b4f
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_SetLeaderGrp.sqf
@@ -0,0 +1,39 @@
+/****************************************************************
+File: UPSMON_SetLeaderGrp.sqf
+Author: Azroul13
+
+Description:
+ Set the leader of the group
+Parameter(s):
+ <--- Unit or Group
+Returns:
+ ---> Leader
+****************************************************************/
+
+private ["_unit","_Leader", "_grp"];
+
+_unit = _this select 0;
+_grp = group _unit;
+_Leader = leader (_grp);
+
+if ((_unit iskindof "Man")) then {
+
+ if(_unit != _Leader) then {
+ _grp selectLeader _unit;
+ };
+
+} else {
+
+ if (!isnull(commander _unit) ) then {
+ _unit = commander _unit;
+ }else{
+ if (!isnull(driver _unit) ) then {
+ _unit = driver _unit;
+ }else{
+ _unit = gunner _unit;
+ };
+ };
+ _grp selectLeader _unit;
+};
+
+_Leader
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Supressfire.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Supressfire.sqf
new file mode 100644
index 0000000..a41b2a6
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_Supressfire.sqf
@@ -0,0 +1,56 @@
+private ["_units","_targetpos","_timeout","_delete","_unit","_target","_Pos","_direction"];
+
+_units = _this select 0;
+_targetpos = _this select 1;
+
+_timeout = time + 15;
+while {_timeout > time && {alive _x} count _units > 0} do
+{
+ {
+ _delete = false;
+ If (alive _x) then
+ {
+ _unit = _x;
+ _target = _targetpos;
+ If (typename _targetpos == "ARRAY") then
+ {
+ _Pos = [_targetpos,[0,20],[0,360],0,[0,100],0] call UPSMON_pos;
+ _target = createVehicle ["UserTexture1m_F",[_Pos select 0,_Pos select 1,1], [], 0, "NONE"];
+ _delete = true;
+ };
+
+ If ([_unit,_target,300,130] call UPSMON_Haslos) then
+ {
+ [_unit,_target,100] call UPSMON_DOwatch;
+ sleep 1;
+ _direction = [_unit, _target] call BIS_fnc_dirTo;
+ _unit setDir _direction;
+ _weapon = primaryweapon _unit;
+ _mode = getArray (configFile >> "cfgweapons" >> _weapon >> "modes");
+ _firemode = "SINGLE";
+ If (random 100 < 60) then
+ {
+ If ("fullauto_medium" in _mode) then {_firemode = "fullauto_medium";};
+ If ("short" in _mode) then {_firemode = "short";};
+ };
+ if ((_mode select 0) == "this") then {_mode = _weapon};
+ If (needReload _unit == 1) then {reload _unit};
+ _unit selectWeapon (primaryweapon _unit);
+ _unit forceWeaponFire [ weaponState _unit select 1,_firemode];
+ [_unit] spawn
+ {
+ sleep 5;
+ (_this select 0) doTarget ObjNull;
+ (_this select 0) dofire ObjNull;
+ (_this select 0) doWatch ObjNull;
+ };
+ };
+
+ if (_delete) then
+ {
+ [_target] spawn {sleep 5; Deletevehicle (_this select 0)};
+ };
+ };
+ } foreach _units;
+ sleep ((random 0.4) +0.4);
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_analysegrp.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_analysegrp.sqf
new file mode 100644
index 0000000..8b0944b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_analysegrp.sqf
@@ -0,0 +1,447 @@
+/****************************************************************
+File: UPSMON_analysegrp.sqf
+Author: Azroul13
+
+Description:
+ get all information about the group
+Parameter(s):
+ <--- Group
+Returns:
+ ----> type of the group (array) ["arti","infantry","incargo","tank","transport","armed","apc","car","ship","static","staticbag"]
+ ----> Capacity of the group (array) ["aa1","aa2","at1","at2","at3"] [AAcapability but without missile,AA missile,At Rocket,At missile,At gun]
+ ----> Assigned vehicles (array)
+****************************************************************/
+
+private ["_grp","_assignedvehicles","_typeofgrp","_capacityofgrp","_result","_vehicleClass","_MagazinesUnit","_Cargo","_gunner","_ammo","_irlock","_laserlock","_airlock","_checkbag","_staticteam","_points","_vehicle"];
+_grp = _this select 0;
+
+_assignedvehicles = [];
+_typeofgrp = [];
+_capacityofgrp = [];
+_engagementrange = 600;
+_result = [];
+_points = 0;
+
+if (({alive _x} count units _grp) == 0) exitwith {_result = [_typeofgrp,_capacityofgrp,_assignedvehicles,_engagementrange];_result;};
+
+_artibatteryarray = [];
+
+{
+ If (alive _x) then
+ {
+ if ((vehicle _x) != _x && !(Isnull assignedVehicle _x) && !(_x in (assignedCargo assignedVehicle _x))) then
+ {
+ if (!((assignedVehicle _x) in _assignedvehicles)) then
+ {
+ _vehicle = assignedVehicle _x;
+ _assignedvehicles pushback _vehicle;
+ _MagazinesUnit = (magazines _vehicle);
+ _Cargo = getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> "transportSoldier");
+ _armor = getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> "armor");
+ _support = tolower gettext (configFile >> "CfgVehicles" >> typeof _vehicle >> "vehicleClass");
+ _cfgArtillery = getnumber (configFile >> "cfgVehicles" >> typeOf (_vehicle) >> "artilleryScanner");
+ _repair = getnumber (configFile >> "cfgVehicles" >> typeOf (_vehicle) >> "transportRepair");
+ _fuel = getnumber (configFile >> "cfgVehicles" >> typeOf (_vehicle) >> "transportFuel");
+ _munsupply = getnumber (configFile >> "cfgVehicles" >> typeOf (_vehicle) >> "attendant");
+
+ _gunner = gunner _vehicle;
+ _ammorated = [];
+
+ _points = _points + 1;
+
+ If (!IsNull _gunner) then
+ {
+ If (alive _gunner) then
+ {
+ {
+ _ammo = tolower gettext (configFile >> "CfgMagazines" >> _x >> "ammo");
+ _irlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "irLock");
+ _laserlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "laserLock");
+ _airlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "airLock");
+ _hit = getNumber (configfile >> "CfgAmmo" >> _ammo >> "hit");
+
+ if (_airlock == 1) then
+ {
+ if (_ammo iskindof "BulletBase") then
+ {
+ If (!("aa1" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "aa1";
+ };
+ };
+ };
+
+ if (_airlock == 2) then
+ {
+ if (!(_ammo iskindof "BulletBase")) then
+ {
+ If (!("aa2" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "aa2";
+ };
+ };
+ };
+
+ if (_irlock>0 || _laserlock>0) then
+ {
+ if (_ammo iskindof "MissileBase") then
+ {
+ If (!("at2" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "at2";
+ };
+ };
+ };
+
+ if (_ammo iskindof "ShellBase") then
+ {
+ if (!("arti" in _typeofgrp)) then
+ {
+ If (!("at3" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "at3";
+ };
+ };
+ };
+
+ if (_ammo iskindof "BulletBase") then
+ {
+ if (_hit >= 40) then
+ {
+ If (!("at1" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "at1";
+ };
+ };
+ };
+
+ If (!(_ammo in _ammorated)) then
+ {
+ _points = _points + _hit;
+ _ammorated pushback _ammo;
+ };
+
+ } foreach _MagazinesUnit;
+ };
+ };
+
+ _points = _points + _armor;
+
+ If (_vehicle iskindof "car") then
+ {
+ If (!("car" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "car";
+ };
+
+ If (_armor >= 500) then
+ {
+ If (!("heavy" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "heavy";
+ };
+ };
+
+ If (_armor >= 250 && _armor < 500) then
+ {
+ If (!("medium" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "medium";
+ };
+ };
+
+ If (_armor < 250) then
+ {
+ If (!("light" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "light";
+ };
+ };
+ };
+
+ If (_vehicle iskindof "staticweapon") then
+ {
+ If (!("static" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "static";
+ };
+ };
+
+ If (_vehicle iskindof "air") then
+ {
+ If (!("air" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "air";
+ };
+ };
+
+ If (_vehicle iskindof "PLANE") then
+ {
+ If ("aa2" in _capacityofgrp || "aa1" in _capacityofgrp || "at1" in _capacityofgrp || "at2" in _capacityofgrp) then
+ {
+ If (!("plane" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "plane";
+ };
+ };
+ };
+
+ If (_vehicle iskindof "Ship") then
+ {
+ If (!("Ship" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "Ship";
+ };
+ };
+
+ If (_cargo >= 6) then
+ {
+ If (!("transport" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "transport";
+ };
+ };
+
+ If (!IsNull (Gunner _vehicle)) then
+ {
+ If (!("armed" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "armed";
+ _engagementrange = 1000;
+ };
+ };
+
+ If (_cfgArtillery == 1) then
+ {
+ If (!(_vehicle in _artibatteryarray)) then
+ {
+ _artibatteryarray pushback _vehicle;
+ _grp setvariable ["UPSMON_Battery",_artibatteryarray];
+ };
+
+ If (!("arti" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "arti";
+ };
+ };
+
+ If (_support == "Support") then
+ {
+ If (!("supply" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "supply";
+ };
+
+ If (_repair > 0) then
+ {
+ if (!("repair" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "repair";
+ };
+ };
+
+ If (_fuel > 0) then
+ {
+ if (!("fuel" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "fuel";
+ };
+ };
+
+ If (_munsupply > 0) then
+ {
+ if (!("ammo" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "ammo";
+ };
+ };
+
+ If (!("support" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "support";
+ };
+ };
+
+ if (_vehicle iskindof "tank" && !("tank" in _typeofgrp)) then
+ {_typeofgrp pushback "tank";};
+ if (_vehicle iskindof "Wheeled_APC_F" && !("apc" in _typeofgrp)) then
+ {_typeofgrp pushback "apc";};
+
+ };
+ }
+ else
+ {
+ If (vehicle _x != _x) then
+ {
+ If (!((assignedVehicle _x) in _assignedvehicles)) then
+ {
+ _assignedvehicles pushback (assignedVehicle _x);
+ }
+ };
+
+ _sweapon = secondaryWeapon _x;
+ _MagazinesUnit=(magazines _x);
+ _smagazineclass = [];
+ If (_sweapon != "") then
+ {
+ _smagazineclass = getArray (configFile >> "CfgWeapons" >> _sweapon >> "magazines");
+ };
+ _ammorated = [];
+
+ _points = _points + 1;
+
+ {
+ _ammo = tolower gettext (configFile >> "CfgMagazines" >> _x >> "ammo");
+ _irlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "irLock");
+ _laserlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "laserLock");
+ _airlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "airLock");
+ _hit = getNumber (configfile >> "CfgAmmo" >> _ammo >> "hit");
+
+ If (_airlock==2) then
+ {
+ if (!(_ammo iskindof "BulletBase")) then
+ {
+ If (_ammo in _smagazineclass) then
+ {
+ If (!("aa2" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "aa2";
+ };
+ };
+ };
+ };
+
+ If (_irlock>0 || _laserlock>0) then
+ {
+ if ((_ammo iskindof "RocketBase") || (_ammo iskindof "MissileBase")) then
+ {
+ If (_ammo in _smagazineclass) then
+ {
+ If (!("at2" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "at2";
+ };
+ };
+ };
+ };
+
+ If (_irlock==0 || _laserlock==0) then
+ {
+ if ((_ammo iskindof "RocketBase") || (_ammo iskindof "MissileBase")) then
+ {
+ If (_ammo in _smagazineclass) then
+ {
+ If (!("at1" in _capacityofgrp)) then
+ {
+ _capacityofgrp pushback "at1";
+ };
+ };
+ };
+ };
+
+ If (_ammo iskindof "ShellBase" || (_ammo iskindof "RocketBase") || (_ammo iskindof "MissileBase") && !(_ammo in _ammorated) && (_ammo in _smagazineclass)) then
+ {
+ _points = _points + _hit;
+ _ammorated pushback _ammo;
+ };
+ } foreach _MagazinesUnit;
+
+ if (!("infantry" in _typeofgrp)) then
+ {_typeofgrp pushback "infantry";};
+ };
+ _points = _points + ((1+(morale _x)) + (1-(damage _x)) + ((_x skillFinal "Endurance") + (_x skillFinal "courage")));
+ };
+
+} foreach units _grp;
+
+_checkbag = [_grp] call UPSMON_GetStaticTeam;
+_staticteam = _checkbag select 0;
+If (count _staticteam == 2) then
+{
+ _cfgArtillery = getnumber (configFile >> "cfgVehicles" >> (_checkbag select 1) >> "artilleryScanner");
+
+ _capacityofgrp pushback ["staticbag"];
+ _engagementrange = 1000;
+
+ If (_cfgArtillery == 1) then
+ {
+ If (!("arti" in _typeofgrp)) then
+ {
+ _typeofgrp pushback "arti";
+ };
+
+ If (!((_staticteam select 0) in _artibatteryarray)) then
+ {
+ _artibatteryarray pushback _staticteam;
+ _grp setvariable ["UPSMON_Battery",_artibatteryarray];
+ };
+
+ If (count (_grp getvariable ["UPSMON_Mortarmun",[]]) == 0) then
+ {
+ _rounds = [_checkbag select 1] call UPSMON_GetDefaultmun;
+ _grp setvariable ["UPSMON_Mortarmun",_rounds];
+ };
+ };
+};
+
+[_grp,_typeofgrp] call UPSMON_AddtoArray;
+
+_points = _points;
+
+{
+ If (!IsNull _x) then
+ {
+ If ((_renfgroup getvariable ["UPSMON_GrpToRenf",ObjNull]) == _grp) then
+ {
+ If (({alive _x && !(captive _x)} count units _x) > 0) then
+ {
+ _points = _points + (_x getvariable ["UPSMON_Grpratio",0]);
+ };
+ };
+ };
+} foreach (_grp getvariable ["UPSMON_RenfGrps",[]]);
+
+_grp setvariable ["UPSMON_Grpratio",_points];
+_grp setvariable ["UPSMON_GroupCapacity",_capacityofgrp];
+_grp setvariable ["UPSMON_typeofgrp",_typeofgrp];
+_grp setvariable ["UPSMON_Assignedvehicle",_assignedvehicles];
+
+If (count _assignedvehicles > 0) then
+{
+ _array = [];
+
+ {
+ If (canmove _x) then
+ {
+ If (driver _x in units _grp) then
+ {
+ _array pushback _x;
+ };
+ };
+ } foreach _assignedvehicles;
+ _grp setvariable ["UPSMON_LastAssignedvehicle",_array];
+};
+
+If (count (_grp getvariable ["UPSMON_LastAssignedvehicle",_assignedvehicles]) > 0) then
+{
+ _array = [];
+
+ {
+ If (!IsNull _x) then
+ {
+ If (canmove _x) then
+ {
+ If (driver _x in units _grp) then
+ {
+ _array pushback _x;
+ };
+ };
+ };
+ } foreach _assignedvehicles;
+ _grp setvariable ["UPSMON_LastAssignedvehicle",_array];
+};
+
+//if (UPSMON_Debug>0) then {diag_log format ["Grpcompos/ typeofgrp:%1 Capacity:%2 Assignedvehicles:%3 range:%4 Points:%5",_typeofgrp,_capacityofgrp,_assignedvehicles,_engagementrange,_points];};
+
+_result = [_typeofgrp,_capacityofgrp,_assignedvehicles,_engagementrange];
+_result;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checkallied.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checkallied.sqf
new file mode 100644
index 0000000..bd03663
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checkallied.sqf
@@ -0,0 +1,37 @@
+/****************************************************************
+File: UPSMON_checkallied.sqf
+Author: Azroul13
+
+Description:
+ Are they any allied near the group
+ Use for Surrending condition
+Parameter(s):
+ <--- leader
+ <--- Searching radius
+ <--- Unit Side
+Returns:
+ Array [[Eni units],[Allied Units]]
+****************************************************************/
+
+private ["_npc","_mennear","_result","_radius"];
+
+_npc = _this select 0;
+_radius = _this select 1;
+_side = side _npc;
+
+_mennear = _npc nearTargets 180;
+_result = false;
+_allied = [];
+_eny = [];
+_enemySides = _npc call BIS_fnc_enemySides;
+
+{
+ _unit = _x select 4;
+ _unitside = _x select 2;
+ If ((alive _unit) && (_unitside == _side) && !(_unit in (units _npc)) && !(captive _unit)) then {_allied = _allied + [_x];};
+ If ((alive _unit) && (_unitside in _enemySides) && _npc knowsabout _unit >= UPSMON_knowsAboutEnemy) then {_eny = _eny + [_x];}
+} foreach _mennear;
+
+
+_result = [_allied,_eny];
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checkmunition.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checkmunition.sqf
new file mode 100644
index 0000000..d586521
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checkmunition.sqf
@@ -0,0 +1,79 @@
+/****************************************************************
+File: UPSMON_checkmunition.sqf
+Author: Azroul13
+
+Description:
+ Check if unit in the group is out of munition
+Parameter(s):
+ <--- leader
+Returns:
+ Array of units who needs ammo
+****************************************************************/
+
+private ["_npc","_units","_result","_unit","_weapon","_magazineclass","_magazines","_weapon","_sweapon","_mags","_magazinescount","_smagazineclass"];
+
+_npc = _this select 0;
+_units = units _npc;
+_result = [];
+_minmag = 2;
+
+{
+ If (!IsNull _x) then
+ {
+ If (alive _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ _unit = _x;
+ _magsneeded = [[],[]];
+ _weapon = primaryWeapon _unit;
+ _sweapon = secondaryWeapon _unit;
+ _magazineclass = getArray (configFile / "CfgWeapons" / _weapon / "magazines");
+ _smagazineclass = [];
+ If (_sweapon != "") then {_smagazineclass = getArray (configFile / "CfgWeapons" / _sweapon / "magazines");};
+ _mags = magazinesAmmoFull _unit;
+
+ If (count _smagazineclass > 0) then
+ {
+ _magazinescount = {(_x select 0) in _smagazineclass} count _mags;
+ _arr = [];
+ {_arr pushback _x} foreach _smagazineclass;
+ _magsneeded set [0,_arr];
+ If (_magazinescount == 0) then
+ {
+ If (!(_unit in _result)) then
+ {
+ _result pushback _unit;
+ };
+ };
+ };
+
+ If (count _magazineclass > 0) then
+ {
+ _magazinescount = {(_x select 0) in _magazineclass} count _mags;
+ _arr = [];
+ {_arr pushback _x} foreach _magazineclass;
+ _magsneeded set [1,_arr];
+ If (_magazinescount <= 2) then
+ {
+ If (!(_unit in _result)) then
+ {
+ _result pushback _unit;
+ };
+ };
+ };
+
+ If (_unit in _result) then
+ {
+ if (UPSMON_AllowRearm) then
+ {
+ [_unit,_magsneeded] spawn UPSMON_Rearm;
+ };
+ };
+ };
+ };
+ };
+
+} foreach _units;
+
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checksizetargetgrp.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checksizetargetgrp.sqf
new file mode 100644
index 0000000..79efe81
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_checksizetargetgrp.sqf
@@ -0,0 +1,34 @@
+/****************************************************************
+File: UPSMON_checksizetargetgrp.sqf
+Author: Azroul13
+
+Description:
+ Check how many suplementary targets are near the revealed target
+ Use for Artillery fire condition: if (count([_attackpos,50,EAST] call UPSMON_checksizetargetgrp) >= 4) then {_artillery=true}
+Parameter(s):
+ <--- unit
+ <--- Searching radius
+ <--- Unit Side
+Returns:
+ Array of units
+****************************************************************/
+
+private ["_mennear","_result","_pos","_radius"];
+
+_pos = _this select 0;
+_radius = _this select 1;
+_side = _this select 2;
+
+_mennear = _pos nearentities [["CAManBase"],_radius];
+_enemySides = _side call BIS_fnc_enemySides;
+_result = false;
+_allied = [];
+_eny = [];
+
+{
+ If ((side _x in _enemySides) && _npc knowsabout _x >= UPSMON_knowsAboutEnemy) then {_eny = _eny + [_x];}
+} foreach _mennear;
+
+
+_result = [_eny];
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_composeteam.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_composeteam.sqf
new file mode 100644
index 0000000..1603108
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_composeteam.sqf
@@ -0,0 +1,173 @@
+/****************************************************************
+File: UPSMON_composeteam.sqf
+Author: Azroul13
+
+Description:
+ Each units of the group is assigned to a team
+Parameter(s):
+ <--- group
+Returns:
+ ----> Support Team (array of units)
+ ----> Assault Team (array of units)
+ ----> ATteam (array of units)
+ ----> AAteam (array of units)
+****************************************************************/
+private ["_grp","_units","_Assltteam","_Supportteam","_Atteam","_result","_units","_at","_unit","_weapon","_sweapon","_typeweapon"];
+
+_grp = _this select 0;
+
+_Assltteam = [];
+_Supportteam = [];
+_Atteam = [];
+_AAteam = [];
+_snpteam = [];
+_mgteam = [];
+_result = [];
+
+if (({alive _x} count units _grp) == 0) exitwith {_result = [];_result;};
+
+// add leader and people to team 1
+_Supportteam pushback (vehicle (leader _grp));
+_unitsleft = units _grp;
+_unitsleft = _unitsleft - [leader _grp];
+_unitsinvalid = [];
+_vehiclesnbr = 0;
+
+//Add vehicles with gunner in the support team
+{
+ If (alive _x) then
+ {
+ If (vehicle _x != _x) then
+ {
+ If (!(_x in (assignedCargo assignedVehicle _x))) then
+ {
+ If (!IsNull (gunner vehicle _x)) then
+ {
+ If (!(vehicle _x in _Supportteam)) then
+ {
+ _Supportteam pushback (vehicle _x);
+ _vehiclesnbr = _vehiclesnbr + 1;
+ };
+
+ _unitsinvalid pushback _x;
+ };
+ };
+ };
+ }
+ else
+ {
+ _unitsinvalid pushback _x;
+ };
+} foreach _unitsleft;
+
+_unitsleft = _unitsleft - _Supportteam;
+_unitsleft = _unitsleft - _unitsinvalid;
+
+
+{
+ If (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (_x == vehicle _x) then
+ {
+ _weapon = currentweapon _x;
+ _sweapon = secondaryWeapon _x;
+ _typeweapon = tolower gettext (configFile / "CfgWeapons" / _weapon / "cursor");
+ if (_sweapon != "") then
+ {
+ _smagazineclass = (getArray (configFile / "CfgWeapons" / _sweapon / "magazines")) select 0;
+ _ammo = tolower gettext (configFile >> "CfgMagazines" >> _smagazineclass >> "ammo");
+ _irlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "irLock");
+ _laserlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "laserLock");
+ _airlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "airLock");
+
+ if (_airlock==2 && !(_ammo iskindof "BulletBase") && !(_x in _AAteam)) then
+ {_AAteam pushback _x};
+ if ((_irlock==0 || _laserlock==0) &&
+ ((_ammo iskindof "RocketBase") || (_ammo iskindof "MissileBase") || (_ammo iskindof "RocketBase") || (_ammo iskindof "MissileBase")) && !(_x in _ATteam)) then
+ {_Atteam pushback _x};
+ };
+
+ if (!(_x in _Supportteam) && (_typeweapon in ["mg","srifle"] || _sweapon != "")) then
+ {
+ _Supportteam pushback _x;
+ If (_typeweapon == "mg") then {_mgteam pushback _x;};
+ If (_typeweapon == "srifle") then {_snpteam pushback _x;};
+ };
+ };
+ }
+ else
+ {
+ _unitsinvalid pushback _x;
+ };
+ }
+ else
+ {
+ _unitsinvalid pushback _x;
+ };
+} foreach _unitsleft;
+
+//Add the rest to the Assltteam
+
+_unitsleft = _unitsleft - _unitsinvalid;
+_Assltteam = _unitsleft - _Supportteam;
+
+
+If ({alive _x && vehicle _x == _x} count units _grp <= 4) then
+{
+ If (_vehiclesnbr == 0) then
+ {
+ _Assltteam = units _grp;
+ }
+ else
+ {
+ if (count _Assltteam <= 1 && count _Supportteam > 1) then
+ {
+ _arr2 = _Supportteam;
+
+ {
+ If (_x != vehicle (leader _grp)) then
+ {
+ If (count _arr2 > count _Assltteam) then
+ {
+ _Assltteam pushback _x;
+ _arr2 = _arr2 - [_x];
+ };
+ };
+ } foreach _Supportteam;
+
+ _Supportteam = _arr2;
+ };
+ };
+}
+else
+{
+ if (count _Assltteam <= 1 && count _Supportteam > 4) then
+ {
+ _arr2 = _Supportteam;
+ {
+ If (_x != vehicle (leader _grp)) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (count _arr2 > count _Assltteam) then
+ {
+ _Assltteam pushback _x;
+ _arr2 = _arr2 - [_x];
+ };
+ };
+ };
+ } foreach _Supportteam;
+
+ _Supportteam = _arr2;
+ };
+};
+
+
+
+{_x assignTeam "RED"} foreach _Assltteam;
+{_x assignTeam "BLUE"} foreach _Supportteam;
+
+_result = [_Supportteam,_Assltteam,_Atteam,_AAteam];
+_result;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getNearestSoldier.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getNearestSoldier.sqf
new file mode 100644
index 0000000..70ab7da
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getNearestSoldier.sqf
@@ -0,0 +1,22 @@
+/****************************************************************
+File: UPSMON_getNearestSoldier.sqf
+Author: Monsada
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+
+private["_units","_position","_near"];
+
+_position = _this select 0;
+_units = _this select 1;
+
+_near = [_units, [], {_position distance _x}, "ASCEND"] call BIS_fnc_sortBy;;
+_near = _near select 0;
+
+
+_near
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getleader.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getleader.sqf
new file mode 100644
index 0000000..c97cd7d
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getleader.sqf
@@ -0,0 +1,112 @@
+/****************************************************************
+File: UPSMON_getleader.sqf
+Author: Monsada
+
+Description:
+ Check if leader is alive and if not search for a replacement in the group
+Parameter(s):
+ <--- leader
+ <--- group
+Returns:
+ leader
+****************************************************************/
+
+private ["_npc","_grp","_members","_list"];
+
+_npc = _this select 0;
+_grp = _this select 1;
+_members = units _grp;
+
+//sleep 0.05;
+if (!alive _npc) then
+{
+
+ //soldier not in vehicle takes the lead or not in tank vehicle
+ _list = [];
+ {
+ if (alive _x) then
+ {
+ If (!isPlayer _x) then
+ {
+ if (canmove _x) then
+ {
+ _points = 0;
+ If (_x == vehicle _x) then
+ {
+ switch (rank _x) do
+ {
+ case "CORPORAL":
+ {
+ _points = _points + 20;
+ };
+ case "SERGEANT":
+ {
+ _points = _points + 30;
+ };
+ case "LIEUTENANT":
+ {
+ _points = _points + 40;
+ };
+ case "MAJOR":
+ {
+ _points = _points + 50;
+ };
+ case "COLONEL":
+ {
+ _points = _points + 60;
+ };
+ case "PRIVATE":
+ {
+ _points = _points + 10;
+ };
+ };
+ }
+ else
+ {
+ If (vehicle _x iskindof "TANK" || vehicle _x iskindof "Wheeled_APC") then
+ {
+ If ((assignedVehicleRole _x) select 0 == "Commander") then
+ {
+ _points = _points + 80;
+ };
+
+ If ((assignedVehicleRole _x) select 0 == "Gunner") then
+ {
+ _points = _points + 40;
+ };
+ };
+ };
+
+ _list pushback [_x,_points];
+ };
+ };
+ };
+ } foreach _members;
+
+ If (count _list > 0) then
+ {
+ _list = [_list, [], {(_x select 1)}, "DESCEND"] call BIS_fnc_sortBy;
+ _npc = (_list select 0) select 0;
+ };
+ //if no soldier out of vehicle takes any
+ if (!alive _npc ) then
+ {
+ {
+ if (alive _x && canmove _x) exitwith {_npc = _x;};
+ } foreach _members;
+ };
+
+ //If not alive or already leader or is player exits
+ {
+ {
+ if (alive _x && !isPlayer _x) exitwith {_npc = [_npc,_grp] call UPSMON_getleader;};
+ } foreach _members;
+ };
+
+ if (leader _grp == _npc) exitwith {_npc};
+
+ //Set new _npc as leader
+ _grp selectLeader _npc;
+};
+
+_npc // return
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getunits.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getunits.sqf
new file mode 100644
index 0000000..e660cb6
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_getunits.sqf
@@ -0,0 +1,41 @@
+/****************************************************************
+File: UPSMON_getunits.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Array of units
+Returns:
+ Array of units
+****************************************************************/
+
+private ["_units","_validunits"];
+
+_units = _this select 0;
+
+_validunits = [];
+
+{
+ if (alive _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (_x getvariable ["UPSMON_Supstatus",""] != "SUPRESSED") then
+ {
+ If (canmove _x) then
+ {
+ If (canstand _x) then
+ {
+ If (!([_x] call UPSMON_Inbuilding)) then
+ {
+ _validunits pushback _x;
+ };
+ };
+ };
+ };
+ };
+ };
+}foreach _units;
+
+_validunits
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_grptype.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_grptype.sqf
new file mode 100644
index 0000000..11f32a0
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_grptype.sqf
@@ -0,0 +1,23 @@
+/****************************************************************
+File: UPSMON_grptype.sqf
+Author: Azroul13
+
+Description:
+ get the type of the group
+Parameter(s):
+ <--- leader
+Returns:
+ ----> Group type ("Isman"/"Iscar"/"IsAir"/"Isboat"/"Isdiver")
+****************************************************************/
+private [];
+
+_npc = _this select 0;
+_type = "";
+
+If ("LandVehicle" countType [vehicle _npc]>0) then {_type = "Iscar"};
+If ("Ship" countType [vehicle _npc]>0) then {_type = "Isboat"};
+If ("Air" countType [vehicle _npc]>0) then {_type = "IsAir"};
+If (["diver", (typeOf (leader _npc))] call BIS_fnc_inString) then {_type = "Isdiver"};
+If (_type == "") then {_type = "Isman"};
+
+_type
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Group/fnc/UPSMON_supstatestatus.sqf b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_supstatestatus.sqf
new file mode 100644
index 0000000..fd3505d
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Group/fnc/UPSMON_supstatestatus.sqf
@@ -0,0 +1,99 @@
+/****************************************************************
+File: UPSMON_supstatestatus.sqf
+Author: Azroul13
+
+Description:
+ Check if the group is under fire
+ Activated only when TPWCAS script is present
+Parameter(s):
+ <--- unit
+Returns:
+ Boolean
+****************************************************************/
+ //Check if the group is under fire
+private ["_grp","_supstatus","_unitsnbr","_tpwcas_running","_statuslist"];
+
+_grp = _this select 0;
+_supstatus = "";
+
+_unitsnbr = count (units _grp);
+_tpwcas_running = if (!isNil "tpwcas_running") then {true} else {false};
+_statuslist = [];
+{
+ If (alive _x) then
+ {
+ _x setvariable ["UPSMON_SUPSTATUS",""];
+ If (_x in UPSMON_GOTHIT_ARRAY) then
+ {
+ UPSMON_GOTHIT_ARRAY = UPSMON_GOTHIT_ARRAY - [_x];
+ If (damage _x < 0.3) then
+ {
+ _statuslist pushback "hit";
+ }
+ else
+ {
+ _statuslist pushback "wounded";
+ };
+
+ _x setvariable ["UPSMON_SUPSTATUS","UNDERFIRE"];
+ };
+
+ if (_tpwcas_running) then
+ {
+ If (_x getvariable "tpwcas_supstate" == 3) then
+ {
+ _statuslist pushback "supressed";
+ _x setvariable ["UPSMON_SUPSTATUS","SUPRESSED"];
+ };
+ If (_x getvariable "tpwcas_supstate" == 2) then
+ {
+ _statuslist pushback "hit";
+ _x setvariable ["UPSMON_SUPSTATUS","UNDERFIRE"];
+ };
+ };
+
+ If (isNil "bdetect_enable") then
+ {
+ If (_x getVariable ["bcombat_suppression_level", 0] >= 20 && _x getVariable ["bcombat_suppression_level", 0] < 75) then
+ {
+ _statuslist pushback "hit";
+ _x setvariable ["UPSMON_SUPSTATUS","UNDERFIRE"];
+ };
+ If (_x getVariable ["bcombat_suppression_level", 0] >= 75) then
+ {
+ _statuslist pushback "supressed";
+ _x setvariable ["UPSMON_SUPSTATUS","SUPRESSED"];
+ };
+ };
+ }
+ else
+ {
+ if (_x in UPSMON_GOTKILL_ARRAY) then
+ {
+ UPSMON_GOTKILL_ARRAY = UPSMON_GOTKILL_ARRAY - [_x];
+ _statuslist pushback "dead";
+ };
+ };
+} foreach units _grp;
+
+If ({_x == "supressed" || _x == "wounded" || _x == "dead"} count _statuslist >= _unitsnbr) then
+{
+ If ({_x == "supressed"} count _statuslist < {_x == "wounded" || _x == "dead"} count _statuslist) then
+ {
+ _supstatus = "INCAPACITED"
+ }
+ else
+ {
+ _supstatus = "SUPRESSED"
+ };
+};
+
+If (_supstatus == "") then
+{
+ If ("hit" in _statuslist || "wounded" in _statuslist || "dead" in _statuslist || "supressed" in _statuslist) then
+ {
+ _supstatus = "UNDERFIRE"
+ };
+};
+
+_supstatus
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Init.sqf b/scripts/UPSMON/COMMON/Init.sqf
new file mode 100644
index 0000000..de6c5fc
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Init.sqf
@@ -0,0 +1,8 @@
+//Group
+UPSMON_SetLeaderGrp = call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\UPSMON_SetLeaderGrp.sqf";
+
+UPSMON_GetParams = call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\Params\UPSMON_GetParams.sqf";
+UPSMON_GetGroupbehaviour = call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\Params\UPSMON_GetGroupbehaviour.sqf";
+UPSMON_GetGroupformation = call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\Params\UPSMON_GetGroupformation.sqf";
+UPSMON_GetGroupspeed = call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\Params\UPSMON_GetGroupspeed.sqf";
+UPSMON_SetEventhandlers = call compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Group\Params\UPSMON_SetEventhandlers.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/MP/fnc/UPSMON_fnc_setVehicleInit.sqf b/scripts/UPSMON/COMMON/MP/fnc/UPSMON_fnc_setVehicleInit.sqf
new file mode 100644
index 0000000..9c66a24
--- /dev/null
+++ b/scripts/UPSMON/COMMON/MP/fnc/UPSMON_fnc_setVehicleInit.sqf
@@ -0,0 +1,26 @@
+/****************************************************************
+File: UPSMON_GetIn_NearestCombat.sqf
+Author: Ollem
+
+Description:
+ Replacement of "setvehicleinit" command. Add init line to a spawned AI.
+Parameter(s):
+ <--- netid object
+ <--- unit init
+Returns:
+ Nothing
+****************************************************************/
+
+
+private ["_netID","_unit","_unitinit"];
+
+_netID = _this select 0;
+_unit = objectFromNetID _netID;
+_unitinit = _this select 1;
+_unitstr = "_unit";
+
+_index=[_unitinit,"this",_unitstr] call UPSMON_Replace;
+
+call compile format ["%1",_index];
+
+if (UPSMON_Debug>0) then { diag_log format ["UPSMON 'UPSMON_fnc_setVehicleInit': %1 %2 %3",_unitinit,_index,_unit]; };
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/MP/fnc/UPSMON_fnc_setVehicleVarName.sqf b/scripts/UPSMON/COMMON/MP/fnc/UPSMON_fnc_setVehicleVarName.sqf
new file mode 100644
index 0000000..dbe57bc
--- /dev/null
+++ b/scripts/UPSMON/COMMON/MP/fnc/UPSMON_fnc_setVehicleVarName.sqf
@@ -0,0 +1,23 @@
+/****************************************************************
+File: UPSMON_fnc_setVehicleVarName.sqf
+Author: Ollem
+
+Description:
+ Replacement of "setvehicleinit" command.
+Parameter(s):
+ <--- netid object
+ <--- unit name
+Returns:
+ Nothing
+****************************************************************/
+
+private ["_netID","_unit","_unitname"];
+
+_netID = _this select 0;
+_unit = objectFromNetID _netID;
+_unitname = _this select 1;
+
+_unit setVehicleVarName _unitname;
+_unit call compile format ["%1=_This; PublicVariable ""%1""",_unitname];
+
+if (UPSMON_Debug>0) then { diag_log format ["UPSMON 'UPSMON_fnc_setVehicleVarName': %1=_This; PublicVariable ""%1""",_unitname]; };
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/MP/init.sqf b/scripts/UPSMON/COMMON/MP/init.sqf
new file mode 100644
index 0000000..7a815ad
--- /dev/null
+++ b/scripts/UPSMON/COMMON/MP/init.sqf
@@ -0,0 +1,3 @@
+
+UPSMON_fnc_setVehicleInit = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\MP\fnc\UPSMON_fnc_setVehicleInit.sqf";
+UPSMON_fnc_setVehicleVarName = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\MP\fnc\UPSMON_fnc_setVehicleVarName.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Params/Init.sqf b/scripts/UPSMON/COMMON/Params/Init.sqf
new file mode 100644
index 0000000..0755d82
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/Init.sqf
@@ -0,0 +1,21 @@
+
+UPSMON_GetParams = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_GetParams.sqf";
+
+UPSMON_GetGroupbehaviour = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_GetGroupbehaviour.sqf";
+UPSMON_GetGroupformation = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_GetGroupformation.sqf";
+UPSMON_GetGroupspeed = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_GetGroupspeed.sqf";
+
+UPSMON_SetEventhandlers = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_SetEventhandlers.sqf";
+
+UPSMON_GetRespawndelay = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_GetRespawndelay.sqf";
+UPSMON_GetRespawnpos = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_GetRespawnpos.sqf";
+UPSMON_GetRespawntime = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_GetRespawntime.sqf";
+
+UPSMON_SetClones = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_SetClones.sqf";
+UPSMON_Settemplate = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_Settemplate.sqf";
+UPSMON_SetmarkerArea = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_SetmarkerArea.sqf";
+UPSMON_SetRenfParam = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_SetRenfParam.sqf";
+
+UPSMON_NOSMOKE = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_NOSMOKE.sqf";
+
+UPSMON_BacktoNormal = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\Params\fnc\UPSMON_BacktoNormal.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_BacktoNormal.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_BacktoNormal.sqf
new file mode 100644
index 0000000..7c786e2
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_BacktoNormal.sqf
@@ -0,0 +1,29 @@
+/****************************************************************
+File: UPSMON_BackToNormal.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- group
+Returns:
+ Nothing
+****************************************************************/
+private["_npc","_Ucthis","_behaviour"];
+
+_grp = _this select 0;
+
+_grp setvariable ["UPSMON_Grpstatus","GREEN"];
+
+If (_grp getvariable ["UPSMON_NOWP",0] > 0) then
+{
+ [_grp,((_grp getvariable "UPSMON_Origin") select 0),"MOVE",((_grp getvariable "UPSMON_Origin") select 1),((_grp getvariable "UPSMON_Origin") select 2),((_grp getvariable "UPSMON_Origin") select 3),"YELLOW",1] spawn UPSMON_DocreateWP;
+}
+else
+{
+ _grp setbehaviour ((_grp getvariable "UPSMON_Origin") select 1);
+ _grp setspeedmode ((_grp getvariable "UPSMON_Origin") select 2);
+ _grp setformation ((_grp getvariable "UPSMON_Origin") select 3);
+};
+
+_grp setvariable ["UPSMON_Grpmission",_grp getvariable "UPSMON_OrgGrpmission"];
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupbehaviour.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupbehaviour.sqf
new file mode 100644
index 0000000..03dd9a8
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupbehaviour.sqf
@@ -0,0 +1,29 @@
+/****************************************************************
+File: UPSMON_GetGroupbehaviour.sqf
+Author: Azroul13
+
+Description:
+ Get unit behaviour
+Parameter(s):
+ <--- leader
+ <--- UPSMON parameters
+Returns:
+ ---> behaviour of the group
+****************************************************************/
+private["_npc","_Ucthis","_behaviour"];
+
+_npc = _this select 0;
+_Ucthis = _this select 1;
+
+_behaviour = Behaviour _npc;
+
+// set behaviour modes (or not)
+if ("CARELESS" in _UCthis) then {_behaviour = "CARELESS"};
+if ("SAFE" in _UCthis) then {_behaviour = "SAFE"};
+if ("AWARE" in _UCthis) then {_behaviour = "AWARE"};
+if ("COMBAT" in _UCthis) then {_behaviour = "COMBAT"};
+if ("STEALTH" in _UCthis) then {_behaviour = "STEALTH"};
+
+_behaviour
+
+
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupformation.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupformation.sqf
new file mode 100644
index 0000000..e363241
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupformation.sqf
@@ -0,0 +1,28 @@
+/****************************************************************
+File: UPSMON_GetGroupformation.sqf
+Author: Azroul13
+
+Description:
+ Get unit behaviour
+Parameter(s):
+ <--- leader
+ <--- UPSMON parameters
+Returns:
+ ---> formation
+****************************************************************/
+private["_npc","_Ucthis","_formation"];
+
+_npc = _this select 0;
+_Ucthis = _this select 1;
+
+_formation = Formation _npc;
+
+// set formation modes (or not)
+If ("COLUMN" in _UCthis) then {_formation = "COLUMN";};
+If ("STAG COLUMN" in _UCthis) then {_formation = "STAG COLUMN";};
+If ("WEDGE" in _UCthis) then {_formation = "WEDGE";};
+If ("VEE" in _UCthis) then {_formation = "VEE";};
+If ("LINE" in _UCthis) then {_formation = "LINE";};
+If ("FILE" in _UCthis) then {_formation = "FILE";};
+
+_formation
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupspeed.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupspeed.sqf
new file mode 100644
index 0000000..9c88122
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetGroupspeed.sqf
@@ -0,0 +1,26 @@
+/****************************************************************
+File: UPSMON_GetGroupspeed.sqf
+Author: Azroul13
+
+Description:
+ Get unit speed mode
+Parameter(s):
+ <--- leader
+ <--- UPSMON parameters
+Returns:
+ ---> speed mode
+****************************************************************/
+private["_npc","_Ucthis","_speed"];
+
+_npc = _this select 0;
+_Ucthis = _this select 1;
+
+_speed = Speedmode _npc;
+
+// set initial speed
+_noslow = if ("NOSLOW" in _UCthis) then {"NOSLOW"} else {"SLOW"};
+if ("LIMITED" in _UCthis) then {_speed = "LIMITED"};
+if ("NORMAL" in _UCthis) then {_speed = "NORMAL"};
+if ("FULL" in _UCthis || _noslow == "NOSLOW") then {_speed = "FULL"};
+
+_speed
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetParams.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetParams.sqf
new file mode 100644
index 0000000..6758140
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_GetParams.sqf
@@ -0,0 +1,25 @@
+/****************************************************************
+File: UPSMON_GetParams.sqf
+Author: Azroul13
+
+Description:
+ Convert argument list to uppercase
+Parameter(s):
+ <--- Parameters
+Returns:
+ ---> Parameters
+****************************************************************/
+
+private["_Params","_UCthis","_i","_e"];
+
+_Params = _this select 0;
+_UCthis = [];
+
+for [{_i=0},{_i UPSMON_USE_SMOKE) then
+{
+ If (_grp getvariable ["UPSMON_SmokeTime",0] < time) then
+ {
+ If (!(_grp getvariable ["UPSMON_NOSMOKE",false])) then
+ {
+ _nosmoke = false;
+ };
+ };
+};
+
+_nosmoke
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetClones.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetClones.sqf
new file mode 100644
index 0000000..2ef4610
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetClones.sqf
@@ -0,0 +1,27 @@
+/****************************************************************
+File: UPSMON_SetClones.sqf
+Author: Azroul
+
+Description:
+
+Parameter(s):
+ <--- Parameters of UPSMON
+Returns:
+ nothing
+****************************************************************/
+private ["_Ucthis","_mincopies","_maxcopies","_membertypes"];
+
+_Ucthis = _this select 0;
+_membertypes = _this select 1;
+
+_mincopies = ["MIN:",0,_UCthis] call UPSMON_getArg;
+_maxcopies = ["MAX:",0,_UCthis] call UPSMON_getArg;
+if (_mincopies>_maxcopies) then {_maxcopies=_mincopies};
+if (_maxcopies>140) exitWith {hint "Cannot create more than 140 groups!"};
+
+if (_maxcopies>0) then
+{
+ _Ucthis = ["MIN:",0,_UCthis] call UPSMON_setArg;
+ _Ucthis = ["MAX:",0,_Ucthis] call UPSMON_setArg;
+ [_Ucthis,_mincopies,_maxcopies,_membertypes] call UPSMON_Clones;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetEventhandlers.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetEventhandlers.sqf
new file mode 100644
index 0000000..f5c5ca7
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetEventhandlers.sqf
@@ -0,0 +1,51 @@
+/****************************************************************
+File: UPSMON_SetEventhandlers.sqf
+Author: Azroul13
+
+Description:
+ Convert argument list to uppercase
+Parameter(s):
+ <--- Members of the group
+ <--- Parameters
+Returns:
+ Nothing
+****************************************************************/
+
+private["_members","_UCthis","_grpid","_deletedead"];
+
+_members = _this select 0;
+_UCthis = _this select 1;
+_grpid = _this select 2;
+
+_deletedead = ["DELETE:",0,_UCthis] call UPSMON_getArg;
+{
+ _x setVariable ["UPSMON_grpid", _grpid, false];
+ If (_x != vehicle _x && (vehicle _x) getVariable ["UPSMON_grpid",0] != _grpid) then {(vehicle _x) setVariable ["UPSMON_grpid", _grpid, false];};
+ sleep 0.05;
+
+ if (side _x != civilian) then
+ {//soldiers
+ _x AddEventHandler ["hit", {nul = _this spawn UPSMON_SN_EHHIT}];
+ sleep 0.05;
+ _x AddEventHandler ["killed", {nul = _this spawn UPSMON_SN_EHKILLED}];
+ //_x AddEventHandler ["fired", {nul = _this spawn UPSMON_SN_EHFIRED}];
+ }
+ else
+ {//civ
+ if (!isnil "_x") then
+ {
+ sleep 0.05;
+ _x AddEventHandler ["firedNear", {nul = _this spawn UPSMON_SN_EHFIREDNEAR}];
+ sleep 0.05;
+ _x AddEventHandler ["killed", {nul = _this spawn UPSMON_SN_EHKILLEDCIV}];
+ sleep 0.05;
+ };
+ };
+
+ if (_deletedead>0) then
+ {
+ _x addEventHandler['killed',format["[_this select 0,%1] spawn UPSMON_deleteDead",_deletedead]];
+ sleep 0.01;
+ };
+} foreach _members;
+
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetMarkerArea.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetMarkerArea.sqf
new file mode 100644
index 0000000..a6d6f0a
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetMarkerArea.sqf
@@ -0,0 +1,69 @@
+/****************************************************************
+File: UPSMON_SetMarkerArea.sqf
+Author: Azroul13
+
+Description:
+ Get unit behaviour
+Parameter(s):
+ <--- group
+ <--- Marker Area of the group
+ <--- UPSMON parameters
+Returns:
+
+****************************************************************/
+private["_grp","_areamarker","_Ucthis","_showmarker","_groups","_marker","_in","_id"];
+
+_grp = _this select 0;
+_areamarker = _this select 1;
+_Ucthis = _this select 2;
+
+_showmarker = "HIDEMARKER";
+_in = false;
+_groups = [];
+_id = - 1;
+{
+ _id = _id + 1;
+ _marker = _x select 0;
+ if (UPSMON_Debug > 0) then
+ {
+ Hint format ["AreaMarker:%1 marker:%2 array:%3",_areamarker,_marker,_x];
+ diag_log format ["AreaMarker:%1 marker:%2 array:%3",_areamarker,_marker,_x];
+ };
+ If (_areamarker == _marker) exitwith
+ {
+ _in = true;
+ _groups = _x select 1;
+ };
+} foreach UPSMON_Markers;
+
+_groups set [count _groups,_grp];
+_markerarray = [_areamarker,_groups];
+If (_in) then
+{
+ UPSMON_Markers set [_id,_markerarray];
+}
+else
+{
+ UPSMON_Markers set [count UPSMON_Markers,_markerarray];
+};
+
+{
+ _group = _x;
+ If (({alive _x && !(captive _x)} count units _group) > 0) then
+ {
+ _UCthis = _group getvariable ["UPSMON_Ucthis",[]];
+ If ("SHOWMARKER" in _UCthis) exitwith {_showmarker = "SHOWMARKER";};
+ };
+} foreach _groups;
+
+if (_showmarker=="HIDEMARKER") then
+{
+ _areamarker setmarkerAlpha 0;
+}
+else
+{
+ If (MarkerAlpha _areamarker == 0) then
+ {
+ _areamarker setmarkerAlpha 1;
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetRenfParam.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetRenfParam.sqf
new file mode 100644
index 0000000..4e58bb4
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_SetRenfParam.sqf
@@ -0,0 +1,53 @@
+/****************************************************************
+File: UPSMON_SetRenfParam.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- _grp
+ <--- UPSMON parameters
+Returns:
+
+****************************************************************/
+private[];
+
+_grp = _this select 0;
+_Ucthis = _this select 1;
+
+// set If enemy detected reinforcements will be sent REIN1
+_rfid = ["REINFORCEMENT:",0,_UCthis] call UPSMON_getArg; // rein_#
+_reinforcement= if ("REINFORCEMENT" in _UCthis) then {"REINFORCEMENT"} else {"NOREINFORCEMENT"}; //rein_yes
+
+If (_rfid > 0 || "REINFORCEMENT" in _UCthis) then
+{
+ _grp setvariable ["UPSMON_Reinforcement",true];
+ _grp setvariable ["UPSMON_ReinforcementSent",false];
+
+ If ("REINFORCEMENT" in _UCthis) then
+ {
+ switch (side _grp) do
+ {
+ case West:
+ {
+ UPSMON_REINFORCEMENT_WEST_UNITS pushback _grp;
+ PublicVariable "UPSMON_REINFORCEMENT_WEST_UNITS";
+ };
+ case EAST:
+ {
+ UPSMON_REINFORCEMENT_EAST_UNITS pushback _grp;
+ PublicVariable "UPSMON_REINFORCEMENT_EAST_UNITS";
+ };
+ case RESISTANCE:
+ {
+ UPSMON_REINFORCEMENT_GUER_UNITS pushback _grp;
+ PublicVariable "UPSMON_REINFORCEMENT_GUER_UNITS";
+ };
+ };
+ }
+ else
+ {
+ _grp setvariable ["UPSMON_Rfid",_rfid];
+ };
+};
+
diff --git a/scripts/UPSMON/COMMON/Params/fnc/UPSMON_Settemplate.sqf b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_Settemplate.sqf
new file mode 100644
index 0000000..1b69d18
--- /dev/null
+++ b/scripts/UPSMON/COMMON/Params/fnc/UPSMON_Settemplate.sqf
@@ -0,0 +1,29 @@
+/****************************************************************
+File: UPSMON_SetTemplate.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Spawned parameter
+ <--- template number
+ <--- Side of the group
+Returns:
+
+****************************************************************/
+private["_spawned","_template","_side","_unitstypes"];
+
+_spawned= _this select 0;
+_template = _this select 1;
+_side = _this select 2;
+_unitstypes = _this select 3;
+
+//Fills template array for spawn
+if (_template > 0 && !_spawned) then
+{
+ UPSMON_TEMPLATES = UPSMON_TEMPLATES + ( [[_template]+[_side]+_unitstypes select 0+_unitstypes select 1] );
+ if (UPSMON_Debug>0) then
+ {
+ diag_log format["Adding TEMPLATE %1 _spawned %2",_template,_spawned];
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/UPSMON_closedoor.sqf b/scripts/UPSMON/COMMON/UPSMON_closedoor.sqf
new file mode 100644
index 0000000..fd3c4d5
--- /dev/null
+++ b/scripts/UPSMON/COMMON/UPSMON_closedoor.sqf
@@ -0,0 +1,10 @@
+
+private ["_bld"];
+_bld = _this select 0;
+_nbrdoors = round (count ((configfile >> "cfgVehicles" >> (typeOf _bld) >> "UserActions") call bis_fnc_returnchildren))/2;
+sleep 20;
+
+for "_i" from 0 to _nbrdoors do
+{
+ [_bld, "door_" + str _i + "_rot", "Door_Handle_" + str _i + "_rot_1", "Door_Handle_" + str _i + "_rot_2"] execVM "\A3\Structures_F\scripts\Door_close.sqf";
+};
diff --git a/scripts/UPSMON/COMMON/buildings/Init.sqf b/scripts/UPSMON/COMMON/buildings/Init.sqf
new file mode 100644
index 0000000..1bf0296
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/Init.sqf
@@ -0,0 +1,15 @@
+
+UPSMON_GetNearestBuildings = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_GetNearestBuildings.sqf";
+UPSMON_GetNearestBuilding = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_GetNearestBuilding.sqf";
+
+UPSMON_filterbuilding = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_filterbuilding.sqf";
+UPSMON_checkdoorposition = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_checkdoorposition.sqf";
+UPSMON_Checkfreebldpos = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_Checkfreebldpos.sqf";
+UPSMON_Checkfreebldpos2 = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_Checkfreebldpos2.sqf";
+UPSMON_checkwindowposition = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_checkwindowposition.sqf";
+UPSMON_gethighestbldpos = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_gethighestbldpos.sqf";
+UPSMON_Isroof = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_Isroof.sqf";
+UPSMON_Inbuilding = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_Inbuilding.sqf";
+UPSMON_SortOutBldpos = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_SortOutBldpos.sqf";
+UPSMON_UnitWatchDir = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_UnitWatchDir.sqf";
+UPSMON_WillSee = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\buildings\fnc\UPSMON_WillSee.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Checkfreebldpos.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Checkfreebldpos.sqf
new file mode 100644
index 0000000..788eea7
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Checkfreebldpos.sqf
@@ -0,0 +1,35 @@
+/****************************************************************
+File: UPSMON_Checkfreebldpos.sqf
+Author: Azroul13
+
+Description:
+ Filter the building position and check if there're no unit near the position.
+
+Parameter(s):
+ <--- Building positions
+Returns:
+ Building position
+****************************************************************/
+
+private ["_bldpos","_altura","_unitnear","_id"];
+
+_bldpos = _this select 0;
+_unitnear = [];
+_altura = [];
+_id = -1;
+{
+ _id = _id + 1;
+ If (typename _x == "ARRAY") then
+ {
+ If (count _x > 0) then
+ {
+ _unitnear = _x nearEntities [["CAManBase","STATICWEAPON"],0.5];
+ If (count _unitnear == 0) exitwith
+ {
+ _altura = [_x,_id]
+ };
+ };
+ };
+} foreach _bldpos;
+
+_altura;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Checkfreebldpos2.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Checkfreebldpos2.sqf
new file mode 100644
index 0000000..e697260
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Checkfreebldpos2.sqf
@@ -0,0 +1,37 @@
+/****************************************************************
+File: UPSMON_Checkfreebldpos2.sqf
+Author: Azroul13
+
+Description:
+ Filter the building position and check if there're no unit near the position.
+
+Parameter(s):
+ <--- Building positions
+Returns:
+ Building positions
+****************************************************************/
+private ["_bldpos","_bldpostemp","_id","_altura","_unitnear"];
+
+_bldpos = _this select 0;
+_bldpostemp = _bldpos;
+_id = -1;
+_unitnear = [];
+
+{
+ _id = _id + 1;
+ If (typename _x == "ARRAY") then
+ {
+ _altura = _x;
+ If (count _altura > 0) then
+ {
+ _unitnear = _altura nearEntities [["CAManBase","STATICWEAPON"],0.5];
+ If (count _unitnear > 0) then
+ {
+ _bldpostemp set [_id,"deletethis"];
+ _bldpostemp = _bldpostemp - ["deletethis"];
+ };
+ };
+ };
+} foreach _bldpos;
+
+_bldpostemp;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_GetNearestBuilding.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_GetNearestBuilding.sqf
new file mode 100644
index 0000000..1cb4c86
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_GetNearestBuilding.sqf
@@ -0,0 +1,40 @@
+/****************************************************************
+File: UPSMON_GetNearestBuildings.sqf
+Author: Monsada
+
+Description:
+ Get all nearest buildings and theirs positions.
+
+Parameter(s):
+ <--- soldier to get near buildings
+ <--- distance to search buildings (optional, 25 by default)
+ <--- min floors of building (optional) if not especified min floors
+Returns:
+ [_bld,_bldpos]
+****************************************************************/
+private ["_distance","_minfloors","_marker","_shuffle","_position","_bldaltura","_nbbldpos","_bldpositions","_OCercanos","_allpos"];
+
+_distance = 25;
+_minfloors = 2;
+_marker = "";
+_shuffle = false;
+
+_position = _this select 0;
+_bldaltura = _this select 1;
+if ((count _this) > 2) then {_distance = _this select 2;};
+if ((count _this) > 3) then {_marker = _this select 3;};
+if ((count _this) > 4) then {_shuffle = _this select 4;};
+
+_bldposition = [];
+
+_OCercanos = [ (nearestObjects [_position, ["house","building"], _distance]), { [_x,_marker] call UPSMON_filterbuilding } ] call BIS_fnc_conditionalSelect;
+
+if (_shuffle && count _OCercanos > 0) then {_OCercanos = _OCercanos call UPSMON_arrayShufflePlus;};
+
+{
+ _allpos = [_x,_bldaltura] call UPSMON_SortOutBldpos;
+ _nbbldpos = count (_allpos select 0);
+ if (damage _x == 0 && _nbbldpos > 0) exitwith {_bldposition = [_x,_allpos];};
+} foreach _OCercanos;
+
+_bldposition;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_GetNearestBuildings.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_GetNearestBuildings.sqf
new file mode 100644
index 0000000..f6ae8ff
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_GetNearestBuildings.sqf
@@ -0,0 +1,40 @@
+/****************************************************************
+File: UPSMON_GetNearestBuildings.sqf
+Author: Monsada
+
+Description:
+ Get all nearest buildings and theirs positions.
+
+Parameter(s):
+ <--- soldier to get near buildings
+ <--- distance to search buildings (optional, 25 by default)
+ <--- min floors of building (optional) if not especified min floors
+Returns:
+ [_bld,_bldpos]
+****************************************************************/
+private ["_distance","_minfloors","_marker","_shuffle","_position","_bldaltura","_nbbldpos","_bldpositions","_OCercanos","_allpos"];
+
+_distance = 25;
+_minfloors = 2;
+_marker = "";
+_shuffle = false;
+
+_position = _this select 0;
+_bldaltura = _this select 1;
+if ((count _this) > 2) then {_distance = _this select 2;};
+if ((count _this) > 3) then {_marker = _this select 3;};
+if ((count _this) > 4) then {_shuffle = _this select 4;};
+
+_bldpositions = [];
+
+_OCercanos = [ (nearestObjects [_position, ["house","building"], _distance]), { [_x,_marker] call UPSMON_filterbuilding } ] call BIS_fnc_conditionalSelect;
+if (_shuffle && count _OCercanos > 1) then {_OCercanos = _OCercanos call UPSMON_arrayShufflePlus;};
+
+{
+ _allpos = [_x,_bldaltura] call UPSMON_SortOutBldpos;
+ {[_x] call UPSMON_Checkfreebldpos2} foreach _allpos;
+ _nbbldpos = (count (_allpos select 0)) + (count (_allpos select 1));
+ if (damage _x == 0 && _nbbldpos > 0) then {_bldpositions pushback [_x,_allpos];};
+} foreach _OCercanos;
+
+_bldpositions;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Inbuilding.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Inbuilding.sqf
new file mode 100644
index 0000000..a171622
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Inbuilding.sqf
@@ -0,0 +1,34 @@
+/****************************************************************
+File: UPSMON_Inbuilding.sqf
+Author: Azroul13
+
+Description:
+ Check if the AI is in a building.
+
+Parameter(s):
+ <--- Unit
+Returns:
+ boolean
+****************************************************************/
+
+private ["_Inbuilding","_Roof","_unit","_Down"];
+_unit = _this select 0;
+
+_Inbuilding = false;
+_Roof = lineIntersectsWith [getposASL _unit, [((getposASL _unit) select 0), ((getposASL _unit) select 1), ((getposASL _unit) select 2) + 20]];
+
+If (count _Roof > 0) then
+{
+ _Inbuilding = (_Roof select 0) isKindOf "BUILDING";
+};
+
+If (!_Inbuilding) then
+{
+ _Down = lineIntersectsWith [getposASL _unit, [((getposASL _unit) select 0), ((getposASL _unit) select 1), ((getposASL _unit) select 2) - 20]];
+ if (count _Down > 0) then
+ {
+ _Inbuilding = (_Down select 0) isKindOf "BUILDING";
+ };
+};
+
+_Inbuilding
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Isroof.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Isroof.sqf
new file mode 100644
index 0000000..7a6e28a
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_Isroof.sqf
@@ -0,0 +1,26 @@
+/****************************************************************
+File: UPSMON_Isroof.sqf
+Author: Azroul13
+
+Description:
+ Check if the AI is under a roof.
+
+Parameter(s):
+ <--- Unit
+Returns:
+ boolean
+****************************************************************/
+
+private ["_Inbuilding","_Roof","_unit"];
+
+_unit = _this select 0;
+
+_Inbuilding = false;
+_Roof = lineIntersectsWith [getposASL _unit, [((getposASL _unit) select 0), ((getposASL _unit) select 1), ((getposASL _unit) select 2) + 20]];
+
+If (count _Roof > 0) then
+{
+ _Inbuilding = (_Roof select 0) isKindOf "BUILDING";
+};
+
+_Inbuilding
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_SortOutBldpos.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_SortOutBldpos.sqf
new file mode 100644
index 0000000..f063743
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_SortOutBldpos.sqf
@@ -0,0 +1,77 @@
+/****************************************************************
+File: UPSMON_SortOutBldpos.sqf
+Author: Azroul13
+
+Description:
+ Get All position from a building
+
+Parameter(s):
+ <--- building
+ <--- Search parameters: get only 1st floor position or upstairs position or both ("RANDOMUP"/"RANDOMDN"/"RANDOMA")
+Returns:
+ Array of bldpos
+****************************************************************/
+
+private ["_bld","_initpos","_height","_bldpos","_checkheight","_downpos","_roofpos","_allpos","_bldpos1","_posz"];
+
+_bld = _this select 0;
+_initpos = _this select 1;
+_height = 2;
+
+_bldpos = [_bld, 70] call BIS_fnc_buildingPositions;
+_checkheight = [_bldpos] call UPSMON_gethighestbldpos;
+If (_checkheight > _height) then {If (_checkheight >= 4) then {_height = _checkheight - 1.5;} else {_height = _checkheight - 0.5;};};
+
+_downpos = [];
+_roofpos = [];
+_allpos = [];
+
+{
+ _bldpos1 = _x;
+ _posz = _bldpos1 select 2;
+
+ If (_posz >= _height) then {_roofpos pushback _bldpos1;};
+ If (_posz < _height) then {_downpos pushback _bldpos1;};
+
+} foreach _bldpos;
+
+If (count _downpos > 1) then
+{
+ _downpos = _downpos call UPSMON_arrayShufflePlus;
+};
+
+If (count _roofpos > 1) then
+{
+ _roofpos = _roofpos call UPSMON_arrayShufflePlus;
+};
+
+If (_initpos == "RANDOMUP") then {_allpos pushback _roofpos; _allpos pushback _downpos;};
+If (_initpos == "RANDOMDN") then {_allpos pushback _downpos; _allpos pushback _roofpos;};
+If (_initpos == "RANDOMA") then {_allpostemp = [_downpos,_roofpos] call BIS_fnc_arrayPushStack;_allpos pushback _allpostemp;_allpos pushback [];};
+
+
+if (_initpos == "RANDOMA") then
+{
+ If (count (_allpos select 0) > 1) then
+ {
+ _allpostemp = (_allpos select 0) call UPSMON_arrayShufflePlus;
+ _allpos set [0,_allpostemp];
+ };
+};
+
+if (count _allpos > 0) then
+{
+ if (UPSMON_Debug > 0) then
+ { {
+ If (count _x > 0) then
+ {
+ {
+ _ballCover = "Sign_Arrow_Large_GREEN_F" createvehicle [0,0,0];
+ _ballCover setpos _x;
+ } foreach _x;
+ };
+ } foreach _allpos;
+ };
+};
+
+_allpos;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_SortOutBldpos2.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_SortOutBldpos2.sqf
new file mode 100644
index 0000000..6dfcc74
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_SortOutBldpos2.sqf
@@ -0,0 +1,33 @@
+/****************************************************************
+File: UPSMON_SortOutBldpos.sqf
+Author: Azroul13
+
+Description:
+ Get All position from a building
+
+Parameter(s):
+ <--- building
+ <--- Search parameters: get only 1st floor position or upstairs position or both ("RANDOMUP"/"RANDOMDN"/"RANDOMA")
+Returns:
+ Array of bldpos
+****************************************************************/
+
+private ["_bld","_initpos","_height","_bldpos","_checkheight","_downpos","_roofpos","_allpos","_bldpos1","_posz"];
+
+_bld = _this select 0;
+_targetpos = _this select 1;
+
+_bldpos = [_bld, 70] call BIS_fnc_buildingPositions;
+
+_allpos = [];
+
+{
+ If ([_x,_targetpos] call UPSMON_LOS) then {_allpos pushback _x;};
+} foreach _bldpos;
+
+If (count _allpos > 1) then
+{
+ _allpos = _roofpos call UPSMON_arrayShufflePlus;
+};
+
+_allpos;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_UnitWatchDir.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_UnitWatchDir.sqf
new file mode 100644
index 0000000..8a9b159
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_UnitWatchDir.sqf
@@ -0,0 +1,118 @@
+/****************************************************************
+File: UPSMON_UnitWatchDir.sqf
+Author: Azroul13
+
+Description:
+ make unit watch doors or windows.
+
+Parameter(s):
+ <--- Unit
+ <--- Direction of the unit
+ <--- Building where is the unit
+Returns:
+ nothing
+****************************************************************/
+private ["_see","_infront","_uposASL","_opp","_adj","_hyp","_eyes","_obstruction","_angle","_isroof"];
+
+_unit = _this select 0;
+_angle = _this select 1;
+_bld = _this select 2;
+_essai = 0;
+_see = false;
+_ouverture = false;
+_findoor = false;
+_wpos = [];
+_dpos = [];
+_watch = [];
+dostop _unit;
+_windowpositions = [];
+_doorpositions = [];
+
+_watchdir = [getposATL _unit,_bld modeltoworld [0,0,0]] call BIS_fnc_DirTo;
+_watchdir = _watchdir + 180;
+_unit setdir 0;
+_unit setdir _watchdir;
+sleep 0.7;
+
+_sight = [_unit,getdir _unit, 20] call UPSMON_CanSee;
+
+_isroof = [_unit] call UPSMON_Isroof;
+
+If (_isroof) then
+{
+ if (!_sight) then
+ {
+ // check window
+ _windowpositions = [_bld] call UPSMON_checkwindowposition;
+ If (count _windowpositions > 0) then
+ {
+ {
+ If (UPSMON_Debug > 0) then {diag_log format ["%1 %2 window %3 result %4",_unit,(ASLtoATL(eyePos _unit)),_x select 0,(ASLtoATL(eyePos _unit)) distance _x]};
+ If (((ASLtoATL(eyePos _unit)) vectorDistance _x) <= 2.5) exitwith {_watch = _x;};
+ } forEach _windowpositions;
+
+ if (count _watch > 0) then
+ {
+ _wpos = _watch;
+ };
+ };
+
+ // check for door
+ _doorpositions = [_bld] call UPSMON_checkdoorposition;
+
+ if (count _doorpositions == 0) then
+ {
+ _exitpos = _bld buildingExit 0;
+ If (count _exitpos > 0) then {_doorpositions pushback (_bld modelToWorld _exitpos)};
+ };
+
+ If (count _doorpositions > 0) then
+ {
+ {
+ //diag_log format ["%1 %2 door %3 result %4",_unit,(ASLtoATL(eyePos _unit)),_x,(ASLtoATL(eyePos _unit)) distance _x];
+ If (((ASLtoATL(eyePos _unit)) vectorDistance _x) <= 3) exitwith {_watch = _x;};
+ } forEach _doorpositions;
+
+ if (count _watch > 0) then
+ {
+ _dpos = _watch;
+
+ };
+ };
+ };
+};
+
+_unit setvariable ["UPSMON_unitdir",[_wpos,_dpos]];
+If (count _dpos > 0) then {_watch = _dpos;_ouverture = true; _findoor = true;};
+If (count _wpos > 0) then {_watch = _wpos;_ouverture = true;_findoor = false;};
+sleep 0.1;
+If (count _watch > 0) then
+{
+ _posATL = getPosATL _unit;
+
+ _abx = (_watch select 0) - (_posATL select 0);
+ _aby = (_watch select 1) - (_posATL select 1);
+ _abz = (_watch select 2) - (_posATL select 2);
+
+ _vec = [_abx, _aby, _abz];
+
+ // Main body of the function;
+ _unit setdir 0;
+ _unit setVectorDir _vec;
+
+ _unit dowatch ObjNull;
+ _unit dowatch _watch;
+
+ If(UPSMON_DEBUG > 0) then
+ {
+ _ballCover2 = "Sign_Sphere25cm_F" createvehicle [0,0,0];
+ _ballCover2 setposATL _watch;
+ };
+};
+
+Sleep 0.5;
+// Check if window blocking view or search direction for AI if he doesn't watch window or door.
+If (!(_findoor) && !_sight) then
+{
+ [_unit,getdir _unit,_ouverture] spawn UPSMON_WillSee;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_WillSee.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_WillSee.sqf
new file mode 100644
index 0000000..9d0764b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_WillSee.sqf
@@ -0,0 +1,75 @@
+/****************************************************************
+File: UPSMON_WillSee.sqf
+Author: Zorilaya
+
+Description:
+ Make the AI watch openings.
+
+Parameter(s):
+ <--- Parameters of the original group
+ <--- Minimum number of group to create
+ <--- Maximum number of group to create
+Returns:
+ nothing
+****************************************************************/
+
+// garrison func from Zorilaya
+private ["_unit","_angle","_window","_essai","_eyes","_hyp","_adj","_opp","_infront","_obstruction","_see","_abx","_aby","_abz","_vec"];
+
+_unit = _this select 0;
+_angle = _this select 1;
+_window = _this select 2;
+_essai = 0;
+
+If (count _this > 3) then {_essai = _this select 3;};
+
+_eyes = eyepos _unit;
+
+_hyp = 10;
+_adj = _hyp * (cos _angle);
+_opp = sqrt ((_hyp*_hyp) - (_adj * _adj));
+
+
+_infront = if ((_angle) >= 180) then
+{
+ [(_eyes select 0) - _opp,(_eyes select 1) + _adj,(_eyes select 2)]
+}
+else
+{
+ [(_eyes select 0) + _opp,(_eyes select 1) + _adj,(_eyes select 2)]
+};
+
+_obstruction = (lineintersectswith [_eyes,_infront,_unit]) select 0;
+
+_see = if (isnil("_obstruction")) then {true} else {false};
+if (UPSMON_DEBUG > 0) then {diag_log format ["Unit: %1 See:%2 Essai:%3",_unit,_see,_essai];};
+
+If (!_see && _essai < 20) exitwith
+{
+ _essai = _essai + 1;
+ If (_window) then {_angle = _angle + 2} else {_angle = random 360};
+ [_unit,_angle,_window,_essai] call UPSMON_WillSee;
+};
+
+If (_see && _essai > 0) then
+{
+ _posATL = getPosATL _unit;
+
+ _abx = (_infront select 0) - (_posATL select 0);
+ _aby = (_infront select 1) - (_posATL select 1);
+ _abz = (_infront select 2) - (_posATL select 2);
+
+ _vec = [_abx, _aby, _abz];
+
+ // Main body of the function;
+ _unit setVectorDir _vec;
+ sleep 0.02;
+ _unit dowatch ObjNull;
+ _unit dowatch [_infront select 0,_infront select 1, _posATL select 2];
+
+ if (UPSMON_DEBUG > 0) then
+ {
+ _ballCover = "Sign_Arrow_Large_BLUE_F" createvehicle [0,0,0];
+ _ballCover setposATL [_infront select 0,_infront select 1, _posATL select 2];
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_checkdoorposition.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_checkdoorposition.sqf
new file mode 100644
index 0000000..4c23032
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_checkdoorposition.sqf
@@ -0,0 +1,37 @@
+/****************************************************************
+File: UPSMON_checkdoorposition.sqf
+Author: Azroul13
+
+Description:
+ Get all doors position of the building
+
+Parameter(s):
+ <--- Building
+Returns:
+ Doors positions.
+****************************************************************/
+private ["_model_pos","_world_pos","_armor","_cfg_entry","_veh","_house","_window_pos_arr","_cfgHitPoints","_cfgDestEff","_brokenGlass","_selection_name"];
+
+_house = _this select 0;
+_anim_source_pos_arr = [];
+
+_cfgUserActions = (configFile >> "cfgVehicles" >> (typeOf _house) >> "UserActions");
+
+for "_i" from 0 to count _cfgUserActions - 1 do
+{
+ _cfg_entry = _cfgUserActions select _i;
+
+ if (isClass _cfg_entry) then
+ {
+ _display_name = getText (_cfg_entry / "displayname");
+ if (_display_name == "Open hatch" or {_display_name == "Open door"}) then
+ {
+ _selection_name = getText (_cfg_entry / "position");
+ _model_pos = _house selectionPosition _selection_name;
+ _world_pos = _house modelToWorld _model_pos;
+ _anim_source_pos_arr pushback _world_pos;
+ };
+ };
+};
+
+_anim_source_pos_arr
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_checkwindowposition.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_checkwindowposition.sqf
new file mode 100644
index 0000000..8d44dda
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_checkwindowposition.sqf
@@ -0,0 +1,40 @@
+/****************************************************************
+File: UPSMON_checkwindowposition.sqf
+Author: Azroul13
+
+Description:
+ Get all windows position of the building
+
+Parameter(s):
+ <--- Building
+Returns:
+ windows positions.
+****************************************************************/
+
+private ["_model_pos","_world_pos","_armor","_cfg_entry","_veh","_house","_window_pos_arr","_cfgHitPoints","_cfgDestEff","_brokenGlass","_selection_name"];
+
+_house = _this select 0;
+_window_pos_arr = [];
+
+_cfgHitPoints = (configFile >> "cfgVehicles" >> (typeOf _house) >> "HitPoints");
+
+for "_i" from 0 to count _cfgHitPoints - 1 do
+{
+ _cfg_entry = _cfgHitPoints select _i;
+
+ if (isClass _cfg_entry) then
+ {
+ _armor = getNumber (_cfg_entry / "armor");
+
+ if (_armor < 10) then
+ {
+ _cfgDestEff = (_cfg_entry / "DestructionEffects");
+ _brokenGlass = _cfgDestEff select 0;
+ _selection_name = getText (_brokenGlass / "position");
+ _model_pos = _house selectionPosition _selection_name;
+ _world_pos = _house modelToWorld _model_pos;
+ _window_pos_arr pushback _world_pos;
+ };
+ };
+};
+_window_pos_arr
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_filterbuilding.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_filterbuilding.sqf
new file mode 100644
index 0000000..8e586ef
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_filterbuilding.sqf
@@ -0,0 +1,37 @@
+/****************************************************************
+File: UPSMON_filterbuilding.sqf
+Author: Azroul13
+
+Description:
+ Filter the building, avoid bridge building or building with no position.
+
+Parameter(s):
+ <--- Building
+Returns:
+ boolean
+****************************************************************/
+
+private ["_bld","_marker","_return","_in","_UPSMON_Bld_remove"];
+
+_bld = _this select 0;
+_marker = _this select 1;
+_return = false;
+_in = true;
+
+_UPSMON_Bld_remove = ["Bridge_PathLod_base_F","Land_Slum_House03_F","Land_Bridge_01_PathLod_F","Land_Bridge_Asphalt_PathLod_F","Land_Bridge_Concrete_PathLod_F","Land_Bridge_HighWay_PathLod_F","Land_Bridge_01_F","Land_Bridge_Asphalt_F","Land_Bridge_Concrete_F","Land_Bridge_HighWay_F","Land_Canal_Wall_Stairs_F"];
+if (!((typeof _bld) in _UPSMON_Bld_remove)) then
+{
+ If (_marker != "") then
+ {
+ _in = [getposATL _bld,_marker] call UPSMON_pos_fnc_isBlacklisted;
+ };
+ if (_in) then
+ {
+ if ([_bld,1] call BIS_fnc_isBuildingEnterable) then
+ {
+ _return = true;
+ };
+ };
+};
+
+_return;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_gethighestbldpos.sqf b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_gethighestbldpos.sqf
new file mode 100644
index 0000000..eb4e84b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/buildings/fnc/UPSMON_gethighestbldpos.sqf
@@ -0,0 +1,32 @@
+/****************************************************************
+File: UPSMON_gethighestbldpos.sqf
+Author: Azroul13
+
+Description:
+ Get the highest point of the building
+
+Parameter(s):
+ <--- Array of building positions
+Returns:
+ Number
+****************************************************************/
+
+private ["_bldpos","_result","_zbldposs","_lastzbldpos"];
+
+_bldpos = _this select 0;
+_result = 0;
+_zbldposs = [];
+_lastzbldpos = 0;
+
+
+{
+ _zbldposs = _zbldposs + [_x select 2];
+} foreach _bldpos;
+
+{
+ _zblpos = _x;
+ If (_zblpos > _lastzbldpos) then {_result = _zblpos;} else {_result = _lastzbldpos;};
+ _lastzbldpos = _x;
+} foreach _zbldposs;
+
+_result;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/markerAlpha.sqf b/scripts/UPSMON/COMMON/markerAlpha.sqf
new file mode 100644
index 0000000..0b33d06
--- /dev/null
+++ b/scripts/UPSMON/COMMON/markerAlpha.sqf
@@ -0,0 +1,14 @@
+/* =============================================
+ !R
+ Hide area markers.
+
+ create Game Logic Object
+ put in initialization field:
+
+ nul = call compile preprocessFile "scripts\UPSMON\!R\markerAlpha.sqf";
+
+ all markers area must be named area0, area1...area13
+
+================================================= */
+
+{ _x setmarkeralpha 0; } foreach ["area0", "area1", "area2","area3","area4","area5","area6","area7","area8","area9","area10","area11","area12","area13"];
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/target/fnc/UPSMON_Checkratio.sqf b/scripts/UPSMON/COMMON/target/fnc/UPSMON_Checkratio.sqf
new file mode 100644
index 0000000..580e8d8
--- /dev/null
+++ b/scripts/UPSMON/COMMON/target/fnc/UPSMON_Checkratio.sqf
@@ -0,0 +1,254 @@
+/****************************************************************
+File: UPSMON_Checkratio.sqf
+Author: Azroul13
+
+Description:
+ Comparison between Allied and Enemies forces in 800 radius
+Parameter(s):
+ <--- Group
+ <--- Array of allied groups
+ <--- Array of enies units
+Returns:
+ ---> Ratio Eni/Allies
+ ---> Array of importants targets
+****************************************************************/
+private ["_grp","_allies","_enies","_pointsallies","_pointsenies","_ratedveh","_Itarget","_result","_points","_vehicle","_MagazinesUnit","_Cargo","_armor","_assignedvehicles"];
+
+_grp = _this select 0;
+_allies = _this select 1;
+_enies = _this select 2;
+_pointsallies = 0;
+_pointsenies = 0;
+_ratedveh = [];
+_typeofeni = [];
+_enicapacity = [];
+_assignedvehicles = [];
+
+_allies pushback _grp;
+
+{
+ If(!IsNull _x) then
+ {
+ If (({alive _x} count units _x) > 0) then
+ {
+ _pointsallies = _pointsallies + (_x getvariable ["UPSMON_Grpratio",0]);
+ };
+ };
+} count _allies > 0;
+
+{
+ _eni = _x;
+ _points = 0;
+
+ If (!IsNull _eni) then
+ {
+ If (alive _eni) then
+ {
+ if ((vehicle _eni) != _eni && !(Isnull assignedVehicle _eni) && !(_eni in (assignedCargo assignedVehicle _eni))) then
+ {
+ if (!((assignedVehicle _eni) in _assignedvehicles)) then
+ {
+ _vehicle = assignedVehicle _eni;
+ _assignedvehicles pushback _vehicle;
+ _MagazinesUnit=(magazines _vehicle);
+ _Cargo = getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> "transportSoldier");
+ _armor = getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> "armor");
+ _gunner = gunner _vehicle;
+ _ammorated = [];
+
+ _points = _points + 1;
+
+ If (!IsNull _gunner) then
+ {
+ If (alive _gunner) then
+ {
+ {
+ _ammo = tolower gettext (configFile >> "CfgMagazines" >> _x >> "ammo");
+ _irlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "irLock");
+ _laserlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "laserLock");
+ _airlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "airLock");
+ _hit = getNumber (configfile >> "CfgAmmo" >> _ammo >> "hit");
+
+ if (_airlock == 1) then
+ {
+ if (_ammo iskindof "BulletBase") then
+ {
+ If (!("aa1" in _enicapacity)) then
+ {
+ _enicapacity pushback "aa1";
+ };
+ };
+ };
+
+ if (_airlock == 2) then
+ {
+ if (!(_ammo iskindof "BulletBase")) then
+ {
+ If (!("aa2" in _enicapacity)) then
+ {
+ _enicapacity pushback "aa2";
+ };
+ };
+ };
+
+ if (_irlock>0 || _laserlock>0) then
+ {
+ if (_ammo iskindof "MissileBase") then
+ {
+ If (!("at2" in _enicapacity)) then
+ {
+ _enicapacity pushback "at2";
+ };
+ };
+ };
+
+ if (_ammo iskindof "ShellBase") then
+ {
+ if (!(arti in _typeofgrp)) then
+ {
+ If (!("at3" in _enicapacity)) then
+ {
+ _enicapacity pushback "at3";
+ };
+ };
+ };
+
+ if (_ammo iskindof "BulletBase") then
+ {
+ if (_hit >= 40) then
+ {
+ If (!("at1" in _enicapacity)) then
+ {
+ _enicapacity pushback "at1";
+ };
+ };
+ };
+ If (!(_ammo in _ammorated)) then
+ {
+ _points = _points + _hit;
+ _ammorated pushback _ammo;
+ };
+
+ } foreach _MagazinesUnit;
+ };
+ };
+
+ _points = _points + _armor;
+
+
+ If (_vehicle iskindof "car") then
+ {
+ If (!("car" in _typeofeni)) then
+ {
+ _typeofeni pushback "car";
+ };
+
+ If (_armor >= 500) then
+ {
+ If (!("heavy" in _typeofeni)) then
+ {
+ _typeofeni pushback "heavy";
+ };
+ };
+
+ If (_armor >= 250 && _armor < 500) then
+ {
+ If (!("medium" in _typeofeni)) then
+ {
+ _typeofeni pushback "medium";
+ };
+ };
+
+ If (_armor < 250) then
+ {
+ If (!("light" in _typeofeni)) then
+ {
+ _typeofeni pushback "light";
+ };
+ };
+ };
+
+ If (_vehicle iskindof "air") then
+ {
+ If (!("air" in _typeofeni)) then
+ {
+ _typeofeni pushback "air";
+ };
+ };
+
+ If (_vehicle iskindof "Ship") then
+ {
+ If (!("Ship" in _typeofeni)) then
+ {
+ _typeofeni pushback "Ship";
+ };
+ };
+
+ If (!IsNull (Gunner _vehicle)) then
+ {
+ If (!("armed" in _typeofeni)) then
+ {
+ _typeofeni pushback "armed";
+ };
+ };
+
+ };
+ }
+ else
+ {
+ If (vehicle _x != _x) then
+ {
+ If (!((assignedVehicle _x) in _assignedvehicles)) then
+ {
+ _assignedvehicles pushback (assignedVehicle _x);
+ }
+ };
+ _sweapon = secondaryWeapon _x;
+ _MagazinesUnit=(magazines _x);
+ _smagazineclass = [];
+ If (_sweapon != "") then
+ {
+ _smagazineclass = getArray (configFile >> "CfgWeapons" >> _sweapon >> "magazines");
+ };
+ _ammorated = [];
+
+ _points = _points + 1;
+
+ {
+ _ammo = tolower gettext (configFile >> "CfgMagazines" >> _x >> "ammo");
+ _irlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "irLock");
+ _laserlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "laserLock");
+ _airlock = getNumber (configfile >> "CfgAmmo" >> _ammo >> "airLock");
+ _hit = getNumber (configfile >> "CfgAmmo" >> _ammo >> "hit");
+
+ if (_airlock==2 && !(_ammo iskindof "BulletBase") && !("aa2" in _enicapacity) && (_ammo in _smagazineclass)) then
+ {_enicapacity pushback "aa2";};
+ if ((_irlock>0 || _laserlock>0) &&
+ ((_ammo iskindof "RocketBase") || (_ammo iskindof "MissileBase")) && !("at2" in _enicapacity) && (_ammo in _smagazineclass)) then
+ {_enicapacity pushback "at2";};
+ if ((_irlock==0 || _laserlock==0) &&
+ ((_ammo iskindof "RocketBase") || (_ammo iskindof "MissileBase")) && !("at1" in _enicapacity) && (_ammo in _smagazineclass)) then
+ {_enicapacity pushback "at1";};
+
+ If (_ammo iskindof "ShellBase" || (_ammo iskindof "RocketBase") || (_ammo iskindof "MissileBase") && !(_ammo in _ammorated) && (_ammo in _smagazineclass)) then
+ {
+ _points = _points + _hit;
+ _ammorated pushback _ammo;
+ };
+ } foreach _MagazinesUnit;
+
+ if (!("infantry" in _typeofeni)) then
+ {_typeofeni pushback "infantry";};
+ };
+ _points = _points + ((1+(morale _eni)) + (1-(damage _eni)) + ((_eni skillFinal "Endurance") + (_eni skillFinal "courage")));
+ _pointsenies = _points;
+ };
+ };
+} foreach _enies;
+
+//diag_log str _pointsenies;
+//diag_log str _pointsallies;
+_ratio = _pointsenies/_pointsallies;
+
+_result = [_ratio,_enicapacity,_typeofeni];
+_result;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/target/fnc/UPSMON_ClassifyEnies.sqf b/scripts/UPSMON/COMMON/target/fnc/UPSMON_ClassifyEnies.sqf
new file mode 100644
index 0000000..7385897
--- /dev/null
+++ b/scripts/UPSMON/COMMON/target/fnc/UPSMON_ClassifyEnies.sqf
@@ -0,0 +1,78 @@
+private ["_grp","_enies","_npcpos","_capacitygrp","_typeofgrp","_list","_points","_armor"];
+
+_grp = _this select 0;
+_enies = _this select 1;
+
+_npcpos = getposATL (leader _grp);
+_capacitygrp = _grp getvariable ["UPSMON_GroupCapacity",[]];
+_typeofgrp = _grp getvariable ["UPSMON_typeofgrp",[]];
+_list = [];
+
+{
+ If (alive _x) then
+ {
+ _points = 0;
+
+ If ([leader _grp,_x,_npcpos vectordistance ((_x getvariable "UPSMON_TargetInfo") select 0),130] call UPSMON_Haslos) then
+ {
+ _points = _points + 200;
+ };
+
+ If (vehicle _x != _x) then
+ {
+ If ("ship" in _typeofgrp) then
+ {
+ If ((vehicle _x) iskindof "ship") then
+ {
+ _points = _points + 200;
+ };
+ };
+
+ If ("air" in _typeofgrp || "aa1" in _capacitygrp || "aa2" in _capacitygrp) then
+ {
+ if ("aa1" in _capacitygrp || "aa2" in _capacitygrp) then
+ {
+ If ((vehicle _x) iskindof "air") then
+ {
+ _points = _points + 300;
+ };
+ };
+ };
+
+ If ("at1" in _capacitygrp || "at2" in _capacitygrp || "at3" in _capacitygrp) then
+ {
+ _armor = getNumber (configFile >> "CfgVehicles" >> typeof (vehicle _x) >> "armor");
+ If (_armor >= 500 && ("at2" in _capacitygrp || "at3" in _capacitygrp)) then
+ {
+ _points = _points + 300;
+ };
+
+ If (_armor < 500 && "at1" in _capacitygrp) then
+ {
+ _points = _points + 200;
+ };
+
+ If (_armor < 250) then
+ {
+ _points = _points + 200;
+ };
+
+ if (!IsNull (Gunner (vehicle _x))) then
+ {
+ _points = _points + 100;
+ };
+ };
+ };
+ _points = _points - ((_npcpos vectordistance ((_x getvariable "UPSMON_TargetInfos") select 0)) / 10);
+ If (_points < 0) then {_points = 0;};
+ _list pushback [_x,_points];
+ }
+} foreach _enies;
+
+_list = [_list, [], {(_x select 1)}, "DESCEND"] call BIS_fnc_sortBy;
+
+{
+ _enies pushback (_x select 0);
+} foreach _list;
+
+_enies
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/target/fnc/UPSMON_Eniesnear.sqf b/scripts/UPSMON/COMMON/target/fnc/UPSMON_Eniesnear.sqf
new file mode 100644
index 0000000..e9292ef
--- /dev/null
+++ b/scripts/UPSMON/COMMON/target/fnc/UPSMON_Eniesnear.sqf
@@ -0,0 +1,20 @@
+private ["_npc","_enies","_nbr","_unitsnear"];
+
+_npc = _this select 0;
+_enies = _this select 1;
+
+_enies = _enies - _npc;
+_unitsnear = nearestobjects [getposATL _npc,["CAManBase","TANK","CAR"],100];
+_nbr = 0;
+
+{
+ If (alive _x) then
+ {
+ If (_x in _enies) then
+ {
+ _nbr = _nbr +1;
+ };
+ }
+} foreach _unitsnear;
+
+_nbr
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/target/fnc/UPSMON_Shareinfos.sqf b/scripts/UPSMON/COMMON/target/fnc/UPSMON_Shareinfos.sqf
new file mode 100644
index 0000000..f4d474e
--- /dev/null
+++ b/scripts/UPSMON/COMMON/target/fnc/UPSMON_Shareinfos.sqf
@@ -0,0 +1,67 @@
+/****************************************************************
+File: UPSMON_Shareinfos.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Array of enemies
+ <--- leader
+Returns:
+ Nothing
+****************************************************************/
+
+private ["_enemies","_npc","_arrnpc","_side","_pos","_alliednpc","_alliedlead","_enemy"];
+
+_npc = _this select 0;
+_arrnpc = UPSMON_NPCs - [group _npc];
+_side = side _npc;
+_pos = getposATL _npc;
+_alliednpc = [];
+_enemies = [];
+
+{
+ If (!IsNull _x) then
+ {
+ If (alive (leader _x)) then
+ {
+ If (_x getvariable ["UPSMON_Shareinfos",false]) then
+ {
+ If (_side == side _x) then
+ {
+ If (count (_x getvariable ["UPSMON_GrpEnies",[]]) > 0) then
+ {
+ If (round ([_pos,getposATL (leader _x)] call UPSMON_distancePosSqr) <= UPSMON_sharedist) then
+ {
+ _alliednpc pushback _x;
+ };
+ };
+ };
+ };
+ };
+ };
+} foreach _arrnpc;
+
+
+{
+ If (!IsNull _x) then
+ {
+ _alliedlead = leader _x;
+ if (alive _alliedlead) then
+ {
+ _enies = _x getvariable ["UPSMON_GrpEnies",[]];
+ {
+ If (alive _x) then
+ {
+ If (!(_x in _enemies)) then
+ {
+ _enemies pushback _x;
+ };
+ };
+ } foreach _enies;
+ };
+ sleep 0.1;
+ };
+} foreach _alliednpc;
+
+_enemies
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/target/fnc/UPSMON_TargetAcquisition.sqf b/scripts/UPSMON/COMMON/target/fnc/UPSMON_TargetAcquisition.sqf
new file mode 100644
index 0000000..49ddddc
--- /dev/null
+++ b/scripts/UPSMON/COMMON/target/fnc/UPSMON_TargetAcquisition.sqf
@@ -0,0 +1,105 @@
+/****************************************************************
+File: UPSMON_TargetAcquisition.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Group
+ <--- Does the group share enemy info
+ <--- Radius where Enemys is consider closed to the group
+ <--- Time
+ <--- Last time group share infos
+ <---
+Returns:
+ ---> Enemies Array
+ ---> Allies Array
+ ---> nearest target
+ ---> Distance from target
+ ---> how much group know about target
+ ---> Is target near to the group (less than 300m)
+ ---> known position of the target
+****************************************************************/
+private ["_grp","_timeontarget","_react","_npc","_target","_opfknowval","_attackPos","_Enemies","_Allies","_targetsnear","_Units","_dist","_newattackPos","_newtarget"];
+
+_grp = _this select 0;
+_accuracy = 1000;
+
+_npc = leader _grp;
+
+_target = objNull;
+_opfknowval = 0;
+_attackPos = [];
+_Enemies = [];
+_Allies = [];
+_targetsnear = false;
+
+//Resets distance to target
+_dist = 10000;
+
+/// GET ENEMIES AND ALLIES UNITS NEAR THE LEADER ////
+_Units = [_npc] call UPSMON_findnearestenemy;
+_Enemies = _Units select 0;
+_Allies = _Units select 1;
+_suspectenies = _Units select 2;
+
+_grp setvariable ["UPSMON_GrpEnies",_Enemies];
+If (count _Enemies == 0) then
+{
+ // Share the enemies infos we found with our allies
+ If (_grp getvariable ["UPSMON_Shareinfos",false]) then
+ {
+ _enemies = [_npc] call UPSMON_Shareinfos;
+ };
+};
+
+/// ENEMIES FOUND, the first of the list is our enemy now :p ////
+If (count _Enemies > 0) then
+{
+ //Get the most dangerous in the list of enies
+ _Enemies = [_grp,_Enemies] call UPSMON_Classifyenies;
+ _target = _Enemies select 0;
+
+ If (!IsNull _target) then
+ {
+ _opfknowval = (_target getvariable "UPSMON_TargetInfos") select 3;
+ If (_npc knowsAbout _target < _opfknowval) then
+ {
+ _npc reveal [_target,_opfknowval];
+ };
+ _attackPos = (_target getvariable "UPSMON_TargetInfos") select 0;
+ _grp setvariable ["UPSMON_Attackpos",_attackpos];
+ If (_grp getvariable ["UPSMON_Grptarget",ObjNull] != _target) then
+ {
+ _grp setvariable ["UPSMON_TIMEONTARGET",time];
+ _grp setvariable ["UPSMON_Grptarget",_target];
+ };
+ };
+};
+
+//
+if (!IsNull (_grp getvariable ["UPSMON_Grptarget",ObjNull])) then
+{
+ If (!alive (_grp getvariable ["UPSMON_Grptarget",ObjNull])) then
+ {
+ _grp setvariable ["UPSMON_Grptarget",ObjNull];
+ };
+};
+
+If (count _attackpos == 0) then
+{
+ _attackpos = _grp getvariable ["UPSMON_Attackpos",[]];
+};
+
+If (count _attackpos > 0) then
+{
+ _grp setvariable ["UPSMON_GrpStatus","YELLOW"];
+ _dist = ([getposATL _npc,_attackPos] call UPSMON_distancePosSqr);
+ if (UPSMON_Debug > 0) then {[_attackPos,"ICON","Hd_dot","ColorRed",format ["Group:%1 Time:%2",_grp getvariable ["UPSMON_Grpid",0],time]] call UPSMON_createmarker;};
+};
+
+If (_dist <= 300) then {_targetsnear = true;};
+
+_result = [_Enemies,_Allies,_target,_dist,_targetsnear,_attackPos,_suspectenies,_opfknowval];
+
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/target/fnc/UPSMON_TargetAcquisitionCiv.sqf b/scripts/UPSMON/COMMON/target/fnc/UPSMON_TargetAcquisitionCiv.sqf
new file mode 100644
index 0000000..d49901b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/target/fnc/UPSMON_TargetAcquisitionCiv.sqf
@@ -0,0 +1,116 @@
+/****************************************************************
+File: UPSMON_TargetAcquisition.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Group
+ <--- Does the group share enemy info
+ <--- Radius where Enemys is consider closed to the group
+ <--- Time
+ <--- Last time group share infos
+ <---
+Returns:
+ ---> Enemies Array
+ ---> Allies Array
+ ---> nearest target
+ ---> Distance from target
+ ---> how much group know about target
+ ---> Is target near to the group (less than 300m)
+ ---> known position of the target
+ --->
+****************************************************************/
+private ["_grp","_timeontarget","_npc","_target","_attackPos","_Enemies","_Units","_dist"];
+
+_grp = _this select 0;
+_areamarker = _this select 1;
+
+_npc = leader _grp;
+
+_target = objNull;
+_attackPos = [];
+_Enemies = [];
+
+//Resets distance to target
+_dist = 10000;
+
+/// GET ENEMIES AND ALLIES UNITS NEAR THE LEADER ////
+_targets = _npc nearTargets 500;
+
+_enemysides = [];
+If (_grp getvariable ["UPSMON_GrpHostility",0] > UPSMON_WEST_HM) then {_enemysides pushback WEST};
+If (_grp getvariable ["UPSMON_GrpHostility",0] > UPSMON_EAST_HM) then {_enemysides pushback EAST};
+If (_grp getvariable ["UPSMON_GrpHostility",0] > UPSMON_GUER_HM) then {_enemysides pushback Resistance};
+
+{
+ _position = (_x select 0);
+ _cost = (_x select 3);
+ _unit = (_x select 4);
+ _side = (_x select 2);
+ _accuracy = (_x select 5);
+
+ If (_side in _enemySides) then
+ {
+ If (alive _unit) then
+ {
+ If (alive _npc) then
+ {
+ if (vehicle _unit == _unit) then
+ {
+ If ([_position,_areamarker] call UPSMON_pos_fnc_isBlacklisted) then
+ {
+ if (_accuracy < 20) then
+ {
+ _enemies pushback [_unit,_position];
+ };
+ };
+ };
+ };
+ };
+ };
+} forEach _targets;
+
+
+/// ENEMIES FOUND, the first of the list is our enemy now :p ////
+If (count _Enemies > 0) then
+{
+ //Get the most dangerous in the list of enies
+ _Enemies = [_Enemies, [], {(_x select 1) vectordistance getposATL _npc}, "ASCEND"] call BIS_fnc_sortBy;
+ _target = (_Enemies select 0) select 0;
+ If (!IsNull _target) then
+ {
+ _attackPos = (_Enemies select 0) select 1;
+ _grp setvariable ["UPSMON_Attackpos",_attackpos];
+ };
+
+ // Let's check if we have a more dangerous threat
+};
+
+//
+if (!isNull (_target)) then
+{
+ If (alive _target) then
+ {
+ If ((_grp getvariable ["UPSMON_Grptarget",ObjNull]) != _target) then
+ {
+ _timeontarget = time;
+ _grp setvariable ["UPSMON_TIMEONTARGET",_timeontarget];
+ _grp setvariable ["UPSMON_Grptarget",_target];
+ };
+ };
+};
+
+If (count _attackpos == 0) then
+{
+ _attackpos = _grp getvariable ["UPSMON_Attackpos",[]];
+};
+
+If (count _attackpos > 0) then
+{
+ _dist = ([getposATL _npc,_attackPos] call UPSMON_distancePosSqr);
+};
+
+_result = [_target,_dist,_attackPos];
+
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/target/fnc/UPSMON_findnearestenemy.sqf b/scripts/UPSMON/COMMON/target/fnc/UPSMON_findnearestenemy.sqf
new file mode 100644
index 0000000..7984f7d
--- /dev/null
+++ b/scripts/UPSMON/COMMON/target/fnc/UPSMON_findnearestenemy.sqf
@@ -0,0 +1,112 @@
+/****************************************************************
+File: UPSMON_findnearestenemy.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Unit
+Returns:
+ ---> Array of allied groups
+ ---> Array of enies units
+****************************************************************/
+
+private["_npc","_targets","_enemies","_allies","_enemySides","_friendlySides","_side","_unit"];
+
+_npc = _this select 0;
+_npcpos= getposATL _npc;
+_enemies = [];
+_suspectenies = [];
+_allies = [];
+_targets = [];
+
+if (_npc isKindof "CAManBase") then
+{_targets = _npc nearTargets 800;};
+if (_npc isKindof "car") then
+{
+ If ((!isNull gunner (vehicle _npc)) && (gunner (vehicle _npc) == _npc) ) then
+ {_targets = _npc nearTargets 1000;} else {_targets = _npc nearTargets 500;};
+};
+if (_npc isKindof "Tank" || _npc isKindof "Wheeled_APC" || _npc isKindof "Ship") then
+{
+ If (((!isNull gunner (vehicle _npc)) && (gunner (vehicle _npc) == _npc)) || ((!isNull commander (vehicle _npc)) && (commander (vehicle _npc) == _npc))) then
+ {_targets = _npc nearTargets 1500;} else {_targets = _npc nearTargets 500;};
+};
+if (_npc isKindof "StaticWeapon") then
+{_targets = _npc nearTargets 1000;};
+if (_npc isKindof "air") then
+{
+ if ((driver (vehicle _npc) == _npc) || ((!isNull gunner (vehicle _npc)) && (gunner (vehicle _npc) == _npc))) then
+ {_targets = _npc nearTargets 2000;};
+};
+
+_enemySides = _npc call BIS_fnc_enemySides;
+_friendlySides = _npc call BIS_fnc_friendlySides;
+
+{
+ _position = (_x select 0);
+ _cost = (_x select 3);
+ _unit = (_x select 4);
+ _side = (_x select 2);
+ _accuracy = (_x select 5);
+
+ If (_side in _enemySides) then
+ {
+ If (alive _unit) then
+ {
+ If (alive _npc) then
+ {
+ if (count crew _unit > 0) then
+ {
+ if ((side driver _unit) in _enemySides) then
+ {
+ if (_accuracy < 20) then
+ {
+ _enemies pushback _unit;
+ _kv = _npc knowsAbout _unit;
+ _unit setvariable ["UPSMON_TargetInfos",[_position,_accuracy,_cost,_kv]];
+ //[_position,"ColorRed"] call fnc_createMarker;
+ }
+ else
+ {
+ If (_accuracy < 100) then
+ {
+ _suspectenies pushback _unit;
+ _unit setvariable ["UPSMON_TargetInfos",[_position,_accuracy,_cost,time]];
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ If (_unit == leader group _unit) then
+ {
+ if (_unit != _npc) then
+ {
+ If (_side in _friendlySides) then
+ {
+ if (group _unit in UPSMON_NPCs) then
+ {
+ if (round ([getposATL (leader (group _unit)),_npcpos] call UPSMON_distancePosSqr) <= UPSMON_sharedist) then
+ {
+ if (count crew _unit > 0) then
+ {
+ if ((side driver _unit) in _friendlySides) then
+ {
+ _allies pushback (group _unit);
+ //[_position,"ColorBlue"] call fnc_createMarker;
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+
+} forEach _targets;
+
+//if (UPSMON_Debug>0) then {diag_log format ["Targets found by %1: %2",_npc,_enemies];};
+
+_result = [_enemies,_allies,_suspectenies];
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/target/init.sqf b/scripts/UPSMON/COMMON/target/init.sqf
new file mode 100644
index 0000000..6098c58
--- /dev/null
+++ b/scripts/UPSMON/COMMON/target/init.sqf
@@ -0,0 +1,10 @@
+
+UPSMON_findnearestenemy = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\target\fnc\UPSMON_findnearestenemy.sqf";
+UPSMON_ClassifyEnies = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\target\fnc\UPSMON_ClassifyEnies.sqf";
+UPSMON_Shareinfos = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\target\fnc\UPSMON_Shareinfos.sqf";
+UPSMON_TargetAcquisition = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\target\fnc\UPSMON_TargetAcquisition.sqf";
+
+UPSMON_Checkratio = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\target\fnc\UPSMON_Checkratio.sqf";
+UPSMON_Eniesnear = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\target\fnc\UPSMON_Eniesnear.sqf";
+
+UPSMON_TargetAcquisitionCiv = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\target\fnc\UPSMON_TargetAcquisitionCiv.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/terrain/Init.sqf b/scripts/UPSMON/COMMON/terrain/Init.sqf
new file mode 100644
index 0000000..c5fb8b1
--- /dev/null
+++ b/scripts/UPSMON/COMMON/terrain/Init.sqf
@@ -0,0 +1,3 @@
+
+UPSMON_TerraCognita = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\terrain\fnc\UPSMON_TerraCognita.sqf";
+UPSMON_sample_terrain = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\terrain\fnc\UPSMON_sample_terrain.sqf";
diff --git a/scripts/UPSMON/COMMON/terrain/fnc/UPSMON_TerraCognita.sqf b/scripts/UPSMON/COMMON/terrain/fnc/UPSMON_TerraCognita.sqf
new file mode 100644
index 0000000..9881fef
--- /dev/null
+++ b/scripts/UPSMON/COMMON/terrain/fnc/UPSMON_TerraCognita.sqf
@@ -0,0 +1,70 @@
+/****************************************************************
+File: UPSMON_TerraCognita.sqf
+Author: Rydgier
+
+****************************************************************/
+
+private ["_position","_posX","_posY","_radius","_precision","_sourcesCount","_urban","_forest","_hills","_flat","_sea","_valS","_value","_val0","_samples","_sGr","_hprev","_hcurr","_samplePos","_i","_rds"];
+
+_position = _this select 0;
+_samples = _this select 1;
+_rds = 100;
+if ((count _this) > 2) then {_rds = _this select 2};
+
+if !((typeName _position) == "ARRAY") then {_position = getPosATL _position};
+
+_posX = _position select 0;
+_posY = _position select 1;
+
+_radius = 5;
+_precision = 1;
+_sourcesCount = 1;
+
+_urban = 0;
+_forest = 0;
+_hills = 0;
+_flat = 0;
+_sea = 0;
+
+_sGr = 0;
+_hprev = getTerrainHeightASL [_posX,_posY];
+
+for "_i" from 1 to 10 do
+{
+ _samplePos = [_posX + ((random (_rds * 2)) - _rds),_posY + ((random (_rds * 2)) - _rds)];
+ _hcurr = getTerrainHeightASL _samplePos;
+ _sGr = _sGr + abs (_hcurr - _hprev)
+};
+
+_sGr = _sGr/10;
+
+{
+ _valS = 0;
+
+ for "_i" from 1 to _samples do
+ {
+ _position = [_posX + (random (_rds/5)) - (_rds/10),_posY + (random (_rds/5)) - (_rds/10)];
+
+
+ _value = selectBestPlaces [_position,_radius,_x,_precision,_sourcesCount];
+
+ _val0 = _value select 0;
+ _val0 = _val0 select 1;
+
+ _valS = _valS + _val0;
+ };
+
+ _valS = _valS/_samples;
+
+ switch (_x) do
+ {
+ case ("Houses") : {_urban = _urban + _valS};
+ case ("Trees") : {_forest = _forest + (_valS/3)};
+ case ("Forest") : {_forest = _forest + _valS};
+ case ("Hills") : {_hills = _hills + _valS};
+ case ("Meadow") : {_flat = _flat + _valS};
+ case ("Sea") : {_sea = _sea + _valS};
+ };
+} foreach ["Houses","Trees","Forest","Hills","Meadow","Sea"];
+
+[_urban,_forest,_hills,_flat,_sea,_sGr]
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/terrain/fnc/UPSMON_sample_terrain.sqf b/scripts/UPSMON/COMMON/terrain/fnc/UPSMON_sample_terrain.sqf
new file mode 100644
index 0000000..98cc6a5
--- /dev/null
+++ b/scripts/UPSMON/COMMON/terrain/fnc/UPSMON_sample_terrain.sqf
@@ -0,0 +1,41 @@
+/****************************************************************
+File: UPSMON_sample_terrain.sqf
+Author: Azroul13
+
+Description:
+ Get the Type of the terrain that surrounding the position ("inhabited"/"forest"/"sea"/"coast"/"undefined")
+Parameter(s):
+ <--- position
+Returns:
+ Array [terrain type, value of the terrain]
+****************************************************************/
+
+private ["_sample", "_sampleValue", "_sampleType"];
+
+_sample = selectBestPlaces [
+ _this, // sample position
+ 30, // radius
+ "(1000 * houses) + (100 * forest) + (10 * trees) + (1 * meadow) - (1000 * sea)", // expression
+ 10, // precision
+ 1 // sourcesCount
+];
+
+if ((count _sample) < 1) exitWith
+{
+ ["undefined", 0]
+};
+
+_sampleValue = (_sample select 0) select 1;
+_sampleType = "meadow";
+
+switch (true) do
+{
+ case (_sampleValue > 200): { _sampleType = "inhabited"; };
+ case (_sampleValue > 50): { _sampleType = "forest"; };
+ case (_sampleValue < -992): { _sampleType = "sea"; };
+ case (_sampleValue < 0): { _sampleType = "coast"; };
+ case (_sampleValue == 0): { _sampleType = "undefined"; }; // out of map/end of world
+};
+
+// return sample
+[_sampleType, _sampleValue]
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_CreateSmokeCover.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_CreateSmokeCover.sqf
new file mode 100644
index 0000000..f63d9a0
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_CreateSmokeCover.sqf
@@ -0,0 +1,64 @@
+/****************************************************************
+File: UPSMON_CreateSmokeCover.sqf
+Author: Azroul13
+
+Description:
+ Throw a grenade
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_target","_units","_i","_vehicle","_role","_mags"];
+
+_units = _this select 0;
+_targetpos = _this select 1;
+
+_i = 0;
+
+{
+ if (_i >= 3) exitwith {};
+ If (alive _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (!([_x] call UPSMON_InBuilding)) then
+ {
+ If ("SmokeShell" in (magazines _x)) then
+ {
+ If (_x getvariable ["UPSMON_Supstate",""] != "SUPRESSED") then
+ {
+ _targetpos = [(_targetpos select 0) + ((random 10) - (random 20)) , (_targetpos select 1) + ((random 10) - (random 15)),_targetpos select 2];
+ [_x,_targetpos] spawn UPSMON_throw_grenade;
+ _i = _i + 1;
+ };
+ };
+ };
+ }
+ else
+ {
+ _vehicle = vehicle _x;
+ If (getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> "gunnerHasFlares") > 0) then
+ {
+ _role = assignedVehicleRole _vehicle;
+ If (count _role > 1) then
+ {
+ _mags = _vehicle weaponsTurret (_role select 1);
+ _smoke = false;
+ {
+ If (_x == "SmokeLauncher") then
+ {
+ _smoke = true;
+ };
+ } foreach _mags;
+
+ If (_smoke) then
+ {
+ _i = 3;
+ [_vehicle] call UPSMON_DoSmokeScreen;
+ };
+ };
+ };
+ };
+ };
+} foreach _units;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DeployStatic.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DeployStatic.sqf
new file mode 100644
index 0000000..913bfdc
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DeployStatic.sqf
@@ -0,0 +1,42 @@
+/****************************************************************
+File: UPSMON_DeployStatic.sqf
+Author: Azroul13
+
+Description:
+ Check before deploying the static
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_grp","_currpos","_attackpos","_checkforstatic","_staticteam","_insideveh"];
+
+_grp = _this select 0;
+_currpos = _this select 1;
+_attackpos = _this select 2;
+
+_checkforstatic = [_grp] call UPSMON_GetStaticTeam;
+_staticteam = _checkforstatic select 0;
+_weapon = _checkforstatic select 1;
+
+if (count _staticteam == 2) then
+{
+ _insideveh = false;
+ {
+ If (alive _x) exitwith
+ {
+ If (vehicle _x != _x) then
+ {
+ If (!_insideveh) then
+ {
+ _insideveh = true
+ };
+ };
+ };
+ } foreach _staticteam;
+
+ If (!_insideveh) then
+ {
+ [_staticteam select 0,_staticteam select 1,_currpos,_attackpos,_weapon] spawn UPSMON_Unpackbag;
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Disableunitloop.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Disableunitloop.sqf
new file mode 100644
index 0000000..ba33e88
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Disableunitloop.sqf
@@ -0,0 +1,18 @@
+/****************************************************************
+
+****************************************************************/
+private["_unit"];
+
+_unit = _this select 0;
+
+waituntil {IsNull _unit || !alive _unit || !IsNull ((group _unit) getvariable ["UPSMON_target",Objnull]) || _unit getvariable ["UPSMON_SUPSTATUS",""] != "" || _unit getvariable ["UPSMON_Wait",time] <= time};
+
+if (!IsNull _unit) then
+{
+ If (alive _unit) then
+ {
+ _unit switchmove "";
+ _unit enableAI "MOVE";
+ _unit setvariable ["UPSMON_Civdisable",false];
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoFireFlare.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoFireFlare.sqf
new file mode 100644
index 0000000..ee9be60
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoFireFlare.sqf
@@ -0,0 +1,38 @@
+/****************************************************************
+File: UPSMON_DoFireFlare.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_unit","_muzzle","_munition","_target","_direction"];
+
+_unit = _this select 0;
+_muzzle = _this select 1;
+_munition = _this select 2;
+_targetpos = _this select 3;
+
+if (alive _unit) then
+{
+ _target = createVehicle ["UserTexture1m_F",[_targetpos select 0,_targetpos select 1,100], [], 0, "NONE"];
+ _unit selectWeapon _muzzle;
+ [_unit,_targetpos,100] call UPSMON_DOwatch;
+ sleep 0.7;
+ _direction = [_unit, _target] call BIS_fnc_dirTo;
+ _unit setDir _direction;
+ _unit dotarget _target;
+ sleep 4;
+ [] spawn UPSMON_Flaretime;
+ sleep 1;
+ if (alive _unit) then
+ {
+ _unit fire [_muzzle, _muzzle, _munition];
+ sleep 1;
+ _unit dowatch ObjNull;
+ };
+ Deletevehicle _target;
+};
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoRearm.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoRearm.sqf
new file mode 100644
index 0000000..f9fb6f9
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoRearm.sqf
@@ -0,0 +1,68 @@
+/****************************************************************
+File: UPSMON_getunits.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Array of units
+Returns:
+ Array of units
+****************************************************************/
+
+private ["_unit","_magsneeded","_supply","_timeout"];
+
+_unit = _this select 0;
+_supply = (_this select 1) select 0;
+_magsneeded = (_this select 1) select 1;
+
+_position = getposATL _supply;
+
+_supply setvariable ["UPSMON_Supplyuse",true];
+_unit setvariable ["UPSMON_Rearming",true];
+
+Dostop _unit;
+_unit Domove _position;
+_unit setDestination [_position, "LEADER PLANNED", true];
+_unit forcespeed 100;
+
+_timeout = time + (1.4*((getposATL _unit) vectordistance _position));
+
+waituntil {IsNull _unit || IsNull _supply || !alive _unit || !canmove _unit || (getposATL _unit) vectordistance _position <= 4|| time >= _timeout};
+
+If (!IsNull _supply) then
+{
+ If (!IsNull _unit) then
+ {
+ If (alive _unit) then
+ {
+ If (canmove _unit) then
+ {
+ If ((getposATL _unit) vectordistance _position <= 4) then
+ {
+ {
+ _supply removeMagazineGlobal _x;
+ _unit addMagazineGlobal _x;
+ } foreach _magsneeded;
+ };
+ };
+ };
+ };
+};
+
+If (!IsNull _supply) then
+{
+ _supply setvariable ["UPSMON_Supplyuse",false];
+};
+
+If (!IsNull _unit) then
+{
+ If (alive _unit) then
+ {
+ _unit setvariable ["UPSMON_Rearming",false];
+ if (_unit != leader (group _unit)) then
+ {
+ _unit dofollow (leader (group _unit))
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoSmokeScreen.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoSmokeScreen.sqf
new file mode 100644
index 0000000..1cb4c02
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoSmokeScreen.sqf
@@ -0,0 +1,18 @@
+/****************************************************************
+File: UPSMON_throw_grenade.sqf
+Author: MONSADA
+
+Description:
+ Throw a grenade
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_npc","_time"];
+
+_npc = _this select 0;
+
+_npc fire "SmokeLauncher";
+_time = time + 20;
+(group _npc) setvariable ["UPSMON_SmokeTime",_time];
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoSurrender.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoSurrender.sqf
new file mode 100644
index 0000000..655fc1a
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_DoSurrender.sqf
@@ -0,0 +1,59 @@
+/****************************************************************
+File: UPSMON_surrended.sqf
+Author: MONSADA
+
+Description:
+ Function to surrender AI soldier
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_npc","_vehicle"];
+
+_npc = _this select 0;
+
+if (!alive _npc) exitwith {};
+
+_npc addrating -1000;
+_npc setcaptive true;
+sleep 0.5;
+
+_vehicle = vehicle _npc;
+
+if ( _npc != _vehicle || !(_npc iskindof "Man" )) then
+{
+ _vehicle setcaptive true;
+
+ if ( "Air" countType [_vehicle]>0) then
+ {
+
+ //Si acaba de entrar en el heli se define punto de aterrizaje
+ if (_npc == driver _vehicle ) then
+ {
+ [_vehicle,getpos _vehicle] call UPSMON_MoveHeliback;
+ };
+ } else {
+ [_transport,[_npc]] call UPSMON_UnitsGetOut;
+ };
+
+ //Esperamos a que esté parado
+ waituntil {_npc == vehicle _npc || !alive _npc};
+};
+
+if (!alive _npc) exitwith {};
+_npc setcaptive true;
+_npc stop true;
+
+_npc setunitpos "UP";
+//If (_handweap != "") then {_npc action ["DropWeapon","GroundWeaponHolder" createVehicle getposATL _npc,handgunWeapon _npc];};
+_ground = createVehicle ["groundweaponholder", getposATL _npc, [], 0, "NONE"];
+
+If (primaryweapon _npc != "") then {_ground addWeaponCargo [primaryweapon _npc,1];};
+If (secondaryWeapon _npc != "") then {_ground addWeaponCargo [secondaryWeapon _npc,1];};
+If (handgunWeapon _npc != "") then {_ground addWeaponCargo [handgunWeapon _npc,1];};
+
+RemoveAllweapons _npc;
+
+sleep 1;
+_npc playMoveNow "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_FireFlare.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_FireFlare.sqf
new file mode 100644
index 0000000..9f91642
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_FireFlare.sqf
@@ -0,0 +1,81 @@
+/****************************************************************
+File: UPSMON_FireFlare.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_grp","_muzzle","_munition","_weapon","_muzzles","_cfg","_parents","_muns","_flaresclass"];
+
+_grp = _this select 0;
+_targetpos = _this select 1;
+
+_muzzle = "";
+_munition = "";
+
+{
+ If (alive _x) then
+ {
+ _unit = _x;
+ If (vehicle _unit == _unit) then
+ {
+ If (Unitready _unit) then
+ {
+ _weapon = primaryWeapon _unit;
+ If (_weapon != "") then
+ {
+ _muzzles = getArray(configFile>> "cfgWeapons" >> _weapon >> "muzzles");
+ _continue = false;
+ {
+ if (_x != "this") then
+ {
+ _cfg = (configFile>> "cfgWeapons" >> _weapon >> _x);
+ _parents = [_cfg,true] call BIS_fnc_returnParents;
+ If ("UGL_F" in _parents) exitwith
+ {
+ _muzzle = _x;
+ _continue = true;
+ };
+ };
+ } foreach _muzzles;
+
+ If (_continue) then
+ {
+ _muns = getarray (configFile>> "cfgWeapons" >> _weapon >> _muzzle >> "magazines");
+ _flaresclass = [];
+ {
+ _ammo = tolower gettext (configFile>> "CfgMagazines" >> _x >> "ammo");
+ _cfg = getnumber (configFile>> "CfgAmmo" >> _ammo >> "useFlare");
+
+ If (_cfg == 1) then
+ {
+ _flaresclass pushback _x;
+ };
+ } foreach _muns;
+
+ If (count _flaresclass > 0) then
+ {
+ _continue = false;
+ {
+ If (_x in (magazines _unit)) exitwith
+ {
+ _munition = _x;
+ _continue = true;
+ };
+ } foreach _flaresclass;
+
+ If (_continue) exitwith
+ {
+ [_unit,_muzzle,_munition,_targetpos] spawn UPSMON_DoFireFlare;
+ };
+ };
+ };
+ };
+ };
+ }
+ }
+} foreach units _grp;
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_FireGun.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_FireGun.sqf
new file mode 100644
index 0000000..61d198f
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_FireGun.sqf
@@ -0,0 +1,75 @@
+/****************************************************************
+File: UPSMON_FireGun.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_grp","_assignedvehicles","_target","_gunner","_vehicle","_mags","_ammo","_gun","_weapon","_targetpos"];
+
+_grp = _this select 0;
+_assignedvehicles = _this select 1;
+_target = _this select 2;
+
+_gunner = ObjNull;
+_munition = "";
+
+
+{
+ If (alive _x) then
+ {
+ _vehicle = _x;
+ If (!(_vehicle iskindof "CAManBase")) then
+ {
+ If (!IsNull (gunner _vehicle)) then
+ {
+ If (alive (gunner _vehicle)) then
+ {
+ _mags = magazinesAmmo _vehicle;
+ _gun = false;
+ {
+ If (_x select 1 > 0) then
+ {
+ _ammo = tolower gettext (configFile >> "CfgMagazines" >> _x select 0 >> "ammo");
+ If (_ammo iskindof "ShellBase") exitwith
+ {
+ _gun = true;
+ _munition = _x select 0;
+ };
+ };
+ } foreach _mags;
+
+ If (_gun) then
+ {
+ _gunner = gunner _vehicle;
+ };
+ };
+ }
+ };
+ };
+} foreach _assignedvehicles;
+
+if (!IsNull _gunner) then
+{
+ _weapon = (weapons (vehicle _gunner)) select 0;
+ _gunner selectWeapon _weapon;
+ _targetpos = getposATL _target;
+ [_gunner,_targetpos,1.5] call UPSMON_DOwatch;
+ sleep 2;
+ _gunner doTarget _target;
+ sleep 2;
+ if (alive _gunner) then
+ {
+ If ([_gunner,_target,1000,270] call UPSMON_HasLos) then
+ {
+ _grp setvariable ["UPSMON_GrpinAction",true];
+ (vehicle _gunner) fire _weapon;
+ sleep 2;
+ _gunner dowatch ObjNull;
+ };
+ };
+};
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Getmemberstype.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Getmemberstype.sqf
new file mode 100644
index 0000000..d31e073
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Getmemberstype.sqf
@@ -0,0 +1,46 @@
+/****************************************************************
+File: UPSMON_Getmemberstype.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- members of the group
+Returns:
+ Array: [[],[]]
+****************************************************************/
+
+private ["_members","_vehicles","_equipment","_membertypes","_vehicletypes","_dirveh","_unitstype"];
+
+_members = _this select 0;
+_vehicles = [];
+_membertypes = [];
+_vehicletypes = [];
+
+//Fills member soldier types
+{
+ if (vehicle _x != _x ) then
+ {
+ if (!(vehicle _x in _vehicles)) then
+ {
+ _vehicles pushback (vehicle _x);
+ };
+ };
+
+ _equipment = _x call UPSMON_getequipment;
+ //_membertypes = _membertypes + [[typeof _x,_equipment]];
+ _membertypes pushback [typeof _x,_equipment,assignedVehicleRole _x];
+} foreach _members;
+
+//Fills member vehicle types
+{
+ _dirveh = getdir _x;
+ _unitsin = [];
+
+ //_vehicletypes = _vehicletypes + [typeof _x,_dirveh,_unitsin];
+ _vehicletypes pushback [typeof _x,_dirveh];
+} foreach _vehicles;
+
+_unitstype = [_membertypes,_vehicletypes];
+If (UPSMON_Debug > 0) then {Diag_log format ["Units Array:%1",_unitstype]};
+_unitstype
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Packbag.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Packbag.sqf
new file mode 100644
index 0000000..bc1f92c
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Packbag.sqf
@@ -0,0 +1,51 @@
+/****************************************************************
+File: UPSMON_Packbag.sqf
+Author: Azroul13
+
+Description:
+ Team dismounts static weapon
+Parameter(s):
+ <--- Gunner
+ <--- Assistant
+ <--- Static to dismount
+Returns:
+ Nothing
+****************************************************************/
+
+private["_gunner","_assistant","_weapon","_B_weapon","_B_tripod","_array","_position"];
+
+_gunner = _this select 0;
+_assistant = _this select 1;
+_weapon = vehicle _gunner;
+
+_B_weapon = "";
+_B_tripod = "";
+_array = getarray (configFile >> "cfgVehicles" >> typeof _weapon >> "assembleInfo" >> "dissasembleTo");
+If (count _array > 0) then
+{
+ _B_weapon = _array select 0;
+ _B_tripod = _array select 1;
+};
+
+_position = position _weapon;
+unassignVehicle _gunner;
+_gunner action ["getOut", _weapon];
+doGetOut _gunner;
+[_gunner] allowGetIn false;
+
+
+sleep 0.5;
+deletevehicle _weapon;
+sleep 1;
+
+if (alive _gunner && alive _assistant) then
+{
+ if (_B_weapon != "" && _B_tripod != "") then
+ {
+ _gunner addBackpack _B_weapon;
+ _assistant addBackpack _B_tripod;
+ };
+ sleep 1;
+ _assistant enableAI "move";
+ _gunner enableAI "move";
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_PutMine.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_PutMine.sqf
new file mode 100644
index 0000000..a1e6174
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_PutMine.sqf
@@ -0,0 +1,83 @@
+/****************************************************************
+File: UPSMON_doCreateMine.sqf
+Author: MONSADA
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+
+private ["_minetype","_soldier","_position","_dir","_minesnbr"];
+
+_soldier = _this select 0;
+_grp = _this select 1;
+_position = [(_this select 2) select 0,(_this select 2) select 1,0];
+_currPos = _this select 3;
+_minemag = _this select 4;
+
+if (isnil "_soldier") exitWith {};
+_grp setvariable ["UPSMON_GrpinAction",true];
+
+_minetype = "";
+switch (_minemag) do
+{
+ case "SLAMDirectionalMine_Wire_Mag":
+ {
+ _minetype = "SLAMDirectionalMine";
+ };
+
+ case "ATMine_Range_Mag":
+ {
+ _minetype = "ATMine";
+ };
+};
+
+//If not is Man or dead exit
+if (!alive _soldier || !canstand _soldier) exitwith {_grp setvariable ["UPSMON_GrpinAction",false];};
+
+
+_soldier domove _position;
+_soldier disableAI "AUTOTARGET";
+_soldier disableAI "TARGET";
+_soldier setDestination [_position, "LEADER PLANNED", true];
+
+if (!isnil "_soldier") then
+{
+ waituntil {unitReady _soldier || moveToCompleted _soldier || moveToFailed _soldier || !alive _soldier || !canstand _soldier || ((getposATL _soldier) vectordistance _position <= 5)}
+};
+
+if (moveToFailed _soldier || !alive _soldier || _soldier != vehicle _soldier || !canmove _soldier) exitwith {_grp setvariable ["UPSMON_GrpinAction",false];};
+
+//Crouche
+//_soldier playMove "ainvpknlmstpslaywrfldnon_1";
+
+sleep 1;
+if (isnil "_soldier") exitWith {_grp setvariable ["UPSMON_GrpinAction",false];};
+if (!alive _soldier || !canstand _soldier) exitwith {_grp setvariable ["UPSMON_GrpinAction",false];};
+
+
+_dir = getdir _soldier;
+_minesnbr = {_x == _minemag} count (magazines _soldier);
+[_minesnbr,_minetype,_minetype,_position,_dir,side _soldier] spawn UPSMON_spawnmines;
+
+//Remove magazines
+for "_x" from 0 to _minesnbr do
+{
+ _soldier removeMagazineGlobal _minemag;
+};
+//Prepare mine
+//_soldier playMoveNow "AinvPknlMstpSlayWrflDnon_medic";
+sleep 1;
+
+if (alive _soldier) then
+{
+ _soldier Domove _currPos;
+ _soldier enableAI "AUTOTARGET";
+ _soldier enableAI "TARGET";
+};
+//Return to formation
+if (isnil "_soldier") exitWith {_grp setvariable ["UPSMON_GrpinAction",false];};
+_grp setvariable ["UPSMON_GrpinAction",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_PutSatchel.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_PutSatchel.sqf
new file mode 100644
index 0000000..3536d25
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_PutSatchel.sqf
@@ -0,0 +1,82 @@
+/****************************************************************
+File: UPSMON_doCreateMine.sqf
+Author: MONSADA
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+
+private ["_minetype","_soldier","_position","_currPos","_minemag"];
+
+_soldier = _this select 0;
+_grp = _this select 1;
+_position = [(_this select 2) select 0,(_this select 2) select 1,0];
+_currPos = _this select 3;
+_minemag = _this select 4;
+
+if (isnil "_soldier") exitWith {};
+_muzzle = "";
+switch (_minemag) do
+{
+ case "SatchelCharge_Remote_Mag":
+ {
+ _muzzle = "SatchelChargeMuzzle";
+ };
+
+ case "DemoCharge_Remote_Mag":
+ {
+ _muzzle = "DemoChargeMuzzle";
+ };
+};
+
+//If not is Man or dead exit
+if (!alive _soldier || !canstand _soldier) exitwith {};
+
+
+_soldier domove _position;
+_soldier disableAI "AUTOTARGET";
+_soldier disableAI "TARGET";
+_soldier setDestination [_position, "LEADER PLANNED", true];
+_soldier forcespeed 100;
+if (!isnil "_soldier") then
+{
+ waituntil {unitReady _soldier || moveToCompleted _soldier || moveToFailed _soldier || !alive _soldier || !canstand _soldier || ((getposATL _soldier) vectordistance _position <= 10)}
+};
+
+if (moveToFailed _soldier || !alive _soldier || _soldier != vehicle _soldier || !canmove _soldier) exitwith {};
+
+//Crouche
+//_soldier playMove "ainvpknlmstpslaywrfldnon_1";
+
+sleep 0.5;
+if (isnil "_soldier") exitWith {};
+if (!alive _soldier || !canstand _soldier) exitwith {};
+
+_soldier playActionNow "PutDown";
+_soldier selectWeapon _muzzle;
+_soldier fire [_muzzle, _muzzle, _minemag];
+
+//Prepare mine
+//_soldier playMoveNow "AinvPknlMstpSlayWrflDnon_medic";
+sleep 1;
+
+if (alive _soldier) then
+{
+ _soldier Domove _currPos;
+ waituntil {_position vectordistance (getposATL _soldier) >= 50 || !alive _soldier || !canmove _soldier};
+
+ If (alive _soldier) then
+ {
+ _soldier enableAI "AUTOTARGET";
+ _soldier enableAI "TARGET";
+ _soldier forcespeed -1;
+ _soldier action ["TOUCHOFF", _soldier];
+ _soldier dofollow (leader (group _soldier));
+ };
+};
+//Return to formation
+if (isnil "_soldier") exitWith {};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Rearm.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Rearm.sqf
new file mode 100644
index 0000000..6a54b72
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Rearm.sqf
@@ -0,0 +1,125 @@
+/****************************************************************
+File: UPSMON_Rearm.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Array of units
+Returns:
+ Array of units
+****************************************************************/
+
+private ["_unit","_magsneeded","_supplylist","_supplies","_supply","_ammo","_points","_ammoclass","_array","_list","_containers"];
+
+_unit = _this select 0;
+_magsneeded = _this select 1;
+_supplylist = [];
+
+If (!(_unit getvariable ["UPSMON_Rearming",false])) then
+{
+ If (canmove _unit) then
+ {
+ If (unitready _unit) then
+ {
+ If (IsNull(assignedTarget _unit) || (getposATL (assignedTarget _unit)) vectordistance (getposATL _unit) > 300) then
+ {
+ If (_unit getvariable ["UPSMON_SUPSTATUS",""] == "") then
+ {
+ If (vehicle _unit == _unit) then
+ {
+ _supplies = (getposATL _unit) nearSupplies 50;
+
+ {
+ If (!(_x getvariable ["UPSMON_Supplyuse",false])) then
+ {
+ _supply = _x;
+ _ammo = [];
+ if (_supply != _unit) then
+ {
+ If (_supply iskindof "MAN") then
+ {
+ If (alive _supply) then
+ {
+ if (side _supply == side _unit) then
+ {
+ _ammo = (getMagazineCargo backpackContainer _supply) select 0;
+ };
+ }
+ else
+ {
+ _containers = [];
+ _containers pushback (backpackContainer _supply);
+ _containers pushback (vestContainer _supply);
+ _containers pushback (uniformContainer _supply);
+ {
+ _ammo = [_ammo, (getMagazineCargo _x) select 0] call BIS_fnc_arrayPushStack
+ } foreach _containers;
+ };
+ }
+ else
+ {
+ If (_supply iskindof "CAR" || _supply iskindof "TANK" || _supply iskindof "AIR") then
+ {
+ If ((IsNull (driver _supply)) || !alive (driver _supply) || (side (driver _supply) == side _unit)) then
+ {
+ _ammo = (getMagazineCargo _supply) select 0;
+ };
+ }
+ else
+ {
+ _ammo = (getMagazineCargo _supply) select 0;
+ };
+ };
+ };
+
+ If (count _ammo > 0) then
+ {
+ _points = 0;
+ _ammoclass = [];
+ If ({_x in (_magsneeded select 0)} count _ammo > 0) then
+ {
+ {
+ if (_x in (_magsneeded select 0)) then
+ {
+ If (_unit canAdd _x) then
+ {
+ _ammoclass pushback _x;
+ };
+ };
+ } foreach _ammo;
+ _points = _points + 100;
+ };
+
+ If ({_x in (_magsneeded select 1)} count _ammo > 0) then
+ {
+ {
+ if (_x in (_magsneeded select 1)) then
+ {
+ If (_unit canAdd _x) then
+ {
+ _ammoclass pushback _x;
+ };
+ };
+ } foreach _ammo;
+ _points = _points + 50;
+ };
+
+ _supplylist pushback [_supply,_ammoclass,_points];
+ };
+ };
+ } foreach _supplies;
+
+ If (count _supplylist > 0) then
+ {
+ _list = [_supplylist, [], {_x select 2}, "DESCEND"] call BIS_fnc_sortBy;
+ _array = _list select 0;
+ _array resize 2;
+ [_unit,_array] spawn UPSMON_DoRearm;
+ };
+ };
+ };
+ };
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_SetMinefield.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_SetMinefield.sqf
new file mode 100644
index 0000000..92d3e01
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_SetMinefield.sqf
@@ -0,0 +1,60 @@
+/****************************************************************
+File: UPSMON_SetMinefield.sqf
+Author: MONSADA
+
+Description:
+ Function to put a mine
+Parameter(s):
+ <--- unit
+ <--- position where to put the mine
+ <--- Classname of the mine
+Returns:
+
+****************************************************************/
+private ["_grp","_attackpos","_currPos","_ATmine","_Atunit","_dir1","_mineposition","_roads"];
+
+_grp = _this select 0;
+_attackpos = _this select 1;
+_currPos = getposATL (leader _grp);
+
+If (UPSMON_useMines) then
+{
+ _ATmag = ObjNull;
+ _unit = ObjNull;
+
+ {
+ If (alive _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (canstand _x) then
+ {
+ If ("ATMine_Range_Mag" in (magazines _x) || "SLAMDirectionalMine_Wire_Mag" in (magazines _x)) exitwith
+ {
+ If ("ATMine_Range_Mag" in (magazines _x)) then
+ {
+ _ATmag = "ATMine_Range_Mag";
+ }
+ else
+ {
+ _ATmag = "SLAMDirectionalMine_Wire_Mag";
+ };
+ _Atunit = _x;
+ };
+ };
+ };
+ };
+ } foreach units _grp;
+
+ If (!IsNull _unit) then
+ {
+ If ((random 100) < 40) then
+ {
+ _dir1 = [_currPos,_attackpos] call BIS_fnc_DirTo;;
+ _mineposition = [_currPos,_dir1, 30] call UPSMON_GetPos2D;
+ _roads = _mineposition nearroads 25;
+ if (count _roads > 0) then {_mineposition = getposATL (_roads select 0);};
+ [_unit,_grp,_mineposition,_currPos,_ATmag] spawn UPSMON_PutMine;
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_SetSatchel.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_SetSatchel.sqf
new file mode 100644
index 0000000..ed58819
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_SetSatchel.sqf
@@ -0,0 +1,65 @@
+/****************************************************************
+File: UPSMON_SetMinefield.sqf
+Author: MONSADA
+
+Description:
+ Function to put a mine
+Parameter(s):
+ <--- unit
+ <--- position where to put the mine
+ <--- Classname of the mine
+Returns:
+
+****************************************************************/
+private ["_grp","_attackpos","_currPos","_ATmine","_Atunit","_dir1","_mineposition","_roads","_units"];
+
+_grp = _this select 0;
+_attackpos = _this select 1;
+_currPos = getposATL (leader _grp);
+
+_grp setvariable ["UPSMON_GrpinAction",true];
+
+If (UPSMON_useMines) then
+{
+ _Satchelmag = ObjNull;
+ _unit = ObjNull;
+
+ {
+ If (alive _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (canstand _x) then
+ {
+ If ("SatchelCharge_Remote_Mag" in (magazines _x) || "DemoCharge_Remote_Mag" in (magazines _x)) exitwith
+ {
+ If ("SatchelCharge_Remote_Mag" in (magazines _x)) then
+ {
+ _Satchelmag = "SatchelCharge_Remote_Mag";
+ }
+ else
+ {
+ _Satchelmag = "DemoCharge_Remote_Mag";
+ };
+
+ _unit = _x;
+ };
+ };
+ };
+ };
+ } foreach units _grp;
+
+ _units = units _grp - [_unit];
+
+ If (!IsNull _unit) then
+ {
+ If ((random 100) < 40) then
+ {
+ _nosmoke = [_grp] call UPSMON_NOSMOKE;
+ If (!_nosmoke) then {[_units,_attackpos] call UPSMON_CreateSmokeCover;};
+ [_unit,_grp,_attackpos,_currPos,_Satchelmag] call UPSMON_PutSatchel;
+ };
+ };
+};
+
+_grp setvariable ["UPSMON_GrpinAction",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Unpackbag.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Unpackbag.sqf
new file mode 100644
index 0000000..32c2a15
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Unpackbag.sqf
@@ -0,0 +1,70 @@
+/****************************************************************
+File: UPSMON_Unpackbag.sqf
+Author: Azroul13
+
+Description:
+ Units mounts static weapon
+Parameter(s):
+ <--- Gunner
+ <--- Assistant
+ <--- Position where teams mount static
+ <--- Position where teams points the static
+Returns:
+ Nothing
+****************************************************************/
+
+private["_gunner","_assistant","_position","_targetPos","_weapontype","_group","_weapon","_dirTo"];
+
+_gunner = _this select 0;
+_assistant = _this select 1;
+_position = _this select 2;
+_targetPos = _this select 3;
+_weapontype = _this select 4;
+_group = group _gunner;
+_group setvariable ["UPSMON_GrpinAction",true];
+
+{
+ Dostop _x;
+ sleep 0.1;
+ _x doMove _position;
+ _x forcespeed 100;
+ _x commandmove _position;
+ _x setDestination [_position, "LEADER DIRECT",false];
+ _x disableAI "AUTOTARGET";
+ _x disableAI "TARGET";
+} forEach [_gunner,_assistant];
+
+
+waitUntil {unitReady _gunner || !alive _gunner || !canmove _gunner};
+If (!alive _gunner || !canmove _gunner) exitwith {};
+waitUntil {unitReady _assistant || !alive _assistant || !canmove _assistant};
+If (!alive _assistant || !canmove _assistant) exitwith {};
+
+
+if (alive _gunner && alive _assistant) then
+{
+ {
+ _x disableAI "MOVE";
+ _x playActionNow "PutDown";
+ RemoveBackpack _x;
+ } forEach [_gunner,_assistant];
+
+ //_weapon = "_weapontype" createVehicle [_weapontype,_position, [], 0, "NONE"];
+ _weapon = _weapontype createVehicle _position;
+ sleep 0.05;
+ _dirTo = [getposATL _weapon,_targetPos] call BIS_fnc_dirTo;
+ _weapon setDir _dirTo;
+ sleep 2;
+ _gunner assignAsGunner _weapon;
+ _gunner moveInGunner _weapon;
+
+ {
+ _x enableAI "AUTOTARGET";
+ _x enableAI "TARGET";
+ _x forcespeed -1;
+ } forEach [_gunner,_assistant];
+ sleep 3;
+ _gunner commandWatch _targetPos;
+};
+
+_group setvariable ["UPSMON_GrpinAction",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Watchbino.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Watchbino.sqf
new file mode 100644
index 0000000..26ec185
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_Watchbino.sqf
@@ -0,0 +1,69 @@
+/****************************************************************
+File: UPSMON_Watchbino.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Array of units
+Returns:
+ Array of units
+****************************************************************/
+
+private ["_npc","_hasbinocular","_timeout","_colorstatus","_dir","_dirpos"];
+_npc = _this select 0;
+_lookingpos = _this select 1;
+
+_dir1 =[getposATL _npc, _lookingpos] call BIS_fnc_DirTo;
+
+If (!IsNull _npc) then
+{
+ If (alive _npc) then
+ {
+
+ If (vehicle _npc == _npc) then
+ {
+ _hasbinocular = {_x == "Binocular"} count (weapons _npc);
+ If (count _hasbinocular > 0) then
+ {
+ _timeout = time + 15;
+ sleep 0.5;
+ _npc selectWeapon "Binocular";
+ //_colorstatus = ((group _npc) getvariable "UPSMON_Grpstatus") select 1;
+ while {_timeout > time && alive _npc} do
+ {
+ _npc enableAI "anim";
+ sleep 1;
+ //_colorstatus = ((group _npc) getvariable "UPSMON_Grpstatus") select 1;
+ If (!alive _npc) exitwith {};
+ _dir2 = [(_dir1 + (random 70)),(_dir1 + ((random 100) + 190))] select (floor (random 2));
+ _dirpos = [getposATL _npc,_dir2, 200] call UPSMON_GetPos2D;
+ [_npc,_dirpos] call UPSMON_dowatch;
+ sleep 0.7;
+ _unit setDir _dir2;
+ If (!alive _npc) exitwith {};
+ _npc disableAI "anim";
+ _npc dowatch objnull;
+ };
+ If (alive _npc) then {_npc lookat objNull;_npc enableAI "anim";_npc selectWeapon ((weapons _npc) select 0);};
+ };
+ }
+ else
+ {
+ _timeout = time + 15;
+
+ while {_timeout > time && alive _npc} do
+ {
+ sleep 1;
+ //_colorstatus = ((group _npc) getvariable "UPSMON_Grpstatus") select 1;
+ If (!alive _npc) exitwith {};
+ _dir2 = [(_dir1 + (random 70)),(_dir1 + ((random 100) + 190))] select (floor (random 2));
+ _dirpos = [getposATL _npc,_dir2, 200] call UPSMON_GetPos2D;
+ [_npc,_dirpos] call UPSMON_dowatch;
+ sleep 1;
+ If (!alive _npc) exitwith {};
+ _npc dowatch objnull;
+ };
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_addequipment.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_addequipment.sqf
new file mode 100644
index 0000000..830077e
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_addequipment.sqf
@@ -0,0 +1,77 @@
+/****************************************************************
+File: UPSMON_addequipment.sqf
+Author: Azroul13
+
+Description:
+ Add the equipment collected from UPSMON_getequipment function
+Parameter(s):
+ <--- unit
+Returns:
+ Nothing
+****************************************************************/
+private ["_unit","_clonearray","_uniform","_headgear","_vest","_classbag","_itemsunit","_assigneditems","_allmag","_weaponsunit","_array1","_array2","_index","_magazineName","_count","_weapon","_item","_item1","_item2","_item3","_magweapon1","_magweapon2"];
+_unit = _this select 0;
+
+_clonearray = _this select 1;
+_uniform = _clonearray select 0;
+_headgear = _clonearray select 1;
+_vest = _clonearray select 2;
+_classbag = _clonearray select 3;
+_itemsunit = _clonearray select 4;
+_assigneditems = _clonearray select 5;
+_allmag = _clonearray select 6;
+_weaponsunit = _clonearray select 7;
+
+
+removeAllAssignedItems _unit;
+removeHeadgear _unit;
+removeAllItemsWithMagazines _unit;
+removeAllWeapons _unit;
+removeAllContainers _unit;
+
+If (_uniform != "") then {_unit addUniform _uniform;};
+If (_vest != "") then {_unit addVest _vest;};
+If (_headgear != "") then {_unit addHeadgear _headgear;};
+If (_classbag != "") then {_unit addBackpack _classbag;};
+
+{
+ _unit addItem _x;
+} foreach _itemsunit;
+
+{
+ _unit addItem _x;
+ _unit assignItem _x;
+} foreach _assigneditems;
+
+{
+ If (count _x > 0) then
+ {
+ _array1 = _x select 0;
+ _array2 = _x select 1;
+ _index = -1;
+ {
+ _index = _index + 1;
+ _magazineName = _x;
+ _count = _array2 select _index;
+ _unit addMagazines [_magazineName, _count];
+ } foreach _array1;
+ };
+} foreach _allmag;
+
+_index = -1;
+
+{
+ _index = _index + 1;
+ If (count _x > 0) then
+ {
+ _weapon = _x select 0;
+ _items = _x select 1;
+ _magweapon = _x select 2;
+
+ if (_index == 0) then {{_item = _x; If (_item != "") then {_unit addPrimaryWeaponItem _item;}} foreach _items;};
+ if (_index == 2) then {{_item = _x; If (_item != "") then {_unit addHandgunItem _item;}} foreach _items;};
+
+ _unit addMagazineGlobal _magweapon;
+ _unit addWeaponGlobal _weapon;
+ };
+} foreach _weaponsunit;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_cancelstop.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_cancelstop.sqf
new file mode 100644
index 0000000..3035aca
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_cancelstop.sqf
@@ -0,0 +1,15 @@
+/****************************************************************
+File: UPSMON_cancelstop.sqf
+Author: MONSADA
+
+Description:
+ Función que detiene al soldado y lo hace esperar x segundos
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_npc"];
+
+_npc = _this select 0;
+_npc stop false;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_deadbodies.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_deadbodies.sqf
new file mode 100644
index 0000000..bf3f66b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_deadbodies.sqf
@@ -0,0 +1,35 @@
+/****************************************************************
+File: UPSMON_deadbodies.sqf
+Author: Monsada
+
+Description:
+ Función que devuelve un array con los vehiculos terrestres más cercanos
+Parameter(s):
+ <--- object for position search
+ <--- max distance from npc
+Returns:
+ ---> _vehicles: array of vehiclesnetid object
+****************************************************************/
+private["_vehicles","_npc","_bodies","_OCercanos","_distance","_side"];
+
+_npc = _this select 0;
+_distance = _this select 1;
+
+_OCercanos = [];
+_bodies = objNull;
+
+//Buscamos objetos cercanos
+_OCercanos = nearestObjects [_npc,["Man"],_distance];
+
+{
+ if (!alive _x) then
+ {
+ if ([_npc,_x,_distance,130] call UPSMON_Haslos) exitwith
+ {
+ _bodies = _x;
+ _bodies
+ };
+ };
+}foreach _OCercanos;
+
+_bodies;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_doGetOut.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_doGetOut.sqf
new file mode 100644
index 0000000..f91c0dc
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_doGetOut.sqf
@@ -0,0 +1,43 @@
+/****************************************************************
+File: UPSMON_doGetOut.sqf
+Author: MONSADA
+
+Description:
+ Function for order a unit to exit
+Parameter(s):
+ <--- unit
+ <--- Vehicle to leave
+Returns:
+
+****************************************************************/
+
+private["_vehicle","_npc","_getout" ,"_gunner","_groupOne","_timeout","_dir"];
+
+_npc = _this;
+_vehicle = vehicle (_npc);
+
+sleep 0.05;
+if (_vehicle == _npc) exitwith{};
+
+//Wait until vehicle is stopped
+waituntil {!alive _npc || !canmove _npc || !alive _vehicle || ( (abs(velocity _vehicle select 0)) <= 0.5 && (abs(velocity _vehicle select 1)) <= 0.5 )
+ || ( _vehicle iskindof "Air" && ((getposATL _vehicle) select 2) <= 2.5)};
+
+if (!alive _npc || !canmove _npc) exitwith{};
+unassignVehicle _npc;
+_npc action ["getOut", _vehicle];
+doGetOut _npc;
+[_npc] allowGetIn false;
+nul = [_npc] spawn UPSMON_cancelstop;
+
+waituntil {!alive _npc || !canmove _npc || vehicle _npc == _npc};
+if (!alive _npc || !canmove _npc) exitwith{};
+
+if (leader _npc != _npc) then
+{
+ //Moves out with dispersion of 45º
+ _dir = getDir _npc;
+ _dir = _dir + 45 - (random 90);
+ nul = [_npc,25,_dir] spawn UPSMON_domove;
+ //if (UPSMON_Debug>0 ) then { player globalchat format["%1 Moving away from %2 %2º",_npc, typeof _vehicle,_dir];};
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_doStop.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_doStop.sqf
new file mode 100644
index 0000000..49ce977
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_doStop.sqf
@@ -0,0 +1,33 @@
+/****************************************************************
+File: UPSMON_doStop.sqf
+Author: MONSADA
+
+Description:
+ Función que detiene al soldado y lo hace esperar x segundos
+Parameter(s):
+ <--- unit
+ <--- Wait time
+Returns:
+
+****************************************************************/
+private["_sleep","_npc"];
+
+_npc = _this select 0;
+_sleep = _this select 1;
+
+sleep 0.05;
+if (!alive _npc || !canmove _npc ) exitwith{};
+if ( _sleep == 0 ) then {_sleep = 0.1};
+
+//Restauramos valores por defecto de movimiento
+if (((group _npc) getvariable "UPSMON_Grpstatus") select 0 == "FORTIFY") then
+{
+ dostop _npc ;
+ _npc disableAI "TARGET";
+}
+else
+{
+ dostop _npc ;
+ sleep _sleep;
+ [_npc] spawn UPSMON_cancelstop;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_domove.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_domove.sqf
new file mode 100644
index 0000000..508c822
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_domove.sqf
@@ -0,0 +1,31 @@
+/****************************************************************
+File: UPSMON_domove.sqf
+Author: MONSADA
+
+Description:
+ Mueve al soldado adelante
+Parameter(s):
+ <--- unit
+ <--- Distance
+Returns:
+ nothing
+****************************************************************/
+private["_npc","_dir1","_targetPos","_dist"];
+
+_npc = _this select 0;
+_dist = _this select 1;
+if ((count _this) > 2) then {_dir1 = _this select 2;} else{_dir1 = getDir _npc;};
+
+sleep 0.05;
+if (!alive _npc || !canmove _npc ) exitwith{};
+
+_targetPos = [position _npc,_dir1, _dist] call UPSMON_GetPos2D;
+//If position water and not boat, plane nor diver no go
+
+if (surfaceIsWater _targetPos && { !( _npc iskindof "boat" || _npc iskindof "air" || ["diver", (typeOf (leader _npc))] call BIS_fnc_inString ) } ) exitwith
+{
+ if (UPSMON_Debug>0) then {
+ diag_log format ["UPSMON 'UPSMON_domove' exit: targetPos is water: [%1] - [%2] - [%3]", _npc iskindof 'boat', _npc iskindof 'air', ['diver', (typeOf (leader _npc))] call BIS_fnc_inString];
+ };
+};
+_npc doMove _targetPos;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_dowatch.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_dowatch.sqf
new file mode 100644
index 0000000..d474c5b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_dowatch.sqf
@@ -0,0 +1,32 @@
+/****************************************************************
+File: UPSMON_dowatch.sqf
+Author: MONSADA
+
+Description:
+ Función para mirar en una dirección
+Parameter(s):
+ <--- Unit
+ <--- Position to watch
+Returns:
+
+****************************************************************/
+private["_target","_npc","_height"];
+
+_npc = _this select 0;
+_target = _this select 1;
+_height = 1;
+If (count _this > 2) then {_height = _this select 2};
+
+If (typename _target == "ARRAY") then
+{
+ _target = [(_this select 1) select 0,(_this select 1) select 1,_height];
+}
+else
+{
+ _target = getposATL _target;
+ _target set [2,_height];
+};
+
+if (!alive _npc) exitwith{};
+_npc doWatch ObjNull;
+_npc doWatch _target;
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_firing.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_firing.sqf
new file mode 100644
index 0000000..9f4d7e8
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_firing.sqf
@@ -0,0 +1,38 @@
+/****************************************************************
+File: UPSMON_DoFireFlare.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_unit","_muzzle","_munition","_target"];
+
+_unit = _this select 0;
+_target = _this select 1;
+
+if (alive _unit) then
+{
+ _targetpos = getposATL _target;
+ _target = createVehicle ["UserTexture1m_F",[_targetpos select 0,_targetpos select 1,5], [], 0, "NONE"];;
+ _weapon = primaryweapon _unit;
+ _unit selectWeapon _weapon;
+ [_unit,_targetpos,1.5] call UPSMON_DOwatch;
+ sleep 2;
+ _unit doTarget _target;
+ sleep 8;
+ if (alive _unit) then
+ {
+ _ammo = _unit ammo _weapon;
+ _unit setAmmo [_weapon, 10];
+ _unit forceWeaponFire [_weapon, "FullAuto"];
+ _unit setAmmo [_weapon, _ammo];
+ sleep 1;
+ _unit dowatch ObjNull;
+ _unit doTarget ObjNull;
+ };
+ Deletevehicle _target;
+};
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_getequipment.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_getequipment.sqf
new file mode 100644
index 0000000..9b536b5
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_getequipment.sqf
@@ -0,0 +1,64 @@
+/****************************************************************
+File: UPSMON_getequipment.sqf
+Author: Azroul13
+
+Description:
+ In order to respawn a unit with the same loadout
+ Called from UPSMON.sqf
+Parameter(s):
+ <--- unit
+Returns:
+ Array of equipments
+****************************************************************/
+
+private ["_unit","_maguniformunit","_magbackunit","_magvestunit","_uniform","_headgear","_vest","_bag","_classbag","_itemsunit","_weaponsunit","_equipmentarray"];
+_unit = _this;
+_maguniformunit = [];
+_magbackunit = [];
+_magvestunit = [];
+
+
+_uniform = uniform _unit;
+If (_uniform != "") then {_maguniformunit = getMagazineCargo uniformContainer _unit;};
+
+_headgear = headgear _unit;
+
+_vest = vest _unit;
+If (_vest != "") then {_magvestunit = getMagazineCargo vestContainer _unit;};
+
+_bag = unitBackpack _unit;
+_classbag = typeOf _bag;
+If (_classbag != "") then {_magbackunit = getMagazineCargo backpackContainer _unit;};
+
+
+_itemsunit = items _unit;
+_assigneditems = assignedItems _unit;
+_primaryweapon = [];
+_secondaryweapon = [];
+_handgunweapon = [];
+If (primaryweapon _unit != "") then
+{
+ _primaryweapon pushback (primaryweapon _unit);
+ _primaryweapon pushback (primaryWeaponItems _unit);
+ _primaryweapon pushback ((getArray (configFile >> "CfgWeapons" >> (primaryweapon _unit) >> "magazines")) select 0);
+};
+
+If (secondaryweapon _unit != "") then
+{
+ _secondaryweapon pushback (secondaryweapon _unit);
+ _secondaryweapon pushback (secondaryWeaponItems _unit);
+ _secondaryweapon pushback ((getArray (configFile >> "CfgWeapons" >> (secondaryweapon _unit) >> "magazines")) select 0);
+};
+
+If (handgunWeapon _unit != "") then
+{
+ _handgunweapon pushback (handgunWeapon _unit);
+ _handgunweapon pushback (handgunItems _unit);
+ _handgunweapon pushback ((getArray (configFile >> "CfgWeapons" >> (handgunWeapon _unit) >> "magazines")) select 0);
+};
+
+_weaponsunit = [_primaryweapon,_secondaryweapon,_handgunweapon];
+
+_allmag = [] + [_maguniformunit] + [_magvestunit] + [_magbackunit];
+_equipmentarray = [_uniform,_headgear,_vest,_classbag,_itemsunit,_assigneditems,_allmag,_weaponsunit];
+_equipmentarray
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_movetoDriver.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_movetoDriver.sqf
new file mode 100644
index 0000000..e895e9a
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_movetoDriver.sqf
@@ -0,0 +1,32 @@
+/****************************************************************
+File: UPSMON_movetoDriver.sqf
+Author: MONSADA
+
+Description:
+ Función que mueve al soldado a la posición de conductor
+Parameter(s):
+ <--- unit
+ <--- Vehicle to mount
+Returns:
+
+****************************************************************/
+private["_vehicle","_npc"];
+
+_npc = _this ;
+_vehicle = vehicle _npc;
+
+//Si está muerto
+if (vehicle _npc == _npc || !alive _npc || !canmove _npc || !(_npc iskindof "Man")) exitwith{};
+
+if (isnull(driver _vehicle) || !alive(driver _vehicle) || !canmove(driver _vehicle)) then
+{
+ //if (UPSMON_Debug>0) then {player sidechat format["%1: Moving to driver of %2 ",_npc,typeof _vehicle]};
+ _npc action ["getOut", _vehicle];
+ doGetOut _npc;
+ WaitUntil {vehicle _npc==_npc || !alive _npc || !canmove _npc};
+ //Si está muerto
+ if (!alive _npc || !canmove _npc) exitwith{};
+ unassignVehicle _npc;
+ _npc assignasdriver _vehicle;
+ _npc moveindriver _vehicle;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_movetogunner.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_movetogunner.sqf
new file mode 100644
index 0000000..bc3e89b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_movetogunner.sqf
@@ -0,0 +1,33 @@
+/****************************************************************
+File: UPSMON_movetogunner.sqf
+Author: MONSADA
+
+Description:
+ Función que mueve al soldado a la posición de conductor
+Parameter(s):
+ <--- unit
+ <--- Vehicle to mount
+Returns:
+
+****************************************************************/
+private["_vehicle","_npc"];
+
+_npc = _this ;
+_vehicle = vehicle _npc;
+
+sleep 0.05;
+//Si está muerto
+if (vehicle _npc == _npc || !alive _npc || !canmove _npc || !(_npc iskindof "Man")) exitwith{};
+
+if (isnull(gunner _vehicle) || !alive(gunner _vehicle) || !canmove(gunner _vehicle)) then
+{
+ if (UPSMON_Debug>0) then {player sidechat format["%1: Moving to gunner of %2 ",_npc,typeof _vehicle]};
+ _npc action ["getOut", _vehicle];
+ doGetOut _npc;
+ WaitUntil {vehicle _npc==_npc || !alive _npc || !canmove _npc};
+ //Si está muerto
+ if (!alive _npc || !canmove _npc) exitwith{};
+ unassignVehicle _npc;
+ _npc assignasgunner _vehicle;
+ _npc moveingunner _vehicle;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_surrended.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_surrended.sqf
new file mode 100644
index 0000000..bfbd7b5
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_surrended.sqf
@@ -0,0 +1,23 @@
+/****************************************************************
+File: UPSMON_surrended.sqf
+Author: MONSADA
+
+Description:
+ Function to surrender AI soldier
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private ["_grp"];
+
+_grp = _this select 0;
+
+UPSMON_NPCs = UPSMON_NPCs - [_grp];
+
+{
+ If (alive _x) then
+ {
+ [_x] spawn UPSMON_DoSurrender;
+ };
+} foreach units _grp;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_throw_grenade.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_throw_grenade.sqf
new file mode 100644
index 0000000..cb21d4f
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_throw_grenade.sqf
@@ -0,0 +1,41 @@
+/****************************************************************
+File: UPSMON_throw_grenade.sqf
+Author: MONSADA
+
+Description:
+ Throw a grenade
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_target","_npc","_dir","_time"];
+
+_npc = _this select 0;
+_target = _this select 1;
+
+sleep random 1.5;
+if (!alive _npc || (vehicle _npc) != _npc || !canmove _npc) exitwith{};
+
+_npc forcespeed 0;
+_npc disableAI "MOVE";
+_npc disableAI "TARGET";
+_npc disableAI "AUTOTARGET";
+
+[_npc,_target] call UPSMON_dowatch;
+sleep 0.7;
+
+_dir = [getposATL _npc,_target] call BIS_fnc_DirTo;
+_npc setDir _dir;
+
+_npc selectWeapon "throw";
+sleep .1;
+_npc forceWeaponFire ["SmokeShellMuzzle","SmokeShellMuzzle"];
+_time = time + 20;
+(group _npc) setvariable ["UPSMON_SmokeTime",_time];
+sleep 1;
+_npc forcespeed -1;
+_npc enableAI "MOVE";
+_npc enableAI "TARGET";
+_npc enableAI "AUTOTARGET";
+_npc dowatch ObjNull;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/fnc/UPSMON_throw_stone.sqf b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_throw_stone.sqf
new file mode 100644
index 0000000..2e749e7
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/fnc/UPSMON_throw_stone.sqf
@@ -0,0 +1,31 @@
+/****************************************************************
+File: UPSMON_throw_grenade.sqf
+Author: MONSADA
+
+Description:
+ Throw a grenade
+Parameter(s):
+
+Returns:
+
+****************************************************************/
+private["_target","_npc","_time"];
+
+_npc = _this select 0;
+_target = _this select 1;
+
+if (!alive _npc || (vehicle _npc) != _npc || !canmove _npc) exitwith{};
+[_npc,_target] call UPSMON_dowatch;
+sleep 0.5;
+
+hint "THROW";
+_npc switchmove "AwopPercMstpSgthWnonDnon_end";
+_npc addmagazine "HandGrenade_Stone";
+_npc selectWeapon "throw";
+sleep .1;
+_npc forceWeaponFire ["HandGrenade_Stone","HandGrenade_Stone"];
+_time = time + 5;
+_npc setvariable ["UPSMON_ThrowStone",_time];
+sleep 1;
+_npc switchmove "";
+_npc dowatch ObjNull;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/unit/init.sqf b/scripts/UPSMON/COMMON/unit/init.sqf
new file mode 100644
index 0000000..b381e60
--- /dev/null
+++ b/scripts/UPSMON/COMMON/unit/init.sqf
@@ -0,0 +1,33 @@
+
+UPSMON_Getmemberstype = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_Getmemberstype.sqf";
+UPSMON_getequipment = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_getequipment.sqf";
+UPSMON_addequipment = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_addequipment.sqf";
+
+UPSMON_deadbodies = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_deadbodies.sqf";
+
+UPSMON_SetMinefield = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_SetMinefield.sqf";
+UPSMON_PutMine = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_PutMine.sqf";
+UPSMON_PutSatchel = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_PutSatchel.sqf";
+UPSMON_SetSatchel = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_SetSatchel.sqf";
+
+UPSMON_DeployStatic = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_DeployStatic.sqf";
+UPSMON_Unpackbag = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_Unpackbag.sqf";
+UPSMON_Packbag = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_Packbag.sqf";
+
+UPSMON_Surrended = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_Surrended.sqf";
+UPSMON_DoSurrender = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_DoSurrender.sqf";
+
+UPSMON_dowatch = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_dowatch.sqf";
+
+UPSMON_CreateSmokeCover = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_CreateSmokeCover.sqf";
+UPSMON_throw_grenade = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_throw_grenade.sqf";
+UPSMON_DoSmokeScreen = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_DoSmokeScreen.sqf";
+UPSMON_throw_stone = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_throw_stone.sqf";
+
+UPSMON_FireFlare = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_FireFlare.sqf";
+UPSMON_DoFireFlare = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_DoFireFlare.sqf";
+UPSMON_FireGun = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_FireGun.sqf";
+UPSMON_firing = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_firing.sqf";
+
+UPSMON_Rearm = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_Rearm.sqf";
+UPSMON_DoRearm = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\unit\fnc\UPSMON_DoRearm.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/Init.sqf b/scripts/UPSMON/COMMON/vehicles/Init.sqf
new file mode 100644
index 0000000..0d3f536
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/Init.sqf
@@ -0,0 +1,17 @@
+UPSMON_FN_unitsInCargo = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_FN_unitsInCargo.sqf";
+UPSMON_Fn_Gunnercrew = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_Fn_Gunnercrew.sqf";
+UPSMON_GetIn_NearestVehicles = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_GetIn_NearestVehicles.sqf";
+UPSMON_GetNearestVehicles = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_GetNearestVehicles.sqf";
+UPSMON_selectvehicles = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_selectvehicles.sqf";
+UPSMON_GetNeareststatics = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_GetNeareststatics.sqf";
+
+UPSMON_UnitsGetIn = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_UnitsGetIn.sqf";
+UPSMON_UnitsGetout = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_UnitsGetout.sqf";
+UPSMON_EjectUnits = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_EjectUnits.sqf";
+UPSMON_assignasrole = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_assignasrole.sqf";
+UPSMON_Allowgetin = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_Allowgetin.sqf";
+UPSMON_avoidDissembark = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_avoidDissembark.sqf";
+UPSMON_fnc_commonTurrets = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_fnc_commonTurrets.sqf";
+UPSMON_Emptyturret = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_Emptyturret.sqf";
+
+UPSMON_Checkvehiclesstatus = compile preProcessFileLineNumbers "Scripts\UPSMON\COMMON\vehicles\fnc\UPSMON_Checkvehiclesstatus.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Allowgetin.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Allowgetin.sqf
new file mode 100644
index 0000000..5cc11af
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Allowgetin.sqf
@@ -0,0 +1,12 @@
+/****************************************************************
+File: UPSMON_Allowgetin.sqf
+Author: MONSADA
+
+Description:
+ Allow unit to move in vehicle
+Parameter(s):
+ <--- unit
+Returns:
+ Nothing
+****************************************************************/
+[_this] allowGetIn true;
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Checkvehiclesstatus.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Checkvehiclesstatus.sqf
new file mode 100644
index 0000000..6036db6
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Checkvehiclesstatus.sqf
@@ -0,0 +1,64 @@
+/****************************************************************
+File: UPSMON_checkleaveVehicle.sqf
+Author: MONSADA
+
+Description:
+ If every on is outside, make sure driver can move
+Parameter(s):
+ <--- leader
+ <--- vehicle
+ <--- driver
+Returns:
+ Nothing
+****************************************************************/
+private["_assignedvehicle","_vehiclesneedsupply","_fuel","_damage","_magazinescount","_weapon","_basepos","_air","_mags"];
+_assignedvehicle = _this select 0;
+
+_vehiclesneedsupply = [];
+_supplyneeded = [];
+
+{
+ If (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (!(vehicle _x in _vehiclesneedsupply)) then
+ {
+ _fuel = fuel (vehicle _x);
+ _damage = damage (vehicle _x);
+ _magazinescount = 100;
+
+ if (!IsNull (Gunner (vehicle _x))) then
+ {
+ _magazinescount = 0;
+ _mags = magazinesAmmo (vehicle _x);
+ {
+ _magazinescount = _magazinescount + (_x select 1);
+ } foreach _mags;
+ _supplyneeded pushback "munition";
+ };
+ _enoughfuel = true;
+ _fuelneeded = 0.3;
+
+ If ((vehicle _x) iskindof "AIR") then
+ {
+ _dist = (getposATL _x) vectordistance ((_grp getvariable ["UPSMON_Origin",[]]) select 0);
+ _fuelneeded = ((0.000537*_dist) / 100) + 0.0005;
+ _supplyneeded pushback "fuel";
+ };
+
+ If (_damage > 0.5) then {_supplyneeded pushback "repair";};
+ If (_fuel <= _fuelneeded) then {_supplyneeded pushback "fuel";};
+
+ If (_damage > 0.5 || (_fuel <= _fuelneeded && !(vehicle _x iskindof "STATICWEAPON")) || _magazinescount <= 2) then
+ {
+ _vehiclesneedsupply pushback _x;
+ };
+ };
+ };
+ };
+} foreach _assignedvehicle;
+
+_grp setvariable ["UPSMON_Supplyneeded",_supplyneeded];
+
+_vehiclesneedsupply;
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_EjectUnits.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_EjectUnits.sqf
new file mode 100644
index 0000000..b2b8641
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_EjectUnits.sqf
@@ -0,0 +1,28 @@
+/****************************************************************
+File: UPSMON_EjectUnits.sqf
+Author: Azroul13
+
+Description:
+ Make unit leave the vehicle
+Parameter(s):
+ <--- vehicle
+ <--- Units
+Returns:
+
+****************************************************************/
+private["_transport","_units","_chute"];
+
+_transport = _this select 0;
+_units = _this select 1;
+
+{
+ _x disableCollisionWith _transport;
+ unassignVehicle _x;
+ _x action ["EJECT", _transport];
+ [_x] allowGetIn false;
+ sleep 0.25;
+ _chute = createVehicle ["NonSteerable_Parachute_F", (getPosATL _x), [], 0, "NONE"];
+ _chute setPos (getPosATL _x);
+ _x moveinDriver _chute;
+ sleep 0.1;
+} forEach _units;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Emptyturret.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Emptyturret.sqf
new file mode 100644
index 0000000..d5085d2
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Emptyturret.sqf
@@ -0,0 +1,23 @@
+/****************************************************************
+File: UPSMON_Emptyturret.sqf
+Author: Azroul13
+
+Description:
+ Get number of empty turret
+Parameter(s):
+ <--- vehicle
+Returns:
+ number
+****************************************************************/
+
+private ["_turretpath","_number"];
+
+_turretpath = _this call UPSMON_fnc_commonTurrets;
+
+_number = 0;
+
+{
+ If (IsNull (_this turretUnit _x)) then {_number = _number + 1;};
+} foreach _turretpath;
+
+_number
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_FN_unitsInCargo.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_FN_unitsInCargo.sqf
new file mode 100644
index 0000000..bc2d953
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_FN_unitsInCargo.sqf
@@ -0,0 +1,23 @@
+/****************************************************************
+File: UPSMON_FN_unitsInCargo.sqf
+Author: Rafalsky
+
+Description:
+ Return all units in cargo
+Parameter(s):
+ <--- vehicle
+Returns:
+ array of units in cargo of the vehicle (in vehicle and assigned as cargo)
+****************************************************************/
+private ["_vehicle","_x","_unitsInCargo"];
+
+_vehicle = _this select 0;
+_unitsInCargo = [];
+{
+ if( (assignedVehicleRole _x) select 0 == "Cargo") then
+ {
+ _unitsInCargo pushback _x;
+ };
+} forEach crew _vehicle;
+
+_unitsInCargo
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Fn_Gunnercrew.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Fn_Gunnercrew.sqf
new file mode 100644
index 0000000..a3e71c2
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Fn_Gunnercrew.sqf
@@ -0,0 +1,23 @@
+/****************************************************************
+File: UPSMON_Fn_Gunnercrew.sqf
+Author: Rafalsky
+
+Description:
+ Return all units in turret
+Parameter(s):
+ <--- vehicle
+Returns:
+ array of units in turret of the vehicle (in vehicle and assigned as turret)
+****************************************************************/
+private ["_vehicle","_x","_unitsInturret"];
+
+_vehicle = _this select 0;
+_unitsInturret = [];
+{
+ if( (assignedVehicleRole _x) select 0 == "TURRET") then
+ {
+ _unitsInturret pushback _x;
+ };
+} forEach crew _vehicle;
+
+_unitsInturret
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetIn_NearestVehicles.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetIn_NearestVehicles.sqf
new file mode 100644
index 0000000..be0d9b0
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetIn_NearestVehicles.sqf
@@ -0,0 +1,49 @@
+/****************************************************************
+File: UPSMON_GetIn_NearestVehicles.sqf
+Author: Azroul13
+
+Description:
+ Función que busca vehiculos cercanos y hace entrar a las unidades del lider
+Parameter(s):
+ <--- Leader
+ <--- Types of vehicle the group must search
+ <--- Radius of research
+ <--- Do the unit needs to be spawn in the vehicle
+ <--- Is there a area the unit must search in
+Returns:
+ Array of units moving to vehicle
+****************************************************************/
+private["_npc","_types","_area","_spawn","_marker","_vehicles","_unitsmoveIn","_unitsIn","_vehicletypearray"];
+
+_npc = _this select 0;
+_types = _this select 1;
+_area = _this select 2;
+_spawn = false;
+_marker = "";
+If (count _this > 3) then {_spawn = _this select 3};
+If (count _this > 4) then {_marker = _this select 4};
+
+_grpid = (group _npc) getvariable ["UPSMON_grpid",0];
+
+
+_validunits = [units _npc] call UPSMON_Getunits;
+_unitsIn = _validunits;
+if ( (count _validunits) > 0) then
+{
+ _vehicles = [];
+ if ("static" in _types) then
+ {
+ _vehicles = [_npc,_area,_marker] call UPSMON_GetNeareststatics;
+ If (_npc in _validunits) then
+ {
+ _validunits = _validunits - [_npc];
+ _validunits pushback _npc;
+ };
+ };
+ If !("static" in _types) then {_vehicles = [_npc,_types,_area,_marker] call UPSMON_GetNearestvehicles;};
+
+ _unitsIn = [_validunits,_vehicles,_spawn] call UPSMON_selectvehicles;
+};
+sleep 0.01;
+
+_unitsIn;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetNearestStatics.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetNearestStatics.sqf
new file mode 100644
index 0000000..6f54781
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetNearestStatics.sqf
@@ -0,0 +1,63 @@
+/****************************************************************
+File: UPSMON_GetNearestCombat.sqf
+Author: Azroul13
+
+Description:
+ Función que busca vehiculos cercanos y hace entrar a las unidades del lider
+Parameter(s):
+ <--- leader
+ <--- Vehicle types
+ <--- Searching radius
+Returns:
+ Array vehicles [[vehicles,emptypositions]]
+****************************************************************/
+private["_npc","_distance","_marker","_OCercanos","_emptypositions","_vehicles","_isuav","_inzone"];
+
+_npc = _this select 0;
+_distance = _this select 1;
+_marker = _this select 2;
+
+_OCercanos = [];
+_emptypositions = 0;
+_vehicles = [];
+_Cargocount = 0;
+_Gunnercount = 0;
+_Commandercount = 0;
+_Drivercount = 0;
+
+//Buscamos objetos cercanos
+_OCercanos = _npc nearentities [["StaticWeapon"], _distance];
+
+{
+ _isuav = getnumber (configFile >> "cfgVehicles" >> (typeOf (_x)) >> "isUav");
+ if (_isuav != 1) then
+ {
+ _inzone = true;
+ _emptypositions = _x call UPSMON_Emptyturret;
+
+ If (_marker != "") then
+ {
+ _inzone = [getposATL _x,_marker] call UPSMON_pos_fnc_isBlacklisted;
+ };
+
+ //ToDo check impact (locked _x != 2)
+ if (locked _x == 1 || locked _x == 0 || locked _x == 3) then
+ {
+ If (damage _x == 0) then
+ {
+ If (canMove _x) then
+ {
+ If (_emptypositions > 0) then
+ {
+ If (_inzone) then
+ {
+ _vehicles pushback [_x,_emptypositions];
+ };
+ };
+ }
+ };
+ };
+ };
+}foreach _OCercanos;
+
+_vehicles;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetNearestVehicles.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetNearestVehicles.sqf
new file mode 100644
index 0000000..60ae923
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_GetNearestVehicles.sqf
@@ -0,0 +1,83 @@
+/****************************************************************
+File: UPSMON_GetNearestCombat.sqf
+Author: Azroul13
+
+Description:
+ Función que busca vehiculos cercanos y hace entrar a las unidades del lider
+Parameter(s):
+ <--- leader
+ <--- Vehicle types
+ <--- Searching radius
+Returns:
+ Array vehicles [[vehicles,emptypositions]]
+****************************************************************/
+private["_npc","_vehtypes","_distance","_types","_marker","_OCercanos","_emptypositions","_vehicles","_Cargocount","_Gunnercount","_Commandercount","_Drivercount","_isuav","_inzone"];
+
+_npc = _this select 0;
+_types = _this select 1;
+_distance = _this select 2;
+_marker = _this select 3;
+
+_OCercanos = [];
+_emptypositions = 0;
+_vehicles = [];
+_Cargocount = 0;
+_Gunnercount = 0;
+_Commandercount = 0;
+_Drivercount = 0;
+
+//Buscamos objetos cercanos
+_OCercanos = _npc nearentities [["CAR","TANK","SHIP","HELICOPTER"], _distance];
+
+{
+ _isuav = getnumber (configFile >> "cfgVehicles" >> (typeOf (_x)) >> "isUav");
+ if (_isuav != 1) then
+ {
+ _points = 0;
+ _inzone = true;
+ _Cargocount = (_x) emptyPositions "Cargo";
+
+ _Gunnercount = _x call UPSMON_Emptyturret;
+ _Drivercount = (_x) emptyPositions "Driver";
+ _Commandercount = (_x) emptyPositions "Commander";
+
+ _emptypositions = _Cargocount + _Gunnercount + _Commandercount + _Drivercount;
+
+ _points = _points + _emptypositions;
+
+ If (_marker != "") then
+ {
+ _inzone = [getposATL _x,_marker] call UPSMON_pos_fnc_isBlacklisted;
+ };
+
+ If ("transport" in _types && _Cargocount == 0) then {_points = _points + 100};
+ If ("gun" in _types && _Gunnercount == 0) then {_points = _points + 50};
+
+ //ToDo check impact (locked _x != 2)
+ If (getposATL _x select 2 <= 0.5) then
+ {
+ if (locked _x == 1 || locked _x == 0 || locked _x == 3) then
+ {
+ If (damage _x == 0) then
+ {
+ If (canMove _x) then
+ {
+ If (_drivercount > 0) then
+ {
+ If (_x getvariable ["UPSMON_GrpId",0] == 0) then
+ {
+ If (_inzone) then
+ {
+ _vehicles pushback [_x,_emptypositions,_points];
+ };
+ };
+ };
+ }
+ };
+ };
+ };
+ };
+}foreach _OCercanos;
+
+_vehicles = [_vehicles, [], {_x select 2}, "DESCEND"] call BIS_fnc_sortBy;
+_vehicles;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Gunnercontrol.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Gunnercontrol.sqf
new file mode 100644
index 0000000..61c3045
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_Gunnercontrol.sqf
@@ -0,0 +1,66 @@
+/****************************************************************
+File: UPSMON_Gunnercontrol.sqf
+Author: MONSADA
+
+Description:
+ Function that checks is gunner is alive, if not moves a cargo
+Parameter(s):
+ <--- vehicle
+Returns:
+ Nothing
+****************************************************************/
+private["_vehicle","_gunnercontrol","_hasgunner","_crew","_crew2"];
+_vehicle = _this select 0;
+
+_gunnercontrol = false;
+_hasgunner = (_vehicle) emptyPositions "Gunner" > 0 || !isnull gunner _vehicle;
+_crew = [];
+_crew2 = []; //Without driver and gunner
+
+sleep 0.05;
+if ( !alive _vehicle || !canmove _vehicle ) exitwith{};
+
+//Checks stuckcontrol not active
+_gunnercontrol = _vehicle getVariable "UPSMON_gunnercontrol";
+if (isnil ("_gunnercontrol")) then {_gunnercontrol=false};
+if (_gunnercontrol) exitwith {};
+
+_vehicle setVariable ["UPSMON_gunnercontrol", true, false];
+
+_crew = crew _vehicle;
+//gunner and driver loop control
+while { alive _vehicle && canmove _vehicle && count _crew > 0} do
+{
+ _crew = crew _vehicle;
+ {
+ if (!canmove _x || !alive _x) then {_crew = _crew -[_x];};
+ }foreach _crew;
+
+ //Driver control
+ if ((isnull (driver _vehicle) || !alive (driver _vehicle) || !canmove (driver _vehicle)) && count _crew > 0) then
+ {
+ _crew2 = _crew - [gunner _vehicle];
+ if (count _crew2 > 0) then
+ {
+ (_crew2 select (count _crew2 - 1)) spawn UPSMON_movetodriver;
+ };
+ };
+
+ //Gunner control
+ if ( _hasgunner && (isnull (gunner _vehicle) || !alive (gunner _vehicle) || !canmove (gunner _vehicle)) && count _crew > 1) then
+ {
+ _crew2 = _crew - [driver _vehicle];
+ if (count _crew2 > 0) then
+ {
+ (_crew2 select (count _crew2 - 1)) spawn UPSMON_movetogunner;
+ }
+ else
+ {
+ (_crew select 0) spawn UPSMON_movetogunner;
+ };
+ };
+ sleep 20;
+ //if (UPSMON_Debug>0 ) then {player globalchat format["%1 crew=%2",typeof _vehicle, count _crew];};
+};
+//if (UPSMON_Debug>0 ) then {player globalchat format["%1 exits from gunner control",typeof _vehicle];};
+_vehicle setVariable ["UPSMON_gunnercontrol", false, false];
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_UnitsGetIn.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_UnitsGetIn.sqf
new file mode 100644
index 0000000..78cb063
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_UnitsGetIn.sqf
@@ -0,0 +1,128 @@
+/****************************************************************
+File: UPSMON_UnitsGetIn.sqf
+Author: Azroul13
+
+Description:
+ Funcion que mete la tropa en el vehiculo
+Parameter(s):
+ <--- id of the group
+ <--- array of units that will embark in the vehicle
+ <--- Do the unit needs to be spawn in the vehicle
+Returns:
+
+****************************************************************/
+private["_grpid","_vehicle","_npc","_driver","_gunner", "_unitsin", "_units" , "_Commandercount","_Drivercount","_Gunnercount","_cargo",
+ "_Cargocount","_emptypositions","_commander","_vehgrpid","_cargo","_gunners"];
+
+_grpid = _this select 0;
+_unitsin = _this select 1;
+_vehicle = _this select 2;
+_spawninveh = false;
+if ((count _this) > 3) then {_spawninveh = _this select 3;};
+
+_units = _unitsin;
+_driver = objnull;
+_gunner = objnull;
+_commander = objnull;
+_Cargocount = 0;
+_Gunnercount = 0;
+_Commandercount = 0;
+_Drivercount = 0;
+_cargo = [];
+
+_Cargocount = (_vehicle) emptyPositions "Cargo";
+_Gunnerturrets = _vehicle call UPSMON_fnc_commonTurrets;
+_Commandercount = (_vehicle) emptyPositions "Commander";
+_Drivercount = (_vehicle) emptyPositions "Driver";
+
+//Obtenemos el identificador del vehiculo
+_vehgrpid = _vehicle getvariable ["UPSMON_grpid",0];
+_cargo = _vehicle getvariable ["UPSMON_cargo",[]];
+
+_cargo = _cargo - _unitsin; //Para evitar duplicados
+_cargo = _cargo + _unitsin; //Añadimos a la carga
+_vehicle setVariable ["UPSMON_cargo", _cargo, false];
+
+//Hablitamos a la IA para entrar en el vehiculo
+//Tell AI to get in vehicle
+{
+ Dostop _x;
+
+ if ("StaticWeapon" countType [vehicle (_x)]>0) then
+ {
+ _x spawn UPSMON_doGetOut;
+ };
+
+ unassignVehicle _x;
+ _x spawn UPSMON_Allowgetin;
+} foreach _units;
+
+//Assigned to the leader as commander or cargo
+{
+ if ( _vehgrpid == _grpid && _x == leader _x && _Commandercount > 0 ) exitwith
+ {
+ _Commandercount = 0;
+ _commander = _x;
+ [_commander,"COMMANDER",_vehicle,0] spawn UPSMON_assignasrole;
+ _units = _units - [_x];
+ };
+
+ if ( _x == leader _x && _Cargocount > 0 ) exitwith
+ {
+ [_x,"CARGO",_vehicle,0] spawn UPSMON_assignasrole;
+ _units = _units - [_x];
+ _Cargocount = _Cargocount - 1;
+ };
+} foreach _units;
+//if (UPSMON_Debug>0 ) then {player sidechat format["%1: _vehgrpid %2 ,_Gunnercount %3, %4",_grpid,_vehgrpid,_Gunnercount,count _units]};
+
+//Si el vehiculo pertenece al grupo asignamos posiciones de piloto, sinó solo de carga
+//Make sure some AI will get in as driver (and if available as gunner(s))
+
+if ( _vehgrpid == _grpid ) then
+{
+ //Asignamos el conductor
+ if (_Drivercount > 0) then
+ {
+ If (count (_units) > 0) then
+ {
+ _driver = _units select (count _units - 1);
+ [_driver,"DRIVER",_vehicle,0] spawn UPSMON_assignasrole;
+ _units = _units - [_driver];
+ };
+ };
+
+ //Asignamos el artillero
+ if ( count _Gunnerturrets > 0) then
+ {
+ If (count (_units) > 0) then
+ {
+ _gunners = [];
+ _i = - 1;
+ {
+ _i = _i + 1;
+ If (_i > (count _Gunnerturrets - 1)) exitwith {_gunners};
+ _gunners pushback _x;
+ _turret = _Gunnerturrets select _i;
+ [_x,"GUNNER",_vehicle,0,_turret,_spawninveh] spawn UPSMON_assignasrole;
+ } foreach _units;
+ _units = _units - _gunners;
+ };
+ };
+};
+
+//if (UPSMON_Debug>0 ) then {player sidechat format["%1: _vehgrpid=%2 units=%4",_grpid,_vehgrpid,_cargocount,count _units]};
+//Movemos el resto como carga
+if ( _Cargocount > 0) then
+{
+ If (count (_units) > 0) then
+ {
+ {
+ [_x,"CARGO",_vehicle,0] spawn UPSMON_assignasrole;
+ } forEach _units;
+ };
+};
+
+{
+ [_x] spawn UPSMON_avoidDissembark;
+} forEach _unitsin - [_driver] - [_gunner] -[_commander];
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_UnitsGetOut.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_UnitsGetOut.sqf
new file mode 100644
index 0000000..bcb2e4b
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_UnitsGetOut.sqf
@@ -0,0 +1,27 @@
+/****************************************************************
+File: UPSMON_UnitsGetout.sqf
+Author: Azroul13
+
+Description:
+ Make unit leave the vehicle
+Parameter(s):
+ <--- vehicle
+ <--- Units
+Returns:
+
+****************************************************************/
+private["_transport","_units"];
+
+_transport = _this select 0;
+_units = _this select 1;
+
+{
+ unassignVehicle _x;
+ _x action ["GETOUT", _transport];
+ doGetOut _x;
+ [_x] allowGetIn false;
+ _x leaveVehicle _transport;
+ _Pos = [getposATL _x,[5,20],[0,360]] call UPSMON_pos;
+ _x domove _Pos;
+ sleep 0.1;
+} forEach _units;
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_assignasgunner.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_assignasgunner.sqf
new file mode 100644
index 0000000..0e28069
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_assignasgunner.sqf
@@ -0,0 +1,34 @@
+/****************************************************************
+File: UPSMON_assignasgunner.sqf
+Author: MONSADA
+
+Description:
+ Move unit to the gunner position of a vehicle
+Parameter(s):
+ <--- unit
+ <--- vehicle
+ <--- Do they move to the position or spawn ?
+Returns:
+ Nothing
+****************************************************************/
+private["_vehicle","_gunner","_dist","_spawninveh"];
+_gunner = _this select 0;
+_vehicle = _this select 1;
+_spawninveh = false;
+if (count _this > 2) then {_spawninveh = _this select 2;};
+
+_dist=0;
+
+[_gunner] orderGetIn true;
+_gunner forcespeed 40;
+_gunner assignasgunner _vehicle;
+if (_spawninveh) then {_gunner moveingunner _vehicle;};
+
+waituntil { _gunner != vehicle _gunner || !alive _gunner || !canmove _gunner ||!alive _vehicle || !canfire _vehicle};
+
+if ( alive _gunner && alive _vehicle && canmove _gunner && canfire _vehicle) then {
+_dist = _gunner distanceSqr _vehicle;
+if (_dist < 3) then
+{
+ _gunner moveInTurret [_vehicle, [0]] ;
+};
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_assignasrole.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_assignasrole.sqf
new file mode 100644
index 0000000..93c3450
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_assignasrole.sqf
@@ -0,0 +1,47 @@
+/****************************************************************
+File: UPSMON_assignasrole.sqf
+Author: MONSADA
+
+Description:
+ Move unit to the position of a vehicle
+Parameter(s):
+ <--- unit
+ <--- vehicle
+ <--- time before moving
+Returns:
+ Nothing
+****************************************************************/
+private["_vehicle","_unit","_role","_wait","_spawninveh","_turretpath"];
+_unit = _this select 0;
+_role = _this select 1;
+_vehicle = _this select 2;
+_wait = _this select 3;
+_turretpath = 0;
+if (count _this > 4) then {_turretpath = _this select 4;};
+_spawninveh = true;
+if (count _this > 5) then {_spawninveh = _this select 5;};
+Dostop _unit;
+sleep _wait;
+
+unassignVehicle _unit;
+switch (_role) do
+{
+ case "DRIVER": {_unit assignasdriver _vehicle;};
+ case "COMMANDER": {_unit assignascommander _vehicle;};
+ case "GUNNER":
+ {
+ if (_spawninveh) then
+ {
+ _unit moveInTurret [_vehicle,_turretpath];
+ }
+ else
+ {
+ _unit assignAsTurret [_vehicle,_turretpath];
+ };
+ };
+ case "CARGO": {_unit assignascargo _vehicle;};
+};
+[_unit] orderGetIn true;
+_unit forcespeed 40;
+
+//if ( UPSMON_Debug>0) then {player sidechat format["%1: assigning to driver of %2 ",_driver, typeof _vehicle]};
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_avoidDissembark.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_avoidDissembark.sqf
new file mode 100644
index 0000000..c5781b6
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_avoidDissembark.sqf
@@ -0,0 +1,31 @@
+/****************************************************************
+File: UPSMON_avoidDissembark.sqf
+Author: MONSADA
+
+Description:
+ If every on is outside, make sure driver can move
+Parameter(s):
+ <--- leader
+Returns:
+ Nothing
+****************************************************************/
+private["_npc","_vehicle","_timeout"];
+
+_npc = _this select 0;
+_vehicle = vehicle _npc;
+
+_timeout = 120;
+_timeout = time + _timeout;
+
+while {_npc == vehicle _npc && alive _npc && canmove _npc && time < _timeout} do {
+ sleep 1;
+};
+
+if (!alive _npc || !canmove _npc || time >= _timeout || driver vehicle _npc == _npc) exitwith{};
+_npc stop true;
+
+while {_npc != vehicle _npc && alive _npc && canmove _npc} do {sleep 1;};
+_npc stop false;
+sleep 0.5;
+
+if (!alive _npc || !canmove _npc) exitwith{};
\ No newline at end of file
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_checkleaveVehicle.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_checkleaveVehicle.sqf
new file mode 100644
index 0000000..4c381f0
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_checkleaveVehicle.sqf
@@ -0,0 +1,35 @@
+/****************************************************************
+File: UPSMON_checkleaveVehicle.sqf
+Author: MONSADA
+
+Description:
+ If every on is outside, make sure driver can move
+Parameter(s):
+ <--- leader
+ <--- vehicle
+ <--- driver
+Returns:
+ Nothing
+****************************************************************/
+private["_npc","_vehicle","_driver","_in"];
+_npc = _this select 0;
+_vehicle = _this select 1;
+_driver = _this select 2;
+_in = false;
+
+//Take time to go all units
+sleep 5;
+{
+ if (_x != vehicle _x) then {_in = true};
+}foreach units _npc;
+
+
+// if no one is inside
+if (!_in) then {
+ _driver enableAI "MOVE";
+ sleep 1;
+ _driver stop false;
+ sleep 1;
+ _driver leaveVehicle _vehicle;
+ sleep 1;
+ };
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_fnc_commonTurrets.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_fnc_commonTurrets.sqf
new file mode 100644
index 0000000..86fe003
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_fnc_commonTurrets.sqf
@@ -0,0 +1,29 @@
+/****************************************************************
+File: UPSMON_fnc_commonTurrets.sqf
+Author: Killzonekid
+
+Description:
+ Get all the turretpath of the vehicle
+Parameter(s):
+ <--- vehicle
+Returns:
+ array of turretpath
+****************************************************************/
+
+private ["_arr","_trts"];
+
+_arr = [];
+_trts = configFile / "CfgVehicles" / typeOf _this / "Turrets";
+for "_i" from 0 to count _trts - 1 do
+{
+ _arr pushback [_i];
+
+ for "_j" from 0 to count (
+ _trts / configName (_trts select _i) / "Turrets"
+ ) - 1 do
+ {
+ _arr pushback [_i, _j];
+ };
+};
+
+_arr
diff --git a/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_selectvehicles.sqf b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_selectvehicles.sqf
new file mode 100644
index 0000000..e98dee4
--- /dev/null
+++ b/scripts/UPSMON/COMMON/vehicles/fnc/UPSMON_selectvehicles.sqf
@@ -0,0 +1,57 @@
+/****************************************************************
+File: UPSMON_selectvehicles.sqf
+Author: Azroul13
+
+Description:
+ Función que busca vehiculos cercanos y hace entrar a las unidades del lider
+Parameter(s):
+ <--- Units
+ <--- Array of vehicles
+ <--- Do the unit needs to be spawn in the vehicle
+Returns:
+ Array of units moving to vehicle
+****************************************************************/
+private["_units","_vehicles","_spawninveh","_grpid","_vehicle","_emptypositions","_i","_vehgrpid","_cargo"];
+
+_units = _this select 0;
+_vehicles = _this select 1;
+_spawninveh = false;
+if ((count _this) > 2) then {_spawninveh = _this select 2;};
+
+_grpid = (group (_units select 0)) getvariable ["UPSMON_Grpid",0];
+_unitsIn = [];
+
+If (count _vehicles > 0) then
+{
+ {
+ if ((count _units) == 0 ) exitwith {_units};
+ _vehicle = _x select 0;
+ _emptypositions = _x select 1;
+ _i = 0;
+ _unitsmoveIn = [];
+ _cargo = _vehicle getVariable ["UPSMON_cargo",[]];
+
+ _vehicle setVariable ["UPSMON_grpid", _grpid, false];
+
+ _emptypositions = _emptypositions - (count crew _vehicle);
+
+ while {_i < _emptypositions && _i < count _units} do
+ {
+ _unit = _units select _i;
+ _unitsmoveIn pushback _unit;
+ _unitsIn pushback _unit;
+ _i = _i + 1;
+ };
+
+ _units = _units - _unitsmoveIn;
+
+ If (count _unitsmoveIn > 0) then
+ {
+ [_grpid,_unitsmoveIn,_vehicle,_spawninveh] spawn UPSMON_UnitsGetIn;
+ if (UPSMON_Debug>0 ) then {player sidechat format["%1: Get in %2 %3 units of %4 available",_grpid,typeof _vehicle,count _unitsmoveIn,_emptypositions]};
+ if (UPSMON_Debug>0 ) then {diag_log format["UPSMON %1: Moving %3 units into %2 with %4 positions",_grpid,typeof _vehicle,count _unitsmoveIn,_emptypositions]};
+ };
+ } foreach _vehicles;
+};
+
+_unitsIn
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_findclosestposition.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_findclosestposition.sqf
new file mode 100644
index 0000000..43018b9
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_findclosestposition.sqf
@@ -0,0 +1,19 @@
+// Return the closest position from array to the positionA.
+// In: [positionA,[array of positions]]
+// Out: positionB
+private ["_pA","_ps","_p1","_p2"];
+_pA = _this select 0;
+_ps = _this select 1;
+
+_p1 = _ps select 0;
+
+if (count _ps > 1) then {
+ for "_i" from 1 to (count _ps - 1) do {
+ _p2 = _ps select _i;
+ if ((_p2 distance _pA) < (_p1 distance _pA)) then {
+ _p1 = _p2;
+ };
+ };
+};
+
+_p1
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getmarkercorners.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getmarkercorners.sqf
new file mode 100644
index 0000000..1cac68b
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getmarkercorners.sqf
@@ -0,0 +1,59 @@
+// In: marker
+// Out: array of positions
+private ["_area","_corners"];
+_area = _this;
+_corners = [];
+
+// Center point
+private ["_center","_centerX","_centerY"];
+_center = getMarkerPos _area;
+_centerX = _center select 0;
+_centerY = _center select 1;
+
+// Direction and make sure it's between 0 and 360.
+private ["_dir","_dirCos","_dirSin"];
+_dir = (markerDir _area) * -1;
+_dir = _dir % 360;
+_dirCos = cos _dir;
+_dirSin = sin _dir;
+
+// Size
+private ["_size","_sizeX","_sizeY"];
+_size = getMarkerSize _area;
+_sizeX = _size select 0;
+_sizeY = _size select 1;
+
+
+private ["_cosX","_sinX","_cosY","_sinY","_addX","_addY","_subX","_subY"];
+_cosX = _dirCos * _sizeX;
+_sinX = _dirSin * _sizeX;
+_cosY = _dirCos * _sizeY;
+_sinY = _dirSin * _sizeY;
+
+_addX = _cosX + _sinY;
+_addY = _sinX + _cosY;
+_subX = _cosX - _sinY;
+_subY = _sinX - _cosY;
+
+private ["_posX","_posY"];
+// Bottom Left
+_posX = _centerX - _subX;
+_posY = _centerY - _addY;
+_corners set [0,[_posX,_posY]];
+
+// Top Left
+_posX = _centerX - _addX;
+_posY = _centerY - _subY;
+_corners set [1,[_posX,_posY]];
+
+// Top Right
+_posX = _centerX + _subX;
+_posY = _centerY + _addY;
+_corners set [2,[_posX,_posY]];
+
+// Bottom Right
+_posX = _centerX + _addX;
+_posY = _centerY + _subY;
+_corners set [3,[_posX,_posY]];
+
+_corners
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getmarkershape.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getmarkershape.sqf
new file mode 100644
index 0000000..e397c5e
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getmarkershape.sqf
@@ -0,0 +1,30 @@
+// In: marker
+// Out: string (marker shape)
+
+private ["_size","_x","_y","_ret"];
+_size = markersize _this;
+_x = _size select 0;
+_y = _size select 1;
+
+_ret = "";
+
+switch (tolower(markershape _this)) do {
+ case "rectangle": {
+ if (_x == _y) then {
+ _ret = "SQUARE";
+ } else {
+ _ret = "RECTANGLE";
+ };
+ };
+ case "ellipse": {
+ if (_x == _y) then {
+ _ret = "CIRCLE";
+ } else {
+ _ret = "ELLIPSE";
+ };
+ };
+ case "icon": {
+ _ret = "ICON";
+ };
+};
+_ret
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getpos.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getpos.sqf
new file mode 100644
index 0000000..d5c5fb4
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getpos.sqf
@@ -0,0 +1,13 @@
+// In: [position,distance,direction]
+// Out: position
+private ["_pos","_dst","_dir","_orgX","_orgY","_posX","_posY"];
+_pos = _this select 0;
+_dst = _this select 1;
+_dir = _this select 2;
+
+_orgX = _pos select 0;
+_orgY = _pos select 1;
+_posX = _orgX + (_dst * sin _dir);
+_posY = _orgY + (_dst * cos _dir);
+
+[_posX,_posY,0]
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromcircle.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromcircle.sqf
new file mode 100644
index 0000000..87269f8
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromcircle.sqf
@@ -0,0 +1,26 @@
+// In: marker
+// Out: position
+
+// Center point
+private ["_center","_centerX","_centerY"];
+_center = getMarkerPos _this;
+_centerX = _center select 0;
+_centerY = _center select 1;
+
+// Size
+private ["_size"];
+_size = getMarkerSize _this;
+_size = _size select 0;
+
+// Randomly pick a direction,
+private ["_dir","_posX","_posY","_rand","_pos"];
+_dir = random 360;
+_rand = sqrt random 1;
+_posX = (_size * (cos _dir)) * _rand;
+_posY = (_size * (sin _dir)) * _rand;
+_pos = [_posX,_posY];
+
+_posX = _centerX + (_pos select 0);
+_posY = _centerY + (_pos select 1);
+
+[_posX,_posY,0]
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromellipse.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromellipse.sqf
new file mode 100644
index 0000000..86b74a0
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromellipse.sqf
@@ -0,0 +1,43 @@
+// In: ellipseMarker
+// Out: position
+
+// Center point
+private ["_center","_centerX","_centerY"];
+_center = getMarkerPos _this;
+_centerX = _center select 0;
+_centerY = _center select 1;
+
+// Direction and make sure it's between 0 and 360.
+private ["_dirMrk"];
+_dirMrk = (markerDir _this) * -1;
+_dirMrk = _dirMrk % 360;
+
+// Size
+private ["_size","_sizeX","_sizeY"];
+_size = getMarkerSize _this;
+_sizeX = _size select 0;
+_sizeY = _size select 1;
+
+// If B axis is longer than A, switch them and fix direction.
+if (_sizeX < _sizeY) then {
+ _sizeX = _size select 1;
+ _sizeY = _size select 0;
+ _dirMrk = _dirMrk + 90;
+};
+
+// Randomly pick a direction,
+private ["_dir","_posX","_posY","_rand","_pos"];
+_dir = random 360;
+_rand = sqrt random 1;
+_posX = (_sizeX * (cos _dir)) * _rand;
+_posY = (_sizeY * (sin _dir)) * _rand;
+_pos = [_posX,_posY];
+
+if (_dirMrk != 0) then {
+ _pos = [_pos,_dirMrk] call UPSMON_pos_fnc_rotatePosition;
+};
+
+_posX = _centerX + (_pos select 0);
+_posY = _centerY + (_pos select 1);
+
+[_posX,_posY,0]
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromrectangle.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromrectangle.sqf
new file mode 100644
index 0000000..76ebd7d
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromrectangle.sqf
@@ -0,0 +1,37 @@
+// In: marker
+// Out: position
+
+// Center point
+private ["_center","_centerX","_centerY"];
+_center = getMarkerPos _this;
+_centerX = _center select 0;
+_centerY = _center select 1;
+
+// Size
+private ["_size","_sizeX","_sizeY"];
+_size = getMarkerSize _this;
+_sizeX = _size select 0;
+_sizeY = _size select 1;
+
+// Direction and make sure it's between 0 and 360.
+private ["_dir","_dirCos","_dirSin"];
+_dir = (markerDir _this) * -1;
+_dir = _dir % 360;
+_dirCos = cos _dir;
+_dirSin = sin _dir;
+
+private ["_rndX","_rndY","_posX","_posY"];
+// Select random X and Y
+_rndX = (random (_sizeX * 2)) - _sizeX;
+_rndY = (random (_sizeY * 2)) - _sizeY;
+
+// If area is angled, shift X and Y
+if (_dir != 0) then {
+ _posX = _centerX + (_dirCos * _rndX - _dirSin * _rndY);
+ _posY = _centerY + (_dirSin * _rndX + _dirCos * _rndY);
+} else {
+ _posX = _centerX + _rndX;
+ _posY = _centerY + _rndY;
+};
+
+[_posX,_posY,0]
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromsquare.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromsquare.sqf
new file mode 100644
index 0000000..c47df5b
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_getposfromsquare.sqf
@@ -0,0 +1,36 @@
+// In: marker
+// Out: position
+
+// Center point
+private ["_center","_centerX","_centerY"];
+_center = getMarkerPos _this;
+_centerX = _center select 0;
+_centerY = _center select 1;
+
+// Size
+private ["_size"];
+_size = getMarkerSize _this;
+_size = _size select 0;
+
+// Direction and make sure it's between 0 and 360.
+private ["_dir","_dirCos","_dirSin"];
+_dir = (markerDir _this) * -1;
+_dir = _dir % 360;
+_dirCos = cos _dir;
+_dirSin = sin _dir;
+
+private ["_rndX","_rndY","_posX","_posY"];
+// Select random X and Y
+_rndX = (random (_size * 2)) - _size;
+_rndY = (random (_size * 2)) - _size;
+
+// If area is angled, shift X and Y
+if (_dir != 0) then {
+ _posX = _centerX + (_dirCos * _rndX - _dirSin * _rndY);
+ _posY = _centerY + (_dirSin * _rndX + _dirCos * _rndY);
+} else {
+ _posX = _centerX + _rndX;
+ _posY = _centerY + _rndY;
+};
+
+[_posX,_posY,0]
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isblacklisted.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isblacklisted.sqf
new file mode 100644
index 0000000..4d38d3e
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isblacklisted.sqf
@@ -0,0 +1,85 @@
+// In: [position,blackListMarker]
+// Out: boolean
+
+private ["_pos","_area","_return"];
+_pos = _this select 0;
+_area = _this select 1;
+_return = false;
+
+// Find corner positions of the rectangle
+private ["_dir"];
+_dir = markerDir _area;
+_dir = _dir % 360;
+
+// Center point
+private ["_center","_centerX","_centerY"];
+_center = getMarkerPos _area;
+_centerX = _center select 0;
+_centerY = _center select 1;
+
+private ["_shape"];
+_shape = _area call UPSMON_pos_fnc_getMarkerShape;
+
+if (_shape == "ICON") then {
+ // Icon has only one position, so if it equals to the given position, then it's blacklisted.
+ if ([_pos,_center] call UPSMON_pos_fnc_issameposition) then {
+ _return = true;
+ };
+
+// Markers that have an area.
+} else {
+ if (_shape in ["RECTANGLE","SQUARE"]) then {
+ private ["_corners"];
+ _corners = _area call UPSMON_pos_fnc_getMarkerCorners;
+
+ // If rectangle is not axis-aligned.
+ if (_dir % 90 != 0) then {
+ // Add the point position to the array to have it shifted by the FOR below
+ _corners set [4,_pos];
+
+ // Rotate each corner position so that the rectangle is aligned with x and y axises
+ // Use origo as center while rotating, but for comparison shift positions back
+ private ["_posCor","_posNew","_orgX","_orgY","_shiftedX","_shiftedY","_newX","_newY"];
+ for "_i" from 0 to (count _corners - 1) do {
+ _posCor = _corners select _i;
+
+ // Original coordinates
+ _orgX = _posCor select 0;
+ _orgY = _posCor select 1;
+
+ // Subtract the marker center coordinates from corner coordinates.
+ // Rotation is done using origo (0,0) as anchor/centerpoint.
+ _shiftedX = _orgX - _centerX;
+ _shiftedY = _orgY - _centerY;
+
+ // Axis-aligned corner position
+ _posNew = [[_shiftedX,_shiftedY],_dir] call UPSMON_pos_fnc_rotatePosition;
+
+ // Shift the aligned corner position back near to the original marker location.
+ _newX = _posNew select 0;
+ _newY = _posNew select 1;
+ _newX = _newX + _centerX;
+ _newY = _newY + _centerY;
+
+ _posCor = [_newX,_newY];
+
+ _corners set [_i,_posCor];
+ };
+
+ // Point position
+ _pos = _corners select 4;
+ };
+
+ // Check if the position is within the marker area.
+ _return = [_pos,_corners] call UPSMON_pos_fnc_isInRectangle;
+ } else {
+ if (_shape == "CIRCLE") then {
+ _return = [_pos,_area] call UPSMON_pos_fnc_isInCircle;
+ } else {
+ _return = [_pos,_area] call UPSMON_pos_fnc_isInEllipse;
+ };
+ };
+};
+
+
+_return
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isincircle.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isincircle.sqf
new file mode 100644
index 0000000..39616d9
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isincircle.sqf
@@ -0,0 +1,36 @@
+// In: [position,marker]
+// Out: boolean
+
+private ["_pos","_area","_posX","_posY"];
+_pos = _this select 0;
+_area = _this select 1;
+
+_posX = _pos select 0;
+_posY = _pos select 1;
+
+// Center point
+private ["_center","_centerX","_centerY"];
+_center = getMarkerPos _area;
+_centerX = _center select 0;
+_centerY = _center select 1;
+
+// Size
+private ["_size"];
+_size = getMarkerSize _area;
+_size = _size select 0;
+
+// Difference in coordinates
+private ["_difX","_difY"];
+_difX = _posX - _centerX;
+_difY = _posY - _centerY;
+
+private ["_return"];
+_return = false;
+
+// If distance from center of marker to the given position is
+// smaller than the radius of the circle, then position is inside.
+if (sqrt((_difX * _difX) + (_difY * _difY)) < _size) then {
+ _return = true;
+};
+
+_return
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isinellipse.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isinellipse.sqf
new file mode 100644
index 0000000..1a138ad
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isinellipse.sqf
@@ -0,0 +1,54 @@
+// In: [position,ellipseMarker]
+// Out: boolean
+
+private ["_pos","_area","_return"];
+_pos = _this select 0;
+_area = _this select 1;
+_return = false;
+
+// Ellipse size
+private ["_size","_sizeX","_sizeY"];
+_size = getMarkerSize _area;
+_sizeX = _size select 0;
+_sizeY = _size select 1;
+
+// Direction and make sure it's between 0 and 360.
+private ["_dir"];
+_dir = markerDir _area;
+_dir = _dir % 360;
+
+// Ellipse center position
+private ["_center","_centerX","_centerY"];
+_center = getMarkerPos _area;
+_centerX = _center select 0;
+_centerY = _center select 1;
+
+// If marker is not axis-aligned, rotate the dot position.
+if (_dir % 90 != 0) then {
+ private ["_orgX","_orgY","_shiftedX","_shiftedY"];
+ _orgX = _pos select 0;
+ _orgY = _pos select 1;
+ _shiftedX = _orgX - _centerX;
+ _shiftedY = _orgY - _centerY;
+ _pos = [[_shiftedX,_shiftedY],_dir] call UPSMON_pos_fnc_rotatePosition;
+ _pos set [0,(_pos select 0) + _centerX];
+ _pos set [1,(_pos select 1) + _centerY];
+};
+// Dot position
+private ["_posX","_posY"];
+_posX = _pos select 0;
+_posY = _pos select 1;
+
+// Distance between dot and ellipse center
+private ["_dstX","_dstY"];
+_dstX = abs(_posX - _centerX);
+_dstY = abs(_posY - _centerY);
+
+private ["_sum"];
+_sum = ((_dstX * _dstX)/(_sizeX * _sizeX)) + ((_dstY * _dstY)/(_sizeY * _sizeY));
+
+if (_sum <= 1) then {
+ _return = true;
+};
+
+_return
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isinrectangle.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isinrectangle.sqf
new file mode 100644
index 0000000..43d7d36
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_isinrectangle.sqf
@@ -0,0 +1,26 @@
+// In: [pointPosition,corners]
+// Out: boolean
+private ["_pos","_corners","_return"];
+_pos = _this select 0;
+_corners = _this select 1;
+_return = false;
+
+private ["_dotX","_dotY","_bottomLeft","_left","_bottom","_topRight","_right","_top"];
+_dotX = _pos select 0;
+_dotY = _pos select 1;
+
+_bottomLeft = _corners select 0;
+_left = _bottomLeft select 0;
+_bottom = _bottomLeft select 1;
+
+_topRight = _corners select 2;
+_right = _topRight select 0;
+_top = _topRight select 1;
+
+// x is between left and right
+// y is between bottom and top
+if (_dotX >= _left && _dotX < _right && _dotY >= _bottom && _dotY < _top) then {
+ _return = true;
+};
+
+_return
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_issameposition.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_issameposition.sqf
new file mode 100644
index 0000000..32dbf4c
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_issameposition.sqf
@@ -0,0 +1,16 @@
+// In: [array1,array2]
+// Out: boolean
+
+private ["_p1","_p2","_return"];
+_p1 = _this select 0;
+_p2 = _this select 1;
+_return = true;
+
+// Only compare X and Y coordinates, ignore Z.
+for "_i" from 0 to 1 do {
+ if ((_p1 select _i) != (_p2 select _i)) exitwith {
+ _return = false;
+ };
+};
+
+_return
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_rotateposition.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_rotateposition.sqf
new file mode 100644
index 0000000..c0afaae
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_fnc_rotateposition.sqf
@@ -0,0 +1,13 @@
+// In: [position,direction]
+// Out: position
+private ["_pos","_dir","_orgX","_orgY","_newX","_newY"];
+_pos = _this select 0;
+_dir = _this select 1;
+
+_orgX = _pos select 0;
+_orgY = _pos select 1;
+
+_newX = (_orgX * (cos _dir)) - (_orgY * (sin _dir));
+_newY = (_orgX * (sin _dir)) + (_orgY * (cos _dir));
+
+[_newX,_newY]
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_getpos.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_getpos.sqf
new file mode 100644
index 0000000..0be58a4
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_getpos.sqf
@@ -0,0 +1,170 @@
+/* Select a random position based on anchor position, direction and distance.
+ In: [position,distance,direction,water,road,emptySpace]
+ Out: position
+*/
+private ["_org","_dst","_dir","_pos","_water","_road","_empty"];
+_org = _this select 0;
+_dst = _this select 1;
+_dir = if (count _this > 2) then {_this select 2} else {random 360};
+_water = if (count _this > 3) then {_this select 3} else {0};
+_road = if (count _this > 4) then {_this select 4} else {[0,200]};
+_empty = if (count _this > 5) then {_this select 5} else {[]};
+
+// Object instead of position array given
+if (typename _org == "OBJECT") then {_org = getpos _org};
+
+// Distance given as an array of min and max. Pick a random between them.
+if (typename _dst == "ARRAY") then {
+ private ["_min","_max"];
+ _min = _dst select 0;
+ _max = _dst select 1;
+ _dst = (_min + random(_max - _min));
+};
+
+// Direction given as an array of min and max. Pick a random dir between them.
+if (typename _dir == "ARRAY") then {
+ private ["_min","_max","_ang"];
+ _min = _dir select 0;
+ _max = _dir select 1;
+
+ _ang = _max - _min;
+
+ // Min bigger than max, can happen with directions around north
+ if (_ang < 0) then { _ang = _ang + 360 };
+
+ _dir = (_min + random _ang);
+};
+
+_pos = [_org,_dst,_dir] call UPSMON_pos_fnc_getPos;
+
+// Water position
+if (typeName _water == "SCALAR") then {
+ switch _water do {
+ case 0: { // Water not allowed
+ if (surfaceIsWater _pos) then {
+ private ["_p","_d","_l"];
+ _d = 0; _l = true;
+
+ // Search for a land position starting from the randomly picked position and
+ // then going outwards from it in full circles in 20m steps.
+ while {_d = _d + 20; _l && _d < 5000} do {
+ for "_i" from 0 to 340 step 20 do {
+ _p = [_pos,_d,_i] call UPSMON_pos_fnc_getpos;
+ if (!surfaceIsWater _p) exitwith {_l = false};
+ };
+ };
+ _pos = _p;
+ };
+ };
+ case 1: { // Water allowed
+
+ };
+ case 2: { // Only water allowed
+ if !(surfaceIsWater _pos) then {
+ private ["_p","_d","_l"];
+ _d = 0; _l = true;
+
+ // Search for a water position starting from the randomly picked position and
+ // then going outwards from it in full circles in 20m steps.
+ while {_d = _d + 20; _l && _d < 5000} do {
+ for "_i" from 0 to 340 step 20 do {
+ _p = [_pos,_d,_i] call UPSMON_pos_fnc_getpos;
+ if (surfaceIsWater _p) exitwith {_l = false};
+ };
+ };
+ _pos = _p;
+ };
+ };
+ };
+} else { // For backward compatibility
+ // Water position is not allowed
+ if !_water then {
+ if (surfaceIsWater _pos) then {
+ private ["_p","_d","_l"];
+ _d = 0; _l = true;
+
+ // Search for a land position starting from the randomly picked position and
+ // then going outwards from it in full circles in 20m steps.
+ while {_d = _d + 20; _l && _d < 5000} do {
+ for "_i" from 0 to 340 step 20 do {
+ _p = [_pos,_d,_i] call UPSMON_pos_fnc_getpos;
+ if (!surfaceIsWater _p) exitwith {_l = false};
+ };
+ };
+ _pos = _p;
+ };
+ };
+};
+
+// Road position.
+if (count _road > 0) then {
+ if ((_road select 0) > 0) then {
+ private ["_mode","_range","_roads","_cnt","_p","_p2"];
+ _mode = _road select 0;
+ _range = _road select 1;
+ _roads = _pos nearroads _range;
+ _cnt = count _roads;
+ _p = [];
+
+ // Road position(s) found.
+ if (_cnt > 0) then {
+ _p = getpos (_roads select 0);
+
+ // Found more than one road position, return closest.
+ if (_cnt > 1) then {
+ for "_i" from 1 to (_cnt - 1) do {
+ _p2 = getpos (_roads select _i);
+ if ((_p2 distance _pos) < (_p distance _pos)) then {
+ _p = _p2;
+ };
+ };
+ };
+ };
+
+ switch _mode do {
+ // Road position preferred but not forced.
+ case 1: {
+ if (count _p > 0) then {
+ _pos = _p;
+ };
+ };
+ // Only accept road position, return empty array if none found.
+ case 2: {
+ if (count _p > 0) then {
+ _pos = _p;
+ } else {
+ _pos resize 0;
+ };
+ };
+ };
+ };
+};
+
+// Find empty position
+private ["_dst","_veh","_p"];
+
+_dst = 200;
+_veh = "";
+switch (typename _empty) do {
+ case "OBJECT": { _veh = typeof _empty }; // Only vehicle given, use default distance
+ case "SCALAR": {_dst = _empty;};
+ case "ARRAY": {
+ if (count _empty > 0) then {
+ _dst = _empty select 0;
+ _veh = _empty select 1;
+ if (typename _veh == typename objNull) then { _veh = typeof _veh };
+ };
+ };
+};
+
+_p = [];
+if (count _pos > 0) then {_p = _pos findEmptyPosition [0,_dst,_veh];};
+
+
+// If an empty position is found, use it. Otherwise, return the original position.
+if (count _p > 0) then {
+ _pos = _p;
+};
+
+// Return position
+_pos
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_getposmarker.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_getposmarker.sqf
new file mode 100644
index 0000000..ca865fa
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_getposmarker.sqf
@@ -0,0 +1,101 @@
+/* Select a random position from an area defined by a marker.
+ In: [marker,water,blacklist,emptySpace]
+ Out: position
+*/
+private ["_area","_water","_blist","_pos","_empty"];
+_area = _this select 0;
+_water = if (count _this > 1) then {_this select 1} else {0};
+_blist = if (count _this > 2) then {_this select 2} else {[]};
+_empty = if (count _this > 3) then {_this select 3} else {[]};
+_pos = [];
+
+if (typename _blist == "STRING") then {_blist = [_blist]};
+
+private ["_shape"];
+_shape = _area call UPSMON_pos_fnc_getMarkerShape;
+
+// Limited loop so the script won't get stuck
+private ["_i","_exit"];
+_exit = false;
+for [{_i = 0}, {_i < 1000 && !_exit}, {_i = _i + 1}] do {
+
+ // Rectangle or Ellipse marker given?
+ if (_shape in ["SQUARE","RECTANGLE"]) then {
+ _pos = _area call UPSMON_pos_fnc_getPosFromRectangle;
+ } else {
+ _pos = _area call UPSMON_pos_fnc_getPosFromEllipse;
+ };
+
+ // Find empty position
+ private ["_dst","_veh","_p"];
+
+ _dst = 200;
+ _veh = "";
+ switch (typename _empty) do {
+ case (typename objNull): { _veh = typeof _empty }; // Only vehicle given, use default distance
+ case ("STRING"): { _veh = _empty };
+ case (typename []): {
+ if (count _empty > 0) then {
+ _dst = _empty select 0;
+ _veh = _empty select 1;
+ if (typename _veh == typename objNull) then { _veh = typeof _veh };
+ };
+ };
+ };
+
+ _p = _pos findEmptyPosition [0,_dst,_veh];
+
+ // If an empty position is found, use it. Otherwise, return the original position.
+ if (count _p > 0) then {
+ _pos = _p;
+ };
+
+ // Water position
+ if (typeName _water == "SCALAR") then {
+ switch _water do {
+
+ case 0: { // Water position is not allowed
+ // Position is on land, try to exit script.
+ if !(surfaceIsWater _pos) then {
+ _exit = true;
+ };
+ };
+
+ case 1: { // Doesn't matter if position is on water or land.
+ _exit = true;
+ };
+
+ case 2: { // Only water position is allowed
+ // Position is on water, try to exit script.
+ if (surfaceIsWater _pos) then {
+ _exit = true;
+ };
+ };
+ };
+ } else { // For backward compatibility
+ // Water position is not allowed
+ if !_water then {
+ // Position is on land, try to exit script.
+ if !(surfaceIsWater _pos) then {
+ _exit = true;
+ };
+ // Doesn't matter if position is on water or land.
+ } else {
+ _exit = true;
+ };
+ };
+
+ // Position is not allowed in blacklisted areas
+ if (count _blist > 0 && _exit) then {
+ // Check each blacklist marker
+ {
+ // If blacklisted, jump out of blacklist check and continue main loop.
+ if ([_pos,_x] call UPSMON_pos_fnc_isBlacklisted) exitwith {
+ _exit = false;
+ };
+ } foreach _blist;
+ };
+};
+
+// Return position
+_pos
\ No newline at end of file
diff --git a/scripts/UPSMON/Get_pos/UPSMON_pos_init.sqf b/scripts/UPSMON/Get_pos/UPSMON_pos_init.sqf
new file mode 100644
index 0000000..556b93b
--- /dev/null
+++ b/scripts/UPSMON/Get_pos/UPSMON_pos_init.sqf
@@ -0,0 +1,105 @@
+/*
+ SHK_pos
+
+ Version 0.23
+ Author: Shuko (shuko@quakenet, miika@miikajarvinen.fi)
+ Contributors: Hatifnat
+
+ Forum: http://forums.bistudio.com/showthread.php?162695-SHK_pos
+
+ Marker Based Selection
+ Required Parameters:
+ 0 String Area marker's name.
+
+ Optional Parameters:
+ 1 Number Water position. Default is only land positions allowed.
+ 0 Find closest land. Search outwards 360 degrees (20 degree steps) and 20m steps.
+ 1 Allow water positions.
+ 2 Find only water positions.
+ 2 Array or String One or multiple blacklist area markers which are excluded from the main marker area.
+ 3 Array, Number, Object or Vehicle Type Force finding large enough empty position.
+ 0 Max range from the selection position to look for empty space. Default is 200.
+ 1 Vehicle or vehicle type to fit into an empty space.
+
+ Examples:
+ [...,[300,heli]] Array with distance and vehicle object.
+ [...,350] Only distance given
+ [...,(typeof heli)] Only vehicle type given
+ [...,heli] Only vehicle object given
+
+ Position Based Selection
+ Required Parameters:
+ 0 Object or Position Anchor point from where the relative position is calculated from.
+ 1 Array or Number Distance from anchor.
+
+ Optional Parameters:
+ 2 Array of Number Direction from anchor. Default is random between 0 and 360.
+ 3 Number Water position. Default is only land positions allowed.
+ 0 Find closest land. Search outwards 360 degrees (20 degree steps) and 20m steps.
+ 1 Allow water positions.
+ 2 Find only water positions.
+ 4 Array Road positions.
+ 0 Number Road position forcing. Default is 0.
+ 0 Do not search for road positions.
+ 1 Find closest road position. Return the generated random position if none found.
+ 2 Find closest road position. Return empty array if none found.
+ 1 Number Road search range. Default is 200m.
+ 5 Array, Number, Object or Vehicle Type Force finding large enough empty position.
+ 0 Max range from the selection position to look for empty space. Default is 200.
+ 1 Vehicle or vehicle type to fit into an empty space.
+
+ Examples:
+ [...,[300,heli]] Array with distance and vehicle object.
+ [...,350] Only distance given
+ [...,(typeof heli)] Only vehicle type given
+ [...,heli] Only vehicle object given
+
+ Usage:
+ Preprocess the file in init.sqf:
+ call compile preprocessfile "SHK_pos\shk_pos_init.sqf";
+
+ Actually getting the position:
+ pos = [parameters] call SHK_pos;
+*/
+// Functions
+UPSMON_pos_getPos = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_getpos.sqf";
+UPSMON_pos_getPosMarker = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_getposmarker.sqf";
+
+// Sub functions
+UPSMON_pos_fnc_findClosestPosition = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_findclosestposition.sqf";
+UPSMON_pos_fnc_getMarkerCorners = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_getmarkercorners.sqf";
+UPSMON_pos_fnc_getMarkerShape = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_getmarkershape.sqf";
+UPSMON_pos_fnc_getPos = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_getpos.sqf";
+UPSMON_pos_fnc_getPosFromCircle = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_getposfromcircle.sqf";
+UPSMON_pos_fnc_getPosFromEllipse = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_getposfromellipse.sqf";
+UPSMON_pos_fnc_getPosFromRectangle = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_getposfromrectangle.sqf";
+UPSMON_pos_fnc_getPosFromSquare = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_getposfromsquare.sqf";
+UPSMON_pos_fnc_isBlacklisted = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_isblacklisted.sqf";
+UPSMON_pos_fnc_isInCircle = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_isincircle.sqf";
+UPSMON_pos_fnc_isInEllipse = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_isinellipse.sqf";
+UPSMON_pos_fnc_isInRectangle = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_isinrectangle.sqf";
+UPSMON_pos_fnc_isSamePosition = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_issameposition.sqf";
+UPSMON_pos_fnc_rotatePosition = compile preprocessfilelinenumbers "Scripts\UPSMON\Get_pos\UPSMON_pos_fnc_rotateposition.sqf";
+
+// Wrapper function
+// Decide which function to call based on parameters.
+UPSMON_pos = {
+ private ["_pos"];
+ _pos = [];
+
+ // Only marker is given as parameter
+ if (typename _this == "STRING") then {
+ _pos = [_this] call UPSMON_pos_getPosMarker;
+
+ // Parameter array
+ } else {
+ if (typename (_this select 0) == "STRING") then {
+ _pos = _this call UPSMON_pos_getPosMarker;
+ } else {
+ _pos = _this call UPSMON_pos_getPos;
+ };
+ };
+
+ // Return position
+ _pos
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/AMBUSH/Init.sqf b/scripts/UPSMON/MODULES/AMBUSH/Init.sqf
new file mode 100644
index 0000000..5cfe2fe
--- /dev/null
+++ b/scripts/UPSMON/MODULES/AMBUSH/Init.sqf
@@ -0,0 +1,4 @@
+
+UPSMON_FindAmbushPos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\AMBUSH\fnc\UPSMON_FindAmbushPos.sqf";
+UPSMON_getAmbushpos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\AMBUSH\fnc\UPSMON_getAmbushpos.sqf";
+UPSMON_SetAmbush = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\AMBUSH\fnc\UPSMON_SetAmbush.sqf";
diff --git a/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_FindAmbushPos.sqf b/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_FindAmbushPos.sqf
new file mode 100644
index 0000000..699cbad
--- /dev/null
+++ b/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_FindAmbushPos.sqf
@@ -0,0 +1,77 @@
+/****************************************************************
+File: UPSMON_getAmbushpos.sqf
+Author: Azroul13
+
+Description:
+ Search an ambush position near the leader of the group.
+ It will search in priority a road position near the leader if it doesn't find any roads it will take the position of the leader as the ambush position.
+
+Parameter(s):
+ <--- Leader of the group
+ <--- Direction from the leader to the positiontoambush
+ <--- Position choose as an ambush position
+ <--- Distance from the positiontoambush, the search begin.
+Returns:
+
+****************************************************************/
+
+private ["_npc","_diramb","_ambushdir","_positiontoambush","_ambushdist","_AmbushPosition","_AmbushPositions","_i","_max","_min","_ang","_dir","_distancetemp","_orgX","_orgY","_posX","_posY","_obspos1","_los_ok","_objects"];
+
+_npc = _this select 0;
+_diramb = _this select 1;
+_positiontoambush = _this select 2;
+_ambushdist = _this select 3;
+
+_AmbushPosition = [_positiontoambush,_diramb, _ambushdist] call UPSMON_GetPos2D;
+_AmbushPositions = [];
+_i = 0;
+
+for "_i" from 1 to 50 do
+{
+ // Many thanks Shuko ...
+ _min = _diramb + 290;
+ _max = _diramb + 70;
+
+ _ang = _max - _min;
+ // Min bigger than max, can happen with directions around north
+ if (_ang < 0) then { _ang = _ang + 360 };
+ _dir = (_min + random _ang);
+ _distancetemp = (random _ambushdist) + 50;
+ If (_distancetemp > _ambushdist) then {_distancetemp = _ambushdist;};
+
+ _orgX = _positiontoambush select 0;
+ _orgY = _positiontoambush select 1;
+ _posX = _orgX - ((_distancetemp) * sin _dir);
+ _posY = _orgY - ((_distancetemp) * cos _dir);
+
+ _obspos1 = [_posX,_posY,0];
+ If (!surfaceIsWater _obspos1) then
+ {
+ If (count (_obspos1 nearRoads 50) == 0) then
+ {
+ If ([_obspos1,_positiontoambush] call UPSMON_LOS) then
+ {
+ _AmbushPositions pushback _obspos1;
+ };
+ };
+ };
+};
+
+{
+ _obspos = _x;
+ _value = [_obspos,1,1] call UPSMON_TerraCognita;
+ _urban = _value select 0;
+ _forest = _value select 1;
+ _terr = (_urban + _forest) * 100;
+ _elev = getTerrainHeightASL [_obspos select 0,_obspos select 1];
+ _obspos set [(count _obspos),_terr + _elev];
+} foreach _AmbushPositions;
+
+if (count _AmbushPositions > 0) then
+{
+ _AmbushPositions = [_AmbushPositions] call UPSMON_ValueOrd;
+ _AmbushPosition = _AmbushPositions select 0;
+ _AmbushPosition = [_AmbushPosition select 0,_AmbushPosition select 1,0];
+};
+
+_AmbushPosition
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_SetAmbush.sqf b/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_SetAmbush.sqf
new file mode 100644
index 0000000..60165ce
--- /dev/null
+++ b/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_SetAmbush.sqf
@@ -0,0 +1,55 @@
+/****************************************************************
+File: UPSMON_SetAmbush.sqf
+Author: Azroul13
+
+Description:
+ Move the group to a position where he can ambushed any units that cross the positiontoambush
+
+Parameter(s):
+ <--- Leader of the group
+ <--- Direction from the leader to the positiontoambush
+ <--- Position choose as an ambush position
+ <--- Distance from the positiontoambush, the search begin.
+Returns:
+ Nothing
+****************************************************************/
+
+
+private ["_npc","_diramb","_positiontoambush","_ambushdist","_bldpositions","_bldpos"];
+
+_npc = _this select 0;
+_diramb = _this select 1;
+_positiontoambush = _this select 2;
+_ambushdist = _this select 3;
+_AmbushPosition = [];
+
+_terrainscan = _positiontoambush call UPSMON_sample_terrain;
+if (_terrainscan select 0 == "meadow") then {_ambushdist = 300};
+if (_terrainscan select 0 == "forest") then {_ambushdist = 100};
+
+if (_terrainscan select 0 == "inhabited" && _terrainscan select 1 > 300) then
+{
+ _AmbushPosition = _positiontoambush;
+}
+else
+{
+ _AmbushPosition = [_npc,_diramb,_positiontoambush,_ambushdist] call UPSMON_FindAmbushPos;
+};
+
+if (UPSMON_Debug>0) then {[_AmbushPosition,"Icon","hd_ambush","Colorred"] spawn UPSMON_createmarker};
+
+if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {};
+
+
+_bldpositions = [[_AmbushPosition select 0,_AmbushPosition select 1,0],"RANDOMUP",50,"",true] call UPSMON_GetNearestBuildings;
+
+_units = units _npc;
+If (count _bldpositions > 0) then
+{
+ _units = [_units,_bldpositions] call UPSMON_SpawninBuildings;
+};
+
+If (count _units > 0) then
+{
+ [_AmbushPosition,_positiontoambush,100,true,_units] call UPSMON_fnc_find_cover;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_getAmbushpos.sqf b/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_getAmbushpos.sqf
new file mode 100644
index 0000000..15d7569
--- /dev/null
+++ b/scripts/UPSMON/MODULES/AMBUSH/fnc/UPSMON_getAmbushpos.sqf
@@ -0,0 +1,102 @@
+/****************************************************************
+File: UPSMON_getAmbushpos.sqf
+Author: Azroul13
+
+Description:
+ Search an ambush position near the leader of the group.
+ It will search in priority a road position near the leader if it doesn't find any roads it will take the position of the leader as the ambush position.
+
+Parameter(s):
+ <--- Leader of the group
+Returns:
+ ---> Ambush Position.
+ This position is used in the main loop for the ambush behaviour.
+****************************************************************/
+
+private ["_grp","_Ucthis","_position","_npc","_ambushdir","_ambushType","_ambushdist","_Mines","_Minestype","_npcdir","_roads","_roadConnectedTo","_connectedRoad","_minetype1","_minetype2"];
+
+_grp = _this select 0;
+_Ucthis = _this select 1;
+_position = _this select 2;
+_npc = leader _grp;
+_ambushdir = "";
+_ambushType = 1;
+_ambushdist = UPSMON_ambushdist;
+_Mines = 4;
+_Minestype = 1;
+
+_ambushdir = ["AMBUSHDIR:",_ambushdir,_UCthis] call UPSMON_getArg;_ambushdir = ["AMBUSHDIR2:",_ambushdir,_UCthis] call UPSMON_getArg;
+_ambushType = if ("AMBUSH2" in _UCthis || "AMBUSHDIR2:" in _UCthis || "AMBUSH2:" in _UCthis) then {2} else {_ambushType};
+if ("AMBUSHDIST:" in _UCthis) then {_ambushdist = ["AMBUSHDIST:",_ambushdist,_UCthis] call UPSMON_getArg;} else {_ambushdist = 100};
+// Mine Parameter (for ambush)
+if ("MINE:" in _UCthis) then {_Mines = ["MINE:",_Mines,_UCthis] call UPSMON_getArg;}; // ajout
+if ("MINEtype:" in _UCthis) then {_Minestype = ["MINEtype:",_Minestype,_UCthis] call UPSMON_getArg;}; // ajout
+
+
+_positiontoambush = _position;
+
+_npcdir = getDir _npc;
+(group _npc) setCombatMode "BLUE";
+
+If (_ambushdir != "") then
+{
+ switch (_ambushdir) do
+ {
+ case "NORTH": {_npcdir = 0;};
+ case "NORTHEAST":{_npcdir = 45;};
+ case "EAST": {_npcdir = 90;};
+ case "SOUTHEAST": {_npcdir = 135;};
+ case "SOUTH": {_npcdir = 180;};
+ case "SOUTHWEST": {_npcdir = 225;};
+ case "WEST": {_npcdir = 270;};
+ case "NORTHWEST": {_npcdir = 315;};
+ };
+};
+
+_diramb = _npcdir;
+
+_positiontoambush = [_positiontoambush,_diramb, 20] call UPSMON_GetPos2D;
+_positiontoambush set [count _positiontoambush,0];
+_roads = _positiontoambush nearRoads 100;
+
+
+if (count _roads > 0) then
+{
+ _roads = [_roads, [], { _positiontoambush vectorDistance getposATL _x}, "ASCEND"] call BIS_fnc_sortBy;
+
+ // Thanks ARJay
+ _roadConnectedTo = roadsConnectedTo (_roads select 0);
+ _connectedRoad = _roadConnectedTo select 0;
+ _diramb = [(_roads select 0), _connectedRoad] call BIS_fnc_DirTo;
+ If ((_npcdir < 180 && _diramb > (_npcdir + 90)) || (_npcdir > 180 && _diramb < (_npcdir - 90))) then {_diramb = _diramb +180;diag_log format ["Min2: %1 Max2: %2 %3 %4",_npcdir,_diramb,(_npcdir < 180 && _diramb > (_npcdir + 90)),(_npcdir > 180 && _diramb < (_npcdir - 90))];};
+ _positiontoambush = getposATL (_roads select 0);
+};
+
+//Puts a mine if near road
+if ( UPSMON_useMines && _ambushType == 1 ) then
+{
+ if (UPSMON_Debug>0) then
+ {
+ player sidechat format["%1: Putting mine for ambush",_grp getvariable ["UPSMON_grpid",0]];
+ diag_log format["UPSMON %1: Putting mine for ambush",_grp getvariable ["UPSMON_grpid",0]];
+ diag_log format["%1: Roads #:%2 Pos:%3 Dir:%4",_grp getvariable ["UPSMON_grpid",0], _roads,_positiontoambush,_npcdir]
+ };
+
+ _minetype1 = UPSMON_Minestype1 call BIS_fnc_selectRandom;
+ _minetype2 = UPSMON_Minestype2 call BIS_fnc_selectRandom;
+
+ switch (_Minestype) do
+ {
+ case "1": {_minetype2 = _minetype1;};
+ case "2": {_minetype2 = _minetype2;};
+ case "3": {_minetype1 = _minetype2;};
+ };
+
+ [_Mines,_minetype1,_minetype2,_positiontoambush,_diramb,side _npc] spawn UPSMON_spawnmines;
+
+};
+
+[_npc,_diramb,_positiontoambush,_ambushdist] spawn UPSMON_SetAmbush;
+sleep 1;
+
+_positiontoambush
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/Init.sqf b/scripts/UPSMON/MODULES/ARTILLERY/Init.sqf
new file mode 100644
index 0000000..6958b96
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/Init.sqf
@@ -0,0 +1,14 @@
+
+UPSMON_ArtiChk = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_ArtiChk.sqf";
+UPSMON_FO = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_FO.sqf";
+UPSMON_GetArtiTarget = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_GetArtiTarget.sqf";
+
+UPSMON_selectartillery = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_selectartillery.sqf";
+UPSMON_artillerydofire = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_artillerydofire.sqf";
+UPSMON_GetDefaultmun = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_GetDefaultmun.sqf";
+UPSMON_getmuninfos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_getmuninfos.sqf";
+UPSMON_getmuninfosbackpack = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_getmuninfosbackpack.sqf";
+UPSMON_Splashzone = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_Splashzone.sqf";
+UPSMON_Flaretime = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_Flaretime.sqf";
+UPSMON_artillerysetBattery = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_artillerysetBattery.sqf";
+UPSMON_artilleryBatteryout = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ARTILLERY\fnc\UPSMON_artilleryBatteryout.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_ArtiChk.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_ArtiChk.sqf
new file mode 100644
index 0000000..c5c19d4
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_ArtiChk.sqf
@@ -0,0 +1,45 @@
+/****************************************************************
+File: UPSMON_Splashzone.sqf
+Author: Azroul13
+
+Description:
+ check if there's allied near the targetpos.
+
+Parameter(s):
+ <--- Arti unit
+ <--- Mission fire
+Returns:
+ boolean
+****************************************************************/
+
+private ["_grp","_result","_artillerysideFire","_artillerysideunits"];
+
+_grp = _this select 0;
+_result = false;
+
+If (!(_grp getvariable ["UPSMON_NOARTILLERY",false])) then
+{
+ If (_grp getvariable ["UPSMON_RADIORANGE",0] > 0) then
+ {
+ If (_grp getvariable ["UPSMON_Articalltime",time] <= time) then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "AMBUSH") then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "SURRENDER") then
+ {
+ _artillerysideFire = call (compile format ["UPSMON_ARTILLERY_%1_FIRE",side _grp]);
+ If (_artillerysideFire) then
+ {
+ _artillerysideunits = call (compile format ["UPSMON_ARTILLERY_%1_UNITS",side _grp]);
+ If (count _artillerysideunits > 0) then
+ {
+ _result = true;
+ };
+ };
+ };
+ };
+ };
+ };
+};
+
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_FO.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_FO.sqf
new file mode 100644
index 0000000..9919e56
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_FO.sqf
@@ -0,0 +1,82 @@
+/****************************************************************
+File: UPSMON_FO.sqf
+Author: Azroul13
+
+Description:
+ Analyse the situation for artillery support, target and munition to use for them.
+
+Parameter(s):
+ <--- group
+ <--- leader position
+ <--- Attack position
+ <--- Dist from target
+ <--- Enemies array
+Returns:
+ Nothing
+****************************************************************/
+
+private ["_grp","_currpos","_attackpos","_dist","_enies","_suspectenies","_RadioRange","_artillerysideunits","_suspectpos","_artitarget","_mission"];
+
+_grp = _this select 0;
+_currpos = _this select 1;
+_attackpos = _this select 2;
+_dist = _this select 3;
+_enies = _this select 4;
+_mission = "HE";
+If (count _this > 5) then {_mission = _this select 5};
+
+_RadioRange = _grp getvariable ["UPSMON_RADIORANGE",0];
+_artillerysideunits = (call (compile format ["UPSMON_ARTILLERY_%1_UNITS",side _grp])) - [_grp];
+
+If (_mission == "ILLUM") then
+{
+
+ [_artillerysideunits,"ILLUM",_RadioRange,_currpos,3,_attackpos,50] spawn UPSMON_selectartillery;
+ _time = time + 10;
+ _grp setvariable ["UPSMON_Articalltime",_time];
+}
+else
+{
+ If (_grp getvariable ["UPSMON_Grpmission",""] == "RETREAT") then
+ {
+ If (_dist > 200) then
+ {
+ _time = time + 10;
+ _grp setvariable ["UPSMON_Articalltime",_time];
+ _vcttarget = [_currpos, _attackpos] call BIS_fnc_dirTo;
+ _dist = (_currpos vectorDistance _attackpos)/2;
+ _attackpos = [_currpos,_vcttarget, _dist] call UPSMON_GetPos2D;
+ [_artillerysideunits,"SMOKE",_RadioRange,_currpos,4,_attackpos,50] spawn UPSMON_selectartillery;
+ };
+ }
+ else
+ {
+ _artitarget = [_enies,_currpos] call UPSMON_GetArtiTarget;
+ _area = 30;
+ If (!IsNull _artitarget) then
+ {
+ _muntype = "HE";
+ _nbr = 4;
+ If (vehicle _artitarget == _artitarget) then
+ {
+ If ([_artitarget] call UPSMON_Inbuilding) then
+ {
+ _nbr = 2;
+ _area = 5;
+ };
+ }
+ else
+ {
+ if (_artitarget iskindof "Tank") then
+ {
+ _nbr = 2;
+ _area = 10;
+ _muntype = "AT";
+ };
+ };
+ _time = time + 10;
+ _grp setvariable ["UPSMON_Articalltime",_time];
+ [_artillerysideunits,_muntype,_RadioRange,_currpos,_nbr,_artitarget,_area] spawn UPSMON_selectartillery;
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_Flaretime.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_Flaretime.sqf
new file mode 100644
index 0000000..dc0bf0d
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_Flaretime.sqf
@@ -0,0 +1,4 @@
+UPSMON_FlareInTheAir = true;
+sleep 50;
+UPSMON_FlareInTheAir = false;
+Publicvariable "UPSMON_FlareInTheAir";
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_GetArtiTarget.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_GetArtiTarget.sqf
new file mode 100644
index 0000000..3240056
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_GetArtiTarget.sqf
@@ -0,0 +1,93 @@
+/****************************************************************
+File: UPSMON_GetArtitarget.sqf
+Author: Azroul13
+
+Description:
+ Get the most interesting target for Arti.
+
+Parameter(s):
+ <--- Array of enies
+ <--- position of the calling leader
+Returns:
+ Target
+****************************************************************/
+
+private ["_enies","_currpos","_target","_list","_points"];
+
+_enies = _this select 0;
+_currpos = _this select 1;
+
+_target = ObjNull;
+_list = [];
+
+{
+ If (alive _x) then
+ {
+ If (_currpos vectordistance (getposATL _x) > 300) then
+ {
+ If (!((vehicle _x) iskindof "AIR")) then
+ {
+ _points = 0;
+ If (vehicle _x != _x) then
+ {
+ If ((vehicle _x) iskindof "STATICWEAPON") then
+ {
+ _points = _points + 100;
+ };
+
+ If ((vehicle _x) iskindof "CAR" || (vehicle _x) iskindof "TANK") then
+ {
+ if (Speed _x < 10) then
+ {
+ _armor = getNumber (configFile >> "CfgVehicles" >> (typeof (vehicle _x)) >> "armor");
+ If (_armor > 500) then
+ {
+ _points = _points + 100;
+ }
+ else
+ {
+ _points = _points + 50;
+ };
+
+ If (!(IsNull (Gunner (vehicle _x)))) then
+ {
+ _points = _points + 100;
+ };
+ };
+ };
+
+ _cfgArtillery = getnumber (configFile >> "cfgVehicles" >> (typeOf (vehicle _x)) >> "artilleryScanner");
+
+ If (_cfgArtillery == 1) then
+ {
+ _points = _points + 200;
+ };
+ }
+ else
+ {
+ If ([_x] call UPSMON_Inbuilding) then
+ {
+ _points = _points + 100;
+ };
+
+ _eniesnear = [_x,_enies] call UPSMON_Eniesnear;
+
+ If (_eniesnear > 4) then
+ {
+ _points = _points + (20 * (_eniesnear));
+ };
+ };
+
+ _list pushback [_x,_points];
+ };
+ };
+ };
+} foreach _enies;
+
+If (count _list > 0) then
+{
+ _list = [_list, [], {_x select 1}, "DESCEND"] call BIS_fnc_sortBy;
+ _target = (_list select 0) select 0;
+};
+
+_target
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_GetDefaultmun.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_GetDefaultmun.sqf
new file mode 100644
index 0000000..16f2760
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_GetDefaultmun.sqf
@@ -0,0 +1,47 @@
+/****************************************************************
+File: UPSMON_getdefaultmun.sqf
+Author: Azroul13
+
+Description:
+ Get the number munition for mortar backpack
+
+Parameter(s):
+ <--- vehicle type
+Returns:
+ Array [nbr HE,nbr Smoke,nbr Illum]
+****************************************************************/
+
+private ["_vehicle","_cfgArtillerymag","_rounds","_ammo","_parents","_cfg","_count"];
+
+_vehicle = _this select 0;
+
+_cfgArtillerymag = getArray (configFile >> "cfgVehicles" >> _vehicle >> "Turrets" >> "MainTurret" >> "magazines");
+
+_rounds = [0,0,0];
+
+{
+ _ammo = tolower gettext (configFile>> "CfgMagazines" >> _x >> "ammo");
+ _parents = [(configFile>> "CfgAmmo" >> _ammo),true] call BIS_fnc_returnParents;
+ _cfg = tolower gettext (configFile>> "CfgAmmo" >> _ammo >> "submunitionAmmo");
+
+ If ("ShellBase" in _parents) then
+ {
+ _count = getnumber (configFile>> "CfgMagazines" >> _x >> "count");
+ _rounds set [0,(_rounds select 0) + _count];
+ };
+
+ If (_cfg == "SmokeShellArty") then
+ {
+ _count = getnumber (configFile>> "CfgMagazines" >> _x >> "count");
+ _rounds set [1,(_rounds select 1) + _count];
+ };
+
+ If ("FlareCore" in _parents) then
+ {
+ _count = getnumber (configFile>> "CfgMagazines" >> _x >> "count");
+ _rounds set [2,(_rounds select 2) + _count];
+ };
+
+} foreach _cfgArtillerymag;
+
+_rounds
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_Splashzone.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_Splashzone.sqf
new file mode 100644
index 0000000..fdf2d45
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_Splashzone.sqf
@@ -0,0 +1,36 @@
+/****************************************************************
+File: UPSMON_Splashzone.sqf
+Author: Azroul13
+
+Description:
+ check if there's allied near the targetpos.
+
+Parameter(s):
+ <--- Arti unit
+ <--- Mission fire
+Returns:
+ boolean
+****************************************************************/
+
+private [];
+
+_targetPos = _this select 0;
+_munradius = _this select 1;
+_side = _this select 2;
+
+_result = false;
+//Must check if no friendly squad near fire position
+{
+ If (!IsNull _x) then
+ {
+ if (alive (leader _x)) then
+ {
+ If (_side == side _x) then
+ {
+ if ((round([getposATL (leader _x),_targetPos] call UPSMON_distancePosSqr)) <= (_munradius)) exitwith {_result = true;_result};
+ };
+ };
+ };
+} foreach UPSMON_NPCs;
+
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artilleryBatteryout.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artilleryBatteryout.sqf
new file mode 100644
index 0000000..7c03f8f
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artilleryBatteryout.sqf
@@ -0,0 +1,28 @@
+/****************************************************************
+File: UPSMON_artilleryBatteryout.sqf
+Author: Azroul13
+
+Description:
+ Mortar units repack the static weapon
+Parameter(s):
+
+Returns:
+ nothing
+****************************************************************/
+private ["_batteryunits","_staticteam"];
+
+_batteryunits = _this select 0;
+
+If (typename (_batteryunits select 0) == "ARRAY") then
+{
+ _staticteam = _batteryunits select 0;
+ {
+ If (!alive _x) exitwith {_batteryunits = [];};
+ } foreach _staticteam;
+
+ If (count _batteryunits > 0) then
+ {
+ [_staticteam select 0,_staticteam select 1] call UPSMON_Packbag;
+ };
+
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artillerydofire.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artillerydofire.sqf
new file mode 100644
index 0000000..c0e93f4
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artillerydofire.sqf
@@ -0,0 +1,132 @@
+/****************************************************************
+File: UPSMON_artillerydofire.sqf
+Author: Azroul13
+
+Description:
+ Make Artillery fire !!
+
+Parameter(s):
+ <--- Artillery Group
+ <--- target position
+ <--- Area of dispersion
+ <--- Number of rounds
+ <--- Artillery Mission
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_position","_area","_area2","_area3","_roundsask","_askmission","_maxcadence","_mincadence","_batteryunits","_result","_i","_roundclass","_roundsleft","_sleep","_timeout"];
+
+_grp = _this select 0;
+_position = _this select 1;
+_area = _this select 2;
+_roundsask = _this select 3;
+_askmission = _this select 4;
+
+_maxcadence = _grp getvariable ["UPSMON_Artillerymaxcadence",6];
+_mincadence = _grp getvariable ["UPSMON_Artillerymincadence",3];
+_batteryunits = _grp getvariable ["UPSMON_Battery",[]];
+_area2 = _grp getvariable ["UPSMON_Artilleryarea",1];
+_npc = leader _grp;
+
+
+_grp setvariable ["UPSMON_Batteryfire",true];
+_result = [0,Objnull,0,0];
+
+If (count (_grp getvariable ["UPSMON_Mortarmun",[]]) > 0) then
+{
+ If (typename ((_grp getvariable ["UPSMON_Battery",[]])select 0) == "ARRAY") then
+ {
+ _result = [_askmission,typeof (vehicle ((_batteryunits select 0) select 0))] call UPSMON_getmuninfosbackpack;
+ _batteryunits = [];
+ _batteryunits pushback ((_batteryunits select 0) select 0);
+ }
+ else
+ {
+ _result = [_askmission,typeof (vehicle (_batteryunits select 0))] call UPSMON_getmuninfosbackpack;
+ };
+}
+else
+{
+ _result = [_askmission,_batteryunits] call UPSMON_getmuninfos;
+};
+
+_roundclass = _result select 1;
+
+If (_result select 3 < 200) then {_roundsask = _roundsask*2;};
+If (_result select 3 >= 400) then {_roundsask = _roundsask/2;};
+
+If (_roundsask > _result select 0) then {_roundsask = _result select 0;};
+
+If (count (_grp getvariable ["UPSMON_Mortarmun",[]]) > 0) then
+{
+ _roundsleft = _grp getvariable ["UPSMON_Mortarmun",[]];
+ switch (_askmission) do
+ {
+ case "HE":
+ {
+ _roundsleft set [0,((_grp getvariable ["UPSMON_Mortarmun",[]]) select 0) - _roundsask];
+ _grp setvariable ["UPSMON_Mortarmun",_roundsleft]
+ };
+ case "SMOKE":
+ {
+ _roundsleft set [1,((_grp getvariable ["UPSMON_Mortarmun",[]]) select 1) - _roundsask];
+ _grp setvariable ["UPSMON_Mortarmun",_roundsleft]
+ };
+ case "ILLUM":
+ {
+ _roundsleft set [2,((_grp getvariable ["UPSMON_Mortarmun",[]]) select 2) - _roundsask];
+ _grp setvariable ["UPSMON_Mortarmun",_roundsleft]
+ };
+ };
+};
+
+If (_askmission == "ILLUM") then {[] spawn UPSMON_Flaretime;};
+
+_area3 = _area * (_area2 + random 0.4);
+
+If (UPSMON_DEBUG > 0) then
+{
+ player globalchat format["artillery doing fire on %1",_position];
+ [_position,"Icon","mil_arrow","Colorblue",0] spawn UPSMON_createmarker
+};
+
+sleep 1;
+_i = 0;
+_timeout = time + 140;
+
+while {_i<_roundsask && count _batteryunits > 0 && time < _timeout} do
+{
+ {
+ if (alive (gunner (vehicle _x)) && (getnumber (configFile >> "cfgVehicles" >> (typeOf (vehicle _x)) >> "artilleryScanner") == 1)) then
+ {
+ _i=_i+1;
+ //(vehicle _x) addMagazine _roundclass;
+ (vehicle _x) commandArtilleryFire [[(_position select 0)+ random _area3 - _area, (_position select 1)+ random _area3 - _area, 0], _roundclass, 1];
+ }
+ else
+ {
+ _batteryunits = _batteryunits - [_x];
+ };
+ sleep 1;
+ } foreach _batteryunits;
+
+ _sleep = random _maxcadence;
+ if (_sleep < _mincadence) then {_sleep = _mincadence};
+ sleep _sleep;
+};
+
+[_batteryunits] call UPSMON_artillerybatteryout;
+
+_grp setvariable ["UPSMON_Batteryfire",false];
+_grp setvariable ["UPSMON_Artifiremission",[]];
+_grp setvariable ["UPSMON_RoundsComplete",true];
+
+sleep 30;
+If (!IsNull _grp) then
+{
+ If (alive (leader _grp)) then
+ {
+ _grp setVariable ["UPSMON_ArtiBusy",false];
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artillerysetBattery.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artillerysetBattery.sqf
new file mode 100644
index 0000000..1b82a0f
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_artillerysetBattery.sqf
@@ -0,0 +1,84 @@
+/****************************************************************
+File: UPSMON_artillerysetBattery.sqf
+Author: Azroul13
+
+Description:
+ All artillery stop and set to battery
+Parameter(s):
+ <--- Group
+ <--- Type of group
+ <--- Nowp (true/false)
+ <--- Targetpos
+Returns:
+ nothing
+****************************************************************/
+private ["_grp","_typeofgrp","_nowp","_npc","_target","_pos","_staticteam","_backpack","_batteryunits"];
+
+_grp = _this select 0;
+_typeofgrp = _this select 1;
+_nowp = _this select 2;
+_target = _this select 3;
+
+_npc = leader _grp;
+_currpos = getposATL _npc;
+
+_grp setvariable ["UPSMON_OnBattery",false];
+
+If (count (_grp getvariable ["UPSMON_Battery",[]]) > 0) then
+{
+ If (!(_grp getvariable ["UPSMON_GrpinAction",false])) then
+ {
+ If (!("static" in _typeofgrp) || !_nowp) then
+ {
+ {
+ Dostop _x;
+ } foreach units _grp;
+
+ _pos = _currpos isFlatEmpty [10,1,0.5,10,20,false];
+
+ If (count _pos > 0) then
+ {
+ _pos = ASLToATL _pos;
+ }
+ else
+ {
+ _pos = _currpos;
+ };
+
+ [_grp,_pos,"HOLD","LINE","LIMITED","COMBAT","YELLOW",1] spawn UPSMON_DocreateWP;
+
+ If (typename ((_grp getvariable ["UPSMON_Battery",[]])select 0) == "ARRAY") then
+ {
+ sleep 2;
+ _staticteam = (_grp getvariable ["UPSMON_Battery",[]])select 0;
+ _batteryunits = _staticteam;
+ {
+ If (alive _x && vehicle _x != _x && !((vehicle _x) getvariable ["UPSMON_disembarking",false])) then
+ {
+ waituntil {vehicle _x == _x || !alive _x};
+ };
+ If (!alive _x) exitwith {_batteryunits = [];};
+ } foreach _staticteam;
+
+ If (count _batteryunits > 0) then
+ {
+ _grp call UPSMON_DeleteWP;
+ _backpack = backpack (_batteryunits select 0);
+ _vehicle = ([_backpack] call UPSMON_checkbackpack) select 0;
+ [_staticteam select 0,_staticteam select 1,_pos,_target,_vehicle] call UPSMON_Unpackbag;
+ _grp setvariable ["UPSMON_OnBattery",true];
+ [_grp,_pos,"HOLD","LINE","LIMITED","COMBAT","YELLOW",1] spawn UPSMON_DocreateWP;
+ };
+ }
+ else
+ {
+ sleep 2;
+ _grp setvariable ["UPSMON_OnBattery",true];
+ };
+ }
+ else
+ {
+ _grp setvariable ["UPSMON_OnBattery",true];
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_getmuninfos.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_getmuninfos.sqf
new file mode 100644
index 0000000..56e8e5b
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_getmuninfos.sqf
@@ -0,0 +1,94 @@
+/****************************************************************
+File: UPSMON_getrounnbr.sqf
+Author: Azroul13
+
+Description:
+ Get the number of rounds the unit has
+Parameter(s):
+ <--- fire mission
+ <--- battery units
+Returns:
+ [Number of rounds,class of the munition,indirect range value,hit value]
+****************************************************************/
+
+private ["_askmission","_vehicles","_rounds","_class","_indirectrange","_hit","_mags","_ammo","_parents","_cfg","_result"];
+
+_askmission = _this select 0;
+_vehicles = _this select 1;
+
+_rounds = 0;
+_class = ObjNull;
+_indirectrange = 0;
+_hit = 0;
+_mags = [];
+
+{
+ If (alive _x) then
+ {
+ _mags = [_mags,magazinesAmmo _x] call BIS_fnc_arrayPushStack
+ };
+} foreach _vehicles;
+
+{
+ Switch (_askmission) do
+ {
+ case "HE":
+ {
+ _ammo = tolower gettext (configFile>> "CfgMagazines" >> (_x select 0) >> "ammo");
+ _parents = [(configFile>> "CfgAmmo" >> _ammo),true] call BIS_fnc_returnParents;
+
+ If ("ShellBase" in _parents) then
+ {
+ _class = _x select 0;
+ _rounds = _rounds + (_x select 1);
+ _indirectrange = (getnumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")) * 8;
+ _hit = getnumber (configFile >> "CfgAmmo" >> _ammo >> "Hit");
+ };
+ };
+
+ case "AT":
+ {
+ _ammo = tolower gettext (configFile>> "CfgMagazines" >> (_x select 0) >> "ammo");
+ _cfg = tolower gettext (configFile>> "CfgAmmo" >> _ammo >> "submunitionAmmo");
+
+ If (_cfg == "M_Mo_82mm_AT_LG") then
+ {
+ _class = _x select 0;
+ _rounds = _rounds + (_x select 1);
+ _indirectrange = getnumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
+ _hit = getnumber (configFile >> "CfgAmmo" >> _ammo >> "Hit");
+ };
+ };
+
+ case "SMOKE":
+ {
+ _ammo = tolower gettext (configFile>> "CfgMagazines" >> (_x select 0) >> "ammo");
+ _cfg = tolower gettext (configFile>> "CfgAmmo" >> _ammo >> "submunitionAmmo");
+
+ If (_cfg == "SmokeShellArty") then
+ {
+ _class = _x select 0;
+ _rounds = _rounds + (_x select 1);
+ _indirectrange = getnumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
+ _hit = getnumber (configFile >> "CfgAmmo" >> _ammo >> "Hit");
+ };
+ };
+
+ case "ILLUM":
+ {
+ _ammo = tolower gettext (configFile>> "CfgMagazines" >> (_x select 0) >> "ammo");
+ _parents = [(configFile>> "CfgAmmo" >> _ammo),true] call BIS_fnc_returnParents;
+
+ If ("FlareCore" in _parents) then
+ {
+ _class = _x select 0;
+ _rounds = _rounds + (_x select 1);
+ _indirectrange = getnumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
+ _hit = getnumber (configFile >> "CfgAmmo" >> _ammo >> "Hit");
+ };
+ };
+ };
+} foreach _mags;
+
+_result = [_rounds,_class,_indirectrange,_hit];
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_getmuninfosbackpack.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_getmuninfosbackpack.sqf
new file mode 100644
index 0000000..1c004a1
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_getmuninfosbackpack.sqf
@@ -0,0 +1,89 @@
+/****************************************************************
+File: UPSMON_getmuninfos.sqf
+Author: Azroul13
+
+Description:
+ Return Mun information about the mortar in the backpack of the unit
+
+Parameter(s):
+ <--- Mission fire
+ <--- man holding the mortar backpack
+Returns:
+ [Number of rounds,class of the munition,indirect range value,hit value]
+****************************************************************/
+
+private ["_askmission","_vehicle","_result","_backpack","_cfgArtillerymag","_rounds","_class","_hit","_cfg","_parents","_indirectrange","_ammo","_result"];
+
+_askmission = _this select 0;
+_vehicle = _this select 1;
+
+_cfgArtillerymag = getArray (configFile >> "cfgVehicles" >> _vehicle >> "Turrets" >> "MainTurret" >> "magazines");
+
+
+_rounds = 0;
+_class = ObjNull;
+_indirectrange = 0;
+_hit = 0;
+_mags = [];
+
+{
+ _ammo = tolower gettext (configFile>> "CfgMagazines" >> _x >> "ammo");
+ _parents = [(configFile>> "CfgAmmo" >> _ammo),true] call BIS_fnc_returnParents;
+ _cfg = tolower gettext (configFile>> "CfgAmmo" >> _ammo >> "submunitionAmmo");
+
+ Switch (_askmission) do
+ {
+ case "HE":
+ {
+ _rounds = (_grp getvariable ["UPSMON_Mortarmun",[]]) select 0;
+
+ If (_rounds > 0) then
+ {
+ If ("ShellBase" in _parents) then
+ {
+ _class = _x;
+ _indirectrange = (getnumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")) * 8;
+ _hit = getnumber (configFile >> "CfgAmmo" >> _ammo >> "Hit");
+ };
+ };
+ };
+
+ case "AT":
+ {
+ _rounds = 0;
+ };
+
+ case "SMOKE":
+ {
+ _rounds = (_grp getvariable ["UPSMON_Mortarmun",[]]) select 1;
+
+ If (_rounds > 0) then
+ {
+ If (_cfg == "SmokeShellArty") then
+ {
+ _class = _x;
+ _indirectrange = getnumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
+ _hit = getnumber (configFile >> "CfgAmmo" >> _ammo >> "Hit");
+ };
+ };
+ };
+
+ case "ILLUM":
+ {
+ _rounds = (_grp getvariable ["UPSMON_Mortarmun",[]]) select 2;
+
+ If (_rounds > 0) then
+ {
+ If ("FlareCore" in _parents) then
+ {
+ _class = _x;
+ _indirectrange = getnumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
+ _hit = getnumber (configFile >> "CfgAmmo" >> _ammo >> "Hit");
+ };
+ };
+ };
+ };
+} foreach _cfgArtillerymag;
+
+_result = [_rounds,_class,_indirectrange,_hit];
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_selectartillery.sqf b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_selectartillery.sqf
new file mode 100644
index 0000000..466238d
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ARTILLERY/fnc/UPSMON_selectartillery.sqf
@@ -0,0 +1,82 @@
+/****************************************************************
+File: UPSMON_selectartillery.sqf
+Author: Azroul13
+
+Description:
+ Select the artillery that has ammunition and are near the group.
+
+Parameter(s):
+ <--- Artillery groups array
+ <--- type of round ("HE","WP","ILLUM")
+ <--- position of the leader of the group
+Returns:
+ Artillery group
+****************************************************************/
+
+private ["_artillerysidegrps","_askMission","_RadioRange","_npcpos","_roundsask","_targetpos","_area","_artilleryunit","_rounds","_artiarray","_arti","_vehicledemo"];
+
+_artillerysidegrps = _this select 0;
+_askMission = _this select 1;
+_RadioRange = _this select 2;
+_npcpos = _this select 3;
+_roundsask = _this select 4;
+_targetpos = _this select 5;
+_area = _this select 6;
+
+
+_artilleryunit = ObjNull;
+_artiarray = [_artillerysidegrps, [], { _npcpos vectorDistance (leader _x) }, "ASCEND"] call BIS_fnc_sortBy;
+{
+ _arti = _x;
+
+ If (count units _x > 0) then
+ {
+ If (count (_grp getvariable ["UPSMON_Battery",[]]) > 0) then
+ {
+ If ((round([getposATL (leader _arti),_npcpos] call UPSMON_distancePosSqr)) <= _RadioRange) then
+ {
+ If (!(_grp getVariable ["UPSMON_ArtiBusy",false])) then
+ {
+ _result = [0,ObjNull,0,0];
+ _vehicledemo = (_grp getvariable ["UPSMON_Battery",[]]) select 0;
+
+ If (count (_grp getvariable ["UPSMON_Mortarmun",[]]) > 0) then
+ {
+ If (typename ((_grp getvariable ["UPSMON_Battery",[]])select 0) == "ARRAY") then
+ {
+ _backpack = backpack (_vehicledemo select 0);
+ _vehicledemo = ([_backpack] call UPSMON_checkbackpack) select 0;
+ _result = [_askMission,_vehicledemo] call UPSMON_getmuninfos;
+ }
+ else
+ {
+ _result = [_askmission,typeof _vehicledemo] call UPSMON_getmuninfosbackpack;
+ };
+ }
+ else
+ {
+ _result = [_askMission,(_grp getvariable ["UPSMON_Battery",[]])] call UPSMON_getmuninfos;
+ };
+
+ If ((_result select 0) > 0) then
+ {
+ if ((_targetPos inRangeOfArtillery [_vehicledemo, _result select 1])) then
+ {
+ _side = side _arti;
+ _alliednear = [_targetpos,_result select 2,_side] call UPSMON_Splashzone;
+
+ If (!_alliednear) exitwith
+ {
+ _grp getVariable ["UPSMON_ArtiBusy",true];
+ _arti setvariable ["UPSMON_Artifiremission",[_targetPos,_askmission,_roundsask,_area]];
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+
+ if (UPSMON_Debug>0) then {diag_log format ["Busy:%1 Distance:%2 RadioRange:%3 Rounds:%4",_artibusy,leader _x distance _npcpos,_RadioRange,_rounds];};
+
+} ForEach _artiarray;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_Fortify.sqf b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_Fortify.sqf
new file mode 100644
index 0000000..404485b
--- /dev/null
+++ b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_Fortify.sqf
@@ -0,0 +1,42 @@
+/****************************************************************
+File: UPSMON_unitdefend.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- group
+ <--- Distance between group and nearest enemy
+ <--- Is supressed? (boolean)
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_units","_npc","_currpos","_dir","_blds","_lookpos","_attackpos"];
+
+_grp = _this select 0;
+_attackpos = _this select 1;
+_units = units _grp;
+_npc = leader _grp;
+_currpos = getposATL _npc;
+_dir = getdir _npc;
+
+_grp setvariable ["UPSMON_GrpinAction",true];
+
+_unitsin = [_npc,["static"],50,false,""] call UPSMON_GetIn_NearestVehicles;
+_units = _units - _unitsin;
+
+If ( count _units > 0 ) then
+{
+ _nosmoke = [_grp] call UPSMON_NOSMOKE;
+ If (!_nosmoke) then {[units _grp,_attackpos] spawn UPSMON_CreateSmokeCover;};
+ sleep 1;
+ _units = [_npc,_units,70,9999] call UPSMON_moveNearestBuildings;
+ If (count _units > 0) then
+ {
+ _lookpos = [_currpos,_dir, 20] call UPSMON_GetPos2D;
+ [_currpos,_lookpos,50,false,_units] call UPSMON_fnc_find_cover;
+ };
+};
+_grp setvariable ["UPSMON_GrpinAction",false];
+_grp setvariable ["UPSMON_Grpmission","FORTIFY"];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_SpawninBuildings.sqf b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_SpawninBuildings.sqf
new file mode 100644
index 0000000..48fee77
--- /dev/null
+++ b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_SpawninBuildings.sqf
@@ -0,0 +1,96 @@
+/****************************************************************
+File: UPSMON_SpawninBuildings.sqf
+Author: Azroul13
+
+Description:
+ Spawn each unit of the group in building
+
+Parameter(s):
+ <--- Group units
+ <--- Array of buildings
+ <--- Leader of group
+Returns:
+ units not in building
+****************************************************************/
+
+private ["_minpos","_units","_blds","_blds2","_altura","_bld","_bldpos1","_bldpos2","_cntobjs1","_movein","_i","_result","_id2"];
+
+_minpos = 1;
+
+_units = _this select 0;
+_blds = _this select 1;
+_i = 0;
+If (count _this > 2) then {_i = _this select 2};
+
+If (_i > 4) exitwith {_units};
+
+_blds2 = [];
+
+{
+ _arraybld = _x;
+ _bld = _x select 0;
+ _bldpos1 = (_x select 1) select 0;
+ _bldpos2 = (_x select 1) select 1;
+
+ If (count _bldpos1 < _minpos) then {_bldpos1 = (_x select 1) select 1;_bldpos2 = _bldpos1;};
+ if ("deletethis" in _bldpos1) then {_bldpos1 = _bldpos1 - ["deletethis"];};
+
+ if ( count _bldpos1 >= _minpos ) then
+ {
+ _cntobjs1 = 1;
+ _movein = [];
+ if (count _bldpos1 >= 3) then { _cntobjs1 = round(random 1) + 2;};
+ if (count _bldpos1 >= 8) then { _cntobjs1 = round(random 2) + 6;};
+ if (count _bldpos1 >= 10) then {_cntobjs1 = round(random 3) + 7;};
+
+ {
+ if (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (_cntobjs1 > 0) then
+ {
+ _movein pushback _x;
+ _cntobjs1 = _cntobjs1 - 1;
+ };
+ };
+ };
+ };
+ } foreach _units;
+
+ if (count _movein > 0) then
+ {
+ {
+ If (count _bldpos1 > 0) then
+ {
+ _result = [_bldpos1] call UPSMON_Checkfreebldpos;
+ If (count _result > 0) then
+ {
+ _altura = _result select 0;
+ _id2 = _result select 1;
+ _x setpos _altura;
+ dostop _x;
+ if ((group _x) getvariable ["UPSMON_NOWP",0] > 2) then {_x disableAI "TARGET"};
+ [_x,getdir _x,_bld] spawn UPSMON_UnitWatchDir;
+ _bldpos1 set [_id2,"deletethis"];
+ _bldpos1 = _bldpos1 - ["deletethis"];
+ _units = _units - [_x];
+ };
+ };
+ } foreach _movein;
+ };
+ };
+ _blds2 pushback [_bld,[_bldpos1,_bldpos2]];
+} foreach _blds;
+
+_blds = _blds2;
+
+If (count _units > 0) then
+{
+ _i = _i +1;
+ _units = [_units,_blds,_i] call UPSMON_SpawninBuildings;
+};
+
+_units
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_moveBuildings.sqf b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_moveBuildings.sqf
new file mode 100644
index 0000000..0d05887
--- /dev/null
+++ b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_moveBuildings.sqf
@@ -0,0 +1,105 @@
+/****************************************************************
+File: UPSMON_moveBuildings.sqf
+Author: Monsada
+
+Description:
+
+Parameter(s):
+ <--- array of units
+ <--- array of buildingsinfo [_bld,pos]
+ <--- must patrol or not
+Returns:
+ nothing
+****************************************************************/
+
+private ["_wait","_minpos","_units","_blds","_blds2","_UPSMON_Bld_ruins","_i","_arraybld","_bld","_bldpos1","_bldpos2","_cntobjs1","_movein","_result","_altura","_id2"];
+
+_wait = 60;
+_minpos = 2;
+
+_units = _this select 0;
+_blds = _this select 1;
+_i = 0;
+if ((count _this) > 2) then {_wait = _this select 2;};
+if ((count _this) > 3) then {_i = _this select 3;};
+
+if (_i > 7) exitwith {_units};
+
+_UPSMON_Bld_ruins = ["Land_Unfinished_Building_01_F","Land_Unfinished_Building_02_F","Land_d_Stone_HouseBig_V1_F","Land_d_Stone_Shed_V1_F","Land_u_House_Small_02_V1_F","Land_i_Stone_HouseBig_V1_F","Land_u_Addon_02_V1_F","Land_Cargo_Patrol_V1_F"];
+_blds2 = [];
+if (UPSMON_Debug>0) then {diag_log format["MON_moveBuildings _units=%1 _blds=%2",count _units, count _blds];};
+
+
+{
+ _arraybld = _x;
+ _bld = _x select 0;
+ _bldpos1 = (_x select 1) select 0;
+ _bldpos2 = (_x select 1) select 1;
+
+ If (count _bldpos1 < _minpos) then {_bldpos1 = (_x select 1) select 1;_bldpos2 = _bldpos1;};
+ if ("deletethis" in _bldpos1) then {_bldpos1 = _bldpos1 - ["deletethis"];};
+
+ if ( count _bldpos1 >= _minpos ) then
+ {
+ _cntobjs1 = 1;
+ _movein = [];
+ if (count _bldpos1 >= 3) then { _cntobjs1 = round(random 1) + 2;};
+ if (count _bldpos1 >= 8) then { _cntobjs1 = round(random 2) + 6;};
+ if (count _bldpos1 >= 10) then {_cntobjs1 = round(random 3) + 7;};
+
+ {
+ if (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (_cntobjs1 > 0) then
+ {
+ _movein pushback _x;
+ _cntobjs1 = _cntobjs1 - 1;
+ };
+ };
+ };
+ };
+ } foreach _units;
+
+ if (count _movein > 0) then
+ {
+ {
+ If (count _bldpos1 > 0) then
+ {
+ _result = [_bldpos1] call UPSMON_Checkfreebldpos;
+ If (count _result > 0) then
+ {
+ _altura = _result select 0;
+ _id2 = _result select 1;
+ [_x,_bld,_altura,_wait,_arraybld] spawn UPSMON_movetoBuilding;
+ _bldpos1 set [_id2,"deletethis"];
+ _bldpos1 = _bldpos1 - ["deletethis"];
+ _units = _units - [_x];
+ };
+ };
+ } foreach _movein;
+ };
+ };
+ _blds2 pushback [_bld,[_bldpos1,_bldpos2]];
+} foreach _blds;
+_blds = _blds2;
+
+
+if (count _units > 0) then
+{
+ _i = _i + 1;
+ _units = [_units,_blds,_wait,_i] call UPSMON_moveBuildings;
+};
+
+if (_i <= 1) then
+{
+ {
+ _bld = _x select 0;
+ If (!(typeof _bld in _UPSMON_Bld_ruins)) then {[_bld] execvm "Scripts\UPSMON\COMMON\UPSMON_CloseDoor.sqf";};
+ } foreach _blds;
+};
+
+_units
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_moveNearestBuildings.sqf b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_moveNearestBuildings.sqf
new file mode 100644
index 0000000..fe09ea8
--- /dev/null
+++ b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_moveNearestBuildings.sqf
@@ -0,0 +1,41 @@
+/****************************************************************
+File: UPSMON_moveNearestBuildings.sqf
+Author: Monsada
+
+Description:
+ move all units of squad to the nearest building
+
+Parameter(s):
+ <--- leader
+ <--- distance to search buildings (optional, 25 by default)
+ <--- must patrol or not
+Returns:
+ Buildings array
+****************************************************************/
+
+private ["_distance","_wait","_npc","_units","_blds"];
+
+_distance = 30;
+_wait=60;
+
+_npc = _this select 0;
+_units = _this select 1;
+_distance = _this select 2;
+if ((count _this) > 3) then {_wait = _this select 3;};
+
+_blds = [];
+
+_units = [_units] call UPSMON_getunits;
+
+if (UPSMON_Debug>0) then {diag_log format["UPSMON_moveNearestBuildings _units=%1 _blds=%2",_units,_blds];};
+if (count _units == 0) exitwith {_units};
+
+//Obtenemos los edificios cercanos al lider
+_blds = [getposATL _npc,"RANDOMA",_distance,"",false] call UPSMON_GetNearestBuildings;
+
+if (count _blds==0) exitwith {_units};
+
+//Movemos a la unidades a los edificios cercanos.
+_units = [_units,_blds,_wait] call UPSMON_moveBuildings;
+
+_units
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_movetoBuilding.sqf b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_movetoBuilding.sqf
new file mode 100644
index 0000000..b3e0a40
--- /dev/null
+++ b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_movetoBuilding.sqf
@@ -0,0 +1,94 @@
+/****************************************************************
+File: UPSMON_movetoBuilding.sqf
+Author: Monsada
+
+Description:
+ move a unit to a position in a building
+
+Parameter(s):
+ <--- soldier
+ <--- building
+ <--- building position
+ <--- time to wait in position
+Returns:
+ nothing
+****************************************************************/
+
+private ["_wait","_retry","_npc","_bld","_altura","_blds","_inbuilding","_result"];
+
+_wait = 60; // 60
+_retry = false;
+
+_npc = _this select 0;
+_bld = _this select 1;
+_altura = _this select 2;
+_blds = [];
+_retrytime = 0;
+
+if ((count _this) > 3) then {_wait = _this select 3;};
+if ((count _this) > 4) then {_blds = _this select 4;};
+if ((count _this) > 5) then {_retrytime = _this select 5;};
+
+//Si está en un vehiculo ignoramos la orden
+if (vehicle _npc != _npc || !alive _npc || !canmove _npc) exitwith{};
+
+//Si ya está en un edificio ignoramos la orden
+_inbuilding = _npc getvariable ["UPSMON_inbuilding",false];
+if (_inbuilding || _retrytime >= 3) exitwith{};
+
+dostop _npc;
+_npc domove _altura;
+_npc commandMove _altura;
+_npc setDestination [_altura, "LEADER PLANNED", true];
+_npc forcespeed 100;
+_npc setVariable ["UPSMON_inbuilding", _inbuilding, false];
+_npc setvariable ["UPSMON_buildingpos", nil, false];
+
+_timeout = time + ((_altura vectordistance (getposATL _npc))*1.4);
+//if (UPSMON_Debug>0) then {diag_log format["%4|_bld=%1 | %2 | %3",typeof _bld, _npc, typeof _npc ,_altura];};
+
+waituntil {!alive _npc || !canmove _npc || ((getposATL _npc) vectordistance _altura <= 1) || _timeout <= time || (_npc getvariable ["UPSMON_SUPSTATUS",""] != "")};
+
+
+If (!alive _npc || !canmove _npc || (_npc getvariable ["UPSMON_SUPSTATUS",""] != "")) exitwith {};
+
+if ((getposATL _npc) distance _altura <= 1) then
+{
+ If (alive _npc) then
+ {
+ If (canmove _npc) then
+ {
+ _npc forcespeed -1;
+ _npc setvariable ["UPSMON_buildingpos",[_bld,_altura], false];
+ _npc setVariable ["UPSMON_inbuilding", true, false];
+ Dostop _npc;
+ If (_wait >= 8999) then {_npc disableAI "TARGET"};
+ sleep 1;
+ [_npc,getdir _npc,_bld] spawn UPSMON_UnitWatchDir;
+ if (!isNil "tpwcas_running") then {_npc setvariable ["tpwcas_cover", 2];};
+ };
+ };
+};
+
+//_npc distance _altura > 1
+if ((getposATL _npc) vectordistance _altura > 1) then {_retry = true};
+
+_npc setVariable ["UPSMON_inbuilding", false, false];
+
+//hint format ["Unit has moved to %1 %2 %3 Retry: %4",_altura,_npc distance _altura <= 0.5,_timeout < time,_retry];
+//Down one position.
+if (_retry) then
+{
+ {
+ If (count _x > 0) then
+ {
+ _result = [_x] call UPSMON_Checkfreebldpos;
+ If (count _result > 0) exitwith
+ {
+ _altura = _result select 0;
+ _retrytime = _retrytime + 1;
+ [_npc,_bld,_altura,_wait,_blds,_retrytime] spawn UPSMON_movetoBuilding;
+ };
+ };
+ } foreach (_blds select 1);
+};
diff --git a/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_patrolBuilding.sqf b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_patrolBuilding.sqf
new file mode 100644
index 0000000..e70a4b5
--- /dev/null
+++ b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_patrolBuilding.sqf
@@ -0,0 +1,72 @@
+/****************************************************************
+File: UPSMON_patrolBuilding.sqf
+Author: Monsada
+
+Description:
+ unit will patrol in building
+
+Parameter(s):
+ <--- soldier to move
+ <--- building to patrol
+ <--- positions of building (optional)
+Returns:
+ nothing
+****************************************************************/
+
+private ["_units","_bldpos","_grp","_movein","_currpos","_attackpos","_unit","_patrolto","_time"];
+
+_units = _this select 0;
+_bldpos = _this select 1;
+_grp = _this select 2;
+_time = _this select 3;
+
+_grp setVariable ["UPSMON_inbuilding",true];
+
+_units = [_units] call UPSMON_Getunits;
+_movein = [];
+
+_currpos = getposATL (_units select 0);
+_attackpos = _currpos;
+
+If ("deletethis" in _bldpos) then {_bldpos = _bldpos - ["deletethis"]};
+If (count _bldpos > 0) then
+{
+ _attackpos = _bldpos select 0;
+};
+
+{
+ _unit = _x;
+ If (alive _unit) then
+ {
+ If (vehicle _unit == _unit) then
+ {
+ If (Unitready _unit) then
+ {
+ If ("deletethis" in _bldpos) then {_bldpos = _bldpos - ["deletethis"]};
+ If (count _bldpos > 0) then
+ {
+ _patrolto = _bldpos select 0;
+ _bldpos set [0,"deletethis"];
+ _bldpos = _bldpos - ["deletethis"];
+ Dostop _unit;
+ _unit domove _patrolto;
+ _unit setdestination [_patrolto,"LEADER PLANNED",true];
+ _movein pushback _unit;
+ };
+ };
+ };
+ };
+} foreach _units;
+
+sleep _time;
+
+_time = (((_attackpos vectordistance _currpos)*1.2) + 5);
+
+If (_grp getvariable ["UPSMON_Grpmission",""] != "PATROLINBLD" || _grp getvariable ["UPSMON_Grpmission",""] != "ASSAULT") exitwith {_grp setVariable ["UPSMON_inbuilding",false];};
+
+If (count _bldpos > 0 && count _units > 0) then
+{
+ [_units,_bldpos,_grp,_time] call UPSMON_patrolBuilding;
+};
+
+_grp setVariable ["UPSMON_inbuilding",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_unitdefend.sqf b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_unitdefend.sqf
new file mode 100644
index 0000000..d21c8de
--- /dev/null
+++ b/scripts/UPSMON/MODULES/FORTIFY/Fnc/UPSMON_unitdefend.sqf
@@ -0,0 +1,123 @@
+/****************************************************************
+File: UPSMON_unitdefend.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- group
+ <--- Distance between group and nearest enemy
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_dist","_supstatus","_unit","_inbuilding","_NearestEnemy","_cansee","_poseni","_distance","_unitdirchk","_watch","_abx","_aby","_abz","_vec","_result","_bld","_bldpos","_pos"];
+
+_grp = _this select 0;
+_dist = _this select 1;
+
+_grp setvariable ["UPSMON_Checkbuild",true];
+{
+ _unit = _x;
+ if (alive _unit && !captive _unit) then
+ {
+ If (vehicle _unit == _unit) then
+ {
+ _inbuilding = [_unit] call UPSMON_Inbuilding;
+ If (_inbuilding) then
+ {
+ _NearestEnemy = _unit findNearestEnemy _unit;
+ _supstatus = _unit getvariable ["UPSMON_SUPSTATUS",""];
+ if (_supstatus != "SUPRESSED") then
+ {
+ _cansee = true;
+ if (stance _unit in ["CROUCH","PRONE"]) then {_unit setunitpos "MIDDLE";_cansee = [_unit,getdir _unit,10] call UPSMON_CanSee;};
+ if (!_cansee) then {_unit setunitpos "UP";};
+ };
+ if (!IsNull _NearestEnemy && alive _NearestEnemy) then
+ {
+ _poseni = getposATL _NearestEnemy;
+ _distance = [getposATL _unit,_poseni] call UPSMON_distancePosSqr;
+ If (_distance <= 300) then
+ {
+ _haslos = [_unit,_NearestEnemy,300,130] call UPSMON_Haslos;
+ If (_haslos) then
+ {
+ [_unit,_NearestEnemy] call UPSMON_Dowatch;
+ sleep 0.5;
+ _unit dotarget ObjNull;
+ _unit dotarget _NearestEnemy;
+ }
+ else
+ {
+ if (_distance < 100 && (_supstatus != "SUPRESSED" || _supstatus != "UNDERFIRE")) then
+ {
+ _unitdirchk = _unit getvariable ["UPSMON_unitdir",[]];
+ If (count _unitdirchk > 0) then
+ {
+ _watch = [];
+ If (_dist <= 150 && random 100 < 60) then {_watch = (_unit getvariable "UPSMON_unitdir") select 1} else {_watch = (_unit getvariable "UPSMON_unitdir") select 0};
+ _posATL = getPosATL _unit;
+ If (count _watch > 0) then
+ {
+ _abx = (_watch select 0) - (_posATL select 0);
+ _aby = (_watch select 1) - (_posATL select 1);
+ _abz = (_watch select 2) - (_posATL select 2);
+
+ _vec = [_abx, _aby, _abz];
+
+ // Main body of the function;
+ _unit setdir 0;
+ _unit setVectorDir _vec;
+
+ sleep 0.1;
+ _unit dowatch ObjNull;
+ _unit dowatch _watch;
+ sleep 0.5;
+ }
+ else
+ {
+ If (!_cansee) then {[_unit,getdir _unit,false] spawn UPSMON_WillSee;};
+ };
+ };
+ }
+ else
+ {
+ _result = _unit getvariable ["UPSMON_buildingpos",[]];
+ If (count _result > 0 && random 100 < 30) then
+ {
+ _bld = _result select 0;
+ _allpos = [_bld,"RANDOMA"] call UPSMON_SortOutBldpos;
+ _allpos = _allpos select 0;
+ _bldpos = [];
+ {
+ _pos = _x;
+ If (count (_pos nearEntities ["CAManBase",1]) == 0) then
+ {
+ If ([_pos,_poseni] call UPSMON_los) then
+ {
+ _bldpos pushback _pos;
+ };
+ };
+ } foreach _allpos;
+
+ if (count _bldpos > 0) then
+ {
+ _bldpos = _bldpos select 0;
+ dostop _unit;
+ _unit domove _bldpos;
+ _unit commandMove _bldpos;
+ _unit setDestination [_bldpos, "LEADER PLANNED", true];
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ sleep 0.01;
+}foreach units _grp;
+sleep 15;
+_grp setvariable ["UPSMON_Checkbuild",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/FORTIFY/Init.sqf b/scripts/UPSMON/MODULES/FORTIFY/Init.sqf
new file mode 100644
index 0000000..b3e7502
--- /dev/null
+++ b/scripts/UPSMON/MODULES/FORTIFY/Init.sqf
@@ -0,0 +1,12 @@
+
+UPSMON_SpawninBuildings = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\FORTIFY\fnc\UPSMON_SpawninBuildings.sqf";
+
+UPSMON_moveBuildings = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\FORTIFY\fnc\UPSMON_moveBuildings.sqf";
+UPSMON_moveNearestBuildings = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\FORTIFY\fnc\UPSMON_moveNearestBuildings.sqf";
+UPSMON_movetoBuilding = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\FORTIFY\fnc\UPSMON_movetoBuilding.sqf";
+
+UPSMON_unitdefend = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\FORTIFY\fnc\UPSMON_unitdefend.sqf";
+UPSMON_Fortify = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\FORTIFY\fnc\UPSMON_Fortify.sqf";
+
+UPSMON_patrolBuilding = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\FORTIFY\fnc\UPSMON_patrolBuilding.sqf";
+
diff --git a/scripts/UPSMON/MODULES/Init.sqf b/scripts/UPSMON/MODULES/Init.sqf
new file mode 100644
index 0000000..be6e019
--- /dev/null
+++ b/scripts/UPSMON/MODULES/Init.sqf
@@ -0,0 +1,5 @@
+
+UPSMON_CLONES = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\UPSMON_CLONES.sqf";
+
+UPSMON_RESPAWN = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\UPSMON_RESPAWN.sqf";
+UPSMON_SPAWN = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\UPSMON_SPAWN.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/Init.sqf
new file mode 100644
index 0000000..886cb39
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/Init.sqf
@@ -0,0 +1,5 @@
+
+UPSMON_DOASSAULT = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_ASSAULT\fnc\UPSMON_DOASSAULT.sqf";
+UPSMON_PLANASSLT = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_ASSAULT\fnc\UPSMON_PLANASSLT.sqf";
+
+UPSMON_Assltbld = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_ASSAULT\fnc\UPSMON_Assltbld.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_AssltBld.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_AssltBld.sqf
new file mode 100644
index 0000000..df06246
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_AssltBld.sqf
@@ -0,0 +1,81 @@
+/****************************************************************
+File: UPSMON_Assltbld.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a patrol waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- attack position
+ <--- Type of group
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_target","_attackpos","_currpos","_assignedvehicles","_capacityofgrp","_bld","_teams","_teamsupport","_teamasslt","_time"];
+
+_grp = _this select 0;
+_target = _this select 1;
+_currpos = _this select 2;
+
+_assignedvehicles = _grp getvariable ["UPSMON_Assignedvehicle",[]];
+_capacityofgrp = _grp getvariable ["UPSMON_GroupCapacity",[]];
+_attackpos = getposATL _target;
+
+_bld = [_attackpos,"RANDOMA",20,"",false] call UPSMON_GetNearestBuilding;
+if (count _bld > 0) then
+{
+ _bldpos = (_bld select 1) select 0;
+
+ [_grp,_attackpos,_currpos] spawn UPSMON_SetSatchel;
+ sleep 1;
+ If (!(_grp getvariable ["UPSMON_GrpinAction",false])) then
+ {
+ If ("at3" in _capacityofgrp) then
+ {
+ [_grp,_assignedvehicles,_bld select 0] call UPSMON_FireGun;
+ };
+ };
+
+ If (!(_grp getvariable ["UPSMON_GrpinAction",false])) then
+ {
+ _teams = [_grp] call UPSMON_composeteam;
+ If (count _teams > 0) then
+ {
+ _grp setvariable ["UPSMON_GrpinAction",true];
+ _teamsupport = _teams select 0;
+ _teamasslt = _teams select 1;
+ if (count _teamasslt > 0) then
+ {
+ {
+ If (alive _x) then
+ {
+ Dostop _x;
+ _x suppressfor 100;
+ };
+ } foreach _teamsupport;
+
+ _time = ((_attackpos vectordistance _currpos)*1.4);
+ [_teamasslt,_bldpos,_grp,_time] call UPSMON_patrolbuilding;
+
+ if (({alive _x} count (units _grp)) > 0) then
+ {
+ {
+ If (alive _x) then
+ {
+ If (_x != (leader _grp)) then
+ {
+ _x domove (getposATL (leader _grp));
+ _x dofollow (leader _grp);
+ _x suppressfor 10;
+ };
+ };
+ } foreach units _grp;
+ };
+ };
+ };
+ };
+};
+
+_grp setvariable ["UPSMON_GrpinAction",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_Assltposition.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_Assltposition.sqf
new file mode 100644
index 0000000..53b3eb5
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_Assltposition.sqf
@@ -0,0 +1,53 @@
+/****************************************************************
+File: UPSMON_Assltbld.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a patrol waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- attack position
+ <--- Type of group
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_target","_attackpos","_currpos","_assignedvehicles","_capacityofgrp","_bld","_teams","_teamsupport","_teamasslt","_time"];
+
+_grp = _this select 0;
+_targetpos = _this select 1;
+_currpos = _this select 2;
+
+If (!(_grp getvariable ["UPSMON_GrpinAction",false])) then
+{
+ _teams = [_grp] call UPSMON_composeteam;
+ If (count _teams > 0) then
+ {
+ _grp setvariable ["UPSMON_GrpinAction",true];
+ _teamsupport = _teams select 0;
+ _teamasslt = _teams select 1;
+
+ _dir =[_currpos,_targetpos] call BIS_fnc_DirTo;
+
+ If (count _teamasslt > 0) then
+ {
+ {
+ If (alive _x) then
+ {
+ Dostop _x;
+ [_x,_targetpos,2] call UPSMON_DOwatch;
+ _pos = [_targetpos,_dir] call UPSMON_overwatch;
+ _x domove _pos;
+ _x suppressfor 100;
+ };
+ } foreach _teamsupport;
+
+ // angle from unit to target
+ _targetpos = [_targetpos,_dir] call UPSMON_overwatch;
+ _teamasslt domove _targetpos;
+ };
+ };
+};
+
+_grp setvariable ["UPSMON_GrpinAction",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_DOASSAULT.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_DOASSAULT.sqf
new file mode 100644
index 0000000..66da3a0
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_DOASSAULT.sqf
@@ -0,0 +1,46 @@
+/****************************************************************
+File: UPSMON_DOASSAULT.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a patrol waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- attack position
+ <--- Type of group
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_attackpos","_typeofgrp","_radius","_speed","_dist","_combatmode"];
+
+_grp = _this select 0;
+_attackpos = _this select 1;
+_typeofgrp = _this select 2;
+_dist = _this select 3;
+
+_grp setvariable ["UPSMON_searchingpos",true];
+
+_radius = 20;
+_speed = "LIMITED";
+_combatmode = "YELLOW";
+
+If ("air" in _typeofgrp) then
+{
+ _radius = 400;
+ _speed = "FULL";
+ _combatmode = "RED";
+}
+else
+{
+ If (_dist <= 100) then
+ {
+ _combatmode = "RED";
+ };
+};
+
+[_grp,_attackpos,"SAD","LINE",_speed,"COMBAT",_combatmode,_radius] call UPSMON_DocreateWP;
+_grp setvariable ["UPSMON_targetPos",_attackpos];
+_grp setvariable ["UPSMON_Lastattackpos",_attackpos];
+_grp setvariable ["UPSMON_searchingpos",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_PLANASSLT.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_PLANASSLT.sqf
new file mode 100644
index 0000000..acc5f00
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_ASSAULT/fnc/UPSMON_PLANASSLT.sqf
@@ -0,0 +1,44 @@
+/****************************************************************
+File: UPSMON_PLANASSLT.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a patrol waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- attack position
+ <--- last attack position
+ <--- Type of group
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_attackpos","_lastattackpos","_typeofgrp","_time","_attackdist"];
+
+_grp = _this select 0;
+_attackpos = _this select 1;
+_lastattackpos = _this select 2;
+_typeofgrp = _this select 3;
+_dist = _this select 4;
+
+_grp setvariable ["UPSMON_Grpmission","ASSAULT"];
+
+If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+{
+ _attackdist = 1000;
+ If (count _lastattackpos > 0) then
+ {
+ _attackdist = ([_lastattackpos,_attackpos] call UPSMON_distancePosSqr);
+ };
+
+ If (_attackdist > 50 || count(waypoints _grp) == 0 || (_grp getvariable ["UPSMON_LastGrpmission",""] != "ASSAULT")) then
+ {
+ If (_grp getvariable ["UPSMON_TIMEORDER",time] <= time) then
+ {
+ [_grp,_attackPos,_typeofgrp,_dist] spawn UPSMON_DOASSAULT;
+ _time = time + 10;
+ _grp setvariable ["UPSMON_TIMEORDER",_time];
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/Init.sqf
new file mode 100644
index 0000000..cc041f1
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/Init.sqf
@@ -0,0 +1,3 @@
+
+UPSMON_DODEFEND = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_DEFEND\fnc\UPSMON_DODEFEND.sqf";
+UPSMON_SrchGuardPos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_DEFEND\fnc\UPSMON_SrchGuardPos.sqf";
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/fnc/UPSMON_DODEFEND.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/fnc/UPSMON_DODEFEND.sqf
new file mode 100644
index 0000000..4655293
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/fnc/UPSMON_DODEFEND.sqf
@@ -0,0 +1,53 @@
+/****************************************************************
+File: UPSMON_DODEFEND.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a defense waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- distance between group and enemy
+ <--- Target
+ <--- Id of the group
+ <--- position of the target
+ <--- Supressed (boolean)
+
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_dist","_target","_supressed","_terrainscan","_wptype","_wpformation","_speedmode","_Behaviour","_npc","_targetPos","_CombatMode"];
+
+_grp = _this select 0;
+_dist = _this select 1;
+_target = _this select 2;
+_supstatus = _this select 3;
+_terrainscan = _this select 4;
+
+_npc = leader _grp;
+_targetPos = getposATL _npc;
+
+_wptype = "HOLD";
+_wpformation = "LINE";
+_speedmode = "LIMITED";
+_Behaviour = "STEALTH";
+_CombatMode = "YELLOW";
+
+If (IsNull _target) then {_wpformation = "DIAMOND";};
+If (_supstatus != "SUPRESSED") then {_Behaviour = "COMBAT";_speedmode = "NORMAL";};
+
+if ((_terrainscan select 0) == "meadow" && (_terrainscan select 1) < 100 && _supstatus != "SUPRESSED") then
+{
+ _targetPos = [_targetPos,[0,360],100] call UPSMON_SrchGuardPos;
+ _nosmoke = [_grp] call UPSMON_NOSMOKE;
+ If (!_nosmoke) then {[units _grp,getposATL _target] spawn UPSMON_CreateSmokeCover;};
+ [_grp,_targetPos,"MOVE","STAG COLUMN","FULL","COMBAT",_CombatMode,1] call UPSMON_DocreateWP;
+ [_grp,_targetPos,_wptype,_wpformation,_speedmode,_Behaviour,_CombatMode,1] call UPSMON_DoaddWP;
+}
+else
+{
+ [_grp,_targetpos,_wptype,_wpformation,_speedmode,_Behaviour,_CombatMode,1] call UPSMON_DocreateWP;
+};
+
+_grp setvariable ["UPSMON_targetPos",_targetPos];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/fnc/UPSMON_SrchGuardPos.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/fnc/UPSMON_SrchGuardPos.sqf
new file mode 100644
index 0000000..c63f1e8
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_DEFEND/fnc/UPSMON_SrchGuardPos.sqf
@@ -0,0 +1,45 @@
+/****************************************************************
+File: UPSMON_SrchGuardPos.sqf
+Author: Azroul13
+
+Description:
+ Search a covered position to defend
+
+Parameter(s):
+ <--- leader of the group
+ <--- enemy position
+ <--- Direction to search
+ <--- Distance where to begin the search
+
+Returns:
+ Position
+****************************************************************/
+
+private ["_currpos","_direction","_dist","_targetPosTemp","_pool","_distmin","_i","_targetPosTemp"];
+
+_currpos = _this select 0;
+_direction = _this select 1;
+_dist = _this select 2;
+
+_guardPos = [];
+_targetPosTemp = [];
+_pool = [];
+_distmin = 5;
+_i = 0;
+
+while {count _guardPos == 0 && _i < 30} do
+{
+ _i = _i + 1;
+ _targetPosTemp = [_currpos,[_dist,_dist + 100],_direction,0,[0,50],_distmin] call UPSMON_pos;
+ if (!(surfaceIsWater _targetPosTemp)) then
+ {
+ _terrainscan = _targetPosTemp call UPSMON_sample_terrain;
+ If ((_terrainscan select 0) == "inhabited" || (_terrainscan select 0) == "forest") then
+ {
+ _guardPos = _targetPosTemp;
+ };
+ };
+};
+
+if (count _guardPos == 0) then {_guardPos = _currpos;};
+_guardPos;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/Init.sqf
new file mode 100644
index 0000000..f0676c6
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/Init.sqf
@@ -0,0 +1,5 @@
+
+UPSMON_DOFLANK = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_FLANK\fnc\UPSMON_DOFLANK.sqf";
+UPSMON_PLANFLANK = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_FLANK\fnc\UPSMON_PLANFLANK.sqf";
+UPSMON_SrchFlankPos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_FLANK\fnc\UPSMON_SrchFlankPos.sqf";
+UPSMON_SrchFlankPosforboat = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_FLANK\fnc\UPSMON_SrchFlankPosforboat.sqf";
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_DOFLANK.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_DOFLANK.sqf
new file mode 100644
index 0000000..e58b2f1
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_DOFLANK.sqf
@@ -0,0 +1,162 @@
+/****************************************************************
+File: UPSMON_DOATTACK.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a combat waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- position of the target
+ <--- distance between group and enemy
+ <--- Id of the group
+ <--- Nofollow parameters.
+ <--- Group type (Array: "Air","Tank","car","ship","infantry")
+ <--- Terrain around the leader ("meadow","forest","urban")
+ <--- Areamarker
+ <--- Group side
+ <--- Do unit can see the enemy position
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_npc","_attackPos","_dist","_gothit","_closeenough","_dir1","_dir2","_wptype","_wpformation","_result","_targetPos","_speedmode","_Behaviour","_grpid","_nofollow","_targetdist","_areamarker","_centerpos","_centerX","_centerY","_areadir","_areasize","_RangeX","_RangeY"];
+
+_grp = _this select 0;
+_attackPos = _this select 1;
+_dist = _this select 2;
+_typeofgrp = _this select 3;
+_terrainscan = _this select 4;
+_areamarker = _this select 5;
+_haslos = _this select 6;
+
+_npc = leader _grp;
+_currpos = getposATL _npc;
+_side = side _grp;
+_grpid = _grp getvariable ["UPSMON_Grpid",0];
+_water = 0;
+
+_grp setvariable ["UPSMON_searchingpos",true];
+
+_closeenough = UPSMON_closeenough;
+// get position of spotted unit in player group, and watch that spot
+
+// angle from unit to target
+_dir =[_attackPos,getposATL _npc] call BIS_fnc_DirTo;
+
+
+//Establish the type of waypoint
+//DESTROY has worse behavior with and sometimes do not move
+_wptype = "MOVE";
+_wpformation = "WEDGE";
+_CombatMode = "YELLOW";
+_radius = 1;
+
+_attackPos = [_attackPos select 0,_attackPos select 1,0];
+
+//Set speed and combat mode
+_rnd = random 100;
+If (!("ship" in _typeofgrp)) then
+{
+
+ _targetPos = [_currpos,_dir,_attackPos,_side,_typeofgrp,_grpid] call UPSMON_SrchFlankPos;
+
+
+ if ( _dist <= _closeenough ) then
+ {
+ //If we are so close we prioritize discretion fire
+ if ( _dist <= _closeenough/2 ) then
+ {
+
+ //Close combat modeo
+ _wpformation = "LINE";
+ _speedmode = "LIMITED";
+ If (("armed" in _typeofgrp) || ("tank" in _typeofgrp)) then {_wpformation = "VEE";};
+
+ // _rnd < 80
+ if (morale _npc > 0) then
+ {
+ _Behaviour = "COMBAT";
+ }
+ else
+ {
+ _Behaviour = "STEALTH"; // ToDo check impact "STEALTH";
+ };
+
+ }
+ else
+ {
+ //If the troop has the role of not moving tend to keep the position
+ _Behaviour = "COMBAT";
+ _speedmode = "NORMAL";
+ If (("armed" in _typeofgrp) || ("tank" in _typeofgrp)) then {_wpformation = "WEDGE";_speedmode = "LIMITED";};
+ };
+ }
+ else
+ {
+ if (_dist <= 1000) then
+ {
+ If (_haslos) then
+ {
+ _speedmode = "LIMITED";
+ _Behaviour = "COMBAT";
+ }
+ else
+ {
+ _speedmode = "NORMAL";
+ _Behaviour = "AWARE";
+ };
+ }
+ else
+ {
+ //Platoon from the target must move fast and to the point
+ _Behaviour = "SAFE";
+ _speedmode = "FULL";
+ _wpformation = "COLUMN";
+ };
+ };
+}
+else
+{
+ _water = 2;
+ _Behaviour = "COMBAT";
+ _speedmode = "FULL";
+
+ _targetPos = [_currpos,_dir,_attackPos,_side,_grpid] call UPSMON_SrchFlankPosforboat;
+ If (!surfaceiswater _targetpos) then {_targetpos = _currpos;};
+};
+
+_targetPos = [_targetPos select 0,_targetPos select 1,0];
+
+if (_grp getvariable ["UPSMON_NOFOLLOW",false]) then
+{
+ If !([_targetPos,_areamarker] call UPSMON_pos_fnc_isBlacklisted) then
+ {
+ _wptype = "HOLD";
+ _speedmode = "FULL";
+ _Behaviour = "AWARE";
+ _targetPos = _currpos;
+ };
+};
+
+If ((_terrainscan select 0) == "meadow") then
+{
+ _speedmode = "FULL";
+};
+
+If (UPSMON_Debug > 0) then
+{
+ player sidechat format ["%1 DOFLANK",_grp getvariable ["UPSMON_Grpid",0]];
+ diag_log format ["%1 DOFLANK",_grp getvariable ["UPSMON_Grpid",0]];
+ diag_log format ["targetpos:%1",_targetPos]
+};
+
+_grp setvariable ["UPSMON_targetPos",_targetPos];
+_grp setvariable ["UPSMON_Lastattackpos",_attackpos];
+
+[_grp,_targetpos,_wptype,_wpformation,_speedmode,_Behaviour,_CombatMode,_radius] call UPSMON_DocreateWP;
+
+_timeontarget = time + (1.4 *(_currpos vectordistance _targetpos));
+_grp setvariable ["UPSMON_TIMEONTARGET",_timeontarget];
+
+_grp setvariable ["UPSMON_searchingpos",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_PLANFLANK.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_PLANFLANK.sqf
new file mode 100644
index 0000000..2366579
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_PLANFLANK.sqf
@@ -0,0 +1,45 @@
+/****************************************************************
+File: UPSMON_DOATTACK.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a combat waypoint to the group
+
+Parameter(s):
+
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_attackpos","_lastattackpos","_dist","_typeofgrp","_terrainscan","_areamarker","_haslos","_attackdist","_timeorder"];
+
+_grp = _this select 0;
+_attackpos = _this select 1;
+_lastattackpos = _this select 2;
+_dist = _this select 3;
+_typeofgrp = _this select 4;
+_terrainscan = _this select 5;
+_areamarker = _this select 6;
+_haslos = _this select 7;
+_targetpos = _this select 8;
+
+_attackdist = 1000;
+_grp setvariable ["UPSMON_Grpmission","FLANK"];
+
+If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+{
+ If (count _lastattackpos > 0) then
+ {
+ _attackdist = ([_lastattackpos,_attackpos] call UPSMON_distancePosSqr);
+ };
+
+ If (_attackdist > 50 || count(waypoints _grp) == 0 || Unitready (leader _grp) || moveToCompleted (leader _grp) || (_grp getvariable ["UPSMON_TIMEONTARGET",time] <= time) || _targetdist <= 50) then
+ {
+ If (_grp getvariable ["UPSMON_TIMEORDER",time] <= time) then
+ {
+ [_grp,_attackPos,_dist,_typeofgrp,_terrainscan,_areamarker,_haslos] spawn UPSMON_DOFLANK;
+ _timeorder = time + 10;
+ _grp setvariable ["UPSMON_TIMEORDER",_timeorder];
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_SrchFlankPos.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_SrchFlankPos.sqf
new file mode 100644
index 0000000..ad31165
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_SrchFlankPos.sqf
@@ -0,0 +1,129 @@
+/****************************************************************
+File: UPSMON_SrchFlankPos.sqf
+Author: Azroul13
+
+Description:
+ Search Flank position
+
+Parameter(s):
+ <--- Leader position
+ <--- Direction where to search
+ <--- enemy position
+ <--- Side of group
+ <--- Group type (Array: "Air","Tank","car","ship","infantry")
+ <--- Terrain around the leader ("meadow","forest","urban")
+ <--- Id of the group
+Returns:
+ Position
+****************************************************************/
+
+private ["_npcpos","_dir2","_targetPos","_side","_typeofgroup","_dist","_flankAngle","_scan","_points","_flankdist","_roadchk","_distmin","_pool","_targetPosTemp","_terrainscan","_los_ok","_i","_final","_grp"];
+
+_npcpos = _this select 0;
+_dir2 = _this select 1;
+_targetPos = _this select 2;
+_side = _this select 3;
+_typeofgrp = _this select 4;
+_grpid = _this select 5;
+_distance = round ([_npcpos,_targetpos] call UPSMON_distancePosSqr);
+//_distance = _npcpos vectordistance _targetpos;
+
+_flankAngle = 45;
+//Establecemos una distancia de flanqueo
+_flankdist = _distance/2;
+_dist = 50;
+_distmin = 1;
+_roadchk = [0,50];
+If ("car" in _typeofgrp || "tank" in _typeofgrp) then
+{
+ If ("car" in _typeofgrp) then
+ {
+ _roadchk = [1,50];
+ };
+ _distmin = 10;
+ _flankdist = ((random 0.2)+1)*(_distance/2);
+ _dist = 100;
+};
+
+//La distancia de flanqueo no puede ser superior a la distancia del objetivo o nos pordrÃa pillar por la espalda
+_flankdist = if ((_flankdist) > _distance) then {_dist + 50} else {_flankdist};
+_flankdist = if ((_flankdist) < _dist) then {_dist} else {_flankdist};
+_pool = [];
+
+_i = 0;
+_scan = true;
+
+while {_scan} do
+{
+ _i = _i + 1;
+ _targetPosTemp = [_npcpos,[_dist,_flankdist],[_dir2 +100,_dir2+200],0,_roadchk,_distmin] call UPSMON_pos;
+ If (!surfaceIsWater _targetPosTemp) then
+ {
+ _targetPosTemp = [_targetPosTemp select 0,_targetPosTemp select 1,0];
+ _points = 0;
+ If ("car" in _typeofgrp || "tank" in _typeofgrp) then
+ {
+ If (isOnRoad _targetPosTemp) then
+ {
+ _points = _points +20;
+ };
+ _value = [[_targetPosTemp select 0, _targetPosTemp select 1,0],1,1] call UPSMON_TerraCognita;
+ _meadow = _value select 3;
+ _terr = _meadow * 100;
+ _elev = getTerrainHeightASL [_targetPosTemp select 0,_targetPosTemp select 1];
+ _points = _points + _terr + _elev;
+ }
+ else
+ {
+ _value = [_targetPosTemp,1,1] call UPSMON_TerraCognita;
+ _urban = _value select 0;
+ _forest = _value select 1;
+ _terr = (_urban + _forest) * 100;
+ _elev = getTerrainHeightASL [_targetPosTemp select 0,_targetPosTemp select 1];
+ _points = _points + _terr + _elev;
+ };
+
+ _los_ok = [_targetPos,_targetPosTemp] call UPSMON_LOS;
+ If (_los_ok) then {_points = _points + 100;};
+
+ {
+ _grp = _x;
+ if (!isnil "_grp") then
+ {
+ _posgrp = _grp getvariable ["UPSMON_targetpos",[0,0]];
+ if (!isnull(_grp)) then
+ {
+ If (side _grp == _side) then
+ {
+ If (_posgrp select 0 != 0 && _posgrp select 1 != 0) then
+ {
+ If (_x getvariable ["UPSMON_Grpid",0] != _grpid) then
+ {
+ _dist1 = [_posgrp,_targetPosTemp] call UPSMON_distancePosSqr;
+ _dist2 = [getposATL (leader _grp),_targetPosTemp] call UPSMON_distancePosSqr;
+ if (_dist1 > 100) then
+ {
+ _points = _points + 50;
+ };
+ if (_dist2 > 100) then
+ {
+ _points = _points + 50;
+ };
+ };
+ };
+ };
+ };
+ };
+ sleep 0.01;
+ } foreach UPSMON_NPCs;
+ _targetPosTemp pushback _points;
+ _pool pushback _targetPosTemp;
+ };
+ If (count _pool > 15 || _i > 60) then {_scan = false};
+};
+
+_pool = [_pool, [], {_x select 3}, "DESCEND"] call BIS_fnc_sortBy;
+
+If (count _pool > 0) then {_targetpos = [(_pool select 0) select 0,(_pool select 0) select 1,0];};
+
+_targetPos;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_SrchFlankPosforboat.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_SrchFlankPosforboat.sqf
new file mode 100644
index 0000000..43a293b
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_FLANK/fnc/UPSMON_SrchFlankPosforboat.sqf
@@ -0,0 +1,90 @@
+/****************************************************************
+File: UPSMON_SrchFlankPosforboat.sqf
+Author: Azroul13
+
+Description:
+ Search Flank position
+
+Parameter(s):
+ <--- Leader position
+ <--- Direction where to search
+ <--- enemy position
+ <--- Side of group
+ <--- Group type (Array: "Air","Tank","car","ship","infantry")
+ <--- Terrain around the leader ("meadow","forest","urban")
+ <--- Id of the group
+Returns:
+ Position
+****************************************************************/
+
+private ["_npcpos","_dir2","_targetPos","_flankdir","_side","_typeofgroup","_scan","_points","_dist","_flankAngle","_flankdist","_pool","_targetPosTemp","_terrainscan","_los_ok","_i","_final","_grp"];
+
+_npcpos = _this select 0;
+_dir2 = _this select 1;
+_targetPos = _this select 2;
+_side = _this select 3;
+_grpid = _this select 4;
+_dist = [_npcpos,_targetpos] call UPSMON_distancePosSqr;
+
+_flankAngle = 45;
+//Establecemos una distancia de flanqueo
+_flankdist = ((random 0.3)+0.5)*(_dist/2);
+
+//La distancia de flanqueo no puede ser superior a la distancia del objetivo o nos pordrÃa pillar por la espalda
+_flankdist = if ((_flankdist) >= _dist) then {_dist*.65} else {_flankdist};
+
+_pool = [];
+_i = 0;
+_scan = true;
+while {_scan} do
+{
+ _i = _i + 1;
+ _targetPosTemp = [_npcpos,[_dist,_flankdist],[_dir2 +100,_dir2+200],0,_roadchk,_distmin] call UPSMON_pos;
+ If (surfaceIsWater _targetPosTemp) then
+ {
+ _targetPosTemp = [_targetPosTemp select 0,_targetPosTemp select 1,0];
+ _points = 0;
+ _los_ok = [_targetPos,_targetPosTemp] call UPSMON_LOS;
+ If (_los_ok) then {_points = _points + 100;};
+
+ {
+ _grp = _x;
+ if (!isnil "_grp") then
+ {
+ _posgrp = _grp getvariable ["UPSMON_targetpos",[0,0]];
+ if (!isnull(_grp)) then
+ {
+ If (side _grp == _side) then
+ {
+ If (_posgrp select 0 != 0 && _posgrp select 1 != 0) then
+ {
+ If (_x getvariable ["UPSMON_Grpid",0] != _grpid) then
+ {
+ _dist1 = [_posgrp,_targetPosTemp] call UPSMON_distancePosSqr;
+ _dist2 = [getposATL (leader _grp),_targetPosTemp] call UPSMON_distancePosSqr;
+ if (_dist1 > 100) then
+ {
+ _points = _points + 50;
+ };
+ if (_dist2 > 100) then
+ {
+ _points = _points + 50;
+ };
+ };
+ };
+ };
+ };
+ };
+ sleep 0.01;
+ } foreach UPSMON_NPCs;
+ _targetpostemp pushback _points;
+ _pool pushback _targetPosTemp;
+ };
+ If (count _pool > 15 || _i > 60) then {_scan = false};
+};
+
+_pool = [_pool, [], {_x select 3}, "DESCEND"] call BIS_fnc_sortBy;
+
+If (count _pool > 0) then {_targetpos = [(_pool select 0) select 0,(_pool select 0) select 1,0];};
+
+_targetPos;
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Fnc/UPSMON_DOPATROL.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Fnc/UPSMON_DOPATROL.sqf
new file mode 100644
index 0000000..f255594
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Fnc/UPSMON_DOPATROL.sqf
@@ -0,0 +1,42 @@
+/****************************************************************
+File: UPSMON_DOPATROL.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a patrol waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- Waypoint Formation ("LINE","COLUMN","STAG COLUMN")
+ <--- Waypoint Speed Mode ("LIMITED","NORMAL","FULL")
+ <--- Area marker
+ <--- Waypoint behaviour ("CARELESS","SAFE","NORMAL","COMBAT","STEALTH")
+ <--- Waypoint Combat Mode ("BLUE","WHITE","YELLOW","RED")
+ <--- Group type (Array: "Air","Tank","car","ship","infantry")
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_wpformation","_speedmode","_areamarker","_targetpos","_targetdist","_dist","_onroad","_Behaviour"];
+
+_grp = _this select 0;
+_wpformation = _this select 1;
+_speedmode = _this select 2;
+_areamarker = _this select 3;
+_Behaviour = _this select 4;
+_combatmode = _this select 5;
+_typeofgrp = _this select 6;
+
+_grp setvariable ["UPSMON_searchingpos",true];
+_npc = leader _grp;
+
+_targetpos = [_npc,_areamarker,_typeofgrp] call UPSMON_SrchPtrlPos;
+_timeontarget = time + (1.4*(getposATL _npc vectordistance _targetpos));
+
+If ("arti" in _typeofgrp) then {_timeontarget = _timeontarget + 20};
+_grp setvariable ["UPSMON_Timeontarget",_timeontarget];
+
+[_grp,_targetpos,"MOVE",_wpformation,_speedmode,_Behaviour,_CombatMode,1] call UPSMON_DocreateWP;
+_grp setvariable ["UPSMON_targetPos",_targetPos];
+_grp setvariable ["UPSMON_RSTUCKCONTROL",0];
+_grp setvariable ["UPSMON_searchingpos",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Fnc/UPSMON_SrchPtrlPos.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Fnc/UPSMON_SrchPtrlPos.sqf
new file mode 100644
index 0000000..5233b3a
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Fnc/UPSMON_SrchPtrlPos.sqf
@@ -0,0 +1,140 @@
+/****************************************************************
+File: UPSMON_SrchPtrlPos.sqf
+Author: Azroul13
+
+Description:
+ Search for a valid patrol position.
+
+Parameter(s):
+ <--- leader of the group
+ <--- Area marker
+ <--- Group type (Array: "Air","Tank","car","ship","infantry")
+Returns:
+ Position
+****************************************************************/
+ private ["_npc","_jumpers","_areamarker","_targetPos","_incar","_scan","_inheli","_inboat","_isdiver","_dist","_currPos","_water","_mindist","_i"];
+
+_npc = _this select 0;
+_areamarker = _this select 1;
+_typeofgrp = _this select 2;
+
+_currPos = getposATL _npc;
+_targetPos = [];
+_isMan = false;
+_dist = 1;
+_mindist = 10;
+_water = 0;
+_centerpos = getMarkerPos _areamarker;
+_areasize = getMarkerSize _areamarker;
+_rangeX = _areasize select 0;
+
+if (!("ship" in _typeofgrp) && !("air" in _typeofgrp)&& !("car" in _typeofgrp) && !("tank" in _typeofgrp)) then {_isMan = true;};
+
+// find a new target that's not too close to the current position
+
+if (!_isMan) then
+{
+ If (("car" in _typeofgrp) || ("tank" in _typeofgrp) || ("air" in _typeofgrp && (group _npc) getvariable ["UPSMON_MOVELANDING",false])) then
+ {
+ _dist = 10;
+ _mindist = 50;
+ }
+ else // boat or plane
+ {
+ If ("air" in _typeofgrp) then
+ {
+ _water = 1;
+ _dist = 0;
+ _mindist = 80;
+ }
+ else // boat
+ {
+ _water = 2;
+ _dist = 0;
+ _mindist = 30;
+ };
+ };
+};
+
+If ((group _npc) getvariable ["UPSMON_Patrolinbld",false]) then
+{
+ _bldpositions = [_currpos,"RANDOMA",30,_areamarker,true] call UPSMON_GetNearestBuildings;
+
+ If (count _bldpositions > 0) then
+ {
+ _bldpos = (_bldpositions select 0) select 1;
+ _nbbldpos = count _bldpos;
+ };
+
+};
+
+_i = 0;
+_scan = true;
+while {_scan} do
+{
+ _i = _i + 1;
+ _targetPosTemp = [_areamarker,_water,[],_dist] call UPSMON_pos;
+ if ((group _npc) getvariable ["UPSMON_ONROAD",false] || ("car" in _typeofgrp)) then
+ {
+ If (!("ship" in _typeofgrp)) then
+ {
+ if (!("air" in _typeofgrp)) then
+ {
+ _nearRoads = _centerpos nearRoads _rangeX;
+ If (count _nearRoads > 0) then
+ {
+ _nearRoads = _nearRoads call UPSMON_arrayShufflePlus;
+ {
+ If ([getposATL _x,_areamarker] call UPSMON_pos_fnc_isBlacklisted) then
+ {
+ if ((([_currpos,getposATL _x] call UPSMON_distancePosSqr) > _mindist)) exitwith
+ {
+ _targetPos = getposATL _x;
+ };
+ };
+ } foreach _nearRoads;
+ };
+ };
+ };
+ };
+
+ If (count _targetPos == 0) then
+ {
+ If (("car" in _typeofgrp) || ("tank" in _typeofgrp) || ((group _npc) getvariable ["UPSMON_movetolanding",false])) then
+ {
+ if (!(surfaceIsWater _targetPosTemp)) then
+ {
+ _terrainscan = _targetPosTemp call UPSMON_sample_terrain;
+ If ((_terrainscan select 0) == "meadow" || (_terrainscan select 0) == "forest") then
+ {
+ If ((_terrainscan select 1) < 90) then
+ {
+ If (count (_targetPosTemp isflatempty [50,1,10,10,0,false,player]) > 0) then
+ {
+ If ((([_currpos,_targetPosTemp] call UPSMON_distancePosSqr) >= _mindist)) then {_targetpos = _targetPosTemp;};
+ };
+ };
+ };
+ };
+ }
+ else
+ {
+ If ("ship" in _typeofgrp && (surfaceIsWater _targetPosTemp)) then
+ {
+ If ((([_currpos,_targetPosTemp] call UPSMON_distancePosSqr) >= _mindist)) then {_targetpos = _targetPosTemp;};
+ }
+ else
+ {
+ if (!(surfaceIsWater _targetPosTemp) || ("air" in _typeofgrp)) then
+ {
+ If ((([_currpos,_targetPosTemp] call UPSMON_distancePosSqr) >= _mindist)) then {_targetpos = _targetPosTemp;};
+ };
+ };
+ };
+ };
+ If (count _targetPos > 0 || _i > 70) then {_scan = false};
+};
+
+If (count _targetPos == 0) then {_targetPos = _currPos;};
+_targetPos;
+
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Init.sqf
new file mode 100644
index 0000000..70bcc66
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROL/Init.sqf
@@ -0,0 +1,3 @@
+
+UPSMON_DOPATROL = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_PATROL\fnc\UPSMON_DOPATROL.sqf";
+UPSMON_SrchPtrlPos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_PATROL\fnc\UPSMON_SrchPtrlPos.sqf";
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/Init.sqf
new file mode 100644
index 0000000..ca426c6
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/Init.sqf
@@ -0,0 +1,4 @@
+
+UPSMON_DOPATROLSRCH = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_PATROLSRCH\fnc\UPSMON_DOPATROLSRCH.sqf";
+UPSMON_SrchPtrlFlankPos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_PATROLSRCH\fnc\UPSMON_SrchPtrlFlankPos.sqf";
+UPSMON_GETINPATROLSRCH = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_PATROLSRCH\fnc\UPSMON_GETINPATROLSRCH.sqf";
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_DOPATROLSRCH.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_DOPATROLSRCH.sqf
new file mode 100644
index 0000000..90ba04b
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_DOPATROLSRCH.sqf
@@ -0,0 +1,102 @@
+/****************************************************************
+File: UPSMON_DORESEARCH.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a combat waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- position of the target
+ <--- Group type (Array: "Air","Tank","car","ship","infantry")
+ <--- Areamarker
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_suspectPos","_grpid","_typeofgrp","_areamarker","_side","_speedmode","_Behaviour","_radius","_npc","_currpos","_dist","_dir1","_targetPos","_wptype"];
+
+_grp = _this select 0;
+_suspectPos = _this select 1;
+_typeofgrp = _this select 2;
+_areamarker = _this select 3;
+_side = side _grp;
+_grpid = _grp getvariable ["UPSMON_Grpid",0];
+
+_speedmode = "NORMAL";
+_Behaviour = "AWARE";
+_radius = 1;
+_water = 0;
+
+_npc = leader _grp;
+_currpos = getposATL _npc;
+_dist = [_suspectPos,_currpos] call UPSMON_distancePosSqr;
+
+_targetPos = _suspectPos;
+_wptype = "MOVE";
+_grp setvariable ["UPSMON_searchingpos",true];
+
+// angle from unit to target
+_dir1 =[_currpos,_suspectPos] call BIS_fnc_DirTo;
+_dir2 = [_suspectPos,_currpos] call BIS_fnc_DirTo;;
+
+_suspectPos = [_suspectPos select 0,_suspectPos select 1,0];
+If (("ship" in _typeofgrp) || ("air" in _typeofgrp)) then
+{
+ if ("ship" in _typeofgrp) then
+ {
+ _water = 2;
+ _targetPos = [_suspectPos,[50,100],[0,360],2,[0,100],1] call UPSMON_pos;
+ If (!surfaceiswater _targetpos) then {_targetpos = _currpos;};
+ _targetPos = [_targetPos select 0,_targetPos select 1,0];
+ _speedmode = "NORMAL";
+ }
+ else
+ {
+ _water = 1;
+ //_targetPos = [_attackpos,[200,1000],[0,360],1,[0,100],0] call UPSMON_pos;
+ _targetPos = _suspectPos;
+ _wptype = "LOITER";
+ _radius = 200;
+ _targetPos = [_targetPos select 0,_targetPos select 1,50];
+ };
+}
+else
+{
+ If (_dist <= 200) then
+ {
+ _speedmode = "LIMITED";
+ _Behaviour = "STEALTH";
+ _targetPos = [_suspectPos,[10,50],[_dir2 + 70,_dir2 + 280],0,[0,100],0] call UPSMON_pos;
+ }
+ else
+ {
+ _targetPos = [_currpos,_dir1,_suspectPos,_side,_typeofgrp,_grpid] call UPSMON_SrchPtrlFlankPos;
+ };
+};
+
+
+if (_grp getvariable ["UPSMON_NOFOLLOW",false]) then
+{
+ If !([_targetPos,_areamarker] call UPSMON_pos_fnc_isBlacklisted) then
+ {
+ _wptype = "HOLD";
+ _speedmode = "FULL";
+ _Behaviour = "AWARE";
+ _targetPos = _currpos;
+ };
+};
+
+
+_grp setvariable ["UPSMON_targetPos",_targetPos];
+_timeontarget = time + (1.4 *(_currpos vectordistance _targetpos)) + (random 10 + 30);
+_grp setvariable ["UPSMON_TIMEONTARGET",_timeontarget];
+_bldpositions = [_targetPos,"RANDOMA"] call UPSMON_GetNearestBuilding;
+If (count _bldpositions > 0) then
+{
+ _bldpos = (_bldpositions select 1) select 0;
+ _grp setvariable ["UPSMON_Grpmission","PATROLINBLD"];
+ _grp setvariable ["UPSMON_bldposToCheck",_bldpos];
+};
+[_grp,_targetpos,_wptype,"COLUMN",_speedmode,_Behaviour,"YELLOW",_radius] call UPSMON_DocreateWP;
+_grp setvariable ["UPSMON_searchingpos",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_GETINPATROLSRCH.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_GETINPATROLSRCH.sqf
new file mode 100644
index 0000000..97d0943
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_GETINPATROLSRCH.sqf
@@ -0,0 +1,25 @@
+/****************************************************************
+File: UPSMON_DORESEARCH.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a combat waypoint to the group
+
+Parameter(s):
+
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_position","_currpos","_time"];
+
+_grp = _this select 0;
+_position = _this select 1;
+_currpos = _this select 2;
+
+_grp setvariable ["UPSMON_Alertpos",_position];
+if (UPSMON_Debug > 0) then {[_position,"ICON","Hd_dot","ColorBlue",format ["Group:%1 Time:%2",_grp getvariable ["UPSMON_Grpid",0],time]] call UPSMON_createmarker;};
+_time = time + UPSMON_SRCHTIME + (1.4 * (_position vectordistance _currpos));
+_grp setvariable ["UPSMON_SRCHTIME",_time];
+_grp setvariable ["UPSMON_Grpmission","PATROLSRCH"];
+_grp setvariable ["UPSMON_attackpos",[]];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_SrchPtrlFlankPos.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_SrchPtrlFlankPos.sqf
new file mode 100644
index 0000000..f18974a
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_PATROLSRCH/fnc/UPSMON_SrchPtrlFlankPos.sqf
@@ -0,0 +1,124 @@
+/****************************************************************
+File: UPSMON_SrchFlankPos.sqf
+Author: Azroul13
+
+Description:
+ Search Flank position
+
+Parameter(s):
+ <--- Leader position
+ <--- Direction where to search
+ <--- enemy position
+ <--- Side of group
+ <--- Group type (Array: "Air","Tank","car","ship","infantry")
+ <--- Terrain around the leader ("meadow","forest","urban")
+ <--- Id of the group
+Returns:
+ Position
+****************************************************************/
+
+private ["_npcpos","_dir2","_targetPos","_side","_typeofgroup","_scan","_points","_dist","_flankAngle","_flankdist","_roadchk","_distmin","_pool","_targetPosTemp","_terrainscan","_los_ok","_i","_final","_grp"];
+
+_npcpos = _this select 0;
+_dir2 = _this select 1;
+_targetPos = _this select 2;
+_side = _this select 3;
+_typeofgrp = _this select 4;
+_grpid = _this select 5;
+_distance = [_npcpos,_targetpos] call UPSMON_distancePosSqr;
+
+_flankAngle = 45;
+//Establecemos una distancia de flanqueo
+_flankdist = _distance/2;
+_dist = 50;
+_distmin = 1;
+_roadchk = [0,50];
+If ("car" in _typeofgrp || "tank" in _typeofgrp) then
+{
+ _roadchk = [1,50];
+ _distmin = 5;
+ _flankdist = ((random 0.2)+1)*(_distance/2);
+ _dist = 100;
+};
+
+//La distancia de flanqueo no puede ser superior a la distancia del objetivo o nos pordrÃa pillar por la espalda
+_flankdist = if ((_flankdist) > _distance) then {_dist + 50} else {_flankdist};
+
+_pool = [];
+_i = 0;
+_scan = true;
+while {_scan} do
+{
+ _i = _i + 1;
+ _targetPosTemp = [_npcpos,[_dist,_flankdist],[_dir2 +100,_dir2+200],0,_roadchk,_distmin] call UPSMON_pos;
+ If (!surfaceIsWater _targetPosTemp) then
+ {
+ _points = 0;
+ _targetPosTemp = [_targetPosTemp select 0,_targetPosTemp select 1,0];
+ If ("car" in _typeofgrp || "tank" in _typeofgrp) then
+ {
+ If (isOnRoad _targetPosTemp) then
+ {
+ _points = _points +20;
+ };
+ _value = [_targetPosTemp,1,1] call UPSMON_TerraCognita;
+ _meadow = _value select 3;
+ _terr = _meadow * 100;
+ _elev = getTerrainHeightASL [_targetPosTemp select 0,_targetPosTemp select 1];
+ _points = _points + _terr + _elev;
+ }
+ else
+ {
+ _value = [_targetPosTemp,1,1] call UPSMON_TerraCognita;
+ _urban = _value select 0;
+ _forest = _value select 1;
+ _terr = (_urban + _forest) * 100;
+ _elev = getTerrainHeightASL [_targetPosTemp select 0,_targetPosTemp select 1];
+ _points = _points +_terr + _elev;
+ };
+
+ _los_ok = [_targetPos,_targetPosTemp] call UPSMON_LOS;
+ If (_los_ok) then {_points = _points + 100;};
+
+ {
+ _grp = _x;
+ if (!isnil "_grp") then
+ {
+ _posgrp = _grp getvariable ["UPSMON_targetpos",[0,0]];
+ if (!isnull(_grp)) then
+ {
+ If (side _grp == _side) then
+ {
+ If (_posgrp select 0 != 0 && _posgrp select 1 != 0) then
+ {
+ If (_x getvariable ["UPSMON_Grpid",0] != _grpid) then
+ {
+ _dist1 = [_posgrp,[_targetPosTemp select 0,_targetPosTemp select 1,0]] call UPSMON_distancePosSqr;
+ _dist2 = [getposATL (leader _grp),[_targetPosTemp select 0,_targetPosTemp select 1,0]] call UPSMON_distancePosSqr;
+ if (_dist1 > 100) then
+ {
+ _points = _points + 50;
+ };
+ if (_dist2 > 100) then
+ {
+ _points = _points + 50;
+ };
+ };
+ };
+ };
+ };
+ };
+ sleep 0.01;
+ } foreach UPSMON_NPCs;
+ _targetpostemp pushback _points;
+ _pool pushback _targetPosTemp;
+ };
+ If (count _pool > 15 || _i > 60) then {_scan = false};
+};
+
+//_pool = [_pool] call UPSMON_ValueOrd;
+_pool = [_pool, [], {_x select 3}, "DESCEND"] call BIS_fnc_sortBy;
+
+If (count _pool > 0) then {_targetpos = [(_pool select 0) select 0,(_pool select 0) select 1,0];};
+
+_targetPos;
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/Init.sqf
new file mode 100644
index 0000000..77eb3fb
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/Init.sqf
@@ -0,0 +1,4 @@
+
+UPSMON_GetReinfPos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_REINFORCEMENT\fnc\UPSMON_GetReinfPos.sqf";
+UPSMON_CallRenf = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_REINFORCEMENT\fnc\UPSMON_CallRenf.sqf";
+UPSMON_ReinfChk = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_REINFORCEMENT\fnc\UPSMON_ReinfChk.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_CallRenf.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_CallRenf.sqf
new file mode 100644
index 0000000..e18653d
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_CallRenf.sqf
@@ -0,0 +1,120 @@
+/****************************************************************
+File: UPSMON_CallRenf.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a combat waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- lastposition
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_currpos","_targetpos","_radiorange","_Eniescapacity","_renfgroup","_list","",""];
+
+_grp = _this select 0;
+_currpos = _this select 1;
+_targetpos = _this select 2;
+_radiorange = _this select 3;
+_Eniescapacity = _this select 4;
+
+_renfgroup = ObjNull;
+_list = [];
+
+_grp setvariable ["UPSMON_ONRADIO",true];
+
+_UPSMON_Renf = (call (compile format ["UPSMON_REINFORCEMENT_%1_UNITS",side _grp])) - [_grp];
+
+if (UPSMON_Debug>0) then {diag_log format["%1 ask reinforcement position %2 KRON_Renf: %3",_npcpos,_fixedtargetpos,_UPSMON_Renf]};
+If (count _UPSMON_Renf > 0) then
+{
+ {
+ If (!IsNull _x) then
+ {
+ If (({alive _x && !(captive _x)} count units _x) > 0) then
+ {
+ If (!(_x getvariable ["UPSMON_ReinforcementSent",false])) then
+ {
+ If (_x getvariable ["UPSMON_Grpmission",""] != "RETREAT") then
+ {
+ If (_x getvariable ["UPSMON_Grpstatus","GREEN"] == "GREEN") then
+ {
+ If ((_currpos vectordistance (getposATL (leader _x))) <= _radiorange) then
+ {
+ _points = 0;
+ If (surfaceIsWater _targetpos) then
+ {
+ If ("ship" in (_x getvariable ["UPSMON_typeofgrp",[]])) then
+ {
+ If ("armed" in (_x getvariable ["UPSMON_typeofgrp",[]])) then
+ {
+ _points = _points + 100;
+ };
+ };
+
+ If ("air" in (_x getvariable ["UPSMON_typeofgrp",[]])) then
+ {
+ If ("at1" in (_x getvariable ["UPSMON_GroupCapacity",[]]) || "at2" in (_x getvariable ["UPSMON_GroupCapacity",[]])) then
+ {
+ _points = _points + 200;
+ };
+ };
+ }
+ else
+ {
+ If (!("ship" in (_x getvariable ["UPSMON_typeofgrp",[]]))) then
+ {
+ _points = _points + (_x getvariable ["UPSMON_Grpratio",0]);
+ };
+
+ If ("aa2" in _Eniescapacity) then
+ {
+ If ("air" in (_x getvariable ["UPSMON_typeofgrp",[]])) then
+ {
+ _points = _points - 200;
+ };
+ };
+
+ If ("at3" in _Eniescapacity) then
+ {
+ If (("at3" in (_x getvariable ["UPSMON_GroupCapacity",[]])) || ("at2" in (_x getvariable ["UPSMON_GroupCapacity",[]]))) then
+ {
+ _points = _points + 200;
+ };
+ };
+
+ If ("at2" in _Eniescapacity) then
+ {
+ If ("air" in (_x getvariable ["UPSMON_GroupCapacity",[]]) && "at1" in (_x getvariable ["UPSMON_GroupCapacity",[]])) then
+ {
+ _points = _points + 100;
+ };
+ };
+ };
+
+ _list pushback [_x,_points];
+ };
+ };
+ };
+ };
+ };
+ };
+
+ If (count _list > 0) then
+ {
+ _list = [_list, [], {_x select 1}, "DESCEND"] call BIS_fnc_sortBy;
+ _renfgroup = (_list select 0) select 0;
+ };
+
+ If (!IsNull _renfgroup) then
+ {
+ _renfgroup setvariable ["UPSMON_PosToRenf",[_targetpos select 0,_targetpos select 1,0]];
+ _renfgroup setvariable ["UPSMON_GrpToRenf",_grp];
+ _grp setvariable ["UPSMON_RenfGrps",_renfgroup getvariable ["UPSMON_RenfGrps",[]] + _renfgroup];
+ };
+ } foreach _UPSMON_Renf;
+};
+
+_grp setvariable ["UPSMON_ONRADIO",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_GetReinfPos.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_GetReinfPos.sqf
new file mode 100644
index 0000000..0b7b104
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_GetReinfPos.sqf
@@ -0,0 +1,67 @@
+/****************************************************************
+File: UPSMON_GetReinfPos.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a combat waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- lastposition
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_lastpos","_fixedtargetpos","_rfidcalled"];
+
+_grp = _this select 0;
+_lastpos = _this select 1;
+
+_fixedtargetpos = [];
+_rfidcalled = false;
+
+if (!(isnil (compile format ["UPSMON_reinforcement%1",_grp getvariable ["UPSMON_RFID",0]]))) then
+{
+ _rfidcalled= call (compile format ["UPSMON_reinforcement%1",_grp getvariable ["UPSMON_RFID",0]])
+};
+
+
+If (UPSMON_reinforcement || _rfidcalled) then
+{
+ If (_grp getvariable ["UPSMON_Reinforcement",false]) then
+ {
+ If (!(_grp getvariable ["UPSMON_ReinforcementSent",false])) then
+ {
+ If (_rfidcalled) then
+ {
+ _fixedtargetPos = call (compile format ["UPSMON_reinforcement%1_pos",_grp getvariable ["UPSMON_RFID",0]]); // will be position os setfix target of sending reinforcement
+ if (isnil "_fixedtargetPos") then
+ {
+ _fixedtargetPos = [];
+ }
+ else
+ {
+ _fixedtargetPos = [_fixedtargetPos select 0,_fixedtargetPos select 1,0];
+ };
+ }
+ else
+ {
+ _fixedtargetPos = _grp getvariable ["UPSMON_PosToRenf",[]];
+ };
+
+ if (count _fixedtargetPos > 0) then
+ {
+ If (_fixedtargetPos select 0 != 0 && _fixedtargetPos select 1 != 0) then
+ {
+ _grp setvariable ["UPSMON_ReinforcementSent",true];
+ _grp setvariable ["UPSMON_Grpmission","REINFORCEMENT"];
+ _grp setvariable ["UPSMON_NOWP",0];
+ [_grp,_fixedtargetPos,"MOVE","COLUMN","FULL","AWARE","YELLOW",1] spawn UPSMON_DocreateWP;
+ };
+ };
+ if (UPSMON_Debug>0) then {player sidechat format["%1 called for reinforcement %2 %3",_grp getvariable ["UPSMON_Grpid",0],_fixedtargetPos,_grp getvariable ["UPSMON_ReinforcementSent",false]]};
+ };
+ };
+};
+
+_fixedtargetpos
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_ReinfChk.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_ReinfChk.sqf
new file mode 100644
index 0000000..44aaef6
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_REINFORCEMENT/fnc/UPSMON_ReinfChk.sqf
@@ -0,0 +1,43 @@
+/****************************************************************
+File: UPSMON_GetReinfPos.sqf
+Author: Azroul13
+
+Description:
+ The script will assign a combat waypoint to the group
+
+Parameter(s):
+ <--- Group
+ <--- lastposition
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_ratio","_typeofgrp","_result"];
+
+_grp = _this select 0;
+_ratio = _this select 1;
+_typeofgrp = _this select 2;
+
+_result = false;
+
+If (UPSMON_reinforcement) then
+{
+ If (!(_grp getvariable ["UPSMON_ONRADIO",false])) then
+ {
+ If (_ratio >= 1) then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "AMBUSH") then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "RETREAT") then
+ {
+ If (!("air" in _typeofgrp)) then
+ {
+ _result = true;
+ };
+ };
+ }
+ };
+ };
+};
+
+_result
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/Init.sqf
new file mode 100644
index 0000000..8b46fdf
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/Init.sqf
@@ -0,0 +1,2 @@
+UPSMON_DORELAX = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_RELAX\fnc\UPSMON_DORELAX.sqf";
+UPSMON_Civaction = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_RELAX\fnc\UPSMON_Civaction.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/fnc/UPSMON_Civaction.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/fnc/UPSMON_Civaction.sqf
new file mode 100644
index 0000000..ac29260
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/fnc/UPSMON_Civaction.sqf
@@ -0,0 +1,120 @@
+private ["_bldpositions","_position","_allpos","_timeontarget"];
+
+(_this select 1) setvariable ["UPSMON_Civdisable",true];
+
+switch (_this select 0) do
+{
+ case "COMBAT":
+ {
+
+ };
+
+ case "TALK":
+ {
+ _timeontarget = time + 120;
+ _position1 = getposATL (_this select 1);
+ _position2 = getposATL (_this select 2);
+ If (_position1 vectordistance _position2 > 5) then
+ {
+ Dostop (_this select 1);
+ (_this select 1) Domove _position2;
+ (_this select 1) setDestination [_position2, "LEADER PLANNED", true];
+ waituntil {IsNull (_this select 1) || !alive (_this select 1) || getposATL (_this select 1) vectordistance _position2 <= 3};
+ };
+
+ If (alive (_this select 1)) then
+ {
+ Dostop (_this select 1);
+ [(_this select 1),_position2] call UPSMON_dowatch;
+ (_this select 1) action ["Talk", _this select 2];
+ sleep 0.8;
+ (_this select 1) disableAI "MOVE";
+ };
+ };
+
+ case "SIT":
+ {
+ (_this select 1) action ["sitDown", _this select 1];
+ (_this select 1) disableAI "MOVE";
+ If (UPSMON_Allowfireplace) then
+ {
+ If ([] call UPSMON_Nighttime) then
+ {
+ If (!([(_this select 1)] call UPSMON_Inbuilding)) then
+ {
+ If (count (nearestobjects [getposATL (_this select 1),["FirePlace_burning_F"],50]) == 0) then
+ {
+ If (count (nearestobjects [getposATL (_this select 1),["Streetlamp"],100]) == 0) then
+ {
+ _pos = [getposATL (_this select 1),getdir (_this select 1),2] call UPSMON_GetPos2D;
+ _fireplace = "FirePlace_burning_F" createvehicle _pos;
+ (_this select 1) setvariable ["UPSMON_fireplace",_fireplace]
+ };
+ };
+ };
+ };
+ };
+ };
+
+ case "FLEE":
+ {
+ If (Speedmode (_this select 1) != "FULL") then {(_this select 1) setspeedmode "FULL"};
+ If (Behaviour (_this select 1) != "CARELESS") then {(_this select 1) setspeedmode "CARELESS"};
+
+ If ((_this select 1) getvariable ["UPSMON_Civdisable",false]) then
+ {
+ (_this select 1) switchmove "";
+ (_this select 1) enableAI "MOVE";
+ (_this select 1) setvariable ["UPSMON_Civdisable",false];
+ };
+
+ (_this select 1) setvariable ["UPSMON_Civfleeing",true];
+ _position = [];
+
+ If ((IsNull (_this select 2)) || !([(_this select 2),(_this select 1),20,130] call UPSMON_Haslos)) then
+ {
+ _bldpositions = [getposATL (_this select 1),"RANDOMDN",100] call UPSMON_GetNearestBuilding;
+ if (count _bldpositions > 0) then
+ {
+ _bldpos = _bldpositions select 1;
+ _position = (_bldpos select 0) select 0;
+ };
+
+ If (count _position > 0) then
+ {
+ Dostop (_this select 1);
+ (_this select 1) Domove _position;
+ (_this select 1) setDestination [_position, "LEADER PLANNED", true];
+ waituntil {IsNull (_this select 1) || !alive (_this select 1) || (((getposATL (_this select 1)) vectordistance _position) <= 3)};
+
+ if (!IsNull (_this select 1)) then
+ {
+ if (alive (_this select 1)) then
+ {
+ If (getposATL (_this select 1) vectordistance _position <= 3) then
+ {
+ (_this select 1) disableAI "MOVE";
+ (_this select 1) setunitpos "MIDDLE";
+ };
+ };
+ };
+ }
+ else
+ {
+ (_this select 1) disableAI "MOVE";
+ (_this select 1) setunitpos "DOWN";
+ };
+
+ }
+ else
+ {
+ (_this select 1) disableAI "MOVE";
+ (_this select 1) setunitpos "DOWN";
+ };
+
+ sleep 120;
+
+ (_this select 1) setvariable ["UPSMON_Civfleeing",false];
+ If (Speedmode (_this select 1) != "LIMITED") then {(_this select 1) setspeedmode "LIMITED"};
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/fnc/UPSMON_DORELAX.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/fnc/UPSMON_DORELAX.sqf
new file mode 100644
index 0000000..6c28564
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RELAX/fnc/UPSMON_DORELAX.sqf
@@ -0,0 +1,108 @@
+private ["_grp","_unit","_currpos","_lastpos","_timeontarget","_time","_civnear","_position","_positionfound","_rnd"];
+
+_grp = _this select 0;
+_areamarker = _this select 1;
+
+{
+ If (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (!(fleeing _x)) then
+ {
+ If (!(captive _x)) then
+ {
+ _unit = _x;
+ _currpos = getposATL _x;
+ _lastpos = _unit getvariable ["UPSMON_lastpos",[0,0]];
+ _timeontarget = time;
+ _destination = _unit getvariable ["UPSMON_Destination",[]];
+
+ If (count (_unit getvariable ["UPSMON_Destination",[]]) == 0) then
+ {
+ _destination = _currpos;
+ };
+
+ If (_unit getvariable ["UPSMON_Wait",time] <= time && !(_unit getvariable ["UPSMON_Civfleeing",false])) then
+ {
+ If (_unit getvariable ["UPSMON_Civdisable",false]) then
+ {
+ _unit switchmove "";
+ _unit enableAI "MOVE";
+ _unit setvariable ["UPSMON_Civdisable",false];
+ };
+
+ If (!IsNull (_unit getvariable ["UPSMON_fireplace",ObjNull])) then
+ {
+ Deletevehicle (_unit getvariable ["UPSMON_fireplace",ObjNull]);
+ };
+
+ _position = [];
+ If (random 100 < 25 && !(IsOnroad _currpos) && ((overcast < 0.5 || rain == 0) || ([_unit] call UPSMON_Inbuilding))) then
+ {
+ _civnear = ObjNull;
+
+ _civsnear = [(nearestObjects [_unit, ["CAManBase"], 10]), {(side _x == (side _unit)) && (alive _x) && (_x getvariable ["UPSMON_Civdisable",false])} ] call BIS_fnc_conditionalSelect;
+
+ If (count _civsnear > 0) then
+ {
+ _civnear = _civsnear select 0;
+ };
+
+ If (random 100 < 12 && !IsNull _civnear) then
+ {
+ _timeontarget = time + 120;
+ If (UPSMON_Debug > 0) then {[_currpos,"ICON","hd_dot","ColorYellow",0] call UPSMON_createmarker;};
+ _unit setvariable ["UPSMON_Civdisable",true];
+ ["TALK",_unit,_civnear] spawn UPSMON_Civaction;
+ }
+ else
+ {
+ _timeontarget = time + 70;
+ _unit disableAI "MOVE";
+ _unit setvariable ["UPSMON_Civdisable",true];
+ ["SIT",_unit] spawn UPSMON_Civaction;
+ };
+ _unit setvariable ["UPSMON_wait",_timeontarget];
+ }
+ else
+ {
+ If ((_destination vectordistance _currpos <= 1) || (_unit getvariable ["UPSMON_Utimeontarget",time] <= time)) then
+ {
+ if (random 100 <= 45) then
+ {
+ _bldpositions = [_currpos,"RANDOMDN"] call UPSMON_GetNearestBuilding;
+
+ if (count _bldpositions > 0) then
+ {
+ _bldpos = _bldpositions select 1;
+ _position = _bldpos select 0;
+ };
+ };
+ if (count _position == 0) then {_position = [_areamarker,0,[],1] call UPSMON_pos;};
+ If (count _position > 0) then
+ {
+ If (!(IsOnroad _position)) then
+ {
+ _unit setvariable ["UPSMON_destination", _position, false];
+ _unit setvariable ["UPSMON_lastpos",_currpos];
+ If (UPSMON_Debug > 0) then {[_position,"ICON","hd_dot","ColorRed",0] call UPSMON_createmarker;};
+ _timeontarget = time + (1.6*(_currpos vectordistance _position));
+ Dostop _unit;
+ _unit domove _position;
+ _unit setDestination [_position, "LEADER PLANNED", true];
+ };
+ };
+ };
+ _unit setvariable ["UPSMON_Utimeontarget",_timeontarget];
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ sleep 0.2;
+} foreach units _grp;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/Init.sqf
new file mode 100644
index 0000000..4576689
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/Init.sqf
@@ -0,0 +1,3 @@
+
+UPSMON_DORETREAT = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_RETREAT\fnc\UPSMON_DORETREAT.sqf";
+UPSMON_SrchRetreatPos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_RETREAT\fnc\UPSMON_SrchRetreatPos.sqf";
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/fnc/UPSMON_DORETREAT.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/fnc/UPSMON_DORETREAT.sqf
new file mode 100644
index 0000000..6ac52e6
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/fnc/UPSMON_DORETREAT.sqf
@@ -0,0 +1,60 @@
+/****************************************************************
+File: UPSMON_DORETREAT.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- Group
+ <--- position of the target)
+
+Returns:
+ nothing
+****************************************************************/
+
+private [_grp"","_AttackPos","_typeofgrp","_assignedvehicles","_dir","_npc","_dist","_retreatPos","_behaviour","_combatmode","_wpformation","_speedmode"];
+
+_grp = _this select 0;
+_AttackPos = _this select 1;
+_typeofgrp = _this select 2;
+_assignedvehicles = _this select 3;
+
+_dir = [];
+_npc = leader _grp;
+_dist = 100;
+
+_grp setvariable ["UPSMON_searchingpos",true];
+
+If ("car" in _typeofgrp || "ship" in _typeofgrp || "air" in _typeofgrp) then
+{
+ _dist = 500;
+};
+
+If ("arti" in _typeofgrp) then
+{
+ [_grp,_assignedvehicles,_grp getvariable ["UPSMON_GrpTarget",ObjNull]] call UPSMON_FireGun;
+};
+
+
+If (_AttackPos select 0 != 0 && _AttackPos select 1 != 0) then
+{
+ // angle from unit to target
+ _dir1 = [_AttackPos,getposATL _npc] call UPSMON_getDirPos;
+ _dir = [_dir1 +290,_dir1 +70];
+}
+else
+{
+ _dir = [getposATL _npc,(_grp getvariable "UPSMON_Origin") select 2] call UPSMON_getDirPos;
+};
+
+_retreatPos = [_npc,_AttackPos,_dir,_dist] call UPSMON_SrchRetreatPos;
+
+_behaviour = "CARELESS";
+_CombatMode = "BLUE";
+if (UPSMON_Debug>0) then {player sidechat format["%1 All Retreat!!!",_npc]};
+_wpformation = "LINE";
+_speedmode = "FULL";
+
+[_grp,_targetpos,_wptype,_wpformation,_speedmode,_behaviour,_CombatMode,1] spawn UPSMON_DocreateWP;
+
+_grp setvariable ["UPSMON_searchingpos",false];
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/fnc/UPSMON_SrchRetreatPos.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/fnc/UPSMON_SrchRetreatPos.sqf
new file mode 100644
index 0000000..295c6f9
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_RETREAT/fnc/UPSMON_SrchRetreatPos.sqf
@@ -0,0 +1,64 @@
+/****************************************************************
+File: UPSMON_SrchRetreatPos.sqf
+Author: Azroul13
+
+Description:
+
+Parameter(s):
+ <--- leader of he group
+ <--- position of the target
+ <--- Direction where to search
+ <--- Distance where to search
+Returns:
+ Position
+****************************************************************/
+
+private ["_npc","_dist","_dir2","_exp","_scan","_avoidPos","_bestplaces","_roadcheckpos"];
+
+_npc = _this select 0;
+_targetPos = _this select 1;
+_direction = _this select 2;
+_dist = _this select 3;
+_typeofgrp = _this select 4;
+
+_currpos = getposATL _npc;
+_water = 0;
+If ("ship" in _typeofgrp) then
+{
+ _water = 1;
+};
+_avoidPos = [];
+_targetPosTemp = [];
+_pool = [];
+_distmin = 5;
+_i = 0;
+_scan = true;
+while {_scan} do
+{
+ _i = _i + 1;
+ _targetPosTemp = [_currpos,[_dist,_dist + 100],_direction,_water,[0,50],_distmin] call UPSMON_pos;
+ If ("ship" in _typeofgrp) then
+ {
+ If (surfaceIsWater _targetPosTemp) then
+ {
+ _avoidPos = _targetPosTemp;
+ };
+ }
+ else
+ {
+ If (!(surfaceIsWater _targetPosTemp)) then
+ {
+ _terrainscan = _targetPosTemp call UPSMON_sample_terrain;
+ _los_ok = [_targetPos,[_targetPosTemp select 0,_targetPosTemp select 1,0]] call UPSMON_LOS;
+ If (!_los_ok && ((_terrainscan select 0) == "inhabited" || (_terrainscan select 0) == "forest")) then
+ {
+ _avoidPos = _targetPosTemp;
+ };
+ };
+ };
+
+ If (count _avoidPos > 0 || _i > 30) then {_scan = false};
+};
+
+if (count _avoidPos == 0) then {_avoidPos = _currpos;};
+_avoidPos;
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/Init.sqf
new file mode 100644
index 0000000..d85d5a4
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/Init.sqf
@@ -0,0 +1,2 @@
+
+UPSMON_GetSupply = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_SUPPLY\fnc\UPSMON_GetSupply.sqf";
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/fnc/UPSMON_GetSupply.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/fnc/UPSMON_GetSupply.sqf
new file mode 100644
index 0000000..92633f9
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/fnc/UPSMON_GetSupply.sqf
@@ -0,0 +1,93 @@
+/****************************************************************
+File: UPSMON_GetTransport.sqf
+Author: Azroul13
+
+Description:
+ Search for a valid patrol position.
+
+Parameter(s):
+ <--- group
+Returns:
+ Transport group
+****************************************************************/
+private ["_grp","_leader","_side","_supplyneeded","_supplyarray","_supplyselected","_supplygrp","_assignedvehicles","_cargonumber"];
+
+_grp = _this select 0;
+_supplyneeded = _grp getvariable ["UPSMON_Supplyneeded",[]];
+_leader = leader _grp;
+_side = side _grp;
+
+_supplyarray = (call (compile format ["UPSMON_SUPPLY_%1_UNITS",side _grp])) - [_grp];
+_supplyselected = [];
+_supplygrp = ObjNull;
+
+
+{
+ If (!IsNull _x) then
+ {
+ _group = _x;
+ If (({alive _x} count units _group) > 0) then
+ {
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "WAITING" || ((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "RETURNBASE" || ((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDBASE") then
+ {
+ _assignedvehicles = [];
+ _cargonumber = 0;
+ {
+ If (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (vehicle _x != _x) then
+ {
+ _support = tolower gettext (configFile >> "CfgVehicles" >> typeof _vehicle >> "vehicleClass");
+ If (_support == "Support") then
+ {
+ If (!((vehicle _x) in _assignedvehicles)) then
+ {
+ _repair = getnumber (configFile >> "cfgVehicles" >> typeOf (_vehicle) >> "transportRepair");
+ _fuel = getnumber (configFile >> "cfgVehicles" >> typeOf (_vehicle) >> "transportFuel");
+ _munsupply = getnumber (configFile >> "cfgVehicles" >> typeOf (_vehicle) >> "attendant");
+
+ If ("repair" in _supplyneeded) then
+ {
+ if (_repair > 0) then
+ {
+ _points = _points + _repair;
+ };
+ };
+
+ If ("fuel" in _supplyneeded) then
+ {
+ if (_fuel > 0) then
+ {
+ _points = _points + _fuel;
+ };
+ };
+
+ If ("munition" in _supplyneeded) then
+ {
+ if (_munsupply > 0) then
+ {
+ _points = _points + _munsupply;
+ };
+ };
+
+ _supplyselected pushback [_group,_points];
+ };
+ };
+ };
+ };
+ };
+ } foreach units _group;
+ };
+ };
+ };
+} foreach _supplyarray;
+
+If (count _supplyselected > 0) then
+{
+ _supplyselected = [_supplyselected, [], {_x select 1}, "DESCEND"] call BIS_fnc_sortBy;
+ _supplygrp = (_supplyselected select 0) select 0;
+};
+
+_supplygrp
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/fnc/UPSMON_GetSupplyPos.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/fnc/UPSMON_GetSupplyPos.sqf
new file mode 100644
index 0000000..a541f70
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_SUPPLY/fnc/UPSMON_GetSupplyPos.sqf
@@ -0,0 +1,21 @@
+/****************************************************************
+File: UPSMON_GetTransport.sqf
+Author: Azroul13
+
+Description:
+ Search for a valid patrol position.
+
+Parameter(s):
+ <--- group
+Returns:
+ Transport group
+****************************************************************/
+private ["_grp","_supplypos","_side","_supplyneeded","_supplyarray","_supplyselected","_supplygrp","_assignedvehicles","_cargonumber"];
+
+_grp = _this select 0;
+
+_wppos = waypointPosition [_grp,count(waypoints _grp)-1];
+
+_supplypos = [];
+
+_supplypos;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/Init.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/Init.sqf
new file mode 100644
index 0000000..44e61c7
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/Init.sqf
@@ -0,0 +1,17 @@
+UPSMON_dohelidisembark = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_dohelidisembark.sqf";
+UPSMON_doparadrop = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_doparadrop.sqf";
+UPSMON_dodisembark = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_dodisembark.sqf";
+UPSMON_Returnbase = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_Returnbase.sqf";
+UPSMON_Disembarkment = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_Disembarkment.sqf";
+
+UPSMON_KeepAltitude = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_KeepAltitude.sqf";
+UPSMON_GetTransport = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_GetTransport.sqf";
+UPSMON_CheckTransport = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_CheckTransport.sqf";
+UPSMON_CheckTransported = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_CheckTransported.sqf";
+
+UPSMON_Embarkment = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_Embarkment.sqf";
+UPSMON_DOfindvehicle = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_DOfindvehicle.sqf";
+UPSMON_DOfindCombatvehicle = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_DOfindCombatvehicle.sqf";
+UPSMON_getinassignedveh = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_getinassignedveh.sqf";
+UPSMON_SrchTrpPos = compile preProcessFileLineNumbers "Scripts\UPSMON\MODULES\ORDERS\UPSMON_Transport\fnc\UPSMON_SrchTrpPos.sqf";
+
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/UPSMON_Dofindstatic.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/UPSMON_Dofindstatic.sqf
new file mode 100644
index 0000000..54307a1
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/UPSMON_Dofindstatic.sqf
@@ -0,0 +1,30 @@
+/****************************************************************
+File: UPSMON_Dofindstatic.sqf
+Author: Azroul13
+
+Description:
+ Search for near combat statics.
+
+Parameter(s):
+ <--- leader
+ <--- Id of the group
+Returns:
+ nothing
+****************************************************************/
+private ["_npc","_unitsIn","_grpid","_buildingdist"];
+_npc = _this select 0;
+_grpid = _this select 1;
+_buildingdist = _this select 2;
+
+//If use statics are enabled leader searches for static weapons near.
+_unitsIn = [_grpid,_npc,_buildingdist] call UPSMON_GetIn_NearestStatic;
+
+if ( count _unitsIn > 0) then
+{
+ _npc setspeedmode "FULL";
+ _timeout = time + 60;
+
+ {
+ waituntil {vehicle _x != _x || { time > _timeout } || { movetofailed _x } || { !canmove _x } || { !alive _x } };
+ } foreach _unitsIn;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_CheckTransport.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_CheckTransport.sqf
new file mode 100644
index 0000000..e234b4e
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_CheckTransport.sqf
@@ -0,0 +1,35 @@
+/****************************************************************
+File: UPSMON_CheckTransport.sqf
+Author: Azroul13
+
+Description:
+ Return if the group keep doing transport
+
+Parameter(s):
+ <--- Group
+Returns:
+ Group transported
+****************************************************************/
+
+private["_grp","_transportgrp","_grptransport","_vehicles"];
+
+_grp = _this select 0;
+_transportgrp = ObjNull;
+
+If (!IsNull (_grp getvariable ["UPSMON_Transport",ObjNull])) then
+{
+ _grptransport = _grp getvariable ["UPSMON_Transport",ObjNull];
+ If (_grptransport getvariable ["UPSMON_Grpmission",""] == "TRANSPORT") then
+ {
+ If (count (_grptransport getvariable ["UPSMON_Assignedvehicle",_assignedvehicles]) > 0) then
+ {
+ _vehicles = _grptransport getvariable ["UPSMON_Assignedvehicle",_assignedvehicles];
+ If ({alive _x && vehicle _x != _x && canmove _x} count _vehicles > 0) then
+ {
+ _transportgrp = _grptransport;
+ };
+ };
+ };
+};
+
+_transportgrp
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_CheckTransported.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_CheckTransported.sqf
new file mode 100644
index 0000000..4b6a8e7
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_CheckTransported.sqf
@@ -0,0 +1,30 @@
+/****************************************************************
+File: UPSMON_CheckTransport.sqf
+Author: Azroul13
+
+Description:
+ Return if the group keep doing transport
+
+Parameter(s):
+ <--- Group
+Returns:
+ Group transported
+****************************************************************/
+
+private["_grp","_grouptransported"];
+
+_grp = _this select 0;
+_grouptransported = ObjNull;
+
+If (!IsNull ((_grp getvariable ["UPSMON_Transportmission",[]]) select 2)) then
+{
+ If ({alive _x && !(captive _x)} count units ((_grp getvariable ["UPSMON_Transportmission",[]])select 2) > 0) then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] == "WAITTRANSPORT") then
+ {
+ _grouptransported = (_grp getvariable ["UPSMON_Transportmission",[]])select 2;
+ };
+ };
+};
+
+_grouptransported
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_DOfindCombatvehicle.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_DOfindCombatvehicle.sqf
new file mode 100644
index 0000000..5e76d9a
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_DOfindCombatvehicle.sqf
@@ -0,0 +1,64 @@
+/****************************************************************
+File: UPSMON_DOfindCombatvehicle.sqf
+Author: Azroul13
+
+Description:
+ Search for near combat vehicles.
+
+Parameter(s):
+ <--- Group
+ <--- Id of the group
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_npc","_unitsIn","_vehicle","_timeout"];
+
+_grp = _this select 0;
+
+//Get in combat vehicles
+_unitsIn = [];
+_npc = leader _grp;
+_grp setvariable ["UPSMON_embarking",true];
+_unitsIn = [_npc,["air","land","sea","gun"],200] call UPSMON_GetIn_NearestVehicles;
+_timeout = time + 30;
+
+ if ( count _unitsIn == 0) then
+ {
+ //if (UPSMON_Debug>0 ) then {player sidechat format["%1: Geting in combat vehicle targetdist=%2",_grp getvariable ["UPSMON_Grpid",0],_npc distance _target]};
+
+ {
+ waituntil {vehicle _x != _x || !canmove _x || !canstand _x || !alive _x || time > _timeout || movetofailed _x};
+ }foreach _unitsIn;
+
+ // did the leader die?
+ If (({alive _x} count units _grp) == 0) exitwith {};
+
+ //Return to combat mode
+ _timeout = time + 30;
+ {
+ waituntil {vehicle _x != _x || !canmove _x || !alive _x || time > _timeout || movetofailed _x};
+ }foreach _unitsIn;
+
+ {
+ if ( vehicle _x iskindof "Air") then
+ {
+ //moving hely for avoiding stuck
+ if (driver vehicle _x == _x) then
+ {
+ _vehicle = vehicle (_x);
+ nul = [_vehicle,1000] spawn UPSMON_domove;
+ //Execute control stuck for helys
+ [_vehicle] spawn UPSMON_HeliStuckcontrol;
+ //if (UPSMON_Debug>0 ) then {diag_log format["UPSMON %1: Getting in combat vehicle - distance: %2 m",_grpidx,_npc distance _target]};
+ };
+ };
+
+ if (driver vehicle _x == _x) then
+ {
+ //Starts gunner control
+ nul = [vehicle _x] spawn UPSMON_Gunnercontrol;
+ };
+ } foreach _unitsIn;
+};
+_grp setvariable ["UPSMON_embarking",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_DOfindvehicle.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_DOfindvehicle.sqf
new file mode 100644
index 0000000..3e72031
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_DOfindvehicle.sqf
@@ -0,0 +1,156 @@
+/****************************************************************
+File: UPSMON_DOfindvehicle.sqf
+Author: Azroul13
+
+Description:
+ Search vehicles near the leader of the group.
+
+Parameter(s):
+ <--- Group
+ <--- Current waypoint position
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_targetpos","_speedmode","_behaviour","_grpid","_npc","_unitsIn","_transportgrp","_targetpos2","_assignedvehicle","_timeout","_vehicle","_driver","_gunnerscrew","_timeontarget","_mission"];
+
+_grp = _this select 0;
+_targetpos = _this select 1;
+_speedmode = _this select 2;
+_behaviour = _this select 3;
+
+_grp setvariable ["UPSMON_embarking",true];
+_grp setvariable ["UPSMON_searchingpos",true];
+
+if (UPSMON_Debug > 0) then {diag_log format ["Grp%1 search vehicle",_grp getvariable ["UPSMON_grpid",0]];};
+
+If (({alive _x} count units _grp) == 0) exitwith {};
+
+_grpid = _grp getvariable ["UPSMON_Grpid",0];
+_npc = leader _grp;
+_unitsIn = [_npc,["air","land","sea","transport"],200] call UPSMON_GetIn_NearestVehicles;
+
+if (UPSMON_Debug > 0) then {diag_log format ["Grp%1 unitsin:%2",_grp getvariable ["UPSMON_grpid",0],_unitsIn];};
+
+if (count _unitsIn == 0) then
+{
+ _transportgrp = [_grp] call UPSMON_GetTransport;
+ if (!IsNull _transportgrp) then
+ {
+ _grp setvariable ["UPSMON_Grpmission","WAITTransport"];
+ _grp setvariable ["UPSMON_Transport",_transportgrp];
+ _grp setvariable ["UPSMON_TransportDest",_targetpos];
+ _mission = "MOVETODEST";
+
+ If ((getposATL (leader _grp)) vectordistance (getposATL (leader _transportgrp)) > 300) then
+ {
+ if ("Air" countType [vehicle _npc] == 0) then
+ {
+ _mission = "MoveToRP";
+ }
+ else
+ {
+ _mission = "LANDRP";
+ };
+
+ _targetpos = [_npc,getposATL _npc,["car"]] call UPSMON_SrchTrpPos;
+ [_transportgrp,_targetpos,"MOVE","COLUMN","FULL","SAFE","BLUE",1] spawn UPSMON_DocreateWP;
+ [_grp,_targetpos,"MOVE","COLUMN","FULL","SAFE","BLUE",1] spawn UPSMON_DocreateWP;
+ }
+ else
+ {
+ _transportgrp call UPSMON_DeleteWP;
+ _assignedvehicle = [];
+ {
+ if (alive _x) then
+ {
+ If (vehicle _x != _x) then
+ {
+ If (!((vehicle _x) in _assignedvehicle)) then
+ {
+ _assignedvehicle pushback (vehicle _x);
+ };
+ };
+ };
+ } foreach units _transportgrp;
+ [_grp,_assignedvehicle,_targetpos] spawn UPSMON_getinassignedveh;
+ };
+
+ _transportgrp setvariable ["UPSMON_Transportmission",[_mission,_targetpos,_grp]];
+ };
+};
+if (count _unitsIn > 0) then
+{
+ _timeout = time + 120;
+
+ _vehicle = objnull;
+ _vehicles = [];
+
+ {
+ waitUntil { (vehicle _x != _x) || { time > _timeout } || { moveToFailed _x } || { !canMove _x } || { !canStand _x } || { !alive _x } };
+
+ if ( vehicle _x != _x && !(_vehicle in _vehicles)) then
+ {
+ _vehicles pushback (vehicle _x)
+ };
+ } foreach _unitsIn;
+
+ {
+ if (_x iskindof "AIR") exitwith
+ {
+ _driver = driver _x;
+
+ If (_driver in (units (group _npc))) then
+ {
+ If (_driver == _npc) then
+ {
+ (group _npc) selectLeader ((units _npc) select 1);
+ };
+ [_driver] join GrpNull;
+ _gunnerscrew = [_x] call UPSMON_Fn_Gunnercrew;
+ _gunnerscrew join _driver;
+ };
+ _targetpos = [_npc,_targetpos,["air"]] call UPSMON_SrchTrpPos;
+
+ _mission = "MOVETODEST";
+ if (_grp getvariable ["UPSMON_LANDDROP",false]) then
+ {
+ _h2 = createVehicle ["Land_HelipadEmpty_F", _targetpos, [], 0, "NONE"];
+ [(group _driver),_targetpos,"MOVE","COLUMN","FULL","CARELESS","BLUE",1] spawn UPSMON_DocreateWP;
+ _mission = "LANDING";
+ }
+ else
+ {
+ _targetpos2 = [_targetpos,[_targetpos,getposATL _driver] call BIS_fnc_DirTo,400] call UPSMON_GetPos2D;
+ [(group _driver), [_targetpos select 0,_targetpos select 1,UPSMON_paraflyinheight],"MOVE","COLUMN","FULL","CARELESS","BLUE",1,UPSMON_paraflyinheight,[_targetpos2,"MOVE","COLUMN","FULL","CARELESS","BLUE",1]] spawn UPSMON_DocreateWP;
+ };
+ (group _driver) setvariable ["UPSMON_Transportmission",[_mission,_targetpos,_grp]];
+ _grp setvariable ["UPSMON_InTransport",true];
+ [_driver,(group _npc) getvariable "UPSMON_Marker","TRANSPORT"] spawn UPSMON;
+ };
+ } foreach _vehicles;
+
+ _grptype = [leader _grp] call UPSMON_grptype;
+
+ if (_grptype == "Iscar") then
+ {
+ _targetpos = [leader _grp,_targetpos,["car"]] call UPSMON_SrchTrpPos;
+ };
+
+ if (_grptype == "Isboat") then
+ {
+ _targetpos = [leader _grp,_targetpos,["ship"]] call UPSMON_SrchTrpPos;
+ };
+
+ {_x forcespeed -1} foreach units _grp;
+
+ [_grp,_targetpos,"MOVE","COLUMN",_speedmode,_behaviour,"YELLOW",1] call UPSMON_DocreateWP;
+ _timeontarget = time + (1.4*((getposATL (leader _grp)) vectordistance _targetpos));
+ _grp setvariable ["UPSMON_Timeontarget",_timeontarget];
+};
+
+sleep 2;
+
+_grp setvariable ["UPSMON_targetpos",_targetpos];
+_grp setvariable ["UPSMON_embarking",false];
+_grp setvariable ["UPSMON_searchingpos",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Disembarkment.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Disembarkment.sqf
new file mode 100644
index 0000000..a54e977
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Disembarkment.sqf
@@ -0,0 +1,81 @@
+
+private ["_grp","_assignedvehicle","_dist","_targetdist","_get_out_dist","_unitsincargo"];
+
+_grp = _this select 0;
+_assignedvehicle = _this select 1;
+_dist = _this select 2;
+_targetdist = _this select 3;
+_supstate = _this select 4;
+_safemode = ["CARELESS","SAFE"];
+
+{
+ _vehicle = vehicle _x;
+ _unitsincargo = [_vehicle] call UPSMON_FN_unitsInCargo;
+
+
+ if (!(_vehicle iskindof "AIR") && !(_vehicle iskindof "StaticWeapon") && !(_vehicle iskindof "MAN")) then
+ {
+ _get_out_dist = UPSMON_closeenoughV * ((random .4) + 1);
+ If (_vehicle iskindof "TANK" || _vehicle iskindof "Wheeled_APC_F" || !(IsNull (gunner _vehicle))) then {_get_out_dist = UPSMON_closeenough * ((random .4) + 0.8);};
+ If ((behaviour _x) in _safemode) then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "TRANSPORT") then
+ {
+ _targetdist = 20000
+ };
+ };
+
+ if (UPSMON_Debug>0) then {diag_log format ["Disembark!!! CanMove:%1 Alive:%2 Dist1:%3 targetDist:%4 Gothit:%5 Cargo:%6",canmove _vehicle,alive (driver _vehicle),_dist <= _get_out_dist,_targetdist <= (200 * ((random .4) + 1)),_supstate,_unitsincargo];};
+
+ if (!(_vehicle getvariable ["UPSMON_disembarking",false])) then
+ {
+ if (!(canmove _vehicle)
+ || !(alive (driver _vehicle))
+ || _dist <= _get_out_dist
+ || (_supstate != "")
+ || _targetdist <= (200 * ((random .4) + 1))) then
+ {
+ [_vehicle,_unitsincargo,_grp,_supstate] spawn UPSMON_dodisembark;
+ };
+ }
+ };
+
+ If (_vehicle iskindof "AIR") then
+ {
+ If (count _unitsincargo > 0) then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] == "TRANSPORT") then
+ {
+ _get_out_dist = UPSMON_paradropdist * ((random 0.4) + 1);
+ if (UPSMON_Debug>0) then {diag_log format ["Disembark!!! CanMove:%1 Alive:%2 Dist1:%3 targetDist:%4 Gothit:%5 Cargo:%6",canmove _vehicle,alive (driver _vehicle),_dist <= _get_out_dist,_targetdist <= (200 * ((random .4) + 1)),_supstate,_unitsincargo];};
+ If (_targetdist <= _get_out_dist || _dist <= 800) then
+ {
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDING" || ((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDBASE") then
+ {
+ If (_dist <= 800) then
+ {
+ If (!(_grp getvariable ["UPSMON_ChangingLZ",false])) then
+ {
+ _targetpos = [_vehicle,getposATL _vehicle,["car"]] call UPSMON_SrchTrpPos;
+ _mission = (_grp getvariable ["UPSMON_Transportmission",[]]) select 0;
+ _group = (_grp getvariable ["UPSMON_Transportmission",[]]) select 2;
+ _grp setvariable ["UPSMON_Transportmission",[_mission,_targetpos,_group]];
+ [_grp,_targetpos,"MOVE","COLUMN","FULL","CARELESS","YELLOW",1,UPSMON_flyInHeight] call UPSMON_DocreateWP;
+ _grp getvariable ["UPSMON_ChangingLZ",true];
+ };
+ };
+ If ((abs(velocity _vehicle select 2)) <= 1 && ((getposATL _vehicle) select 2) <= 4) then
+ {
+ [_vehicle,_unitsincargo,_grp] spawn UPSMON_dohelidisembark;
+ };
+ }
+ else
+ {
+ [_vehicle] spawn UPSMON_KeepAltitude;
+ [_vehicle,_unitsincargo,_grp] spawn UPSMON_doparadrop;
+ };
+ };
+ };
+ };
+ };
+} foreach _assignedvehicle;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Embarkment.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Embarkment.sqf
new file mode 100644
index 0000000..b9507e5
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Embarkment.sqf
@@ -0,0 +1,85 @@
+
+private ["_grp","_typeofgrp","_targetpos","_dist","_traveldist","_assignedvehicle","_gothit","_units","_unitsout"];
+
+_grp = _this select 0;
+_typeofgrp = _this select 1;
+_targetpos = _this select 2;
+_dist = _this select 3;
+_traveldist = _this select 4;
+_assignedvehicle = _this select 5;
+_gothit = _this select 6;
+_speedmode = _this select 7;
+_behaviour = _this select 8;
+
+_units = units _grp;
+_unitsout = [];
+{
+ If (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ _unitsout pushback _x;
+ };
+ };
+ };
+} foreach _units;
+
+If (UPSMON_Debug > 0) then {diag_log format ["Embark!!! outcargo:%1 Dist:%2 Gothit:%3 targetDist:%4",count _unitsout,_dist > 800,_gothit,_traveldist >= UPSMON_searchVehicledist]};
+If (count _unitsout > 0) then
+{
+ If ("car" in _typeofgrp || "tank" in _typeofgrp) then
+ {
+ {
+ If (alive _x) then
+ {
+ If (Speed _x > 5) then
+ {
+ _x forcespeed 5.5;
+ };
+ };
+ } foreach _assignedvehicle;
+ };
+
+ If (_dist > 800 && _gothit == "") then
+ {
+ If (_targetpos select 0 != 0 && _targetpos select 1 != 0) then
+ {
+ If (_traveldist >= UPSMON_searchVehicledist) then
+ {
+ if (count _assignedvehicle == 0 && count (_grp getvariable ["UPSMON_Lastassignedvehicle",[]]) == 0) then
+ {
+ if (_grp getvariable ["UPSMON_NOVEH",0] == 0) then
+ {
+ if (!("tank" in _typeofgrp) && !("armed" in _typeofgrp) && !("apc" in _typeofgrp) && !("air" in _typeofgrp)) then
+ {
+ [_grp,_targetpos,_speedmode,_behaviour] spawn UPSMON_DOfindvehicle;
+ };
+ };
+ }
+ else
+ {
+ If ("infantry" in _typeofgrp) then
+ {
+ If (count _assignedvehicle == 0) then
+ {
+ //_assignedvehicle = _grp getvariable ["UPSMON_Lastassignedvehicle",[]];
+ };
+ If (count _assignedvehicle > 0) then
+ {
+ [_grp,_assignedvehicle,_targetpos] spawn UPSMON_getinassignedveh;
+ };
+ };
+ };
+ };
+ };
+ }
+ else
+ {
+ If (_grp getvariable ["UPSMON_NOVEH",0] < 2) then
+ {
+ [_grp] spawn UPSMON_DOfindCombatvehicle;
+ };
+ };
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_GetTransport.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_GetTransport.sqf
new file mode 100644
index 0000000..951007d
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_GetTransport.sqf
@@ -0,0 +1,69 @@
+/****************************************************************
+File: UPSMON_GetTransport.sqf
+Author: Azroul13
+
+Description:
+ Search for a valid patrol position.
+
+Parameter(s):
+ <--- group
+Returns:
+ Transport group
+****************************************************************/
+private ["_grp","_leader","_side","_unitstotransport","_transportarray","_transportsselected","_transportgrp","_assignedvehicles","_cargonumber"];
+
+_grp = _this select 0;
+_leader = leader _grp;
+_side = side _grp;
+
+_unitstotransport = units _grp;
+
+_transportarray = (call (compile format ["UPSMON_TRANSPORT_%1_UNITS",side _grp])) - [_grp];
+_transportsselected = [];
+_transportgrp = ObjNull;
+_assignedvehicles = [];
+
+
+{
+ If (!IsNull _x) then
+ {
+ _group = _x;
+ If (({alive _x} count units _group) > 0) then
+ {
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "WAITING" || ((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "RETURNBASE" || ((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDBASE") then
+ {
+ _cargonumber = 0;
+ {
+ If (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (vehicle _x != _x) then
+ {
+ If (!((vehicle _x) in _assignedvehicles)) then
+ {
+ _assignedvehicles pushback (vehicle _x);
+ _Cargocfg = getNumber (configFile >> "CfgVehicles" >> typeof (vehicle _x) >> "transportSoldier");
+ _unitsincargo = assignedCargo (vehicle _x);
+ _cargonumber = _cargonumber + (_Cargocfg - (count _unitsincargo));
+ };
+ };
+ };
+ };
+ } foreach units _group;
+
+ If (_cargonumber >= count _unitstotransport) then
+ {
+ _transportsselected pushback _group;
+ };
+ };
+ };
+ };
+} foreach _transportarray;
+
+If (count _transportsselected > 0) then
+{
+ _transportgrp = _transportsselected select 0;
+};
+
+_transportgrp
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_KeepAltitude.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_KeepAltitude.sqf
new file mode 100644
index 0000000..a9cb872
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_KeepAltitude.sqf
@@ -0,0 +1,12 @@
+private ["_transport","_diff","_time"];
+
+_transport = _this select 0;
+
+_time = time + 60;
+_orgpos = (getposASL _transport) select 2;
+
+While {alive _transport && _time > time} do
+{
+ _transport flyInHeight UPSMON_paraflyinheight;
+ sleep 0.1;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Returnbase.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Returnbase.sqf
new file mode 100644
index 0000000..b19381a
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_Returnbase.sqf
@@ -0,0 +1,33 @@
+/****************************************************************
+File: UPSMON_Returnbase.sqf
+Author: Azroul13
+
+Description:
+ Make the transport return to the base
+
+Parameter(s):
+ <--- Vehicle
+Returns:
+ nothing
+****************************************************************/
+
+private["_transport","_grp","_basepos"];
+
+_transport = _this select 0;
+_grp = group _transport;
+
+_basepos = (_grp getvariable "UPSMON_Origin") select 0;
+
+if (!alive _transport) exitwith{};
+
+If (_transport iskindof "Air") then
+{
+ _grp setvariable ["UPSMON_Transportmission",["LANDBASE",_basepos,ObjNull]];
+ _grp setvariable ["UPSMON_ChangingLZ",false];
+ [_grp,_basepos,"MOVE","COLUMN","FULL","CARELESS","YELLOW",1,UPSMON_flyInHeight] call UPSMON_DocreateWP;
+}
+else
+{
+ _grp setvariable ["UPSMON_Transportmission",["RETURNBASE",_basepos,ObjNull]];
+ [_grp,_basepos,"MOVE","COLUMN","NORMAL","SAFE","YELLOW",1] call UPSMON_DocreateWP;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_SrchTrpPos.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_SrchTrpPos.sqf
new file mode 100644
index 0000000..387b1ec
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_SrchTrpPos.sqf
@@ -0,0 +1,105 @@
+/****************************************************************
+File: UPSMON_SrchTrpPos.sqf
+Author: Azroul13
+
+Description:
+ Search for a valid patrol position.
+
+Parameter(s):
+ <--- leader of the group
+ <--- Position
+ <--- Group type (Array: "Air","Tank","car","ship","infantry")
+Returns:
+ Position
+****************************************************************/
+ private ["_npc","_direction","_dir","_jumpers","_position","_targetPos","_incar","_inheli","_inboat","_isdiver","_dist","_currPos","_water","_mindist","_i"];
+
+_npc = _this select 0;
+_position = _this select 1;
+_typeofgrp = _this select 2;
+
+_currPos = _position;
+_direction =[_currPos,getposATL _npc] call BIS_fnc_DirTo;
+_dir = [_direction + 270, _direction + 90];
+_targetPos = [];
+_isMan = false;
+_dist = 1;
+_mindist = 10;
+_road = [0,100];
+_water = 0;
+
+if (!("ship" in _typeofgrp) && !("air" in _typeofgrp)&& !("car" in _typeofgrp) && !("tank" in _typeofgrp)) then {_isMan = true;};
+
+// find a new target that's not too close to the current position
+
+if (!_isMan) then
+{
+ If (("car" in _typeofgrp) || ("tank" in _typeofgrp) || ("air" in _typeofgrp && (group _npc) getvariable ["UPSMON_MOVELANDING",false])) then
+ {
+ _dist = 10;
+ _mindist = 30;
+ _road = [1,200];
+ }
+ else // boat or plane
+ {
+ If ("air" in _typeofgrp) then
+ {
+ _water = 1;
+ _dist = 0;
+ _mindist = 70;
+ }
+ else // boat
+ {
+ _water = 2;
+ _dist = 0;
+ _mindist = 30;
+ };
+ };
+};
+
+_i = 0;
+
+while {count _targetPos == 0 && _i < 40} do
+{
+ _i = _i + 1;
+ _targetPosTemp = [_position,[0,200],_dir,_water,_road,_dist] call UPSMON_pos;
+ If (count _targetPos == 0) then
+ {
+ If (("car" in _typeofgrp) || ("tank" in _typeofgrp) || ((group _npc) getvariable ["UPSMON_LANDDROP",false])) then
+ {
+ if (!(surfaceIsWater _targetPosTemp)) then
+ {
+ _terrainscan = _targetPosTemp call UPSMON_sample_terrain;
+ If ((_terrainscan select 0) == "meadow" || (_terrainscan select 0) == "forest") then
+ {
+ If ((_terrainscan select 1) < 90) then
+ {
+ If ((count (_targetPosTemp isflatempty [100,0,10,10,0,false,objnull]) > 0) || (isOnRoad _targetPosTemp)) then
+ {
+ _targetpos = _targetPosTemp;
+ };
+ };
+ };
+ };
+ }
+ else
+ {
+ If ("ship" in _typeofgrp && (surfaceIsWater _targetPosTemp)) then
+ {
+ _targetpos = _targetPosTemp;
+ }
+ else
+ {
+ if (!(surfaceIsWater _targetPosTemp) || ("air" in _typeofgrp)) then
+ {
+ _targetpos = _targetPosTemp;
+ };
+ };
+ };
+ };
+ sleep 0.02;
+};
+
+If (count _targetPos == 0) then {_targetPos = _currPos;};
+_targetPos;
+
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_dodisembark.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_dodisembark.sqf
new file mode 100644
index 0000000..6dc8684
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_dodisembark.sqf
@@ -0,0 +1,91 @@
+/****************************************************************
+File: UPSMON_Clones.sqf
+Author: Azroul13
+
+Description:
+ The group dismount the vehicle, if the vehicle is unarmed the driver will dismount too.
+
+Parameter(s):
+ <--- Vehicle which unload his cargo
+ <--- Group disembarking
+Returns:
+ nothing
+****************************************************************/
+
+if (UPSMON_Debug>0) then { player globalchat format["Mon_disembark started"];};
+private ["_transport","_unitsgetout","_grp","_grps","_driver","_driverout"];
+
+_transport = _this select 0;
+_unitsgetout = _this select 1;
+_grp = _this select 2;
+_supstatus = _this select 3;
+
+_transport setvariable ["UPSMON_disembarking",true];
+
+_grps = [];
+_grps pushback _grp;
+
+if (!alive _transport) exitwith{};
+
+_driver = driver _transport;
+
+if ( count _unitsgetout > 0 ) then
+{
+ {
+ If (!(group _x in _grps)) then {_grps pushback (group _x)};
+ } foreach _unitsgetout;
+
+ {
+ _x getvariable ["UPSMON_disembarking",true];
+ } foreach _grps;
+
+ // All units disembark if the vehicle is a Car
+ Dostop _driver;
+ _driver disableAI "MOVE";
+ //Stop the veh for 5.5 sek
+ sleep 1.5; // give time to actualy stop
+
+ if (Isnull (gunner _transport)) then
+ {
+ //We removed the id to the vehicle so it can be reused
+ _transport setVariable ["UPSMON_grpid", 0, false];
+ _transport setVariable ["UPSMON_cargo", [], false];
+
+ // [_npc,_x, _driver] spawn UPSMON_checkleaveVehicle; // if every one outside, make sure driver can walk
+ if (((group _transport) getvariable ["UPSMON_Grpmission",""]) != "TRANSPORT") then
+ {
+ _driver enableAI "MOVE";
+ _unitsgetout pushback _driver
+ };
+
+ //We removed the id to the vehicle so it can be reused
+ _transport setVariable ["UPSMON_grpid", 0, false];
+ };
+
+ If (_supstatus != "") then
+ {
+ _weapons = getarray (configFile >> "CfgVehicles" >> typeof _transport >> "weapons");
+ If ("SmokeLauncher" in _weapons) then
+ {
+ _nosmoke = [_grp] call UPSMON_NOSMOKE;
+ If (!_nosmoke) then {[_transport] spawn UPSMON_DoSmokeScreen;};
+ };
+ };
+ [_transport,_unitsgetout] call UPSMON_UnitsGetOut;
+ _driver enableAI "MOVE";
+
+ _transport setVariable ["UPSMON_cargo", [], false];
+};
+
+If (UPSMON_Debug > 0) then {diag_log format ["transport:%1",_unitsgetout]};
+If (((group _transport) getvariable ["UPSMON_Grpmission",""]) == "TRANSPORT") then
+{
+ [_transport] spawn UPSMON_Returnbase;
+};
+
+_transport setvariable ["UPSMON_disembarking",false];
+{
+ _x getvariable ["UPSMON_disembarking",false];
+ If (_x getvariable ["UPSMON_InTransport",false]) then {_x setvariable ["UPSMON_InTransport",false];};
+ If (_x getvariable ["UPSMON_Grpmission",""] == "WAITTRANSPORT") then {_x setvariable ["UPSMON_Grpmission","PATROL"]};
+} foreach _grps;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_dohelidisembark.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_dohelidisembark.sqf
new file mode 100644
index 0000000..62a1ffa
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_dohelidisembark.sqf
@@ -0,0 +1,58 @@
+/****************************************************************
+File: UPSMON_dohelidisembark.sqf
+Author: Azroul13
+
+Description:
+ Eject the group from the helicopter.
+
+Parameter(s):
+ <--- Vehicle which unload his cargo
+ <--- Group disembarking
+Returns:
+ nothing
+****************************************************************/
+
+private["_transport","_unitsout","_grp","_grps","_timeout"];
+
+_transport = _this select 0;
+_unitsout = _this select 1;
+_grp = _this select 2;
+
+_transport setvariable ["UPSMON_disembarking",true];
+_grp setvariable ["UPSMON_disembarking",true];
+_grps = [];
+
+if (!alive _transport) exitwith{};
+
+{
+ If (!(group _x in _grps)) then {_grps pushback (group _x)};
+} foreach _unitsout;
+
+{
+ _x setvariable ["UPSMON_disembarking",true];
+ _x setVariable ["UPSMON_landing",true];
+} foreach _grps;
+
+//dogetout each of _jumpers
+[_transport,_unitsout] call UPSMON_UnitsGetout;
+
+sleep 3;
+
+[_transport] call UPSMON_Returnbase;
+
+_timeout = 100 + time;
+
+//Waits until all getout of heli
+{
+ waituntil {!canmove _x || !alive _x || movetofailed _x || time > _timeout || isTouchingGround _x};
+ _x switchMove "AmovPercMstpSrasWrflDnon";
+} forEach _unitsout;
+
+
+_transport setvariable ["UPSMON_disembarking",false];
+{
+ _x setvariable ["UPSMON_disembarking",false];
+ If (_x getvariable ["UPSMON_InTransport",false]) then {_x setvariable ["UPSMON_InTransport",false]};
+ If (_x getvariable ["UPSMON_Grpmission",""] == "WAITTRANSPORT") then {_x setvariable ["UPSMON_Grpmission","PATROL"]};
+ _x setVariable ["UPSMON_landing",false];
+} forEach _grps;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_doparadrop.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_doparadrop.sqf
new file mode 100644
index 0000000..e56d31e
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_doparadrop.sqf
@@ -0,0 +1,59 @@
+/****************************************************************
+File: UPSMON_doparadrop.sqf
+Author: Azroul13
+
+Description:
+ Eject the group from the helicopter.
+
+Parameter(s):
+ <--- Vehicle which unload his cargo
+ <--- Group disembarking
+Returns:
+ nothing
+****************************************************************/
+
+private["_transport","_grp","_unitsout","_grps"];
+
+_transport = _this select 0;
+_unitsout = _this select 1;
+_grp = _this select 2;
+
+_transport setvariable ["UPSMON_disembarking",true];
+_grp setvariable ["UPSMON_disembarking",true];
+
+
+_grps = [];
+_grps pushback _grp;
+
+if (!alive _transport) exitwith{};
+
+{
+ If (!(group _x in _grps)) then {_grps pushback (group _x)};
+} foreach _unitsout;
+
+{
+ _x setvariable ["UPSMON_disembarking",true];
+} foreach _grps;
+
+//dogetout each of _jumpers
+[_transport,_unitsout] call UPSMON_EjectUnits;
+
+sleep 3;
+
+[_transport] call UPSMON_Returnbase;
+
+_timeout = 100 + time;
+
+//Waits until all getout of heli
+{
+ waituntil {!canmove _x || !alive _x || movetofailed _x || time > _timeout || isTouchingGround _x};
+ _x switchMove "AmovPercMstpSrasWrflDnon";
+} forEach _unitsout;
+
+
+_transport setvariable ["UPSMON_disembarking",false];
+{
+ _x setvariable ["UPSMON_disembarking",false];
+ If (_x getvariable ["UPSMON_InTransport",false]) then {_x setvariable ["UPSMON_InTransport",false]};
+ If (_x getvariable ["UPSMON_Grpmission",""] == "WAITTRANSPORT") then {_x setvariable ["UPSMON_Grpmission","PATROL"]};
+} foreach _grps;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_getinassignedveh.sqf b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_getinassignedveh.sqf
new file mode 100644
index 0000000..03ecd3b
--- /dev/null
+++ b/scripts/UPSMON/MODULES/ORDERS/UPSMON_Transport/fnc/UPSMON_getinassignedveh.sqf
@@ -0,0 +1,71 @@
+/****************************************************************
+File: UPSMON_getinassignedveh.sqf
+Author: Azroul13
+
+Description:
+ Make Units of the group mount in theirs assigned vehicle
+
+Parameter(s):
+ <--- Group
+ <--- Vehicles assigned to the group
+Returns:
+ nothing
+****************************************************************/
+
+private ["_grp","_assignedvehicle","_validunits","_vehicles","_Cargocount","_Gunnercount","_Commandercount","_Drivercount","_emptypositions","_timeout"];
+
+_grp = _this select 0;
+_assignedvehicle = _this select 1;
+_targetpos = _this select 2;
+_npc = leader _grp;
+_orgbehaviour = behaviour _npc;
+_orgformation = formation _npc;
+_speedmode = Speedmode _npc;
+
+_grp setvariable ["UPSMON_embarking",true];
+(group (driver (_assignedvehicle select 0))) setvariable ["UPSMON_embarking",true];
+
+_vehicles = [];
+_validunits = [units _grp] call UPSMON_Getunits;
+_unitsIn = _validunits;
+{
+ _Cargocount = (_x) emptyPositions "Cargo";
+ _Gunnercount = (_x) emptyPositions "Gunner";
+ _Commandercount = (_x) emptyPositions "Commander";
+ _Drivercount = (_x) emptyPositions "Driver";
+
+ _emptypositions = _Cargocount + _Gunnercount + _Commandercount + _Drivercount;
+
+ if (_emptypositions > 0 && canMove _x) then { _vehicles pushback [vehicle _x,_emptypositions];};
+} foreach _assignedvehicle;
+
+If (count _validunits > 0 && count _vehicles > 0) then
+{
+ _grp setbehaviour "SAFE";
+ _validunits = [_validunits, _vehicles, true] call UPSMON_selectvehicles;
+ _unitsIn = _unitsIn - _validunits;
+ _timeout = time + 50;
+
+ {_x disableAI "MOVE"} foreach _assignedvehicle;
+ {
+ waituntil {vehicle _x != _x || !canmove _x || !canstand _x || !alive _x || time > _timeout || movetofailed _x};
+ } foreach _unitsIn;
+
+ // did the leader die?
+ If (({alive _x} count units _grp) == 0) exitwith {};
+
+ {_x enableAI "MOVE"} foreach _assignedvehicle;
+ _grp setbehaviour _orgbehaviour;
+};
+
+If (count _this > 2) then
+{
+ If (!((driver (_assignedvehicle select 0)) in units _grp)) then
+ {
+ (group (driver (_assignedvehicle select 0))) setvariable ["UPSMON_embarking",false];
+ (group (driver (_assignedvehicle select 0))) setvariable ["UPSMON_Transportmission",["MOVETODEST",[],_grp]];
+ [group (driver (_assignedvehicle select 0)),_this select 2,"MOVE","COLUMN","NORMAL","SAFE","BLUE",1] spawn UPSMON_DocreateWP;
+ };
+ [_grp,_this select 2,"MOVE",_orgformation,_speedmode,_orgbehaviour,"YELLOW",1] spawn UPSMON_DocreateWP;
+};
+_grp setvariable ["UPSMON_embarking",false];
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/UPSMON_CLONES.sqf b/scripts/UPSMON/MODULES/UPSMON_CLONES.sqf
new file mode 100644
index 0000000..608c389
--- /dev/null
+++ b/scripts/UPSMON/MODULES/UPSMON_CLONES.sqf
@@ -0,0 +1,89 @@
+/****************************************************************
+File: UPSMON_Clones.sqf
+Author: Monsada
+
+Description:
+ The script will create X Group with the same parameters and unit than the group of reference
+
+Parameter(s):
+ <--- Parameters of the original group
+ <--- Minimum number of group to create
+ <--- Maximum number of group to create
+Returns:
+ nothing
+****************************************************************/
+
+private ["_Ucthis","_mincopies","_maxcopies","_copies","_grpcnt","_unittype","_grp","_lead","_initstr","_members","_newunit"];
+
+_Ucthis = _this select 0;
+_mincopies = _this select 1;
+_maxcopies = _this select 2;
+
+_npc = _Ucthis select 0;
+_grp = group _npc;
+_members = (_this select 3) select 0;
+_grpcnt = count units _npc;
+_orgPos = (_grp getvariable "UPSMON_Origin") select 0;
+_behaviour = (_grp getvariable "UPSMON_Origin") select 1;
+_speedmode = (_grp getvariable "UPSMON_Origin") select 2;
+If (UPSMON_Debug > 0) then {diag_log format ["%1 copy",_npc];};
+_copies=_mincopies+random (_maxcopies-_mincopies);
+
+// create the clones
+for "_grpcnt" from 1 to _copies do
+{
+ // copy groups
+ if (isNil ("UPSMON_grpindex")) then {UPSMON_grpindex = 0};
+ UPSMON_grpindex = UPSMON_grpindex+1;
+
+ _grp=createGroup (side _npc);
+ // make the clones civilians
+ // use random Civilian models for single unit groups
+ // any init strings?
+ _initstr = ["INIT:","",_UCthis] call UPSMON_getArg;
+ _lead = ObjNull;
+ // copy team members (skip the leader)
+ _c=0;
+ {
+ _unittype = _x select 0;
+ if (((side _npc) == Civilian) && (count _members==1)) then {_rnd=1+round(random 20); if (_rnd>1) then {_unittype=format["Civilian%1",_rnd]}};
+ _roletype = _x select 2;
+ _targetpos = _orgpos findEmptyPosition [5,50];
+ if (count _targetpos == 0) then {_targetpos = _orgpos};
+ _newunit = _grp createUnit [_unittype, _targetpos, [], 0, "FORM"];
+ _newunit setBehaviour _behaviour;
+ _newunit setSpeedMode _speedmode;
+ _equipment = _x select 1;
+ [_newunit,_equipment] call UPSMON_addequipment;
+
+ if (isMultiplayer) then
+ {
+ [[netid _newunit, _initstr], "UPSMON_fnc_setVehicleInit", true, true] spawn BIS_fnc_MP;
+ }
+ else
+ {
+ _unitstr = "_newunit";
+ _index=[_initstr,"this",_unitstr] call UPSMON_Replace;
+ call compile format ["%1",_index];
+ };
+
+ If (count _roletype > 0) then
+ {
+ _crews pushback [_newunit,_roletype];
+ };
+
+ [_newunit] join _grp;
+ If (_c == 0) then
+ {
+ _grp selectLeader _newunit;
+ _lead = _newunit;
+ };
+ _c=_c+1;
+ sleep 0.1;
+ } foreach _members;
+
+ _Ucthis set [0,_lead];
+ nul= _Ucthis spawn UPSMON;
+ //sleep .05;
+};
+sleep .05;
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/UPSMON_ModifyUcthis.sqf b/scripts/UPSMON/MODULES/UPSMON_ModifyUcthis.sqf
new file mode 100644
index 0000000..a4f239f
--- /dev/null
+++ b/scripts/UPSMON/MODULES/UPSMON_ModifyUcthis.sqf
@@ -0,0 +1,17 @@
+
+private ["_npc"];
+
+_npc = _this select 0;
+_grp = group _npc;
+
+If (!IsNull _npc && alive _npc && _grp in UPSMON_NPCs) then
+{
+ _grp setvariable ["UPSMON_Removegroup",true];
+
+ waituntil {!alive _npc || !(_grp in UPSMON_NPCs)};
+
+ If (alive _npc) then
+ {
+ _this execvm "Scripts\UPSMON.sqf";
+ };
+ };
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/UPSMON_RESPAWN.sqf b/scripts/UPSMON/MODULES/UPSMON_RESPAWN.sqf
new file mode 100644
index 0000000..bb35604
--- /dev/null
+++ b/scripts/UPSMON/MODULES/UPSMON_RESPAWN.sqf
@@ -0,0 +1,214 @@
+/****************************************************************
+File: UPSMON_RESPAWN.sqf
+Author: Monsada
+
+Description:
+ The script will create X Group with the same parameters and unit than the group of reference
+
+Parameter(s):
+ <--- Parameters of the original group
+ <--- Surrended (boolean)
+ <--- Side of the group
+Returns:
+ nothing
+****************************************************************/
+private ["_grp","_grpidx","_track","_orgpos","_respawn","_respawnmax","_unittype","_membertypes","_rnd","_grp","_lead","_initstr","_targetpos","_spawned","_vehicletypes","_UCthis","_respawndelay","_group"];
+
+_grp = _this select 0;
+_UCthis = _this select 1;
+
+_side = (_grp getvariable "UPSMON_Origin") select 5;
+_grpid = _grp getvariable ["UPSMON_Grpid",0];
+_removeunit = _grp getvariable ["UPSMON_Removegroup",false];
+
+_dist = 1000;
+_respawnmax = 0;
+
+
+if (UPSMON_Debug>0) then {hint format["%1 exiting mainloop",_grpid]; diag_log format ["exit: %1 %2 %3 %4",_grp,units _grp,alive leader _grp,_removeunit];};
+//Limpiamos variables globales de este grupo
+//UPSMON_targetsPos set [_grpid,[0,0]];
+if (_side == civilian) then
+{
+ if (_grp in UPSMON_Civs) then {UPSMON_Civs = UPSMON_Civs - [_grp];};
+}
+else
+{
+ if (_grp in UPSMON_NPCs) then {UPSMON_NPCs = UPSMON_NPCs - [_grp];};
+};
+
+switch (_side) do
+{
+ case West:
+ {
+ if (_grp in UPSMON_TRANSPORT_WEST_UNITS) then {UPSMON_TRANSPORT_WEST_UNITS = UPSMON_TRANSPORT_WEST_UNITS - [_grp];};
+ if (_grp in UPSMON_REINFORCEMENT_WEST_UNITS) then {UPSMON_REINFORCEMENT_WEST_UNITS = UPSMON_REINFORCEMENT_WEST_UNITS - [_grp];};
+ if (_grp in UPSMON_ARTILLERY_WEST_UNITS) then {UPSMON_ARTILLERY_WEST_UNITS = UPSMON_ARTILLERY_WEST_UNITS - [_grp];};
+ };
+ case EAST:
+ {
+ if (_grp in UPSMON_TRANSPORT_EAST_UNITS) then {UPSMON_TRANSPORT_EAST_UNITS = UPSMON_TRANSPORT_EAST_UNITS - [_grp];};
+ if (_grp in UPSMON_REINFORCEMENT_EAST_UNITS) then {UPSMON_REINFORCEMENT_EAST_UNITS = UPSMON_REINFORCEMENT_EAST_UNITS - [_grp];};
+ if (_grp in UPSMON_ARTILLERY_EAST_UNITS) then {UPSMON_ARTILLERY_EAST_UNITS = UPSMON_ARTILLERY_EAST_UNITS - [_grp];};
+ };
+ case resistance:
+ {
+ if (_grp in UPSMON_TRANSPORT_GUER_UNITS) then {UPSMON_TRANSPORT_GUER_UNITS = UPSMON_TRANSPORT_GUER_UNITS - [_grp];};
+ if (_grp in UPSMON_REINFORCEMENT_GUER_UNITS) then {UPSMON_REINFORCEMENT_GUER_UNITS = UPSMON_REINFORCEMENT_GUER_UNITS - [_grp];};
+ if (_grp in UPSMON_ARTILLERY_GUER_UNITS) then {UPSMON_ARTILLERY_GUER_UNITS = UPSMON_ARTILLERY_GUER_UNITS - [_grp];};
+ };
+
+};
+
+UPSMON_Exited=UPSMON_Exited+1;
+
+If (!_removeunit) then
+{
+
+ sleep (_grp getvariable ["UPSMON_RESPAWNDELAY",0]);
+
+ _respawnmax = _grp getvariable ["UPSMON_RESPAWNTIME",0];
+ _orgpos = _grp getvariable "UPSMON_RESPAWNPOS";
+ //Verify if targets near respawn
+ _mensnear = _orgpos nearentities [["CAManBase","TANK","CAR"],800];
+ _enemySides = _side call BIS_fnc_enemySides;
+ _enynear = false;
+ {
+ If (side _x in _enemySides) then {_enynear = true;}
+ } foreach _mensnear;
+
+ //does respawn of group =====================================================================================================
+ if (_grp getvariable ["UPSMON_RESPAWN",false] && _respawnmax > 0 && (_grp getvariable ["UPSMON_Grpmission",""] != "SURRENDER") && !_enynear) then
+ {
+ if (UPSMON_Debug>0) then {player sidechat format["%1 doing respawn",_grpid]};
+
+ _membertypes = (_grp getvariable "UPSMON_RESPAWNUNITS") select 0;
+ _vehicletypes = (_grp getvariable "UPSMON_RESPAWNUNITS") select 1;
+ _crews = [];
+
+ // any init strings?
+ _initstr = ["INIT:","",_UCthis] call UPSMON_getArg;
+
+ // make the clones civilians
+ // use random Civilian models for single unit groups
+
+ _group = createGroup _side;
+
+ _lead = ObjNull;
+ // copy team members (skip the leader)
+ _i=0;
+ {
+ _unittype = _x select 0;
+ if (_side == Civilian) then {_rnd=1+round(random 20); if (_rnd>1) then {_unittype=format["Civilian%1",_rnd]}};
+ _roletype = _x select 2;
+ _targetpos = _orgpos findEmptyPosition [5,50];
+ if (count _targetpos == 0) then {_targetpos = _orgpos};
+ _newunit = _group createUnit [_unittype, _targetpos, [], 0, "FORM"];
+ _equipment = _x select 1;
+ [_newunit,_equipment] call UPSMON_addequipment;
+
+ if (isMultiplayer) then
+ {
+ [[netid _newunit, _initstr], "UPSMON_fnc_setVehicleInit", true, true] spawn BIS_fnc_MP;
+ } else
+ {
+ _unitstr = "_newunit";
+ _index=[_initstr,"this",_unitstr] call UPSMON_Replace;
+ call compile format ["%1",_index];
+ };
+
+ If (count _roletype > 0) then
+ {
+ _crews pushback [_newunit,_roletype];
+ };
+
+ [_newunit] join _group;
+ If (_i == 0) then
+ {
+ _group selectLeader _newunit;
+ _lead = _newunit;
+ };
+ _i=_i+1;
+ sleep 0.1;
+ } foreach _membertypes;
+
+
+ if ( _lead == vehicle _lead) then {
+ {
+ if (alive _x && canmove _x) then
+ {
+ [_x] dofollow _lead;
+ };
+ sleep 0.1;
+ } foreach units _lead;
+ };
+
+ {
+ _vehicle = _x;
+ _targetpos = _orgpos findEmptyPosition [10, 200];
+ if (count _targetpos == 0) then {_targetpos = _orgpos};
+ //if (UPSMON_Debug>0) then {player globalchat format["%1 create vehicle _newpos %2 ",_x,_targetpos]};
+ _newunit = (_vehicle select 0) createvehicle (_targetpos);
+ _newunit setdir (_vehicle select 1);
+ {
+ _crew = _x select 0;
+ _role = (_x select 1) select 0;
+ unassignVehicle _crew;
+ switch (_role) do
+ {
+ case "driver":
+ {
+ _crew moveindriver _newunit
+ };
+ case "commander":
+ {
+ _crew moveincommander _newunit
+ };
+ case "Turret":
+ {
+ _crew moveInTurret [_newunit,(_x select 1) select 1]
+ };
+ case "cargo":
+ {
+ _crew moveinCargo _newunit
+ };
+ case "default":
+ {
+ };
+ };
+ sleep 0.02;
+ } foreach _crews;
+ } foreach _vehicletypes;
+
+
+ //if (UPSMON_Debug>0) then {player globalchat format["%1 _vehicletypes: %2",_grpidx, _vehicletypes]};
+
+ _spawned= if ("SPAWNED" in _UCthis) then {true} else {false};
+ //Set new parameters
+ if (!_spawned) then
+ {
+
+ _UCthis = _UCthis + ["SPAWNED"];
+
+ if ((count _vehicletypes) > 0) then
+ {
+ _UCthis = _UCthis + ["VEHTYPE:"] + ["dummyveh"];
+ };
+ };
+
+
+ _UCthis set [0,_lead];
+ _respawnmax = _respawnmax - 1;
+ _UCthis = ["RESPAWN:",_respawnmax,_UCthis] call UPSMON_setArg;
+ sleep 0.1;
+ _UCthis = ["VEHTYPE:",_vehicletypes,_UCthis] call UPSMON_setArg;
+
+ //Exec UPSMON script
+ _UCthis spawn UPSMON;
+ sleep 0.1;
+ };
+};
+
+if (({alive _x} count units _grp) == 0 ) then {
+ deleteGroup _grp;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/MODULES/UPSMON_spawn.sqf b/scripts/UPSMON/MODULES/UPSMON_spawn.sqf
new file mode 100644
index 0000000..09ec4f9
--- /dev/null
+++ b/scripts/UPSMON/MODULES/UPSMON_spawn.sqf
@@ -0,0 +1,157 @@
+
+/****************************************************************
+File: UPSMON_spawn.sqf
+Author: Monsada
+
+Description:
+ The script will spawn a squad based on a template.
+ Called by the mission creator:
+ nul = [1,[0,0,0],3,[mark, upsmon optional params]] EXECVM "SCRIPTS\UPSMON\MODULES\UPSMON_SPAWN.SQF";
+
+Parameter(s):
+ <--- Id of the template to copy.
+ <--- Position to create new squad.
+ <--- Number of squads to create
+ <--- Array of parameters of UPSMON, first must be name of marker to patrol
+Returns:
+ nothing
+****************************************************************/
+
+ //if (!isserver) exitWith {};
+if (!isServer) exitWith {};
+
+//Waits until UPSMON is init
+waitUntil {!isNil("UPSMON_INIT")};
+waitUntil {UPSMON_INIT==1};
+private ["_template","_position","_params","_copies","_membertypes","_unittype","_side","_UCthis","_initstr","_grp","_lead","_newunit","_i","_newpos","_vehicle","_initlstr"];
+
+//Parameter reading
+_template = _this select 0;
+_position = _this select 1;
+_copies = _this select 2;
+_params = _this select 3;
+
+//Initialization
+_membertypes = [];
+_side = "";
+_UCthis = [];
+_initstr = "";
+_initlstr = "";
+_grp = grpnull;
+_lead = objnull;
+_newunit = objnull;
+_newpos=[];
+_vehicle=[];
+
+//Gets parameters of UPSMON
+for [{_i=0},{_i0) then {player globalchat format["Spawning %3 copies of template %1",_template,_position,_copies,count UPSMON_TEMPLATES]};
+if (UPSMON_Debug>0) then {diag_log format["Spawning %3 copies of template %1 on %2 templates %4",_template,_position,_copies,UPSMON_TEMPLATES]};
+
+//Search if any template
+{
+ if ((_x select 0) == _template) then
+ {
+ _side = _x select 1;
+ _membertypes = _x select 2;
+ _vehicletypes = _x select 3;
+ //Gets leader type
+ if (UPSMON_Debug>0) then {diag_log format["template %1 side %2 membertypes %3",_template,_side,_membertypes]};
+ //if (UPSMON_Debug>0) then {player globalchat format["template %1:%2 ",_template,_membertypes]};
+ // any init strings?
+ _initstr = ["INIT:","",_UCthis] call UPSMON_getArg;
+
+ for [{_i=1},{_i<=_copies},{_i=_i+1}] do
+ {
+
+ // make the clones civilians
+ // use random Civilian models for single unit groups
+ //if ((_side == "Civilian") && (count _members==1)) then {_rnd=1+round(random 20); if (_rnd>1) then {_unittype=format["Civilian%1",_rnd]}};
+
+ _grp=createGroup _side;
+
+ _lead = ObjNull;
+ // copy team members (skip the leader)
+ _c=0;
+ {
+ _unittype = _x select 0;
+ _roletype = _x select 2;
+ _targetpos = _orgpos findEmptyPosition [5,50];
+ if (count _targetpos == 0) then {_targetpos = _orgpos};
+ _newunit = _grp createUnit [_unittype, _targetpos, [], 0, "FORM"];
+ _equipment = _x select 1;
+ [_newunit,_equipment] call UPSMON_addequipment;
+
+ if (isMultiplayer) then
+ {
+ [[netid _newunit, _initstr], "UPSMON_fnc_setVehicleInit", true, true] spawn BIS_fnc_MP;
+ } else
+ {
+ _unitstr = "_newunit";
+ _index=[_initstr,"this",_unitstr] call UPSMON_Replace;
+ call compile format ["%1",_index];
+ };
+
+ If (count _roletype > 0) then
+ {
+ _crews pushback [_newunit,_roletype];
+ };
+
+ [_newunit] join _grp;
+ If (_c == 0) then
+ {
+ _grp selectLeader _newunit;
+ _lead = _newunit;
+ };
+ _c=_c+1;
+ sleep 0.1;
+ } foreach _membertypes;
+
+
+ {
+ _vehicle = _x;
+ _targetpos = _orgpos findEmptyPosition [10, 200];
+ sleep .4;
+ if (count _targetpos <= 0) then {_targetpos = _orgpos};
+ //if (UPSMON_Debug>0) then {player globalchat format["%1 create vehicle _newpos %2 ",_x,_targetpos]};
+ _newunit = (_x select 0) createvehicle (_targetpos);
+ _newunit setdir (_x select 1);
+ _crews = _x select 2;
+ {
+ _crew = _x select 1;
+ _role = (_x select 2) select 0;
+ _newunit = _grp createUnit [_crew, _orgpos, [], 0, "FORM"];
+ switch (_role) do
+ {
+ case "Driver":
+ {
+ _newunit moveindriver _vehicle
+ };
+ case "COMMANDER":
+ {
+ _newunit moveincommander _vehicle
+ };
+ case "TURRET":
+ {
+ _newunit moveInTurret [_vehicle,(_x select 2) select 1]
+ };
+ };
+ } foreach _crews;
+ } foreach _vehicletypes;
+
+ //Set new parameters
+ _params = [_lead] + _UCthis;
+
+ //Exec UPSMON script
+ _params SPAWN UPSMON;
+ };
+ };
+}foreach UPSMON_TEMPLATES;
+
+if (true) exitwith{};
\ No newline at end of file
diff --git a/scripts/UPSMON/MON_artillery_add.sqf b/scripts/UPSMON/MON_artillery_add.sqf
new file mode 100644
index 0000000..3c8aa38
--- /dev/null
+++ b/scripts/UPSMON/MON_artillery_add.sqf
@@ -0,0 +1,57 @@
+/* =====================================================================================================
+ MON_spawn.sqf
+ Author: Monsada (chs.monsada@gmail.com)
+ Comunidad Hispana de Simulación:
+ http://www.simulacion-esp.com
+ =====================================================================================================
+ Parámeters: [_artillery,(_rounds,_area,_cadence,_mincadence)] execvm "scripts\UPSMON\MON_artillery_add.sqf";
+ <- _artillery object to attach artillery script, must be an object with gunner.
+ <- ( _rounds ) number of rounds for the artillery [FLARE,SMOKE,HE]
+ <- ( _area ) Dispersion area, 150m by default
+ <- ( _maxcadence ) Cadence of fire, is random between min, default 10s
+ <- ( _mincadence ) Minimum cadence, default 5s
+ =====================================================================================================
+ 1. Place a static weapon on map.
+ 2. Exec module in int of static weapon
+
+ nul=[this] execVM "scripts\UPSMON\MON_artillery_add.sqf";
+
+ 1. Be sure static weapon has a gunner or place a "fortify" squad near, this will make squad to take static weapon.
+ 2. Create a trigger in your mission for setting when to fire. Set side artillery variable to true:
+
+ UPSMON_ARTILLERY_EAST_FIRE = true;
+
+ This sample will do east artilleries to fire on known enemies position, when you want to stop fire set to false.
+
+ For more info:
+ http://dev-heaven.net/projects/upsmon/wiki/Artillery_module
+ =====================================================================================================*/
+//if (!isserver) exitWith {};
+if (!isServer) exitWith {};
+
+//Waits until UPSMON is init
+waitUntil {!isNil("UPSMON_INIT")};
+waitUntil {UPSMON_INIT==1};
+
+private ["_area","_maxcadence","_mincadence","_rounds","_vector","_grpmission","_grp","_cfgArtillery","_grpunits","_batteryunits","_assistsmortar","_unit","_vehicle","_result","_staticteam","_artimuntype","_id","_foundshell","_foundsmoke","_foundrocket","_foundillum","_vector","_sidearty"];
+
+_area = 50;
+_maxcadence = 6;
+_mincadence = 3;
+_rounds = [10,30,50];
+_unit = _this select 0;
+
+If (!alive _unit) exitwith {};
+
+_grp = group _unit;
+
+if ((count _this) > 1) then {_rounds = _this select 1;};
+if ((count _this) > 2) then {_area = _this select 2;};
+if ((count _this) > 3) then {_maxcadence = _this select 3;};
+if ((count _this) > 4) then {_mincadence = _this select 4;};
+
+_grp setvariable ["UPSMON_Artilleryarea",_area];
+_grp setvariable ["UPSMON_Artillerymaxcadence",_maxcadence];
+_grp setvariable ["UPSMON_Artillerymincadence",_mincadence];
+
+[_unit,"DummyUPSMONMarker","NOWP3"] spawn UPSMON;
\ No newline at end of file
diff --git a/scripts/UPSMON/UPSMON_CreateGroup.sqf b/scripts/UPSMON/UPSMON_CreateGroup.sqf
new file mode 100644
index 0000000..00386a1
--- /dev/null
+++ b/scripts/UPSMON/UPSMON_CreateGroup.sqf
@@ -0,0 +1,94 @@
+/* =====================================================================================================
+ UPSMON_CreateGroup.sqf
+ Author: Azroul13
+ =====================================================================================================
+ Parámeters: _grp = [position,side,[unitsarray],[min units,max units per group],3,["markername","SAFE","COLUMN"]] call UPSMON_CreateGroup;
+ <- _position Position where the group will spawn
+ <- side Side of the group (EAST,WEST,GUER,CIVILIAN)
+ <- [unitsarray] Array with classname of unit you want to spawn (classname will be choose randomly)
+ <- [min,max] Minimum and maximun units you want to spawn in the group [1,4]
+ <- 3 amount of mandatory units
+ <- ["markername"] UPSMON parameters for the group
+ =====================================================================================================
+ =====================================================================================================*/
+if (!isServer && hasInterface ) exitWith {};
+
+if (isNil("UPSMON_INIT")) then {
+ UPSMON_INIT=0;
+};
+
+waitUntil {UPSMON_INIT==1};
+
+private ["_position","_side","_unitsarray","_options1","_size","_ucthis","_lead","_unitsnbr","_min","_max","_unitstype","_unitstypes2","_unitpos","_unit","_vehicle","_crew"];
+
+ _position = _this select 0;
+ _side = _this select 1;
+ _unitsarray = _this select 2;
+ _options1 = _this select 3;
+ _size = _this select 4;
+ _ucthis = _this select 5;
+
+ _lead = ObjNull;
+ _unitsnbr = 1;
+ _min = _options1 select 0;
+ _max = _options1 select 1;
+ If (_min > _max) then {_min = _max};
+ _unitsnbr = _min+random (_max-_min);
+ _unitstypes2 = _unitsarray;
+ _unitstypes2 = _unitstypes2 call UPSMON_arrayShufflePlus;
+
+ _grp = createGroup _side;
+
+for [{_i=0}, {_i<_unitsnbr}, {_i=_i+1}] do
+{
+ _unitpos = _position findEmptyPosition [2,20];
+ if (count _unitpos == 0) then {_unitpos = _position};
+ _unittype = "";
+
+ If ((_i + 1) <= _size) then
+ {
+ _unittype = (_unitsarray) select _i;
+ }
+ else
+ {
+ _unittype = _unitstypes2 select (floor (random (count _unitstypes2)));
+ };
+
+ _unit = ObjNull;
+
+ //If the type of the unit is a vehicle then spawn some crews
+ If (!(_unittype iskindof "CAManBase")) then
+ {
+ _vehicle = createVehicle [_unittype,_unitpos,[], 0, "NONE"];
+ _crew = tolower gettext (configFile >> "CfgVehicles" >> _unittype >> "crew");
+ {
+ _unit = _grp createUnit [_crew, _unitpos, [], 0, "form"];
+ Unassignvehicle _unit;
+
+ If ((_vehicle emptyPositions _x) > 0) then
+ {
+ If ("DRIVER" == _x) then {_unit moveindriver _vehicle};
+ If ("GUNNER" == _x) then {_unit moveingunner _vehicle};
+ If ("COMMANDER" == _x) then {_unit moveincommander _vehicle};
+ };
+ [_unit] join _grp;
+ } foreach ["DRIVER","GUNNER","COMMANDER"];
+ }
+ else
+ {
+ _unit = _grp createUnit [_unittype, _unitpos, [], 0, "form"];
+ [_unit] join _grp;
+ };
+
+ If (_i == 0) then
+ {
+ _lead = _unit;
+ };
+};
+
+_grp selectLeader _lead;
+_ucthis = [_lead] + _Ucthis;
+
+_Ucthis spawn UPSMON;
+
+_grp;
\ No newline at end of file
diff --git a/scripts/UPSMON/UPSMON_MAINLOOP.sqf b/scripts/UPSMON/UPSMON_MAINLOOP.sqf
new file mode 100644
index 0000000..1d660fc
--- /dev/null
+++ b/scripts/UPSMON/UPSMON_MAINLOOP.sqf
@@ -0,0 +1,965 @@
+while {true} do
+{
+ _cycle = ((random 1) + 1);
+ {
+ If (!IsNull _x) then
+ {
+ _grp = _x;
+
+ _members = (_grp getvariable "UPSMON_Origin") select 4;
+
+ _grpmission = _grp getvariable "UPSMON_GrpMission";
+ _grpstatus = _grp getvariable "UPSMON_Grpstatus";
+
+ _grpid = _grp getVariable "UPSMON_grpid";
+ _Ucthis = _grp getvariable "UPSMON_Ucthis";
+
+ _lastcurrpos = (_grp getvariable "UPSMON_Lastinfos") select 0;
+ _lastpos = (_grp getvariable "UPSMON_Lastinfos") select 1;
+ _lastattackpos = _grp getvariable ["UPSMON_Lastattackpos",[]];
+
+ _areamarker = _Ucthis select 1;
+ _surrended = false;
+
+ if (({alive _x && !(captive _x)} count units _grp) == 0 || _grp getvariable ["UPSMON_Removegroup",false]) exitwith
+ {
+ [_grp,_UCthis] call UPSMON_RESPAWN;
+ };
+
+ _npc = leader _grp;
+ _driver = driver (vehicle _npc);
+
+ // did the leader die?
+ _npc = [_npc,_grp] call UPSMON_getleader;
+ if (!alive _npc || isplayer _npc) exitwith {[_grp,_UCthis] call UPSMON_RESPAWN;};
+
+ _buildingdist = 50;
+ _deadbodiesnear = false;
+ _stuck = false;
+ _makenewtarget = false;
+ _haslos = false;
+ _terrainscan = ["meadow",10];
+ _targetpos = [0,0];
+ _Attackpos = [];
+ _opfknowval = 0;
+ _wptype = "MOVE";
+ _targetdist = 1000;
+ _traveldist = 0;
+ _dist = 10000;
+ _ratio = 0.5;
+ _safemode = ["CARELESS","SAFE"];
+
+ _target = ObjNull;
+ _typeofeni = [];
+
+ _speedmode = speedmode _npc;
+ _behaviour = behaviour _npc;
+ _combatmode = "YELLOW";
+
+
+ // current position
+ _currPos = getposATL _npc;
+
+ If (count(waypoints _grp) != 0) then
+ {
+ _wppos = waypointPosition [_grp,count(waypoints _grp)-1];
+ _targetpos = _wppos;
+ _wptype = waypointType [_grp,count(waypoints _grp)-1];
+ _targetdist = [_currpos,_targetpos] call UPSMON_distancePosSqr;
+ };
+
+ _grpcomposition = [_grp] call UPSMON_analysegrp;
+ _typeofgrp = _grpcomposition select 0;
+ _capacityofgrp = _grpcomposition select 1;
+ _assignedvehicle = _grpcomposition select 2;
+ _weaponrange = _grpcomposition select 3;
+
+ _supstatus = [_grp] call UPSMON_supstatestatus;
+ _nowp = [_grp,_target,_supstatus] call UPSMON_NOWP;
+
+ If (_grp getvariable ["UPSMON_NOAI",false]) then
+ {
+ _fixedtargetPos = [_grp,_lastpos] call UPSMON_GetReinfPos;
+ if (count _fixedtargetPos > 0) then {_targetpos = _fixedtargetPos;};
+
+ _terrainscan = _currpos call UPSMON_sample_terrain;
+ _unitsneedammo = [_npc] call UPSMON_checkmunition;
+ _vehiclesneedsupply = [_assignedvehicle] call UPSMON_Checkvehiclesstatus;
+
+//*********************************************************************************************************************
+// Acquisition of the target
+//*********************************************************************************************************************
+ _TargetSearch = [_grp] call UPSMON_TargetAcquisition;
+ _Enemies = _TargetSearch select 0;
+ _Allies = _TargetSearch select 1;
+ _target = _TargetSearch select 2;
+ _dist = _TargetSearch select 3;
+ _targetsnear = _TargetSearch select 4;
+ _attackPos = _TargetSearch select 5;
+ _suspectenies = _TargetSearch select 6;
+ _opfknowval = _TargetSearch select 7;
+
+ if (_opfknowval > 0) then
+ {
+ If (_grp getvariable ["UPSMON_lastOpfknowval",0] < _opfknowval) then
+ {
+ _timeontarget = (_grp getvariable ["UPSMON_TIMEONTARGET",time]) - 10;
+ _grp setvariable ["UPSMON_TIMEONTARGET",_timeontarget];
+ };
+ };
+//*********************************************************************************************************************
+// Reactions
+//*********************************************************************************************************************
+
+ _nowp = [_grp,_target,_supstatus] call UPSMON_NOWP;
+
+ If (!IsNull _target) then
+ {
+ _grp setvariable ["UPSMON_Grpstatus","RED"];
+
+ _haslos = [_npc,_target,_weaponrange,130] call UPSMON_Haslos;
+
+ //Analyse Targets && Allies
+ _Situation = [_grp,_Allies,_Enemies] call UPSMON_Checkratio;
+ _ratio = _Situation select 0;
+ _enicapacity = _Situation select 1;
+ _typeofeni = _Situation select 2;
+
+ //Retreat
+ [_grp,_dist,_ratio,_supstatus,_unitsneedammo,_typeofgrp,_attackpos,_assignedvehicle] call UPSMON_IsRetreating;
+
+ //Surrender
+ [_grp,_dist,_ratio,_supstatus,_unitsneedammo,_typeofgrp,_haslos] call UPSMON_IsSurrending;
+
+ If (_grp getvariable ["UPSMON_Grpmission",""] == "SURRENDER") exitwith {[_grp] call UPSMON_surrended;};
+
+ // Artillery Support
+ _artillery = [_grp] call UPSMON_ArtiChk;
+ If (_artillery) then
+ {
+ [_grp,_currpos,_attackpos,_dist,_enies] call UPSMON_FO;
+ };
+
+ // Reinforcement Support
+ _reinf = [_grp,_ratio,_typeofgrp] call UPSMON_ReinfChk;
+ If (_reinf) then
+ {
+ [_grp,_currpos,_attackpos,_radiorange,_enicapacity] spawn UPSMON_CallRenf;
+ };
+ };
+
+ if (_supstatus == "SUPRESSED") then
+ {
+ _timeontarget = (_grp getvariable ["UPSMON_TIMEONTARGET",time]) + 30;
+ _grp setvariable ["UPSMON_TIMEONTARGET",_timeontarget];
+ };
+
+ _nowp = [_grp,_target,_supstatus] call UPSMON_NOWP;
+ _maneuver = [_grp,_nowp,_attackpos,_typeofgrp] call UPSMON_Cangrpmaneuver;
+
+ If (_maneuver) then
+ {
+ If ("air" in _typeofgrp) then
+ {
+ [_grp,_attackpos,_lastattackpos,_typeofgrp,_dist] call UPSMON_PLANASSLT;
+ _grp setvariable ["UPSMON_Grpmission","ASSAULT"];
+ _grpstatus = "PURPLE";
+ }
+ else
+ {
+ If ("ship" in _typeofgrp) then
+ {
+ If (_dist < 300 && (surfaceIsWater _attackpos)) then
+ {
+ [_grp,_attackpos,_lastattackpos,_typeofgrp,_dist] call UPSMON_PLANASSLT;
+ _grp setvariable ["UPSMON_Grpstatus","BLACK"];
+ }
+ else
+ {
+ [_grp,_attackpos,_lastattackpos,_dist,_typeofgrp,_terrainscan,_areamarker,_haslos] call UPSMON_PLANFLANK;
+ };
+ }
+ else
+ {
+ If (_ratio < 1.2 && (_supstatus != "SUPRESSED")) then
+ {
+ _inmarker = [_attackpos,_areamarker] call UPSMON_pos_fnc_isBlacklisted;
+ // Offensive Behaviour
+ If (_dist <= 300 && ({alive _x && !(captive _x)} count units _grp) >= 4 && !("arti" in _typeofgrp) && (!(_grp getvariable ["UPSMON_NOFOLLOW",false]) || !_inmarker)) then
+ {
+ //Assault
+ If ("car" in _typeofgrp && !("infantry" in _typeofgrp)) then
+ {
+ _terrainscantarget = _attackpos call UPSMON_sample_terrain;
+
+ If (((_terrainscantarget) select 0 == "inhabited" || (_terrainscantarget) select 0 == "forest") && (_terrainscantarget) select 1 > 100) then
+ {
+ [_grp,_attackpos,_lastattackpos,_dist,_typeofgrp,_terrainscan,_areamarker,_haslos] call UPSMON_PLANFLANK;
+ }
+ else
+ {
+ [_grp,_attackpos,_lastattackpos,_typeofgrp,_dist] call UPSMON_PLANASSLT;
+ _grp setvariable ["UPSMON_Grpstatus","BLACK"];
+ };
+ }
+ else
+ {
+ [_grp,_attackpos,_lastattackpos,_typeofgrp,_dist,_targetdist] call UPSMON_PLANASSLT;
+ _grp setvariable ["UPSMON_Grpstatus","BLACK"];
+ };
+ }
+ else
+ {
+ If (("staticbag" in _typeofgrp) || (_grp getvariable ["UPSMON_NOFOLLOW",false] && _inmarker)) then
+ {
+ If ((_haslos && _dist <= _weaponrange && _dist > 300) || (_grp getvariable ["UPSMON_NOFOLLOW",false] && _inmarker)) then
+ {
+ //SUPPORT
+ //[_grp] call UPSMON_PLANSPT;
+ if (_wptype != "HOLD") then
+ {
+ _timeorder = time + 15;
+ _grp setvariable ["UPSMON_TIMEORDER",_timeorder];
+ [_grp,_currpos,"HOLD","LINE","LIMITED","STEALTH","YELLOW",1] call UPSMON_DocreateWP;
+ };
+ _grp setvariable ["UPSMON_Grpmission","SUPPORT"];
+ _grp setvariable ["UPSMON_Grpstatus","PURPLE"];
+ }
+ else
+ {
+ //FLANK
+ [_grp,_attackpos,_lastattackpos,_dist,_typeofgrp,_terrainscan,_areamarker,_haslos,_targetpos,_currpos] call UPSMON_PLANFLANK;
+ };
+ }
+ else
+ {
+ //FLANK
+ [_grp,_attackpos,_lastattackpos,_dist,_typeofgrp,_terrainscan,_areamarker,_haslos,_targetpos,_currpos] call UPSMON_PLANFLANK;
+ };
+ };
+ }
+ else
+ {
+ //Defensive Behaviour
+ if (_wptype != "HOLD") then
+ {
+ [_grp,_dist,_target,_supstatus,_terrainscan] spawn UPSMON_DODEFEND;
+ _timeorder = time + 5;
+ _grp setvariable ["UPSMON_TIMEORDER",_timeorder];
+ };
+ _grp setvariable ["UPSMON_Grpmission","DEFEND"];
+ };
+ };
+ };
+ };
+
+ If (IsNull _target) then
+ {
+ If (count (_grp getvariable ["UPSMON_attackpos",[]]) == 0) then
+ {
+ If (count _suspectenies > 0) then
+ {
+ _suspectenies = [_suspectenies, [], { _currpos distance ((_x getvariable "UPSMON_TargetInfos") select 0)}, "ASCEND"] call BIS_fnc_sortBy;
+ _suspectpos = ((_suspectenies select 0) getvariable "UPSMON_TargetInfos") select 0;
+ _grp setvariable ["UPSMON_SuspectPos",_suspectpos];
+ };
+ };
+
+ If (_supstatus != "" || count (_grp getvariable ["UPSMON_SuspectPos",[]]) > 0) then
+ {
+ _artipos = _grp getvariable ["UPSMON_SuspectPos",[]];
+
+ If (count _artipos > 0) then
+ {
+ [_grp,(_grp getvariable "UPSMON_SuspectPos"),_currpos] call UPSMON_GETINPATROLSRCH;
+ };
+ If ([] call UPSMON_Nighttime) then
+ {
+ If (!(UPSMON_FlareInTheAir)) then
+ {
+
+ If (count _artipos == 0) then
+ {
+ _artipos = [_currpos,[100,200],[0,360],0,[0,100],0] call UPSMON_pos;
+ };
+
+ If (count _artipos > 0) then
+ {
+ _artillery = [_grp] call UPSMON_ArtiChk;
+ If (_artillery) then
+ {
+ [_grp,_currpos,_artipos,_dist,_enies,"ILLUM"] call UPSMON_FO;
+ }
+ else
+ {
+ If (_supstatus != "SUPRESSED") then
+ {
+ //Fire Flare
+ [_grp,_artipos] call UPSMON_FireFlare;
+ };
+ };
+ };
+ };
+ }
+ else
+ {
+ If (_supstatus == "SUPRESSED") then
+ {
+ _smokepos = _grp getvariable ["UPSMON_SuspectPos",[]];
+ If (count _smokepos == 0) then
+ {
+ _smokepos = [_currpos,[30,100],[0,360],0,[0,100],0] call UPSMON_pos;
+ };
+
+ If (count _smokepos > 0) then
+ {
+ _nosmoke = [_grp] call UPSMON_NOSMOKE;
+ If (!_nosmoke) then {[units _grp,_smokepos] spawn UPSMON_CreateSmokeCover;};
+ };
+ };
+ };
+ };
+ };
+
+ _targetdist = [_currpos,_targetpos] call UPSMON_distancePosSqr;
+
+ [_grp,_supstatus,_attackpos,_dist,_terrainscan,_haslos,_typeofgrp] call UPSMON_ChangeFormation;
+
+ If ("arti" in _typeofgrp) then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "RETREAT") then
+ {
+ If (!(_grp getvariable ["UPSMON_OnBattery",false])) then
+ {
+ If (count _attackpos > 0 || count (_grp getvariable ["UPSMON_Artifiremission",[]]) > 0) then
+ {
+ _artitarget = _attackpos;
+ If (count (_grp getvariable ["UPSMON_Artifiremission",[]]) > 0) then {_artitarget = (_grp getvariable ["UPSMON_Artifiremission",[]]) select 0;};
+ [_grp,_typeofgrp,_nowp,_artitarget] spawn UPSMON_artillerysetbattery;
+ if (_grp getvariable ["UPSMON_Grpmission",""] != "FIREMISSION") then
+ {
+ _grp setvariable ["UPSMON_Grpmission","FIREMISSION"];
+ };
+ };
+ };
+ };
+ };
+
+ If (_grp getvariable ["UPSMON_TRANSPORT",false]) then
+ {
+ If (!(_grp getvariable ["UPSMON_GrpInAction",false])) then
+ {
+ If (count (_grp getvariable ["UPSMON_Transportmission",[]]) > 0) then
+ {
+ _grp setvariable ["UPSMON_Grpmission","TRANSPORT"];
+ };
+ };
+ };
+
+ If (_grp getvariable ["UPSMON_Supply",false]) then
+ {
+ If (!(_grp getvariable ["UPSMON_GrpInAction",false])) then
+ {
+ If (count (_grp getvariable ["UPSMON_Supplymission",[]]) > 0) then
+ {
+ _grp setvariable ["UPSMON_Grpmission","SUPPLY"];
+ };
+ };
+ };
+
+ If (_grpstatus == "GREEN") then
+ {
+ _dead = ObjNull;
+ //If in safe mode if find dead bodies change behaviour
+ if (UPSMON_deadBodiesReact)then
+ {
+ {
+ if (alive _x) then
+ {
+ if (vehicle _x == _x) then
+ {
+ _dead = [_x,_buildingdist] call UPSMON_deadbodies;
+ if (!IsNull _dead) exitwith
+ {
+ _deadbodiesnear = true;
+ _grp setvariable ["UPSMON_Grpstatus","YELLOW"];
+ };
+ };
+ };
+ } foreach units _grp;
+
+ If (_deadbodiesnear) then
+ {
+ [_grp,getposATL _dead,_currpos] call UPSMON_GETINPATROLSRCH;
+ };
+ };
+
+ //Stuck control
+ _stuck = [_npc,_lastcurrpos,_currpos] call UPSMON_Isgrpstuck;
+ }
+ else
+ {
+ If (IsNull _target) then
+ {
+ _grpstatus = "YELLOW";
+ };
+ };
+
+ }; // End NOAI
+
+ If ("air" in _typeofgrp || "car" in _typeofgrp || "tank" in _typeofgrp) then
+ {
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "RESSUPLY") then
+ {
+ If ((_grp getvariable ["UPSMON_Grpstatus","GREEN"] == "GREEN") || (_grp getvariable ["UPSMON_Grpmission",""] == "DEFEND") || ("air" in _typeofgrp)) then
+ {
+ If (_dist > 800) then
+ {
+ //_supplyunit = [_grp] call UPSMON_getsupply;
+ //If (!IsNull _supplyunit) then
+ //{
+ //_grp setvariable ["UPSMON_Grpmission","RESSUPLY"];
+ //_grp setvariable ["UPSMON_SupplyGrp",_supplyunit];
+ //_supplypos = [_grp] call UPSMON_GetSupplyPos;
+ //_supplyunit setvariable ["UPSMON_Supplymission",[_grp,_vehiclesneedsupply,_supplypos]];
+ //}
+ //else
+ //{
+ //If ("air" in _typeofgrp) then
+ //{
+ //_basepos = (_grp getvariable "UPSMON_Origin") select 0;
+ //[_grp,_basepos,"MOVE","COLUMN","FULL","CARELESS","YELLOW",1,UPSMON_flyInHeight] call UPSMON_DocreateWP;
+ //_grp setvariable ["UPSMON_Grpmission","RESSUPLY"];
+ //}
+ //};
+ };
+ };
+ };
+ };
+
+//*********************************************************************************************************************
+// ORDERS
+//*********************************************************************************************************************
+
+ switch (_grp getvariable "UPSMON_GrpMission") do
+ {
+ case "ASSAULT":
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (!(_grp getvariable ["UPSMON_GrpinAction",false])) then
+ {
+ If (_targetdist <= 300) then
+ {
+ If (IsNull _target) then
+ {
+ If (_targetdist <= 100) then
+ {
+ [_grp,_grp getvariable ["UPSMON_attackpos",[]],_currpos] call UPSMON_GETINPATROLSRCH;
+ };
+ }
+ else
+ {
+ If (vehicle _target == _target) then
+ {
+ If ([_target] call UPSMON_Inbuilding) then
+ {
+ If ((_target getvariable "UPSMON_TargetInfos") select 1 <= 10) then
+ {
+ If (_dist <= 100) then
+ {
+ //The target is in a building, what do we do ?
+ [_grp,_target] spawn UPSMON_AssltBld;
+ };
+ };
+ }
+ else
+ {
+ if (_dist > 50) then
+ {
+ If (_haslos) then
+ {
+ //[_grp,_target] spawn UPSMON_Assltposition;
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+
+ case "FLANK":
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (_targetdist <= 20) then
+ {
+ If (_grp getvariable "UPSMON_TIMEORDER" <= time) then
+ {
+ If (IsNull _target) then
+ {
+ [_grp,_grp getvariable ["UPSMON_attackpos",[]],_currpos] call UPSMON_GETINPATROLSRCH;
+ };
+ };
+ };
+ };
+ };
+
+ case "SUPPORT":
+ {
+ If (_targetdist <= 10) then
+ {
+ If (!IsNull _target) then
+ {
+ If (!(_grp setvariable ["UPSMON_GrpinAction",false])) then
+ {
+ If ("staticbag" in _typeofgrp) then
+ {
+ //Deploy static
+ [_grp,_currpos,_attackpos] call UPSMON_DeployStatic;
+ };
+ };
+ }
+ else
+ {
+ [_grp,(_grp getvariable "UPSMON_Attackpos"),_currpos] call UPSMON_GETINPATROLSRCH;
+ };
+ };
+ };
+
+ case "DEFEND":
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (_wptype == "HOLD") then
+ {
+ If (!(_grp getvariable ["UPSMON_GrpinAction",false])) then
+ {
+ If (_supstatus != "SUPRESSED") then
+ {
+ If (_targetdist <= 100) then
+ {
+ If (_dist > 500) then
+ {
+ If ("heavy" in _typeofeni || "medium" in _typeofeni) then
+ {
+ //Put minefield
+ [_grp,_attackpos] call UPSMON_SetMinefield;
+ };
+ };
+
+ [_grp,_attackpos] spawn UPSMON_FORTIFY;
+ };
+ };
+ };
+ };
+ };
+ };
+
+ case "PATROLSRCH":
+ {
+ If (count (_grp getvariable ["UPSMON_Alertpos",[]]) > 0) then
+ {
+ If (_grp getvariable ["UPSMON_SRCHTIME",time] > time) then
+ {
+ if (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ if (!(_grp getvariable ["UPSMON_Disembarking",false])) then
+ {
+ If ((_targetpos select 0 == (_grp getvariable "UPSMON_Alertpos") select 0 && _targetpos select 1 == (_grp getvariable "UPSMON_Alertpos") select 1)
+ || _targetdist <= 5
+ //|| _stuck
+ || moveToFailed _npc
+ || moveToCompleted _npc
+ || (_grp getvariable ["UPSMON_TIMEONTARGET",0] < time && !("air" in _typeofgrp))
+ //|| (("air" in _typeofgrp && !(_grp getVariable ["UPSMON_landing",false])) && (_targetdist <= (30 + (_currpos select 2))))
+ || ("air" in _typeofgrp && _wptype != "LOITER")) then
+ {
+ [_grp,_grp getvariable "UPSMON_Alertpos",_typeofgrp,_areamarker] spawn UPSMON_DOPATROLSRCH;
+ };
+ };
+ };
+ }
+ else
+ {
+ [_grp] spawn UPSMON_BackToNormal;
+ _grp setvariable ["UPSMON_Alertpos",[]];
+ };
+ };
+ };
+
+ case "PATROLINBLD":
+ {
+ If (_targetdist <= 100) then
+ {
+ If (count (_grp getvariable ["UPSMON_bldposToCheck",[]]) > 0) then
+ {
+ If (!(_grp getvariable ["UPSMON_InBuilding",false])) then
+ {
+ _units = [units _grp] call UPSMON_Getunits;
+ [_units,_grp getvariable ["UPSMON_bldposToCheck",[]],_grp,55] spawn UPSMON_patrolBuilding;
+ }
+ }
+ else
+ {
+ _grp setvariable ["UPSMON_Grpmission","PATROLSRCH"];
+ };
+ };
+ };
+
+ case "REINFORCEMENT":
+ {
+ If (_targetdist <= UPSMON_Closeenough) then
+ {
+ [_grp,_targetpos,_currpos] call UPSMON_GETINPATROLSRCH;
+ _grpstatus = "YELLOW"
+ };
+ };
+
+ case "AMBUSH":
+ {
+ _ambush2 = if ("AMBUSH2:" in _UCthis || "AMBUSH2" in _UCthis || "AMBUSHDIR2:" in _UCthis) then {true} else {false};
+ _ambushdistance = [_currpos,(_grp getvariable "UPSMON_Positiontoambush")] call UPSMON_distancePosSqr;
+ _targetdistance = 1000;
+ _targetknowaboutyou = 0;
+ _linkactivate = false;
+
+ if (!isnull _target) then {_targetdistance = [_currpos,getposATL _target] call UPSMON_distancePosSqr;_targetknowaboutyou = _target knowsabout _npc;};
+ //Ambush enemy is nearly aproach
+ //_ambushdist = 50;
+ // replaced _target by _NearestEnemy
+
+ If (_grp getvariable ["UPSMON_LINKED",0] > 0) then
+ {
+ {
+ If (side _x == _side) then
+ {
+ If (round ([_currpos,getposATL (leader _x)] call UPSMON_distancePosSqr) <= (_grp getvariable ["UPSMON_LINKED",0])) then
+ {
+ If (_x getvariable "UPSMON_AMBUSHFIRE")
+ exitwith {_linkactivate = true};
+ };
+ };
+ } foreach UPSMON_NPCs
+ };
+
+ If (((_supstatus != "") || _linkactivate || (_grp getvariable ["UPSMON_AMBUSHWAIT",time]) < time)
+ || ((!isNull _target && "Air" countType [_target] == 0)
+ && ((_targetdistance <= _ambushdistance)
+ ||(round ([getposATL _target,(_grp getvariable "UPSMON_Positiontoambush")] call UPSMON_distancePosSqr) < 10)
+ || (_npc knowsabout _target > 3 && _ambush2)))) then
+ {
+ sleep ((random 0.5) + 1); // let the enemy then get in the area
+
+ if (UPSMON_Debug>0) then {diag_log format["%1: FIREEEEEEEEE!!! Gothit: %2 linkactivate: %3 Distance: %4 PositionToAmbush: %5 AmbushWait:%6 %7",_grpid,_supstatus,_linkactivate,(_targetdistance <= _ambushdistance),_target distance (_grp getvariable "UPSMON_Positiontoambush") < 20,_grp getvariable ["UPSMON_AMBUSHWAIT",time] < time,(_npc knowsabout _target > 3 && _ambush2)]};
+
+ _npc setBehaviour "COMBAT";
+ _npc setcombatmode "YELLOW";
+ _grpstatus = "PURPLE";
+
+ {
+ If !(isNil "bdetect_enable") then {_x setVariable ["bcombat_task", nil];};
+ } foreach units _grp;
+
+ _grp setvariable ["UPSMON_AMBUSHFIRE",true];
+
+ //No engage yet
+ _grp setvariable ["UPSMON_grpmission","SUPPORT"];
+ };
+ };
+
+ case "FORTIFY":
+ {
+ If (!(IsNull _target)) then
+ {
+ If (!(_grp getvariable ["UPSMON_Checkbuild",false])) then
+ {
+ if (behaviour _npc != "COMBAT") then {_npc setbehaviour "COMBAT"};
+ [_grp,_dist] call UPSMON_unitdefend;
+
+ If (_grp getvariable ["UPSMON_OrgGrpMission",""] != "FORTIFY") then
+ {
+ If (_ratio > 1.2) then
+ {
+ _grp setvariable ["UPSMON_Grpmission","SUPPORT"];
+ }
+ };
+ };
+ }
+ else
+ {
+ If (_grp getvariable ["UPSMON_OrgGrpMission",""] != "FORTIFY") then
+ {
+ [_grp,(_grp getvariable "UPSMON_Attackpos"),_currpos] call UPSMON_GETINPATROLSRCH;
+ _grpstatus = "YELLOW"
+ };
+ };
+ };
+
+ case "RETREAT":
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (_targetdist <= 50) then
+ {
+ _grp setvariable ["UPSMON_Grpmission","DEFEND"];
+ };
+ };
+ };
+
+ case "TRANSPORT":
+ {
+ If (count _assignedvehicle > 0) then
+ {
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "MoveToRP" || ((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDRP") then
+ {
+ _grouptransported = [_grp] call UPSMON_CheckTransported;
+
+ If (!IsNull _grouptransported) then
+ {
+ If (!(_grp getvariable ["UPSMON_embarking",false])) then
+ {
+ If (_targetdist <= 50) then
+ {
+ _destination = (_grp getvariable ["UPSMON_Transportmission",[]]) select 1;
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "MoveToRP") then
+ {
+ //Embark group in transport (LAND)
+ [_grouptransported,_assignedvehicle,_destination] spawn UPSMON_getinassignedveh;
+ };
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDRP") then
+ {
+ if (_currpos select 2 <= 3) then
+ {
+ //Embark group in transport (HELI)
+ [_grouptransported,_assignedvehicle,_destination] spawn UPSMON_getinassignedveh;
+ };
+ };
+ };
+ };
+ }
+ else
+ {
+ //If there are nobody anymore to transport then return to base
+ [_assignedvehicle select 0] call UPSMON_Returnbase;
+ };
+ };
+
+ If (_targetdist <= 100) then
+ {
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDING" || ((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDBASE" || ((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDPZ") then
+ {
+ If (unitReady (driver (_assignedvehicle select 0)) || toUpper(landResult (_assignedvehicle select 0)) != "NOTREADY" || (landResult (_assignedvehicle select 0)) == "") then
+ {
+ //Make heli land and stop or land and be ready to move :)
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDING") then {If (((getposATL (_assignedvehicle select 0)) select 2) > 20) then {(_assignedvehicle select 0) land "GET OUT";}};
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDRP") then {If (((getposATL (_assignedvehicle select 0)) select 2) > 20) then {(_assignedvehicle select 0) land "GET IN";}};
+ If (((_grp getvariable ["UPSMON_Transportmission",[]]) select 0) == "LANDBASE") then {(_assignedvehicle select 0) land "LAND";};
+ };
+ };
+ };
+ }
+ else
+ {
+ _grp setvariable ["UPSMON_Transport",false];
+ _grp setvariable ["UPSMON_Transportmission",[]]
+ };
+ };
+
+ case "WAITTRANSPORT":
+ {
+ _grouptransported = [_grp] call UPSMON_CheckTransported;
+ If (IsNull _grouptransported) then
+ {
+ [_grp,_grp getvariable ["UPSMON_TransportDest",[]],"MOVE",_formation,_speedmode,_behaviour,"YELLOW",1] spawn UPSMON_DocreateWP;
+ };
+ };
+
+ case "SUPPLY":
+ {
+ If (true) then
+ {
+
+ };
+ };
+
+ case "RESUPPLY":
+ {
+
+ };
+
+ case "PATROL":
+ {
+ _speedmode = Speedmode _npc;
+ _behaviour = Behaviour _npc;
+ _wpformation = Formation _npc;
+
+ If (!(_grp getvariable ["UPSMON_InTransport",false])) then
+ {
+
+ If ("arti" in _typeofgrp) then
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (_targetdist <= 10 && (_grp getvariable ["UPSMON_TIMEONTARGET",time] <= time)) then
+ {
+ _makenewtarget=true;
+ };
+ };
+ }
+ else
+ {
+
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (!(_grp getvariable ["UPSMON_embarking",false])) then
+ {
+ If (!(_grp getvariable ["UPSMON_Disembarking",false])) then
+ {
+ If (!([_targetpos,_areamarker] call UPSMON_pos_fnc_isBlacklisted)
+ || _stuck
+ || _targetdist <= 5
+ //|| moveToFailed _driver
+ //|| Unitready _driver
+ //|| moveToCompleted _driver
+ || count(waypoints _grp) == 0
+ || ((("tank" in _typeofgrp) || ("ship" in _typeofgrp) || ("apc" in _typeofgrp) ||("car" in _typeofgrp)) && _targetdist <= 25)
+ || (("air" in _typeofgrp && !(_grp getVariable ["UPSMON_landing",false])) && (_targetdist <= 70 || Unitready _driver))) then
+ {
+ _makenewtarget=true;
+ };
+ };
+ };
+ };
+ };
+ };
+
+ // Search new patrol pos
+ if (_makenewtarget) then
+ {
+ if (UPSMON_Debug > 0) then {diag_log format ["Grp%1 search newpos",_grp getvariable ["UPSMON_grpid",0]];};
+ [_grp,_wpformation,_speedmode,_areamarker,_Behaviour,_combatmode,_typeofgrp] spawn UPSMON_DOPATROL;
+ };
+ };
+
+ case "FIREMISSION":
+ {
+ If (count _attackpos > 0 || count (_grp getvariable ["UPSMON_Artifiremission",[]]) > 0) then
+ {
+ If (_grp getvariable ["UPSMON_OnBattery",false]) then
+ {
+ If (!(_grp getvariable ["UPSMON_Batteryfire",false])) then
+ {
+ _artitarget = _attackpos;
+ _firemission = "HE";
+ _roundsask = 1;
+ _area = 10;
+ If (count (_grp getvariable ["UPSMON_Artifiremission",[]]) > 0) then
+ {
+ _artitarget = (_grp getvariable ["UPSMON_Artifiremission",[]]) select 0;
+ _firemission = (_grp getvariable ["UPSMON_Artifiremission",[]]) select 1;
+ _roundsask = (_grp getvariable ["UPSMON_Artifiremission",[]]) select 2;
+ _area = (_grp getvariable ["UPSMON_Artifiremission",[]]) select 2;
+ };
+
+ [_grp,_artitarget,_area,_roundsask,_firemission] spawn UPSMON_artillerydofire;
+ }
+ else
+ {
+ If (_grp getvariable ["UPSMON_RoundsComplete",false]) then
+ {
+ [_grp] call UPSMON_BackToNormal;
+ _grp setvariable ["UPSMON_OnBattery",false];
+ _grp setvariable ["UPSMON_RoundsComplete",false];
+ };
+ };
+ };
+ }
+ else
+ {
+ If (_grp getvariable ["UPSMON_RoundsComplete",false]) then
+ {
+ [_grp] call UPSMON_BackToNormal;
+ _grp setvariable ["UPSMON_OnBattery",false];
+ _grp setvariable ["UPSMON_RoundsComplete",false];
+ };
+ };
+ };
+
+ case "RELAX":
+ {
+ [_grp,_areamarker] call UPSMON_DORELAX;
+ };
+
+ case "STATIC":
+ {
+
+ };
+
+ };
+
+ If (count(waypoints _grp) != 0) then
+ {
+ _wppos = waypointPosition [_grp,count(waypoints _grp)-1];
+ _targetpos = _wppos;
+ _wptype = waypointType [_grp,count(waypoints _grp)-1];
+ _targetdist = [_currpos,_targetpos] call UPSMON_distancePosSqr;
+ };
+
+ if (!_nowp) then
+ {
+///////////////////////////////////////////////////////////////////////////
+/////////// Disembarking //////////////////
+//////////////////////////////////////////////////////////////////////////
+
+ If (!(_grp getvariable ["UPSMON_disembarking",false])) then
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (_targetpos select 0 != 0 && _targetpos select 1 != 0) then
+ {
+ If (count _assignedvehicle > 0) then
+ {
+ [_grp,_assignedvehicle,_dist,_targetdist,_supstatus] call UPSMON_Disembarkment;
+ };
+ };
+ };
+ };
+///////////////////////////////////////////////////////////////////////////
+/////////// Embarking //////////////////
+//////////////////////////////////////////////////////////////////////////
+
+ If (!(_grp getvariable ["UPSMON_embarking",false])) then
+ {
+ if (!(_grp getvariable ["UPSMON_Disembarking",false])) then
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (!(_grp getVariable ["UPSMON_landing",false])) then
+ {
+ [_grp,_typeofgrp,_targetpos,_dist,_targetdist,_assignedvehicle,_supstatus,_speedmode,_behaviour] call UPSMON_Embarkment;
+ };
+ };
+ };
+ };
+ };// !NOWP
+
+ if (({alive _x && !(captive _x)} count units _grp) == 0 || _grp getvariable ["UPSMON_Removegroup",false]) exitwith
+ {
+ [_grp,_UCthis] call UPSMON_RESPAWN;
+ };
+
+ _grp setvariable ["UPSMON_Lastinfos",[_currpos,_targetpos]];
+ _grp setvariable ["UPSMON_lastOpfknowval",_opfknowval];
+ _grp setvariable ["UPSMON_LastGrpmission",_grp getvariable ["UPSMON_Grpmission",""]];
+
+ sleep 0.1;
+ };
+
+ } foreach UPSMON_NPCs;
+
+ If (ObjNull in UPSMON_NPCs) then {UPSMON_NPCs = UPSMON_NPCs - [ObjNull]};
+ sleep _cycle;
+};
\ No newline at end of file
diff --git a/scripts/UPSMON/UPSMON_MAINLOOPCiv.sqf b/scripts/UPSMON/UPSMON_MAINLOOPCiv.sqf
new file mode 100644
index 0000000..73d9e80
--- /dev/null
+++ b/scripts/UPSMON/UPSMON_MAINLOOPCiv.sqf
@@ -0,0 +1,298 @@
+private ["_cycle","_grp","_members","_grpmission","_grpstatus","_grpid","_Ucthis","_lastcurrpos","_lastpos","_lastattackpos","_areamarker","_npc","_driver","_buildingdist","_deadbodiesnear","_stuck","_makenewtarget","_targetpos","_attackpos","_dist","_target","_wptype","_traveldist","_targetdist","_speedmode","_behaviour","_combatmode","_currPos","_grpcomposition","_typeofgrp","_capacityofgrp","_assignedvehicle","_supstatus","_TargetSearch"];
+
+while {true} do
+{
+ _cycle = ((random 1) + 1.5);
+ {
+ If (!IsNull _x) then
+ {
+ _grp = _x;
+
+ _members = (_grp getvariable "UPSMON_Origin") select 4;
+
+ _grpmission = _grp getvariable "UPSMON_GrpMission";
+ _grpstatus = _grp getvariable "UPSMON_Grpstatus";
+
+ _grpid = _grp getVariable "UPSMON_grpid";
+ _Ucthis = _grp getvariable "UPSMON_Ucthis";
+
+ _lastcurrpos = (_grp getvariable "UPSMON_Lastinfos") select 0;
+ _lastpos = (_grp getvariable "UPSMON_Lastinfos") select 1;
+ _lastattackpos = _grp getvariable ["UPSMON_Lastattackpos",[]];
+
+ _areamarker = _Ucthis select 1;
+
+ if (({alive _x && !(captive _x)} count units _grp) == 0 || _grp getvariable ["UPSMON_Removegroup",false]) exitwith
+ {
+ [_grp,_UCthis] call UPSMON_RESPAWN;
+ };
+
+ _npc = leader _grp;
+ _driver = driver (vehicle _npc);
+
+ // did the leader die?
+ _npc = [_npc,_grp] call UPSMON_getleader;
+ if (!alive _npc || isplayer _npc) exitwith {[_grp,_UCthis] call UPSMON_Respawngrp;};
+
+ _buildingdist = 50;
+ _deadbodiesnear = false;
+ _stuck = false;
+ _makenewtarget = false;
+ _targetpos = [0,0];
+ _Attackpos = [];
+ _wptype = "MOVE";
+ _targetdist = 1000;
+ _traveldist = 0;
+ _dist = 10000;
+ _safemode = ["CARELESS","SAFE"];
+
+ _target = ObjNull;
+
+ _speedmode = speedmode _npc;
+ _behaviour = behaviour _npc;
+ _combatmode = "YELLOW";
+
+
+ // current position
+ _currPos = getposATL _npc;
+
+ If (count(waypoints _grp) != 0) then
+ {
+ _wppos = waypointPosition [_grp,count(waypoints _grp)-1];
+ _targetpos = _wppos;
+ _wptype = waypointType [_grp,count(waypoints _grp)-1];
+ _targetdist = [_currpos,_targetpos] call UPSMON_distancePosSqr;
+ };
+
+ _grpcomposition = [_grp] call UPSMON_analysegrp;
+ _typeofgrp = _grpcomposition select 0;
+ _capacityofgrp = _grpcomposition select 1;
+ _assignedvehicle = _grpcomposition select 2;
+
+ _supstatus = [_grp] call UPSMON_supstatestatus;
+ _nowp = [_grp,_target,_supstatus] call UPSMON_NOWP;
+
+ If (_grp getvariable ["UPSMON_GrpHostility",0] > 0) then
+ {
+ _TargetSearch = [_grp,_areamarker] call UPSMON_TargetAcquisitionCiv;
+ _target = _TargetSearch select 0;
+ _dist = _TargetSearch select 1;
+ _attackpos = _TargetSearch select 2;
+
+ If (_grp getvariable ["UPSMON_Grpmission",""] != "HARASS") then
+ {
+ If (!Isnull _target) then
+ {
+ _grp setvariable ["UPSMON_Grpmission","HARASS"]
+ };
+ }
+ else
+ {
+ If (Isnull _target) then
+ {
+ [_grp] call UPSMON_BackToNormal;
+ };
+ };
+ };
+
+ //If in safe mode if find dead bodies change behaviour
+ {
+ if (alive _x) then
+ {
+ if (vehicle _x == _x) then
+ {
+ If (!(_x getvariable ["UPSMON_Civfleeing",false])) then
+ {
+ If ((_x getvariable ["UPSMON_SUPSTATUS",""]) == "") then
+ {
+ If (UPSMON_deadBodiesReact)then
+ {
+ _dead = [_x,_buildingdist] call UPSMON_deadbodies;
+ if (!IsNull _dead) exitwith
+ {
+ ["FLEE",_x,Objnull] spawn UPSMON_Civaction;
+ };
+ };
+ }
+ else
+ {
+ ["FLEE",_x,Objnull] spawn UPSMON_Civaction;
+ };
+
+ };
+ };
+ };
+ } foreach units _grp;
+
+ //Stuck control
+ If (!(_npc getvariable ["UPSMON_Civdisable",false])) then
+ {
+ _stuck = [_npc,_lastcurrpos,_currpos] call UPSMON_Isgrpstuck;
+ };
+
+//*********************************************************************************************************************
+// ORDERS
+//*********************************************************************************************************************
+
+ switch (_grp getvariable "UPSMON_GrpMission") do
+ {
+ case "PATROL":
+ {
+ _speedmode = Speedmode _npc;
+ _behaviour = Behaviour _npc;
+ _wpformation = Formation _npc;
+
+ If (!(_grp getvariable ["UPSMON_InTransport",false])) then
+ {
+
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (!([_targetpos,_areamarker] call UPSMON_pos_fnc_isBlacklisted)
+ || _stuck
+ || _targetdist <= 5
+ || count(waypoints _grp) == 0
+ || ((("tank" in _typeofgrp) || ("ship" in _typeofgrp) || ("apc" in _typeofgrp) ||("car" in _typeofgrp)) && _targetdist <= 25)
+ || (("air" in _typeofgrp && !(_grp getVariable ["UPSMON_landing",false])) && (_targetdist <= 70 || Unitready _driver))) then
+ {
+ _makenewtarget=true;
+ };
+ };
+ };
+
+ // Search new patrol pos
+ if (_makenewtarget) then
+ {
+ if (UPSMON_Debug > 0) then {diag_log format ["Grp%1 search newpos",_grp getvariable ["UPSMON_grpid",0]];};
+ [_grp,_wpformation,_speedmode,_areamarker,_Behaviour,_combatmode,_typeofgrp] spawn UPSMON_DOPATROL;
+ };
+ };
+
+ case "RELAX":
+ {
+ [_grp,_areamarker] call UPSMON_DORELAX;
+ };
+
+ case "HARASS":
+ {
+ {
+ If (alive _x) then
+ {
+ If (canmove _x) then
+ {
+ If (vehicle _x == _x) then
+ {
+ If (!(_x getvariable ["UPSMON_Civfleeing",false])) then
+ {
+ If (_x getvariable ["UPSMON_Throwstone",time] <= time) then
+ {
+ If (!IsNull _target) then
+ {
+ If (_dist > 100 && !([_x,_target,100,130] call UPSMON_Haslos)) then
+ {
+ If (_x getvariable ["UPSMON_Civdisable",false]) then
+ {
+ _x switchmove "";
+ _x enableAI "MOVE";
+ _x setvariable ["UPSMON_Civdisable",false];
+ };
+
+ If (_x getvariable ["UPSMON_Movingtotarget",time] <= time) then
+ {
+ Dostop _x;
+ _x domove _attackpos;
+ _x setDestination [_attackpos, "LEADER PLANNED", true];
+ _time = time + 120;
+ _x setvariable ["UPSMON_Movingtotarget",_time];
+ };
+ }
+ else
+ {
+ [_x,_attackpos] spawn UPSMON_throw_stone;
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ sleep 0.2;
+ } foreach units _grp;
+ };
+
+ case "STATIC":
+ {
+
+ };
+
+ };
+
+ If (count(waypoints _grp) != 0) then
+ {
+ _wppos = waypointPosition [_grp,count(waypoints _grp)-1];
+ _targetpos = _wppos;
+ _wptype = waypointType [_grp,count(waypoints _grp)-1];
+ _targetdist = [_currpos,_targetpos] call UPSMON_distancePosSqr;
+ };
+
+ if (!_nowp) then
+ {
+ If (_grp getvariable "UPSMON_GrpMission" == "PATROL") then
+ {
+///////////////////////////////////////////////////////////////////////////
+/////////// Disembarking //////////////////
+//////////////////////////////////////////////////////////////////////////
+
+ If (!(_grp getvariable ["UPSMON_disembarking",false])) then
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (_targetpos select 0 != 0 && _targetpos select 1 != 0) then
+ {
+ If (!(_npc getvariable ["UPSMON_Civfleeing",false])) then
+ {
+ If (count _assignedvehicle > 0) then
+ {
+ [_grp,_assignedvehicle,_dist,_targetdist,_supstatus] call UPSMON_Disembarkment;
+ };
+ };
+ };
+ };
+ };
+///////////////////////////////////////////////////////////////////////////
+/////////// Embarking //////////////////
+//////////////////////////////////////////////////////////////////////////
+
+ If (!(_grp getvariable ["UPSMON_embarking",false])) then
+ {
+ if (!(_grp getvariable ["UPSMON_Disembarking",false])) then
+ {
+ If (!(_grp getvariable ["UPSMON_searchingpos",false])) then
+ {
+ If (!(_grp getVariable ["UPSMON_landing",false])) then
+ {
+ [_grp,_typeofgrp,_targetpos,_dist,_targetdist,_assignedvehicle,_supstatus,_speedmode,_behaviour] call UPSMON_Embarkment;
+ };
+ };
+ };
+ };
+ };
+ };// !NOWP
+
+ if (({alive _x && !(captive _x)} count units _grp) == 0 || _grp getvariable ["UPSMON_Removegroup",false]) exitwith
+ {
+ [_grp,_UCthis] call UPSMON_RESPAWN;
+ };
+
+ _grp setvariable ["UPSMON_Grpstatus",_grpstatus];
+ _grp setvariable ["UPSMON_Lastinfos",[_currpos,_targetpos]];
+ _grp setvariable ["UPSMON_Lastattackpos",_attackpos];
+ _grp setvariable ["UPSMON_LastGrpmission",_grp getvariable ["UPSMON_Grpmission",""]];
+
+ sleep 0.1;
+
+ };
+
+ } foreach UPSMON_Civs;
+ If (ObjNull in UPSMON_NPCs) then {UPSMON_NPCs = UPSMON_NPCs - [ObjNull]};
+ sleep _cycle;
+};
\ No newline at end of file
diff --git a/scripts/bonus/Composition_table.sqf b/scripts/bonus/Composition_table.sqf
new file mode 100644
index 0000000..8a016e5
--- /dev/null
+++ b/scripts/bonus/Composition_table.sqf
@@ -0,0 +1,112 @@
+if (!isServer) exitwith {};
+
+_cas = _this select 0;
+_object = _this select 1;
+
+switch (_cas) do {
+ case 0: {
+ // composition pour fabrique IED
+
+ _objects = [[_object,"TOP"],"DemoCharge_Remote_Ammo",1,[(random 0.2)+0.2,(random 0.2)-0.1,0],(random 20)-10] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"DemoCharge_Remote_Ammo",1,[(random 0.2)-0.4,(random 0.2)-0.2,0],random 60] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_DuctTape_F",1,[-0.4,(random 0.2)+0.3,0],(random 20)-20] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_File1_F",1,[-0.4,-0.5,0],90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_Can_V3_F",1,[-0.4,-0.6,0],90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_Screwdriver_V2_F",1,[-0.3,-0.5,0],random 90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_MobilePhone_old_F",1,[-0.4,-0.3,0],60] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_MultiMeter_F",1,[-0.2,+0.5,0],random 180] call BIS_fnc_spawnObjects;
+ };
+
+ case 1: {
+ // Composition pour QG insurgé
+ _file = ["Land_File1_F","Land_FilePhotos_F","Land_File2_F"] call BIS_fnc_selectRandom;
+ _pen = ["Land_PenRed_F","Land_PenBlack_F"] call BIS_fnc_selectRandom;
+
+ _objects = [[_object,"TOP"],"Land_Map_altis_F",1,[0,0,0],(getdir _object)+ 180] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_PortableLongRangeRadio_F",1,[-0.4,(random 0.2)+0.3,0],(random 20)-20] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_BottlePlastic_V1_F",1,[-0.4,-0.2,0],0] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_file,1,[-0.4,-0.6,0],90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_pen,1,[-0.3,-0.5,0],random 90] call BIS_fnc_spawnObjects;
+
+ };
+
+ case 2: {
+ // Composition table argent
+
+ _ordi = ["Land_Laptop_unfolded_F","Land_Laptop_F"] call BIS_fnc_selectRandom;
+ _file = ["Land_File1_F","Land_FilePhotos_F","Land_File2_F"] call BIS_fnc_selectRandom;
+ _pen = ["Land_PenRed_F","Land_PenBlack_F"] call BIS_fnc_selectRandom;
+ _can = ["Land_Can_V2_F","Land_Can_V3_F","Land_Can_Rusty_F","Land_Can_V1_F"] call BIS_fnc_selectRandom;
+
+ _objects = [[_object,"TOP"],_ordi,1,[0,0,0],(getdir _object) +270] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_MobilePhone_smart_F",1,[-0.4,(random 0.2)+0.3,-0.4],(random 20)-20] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_can,1,[0.2,-0.4,-0.4],0] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_Money_F",1,[0.4,0.5,-0.1],0] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_file,1,[-0.4,-0.6,0],90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_pen,1,[-0.3,-0.5,0],random 90] call BIS_fnc_spawnObjects;
+ };
+
+ case 3: {
+ // Composition table d'operation
+ _object1 = ["Land_Bandage_F","Land_BloodBag_F","Land_Antibiotic_F","Land_Bandage_F","Land_Bandage_F","Land_PainKillers_F"] call BIS_fnc_selectRandom;
+ _object2 = ["Land_Bandage_F","Land_BloodBag_F","Land_Antibiotic_F","Land_Bandage_F","Land_Bandage_F","Land_PainKillers_F"] call BIS_fnc_selectRandom;
+ _object3 = ["Land_Bandage_F","Land_BloodBag_F","Land_Antibiotic_F","Land_Bandage_F","Land_Bandage_F","Land_PainKillers_F"] call BIS_fnc_selectRandom;
+
+ _objects = [[_object,"TOP"],"Land_Defibrillator_F",1,[0,random -0.2,0],(getdir _object)+ 180] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_Bandage_F",1,[-0.4,(random 0.2)+0.3,0],(random 20)-20] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_object1,1,[-0.4,-0.1,0],random 90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_object2,1,[-0.2,-0.1,0],random 180] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_Antibiotic_F",1,[-0.4,-0.5,0],90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_BloodBag_F",1,[-0.3,0,0],random 90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_object3,1,[0.2,0.1,0],random 90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_object1,1,[0.4,0.3,0],random 180] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],_object2,1,[0.3,-0.4,0],random 180] call BIS_fnc_spawnObjects;
+ };
+
+ case 4: {
+ // Composition atelier réparation
+ _objects = [[_object,"TOP"],"Land_CanisterOil_F",1,[-0.5,-0.1,0],random 180] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_MultiMeter_F",1,[0.2,0.2,0],(random 20)-20] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_Pliers_F",1,[0.1,0.1,0],0] call BIS_fnc_spawnObjects;
+ };
+
+ case 5: {
+ // compostion pour etagère ied
+ _obj1 = "Land_FMradio_F" createVehicle [0,0,0];
+ _obj1 setdir ((getdir _object) + random 30);
+ _obj1 attachTo [_object,[0,0,0.54]];
+ _obj2 = "Land_HandyCam_F" createVehicle [0,0,0];
+ _obj2 setdir random 180;
+ _obj2 attachTo [_object,[0.1,0.3,0.15]];
+ _obj4 = "Land_ButaneCanister_F" createVehicle [0,0,0];
+ _obj4 attachTo [_object,[-0.2,0.3,0.2]];
+ _obj3 = "Land_PortableLongRangeRadio_F" createVehicle [0,0,0];
+ _obj3 attachTo [_object,[-0.2,-0.2,0.15]];
+ };
+
+ case 6: {
+ // Composition dépot munition
+
+ _weapon = ["arifle_TRG21_F","arifle_TRG20_F","arifle_TRG21_GL_F","arifle_TRG20_ACO_Flash_F","launch_B_Titan_short_F"] call BIS_fnc_selectRandom;
+ _weaponspawn = createvehicle ["groundWeaponHolder", getposATL _object, [], 0, "can_collide"];
+ _weaponspawn addweaponcargo [_weapon,1];
+ _weaponspawn setVectorDirAndUp [[0,0,1],[0,0,0]];
+ _tablePosition = getPosATL _object;
+ _tableMaxWorldBounds = _object modelToWorld (boundingBox _object select 1);
+ _tablePosition set [2, _tableMaxWorldBounds select 2];
+ _weaponspawn setPosATL _tablePosition;
+
+ _objects = [[_object,"TOP"],"Land_Magazine_rifle_F",1,[-0.3,0.1,0],90] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_Magazine_rifle_F",1,[-0.4,(random 0.2)+0.3,0],(random 20)-20] call BIS_fnc_spawnObjects;
+ _objects = [[_object,"TOP"],"Land_Magazine_rifle_F",1,[-0.4,-0.1,0],random 90] call BIS_fnc_spawnObjects;
+ };
+
+ case 5: {
+ // compostion pour tentes
+ _obj1 = "Land_Ammobox_rounds_F" createVehicle [0,0,0];
+ _obj1 setdir ((getdir _object) + random 30);
+ _obj1 attachTo [_object,[0,0,0.54]];
+ };
+};
+
+ //[0,0,-0.25],
\ No newline at end of file
diff --git a/scripts/bonus/UPSMON_Anim.sqf b/scripts/bonus/UPSMON_Anim.sqf
new file mode 100644
index 0000000..1605218
--- /dev/null
+++ b/scripts/bonus/UPSMON_Anim.sqf
@@ -0,0 +1,40 @@
+/*
+Stances
+[
+ "STAND",
+ "STAND_IA",
+ "GUARD",
+ "SIT_LOW",
+ "KNEEL",
+ "LEAN",
+ "WATCH",
+ "WATCH1",
+ "WATCH2"
+];
+gear
+[
+ "NONE",
+ "LIGHT",
+ "MEDIUM",
+ "FULL",
+ "ASIS",
+ "RANDOM"
+];
+*/
+
+
+_unit = _this select 0;
+_anim = _this select 1;
+_clothes = _this select 2;
+
+
+if (isNil("UPSMON_INIT")) then {
+ UPSMON_INIT=0;
+};
+
+waitUntil {UPSMON_INIT==1};
+
+If (Alive _unit && canmove _unit) then
+{
+ [_unit,_anim,_clothes,{lifestate _unit == "INJURED" || !alive _unit ||_unit getvariable ["UPSMON_SUPSTATUS",""] != "" || !IsNull ((group _unit) getvariable ["UPSMON_GrpTarget",ObjNull])}] call BIS_fnc_ambientAnimCombat;
+};
\ No newline at end of file