diff --git a/addons/weather/CfgWorlds.hpp b/addons/weather/CfgWorlds.hpp index ed932654f7..1391468fd9 100644 --- a/addons/weather/CfgWorlds.hpp +++ b/addons/weather/CfgWorlds.hpp @@ -7,6 +7,22 @@ class CfgWorlds { ACE_TempNight[] = {4, 4, 6, 8, 13, 17, 20, 20, 16, 12, 8, 6}; // Source: http://www.weather-and-climate.com/average-monthly-Humidity-perc,Limnos,Greece ACE_Humidity[] = {78, 77, 78, 74, 71, 60, 59, 61, 65, 72, 79, 80}; + // Source: https://weatherspark.com/averages/32194/Lemnos-Limnos-North-Aegean-Islands-Greece + ACE_WindSpeedMax[] = {{8.8, 5.5}, {8.8, 5}, {8.6, 4.8}, {7.6, 3.4}, {7.0, 3.0}, {7.1, 3.0}, {7.5, 3.1}, {8.0, 3.2}, {7.6, 3.5}, {7.8, 4.6}, {7.9, 5.0}, {8.2, 5.5}}; + ACE_WindSpeedMean[] = {4.8, 4.9, 4.6, 4.1, 3.5, 3.5, 4.3, 4.4, 4.1, 4.5, 4.5, 5.0}; + ACE_WindSpeedMin[] = {{0.2, 5.0}, {0.1, 5.0}, {0.2, 4.3}, {0.0, 3.0}, {0.0, 2.1}, {0.0, 2.0}, {0.1, 3.1}, {0.3, 3.1}, {0.0, 3.6}, {0.0, 4.2}, {0.1, 5.0}, {0.2, 5.5}}; + ACE_WindDirectionProbabilities[] = {{0.06, 0.32, 0.05, 0.04, 0.15, 0.06, 0.02, 0.02}, // January + {0.08, 0.32, 0.04, 0.04, 0.18, 0.06, 0.02, 0.02}, // February + {0.09, 0.30, 0.04, 0.04, 0.20, 0.06, 0.02, 0.03}, // March + {0.10, 0.25, 0.03, 0.04, 0.22, 0.06, 0.02, 0.04}, // April + {0.18, 0.25, 0.03, 0.04, 0.18, 0.04, 0.01, 0.05}, // May + {0.25, 0.25, 0.03, 0.03, 0.15, 0.03, 0.00, 0.08}, // June + {0.32, 0.30, 0.02, 0.02, 0.10, 0.01, 0.00, 0.09}, // July + {0.28, 0.35, 0.02, 0.01, 0.08, 0.01, 0.00, 0.08}, // August + {0.20, 0.37, 0.03, 0.01, 0.11, 0.01, 0.01, 0.05}, // September + {0.10, 0.39, 0.04, 0.02, 0.15, 0.02, 0.01, 0.03}, // October + {0.08, 0.38, 0.06, 0.04, 0.19, 0.03, 0.02, 0.02}, // November + {0.06, 0.37, 0.05, 0.03, 0.18, 0.04, 0.02, 0.02}};// December }; class Altis: CAWorld { @@ -15,5 +31,21 @@ class CfgWorlds { ACE_TempNight[] = {4, 4, 6, 8, 13, 17, 20, 20, 16, 12, 8, 6}; // Source: http://www.weather-and-climate.com/average-monthly-Humidity-perc,Limnos,Greece ACE_Humidity[] = {78, 77, 78, 74, 71, 60, 59, 61, 65, 72, 79, 80}; + // Source: https://weatherspark.com/averages/32194/Lemnos-Limnos-North-Aegean-Islands-Greece + ACE_WindSpeedMax[] = {{8.8, 5.5}, {8.8, 5}, {8.6, 4.8}, {7.6, 3.4}, {7.0, 3.0}, {7.1, 3.0}, {7.5, 3.1}, {8.0, 3.2}, {7.6, 3.5}, {7.8, 4.6}, {7.9, 5.0}, {8.2, 5.5}}; + ACE_WindSpeedMean[] = {4.8, 4.9, 4.6, 4.1, 3.5, 3.5, 4.3, 4.4, 4.1, 4.5, 4.5, 5.0}; + ACE_WindSpeedMin[] = {{0.2, 5.0}, {0.1, 5.0}, {0.2, 4.3}, {0.0, 3.0}, {0.0, 2.1}, {0.0, 2.0}, {0.1, 3.1}, {0.3, 3.1}, {0.0, 3.6}, {0.0, 4.2}, {0.1, 5.0}, {0.2, 5.5}}; + ACE_WindDirectionProbabilities[] = {{0.06, 0.32, 0.05, 0.04, 0.15, 0.06, 0.02, 0.02}, // January + {0.08, 0.32, 0.04, 0.04, 0.18, 0.06, 0.02, 0.02}, // February + {0.09, 0.30, 0.04, 0.04, 0.20, 0.06, 0.02, 0.03}, // March + {0.10, 0.25, 0.03, 0.04, 0.22, 0.06, 0.02, 0.04}, // April + {0.18, 0.25, 0.03, 0.04, 0.18, 0.04, 0.01, 0.05}, // May + {0.25, 0.25, 0.03, 0.03, 0.15, 0.03, 0.00, 0.08}, // June + {0.32, 0.30, 0.02, 0.02, 0.10, 0.01, 0.00, 0.09}, // July + {0.28, 0.35, 0.02, 0.01, 0.08, 0.01, 0.00, 0.08}, // August + {0.20, 0.37, 0.03, 0.01, 0.11, 0.01, 0.01, 0.05}, // September + {0.10, 0.39, 0.04, 0.02, 0.15, 0.02, 0.01, 0.03}, // October + {0.08, 0.38, 0.06, 0.04, 0.19, 0.03, 0.02, 0.02}, // November + {0.06, 0.37, 0.05, 0.03, 0.18, 0.04, 0.02, 0.02}};// December }; -}; +}; \ No newline at end of file diff --git a/addons/weather/XEH_postInit.sqf b/addons/weather/XEH_postInit.sqf index e40a061aaf..04879971b4 100644 --- a/addons/weather/XEH_postInit.sqf +++ b/addons/weather/XEH_postInit.sqf @@ -1,35 +1,9 @@ #include "script_component.hpp" -// Rain variables GVAR(enableRain) = true; -GVAR(rain_next_period) = -1; -GVAR(rain_period_count) = 0; -GVAR(rain_initial_rain) = 0; -if(overcast >= 0.7) then { - GVAR(rain_initial_rain) = (random ((overcast-0.7)/0.3)); -}; -GVAR(current_rain) = GVAR(rain_initial_rain); -GVAR(rain_current_range) = -1+(random 2); -GVAR(overcast_multiplier) = 1; -// Wind Variables -ACE_wind = [0, 0, 0]; -GVAR(wind_initial_dir) = (random 360); -GVAR(wind_initial_speed) = (overcast*5)+(random (overcast*5)) max 1; -GVAR(wind_mean_speed) = GVAR(wind_initial_speed); -GVAR(wind_mean_dir) = GVAR(wind_initial_dir); -GVAR(wind_current_speed) = GVAR(wind_initial_speed); -GVAR(wind_current_dir) = GVAR(wind_initial_dir); -GVAR(wind_current_range_speed) = -1+(random 2); -GVAR(wind_current_range_dir) = -1+(random 2); -GVAR(wind_next_period) = -1; //ceil((2+random(5))/(GVAR(overcast_multiplier)/10)); -GVAR(wind_next_major_period) = -1; -GVAR(wind_period_count) = 0; -GVAR(wind_major_period_count) = 0; -GVAR(wind_total_time) = 0; GVAR(wind_period_start_time) = time; - -call FUNC(getMapData); +GVAR(rain_period_start_time) = time; "ACE_WIND_PARAMS" addPublicVariableEventHandler { GVAR(wind_period_start_time) = time; }; "ACE_RAIN_PARAMS" addPublicVariableEventHandler { GVAR(rain_period_start_time) = time; }; @@ -38,6 +12,11 @@ call FUNC(getMapData); 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); }; }; diff --git a/addons/weather/XEH_postServerInit.sqf b/addons/weather/XEH_postServerInit.sqf index cfe35e6009..67d536b996 100644 --- a/addons/weather/XEH_postServerInit.sqf +++ b/addons/weather/XEH_postServerInit.sqf @@ -1,3 +1,20 @@ #include "script_component.hpp" -[FUNC(serverController), 60] call cba_fnc_addPerFrameHandler; +// Randomization +GVAR(temperatureShift) = 3 - random 6; +GVAR(badWeatherShift) = (random 1) ^ 2 * 10; +GVAR(humidityShift) = (5 - random 10) / 100; + +// Rain +GVAR(rain_next_period) = -1; +GVAR(rain_period_count) = 0; +GVAR(current_rain) = 0; +GVAR(rain_current_range) = -1+(random 2); + +// Wind +call FUNC(initWind); + +GVAR(overcast_multiplier) = 1; +GVAR(serverUpdateInterval) = 60; + +[FUNC(serverController), GVAR(serverUpdateInterval)] call cba_fnc_addPerFrameHandler; diff --git a/addons/weather/XEH_preInit.sqf b/addons/weather/XEH_preInit.sqf index ee05983a69..70c9341d0f 100644 --- a/addons/weather/XEH_preInit.sqf +++ b/addons/weather/XEH_preInit.sqf @@ -8,10 +8,14 @@ PREP(calculateBarometricPressure); PREP(displayWindInfo); PREP(getMapData); PREP(getWind); +PREP(initWind); PREP(serverController); PREP(updateHumidity); PREP(updateRain); PREP(updateTemperature); PREP(updateWind); +// Make sure this data is read before client/server postInit +call FUNC(getMapData); + ADDON = true; diff --git a/addons/weather/functions/fnc_getMapData.sqf b/addons/weather/functions/fnc_getMapData.sqf index cb0a961c21..f2527d1157 100644 --- a/addons/weather/functions/fnc_getMapData.sqf +++ b/addons/weather/functions/fnc_getMapData.sqf @@ -35,6 +35,32 @@ if (worldName in ["Thirsk"]) then { GVAR(Latitude) = 65; GVAR(Altitude) = 0; }; if (worldName in ["lingor"]) then { GVAR(Latitude) = -4; GVAR(Altitude) = 0; }; if (worldName in ["Panthera3"]) then { GVAR(Latitude) = 46; GVAR(Altitude) = 0; }; +// Assume default wind values +// Source: https://weatherspark.com/averages/32194/Lemnos-Limnos-North-Aegean-Islands-Greece +GVAR(WindSpeedMax) = [[8.8, 5.5], [8.8, 5], [8.6, 4.8], [7.6, 3.4], [7.0, 3.0], [7.1, 3.0], [7.5, 3.1], [8.0, 3.2], [7.6, 3.5], [7.8, 4.6], [7.9, 5.0], [8.2, 5.5]]; +GVAR(WindSpeedMean) = [4.8, 4.9, 4.6, 4.1, 3.5, 3.5, 4.3, 4.4, 4.1, 4.5, 4.5, 5.0]; +GVAR(WindSpeedMin) = [[0.2, 5.0], [0.1, 5.0], [0.2, 4.3], [0.0, 3.0], [0.0, 2.1], [0.0, 2.0], [0.1, 3.1], [0.3, 3.1], [0.0, 3.6], [0.0, 4.2], [0.1, 5.0], [0.2, 5.5]]; +GVAR(WindDirectionProbabilities) = [[0.06, 0.32, 0.05, 0.04, 0.15, 0.06, 0.02, 0.02], // January + [0.08, 0.32, 0.04, 0.04, 0.18, 0.06, 0.02, 0.02], // February + [0.09, 0.30, 0.04, 0.04, 0.20, 0.06, 0.02, 0.03], // March + [0.10, 0.25, 0.03, 0.04, 0.22, 0.06, 0.02, 0.04], // April + [0.18, 0.25, 0.03, 0.04, 0.18, 0.04, 0.01, 0.05], // May + [0.25, 0.25, 0.03, 0.03, 0.15, 0.03, 0.00, 0.08], // June + [0.32, 0.30, 0.02, 0.02, 0.10, 0.01, 0.00, 0.09], // July + [0.28, 0.35, 0.02, 0.01, 0.08, 0.01, 0.00, 0.08], // August + [0.20, 0.37, 0.03, 0.01, 0.11, 0.01, 0.01, 0.05], // September + [0.10, 0.39, 0.04, 0.02, 0.15, 0.02, 0.01, 0.03], // October + [0.08, 0.38, 0.06, 0.04, 0.19, 0.03, 0.02, 0.02], // November + [0.06, 0.37, 0.05, 0.03, 0.18, 0.04, 0.02, 0.02]];// December + +// Check if the wind data is defined in the map config +if (isArray (configFile >> "CfgWorlds" >> worldName >> "ACE_WindSpeedMean")) then { + GVAR(WindSpeedMin) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_WindSpeedMin"); + GVAR(WindSpeedMean) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_WindSpeedMean"); + GVAR(WindSpeedMax) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_WindSpeedMax"); + GVAR(WindDirectionProbabilities) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_WindDirectionProbabilities"); +}; + // Check if the weather data is defined in the map config if (isArray (configFile >> "CfgWorlds" >> worldName >> "ACE_TempDay")) exitWith { GVAR(TempDay) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_TempDay"); @@ -112,4 +138,4 @@ GVAR(TempNight) = [-4, -3, 0, 4, 9, 12, 14, 14, 10, 6, 2, -2]; GVAR(Humidity) = [82, 80, 78, 70, 71, 72, 70, 73, 78, 80, 83, 82]; GVAR(currentTemperature) = 20; -GVAR(currentHumidity) = 0.5; +GVAR(currentHumidity) = 0.5; \ No newline at end of file diff --git a/addons/weather/functions/fnc_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index 54ec6efad3..95d97d98b3 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -10,25 +10,25 @@ * Wind */ #include "script_component.hpp" -private ["_dir","_dirInc","_dirRange","_period","_periodPercent","_periodPosition","_return","_spd","_spdInc","_spdRange"]; -_return = [0,0,0]; -if(!isNil "ACE_WIND_PARAMS") then { - _dir = ACE_WIND_PARAMS select 0; - _dirRange = (ACE_WIND_PARAMS select 1) - (ACE_WIND_PARAMS select 0); - _spd = ACE_WIND_PARAMS select 2; - _spdRange = (ACE_WIND_PARAMS select 3) - (ACE_WIND_PARAMS select 2); - _period = ACE_WIND_PARAMS select 4; +if (isNil "ACE_WIND_PARAMS") exitWith { [0, 0, 0] }; - _periodPosition = (time - GVAR(wind_period_start_time)) min _period; - _periodPercent = _periodPosition/_period; - _spdInc = _spdRange * _periodPercent; - _dirInc = _dirRange * _periodPercent; - _spd = (_spd + _spdInc); - _dir = _dir + _dirInc; - if (_dir > 360) then {_dir = _dir - 360}; - if (_dir < 0) then {_dir = _dir + 360}; +EXPLODE_5_PVT(ACE_WIND_PARAMS,_dir,_dirChange,_spd,_spdChange,_period); - _return = [_spd * sin _dir, _spd * cos _dir, 0]; -}; -_return; \ No newline at end of file +private ["_periodPercent", "_periodPosition"]; +_periodPosition = (time - GVAR(wind_period_start_time)) min _period; +_periodPercent = _periodPosition / _period; + +_spd = _spd + _spdChange * _periodPercent; +_dir = _dir + _dirChange * _periodPercent; + +_dir = (360 + _dir) % 360; + +TRACE_1("PeriodStartTime",Round(GVAR(wind_period_start_time))); +TRACE_2("Dir: Current/Change",Round(_dir),Round(_dirChange)); +TRACE_2("Spd: Current/Change",Round(_spd * 10) / 10,Round(_spdChange * 10) / 10); +TRACE_3("Period/Position/Percent",Round(_period),Round(_periodPosition),Round(_periodPercent * 100) / 100); + +// TODO: Add some deterministic noise + +[-_spd * sin(_dir), -_spd * cos(_dir), 0] diff --git a/addons/weather/functions/fnc_initWind.sqf b/addons/weather/functions/fnc_initWind.sqf new file mode 100644 index 0000000000..10b22efa2a --- /dev/null +++ b/addons/weather/functions/fnc_initWind.sqf @@ -0,0 +1,58 @@ +/* + * Author: Ruthberg + * + * Inits the wind variables on mission start + * + * Argument: + * None + * + * Return value: + * None + */ +#include "script_component.hpp" + +private ["_sum", "_rand", "_csum", "_index", "_month", "_windDirectionProbabilities"]; +_month = date select 1; +_windDirectionProbabilities = GVAR(WindDirectionProbabilities) select (_month - 1); + +ACE_wind = [0, 0, 0]; + +GVAR(wind_direction_reference) = random 360; +_sum = 0; +for "_i" from 0 to 7 do { + _sum = _sum + (_windDirectionProbabilities select _i); +}; +_rand = random _sum; +_csum = [0, 0, 0, 0, 0, 0, 0, 0]; +for "_i" from 0 to 7 do { + for "_j" from 0 to _i do { + _csum set [_i, (_csum select _i) + (_windDirectionProbabilities select _j)]; + }; +}; +_index = 0; +for "_i" from 0 to 7 do { + if (_rand > (_csum select _i)) then { + _index = _index + 1; + }; +}; +GVAR(wind_direction_reference) = 45 * _index; + +GVAR(wind_mean_dir) = GVAR(wind_direction_reference); +GVAR(wind_direction_reference) = GVAR(wind_direction_reference) + (random 22.5) - (random 22.5); +GVAR(wind_direction_reference) = (360 + GVAR(wind_direction_reference)) % 360; + +GVAR(min_wind_speed) = GVAR(WindSpeedMin) select (_month - 1); +GVAR(min_wind_speed) = (GVAR(min_wind_speed) select 0) + (random (GVAR(min_wind_speed) select 1)) - (random (GVAR(min_wind_speed) select 1)); +GVAR(min_wind_speed) = 0 max GVAR(min_wind_speed); +GVAR(mean_wind_speed) = GVAR(WindSpeedMean) select (_month - 1); +GVAR(max_wind_speed) = GVAR(WindSpeedMax) select (_month - 1); +GVAR(max_wind_speed) = (GVAR(max_wind_speed) select 0) + (random (GVAR(max_wind_speed) select 1)) - (random (GVAR(max_wind_speed) select 1)); +GVAR(max_wind_speed) = 0 max GVAR(max_wind_speed); + +GVAR(current_wind_direction) = GVAR(wind_direction_reference); +GVAR(current_wind_speed) = GVAR(min_wind_speed) + (GVAR(max_wind_speed) - GVAR(min_wind_speed)) * (random 1); + +GVAR(wind_period_count) = 0; +GVAR(wind_next_period) = -1; + +GVAR(wind_speed_debug_output) = []; diff --git a/addons/weather/functions/fnc_serverController.sqf b/addons/weather/functions/fnc_serverController.sqf index d7dff0eb70..33ac909868 100644 --- a/addons/weather/functions/fnc_serverController.sqf +++ b/addons/weather/functions/fnc_serverController.sqf @@ -1,7 +1,7 @@ /* - * Author: ACE2 Team, esteldunedain + * Author: ACE2 Team, esteldunedain, ruthberg * - * Calculate the wind and rain evolution on the server. Broadcast the current and next values to the clients + * Calculate the wind and rain evolution on the server. Broadcasts the current and next values to the clients * * Argument: * None @@ -10,7 +10,8 @@ * None */ #include "script_component.hpp" -private ["_gustCount","_gustDir","_gustSpeed","_gustTime","_gusts","_i","_lastRain","_maxInterval","_rainOverCast","_startDir","_startSpeed","_time","_timeTillGust","_transitionTime"]; + +private ["_i", "_lastRain", "_rainOverCast", "_transitionTime", "_windDirectionVariance", "_windSpeed", "_windSpeedChange", "_windMaxDiff", "_windMinDiff", "_windDirection", "_windDirectionChange", "_time"]; // Rain simulation if(GVAR(rain_period_count) > GVAR(rain_next_period)) then { @@ -44,56 +45,51 @@ if(GVAR(rain_period_count) > GVAR(rain_next_period)) then { // Wind simulation if(GVAR(wind_period_count) > GVAR(wind_next_period)) then { - _startDir = GVAR(wind_current_dir); - _startSpeed = GVAR(wind_current_speed); - GVAR(wind_current_dir) = (GVAR(wind_current_dir)+(((GVAR(wind_current_dir)))*((overcast*(GVAR(overcast_multiplier)))/8)*GVAR(wind_current_range_dir))); - - GVAR(wind_current_speed) = (GVAR(wind_current_speed)+(((GVAR(wind_current_speed)))*(overcast*(GVAR(overcast_multiplier))/12)*GVAR(wind_current_range_speed))); - GVAR(wind_current_speed) = GVAR(wind_current_speed) max 0.01; - - if(GVAR(wind_current_dir) < 0) then { - GVAR(wind_current_dir) = GVAR(wind_current_dir)+360; - }; - GVAR(wind_current_dir) = GVAR(wind_current_dir) % 360; - - GVAR(wind_current_range_speed) = (-1)+(random 2); - - GVAR(wind_current_range_dir) = (-1)+(random 2); - - GVAR(wind_next_period) = ceil((2+random(5))/(GVAR(overcast_multiplier))); + + GVAR(wind_next_period) = ceil((2 + (random 5)) / GVAR(overcast_multiplier)); GVAR(wind_period_count) = 0; - - _gustCount = floor(random(GVAR(wind_next_period)*(overcast*((GVAR(overcast_multiplier)^3))))); - - _time = GVAR(wind_next_period)*60; - _gusts = []; - if(_gustCount > 0) then { - _maxInterval = _time/_gustCount; - for "_i" from 0 to _gustCount-1 do { - _gustTime = (random (3 min _maxInterval)); - _timeTillGust = (_maxInterval*_i)+(random (_maxInterval - _gustTime)); - _gustSpeed = (random 1); - _gustDir = (GVAR(wind_current_dir)+(GVAR(wind_current_dir)*(-1+(random 2))))*(overcast*(GVAR(overcast_multiplier))); - _gusts set[(count _gusts), [_timeTillGust, _gustTime, _gustSpeed, _gustDir]]; - }; + + _windDirectionVariance = (90 - (random 180)) * (overcast ^ 2); + _windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360; + _windDirectionChange = _windDirection - GVAR(current_wind_direction); + if (_windDirectionChange > 180) then { + _windDirectionChange = _windDirectionChange - 360; }; - - GVAR(wind_total_time) = GVAR(wind_total_time) + GVAR(wind_next_period); - - ACE_WIND_PARAMS = [_startDir, - GVAR(wind_current_dir), - _startSpeed, - GVAR(wind_current_speed), - _time, - _gusts]; - + if (_windDirectionChange < -180) then { + _windDirectionChange = 360 + _windDirectionChange; + }; + + _windMaxDiff = GVAR(mean_wind_speed) - GVAR(max_wind_speed); + _windMinDiff = GVAR(min_wind_speed) - GVAR(mean_wind_speed); + + _ratioMax = (random 1) ^ 2; + _ratioMin = (random 1) ^ 2; + + _windSpeed = GVAR(mean_wind_speed) + _windMaxDiff * _ratioMax + _windMinDiff * _ratioMin; + _windSpeedChange = _windSpeed - GVAR(current_wind_speed); + + _time = GVAR(wind_next_period) * GVAR(serverUpdateInterval); + + TRACE_5("dirCur/dirNew/spdCur/spdNew/period",GVAR(current_wind_direction),_windDirection,GVAR(current_wind_speed),_windSpeed,_time); + + ACE_WIND_PARAMS = [GVAR(current_wind_direction), + _windDirectionChange, + GVAR(current_wind_speed), + _windSpeedChange, + _time]; + + GVAR(current_wind_direction) = _windDirection; + GVAR(current_wind_speed) = _windSpeed; + GVAR(wind_period_start_time) = time; publicVariable "ACE_WIND_PARAMS"; }; // Sync misc. parameters -ACE_MISC_PARAMS = [lightnings, rainbow, fogParams]; +ACE_MISC_PARAMS = [lightnings, rainbow, fogParams, GVAR(temperatureShift), GVAR(badWeatherShift), GVAR(humidityShift)]; publicVariable "ACE_MISC_PARAMS"; GVAR(rain_period_count) = GVAR(rain_period_count) + 1; -GVAR(wind_period_count) = GVAR(wind_period_count) + 1; \ No newline at end of file +GVAR(wind_period_count) = GVAR(wind_period_count) + 1; + +GVAR(overcast_multiplier) = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1) \ No newline at end of file diff --git a/addons/weather/functions/fnc_updateHumidity.sqf b/addons/weather/functions/fnc_updateHumidity.sqf index e3ba7a0224..dce031b3f3 100644 --- a/addons/weather/functions/fnc_updateHumidity.sqf +++ b/addons/weather/functions/fnc_updateHumidity.sqf @@ -23,6 +23,9 @@ if (rain > 0 && overcast > 0.7) then { _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) = GVAR(currentHumidity) + GVAR(humidityShift); + + TRACE_1("humidityShift",GVAR(humidityShift)); }; GVAR(currentHumidity) = 0 max GVAR(currentHumidity) min 1; diff --git a/addons/weather/functions/fnc_updateTemperature.sqf b/addons/weather/functions/fnc_updateTemperature.sqf index 5e342ad83d..870d00333c 100644 --- a/addons/weather/functions/fnc_updateTemperature.sqf +++ b/addons/weather/functions/fnc_updateTemperature.sqf @@ -18,5 +18,7 @@ _month = date select 1; _hourlyCoef = -0.5 * sin(360 * ((3 + (date select 3))/24 + (date select 4)/1440)); GVAR(currentTemperature) = (GVAR(TempDay) select (_month - 1)) * (1 - _hourlyCoef) + (GVAR(TempNight) select (_month - 1)) * _hourlyCoef; -GVAR(currentTemperature) = GVAR(currentTemperature) - 2 * humidity - 4 * overcast; +GVAR(currentTemperature) = GVAR(currentTemperature) + GVAR(temperatureShift) - GVAR(badWeatherShift) * overcast; GVAR(currentTemperature) = round(GVAR(currentTemperature) * 10) / 10; + +TRACE_2("temperatureShift/badWeatherShift",GVAR(temperatureShift),GVAR(badWeatherShift));