mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2007 from jokoho48/codeCleanupWeather
Code cleanup Weather module
This commit is contained in:
commit
f8cebd9403
@ -9,14 +9,14 @@
|
||||
* 2: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: density of air - kg * m^(-3) <NUMBER>
|
||||
* density of air - kg * m^(-3) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_3(_temperature,_pressure,_relativeHumidity);
|
||||
params ["_temperature", "_pressure", "_relativeHumidity"];
|
||||
|
||||
_pressure = _pressure * 100; // hPa to Pa
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
* Calculates the barometric pressure based on altitude and weather
|
||||
*
|
||||
* Arguments:
|
||||
* 0: altitude - meters <NUMBER>
|
||||
* altitude - meters <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: barometric pressure - hPA <NUMBER>
|
||||
* barometric pressure - hPA <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
|
@ -8,7 +8,7 @@
|
||||
* 2: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: dew point <NUMBER>
|
||||
* dew point <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
@ -18,7 +18,7 @@
|
||||
#define __b 17.67
|
||||
#define __c 243.5
|
||||
|
||||
PARAMS_2(_t,_rh);
|
||||
params ["_t", "_rh"];
|
||||
|
||||
if (_rh == 0) exitWith { CELSIUS(0) };
|
||||
|
||||
|
@ -5,10 +5,10 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: temperature - degrees celcius <NUMBER>
|
||||
* 2: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
* 1: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: heat index <NUMBER>
|
||||
* heat index <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
@ -24,7 +24,7 @@
|
||||
#define __C7 0.000687678
|
||||
#define __C8 0.000274954
|
||||
|
||||
PARAMS_2(_t,_rh);
|
||||
params ["_t", "_rh"];
|
||||
|
||||
// Source: https://en.wikipedia.org/wiki/Heat_index
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
* Calculates the terrain roughness length at a given world position
|
||||
*
|
||||
* Arguments:
|
||||
* 0: _this - world position <posASL>
|
||||
* world position <posASL>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: roughness length <NUMBER>
|
||||
* roughness length <NUMBER>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -4,10 +4,10 @@
|
||||
* Calculates the temperature based on altitude and weather
|
||||
*
|
||||
* Arguments:
|
||||
* 0: height - meters <NUMBER>
|
||||
* height - meters <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: temperature - degrees celsius <NUMBER>
|
||||
* temperature - degrees celsius <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
|
@ -9,7 +9,7 @@
|
||||
* 2: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: wet bulb <NUMBER>
|
||||
* wet bulb <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
private ["_es", "_e", "_eDiff", "_eGuessPrev", "_cTempDelta", "_twGuess", "_eguess"];
|
||||
|
||||
PARAMS_3(_temperature,_pressure,_relativeHumidity);
|
||||
params ["_temperature", "_pressure", "_relativeHumidity"];
|
||||
|
||||
// Source: http://cosmoquest.org/forum/showthread.php?155366-Calculating-Wet-Bulb-Temperature-from-RH-amp-Dry-Bulb
|
||||
_es = 6.112 * exp((17.67 * _temperature) / (_temperature + 243.5));
|
||||
|
@ -5,16 +5,16 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: temperature - degrees celcius <NUMBER>
|
||||
* 2: wind speed - m/s <NUMBER>
|
||||
* 1: wind speed - m/s <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: wind chill <NUMBER>
|
||||
* wind chill <NUMBER>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_t,_v);
|
||||
params ["_t", "_v"];
|
||||
|
||||
// Source: https://en.wikipedia.org/wiki/Wind_chill
|
||||
|
||||
|
@ -10,24 +10,26 @@
|
||||
* 3: Account for obstacles <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: wind speed - m/s <NUMBER>
|
||||
* wind speed - m/s <NUMBER>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_windSpeed", "_windDir", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"];
|
||||
private ["_fnc_polar2vect", "_windSpeed", "_windDir", "_windDirAdjusted", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"];
|
||||
|
||||
PARAMS_4(_position,_windGradientEnabled,_terrainEffectEnabled,_obstacleEffectEnabled);
|
||||
params ["_position", "_windGradientEnabled", "_terrainEffectEnabled", "_obstacleEffectEnabled"];
|
||||
|
||||
fnc_polar2vect = {
|
||||
_fnc_polar2vect = {
|
||||
private ["_mag2D"];
|
||||
_mag2D = (_this select 0) * cos((_this select 2));
|
||||
[_mag2D * sin((_this select 1)), _mag2D * cos((_this select 1)), (_this select 0) * sin((_this select 2))];
|
||||
params ["_x", "_y", "_z"];
|
||||
_mag2D = _x * cos(_z);
|
||||
[_mag2D * sin(_y), _mag2D * cos(_y), _x * sin(_z)];
|
||||
};
|
||||
|
||||
_windSpeed = vectorMagnitude ACE_wind;
|
||||
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
||||
_windDirAdjusted = _windDir + 180;
|
||||
|
||||
// Wind gradient
|
||||
if (_windGradientEnabled) then {
|
||||
@ -46,19 +48,19 @@ if (_terrainEffectEnabled) then {
|
||||
if (_windSpeed > 0.05) then {
|
||||
_newWindSpeed = 0;
|
||||
{
|
||||
_windSource = [100, _windDir + 180, _x] call fnc_polar2vect;
|
||||
_windSource = [100, _windDirAdjusted, _x] call _fnc_polar2vect;
|
||||
if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 9) * _windSpeed;
|
||||
};
|
||||
_windSource = [100, _windDir + 180 + _x, 0] call fnc_polar2vect;
|
||||
_windSource = [100, _windDirAdjusted + _x, 0] call _fnc_polar2vect;
|
||||
if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 9) * _windSpeed;
|
||||
};
|
||||
_windSource = [100, _windDir + 180 - _x, 0] call fnc_polar2vect;
|
||||
_windSource = [100, _windDirAdjusted - _x, 0] call _fnc_polar2vect;
|
||||
if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 9) * _windSpeed;
|
||||
};
|
||||
} forEach [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
} count [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
_windSpeed = _newWindSpeed;
|
||||
};
|
||||
};
|
||||
@ -68,19 +70,19 @@ if (_obstacleEffectEnabled) then {
|
||||
if (_windSpeed > 0.05) then {
|
||||
_newWindSpeed = 0;
|
||||
{
|
||||
_windSource = [20, _windDir + 180, _x] call fnc_polar2vect;
|
||||
_windSource = [20, _windDirAdjusted, _x] call _fnc_polar2vect;
|
||||
if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 2) * _windSpeed;
|
||||
};
|
||||
_windSource = [20, _windDir + 180 + _x, 0] call fnc_polar2vect;
|
||||
_windSource = [20, _windDirAdjusted + _x, 0] call _fnc_polar2vect;
|
||||
if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 2) * _windSpeed;
|
||||
};
|
||||
_windSource = [20, _windDir + 180 - _x, 0] call fnc_polar2vect;
|
||||
_windSource = [20, _windDirAdjusted - _x, 0] call _fnc_polar2vect;
|
||||
if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 2) * _windSpeed;
|
||||
};
|
||||
} forEach [0, 5, 10, 15, 20, 25, 30, 35, 40, 45];
|
||||
} count [0, 5, 10, 15, 20, 25, 30, 35, 40, 45];
|
||||
_windSpeed = _newWindSpeed;
|
||||
};
|
||||
};
|
||||
|
@ -11,11 +11,12 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_periodPercent", "_periodPosition"];
|
||||
|
||||
if (isNil "ACE_WIND_PARAMS") exitWith { [0, 0, 0] };
|
||||
|
||||
EXPLODE_5_PVT(ACE_WIND_PARAMS,_dir,_dirChange,_spd,_spdChange,_period);
|
||||
ACE_WIND_PARAMS params ["_dir", "_dirChange", "_spd", "_spdChange", "_period"];
|
||||
|
||||
private ["_periodPercent", "_periodPosition"];
|
||||
_periodPosition = (ACE_time - GVAR(wind_period_start_time)) min _period;
|
||||
_periodPercent = _periodPosition / _period;
|
||||
|
||||
|
@ -15,10 +15,7 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_logic", "_units", "_activated"];
|
||||
_logic = _this select 0;
|
||||
_units = _this select 1;
|
||||
_activated = _this select 2;
|
||||
params ["_logic", "_units", "_activated"];
|
||||
|
||||
if !(_activated) exitWith {};
|
||||
|
||||
@ -36,4 +33,4 @@ if !(_activated) exitWith {};
|
||||
// Server weather update interval
|
||||
[_logic, QGVAR(serverUpdateInterval), "serverUpdateInterval"] call EFUNC(common,readSettingFromModule);
|
||||
|
||||
GVAR(serverUpdateInterval) = 1 max GVAR(serverUpdateInterval) min 600;
|
||||
GVAR(serverUpdateInterval) = 1 max GVAR(serverUpdateInterval) min 600;
|
||||
|
@ -14,8 +14,8 @@
|
||||
if (!GVAR(syncRain)) exitWith {};
|
||||
|
||||
if (!isNil "ACE_RAIN_PARAMS") then {
|
||||
EXPLODE_3_PVT(ACE_RAIN_PARAMS,_oldRain,_newRain,_period);
|
||||
|
||||
ACE_RAIN_PARAMS params ["_oldRain", "_newRain", "_period"];
|
||||
|
||||
private ["_periodPosition", "_periodPercent"];
|
||||
_periodPosition = (ACE_time - GVAR(rain_period_start_time)) min _period;
|
||||
_periodPercent = (_periodPosition / _period) min 1;
|
||||
|
Loading…
Reference in New Issue
Block a user