Difference between revisions of "VN ms fnc tracker getHiddenPos"

From Savage Game Design Wiki
Jump to navigation Jump to search
m (Text replacement - " |e=" to " |a= |e=")
m (Text replacement - " {{Function" to "Category:TODO {{Function")
Line 1: Line 1:
 
+
[[Category:TODO]]
 
{{Function
 
{{Function
  

Revision as of 22:37, 5 January 2021

← back to Functions Introduced in S.O.G. Prairie Fire v1.00
by Wyqer, veteran29
Argument(s): n/a
Effect(s): unknown

Description

/*
    File: fn_tracker_getHiddenPos.sqf
    Author: Wyqer, veteran29
    Date: 2019-12-04
    Last Update: 2020-11-13
    Public: Yes

    Description:
        Search for hidden postion around target position.

    Parameter(s):
        _target      - Target position                          [ARRAY or STRING, defaults to nil]
        _minDistance - Wanted position distance from target pos [NUMBER, defaults to nil]

    Example:
        [getPos player, 150] call vn_ms_fnc_tracker_getHiddenPos;

    Returns:
        Found position [ARRAY]
*/
#define SEARCH_RADIUS   50

params ["_target", "_minDistance"];

if (isNil "_target" || isNil "_minDistance") exitWith {
    (format ["[VN] Invalid parameters, _target - %1, _minDistance - %2", _target, _minDistance]) call BIS_fnc_error;
    false
};

if (_target isEqualType "") then {
    _target = markerPos _target;
};

private _spawnPos = [];
waitUntil {
    sleep 1;
    private _spawns = selectBestPlaces [
        _target getPos [_minDistance + SEARCH_RADIUS, random 360],
        SEARCH_RADIUS,    //radius
        "forest + (1 - meadow)",
        50,     // precision
        10      // count
    ];

    _spawnPos = (selectRandom _spawns) param [0, []];

    private _msg = format ["[VN] Searching for hidden pos - %1, tgt - %2", _spawnPos, _target];
    diag_log text _msg;
    #ifdef VN_DEBUG
        systemChat _msg;
    #endif

    // return
    !(_spawnPos isEqualTo []) && {
        !([allPlayers, _spawnPos] call vn_ms_fnc_tracker_positionVisible)
        && !surfaceIsWater _spawnPos
    }
};

_spawnPos
(Placeholder description extracted from the function header by LM_exportFunctionsToWiki.sqf)

Syntax

Syntax
[] call vn_ms_fnc_tracker_getHiddenPos;
Return value
Nothing

Examples

Example 1
-