DayZ 1.24
Loading...
Searching...
No Matches
Enoch.c
Go to the documentation of this file.
1class EnochData extends WorldData
2{
3 const float RAIN_THRESHOLD = 0.6;
4 const float STORM_THRESHOLD = 0.85;
5
6 const int OVERCAST_MIN_TIME = 600;
7 const int OVERCAST_MAX_TIME = 900;
8
9 const int RAIN_TIME_MIN = 60;
10 const int RAIN_TIME_MAX = 120;
11
12 const int CLEAR_WEATHER = 1;
13 const int CLOUDY_WEATHER = 2;
14 const int BAD_WEATHER = 3;
15
16 const int CLEAR_WEATHER_CHANCE = 50;
17 const int BAD_WEATHER_CHANCE = 75;
18
19 protected int m_clearWeatherChance = CLEAR_WEATHER_CHANCE;
20 //protected int m_badCloudyChance = 80;
21 protected int m_badWeatherChance = BAD_WEATHER_CHANCE;
22
23 protected int m_stepValue = 5;
24
25 protected int m_sameWeatherCnt = 0;
26 protected int m_chance = 50;
27
28 protected int m_choosenWeather = 1;
29 protected int m_lastWeather = 0;
30
31 protected static const ref array<vector> LIVONIA_ARTY_STRIKE_POS = {
32 "7440.00 417.00 -500.00",
33 "-500.00 276.00 5473.00",
34 "-500.00 265.00 9852.00",
35 "4953.00 240.00 13300.00",
36 "9620.00 188.00 13300.00",
37 "13300.00 204.00 10322.00",
38 "13300.00 288.00 6204.00",
39 "13300.00 296.00 -500.00"
40 };
41
42 override void Init()
43 {
44 super.Init();
45
46 // new temperature curve settings
47 m_Sunrise_Jan = 8.4;
48 m_Sunset_Jan = 15.63;
49 m_Sunrise_Jul = 3.65;
50 m_Sunset_Jul = 20.35;
51
52 int tempIdx;
53 m_MinTemps = {-7, -7.4, -4.1, 1.5, 7, 11.3, 13.4, 13.1, 9.3, 5.3, 0.8, -3.6};
55 {
58 }
59
60 m_MaxTemps = {-2.5, -2.1, 2.3, 9, 15.5, 19.4, 20.9, 20.4, 16, 10.5, 4.2, 0.1};
62 {
65 }
66
67 m_FiringPos = LIVONIA_ARTY_STRIKE_POS;
68 }
69
70 override bool WeatherOnBeforeChange(EWeatherPhenomenon type, float actual, float change, float time)
71 {
72 int phmnTime = 5;
73 int phmnLength = 10;
74 float phmnValue = 0;
75
76 m_Weather.SetStorm(1.0, STORM_THRESHOLD, 20);
77
78 m_Weather.SetRainThresholds(0.0, 1.0, 60);
79 m_Weather.SetWindMaximumSpeed(20);
80 m_Weather.SetWindFunctionParams(0.1, 1.0, 20);
81
82 switch (type)
83 {
84 //-----------------------------------------------------------------------------------------------------------------------------
85 case EWeatherPhenomenon.OVERCAST:
86
87 //went something goes wrong choose some default random weather
89 phmnTime = Math.RandomIntInclusive(OVERCAST_MIN_TIME, OVERCAST_MAX_TIME);
90 phmnLength = Math.RandomIntInclusive(OVERCAST_MIN_TIME, OVERCAST_MAX_TIME);
91
92 //----
93 //calculate next weather
94 m_chance = Math.RandomIntInclusive(0, 100);
95
96 //--
97 if (m_lastWeather == CLEAR_WEATHER)
98 {
99 m_clearWeatherChance -= (m_stepValue * m_sameWeatherCnt); //decrease the chance of the same weather
100 }
101
102 if (m_lastWeather == CLOUDY_WEATHER)
103 {
104 m_clearWeatherChance += (m_stepValue * m_sameWeatherCnt); //increase the chance of the better weather
105 m_badWeatherChance -= (m_stepValue * m_sameWeatherCnt);
106 }
107
108 if (m_lastWeather == BAD_WEATHER)
109 {
110 m_clearWeatherChance += m_stepValue; //increase the chance of the better weather slightly
111 m_badWeatherChance += (m_stepValue * m_sameWeatherCnt); //decrease the chance of the same weather
112 }
113
114 //----
115 if (m_chance < m_clearWeatherChance)
116 {
117 m_choosenWeather = CLEAR_WEATHER;
118 if (m_lastWeather == CLEAR_WEATHER)
119 m_sameWeatherCnt ++;
120 }
121 else if (m_chance > m_badWeatherChance)
122 {
123 m_choosenWeather = BAD_WEATHER;
124 if (m_lastWeather == BAD_WEATHER)
125 m_sameWeatherCnt ++;
126 }
127 else
128 {
129 m_choosenWeather = CLOUDY_WEATHER;
130 if (m_lastWeather == CLOUDY_WEATHER)
131 m_sameWeatherCnt ++;
132 }
133
134 if (m_choosenWeather != m_lastWeather)
135 m_sameWeatherCnt = 0;
136
137 m_clearWeatherChance = CLEAR_WEATHER_CHANCE;
138 m_badWeatherChance = BAD_WEATHER_CHANCE;
139
140 //----
141 //set choosen weather
142 if (m_choosenWeather == CLEAR_WEATHER)
143 {
144 m_lastWeather = CLEAR_WEATHER;
145
147 phmnTime = Math.RandomIntInclusive(OVERCAST_MIN_TIME, OVERCAST_MAX_TIME);
148 phmnLength = Math.RandomIntInclusive(OVERCAST_MIN_TIME, OVERCAST_MAX_TIME);
149 }
150
151 if (m_choosenWeather == CLOUDY_WEATHER)
152 {
153 m_lastWeather = CLOUDY_WEATHER;
154
156 phmnTime = Math.RandomIntInclusive(OVERCAST_MIN_TIME, OVERCAST_MAX_TIME);
157 phmnLength = Math.RandomIntInclusive(0, OVERCAST_MIN_TIME);
158 }
159
160 if (m_choosenWeather == BAD_WEATHER)
161 {
162 m_lastWeather = BAD_WEATHER;
163
165 phmnTime = Math.RandomIntInclusive(OVERCAST_MIN_TIME, OVERCAST_MAX_TIME);
166 phmnLength = Math.RandomIntInclusive(0, OVERCAST_MIN_TIME);
167 }
168
169 m_Weather.GetOvercast().Set(phmnValue, phmnTime, phmnLength);
170
171 Debug.WeatherLog(string.Format("Enoch::Weather::Overcast:: (%1) overcast: %2", g_Game.GetDayTime(), actual));
172 Debug.WeatherLog(string.Format("Enoch::Weather::Overcast::Rain:: (%1) %2", g_Game.GetDayTime(), m_Weather.GetRain().GetActual()));
173
174 return true;
175
176 //-----------------------------------------------------------------------------------------------------------------------------
177 case EWeatherPhenomenon.RAIN:
178 float actualOvercast = m_Weather.GetOvercast().GetActual();
179
180 m_chance = Math.RandomIntInclusive(0, 100);
181 phmnValue = 0.2;
182 phmnTime = 90;
183 phmnLength = 30;
184
185 if (actualOvercast <= RAIN_THRESHOLD)
186 {
187 m_Weather.GetRain().Set(0.0, RAIN_TIME_MIN, RAIN_TIME_MAX);
188 Debug.WeatherLog(string.Format("Enoch::Weather::Rain::ForceEnd:: (%1) %2 -> 0", g_Game.GetDayTime(), actual));
189 return true;
190 }
191
192 if (actualOvercast > STORM_THRESHOLD)
193 {
195 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
196 phmnLength = 0;
197
198 m_Weather.GetRain().Set(phmnValue, phmnTime, phmnLength);
199 Debug.WeatherLog(string.Format("Enoch::Weather::Rain::ForceStorm:: (%1) %2 -> %3", g_Game.GetDayTime(), actual, phmnValue));
200 return true;
201 }
202
203 //make a differnce in "normal rain"
204 if (actualOvercast < 0.75)
205 {
206 if (m_chance < 30)
207 {
209 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
210 phmnLength = 0;
211 }
212 else if (m_chance < 60)
213 {
215 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
216 phmnLength = 0;
217 }
218 else if (m_chance < 85)
219 {
221 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
222 phmnLength = 0;
223 }
224 else //also have the chance to not have rain at all
225 {
226 phmnValue = 0;
227 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
228 phmnLength = 120;
229 }
230 }
231 else if (actualOvercast < STORM_THRESHOLD)
232 {
233 if (m_chance < 15)
234 {
236 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
237 phmnLength = 0;
238 }
239 else if (m_chance < 50)
240 {
242 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
243 phmnLength = 0;
244 }
245 else if (m_chance < 90)
246 {
248 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
249 phmnLength = 0;
250 }
251 else //also have the chance to not have rain at all
252 {
253 phmnValue = 0;
254 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
255 phmnLength = 120;
256 }
257 }
258 else
259 {
260 if (m_chance < 50)
261 {
263 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
264 phmnLength = 0;
265 }
266 else
267 {
269 phmnTime = Math.RandomInt(RAIN_TIME_MIN, RAIN_TIME_MAX);
270 phmnLength = 0;
271 }
272 }
273
274 m_Weather.GetRain().Set(phmnValue, phmnTime, phmnLength);
275
276 Debug.WeatherLog(string.Format("Enoch::Weather::Rain:: (%1) %2", g_Game.GetDayTime(), actual));
277 return true;
278
279 //-----------------------------------------------------------------------------------------------------------------------------
280 case EWeatherPhenomenon.FOG:
281 int year, month, day, hour, minute;
282 GetGame().GetWorld().GetDate(year, month, day, hour, minute);
283 if ((hour >= 1) && (hour <= 5))
284 m_Weather.GetFog().Set(0.1, 1800, 0);
285 else
286 m_Weather.GetFog().Set(0.0, 1800, 0);
287
288 Debug.WeatherLog(string.Format("Enoch::Weather::Fog:: (%1) %2", g_Game.GetDayTime(), actual));
289
290 return true;
291 }
292 return false;
293 }
294};
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)
Definition Enoch.c:70
override void Init()
Definition Enoch.c:42
proto native CGame GetGame()
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