ACE3/addons/kestrel4500/functions/fnc_measureWindSpeed.sqf

40 lines
1.2 KiB
Plaintext
Raw Normal View History

2015-04-13 09:53:19 +00:00
/*
* Author: Ruthberg
* Measures the wind speed, stores the information in GVAR(MeasuredWindSpeed) and updates GVAR(ImpellerState)
*
* Arguments:
2015-08-13 23:55:54 +00:00
* None
2015-04-13 09:53:19 +00:00
*
* Return Value:
* wind speed <NUMBER>
*
* Example:
2015-08-13 23:55:54 +00:00
* call ace_kestrel4500_fnc_canShow
2015-04-13 09:53:19 +00:00
*
* Public: No
*/
#include "script_component.hpp"
private _playerDir = getDir ACE_player;
private _windSpeed = vectorMagnitude ACE_wind;
private _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
2015-04-13 09:53:19 +00:00
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
// With wind gradient
_windSpeed = [eyePos ACE_player, true, true, true] call EFUNC(weather,calculateWindSpeed);
2015-04-13 09:53:19 +00:00
_windSpeed = abs(cos(_playerDir - _windDir)) * _windSpeed;
} else {
// Without wind gradient
_windSpeed = [eyePos ACE_player, false, true, true] call EFUNC(weather,calculateWindSpeed);
2015-04-13 09:53:19 +00:00
};
if (_windSpeed > 0.3 || {GVAR(MeasuredWindSpeed) > 0.1 && _windSpeed > 0.125}) then {
GVAR(MeasuredWindSpeed) = _windSpeed;
} else {
GVAR(MeasuredWindSpeed) = GVAR(MeasuredWindSpeed) * 0.99;
if (GVAR(MeasuredWindSpeed) < 0.05) then {
GVAR(MeasuredWindSpeed) = 0;
};
};
GVAR(MeasuredWindSpeed)