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

◆ WeatherOnBeforeChange()

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

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

93 {
94 #ifdef WEATHER_DATA_LOGGING
95 if ( !dayInit )
96 {
97 g_Game.GetWorld().GetDate(startYear, startMonth, startDay, startHour, startMinute);
98 dayInit = true;
99 }
100 #endif
101
102 float phmnTime = 5;
103 float phmnLength = 10;
104 float phmnValue = 0;
105
106 m_Weather.SetStorm( 1.0, m_WeatherDefaultSettings.m_StormThreshold, 45 );
107 m_Weather.GetSnowfall().SetLimits(0, 0);
108
109 m_Weather.SetRainThresholds( m_WeatherDefaultSettings.m_RainThreshold, 1.0, 60 );
110 m_Weather.SetWindMaximumSpeed( 20 );
111
112 if (m_Weather.GetDynVolFogHeightBias() < m_WeatherDefaultSettings.m_DefaultHeigthBias)
113 {
114 m_Weather.SetDynVolFogHeightBias(m_WeatherDefaultSettings.m_DefaultHeigthBias);
115 }
116
117 switch (type)
118 {
119 //-----------------------------------------------------------------------------------------------------------------------------
120 case EWeatherPhenomenon.OVERCAST:
121 {
122 #ifdef WEATHER_DATA_LOGGING
123 overcastChangeCount++;
124 #endif
125
126 float windDirection, windMag;
127
128 //went something goes wrong choose some default random weather
129 phmnValue = Math.RandomFloatInclusive( 0.2, 0.7 );
130 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
131 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
132
133 //----
134 //calculate next weather
135 m_Chance = Math.RandomIntInclusive( 0, 100 );
136
137 //--
138 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
139 {
140 m_ClearWeatherChance -= ( m_StepValue * m_SameWeatherCnt); //decrease the chance of the same weather
141 }
142
143 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
144 {
145 m_ClearWeatherChance += ( m_StepValue * m_SameWeatherCnt); //increase the chance of the better weather
146 }
147
148 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
149 {
150 m_ClearWeatherChance += m_StepValue; //increase the chance of the better weather slightly
151 m_BadWeatherChance += (( m_StepValue * m_SameWeatherCnt ) + m_StepValue ); //decrease the chance of the same weather rapidly
152 }
153
154 //----
156 {
157 m_ChoosenWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
158 if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
160 }
161 else if ( m_Chance > m_BadWeatherChance )
162 {
163 m_ChoosenWeather = WorldDataWeatherConstants.BAD_WEATHER;
164 if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
166 }
167 else
168 {
169 m_ChoosenWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
170 if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
172 }
173
176
177 m_ClearWeatherChance = m_WeatherDefaultSettings.m_ClearWeatherChance;
178 m_BadWeatherChance = m_WeatherDefaultSettings.m_BadWeatherChance;
179
180 //----
181 //set choosen weather
182 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
183 {
184 m_LastWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
185 #ifdef WEATHER_DATA_LOGGING
186 clearWeatherCount++;
187 #endif
188
189 phmnValue = Math.RandomFloatInclusive( 0.0, 0.3 );
190 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
191 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
192 }
193
194 if ( m_ChoosenWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
195 {
196 m_LastWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
197 #ifdef WEATHER_DATA_LOGGING
198 cloudyWeatherCount++;
199 #endif
200
201 phmnValue = Math.RandomFloatInclusive( 0.3, 0.6 );
202 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
203 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
204 }
205
206 if ( m_ChoosenWeather == WorldDataWeatherConstants.BAD_WEATHER )
207 {
208 m_LastWeather = WorldDataWeatherConstants.BAD_WEATHER;
209 #ifdef WEATHER_DATA_LOGGING
210 badWeatherCount++;
211 #endif
212
213 phmnValue = Math.RandomFloatInclusive( 0.6, 1.0 );
214 phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
215 phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
216 }
217
218 m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
219
220 CalculateWind( m_ChoosenWeather, false, windMag, windDirection );
221 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
222 m_Weather.GetWindDirection().Set( windDirection, phmnTime * WIND_DIRECTION_TIME_MULTIPLIER , phmnTime - (phmnTime * WIND_DIRECTION_TIME_MULTIPLIER) + phmnLength + 1000 );
223
224 CalculateVolFog(phmnValue, windMag, phmnTime);
225
226 Debug.WeatherLog(string.Format("Chernarus::Weather::Overcast:: (%1) overcast: %2", g_Game.GetDayTime(), actual));
227 Debug.WeatherLog(string.Format("Chernarus::Weather::Overcast::Rain:: (%1) %2", g_Game.GetDayTime(), m_Weather.GetRain().GetActual()));
228
229 #ifdef WEATHER_DATA_LOGGING
230 int testYear = 0;
231 int testMonth = 0;
232 int testDay = 0;
233 int testHour = 0;
234 int testMinute = 0;
235 g_Game.GetWorld().GetDate(testYear, testMonth, testDay, testHour, testMinute);
236
237 if ( testDay - startDay > currentDay && testHour - startHour >= 0 && testMinute - startMinute >= 0 )
238 {
239 FileHandle file = OpenFile("$profile:OvercastCountsCharnarus" + (currentDay + 1) + ".log", FileMode.WRITE);
240 FPrintln(file, "================================================================");
241 FPrintln(file," ================== Day " + (currentDay + 1) + " ================== ");
242 FPrintln(file, "================================================================");
243 FPrintln(file, "Overcast Change Count: " + overcastChangeCount);
244 FPrintln(file, "Bad Weather Change Count: " + badWeatherCount);
245 FPrintln(file, "Cloudy Weather Count: " + cloudyWeatherCount);
246 FPrintln(file, "Clear Weather Count: " + clearWeatherCount);
247
248 currentDay++;
249 CloseFile(file);
250 if ( currentDay == daysToRun )
251 {
252 g_Game.RequestExit(IDC_MAIN_QUIT);
253 }
254
255 overcastChangeCount = 0;
256 badWeatherCount = 0;
257 cloudyWeatherCount = 0;
258 clearWeatherCount = 0;
259 }
260 #endif
261
262 return true;
263 }
264 //-----------------------------------------------------------------------------------------------------------------------------
265 case EWeatherPhenomenon.RAIN:
266 {
267 float actualOvercast = m_Weather.GetOvercast().GetActual();
268
269 m_Chance = Math.RandomIntInclusive( 0, 100 );
270 phmnValue = 0.2;
271 phmnTime = 90;
272 phmnLength = 30;
273
274 if ( actualOvercast <= m_WeatherDefaultSettings.m_RainThreshold )
275 {
276 m_Weather.GetRain().Set( 0.0, m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
277 Debug.WeatherLog(string.Format("Chernarus::Weather::Rain::ForceEnd:: (%1) %2 -> 0", g_Game.GetDayTime(), actual));
278 return true;
279 }
280
281 if ( actualOvercast > m_WeatherDefaultSettings.m_StormThreshold )
282 {
283 phmnValue = Math.RandomFloatInclusive( 0.8, 1.0 );
284 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
285 phmnLength = 0;
286
287 m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
288 Debug.WeatherLog(string.Format("Chernarus::Weather::Rain::ForceStorm:: (%1) %2 -> %3", g_Game.GetDayTime(), actual, phmnValue));
289 return true;
290 }
291
292 //make a differnce in "normal rain"
293 if ( actualOvercast < 0.75 )
294 {
295 if ( m_Chance < 30 )
296 {
297 phmnValue = Math.RandomFloatInclusive( 0.1, 0.3 );
298 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
299 phmnLength = 0;
300 }
301 else if ( m_Chance < 60 )
302 {
303 phmnValue = Math.RandomFloatInclusive( 0.2, 0.5 );
304 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
305 phmnLength = 0;
306 }
307 else if ( m_Chance < 80 )
308 {
309 phmnValue = Math.RandomFloatInclusive( 0.0, 0.2 );
310 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
311 phmnLength = 0;
312 }
313 else //also have the chance to not have rain at all
314 {
315 phmnValue = 0;
316 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
317 phmnLength = m_WeatherDefaultSettings.m_RainLengthMax;
318 }
319 }
320 else
321 {
322 if ( m_Chance < 25 )
323 {
324 phmnValue = Math.RandomFloatInclusive( 0.5, 0.7 );
325 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
326 phmnLength = 0;
327 }
328 else if ( m_Chance < 50 )
329 {
330 phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
331 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
332 phmnLength = 0;
333 }
334 else if ( m_Chance < 75 )
335 {
336 phmnValue = Math.RandomFloatInclusive( 0.4, 0.6 );
337 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
338 phmnLength = 0;
339 }
340 else //also have the chance to not have rain at all
341 {
342 phmnValue = 0;
343 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
344 phmnLength = m_WeatherDefaultSettings.m_RainLengthMax;
345 }
346 }
347
348 m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
349
350 Debug.WeatherLog(string.Format("Chernarus::Weather::Rain:: (%1) %2", g_Game.GetDayTime(), actual));
351
352 return true;
353 }
354 //-----------------------------------------------------------------------------------------------------------------------------
355 case EWeatherPhenomenon.FOG:
356 {
357 float fogMin = 0.0;
358 float fogMax = 0.15;
359 float fogTime = 1800.0;
360
361 float fogyMorning = Math.RandomFloatInclusive( 0.0, 1.0 );
362
363 if ( fogyMorning > 0.85 )
364 {
365 if ( (g_Game.GetDayTime() > 4 && g_Game.GetDayTime() < 7 ) )
366 {
367 fogMin = 0.10;
368 fogMax = 0.35;
369 fogTime = 300;
370 }
371 }
372
373 if ( m_Weather.GetOvercast().GetActual() < 0.3 )
374 {
375 fogMin = 0.0;
376 fogMax = 0.08;
377 fogTime = 900.0;
378 }
379
380 m_Weather.GetFog().Set( Math.RandomFloatInclusive( fogMin, fogMax ), fogTime, 0);
381
382 Debug.WeatherLog(string.Format("Chernarus::Weather::Fog:: (%1) %2", g_Game.GetDayTime(), actual));
383
384 return true;
385 }
386 //-----------------------------------------------------------------------------------------------------------------------------
387 case EWeatherPhenomenon.WIND_MAGNITUDE:
388 {
389 phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
390 m_Weather.GetWindMagnitude().Set(m_Weather.GetWindMagnitude().GetActual() * 0.75, phmnTime , m_WeatherDefaultSettings.m_OvercastMaxLength); // next change will be happen with the overcast change
391
392 return true;
393 }
394 }
395
396 return false;
397 }
string Debug()
Определения CachedEquipmentStorageBase.c:29
DayZGame g_Game
Определения DayZGame.c:3942
EWeatherPhenomenon
Определения Weather.c:11
override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
Определения ChernarusPlus.c:468
override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
Определения ChernarusPlus.c:399
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
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_LastWeather, WorldData::m_SameWeatherCnt, WorldData::m_StepValue, WorldData::m_Weather, WorldData::m_WeatherDefaultSettings, OpenFile(), Math::RandomFloatInclusive(), Math::RandomInt(), Math::RandomIntInclusive(), Debug::WeatherLog(), WorldData::WIND_DIRECTION_TIME_MULTIPLIER и WorldData::WIND_MAGNITUDE_TIME_MULTIPLIER.