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

◆ WeatherOnBeforeChange() [2/2]

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

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

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