136 {
137 #ifdef WEATHER_DATA_LOGGING
138 if ( !dayInit )
139 {
141 dayInit = true;
142 }
143 #endif
144
145 float phmnTime = 120;
146 float phmnLength = 10;
147 float phmnValue = 0;
148
150
151 m_Weather.GetOvercast().SetLimits(0.07, 1);
154 m_Weather.GetSnowfall().SetForecastChangeLimits(0, 1);
155
157
159 m_Weather.GetWindMagnitude().SetForecastChangeLimits( 0, 20 );
160
162
163 switch (type)
164 {
165
167 {
168 float windDirection, windMag;
169
170 #ifdef WEATHER_DATA_LOGGING
171 overcastChangeCount++;
172 #endif
173
174 phmnValue = Math.RandomFloatInclusive( 0.2, 0.7 );
177
178
179
180 if (
m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
181 {
183 }
184
185 if (
m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
186 {
188 }
189
190 if (
m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
191 {
194 }
195
196
197
198
199 m_Chance = Math.RandomIntInclusive( 0, 100 );
201 {
202 #ifdef WEATHER_DATA_LOGGING
203 directSuddenChangeCount++;
204 #endif
205
208 if (
m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
210 }
212 {
215
216 if (
m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
218 }
220 {
222
223 if (
m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
225
227 {
229
230 #ifdef WEATHER_DATA_LOGGING
231 badWeatherCount++;
232 #endif
233 }
234 else
235 {
237 {
239
240 #ifdef WEATHER_DATA_LOGGING
241 badWeatherSuddenChangeCount++;
242 #endif
243 }
244 else
245 {
246 #ifdef WEATHER_DATA_LOGGING
247 badWeatherCount++;
248 #endif
249 }
250 }
251 }
252 else
253 {
256 if (
m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
258 }
259
262
265
266
267
269 {
271 #ifdef WEATHER_DATA_LOGGING
272 clearWeatherCount++;
273 #endif
274 phmnValue = Math.RandomFloatInclusive( 0.07, 0.3 );
277 }
278
280 {
281 #ifdef WEATHER_DATA_LOGGING
282 cloudyWeatherCount++;
283 #endif
285
286 phmnValue = Math.RandomFloatInclusive( 0.3, 0.6 );
289 }
290
292 {
294
295 phmnValue = Math.RandomFloatInclusive( 0.6, 1.0 );
298
300 {
303 }
304
305 #ifdef WEATHER_DATA_LOGGING
307 {
309 {
310 suddenThundersnowCount++;
312 {
313 directSuddenChangeCount--;
314 }
315 else
316 {
317 badWeatherSuddenChangeCount--;
318 }
319 }
320 else
321 {
322 thundersnowCount++;
323 badWeatherCount--;
324 }
325 }
326 #endif
327
328 }
329
330 m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
331
332
336
338 {
339 m_Weather.GetSnowfall().Set(Math.RandomFloatInclusive( 0.4, 0.8 ), phmnTime, 0);
340 }
341
342 Debug.WeatherLog(
string.Format(
"Sakhal::Weather::Overcast:: (%1) overcast: %2",
g_Game.GetDayTime(), actual));
343 Debug.WeatherLog(
string.Format(
"Sakhal::Weather::Overcast::Snow:: (%1) %2",
g_Game.GetDayTime(),
m_Weather.GetRain().GetActual()));
344
345 #ifdef WEATHER_DATA_LOGGING
346 int testYear = 0;
347 int testMonth = 0;
348 int testDay = 0;
349 int testHour = 0;
350 int testMinute = 0;
352
353 if ( testDay - startDay > currentDay && testHour - startHour >= 0 && testMinute - startMinute >= 0 )
354 {
356 FPrintln(file,
"================================================================");
357 FPrintln(file,
" ================== Day " + (currentDay + 1) +
" ================== ");
358 FPrintln(file,
"================================================================");
359 FPrintln(file,
"Overcast Change Count: " + overcastChangeCount);
360 FPrintln(file,
"Bad Weather Change Count: " + badWeatherCount);
361 FPrintln(file,
"Bad Weather Sudden Change Count: " + badWeatherSuddenChangeCount);
362 FPrintln(file,
"Global Sudden Change Count: " + directSuddenChangeCount);
363 FPrintln(file,
"Thunder Snow Count: " + thundersnowCount);
364 FPrintln(file,
"Sudden Thundersnow Count: " + suddenThundersnowCount);
365 FPrintln(file,
"Cloudy Weather Count: " + cloudyWeatherCount);
366 FPrintln(file,
"Clear Weather Count: " + clearWeatherCount);
367
368 currentDay++;
370 if ( currentDay == daysToRun )
371 {
373 }
374
375 overcastChangeCount = 0;
376 directSuddenChangeCount = 0;
377 badWeatherSuddenChangeCount = 0;
378 thundersnowCount = 0;
379 suddenThundersnowCount = 0;
380 badWeatherCount = 0;
381 cloudyWeatherCount = 0;
382 clearWeatherCount = 0;
383 }
384 #endif
385
386
387 return true;
388 }
389
391 {
392 float actualOvercast =
m_Weather.GetOvercast().GetActual();
393
394 m_Chance = Math.RandomIntInclusive( 0, 100 );
395 phmnValue = 0.2;
396 phmnTime = 90;
397 phmnLength = 20;
398
400 {
403
404 Debug.WeatherLog(
string.Format(
"Sakhal::Weather::Snow::ForceEnd:: (%1) %2 -> 0",
g_Game.GetDayTime(), actual));
405 return true;
406 }
407
409 {
410 phmnValue = Math.RandomFloatInclusive( 0.8, 1.0 );
413
414 m_Weather.GetSnowfall().Set( phmnValue, phmnTime, phmnLength );
415
417 Debug.WeatherLog(
string.Format(
"Sakhal::Weather::Snow::ForceStorm:: (%1) %2 -> %3",
g_Game.GetDayTime(), actual, phmnValue));
418 return true;
419 }
420
421 if ( actualOvercast ==
m_Weather.GetOvercast().GetForecast() &&
m_Weather.GetSnowfall().GetActual() >= 0.8 &&
m_Weather.GetWindSpeed() >= 10 )
422 {
423 phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
426
427 m_Weather.GetWindMagnitude().Set(
m_Weather.GetWindMagnitude().GetActual() * 0.2, phmnTime , phmnLength);
428 m_Weather.GetSnowfall().Set( phmnValue, phmnTime, phmnLength );
429
431 Debug.WeatherLog(
string.Format(
"Sakhal::Weather::Snow::ForceStorm:: (%1) %2 -> %3",
g_Game.GetDayTime(), actual, phmnValue));
432 return true;
433 }
434
435 if ( actualOvercast < 0.6 )
436 {
438 {
439 phmnValue = Math.RandomFloatInclusive( 0.02, 0.4 );
442 }
443 else
444 {
445 phmnValue = 0;
448 }
449 }
450 else if ( actualOvercast < 0.75 )
451 {
453 {
454 phmnValue = Math.RandomFloatInclusive( 0.5, 0.8 );
457 }
459 {
460 phmnValue = Math.RandomFloat( 0.3, 0.5 );
463 }
465 {
466 phmnValue = Math.RandomFloatInclusive( 0.02, 0.3 );
469 }
470 else
471 {
473 {
474 phmnValue = Math.RandomFloat( 0.3, 0.5 );
477 }
478 else
479 {
480 phmnValue = 0;
483 }
484 }
485 }
486 else
487 {
489 {
490 phmnValue = Math.RandomFloatInclusive( 0.7, 1.0 );
493 }
495 {
496 phmnValue = Math.RandomFloatInclusive( 0.5, 0.7 );
499 }
501 {
502 phmnValue = Math.RandomFloat( 0.2, 0.5 );
505 }
506 else
507 {
509 {
510 phmnValue = Math.RandomFloat( 0.5, 0.7 );
513 }
514 else
515 {
516 phmnValue = Math.RandomFloat( 0.02, 0.1 );
519 }
520 }
521 }
522
523 m_Weather.GetSnowfall().Set( phmnValue, phmnTime, phmnLength );
525
526 Debug.WeatherLog(
string.Format(
"Sakhal::Weather::Snow:: (%1) %2",
g_Game.GetDayTime(), actual));
527
528 return true;
529 }
530
532 {
534
535 return true;
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572 }
573
575 {
579
580 return true;
581 }
582 }
583
584 return false;
585 }
proto native World GetWorld()
override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
proto void GetDate(out int year, out int month, out int day, out int hour, out int minute)
Get actual ingame world time.
float SUDDENCHANGE_TIME_MULTIPLIER
float SUDDENCHANGE_LENGTH_MULTIPLIER
float WIND_DIRECTION_TIME_MULTIPLIER
ref WorldDataWeatherSettings m_WeatherDefaultSettings
int m_BadWeatherChance
weather related
float WIND_MAGNITUDE_TIME_MULTIPLIER
proto native CGame GetGame()
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.