ACE3/addons/weather/XEH_postInit.sqf
jonpas 856ffb5579 Remove rain, lightnings and wind sync (#5622)
* Move ACE Weather rain simulation to server and remove sync (synced correctly by vanilla from server)

* Remove lightnings sync (synced correctly by vanilla, ACE3 doesn't have own lightnings probability)

* Cleanup rain and lightning settings, strings, comments

* Set wind only on server (correctly synced in vanilla, gusts and waves still need manual sync)
2017-10-17 20:19:30 +02:00

75 lines
2.3 KiB
Plaintext

#include "script_component.hpp"
// Randomization
GVAR(temperatureShift) = 3 - random 6;
GVAR(badWeatherShift) = (random 1) ^ 2 * 10;
GVAR(humidityShift) = (5 - random 10) / 100;
GVAR(wind_period_start_time) = CBA_missionTime;
"ACE_WIND_PARAMS" addPublicVariableEventHandler { GVAR(wind_period_start_time) = CBA_missionTime; };
if (!isServer) then {
"ACE_MISC_PARAMS" addPublicVariableEventHandler {
TRACE_1("MISC PARAMS PVEH",ACE_MISC_PARAMS);
if (GVAR(syncMisc)) then {
30 setRainbow (ACE_MISC_PARAMS select 0);
30 setFog (ACE_MISC_PARAMS select 1);
};
GVAR(temperatureShift) = (ACE_MISC_PARAMS select 2);
GVAR(badWeatherShift) = (ACE_MISC_PARAMS select 3);
GVAR(humidityShift) = (ACE_MISC_PARAMS select 4);
call FUNC(updateTemperature);
call FUNC(updateHumidity);
};
};
GVAR(WindInfo) = false;
["ACE3 Common", QGVAR(WindInfoKey), localize LSTRING(WindInfoKeyToggle),
{
// Conditions: canInteract
if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Statement
[] call FUNC(displayWindInfo);
},
{false},
[37, [true, false, false]], false, 0] call CBA_fnc_addKeybind; // (SHIFT + K)
["ACE3 Common", QGVAR(WindInfoKey_hold), localize LSTRING(WindInfoKeyHold),
{
// 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)
simulWeatherSync;
["ace_settingsInitialized",{
// Create a 1 sec delay PFEH to update wind/temp/humidity
GVAR(nextUpdateTempAndHumidity) = 0;
[{
BEGIN_COUNTER(weatherPFEH);
[] call FUNC(updateWind); //Every 1 second
if (CBA_missionTime >= GVAR(nextUpdateTempAndHumidity)) then {
[] call FUNC(updateTemperature); //Every 20 seconds
[] call FUNC(updateHumidity); //Every 20 seconds
GVAR(nextUpdateTempAndHumidity) = 20 + CBA_missionTime;
};
END_COUNTER(weatherPFEH);
}, 1, []] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler;