2015-01-20 23:18:40 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-20 11:54:22 +00:00
|
|
|
|
2015-04-25 16:56:55 +00:00
|
|
|
// Randomization
|
|
|
|
GVAR(temperatureShift) = 3 - random 6;
|
|
|
|
GVAR(badWeatherShift) = (random 1) ^ 2 * 10;
|
|
|
|
GVAR(humidityShift) = (5 - random 10) / 100;
|
|
|
|
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(wind_period_start_time) = CBA_missionTime;
|
|
|
|
GVAR(rain_period_start_time) = CBA_missionTime;
|
2015-04-20 11:54:22 +00:00
|
|
|
|
2015-06-07 16:57:16 +00:00
|
|
|
GVAR(ACE_rain) = rain;
|
|
|
|
|
2016-03-02 10:01:39 +00:00
|
|
|
"ACE_WIND_PARAMS" addPublicVariableEventHandler { GVAR(wind_period_start_time) = CBA_missionTime; };
|
|
|
|
"ACE_RAIN_PARAMS" addPublicVariableEventHandler { GVAR(rain_period_start_time) = CBA_missionTime; };
|
2015-01-21 03:00:06 +00:00
|
|
|
"ACE_MISC_PARAMS" addPublicVariableEventHandler {
|
2015-04-24 08:03:48 +00:00
|
|
|
if (!isServer) then {
|
2016-01-06 22:26:16 +00:00
|
|
|
TRACE_1("MISC PARAMS PVEH",ACE_MISC_PARAMS);
|
2015-04-24 08:03:48 +00:00
|
|
|
if (GVAR(syncMisc)) then {
|
|
|
|
30 setLightnings (ACE_MISC_PARAMS select 0);
|
|
|
|
30 setRainbow (ACE_MISC_PARAMS select 1);
|
|
|
|
30 setFog (ACE_MISC_PARAMS select 2);
|
|
|
|
};
|
2015-04-21 18:41:50 +00:00
|
|
|
GVAR(temperatureShift) = (ACE_MISC_PARAMS select 3);
|
|
|
|
GVAR(badWeatherShift) = (ACE_MISC_PARAMS select 4);
|
|
|
|
GVAR(humidityShift) = (ACE_MISC_PARAMS select 5);
|
|
|
|
call FUNC(updateTemperature);
|
|
|
|
call FUNC(updateHumidity);
|
2015-01-21 04:07:33 +00:00
|
|
|
};
|
2015-01-21 03:00:06 +00:00
|
|
|
};
|
2015-01-21 03:14:51 +00:00
|
|
|
|
2016-01-06 22:26:16 +00:00
|
|
|
GVAR(WindInfo) = false;
|
2016-06-07 00:22:53 +00:00
|
|
|
["ACE3 Common", QGVAR(WindInfoKey), localize LSTRING(WindInfoKeyToggle),
|
2015-04-06 03:02:34 +00:00
|
|
|
{
|
|
|
|
// Conditions: canInteract
|
2016-01-06 22:26:16 +00:00
|
|
|
if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
2015-04-06 03:02:34 +00:00
|
|
|
|
|
|
|
// Statement
|
|
|
|
[] call FUNC(displayWindInfo);
|
|
|
|
},
|
|
|
|
{false},
|
|
|
|
[37, [true, false, false]], false, 0] call CBA_fnc_addKeybind; // (SHIFT + K)
|
2016-06-07 00:22:53 +00:00
|
|
|
|
|
|
|
["ACE3 Common", QGVAR(WindInfoKey_hold), localize LSTRING(WindInfoKeyHold),
|
2016-05-06 17:47:59 +00:00
|
|
|
{
|
|
|
|
// Conditions: canInteract
|
|
|
|
if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
|
|
|
|
|
|
|
// Statement
|
|
|
|
[] call FUNC(displayWindInfo);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
GVAR(WindInfo) = false;
|
|
|
|
(["RscWindIntuitive"] call BIS_fnc_rscLayer) cutText ["", "PLAIN", 2];
|
|
|
|
},
|
|
|
|
[0, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // (empty default key)
|
2015-04-06 03:02:34 +00:00
|
|
|
|
2015-01-21 02:17:09 +00:00
|
|
|
simulWeatherSync;
|
2015-01-20 23:18:40 +00:00
|
|
|
|
2016-01-05 07:39:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-24 13:13:11 +00:00
|
|
|
["ace_settingsInitialized",{
|
2016-06-03 00:59:18 +00:00
|
|
|
TRACE_1("ace_settingsInitialized eh",GVAR(syncRain));
|
2016-01-06 22:26:16 +00:00
|
|
|
|
2017-05-10 16:28:26 +00:00
|
|
|
// update rain every frame:
|
2015-06-07 16:57:16 +00:00
|
|
|
if (GVAR(syncRain)) then {
|
2017-05-10 16:28:26 +00:00
|
|
|
addMissionEventHandler ["EachFrame", {0 setRain GVAR(ACE_rain)}];
|
2015-06-07 16:57:16 +00:00
|
|
|
};
|
2016-01-06 22:26:16 +00:00
|
|
|
|
|
|
|
//Create a 1 sec delay PFEH to update wind/rain/temp/humidity:
|
|
|
|
|
2016-01-05 07:39:29 +00:00
|
|
|
//If we don't sync rain, set next time to infinity
|
|
|
|
GVAR(nextUpdateRain) = if (GVAR(syncRain)) then {0} else {1e99};
|
|
|
|
GVAR(nextUpdateTempAndHumidity) = 0;
|
|
|
|
[{
|
|
|
|
BEGIN_COUNTER(weatherPFEH);
|
|
|
|
|
|
|
|
[] call FUNC(updateWind); //Every 1 second
|
2016-01-06 22:26:16 +00:00
|
|
|
|
2016-03-02 10:01:39 +00:00
|
|
|
if (CBA_missionTime >= GVAR(nextUpdateRain)) then {
|
2016-01-05 07:39:29 +00:00
|
|
|
[] call FUNC(updateRain); //Every 2 seconds
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(nextUpdateRain) = 2 + CBA_missionTime;
|
2016-01-05 07:39:29 +00:00
|
|
|
};
|
2016-03-02 10:01:39 +00:00
|
|
|
if (CBA_missionTime >= GVAR(nextUpdateTempAndHumidity)) then {
|
2016-01-05 07:39:29 +00:00
|
|
|
[] call FUNC(updateTemperature); //Every 20 seconds
|
|
|
|
[] call FUNC(updateHumidity); //Every 20 seconds
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(nextUpdateTempAndHumidity) = 20 + CBA_missionTime;
|
2016-01-05 07:39:29 +00:00
|
|
|
};
|
2016-01-06 22:26:16 +00:00
|
|
|
|
2016-01-05 07:39:29 +00:00
|
|
|
END_COUNTER(weatherPFEH);
|
|
|
|
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|