173 {
174 #ifdef WEATHER_DATA_LOGGING
175 if ( !dayInit )
176 {
177 GetGame().GetWorld().GetDate(startYear, startMonth, startDay, startHour, startMinute);
178 dayInit = true;
179 }
180 #endif
181
182 float phmnTime = 120;
183 float phmnLength = 10;
184 float phmnValue = 0;
185
188
189 m_Weather.GetOvercast().SetLimits(0.07, 1);
191
193
195 m_Weather.GetWindMagnitude().SetForecastChangeLimits( 0, 20 );
196
198
200
201 switch (type)
202 {
203
205 {
206 float windDirection, windMag;
208
209 #ifdef WEATHER_DATA_LOGGING
210 overcastChangeCount++;
211 #endif
212
214 {
215 phmnValue = Math.RandomFloatInclusive( 0.75, 1 );
217 m_Weather.GetOvercast().Set( phmnValue, 120, phmnLength );
219 return true;
220 }
221
222
223 phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
226
227
228
229 if (
m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
230 {
232 }
233
234 if (
m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
235 {
237 }
238
239 if (
m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
240 {
243 }
244
245
246
247
248 m_Chance = Math.RandomIntInclusive( 0, 100 );
250 {
252
253 if (
m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
255 }
257 {
259
260 if (
m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
262 }
263 else
264 {
267 if (
m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
269 }
270
273
276
277
278
280 {
282 #ifdef WEATHER_DATA_LOGGING
283 clearWeatherCount++;
284 #endif
285 phmnValue = Math.RandomFloatInclusive( 0.07, 0.2 );
288 }
289
291 {
293 #ifdef WEATHER_DATA_LOGGING
294 cloudyWeatherCount++;
295 #endif
296
297 phmnValue = Math.RandomFloatInclusive( 0.2, 0.45 );
300 }
301
303 {
305
306 phmnValue = Math.RandomFloatInclusive( 0.45, 0.75 );
309
310 #ifdef WEATHER_DATA_LOGGING
311 badWeatherCount++;
312 #endif
313 }
314
315
317
319 {
320 phmnLength = 0;
324
325 if (phmnValue < 0.75)
326 {
327 phmnValue = 0.75;
328 }
329
330 windMagLength = 99999;
331 }
333 {
334 Debug.LogError(
"Two consecutive sandstorm tried to occur");
335 windMag = Math.RandomFloatInclusive( 3, 7 );
336
338 {
340 windDirection = -1.5;
341 }
342 else
343 {
344 windDirection = Math.RandomFloatInclusive( 0.20 , 0.90);
345 }
346
349
351 }
352 else
353 {
356 {
358 windDirection =
m_Weather.GetWindDirection().GetActual();
359 }
360
362 }
363
364 m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
365
368
370
371 Debug.WeatherLog(
string.Format(
"Nasdara::Weather::Overcast:: (%1) overcast: %2",
g_Game.GetDayTime(), actual));
372 Debug.WeatherLog(
string.Format(
"Nasdara::Weather::Overcast::Rain:: (%1) %2",
g_Game.GetDayTime(),
m_Weather.GetRain().GetActual()));
373
374 #ifdef WEATHER_DATA_LOGGING
375 int testYear = 0;
376 int testMonth = 0;
377 int testDay = 0;
378 int testHour = 0;
379 int testMinute = 0;
380 GetGame().GetWorld().GetDate(testYear, testMonth, testDay, testHour, testMinute);
381
382 if ( testDay - startDay > currentDay && testHour - startHour >= 0 && testMinute - startMinute >= 0 )
383 {
385 FPrintln(file,
"================================================================");
386 FPrintln(file,
" ================== Day " + (currentDay + 1) +
" ================== ");
387 FPrintln(file,
"================================================================");
388 FPrintln(file,
"Overcast Change Count: " + overcastChangeCount);
389 FPrintln(file,
"Bad Weather Change Count: " + badWeatherCount);
390 FPrintln(file,
"Cloudy Weather Count: " + cloudyWeatherCount);
391 FPrintln(file,
"Clear Weather Count: " + clearWeatherCount);
392 FPrintln(file,
"Sandstorm Count: " + sandstormCount);
393
394 currentDay++;
396 if ( currentDay == daysToRun )
397 {
399 }
400
401 overcastChangeCount = 0;
402 badWeatherCount = 0;
403 cloudyWeatherCount = 0;
404 clearWeatherCount = 0;
405 sandstormCount = 0;
406 }
407 #endif
408
409
410 return true;
411 }
412
414 {
415 float actualOvercast =
m_Weather.GetOvercast().GetActual();
416
417 m_Chance = Math.RandomIntInclusive( 0, 100 );
418 phmnValue = 0.2;
419 phmnTime = 90;
420 phmnLength = 30;
421
423 {
425 Debug.WeatherLog(
string.Format(
"Nasdara::Weather::Rain::ForceEnd:: (%1) %2 -> 0",
g_Game.GetDayTime(), actual));
426 return true;
427 }
428 else
429 {
431 {
432 phmnValue = Math.RandomFloatInclusive( 0.05, 0.3 );
435 }
436 else
437 {
438 phmnValue = 0.0;
441 }
442 }
443
444 m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
445
446 Debug.WeatherLog(
string.Format(
"Nasdara::Weather::Rain:: (%1) %2",
g_Game.GetDayTime(), actual));
447
448 return true;
449 }
450
452 {
454
455 return true;
456 }
457
459 {
461 float sereneWindMag =
m_Weather.GetWindMagnitude().GetActual() * 0.6;
462
465
467
469
471 {
472 sandstorm.
Stop(phmnTime,
true);
474 }
475
476 return true;
477 }
479 {
480 m_Weather.GetWindDirection().Set( 0, 60 , 100000);
481 Debug.LogError(
"Wind direction has been changed out of overcast change");
482
484 {
485 sandstorm.
Stop(30,
true);
486 Debug.LogError(
"Wind direction changed while sandstorm was active, stopping sandstorm");
487 }
488
489 return true;
490 }
491
492 }
493
494 return false;
495 }
SandstormController Sandstorm
bool sandstormWillChangeOvercast
bool previousWeatherHadSandstorm
override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
proto native void Stop(float duration, bool calledByWeather)
Stops the sandstorm, leaving it to fade out over duration seconds. The sandstorm must be active prior...
proto native bool IsActive()
Returns whether sandstorm is currently active.
void StartSandstorm(float timeToGather)
Helper function that starts the sandstorm while setting an internal flag that allows WorldData identi...
float WIND_DIRECTION_TIME_MULTIPLIER
ref WorldDataWeatherSettings m_WeatherDefaultSettings
int m_BadWeatherChance
weather related
float WIND_MAGNITUDE_TIME_MULTIPLIER
proto void CloseFile(FileHandle file)
Close the File.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
proto void FPrintln(FileHandle file, void var)
Write to file and add new line.