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