fn_getNearestFob

This commit is contained in:
Wyqer 2019-12-05 23:01:39 +01:00
parent d4088ae9e5
commit c68b7e9eb1
No known key found for this signature in database
GPG Key ID: D7E2F8BD7F1E48FA
1 changed files with 13 additions and 11 deletions

View File

@ -2,25 +2,27 @@
File: fn_getNearestFob.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.
Gets the nearest FOB position to given position.
Parameter(s):
_localVariable - Description [DATATYPE, defaults to DEFAULTVALUE]
_pos - Position to find the nearest FOB from [POSITION, defaults to getPos player]
Returns:
Function reached the end [BOOL]
Nearest FOB position [POSITION]
*/
// TODO
params [["_source_position", (getpos player)]];
private _retvalue = [];
params [
["_pos", getPos player, [[]], [2, 3]]
];
if (count GRLIB_all_fobs > 0) then {
_retvalue = ([ GRLIB_all_fobs, [], {_source_position distance _x}, 'ASCEND'] call BIS_fnc_sortBy) select 0;
if !(GRLIB_all_fobs isEqualTo []) then {
private _fobs = GRLIB_all_fobs apply {[_pos distance2d _x, _x]};
_fobs sort true;
(_fobs select 0) select 1
} else {
[]
};
_retvalue