DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Sakhal.c
См. документацию.
1//#define WEATHER_DATA_LOGGING
3{
4 const float SPAWN_CHANCE_CHOLERA = 20;
5 const float COLD_AREA_TOOL_DMG_MODIF = 1.2;
6
7 //-------test variables & methods ------
8 #ifdef WEATHER_DATA_LOGGING
9 int overcastChangeCount = 0;
10 int directSuddenChangeCount = 0;
11 int badWeatherSuddenChangeCount = 0;
12 int thundersnowCount = 0;
13 int suddenThundersnowCount = 0;
14 int badWeatherCount = 0;
15 int cloudyWeatherCount = 0;
16 int clearWeatherCount = 0;
17 int startYear = 0;
18 int startMonth = 0;
19 int startDay = 0;
20 int startHour = 0;
21 int startMinute = 0;
22 int currentDay = 0;
23 int daysToRun = 10;
24 bool dayInit = false;
25 #endif
26 //------------------------
27
28 override void Init()
29 {
30 super.Init();
31
32 // new temperature curve settings
33 m_Sunrise_Jan = 8.41;
34 m_Sunset_Jan = 15.58;
35 m_Sunrise_Jul = 3.75;
36 m_Sunset_Jul = 20.25;
37
38 int tempIdx;
39 m_MinTemps = {-6.5, -9.5, -6.5, -9.5, 2, 6, 9, 10, 6, 1, -5, -10}; //{-13, -11, -7, -3, 2, 6, 9, 10, 6, 1, -5, -10} original values
41 {
42 for (tempIdx = 0; tempIdx < CfgGameplayHandler.GetEnvironmentMinTemps().Count(); tempIdx++)
43 {
45 }
46 }
47
48 m_MaxTemps = {-3, -5, -3, -5, 9, 14, 16, 17, 14, 8, 1, -3}; //{-6, -4, -1, 3, 9, 14, 16, 17, 14, 8, 1, -3} original values
50 {
51 for (tempIdx = 0; tempIdx < CfgGameplayHandler.GetEnvironmentMaxTemps().Count(); tempIdx++)
52 {
54 }
55 }
56 m_Pollution = m_Pollution | EPollution.HEAVYMETAL;
57
59
61
64
65 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
66 {
67 m_Weather.SetDynVolFogHeightDensity( 1, 0 );
68 m_Weather.SetDynVolFogHeightBias( 0, 0 );
69 m_Weather.GetFog().Set(0,0,1000);
70 m_Weather.GetFog().SetLimits(0,0);
71 m_Weather.GetOvercast().SetLimits(0.07, 1);
72
73 if (GetGame().IsMultiplayer())
74 {
75 m_Weather.GetOvercast().Set(Math.RandomFloat(0,0.75),0,5); //forcing a random weather at a clean server start and an instant change for overcast
76 CalculateVolFog(m_Weather.GetSnowfall().GetActual(),m_Weather.GetWindSpeed(),0);
77 }
78
79 m_DefaultPlayerRestrictedAreas = {"pra/warheadstorage.json"};
80 }
81
82
83 }
84
85 override void InitYieldBank()
86 {
87 super.InitYieldBank();
88
89 m_YieldBank.ClearAllRegisteredItems();
90
91 //fishies
92 m_YieldBank.RegisterYieldItem(new YieldItemWalleyePollock(61));
93 m_YieldBank.RegisterYieldItem(new YieldItemSteelheadTrout(36));
94
95 m_YieldBank.RegisterYieldItem(new YieldItemShrimp(1));
96
97 //fishy junk
98 m_YieldBank.RegisterYieldItem(new YieldItemJunk(1,"Wellies_Brown"));
99 m_YieldBank.RegisterYieldItem(new YieldItemJunk(1,"Wellies_Grey"));
100 m_YieldBank.RegisterYieldItem(new YieldItemJunk(1,"Wellies_Green"));
101 m_YieldBank.RegisterYieldItem(new YieldItemJunk(1,"Wellies_Black"));
102 m_YieldBank.RegisterYieldItem(new YieldItemJunkEmpty(1,"Pot"));
103
104 //non-fishies
105 m_YieldBank.RegisterYieldItem(new YieldItemDeadRabbit(1));
106 m_YieldBank.RegisterYieldItem(new YieldItemDeadFox(1));
107 //m_YieldBank.RegisterYieldItem(new YieldItemGenericSmallAnimal(1,"Animal_UrsusArctos",AnimalCatchingConstants.MASK_ENVIRO_FOREST,AnimalCatchingConstants.MASK_METHOD_LANDTRAP_MEATBAIT));
108 }
109
110 override void SetupWeatherSettings()
111 {
112 super.SetupWeatherSettings();
113
114 m_WeatherDefaultSettings.m_GlobalSuddenChance = 95; // works if the randomization value is bigger than this. we do not want to decrease the clear sky chance
115 m_WeatherDefaultSettings.m_ClearWeatherChance = 20;
116 m_WeatherDefaultSettings.m_BadWeatherChance = 65;
117 m_WeatherDefaultSettings.m_BadWeatherSuddenChance = 15;
118 }
119
121 {
122
123 m_LiquidSettings = new WorldDataLiquidSettings();
124
125 m_LiquidSettings.m_Temperatures[LIQUID_SALTWATER] = -0.5;
126 m_LiquidSettings.m_Temperatures[LIQUID_WATER] = 2.0;
127 m_LiquidSettings.m_Temperatures[LIQUID_STILLWATER] = 2.0;
128 m_LiquidSettings.m_Temperatures[LIQUID_RIVERWATER] = 2.0;
129 m_LiquidSettings.m_Temperatures[LIQUID_FRESHWATER] = 2.0;
130 m_LiquidSettings.m_Temperatures[LIQUID_CLEANWATER] = 5.0;
131 m_LiquidSettings.m_Temperatures[LIQUID_SNOW] = -5.0;
132 m_LiquidSettings.m_Temperatures[LIQUID_HOTWATER] = 90.0;
133 }
134
135 override bool WeatherOnBeforeChange( EWeatherPhenomenon type, float actual, float change, float time )
136 {
137 #ifdef WEATHER_DATA_LOGGING
138 if ( !dayInit )
139 {
140 GetGame().GetWorld().GetDate(startYear, startMonth, startDay, startHour, startMinute);
141 dayInit = true;
142 }
143 #endif
144
145 float phmnTime = 120;
146 float phmnLength = 10;
147 float phmnValue = 0;
148
149 m_Weather.GetRain().SetLimits(0, 0);//since we decided that it will not rain in sakhal...
150
151 m_Weather.GetOvercast().SetLimits(0.07, 1);
152 m_Weather.GetSnowfall().SetLimits(0, 1);
153 m_Weather.SetSnowfallThresholds( m_WeatherDefaultSettings.m_SnowfallThreshold, 1.0, 60 );
154 m_Weather.GetSnowfall().SetForecastChangeLimits(0, 1);
155
156 m_Weather.SetStorm( 1.0, m_WeatherDefaultSettings.m_ThundersnowThreshold, 45 );
157
158 m_Weather.SetWindMaximumSpeed( 20 );
159 m_Weather.GetWindMagnitude().SetForecastChangeLimits( 0, 20 );
160
161 m_Weather.GetFog().SetLimits(0,0);
162
163 switch (type)
164 {
165 //-----------------------------------------------------------------------------------------------------------------------------
166 case EWeatherPhenomenon.OVERCAST:
167 {
168 float windDirection, windMag;
169
170 #ifdef WEATHER_DATA_LOGGING
171 overcastChangeCount++;
172 #endif
173 //went something goes wrong choose some default random weather
174 phmnValue = Math.RandomFloatInclusive( 0.2, 0.7 );
175 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
176 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
177
178 //----
179 //--
180 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
181 {
182 m_ClearWeatherChance -= ( m_StepValue * m_SameWeatherCnt); //decrease the chance of the same weather
183 }
184
185 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
186 {
187 m_ClearWeatherChance += ( m_StepValue * m_SameWeatherCnt); //increase the chance of the better weather
188 }
189
190 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
191 {
192 m_ClearWeatherChance += m_StepValue; //increase the chance of the better weather slightly
193 m_BadWeatherChance += (( m_StepValue * m_SameWeatherCnt ) + m_StepValue ); //decrease the chance of the same weather rapidly
194 }
195
196 //----
197 //calculate next weather
198
199 m_Chance = Math.RandomIntInclusive( 0, 100 );
200 if ( m_Chance > m_WeatherDefaultSettings.m_GlobalSuddenChance && !m_IsSuddenChange) //checks if previous weather was a sudden change
201 {
202 #ifdef WEATHER_DATA_LOGGING
203 directSuddenChangeCount++;
204 #endif
205
206 m_IsSuddenChange = true;
207 m_ChoosenWeather = WorldDataWeatherConstants.BAD_WEATHER;
208 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
210 }
211 else if ( m_Chance < m_ClearWeatherChance )
212 {
213 m_ChoosenWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
214 m_IsSuddenChange = false;
215
216 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
218 }
219 else if ( m_Chance > m_BadWeatherChance )
220 {
221 m_ChoosenWeather = WorldDataWeatherConstants.BAD_WEATHER;
222
223 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
225
226 if ( m_IsSuddenChange )
227 {
228 m_IsSuddenChange = false;
229
230 #ifdef WEATHER_DATA_LOGGING
231 badWeatherCount++;
232 #endif
233 }
234 else
235 {
236 if ( Math.RandomIntInclusive( 0, 100 ) < m_WeatherDefaultSettings.m_BadWeatherSuddenChance )
237 {
238 m_IsSuddenChange = true;
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 {
254 m_ChoosenWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
255 m_IsSuddenChange = false;
256 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
258 }
259
262
263 m_ClearWeatherChance = m_WeatherDefaultSettings.m_ClearWeatherChance;
264 m_BadWeatherChance = m_WeatherDefaultSettings.m_BadWeatherChance;
265
266 //----
267 //set choosen weather
268 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
269 {
270 m_LastWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
271 #ifdef WEATHER_DATA_LOGGING
272 clearWeatherCount++;
273 #endif
274 phmnValue = Math.RandomFloatInclusive( 0.07, 0.3 );
275 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
276 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
277 }
278
280 {
281 #ifdef WEATHER_DATA_LOGGING
282 cloudyWeatherCount++;
283 #endif
285
286 phmnValue = Math.RandomFloatInclusive( 0.3, 0.6 );
287 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
288 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
289 }
290
291 if ( m_ChoosenWeather == WorldDataWeatherConstants.BAD_WEATHER )
292 {
293 m_LastWeather = WorldDataWeatherConstants.BAD_WEATHER;
294
295 phmnValue = Math.RandomFloatInclusive( 0.6, 1.0 );
296 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
297 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
298
299 if ( m_IsSuddenChange )
300 {
302 phmnLength *= SUDDENCHANGE_LENGTH_MULTIPLIER;
303 }
304
305 #ifdef WEATHER_DATA_LOGGING
306 if ( phmnValue > m_WeatherDefaultSettings.m_ThundersnowThreshold )
307 {
308 if ( m_IsSuddenChange )
309 {
310 suddenThundersnowCount++;
311 if ( m_Chance < m_WeatherDefaultSettings.m_GlobalSuddenChance )
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 //we want to control wind with the overcast calculation and change with it.
333 CalculateWind( m_ChoosenWeather, m_IsSuddenChange, windMag, windDirection );
334 m_Weather.GetWindMagnitude().Set( windMag, phmnTime * WIND_MAGNITUDE_TIME_MULTIPLIER , phmnTime - (phmnTime * WIND_MAGNITUDE_TIME_MULTIPLIER) + phmnLength + 1000 );
335 m_Weather.GetWindDirection().Set( windDirection, phmnTime * WIND_DIRECTION_TIME_MULTIPLIER , phmnTime - (phmnTime * WIND_DIRECTION_TIME_MULTIPLIER) + phmnLength + 1000 );
336
337 if( m_IsSuddenChange )
338 {
339 m_Weather.GetSnowfall().Set(Math.RandomFloatInclusive( 0.4, 0.8 ), phmnTime, 0); //forces to snow in the suddenchange.
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;
351 GetGame().GetWorld().GetDate(testYear, testMonth, testDay, testHour, testMinute);
352
353 if ( testDay - startDay > currentDay && testHour - startHour >= 0 && testMinute - startMinute >= 0 )
354 {
355 FileHandle file = OpenFile("$profile:OvercastCountsSakhal" + (currentDay + 1) + ".log", FileMode.WRITE);
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++;
369 CloseFile(file);
370 if ( currentDay == daysToRun )
371 {
372 g_Game.RequestExit(IDC_MAIN_QUIT);
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 //-----------------------------------------------------------------------------------------------------------------------------
390 case EWeatherPhenomenon.SNOWFALL:
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
399 if ( actualOvercast <= m_WeatherDefaultSettings.m_SnowfallThreshold )
400 {
401 m_Weather.GetSnowfall().Set( 0.0, m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMin );
402 CalculateVolFog(0.0, m_Weather.GetWindMagnitude().GetForecast(), phmnTime);
403
404 Debug.WeatherLog(string.Format("Sakhal::Weather::Snow::ForceEnd:: (%1) %2 -> 0", g_Game.GetDayTime(), actual));
405 return true;
406 }
407
408 if ( actualOvercast > m_WeatherDefaultSettings.m_ThundersnowThreshold )
409 {
410 phmnValue = Math.RandomFloatInclusive( 0.8, 1.0 );
411 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax ) * 0.5;
412 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax ) * 1.2;
413
414 m_Weather.GetSnowfall().Set( phmnValue, phmnTime, phmnLength );
415
416 CalculateVolFog(phmnValue, m_Weather.GetWindMagnitude().GetForecast(), phmnTime);
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 ) //if overcast is not changing and there was high snowfall
422 {
423 phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
424 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax ) * 0.5;
425 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax ) * 1.2;
426
427 m_Weather.GetWindMagnitude().Set(m_Weather.GetWindMagnitude().GetActual() * 0.2, phmnTime , phmnLength); // next change will be happen in phenomenon change and reset the wind speed
428 m_Weather.GetSnowfall().Set( phmnValue, phmnTime, phmnLength );
429
430 CalculateVolFog(phmnValue, m_Weather.GetWindMagnitude().GetForecast(), phmnTime);
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 ) //snowfall treshold to 0.6 overcast, snowfall in this bracket does not increase wetness
436 {
437 if ( m_Chance < 40 )
438 {
439 phmnValue = Math.RandomFloatInclusive( 0.02, 0.4 );
440 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
441 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax ) * 1.2;
442 }
443 else //also have the chance to not have snow at all
444 {
445 phmnValue = 0;
446 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
447 phmnLength = Math.RandomIntInclusive(m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax) * 2;
448 }
449 }
450 else if ( actualOvercast < 0.75 ) //0.6 to 0.75 overcast
451 {
452 if ( m_Chance < 30 )
453 {
454 phmnValue = Math.RandomFloatInclusive( 0.5, 0.8 );
455 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
456 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax );
457 }
458 else if ( m_Chance < 60 )
459 {
460 phmnValue = Math.RandomFloat( 0.3, 0.5 ); //0.5 snowfall starts to increase wetness
461 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
462 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax );
463 }
464 else if ( m_Chance < 75 )
465 {
466 phmnValue = Math.RandomFloatInclusive( 0.02, 0.3 );
467 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
468 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax );
469 }
470 else //also have the chance to not have snow at all
471 {
472 if ( m_IsSuddenChange )
473 {
474 phmnValue = Math.RandomFloat( 0.3, 0.5 ); //0.5 snowfall starts to increase wetness
475 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
476 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax );
477 }
478 else
479 {
480 phmnValue = 0;
481 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
482 phmnLength = Math.RandomIntInclusive(m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax) * 1.2;
483 }
484 }
485 }
486 else //0.75 to thunderstorm threshold overcast
487 {
488 if ( m_Chance < 35 )
489 {
490 phmnValue = Math.RandomFloatInclusive( 0.7, 1.0 );
491 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
492 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax );
493 }
494 else if ( m_Chance < 75 )
495 {
496 phmnValue = Math.RandomFloatInclusive( 0.5, 0.7 );
497 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
498 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax ) ;
499 }
500 else if ( m_Chance < 85 )
501 {
502 phmnValue = Math.RandomFloat( 0.2, 0.5 ); //0.5 snowfall starts to increase wetness
503 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
504 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax );
505 }
506 else
507 {
508 if ( m_IsSuddenChange )
509 {
510 phmnValue = Math.RandomFloat( 0.5, 0.7 ); //0.5 snowfall starts to increase wetness
511 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
512 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax );
513 }
514 else
515 {
516 phmnValue = Math.RandomFloat( 0.02, 0.1 );
517 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
518 phmnLength = Math.RandomIntInclusive(m_WeatherDefaultSettings.m_SnowfallLengthMin, m_WeatherDefaultSettings.m_SnowfallLengthMax) * 1.2;
519 }
520 }
521 }
522
523 m_Weather.GetSnowfall().Set( phmnValue, phmnTime, phmnLength );
524 CalculateVolFog(phmnValue, m_Weather.GetWindMagnitude().GetForecast(), phmnTime);
525
526 Debug.WeatherLog(string.Format("Sakhal::Weather::Snow:: (%1) %2", g_Game.GetDayTime(), actual));
527
528 return true;
529 }
530 //-----------------------------------------------------------------------------------------------------------------------------
531 case EWeatherPhenomenon.FOG:
532 {
533 m_Weather.GetFog().Set(0,0,100000);
534
535 return true;
536
537 /*float fogMin = 0.0;
538 float fogMax = 0.15;
539 float fogTime = 1800.0;
540
541 if ( m_Weather.GetWindSpeed() >= 10 )
542 {
543 m_Weather.GetFog().Set( 0, 300, 0);
544 Debug.WeatherLog(string.Format("Sakhal::Weather::Fog:: (%1) %2", g_Game.GetDayTime(), actual));
545
546 return true;
547 }
548
549 if ( m_Weather.GetOvercast().GetActual() < 0.3 )
550 {
551 fogMin = 0.0;
552 fogMax = 0.1;
553 fogTime = 600.0;
554 }
555 else if ( m_Weather.GetOvercast().GetActual() > 0.6 )
556 {
557 fogMin = 0.1;
558 fogMax = 0.3;
559 fogTime = 600.0;
560 }
561 else
562 {
563 fogMin = 0.0;
564 fogMax = 0.15;
565 fogTime = 600.0;
566 }
567
568 m_Weather.GetFog().Set( Math.RandomFloatInclusive( fogMin, fogMax ), fogTime, 0);
569 Debug.WeatherLog(string.Format("Sakhal::Weather::Fog:: (%1) %2", g_Game.GetDayTime(), actual));
570
571 return true;*/
572 }
573 //-----------------------------------------------------------------------------------------------------------------------------
574 case EWeatherPhenomenon.WIND_MAGNITUDE:
575 {
576 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_SnowfallTimeMin, m_WeatherDefaultSettings.m_SnowfallTimeMax );
577 m_Weather.GetWindMagnitude().Set(m_Weather.GetWindMagnitude().GetActual() / 0.2, phmnTime , m_WeatherDefaultSettings.m_OvercastMaxTime + 1000); // next change will be happen with the overcast or snowfall change
578 CalculateVolFog(m_Weather.GetSnowfall().GetForecast(), m_Weather.GetWindMagnitude().GetForecast(), phmnTime);
579
580 return true;
581 }
582 }
583
584 return false;
585 }
586
587 protected override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
588 {
589 magnitude = 5;
590 direction = 0;
591
592 float windChance = Math.RandomIntInclusive( 0, 100 );
593
594 if ( newWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
595 {
596 if ( windChance < 15 )
597 {
598 magnitude = Math.RandomFloatInclusive( 2 , 4 );
599 direction = Math.RandomFloatInclusive( -0.35 , 0.35);
600 }
601 else if ( windChance < 90 )
602 {
603 magnitude = Math.RandomFloatInclusive( 3 , 6 );
604 direction = Math.RandomFloatInclusive( 0 , 2.2);
605 }
606 else
607 {
608 magnitude = Math.RandomFloatInclusive( 8 , 15 );
609 direction = Math.RandomFloatInclusive( -3.0 , -2.25);
610 }
611 }
612 else if ( newWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
613 {
614 if ( windChance < 45 )
615 {
616 magnitude = Math.RandomFloatInclusive( 5 , 10 );
617 direction = Math.RandomFloatInclusive( 1.0 , 1.25);
618 }
619 else if ( windChance < 90 )
620 {
621 magnitude = Math.RandomFloatInclusive( 8 , 14 );
622 direction = Math.RandomFloatInclusive( -1.8, -1.4);
623 }
624 else
625 {
626 magnitude = Math.RandomFloatInclusive( 2 , 4 );
627 direction = Math.RandomFloatInclusive( -1.0 , -0.4);
628 }
629 }
630 else
631 {
632 if ( suddenChange || m_Weather.GetOvercast().GetForecast() > 0.85 )
633 {
634 magnitude = Math.RandomFloatInclusive( 18 , 20 );
635 direction = Math.RandomFloatInclusive( 2.25 , 3.14);
636 }
637 else if ( windChance < 45 )
638 {
639 magnitude = Math.RandomFloatInclusive( 6 , 12 );
640 direction = Math.RandomFloatInclusive( -1.8 , -1.4);
641 }
642 else if ( windChance < 90 )
643 {
644 magnitude = Math.RandomFloatInclusive( 8 , 20 );
645 direction = Math.RandomFloatInclusive( 1.6 , 2.0);
646 }
647 else
648 {
649 magnitude = Math.RandomFloatInclusive( 4 , 10 );
650 direction = Math.RandomFloatInclusive( 1.5, 1.75 );
651 }
652 }
653
654 CalculateVolFog(m_Weather.GetSnowfall().GetForecast(), magnitude, 60);
655 }
656
657 protected override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)// in sakhal volfog supports snowfall effect
658 {
659 float maxVolFogDistanceDensity = Math.Lerp( 0, 0.35, Easing.EaseInQuart(lerpValue) );
660 float minVolFogDistanceDensity = Math.Lerp(0.001, 0.01, m_Weather.GetOvercast().GetActual());
661
662 if (minVolFogDistanceDensity > maxVolFogDistanceDensity)
663 maxVolFogDistanceDensity = minVolFogDistanceDensity;
664
665 float volFogDistanceDensity = Math.Lerp( minVolFogDistanceDensity, maxVolFogDistanceDensity, windMagnitude/m_Weather.GetWindMaximumSpeed() );
666 m_Weather.SetDynVolFogDistanceDensity(volFogDistanceDensity, changeTime);
667 }
668
669 override float GetAgentSpawnChance(eAgents agent)
670 {
671 if (agent == eAgents.CHOLERA)
673
674 return 0;
675 }
676
678 {
680 }
681
682 bool LogWeatherData() //called from mission file to check if the logging should start
683 {
684 #ifdef WEATHER_DATA_LOGGING
685 return true;
686 #endif
687 return false;
688 }
689
691 const int CLEAR_WEATHER = 1;
692 const int CLOUDY_WEATHER = 2;
693 const int BAD_WEATHER = 3;
694}
DayZGame g_Game
Определения DayZGame.c:3868
eAgents
Определения EAgents.c:3
@ Count
Определения RandomGeneratorSyncManager.c:8
EWeatherPhenomenon
Определения Weather.c:11
void YieldItemJunk(int baseWeight, string type)
Определения YieldsFishingJunk.c:44
proto native World GetWorld()
static array< float > GetEnvironmentMaxTemps()
Определения CfgGameplayHandler.c:151
static array< float > GetEnvironmentMinTemps()
Определения CfgGameplayHandler.c:146
static void WeatherLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения Debug.c:195
Определения Debug.c:2
static float EaseInQuart(float t)
Определения Easing.c:56
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Определения Easing.c:3
Определения EnMath.c:7
override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
Определения Sakhal.c:657
override void Init()
Определения Sakhal.c:28
override void InitYieldBank()
Определения Sakhal.c:85
const float SPAWN_CHANCE_CHOLERA
Определения Sakhal.c:4
override float GetColdAreaToolDamageModifier()
Определения Sakhal.c:677
const int BAD_WEATHER
Определения Sakhal.c:693
const int CLOUDY_WEATHER
Определения Sakhal.c:692
const int CLEAR_WEATHER
DEPRECATED (see WorldDataWeatherConstants)
Определения Sakhal.c:691
override bool WeatherOnBeforeChange(EWeatherPhenomenon type, float actual, float change, float time)
Определения Sakhal.c:135
bool LogWeatherData()
Определения Sakhal.c:682
const float COLD_AREA_TOOL_DMG_MODIF
Определения Sakhal.c:5
override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
Определения Sakhal.c:587
override float GetAgentSpawnChance(eAgents agent)
Определения Sakhal.c:669
override void SetupLiquidTemperatures()
Определения Sakhal.c:120
override void SetupWeatherSettings()
Определения Sakhal.c:110
Определения Sakhal.c:3
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
ref WorldDataLiquidSettings m_LiquidSettings
Определения WorldData.c:32
bool m_Pollution
Определения WorldData.c:29
float WIND_DIRECTION_TIME_MULTIPLIER
Определения WorldData.c:16
float m_Sunset_Jan
Определения WorldData.c:25
float m_Sunrise_Jan
Определения WorldData.c:24
int m_ClearWeatherChance
Определения WorldData.c:37
ref WorldDataWeatherSettings m_WeatherDefaultSettings
Определения WorldData.c:31
void WorldData()
Определения WorldData.c:50
ref CatchYieldBank m_YieldBank
Определения WorldData.c:30
int m_Chance
Определения WorldData.c:46
float m_TemperatureInsideBuildingsModifier
how many % of environment temperature can be lowered by clouds
Определения WorldData.c:10
int m_LastWeather
Определения WorldData.c:48
float m_MaxTemps[12]
Определения WorldData.c:22
int m_SameWeatherCnt
Определения WorldData.c:44
float m_MinTemps[12]
Определения WorldData.c:23
ref TStringArray m_DefaultPlayerRestrictedAreas
Определения WorldData.c:33
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
float m_UniversalTemperatureSourceCapModifier
Определения WorldData.c:41
Weather m_Weather
Определения WorldData.c:18
float m_Sunset_Jul
Определения WorldData.c:27
int m_ChoosenWeather
Определения WorldData.c:47
float m_Sunrise_Jul
Определения WorldData.c:26
Определения YieldsFish.c:156
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 LIQUID_STILLWATER
Определения constants.c:550
const int LIQUID_HOTWATER
Определения constants.c:551
const int LIQUID_FRESHWATER
Определения constants.c:549
const int LIQUID_CLEANWATER
Определения constants.c:552
const int LIQUID_WATER
Определения constants.c:539
const int LIQUID_RIVERWATER
Определения constants.c:540
const int LIQUID_SALTWATER
Определения constants.c:548
const int LIQUID_SNOW
Определения constants.c:547
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 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
Определения constants.c:144