chernarusplus.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. //#define WEATHER_DATA_LOGGING
  2. class ChernarusPlusData extends WorldData
  3. {
  4. //-------test variables & methods ------
  5. #ifdef WEATHER_DATA_LOGGING
  6. int overcastChangeCount = 0;
  7. int badWeatherCount = 0;
  8. int cloudyWeatherCount = 0;
  9. int clearWeatherCount = 0;
  10. int startYear = 0;
  11. int startMonth = 0;
  12. int startDay = 0;
  13. int startHour = 0;
  14. int startMinute = 0;
  15. int currentDay = 0;
  16. int daysToRun = 10;
  17. bool dayInit = false;
  18. #endif
  19. //------------------------
  20. //All Chernarus firing coordinates
  21. protected static const ref array<vector> CHERNARUS_ARTY_STRIKE_POS =
  22. {
  23. "-500.00 165.00 5231.69",
  24. "-500.00 300.00 9934.41",
  25. "10406.86 192.00 15860.00",
  26. "4811.75 370.00 15860.00",
  27. "-500.00 453.00 15860.00"
  28. };
  29. override void Init()
  30. {
  31. super.Init();
  32. // new temperature curve settings
  33. m_Sunrise_Jan = 8.54;
  34. m_Sunset_Jan = 15.52;
  35. m_Sunrise_Jul = 3.26;
  36. m_Sunset_Jul = 20.73;
  37. int tempIdx;
  38. m_MinTemps = {-3,-2,0,4,9,14,18,17,13,11,9,0}; //{-3,-2,0,4,9,14,18,17,12,7,4,0} original values
  39. if (CfgGameplayHandler.GetEnvironmentMinTemps() && CfgGameplayHandler.GetEnvironmentMinTemps().Count() == 12)
  40. {
  41. for (tempIdx = 0; tempIdx < CfgGameplayHandler.GetEnvironmentMinTemps().Count(); tempIdx++)
  42. {
  43. m_MinTemps[tempIdx] = CfgGameplayHandler.GetEnvironmentMinTemps().Get(tempIdx);
  44. }
  45. }
  46. m_MaxTemps = {3,5,7,14,19,24,26,25,18,14,10,5}; //{3,5,7,14,19,24,26,25,21,16,10,5} original values
  47. if (CfgGameplayHandler.GetEnvironmentMaxTemps() && CfgGameplayHandler.GetEnvironmentMaxTemps().Count() == 12)
  48. {
  49. for (tempIdx = 0; tempIdx < CfgGameplayHandler.GetEnvironmentMaxTemps().Count(); tempIdx++)
  50. {
  51. m_MaxTemps[tempIdx] = CfgGameplayHandler.GetEnvironmentMaxTemps().Get(tempIdx);
  52. }
  53. }
  54. m_FiringPos = CHERNARUS_ARTY_STRIKE_POS;
  55. m_WorldWindCoef = 0.4;
  56. m_CloudsTemperatureEffectModifier = 2.0;
  57. m_TemperaturePerHeightReductionModifier = 0.012;
  58. m_UniversalTemperatureSourceCapModifier = -1.0;
  59. if (GetGame().IsServer() || !GetGame().IsMultiplayer())
  60. {
  61. m_Weather.SetDynVolFogHeightBias(m_WeatherDefaultSettings.m_DefaultHeigthBias);
  62. if (GetGame().IsMultiplayer())
  63. {
  64. float startingOvercast = Math.RandomFloat(0.2,0.75);
  65. m_Weather.GetOvercast().Set(startingOvercast,0,5); //forcing a random weather at a clean server start and an instant change for overcast
  66. CalculateVolFog(startingOvercast, m_Weather.GetWindSpeed(), 0);
  67. }
  68. }
  69. }
  70. override void SetupWeatherSettings()
  71. {
  72. super.SetupWeatherSettings();
  73. m_WeatherDefaultSettings.m_StormThreshold = 0.9;
  74. m_WeatherDefaultSettings.m_GlobalSuddenChance = 0;
  75. m_WeatherDefaultSettings.m_BadWeatherSuddenChance = 0;
  76. m_WeatherDefaultSettings.m_DefaultHeigthBias = 50;
  77. }
  78. override bool WeatherOnBeforeChange( EWeatherPhenomenon type, float actual, float change, float time )
  79. {
  80. #ifdef WEATHER_DATA_LOGGING
  81. if ( !dayInit )
  82. {
  83. GetGame().GetWorld().GetDate(startYear, startMonth, startDay, startHour, startMinute);
  84. dayInit = true;
  85. }
  86. #endif
  87. float phmnTime = 5;
  88. float phmnLength = 10;
  89. float phmnValue = 0;
  90. m_Weather.SetStorm( 1.0, m_WeatherDefaultSettings.m_StormThreshold, 45 );
  91. m_Weather.SetRainThresholds( m_WeatherDefaultSettings.m_RainThreshold, 1.0, 60 );
  92. m_Weather.SetWindMaximumSpeed( 20 );
  93. if (m_Weather.GetDynVolFogHeightBias() < m_WeatherDefaultSettings.m_DefaultHeigthBias)
  94. {
  95. m_Weather.SetDynVolFogHeightBias(m_WeatherDefaultSettings.m_DefaultHeigthBias);
  96. }
  97. switch (type)
  98. {
  99. //-----------------------------------------------------------------------------------------------------------------------------
  100. case EWeatherPhenomenon.OVERCAST:
  101. {
  102. #ifdef WEATHER_DATA_LOGGING
  103. overcastChangeCount++;
  104. #endif
  105. float windDirection, windMag;
  106. //went something goes wrong choose some default random weather
  107. phmnValue = Math.RandomFloatInclusive( 0.2, 0.7 );
  108. phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
  109. phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
  110. //----
  111. //calculate next weather
  112. m_Chance = Math.RandomIntInclusive( 0, 100 );
  113. //--
  114. if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
  115. {
  116. m_ClearWeatherChance -= ( m_StepValue * m_SameWeatherCnt); //decrease the chance of the same weather
  117. }
  118. if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
  119. {
  120. m_ClearWeatherChance += ( m_StepValue * m_SameWeatherCnt); //increase the chance of the better weather
  121. }
  122. if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
  123. {
  124. m_ClearWeatherChance += m_StepValue; //increase the chance of the better weather slightly
  125. m_BadWeatherChance += (( m_StepValue * m_SameWeatherCnt ) + m_StepValue ); //decrease the chance of the same weather rapidly
  126. }
  127. //----
  128. if ( m_Chance < m_ClearWeatherChance )
  129. {
  130. m_ChoosenWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
  131. if ( m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
  132. m_SameWeatherCnt ++;
  133. }
  134. else if ( m_Chance > m_BadWeatherChance )
  135. {
  136. m_ChoosenWeather = WorldDataWeatherConstants.BAD_WEATHER;
  137. if ( m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
  138. m_SameWeatherCnt ++;
  139. }
  140. else
  141. {
  142. m_ChoosenWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
  143. if ( m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
  144. m_SameWeatherCnt ++;
  145. }
  146. if ( m_ChoosenWeather != m_LastWeather )
  147. m_SameWeatherCnt = 0;
  148. m_ClearWeatherChance = m_WeatherDefaultSettings.m_ClearWeatherChance;
  149. m_BadWeatherChance = m_WeatherDefaultSettings.m_BadWeatherChance;
  150. //----
  151. //set choosen weather
  152. if ( m_ChoosenWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
  153. {
  154. m_LastWeather = WorldDataWeatherConstants.CLEAR_WEATHER;
  155. #ifdef WEATHER_DATA_LOGGING
  156. clearWeatherCount++;
  157. #endif
  158. phmnValue = Math.RandomFloatInclusive( 0.0, 0.3 );
  159. phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
  160. phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
  161. }
  162. if ( m_ChoosenWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
  163. {
  164. m_LastWeather = WorldDataWeatherConstants.CLOUDY_WEATHER;
  165. #ifdef WEATHER_DATA_LOGGING
  166. cloudyWeatherCount++;
  167. #endif
  168. phmnValue = Math.RandomFloatInclusive( 0.3, 0.6 );
  169. phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
  170. phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
  171. }
  172. if ( m_ChoosenWeather == WorldDataWeatherConstants.BAD_WEATHER )
  173. {
  174. m_LastWeather = WorldDataWeatherConstants.BAD_WEATHER;
  175. #ifdef WEATHER_DATA_LOGGING
  176. badWeatherCount++;
  177. #endif
  178. phmnValue = Math.RandomFloatInclusive( 0.6, 1.0 );
  179. phmnTime = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinTime, m_WeatherDefaultSettings.m_OvercastMaxTime );
  180. phmnLength = Math.RandomIntInclusive( m_WeatherDefaultSettings.m_OvercastMinLength, m_WeatherDefaultSettings.m_OvercastMaxLength );
  181. }
  182. m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
  183. CalculateWind( m_ChoosenWeather, false, windMag, windDirection );
  184. 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
  185. m_Weather.GetWindDirection().Set( windDirection, phmnTime * WIND_DIRECTION_TIME_MULTIPLIER , phmnTime - (phmnTime * WIND_DIRECTION_TIME_MULTIPLIER) + phmnLength + 1000 );
  186. CalculateVolFog(phmnValue, windMag, phmnTime);
  187. Debug.WeatherLog(string.Format("Chernarus::Weather::Overcast:: (%1) overcast: %2", g_Game.GetDayTime(), actual));
  188. Debug.WeatherLog(string.Format("Chernarus::Weather::Overcast::Rain:: (%1) %2", g_Game.GetDayTime(), m_Weather.GetRain().GetActual()));
  189. #ifdef WEATHER_DATA_LOGGING
  190. int testYear = 0;
  191. int testMonth = 0;
  192. int testDay = 0;
  193. int testHour = 0;
  194. int testMinute = 0;
  195. GetGame().GetWorld().GetDate(testYear, testMonth, testDay, testHour, testMinute);
  196. if ( testDay - startDay > currentDay && testHour - startHour >= 0 && testMinute - startMinute >= 0 )
  197. {
  198. FileHandle file = OpenFile("$profile:OvercastCountsCharnarus" + (currentDay + 1) + ".log", FileMode.WRITE);
  199. FPrintln(file, "================================================================");
  200. FPrintln(file," ================== Day " + (currentDay + 1) + " ================== ");
  201. FPrintln(file, "================================================================");
  202. FPrintln(file, "Overcast Change Count: " + overcastChangeCount);
  203. FPrintln(file, "Bad Weather Change Count: " + badWeatherCount);
  204. FPrintln(file, "Cloudy Weather Count: " + cloudyWeatherCount);
  205. FPrintln(file, "Clear Weather Count: " + clearWeatherCount);
  206. currentDay++;
  207. CloseFile(file);
  208. if ( currentDay == daysToRun )
  209. {
  210. g_Game.RequestExit(IDC_MAIN_QUIT);
  211. }
  212. overcastChangeCount = 0;
  213. badWeatherCount = 0;
  214. cloudyWeatherCount = 0;
  215. clearWeatherCount = 0;
  216. }
  217. #endif
  218. return true;
  219. }
  220. //-----------------------------------------------------------------------------------------------------------------------------
  221. case EWeatherPhenomenon.RAIN:
  222. {
  223. float actualOvercast = m_Weather.GetOvercast().GetActual();
  224. m_Chance = Math.RandomIntInclusive( 0, 100 );
  225. phmnValue = 0.2;
  226. phmnTime = 90;
  227. phmnLength = 30;
  228. if ( actualOvercast <= m_WeatherDefaultSettings.m_RainThreshold )
  229. {
  230. m_Weather.GetRain().Set( 0.0, m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  231. Debug.WeatherLog(string.Format("Chernarus::Weather::Rain::ForceEnd:: (%1) %2 -> 0", g_Game.GetDayTime(), actual));
  232. return true;
  233. }
  234. if ( actualOvercast > m_WeatherDefaultSettings.m_StormThreshold )
  235. {
  236. phmnValue = Math.RandomFloatInclusive( 0.8, 1.0 );
  237. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  238. phmnLength = 0;
  239. m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
  240. Debug.WeatherLog(string.Format("Chernarus::Weather::Rain::ForceStorm:: (%1) %2 -> %3", g_Game.GetDayTime(), actual, phmnValue));
  241. return true;
  242. }
  243. //make a differnce in "normal rain"
  244. if ( actualOvercast < 0.75 )
  245. {
  246. if ( m_Chance < 30 )
  247. {
  248. phmnValue = Math.RandomFloatInclusive( 0.1, 0.3 );
  249. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  250. phmnLength = 0;
  251. }
  252. else if ( m_Chance < 60 )
  253. {
  254. phmnValue = Math.RandomFloatInclusive( 0.2, 0.5 );
  255. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  256. phmnLength = 0;
  257. }
  258. else if ( m_Chance < 80 )
  259. {
  260. phmnValue = Math.RandomFloatInclusive( 0.0, 0.2 );
  261. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  262. phmnLength = 0;
  263. }
  264. else //also have the chance to not have rain at all
  265. {
  266. phmnValue = 0;
  267. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  268. phmnLength = m_WeatherDefaultSettings.m_RainLengthMax;
  269. }
  270. }
  271. else
  272. {
  273. if ( m_Chance < 25 )
  274. {
  275. phmnValue = Math.RandomFloatInclusive( 0.5, 0.7 );
  276. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  277. phmnLength = 0;
  278. }
  279. else if ( m_Chance < 50 )
  280. {
  281. phmnValue = Math.RandomFloatInclusive( 0.2, 0.4 );
  282. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  283. phmnLength = 0;
  284. }
  285. else if ( m_Chance < 75 )
  286. {
  287. phmnValue = Math.RandomFloatInclusive( 0.4, 0.6 );
  288. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  289. phmnLength = 0;
  290. }
  291. else //also have the chance to not have rain at all
  292. {
  293. phmnValue = 0;
  294. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  295. phmnLength = m_WeatherDefaultSettings.m_RainLengthMax;
  296. }
  297. }
  298. m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
  299. Debug.WeatherLog(string.Format("Chernarus::Weather::Rain:: (%1) %2", g_Game.GetDayTime(), actual));
  300. return true;
  301. }
  302. //-----------------------------------------------------------------------------------------------------------------------------
  303. case EWeatherPhenomenon.FOG:
  304. {
  305. float fogMin = 0.0;
  306. float fogMax = 0.15;
  307. float fogTime = 1800.0;
  308. float fogyMorning = Math.RandomFloatInclusive( 0.0, 1.0 );
  309. if ( fogyMorning > 0.85 )
  310. {
  311. if ( (g_Game.GetDayTime() > 4 && g_Game.GetDayTime() < 7 ) )
  312. {
  313. fogMin = 0.10;
  314. fogMax = 0.35;
  315. fogTime = 300;
  316. }
  317. }
  318. if ( m_Weather.GetOvercast().GetActual() < 0.3 )
  319. {
  320. fogMin = 0.0;
  321. fogMax = 0.08;
  322. fogTime = 900.0;
  323. }
  324. m_Weather.GetFog().Set( Math.RandomFloatInclusive( fogMin, fogMax ), fogTime, 0);
  325. Debug.WeatherLog(string.Format("Chernarus::Weather::Fog:: (%1) %2", g_Game.GetDayTime(), actual));
  326. return true;
  327. }
  328. //-----------------------------------------------------------------------------------------------------------------------------
  329. case EWeatherPhenomenon.WIND_MAGNITUDE:
  330. {
  331. phmnTime = Math.RandomInt( m_WeatherDefaultSettings.m_RainTimeMin, m_WeatherDefaultSettings.m_RainTimeMax );
  332. m_Weather.GetWindMagnitude().Set(m_Weather.GetWindMagnitude().GetActual() * 0.75, phmnTime , m_WeatherDefaultSettings.m_OvercastMaxLength); // next change will be happen with the overcast change
  333. return true;
  334. }
  335. }
  336. return false;
  337. }
  338. protected override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
  339. {
  340. magnitude = 5;
  341. direction = 0;
  342. float windChance = Math.RandomIntInclusive( 0, 100 );
  343. if ( newWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
  344. {
  345. if ( windChance < 30 )
  346. {
  347. magnitude = Math.RandomFloatInclusive( 6 , 10 );
  348. direction = Math.RandomFloatInclusive( -1.0 , -0.5);
  349. }
  350. else if ( windChance < 75 )
  351. {
  352. magnitude = Math.RandomFloatInclusive( 8 , 12 );
  353. direction = Math.RandomFloatInclusive( -1.3 , -0.9);
  354. }
  355. else
  356. {
  357. magnitude = Math.RandomFloatInclusive( 4 , 6 );
  358. direction = Math.RandomFloatInclusive( -0.6 , 0.0);
  359. }
  360. }
  361. else if ( newWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
  362. {
  363. if ( windChance < 45 )
  364. {
  365. magnitude = Math.RandomFloatInclusive( 6 , 10 );
  366. direction = Math.RandomFloatInclusive( -3.14 , -2.4);
  367. }
  368. else if ( windChance < 90 )
  369. {
  370. magnitude = Math.RandomFloatInclusive( 8 , 12 );
  371. direction = Math.RandomFloatInclusive( -2.6, -2.0);
  372. }
  373. else
  374. {
  375. magnitude = Math.RandomFloatInclusive( 10 , 14 );
  376. direction = Math.RandomFloatInclusive( -2.2 , -1.4);
  377. }
  378. }
  379. else
  380. {
  381. if ( suddenChange || m_Weather.GetOvercast().GetActual() > m_WeatherDefaultSettings.m_StormThreshold || m_Weather.GetOvercast().GetForecast() - m_Weather.GetOvercast().GetActual() >= 0.4 )
  382. {
  383. magnitude = Math.RandomFloatInclusive( 14 , 17 );
  384. direction = Math.RandomFloatInclusive( 0.9 , 1.45);
  385. }
  386. else if ( windChance < 45 )
  387. {
  388. magnitude = Math.RandomFloatInclusive( 9 , 12 );
  389. direction = Math.RandomFloatInclusive( 1.45, 1.7);
  390. }
  391. else if ( windChance < 90 )
  392. {
  393. magnitude = Math.RandomFloatInclusive( 7 , 10 );
  394. direction = Math.RandomFloatInclusive( 1.6 , 2);
  395. }
  396. else
  397. {
  398. magnitude = Math.RandomFloatInclusive( 4 , 8 );
  399. direction = Math.RandomFloatInclusive( 1.9, 2.2 );
  400. }
  401. }
  402. }
  403. protected override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
  404. {
  405. float distanceDensity, heigthDensity, heightBias;
  406. int year, month, day, hour, minute;
  407. GetGame().GetWorld().GetDate(year, month, day, hour, minute);
  408. if ( hour < 9 && hour >= 5 )
  409. {
  410. distanceDensity = Math.Lerp( 0.015, 0.05, lerpValue ) * Math.Clamp(1 - (windMagnitude / m_Weather.GetWindMaximumSpeed()), 0.1, 1);
  411. heigthDensity = Math.Lerp( 0.8, 1, lerpValue);
  412. heightBias = m_Weather.GetDynVolFogHeightBias();
  413. if (heightBias == m_WeatherDefaultSettings.m_DefaultHeigthBias) //checks if the randomization has been done
  414. {
  415. int diceRoll = Math.RandomIntInclusive(1,100);
  416. if (diceRoll < 50)
  417. {
  418. heightBias = Math.RandomInt(m_WeatherDefaultSettings.m_DefaultHeigthBias + 1, 80);
  419. }
  420. else if (diceRoll < 85)
  421. {
  422. heightBias = Math.RandomInt(80, 120);
  423. }
  424. else
  425. {
  426. heightBias = Math.RandomInt(120, 200);
  427. }
  428. }
  429. }
  430. else if ( hour < 18 && hour >= 9 )
  431. {
  432. distanceDensity = Math.Lerp( 0.01, 0.05, lerpValue ) * Math.Clamp(1 - (windMagnitude / m_Weather.GetWindMaximumSpeed()), 0.1, 1);
  433. heigthDensity = Math.Lerp( 0.9, 1, lerpValue);
  434. heightBias = m_WeatherDefaultSettings.m_DefaultHeigthBias;
  435. }
  436. else
  437. {
  438. distanceDensity = Math.Lerp( 0.01, 0.03, lerpValue ) * Math.Clamp(1 - (windMagnitude / m_Weather.GetWindMaximumSpeed()), 0.1, 1);
  439. heigthDensity = Math.Lerp( 0.9, 1, lerpValue);
  440. heightBias = m_WeatherDefaultSettings.m_DefaultHeigthBias;
  441. }
  442. m_Weather.SetDynVolFogDistanceDensity(distanceDensity, changeTime);
  443. m_Weather.SetDynVolFogHeightDensity(heigthDensity, changeTime);
  444. m_Weather.SetDynVolFogHeightBias(heightBias, changeTime);
  445. }
  446. bool LogWeatherData() //called from mission file to check if the logging should start
  447. {
  448. #ifdef WEATHER_DATA_LOGGING
  449. return true;
  450. #endif
  451. return false;
  452. }
  453. //! DEPRECATED (see WorldDataWeatherConstants)
  454. const int CLEAR_WEATHER = 1;
  455. const int CLOUDY_WEATHER = 2;
  456. const int BAD_WEATHER = 3;
  457. //! DEPRECATED (see WorldDataWeatherSettings)
  458. const int OVERCAST_MIN_TIME = 600;
  459. const int OVERCAST_MAX_TIME = 900;
  460. const float RAIN_THRESHOLD = 0.6;
  461. const int RAIN_TIME_MIN = 60;
  462. const int RAIN_TIME_MAX = 120;
  463. const float STORM_THRESHOLD = 0.9;
  464. protected int m_clearWeatherChance = m_ClearWeatherChance;
  465. protected int m_badWeatherChance = m_BadWeatherChance;
  466. protected int m_sameWeatherCnt = m_SameWeatherCnt;
  467. protected int m_stepValue = m_StepValue;
  468. protected int m_chance = m_Chance;
  469. protected int m_choosenWeather = m_ChoosenWeather;
  470. protected int m_lastWeather = m_LastWeather;
  471. }