mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
weather: added temperature simulation and air density
This commit is contained in:
parent
0f790267f1
commit
bba99d64f7
@ -9,6 +9,8 @@
|
||||
30 setFog (ACE_MISC_PARAMS select 2);
|
||||
};
|
||||
|
||||
|
||||
// Update Wind
|
||||
simulWeatherSync;
|
||||
_fnc_updateWind = {
|
||||
ACE_wind = [] call FUNC(getWind);
|
||||
@ -20,9 +22,10 @@ _fnc_updateWind = {
|
||||
|
||||
//systemChat format ["w:%1 %2,ACE_w:%1 %2, w", [wind select 0, wind select 1, ACE_wind select 0, ACE_wind select 1]];
|
||||
};
|
||||
|
||||
[_fnc_updateWind, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
|
||||
// Update Rain
|
||||
_fnc_updateRain = {
|
||||
if(GVAR(enableRain)) then {
|
||||
if(!isNil "ACE_RAIN_PARAMS" && {!isNil QGVAR(rain_period_start_time)}) then {
|
||||
@ -36,5 +39,18 @@ _fnc_updateRain = {
|
||||
};
|
||||
};
|
||||
};
|
||||
[_fnc_updateRain, 2, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
[_fnc_updateRain, 2, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Update Temperature
|
||||
_fnc_updateTemperature = {
|
||||
_annualCoef = 0.5 - 0.5 * cos(360 * dateToNumber date);
|
||||
_dailyTempMean = GVAR(TempMeanJan) * (1 - _annualCoef) + GVAR(TempMeanJul) * _annualCoef;
|
||||
_dailyTempAmplitude = GVAR(TempAmplitudeJan) * (1 - _annualCoef) + GVAR(TempAmplitudeJul) * _annualCoef;
|
||||
|
||||
_hourlyCoef = -0.5 * sin(360 * ((3 + (date select 3))/24 + (date select 4)/1440));
|
||||
|
||||
GVAR(currentTemperature) = _dailyTempMean + _hourlyCoef * _dailyTempAmplitude - 2 * humidity - 4 * overcast;
|
||||
GVAR(currentRelativeDensity) = (273.15 + 20) / (273.15 + GVAR(currentTemperature));
|
||||
};
|
||||
[_fnc_updateTemperature, 20, []] call CBA_fnc_addPerFrameHandler;
|
@ -7,12 +7,22 @@ LOG(MSG_INIT);
|
||||
PREP(serverController);
|
||||
PREP(getWind);
|
||||
|
||||
ACE_wind = [0, 0];
|
||||
|
||||
|
||||
// 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);
|
||||
@ -28,13 +38,20 @@ GVAR(wind_major_period_count) = 0;
|
||||
GVAR(wind_total_time) = 0;
|
||||
GVAR(wind_period_start_time) = time;
|
||||
|
||||
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));
|
||||
// Temperature variables
|
||||
if (isNumber (configFile >> "CfgWorlds" >> worldName >> "AGM_TempMeanJan")) then {
|
||||
GVAR(TempMeanJan) = getNumber (configFile >> "CfgWorlds" >> worldName >> "ACE_TempMeanJan");
|
||||
GVAR(TempMeanJul) = getNumber (configFile >> "CfgWorlds" >> worldName >> "ACE_TempMeanJul");
|
||||
GVAR(TempAmplitudeJan) = getNumber (configFile >> "CfgWorlds" >> worldName >> "ACE_TempAmplitudeJan");
|
||||
GVAR(TempAmplitudeJul) = getNumber (configFile >> "CfgWorlds" >> worldName >> "ACE_TempAmplitudeJul");
|
||||
} else {
|
||||
_lat = - getNumber (configFile >> "CfgWorlds" >> worldName >> "latitude");
|
||||
if (_lat == 0) then {_lat = 0.1;};
|
||||
_yearlyTempMean = 28 min (28 - (abs(_lat) - 23.5) * (3.14159/180) * 6371 / 145);
|
||||
GVAR(TempMeanJan) = _yearlyTempMean - _lat / abs(_lat) * ((abs(_lat) max 25) - 25) * 30 / 65;
|
||||
GVAR(TempMeanJul) = _yearlyTempMean + _lat / abs(_lat) * ((abs(_lat) max 25) - 25) * 30 / 65;
|
||||
GVAR(TempAmplitudeJan) = 10;
|
||||
GVAR(TempAmplitudeJul) = 10;
|
||||
};
|
||||
GVAR(current_rain) = GVAR(rain_initial_rain);
|
||||
GVAR(rain_current_range) = -1+(random 2);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -83,8 +83,5 @@ if(GVAR(wind_period_count) > GVAR(wind_next_period)) then {
|
||||
ACE_MISC_PARAMS = [lightnings, rainbow, fogParams];
|
||||
publicVariable "ACE_MISC_PARAMS";
|
||||
|
||||
// @todo: Temperature simulation
|
||||
|
||||
|
||||
GVAR(rain_period_count) = GVAR(rain_period_count) + 1;
|
||||
GVAR(wind_period_count) = GVAR(wind_period_count) + 1;
|
Loading…
Reference in New Issue
Block a user