fn_getLessLoadedHC

This commit is contained in:
Wyqer 2019-12-05 18:07:16 +01:00
parent c68db8a058
commit a0cee3b586
No known key found for this signature in database
GPG Key ID: D7E2F8BD7F1E48FA
1 changed files with 15 additions and 45 deletions

View File

@ -2,60 +2,30 @@
File: fn_getLessLoadedHC.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-03
Last Update: 2019-12-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
No description added yet.
Returns the HC with the current less load.
Parameter(s):
_localVariable - Description [DATATYPE, defaults to DEFAULTVALUE]
NONE
Returns:
Function reached the end [BOOL]
Less loaded HC [OBJECT]
*/
// TODO
private _less_loaded_HC = objNull;
private _previous_min_load = 99999;
if (isMultiplayer) then {
if (!isNil "group_owners" && !(isNil "HC1" && isNil "HC2" && isNil "HC3")) then {
{
if (!isNil "HC1") then {
if (!isNull HC1) then {
if (_x select 0 == HC1) then {
if ((_x select 4) + (_x select 5) < _previous_min_load) then {
_previous_min_load = (_x select 4) + (_x select 5);
_less_loaded_HC = HC1;
};
};
};
};
private _hcArray = [];
private _hc = objNull;
if (!isNil "HC2") then {
if (!isNull HC2) then {
if (_x select 0 == HC2) then {
if ((_x select 4) + (_x select 5) < _previous_min_load) then {
_previous_min_load = (_x select 4) + (_x select 5);
_less_loaded_HC = HC2;
};
};
};
};
{
_hc = _x;
_hcArray pushBack [count (allUnits select {(owner _x) isEqualTo (owner _hc)}), _hc];
} forEach (entities "HeadlessClient_F");
if (!isNil "HC3") then {
if (!isNull HC3) then {
if (_x select 0 == HC3) then {
if ((_x select 4) + (_x select 5) < _previous_min_load) then {
_previous_min_load = (_x select 4) + (_x select 5);
_less_loaded_HC = HC3;
};
};
};
};
} foreach group_owners;
};
if !(_hcArray isEqualTo []) then {
_hcArray sort true;
(_hcArray select 0) select 1
} else {
objNull
};
_less_loaded_HC