fn_getSectorOwnership
This commit is contained in:
parent
d4fdbc7de6
commit
8e2ac32de9
|
@ -2,39 +2,36 @@
|
|||
File: fn_getSectorOwnership.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2019-12-03
|
||||
Last Update: 2019-12-03
|
||||
Last Update: 2019-12-07
|
||||
License: MIT License - http://www.opensource.org/licenses/MIT
|
||||
|
||||
Description:
|
||||
No description added yet.
|
||||
Gets the side of the owner of a given position with given radius.
|
||||
|
||||
Parameter(s):
|
||||
_localVariable - Description [DATATYPE, defaults to DEFAULTVALUE]
|
||||
_pos - Position to get owner [POSITION, defaults to [0, 0, 0]]
|
||||
_radius - Radius to count units [NUMBER, defaults to GRLIB_capture_size]
|
||||
|
||||
Returns:
|
||||
Function reached the end [BOOL]
|
||||
Owner of the position [SIDE]
|
||||
*/
|
||||
// TODO
|
||||
params [ "_thatpos", [ "_localsize", GRLIB_capture_size ] ];
|
||||
private [ "_cap_thresold_count", "_cap_thresold_ratio", "_cap_min_ratio", "_sectorside", "_countblufor_ownership", "_countopfor_ownership", "_blufor_ratio" ];
|
||||
|
||||
_cap_thresold_count = 3;
|
||||
_cap_thresold_ratio = 0.85;
|
||||
_cap_min_ratio = 0.51;
|
||||
params [
|
||||
["_pos", [0, 0, 0], [[]], [2, 3]],
|
||||
["_radius", GRLIB_capture_size, [0]]
|
||||
];
|
||||
|
||||
_sectorside = GRLIB_side_resistance;
|
||||
_countblufor_ownership = [_thatpos, _localsize, GRLIB_side_friendly ] call KPLIB_fnc_getUnitsCount;
|
||||
_countopfor_ownership = [_thatpos, _localsize, GRLIB_side_enemy ] call KPLIB_fnc_getUnitsCount;
|
||||
private _capCount = 3;
|
||||
private _capRatio = 0.85;
|
||||
private _capRatioMin = 0.51;
|
||||
private _blufor = [_pos, _radius, GRLIB_side_friendly] call KPLIB_fnc_getUnitsCount;
|
||||
private _opfor = [_pos, _radius, GRLIB_side_enemy] call KPLIB_fnc_getUnitsCount;
|
||||
private _ratio = 0;
|
||||
|
||||
_blufor_ratio = 0;
|
||||
if ( _countblufor_ownership + _countopfor_ownership != 0 ) then {
|
||||
_blufor_ratio = _countblufor_ownership / ( _countblufor_ownership + _countopfor_ownership);
|
||||
if (_blufor + _opfor != 0) then {
|
||||
_ratio = _blufor / (_blufor + _opfor);
|
||||
};
|
||||
|
||||
if ( _countblufor_ownership == 0 && _countopfor_ownership <= _cap_thresold_count ) then { _sectorside = GRLIB_side_civilian; };
|
||||
|
||||
if ( _countblufor_ownership > 0 && ( ( _countopfor_ownership <= _cap_thresold_count && _blufor_ratio > _cap_min_ratio ) || _blufor_ratio > _cap_thresold_ratio) ) then { _sectorside = GRLIB_side_friendly; };
|
||||
|
||||
if ( _countblufor_ownership == 0 && _countopfor_ownership > _cap_thresold_count ) then { _sectorside = GRLIB_side_enemy; };
|
||||
|
||||
_sectorside
|
||||
if (_blufor > 0 && {(_opfor <= _capCount && _ratio > _capRatioMin) || _ratio > _capRatio}) exitWith {GRLIB_side_friendly};
|
||||
if (_blufor == 0 && _opfor > _capCount) exitWith {GRLIB_side_enemy};
|
||||
if (_blufor == 0 && _opfor <= _capCount) exitWith {GRLIB_side_civilian};
|
||||
|
|
Loading…
Reference in New Issue