Difference between revisions of "VN ms fnc tracker getSpiralPositions"

From Savage Game Design Wiki
Jump to navigation Jump to search
vn>Unknown user
m (Generated by LM_exportFunctionsToWiki.sqf)
 
m (1 revision imported)
(No difference)

Revision as of 18:23, 5 January 2021

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

Description

/*
    Author: Wyqer, veteran29
    Date: 2019-08-10

    Description:
        Get positions in spiral with given radius. Useful for patrols.

    Parameter(s):
        _center     - Center of spiral                                      [POSITION or OBJECT, defaults to getPos player]
        _radius     - Max radius of spiral                                  [NUMBER, defaults to 500]
        _steps      - Amount of steps for spiral, 360 / _steps              [NUMBER, defaults to 8]
        _precision  - Radius precision 3 element array for random command   [ARRAY, defaults to [0.3, 0.8, 1]]
        _clockwise  - Should the spiral go clockwise                        [BOOL, defaults to selectRandom [true, false]]

    Returns:
        Positions [ARRAY]
*/
params [
    ["_center", getPos player, [[], objNull], 3],
    ["_radius", 500, [0]],
    ["_steps", 8, [0]],
    ["_precision", [0.3, 0.8, 1], [[]], 3],
    ["_clockwise", selectRandom [true, false], [false]]
];

if (_center isEqualType objNull) then {
    _center = getPos _center;
};

private _direction = [-1, 1] select _clockwise;

private _baseAngle = random 360;

private _step = 360 / _steps;
private _stepRadius = _radius / _steps;

private _positions = [];

for "_i" from  1 to _steps do {
    private _angle = _baseAngle + (_i * _step * _direction);
    private _radius = _i * _stepRadius * random _precision;

    private _x = (_center select 0) + _radius * cos _angle;
    private _y = (_center select 1) + _radius * sin _angle;

    _positions pushBack [_x, _y, _center select 2];
 };

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

Syntax

Syntax
[] call vn_ms_fnc_tracker_getSpiralPositions;
Return value
Nothing

Examples

Example 1
-