DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ WeatherOnBeforeChange()

override bool NasdaraData::WeatherOnBeforeChange ( EWeatherPhenomenon type,
float actual,
float change,
float time )
inlineprivate

См. определение в файле Nasdara.c строка 172

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 }
string Debug()
Определения CachedEquipmentStorageBase.c:26
DayZGame g_Game
Определения DayZGame.c:4074
SandstormController Sandstorm
Определения Sandstorm.c:135
EWeatherPhenomenon
Определения Weather.c:11
bool sandstormWillChangeOvercast
Определения Nasdara.c:5
bool previousWeatherHadSandstorm
Определения Nasdara.c:4
override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
Определения Nasdara.c:522
override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
Определения Nasdara.c:593
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
float WIND_DIRECTION_TIME_MULTIPLIER
Определения WorldData.c:17
bool m_IsSandstorm
Определения WorldData.c:46
int m_ClearWeatherChance
Определения WorldData.c:43
ref WorldDataWeatherSettings m_WeatherDefaultSettings
Определения WorldData.c:36
int m_Chance
Определения WorldData.c:54
int m_LastWeather
Определения WorldData.c:56
int m_SameWeatherCnt
Определения WorldData.c:52
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
Weather m_Weather
Определения WorldData.c:19
int m_ChoosenWeather
Определения WorldData.c:55
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 IDC_MAIN_QUIT
Определения 3_Game/DayZ/constants.c:150

Перекрестные ссылки CalculateVolFog(), CalculateWind(), CloseFile(), FPrintln(), g_Game, GetGame(), IDC_MAIN_QUIT, SandstormController::IsActive(), Debug::LogError(), WorldData::m_BadWeatherChance, WorldData::m_Chance, WorldData::m_ChoosenWeather, WorldData::m_ClearWeatherChance, WorldData::m_IsSandstorm, WorldData::m_IsSuddenChange, WorldData::m_LastWeather, WorldData::m_SameWeatherCnt, WorldData::m_StepValue, WorldData::m_Weather, WorldData::m_WeatherDefaultSettings, OpenFile(), previousWeatherHadSandstorm, Math::RandomFloatInclusive(), Math::RandomInt(), Math::RandomIntInclusive(), sandstormWillChangeOvercast, WorldData::StartSandstorm(), SandstormController::Stop(), Debug::WeatherLog(), WorldData::WIND_DIRECTION_TIME_MULTIPLIER и WorldData::WIND_MAGNITUDE_TIME_MULTIPLIER.