ACE3/addons/weather/functions/fnc_updateHumidity.sqf
ulteq cda060d3e0 Weather - Properly sync overcast value (#5688)
* Makes sure that all clients share the same (numeric) overcast value
* Only affects the barometric pressure calculation
* Does not affect the actual weather on the clients
2017-10-27 12:39:48 +02:00

35 lines
978 B
Plaintext

/*
* Author: ACE2 Team
* Updates GVAR(currentHumidity)
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_weather_fnc_updateHumidity
*
* Public: No
*/
#include "script_component.hpp"
private _month = date select 1;
GVAR(currentHumidity) = (GVAR(Humidity) select (_month - 1)) / 100;
if ((rain > 0) && {GVAR(currentOvercast) > 0.7}) then {
GVAR(currentHumidity) = 1;
} else {
private _avgTemperature = ((GVAR(TempDay) select (_month - 1)) + (GVAR(TempNight) select (_month - 1))) / 2;
private _pS1 = 6.112 * exp((17.62 * _avgTemperature) / (243.12 + _avgTemperature));
private _PS2 = 6.112 * exp((17.62 * GVAR(currentTemperature)) / (243.12 + GVAR(currentTemperature)));
GVAR(currentHumidity) = GVAR(currentHumidity) * _PS1 / _PS2;
GVAR(currentHumidity) = GVAR(currentHumidity) + GVAR(humidityShift);
TRACE_1("humidityShift",GVAR(humidityShift));
};
GVAR(currentHumidity) = 0 max GVAR(currentHumidity) min 1;