From 9155056a501456030ca71d3cd7f642f33f53fcbd Mon Sep 17 00:00:00 2001 From: ulteq Date: Mon, 20 Apr 2015 15:11:14 +0200 Subject: [PATCH 01/12] Proof of concept wind code (custom debug output enabled) --- addons/weather/functions/fnc_getWind.sqf | 66 +++++++++++++++------ addons/weather/functions/fnc_updateWind.sqf | 2 +- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/addons/weather/functions/fnc_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index 54ec6efad3..9163d7e854 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -10,25 +10,53 @@ * 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; +// Source: https://weatherspark.com/averages/32194/Lemnos-Limnos-North-Aegean-Islands-Greece +_AB_Wind_Speed_Max = [[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]]; +_AB_Wind_Speed_Mean = [4.8, 4.9, 4.6, 4.1, 3.5, 3.5, 4.3, 4.4, 4.1, 4.5, 4.5, 5.0]; +_AB_Wind_Speed_Min = [[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]]; +_AB_Wind_Direction_Probabilities = [[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 + +_PI = 3.14159265; +_c1 = 0.2 + random 0.2; +_c2 = 0.3 + random 0.2; +_c3 = 0.5 + random 0.2; +_c4 = 0.7 + random 0.2; - _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}; - - _return = [_spd * sin _dir, _spd * cos _dir, 0]; +_month = date select 1; +_windDirectionProbabilities = _AB_Wind_Direction_Probabilities select (_month - 1); +while {isNil QGVAR(windDirection)} do { + _random = random 1; + for "_i" from 0 to 7 do { + if (_random < (_windDirectionProbabilities select _i)) exitWith { + GVAR(windDirection) = 45 * _i; + }; + }; + GVAR(windDirection) = GVAR(windDirection) + (random 22.5) - (random 22.5); }; -_return; \ No newline at end of file + +_min = _AB_Wind_Speed_Min select (_month - 1); +_min = (_min select 0) + (random (_min select 1)) - (random (_min select 1)); +_min = 0 max _min; +_max = _AB_Wind_Speed_Max select (_month - 1); +_max = (_max select 0) + (random (_max select 1)) - (random (_max select 1)); +_max = 0 max _max; + +_x = time * 180 / _PI; +_ratio = 0 max ((1 + _c1 * sin(_x/1.5) + _c2 * sin(_x/3) + _c3 * sin(_x/12) + _c4 * sin(_x/18)) / (1 + _c1 + _c2 + _c3 + _c4)); +_windSpeed = _min + (_max - _min) * _ratio; + +systemChat format["Speed: %1, Direction: %2", _windSpeed, GVAR(windDirection)]; + +[-1 * sin(GVAR(windDirection)) * _windSpeed, -1 * cos(GVAR(windDirection)) * _windSpeed, 0] diff --git a/addons/weather/functions/fnc_updateWind.sqf b/addons/weather/functions/fnc_updateWind.sqf index e5a52348a8..7c79da0069 100644 --- a/addons/weather/functions/fnc_updateWind.sqf +++ b/addons/weather/functions/fnc_updateWind.sqf @@ -18,4 +18,4 @@ setWind [ACE_wind select 0, ACE_wind select 1, true]; // Set waves: 0 when no wind, 1 when wind >= 16 m/s 1 setWaves (((vectorMagnitude ACE_wind) / 16.0) min 1.0); -//hintSilent format["Wind: %1\nACE_wind: %2\nDeviation: %3 (m/s)", wind, ACE_wind, Round((vectorMagnitude (ACE_wind vectorDiff wind)) * 1000) / 1000]; +hintSilent format["Wind: %1\nACE_wind: %2\nDeviation: %3 (m/s)", wind, ACE_wind, Round((vectorMagnitude (ACE_wind vectorDiff wind)) * 1000) / 1000]; From 8aa69663d6413358be02c2f29bbb3746c9112a4b Mon Sep 17 00:00:00 2001 From: ulteq Date: Mon, 20 Apr 2015 16:01:13 +0200 Subject: [PATCH 02/12] More WIP --- addons/weather/functions/fnc_getWind.sqf | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/weather/functions/fnc_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index 9163d7e854..6a077d86af 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -46,16 +46,18 @@ while {isNil QGVAR(windDirection)} do { GVAR(windDirection) = GVAR(windDirection) + (random 22.5) - (random 22.5); }; -_min = _AB_Wind_Speed_Min select (_month - 1); -_min = (_min select 0) + (random (_min select 1)) - (random (_min select 1)); -_min = 0 max _min; -_max = _AB_Wind_Speed_Max select (_month - 1); -_max = (_max select 0) + (random (_max select 1)) - (random (_max select 1)); -_max = 0 max _max; +if (isNil QGVAR(minWindSpeed) || isNil QGVAR(maxWindSpeed)) then { + GVAR(minWindSpeed) = _AB_Wind_Speed_Min select (_month - 1); + GVAR(minWindSpeed) = (GVAR(minWindSpeed) select 0) + (random (GVAR(minWindSpeed) select 1)) - (random (GVAR(minWindSpeed) select 1)); + GVAR(minWindSpeed) = 0 max GVAR(minWindSpeed); + GVAR(maxWindSpeed) = _AB_Wind_Speed_Max select (_month - 1); + GVAR(maxWindSpeed) = (GVAR(maxWindSpeed) select 0) + (random (GVAR(maxWindSpeed) select 1)) - (random (GVAR(maxWindSpeed) select 1)); + GVAR(maxWindSpeed) = 0 max GVAR(maxWindSpeed); +}; _x = time * 180 / _PI; _ratio = 0 max ((1 + _c1 * sin(_x/1.5) + _c2 * sin(_x/3) + _c3 * sin(_x/12) + _c4 * sin(_x/18)) / (1 + _c1 + _c2 + _c3 + _c4)); -_windSpeed = _min + (_max - _min) * _ratio; +_windSpeed = GVAR(minWindSpeed) + (GVAR(maxWindSpeed) - GVAR(minWindSpeed)) * _ratio; systemChat format["Speed: %1, Direction: %2", _windSpeed, GVAR(windDirection)]; From ac74e6c6110902a71ab60eba2cc20cedcb8bcd00 Mon Sep 17 00:00:00 2001 From: ulteq Date: Mon, 20 Apr 2015 16:33:36 +0200 Subject: [PATCH 03/12] More WIP --- addons/weather/functions/fnc_getWind.sqf | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/addons/weather/functions/fnc_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index 6a077d86af..5b0f1bfd79 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -36,14 +36,15 @@ _c4 = 0.7 + random 0.2; _month = date select 1; _windDirectionProbabilities = _AB_Wind_Direction_Probabilities select (_month - 1); -while {isNil QGVAR(windDirection)} do { +while {isNil QGVAR(windDirectionReference)} do { _random = random 1; for "_i" from 0 to 7 do { if (_random < (_windDirectionProbabilities select _i)) exitWith { - GVAR(windDirection) = 45 * _i; + GVAR(windDirectionReference) = 45 * _i; }; }; - GVAR(windDirection) = GVAR(windDirection) + (random 22.5) - (random 22.5); + GVAR(windDirectionReference) = GVAR(windDirectionReference) + (random 22.5) - (random 22.5); + GVAR(windDirectionVariance) = (random 10) - (random 10); }; if (isNil QGVAR(minWindSpeed) || isNil QGVAR(maxWindSpeed)) then { @@ -55,10 +56,19 @@ if (isNil QGVAR(minWindSpeed) || isNil QGVAR(maxWindSpeed)) then { GVAR(maxWindSpeed) = 0 max GVAR(maxWindSpeed); }; +if ((random 30) < 1) then { + GVAR(windDirectionVariance) = (random 10) - (random 10); +}; +_windDirection = GVAR(windDirectionReference) + GVAR(windDirectionVariance); + _x = time * 180 / _PI; _ratio = 0 max ((1 + _c1 * sin(_x/1.5) + _c2 * sin(_x/3) + _c3 * sin(_x/12) + _c4 * sin(_x/18)) / (1 + _c1 + _c2 + _c3 + _c4)); _windSpeed = GVAR(minWindSpeed) + (GVAR(maxWindSpeed) - GVAR(minWindSpeed)) * _ratio; -systemChat format["Speed: %1, Direction: %2", _windSpeed, GVAR(windDirection)]; +systemChat " "; +systemChat format["(Min/Current/Max) : (%1/%2/%3)", Round(GVAR(minWindSpeed) * 10) / 10, Round(_windSpeed * 10) / 10, Round(GVAR(maxWindSpeed) * 10) / 10]; +systemChat format["(Reference/Current/Variance):(%1/%2/%3)", Round(GVAR(windDirectionReference)), Round(_windDirection), Round(GVAR(windDirectionVariance))]; +systemChat " "; +systemChat " "; -[-1 * sin(GVAR(windDirection)) * _windSpeed, -1 * cos(GVAR(windDirection)) * _windSpeed, 0] +[-1 * sin(_windDirection) * _windSpeed, -1 * cos(_windDirection) * _windSpeed, 0] From af4fdda477cbf305fc06f7c76dfae33f7eb83a19 Mon Sep 17 00:00:00 2001 From: ulteq Date: Tue, 21 Apr 2015 20:20:05 +0200 Subject: [PATCH 04/12] Continued work on the new wind system: * Moved the wind data into CfgWorlds.hpp * Modified the contents of ACE_WIND_PARAMS * new getWind function for the clients * new wind init based on the real world weather data --- addons/weather/CfgWorlds.hpp | 34 ++++++++- addons/weather/XEH_postInit.sqf | 20 +----- addons/weather/XEH_preInit.sqf | 1 + addons/weather/functions/fnc_getMapData.sqf | 22 ++++++ addons/weather/functions/fnc_getWind.sqf | 65 ++++------------- addons/weather/functions/fnc_initWind.sqf | 48 +++++++++++++ .../functions/fnc_serverController.sqf | 71 +++++++------------ 7 files changed, 146 insertions(+), 115 deletions(-) create mode 100644 addons/weather/functions/fnc_initWind.sqf 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..59a83b2a85 100644 --- a/addons/weather/XEH_postInit.sqf +++ b/addons/weather/XEH_postInit.sqf @@ -1,5 +1,7 @@ #include "script_component.hpp" +call FUNC(getMapData); + // Rain variables GVAR(enableRain) = true; GVAR(rain_next_period) = -1; @@ -13,23 +15,7 @@ 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); +call FUNC(initWind); "ACE_WIND_PARAMS" addPublicVariableEventHandler { GVAR(wind_period_start_time) = time; }; "ACE_RAIN_PARAMS" addPublicVariableEventHandler { GVAR(rain_period_start_time) = time; }; diff --git a/addons/weather/XEH_preInit.sqf b/addons/weather/XEH_preInit.sqf index ee05983a69..1d6b12ee60 100644 --- a/addons/weather/XEH_preInit.sqf +++ b/addons/weather/XEH_preInit.sqf @@ -8,6 +8,7 @@ PREP(calculateBarometricPressure); PREP(displayWindInfo); PREP(getMapData); PREP(getWind); +PREP(initWind); PREP(serverController); PREP(updateHumidity); PREP(updateRain); diff --git a/addons/weather/functions/fnc_getMapData.sqf b/addons/weather/functions/fnc_getMapData.sqf index cb0a961c21..2cfcb34a3f 100644 --- a/addons/weather/functions/fnc_getMapData.sqf +++ b/addons/weather/functions/fnc_getMapData.sqf @@ -40,6 +40,11 @@ if (isArray (configFile >> "CfgWorlds" >> worldName >> "ACE_TempDay")) exitWith GVAR(TempDay) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_TempDay"); GVAR(TempNight) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_TempNight"); GVAR(Humidity) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_Humidity"); + + 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 map is among the most popular @@ -113,3 +118,20 @@ GVAR(Humidity) = [82, 80, 78, 70, 71, 72, 70, 73, 78, 80, 83, 82]; GVAR(currentTemperature) = 20; GVAR(currentHumidity) = 0.5; + +// 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 \ No newline at end of file diff --git a/addons/weather/functions/fnc_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index 5b0f1bfd79..c0770b6191 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -11,64 +11,25 @@ */ #include "script_component.hpp" -// Source: https://weatherspark.com/averages/32194/Lemnos-Limnos-North-Aegean-Islands-Greece -_AB_Wind_Speed_Max = [[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]]; -_AB_Wind_Speed_Mean = [4.8, 4.9, 4.6, 4.1, 3.5, 3.5, 4.3, 4.4, 4.1, 4.5, 4.5, 5.0]; -_AB_Wind_Speed_Min = [[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]]; -_AB_Wind_Direction_Probabilities = [[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 - -_PI = 3.14159265; -_c1 = 0.2 + random 0.2; -_c2 = 0.3 + random 0.2; -_c3 = 0.5 + random 0.2; -_c4 = 0.7 + random 0.2; +if (isNil "ACE_WIND_PARAMS") exitWith { [0, 0, 0] }; -_month = date select 1; -_windDirectionProbabilities = _AB_Wind_Direction_Probabilities select (_month - 1); -while {isNil QGVAR(windDirectionReference)} do { - _random = random 1; - for "_i" from 0 to 7 do { - if (_random < (_windDirectionProbabilities select _i)) exitWith { - GVAR(windDirectionReference) = 45 * _i; - }; - }; - GVAR(windDirectionReference) = GVAR(windDirectionReference) + (random 22.5) - (random 22.5); - GVAR(windDirectionVariance) = (random 10) - (random 10); -}; +private ["_period", "_periodPosition", "_x", "_ratio", "_windSpeed"]; -if (isNil QGVAR(minWindSpeed) || isNil QGVAR(maxWindSpeed)) then { - GVAR(minWindSpeed) = _AB_Wind_Speed_Min select (_month - 1); - GVAR(minWindSpeed) = (GVAR(minWindSpeed) select 0) + (random (GVAR(minWindSpeed) select 1)) - (random (GVAR(minWindSpeed) select 1)); - GVAR(minWindSpeed) = 0 max GVAR(minWindSpeed); - GVAR(maxWindSpeed) = _AB_Wind_Speed_Max select (_month - 1); - GVAR(maxWindSpeed) = (GVAR(maxWindSpeed) select 0) + (random (GVAR(maxWindSpeed) select 1)) - (random (GVAR(maxWindSpeed) select 1)); - GVAR(maxWindSpeed) = 0 max GVAR(maxWindSpeed); -}; +EXPLODE_8_PVT(ACE_WIND_PARAMS,_windDirection,_min_wind_speed,_max_wind_speed,_c1,_c2,_c3,_c4,_period); -if ((random 30) < 1) then { - GVAR(windDirectionVariance) = (random 10) - (random 10); -}; -_windDirection = GVAR(windDirectionReference) + GVAR(windDirectionVariance); +_periodPosition = (time - GVAR(wind_period_start_time)) min _period; +_x = _periodPosition * 57.29577958; // time * (180 / PI) +_ratio = 0.5 + (_c1 * sin(_x/1.5) + _c2 * sin(_x/3) + _c3 * sin(_x/12) + _c4 * sin(_x/18)) / (2 * (_c1 + _c2 + _c3 + _c4)); +_windSpeed = _min_wind_speed + (_max_wind_speed - _min_wind_speed) * _ratio; -_x = time * 180 / _PI; -_ratio = 0 max ((1 + _c1 * sin(_x/1.5) + _c2 * sin(_x/3) + _c3 * sin(_x/12) + _c4 * sin(_x/18)) / (1 + _c1 + _c2 + _c3 + _c4)); -_windSpeed = GVAR(minWindSpeed) + (GVAR(maxWindSpeed) - GVAR(minWindSpeed)) * _ratio; +//GVAR(wind_speed_debug_output) pushBack _windspeed; +//copyToClipboard Str(GVAR(wind_speed_debug_output)); systemChat " "; -systemChat format["(Min/Current/Max) : (%1/%2/%3)", Round(GVAR(minWindSpeed) * 10) / 10, Round(_windSpeed * 10) / 10, Round(GVAR(maxWindSpeed) * 10) / 10]; -systemChat format["(Reference/Current/Variance):(%1/%2/%3)", Round(GVAR(windDirectionReference)), Round(_windDirection), Round(GVAR(windDirectionVariance))]; -systemChat " "; +systemChat format["(Min/Current/Max) : (%1/%2/%3)", Round(_min_wind_speed * 10) / 10, Round(_windSpeed * 10) / 10, Round(_max_wind_speed * 10) / 10]; +systemChat format["Direction: %1", Round(_windDirection)]; +systemChat format["(Period/PeriodPosition) : (%1/%2)", Round(_period), Round(_periodPosition)]; +systemChat format["Ratio: %1", _ratio]; systemChat " "; [-1 * sin(_windDirection) * _windSpeed, -1 * cos(_windDirection) * _windSpeed, 0] diff --git a/addons/weather/functions/fnc_initWind.sqf b/addons/weather/functions/fnc_initWind.sqf new file mode 100644 index 0000000000..f0db616c04 --- /dev/null +++ b/addons/weather/functions/fnc_initWind.sqf @@ -0,0 +1,48 @@ +/* + * Author: Ruthberg + * + * Inits the wind variables on mission start + * + * Argument: + * None + * + * Return value: + * None + */ +#include "script_component.hpp" + +private ["_j", "_i", "_month", "_windDirectionProbabilities"]; +_month = date select 1; +_windDirectionProbabilities = GVAR(WindDirectionProbabilities) select (_month - 1); + +ACE_wind = [0, 0, 0]; + +GVAR(wind_direction_reference) = random 360; +for "_j" from 0 to 10 do { + _random = random 1; + for "_i" from 0 to 7 do { + if (_random < (_windDirectionProbabilities select _i)) exitWith { + GVAR(wind_direction_reference) = 45 * _i; + }; + }; + if (_i < 7) exitWith {}; +}; +GVAR(wind_mean_dir) = GVAR(wind_direction_reference); +GVAR(wind_direction_reference) = GVAR(wind_direction_reference) + (random 22.5) - (random 22.5); + +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(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(c1) = 0.1 + random 0.1; +GVAR(c2) = 0.2 + random 0.1; +GVAR(c3) = 0.5 + random 0.2; +GVAR(c4) = 0.7 + random 0.2; + +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..878f0bc241 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", "_windDirection", "_time", "_c1", "_c2", "_c3", "_c4"]; // Rain simulation if(GVAR(rain_period_count) > GVAR(rain_next_period)) then { @@ -44,49 +45,29 @@ 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]]; - }; - }; - - 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]; - + + _windDirectionVariance = (90 - (random 180)) * overcast; + _windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360; + + _c1 = (0.1 + random 0.1) * overcast; + _c2 = (0.2 + random 0.1) * overcast; + _c3 = (0.5 + random 0.2); + _c4 = (0.7 + random 0.2); + + _time = GVAR(wind_next_period) * 60; + + ACE_WIND_PARAMS = [_windDirection, + GVAR(min_wind_speed), + GVAR(max_wind_speed), + _c1, + _c2, + _c3, + _c4, + _time]; + GVAR(wind_period_start_time) = time; publicVariable "ACE_WIND_PARAMS"; }; From 30d1b1b5e5c1804ae04bae21a6df9ddee9c98038 Mon Sep 17 00:00:00 2001 From: ulteq Date: Tue, 21 Apr 2015 20:20:22 +0200 Subject: [PATCH 05/12] Fixed a typo in the updateTemperature function --- addons/weather/functions/fnc_updateTemperature.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/weather/functions/fnc_updateTemperature.sqf b/addons/weather/functions/fnc_updateTemperature.sqf index 5e342ad83d..3a25a7bc52 100644 --- a/addons/weather/functions/fnc_updateTemperature.sqf +++ b/addons/weather/functions/fnc_updateTemperature.sqf @@ -18,5 +18,5 @@ _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) - 2 * GVAR(currentHumidity) - 4 * overcast; GVAR(currentTemperature) = round(GVAR(currentTemperature) * 10) / 10; From 428baefc2c9291853a32dd8614fa379cff859196 Mon Sep 17 00:00:00 2001 From: ulteq Date: Tue, 21 Apr 2015 20:41:50 +0200 Subject: [PATCH 06/12] Added random temperatureShift, badWeatherShift, humidityShift --- addons/weather/XEH_postInit.sqf | 10 ++++++++++ addons/weather/functions/fnc_serverController.sqf | 2 +- addons/weather/functions/fnc_updateHumidity.sqf | 1 + addons/weather/functions/fnc_updateTemperature.sqf | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/weather/XEH_postInit.sqf b/addons/weather/XEH_postInit.sqf index 59a83b2a85..6c287c3a8a 100644 --- a/addons/weather/XEH_postInit.sqf +++ b/addons/weather/XEH_postInit.sqf @@ -2,6 +2,11 @@ call FUNC(getMapData); +// Randomization +GVAR(temperatureShift) = 3 - random 6; +GVAR(badWeatherShift) = (random 1) ^ 2 * 10; +GVAR(humidityShift) = (5 - random 10) / 100; + // Rain variables GVAR(enableRain) = true; GVAR(rain_next_period) = -1; @@ -24,6 +29,11 @@ call FUNC(initWind); 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/functions/fnc_serverController.sqf b/addons/weather/functions/fnc_serverController.sqf index 878f0bc241..cc96ccdf41 100644 --- a/addons/weather/functions/fnc_serverController.sqf +++ b/addons/weather/functions/fnc_serverController.sqf @@ -73,7 +73,7 @@ if(GVAR(wind_period_count) > GVAR(wind_next_period)) then { }; // 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; diff --git a/addons/weather/functions/fnc_updateHumidity.sqf b/addons/weather/functions/fnc_updateHumidity.sqf index e3ba7a0224..07edec1854 100644 --- a/addons/weather/functions/fnc_updateHumidity.sqf +++ b/addons/weather/functions/fnc_updateHumidity.sqf @@ -23,6 +23,7 @@ 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); }; 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 3a25a7bc52..d66a9b28f4 100644 --- a/addons/weather/functions/fnc_updateTemperature.sqf +++ b/addons/weather/functions/fnc_updateTemperature.sqf @@ -18,5 +18,5 @@ _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 * GVAR(currentHumidity) - 4 * overcast; +GVAR(currentTemperature) = GVAR(currentTemperature) + GVAR(temperatureShift) - GVAR(badWeatherShift) * overcast; GVAR(currentTemperature) = round(GVAR(currentTemperature) * 10) / 10; From 1db9f055e26dabffa250d1b1966b286d575d8616 Mon Sep 17 00:00:00 2001 From: ulteq Date: Tue, 21 Apr 2015 20:54:47 +0200 Subject: [PATCH 07/12] Removed debug output --- addons/weather/functions/fnc_getWind.sqf | 4 ++-- addons/weather/functions/fnc_updateWind.sqf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/weather/functions/fnc_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index c0770b6191..7ce9d76722 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -24,12 +24,12 @@ _windSpeed = _min_wind_speed + (_max_wind_speed - _min_wind_speed) * _ratio; //GVAR(wind_speed_debug_output) pushBack _windspeed; //copyToClipboard Str(GVAR(wind_speed_debug_output)); - +/* systemChat " "; systemChat format["(Min/Current/Max) : (%1/%2/%3)", Round(_min_wind_speed * 10) / 10, Round(_windSpeed * 10) / 10, Round(_max_wind_speed * 10) / 10]; systemChat format["Direction: %1", Round(_windDirection)]; systemChat format["(Period/PeriodPosition) : (%1/%2)", Round(_period), Round(_periodPosition)]; systemChat format["Ratio: %1", _ratio]; systemChat " "; - +*/ [-1 * sin(_windDirection) * _windSpeed, -1 * cos(_windDirection) * _windSpeed, 0] diff --git a/addons/weather/functions/fnc_updateWind.sqf b/addons/weather/functions/fnc_updateWind.sqf index 7c79da0069..e5a52348a8 100644 --- a/addons/weather/functions/fnc_updateWind.sqf +++ b/addons/weather/functions/fnc_updateWind.sqf @@ -18,4 +18,4 @@ setWind [ACE_wind select 0, ACE_wind select 1, true]; // Set waves: 0 when no wind, 1 when wind >= 16 m/s 1 setWaves (((vectorMagnitude ACE_wind) / 16.0) min 1.0); -hintSilent format["Wind: %1\nACE_wind: %2\nDeviation: %3 (m/s)", wind, ACE_wind, Round((vectorMagnitude (ACE_wind vectorDiff wind)) * 1000) / 1000]; +//hintSilent format["Wind: %1\nACE_wind: %2\nDeviation: %3 (m/s)", wind, ACE_wind, Round((vectorMagnitude (ACE_wind vectorDiff wind)) * 1000) / 1000]; From d7f67970a41a160ba7df79f3ad7c86a4fa0041da Mon Sep 17 00:00:00 2001 From: ulteq Date: Tue, 21 Apr 2015 20:55:04 +0200 Subject: [PATCH 08/12] Fixed a bug in the wind direction init code --- addons/weather/functions/fnc_initWind.sqf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/weather/functions/fnc_initWind.sqf b/addons/weather/functions/fnc_initWind.sqf index f0db616c04..555ec928f4 100644 --- a/addons/weather/functions/fnc_initWind.sqf +++ b/addons/weather/functions/fnc_initWind.sqf @@ -11,21 +11,23 @@ */ #include "script_component.hpp" -private ["_j", "_i", "_month", "_windDirectionProbabilities"]; +private ["_j", "_i", "_directionFound", "_month", "_windDirectionProbabilities"]; _month = date select 1; _windDirectionProbabilities = GVAR(WindDirectionProbabilities) select (_month - 1); ACE_wind = [0, 0, 0]; GVAR(wind_direction_reference) = random 360; +_directionFound = false; for "_j" from 0 to 10 do { _random = random 1; for "_i" from 0 to 7 do { if (_random < (_windDirectionProbabilities select _i)) exitWith { + _directionFound = true; GVAR(wind_direction_reference) = 45 * _i; }; }; - if (_i < 7) exitWith {}; + if (_directionFound) exitWith {}; }; GVAR(wind_mean_dir) = GVAR(wind_direction_reference); GVAR(wind_direction_reference) = GVAR(wind_direction_reference) + (random 22.5) - (random 22.5); From ac5d593271b1b37604d2dc3150460d96fbb3017c Mon Sep 17 00:00:00 2001 From: ulteq Date: Wed, 22 Apr 2015 12:56:07 +0200 Subject: [PATCH 09/12] Switched to an improved version of the old getWind function --- addons/weather/functions/fnc_getMapData.sqf | 50 ++++++++++--------- addons/weather/functions/fnc_getWind.sqf | 30 +++++------ addons/weather/functions/fnc_initWind.sqf | 8 +-- .../functions/fnc_serverController.sqf | 45 +++++++++++------ 4 files changed, 74 insertions(+), 59 deletions(-) diff --git a/addons/weather/functions/fnc_getMapData.sqf b/addons/weather/functions/fnc_getMapData.sqf index 2cfcb34a3f..f2527d1157 100644 --- a/addons/weather/functions/fnc_getMapData.sqf +++ b/addons/weather/functions/fnc_getMapData.sqf @@ -35,16 +35,37 @@ 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"); GVAR(TempNight) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_TempNight"); GVAR(Humidity) = getArray (configFile >> "CfgWorlds" >> worldName >> "ACE_Humidity"); - - 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 map is among the most popular @@ -117,21 +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; - -// 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 \ No newline at end of file +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 7ce9d76722..33750b77dd 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -13,23 +13,19 @@ if (isNil "ACE_WIND_PARAMS") exitWith { [0, 0, 0] }; -private ["_period", "_periodPosition", "_x", "_ratio", "_windSpeed"]; - -EXPLODE_8_PVT(ACE_WIND_PARAMS,_windDirection,_min_wind_speed,_max_wind_speed,_c1,_c2,_c3,_c4,_period); +EXPLODE_5_PVT(ACE_WIND_PARAMS,_dir,_dirChange,_spd,_spdChange,_period); +private ["_periodPercent", "_periodPosition"]; _periodPosition = (time - GVAR(wind_period_start_time)) min _period; -_x = _periodPosition * 57.29577958; // time * (180 / PI) -_ratio = 0.5 + (_c1 * sin(_x/1.5) + _c2 * sin(_x/3) + _c3 * sin(_x/12) + _c4 * sin(_x/18)) / (2 * (_c1 + _c2 + _c3 + _c4)); -_windSpeed = _min_wind_speed + (_max_wind_speed - _min_wind_speed) * _ratio; +_periodPercent = _periodPosition / _period; -//GVAR(wind_speed_debug_output) pushBack _windspeed; -//copyToClipboard Str(GVAR(wind_speed_debug_output)); -/* -systemChat " "; -systemChat format["(Min/Current/Max) : (%1/%2/%3)", Round(_min_wind_speed * 10) / 10, Round(_windSpeed * 10) / 10, Round(_max_wind_speed * 10) / 10]; -systemChat format["Direction: %1", Round(_windDirection)]; -systemChat format["(Period/PeriodPosition) : (%1/%2)", Round(_period), Round(_periodPosition)]; -systemChat format["Ratio: %1", _ratio]; -systemChat " "; -*/ -[-1 * sin(_windDirection) * _windSpeed, -1 * cos(_windDirection) * _windSpeed, 0] +_spd = _spd + _spdChange * _periodPercent; +_dir = _dir + _dirChange * _periodPercent; + +_dir = (360 + _dir) % 360; + +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); + +[-_spd * sin(_dir), -_spd * cos(_dir), 0] diff --git a/addons/weather/functions/fnc_initWind.sqf b/addons/weather/functions/fnc_initWind.sqf index 555ec928f4..2da1b9ea49 100644 --- a/addons/weather/functions/fnc_initWind.sqf +++ b/addons/weather/functions/fnc_initWind.sqf @@ -31,18 +31,18 @@ for "_j" from 0 to 10 do { }; 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(c1) = 0.1 + random 0.1; -GVAR(c2) = 0.2 + random 0.1; -GVAR(c3) = 0.5 + random 0.2; -GVAR(c4) = 0.7 + random 0.2; +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; diff --git a/addons/weather/functions/fnc_serverController.sqf b/addons/weather/functions/fnc_serverController.sqf index cc96ccdf41..6bc0f4a9bc 100644 --- a/addons/weather/functions/fnc_serverController.sqf +++ b/addons/weather/functions/fnc_serverController.sqf @@ -11,7 +11,7 @@ */ #include "script_component.hpp" -private ["_i", "_lastRain", "_rainOverCast", "_transitionTime", "_windDirectionVariance", "_windDirection", "_time", "_c1", "_c2", "_c3", "_c4"]; +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 { @@ -49,25 +49,38 @@ if(GVAR(wind_period_count) > GVAR(wind_next_period)) then { GVAR(wind_next_period) = ceil((2 + (random 5)) / GVAR(overcast_multiplier)); GVAR(wind_period_count) = 0; - _windDirectionVariance = (90 - (random 180)) * overcast; + _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 = 360 - _windDirectionChange; + }; + if (_windDirectionChange < -180) then { + _windDirectionChange = -360 - _windDirectionChange; + }; - _c1 = (0.1 + random 0.1) * overcast; - _c2 = (0.2 + random 0.1) * overcast; - _c3 = (0.5 + random 0.2); - _c4 = (0.7 + random 0.2); + _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) * 60; - ACE_WIND_PARAMS = [_windDirection, - GVAR(min_wind_speed), - GVAR(max_wind_speed), - _c1, - _c2, - _c3, - _c4, + 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"; }; @@ -77,4 +90,6 @@ ACE_MISC_PARAMS = [lightnings, rainbow, fogParams, GVAR(temperatureShift), GVAR( 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 From caf2f12eb939c417c359f4ce15ceaacb4ee971ab Mon Sep 17 00:00:00 2001 From: ulteq Date: Wed, 22 Apr 2015 19:46:09 +0200 Subject: [PATCH 10/12] Improved the wind direction selection based on the probability array --- addons/weather/functions/fnc_initWind.sqf | 30 ++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/addons/weather/functions/fnc_initWind.sqf b/addons/weather/functions/fnc_initWind.sqf index 2da1b9ea49..10b22efa2a 100644 --- a/addons/weather/functions/fnc_initWind.sqf +++ b/addons/weather/functions/fnc_initWind.sqf @@ -11,24 +11,32 @@ */ #include "script_component.hpp" -private ["_j", "_i", "_directionFound", "_month", "_windDirectionProbabilities"]; +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; -_directionFound = false; -for "_j" from 0 to 10 do { - _random = random 1; - for "_i" from 0 to 7 do { - if (_random < (_windDirectionProbabilities select _i)) exitWith { - _directionFound = true; - GVAR(wind_direction_reference) = 45 * _i; - }; - }; - if (_directionFound) exitWith {}; +_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; From a9726d2b608865ccdea491a3c4b2521f9fdedb4a Mon Sep 17 00:00:00 2001 From: ulteq Date: Wed, 22 Apr 2015 19:46:27 +0200 Subject: [PATCH 11/12] Simplified the wind direction change calculation --- addons/weather/functions/fnc_getWind.sqf | 2 ++ addons/weather/functions/fnc_serverController.sqf | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/weather/functions/fnc_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index 33750b77dd..5f050d74b3 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -28,4 +28,6 @@ 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_serverController.sqf b/addons/weather/functions/fnc_serverController.sqf index 6bc0f4a9bc..5e6928d5b1 100644 --- a/addons/weather/functions/fnc_serverController.sqf +++ b/addons/weather/functions/fnc_serverController.sqf @@ -53,10 +53,10 @@ if(GVAR(wind_period_count) > GVAR(wind_next_period)) then { _windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360; _windDirectionChange = _windDirection - GVAR(current_wind_direction); if (_windDirectionChange > 180) then { - _windDirectionChange = 360 - _windDirectionChange; + _windDirectionChange = _windDirectionChange - 360; }; if (_windDirectionChange < -180) then { - _windDirectionChange = -360 - _windDirectionChange; + _windDirectionChange = 360 + _windDirectionChange; }; _windMaxDiff = GVAR(mean_wind_speed) - GVAR(max_wind_speed); From 09ff217e9343bc124e637e7f97652a354c03739a Mon Sep 17 00:00:00 2001 From: ulteq Date: Wed, 22 Apr 2015 21:16:01 +0200 Subject: [PATCH 12/12] Improved the init process --- addons/weather/XEH_postInit.sqf | 21 ++----------------- addons/weather/XEH_postServerInit.sqf | 19 ++++++++++++++++- addons/weather/XEH_preInit.sqf | 3 +++ addons/weather/functions/fnc_getWind.sqf | 1 + .../functions/fnc_serverController.sqf | 2 +- .../weather/functions/fnc_updateHumidity.sqf | 2 ++ .../functions/fnc_updateTemperature.sqf | 2 ++ 7 files changed, 29 insertions(+), 21 deletions(-) diff --git a/addons/weather/XEH_postInit.sqf b/addons/weather/XEH_postInit.sqf index 6c287c3a8a..04879971b4 100644 --- a/addons/weather/XEH_postInit.sqf +++ b/addons/weather/XEH_postInit.sqf @@ -1,26 +1,9 @@ #include "script_component.hpp" -call FUNC(getMapData); - -// Randomization -GVAR(temperatureShift) = 3 - random 6; -GVAR(badWeatherShift) = (random 1) ^ 2 * 10; -GVAR(humidityShift) = (5 - random 10) / 100; - -// 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 -call FUNC(initWind); +GVAR(wind_period_start_time) = time; +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; }; 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 1d6b12ee60..70c9341d0f 100644 --- a/addons/weather/XEH_preInit.sqf +++ b/addons/weather/XEH_preInit.sqf @@ -15,4 +15,7 @@ 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_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index 5f050d74b3..95d97d98b3 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -24,6 +24,7 @@ _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); diff --git a/addons/weather/functions/fnc_serverController.sqf b/addons/weather/functions/fnc_serverController.sqf index 5e6928d5b1..33ac909868 100644 --- a/addons/weather/functions/fnc_serverController.sqf +++ b/addons/weather/functions/fnc_serverController.sqf @@ -68,7 +68,7 @@ if(GVAR(wind_period_count) > GVAR(wind_next_period)) then { _windSpeed = GVAR(mean_wind_speed) + _windMaxDiff * _ratioMax + _windMinDiff * _ratioMin; _windSpeedChange = _windSpeed - GVAR(current_wind_speed); - _time = GVAR(wind_next_period) * 60; + _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); diff --git a/addons/weather/functions/fnc_updateHumidity.sqf b/addons/weather/functions/fnc_updateHumidity.sqf index 07edec1854..dce031b3f3 100644 --- a/addons/weather/functions/fnc_updateHumidity.sqf +++ b/addons/weather/functions/fnc_updateHumidity.sqf @@ -24,6 +24,8 @@ if (rain > 0 && overcast > 0.7) then { _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 d66a9b28f4..870d00333c 100644 --- a/addons/weather/functions/fnc_updateTemperature.sqf +++ b/addons/weather/functions/fnc_updateTemperature.sqf @@ -20,3 +20,5 @@ _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) + GVAR(temperatureShift) - GVAR(badWeatherShift) * overcast; GVAR(currentTemperature) = round(GVAR(currentTemperature) * 10) / 10; + +TRACE_2("temperatureShift/badWeatherShift",GVAR(temperatureShift),GVAR(badWeatherShift));