2015-04-17 04:44:38 +00:00
|
|
|
/*
|
2015-04-21 18:20:05 +00:00
|
|
|
* Author: ACE2 Team, esteldunedain, ruthberg
|
2015-04-20 11:54:22 +00:00
|
|
|
*
|
2015-04-21 18:20:05 +00:00
|
|
|
* Calculate the wind and rain evolution on the server. Broadcasts the current and next values to the clients
|
2015-04-17 04:44:38 +00:00
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None
|
|
|
|
*/
|
2015-01-20 23:18:40 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-21 18:20:05 +00:00
|
|
|
|
2015-04-22 10:56:07 +00:00
|
|
|
private ["_i", "_lastRain", "_rainOverCast", "_transitionTime", "_windDirectionVariance", "_windSpeed", "_windSpeedChange", "_windMaxDiff", "_windMinDiff", "_windDirection", "_windDirectionChange", "_time"];
|
2015-01-20 23:18:40 +00:00
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
// Rain simulation
|
2015-01-20 23:18:40 +00:00
|
|
|
if(GVAR(rain_period_count) > GVAR(rain_next_period)) then {
|
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
if(overcast >= 0.7) then {
|
|
|
|
_lastRain = GVAR(current_rain);
|
|
|
|
_rainOverCast = ((overcast-0.7)/0.3);
|
|
|
|
GVAR(rain_next_period) = ceil((1+random(10))/GVAR(overcast_multiplier));
|
2015-01-20 23:18:40 +00:00
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
GVAR(current_rain) = (GVAR(current_rain)+(((GVAR(current_rain)))*((_rainOverCast*(GVAR(overcast_multiplier)))/8)*GVAR(rain_current_range)));
|
|
|
|
GVAR(current_rain) = (GVAR(current_rain) max 0.01) min 1;
|
2015-01-20 23:18:40 +00:00
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
_transitionTime = (_rainOverCast*5)+(random (_rainOverCast*20))+1;
|
|
|
|
GVAR(rain_current_range) = -1+(random 2);
|
2015-01-20 23:18:40 +00:00
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
ACE_RAIN_PARAMS = [_lastRain, GVAR(current_rain), _transitionTime];
|
|
|
|
TRACE_4("",_lastRain,_rainOverCast,_transitionTime, overcast);
|
|
|
|
} else {
|
|
|
|
GVAR(current_rain) = 0;
|
|
|
|
_lastRain = GVAR(current_rain);
|
|
|
|
_rainOverCast = 1;
|
|
|
|
_transitionTime = (_rainOverCast*5)+(random (_rainOverCast*20))+1;
|
2015-01-20 23:18:40 +00:00
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
ACE_RAIN_PARAMS = [_lastRain, GVAR(current_rain), _transitionTime];
|
|
|
|
TRACE_4("",_lastRain,_rainOverCast,_transitionTime, overcast);
|
|
|
|
};
|
2015-01-21 02:18:17 +00:00
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
GVAR(rain_period_start_time) = time;
|
|
|
|
publicVariable "ACE_RAIN_PARAMS";
|
2015-01-20 23:18:40 +00:00
|
|
|
};
|
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
// Wind simulation
|
2015-01-20 23:18:40 +00:00
|
|
|
if(GVAR(wind_period_count) > GVAR(wind_next_period)) then {
|
2015-04-21 18:20:05 +00:00
|
|
|
|
|
|
|
GVAR(wind_next_period) = ceil((2 + (random 5)) / GVAR(overcast_multiplier));
|
2015-01-21 02:58:19 +00:00
|
|
|
GVAR(wind_period_count) = 0;
|
2015-04-21 18:20:05 +00:00
|
|
|
|
2015-04-22 10:56:07 +00:00
|
|
|
_windDirectionVariance = (90 - (random 180)) * (overcast ^ 2);
|
2015-04-21 18:20:05 +00:00
|
|
|
_windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360;
|
2015-04-22 10:56:07 +00:00
|
|
|
_windDirectionChange = _windDirection - GVAR(current_wind_direction);
|
|
|
|
if (_windDirectionChange > 180) then {
|
2015-04-22 17:46:27 +00:00
|
|
|
_windDirectionChange = _windDirectionChange - 360;
|
2015-04-22 10:56:07 +00:00
|
|
|
};
|
|
|
|
if (_windDirectionChange < -180) then {
|
2015-04-22 17:46:27 +00:00
|
|
|
_windDirectionChange = 360 + _windDirectionChange;
|
2015-04-22 10:56:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_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;
|
2015-04-21 18:20:05 +00:00
|
|
|
|
2015-04-22 10:56:07 +00:00
|
|
|
_windSpeed = GVAR(mean_wind_speed) + _windMaxDiff * _ratioMax + _windMinDiff * _ratioMin;
|
|
|
|
_windSpeedChange = _windSpeed - GVAR(current_wind_speed);
|
2015-04-21 18:20:05 +00:00
|
|
|
|
2015-04-22 19:16:01 +00:00
|
|
|
_time = GVAR(wind_next_period) * GVAR(serverUpdateInterval);
|
2015-04-21 18:20:05 +00:00
|
|
|
|
2015-04-22 10:56:07 +00:00
|
|
|
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,
|
2015-04-21 18:20:05 +00:00
|
|
|
_time];
|
2015-04-22 10:56:07 +00:00
|
|
|
|
|
|
|
GVAR(current_wind_direction) = _windDirection;
|
|
|
|
GVAR(current_wind_speed) = _windSpeed;
|
|
|
|
|
2015-01-21 02:58:19 +00:00
|
|
|
GVAR(wind_period_start_time) = time;
|
|
|
|
publicVariable "ACE_WIND_PARAMS";
|
2015-01-20 23:18:40 +00:00
|
|
|
};
|
2015-01-21 02:58:19 +00:00
|
|
|
|
2015-01-21 03:00:06 +00:00
|
|
|
// Sync misc. parameters
|
2015-04-21 18:41:50 +00:00
|
|
|
ACE_MISC_PARAMS = [lightnings, rainbow, fogParams, GVAR(temperatureShift), GVAR(badWeatherShift), GVAR(humidityShift)];
|
2015-01-21 03:00:06 +00:00
|
|
|
publicVariable "ACE_MISC_PARAMS";
|
|
|
|
|
2015-01-20 23:18:40 +00:00
|
|
|
GVAR(rain_period_count) = GVAR(rain_period_count) + 1;
|
2015-04-22 10:56:07 +00:00
|
|
|
GVAR(wind_period_count) = GVAR(wind_period_count) + 1;
|
|
|
|
|
|
|
|
GVAR(overcast_multiplier) = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1)
|