DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Nasdara.c
См. документацию.
1//#define WEATHER_DATA_LOGGING
3{
6
7 //-------test variables & methods ------
8 #ifdef WEATHER_DATA_LOGGING
9 int overcastChangeCount = 0;
10 int badWeatherCount = 0;
11 int cloudyWeatherCount = 0;
12 int clearWeatherCount = 0;
13 int sandstormCount = 0;
14 int startYear = 0;
15 int startMonth = 0;
16 int startDay = 0;
17 int startHour = 0;
18 int startMinute = 0;
19 int currentDay = 0;
20 int daysToRun = 10;
21 bool dayInit = false;
22 #endif
23 //------------------------
24
25 override void Init()
26 {
27 super.Init();
28
29 // new temperature curve settings
30 m_Sunrise_Jan = 7.15;
31 m_Sunset_Jan = 16.85;
32 m_Sunrise_Jul = 4.85;
33 m_Sunset_Jul = 19.15;
34
38
39 int tempIdx;
40 m_MinTemps = {3.4, 5.4, 7.4, 8.4, 9.4, 12.4, 14.4, 13.4, 11.4, 8.4, 7.4, 4.4}; //{3, 5, 7, 8, 9, 12, 14, 13, 11, 8, 7, 4} original values
42 {
43 for (tempIdx = 0; tempIdx < CfgGameplayHandler.GetEnvironmentMinTemps().Count(); tempIdx++)
44 {
46 }
47 }
48
49 m_MaxTemps = {17.4, 19.4, 22.4, 25.4, 29.4, 34.4, 38.4, 37.4, 34.4, 28.4, 22.4, 18.4}; //{15, 17, 20, 23, 27, 32, 36, 35, 32, 26, 20, 16} original values
51 {
52 for (tempIdx = 0; tempIdx < CfgGameplayHandler.GetEnvironmentMaxTemps().Count(); tempIdx++)
53 {
55 }
56 }
57
58 m_WorldWindCoef = 0.5;
59
61
62 m_TemperaturePerHeightReductionModifier = 0.005; //if this value changes, calculate new map temperatures. map is elavated for ~80 meters
66
74
77
78 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
79 {
80 m_Weather.SetDynVolFogHeightBias( 0, 0 );
81 m_Weather.GetFog().Set(0,0,1000);
82 m_Weather.GetFog().SetLimits(0,0);
83 m_Weather.GetOvercast().SetLimits(0.1, 1);
84 m_Weather.GetRain().SetLimits(0, 0.3);
85 m_Weather.SetRainThresholds( m_WeatherDefaultSettings.m_RainThreshold, 1.0, 60 );
86 m_Weather.GetSnowfall().SetLimits(0, 0);
87 m_Weather.SetStorm( 0.1, m_WeatherDefaultSettings.m_StormThreshold, 120 );
88 m_Weather.SetWindMaximumSpeed( 20 );
89 m_Weather.GetWindMagnitude().SetForecastChangeLimits( 0, 20 );
90
91 if (GetGame().IsMultiplayer())
92 {
93 float startingOvercast = Math.RandomFloat(0.2,0.3);
94 m_Weather.GetOvercast().Set(startingOvercast,0,5); //forcing a random weather at a clean server start and an instant change for overcast
95 CalculateVolFog(startingOvercast, m_Weather.GetWindSpeed(), 0);
96 }
97 }
98 }
99
100 override void InitYieldBank()
101 {
102 super.InitYieldBank();
103
104 m_YieldBank.ClearAllRegisteredItems();
105
106 //fishies
107 m_YieldBank.RegisterYieldItem(new YieldItemCarp(42));
108 m_YieldBank.RegisterYieldItem(new YieldItemCatfish(42));
109 m_YieldBank.RegisterYieldItem(new YieldItemRoundGoby(15));
110
111 //fishy junk
112 m_YieldBank.RegisterYieldItem(new YieldItemJunk(1,"SandalsShoes_Grey"));
113 m_YieldBank.RegisterYieldItem(new YieldItemJunk(1,"SandalsShoes_Brown"));
114 m_YieldBank.RegisterYieldItem(new YieldItemJunk(1,"SandalsShoes_BlueNavy"));
115 m_YieldBank.RegisterYieldItem(new YieldItemJunk(1,"SandalsShoes_Black"));
116 m_YieldBank.RegisterYieldItem(new YieldItemJunkEmpty(1,"Pot"));
117
118 //non-fishies
119 m_YieldBank.RegisterYieldItem(new YieldItemDeadRabbit(2));
120 m_YieldBank.RegisterYieldItem(new YieldItemDeadRooster(1));
121 m_YieldBank.RegisterYieldItem(new YieldItemDeadChicken_White(1));
122 m_YieldBank.RegisterYieldItem(new YieldItemDeadChicken_Spotted(1));
123 m_YieldBank.RegisterYieldItem(new YieldItemDeadChicken_Brown(1));
124 m_YieldBank.RegisterYieldItem(new YieldItemDeadFox(2));
125 m_YieldBank.RegisterYieldItem(new YieldItemDeadLizard(4));
126 }
127
128 override void SetupWeatherSettings()
129 {
130 super.SetupWeatherSettings();
131
132 m_WeatherDefaultSettings.m_ClearWeatherChance = 40;
133 m_WeatherDefaultSettings.m_BadWeatherChance = 75;
134 m_WeatherDefaultSettings.m_RainThreshold = 0.40;
135 m_WeatherDefaultSettings.m_StormThreshold = 1.1; // we do not want lightning
136 }
137
139 {
140 m_LiquidSettings = new WorldDataLiquidSettings();
141
142 m_LiquidSettings.m_Temperatures[LIQUID_SALTWATER] = -0.5;
143 m_LiquidSettings.m_Temperatures[LIQUID_WATER] = 20.0;
144 m_LiquidSettings.m_Temperatures[LIQUID_STILLWATER] = 20.0;
145 m_LiquidSettings.m_Temperatures[LIQUID_RIVERWATER] = 20.0;
146 m_LiquidSettings.m_Temperatures[LIQUID_FRESHWATER] = 20.0;
147 m_LiquidSettings.m_Temperatures[LIQUID_CLEANWATER] = 8.0;
148 m_LiquidSettings.m_Temperatures[LIQUID_SNOW] = -5.0;
149 m_LiquidSettings.m_Temperatures[LIQUID_HOTWATER] = 90.0;
150 }
151
152 override void SetupDustEffects()
153 {
154 super.SetupDustEffects();
155
156 m_DustEffectsSettings.m_GroundEffectEnable = true;
157 m_DustEffectsSettings.m_GroundEffectMinWindStrength = 8;
158 m_DustEffectsSettings.m_GroundEffectDistance = 30;
159 m_DustEffectsSettings.m_GroundEffectFrequency = 24;
160 m_DustEffectsSettings.m_GroundEffectWindWeight = 0;
161 m_DustEffectsSettings.m_GroundEffectEndPoindTest = true;
162 m_DustEffectsSettings.m_CloudEffectEnable = true;
163 m_DustEffectsSettings.m_CloudEffectMinWindStrength = 5;
164 m_DustEffectsSettings.m_CloudEffectCooldownMin = 6;
165 m_DustEffectsSettings.m_CloudEffectCooldownMax = 10;
166 m_DustEffectsSettings.m_CloudEffectDurationMin = 2;
167 m_DustEffectsSettings.m_CloudEffectDurationMax = 7;
168 m_DustEffectsSettings.m_CloudEffectDistance = 16;
169 m_DustEffectsSettings.m_CloudEffectFromSurface = true;
170 }
171
172 override bool WeatherOnBeforeChange( EWeatherPhenomenon type, float actual, float change, float time )
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
186 m_Weather.GetRain().SetLimits(0, 0.3);
187 m_Weather.SetRainThresholds( m_WeatherDefaultSettings.m_RainThreshold, 1.0, 60 );
188
189 m_Weather.GetOvercast().SetLimits(0.07, 1);
190 m_Weather.GetSnowfall().SetLimits(0, 0);
191
192 m_Weather.SetStorm( 0.1, m_WeatherDefaultSettings.m_StormThreshold, 120 );
193
194 m_Weather.SetWindMaximumSpeed( 20 );
195 m_Weather.GetWindMagnitude().SetForecastChangeLimits( 0, 20 );
196
197 m_Weather.GetFog().SetLimits(0,0);
198
199 Sandstorm sandstorm = m_Weather.GetSandstorm();
200
201 switch (type)
202 {
203 //-----------------------------------------------------------------------------------------------------------------------------
204 case EWeatherPhenomenon.OVERCAST:
205 {
206 float windDirection, windMag;
207 float windMagLength = m_WeatherDefaultSettings.m_OvercastMaxLength;
208
209 #ifdef WEATHER_DATA_LOGGING
210 overcastChangeCount++;
211 #endif
212
214 {
215 phmnValue = Math.RandomFloatInclusive( 0.75, 1 );
216 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength ) * 1.4;
217 m_Weather.GetOvercast().Set( phmnValue, 120, phmnLength );
219 return true;
220 }
221
222 //went something goes wrong choose some default random weather
223 phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
224 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
225 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
226
227 //----
228 //--
229 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
230 {
231 m_ClearWeatherChance -= ( m_StepValue * m_SameWeatherCnt); //decrease the chance of the same weather
232 }
233
234 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
235 {
236 m_ClearWeatherChance += ( m_StepValue * m_SameWeatherCnt); //increase the chance of the better weather
237 }
238
239 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
240 {
241 m_ClearWeatherChance += m_StepValue; //increase the chance of the better weather slightly
242 m_BadWeatherChance += (( m_StepValue * m_SameWeatherCnt ) + m_StepValue ); //decrease the chance of the same weather rapidly
243 }
244
245 //----
246 //calculate next weather
247
248 m_Chance = Math.RandomIntInclusive( 0, 100 );
250 {
251 m_ChoosenWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
252
253 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
255 }
256 else if ( m_Chance > m_BadWeatherChance )
257 {
258 m_ChoosenWeather = WorldDataWeatherConstants.BAD_WEATHER;
259
260 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
262 }
263 else
264 {
265 m_ChoosenWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
266 m_IsSuddenChange = false;
267 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
269 }
270
273
274 m_ClearWeatherChance = m_WeatherDefaultSettings.m_ClearWeatherChance;
275 m_BadWeatherChance = m_WeatherDefaultSettings.m_BadWeatherChance;
276
277 //----
278 //set choosen weather
279 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
280 {
281 m_LastWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
282 #ifdef WEATHER_DATA_LOGGING
283 clearWeatherCount++;
284 #endif
285 phmnValue = Math.RandomFloatInclusive( 0.07, 0.2 );
286 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
287 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
288 }
289
290 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
291 {
292 m_LastWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
293 #ifdef WEATHER_DATA_LOGGING
294 cloudyWeatherCount++;
295 #endif
296
297 phmnValue = Math.RandomFloatInclusive( 0.2, 0.45 );
298 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
299 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
300 }
301
302 if ( m_ChoosenWeather == WorldDataWeatherConstants.BAD_WEATHER )
303 {
304 m_LastWeather = WorldDataWeatherConstants.BAD_WEATHER;
305
306 phmnValue = Math.RandomFloatInclusive( 0.45, 0.75 );
307 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
308 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
309
310 #ifdef WEATHER_DATA_LOGGING
311 badWeatherCount++;
312 #endif
313 }
314
315 //we want to control wind with the overcast calculation and change with it.
316 CalculateWind( m_ChoosenWeather, false, windMag, windDirection );
317
319 {
320 phmnLength = 0;
321 sandstormWillChangeOvercast = true; //this will force the overcast to be in a higher value when the sandstorm ends.
324
325 if (phmnValue < 0.75) //TODO: remove once second layer is added
326 {
327 phmnValue = 0.75;
328 }
329
330 windMagLength = 99999; //we want sandstorm to stay in the map until the next real overcast change.
331 }
333 {
334 Debug.LogError("Two consecutive sandstorm tried to occur");
335 windMag = Math.RandomFloatInclusive( 3, 7 );
336
337 if ( sandstorm.IsActive() )
338 {
339 sandstorm.Stop(phmnTime * WIND_MAGNITUDE_TIME_MULTIPLIER, true);
340 windDirection = -1.5;
341 }
342 else
343 {
344 windDirection = Math.RandomFloatInclusive( 0.20 , 0.90);
345 }
346
347 m_IsSandstorm = false;
349
350 windMagLength = phmnTime * (1 - WIND_MAGNITUDE_TIME_MULTIPLIER); // magnitude change happens during the overcast change, after overcast change finishes wind will decrease a bit
351 }
352 else
353 {
355 if ( sandstorm.IsActive() )
356 {
357 sandstorm.Stop(phmnTime * WIND_MAGNITUDE_TIME_MULTIPLIER, true);
358 windDirection = m_Weather.GetWindDirection().GetActual();
359 }
360
361 windMagLength = phmnTime * (1 - WIND_MAGNITUDE_TIME_MULTIPLIER); // magnitude change happens during the overcast change, after overcast change finishes wind will decrease a bit
362 }
363
364 m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
365
366 m_Weather.GetWindMagnitude().Set( windMag, phmnTime * WIND_MAGNITUDE_TIME_MULTIPLIER, windMagLength );
367 m_Weather.GetWindDirection().Set( windDirection, phmnTime * WIND_DIRECTION_TIME_MULTIPLIER, 99999 ); // we do not want direction to change outside of CalculateWind method
368
369 CalculateVolFog(phmnValue, windMag, phmnTime);
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 {
384 FileHandle file = OpenFile("$profile:OvercastCountsNasdara" + (currentDay + 1) + ".log", FileMode.WRITE);
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++;
395 CloseFile(file);
396 if ( currentDay == daysToRun )
397 {
398 g_Game.RequestExit(IDC_MAIN_QUIT);
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 //-----------------------------------------------------------------------------------------------------------------------------
413 case EWeatherPhenomenon.RAIN:
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
422 if ( actualOvercast < m_WeatherDefaultSettings.m_RainThreshold )
423 {
424 m_Weather.GetRain().Set( 0.0, m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
425 Debug.WeatherLog(string.Format("Nasdara::Weather::Rain::ForceEnd:: (%1) %2 -> 0", g_Game.GetDayTime(), actual));
426 return true;
427 }
428 else
429 {
430 if ( m_Chance < 8 )
431 {
432 phmnValue = Math.RandomFloatInclusive( 0.05, 0.3 );
433 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
434 phmnLength = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax ) * 4;
435 }
436 else
437 {
438 phmnValue = 0.0;
439 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
440 phmnLength = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax ) * 10;
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 //-----------------------------------------------------------------------------------------------------------------------------
451 case EWeatherPhenomenon.FOG:
452 {
453 m_Weather.GetFog().Set(0,0,100000);
454
455 return true;
456 }
457 //-----------------------------------------------------------------------------------------------------------------------------
458 case EWeatherPhenomenon.WIND_MAGNITUDE:
459 {
460 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
461 float sereneWindMag = m_Weather.GetWindMagnitude().GetActual() * 0.6;
462
463 if ( sereneWindMag > m_WeatherDefaultSettings.m_SandstormMinWindMagnitude )
464 sereneWindMag = m_WeatherDefaultSettings.m_SandstormMinWindMagnitude - 1;
465
466 m_Weather.GetWindMagnitude().Set(sereneWindMag, phmnTime , m_WeatherDefaultSettings.m_OvercastMaxLength); // next change will be happen with the overcast change
467
468 CalculateVolFog(m_Weather.GetOvercast().GetActual(), sereneWindMag, phmnTime);
469
470 if (m_IsSandstorm)
471 {
472 sandstorm.Stop(phmnTime, true);
473 m_IsSandstorm = false;
474 }
475
476 return true;
477 }
478 case EWeatherPhenomenon.WIND_DIRECTION:
479 {
480 m_Weather.GetWindDirection().Set( 0, 60 , 100000);
481 Debug.LogError("Wind direction has been changed out of overcast change");
482
483 if( sandstorm.IsActive() )
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 }
496
497 protected override void OnSandstormStart(bool isStartedByWeather)
498 {
499 if (!isStartedByWeather)
500 {
501 float windMagnitude = Math.RandomFloatInclusive( m_WeatherDefaultSettings.m_SandstormMinWindMagnitude , m_Weather.GetWindMaximumSpeed() );
502 float windDirection = Math.RandomFloatInclusive( m_WeatherDefaultSettings.m_SandstormMinWindDirection, m_WeatherDefaultSettings.m_SandstormMaxWindDirection);
503 float randomizedOvercast = Math.RandomFloatInclusive( 0.75, 1 );
504 float fadeInTime = 40;
505
506 m_Weather.GetWindMagnitude().Set( windMagnitude, fadeInTime, 99999 );
507 m_Weather.GetWindDirection().Set( windDirection, fadeInTime * 0.5 , 99999 );
508 m_Weather.GetOvercast().Set( randomizedOvercast , fadeInTime * 2, 99999);
509 CalculateVolFog(randomizedOvercast, windMagnitude, fadeInTime * 2);
510 }
511 }
512
513 protected override void OnSandstormStop(bool calledFromWeather)
514 {
515 if (!calledFromWeather)
516 {
517 // Called once the sandstorm is fully gone :)
518 m_Weather.GetOvercast().Set(m_Weather.GetOvercast().GetActual(), 0, 0);
519 }
520 }
521
522 protected override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
523 {
524 magnitude = 5;
525 direction = 0;
526
527 float windChance = Math.RandomIntInclusive( 0, 99 );
528 m_IsSandstorm = false;
529
530 if ( newWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
531 {
532 if ( windChance < 40 )
533 {
534 magnitude = Math.RandomFloatInclusive( 8 , 15 );
535 direction = Math.RandomFloatInclusive( 2.10 , 2.70);
536 }
537 else if ( windChance < 80 )
538 {
539 magnitude = Math.RandomFloatInclusive( 3 , 6 );
540 direction = Math.RandomFloatInclusive( 0.60 , 1.90);
541 }
542 else
543 {
544 magnitude = Math.RandomFloatInclusive( 4 , 12 );
545 direction = Math.RandomFloatInclusive( 0.30 , 0.80);
546 }
547 }
548 else if ( newWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
549 {
550 if ( windChance < 45 )
551 {
552 magnitude = Math.RandomFloatInclusive( 5 , 10 );
553 direction = Math.RandomFloatInclusive( 0 , 0.4);
554 }
555 else
556 {
557 magnitude = Math.RandomFloatInclusive( 2 , 8 );
558 direction = Math.RandomFloatInclusive( -1.40, 0);
559 }
560 }
561 else //bad weather
562 {
563 float sandstormChance = 8;
564 float windRatio = 0.4;
565
566 sandstormChance = Math.Clamp( sandstormChance * m_WeatherDefaultSettings.m_sandstormFrequency, 0, 100 );
567
568 float highWindChance = ( 100 - sandstormChance ) * windRatio;
569
570 if ( !previousWeatherHadSandstorm && windChance < sandstormChance )
571 {
572 magnitude = Math.RandomFloatInclusive( m_WeatherDefaultSettings.m_SandstormMinWindMagnitude, m_Weather.GetWindMaximumSpeed() );
573 direction = Math.RandomFloatInclusive( m_WeatherDefaultSettings.m_SandstormMinWindDirection, m_WeatherDefaultSettings.m_SandstormMaxWindDirection);
574 m_IsSandstorm = true;
575
576 #ifdef WEATHER_DATA_LOGGING
577 sandstormCount++;
578 #endif
579 }
580 else if ( windChance < sandstormChance + highWindChance )
581 {
582 magnitude = Math.RandomFloatInclusive( 7 , 15 );
583 direction = Math.RandomFloatInclusive( -1.18 , -0.7);
584 }
585 else
586 {
587 magnitude = Math.RandomFloatInclusive( 3, 7 );
588 direction = Math.RandomFloatInclusive( -2.5 , -2.0);
589 }
590 }
591 }
592
593 protected override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
594 {
595 float maxVolFogDistanceDensity = 0.006;
596 float minVolFogDistanceDensity = 0.001;
597
598 maxVolFogDistanceDensity = Math.Lerp(maxVolFogDistanceDensity * 0.5, maxVolFogDistanceDensity, lerpValue);
599
600 if (minVolFogDistanceDensity > maxVolFogDistanceDensity)
601 maxVolFogDistanceDensity = minVolFogDistanceDensity;
602
603 float volFogDistanceDensity = Math.Lerp( minVolFogDistanceDensity, maxVolFogDistanceDensity, windMagnitude/m_Weather.GetWindMaximumSpeed() );
604
605 m_Weather.SetDynVolFogDistanceDensity(volFogDistanceDensity, changeTime);
606
607 float volFogHeightDensity = Math.Lerp(0.95, 0.98, lerpValue);
608 m_Weather.SetDynVolFogHeightDensity(volFogHeightDensity, changeTime );
609 }
610
611 bool LogWeatherData() //called from mission file to check if the logging should start
612 {
613 #ifdef WEATHER_DATA_LOGGING
614 return true;
615 #endif
616 return false;
617 }
618
619 override int GetDaytime()
620 {
621 int year, month, day, hour, minute;
622 g_Game.GetWorld().GetDate(year, month, day, hour, minute);
623
624 WorldData worldData = g_Game.GetMission().GetWorldData();
625 int dayNumber = DayOfYear(day, month);
626 float sunriseTimeStart = GetSunriseTime(dayNumber);
627 float sunsetTimeStart = GetSunsetTime(dayNumber);
628 float currentTime = hour + (minute / 60);
629 float dayLength = sunsetTimeStart - sunriseTimeStart;
630 float dawnT = sunriseTimeStart + (dayLength * 0.1);
631 float morningT = sunriseTimeStart + (dayLength * 0.35);
632 float noonT = sunriseTimeStart + (dayLength * 0.65);
633 float afternoonT = sunriseTimeStart + (dayLength * 0.9);
634
635 if (currentTime >= sunriseTimeStart && currentTime < dawnT)
636 return WorldDataDaytime.DAWN;
637 if (currentTime >= dawnT && currentTime < morningT)
639 if (currentTime >= morningT && currentTime < noonT)
640 return WorldDataDaytime.NOON;
641 if (currentTime >= noonT && currentTime < afternoonT)
643 if (currentTime >= afternoonT && currentTime < sunsetTimeStart)
645 if (currentTime >= sunsetTimeStart && currentTime < (sunsetTimeStart + 2))
646 return WorldDataDaytime.DUSK;
647
648 return WorldDataDaytime.NIGHT;
649 }
650}
DayZGame g_Game
Определения DayZGame.c:4074
@ Count
Определения RandomGeneratorSyncManager.c:8
SandstormController Sandstorm
Определения Sandstorm.c:135
EWeatherPhenomenon
Определения Weather.c:11
void YieldItemJunk(int baseWeight, string type)
Определения YieldsFishingJunk.c:44
static array< float > GetEnvironmentMaxTemps()
Определения CfgGameplayHandler.c:156
static array< float > GetEnvironmentMinTemps()
Определения CfgGameplayHandler.c:151
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Определения 3_Game/DayZ/tools/Debug.c:318
static void WeatherLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения 3_Game/DayZ/tools/Debug.c:256
Определения 3_Game/DayZ/tools/Debug.c:2
Определения EnMath.c:7
override void InitYieldBank()
Определения Nasdara.c:100
bool sandstormWillChangeOvercast
Определения Nasdara.c:5
override void SetupWeatherSettings()
Определения Nasdara.c:128
bool previousWeatherHadSandstorm
Определения Nasdara.c:4
override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
Определения Nasdara.c:522
override void OnSandstormStart(bool isStartedByWeather)
Определения Nasdara.c:497
override bool WeatherOnBeforeChange(EWeatherPhenomenon type, float actual, float change, float time)
Определения Nasdara.c:172
override void SetupLiquidTemperatures()
Определения Nasdara.c:138
bool LogWeatherData()
Определения Nasdara.c:611
override void SetupDustEffects()
Определения Nasdara.c:152
override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
Определения Nasdara.c:593
override void OnSandstormStop(bool calledFromWeather)
Определения Nasdara.c:513
override void Init()
Определения Nasdara.c:25
override int GetDaytime()
Определения Nasdara.c:619
Определения Nasdara.c:3
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...
Определения WorldData.c:477
ref WorldDataLiquidSettings m_LiquidSettings
Определения WorldData.c:37
int m_ShortestDayOfYear
Определения WorldData.c:30
float WIND_DIRECTION_TIME_MULTIPLIER
Определения WorldData.c:17
bool m_IsSandstorm
Определения WorldData.c:46
float GetSunsetTime(float dayNumber)
Returns sunset time for passed day.
Определения WorldData.c:393
float m_Sunset_Jan
Определения WorldData.c:26
float m_WorldWindCoef
Определения WorldData.c:45
float m_Sunrise_Jan
Определения WorldData.c:25
int m_ClearWeatherChance
Определения WorldData.c:43
ref WorldDataWeatherSettings m_WeatherDefaultSettings
Определения WorldData.c:36
void WorldData()
Определения WorldData.c:58
int m_LongestDayOfYear
Определения WorldData.c:31
float m_WaterContactTemperatureModifier
Определения WorldData.c:12
float m_TemperaturePerHeightReductionModifier
directly accesible (defined/overriden in Init())
Определения WorldData.c:8
float m_CloudsTemperatureEffectModifier
amount of °C reduced for each 100 meteres of height above water level
Определения WorldData.c:9
ref CatchYieldBank m_YieldBank
Определения WorldData.c:35
int m_Chance
Определения WorldData.c:54
ref map< int, float > m_TemperatureUnderSunModifier
Определения WorldData.c:11
int DayOfYear(int day, int month)
Returns number of day in current year (eg. 1 - 365)
Определения WorldData.c:365
float m_TemperatureInsideBuildingsModifier
how many % of environment temperature can be lowered by clouds
Определения WorldData.c:10
int m_LastWeather
Определения WorldData.c:56
float GetSunriseTime(float dayNumber)
Returns sunrise time for passed day.
Определения WorldData.c:382
float m_MaxTemps[12]
Определения WorldData.c:23
int m_SameWeatherCnt
Определения WorldData.c:52
ref DustEffectsSettings m_DustEffectsSettings
Определения WorldData.c:38
float m_MinTemps[12]
Определения WorldData.c:24
int m_BadWeatherChance
weather related
Определения WorldData.c:42
int m_StepValue
Определения WorldData.c:53
float WIND_MAGNITUDE_TIME_MULTIPLIER
Определения WorldData.c:16
bool m_IsSuddenChange
Определения WorldData.c:44
float m_UniversalTemperatureSourceCapModifier
Определения WorldData.c:49
Weather m_Weather
Определения WorldData.c:19
float m_Sunset_Jul
Определения WorldData.c:28
int m_ChoosenWeather
Определения WorldData.c:55
float m_Sunrise_Jul
Определения WorldData.c:27
static int NIGHT
Определения WorldData.c:611
static int DAWN
Определения WorldData.c:614
static int DUSK
Определения WorldData.c:613
static int EVENING
Определения WorldData.c:618
static int AFTERNOON
Определения WorldData.c:617
static int MORNING
Определения WorldData.c:615
static int NOON
Определения WorldData.c:616
Определения WorldData.c:609
Определения YieldsFish.c:190
DayZGame GetGame()
Определения gameplay.c:636
FileMode
Определения EnSystem.c:383
proto void CloseFile(FileHandle file)
Close the File.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
int[] FileHandle
Определения EnSystem.c:390
proto void FPrintln(FileHandle file, void var)
Write to file and add new line.
const int LIQUID_STILLWATER
Определения 3_Game/DayZ/constants.c:589
const int LIQUID_HOTWATER
Определения 3_Game/DayZ/constants.c:590
const int LIQUID_FRESHWATER
Определения 3_Game/DayZ/constants.c:588
const int LIQUID_CLEANWATER
Определения 3_Game/DayZ/constants.c:591
const int LIQUID_WATER
Определения 3_Game/DayZ/constants.c:578
const int LIQUID_RIVERWATER
Определения 3_Game/DayZ/constants.c:579
const int LIQUID_SALTWATER
Определения 3_Game/DayZ/constants.c:587
const int LIQUID_SNOW
Определения 3_Game/DayZ/constants.c:586
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:106
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
const int IDC_MAIN_QUIT
Определения 3_Game/DayZ/constants.c:150