Difference between revisions of "VN ms fnc tracker getSpiralPositions"

From Savage Game Design Wiki
Jump to navigation Jump to search
m (Text replacement - " |e=" to " |a= |e=")
(Page filling)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
 
{{Function
 
{{Function
  
Line 12: Line 11:
 
|g1= tracker
 
|g1= tracker
  
|d= <pre>/*
+
|d= Get positions in spiral with given radius. Useful for patrols.
    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 [
 
params [
 
     ["_center", getPos player, [[], objNull], 3],
 
     ["_center", getPos player, [[], objNull], 3],
Line 37: Line 21:
 
];
 
];
  
if (_center isEqualType objNull) then {
+
|s= [centre, radius, steps, precision, clockwise] call [[VN_ms_fnc_tracker_getSpiralPositions]]
    _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];
+
|p1n= centre
};
+
|p1t= {{Biki|Object}} or {{Biki|Position}}
 +
|p1d= spiral centre
 +
|p1v= getPos player
  
_positions
+
|p2n= radius
</pre><small>''(Placeholder description extracted from the function header by '''LM_exportFunctionsToWiki.sqf''')''</small>
+
|p2t= number
 +
|p2d= spiral radius
 +
|p2v= 500
  
|s= [] call [[vn_ms_fnc_tracker_getSpiralPositions]];
+
|p3n= steps
 +
|p3t= number
 +
|p3d= steps per spiral (360°&nbsp;&divide;&nbsp;''steps'')
 +
|p3v= 8
  
|p1n=
+
|p4n= precision
|p1t=
+
|p4t= array
|p1d=
+
|p4d= radius precision, 3-elements number array
|p1v=
+
|p4v= [0.3, 0.8, 1]
  
|p2n=
+
|p5n= clockwise
|p2t=
+
|p5t= boolean
|p2d=
+
|p5d= spiral direction, true for clockwise, false for counter-clockwise
|p2v=
+
|p5v= selectRandom [true, false]
  
|r1t=
+
|r1t= array
|r1d=
+
|r1d= positions
  
|x1= <code>-</code>
+
|x1= <code>private _spiralPositions = [nil, 100, 36, [0,0.25, 0.5], true] call [[VN_ms_fnc_tracker_getSpiralPositions]];</code>
 
}}
 
}}

Latest revision as of 15:45, 26 February 2021

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

Description

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

params [

   ["_center", getPos player, [[], objNull], 3],
   ["_radius", 500, [0]],
   ["_steps", 8, [0]],
   ["_precision", [0.3, 0.8, 1], [[]], 3],
   ["_clockwise", selectRandom [true, false], [false]]

];

Syntax

Syntax
[centre, radius, steps, precision, clockwise] call VN_ms_fnc_tracker_getSpiralPositions
Parameters
centre: Object or Position - (Optional, default getPos player) spiral centre
radius: Number - (Optional, default 500) spiral radius
steps: Number - (Optional, default 8) steps per spiral (360° ÷ steps)
precision: Array - (Optional, default [0.3, 0.8, 1]) radius precision, 3-elements number array
clockwise: Boolean - (Optional, default selectRandom [true, false]) spiral direction, true for clockwise, false for counter-clockwise
Return value
Array - positions

Examples

Example 1
private _spiralPositions = [nil, 100, 36, [0,0.25, 0.5], true] call VN_ms_fnc_tracker_getSpiralPositions;