2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-01-18 21:50:45 +00:00
|
|
|
fnc_isInRotorWash.sqf
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
Author: Garth de Wet (LH)
|
2015-01-18 21:50:45 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
Description:
|
|
|
|
Checks for nearby helicopters (within 15m)
|
2015-01-18 21:50:45 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
Parameters:
|
|
|
|
0: Object - Unit
|
|
|
|
1: NUMBER - (optional) Radius to check for helicopter Default: 15
|
2015-01-18 21:50:45 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
Returns:
|
|
|
|
Array:
|
|
|
|
0 - boolean - If in rotorwash
|
|
|
|
1 - number - Amount of rotor wash.
|
2015-01-18 21:50:45 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
Example:
|
2015-01-18 21:50:45 +00:00
|
|
|
if (([ace_player, 10] call FUNC(isInRotorWash)) select 0) then { hint "Rotor wash"; };
|
|
|
|
if (([ace_player] call FUNC(isInRotorWash)) select 0) then { hint "Rotor wash"; };
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-18 21:50:45 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
private ["_heli", "_unit", "_result", "_radius"];
|
|
|
|
_unit = _this select 0;
|
|
|
|
_radius = 15;
|
|
|
|
if (count _this > 1) then {
|
|
|
|
_radius = _this select 1;
|
|
|
|
};
|
|
|
|
_result = [false, _radius + 2];
|
|
|
|
|
|
|
|
_heli = (getPosATL _unit) nearEntities [["Helicopter"], _radius];
|
|
|
|
{
|
|
|
|
if !(_x isKindOf "ParachuteBase") then {
|
|
|
|
if (isEngineOn _x) then {
|
|
|
|
private "_distance";
|
|
|
|
_distance = (_radius - (_unit distance _x));
|
|
|
|
if (_distance != 0) then {
|
|
|
|
_distance = _distance / _radius;
|
|
|
|
};
|
|
|
|
if (_distance < (_result select 1)) then {
|
|
|
|
_result = [true, _distance];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-01-18 21:50:45 +00:00
|
|
|
false
|
2015-01-11 16:42:31 +00:00
|
|
|
} count _heli;
|
|
|
|
|
|
|
|
_result
|