diff --git a/exile_vemf_reloaded/fn/fn_config.sqf b/exile_vemf_reloaded/fn/fn_config.sqf new file mode 100644 index 0000000..4a5238b --- /dev/null +++ b/exile_vemf_reloaded/fn/fn_config.sqf @@ -0,0 +1,83 @@ +/* + Author: IT07 + + Description: + gets config value of given var from VEMF config OR cfgPath + + Params: + method 1: + _this: STRING - SINGLE config value to get from root of CfgVemfReloaded + method 2: + _this select 0: ARRAY of STRINGS - MULTIPLE config values to get from root of VEMFconfig + method 3: + _this select 0: ARRAY of STRINGS - config path to get value from. Example: "root","subclass" + _this select 1: ARRAY of STRINGS - MULTIPLE config values to get from given path + + Returns: + ARRAY - Result +*/ + +private["_r","_chck","_v","_cfg"]; +_r = []; +_chck = + { + if (isNumber _cfg) then { _v = getNumber _cfg }; + if (isText _cfg) then { _v = getText _cfg }; + if (isArray _cfg) then { _v = getArray _cfg }; + if (isNil "_v") then { _v = "nil" }; + }; + +if (_this isEqualType "") then + { + if (isNull (configFile >> "CfgVemfReloadedOverrides" >> _this)) then + { + _cfg = configFile >> "CfgVemfReloaded" >> _this; + } else + { + _cfg = configFile >> "CfgVemfReloadedOverrides" >> _this; + }; + call _chck; + _r = _v; + }; + +if (_this isEqualType []) then + { + if (_this isEqualTypeArray [[],[]]) then + { + private ["_p","_b"]; + _p = _this select 0; + _b = + { + { + _cfg = _cfg >> _x; + } forEach _p; + }; + { + _cfg = configFile >> "CfgVemfReloadedOverrides"; + call _b; + _cfg = _cfg >> _x; + if (isNull _cfg) then + { + _cfg = configFile >> "CfgVemfReloaded"; + call _b; + _cfg = _cfg >> _x; + }; + call _chck; + _r pushBack _v; + } forEach (_this select 1); + }; + if (_this isEqualTypeArray [[]]) then + { + { + _cfg = configFile >> "CfgVemfReloadedOverrides" >> _x; + if (isNull _cfg) then + { + _cfg = configFile >> "CfgVemfReloaded" >> _x; + }; + call _chck; + _r pushBack _v; + } forEach (_this select 0); + }; + }; + +_r diff --git a/exile_vemf_reloaded/fn/fn_hc.sqf b/exile_vemf_reloaded/fn/fn_hc.sqf new file mode 100644 index 0000000..c0fb971 --- /dev/null +++ b/exile_vemf_reloaded/fn/fn_hc.sqf @@ -0,0 +1,38 @@ +/* + Author: IT07 + + Description: + selects a headless client with least (VEMFr) load + + Params: + None + + Returns: + OBJECT - the headless client +*/ + +private ["_r","_n","_arr","_gl"]; +_n = "headLessClientNames" call VEMFr_fnc_config; +_arr = []; +_gl = uiNamespace getVariable "VEMFrHcLoad"; +{ + if (((side _x) isEqualTo sideLogic) AND ((name _x) in _n)) then + { + _arr pushBackUnique _x; + if not(_x in (_gl select 0)) then + { + _i = (_gl select 0) pushBack _x; + (_gl select 1) set [_i, 0]; + }; + }; +} forEach playableUnits; + +_l = 99999; +{ + if (_x <= _l) then { _l = _x }; +} forEach (_gl select 1); + +_r = (_gl select 0) select ((_gl select 1) find _l); +(_gl select 1) set [(_gl select 0) find _r, _l + 1]; + +_r diff --git a/exile_vemf_reloaded/fn/fn_mines.sqf b/exile_vemf_reloaded/fn/fn_mines.sqf new file mode 100644 index 0000000..fba5724 --- /dev/null +++ b/exile_vemf_reloaded/fn/fn_mines.sqf @@ -0,0 +1,48 @@ +/* + Author: IT07 + + Description: + places mines around given position within given radius + + Params: + _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: + ARRAY - array containing all mine objects +*/ + +scopeName "mines"; +private ["_r","_this0","_this1","_this2","_this3","_s","_ms","_a"]; +params [ + ["_this0",[],[[]]], + ["_this1",-1,[0]], + ["_this2",-1,[0]], + ["_this3", "", [""]] +]; + +_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"] }; + if (_ms < 1 OR _ms > 3) then + { + ["fn_mines", 0, "Invalid mines mode!"] ExecVM "exile_vemf_reloaded\sqf\log.sqf"; + breakOut "mines" + }; + _r = []; + ["fn_mines", 1, format["Placing %1 mines at %2", _a, _this0]] ExecVM "exile_vemf_reloaded\sqf\log.sqf"; + for "_m" from 1 to _a do + { + _r pushBack (createMine [selectRandom _mt, ([_this0, _this1, _this2, 2, 0, 20, 0] call BIS_fnc_findSafePos), [], 0]); + uiSleep 0.1; + }; + }; + +_r diff --git a/exile_vemf_reloaded/fn/fn_playerNear.sqf b/exile_vemf_reloaded/fn/fn_playerNear.sqf new file mode 100644 index 0000000..f5013a7 --- /dev/null +++ b/exile_vemf_reloaded/fn/fn_playerNear.sqf @@ -0,0 +1,33 @@ +/* + Author: IT07 + + Description: + checks for players within given distance of given location/position + + Params: + _this select 0: POSITION - center of area to check around + _this select 1: SCALAR - radius around the position to check for players + + Returns: + BOOL - true if player(s) found +*/ + +private ["_r","_this0","_this1"]; +// By default, we assume that there are no players close. The distance check below should prove otherwise if there are players close +_r = false; +params [ + ["_this0", [], [[]]], + ["_this1", -1, [0]] +]; +if (((count _this0) isEqualTo 3) AND (_this1 > -1)) then + { + scopeName "find"; + { + if ((isPlayer _x) AND ((speed _x) < 250)) then + { + if ((position _x distance _this0) < _this1) then { _r = true; breakOut "find" }; + }; + } forEach allPlayers; + }; + +_r diff --git a/exile_vemf_reloaded/sqf/killedMonitor.sqf b/exile_vemf_reloaded/sqf/killedMonitor.sqf new file mode 100644 index 0000000..4fcd61a --- /dev/null +++ b/exile_vemf_reloaded/sqf/killedMonitor.sqf @@ -0,0 +1,35 @@ +/* + Author: IT07 + + Description: + will loop until all given objects are dead + + Params: + _this select 0: ARRAY - array of objects to monitor + + Returns: + nothing +*/ + +_a = param [0,[],[[]]]; +if ((count _a) > 0) then + { + _k = 0; + _cnt = count _a; + _kp = round(("killPercentage" call VEMFr_fnc_config)/100*_cnt); + while {true} do + { + scopeName "while"; + _k = 0; + { + if (((damage _x) isEqualTo 1) OR (isNull _x)) then { _k = _k + 1 }; + } forEach _a; + if (_k < _kp) then + { + uiSleep 3; + } else + { + breakOut "while"; + }; + }; + }; diff --git a/exile_vemf_reloaded/sqf/respect.sqf b/exile_vemf_reloaded/sqf/respect.sqf new file mode 100644 index 0000000..090e28d --- /dev/null +++ b/exile_vemf_reloaded/sqf/respect.sqf @@ -0,0 +1,97 @@ +/* + Author: IT07 + Description: + handles giving respect to players after killing AI + Params: + _this select 0: OBJECT - the AI that was killed + _this select 1: OBJECT - the killer (must be a player) +*/ + +params [ + ["_t", objNull, [objNull]], + ["_k", objNull, [objNull]] +]; + +_rw = "respectReward" call VEMFr_fnc_config; +if (_rw > 0) then +{ + _arr = [[]]; + (_arr select 0) pushBack [(selectRandom ["AI WACKED","AI CLIPPED","AI DISABLED","AI DISQUALIFIED","AI WIPED","AI ERASED","AI LYNCHED","AI WRECKED","AI NEUTRALIZED","AI SNUFFED","AI WASTED","AI ZAPPED"]), _rw]; + _dist = _t distance _k; + private ["_ok"]; + if (_dist < 2500) then + { + scopeName "below2500"; + if (_dist <= 5) then + { + (_arr select 0) pushBack ["CQB Master", 25]; + _ok = true; + _ok breakOut "below2500"; + }; + if (_dist <= 10) then + { + (_arr select 0) pushBack ["Close one", 15]; + _ok = true; + _ok breakOut "below2500"; + }; + if (_dist <= 50) then + { + (_arr select 0) pushBack ["Danger close", 15]; + _ok = true; + _ok breakOut "below2500"; + }; + if (_dist <= 100) then + { + (_arr select 0) pushBack ["Lethal aim", 20]; + _ok = true; + _ok breakOut "below2500"; + }; + if (_dist <= 200) then + { + (_arr select 0) pushBack ["Deadly.", 25]; + _ok = true; + _ok breakOut "below2500"; + }; + if (_dist <= 500) then + { + (_arr select 0) pushBack ["Niiiiice.", 30]; + _ok = true; + _ok breakOut "below2500"; + }; + if (_dist <= 1000) then + { + (_arr select 0) pushBack ["Dat distance...", 45]; + _ok = true; + _ok breakOut "below2500"; + }; + if (_dist <= 2000) then + { + (_arr select 0) pushBack ["Danger far.", 50]; + _ok = true; + _ok breakOut "below2500"; + }; + if (_dist > 2000) then + { + (_arr select 0) pushBack [format["hax? %1m!!!", round _dist], 65]; + _ok = true; + _ok breakOut "below2500"; + }; + }; + + if _ok then + { + _crRspct = _k getVariable ["ExileScore", nil]; + _rspctTGv = (((_arr select 0) select 1) select 1); + _nwRspct = _crRspct + _rspctTGv + _rw; + _k setVariable ["ExileScore", _nwRspct]; + ExileClientPlayerScore = _nwRspct; + (owner _k) publicVariableClient "ExileClientPlayerScore"; + ExileClientPlayerScore = nil; + [_k, "showFragRequest", _arr] call ExileServer_system_network_send_to; + format["setAccountMoneyAndRespect:%1:%2:%3", _k getVariable ["ExileMoney", 0], _nwRspct, (getPlayerUID _k)] call ExileServer_system_database_query_fireAndForget; + } else + { + ["handleKillMessage", 0, format["There is something wrong with the kill distance (%1)", _dist]] ExecVM "exile_vemf_reloaded\sqf\log.sqf"; + breakOut "outer"; // Stop doing anything after this line + }; +};