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
This commit is contained in:
ulteq 2015-04-21 20:20:05 +02:00
parent 287c0d62ca
commit af4fdda477
7 changed files with 146 additions and 115 deletions

View File

@ -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
};
};
};

View File

@ -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; };

View File

@ -8,6 +8,7 @@ PREP(calculateBarometricPressure);
PREP(displayWindInfo);
PREP(getMapData);
PREP(getWind);
PREP(initWind);
PREP(serverController);
PREP(updateHumidity);
PREP(updateRain);

View File

@ -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

View File

@ -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]

View File

@ -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) = [];

View File

@ -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";
};