mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Switched to an improved version of the old getWind function
This commit is contained in:
parent
e7bc0c26bc
commit
ac5d593271
@ -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
|
||||
@ -118,20 +139,3 @@ 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
|
@ -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]
|
||||
|
@ -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;
|
||||
|
@ -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";
|
||||
};
|
||||
@ -78,3 +91,5 @@ publicVariable "ACE_MISC_PARAMS";
|
||||
|
||||
GVAR(rain_period_count) = GVAR(rain_period_count) + 1;
|
||||
GVAR(wind_period_count) = GVAR(wind_period_count) + 1;
|
||||
|
||||
GVAR(overcast_multiplier) = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1)
|
Loading…
Reference in New Issue
Block a user