ACE3/addons/kestrel4500/functions/fnc_collectData.sqf

94 lines
3.5 KiB
Plaintext
Raw Normal View History

2015-04-07 15:58:54 +00:00
/*
* Author: Ruthberg
* Gathers the weather data for the Kestrel 4500
*
* Arguments:
* Nothing
*
* Return Value:
* Nothing
*
* Example:
*
* Public: No
*/
#include "script_component.hpp"
2015-04-24 09:53:06 +00:00
private ["_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"];
if (isNil QGVAR(MIN) || isNil QGVAR(MAX)) then {
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
_humidity = EGVAR(weather,currentHumidity);
_barometricPressure = ((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure);
_altitude = EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2);
2015-04-08 09:25:15 +00:00
GVAR(MIN) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude];
GVAR(MAX) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude];
};
{
2015-04-08 09:25:15 +00:00
GVAR(ENTRIES) set [_x, (GVAR(ENTRIES) select _x) + 1];
} forEach [0, 4, 5, 6 ,7];
// Direction
_playerDir = getDir ACE_player;
2015-04-08 09:25:15 +00:00
GVAR(MIN) set [0, (GVAR(MIN) select 0) min _playerDir];
GVAR(MAX) set [0, _playerDir max (GVAR(MAX) select 0)];
GVAR(TOTAL) set [0, (GVAR(TOTAL) select 0) + _playerDir];
2015-04-08 09:25:15 +00:00
if (GVAR(MinAvgMaxMode) == 1) then {
2015-04-07 18:19:35 +00:00
{
2015-04-08 09:25:15 +00:00
GVAR(ENTRIES) set [_x, (GVAR(ENTRIES) select _x) + 1];
2015-04-07 18:19:35 +00:00
} forEach [1, 2, 3];
2015-04-07 18:19:35 +00:00
// Wind SPD
2015-04-13 09:53:19 +00:00
_windSpeed = call FUNC(measureWindSpeed);
2015-04-08 09:25:15 +00:00
GVAR(MIN) set [1, (GVAR(MIN) select 1) min abs(_windSpeed)];
GVAR(MAX) set [1, abs(_windSpeed) max (GVAR(MAX) select 1)];
GVAR(TOTAL) set [1, (GVAR(TOTAL) select 1) + abs(_windSpeed)];
2015-04-07 18:19:35 +00:00
// CROSSWIND
2015-04-13 09:53:19 +00:00
_crosswind = 0;
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
_crosswind = abs(sin(GVAR(RefHeading) - _playerDir) * _windSpeed);
} else {
_crosswind = abs(sin(GVAR(RefHeading)) * _windSpeed);
};
2015-04-08 09:25:15 +00:00
GVAR(MIN) set [2, (GVAR(MIN) select 2) min _crosswind];
GVAR(MAX) set [2, _crosswind max (GVAR(MAX) select 2)];
GVAR(TOTAL) set [2, (GVAR(TOTAL) select 2) + _crosswind];
2015-04-07 18:19:35 +00:00
// HEADWIND
2015-04-13 09:53:19 +00:00
_headwind = 0;
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
_headwind = abs(cos(GVAR(RefHeading) - _playerDir) * _windSpeed);
} else {
_headwind = abs(cos(GVAR(RefHeading)) * _windSpeed);
};
2015-04-08 09:25:15 +00:00
GVAR(MIN) set [3, (GVAR(MIN) select 3) min _headwind];
GVAR(MAX) set [3, _headwind max (GVAR(MAX) select 3)];
GVAR(TOTAL) set [3, (GVAR(TOTAL) select 3) + _headwind];
};
// TEMP
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
2015-04-08 09:25:15 +00:00
GVAR(MIN) set [4, (GVAR(MIN) select 4) min _temperature];
GVAR(MAX) set [4, _temperature max (GVAR(MAX) select 4)];
GVAR(TOTAL) set [4, (GVAR(TOTAL) select 4) + _temperature];
// HUMIDITY
_humidity = EGVAR(weather,currentHumidity);
2015-04-08 09:25:15 +00:00
GVAR(MIN) set [5, (GVAR(MIN) select 5) min _humidity];
GVAR(MAX) set [5, _humidity max (GVAR(MAX) select 5)];
GVAR(TOTAL) set [5, (GVAR(TOTAL) select 5) + _humidity];
// BARO
_barometricPressure = ((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure);
2015-04-08 09:25:15 +00:00
GVAR(MIN) set [6, (GVAR(MIN) select 6) min _barometricPressure];
GVAR(MAX) set [6, _barometricPressure max (GVAR(MAX) select 6)];
GVAR(TOTAL) set [6, (GVAR(TOTAL) select 6) + _barometricPressure];
// ALTITUDE
_altitude = EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2);
2015-04-08 09:25:15 +00:00
GVAR(MIN) set [7, (GVAR(MIN) select 7) min _altitude];
GVAR(MAX) set [7, _altitude max (GVAR(MAX) select 7)];
GVAR(TOTAL) set [7, (GVAR(TOTAL) select 7) + _altitude];