ACE3/addons/weather/XEH_postInit.sqf

94 lines
3.0 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
// 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-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; };
"ACE_MISC_PARAMS" addPublicVariableEventHandler {
if (!isServer) then {
TRACE_1("MISC PARAMS PVEH",ACE_MISC_PARAMS);
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);
};
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);
};
};
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
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
simulWeatherSync;
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));
// update rain every frame:
2015-06-07 16:57:16 +00:00
if (GVAR(syncRain)) then {
addMissionEventHandler ["EachFrame", {0 setRain GVAR(ACE_rain)}];
2015-06-07 16:57:16 +00:00
};
//Create a 1 sec delay PFEH to update wind/rain/temp/humidity:
//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-03-02 10:01:39 +00:00
if (CBA_missionTime >= GVAR(nextUpdateRain)) then {
[] call FUNC(updateRain); //Every 2 seconds
2016-03-02 10:01:39 +00:00
GVAR(nextUpdateRain) = 2 + CBA_missionTime;
};
2016-03-02 10:01:39 +00:00
if (CBA_missionTime >= GVAR(nextUpdateTempAndHumidity)) then {
[] 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;
};
END_COUNTER(weatherPFEH);
}, 1, []] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler;