Improved the init process

This commit is contained in:
ulteq 2015-04-22 21:16:01 +02:00
parent 74888b4fff
commit 09ff217e93
7 changed files with 29 additions and 21 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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