diff --git a/exile_vemf_reloaded/fn/fn_checkSide.sqf b/exile_vemf_reloaded/fn/fn_checkSide.sqf index 917ca48..64c5743 100644 --- a/exile_vemf_reloaded/fn/fn_checkSide.sqf +++ b/exile_vemf_reloaded/fn/fn_checkSide.sqf @@ -9,44 +9,41 @@ Returns: SIDE - unit's side */ -private ["_r"]; -if (_this isEqualType "") then +private ["_r","_f"]; +_f = getText (configFile >> "CfgVehicles" >> _this >> "faction"); +if not(_f isEqualTo "") then { - private ["_f"]; - _f = getText (configFile >> "CfgVehicles" >> _this >> "faction"); - if not(_f isEqualTo "") then + scopeName "isNull"; + if (_f isEqualTo "BLU_G_F") then { - scopeName "isNull"; - if (_f isEqualTo "BLU_G_F") then - { - _r = WEST; - breakOut "isNull"; - }; - if (_f isEqualTo "CIV_F") then - { - _r = civilian; - breakOut "isNull"; - }; - if (_f isEqualTo "IND_F") then - { - _r = independent; - breakOut "isNull"; - }; - if (_f isEqualTo "IND_G_F") then - { - _r = resistance; - breakOut "isNull"; - }; - if (_f isEqualTo "OPF_G_F") then - { - _r = EAST; - }; - } else - { - ["fn_checkSide", 0, format["Failed to find faction of %1", _this]] ExecVM "exile_vemf_reloaded\sqf\log.sqf"; + _r = WEST; + breakOut "isNull"; }; - if not(isNil "_r") then - { - _r - }; + if (_f isEqualTo "CIV_F") then + { + _r = civilian; + breakOut "isNull"; + }; + if (_f isEqualTo "IND_F") then + { + _r = independent; + breakOut "isNull"; + }; + if (_f isEqualTo "IND_G_F") then + { + _r = resistance; + breakOut "isNull"; + }; + if (_f isEqualTo "OPF_G_F") then + { + _r = EAST; + }; + } else + { + ["fn_checkSide", 0, format["Failed to find faction of %1", _this]] ExecVM "exile_vemf_reloaded\sqf\log.sqf"; + }; + +if not(isNil "_r") then + { + _r }; diff --git a/exile_vemf_reloaded/fn/fn_findPos.sqf b/exile_vemf_reloaded/fn/fn_findPos.sqf index 79d8760..4e0d08b 100644 --- a/exile_vemf_reloaded/fn/fn_findPos.sqf +++ b/exile_vemf_reloaded/fn/fn_findPos.sqf @@ -8,7 +8,7 @@ _this select 0: STRING - Mode to use. Options: "loc" or "pos" _this select 1: BOOLEAN - True if _pos needs to be a road _this select 2: POSITION - Center for nearestLocations check - _this select 3: SCALAR - Distance in meters. Locations closer than that will be excluded + _this select 3: SCALAR - Distance in meters. Locations closer than given position will be excluded/included _this select 4: SCALAR - Max prefered distance in meters from center. If not achievable, further dest will be selected _this select 5: SCALAR - Distance in meters to check from _this2 for players _this select 6: STRING (optional) - Exact config name of mission override settings to load @@ -21,8 +21,9 @@ private [ "_r","_this0","_this1","_this2","_this3","_this4","_this5","_this6", "_s0","_s1","_s2","_s3", - "_rad","_arr","_bin","_used","_badNames","_maps","_bad", - "_locPos","_xx","_pos","_hi","_low","_dist","_loc" + "_ms0", + "_rad","_arr","_bin","_used","_fltr","_badNames","_maps","_bad", + "_pos","_xx","_pos","_hi","_low","_dist","_loc" ]; params [ @@ -36,6 +37,7 @@ params [ ]; ([["nonPopulated","noMissionPos","missionDistance","missionList"]] call VEMFr_fnc_config) params ["_s0","_s1","_s2","_s3"]; +([[_this6],["skipDistanceReversed"]] call VEMFr_fnc_config) params ["_ms0"]; if (_this6 in _s3) then { @@ -46,7 +48,7 @@ _rad = 5000; if (_this0 isEqualTo "loc") then { // Get a list of locations close to _this2 (position of player) - _arr = nearestLocations [_this2, ["CityCenter","Strategic","StrongpointArea","NameVillage","NameCity","NameCityCapital",if (_s0 isEqualTo 1) then {"nameLocal","Area","BorderCrossing","Hill","fakeTown","Name","RockArea","ViewPoint"}], worldSize]; + _arr = nearestLocations [_this2, ["CityCenter","Strategic","StrongpointArea","NameVillage","NameCity","NameCityCapital",if (_s0 isEqualTo 1) then {"nameLocal","Area","BorderCrossing","Hill","fakeTown","Name","RockArea","ViewPoint"}], if (_ms0 > 0) then {_ms0*2} else {worldSize}]; if ((count _arr) > 0) then { _maps = "isClass _x" configClasses (configFile >> "CfgVemfReloaded" >> "locationBlackLists"); @@ -64,57 +66,35 @@ if (_this0 isEqualTo "loc") then _bin = []; _used = uiNamespace getVariable ["VEMFrUsedLocs",[]]; - { // Check _arr for invalid locations (too close, hasPlayers or inBlacklist) - if ([locationPosition _x, _this5] call VEMFr_fnc_playerNear) then + + _fltr = + { + scopeName "filter"; + _xx = _x; { - _bin pushBack _x; + if (((_x select 0) distance (locationPosition _xx)) <= (_x select 1)) then { _bin pushBack _xx; breakOut "filter" }; + } forEach _s1; + + if (_x in _used) then { _bin pushBack _x } + else + { + { + if (((locationPosition _xx) distance (locationPosition _x)) < _s2) then { _bin pushBack _xx; breakOut "filter" }; + } forEach _used; + }; + + if ((text _x) in _bad) then { _bin pushBack _x }; + }; + { + _dist = _this2 distance (locationPosition _x); + if (_ms0 > 0) then + { + if ((_dist <= (_ms0*2)) AND (_dist > _ms0)) then { call _fltr } + else { _bin pushBack _x }; } else { - if ((count _s1) > 0) then - { - _locPos = locationPosition _x; - _xx = _x; - { - if ((count _x) isEqualTo 2) then - { - if (((_x select 0) distance _locPos) <= (_x select 1)) then - { - _bin pushBack _xx; - }; - } else - { - ["fn_findPos", 0, format["found invalid entry in mission blacklist: %1", _x]] ExecVM "exile_vemf_reloaded\sqf\log.sqf"; - }; - } forEach _s1; - }; - - if ((text _x) in _bad) then - { - _bin pushBack _x; - } else - { - if (_this2 distance (locationPosition _x) < _this3) then - { - _bin pushBack _x; - } else - { - if (_x in _used) then - { - _bin pushBack _x; - }; - }; - }; - - if ((count _used) > 0) then - { - _xx = _x; - { - if (((locationPosition _xx) distance (locationPosition _x)) < _s2) then - { - _bin pushBack _xx; - }; - } forEach _used; - }; + if (_dist > _this3) then { call _fltr } + else { _bin pushBack _x }; }; } forEach _arr; @@ -162,4 +142,4 @@ if (_this0 isEqualTo "pos") then }; }; -_r +if not(isNil "_r") then { _r }; diff --git a/exile_vemf_reloaded/fn/fn_giveAmmo.sqf b/exile_vemf_reloaded/fn/fn_giveAmmo.sqf index c4162cc..995baa8 100644 --- a/exile_vemf_reloaded/fn/fn_giveAmmo.sqf +++ b/exile_vemf_reloaded/fn/fn_giveAmmo.sqf @@ -15,7 +15,7 @@ BOOLEAN - true if successful */ -private ["_r","_this0"]; +private ["_r","_this0","_m"]; params [ ["_this0", objNull, [objNull]], ["_this1", "", [""]], @@ -26,7 +26,6 @@ params [ _r = []; if not(_this1 isEqualTo "") then { - private ["_m"]; _m = selectRandom (getArray (configFile >> "CfgWeapons" >> _this1 >> "magazines")); for "_l" from 1 to 5 do { @@ -40,7 +39,6 @@ if not(_this2 isEqualTo "") then { if not((backPack _this0) isEqualTo "") then { - private ["_m"]; _m = selectRandom (getArray (configFile >> "CfgWeapons" >> _this2 >> "magazines")); for "_l" from 1 to 3 do { @@ -53,7 +51,6 @@ if not(_this2 isEqualTo "") then if not(_this3 isEqualTo "") then { - private ["_m"]; _m = selectRandom (getArray (configFile >> "CfgWeapons" >> _this3 >> "magazines")); for "_l" from 1 to 4 do { diff --git a/exile_vemf_reloaded/fn/fn_loadInv.sqf b/exile_vemf_reloaded/fn/fn_loadInv.sqf index 8594caf..d0d4e6d 100644 --- a/exile_vemf_reloaded/fn/fn_loadInv.sqf +++ b/exile_vemf_reloaded/fn/fn_loadInv.sqf @@ -26,7 +26,7 @@ if ((_this1 in ("missionList" call VEMFr_fnc_config)) OR (_this1 isEqualTo "Stat scopeName "this"; if (_this2 isEqualTo 0) then // "Militia" { - private ["_s","_unifs","_headG","_vests","_packs","_lnchers","_rfles","_pstls","_ls"]; + private ["_s","_unifs","_headG","_vests","_packs","_lnchers","_rfles","_pstls","_ls","_lc","_a"]; // Define settings _s = [["aiGear"],["aiUniforms","aiHeadGear","aiVests","aiBackpacks","aiLaunchers","aiRifles","aiPistols"]] call VEMFr_fnc_config; _s params ["_unifs","_headG","_vests","_packs","_lnchers","_rfles","_pstls"]; @@ -61,7 +61,6 @@ if ((_this1 in ("missionList" call VEMFr_fnc_config)) OR (_this1 isEqualTo "Stat _ls = [[_this1],["allowLaunchers","hasLauncherChance"]] call VEMFr_fnc_config; if ((_ls select 0) isEqualTo 1) then { - private ["_lc"]; _lc = _ls select 1; if ((_lc isEqualTo 100) OR ((ceil random (100 / _lc) isEqualTo (ceil random (100 / _lc))))) then { @@ -71,7 +70,6 @@ if ((_this1 in ("missionList" call VEMFr_fnc_config)) OR (_this1 isEqualTo "Stat _xx addBackpack _g; }; _g = selectRandom _lnchers; - private ["_a"]; _a = getArray (configFile >> "cfgWeapons" >> _g >> "magazines"); if (count _a > 2) then { diff --git a/exile_vemf_reloaded/fn/fn_mines.sqf b/exile_vemf_reloaded/fn/fn_mines.sqf index fba5724..049c54f 100644 --- a/exile_vemf_reloaded/fn/fn_mines.sqf +++ b/exile_vemf_reloaded/fn/fn_mines.sqf @@ -15,7 +15,7 @@ */ scopeName "mines"; -private ["_r","_this0","_this1","_this2","_this3","_s","_ms","_a"]; +private ["_r","_this0","_this1","_this2","_this3","_s","_ms","_a","_mt"]; params [ ["_this0",[],[[]]], ["_this1",-1,[0]], @@ -27,7 +27,6 @@ _s = [[_this3],["mines","minesAmount"]] call VEMFr_fnc_config; _s params ["_ms","_a"]; if ((_this3 in ("missionList" call VEMFr_fnc_config)) AND (_ms > 0) AND ((count _this0) isEqualTo 3) AND (_this1 > -1) AND (_this2 > _this1) AND (_a > -1)) then { - private ["_mt"]; if (_ms isEqualTo 1) then { _mt = ["ATMine"] }; if (_ms isEqualTo 2) then { _mt = ["APERSMine"] }; if (_ms isEqualTo 3) then { _mt = ["ATMine","APERSMine"] }; diff --git a/exile_vemf_reloaded/fn/fn_spawnVEMFrAI.sqf b/exile_vemf_reloaded/fn/fn_spawnVEMFrAI.sqf index 56872d4..4bfd1f6 100644 --- a/exile_vemf_reloaded/fn/fn_spawnVEMFrAI.sqf +++ b/exile_vemf_reloaded/fn/fn_spawnVEMFrAI.sqf @@ -34,18 +34,16 @@ if ((_this4 in ("missionList" call VEMFr_fnc_config)) OR (_this4 isEqualTo "Stat scopeName "outer"; _r = []; _this0 = [_this0 select 0, _this0 select 1, _this5]; - private ["_s","_ccrcy","_mshk","_mspd","_stmn","_sptDst","_sptTm","_crg","_rldSpd","_cmmndng","_gnrl","_i"]; + private ["_s","_ccrcy","_mshk","_mspd","_stmn","_sptDst","_sptTm","_crg","_rldSpd","_cmmndng","_gnrl","_i","_grp","_unit"]; _s = [["aiSkill", ([["aiSkill"],["difficulty"]] call VEMFr_fnc_config) select 0],["accuracy","aimingShake","aimingSpeed","endurance","spotDistance","spotTime","courage","reloadSpeed","commanding","general"]] call VEMFr_fnc_config; _s params ["_ccrcy","_mshk","_mspd","_stmn","_sptDst","_sptTm","_crg","_rldSpd","_cmmndng","_gnrl"]; for "_g" from 1 to _this1 do { - private["_grp"]; _grp = createGroup (("unitClass" call VEMFr_fnc_config) call VEMFr_fnc_checkSide); _grp allowFleeing 0; for "_u" from 1 to _this2 do { - private ["_unit"]; _unit = _grp createUnit [("unitClass" call VEMFr_fnc_config), _this0, [], _this6, "FORM"]; // Create Unit There _allUnits pushBack _unit; _unit addMPEventHandler ["mpkilled","if (isDedicated) then { [[(_this select 0),(name(_this select 0))],[(_this select 1),(name(_this select 1))]] ExecVM 'exile_vemf_reloaded\sqf\aiKilled.sqf' }"]; diff --git a/exile_vemf_reloaded/sqf/broadCast.sqf b/exile_vemf_reloaded/sqf/broadCast.sqf index 6a3c654..81bec65 100644 --- a/exile_vemf_reloaded/sqf/broadCast.sqf +++ b/exile_vemf_reloaded/sqf/broadCast.sqf @@ -24,7 +24,7 @@ _send = { - private ["_arr"]; + private "_arr"; if (count _this isEqualTo 0) then { _arr = allPlayers; diff --git a/exile_vemf_reloaded/sqf/loadLoot.sqf b/exile_vemf_reloaded/sqf/loadLoot.sqf index 2b89ab7..5588c36 100644 --- a/exile_vemf_reloaded/sqf/loadLoot.sqf +++ b/exile_vemf_reloaded/sqf/loadLoot.sqf @@ -42,88 +42,80 @@ _ms params [ // 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 + _g = _primaries call BIS_fnc_selectRandom; + if not((_g select 0) in _blackList) then { - _crate addWeaponCargoGlobal [_prim select 0, _prim select 1]; + _crate addWeaponCargoGlobal [_g select 0, _g select 1]; }; }; // 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 + _g = _secondaries call BIS_fnc_selectRandom; + if not((_g select 0) in _blackList) then { - _crate addWeaponCargoGlobal [_sec select 0, _sec select 1]; + _crate addWeaponCargoGlobal [_g select 0, _g select 1]; }; }; // 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 + _g = _magazines call BIS_fnc_selectRandom; + if not((_g select 0) in _blackList) then { - _crate addMagazineCargoGlobal [_mag select 0, _mag select 1]; + _crate addMagazineCargoGlobal [_g select 0, _g select 1]; }; }; // 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 + _g = _attachments call BIS_fnc_selectRandom; + if not((_g select 0) in _blackList) then { - _crate addItemCargoGlobal [_att select 0, _att select 1]; + _crate addItemCargoGlobal [_g select 0, _g select 1]; }; }; // 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 + _g = _items call BIS_fnc_selectRandom; + if not((_g select 0) in _blacklist) then { - _crate addItemCargoGlobal [_item select 0, _item select 1]; + _crate addItemCargoGlobal [_g select 0, _g select 1]; }; }; // 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 + _g = _vests call BIS_fnc_selectRandom; + if not((_g select 0) in _blackList) then { - _crate addItemCargoGlobal [_vest select 0, _vest select 1]; + _crate addItemCargoGlobal [_g select 0, _g select 1]; }; }; // 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 + _g = _headGear call BIS_fnc_selectRandom; + if not((_g select 0) in _blackList) then { - _crate addItemCargoGlobal [_headGearItem select 0, _headGearItem select 1]; + _crate addItemCargoGlobal [_g select 0, _g select 1]; }; }; // 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 + _g = _backpacks call BIS_fnc_selectRandom; + if not((_g select 0) in _blackList) then { - _crate addBackpackCargoGlobal [_pack select 0, _pack select 1]; + _crate addBackpackCargoGlobal [_g select 0, _g select 1]; }; };