2015-01-20 23:18:40 +00:00
|
|
|
//XEH_postInit.sqf
|
|
|
|
//#define DEBUG_MODE_FULL
|
|
|
|
#include "script_component.hpp"
|
|
|
|
"ACE_WIND_PARAMS" addPublicVariableEventHandler { GVAR(wind_period_start_time) = time; };
|
|
|
|
"ACE_RAIN_PARAMS" addPublicVariableEventHandler { GVAR(rain_period_start_time) = time; };
|
2015-01-21 03:00:06 +00:00
|
|
|
"ACE_MISC_PARAMS" addPublicVariableEventHandler {
|
2015-01-21 04:07:33 +00:00
|
|
|
if !(isServer) then {
|
|
|
|
30 setLightnings (ACE_MISC_PARAMS select 0);
|
|
|
|
30 setRainbow (ACE_MISC_PARAMS select 1);
|
|
|
|
30 setFog (ACE_MISC_PARAMS select 2);
|
|
|
|
};
|
2015-01-21 03:00:06 +00:00
|
|
|
};
|
2015-01-21 03:14:51 +00:00
|
|
|
|
2015-04-06 03:02:34 +00:00
|
|
|
["ACE3", QGVAR(WindInfoKey), localize "STR_ACE_Weather_WindInfoKey",
|
|
|
|
{
|
|
|
|
// Conditions: canInteract
|
|
|
|
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
|
|
|
|
|
|
|
// Statement
|
|
|
|
[] call FUNC(displayWindInfo);
|
|
|
|
false
|
|
|
|
},
|
|
|
|
{false},
|
|
|
|
[37, [true, false, false]], false, 0] call CBA_fnc_addKeybind; // (SHIFT + K)
|
|
|
|
|
2015-01-21 03:14:51 +00:00
|
|
|
// Update Wind
|
2015-01-21 02:17:09 +00:00
|
|
|
simulWeatherSync;
|
|
|
|
_fnc_updateWind = {
|
2015-01-21 02:59:32 +00:00
|
|
|
ACE_wind = [] call FUNC(getWind);
|
|
|
|
setWind [ACE_wind select 0, ACE_wind select 1, true];
|
2015-01-21 02:17:09 +00:00
|
|
|
2 setGusts 0;
|
2015-01-21 02:30:49 +00:00
|
|
|
|
|
|
|
// Set waves: 0 when no wind, 1 when wind >= 16 m/s
|
2015-01-21 02:59:32 +00:00
|
|
|
1 setWaves (((vectorMagnitude ACE_wind) / 16.0) min 1.0);
|
2015-01-21 02:30:49 +00:00
|
|
|
|
2015-01-21 02:59:32 +00:00
|
|
|
//systemChat format ["w:%1 %2,ACE_w:%1 %2, w", [wind select 0, wind select 1, ACE_wind select 0, ACE_wind select 1]];
|
2015-01-20 23:18:40 +00:00
|
|
|
};
|
2015-01-21 02:17:09 +00:00
|
|
|
[_fnc_updateWind, 1, []] call CBA_fnc_addPerFrameHandler;
|
2015-01-20 23:18:40 +00:00
|
|
|
|
2015-01-21 03:14:51 +00:00
|
|
|
|
|
|
|
// Update Rain
|
2015-01-20 23:18:40 +00:00
|
|
|
_fnc_updateRain = {
|
|
|
|
if(GVAR(enableRain)) then {
|
|
|
|
if(!isNil "ACE_RAIN_PARAMS" && {!isNil QGVAR(rain_period_start_time)}) then {
|
|
|
|
_oldStrength = ACE_RAIN_PARAMS select 0;
|
|
|
|
_rainStrength = ACE_RAIN_PARAMS select 1;
|
|
|
|
_transitionTime = ACE_RAIN_PARAMS select 2;
|
|
|
|
_periodPosition = (time - GVAR(rain_period_start_time)) min _transitionTime;
|
|
|
|
_periodPercent = (_periodPosition/_transitionTime) min 1;
|
|
|
|
|
|
|
|
0 setRain ((_periodPercent*(_rainStrength-_oldStrength))+_oldStrength);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-01-21 03:14:51 +00:00
|
|
|
[_fnc_updateRain, 2, []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
|
2015-01-20 23:18:40 +00:00
|
|
|
|
2015-01-21 03:14:51 +00:00
|
|
|
// Update Temperature
|
|
|
|
_fnc_updateTemperature = {
|
2015-01-21 05:12:57 +00:00
|
|
|
_time = daytime;
|
|
|
|
_month = date select 1;
|
2015-01-21 03:14:51 +00:00
|
|
|
|
2015-01-21 05:12:57 +00:00
|
|
|
// Temperature
|
2015-01-21 03:14:51 +00:00
|
|
|
_hourlyCoef = -0.5 * sin(360 * ((3 + (date select 3))/24 + (date select 4)/1440));
|
|
|
|
|
2015-01-21 05:12:57 +00:00
|
|
|
GVAR(currentTemperature) = (GVAR(TempDay) select (_month - 1)) * (1 - _hourlyCoef) + (GVAR(TempNight) select (_month - 1)) * _hourlyCoef;
|
|
|
|
GVAR(currentTemperature) = GVAR(currentTemperature) + GVAR(currentTemperature) - 2 * humidity - 4 * overcast;
|
|
|
|
GVAR(currentTemperature) = round(GVAR(currentTemperature) * 10) / 10;
|
|
|
|
|
|
|
|
// Humidity
|
|
|
|
GVAR(currentHumidity) = (GVAR(Humidity) select _month) / 100;
|
|
|
|
|
|
|
|
if (rain > 0 && overcast > 0.7) then {
|
|
|
|
GVAR(currentHumidity) = 1;
|
|
|
|
} else {
|
|
|
|
_avgTemperature = ((GVAR(TempDay) select (_month - 1)) + (GVAR(TempNight) select (_month - 1))) / 2;
|
|
|
|
_pS1 = 6.112 * exp((17.62 * _avgTemperature) / (243.12 + _avgTemperature));
|
|
|
|
_PS2 = 6.112 * exp((17.62 * GVAR(currentTemperature)) / (243.12 + GVAR(currentTemperature)));
|
|
|
|
GVAR(currentHumidity) = GVAR(currentHumidity) * _PS1 / _PS2;
|
|
|
|
};
|
|
|
|
GVAR(currentHumidity) = 0 max GVAR(currentHumidity) min 1;
|
|
|
|
|
|
|
|
// @todo: take altitude and humidity into account
|
2015-01-21 03:14:51 +00:00
|
|
|
GVAR(currentRelativeDensity) = (273.15 + 20) / (273.15 + GVAR(currentTemperature));
|
|
|
|
};
|
2015-01-21 05:12:57 +00:00
|
|
|
[_fnc_updateTemperature, 20, []] call CBA_fnc_addPerFrameHandler;
|