Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
chernarusplus.c
Go to the documentation of this file.
1 class ChernarusPlusData extends WorldData
2 {
3  //----- weather vars
4  const float RAIN_THRESHOLD = 0.6;
5  const float STORM_THRESHOLD = 0.9;
6 
7  const int OVERCAST_MIN_TIME = 600;
8  const int OVERCAST_MAX_TIME = 900;
9 
10  const int RAIN_TIME_MIN = 60;
11  const int RAIN_TIME_MAX = 120;
12 
13  const int CLEAR_WEATHER = 1;
14  const int CLOUDY_WEATHER = 2;
15  const int BAD_WEATHER = 3;
16 
17  const int CLEAR_WEATHER_CHANCE = 30;
18  const int BAD_WEATHER_CHANCE = 80;
19 
20  protected int m_clearWeatherChance = CLEAR_WEATHER_CHANCE;
21  //protected int m_badCloudyChance = 80;
22  protected int m_badWeatherChance = BAD_WEATHER_CHANCE;
23 
24  protected int m_sameWeatherCnt = 0;
25  protected int m_stepValue = 5;
26  protected int m_chance = 50;
27 
28  protected int m_choosenWeather = 1;
29  protected int m_lastWeather = 0;
30 
31  //All Chernarus firing coordinates
32  protected static const ref array<vector> CHERNARUS_ARTY_STRIKE_POS =
33  {
34  "-500.00 165.00 5231.69",
35  "-500.00 300.00 9934.41",
36  "10406.86 192.00 15860.00",
37  "4811.75 370.00 15860.00",
38  "-500.00 453.00 15860.00"
39  };
40 
41  override void Init()
42  {
43  super.Init();
44 
45  // new temperature curve settings
46  m_Sunrise_Jan = 8.54;
47  m_Sunset_Jan = 15.52;
48  m_Sunrise_Jul = 3.26;
49  m_Sunset_Jul = 20.73;
50 
51  int tempIdx;
52  m_MinTemps = {-3,-2,0,4,9,14,18,17,12,7,4,0};
53  if (CfgGameplayHandler.GetEnvironmentMinTemps() && CfgGameplayHandler.GetEnvironmentMinTemps().Count() == 12)
54  {
55  for (tempIdx = 0; tempIdx < CfgGameplayHandler.GetEnvironmentMinTemps().Count(); tempIdx++)
56  {
57  m_MinTemps[tempIdx] = CfgGameplayHandler.GetEnvironmentMinTemps().Get(tempIdx);
58  }
59  }
60 
61  m_MaxTemps = {3,5,7,14,19,24,26,25,21,16,10,5};
62  if (CfgGameplayHandler.GetEnvironmentMaxTemps() && CfgGameplayHandler.GetEnvironmentMaxTemps().Count() == 12)
63  {
64  for (tempIdx = 0; tempIdx < CfgGameplayHandler.GetEnvironmentMaxTemps().Count(); tempIdx++)
65  {
66  m_MaxTemps[tempIdx] = CfgGameplayHandler.GetEnvironmentMaxTemps().Get(tempIdx);
67  }
68  }
69 
70  m_FiringPos = CHERNARUS_ARTY_STRIKE_POS;
71  }
72 
73  override bool WeatherOnBeforeChange( EWeatherPhenomenon type, float actual, float change, float time )
74  {
75  int phmnTime = 5;
76  int phmnLength = 10;
77  float phmnValue = 0;
78 
79  m_Weather.SetStorm( 1.0, STORM_THRESHOLD, 45 );
80 
81  m_Weather.SetRainThresholds( 0.0, 1.0, 60 );
82  m_Weather.SetWindMaximumSpeed( 20 );
83  m_Weather.SetWindFunctionParams( 0.1, 1.0, 20 );
84 
85  switch (type)
86  {
87  //-----------------------------------------------------------------------------------------------------------------------------
88  case EWeatherPhenomenon.OVERCAST:
89 
90  //went something goes wrong choose some default random weather
91  phmnValue = Math.RandomFloatInclusive( 0.2, 0.7 );
92  phmnTime = Math.RandomIntInclusive( OVERCAST_MIN_TIME, OVERCAST_MAX_TIME );
93  phmnLength = Math.RandomIntInclusive( OVERCAST_MIN_TIME, OVERCAST_MAX_TIME );
94 
95  //----
96  //calculate next weather
97  m_chance = Math.RandomIntInclusive( 0, 100 );
98 
99  //--
100  if ( m_lastWeather == CLEAR_WEATHER )
101  {
102  m_clearWeatherChance -= ( m_stepValue * m_sameWeatherCnt); //decrease the chance of the same weather
103  }
104 
105  if ( m_lastWeather == CLOUDY_WEATHER )
106  {
107  m_clearWeatherChance += ( m_stepValue * m_sameWeatherCnt); //increase the chance of the better weather
108  //m_badWeatherChance += ( m_stepValue * m_sameWeatherCnt);
109  }
110 
111  if ( m_lastWeather == BAD_WEATHER )
112  {
113  m_clearWeatherChance += m_stepValue; //increase the chance of the better weather slightly
114  m_badWeatherChance += (( m_stepValue * m_sameWeatherCnt ) + m_stepValue ); //decrease the chance of the same weather rapidly
115  }
116 
117  //----
118  if ( m_chance < m_clearWeatherChance )
119  {
120  m_choosenWeather = CLEAR_WEATHER;
121  if ( m_lastWeather == CLEAR_WEATHER )
122  m_sameWeatherCnt ++;
123  }
124  else if ( m_chance > m_badWeatherChance )
125  {
126  m_choosenWeather = BAD_WEATHER;
127  if ( m_lastWeather == BAD_WEATHER )
128  m_sameWeatherCnt ++;
129  }
130  else
131  {
132  m_choosenWeather = CLOUDY_WEATHER;
133  if ( m_lastWeather == CLOUDY_WEATHER )
134  m_sameWeatherCnt ++;
135  }
136 
137  if ( m_choosenWeather != m_lastWeather )
138  m_sameWeatherCnt = 0;
139 
140  m_clearWeatherChance = CLEAR_WEATHER_CHANCE;
141  m_badWeatherChance = BAD_WEATHER_CHANCE;
142 
143  //----
144  //set choosen weather
145  if ( m_choosenWeather == CLEAR_WEATHER )
146  {
147  m_lastWeather = CLEAR_WEATHER;
148 
149  phmnValue = Math.RandomFloatInclusive( 0.0, 0.3 );
150  phmnTime = Math.RandomIntInclusive( OVERCAST_MIN_TIME, OVERCAST_MAX_TIME );
151  phmnLength = Math.RandomIntInclusive( OVERCAST_MIN_TIME, OVERCAST_MAX_TIME );
152  }
153 
154  if ( m_choosenWeather == CLOUDY_WEATHER )
155  {
156  m_lastWeather = CLOUDY_WEATHER;
157 
158  phmnValue = Math.RandomFloatInclusive( 0.3, 0.6 );
159  phmnTime = Math.RandomIntInclusive( OVERCAST_MIN_TIME, OVERCAST_MAX_TIME );
160  phmnLength = Math.RandomIntInclusive( OVERCAST_MIN_TIME, OVERCAST_MAX_TIME );
161  }
162 
163  if ( m_choosenWeather == BAD_WEATHER )
164  {
165  m_lastWeather = BAD_WEATHER;
166 
167  phmnValue = Math.RandomFloatInclusive( 0.6, 1.0 );
168  phmnTime = Math.RandomIntInclusive( OVERCAST_MIN_TIME, OVERCAST_MAX_TIME );
169  phmnLength = Math.RandomIntInclusive( OVERCAST_MIN_TIME, OVERCAST_MAX_TIME );
170  }
171 
172  m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
173 
174  Debug.WeatherLog(string.Format("Chernarus::Weather::Overcast:: (%1) overcast: %2", g_Game.GetDayTime(), actual));
175  Debug.WeatherLog(string.Format("Chernarus::Weather::Overcast::Rain:: (%1) %2", g_Game.GetDayTime(), m_Weather.GetRain().GetActual()));
176 
177  return true;
178 
179  //-----------------------------------------------------------------------------------------------------------------------------
180  case EWeatherPhenomenon.RAIN:
181 
182  float actualOvercast = m_Weather.GetOvercast().GetActual();
183 
184  m_chance = Math.RandomIntInclusive( 0, 100 );
185  phmnValue = 0.2;
186  phmnTime = 90;
187  phmnLength = 30;
188 
189  if ( actualOvercast <= RAIN_THRESHOLD )
190  {
191  m_Weather.GetRain().Set( 0.0, RAIN_TIME_MIN, RAIN_TIME_MAX );
192  Debug.WeatherLog(string.Format("Chernarus::Weather::Rain::ForceEnd:: (%1) %2 -> 0", g_Game.GetDayTime(), actual));
193  return true;
194  }
195 
196  if ( actualOvercast > STORM_THRESHOLD )
197  {
198  phmnValue = Math.RandomFloatInclusive( 0.8, 1.0 );
199  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
200  phmnLength = 0;
201 
202  m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
203  Debug.WeatherLog(string.Format("Chernarus::Weather::Rain::ForceStorm:: (%1) %2 -> %3", g_Game.GetDayTime(), actual, phmnValue));
204  return true;
205  }
206 
207  //make a differnce in "normal rain"
208  if ( actualOvercast < 0.75 )
209  {
210  if ( m_chance < 30 )
211  {
212  phmnValue = Math.RandomFloatInclusive( 0.1, 0.3 );
213  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
214  phmnLength = 0;
215  }
216  else if ( m_chance < 60 )
217  {
218  phmnValue = Math.RandomFloatInclusive( 0.2, 0.5 );
219  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
220  phmnLength = 0;
221  }
222  else if ( m_chance < 80 )
223  {
224  phmnValue = Math.RandomFloatInclusive( 0.0, 0.2 );
225  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
226  phmnLength = 0;
227  }
228  else //also have the chance to not have rain at all
229  {
230  phmnValue = 0;
231  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
232  phmnLength = 120;
233  }
234  }
235  else
236  {
237  if ( m_chance < 25 )
238  {
239  phmnValue = Math.RandomFloatInclusive( 0.5, 0.7 );
240  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
241  phmnLength = 0;
242  }
243  else if ( m_chance < 50 )
244  {
245  phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
246  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
247  phmnLength = 0;
248  }
249  else if ( m_chance < 75 )
250  {
251  phmnValue = Math.RandomFloatInclusive( 0.4, 0.6 );
252  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
253  phmnLength = 0;
254  }
255  else //also have the chance to not have rain at all
256  {
257  phmnValue = 0;
258  phmnTime = Math.RandomInt( RAIN_TIME_MIN, RAIN_TIME_MAX );
259  phmnLength = 120;
260  }
261  }
262 
263  m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
264 
265  Debug.WeatherLog(string.Format("Chernarus::Weather::Rain:: (%1) %2", g_Game.GetDayTime(), actual));
266 
267  return true;
268 
269  //-----------------------------------------------------------------------------------------------------------------------------
270  case EWeatherPhenomenon.FOG:
271 
272  float fogMin = 0.0;
273  float fogMax = 0.15;
274  float fogTime = 1800.0;
275 
276  float fogyMorning = Math.RandomFloatInclusive( 0.0, 1.0 );
277 
278  if ( fogyMorning > 0.85 )
279  {
280  if ( (g_Game.GetDayTime() > 4 && g_Game.GetDayTime() < 7 ) )
281  {
282  fogMin = 0.10;
283  fogMax = 0.35;
284  fogTime = 300;
285  }
286  }
287 
288  if ( m_Weather.GetOvercast().GetActual() < 0.3 )
289  {
290  fogMin = 0.0;
291  fogMax = 0.08;
292  fogTime = 900.0;
293  }
294 
295  m_Weather.GetFog().Set( Math.RandomFloatInclusive( fogMin, fogMax ), fogTime, 0);
296 
297  Debug.WeatherLog(string.Format("Chernarus::Weather::Fog:: (%1) %2", g_Game.GetDayTime(), actual));
298 
299  return true;
300  }
301 
302  return false;
303  }
304 };
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
WorldData
Keeps information about currently loaded world, like temperature.
Definition: worlddata.c:2
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
array< vector >
EWeatherPhenomenon
EWeatherPhenomenon
Definition: weather.c:10
Debug
Definition: debug.c:13
Math
Definition: enmath.c:6
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7