Check the change log for details
This commit is contained in:
Teh Dango 2016-08-18 22:58:49 -04:00
parent 075a6a4141
commit 7067ad9b0a
324 changed files with 22695 additions and 178 deletions

View File

@ -1,31 +0,0 @@
//Debugstuff to let u know that it work
playerunits = 0;
hcunits = 0;
svunits = 0;
//PAPABEAR=[West,"airbase"];
while{true}do{
/* if(hasinterface) then {
_unitss = {local _x}count allUnits;
_jochen = "LOCALunits: ";
_zeige = _jochen + str(_unitss);
//[PAPABEAR,nil,rsideChat,_zeige] call RE;
systemChat format ["%1",_zeige];
}; */
if(!hasinterface && !isServer) then {
_unitss = {local _x}count allUnits;
_jochen = "HEADLESSunits: ";
_zeige = _jochen + str(_unitss);
//[PAPABEAR,nil,rsideChat,_zeige] call RE;
systemChat format ["%1",_zeige];
};
/* if(isServer) then {
_unitss = {local _x}count allUnits;
_jochen = "SERVERunits: ";
_zeige = _jochen + str(_unitss);
//[PAPABEAR,nil,rsideChat,_zeige] call RE;
systemChat format ["%1",_zeige];
}; */
sleep 5;
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 KiB

View File

@ -1,129 +0,0 @@
// https://community.bistudio.com/wiki/Description.ext#forceRotorLibSimulation
forceRotorLibSimulation = 2;
// https://community.bistudio.com/wiki/Description.ext#disableChannels
disableChannels[] = {0, 2};
author = "Exile Mod Team";
loadScreen = "exile_assets\texture\mod\logo.paa";
onLoadMission= "www.exilemod.com";
OnLoadIntro = "";
OnLoadIntroTime = false;
OnLoadMissionTime = false;
onLoadName = "Exile Mod";
class Header
{
gameType = Sandbox;
minPlayers = 1;
maxPlayers = 100;
};
// DO NOT CHANGE THIS! +
showHUD[] =
{
true, // Scripted HUD (same as showHUD command)
true, // Vehicle + soldier info
true, // Vehicle radar
true, // Vehicle compass
true, // Tank direction indicator
true, // Commanding menu
false, // Group Bar
true // HUD Weapon Cursors
};
respawn = "BASE";
respawnDelay = 120;
respawnDialog = 0;
respawnOnStart = 0;
respawnButton = 1;
respawnTemplates[] = {"Exile"};
// These are broken as fuck, do not use them!
corpseManagerMode = 0;
corpseLimit = 20;
corpseRemovalMinTime = 1800;
corpseRemovalMaxTime = 3600;
wreckManagerMode = 0;
wreckLimit = 2;
wreckRemovalMinTime = 60;
wreckRemovalMaxTime = 360;
// DO NOT CHANGE THIS! -
// When scripted player is enabled, game no longer shows "No player select" error message upon mission start when no player unit is present.
scriptedPlayer = 1;
// Automatically take a free slot in lobby
joinUnassigned = 0;
// Removes all playable units which do not have a human player.
disabledAI = true;
// Disable dropping items while swimming
enableItemsDropping = 0;
// Briefing will still be displayed until all clients are connected and done loading :(
briefing = 0;
// Defines if the debriefing is shown or not at the end of the mission.
debriefing = 0;
// Allow RPT loging
allowFunctionsLog = 1;
// Allows access to the Debug Console outside of the editor during normal gameplay.
// 0 = Default behavior, available only in editor
// 1 = Available in SP and for hosts / logged in admins
// 2 = Available for everyone
enableDebugConsole = 0; // 2 = dangerous in MP
// NO NO NO
allowFunctionsRecompile = 0;
#include "sarge\SAR_define.hpp"
#include "config.cpp"
#include "CfgRemoteExec.hpp"
#include "infiSTAR_Exile_AdminMenu.hpp"
class CfgSounds
{
sounds[] = {bark, growl, whistleFollow, whistleStay, whistleFind, whistleNon};
class bark
{
name="bark";
sound[]={addin\fx\bark.ogg,0.1,1};
titles[] = {};
};
class growl
{
name="growl";
sound[]={addin\fx\growl.ogg,0.1,1};
titles[] = {};
};
class whistleFollow
{
name="whistleFollow";
sound[]={addin\fx\whistleFollow.ogg,0.8,1};
titles[] = {};
};
class whistleStay
{
name="whistleStay";
sound[]={addin\fx\whistleStay.ogg,0.8,1};
titles[] = {};
};
class WhistleFind
{
name="WhistleFind";
sound[]={addin\fx\whistleFind.ogg,0.8,1};
titles[] = {};
};
class whistleNon
{
name="whistleNon";
sound[]={addin\fx\whistleNon.ogg,0.9,1};
titles[] = {};
};
};

View File

@ -1,18 +0,0 @@
elec_HC_detect = ["on"] execVM "elec_HC_detect.sqf"; waitUntil {scriptDone elec_HC_detect};
call compile preprocessFileLineNumbers "scripts\Init_UPSMON.sqf";
[] execVM "sarge\SAR_AI_init.sqf";
[] execVM "ZOM\init.sqf";
if (isServer) then {
//dogOwner = [];
//[] execVM "addin\dogInit.sqf";
//[] execVM "exile_server\init\server_functions.sqf";
};
if (!isDedicated) then {
[] execVM "rules.sqf";
//_nul = [] execVM "addin\plrInit.sqf";
};
_nul = [] execVM "debug_hint.sqf";

Binary file not shown.

Binary file not shown.

1
sarge/$PBOPREFIX$ Normal file
View File

@ -0,0 +1 @@
addons\sarge

1
sarge/$PREFIX$ Normal file
View File

@ -0,0 +1 @@
addons\sarge

214
sarge/Init_UPSMON.sqf Normal file
View File

@ -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 = true;
// 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 = true;
//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 "\addons\sarge\UPSMON.sqf";
UPSMON_CreateGroup = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\UPSMON_CreateGroup.sqf";
//Core
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\init.sqf";
call compile preprocessFileLineNumbers "\addons\sarge\UPSMON\Get_pos\UPSMON_pos_init.sqf";
//Params
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\target\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\unit\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Params\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\buildings\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\vehicles\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\cover\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\terrain\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\MP\init.sqf";
//Modules
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\FORTIFY\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\AMBUSH\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ARTILLERY\init.sqf";
//Orders
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_PATROL\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_REINFORCEMENT\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_Transport\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_PATROLSRCH\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_FLANK\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_ASSAULT\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_DEFEND\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_RELAX\init.sqf";
call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\MODULES\ORDERS\UPSMON_SUPPLY\init.sqf";
[] execvm "\addons\sarge\UPSMON\COMMON\CORE\fnc\UPSMON_TRACK.sqf";
[] execvm "\addons\sarge\UPSMON\UPSMON_MAINLOOP.sqf";
[] execvm "\addons\sarge\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;

1
sarge/PboPrefix.txt Normal file
View File

@ -0,0 +1 @@
addons\sarge

79
sarge/SAR_AI_despawn.sqf Normal file
View File

@ -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
https://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;
};
};

242
sarge/SAR_AI_landDrop.sqf Normal file
View File

@ -0,0 +1,242 @@
/*
# 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
https://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,0,SAR_Blacklist] 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, "CAN_COLLIDE"];
[_leader,_leader_weapon_names,_leader_items,_leader_tools] call SAR_unit_loadout;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _leader; _leader addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_leader] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_leader setIdentity "id_SAR_sold_man";};
case 2:{_leader setIdentity "id_SAR_surv_lead";};
case 3:{_leader setIdentity "id_SAR_band";};
};
[_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;
// 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];
// store experience value on AI
_leader setVariable ["SAR_AI_experience",0,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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _man2heli; _man2heli addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
_man2heli moveInTurret [_heli,[0]];
[_man2heli] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_man2heli setIdentity "id_SAR_sold_man";};
case 2:{_man2heli setIdentity "id_SAR_surv_lead";};
case 3:{_man2heli setIdentity "id_SAR_band";};
};
[_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];
// store experience value on AI
_man2heli setVariable ["SAR_AI_experience",0,false];
//Gunner 2
_man3heli = _groupheli createunit [_riflemenlist call BIS_fnc_selectRandom, [_rndpos select 0, (_rndpos select 1) + 30, 0], [], 0.5, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _man3heli; _man3heli addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
_man3heli moveInTurret [_heli,[1]];
[_man3heli] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_man3heli setIdentity "id_SAR_sold_man";};
case 2:{_man3heli setIdentity "id_SAR_surv_lead";};
case 3:{_man3heli setIdentity "id_SAR_band";};
};
[_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];
// store experience value on AI
_man3heli setVariable ["SAR_AI_experience",0,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_DEBUG) then {
diag_log format["Sarge's AI System: AI Heli patrol (%2) spawned in: %1.",_patrol_area_name,_groupheli];
};
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: Now moving group %1 to Headless Client %2",_group,_hcID];
};
} else {
if (SAR_DEBUG) then {
diag_log format ["Sarge's AI System: ERROR! Moving group %1 to Headless Client %2 has failed!",_group,_hcID];
};
};
};
} forEach allPlayers;
};
_groupheli;

115
sarge/SAR_AI_spawn.sqf Normal file
View File

@ -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
https://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;
};

View File

@ -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
https://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;

115
sarge/SAR_aihit.sqf Normal file
View File

@ -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
https://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 ((alive _aiKiller) && !(_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) 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((alive _aiKiller) && (isPlayer _aikiller)) then {
if (_aikilled_group_side == SAR_AI_friendly_side) then { // hit a friendly AI
if (SAR_HITKILL_DEBUG) then {
diag_log format["SAR_HITKILL_DEBUG: friendly AI was hit by Player %1",_aikiller];
};
_playerRespect = _aikiller getVariable ["ExileScore", 0];
_playerMoney = _aikiller getVariable ["ExileMoney", 0];
_repChange = SAR_surv_kill_value / 20;
_playerRespect = _playerRespect - _repChange;
_aikiller setVariable ["ExileScore",_playerRespect];
ExileClientPlayerScore = _playerRespect;
(owner _aikiller) publicVariableClient "ExileClientPlayerScore";
ExileClientPlayerScore = nil;
format ["setAccountMoneyAndRespect:%1:%2:%3",_playerMoney ,_playerRespect ,getPlayerUID _aikiller] call ExileServer_system_database_query_fireAndForget;
if ((random 100) < 3) then {
_message = format["Sarge AI: Dammit %1! You are firing on a friendly group check your fire!",_aikiller_name];
_message remoteExec ["systemChat",0];
} else {
if ((random 100) < 3) then {
_message = format["Sarge AI: %1, this was the last time you shot one of our team! We are coming for you!",_aikiller_name];
_message remoteExec ["systemChat",0];
};
};
if (SAR_HITKILL_DEBUG) 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) 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 == SAR_AI_unfriendly_side) then { // hit an unfriendly AI
if (SAR_HITKILL_DEBUG) then {
diag_log format["SAR_HITKILL_DEBUG: unfriendly AI was hit by Player %1",_aikiller];
};
if (SAR_HITKILL_DEBUG) then {
diag_log format["SAR_HITKILL_DEBUG: Adjusting respect for bandit hit by %2 for %1",_aikiller,(SAR_band_kill_value/10)];
};
_playerRespect = _aikiller getVariable ["ExileScore", 0];
_playerMoney = _aikiller getVariable ["ExileMoney", 0];
_repChange = SAR_surv_kill_value / 20;
_playerRespect = _playerRespect + _repChange;
_aikiller setVariable ["ExileScore",_playerRespect];
ExileClientPlayerScore = _playerRespect;
(owner _aikiller) publicVariableClient "ExileClientPlayerScore";
ExileClientPlayerScore = nil;
format ["setAccountMoneyAndRespect:%1:%2:%3",_playerMoney ,_playerRespect ,getPlayerUID _aikiller] call ExileServer_system_database_query_fireAndForget;
};
};

225
sarge/SAR_aikilled.sqf Normal file
View File

@ -0,0 +1,225 @@
/*
# 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
https://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","_tmp","_sphere_alpha","_sphere_red","_sphere_green","_sphere_blue","_obj_text_string","_ai_type","_ai_killer_type","_ai_xp_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 ((alive _aiKiller) && !(_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",""];
// retrieve experience value from the killed AI
_ai_xp = _ai getVariable["SAR_AI_experience",0];
// retrieve experience value from the killing AI
_ai_killer_xp = _aikiller getVariable["SAR_AI_experience",0];
if (_ai_xp < SAR_AI_XP_LVL_2) then {
_ai_xp_type = SAR_AI_XP_NAME_1;
};
if (_ai_xp >= SAR_AI_XP_LVL_2 && _ai_xp < SAR_AI_XP_LVL_3) then {
_ai_xp_type = SAR_AI_XP_NAME_2;
};
if (_ai_xp >= SAR_AI_XP_LVL_3) then {
_ai_xp_type = SAR_AI_XP_NAME_3;
};
if (_ai_killer_xp < SAR_AI_XP_LVL_2) then {
_ai_killer_xp_type = SAR_AI_XP_NAME_1;
};
if (_ai_killer_xp >= SAR_AI_XP_LVL_2 && _ai_killer_xp < SAR_AI_XP_LVL_3) then {
_ai_killer_xp_type = SAR_AI_XP_NAME_2;
};
if (_ai_killer_xp >= SAR_AI_XP_LVL_3) then {
_ai_killer_xp_type = SAR_AI_XP_NAME_3;
};
diag_log format ["Sarge AI System: _ai_xp = %1; _ai_xp_type = %2",_ai_xp,_ai_xp_type];
if (SAR_KILL_MSG) then {
if (isPlayer _aikiller) then {
_message = format["Sarge AI: A %3 %2 was killed by Player: %1",_aikiller_name,_ai_type,_ai_xp_type];
_message remoteExec ["systemChat",0];
};
if (_ai_xp >= SAR_AI_XP_LVL_2) then {
_message = format["Sarge AI: A %3 %2 was killed by a %3 %4!",_ai_xp_type,_ai_type,_ai_killer_xp_type,_ai_killer_type];
diag_log _message;
_message remoteExec ["systemChat",0];
};
};
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((alive _aiKiller) && (isPlayer _aikiller)) then {
if (_aikilled_group_side == SAR_AI_friendly_side) then {
if (SAR_HITKILL_DEBUG) then {
diag_log format ["Sarge's AI System: Adjusting respect for survivor or soldier kill by %2 for %1",_aikiller_name,SAR_surv_kill_value];
};
if (SAR_log_AI_kills) then {
_friendlyCount = profileNamespace getVariable["SAR_FRIENDLY_KILLS",0];
_aikiller setVariable ["SAR_FRIENDLY_KILLS",(_friendlyCount + 1),true];
};
_playerRespect = _aikiller getVariable ["ExileScore", 0];
_playerMoney = _aikiller getVariable ["ExileMoney", 0];
_repChange = SAR_surv_kill_value / 10;
_playerRespect = _playerRespect - _repChange;
_aikiller setVariable ["ExileScore",_playerRespect];
_fragType = [[format ["%1 Kill",_ai_type],-_repChange]];
[_aikiller, "showFragRequest", [_fragType]] call ExileServer_system_network_send_to;
ExileClientPlayerScore = _playerRespect;
(owner _aikiller) publicVariableClient "ExileClientPlayerScore";
ExileClientPlayerScore = nil;
format ["setAccountMoneyAndRespect:%1:%2:%3",_playerMoney ,_playerRespect ,getPlayerUID _aikiller] call ExileServer_system_database_query_fireAndForget;
if ((random 100) < 3) then {
_message = format["Sarge AI: %1 killed a friendly AI - sending reinforcements!",_aikiller_name];
_message remoteExec ["systemChat",0];
} else {
if ((random 100) < 3) then {
_message = format["Sarge AI: Tango down ... we offer a decent reward for the head of %1!",_aikiller_name];
_message remoteExec ["systemChat",0];
};
};
};
if (_aikilled_group_side == SAR_AI_unfriendly_side) then {
if (SAR_HITKILL_DEBUG) then {
diag_log format ["Sarge's AI System: Adjusting respect for bandit kill by %2 for %1",_aikiller_name,SAR_band_kill_value];
};
if(SAR_log_AI_kills) then {
_hostileCount = profileNamespace getVariable["SAR_HOSTILE_KILLS",0];
_aikiller setVariable ["SAR_HOSTILE_KILLS",(_hostileCount + 1),true];
};
_playerRespect = _aikiller getVariable ["ExileScore", 0];
_playerMoney = _aikiller getVariable ["ExileMoney", 0];
_repChange = SAR_band_kill_value / 10;
_playerRespect = _playerRespect + _repChange;
_aikiller setVariable ["ExileScore",_playerRespect];
_fragType = [[format ["%1 Kill",_ai_type],_repChange]];
[_aikiller, "showFragRequest", [_fragType]] call ExileServer_system_network_send_to;
ExileClientPlayerScore = _playerRespect;
(owner _aikiller) publicVariableClient "ExileClientPlayerScore";
ExileClientPlayerScore = nil;
format ["setAccountMoneyAndRespect:%1:%2:%3",_playerMoney ,_playerRespect ,getPlayerUID _aikiller] call ExileServer_system_database_query_fireAndForget;
if ((random 100) < 3) then {
_message = format["Sarge AI: Nice bandit kill %1!",_aikiller_name];
_message remoteExec ["systemChat",0];
} else {
if ((random 100) < 3) then {
_message = format["Sarge AI: Another bandit down ... %1 is going to be the root cause of bandit extinction :]",_aikiller_name];
_message remoteExec ["systemChat",0];
};
};
};
} else {
if(SAR_AI_XP_SYSTEM) then {
if((alive _aiKiller) && (!isNull _aikiller)) then { // check if AI was killed by an AI, and not driven over / fallen to death etc
// get xp from the victim
_xp_gain = _ai_xp;
if(_xp_gain == 0) then {
_xp_gain=1;
};
// get old xp
_ai_killer_xp = _aikiller getVariable ["SAR_AI_experience",0];
// calculate new xp
_ai_killer_xp_new = _ai_killer_xp + _xp_gain;
if(_ai_killer_xp < SAR_AI_XP_LVL_3) then {
if(_ai_killer_xp < SAR_AI_XP_LVL_2 && _ai_killer_xp_new >= SAR_AI_XP_LVL_2 ) then { // from level 1 to level 2
if(SAR_SHOW_XP_LVL) then { diag_log format["Level up from 1 -> 2 for %1",_aikiller];};
_message = format["Sarge AI: A %1 %2 was promoted!",_ai_killer_xp_type,_ai_killer_type];
_message remoteExec ["systemChat",0];
// restore health to full
_aikiller setDamage 0;
// upgrades for the next level
// medium armor
_aikiller removeEventHandler ["HandleDamage",0];
_aikiller addEventHandler ["HandleDamage",{if (_this select 1!="") then {_unit=_this select 0;damage _unit+((_this select 2)-damage _unit)*SAR_AI_XP_ARMOR_2}}];
};
if(_ai_killer_xp < SAR_AI_XP_LVL_3 && _ai_killer_xp_new >= SAR_AI_XP_LVL_3 ) then { // from level 2 to level 3
if(SAR_SHOW_XP_LVL) then { diag_log format["Level up from 2 -> 3 for %1",_aikiller];};
_message = format["Sarge AI: A %1 %2 was promoted!",_ai_killer_xp_type,_ai_killer_type];
_message remoteExec ["systemChat",0];
// restore health to full
_aikiller setDamage 0;
// upgrades for the next level
// highest armor
_aikiller removeEventHandler ["HandleDamage",0];
_aikiller addEventHandler ["HandleDamage",{if (_this select 1!="") then {_unit=_this select 0;damage _unit+((_this select 2)-damage _unit)*SAR_AI_XP_ARMOR_3}}];
};
};
//diag_log format["Start XP: %1, End XP: %2",_ai_killer_xp,_ai_killer_xp+_xp_gain];
// set new xp value for AI that killed the other AI
_ai_killer_xp = _ai_killer_xp + _xp_gain;
_aikiller setVariable["SAR_AI_experience",_ai_killer_xp];
};
};
};

288
sarge/SAR_config.sqf Normal file
View File

@ -0,0 +1,288 @@
/*
# 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
https://www.hod-servers.com
*/
SAR_version = "2.2.3";
SAR_HC = true; // If there is no HC it will spawn on server
SAR_maps = ["altis","chernarus","taviana","namalsk","lingor3","mbg_celle2","takistan","fallujah","panthera2","tanoa"];
/* Debug & RPT Settings */
SAR_DEBUG = true; // 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 = true; // Set to true for RPT info on AI shooting and killing
SAR_log_AI_kills = true; // Set to true for kill logging by variable. *These variables do not save to the database currently*
SAR_KILL_MSG = true; // Set to true for announcing AI kills to the server
/* 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_dynamic_heli_respawn = true; // Turn dynamic grid AI respawn on or off
SAR_AI_COMBAT_VEHICLE = false; // Turn the option for AI using vehicles when in combat on or off
SAR_AI_STEAL_VEHICLE = false; // 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
// Chance the AI will spawn
SAR_chance_bandits = 90; // Chance to spawn 1-100%
SAR_chance_soldiers = 75; // Chance to spawn 1-100%
SAR_chance_survivors = 80; // Chance to spawn 1-100%
// Max number of AI groups allowed at once
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
// Size of AI groups plus a leader
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
// Chance the AI Helicopters will spawn - IN DEVELOPMENT
SAR_chance_band_heli = 35;
SAR_chance_surv_heli = 35;
SAR_chance_mili_heli = 35;
// AI experience system
SAR_AI_XP_SYSTEM = true; // Turn this feature on or off
// Level 1 settings
SAR_AI_XP_LVL_1 = 0; // xp needed to reach this level
SAR_AI_XP_NAME_1 = "Rookie"; // name of the level range
SAR_AI_XP_ARMOR_1 = 1; // armor value for this level - values: 0.1 - 1, 1 = no change, 0.5 = damage taken reduced by 50%, 0.1 = damage taken reduced by 90%
// Level 2 settings
SAR_AI_XP_LVL_2 = 5;
SAR_AI_XP_NAME_2 = "Veteran";
SAR_AI_XP_ARMOR_2 = 0.5;
// Level 3 settings
SAR_AI_XP_LVL_3 = 20;
SAR_AI_XP_NAME_3 = "Legendary";
SAR_AI_XP_ARMOR_3 = 0.3;
// Bonus factors for leaders
SAR_leader_health_factor = 1; // values: 0.1 - 1, 1 = no change, 0.5 = damage taken reduced by 50%, 0.1 = damage taken reduced by 90% - EXPERIMENTAL
// military AI
SAR_leader_sold_skills = [
["aimingAccuracy",0.35, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.35, 0.10],
["aimingSpeed", 0.80, 0.20],
["spotDistance", 0.70, 0.30],
["spotTime", 0.65, 0.20],
["endurance", 0.80, 0.20],
["courage", 0.80, 0.20],
["reloadSpeed", 0.80, 0.20],
["commanding", 0.80, 0.20],
["general", 0.80, 0.20]
];
SAR_soldier_sold_skills = [
["aimingAccuracy",0.25, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.25, 0.10],
["aimingSpeed", 0.70, 0.20],
["spotDistance", 0.55, 0.30],
["spotTime", 0.30, 0.20],
["endurance", 0.60, 0.20],
["courage", 0.60, 0.20],
["reloadSpeed", 0.60, 0.20],
["commanding", 0.60, 0.20],
["general", 0.60, 0.20]
];
SAR_sniper_sold_skills = [
["aimingAccuracy",0.80, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.90, 0.10],
["aimingSpeed", 0.70, 0.20],
["spotDistance", 0.70, 0.30],
["spotTime", 0.75, 0.20],
["endurance", 0.70, 0.20],
["courage", 0.70, 0.20],
["reloadSpeed", 0.70, 0.20],
["commanding", 0.70, 0.20],
["general", 0.70, 0.20]
];
// bandit AI
SAR_leader_band_skills = [
["aimingAccuracy",0.35, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.35, 0.10],
["aimingSpeed", 0.60, 0.20],
["spotDistance", 0.40, 0.30],
["spotTime", 0.45, 0.20],
["endurance", 0.40, 0.20],
["courage", 0.50, 0.20],
["reloadSpeed", 0.60, 0.20],
["commanding", 0.50, 0.20],
["general", 0.50, 0.20]
];
SAR_soldier_band_skills = [
["aimingAccuracy",0.15, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.15, 0.10],
["aimingSpeed", 0.60, 0.20],
["spotDistance", 0.40, 0.20],
["spotTime", 0.40, 0.20],
["endurance", 0.40, 0.20],
["courage", 0.40, 0.20],
["reloadSpeed", 0.40, 0.20],
["commanding", 0.40, 0.20],
["general", 0.40, 0.20]
];
SAR_sniper_band_skills = [
["aimingAccuracy",0.70, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.80, 0.10],
["aimingSpeed", 0.70, 0.20],
["spotDistance", 0.90, 0.10],
["spotTime", 0.55, 0.20],
["endurance", 0.70, 0.20],
["courage", 0.70, 0.20],
["reloadSpeed", 0.70, 0.20],
["commanding", 0.50, 0.20],
["general", 0.60, 0.20]
];
// survivor AI
SAR_leader_surv_skills = [
["aimingAccuracy",0.35, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.35, 0.10],
["aimingSpeed", 0.60, 0.20],
["spotDistance", 0.40, 0.30],
["spotTime", 0.45, 0.20],
["endurance", 0.40, 0.20],
["courage", 0.50, 0.20],
["reloadSpeed", 0.60, 0.20],
["commanding", 0.50, 0.20],
["general", 0.50, 0.20]
];
SAR_soldier_surv_skills = [
["aimingAccuracy",0.15, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.15, 0.10],
["aimingSpeed", 0.60, 0.20],
["spotDistance", 0.45, 0.30],
["spotTime", 0.20, 0.20],
["endurance", 0.40, 0.20],
["courage", 0.40, 0.20],
["reloadSpeed", 0.40, 0.20],
["commanding", 0.40, 0.20],
["general", 0.40, 0.20]
];
SAR_sniper_surv_skills = [
["aimingAccuracy",0.70, 0.10], // skilltype, <min value>, <random value added to min>;
["aimingShake", 0.80, 0.10],
["aimingSpeed", 0.70, 0.20],
["spotDistance", 0.70, 0.30],
["spotTime", 0.65, 0.20],
["endurance", 0.70, 0.20],
["courage", 0.70, 0.20],
["reloadSpeed", 0.70, 0.20],
["commanding", 0.50, 0.20],
["general", 0.60, 0.20]
];
// 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. -------------------------------- */
/* -------------------------------- Do Not Edit Below. If you do the AI will not work properly. -------------------------------- */
/* -------------------------------- Do Not Edit Below. If you do the AI will not work properly. -------------------------------- */
SAR_AI_friendly_side = RESISTANCE;
SAR_AI_unfriendly_side = EAST;
SAR_AI_monitor = [];
SAR_leader_number = 0;

43
sarge/SAR_define.hpp Normal file
View File

@ -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
https://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";
};
};

402
sarge/SAR_functions.sqf Normal file
View File

@ -0,0 +1,402 @@
/*
# 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
https://www.hod-servers.com
*/
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;
_leader disableAI "move";
_leader setunitpos "up";
_leader disableAI "target";
_grp enableAttack false;
["NOAI","NOWP2"] spawn UPSMON;
};
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) + _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_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;
removeAllItems _unit;
removeAllAssignedItems _unit;
removeGoggles _unit;
_unit enableFatigue false;
{
_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;
};

View File

@ -0,0 +1,72 @@
/*
# 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
https://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",0];
_fakeFlag = _x getVariable ["ExileDatabaseID", 0];
if (_fakeFlag == 0) then {
diag_log "Sarge AI System: Non territory flag detected! Skipping fake flag!";
} else {
_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;};
};
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[("<t color=""#FFFFFF"">" + ("Make guards hostile") +"</t>"),""],"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.";

74
sarge/SAR_interact.sqf Normal file
View File

@ -0,0 +1,74 @@
/*
# 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
https://www.hod-servers.com
*/
private ["_targetAI","_actingPlayer","_animState","_started","_finished","_isMedic","_leadername"];
//if (isServer) exitWith {}; // only run this on the client
//if (!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;
*/
diag_log ["Sarge AI System: Sarge Interact feature activated!"];
[_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";
}; */

View File

@ -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
https://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;
};

View File

@ -0,0 +1,260 @@
/*
# 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
https://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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _leader; _leader addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_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 addEventHandler ["HandleDamage",{if (_this select 1!="") then {_unit=_this select 0;damage _unit+((_this select 2)-damage _unit)*SAR_leader_health_factor}}];
[_leader, ["Wait Here!", {"\addons\sarge\SAR_interact.sqf","",1,true,true,"","((side _leader != east) && (alive _leader))"}]] remoteExec ["addAction", 0, true];
//["I need assistance!",{"sarge\SAR_interact.sqf","",1,true,true,"","(side _target != EAST)"}]
//_leader addaction ["Help Me!", {"sarge\SAR_interact.sqf" remoteExec [ "BIS_fnc_execVM",0]}];
[_leader] join _group;
// set skills of the leader
{
_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 + " Leader",false];
// store experience value on AI
_leader setVariable ["SAR_AI_experience",0,false];
/* // set behaviour & speedmode
_leader setspeedmode "FULL";
_leader setBehaviour "AWARE"; */
// 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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _this; _this addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_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 addEventHandler ["HandleDamage",{if (_this select 1!="") then {_unit=_this select 0;damage _unit+((_this select 2)-damage _unit)*1}}];
[_this] join _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];
// store experience value on AI
_this setVariable ["SAR_AI_experience",0,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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _this; _this addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_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 addEventHandler ["HandleDamage",{if (_this select 1!="") then {_unit=_this select 0;damage _unit+((_this select 2)-damage _unit)*1}}];
[_this] join _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];
// store experience value on AI
_this setVariable ["SAR_AI_experience",0,false];
};
// initialize upsmon for the group
_ups_para_list = [_leader,_patrol_area_name,'FULL','AWARE','NOSHARE','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 ['NOVEH2'];
};
if (!SAR_AI_COMBAT_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 "AMBUSH2":
{
_ups_para_list pushBack ['AMBUSH'];
_ups_para_list spawn UPSMON;
};
default
{
_ups_para_list spawn UPSMON;
};
};
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)];
};
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: Now moving group %1 to Headless Client %2",_group,_hcID];
};
} else {
if (SAR_DEBUG) then {
diag_log format ["Sarge's AI System: ERROR! Moving group %1 to Headless Client %2 has failed!",_group,_hcID];
};
};
};
} forEach allPlayers;
};
_group;

View File

@ -0,0 +1,274 @@
/*
# 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
https://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,0,SAR_Blacklist] 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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _this; _this addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_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;
// store AI type on the AI
_leader setVariable ["SAR_AI_type",_ai_type + " Leader",false];
// store experience value on AI
_leader setVariable ["SAR_AI_experience",0,false];
_leader setVariable ["SAR_FLAG_FRIENDLY", _authorizedUID, true];
_leader setVariable ["ATTACK_ALL", false, true];
// set behaviour & speedmode
_leader setspeedmode "FULL";
_leader setBehaviour "AWARE";
_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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _this; _this addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_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];
// store experience value on AI
_this setVariable ["SAR_AI_experience",0,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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _this; _this addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_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) * (_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];
// store experience value on AI
_this setVariable ["SAR_AI_experience",0,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 ['NOVEH2'];
};
if (!SAR_AI_COMBAT_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_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)];
};
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: Now moving group %1 to Headless Client %2",_group,_hcID];
};
} else {
if (SAR_DEBUG) then {
diag_log format ["Sarge's AI System: ERROR! Moving group %1 to Headless Client %2 has failed!",_group,_hcID];
};
};
};
} forEach allPlayers;
};
_group;

View File

@ -0,0 +1,242 @@
/*
# 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
https://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,0,SAR_Blacklist] 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, "CAN_COLLIDE"];
[_leader,_leader_weapon_names,_leader_items,_leader_tools] call SAR_unit_loadout;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _leader; _leader addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_leader] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_leader setIdentity "id_SAR_sold_man";};
case 2:{_leader setIdentity "id_SAR_surv_lead";};
case 3:{_leader setIdentity "id_SAR_band";};
};
[_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;
// 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];
// store experience value on AI
_leader setVariable ["SAR_AI_experience",0,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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _man2heli; _man2heli addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
_man2heli moveInTurret [_heli,[0]];
[_man2heli] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_man2heli setIdentity "id_SAR_sold_man";};
case 2:{_man2heli setIdentity "id_SAR_surv_lead";};
case 3:{_man2heli setIdentity "id_SAR_band";};
};
[_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];
// store experience value on AI
_man2heli setVariable ["SAR_AI_experience",0,false];
//Gunner 2
_man3heli = _groupheli createunit [_riflemenlist call BIS_fnc_selectRandom, [_rndpos select 0, (_rndpos select 1) + 30, 0], [], 0.5, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _man3heli; _man3heli addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
_man3heli moveInTurret [_heli,[1]];
[_man3heli] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_man3heli setIdentity "id_SAR_sold_man";};
case 2:{_man3heli setIdentity "id_SAR_surv_lead";};
case 3:{_man3heli setIdentity "id_SAR_band";};
};
[_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];
// store experience value on AI
_man3heli setVariable ["SAR_AI_experience",0,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_DEBUG) then {
diag_log format["Sarge's AI System: AI Heli patrol (%2) spawned in: %1.",_patrol_area_name,_groupheli];
};
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: Now moving group %1 to Headless Client %2",_group,_hcID];
};
} else {
if (SAR_DEBUG) then {
diag_log format ["Sarge's AI System: ERROR! Moving group %1 to Headless Client %2 has failed!",_group,_hcID];
};
};
};
} forEach allPlayers;
};
_groupheli;

View File

@ -0,0 +1,307 @@
/*
# 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
https://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,0,SAR_Blacklist] 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, "CAN_COLLIDE"];
_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, "CAN_COLLIDE"];
_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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _leader; _leader addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_leader] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_leader setIdentity "id_SAR_sold_man";};
case 2:{_leader setIdentity "id_SAR_surv_lead";};
case 3:{_leader setIdentity "id_SAR_band";};
};
[_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];
// store experience value on AI
_leader setVariable ["SAR_AI_experience",0,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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _this; _this addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_this] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_this setIdentity "id_SAR_sold_man";};
case 2:{_this setIdentity "id_SAR_surv_lead";};
case 3:{_this setIdentity "id_SAR_band";};
};
[_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];
// store experience value on AI
_this setVariable ["SAR_AI_experience",0,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;
if (_side == SAR_AI_unfriendly_side) then {removeHeadgear _this; _this addHeadGear (["H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan"] call BIS_fnc_selectRandom);};
[_this] spawn SAR_AI_trace_veh;
switch (_grouptype) do
{
case 1:{_this setIdentity "id_SAR_sold_man";};
case 2:{_this setIdentity "id_SAR_surv_lead";};
case 3:{_this setIdentity "id_SAR_band";};
};
[_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];
// store experience value on AI
_this setVariable ["SAR_AI_experience",0,false];
};
} foreach _vehicles;
// 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_STEAL_VEHICLE) then {
_ups_para_list pushBack ['NOVEH2'];
};
if (!SAR_AI_COMBAT_VEHICLE) then {
_ups_para_list pushBack ['NOVEH'];
};
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];
};
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: Now moving group %1 to Headless Client %2",_group,_hcID];
};
} else {
if (SAR_DEBUG) then {
diag_log format ["Sarge's AI System: ERROR! Moving group %1 to Headless Client %2 has failed!",_group,_hcID];
};
};
};
} forEach allPlayers;
};
_groupvehicles;

View File

@ -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
https://www.hod-servers.com
*/
private ["_baseOwner","_attackAll","_friendlyPlayers","_ai","_entity_array"];
if (isServer || !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;
};

View File

@ -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 && !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;
};

View File

@ -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
https://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;
};

391
sarge/UPSMON.sqf Normal file
View File

@ -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;};
};

View File

@ -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];};
};
};
};

View File

@ -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

View File

@ -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;
};

View File

@ -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)};

View File

@ -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)];

View File

@ -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

View File

@ -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;
};

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;
};
};

View File

@ -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]};
};
};

View File

@ -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]};
};
};
};

View File

@ -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];
};
};

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
};

View File

@ -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];};'
];
****************************************************************/

View File

@ -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

View File

@ -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

View File

@ -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);};
};

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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]

View File

@ -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]

View File

@ -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

View File

@ -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;
};

View File

@ -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;

View File

@ -0,0 +1,43 @@
UPSMON_Getnearestplayer = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_Getnearestplayer.sqf";
UPSMON_Nighttime = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_Nighttime.sqf";
UPSMON_arrayShufflePlus = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_arrayShufflePlus.sqf";
UPSMON_getArg = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_getArg.sqf";
UPSMON_setArg = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_setArg.sqf";
UPSMON_distancePosSqr = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_distancePosSqr.sqf";
UPSMON_GetPos2D = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_GetPos2D.sqf";
UPSMON_GetCOS = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_GetCOS.sqf";
UPSMON_GetSIN = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_GetSIN.sqf";
UPSMON_Replace = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_Replace.sqf";
UPSMON_rotpoint = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_rotpoint.sqf";
UPSMON_StrIndex = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_StrIndex.sqf";
UPSMON_StrInStr = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_StrInStr.sqf";
UPSMON_StrLen = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_StrLen.sqf";
UPSMON_StrToArray = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_StrToArray.sqf";
UPSMON_CanSee = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_CanSee.sqf";
UPSMON_LOS = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_LOS.sqf";
UPSMON_Haslos = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_Haslos.sqf";
UPSMON_overwatch = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_overwatch.sqf";
UPSMON_DeleteWP = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_DeleteWP.sqf";
UPSMON_DocreateWP = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_DocreateWP.sqf";
UPSMON_DoaddWP = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_DoaddWP.sqf";
UPSMON_createmarker = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_createmarker.sqf";
UPSMON_createsign = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_createsign.sqf";
UPSMON_TRACK = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_TRACK.sqf";
UPSMON_checkbackpack = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_checkbackpack.sqf";
UPSMON_getminesclass = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_getminesclass.sqf";
UPSMON_spawnmines = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_spawnmines.sqf";
UPSMON_SN_EHHIT = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_SN_EHHIT.sqf";
UPSMON_SN_EHKILLED = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_SN_EHKILLED.sqf";
UPSMON_SN_EHFIREDNEAR = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_SN_EHFIREDNEAR.sqf";
UPSMON_deleteDead = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_deleteDead.sqf";
UPSMON_Nowp = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_Nowp.sqf";
UPSMON_AddtoArray = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Core\fnc\UPSMON_AddtoArray.sqf";

View File

@ -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

View File

@ -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;

View File

@ -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";};
};
};

View File

@ -0,0 +1,5 @@
UPSMON_fnc_move_to_cover = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Cover\fnc\UPSMON_fnc_move_to_cover.sqf";
UPSMON_fnc_find_cover = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Cover\fnc\UPSMON_fnc_find_cover.sqf";
UPSMON_fnc_filter = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Cover\fnc\UPSMON_fnc_filter.sqf";

View File

@ -0,0 +1,20 @@
UPSMON_getleader = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_getleader.sqf";
UPSMON_SetLeaderGrp = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_SetLeaderGrp.sqf";
UPSMON_getunits = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_getunits.sqf";
UPSMON_getNearestSoldier = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_getNearestSoldier.sqf";
UPSMON_grptype = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_grptype.sqf";
UPSMON_GetStaticTeam = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_GetStaticTeam.sqf";
UPSMON_composeteam = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_composeteam.sqf";
UPSMON_analysegrp = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_analysegrp.sqf";
UPSMON_supstatestatus = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_supstatestatus.sqf";
UPSMON_checkmunition = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_checkmunition.sqf";
UPSMON_Isgrpstuck = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_Isgrpstuck.sqf";
UPSMON_IsRetreating = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_IsRetreating.sqf";
UPSMON_IsSurrending = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_IsSurrending.sqf";
UPSMON_Cangrpmaneuver = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_Cangrpmaneuver.sqf";
UPSMON_Supressfire = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_Supressfire.sqf";
UPSMON_ChangeFormation = compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\fnc\UPSMON_ChangeFormation.sqf";

View File

@ -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;

View File

@ -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];
};
};

View File

@ -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

View File

@ -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

View File

@ -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";
};
};
};
};
};
};
};

View File

@ -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";
};
};
};
};
};
};
};
};

View File

@ -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

View File

@ -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

View File

@ -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);
};

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,8 @@
//Group
UPSMON_SetLeaderGrp = call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\UPSMON_SetLeaderGrp.sqf";
UPSMON_GetParams = call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\Params\UPSMON_GetParams.sqf";
UPSMON_GetGroupbehaviour = call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\Params\UPSMON_GetGroupbehaviour.sqf";
UPSMON_GetGroupformation = call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\Params\UPSMON_GetGroupformation.sqf";
UPSMON_GetGroupspeed = call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\Params\UPSMON_GetGroupspeed.sqf";
UPSMON_SetEventhandlers = call compile preProcessFileLineNumbers "\addons\sarge\UPSMON\COMMON\Group\Params\UPSMON_SetEventhandlers.sqf";

Some files were not shown because too many files have changed in this diff Show More