mirror of
https://github.com/IT07/a3_vemf_reloaded.git
synced 2024-08-30 16:52:11 +00:00
Code enhancements
This commit is contained in:
parent
6fd21f662e
commit
fa6c8024e2
@ -12,29 +12,31 @@
|
||||
BOOL - true if player(s) found
|
||||
*/
|
||||
|
||||
private ["_pos","_rad","_objs","_found","_isClose"]; // Prevents these variables overwriting existing vars from where this was called from
|
||||
private ["_pos","_found"];
|
||||
// By default, we assume that there are no players close. The distance check below should prove otherwise if there are players close
|
||||
_found = false;
|
||||
_pos = param [0, [], [[]]];
|
||||
if (count _pos isEqualTo 3) then
|
||||
{
|
||||
_rad = param [1, -1, [0]];
|
||||
if (_rad > -1) then
|
||||
{ // Check all player distances from _loc
|
||||
if (count allPlayers > 0) then
|
||||
{
|
||||
private ["_rad"];
|
||||
_rad = param [1, -1, [0]];
|
||||
if (_rad > -1) then
|
||||
{ // Check all player distances from _loc
|
||||
if (count allPlayers > 0) then
|
||||
{
|
||||
{
|
||||
if (isPlayer _x) then
|
||||
{
|
||||
if (isPlayer _x) then
|
||||
{
|
||||
if (speed _x < 250) then // Ignore fast moving players
|
||||
{
|
||||
_isClose = if ((position _x distance _pos) < _rad) then { true } else { false };
|
||||
if _isClose then { _found = true };
|
||||
};
|
||||
};
|
||||
} forEach allPlayers;
|
||||
};
|
||||
};
|
||||
if (speed _x < 250) then // Ignore fast moving players
|
||||
{
|
||||
private ["_isClose"];
|
||||
_isClose = if ((position _x distance _pos) < _rad) then { true } else { false };
|
||||
if _isClose then { _found = true };
|
||||
};
|
||||
};
|
||||
} forEach allPlayers;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_found
|
||||
|
@ -9,12 +9,14 @@
|
||||
Returns: SIDE - unit's side
|
||||
*/
|
||||
|
||||
private ["_return","_cfg","_faction"];
|
||||
private ["_return"];
|
||||
if (_this isEqualType "") then
|
||||
{
|
||||
private ["_cfg"];
|
||||
_cfg = configFile >> "CfgVehicles" >> _this >> "faction";
|
||||
if not isNull _cfg then
|
||||
{
|
||||
private ["_faction"];
|
||||
_faction = getText _cfg;
|
||||
switch _faction do
|
||||
{
|
||||
|
@ -14,12 +14,11 @@
|
||||
_this select 6: STRING (optional) - Exact config name of mission override settings to load
|
||||
|
||||
Returns:
|
||||
if mode = loc then: ARRAY - format [name of town/location, town position]
|
||||
if mode = loc then: ARRAY - format [name of town/location, town center position]
|
||||
if mode = pos then POSITION
|
||||
*/
|
||||
|
||||
private ["_settings","_locPos","_loc","_locName","_ret","_continue","_settings","_blackList","_usedLocs","_checkRange","_tooCloseRange","_maxPrefered","_skipDistance","_nonPopulated","_mode","_pos","_hasPlayers","_blackPos","_checkBlackPos"];
|
||||
|
||||
private ["_ret","_settings","_nonPopulated","_blackPos","_missionDistance","_range","_missionConfigName"];
|
||||
_ret = false;
|
||||
// Define settings
|
||||
_settings = [["nonPopulated","noMissionPos","missionDistance"]] call VEMFr_fnc_getSetting;
|
||||
@ -31,6 +30,7 @@ _range = worldSize;
|
||||
_missionConfigName = param [6, "", [""]];
|
||||
if not(_missionConfigName isEqualTo "") then
|
||||
{
|
||||
private ["_nonPopulatedOverride"];
|
||||
_nonPopulatedOverride = ([[_missionConfigName],["nonPopulated"]] call VEMFr_fnc_getSetting) select 0;
|
||||
if not isNil"_nonPopulatedOverride" then
|
||||
{
|
||||
@ -40,34 +40,44 @@ if not(_missionConfigName isEqualTo "") then
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
private ["_checkBlackPos"];
|
||||
_checkBlackPos = false;
|
||||
if (count _blackPos > 0) then
|
||||
{
|
||||
_checkBlackPos = true;
|
||||
};
|
||||
|
||||
private ["_mode"];
|
||||
_mode = param [0, "", [""]];
|
||||
if not(_mode isEqualTo "") then
|
||||
{
|
||||
private ["_onRoad","_roadRange","_cntr"];
|
||||
_onRoad = param [1, false, [false]];
|
||||
_roadRange = 5000;
|
||||
_cntr = param [2, [], [[]]];
|
||||
if (_cntr isEqualTypeArray [0,0,0]) then
|
||||
{
|
||||
private ["_tooCloseRange"];
|
||||
_tooCloseRange = param [3, -1, [0]];
|
||||
if (_tooCloseRange > -1) then
|
||||
{
|
||||
private ["_maxPrefered"];
|
||||
_maxPrefered = param [4, -1, [0]];
|
||||
if (_maxPrefered > -1) then
|
||||
{
|
||||
private ["_skipDistance"];
|
||||
_skipDistance = param [5, -1, [0]];
|
||||
if (_skipDistance > -1) then
|
||||
{
|
||||
if (_mode isEqualTo "loc") then
|
||||
{
|
||||
// Get a list of locations close to _cntr (position of player)
|
||||
private ["_locs"];
|
||||
_locs = nearestLocations [_cntr, ["CityCenter","Strategic","StrongpointArea","NameVillage","NameCity","NameCityCapital",if(_nonPopulated isEqualTo 1)then{"nameLocal","Area","BorderCrossing","Hill","fakeTown","Name","RockArea","ViewPoint"}], _range];
|
||||
if (count _locs > 0) then
|
||||
{
|
||||
private ["_usedLocs","_remLocs","_blackListMapClasses","_listedMaps"];
|
||||
_usedLocs = uiNamespace getVariable "VEMFrUsedLocs";
|
||||
_remLocs = [];
|
||||
_blackListMapClasses = "true" configClasses (configFile >> "CfgVemfReloaded" >> "locationBlackLists");
|
||||
@ -80,6 +90,7 @@ if not(_mode isEqualTo "") then
|
||||
if not(worldName in _listedMaps) then { _blackList = ([["locationBlackLists","Other"],["locations"]] call VEMFr_fnc_getSetting) select 0 };
|
||||
|
||||
{ // Check _locs for invalid locations (too close, hasPlayers or inBlacklist)
|
||||
private ["_hasPlayers"];
|
||||
_hasPlayers = [locationPosition _x, _skipDistance] call VEMFr_fnc_checkPlayerPresence;
|
||||
if _hasPlayers then
|
||||
{
|
||||
@ -95,9 +106,11 @@ if not(_mode isEqualTo "") then
|
||||
{
|
||||
if (count _x isEqualTo 2) then
|
||||
{
|
||||
private ["_pos"];
|
||||
_pos = _x param [0, [0,0,0], [[]]];
|
||||
if not(_pos isEqualTo [0,0,0]) then
|
||||
{
|
||||
private ["_range"];
|
||||
_range = _x param [1, 600, [0]];
|
||||
if ((_pos distance _locPos) < _range) then
|
||||
{
|
||||
@ -144,14 +157,17 @@ if not(_mode isEqualTo "") then
|
||||
} forEach _locs;
|
||||
|
||||
{ // Remove all invalid locations from _locs
|
||||
private ["_index"];
|
||||
_index = _locs find _x;
|
||||
_locs deleteAt _index;
|
||||
} forEach _remLocs;
|
||||
|
||||
private ["_far","_pref"];
|
||||
// Check what kind of distances we have
|
||||
_far = []; // Further than _maxPrefered
|
||||
_pref = []; // Closer then _maxPrefered
|
||||
{
|
||||
private ["_dist"];
|
||||
_dist = _cntr distance (locationPosition _x);
|
||||
if (_dist > _maxPrefered) then
|
||||
{
|
||||
@ -164,6 +180,7 @@ if not(_mode isEqualTo "") then
|
||||
} forEach _locs;
|
||||
|
||||
// Check if there are any prefered locations. If yes, randomly select one
|
||||
private ["_loc"];
|
||||
if (count _pref > 0) then
|
||||
{
|
||||
_loc = selectRandom _pref;
|
||||
@ -189,6 +206,7 @@ if not(_mode isEqualTo "") then
|
||||
};
|
||||
if (_mode isEqualTo "pos") then
|
||||
{
|
||||
private ["_valid"];
|
||||
_valid = false;
|
||||
for "_p" from 1 to 10 do
|
||||
{
|
||||
@ -196,9 +214,11 @@ if not(_mode isEqualTo "") then
|
||||
{
|
||||
if not _ret then
|
||||
{
|
||||
private ["_pos"];
|
||||
_pos = [_cntr, _tooCloseRange, -1, 2, 0, 50, 0] call BIS_fnc_findSafePos;
|
||||
if _onRoad then
|
||||
{
|
||||
private ["_roads"];
|
||||
_roads = _pos nearRoads _roadRange;
|
||||
if (count _roads > 0) then
|
||||
{
|
||||
@ -214,8 +234,7 @@ if not(_mode isEqualTo "") then
|
||||
_pos = position (_closest select 0);
|
||||
};
|
||||
};
|
||||
_hasPlayers = [_pos, _skipDistance] call VEMFr_fnc_checkPlayerPresence;
|
||||
if not(_hasPlayers) then
|
||||
if not([_pos, _skipDistance] call VEMFr_fnc_checkPlayerPresence) then
|
||||
{
|
||||
_ret = _pos;
|
||||
};
|
||||
|
@ -17,21 +17,19 @@
|
||||
ARRAY - Result
|
||||
*/
|
||||
|
||||
private["_cfg","_v","_r","_path","_check","_build"];
|
||||
private["_r","_check","_v"];
|
||||
_r = [];
|
||||
_check =
|
||||
{
|
||||
if (isNumber _cfg) then
|
||||
{
|
||||
_v = getNumber _cfg
|
||||
};
|
||||
if not(isNumber _cfg) then
|
||||
} else
|
||||
{
|
||||
if (isText _cfg) then
|
||||
{
|
||||
_v = getText _cfg
|
||||
};
|
||||
if not(isText _cfg) then
|
||||
} else
|
||||
{
|
||||
if (isArray _cfg) then
|
||||
{
|
||||
@ -43,6 +41,7 @@ _check =
|
||||
|
||||
if (_this isEqualType "") then
|
||||
{
|
||||
private ["_cfg"];
|
||||
if (isNull (configFile >> "CfgVemfReloaded" >> "CfgSettingsOverride" >> _this)) then
|
||||
{
|
||||
_cfg = configFile >> "CfgVemfReloaded" >> _this;
|
||||
@ -51,7 +50,7 @@ if (_this isEqualType "") then
|
||||
_cfg = configFile >> "CfgVemfReloaded" >> "CfgSettingsOverride" >> _this;
|
||||
};
|
||||
call _check;
|
||||
if not(isNil"_v") then
|
||||
if not isNil"_v" then
|
||||
{
|
||||
_r = _v;
|
||||
};
|
||||
@ -61,14 +60,17 @@ if (_this isEqualType []) then
|
||||
{
|
||||
if (_this isEqualTypeArray [[],[]]) then
|
||||
{
|
||||
private ["_path","_build"];
|
||||
_path = _this select 0;
|
||||
//["fn_getSetting", 1, format["_path = %1", _path]] spawn VEMFr_fnc_log;
|
||||
_build = {
|
||||
_build =
|
||||
{
|
||||
{
|
||||
_cfg = _cfg >> _x;
|
||||
} forEach _path;
|
||||
};
|
||||
{
|
||||
private ["_cfg"];
|
||||
_cfg = configFile >> "CfgVemfReloaded" >> "CfgSettingsOverride";
|
||||
call _build;
|
||||
_cfg = _cfg >> _x;
|
||||
@ -92,6 +94,7 @@ if (_this isEqualType []) then
|
||||
if (_this isEqualTypeArray [[]]) then
|
||||
{
|
||||
{
|
||||
private ["_cfg"];
|
||||
_cfg = configFile >> "CfgVemfReloaded" >> "CfgSettingsOverride" >> _x;
|
||||
if (isNull _cfg) then
|
||||
{
|
||||
@ -103,5 +106,4 @@ if (_this isEqualType []) then
|
||||
};
|
||||
};
|
||||
|
||||
if isNil"_v" then { _r = nil };
|
||||
_r
|
||||
|
@ -26,7 +26,7 @@ if (_this isEqualType []) then
|
||||
{
|
||||
if not(vest _unit isEqualTo "") then
|
||||
{
|
||||
private ["_itemMass","_weapon","_mag","_magMass","_vestMass","_itemMass"];
|
||||
private ["_weapon","_mag","_magMass","_vestMass","_itemMass"];
|
||||
_weapon = primaryWeapon _unit;
|
||||
_mag = selectRandom (getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"));
|
||||
_magMass = getNumber (configFile >> "CfgMagazines" >> _mag >> "mass");
|
||||
@ -83,7 +83,7 @@ if (_this isEqualType []) then
|
||||
{
|
||||
if not(uniform _unit isEqualTo "") then
|
||||
{
|
||||
private ["_weapon","_mag","_uniformMass"];
|
||||
private ["_weapon","_mag","_magMass","_uniformMass"];
|
||||
_weapon = handGunWeapon _unit;
|
||||
_mag = selectRandom (getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"));
|
||||
_magMass = getNumber (configFile >> "CfgMagazines" >> _mag >> "mass");
|
||||
@ -104,13 +104,11 @@ if (_this isEqualType []) then
|
||||
};
|
||||
};
|
||||
_done = true;
|
||||
};
|
||||
if not local _unit then
|
||||
} else // If unit is not local
|
||||
{
|
||||
["fn_giveAmmo", 0, format["%1 is not local. Can not execute!", _unit]] spawn VEMfr_fnc_log;
|
||||
};
|
||||
};
|
||||
if isNull _unit then
|
||||
} else // If unit isNull
|
||||
{
|
||||
["fn_giveAmmo", 0, "_unit isNull. Can not execute!"] spawn VEMFr_fnc_log;
|
||||
};
|
||||
|
@ -8,71 +8,73 @@
|
||||
_this: ARRAY
|
||||
_this select 0: OBJECT - unit
|
||||
|
||||
Returns: BOOLEAN - if not isNull _unit, returns true
|
||||
Returns: BOOLEAN - true if no errors occured
|
||||
*/
|
||||
|
||||
private ["_done","_unit","_randomPattern","_primaryWeapon","_unit","_handgunWeapon"];
|
||||
private ["_done"];
|
||||
_done = false;
|
||||
if (_this isEqualType []) then
|
||||
{
|
||||
_unit = param [0, objNull, [objNull]];
|
||||
if not (isNull _unit) then
|
||||
{
|
||||
// primaryWeapon items
|
||||
private ["_randomPattern"];
|
||||
_randomPattern = [1,0,1,0,1,1,1,1,0,0,1,1,1];
|
||||
_primaryWeapon = primaryWeapon _unit;
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random scope
|
||||
_scopes = getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
|
||||
if ([["DynamicLocationInvasion"],["allowTWS"]] call VEMFr_fnc_getSetting isEqualTo 0) then
|
||||
_unit = param [0, objNull, [objNull]];
|
||||
if not (isNull _unit) then
|
||||
{
|
||||
// primaryWeapon items
|
||||
private ["_randomPattern","_primaryWeapon"];
|
||||
_randomPattern = [1,0,1,0,1,1,1,1,0,0,1,1,1];
|
||||
_primaryWeapon = primaryWeapon _unit;
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random scope
|
||||
private ["_scopes"];
|
||||
_scopes = getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
|
||||
if ([["DynamicLocationInvasion"],["allowTWS"]] call VEMFr_fnc_getSetting isEqualTo 0) then
|
||||
{
|
||||
private["_indexes"];
|
||||
_indexes = [];
|
||||
{
|
||||
private["_indexes"];
|
||||
_indexes = [];
|
||||
{
|
||||
if not(_x find "tws" isEqualTo -1) then
|
||||
{
|
||||
_indexes pushBack _forEachIndex;
|
||||
};
|
||||
if not(_x find "TWS" isEqualTo -1) then
|
||||
{
|
||||
_indexes pushBack _forEachIndex;
|
||||
};
|
||||
} forEach _scopes;
|
||||
if (count _indexes > 0) then
|
||||
{
|
||||
{
|
||||
_scopes deleteAt _x;
|
||||
} forEach _indexes;
|
||||
};
|
||||
if not(_x find "tws" isEqualTo -1) then
|
||||
{
|
||||
_indexes pushBack _forEachIndex;
|
||||
};
|
||||
if not(_x find "TWS" isEqualTo -1) then
|
||||
{
|
||||
_indexes pushBack _forEachIndex;
|
||||
};
|
||||
} forEach _scopes;
|
||||
if (count _indexes > 0) then
|
||||
{
|
||||
{
|
||||
_scopes deleteAt _x;
|
||||
} forEach _indexes;
|
||||
};
|
||||
_unit addPrimaryWeaponItem (selectRandom _scopes);
|
||||
};
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random muzzle
|
||||
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")));
|
||||
};
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random pointer
|
||||
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems")));
|
||||
};
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random bipod
|
||||
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "UnderbarrelSlot" >> "compatibleItems")));
|
||||
};
|
||||
};
|
||||
_unit addPrimaryWeaponItem (selectRandom _scopes);
|
||||
};
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random muzzle
|
||||
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")));
|
||||
};
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random pointer
|
||||
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems")));
|
||||
};
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random bipod
|
||||
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "UnderbarrelSlot" >> "compatibleItems")));
|
||||
};
|
||||
|
||||
// handgunWeapon items
|
||||
_handgunWeapon = handgunWeapon _unit;
|
||||
_randomPattern = [1,0,1,0,0,1,0,0,0,0,1,1,1];
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random scope
|
||||
_unit addSecondaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _handgunWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems")));
|
||||
};
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random muzzle
|
||||
_unit addSecondaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _handgunWeapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")));
|
||||
};
|
||||
_done = true;
|
||||
};
|
||||
private ["_handgunWeapon","_randomPattern"];
|
||||
// handgunWeapon items
|
||||
_handgunWeapon = handgunWeapon _unit;
|
||||
_randomPattern = [1,0,1,0,0,1,0,0,0,0,1,1,1];
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random scope
|
||||
_unit addSecondaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _handgunWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems")));
|
||||
};
|
||||
if (selectRandom _randomPattern isEqualTo 1) then
|
||||
{ // Select random muzzle
|
||||
_unit addSecondaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _handgunWeapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")));
|
||||
};
|
||||
_done = true;
|
||||
};
|
||||
};
|
||||
_done
|
||||
|
@ -2,7 +2,7 @@
|
||||
Author: IT07
|
||||
|
||||
Description:
|
||||
selects a headless client with least (VEMF) load
|
||||
selects a headless client with least (VEMFr) load
|
||||
|
||||
Params:
|
||||
None
|
||||
@ -11,42 +11,49 @@
|
||||
OBJECT - the headless client
|
||||
*/
|
||||
|
||||
private ["_hasLowest"];
|
||||
if (("headLessClientSupport" call VEMFr_fnc_getSetting) isEqualTo 1) then
|
||||
{ // Ok, Headless Clients enabled. let us continue
|
||||
private ["_hcList","_ingameHCs"];
|
||||
_hcList = "headLessClientNames" call VEMFr_fnc_getSetting;
|
||||
// We have the names now, check if any of them is actually ingame
|
||||
_ingameHCs = [];
|
||||
{
|
||||
if (typeOf _x isEqualTo "HeadlessClient_F") then
|
||||
{
|
||||
if (_x in _hcList) then
|
||||
{
|
||||
_ingameHCs pushBack [_x, name _x];
|
||||
};
|
||||
};
|
||||
} forEach allPlayers;
|
||||
if (count _ingameHCs > 0) then
|
||||
{ // At least 1 of given headless clients is ingame, lets check their load
|
||||
private ["_globalLoad","_lowestLoad","_hasLowest"];
|
||||
_globalLoad = uiNamespace getVariable "VEMFrHcLoad";
|
||||
_lowestLoad = 99999;
|
||||
_hasLowest = "";
|
||||
{ // Find the lowest load number
|
||||
private ["_load"];
|
||||
_load = _x select 1;
|
||||
if (_load < _lowestLoad) then
|
||||
{
|
||||
_lowestLoad = _load;
|
||||
_hasLowest = _x select 0;
|
||||
};
|
||||
} forEach _globalLoad;
|
||||
|
||||
private ["_index"];
|
||||
// HC with lowest load found, add +1 to its current load
|
||||
_index = _globalLoad find [_hasLowest, _lowestLoad];
|
||||
if (_index > -1) then
|
||||
{
|
||||
_globalLoad set [_index,[_hasLowest, _lowestLoad +1]]
|
||||
};
|
||||
};
|
||||
} else
|
||||
{
|
||||
// Ok, Headless Clients enabled. let us continue
|
||||
_hcList = "headLessClientNames" call VEMFr_fnc_getSetting;
|
||||
// We have the names now, check if any of them is actually ingame
|
||||
_ingameHCs = [];
|
||||
{
|
||||
if (typeOf _x isEqualTo "HeadlessClient_F") then
|
||||
{
|
||||
if (_x in _hcList) then
|
||||
{
|
||||
_ingameHCs pushBack [_x, name _x];
|
||||
};
|
||||
};
|
||||
} forEach allPlayers;
|
||||
if (count _ingameHCs > 0) then
|
||||
{
|
||||
// At least 1 of given headless clients is ingame, lets check their load
|
||||
_globalLoad = uiNamespace getVariable "VEMFrHcLoad";
|
||||
_lowestLoad = 99999;
|
||||
_hasLowest = "";
|
||||
{ // Find the lowest load number
|
||||
_load = _x select 1;
|
||||
if (_load < _lowestLoad) then
|
||||
{
|
||||
_lowestLoad = _load;
|
||||
_hasLowest = _x select 0;
|
||||
};
|
||||
} forEach _globalLoad;
|
||||
// HC with lowest load found, add +1 to its current load
|
||||
_index = _globalLoad find [_hasLowest, _lowestLoad];
|
||||
if (_index > -1) then
|
||||
{
|
||||
_globalLoad set [_index,[_hasLowest, _lowestLoad +1]]
|
||||
};
|
||||
};
|
||||
["fn_headLessClient", 0, "Can not run. headLessClientSupport is not enabled"] spawn VEMFr_fnc_log;
|
||||
};
|
||||
// Lowest load found, send it
|
||||
_hasLowest
|
||||
|
@ -14,22 +14,26 @@
|
||||
BOOLEAN - true if nothing failed
|
||||
*/
|
||||
|
||||
private ["_ok","_params","_units","_missionName","_settings","_aiLaunchers","_aiGear","_uniforms","_headGear","_vests","_backpacks","_launchers","_rifles","_pistols","_aiMode","_givenAmmo"];
|
||||
private ["_ok","_params"];
|
||||
_ok = false;
|
||||
_params = _this;
|
||||
if (_this isEqualType []) then
|
||||
{
|
||||
private ["_units"];
|
||||
_units = param [0, [], [[]]];
|
||||
if (count _units > 0) then
|
||||
{
|
||||
private ["_missionName"];
|
||||
_missionName = param [1, "", [""]];
|
||||
if (_missionName in ("missionList" call VEMFr_fnc_getSetting)) then
|
||||
{
|
||||
private ["_aiMode"];
|
||||
_aiMode = param [2, 0, [0]];
|
||||
switch _aiMode do
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
private ["_aiGear","_uniforms","_headGear","_vests","_backpacks","_rifles","_pistols","_aiLaunchers","_launchers","_launcherChance"];
|
||||
// Define settings
|
||||
_aiGear = [["aiGear"],["aiUniforms","aiHeadGear","aiVests","aiBackpacks","aiLaunchers","aiRifles","aiPistols"]] call VEMFr_fnc_getSetting;
|
||||
_uniforms = _aiGear select 0;
|
||||
@ -42,6 +46,7 @@ if (_this isEqualType []) then
|
||||
if (_aiLaunchers isEqualTo 1) then
|
||||
{
|
||||
_launchers = _aiGear select 4;
|
||||
_launcherChance = ([["DynamicLocationInvasion"],["hasLauncherChance"]] call VEMFr_fnc_getSetting) select 0;
|
||||
};
|
||||
{
|
||||
private ["_unit","_gear","_ammo"];
|
||||
@ -68,26 +73,23 @@ if (_this isEqualType []) then
|
||||
_gear = selectRandom _vests;
|
||||
_unit addVest _gear;
|
||||
|
||||
if ((floor random 2) isEqualTo 0) then
|
||||
if (_aiLaunchers isEqualTo 1) then
|
||||
{
|
||||
_gear = selectRandom _backpacks;
|
||||
_unit addBackpack _gear;
|
||||
if (_aiLaunchers isEqualTo 1) then
|
||||
if (_launcherChance isEqualTo 100 OR (ceil random (100 / _launcherChance) isEqualTo (ceil random (100 / _launcherChance)))) then
|
||||
{
|
||||
if ((floor random 4) isEqualTo 0) then
|
||||
_gear = selectRandom _backpacks;
|
||||
_unit addBackpack _gear;
|
||||
private ["_ammo"];
|
||||
_gear = selectRandom _launchers;
|
||||
_unit addWeapon _gear;
|
||||
_ammo = getArray (configFile >> "cfgWeapons" >> _gear >> "magazines");
|
||||
if (count _ammo > 2) then
|
||||
{
|
||||
private ["_ammo"];
|
||||
_gear = selectRandom _launchers;
|
||||
_unit addWeapon _gear;
|
||||
_ammo = getArray (configFile >> "cfgWeapons" >> _gear >> "magazines");
|
||||
if (count _ammo > 2) then
|
||||
{
|
||||
_ammo resize 2;
|
||||
};
|
||||
for "_i" from 0 to (2 + (round random 1)) do
|
||||
{
|
||||
_unit addMagazine (selectRandom _ammo);
|
||||
};
|
||||
_ammo resize 2;
|
||||
};
|
||||
for "_i" from 0 to (2 + (round random 1)) do
|
||||
{
|
||||
_unit addMagazine (selectRandom _ammo);
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -118,7 +120,7 @@ if (_this isEqualType []) then
|
||||
};
|
||||
case 1:
|
||||
{
|
||||
private ["_policeGear","_headGear","_vests"];
|
||||
private ["_policeGear","_headGear","_vests","_uniforms","_rifles","_pistols","_backpacks"];
|
||||
_policeGear = [["policeConfig"],["headGear","vests","uniforms","rifles","pistols","backpacks"]] call VEMFr_fnc_getSetting;
|
||||
_headGear = _policeGear select 0;
|
||||
_vests = _policeGear select 1;
|
||||
@ -127,6 +129,7 @@ if (_this isEqualType []) then
|
||||
_pistols = _policeGear select 4;
|
||||
_backpacks = _policeGear select 5;
|
||||
{
|
||||
private ["_unit","_hat","_vest","_uniform","_rifle","_pistol","_backpack","_givenAmmo","_giveAttachments"];
|
||||
_unit = _x;
|
||||
// Strip it
|
||||
removeAllWeapons _unit;
|
||||
@ -172,11 +175,12 @@ if (_this isEqualType []) then
|
||||
};
|
||||
case 2:
|
||||
{
|
||||
private ["_policeGear","_headGear","_vests"];
|
||||
private ["_policeGear","_rifles","_pistols"];
|
||||
_policeGear = [["policeConfig"],["rifles","pistols"]] call VEMFr_fnc_getSetting;
|
||||
_rifles = _policeGear select 0;
|
||||
_pistols = _policeGear select 1;
|
||||
{
|
||||
private ["_unit","_rifle","_pistol","_givenAmmo","_giveAttachments"];
|
||||
_unit = _x;
|
||||
// Strip it
|
||||
removeAllWeapons _unit;
|
||||
@ -217,7 +221,7 @@ if (_this isEqualType []) then
|
||||
};
|
||||
default
|
||||
{
|
||||
["fn_loadInv", 0, format["Incorrect _aiMode of %1 given!", _aiMode]] spawn VEMFr_fnc_log;
|
||||
["fn_loadInv", 0, format["Incorrect _aiMode (%1) given!", _aiMode]] spawn VEMFr_fnc_log;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -7,16 +7,8 @@
|
||||
Returns:
|
||||
BOOL - true if everything went ok
|
||||
*/
|
||||
private
|
||||
[
|
||||
"_crate","_settings","_loot","_amount","_quant","_prim","_sec","_mags","_att","_items","_vests","_packs","_primaries","_secondaries",
|
||||
"_magazines","_attachments","_items","_vests","_backpacks","_headGear","_blackList","_maxPrim","_minPrim","_maxSec","_minSec",
|
||||
"_maxMagSlots","_minMagSlots","_maxAttSlots","_minAttSlots","_maxItemSlots","_minItemSlots","_maxVestSlots","_minVestSlots",
|
||||
"_maxHeadGearSlots","_minHeadGearSlots","_maxBagSlots","_minBagSlots","_ok"
|
||||
];
|
||||
|
||||
private ["_ok","_crate"];
|
||||
_ok = false;
|
||||
// Define _vars
|
||||
_crate = param [0, objNull, [objNull]];
|
||||
if not isNull _crate then
|
||||
{
|
||||
@ -24,6 +16,7 @@ if not isNull _crate then
|
||||
clearMagazineCargoGlobal _crate;
|
||||
clearBackpackCargoGlobal _crate;
|
||||
clearItemCargoGlobal _crate;
|
||||
private ["_settings"];
|
||||
_settings =
|
||||
[
|
||||
["crateLoot"],
|
||||
@ -33,6 +26,10 @@ if not isNull _crate then
|
||||
"itemLoot","vestLoot","backpackLoot","headGearLoot","blackListLoot"
|
||||
]
|
||||
] call VEMFr_fnc_getSetting;
|
||||
private [
|
||||
"_maxPrim","_minPrim","_maxSec","_minSec","_maxMagSlots","_minMagSlots","_maxAttSlots","_minAttSlots","_maxItemSlots","_minItemSlots","_maxVestSlots","_minVestSlots",
|
||||
"_maxHeadGearSlots","_minHeadGearSlots","_maxBagSlots","_minBagSlots","_primaries","_secondaries","_magazines","_attachments","_items","_vests","_backpacks","_headGear","_blackList"
|
||||
];
|
||||
_maxPrim = _settings select 0;
|
||||
_minPrim = _settings select 1;
|
||||
_maxSec = _settings select 2;
|
||||
@ -62,6 +59,7 @@ if not isNull _crate then
|
||||
// Add primary weapons
|
||||
for "_j" from 0 to (_maxPrim - _minPrim + floor random _minPrim) do
|
||||
{
|
||||
private ["_prim"];
|
||||
_prim = _primaries call BIS_fnc_selectRandom;
|
||||
if not((_prim select 0) in _blackList) then
|
||||
{
|
||||
@ -72,6 +70,7 @@ if not isNull _crate then
|
||||
// Secondary weapons
|
||||
for "_j" from 0 to (_maxSec - _minSec + floor random _minSec) do
|
||||
{
|
||||
private ["_sec"];
|
||||
_sec = _secondaries call BIS_fnc_selectRandom;
|
||||
if not((_sec select 0) in _blackList) then
|
||||
{
|
||||
@ -82,6 +81,7 @@ if not isNull _crate then
|
||||
// Magazines
|
||||
for "_j" from 0 to (_maxMagSlots - _minMagSlots + floor random _minMagSlots) do
|
||||
{
|
||||
private ["_mag"];
|
||||
_mag = _magazines call BIS_fnc_selectRandom;
|
||||
if not((_mag select 0) in _blackList) then
|
||||
{
|
||||
@ -92,6 +92,7 @@ if not isNull _crate then
|
||||
// Weapon attachments
|
||||
for "_j" from 0 to (_maxAttSlots - _minAttSlots + floor random _minAttSlots) do
|
||||
{
|
||||
private ["_att"];
|
||||
_att = _attachments call BIS_fnc_selectRandom;
|
||||
if not((_att select 0) in _blackList) then
|
||||
{
|
||||
@ -102,6 +103,7 @@ if not isNull _crate then
|
||||
// Items
|
||||
for "_j" from 0 to (_maxItemSlots - _minItemSlots + floor random _minItemSlots) do
|
||||
{
|
||||
private ["_item"];
|
||||
_item = _items call BIS_fnc_selectRandom;
|
||||
if not((_item select 0) in _blacklist) then
|
||||
{
|
||||
@ -112,6 +114,7 @@ if not isNull _crate then
|
||||
// Vests
|
||||
for "_j" from 0 to (_maxVestSlots - _minVestSlots + floor random _minVestSlots) do
|
||||
{
|
||||
private ["_vest"];
|
||||
_vest = _vests call BIS_fnc_selectRandom;
|
||||
if not((_vest select 0) in _blackList) then
|
||||
{
|
||||
@ -122,6 +125,7 @@ if not isNull _crate then
|
||||
// Helmets / caps / berets / bandanas
|
||||
for "_j" from 0 to (_maxHeadGearSlots - _minHeadGearSlots + floor random _minHeadGearSlots) do
|
||||
{
|
||||
private ["_headGearItem"];
|
||||
_headGearItem = _headGear call BIS_fnc_selectRandom;
|
||||
if not((_headGearItem select 0) in _blackList) then
|
||||
{
|
||||
@ -132,6 +136,7 @@ if not isNull _crate then
|
||||
// Backpacks
|
||||
for "_j" from 0 to (_maxBagSlots - _minBagSlots + floor random _minBagSlots) do
|
||||
{
|
||||
private ["_pack"];
|
||||
_pack = _backpacks call BIS_fnc_selectRandom;
|
||||
if not((_pack select 0) in _blackList) then
|
||||
{
|
||||
|
@ -14,10 +14,11 @@
|
||||
nothing (use spawn, not call)
|
||||
*/
|
||||
|
||||
private ["_param","_prefix","_mode","_logThis","_logModesAllowed","_loggingEnabled"];
|
||||
private ["_loggingEnabled"];
|
||||
_loggingEnabled = "debugMode" call VEMFr_fnc_getSetting;
|
||||
if not(_loggingEnabled isEqualTo 0) then
|
||||
{
|
||||
private ["_prefix","_type","_line","_doLog"];
|
||||
_prefix = param [0, "", [""]];
|
||||
_type = param [1, 3, [0]];
|
||||
_line = param [2, "", [""]];
|
||||
|
@ -8,45 +8,72 @@
|
||||
_this select 0: POSITION - center of area to place mines around
|
||||
_this select 1: SCALAR - the minimum distance
|
||||
_this select 2: SCALAR - the maximum distance (must be higher than minimum of course)
|
||||
_this select 3: STRING - exact config name of mission
|
||||
|
||||
Returns:
|
||||
BOOL - true if all OK
|
||||
*/
|
||||
|
||||
private ["_ok","_enabled","_pos","_min","_max","_amount","_minePos","_mine","_mines","_mines","_mineTypes"];
|
||||
private ["_ok","_mineSetting","_missionName"];
|
||||
_ok = false;
|
||||
_enabled = ([["DynamicLocationInvasion"],["mines"]] call VEMFr_fnc_getSetting) select 0;
|
||||
if (_enabled > 0) then
|
||||
_missionName = param [3, "", [""]];
|
||||
if (_missionName in ("missionList" call VEMFr_fnc_getSetting)) then
|
||||
{
|
||||
_pos = param [0, [], [[]]];
|
||||
if (count _pos isEqualTo 3) then
|
||||
{
|
||||
_min = param [1, -1, [0]];
|
||||
if (_min > -1) then
|
||||
{
|
||||
private ["_mineSetting"];
|
||||
_mineSetting = ([[_missionName],["mines"]] call VEMFr_fnc_getSetting) select 0;
|
||||
if (_mineSetting > 0) then
|
||||
{
|
||||
private ["_pos"];
|
||||
_pos = param [0, [], [[]]];
|
||||
if (count _pos isEqualTo 3) then
|
||||
{
|
||||
private ["_min"];
|
||||
_min = param [1, -1, [0]];
|
||||
if (_min > -1) then
|
||||
{
|
||||
private ["_max"];
|
||||
_max = param [2, -1, [0]];
|
||||
if (_max > _min) then
|
||||
{
|
||||
_amount = ([["DynamicLocationInvasion"],["minesAmount"]] call VEMFr_fnc_getSetting) select 0;
|
||||
if (_amount > -1) then
|
||||
{
|
||||
_mines = [["DynamicLocationInvasion"],["mines"]] call VEMFr_fnc_getSetting param [0, 1, [0]];
|
||||
if (_mines isEqualTo 1) then { _mineTypes = ["ATMine"] };
|
||||
if (_mines isEqualTo 2) then { _mineTypes = ["APERSMine"] };
|
||||
if (_mines isEqualTo 3) then { _mineTypes = ["ATMine","APERSMine"] };
|
||||
_mines = [];
|
||||
["fn_placeMines", 1, format["Placing %1 mines at %2", _amount, _pos]] spawn VEMFr_fnc_log;
|
||||
for "_m" from 1 to _amount do
|
||||
{
|
||||
_mine = createMine [selectRandom _mineTypes, ([_pos, _min, _max, 2, 0, 20, 0] call BIS_fnc_findSafePos), [], 0];
|
||||
uiSleep 0.5;
|
||||
_mines pushBack _mine;
|
||||
};
|
||||
_ok = [_mines];
|
||||
};
|
||||
private ["_amount"];
|
||||
_amount = ([[_missionName],["minesAmount"]] call VEMFr_fnc_getSetting) select 0;
|
||||
if (_amount > -1) then
|
||||
{
|
||||
switch _mineSetting do
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
_mineTypes = ["ATMine"]
|
||||
};
|
||||
case 2:
|
||||
{
|
||||
_mineTypes = ["APERSMine"]
|
||||
};
|
||||
case 3:
|
||||
{
|
||||
_mineTypes = ["ATMine","APERSMine"]
|
||||
};
|
||||
default
|
||||
{
|
||||
["fn_placeMines", 0, "Invalid mines mode!"] spawn VEMFr_fnc_log;
|
||||
};
|
||||
};
|
||||
|
||||
_mines = [];
|
||||
["fn_placeMines", 1, format["Placing %1 mines at %2", _amount, _pos]] spawn VEMFr_fnc_log;
|
||||
for "_m" from 1 to _amount do
|
||||
{
|
||||
private ["_mine"];
|
||||
_mine = createMine [selectRandom _mineTypes, ([_pos, _min, _max, 2, 0, 20, 0] call BIS_fnc_findSafePos), [], 0];
|
||||
uiSleep (0.5 + random 1);
|
||||
_mines pushBack _mine;
|
||||
};
|
||||
_ok = [_mines];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_ok
|
||||
|
@ -11,28 +11,29 @@
|
||||
ARRAY - [false if current player count is below minimum, true if (more than OR equalTo) minimum]
|
||||
*/
|
||||
|
||||
private ["_minimum","_players","_ok"];
|
||||
private ["_ok"];
|
||||
_ok = false;
|
||||
if (_this isEqualType []) then
|
||||
{
|
||||
_minimum = param [0, -1, [0]];
|
||||
if (_minimum > -1) then
|
||||
{
|
||||
if (count allPlayers >= _minimum) then
|
||||
{
|
||||
_players = 0;
|
||||
private ["_minimum"];
|
||||
_minimum = param [0, -1, [0]];
|
||||
if (_minimum > -1) then
|
||||
{
|
||||
if (count allPlayers >= _minimum) then
|
||||
{
|
||||
_players = 0;
|
||||
{
|
||||
if (isPlayer _x) then
|
||||
{
|
||||
if (isPlayer _x) then
|
||||
{
|
||||
_players = _players + 1;
|
||||
};
|
||||
} forEach allPlayers;
|
||||
if not(_players isEqualTo 0) then
|
||||
{
|
||||
_ok = true
|
||||
_players = _players + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach allPlayers;
|
||||
if not(_players isEqualTo 0) then
|
||||
{
|
||||
_ok = true
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_ok
|
||||
|
@ -12,7 +12,7 @@
|
||||
BOOL - true if OK
|
||||
*/
|
||||
|
||||
private["_signed","_abort"];
|
||||
private ["_ok","_group"];
|
||||
_ok = false;
|
||||
_group = param [0, grpNull, [grpNull]];
|
||||
if not isNull _group then
|
||||
@ -20,4 +20,5 @@ if not isNull _group then
|
||||
(uiNamespace getVariable "vemfGroups") pushBack _group;
|
||||
_ok = true
|
||||
};
|
||||
|
||||
_ok
|
||||
|
@ -10,31 +10,35 @@
|
||||
_this select 2: SCALAR - how many units to put in each group
|
||||
_this select 3: SCALAR - AI mode
|
||||
_this select 4: STRING - exact config name of mission
|
||||
_this select 5: SCALAR (optional) - maximum spawn distance from center
|
||||
|
||||
Returns:
|
||||
ARRAY format [[groups],[50cals]]
|
||||
*/
|
||||
|
||||
private // Make sure that the vars in this function do not interfere with vars in the calling script
|
||||
[
|
||||
"_pos","_grpCount","_unitsPerGrp","_sldrClass","_groups","_settings","_hc","_skills","_newPos","_return","_waypoints","_wp","_cyc","_units","_missionName",
|
||||
"_accuracy","_aimShake","_aimSpeed","_stamina","_spotDist","_spotTime","_courage","_reloadSpd","_commanding","_general","_loadInv","_noHouses","_cal50sVehs","_mode"
|
||||
];
|
||||
|
||||
private ["_spawned","_pos"];
|
||||
_spawned = [[],[]];
|
||||
_pos = param [0, [], [[]]];
|
||||
if (count _pos isEqualTo 3) then
|
||||
{
|
||||
private ["_grpCount"];
|
||||
_grpCount = param [1, 1, [0]];
|
||||
if (_grpCount > 0) then
|
||||
{
|
||||
private ["_unitsPerGrp"];
|
||||
_unitsPerGrp = param [2, 1, [0]];
|
||||
if (_unitsPerGrp > 0) then
|
||||
{
|
||||
private ["_mode","_missionName"];
|
||||
_mode = param [3, -1, [0]];
|
||||
_missionName = param [4, "", [""]];
|
||||
if (_missionName in ("missionList" call VEMFr_fnc_getSetting)) then
|
||||
{
|
||||
private [
|
||||
"_maxRange","_sldrClass","_groups","_hc","_aiDifficulty","_skills","_accuracy","_aimShake","_aimSpeed","_stamina","_spotDist","_spotTime",
|
||||
"_courage","_reloadSpd","_commanding","_general","_houses","_notTheseHouses","_goodHouses","_noHouses","_cal50s","_units"
|
||||
];
|
||||
_maxRange = param [5, 175, [0]];
|
||||
_sldrClass = "unitClass" call VEMFr_fnc_getSetting;
|
||||
_groups = [];
|
||||
_hc = "headLessClientSupport" call VEMFr_fnc_getSetting;
|
||||
@ -51,7 +55,7 @@ if (count _pos isEqualTo 3) then
|
||||
_commanding = _skills select 8;
|
||||
_general = _skills select 9;
|
||||
|
||||
_houses = nearestTerrainObjects [_pos, ["House"], 200]; // Find some houses to spawn in
|
||||
_houses = nearestTerrainObjects [_pos, ["House"], _maxRange]; // Find some houses to spawn in
|
||||
_notTheseHouses = "housesBlackList" call VEMFr_fnc_getSetting;
|
||||
_goodHouses = [];
|
||||
{ // Filter the houses that are too small for one group
|
||||
@ -85,15 +89,13 @@ if (count _pos isEqualTo 3) then
|
||||
_noHouses = true
|
||||
};
|
||||
};
|
||||
private ["_unitSide","_grp","_unit","_groupSide"];
|
||||
private ["_groupSide"];
|
||||
_groupSide = ("unitClass" call VEMFr_fnc_getSetting) call VEMFr_fnc_checkSide;
|
||||
if not isNil"_groupSide" then
|
||||
{
|
||||
private ["_grp"];
|
||||
_grp = createGroup _groupSide;
|
||||
(_spawned select 0) pushBack _grp;
|
||||
};
|
||||
if not isNil"_grp" then
|
||||
{
|
||||
if not _noHouses then
|
||||
{
|
||||
_grp enableAttack false;
|
||||
@ -110,11 +112,15 @@ if (count _pos isEqualTo 3) then
|
||||
_housePositions = [_house] call BIS_fnc_buildingPositions;
|
||||
};
|
||||
|
||||
private ["_placed50"];
|
||||
_placed50 = false;
|
||||
for "_u" from 1 to _unitsPerGrp do
|
||||
{
|
||||
private ["_spawnPos","_hmg"];
|
||||
if not _noHouses then
|
||||
if _noHouses then
|
||||
{
|
||||
_spawnPos = [_pos,20,_maxRange,1,0,200,0] call BIS_fnc_findSafePos; // Find Nearby Position
|
||||
} else
|
||||
{
|
||||
_spawnPos = selectRandom _housePositions;
|
||||
if not _placed50 then
|
||||
@ -128,11 +134,8 @@ if (count _pos isEqualTo 3) then
|
||||
};
|
||||
};
|
||||
};
|
||||
if _noHouses then
|
||||
{
|
||||
_spawnPos = [_pos,20,250,1,0,200,0] call BIS_fnc_findSafePos; // Find Nearby Position
|
||||
};
|
||||
|
||||
private ["_unit"];
|
||||
_unit = _grp createUnit [_sldrClass, _spawnPos, [], 0, "CAN_COLLIDE"]; // Create Unit There
|
||||
if not _noHouses then
|
||||
{
|
||||
@ -150,6 +153,7 @@ if (count _pos isEqualTo 3) then
|
||||
};
|
||||
};
|
||||
|
||||
private ["_houseIndex"];
|
||||
_houseIndex = _housePositions find _spawnPos;
|
||||
_housePositions deleteAt _houseIndex;
|
||||
};
|
||||
@ -167,22 +171,26 @@ if (count _pos isEqualTo 3) then
|
||||
_unit setSkill ["commanding", _commanding];
|
||||
_unit setSkill ["general", _general];
|
||||
_unit setRank "Private"; // Set rank
|
||||
if (_u isEqualTo _unitsPerGrp) then
|
||||
{
|
||||
_grp selectLeader _unit; // Leader Assignment
|
||||
};
|
||||
};
|
||||
_grp selectLeader _unit; // Leader Assignment
|
||||
private ["_invLoaded"];
|
||||
_invLoaded = [units _grp, _missionName, _mode] call VEMFr_fnc_loadInv; // Load the AI's inventory
|
||||
if not _invLoaded then
|
||||
{
|
||||
["fn_spawnInvasionAI", 0, "failed to load AI's inventory..."] spawn VEMFr_fnc_log;
|
||||
};
|
||||
_groups pushBack _grp; // Push it into the _groups array
|
||||
};
|
||||
};
|
||||
|
||||
if isNil"_invLoaded" then
|
||||
{
|
||||
["fn_spawnAI", 0, "failed to load AI's inventory..."] spawn VEMFr_fnc_log;
|
||||
};
|
||||
|
||||
if (count _groups isEqualTo _grpCount) then
|
||||
{
|
||||
if _noHouses then
|
||||
{
|
||||
private ["_waypoints"];
|
||||
_waypoints =
|
||||
[
|
||||
[(_pos select 0), (_pos select 1)+50, 0],
|
||||
@ -193,10 +201,12 @@ if (count _pos isEqualTo 3) then
|
||||
{ // Make them Patrol
|
||||
for "_z" from 1 to (count _waypoints) do
|
||||
{
|
||||
private ["_wp"];
|
||||
_wp = _x addWaypoint [(_waypoints select (_z-1)), 10];
|
||||
_wp setWaypointType "SAD";
|
||||
_wp setWaypointCompletionRadius 20;
|
||||
};
|
||||
private ["_cyc"];
|
||||
_cyc = _x addWaypoint [_pos,10];
|
||||
_cyc setWaypointType "CYCLE";
|
||||
_cyc setWaypointCompletionRadius 20;
|
||||
@ -207,4 +217,5 @@ if (count _pos isEqualTo 3) then
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_spawned
|
||||
|
@ -15,27 +15,28 @@
|
||||
ARRAY with group(s)
|
||||
*/
|
||||
|
||||
private // Make sure that the vars in this function do not interfere with vars in the calling script
|
||||
[
|
||||
"_spawned","_allUnits","_pos","_grpCount","_unitsPerGrp","_sldrClass","_settings","_hc","_skills","_newPos","_return","_units","_missionName",
|
||||
"_accuracy","_aimShake","_aimSpeed","_stamina","_spotDist","_spotTime","_courage","_reloadSpd","_commanding","_general","_loadInv","_mode"
|
||||
];
|
||||
|
||||
private ["_spawned","_allUnits","_pos"];
|
||||
_spawned = [];
|
||||
_allUnits = [];
|
||||
_pos = param [0, [], [[]]];
|
||||
if (count _pos isEqualTo 3) then
|
||||
if (_pos isEqualTypeArray [0,0,0]) then
|
||||
{
|
||||
private ["_grpCount"];
|
||||
_grpCount = param [1, 1, [0]];
|
||||
if (_grpCount > 0) then
|
||||
{
|
||||
private ["_unitsPerGrp"];
|
||||
_unitsPerGrp = param [2, 1, [0]];
|
||||
if (_unitsPerGrp > 0) then
|
||||
{
|
||||
private ["_mode","_missionName"];
|
||||
_mode = param [3, -1, [0]];
|
||||
_missionName = param [4, "", [""]];
|
||||
if (_missionName in ("missionList" call VEMFr_fnc_getSetting)) then
|
||||
{
|
||||
private [
|
||||
"_sldrClass","_hc","_aiDifficulty","_skills","_accuracy","_aimShake","_aimSpeed","_stamina","_spotDist","_spotTime","_courage","_reloadSpd","_commanding","_general","_units"
|
||||
];
|
||||
_sldrClass = "unitClass" call VEMFr_fnc_getSetting;
|
||||
_hc = "headLessClientSupport" call VEMFr_fnc_getSetting;
|
||||
_aiDifficulty = [["aiSkill"],["difficulty"]] call VEMFr_fnc_getSetting param [0, "Veteran", [""]];
|
||||
@ -54,43 +55,45 @@ if (count _pos isEqualTo 3) then
|
||||
_units = []; // Define units array. the for loops below will fill it with units
|
||||
for "_g" from 1 to _grpCount do // Spawn Groups near Position
|
||||
{
|
||||
private ["_unitSide","_grp","_unit","_groupSide"];
|
||||
private ["_groupSide"];
|
||||
_groupSide = ("unitClass" call VEMFr_fnc_getSetting) call VEMFr_fnc_checkSide;
|
||||
if not isNil"_groupSide" then
|
||||
{
|
||||
private["_unit"];
|
||||
private["_grp"];
|
||||
_grp = createGroup _groupSide;
|
||||
if not isNil"_grp" then
|
||||
_grp setBehaviour "AWARE";
|
||||
_grp setCombatMode "RED";
|
||||
_grp allowFleeing 0;
|
||||
for "_u" from 1 to _unitsPerGrp do
|
||||
{
|
||||
_grp setBehaviour "AWARE";
|
||||
_grp setCombatMode "RED";
|
||||
_grp allowFleeing 0;
|
||||
for "_u" from 1 to _unitsPerGrp do
|
||||
{
|
||||
_unit = _grp createUnit [_sldrClass, _pos, [], 10, "FORM"]; // Create Unit There
|
||||
_allUnits pushBack _unit;
|
||||
_unit addMPEventHandler ["mpkilled","if (isDedicated) then { [_this select 0, _this select 1] spawn VEMFr_fnc_aiKilled }"];
|
||||
private ["_unit"];
|
||||
_unit = _grp createUnit [_sldrClass, _pos, [], 10, "FORM"]; // Create Unit There
|
||||
_allUnits pushBack _unit;
|
||||
_unit addMPEventHandler ["mpkilled","if (isDedicated) then { [_this select 0, _this select 1] spawn VEMFr_fnc_aiKilled }"];
|
||||
|
||||
// Set skills
|
||||
_unit setSkill ["aimingAccuracy", _accuracy];
|
||||
_unit setSkill ["aimingShake", _aimShake];
|
||||
_unit setSkill ["aimingSpeed", _aimSpeed];
|
||||
_unit setSkill ["endurance", _stamina];
|
||||
_unit setSkill ["spotDistance", _spotDist];
|
||||
_unit setSkill ["spotTime", _spotTime];
|
||||
_unit setSkill ["courage", _courage];
|
||||
_unit setSkill ["reloadSpeed", _reloadSpd];
|
||||
_unit setSkill ["commanding", _commanding];
|
||||
_unit setSkill ["general", _general];
|
||||
_unit setRank "Private"; // Set rank
|
||||
// Set skills
|
||||
_unit setSkill ["aimingAccuracy", _accuracy];
|
||||
_unit setSkill ["aimingShake", _aimShake];
|
||||
_unit setSkill ["aimingSpeed", _aimSpeed];
|
||||
_unit setSkill ["endurance", _stamina];
|
||||
_unit setSkill ["spotDistance", _spotDist];
|
||||
_unit setSkill ["spotTime", _spotTime];
|
||||
_unit setSkill ["courage", _courage];
|
||||
_unit setSkill ["reloadSpeed", _reloadSpd];
|
||||
_unit setSkill ["commanding", _commanding];
|
||||
_unit setSkill ["general", _general];
|
||||
_unit setRank "Private"; // Set rank
|
||||
if (_u isEqualTo _unitsPerGrp) then
|
||||
{
|
||||
_grp selectLeader _unit; // Leader Assignment
|
||||
};
|
||||
};
|
||||
_grp selectLeader _unit; // Leader Assignment
|
||||
_grp enableAttack true;
|
||||
_spawned pushBack _grp;
|
||||
};
|
||||
};
|
||||
|
||||
private ["_invLoaded"];
|
||||
_invLoaded = [_allUnits, _missionName, _mode] call VEMFr_fnc_loadInv; // Load the AI's inventory
|
||||
if not _invLoaded then
|
||||
{
|
||||
@ -101,4 +104,5 @@ if (count _pos isEqualTo 3) then
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_spawned
|
||||
|
@ -12,75 +12,82 @@
|
||||
BOOLEAN - true if transfer was successful
|
||||
*/
|
||||
|
||||
private ["_toTransfer","_hcEnabled","_hcUIDs","_hcClients","_to","_transfer"];
|
||||
private ["_transfer","_toTransfer"];
|
||||
_transfer = false;
|
||||
_toTransfer = param [0, grpNull, [grpNull]];
|
||||
if not isNull _toTransfer then
|
||||
{
|
||||
// Check if HC is enabled
|
||||
_hcEnabled = "headLessClientSupport" call VEMFr_fnc_getSetting;
|
||||
_forceClients = uiNamespace getVariable ["VEMFr_forceAItoClients", nil];
|
||||
if not(isNil"_forceClients") then
|
||||
{
|
||||
if _forceClients then
|
||||
{
|
||||
_hcEnabled = -1;
|
||||
};
|
||||
};
|
||||
if (_hcEnabled isEqualTo 1) then
|
||||
{ // Gather the Headless Client(s)
|
||||
_hcClients = [];
|
||||
{
|
||||
if (typeOf _x isEqualTo "HeadlessClient_F") then // it is an HC
|
||||
private ["_hcEnabled","_forceClients"];
|
||||
// Check if HC is enabled
|
||||
_hcEnabled = "headLessClientSupport" call VEMFr_fnc_getSetting;
|
||||
_forceClients = uiNamespace getVariable ["VEMFr_forceAItoClients", nil];
|
||||
if not(isNil"_forceClients") then
|
||||
{
|
||||
if _forceClients then
|
||||
{
|
||||
_hcEnabled = -1;
|
||||
};
|
||||
};
|
||||
|
||||
private ["_to"];
|
||||
if (_hcEnabled isEqualTo 1) then
|
||||
{ // Gather the Headless Client(s)
|
||||
private ["_hcClients"];
|
||||
_hcClients = [];
|
||||
{
|
||||
if (typeOf _x isEqualTo "HeadlessClient_F") then // it is an HC
|
||||
{
|
||||
_hcClients pushBack [_x, owner _x];
|
||||
};
|
||||
} forEach allPlayers;
|
||||
if (count _hcClients > 0) then
|
||||
{
|
||||
_to = call VEMFr_fnc_headLessClient; // Select a random hc
|
||||
};
|
||||
if (count _hcClients isEqualTo 0) then
|
||||
{
|
||||
uiNamespace setVariable ["VEMFr_forceAItoClients", true];
|
||||
};
|
||||
};
|
||||
if (_hcEnabled isEqualTo 0) then
|
||||
{
|
||||
if ([1] call VEMFr_fnc_playerCount) then
|
||||
{
|
||||
_closest = [0,0,0];
|
||||
};
|
||||
} forEach allPlayers;
|
||||
if (count _hcClients > 0) then
|
||||
{
|
||||
_to = call VEMFr_fnc_headLessClient; // Select a random hc
|
||||
};
|
||||
if (count _hcClients isEqualTo 0) then
|
||||
{
|
||||
uiNamespace setVariable ["VEMFr_forceAItoClients", true];
|
||||
};
|
||||
} else // If Headlessclient setting is not enabled
|
||||
{
|
||||
if ([1] call VEMFr_fnc_playerCount) then
|
||||
{
|
||||
private ["_closest"];
|
||||
_closest = [0,0,0];
|
||||
{
|
||||
if (isPlayer _x) then
|
||||
{
|
||||
if (isPlayer _x) then
|
||||
{
|
||||
_leaderPos = position (leader _toTransfer);
|
||||
_dist = _leaderPos distance (position _x);
|
||||
if (_dist < (_leaderPos distance _closest)) then
|
||||
{ // Find the closest player
|
||||
_closest = position _x;
|
||||
_to = _x;
|
||||
};
|
||||
};
|
||||
} forEach allPlayers;
|
||||
};
|
||||
};
|
||||
if not isNil"_to" then
|
||||
{
|
||||
_transfer = _toTransfer setGroupOwner (owner _to);
|
||||
_load = uiNamespace getVariable ["VEMFrHcLoad", nil];
|
||||
if not isNil"_load" then
|
||||
{
|
||||
_index = _load find _to;
|
||||
if (_index > -1) then
|
||||
{
|
||||
_load set [_index, ((_load select _index) select 1) + 1];
|
||||
private ["_leaderPos","_dist"];
|
||||
_leaderPos = position (leader _toTransfer);
|
||||
_dist = _leaderPos distance (position _x);
|
||||
if (_dist < (_leaderPos distance _closest)) then
|
||||
{ // Find the closest player
|
||||
private ["_closest"];
|
||||
_closest = position _x;
|
||||
_to = _x;
|
||||
};
|
||||
};
|
||||
if (_index isEqualTo -1) then
|
||||
{
|
||||
_load pushBack [_to, 1];
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach allPlayers;
|
||||
};
|
||||
};
|
||||
|
||||
if not isNil"_to" then
|
||||
{
|
||||
_transfer = _toTransfer setGroupOwner (owner _to);
|
||||
_load = uiNamespace getVariable ["VEMFrHcLoad", nil];
|
||||
if not isNil"_load" then
|
||||
{
|
||||
_index = _load find _to;
|
||||
if (_index > -1) then
|
||||
{
|
||||
_load set [_index, ((_load select _index) select 1) + 1];
|
||||
};
|
||||
if (_index isEqualTo -1) then
|
||||
{
|
||||
_load pushBack [_to, 1];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_transfer // Return the value of this var to the calling script
|
||||
|
@ -14,14 +14,16 @@
|
||||
BOOL - true when mission is done
|
||||
*/
|
||||
|
||||
private ["_pos","_unitArr","_unitCount","_killed","_killToComplete","_rad","_playerNear","_complete"];
|
||||
private ["_complete","_pos"];
|
||||
_complete = false;
|
||||
_pos = param [1, [], [[]]];
|
||||
if (count _pos isEqualTo 3) then
|
||||
{
|
||||
private ["_unitArr"];
|
||||
_unitArr = param [2, [], [[]]];
|
||||
if (count _unitArr > 0) then
|
||||
{
|
||||
private ["_unitCount","_killed","_killToComplete","_rad"];
|
||||
_unitCount = count _unitArr;
|
||||
_killed = [];
|
||||
_killToComplete = round(("killPercentage" call VEMFr_fnc_getSetting)/100*_unitCount);
|
||||
@ -30,10 +32,11 @@ if (count _pos isEqualTo 3) then
|
||||
{
|
||||
while {not _complete} do
|
||||
{
|
||||
private ["_playerNear"];
|
||||
// First check for a player
|
||||
if not _complete then { uiSleep 1; };
|
||||
_playerNear = [_pos, _rad] call VEMFr_fnc_checkPlayerPresence;
|
||||
if (_playerNear) then
|
||||
if _playerNear then
|
||||
{
|
||||
{
|
||||
if not(alive _x) then
|
||||
@ -42,6 +45,7 @@ if (count _pos isEqualTo 3) then
|
||||
};
|
||||
} forEach _unitArr;
|
||||
{ // Delete the not(alive) units
|
||||
private ["_index"];
|
||||
_index = _unitArr find _x;
|
||||
if not(_index isEqualTo -1) then
|
||||
{
|
||||
@ -57,4 +61,5 @@ if (count _pos isEqualTo 3) then
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_complete
|
||||
|
@ -12,14 +12,16 @@
|
||||
BOOL - true if there is a player present
|
||||
*/
|
||||
|
||||
private ["_playerNear","_pos","_rad","_time","_timeOutTime","_pp"];
|
||||
private ["_playerNear","_pos"];
|
||||
_playerNear = false;
|
||||
_pos = param [0, [], [[]]];
|
||||
if (count _pos isEqualTo 3) then
|
||||
{
|
||||
private ["_rad"];
|
||||
_rad = param [1, -1, [0]];
|
||||
if (_rad > -1) then
|
||||
{
|
||||
private ["_time","_timeOutTime","_pp"];
|
||||
_time = round time;
|
||||
// Define _settings
|
||||
_timeOutTime = ("timeOutTime" call VEMFr_fnc_getSetting)*60;
|
||||
@ -28,8 +30,7 @@ if (count _pos isEqualTo 3) then
|
||||
if _pp then
|
||||
{
|
||||
_playerNear = true;
|
||||
};
|
||||
if not _pp then
|
||||
} else
|
||||
{
|
||||
waitUntil { uiSleep 2; (([_pos, _rad] call VEMFr_fnc_checkPlayerPresence) OR (round time - _time > _timeOutTime)) };
|
||||
if ([_pos, _rad] call VEMFr_fnc_checkPlayerPresence) then
|
||||
|
@ -1,18 +1,15 @@
|
||||
/*
|
||||
DynamicLocationInvasion by Vampire, rewritten by IT07
|
||||
DynamicLocationInvasion by IT07
|
||||
*/
|
||||
|
||||
if isNil"VEMFrInvasionCount" then
|
||||
{
|
||||
VEMFrInvasionCount = 0;
|
||||
};
|
||||
|
||||
if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call VEMFr_fnc_getSetting) select 0)) then
|
||||
if isNil"VEMFrInvasionCount" then { VEMFrInvasionCount = 0; };
|
||||
_missionName = param [0, "", [""]];
|
||||
if (VEMFrInvasionCount < (([[_missionName],["maxInvasions"]] call VEMFr_fnc_getSetting) select 0)) then
|
||||
{
|
||||
VEMFrInvasionCount = VEMFrInvasionCount + 1;
|
||||
private ["_settings","_grpCount","_groupUnits","_skipDistance","_loc","_hasPlayers","_spawned","_grpArr","_unitArr","_done","_boxes","_box","_chute","_colors","_lightType","_light","_smoke"];
|
||||
// Define _settings
|
||||
_settings = [["DynamicLocationInvasion"],["groupCount","groupUnits","maxDistance","maxDistancePrefered","skipDistance","marker","parachuteCrate","markCrateVisual","markCrateOnMap","announce","streetLights","streetLightsRestore","streetLightsRange","allowCrateLift"]] call VEMFr_fnc_getSetting;
|
||||
_settings = [[_missionName],["groupCount","groupUnits","maxDistance","maxDistancePrefered","skipDistance","marker","parachuteCrate","markCrateVisual","markCrateOnMap","announce","streetLights","streetLightsRestore","streetLightsRange","allowCrateLift"]] call VEMFr_fnc_getSetting;
|
||||
_grpCount = _settings select 0;
|
||||
_groupUnits = _settings select 1;
|
||||
_range = _settings select 2;
|
||||
@ -29,18 +26,18 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
_streetLightsRange = _settings select 12;
|
||||
_allowCrateLift = _settings select 13;
|
||||
|
||||
_loc = ["loc", false, position (selectRandom allPlayers), _skipDistance, _maxPref, _skipDistance, "DynamicLocationInvasion"] call VEMFr_fnc_findPos;
|
||||
_loc = ["loc", false, position (selectRandom allPlayers), _skipDistance, _maxPref, _skipDistance, _missionName] call VEMFr_fnc_findPos;
|
||||
if (_loc isEqualTypeArray ["",[]]) then
|
||||
{
|
||||
_locName = _loc select 0;
|
||||
_locPos = _loc select 1;
|
||||
if (_locName isEqualTo "") then { _locName = "Area"; };
|
||||
["DynamicLocationInvasion", 1, format["Invading %1...", _locName]] spawn VEMFr_fnc_log;
|
||||
[_missionName, 1, format["Invading %1...", _locName]] spawn VEMFr_fnc_log;
|
||||
VEMFrInvasionCount = VEMFrInvasionCount + 1;
|
||||
// Send message to all players
|
||||
private ["_mode"];
|
||||
_mode = "aiMode" call VEMFr_fnc_getSetting;
|
||||
_randomModes = ([["DynamicLocationInvasion"],["randomModes"]] call VEMFr_fnc_getSetting) select 0;
|
||||
_randomModes = ([[_missionName],["randomModes"]] call VEMFr_fnc_getSetting) select 0;
|
||||
if (_randomModes isEqualTo 1) then
|
||||
{
|
||||
_mode = selectRandom [0,1,2];
|
||||
@ -100,9 +97,8 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
// Usage: POSITION, Radius
|
||||
_playerNear = [_locPos, 800] call VEMFr_fnc_waitForPlayers;
|
||||
if _playerNear then
|
||||
{
|
||||
// Player is Near, so Spawn the Units
|
||||
_spawned = [_locPos, ((_grpCount select 0) + round random ((_grpCount select 1) - (_grpCount select 0))), ((_groupUnits select 0) + round random ((_groupUnits select 1) - (_groupUnits select 0))), _mode, "DynamicLocationInvasion"] call VEMFr_fnc_spawnInvasionAI;
|
||||
{ // Player is Near, so Spawn the Units
|
||||
_spawned = [_locPos, ((_grpCount select 0) + round random ((_grpCount select 1) - (_grpCount select 0))), ((_groupUnits select 0) + round random ((_groupUnits select 1) - (_groupUnits select 0))), _mode, _missionName, 200] call VEMFr_fnc_spawnInvasionAI;
|
||||
if (_spawned isEqualType []) then
|
||||
{
|
||||
if (_spawned isEqualTypeArray [[],[]]) then
|
||||
@ -119,50 +115,80 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
_cal50s = _spawned select 1;
|
||||
|
||||
private ["_heliUnits"];
|
||||
_heliPatrolSettings = ([["DynamicLocationInvasion"],["heliPatrol"]] call VEMFr_fnc_getSetting) select 0;
|
||||
_heliPatrolSettings = ([[_missionName],["heliPatrol"]] call VEMFr_fnc_getSetting) select 0;
|
||||
if (_heliPatrolSettings select 0 isEqualTo 1) then
|
||||
{ // If heliPatrol setting is enabled
|
||||
["DynamicLocationInvasion", 1, format["Adding a heli patrol to the invasion of %1 at %2", _locName, mapGridPosition _locPos]] spawn VEMFr_fnc_log;
|
||||
_heli = createVehicle [selectRandom (_heliPatrolSettings select 1), _locPos, [], 50, "FLY"];
|
||||
_heli engineOn true; // Just to make sure
|
||||
_spawnHeliGroup = [_locPos, 1, (((count allTurrets _heli) + (_heli emptyPositions "cargo") + (_heli emptyPositions "commander")) + 1), _mode, "DynamicLocationInvasion"] call VEMFr_fnc_spawnVEMFrAI;
|
||||
if (_spawnHeliGroup isEqualType []) then
|
||||
[_missionName, 1, format["Adding a heli patrol to the invasion of %1 at %2", _locName, mapGridPosition _locPos]] spawn VEMFr_fnc_log;
|
||||
_classToSpawn = selectRandom (_heliPatrolSettings select 1);
|
||||
if (_classToSpawn isKindOf "Air") then
|
||||
{
|
||||
_heliGroup = _spawnHeliGroup select 0;
|
||||
_heliUnits = units _heliGroup;
|
||||
_heli = createVehicle [_classToSpawn, _locPos, [], 50, "FLY"];
|
||||
_heli engineOn true; // Just to make sure
|
||||
_turrets = allTurrets [_heli, false];
|
||||
_spawnHeliGroup = [_locPos, 1, ((count _turrets) + (_heli emptyPositions "commander") + 1), _mode, _missionName] call VEMFr_fnc_spawnVEMFrAI;
|
||||
if (_spawnHeliGroup isEqualType []) then
|
||||
{
|
||||
_x moveInAny _heli;
|
||||
removeBackpack _x;
|
||||
_x addBackpack "B_Parachute";
|
||||
_units pushBack _x;
|
||||
} forEach _heliUnits;
|
||||
_heliGroup = _spawnHeliGroup select 0;
|
||||
_heliUnits = units _heliGroup;
|
||||
{
|
||||
if (_heli emptyPositions "driver" isEqualTo 1) then
|
||||
{
|
||||
_x moveInDriver _heli;
|
||||
} else
|
||||
{
|
||||
private ["_path"];
|
||||
{
|
||||
_unitInTurret = _heli turretUnit _x;
|
||||
if (isNull _unitInTurret) then
|
||||
{
|
||||
_path = _x;
|
||||
};
|
||||
} forEach _turrets;
|
||||
if not isNil"_path" then
|
||||
{
|
||||
_x moveInTurret [_heli, _path];
|
||||
} else
|
||||
{
|
||||
if (_heli emptyPositions "commander" > 0) then
|
||||
{
|
||||
_x moveInCommander _heli;
|
||||
};
|
||||
};
|
||||
};
|
||||
removeBackpack _x;
|
||||
_x addBackpack "B_Parachute";
|
||||
_units pushBack _x;
|
||||
} forEach _heliUnits;
|
||||
|
||||
_loiterWaypoint = _heliGroup addWaypoint [_locPos, 50, 1];
|
||||
_loiterWaypoint setWaypointType "LOITER";
|
||||
_loiterWaypoint setWaypointSpeed "LIMITED";
|
||||
_loiterWaypoint setWaypointCombatMode "RED";
|
||||
_loiterWaypoint setWaypointBehaviour "AWARE";
|
||||
_loiterWaypoint setWaypointLoiterType "CIRCLE_L";
|
||||
_loiterWaypoint setWaypointLoiterRadius 25;
|
||||
_heliGroup setCurrentWaypoint _loiterWaypoint;
|
||||
_loiterWaypoint = _heliGroup addWaypoint [_locPos, 50, 1];
|
||||
_loiterWaypoint setWaypointType "LOITER";
|
||||
_loiterWaypoint setWaypointSpeed "LIMITED";
|
||||
_loiterWaypoint setWaypointCombatMode "RED";
|
||||
_loiterWaypoint setWaypointBehaviour "AWARE";
|
||||
_loiterWaypoint setWaypointLoiterType "CIRCLE_L";
|
||||
_loiterWaypoint setWaypointLoiterRadius 25;
|
||||
_heliGroup setCurrentWaypoint _loiterWaypoint;
|
||||
|
||||
[_heliGroup] spawn VEMFr_fnc_signAI;
|
||||
[_heliGroup] spawn VEMFr_fnc_signAI;
|
||||
};
|
||||
} else { // If the select classname is not an air vehicle
|
||||
[_missionName, 0, format["%1 IS NOT AN AIR VEHICLE", _classToSpawn]] spawn VEMFr_fnc_log;
|
||||
};
|
||||
};
|
||||
|
||||
// Place mines if enabled
|
||||
private ["_minesPlaced","_mines"];
|
||||
_mines = [["DynamicLocationInvasion"],["mines"]] call VEMFr_fnc_getSetting param [0, 0, [0]];
|
||||
_mines = [[_missionName],["mines"]] call VEMFr_fnc_getSetting param [0, 0, [0]];
|
||||
if (_mines > 0) then
|
||||
{
|
||||
_minesPlaced = [_locPos, 5, 100] call VEMFr_fnc_placeMines param [0, [], [[]]];
|
||||
_minesPlaced = [_locPos, 5, 100, _missionName] call VEMFr_fnc_placeMines param [0, [], [[]]];
|
||||
if (count _minesPlaced > 0) then
|
||||
{
|
||||
["DynamicLocationInvasion", 1, format["Successfully placed mines at %1", _locName]] spawn VEMFr_fnc_log;
|
||||
[_missionName, 1, format["Successfully placed mines at %1", _locName]] spawn VEMFr_fnc_log;
|
||||
};
|
||||
if (count _minesPlaced isEqualto 0) then
|
||||
{
|
||||
["DynamicLocationInvasion", 0, format["Failed to place mines at %1", _locName]] spawn VEMFr_fnc_log;
|
||||
[_missionName, 0, format["Failed to place mines at %1", _locName]] spawn VEMFr_fnc_log;
|
||||
_minesPlaced = nil;
|
||||
};
|
||||
};
|
||||
@ -197,7 +223,7 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
if not isNil"_cal50s" then
|
||||
{
|
||||
private["_cal50sDelete"];
|
||||
_cal50sDelete = ([["DynamicLocationInvasion"],["cal50sDelete"]] call VEMFr_fnc_getSetting) select 0;
|
||||
_cal50sDelete = ([[_missionName],["cal50sDelete"]] call VEMFr_fnc_getSetting) select 0;
|
||||
if (_cal50sDelete > 0) then
|
||||
{
|
||||
{
|
||||
@ -213,9 +239,9 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
};
|
||||
};
|
||||
// Choose a box
|
||||
_boxes = [["DynamicLocationInvasion"],["crateTypes"]] call VEMFr_fnc_getSetting;
|
||||
_box = (_boxes select 0) call BIS_fnc_selectRandom;
|
||||
_pos = [_locPos, 0, 100, 0, 0, 300, 0] call bis_fnc_findSafePos;
|
||||
_boxes = [[_missionName],["crateTypes"]] call VEMFr_fnc_getSetting;
|
||||
_box = selectRandom (_boxes select 0);
|
||||
_pos = [_locPos, 0, 200, 0, 0, 300, 0] call bis_fnc_findSafePos;
|
||||
private ["_crate"];
|
||||
if (_useChute isEqualTo 1) then
|
||||
{
|
||||
@ -233,9 +259,9 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
{
|
||||
_crate enableRopeAttach false;
|
||||
};
|
||||
["DynamicLocationInvasion", 1, format ["Crate parachuted at: %1 / Grid: %2", (getPosATL _crate), mapGridPosition (getPosATL _crate)]] spawn VEMFr_fnc_log;
|
||||
[_missionName, 1, format ["Crate parachuted at: %1 / Grid: %2", (getPosATL _crate), mapGridPosition (getPosATL _crate)]] spawn VEMFr_fnc_log;
|
||||
_lootLoaded = [_crate] call VEMFr_fnc_loadLoot;
|
||||
if _lootLoaded then { ["DynamicLocationInvasion", 1, "Loot loaded successfully into parachuting crate"] spawn VEMFr_fnc_log };
|
||||
if _lootLoaded then { [_missionName, 1, "Loot loaded successfully into parachuting crate"] spawn VEMFr_fnc_log };
|
||||
};
|
||||
};
|
||||
if (_useChute isEqualTo 0) then
|
||||
@ -247,7 +273,7 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
_crate enableRopeAttach false;
|
||||
};
|
||||
_lootLoaded = [_crate] call VEMFr_fnc_loadLoot;
|
||||
if _lootLoaded then { ["DynamicLocationInvasion", 1, "Loot loaded successfully into crate"] spawn VEMFr_fnc_log };
|
||||
if _lootLoaded then { [_missionName, 1, format["Loot loaded successfully into crate at %1", _locName]] spawn VEMFr_fnc_log };
|
||||
};
|
||||
if (_markCrateVisual isEqualTo 1) then
|
||||
{
|
||||
@ -255,7 +281,7 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
// If night, attach a chemlight
|
||||
if (dayTime < 5 OR dayTime > 19) then
|
||||
{
|
||||
_colors = [["DynamicLocationInvasion"],["flairTypes"]] call VEMFr_fnc_getSetting param [0, [], [[]]];
|
||||
_colors = [[_missionName],["flairTypes"]] call VEMFr_fnc_getSetting param [0, [], [[]]];
|
||||
if (count _colors > 0) then
|
||||
{
|
||||
_lightType = selectRandom _colors;
|
||||
@ -264,7 +290,7 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
};
|
||||
};
|
||||
// Attach smoke
|
||||
_colors = [["DynamicLocationInvasion"],["smokeTypes"]] call VEMFr_fnc_getSetting param [0, [], [[]]];
|
||||
_colors = [[_missionName],["smokeTypes"]] call VEMFr_fnc_getSetting param [0, [], [[]]];
|
||||
if (count _colors > 0) then
|
||||
{
|
||||
_rndmColor = selectRandom _colors;
|
||||
@ -291,7 +317,7 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
{
|
||||
if not ([getPos _crate, 2] call VEMFr_fnc_checkPlayerPresence) then
|
||||
{
|
||||
_addMarker = [["DynamicLocationInvasion"],["markCrateOnMap"]] call VEMFr_fnc_getSetting param [0, 1, [0]];
|
||||
_addMarker = [[_missionName],["markCrateOnMap"]] call VEMFr_fnc_getSetting param [0, 1, [0]];
|
||||
if (_addMarker isEqualTo 1) then
|
||||
{
|
||||
private ["_crateMarker"];
|
||||
@ -314,14 +340,14 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
|
||||
if isNil "_crate" then
|
||||
{
|
||||
["DynamicLocationInvasion", 0, "ERROR! _crate not found"] spawn VEMFr_fnc_log;
|
||||
[_missionName, 0, "ERROR! _crate not found"] spawn VEMFr_fnc_log;
|
||||
};
|
||||
|
||||
// Explode or remove the mines
|
||||
if not isNil"_minesPlaced" then
|
||||
{
|
||||
private ["_cleanMines"];
|
||||
_cleanMines = [["DynamicLocationInvasion"],["minesCleanup"]] call VEMFr_fnc_getSetting param [0, 1, [0]];
|
||||
_cleanMines = [[_missionName],["minesCleanup"]] call VEMFr_fnc_getSetting param [0, 1, [0]];
|
||||
if (_cleanMines isEqualTo 2) then
|
||||
{
|
||||
{
|
||||
@ -331,7 +357,7 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
uiSleep (2 + round random 2);
|
||||
};
|
||||
} forEach _minesPlaced;
|
||||
["DynamicLocationInvasion", 1, format["Successfully exploded all %1 mines at %2", count _minesPlaced, _locName]] spawn VEMFr_fnc_log;
|
||||
[_missionName, 1, format["Successfully exploded all %1 mines at %2", count _minesPlaced, _locName]] spawn VEMFr_fnc_log;
|
||||
_minesPlaced = nil;
|
||||
};
|
||||
if (_cleanMines isEqualTo 1) then
|
||||
@ -342,7 +368,7 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
deleteVehicle _x;
|
||||
};
|
||||
} forEach _minesPlaced;
|
||||
["DynamicLocationInvasion", 1, format["Successfully deleted all %1 mines at %2", count _minesPlaced, _locName]] spawn VEMFr_fnc_log;
|
||||
[_missionName, 1, format["Successfully deleted all %1 mines at %2", count _minesPlaced, _locName]] spawn VEMFr_fnc_log;
|
||||
_minesPlaced = nil;
|
||||
};
|
||||
};
|
||||
@ -362,17 +388,15 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
if not(_spawned isEqualType []) exitWith
|
||||
} else
|
||||
{
|
||||
VEMFrInvasionCount = VEMFrInvasionCount - 1;
|
||||
VEMFrMissionCount = VEMFrMissionCount - 1;
|
||||
[[format["Failed to spawn AI in %1 @ %2", _locName, mapGridPosition (_locPos)], "ERROR!"], ""] spawn VEMFr_fnc_broadCast;
|
||||
};
|
||||
};
|
||||
if not _playerNear then
|
||||
{
|
||||
["DynamicLocationInvasion", 1, format["Invasion of %1 timed out.", _locName]] spawn VEMFr_fnc_log;
|
||||
} else
|
||||
{ // If done waiting, and no players were detected
|
||||
[_missionName, 1, format["Invasion of %1 @ %2 timed out.", _locName, mapGridPosition _locPos]] spawn VEMFr_fnc_log;
|
||||
if not isNil"_marker" then
|
||||
{
|
||||
deleteMarker _marker
|
||||
@ -386,8 +410,7 @@ if (VEMFrInvasionCount < (([["DynamicLocationInvasion"],["maxInvasions"]] call V
|
||||
VEMFrInvasionCount = VEMFrInvasionCount - 1;
|
||||
VEMFrMissionCount = VEMFrMissionCount - 1;
|
||||
};
|
||||
};
|
||||
if not(_loc isEqualType []) then
|
||||
} else
|
||||
{
|
||||
VEMFrInvasionCount = VEMFrInvasionCount - 1;
|
||||
VEMFrMissionCount = VEMFrMissionCount - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user