2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-09-29 16:51:24 +00:00
|
|
|
* Author: Garth 'L-H' de Wet, commy2
|
2015-02-02 09:04:53 +00:00
|
|
|
* Checks for nearby running helicopters (within 15m)
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
2015-09-29 16:51:24 +00:00
|
|
|
* 1: Radius to check for helicopter (default: 15) <NUMBER>
|
2015-02-02 09:04:53 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* Array <ARRAY>:
|
2015-04-06 16:22:43 +00:00
|
|
|
* 0: In rotorwash <BOOL>
|
|
|
|
* 1: Amount of rotor wash. <NUMBER>
|
2015-02-02 09:04:53 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2015-09-29 16:51:24 +00:00
|
|
|
* if ([ace_player, 10] call ace_goggles_fnc_isInRotorWash select 0) then { hint "Rotor wash"; };
|
|
|
|
* if ([ace_player] call ace_goggles_fnc_isInRotorWash select 0) then { hint "Rotor wash"; };
|
2015-02-02 09:04:53 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2015-01-18 21:50:45 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-29 16:51:24 +00:00
|
|
|
params ["_unit", ["_radius", 15]];
|
|
|
|
|
2015-11-17 16:43:07 +00:00
|
|
|
private _rotorWash = [false, 0];
|
2015-09-29 16:51:24 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
2015-09-29 16:51:24 +00:00
|
|
|
if (isEngineOn _x) then {
|
2015-11-17 16:43:07 +00:00
|
|
|
private _distance = _unit distance _x;
|
2015-09-29 16:51:24 +00:00
|
|
|
|
|
|
|
// convert distance to 0...1 range, where 0 is the maximum radius
|
|
|
|
_distance = 1 - _distance / _radius;
|
|
|
|
|
|
|
|
// use highest amount of rotor wash as return value in case of multiple helicopters
|
|
|
|
if (_distance > _rotorWash select 1) then {
|
|
|
|
_rotorWash set [0, true];
|
|
|
|
_rotorWash set [1, _distance];
|
2015-04-06 16:22:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
false
|
2015-09-29 16:51:24 +00:00
|
|
|
} count (position _unit nearEntities [["Helicopter"], _radius]);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-29 16:51:24 +00:00
|
|
|
_rotorWash
|