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

Перекрестные ссылки CalculateVolFog(), CalculateWind(), CloseFile(), FPrintln(), g_Game, World::GetDate(), GetGame(), CGame::GetWorld(), 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.