Epoch/Sources/epoch_server_settings/EpochEvents/ChangeWeather.sqf

113 lines
4.2 KiB
Plaintext
Raw Normal View History

/*
Weather Control System
by Aaron Clark - EpochMod.com
Improvements and or bugfixes and other contributions are welcome via the github:
2016-06-13 16:54:19 +00:00
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_settings/EpochEvents/ChangeWeather.sqf
*/
2017-03-27 22:43:10 +00:00
private ["_tempOVRD","_rainOVRD","_fogOVRD","_overcastOVRD","_windOVRD","_arr","_response","_windValX","_windValY","_WeatherChangeTime","_force","_temp","_fog","_rain","_overcast"];
2015-10-28 15:16:00 +00:00
// Initalize variable for tracking time between runs.
if (isNil "EPOCH_lastWeatherChange") then {
EPOCH_lastWeatherChange = diag_tickTime;
};
// get the time between weather change events to use as tranistion time.
_WeatherChangeTime = diag_tickTime - EPOCH_lastWeatherChange;
// increment timer to current time.
EPOCH_lastWeatherChange = diag_tickTime;
_force = false;
// use config static weather if set.
if !(EPOCH_WeatherStaticForecast isEqualTo []) then {
EPOCH_WeatherStaticForecast params ["_tempOVRD","_rainOVRD","_fogOVRD","_overcastOVRD","_windOVRD","_lightningOVRD"];
} else {
// Make database call to get "Weather:InstanceID" that can be set in the database to allow for weather controls outside of the game.
2015-08-28 20:33:37 +00:00
_response = ["Weather", (call EPOCH_fn_InstanceID)] call EPOCH_fnc_server_hiveGETRANGE;
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
if ((_response select 0) == 1 && (_response select 1) isEqualType [] && !((_response select 1) isEqualTo[])) then {
_arr = _response select 1;
_arr params ["_tempOVRD","_rainOVRD","_fogOVRD","_overcastOVRD","_windOVRD","_lightningOVRD"];
};
};
2017-03-27 22:43:10 +00:00
/*
New weather configs
BAD WEATHER:
*/
_randomNightTemp = [0,10,32];
_randomNightRainTemp = [-10,5,25];
_randomDayTemp = [50,95,112];
_randomDayRainTemp = [50,75,99];
_randomFogValue = [0,0.1,0.2] vectorMultiply (1-rain);
_randomFogDecay = [0,0.1,0.2] vectorMultiply (1-rain);
_randomFogBase = [0,10,20] vectorMultiply (1-rain);
_randomFogAfterRainValue = [0,0.15,0.25];
_randomFogAfterRainDecay = [0,0.20,0];
_randomFogAfterRainBase = [0,12,25];
_randomRainValue = [0,1,0];
_randomOvercastValue = [0,1,0];
_randomLightningValue = [0,1,0];
2017-03-27 22:43:10 +00:00
_randomDirection = random 360;
_randomWindStr = random 20;
// config end
_rain = if (isNil "_rainOVRD") then { random _randomRainValue } else { _rainOVRD };
2017-03-27 22:43:10 +00:00
_windVal = [cos _randomDirection,sin _randomDirection,0] vectorMultiply (_randomWindStr * _rain);
_windVal params ["_windValX","_windValY"];
// wind.
if (_rain > 0.1) then {
_randomNightTemp = _randomNightRainTemp;
_randomDayTemp = _randomDayRainTemp;
} else {
// use increase fog settings if just it rained
if (humidity > 0.5) then {
_randomFogValue = _randomFogAfterRainValue vectorMultiply humidity;
_randomFogDecay = _randomFogAfterRainDecay vectorMultiply humidity;
_randomFogBase = _randomFogAfterRainBase vectorMultiply humidity;
};
};
2015-10-28 15:16:00 +00:00
if !(isNil "_windOVRD") then {
2017-03-23 20:51:44 +00:00
_windValX = _windOVRD select 0;
2017-03-27 22:43:10 +00:00
_windValY = _windOVRD select 1;
};
// cooler at night
_temp = if (sunOrMoon < 1) then { random _randomNightTemp } else { random _randomDayTemp };
// force reduced fog if temps are out of range
if (_temp < 32 || _temp > 75) then {
_randomFogValue = _randomFogValue vectorMultiply 0.1;
_randomFogDecay = _randomFogValue vectorMultiply 0.1;
_randomFogBase = _randomFogValue vectorMultiply 0.1;
};
_fog = if (isNil "_fogOVRD") then { [random _randomFogValue, random _randomFogDecay, random _randomFogBase] } else { _fogOVRD };
_overcast = if (isNil "_overcastOVRD") then { random _randomOvercastValue } else { _overcastOVRD };
_lightning = if (isNil "_lightningOVRD") then { random _randomLightningValue } else { _lightningOVRD };
_WeatherChangeTime setFog _fog;
_WeatherChangeTime setOvercast _overcast;
_WeatherChangeTime setRain _rain;
_WeatherChangeTime setLightnings _lightning;
2017-03-27 22:43:10 +00:00
setWind[_windValX, _windValY, true];
// push temp to all players and JIP.
missionNamespace setVariable ["EPOCH_CURRENT_WEATHER", if (isNil "_tempOVRD") then { round(_temp) } else { _tempOVRD }, true];
// will force weather change if set to true (will cause lag).
if (_force) then {
forceWeatherChange;
};
2017-03-27 22:43:10 +00:00
diag_log format["Epoch: Weather Change - fog: %1 rain: %2 overcast: %3 wind: %4 wind-xy: %5 forced: %6", _fog, _overcast, _rain, [_randomDirection,_randomWindStr], [_windValX,_windValY], _force];