42 m_MinTemps = {-3,-2,0,4,9,14,18,17,13,11,9,0};
51 m_MaxTemps = {3,5,7,14,19,24,26,25,18,14,10,5};
62 m_WorldWindCoef = 0.4;
63 m_CloudsTemperatureEffectModifier = 2.0;
64 m_TemperaturePerHeightReductionModifier = 0.012;
66 m_UniversalTemperatureSourceCapModifier = -1.0;
70 m_Weather.SetDynVolFogHeightBias(m_WeatherDefaultSettings.m_DefaultHeigthBias);
74 float startingOvercast =
Math.RandomFloat(0.2,0.75);
75 m_Weather.GetOvercast().Set(startingOvercast,0,5);
93 #ifdef WEATHER_DATA_LOGGING
96 GetGame().GetWorld().GetDate(startYear, startMonth, startDay, startHour, startMinute);
102 float phmnLength = 10;
105 m_Weather.SetStorm( 1.0, m_WeatherDefaultSettings.m_StormThreshold, 45 );
107 m_Weather.SetRainThresholds( m_WeatherDefaultSettings.m_RainThreshold, 1.0, 60 );
110 if (
m_Weather.GetDynVolFogHeightBias() < m_WeatherDefaultSettings.m_DefaultHeigthBias)
112 m_Weather.SetDynVolFogHeightBias(m_WeatherDefaultSettings.m_DefaultHeigthBias);
120 #ifdef WEATHER_DATA_LOGGING
121 overcastChangeCount++;
124 float windDirection, windMag;
127 phmnValue =
Math.RandomFloatInclusive( 0.2, 0.7 );
128 phmnTime =
Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
129 phmnLength =
Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
133 m_Chance =
Math.RandomIntInclusive( 0, 100 );
136 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
141 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
146 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
153 if ( m_Chance < m_ClearWeatherChance )
155 m_ChoosenWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
156 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
159 else if ( m_Chance > m_BadWeatherChance )
161 m_ChoosenWeather = WorldDataWeatherConstants.BAD_WEATHER;
162 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
167 m_ChoosenWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
168 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
172 if ( m_ChoosenWeather != m_LastWeather )
173 m_SameWeatherCnt = 0;
175 m_ClearWeatherChance = m_WeatherDefaultSettings.m_ClearWeatherChance;
176 m_BadWeatherChance = m_WeatherDefaultSettings.m_BadWeatherChance;
180 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
182 m_LastWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
183 #ifdef WEATHER_DATA_LOGGING
187 phmnValue =
Math.RandomFloatInclusive( 0.0, 0.3 );
188 phmnTime =
Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
189 phmnLength =
Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
192 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
194 m_LastWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
195 #ifdef WEATHER_DATA_LOGGING
196 cloudyWeatherCount++;
199 phmnValue =
Math.RandomFloatInclusive( 0.3, 0.6 );
200 phmnTime =
Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
201 phmnLength =
Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
204 if ( m_ChoosenWeather == WorldDataWeatherConstants.BAD_WEATHER )
206 m_LastWeather = WorldDataWeatherConstants.BAD_WEATHER;
207 #ifdef WEATHER_DATA_LOGGING
211 phmnValue =
Math.RandomFloatInclusive( 0.6, 1.0 );
212 phmnTime =
Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
213 phmnLength =
Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
216 m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
218 CalculateWind( m_ChoosenWeather,
false, windMag, windDirection );
219 m_Weather.GetWindMagnitude().Set( windMag, phmnTime * WIND_MAGNITUDE_TIME_MULTIPLIER , phmnTime * (1 - WIND_MAGNITUDE_TIME_MULTIPLIER) );
220 m_Weather.GetWindDirection().Set( windDirection, phmnTime * WIND_DIRECTION_TIME_MULTIPLIER , phmnTime - (phmnTime * WIND_DIRECTION_TIME_MULTIPLIER) + phmnLength + 1000 );
224 Debug.WeatherLog(
string.Format(
"Chernarus::Weather::Overcast:: (%1) overcast: %2",
g_Game.GetDayTime(), actual));
225 Debug.WeatherLog(
string.Format(
"Chernarus::Weather::Overcast::Rain:: (%1) %2",
g_Game.GetDayTime(),
m_Weather.GetRain().GetActual()));
227 #ifdef WEATHER_DATA_LOGGING
233 GetGame().GetWorld().GetDate(testYear, testMonth, testDay, testHour, testMinute);
235 if ( testDay - startDay > currentDay && testHour - startHour >= 0 && testMinute - startMinute >= 0 )
238 FPrintln(file,
"================================================================");
239 FPrintln(file,
" ================== Day " + (currentDay + 1) +
" ================== ");
240 FPrintln(file,
"================================================================");
241 FPrintln(file,
"Overcast Change Count: " + overcastChangeCount);
242 FPrintln(file,
"Bad Weather Change Count: " + badWeatherCount);
243 FPrintln(file,
"Cloudy Weather Count: " + cloudyWeatherCount);
244 FPrintln(file,
"Clear Weather Count: " + clearWeatherCount);
248 if ( currentDay == daysToRun )
253 overcastChangeCount = 0;
255 cloudyWeatherCount = 0;
256 clearWeatherCount = 0;
265 float actualOvercast =
m_Weather.GetOvercast().GetActual();
267 m_Chance =
Math.RandomIntInclusive( 0, 100 );
272 if ( actualOvercast <= m_WeatherDefaultSettings.m_RainThreshold )
274 m_Weather.GetRain().Set( 0.0, m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
275 Debug.WeatherLog(
string.Format(
"Chernarus::Weather::Rain::ForceEnd:: (%1) %2 -> 0",
g_Game.GetDayTime(), actual));
279 if ( actualOvercast > m_WeatherDefaultSettings.m_StormThreshold )
281 phmnValue =
Math.RandomFloatInclusive( 0.8, 1.0 );
282 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
285 m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
286 Debug.WeatherLog(
string.Format(
"Chernarus::Weather::Rain::ForceStorm:: (%1) %2 -> %3",
g_Game.GetDayTime(), actual, phmnValue));
291 if ( actualOvercast < 0.75 )
295 phmnValue =
Math.RandomFloatInclusive( 0.1, 0.3 );
296 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
299 else if ( m_Chance < 60 )
301 phmnValue =
Math.RandomFloatInclusive( 0.2, 0.5 );
302 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
305 else if ( m_Chance < 80 )
307 phmnValue =
Math.RandomFloatInclusive( 0.0, 0.2 );
308 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
314 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
315 phmnLength = m_WeatherDefaultSettings.m_RainLengthMax;
322 phmnValue =
Math.RandomFloatInclusive( 0.5, 0.7 );
323 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
326 else if ( m_Chance < 50 )
328 phmnValue =
Math.RandomFloatInclusive( 0.2, 0.4 );
329 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
332 else if ( m_Chance < 75 )
334 phmnValue =
Math.RandomFloatInclusive( 0.4, 0.6 );
335 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
341 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
342 phmnLength = m_WeatherDefaultSettings.m_RainLengthMax;
346 m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
348 Debug.WeatherLog(
string.Format(
"Chernarus::Weather::Rain:: (%1) %2",
g_Game.GetDayTime(), actual));
357 float fogTime = 1800.0;
359 float fogyMorning =
Math.RandomFloatInclusive( 0.0, 1.0 );
361 if ( fogyMorning > 0.85 )
363 if ( (
g_Game.GetDayTime() > 4 &&
g_Game.GetDayTime() < 7 ) )
371 if (
m_Weather.GetOvercast().GetActual() < 0.3 )
378 m_Weather.GetFog().Set(
Math.RandomFloatInclusive( fogMin, fogMax ), fogTime, 0);
380 Debug.WeatherLog(
string.Format(
"Chernarus::Weather::Fog:: (%1) %2",
g_Game.GetDayTime(), actual));
387 phmnTime =
Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
388 m_Weather.GetWindMagnitude().Set(
m_Weather.GetWindMagnitude().GetActual() * 0.75, phmnTime , m_WeatherDefaultSettings.m_OvercastMaxLength);
397 protected override void CalculateWind(
int newWeather,
bool suddenChange, out
float magnitude, out
float direction)
402 float windChance =
Math.RandomIntInclusive( 0, 100 );
404 if ( newWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
406 if ( windChance < 30 )
408 magnitude =
Math.RandomFloatInclusive( 6 , 10 );
409 direction =
Math.RandomFloatInclusive( -1.0 , -0.5);
411 else if ( windChance < 75 )
413 magnitude =
Math.RandomFloatInclusive( 8 , 12 );
414 direction =
Math.RandomFloatInclusive( -1.3 , -0.9);
418 magnitude =
Math.RandomFloatInclusive( 4 , 6 );
419 direction =
Math.RandomFloatInclusive( -0.6 , 0.0);
423 else if ( newWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
425 if ( windChance < 45 )
427 magnitude =
Math.RandomFloatInclusive( 6 , 10 );
428 direction =
Math.RandomFloatInclusive( -3.14 , -2.4);
430 else if ( windChance < 90 )
432 magnitude =
Math.RandomFloatInclusive( 8 , 12 );
433 direction =
Math.RandomFloatInclusive( -2.6, -2.0);
437 magnitude =
Math.RandomFloatInclusive( 10 , 14 );
438 direction =
Math.RandomFloatInclusive( -2.2 , -1.4);
443 if ( suddenChange ||
m_Weather.GetOvercast().GetActual() > m_WeatherDefaultSettings.m_StormThreshold ||
m_Weather.GetOvercast().GetForecast() -
m_Weather.GetOvercast().GetActual() >= 0.4 )
445 magnitude =
Math.RandomFloatInclusive( 14 , 17 );
446 direction =
Math.RandomFloatInclusive( 0.9 , 1.45);
448 else if ( windChance < 45 )
450 magnitude =
Math.RandomFloatInclusive( 9 , 12 );
451 direction =
Math.RandomFloatInclusive( 1.45, 1.7);
453 else if ( windChance < 90 )
455 magnitude =
Math.RandomFloatInclusive( 7 , 10 );
456 direction =
Math.RandomFloatInclusive( 1.6 , 2);
460 magnitude =
Math.RandomFloatInclusive( 4 , 8 );
461 direction =
Math.RandomFloatInclusive( 1.9, 2.2 );
466 protected override void CalculateVolFog(
float lerpValue,
float windMagnitude,
float changeTime)
468 float distanceDensity, heigthDensity, heightBias;
469 int year, month, day, hour, minute;
470 GetGame().GetWorld().GetDate(year, month, day, hour, minute);
472 if ( hour < 9 && hour >= 5 )
474 distanceDensity =
Math.Lerp( 0.015, 0.05, lerpValue ) *
Math.Clamp(1 - (windMagnitude /
m_Weather.GetWindMaximumSpeed()), 0.1, 1);
475 heigthDensity =
Math.Lerp( 0.8, 1, lerpValue);
477 heightBias =
m_Weather.GetDynVolFogHeightBias();
479 if (heightBias == m_WeatherDefaultSettings.m_DefaultHeigthBias)
481 int diceRoll =
Math.RandomIntInclusive(1,100);
485 heightBias =
Math.RandomInt(m_WeatherDefaultSettings.m_DefaultHeigthBias + 1, 80);
487 else if (diceRoll < 85)
489 heightBias =
Math.RandomInt(80, 120);
493 heightBias =
Math.RandomInt(120, 200);
497 else if ( hour < 18 && hour >= 9 )
499 distanceDensity =
Math.Lerp( 0.01, 0.05, lerpValue ) *
Math.Clamp(1 - (windMagnitude /
m_Weather.GetWindMaximumSpeed()), 0.1, 1);
500 heigthDensity =
Math.Lerp( 0.9, 1, lerpValue);
501 heightBias = m_WeatherDefaultSettings.m_DefaultHeigthBias;
505 distanceDensity =
Math.Lerp( 0.01, 0.03, lerpValue ) *
Math.Clamp(1 - (windMagnitude /
m_Weather.GetWindMaximumSpeed()), 0.1, 1);
506 heigthDensity =
Math.Lerp( 0.9, 1, lerpValue);
507 heightBias = m_WeatherDefaultSettings.m_DefaultHeigthBias;
510 m_Weather.SetDynVolFogDistanceDensity(distanceDensity, changeTime);
511 m_Weather.SetDynVolFogHeightDensity(heigthDensity, changeTime);
512 m_Weather.SetDynVolFogHeightBias(heightBias, changeTime);