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

◆ WeatherOnBeforeChange()

override bool EnochData::WeatherOnBeforeChange ( EWeatherPhenomenon type,
float actual,
float change,
float time )
inlineprotected

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

139 {
140 #ifdef WEATHER_DATA_LOGGING
141 if ( !dayInit )
142 {
143 g_Game.GetWorld().GetDate(startYear, startMonth, startDay, startHour, startMinute);
144 dayInit = true;
145 }
146 #endif
147
148 float phmnTime = 5;
149 float phmnLength = 10;
150 float phmnValue = 0;
151
152 int year, month, day, hour, minute;
153 g_Game.GetWorld().GetDate(year, month, day, hour, minute);
154
155 m_Weather.SetStorm( 1.0, m_WeatherDefaultSettings.m_StormThreshold, 20 );
156 m_Weather.GetSnowfall().SetLimits(0, 0);
157
158 m_Weather.SetRainThresholds( m_WeatherDefaultSettings.m_RainThreshold, 1.0, 60 );
159 m_Weather.SetWindMaximumSpeed( 20 );
160
161 switch (type)
162 {
163 //-----------------------------------------------------------------------------------------------------------------------------
164 case EWeatherPhenomenon.OVERCAST:
165 {
166 #ifdef WEATHER_DATA_LOGGING
167 overcastChangeCount++;
168 #endif
169
170 float windDirection, windMag;
171
172 //went something goes wrong choose some default random weather
173 phmnValue = Math.RandomFloatInclusive( 0.1, 0.4 );
174 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
175 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
176
177 //----
178 //calculate next weather
179 m_Chance = Math.RandomIntInclusive( 0, 100 );
180
181 //--
182 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
183 {
184 m_ClearWeatherChance -= ( m_StepValue * m_SameWeatherCnt); //decrease the chance of the same weather
185 }
186
187 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
188 {
189 m_ClearWeatherChance += ( m_StepValue * m_SameWeatherCnt); //increase the chance of the better weather
191 }
192
193 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
194 {
195 m_ClearWeatherChance += m_StepValue; //increase the chance of the better weather slightly
196 m_BadWeatherChance += ( m_StepValue * m_SameWeatherCnt ); //decrease the chance of the same weather
197 }
198
199 //----
200 if ( m_Chance > m_WeatherDefaultSettings.m_GlobalSuddenChance && !m_IsSuddenChange) //checks if previous weather was a sudden change
201 {
202 m_IsSuddenChange = true;
203 m_ChoosenWeather = WorldDataWeatherConstants.BAD_WEATHER;
204 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
206 }
207 else if ( m_Chance < m_ClearWeatherChance )
208 {
209 m_ChoosenWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
210 m_IsSuddenChange = false;
211 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
213 }
214 else if ( m_Chance > m_BadWeatherChance )
215 {
216 m_ChoosenWeather = WorldDataWeatherConstants.BAD_WEATHER;
217 m_IsSuddenChange = false;
218 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
220 }
221 else
222 {
223 m_ChoosenWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
224 m_IsSuddenChange = false;
225 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
227 }
228
231
232 m_ClearWeatherChance = m_WeatherDefaultSettings.m_ClearWeatherChance;
233 m_BadWeatherChance = m_WeatherDefaultSettings.m_BadWeatherChance;
234
235 //----
236 //set choosen weather
237 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
238 {
239 m_LastWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
240 #ifdef WEATHER_DATA_LOGGING
241 clearWeatherCount++;
242 #endif
243
244 phmnValue = Math.RandomFloatInclusive( 0.0, 0.3 );
245 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
246 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
247 }
248
249 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
250 {
251 m_LastWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
252 #ifdef WEATHER_DATA_LOGGING
253 cloudyWeatherCount++;
254 #endif
255
256 phmnValue = Math.RandomFloatInclusive( 0.3, 0.7 );
257 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
258 phmnLength = Math.RandomIntInclusive( 0, m_WeatherDefaultSettings.m_OvercastMinLength );
259 }
260
261 if ( m_ChoosenWeather == WorldDataWeatherConstants.BAD_WEATHER )
262 {
263 m_LastWeather = WorldDataWeatherConstants.BAD_WEATHER;
264
265 phmnValue = Math.RandomFloatInclusive( 0.7, 1.0 );
266 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
267 phmnLength = Math.RandomIntInclusive( 0, m_WeatherDefaultSettings.m_OvercastMinLength );
268
269 #ifdef WEATHER_DATA_LOGGING
270 badWeatherCount++;
271 #endif
272
273 if ( m_IsSuddenChange )
274 {
275 #ifdef WEATHER_DATA_LOGGING
276 suddenChangeCount++;
277 badWeatherCount--;
278 #endif
279
281 phmnLength *= SUDDENCHANGE_LENGTH_MULTIPLIER;
282 }
283
284 #ifdef WEATHER_DATA_LOGGING
285 if ( phmnValue > m_WeatherDefaultSettings.m_StormThreshold )
286 {
287 if ( m_IsSuddenChange )
288 {
289 suddenChangeCount--;
290 suddenStormCount++;
291 }
292 else
293 { stormCount++;
294 badWeatherCount--;
295 }
296 }
297 #endif
298 }
299
300 m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
301
302 //we want to control wind with the overcast calculation and change with it.
303 CalculateWind( m_ChoosenWeather, m_IsSuddenChange, windMag, windDirection );
304 m_Weather.GetWindMagnitude().Set( windMag, phmnTime * WIND_MAGNITUDE_TIME_MULTIPLIER , phmnTime * (1 - WIND_MAGNITUDE_TIME_MULTIPLIER) ); // magnitude change happens during the overcast change, after overcast change finishes wind will decrease a bit
305 m_Weather.GetWindDirection().Set( windDirection, phmnTime * WIND_DIRECTION_TIME_MULTIPLIER , phmnTime - (phmnTime * WIND_DIRECTION_TIME_MULTIPLIER) + phmnLength + 1000 );
306
307 CalculateVolFog(phmnValue, windMag, phmnTime);
308
309 if( m_IsSuddenChange )
310 {
311 m_Weather.GetRain().Set(Math.RandomFloatInclusive( 0.4, 0.8 ), phmnTime, 0); //forces to rain in the suddenchange.
312 }
313
314 Debug.WeatherLog(string.Format("Enoch::Weather::Overcast:: (%1) overcast: %2", g_Game.GetDayTime(), actual));
315 Debug.WeatherLog(string.Format("Enoch::Weather::Overcast::Rain:: (%1) %2", g_Game.GetDayTime(), m_Weather.GetRain().GetActual()));
316
317 #ifdef WEATHER_DATA_LOGGING
318 int testYear = 0;
319 int testMonth = 0;
320 int testDay = 0;
321 int testHour = 0;
322 int testMinute = 0;
323 g_Game.GetWorld().GetDate(testYear, testMonth, testDay, testHour, testMinute);
324
325 if ( testDay - startDay > currentDay && testHour - startHour >= 0 && testMinute - startMinute >= 0 )
326 {
327 FileHandle file = OpenFile("$profile:OvercastCountsLivonia" + (currentDay + 1) + ".log", FileMode.WRITE);
328 FPrintln(file, "================================================================");
329 FPrintln(file," ================== Day " + (currentDay + 1) + " ================== ");
330 FPrintln(file, "================================================================");
331 FPrintln(file, "Overcast Change Count: " + overcastChangeCount);
332 FPrintln(file, "Bad Weather Change Count: " + badWeatherCount);
333 FPrintln(file, "Sudden Change Count: " + suddenChangeCount);
334 FPrintln(file, "Storm Count: " + stormCount);
335 FPrintln(file, "Sudden Storm Count: " + suddenStormCount);
336 FPrintln(file, "Cloudy Weather Count: " + cloudyWeatherCount);
337 FPrintln(file, "Clear Weather Count: " + clearWeatherCount);
338
339 currentDay++;
340 CloseFile(file);
341 if ( currentDay == daysToRun )
342 {
343 g_Game.RequestExit(IDC_MAIN_QUIT);
344 }
345
346 overcastChangeCount = 0;
347 suddenChangeCount = 0;
348 stormCount = 0;
349 suddenStormCount = 0;
350 badWeatherCount = 0;
351 cloudyWeatherCount = 0;
352 clearWeatherCount = 0;
353 }
354 #endif
355
356 return true;
357 }
358 //-----------------------------------------------------------------------------------------------------------------------------
359 case EWeatherPhenomenon.RAIN:
360 {
361 float actualOvercast = m_Weather.GetOvercast().GetActual();
362
363 m_Chance = Math.RandomIntInclusive( 0, 100 );
364 phmnValue = 0.2;
365 phmnTime = 90;
366 phmnLength = 30;
367
368 if ( actualOvercast <= m_WeatherDefaultSettings.m_RainThreshold)
369 {
370 m_Weather.GetRain().Set( 0.0, m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
371 Debug.WeatherLog (string.Format("Enoch::Weather::Rain::ForceEnd:: (%1) %2 -> 0", g_Game.GetDayTime(), actual));
372 return true;
373 }
374
375 if ( actualOvercast > m_WeatherDefaultSettings.m_StormThreshold )
376 {
377 if( m_Weather.GetOvercast().GetActual() > m_Weather.GetOvercast().GetForecast() ) //ensure to have a pause to rain after the storm
378 {
379 phmnValue = 0;
380 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax ) * 2;
381 phmnLength = Math.RandomInt( m_WeatherDefaultSettings.m_CalmAfterStormTimeMin, m_WeatherDefaultSettings.m_CalmAfterStormTimeMax );
382 }
383 else
384 {
385 phmnValue = Math.RandomFloatInclusive( 0.8, 1.0 );
386 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
387 phmnLength = 0;
388 }
389
390 m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
391 Debug.WeatherLog(string.Format("Enoch::Weather::Rain::ForceStorm:: (%1) %2 -> %3", g_Game.GetDayTime(), actual, phmnValue));
392 return true;
393 }
394
395 //make a differnce in "normal rain"
396 if ( actualOvercast < 0.75 )
397 {
398 if ( m_Chance < 30 )
399 {
400 phmnValue = Math.RandomFloatInclusive( 0.1, 0.3 );
401 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
402 phmnLength = Math.RandomInt( m_WeatherDefaultSettings.m_RainLengthMin, m_WeatherDefaultSettings.m_RainLengthMax );
403 }
404 else if ( m_Chance < 60 )
405 {
406 phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
407 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
408 phmnLength = Math.RandomInt( m_WeatherDefaultSettings.m_RainLengthMin, m_WeatherDefaultSettings.m_RainLengthMax );
409 }
410 else if ( m_Chance < 85 )
411 {
412 phmnValue = Math.RandomFloatInclusive( 0.05, 0.2 );
413 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
414 phmnLength = Math.RandomInt( m_WeatherDefaultSettings.m_RainLengthMin, m_WeatherDefaultSettings.m_RainLengthMax );
415 }
416 else //also have the chance to not have rain at all
417 {
418 phmnValue = 0;
419 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
420 phmnLength = Math.RandomInt( m_WeatherDefaultSettings.m_RainLengthMin, m_WeatherDefaultSettings.m_RainLengthMax ) * 4;
421 }
422 }
423 else //overcast between storm threshold and 0.75
424 {
425 if ( m_Chance < 15 )
426 {
427 phmnValue = Math.RandomFloatInclusive( 0.4, 0.6 );
428 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
429 phmnLength = 0;
430 }
431 else if ( m_Chance < 50 )
432 {
433 phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
434 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
435 phmnLength = 0;
436 }
437 else if ( m_Chance < 90 )
438 {
439 phmnValue = Math.RandomFloatInclusive( 0.6, 0.8 );
440 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
441 phmnLength = 0;
442 }
443 else //also have the chance to not have rain at all
444 {
445 phmnValue = 0;
446 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
447 phmnLength = Math.RandomInt( m_WeatherDefaultSettings.m_RainLengthMin, m_WeatherDefaultSettings.m_RainLengthMax ) * 4;
448 }
449 }
450
451 m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
452
453 Debug.WeatherLog(string.Format("Enoch::Weather::Rain:: (%1) %2", g_Game.GetDayTime(), actual));
454 return true;
455 }
456 //-----------------------------------------------------------------------------------------------------------------------------
457 case EWeatherPhenomenon.FOG:
458 {
459 if (( hour >= 2 ) && ( hour <= 5 ))
460 {
461 m_Weather.GetFog().Set( 0.13, 900, 0 );
462 }
463 else
464 {
465 m_Weather.GetFog().Set( 0.01, 900, 0 );
466 }
467
468 Debug.WeatherLog(string.Format("Enoch::Weather::Fog:: (%1) %2", g_Game.GetDayTime(), actual));
469
470 return true;
471 }
472 //-----------------------------------------------------------------------------------------------------------------------------
473 case EWeatherPhenomenon.WIND_MAGNITUDE:
474 {
475 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
476 m_Weather.GetWindMagnitude().Set(m_Weather.GetWindMagnitude().GetActual() * 0.75, phmnTime , m_WeatherDefaultSettings.m_OvercastMaxLength); // next change will be happen with the overcast change
477
478 return true;
479 }
480 }
481 return false;
482 }
string Debug()
Определения CachedEquipmentStorageBase.c:29
DayZGame g_Game
Определения DayZGame.c:3942
EWeatherPhenomenon
Определения Weather.c:11
override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
Определения Enoch.c:484
override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
Определения Enoch.c:553
float SUDDENCHANGE_TIME_MULTIPLIER
Определения WorldData.c:13
float SUDDENCHANGE_LENGTH_MULTIPLIER
Определения WorldData.c:14
float WIND_DIRECTION_TIME_MULTIPLIER
Определения WorldData.c:16
int m_ClearWeatherChance
Определения WorldData.c:37
ref WorldDataWeatherSettings m_WeatherDefaultSettings
Определения WorldData.c:31
int m_Chance
Определения WorldData.c:46
int m_LastWeather
Определения WorldData.c:48
int m_SameWeatherCnt
Определения WorldData.c:44
int m_BadWeatherChance
weather related
Определения WorldData.c:36
int m_StepValue
Определения WorldData.c:45
float WIND_MAGNITUDE_TIME_MULTIPLIER
Определения WorldData.c:15
bool m_IsSuddenChange
Определения WorldData.c:38
Weather m_Weather
Определения WorldData.c:18
int m_ChoosenWeather
Определения WorldData.c:47
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:144

Перекрестные ссылки CalculateVolFog(), CalculateWind(), CloseFile(), FPrintln(), g_Game, IDC_MAIN_QUIT, WorldData::m_BadWeatherChance, WorldData::m_Chance, WorldData::m_ChoosenWeather, WorldData::m_ClearWeatherChance, WorldData::m_IsSuddenChange, WorldData::m_LastWeather, WorldData::m_SameWeatherCnt, WorldData::m_StepValue, WorldData::m_Weather, WorldData::m_WeatherDefaultSettings, OpenFile(), Math::RandomFloatInclusive(), Math::RandomInt(), Math::RandomIntInclusive(), WorldData::SUDDENCHANGE_LENGTH_MULTIPLIER, WorldData::SUDDENCHANGE_TIME_MULTIPLIER, Debug::WeatherLog(), WorldData::WIND_DIRECTION_TIME_MULTIPLIER и WorldData::WIND_MAGNITUDE_TIME_MULTIPLIER.