2015-12-07 16:24:52 +00:00
|
|
|
/*
|
|
|
|
Author: Andrew Gregory - EpochMod.com
|
2015-09-14 20:55:36 +00:00
|
|
|
|
2015-12-07 16:24:52 +00:00
|
|
|
Contributors:
|
|
|
|
|
|
|
|
Description:
|
|
|
|
Picks a random spot behind the player
|
|
|
|
|
|
|
|
Licence:
|
|
|
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
|
|
|
|
|
|
|
Github:
|
2016-06-13 16:54:19 +00:00
|
|
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/functions/EPOCH_fnc_findRandomPosBehind.sqf
|
2015-12-07 16:24:52 +00:00
|
|
|
|
|
|
|
Example:
|
|
|
|
_moveTo = [24,4,142,_trgt] call EPOCH_fnc_findRandomPosBehind;
|
|
|
|
|
|
|
|
Parameter(s):
|
|
|
|
_this select 0: SCALAR - Maximum distance to choose point
|
|
|
|
_this select 1: SCALAR - Minimum distance to choose point
|
|
|
|
_this select 2: SCALAR - Spread of arc in degrees behind player
|
|
|
|
_this select 3: OBJECT - Unit, player, vehicle etc.
|
|
|
|
_this select 4: SCALAR - offset initial angle, allows to pick position to the side with -90 or 90 (right or left) [optional: default 0]
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
ARRAY
|
|
|
|
*/
|
2016-09-01 00:29:08 +00:00
|
|
|
//[[[cog import generate_private_arrays ]]]
|
|
|
|
private ["_dir","_dist","_moveTo","_pos","_rnd"];
|
|
|
|
//[[[end]]]
|
2016-04-08 20:21:46 +00:00
|
|
|
params ["_maxIn","_minIn","_arcIn","_unitIn",["_offset",0]];
|
2015-09-14 20:55:36 +00:00
|
|
|
|
|
|
|
_rnd = ((180 +_offset) - (_arcIn / 2)) + (random _arcIn);
|
2015-12-07 16:24:52 +00:00
|
|
|
_pos = getPosATL _unitIn;
|
2015-09-14 20:55:36 +00:00
|
|
|
_dist = ((random (_maxIn - _minIn)) + _minIn) max _minIn;
|
|
|
|
_dir = (getDir _unitIn) - _rnd;
|
2017-05-02 13:28:52 +00:00
|
|
|
if (_dir < 0) then {_dir = _dir + 360};
|
2016-04-08 20:21:46 +00:00
|
|
|
//return
|
|
|
|
[(_pos select 0) + (_dist*(sin _dir)), (_pos select 1) + (_dist*(cos _dir)), _pos select 2]
|