mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Privates, Headers, Merge 4 PFEH into one
This commit is contained in:
parent
776f9352fe
commit
e2c08d2c26
@ -1,17 +1,13 @@
|
||||
class RscTitles
|
||||
{
|
||||
class RscWindIntuitive
|
||||
{
|
||||
class RscTitles {
|
||||
class RscWindIntuitive {
|
||||
idd=-1;
|
||||
onLoad="with uiNameSpace do { RscWindIntuitive = _this select 0 };";
|
||||
movingEnable=0;
|
||||
duration=60;
|
||||
fadeIn="false";
|
||||
fadeOut="false";
|
||||
class controls
|
||||
{
|
||||
class RscWindIntuitive
|
||||
{
|
||||
class controls {
|
||||
class RscWindIntuitive {
|
||||
idc=132948;
|
||||
type=0;
|
||||
style=48;
|
||||
|
@ -40,12 +40,40 @@ GVAR(ACE_rain) = rain;
|
||||
|
||||
simulWeatherSync;
|
||||
|
||||
[FUNC(updateTemperature), 20, []] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(updateHumidity), 20, []] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(updateWind), 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(updateRain), 2, []] call CBA_fnc_addPerFrameHandler;
|
||||
[{
|
||||
|
||||
|
||||
|
||||
["SettingsInitialized",{
|
||||
TRACE_1("SettingsInitialized",GVAR(syncRain));
|
||||
|
||||
//Create a 1 sec delay PFEH to update rain every frame:
|
||||
if (GVAR(syncRain)) then {
|
||||
[{
|
||||
0 setRain GVAR(ACE_rain);
|
||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
//Create a 1 sec delay PFEH to update wind/rain/temp/humidity
|
||||
|
||||
//If we don't sync rain, set next time to infinity
|
||||
GVAR(nextUpdateRain) = if (GVAR(syncRain)) then {0} else {1e99};
|
||||
GVAR(nextUpdateTempAndHumidity) = 0;
|
||||
[{
|
||||
BEGIN_COUNTER(weatherPFEH);
|
||||
|
||||
[] call FUNC(updateWind); //Every 1 second
|
||||
|
||||
if (ACE_time > GVAR(nextUpdateRain)) then {
|
||||
[] call FUNC(updateRain); //Every 2 seconds
|
||||
GVAR(nextUpdateRain) = 2 + ACE_time;
|
||||
};
|
||||
if (ACE_time > GVAR(nextUpdateTempAndHumidity)) then {
|
||||
[] call FUNC(updateTemperature); //Every 20 seconds
|
||||
[] call FUNC(updateHumidity); //Every 20 seconds
|
||||
GVAR(nextUpdateTempAndHumidity) = 20 + ACE_time;
|
||||
};
|
||||
|
||||
END_COUNTER(weatherPFEH);
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
@ -9,4 +9,10 @@ GVAR(rain_current_range) = -1+(random 2);
|
||||
// Wind
|
||||
call FUNC(initWind);
|
||||
|
||||
[FUNC(serverController), GVAR(serverUpdateInterval)] call CBA_fnc_addPerFrameHandler;
|
||||
["SettingsInitialized", {
|
||||
TRACE_2("SettingsInitialized",GVAR(enableServerController),GVAR(serverUpdateInterval));
|
||||
|
||||
if (GVAR(enableServerController)) then {
|
||||
[FUNC(serverController), GVAR(serverUpdateInterval)] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
@ -1,18 +1,19 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates the air density
|
||||
*
|
||||
* Arguments:
|
||||
* 0: temperature - degrees celcius <NUMBER>
|
||||
* 0: temperature - degrees celsius <NUMBER>
|
||||
* 1: pressure - hPa <NUMBER>
|
||||
* 2: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* density of air - kg * m^(-3) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
* Example:
|
||||
* [0, 1020, 0.5] call ace_weather_fnc_calculateAirDensity
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
@ -21,11 +22,10 @@ params ["_temperature", "_pressure", "_relativeHumidity"];
|
||||
_pressure = _pressure * 100; // hPa to Pa
|
||||
|
||||
if (_relativeHumidity > 0) then {
|
||||
private ["_pSat", "_vaporPressure", "_partialPressure"];
|
||||
// Saturation vapor pressure calculated according to: http://wahiduddin.net/calc/density_algorithms.htm
|
||||
_pSat = 6.1078 * 10 ^ ((7.5 * _temperature) / (_temperature + 237.3));
|
||||
_vaporPressure = _relativeHumidity * _pSat;
|
||||
_partialPressure = _pressure - _vaporPressure;
|
||||
private _pSat = 6.1078 * 10 ^ ((7.5 * _temperature) / (_temperature + 237.3));
|
||||
private _vaporPressure = _relativeHumidity * _pSat;
|
||||
private _partialPressure = _pressure - _vaporPressure;
|
||||
|
||||
(_partialPressure * DRY_AIR_MOLAR_MASS + _vaporPressure * WATER_VAPOR_MOLAR_MASS) / (UNIVERSAL_GAS_CONSTANT * KELVIN(_temperature))
|
||||
} else {
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates the barometric pressure based on altitude and weather
|
||||
*
|
||||
* Arguments:
|
||||
@ -9,8 +8,10 @@
|
||||
* Return Value:
|
||||
* barometric pressure - hPA <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
* Example:
|
||||
* 0 call ace_weather_fnc_calculateBarometricPressure
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates density altitude for a given air density
|
||||
*
|
||||
* Arguments:
|
||||
@ -9,8 +8,10 @@
|
||||
* Return Value:
|
||||
* density altitude - m <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
* Example:
|
||||
* 1.225 call ace_weather_fnc_calculateDensityAltitude
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates dew point based on temperature and relative humidity
|
||||
*
|
||||
* Arguments:
|
||||
* 0: temperature - degrees celcius <NUMBER>
|
||||
* 2: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
* 0: temperature - degrees celsius <NUMBER>
|
||||
* 1: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* dew point <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
* Example:
|
||||
* [32, 0.4] call ace_weather_fnc_calculateDewPoint
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
@ -24,7 +25,6 @@ if (_rh == 0) exitWith { CELSIUS(0) };
|
||||
|
||||
// Source: https://en.wikipedia.org/wiki/Dew_point
|
||||
|
||||
private ["_gamma"];
|
||||
_gamma = ln(_rh) + (__b * _t) / (__c + _t);
|
||||
private _gamma = ln(_rh) + (__b * _t) / (__c + _t);
|
||||
|
||||
(__c * _gamma) / (__b - _gamma)
|
||||
|
@ -1,17 +1,18 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates heat index based on temperature and relative humidity
|
||||
*
|
||||
* Arguments:
|
||||
* 0: temperature - degrees celcius <NUMBER>
|
||||
* 0: temperature - degrees celsius <NUMBER>
|
||||
* 1: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* heat index <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
* Example:
|
||||
* [36, 0.75] call ace_weather_fnc_calculateHeatIndex
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates the terrain roughness length at a given world position
|
||||
*
|
||||
* Arguments:
|
||||
@ -9,19 +8,20 @@
|
||||
* Return Value:
|
||||
* roughness length <NUMBER>
|
||||
*
|
||||
* Example:
|
||||
* (getPosASL player) call ace_weather_fnc_calculateRoughnessLength
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_roughness_lengths", "_windSource", "_nearBuildings", "_isWater"];
|
||||
|
||||
// Source: http://es.ucsc.edu/~jnoble/wind/extrap/index.html
|
||||
_roughness_lengths = [0.0002, 0.0005, 0.0024, 0.03, 0.055, 0.1, 0.2, 0.4, 0.8, 1.6];
|
||||
#define ROUGHNESS_LENGTHS [0.0002, 0.0005, 0.0024, 0.03, 0.055, 0.1, 0.2, 0.4, 0.8, 1.6]
|
||||
|
||||
_windSource = _this vectorDiff ((vectorNormalized ACE_wind) vectorMultiply 25);
|
||||
private _windSource = _this vectorDiff ((vectorNormalized ACE_wind) vectorMultiply 25);
|
||||
|
||||
_nearBuildings = count (_windSource nearObjects ["Building", 50]);
|
||||
_isWater = surfaceIsWater _windSource;
|
||||
private _nearBuildings = count (_windSource nearObjects ["Building", 50]);
|
||||
private _isWater = surfaceIsWater _windSource;
|
||||
|
||||
if (_nearBuildings == 0 && _isWater) exitWith {
|
||||
0.0005
|
||||
@ -31,4 +31,4 @@ if (_nearBuildings >= 10) exitWith {
|
||||
1.6
|
||||
};
|
||||
|
||||
_roughness_lengths select (2 + (_nearBuildings min 6))
|
||||
ROUGHNESS_LENGTHS select (2 + (_nearBuildings min 6))
|
||||
|
@ -1,16 +1,17 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates the speed of sound for a given temperature
|
||||
*
|
||||
* Arguments:
|
||||
* temperature - degrees celcius <NUMBER>
|
||||
* temperature - degrees celsius <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* speed of sound - m/s <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
* Example:
|
||||
* 0 call ace_weather_fnc_calculateSpeedOfSound
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates the temperature based on altitude and weather
|
||||
*
|
||||
* Arguments:
|
||||
@ -9,8 +8,10 @@
|
||||
* Return Value:
|
||||
* temperature - degrees celsius <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
* Example:
|
||||
* 500 call ace_weather_fnc_calculateTemperatureAtHeight
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,36 +1,35 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates wet bulb based on temperature and relative humidity
|
||||
*
|
||||
* Arguments:
|
||||
* 0: temperature - degrees celcius <NUMBER>
|
||||
* 0: temperature - degrees celsius <NUMBER>
|
||||
* 1: pressure - hPa <NUMBER>
|
||||
* 2: relativeHumidity - value between 0.0 and 1.0 <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* wet bulb <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
* Example:
|
||||
* [0, 1020, 0.5] call ace_weather_fnc_calculateWetBulb
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_es", "_e", "_eDiff", "_eGuessPrev", "_cTempDelta", "_twGuess", "_eguess"];
|
||||
|
||||
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));
|
||||
_e = _es * _relativeHumidity;
|
||||
_eDiff = _es - _e;
|
||||
_eGuessPrev = _es;
|
||||
_cTempDelta = 3.3145;
|
||||
_twGuess = _temperature;
|
||||
private _es = 6.112 * exp((17.67 * _temperature) / (_temperature + 243.5));
|
||||
private _e = _es * _relativeHumidity;
|
||||
private _eDiff = _es - _e;
|
||||
private _eGuessPrev = _es;
|
||||
private _cTempDelta = 3.3145;
|
||||
private _twGuess = _temperature;
|
||||
|
||||
for "_j" from 1 to 50 do {
|
||||
_twGuess = _twGuess - _cTempDelta;
|
||||
_eguess = 6.112 * exp((17.67 * _twGuess) / (_twGuess + 243.5));
|
||||
private _eguess = 6.112 * exp((17.67 * _twGuess) / (_twGuess + 243.5));
|
||||
_eguess = _eguess - (_pressure * (_temperature - _twGuess) * 0.00066 * (1 + (0.00115 * _twGuess)));
|
||||
_eDiff = _eguess - _e;
|
||||
if (abs(_eDiff) <= 0.001) exitWith {};
|
||||
|
@ -1,15 +1,17 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates wind chill based on temperature and wind speed
|
||||
*
|
||||
* Arguments:
|
||||
* 0: temperature - degrees celcius <NUMBER>
|
||||
* 0: temperature - degrees celsius <NUMBER>
|
||||
* 1: wind speed - m/s <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* wind chill <NUMBER>
|
||||
*
|
||||
* Example:
|
||||
* [0, 10] call ace_weather_fnc_calculateWindChill
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
@ -1,43 +1,42 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Calculates the true wind speed at a given world position
|
||||
*
|
||||
* Arguments:
|
||||
* 0: world position - posASL <POSTION>
|
||||
* 1: Account for wind gradient <BOOL>
|
||||
* 1: Account for wind gradient (used in advanced ballistics) <BOOL>
|
||||
* 2: Account for terrain <BOOL>
|
||||
* 3: Account for obstacles <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* wind speed - m/s <NUMBER>
|
||||
*
|
||||
* Example:
|
||||
* [eyePos ACE_player, true, true, true] call ace_weather_fnc_calculateWindSpeed;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_fnc_polar2vect", "_windSpeed", "_windDir", "_windDirAdjusted", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"];
|
||||
|
||||
params ["_position", "_windGradientEnabled", "_terrainEffectEnabled", "_obstacleEffectEnabled"];
|
||||
|
||||
_fnc_polar2vect = {
|
||||
private ["_mag2D"];
|
||||
params ["_x", "_y", "_z"];
|
||||
_mag2D = _x * cos(_z);
|
||||
[_mag2D * sin(_y), _mag2D * cos(_y), _x * sin(_z)];
|
||||
private _fnc_polar2vect = {
|
||||
params ["_mag","_dir","_elev"];
|
||||
private _mag2D = _mag * cos(_elev);
|
||||
[_mag2D * sin(_dir), _mag2D * cos(_dir), _mag * sin(_elev)];
|
||||
};
|
||||
|
||||
_windSpeed = vectorMagnitude ACE_wind;
|
||||
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
||||
_windDirAdjusted = _windDir + 180;
|
||||
private _windSpeed = vectorMagnitude ACE_wind;
|
||||
private _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
||||
private _windDirAdjusted = _windDir + 180;
|
||||
|
||||
// Wind gradient
|
||||
if (_windGradientEnabled) then {
|
||||
if (_windSpeed > 0.05) then {
|
||||
_height = (ASLToATL _position) select 2;
|
||||
private _height = (ASLToATL _position) select 2;
|
||||
_height = 0 max _height min 20;
|
||||
if (_height < 20) then {
|
||||
_roughnessLength = _position call FUNC(calculateRoughnessLength);
|
||||
private _roughnessLength = _position call FUNC(calculateRoughnessLength);
|
||||
_windSpeed = _windSpeed * abs(ln(_height / _roughnessLength) / ln(20 / _roughnessLength));
|
||||
};
|
||||
};
|
||||
@ -46,9 +45,9 @@ if (_windGradientEnabled) then {
|
||||
// Terrain effect on wind
|
||||
if (_terrainEffectEnabled) then {
|
||||
if (_windSpeed > 0.05) then {
|
||||
_newWindSpeed = 0;
|
||||
private _newWindSpeed = 0;
|
||||
{
|
||||
_windSource = [100, _windDirAdjusted, _x] call _fnc_polar2vect;
|
||||
private _windSource = [100, _windDirAdjusted, _x] call _fnc_polar2vect;
|
||||
if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 9) * _windSpeed;
|
||||
};
|
||||
@ -60,6 +59,7 @@ if (_terrainEffectEnabled) then {
|
||||
if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 9) * _windSpeed;
|
||||
};
|
||||
nil
|
||||
} count [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
_windSpeed = _newWindSpeed;
|
||||
};
|
||||
@ -68,9 +68,9 @@ if (_terrainEffectEnabled) then {
|
||||
// Obstacle effect on wind
|
||||
if (_obstacleEffectEnabled) then {
|
||||
if (_windSpeed > 0.05) then {
|
||||
_newWindSpeed = 0;
|
||||
private _newWindSpeed = 0;
|
||||
{
|
||||
_windSource = [20, _windDirAdjusted, _x] call _fnc_polar2vect;
|
||||
private _windSource = [20, _windDirAdjusted, _x] call _fnc_polar2vect;
|
||||
if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 2) * _windSpeed;
|
||||
};
|
||||
@ -82,6 +82,7 @@ if (_obstacleEffectEnabled) then {
|
||||
if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith {
|
||||
_newWindSpeed = cos(_x * 2) * _windSpeed;
|
||||
};
|
||||
nil
|
||||
} count [0, 5, 10, 15, 20, 25, 30, 35, 40, 45];
|
||||
_windSpeed = _newWindSpeed;
|
||||
};
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Displays a wind info (colored arrow) in the top left corner of the screen
|
||||
*
|
||||
* Argument:
|
||||
@ -8,6 +7,11 @@
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_displayWindInfo
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
@ -28,17 +32,15 @@ EGVAR(advanced_ballistics,Protractor) = false;
|
||||
GVAR(WindInfo) = true;
|
||||
|
||||
[{
|
||||
private ["_windSpeed", "_windDir", "_playerDir", "_windIndex", "_windColor"];
|
||||
|
||||
if !(GVAR(WindInfo) && !(underwater ACE_player) && vehicle ACE_player == ACE_player) exitWith {
|
||||
if ((!GVAR(WindInfo)) || {underwater ACE_player} || {vehicle ACE_player != ACE_player}) exitWith {
|
||||
GVAR(WindInfo) = false;
|
||||
0 cutText ["", "PLAIN"];
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
_windIndex = 12;
|
||||
_windColor = [1, 1, 1, 1];
|
||||
_windSpeed = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
private _windIndex = 12;
|
||||
private _windColor = [1, 1, 1, 1];
|
||||
private _windSpeed = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
// With wind gradient
|
||||
[eyePos ACE_player, true, true, true] call FUNC(calculateWindSpeed);
|
||||
} else {
|
||||
@ -47,8 +49,8 @@ GVAR(WindInfo) = true;
|
||||
};
|
||||
|
||||
if (_windSpeed > 0.2) then {
|
||||
_playerDir = (ACE_player call CBA_fnc_headDir) select 0;
|
||||
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
||||
private _playerDir = (ACE_player call CBA_fnc_headDir) select 0;
|
||||
private _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
||||
_windIndex = round(((_playerDir - _windDir + 360) % 360) / 30);
|
||||
_windIndex = _windIndex % 12;
|
||||
};
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Ruthberg, esteldunedain
|
||||
*
|
||||
* Get the weather data for the current map
|
||||
*
|
||||
* Argument:
|
||||
@ -8,6 +7,11 @@
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_getMapData
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: ACE2 Team, Ruthberg
|
||||
*
|
||||
* Calculate current wind locally from the data broadcasted by the server
|
||||
*
|
||||
* Argument:
|
||||
@ -8,17 +7,20 @@
|
||||
*
|
||||
* Return value:
|
||||
* Wind <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_getWind
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_periodPercent", "_periodPosition"];
|
||||
|
||||
if (isNil "ACE_WIND_PARAMS") exitWith { [0, 0, 0] };
|
||||
|
||||
ACE_WIND_PARAMS params ["_dir", "_dirChange", "_spd", "_spdChange", "_period"];
|
||||
|
||||
_periodPosition = (ACE_time - GVAR(wind_period_start_time)) min _period;
|
||||
_periodPercent = _periodPosition / _period;
|
||||
private _periodPosition = (ACE_time - GVAR(wind_period_start_time)) min _period;
|
||||
private _periodPercent = _periodPosition / _period;
|
||||
|
||||
_spd = _spd + _spdChange * _periodPercent;
|
||||
_dir = _dir + _dirChange * _periodPercent;
|
||||
|
@ -10,6 +10,9 @@
|
||||
* Return Value:
|
||||
* None <NIL>
|
||||
*
|
||||
* Example:
|
||||
* [module, [], true] call ace_weather_fnc_initModuleSettings
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Inits the wind variables on mission start
|
||||
*
|
||||
* Argument:
|
||||
@ -8,28 +7,32 @@
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_initWind
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_sum", "_rand", "_csum", "_index", "_month", "_windDirectionProbabilities"];
|
||||
_month = date select 1;
|
||||
_windDirectionProbabilities = GVAR(WindDirectionProbabilities) select (_month - 1);
|
||||
private _month = date select 1;
|
||||
private _windDirectionProbabilities = GVAR(WindDirectionProbabilities) select (_month - 1);
|
||||
|
||||
ACE_wind = [0, 0, 0];
|
||||
|
||||
GVAR(wind_direction_reference) = random 360;
|
||||
_sum = 0;
|
||||
private _sum = 0;
|
||||
for "_i" from 0 to 7 do {
|
||||
_sum = _sum + (_windDirectionProbabilities select _i);
|
||||
};
|
||||
_rand = random _sum;
|
||||
_csum = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
private _rand = random _sum;
|
||||
private _csum = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
for "_i" from 0 to 7 do {
|
||||
for "_j" from 0 to _i do {
|
||||
_csum set [_i, (_csum select _i) + (_windDirectionProbabilities select _j)];
|
||||
};
|
||||
};
|
||||
_index = 0;
|
||||
private _index = 0;
|
||||
for "_i" from 0 to 7 do {
|
||||
if (_rand > (_csum select _i)) then {
|
||||
_index = _index + 1;
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
*
|
||||
* Gather weather parameters and broadcast them to the clients
|
||||
*
|
||||
* Argument:
|
||||
@ -8,11 +7,14 @@
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_serverController
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!GVAR(enableServerController)) exitWith {};
|
||||
|
||||
if (GVAR(useACEWeather)) then {
|
||||
// Use location based real world weather data
|
||||
[] call FUNC(updateAceWeather);
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: ACE2 Team, esteldunedain, ruthberg
|
||||
*
|
||||
* Updates the wind and rain evolution on the server. Broadcasts the current and next values to the clients
|
||||
*
|
||||
* Argument:
|
||||
@ -8,20 +7,24 @@
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_updateAceWeather
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_overcastMultiplier", "_lastRain", "_rainOverCast", "_transitionTime", "_windDirectionVariance", "_windSpeed", "_windSpeedChange", "_windMaxDiff", "_windMinDiff", "_windDirection", "_windDirectionChange", "_ratioMin", "_ratioMax"];
|
||||
|
||||
_overcastMultiplier = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1)
|
||||
private _overcastMultiplier = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1)
|
||||
|
||||
// Rain simulation
|
||||
if (GVAR(syncRain) && GVAR(rain_period_count) > GVAR(rain_next_period)) then {
|
||||
if (GVAR(syncRain) && {GVAR(rain_period_count) > GVAR(rain_next_period)}) then {
|
||||
|
||||
GVAR(rain_next_period) = ceil((1 + (random 10)) / _overcastMultiplier);
|
||||
GVAR(rain_period_count) = 0;
|
||||
|
||||
_lastRain = GVAR(current_rain);
|
||||
private _lastRain = GVAR(current_rain);
|
||||
private _rainOverCast = 0;
|
||||
|
||||
if (overcast >= 0.7) then {
|
||||
_rainOverCast = (overcast - 0.7) / 0.3;
|
||||
@ -40,7 +43,7 @@ if (GVAR(syncRain) && GVAR(rain_period_count) > GVAR(rain_next_period)) then {
|
||||
GVAR(current_rain) = 0;
|
||||
};
|
||||
|
||||
_transitionTime = 1 + (_rainOverCast * 5) + (random (_rainOverCast * 20));
|
||||
private _transitionTime = 1 + (_rainOverCast * 5) + (random (_rainOverCast * 20));
|
||||
|
||||
ACE_RAIN_PARAMS = [_lastRain, GVAR(current_rain), _transitionTime];
|
||||
TRACE_4("",_lastRain,_rainOverCast,_transitionTime,overcast);
|
||||
@ -50,14 +53,14 @@ if (GVAR(syncRain) && GVAR(rain_period_count) > GVAR(rain_next_period)) then {
|
||||
};
|
||||
|
||||
// Wind simulation
|
||||
if (GVAR(syncWind) && GVAR(wind_period_count) > GVAR(wind_next_period)) then {
|
||||
if (GVAR(syncWind) && {GVAR(wind_period_count) > GVAR(wind_next_period)}) then {
|
||||
|
||||
GVAR(wind_next_period) = ceil((2 + (random 5)) / _overcastMultiplier);
|
||||
GVAR(wind_period_count) = 0;
|
||||
|
||||
_windDirectionVariance = (90 - (random 180)) * (overcast ^ 2);
|
||||
_windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360;
|
||||
_windDirectionChange = _windDirection - GVAR(current_wind_direction);
|
||||
private _windDirectionVariance = (90 - (random 180)) * (overcast ^ 2);
|
||||
private _windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360;
|
||||
private _windDirectionChange = _windDirection - GVAR(current_wind_direction);
|
||||
if (_windDirectionChange > 180) then {
|
||||
_windDirectionChange = _windDirectionChange - 360;
|
||||
};
|
||||
@ -65,20 +68,20 @@ if (GVAR(syncWind) && GVAR(wind_period_count) > GVAR(wind_next_period)) then {
|
||||
_windDirectionChange = 360 + _windDirectionChange;
|
||||
};
|
||||
|
||||
_windMaxDiff = GVAR(mean_wind_speed) - GVAR(max_wind_speed);
|
||||
_windMinDiff = GVAR(min_wind_speed) - GVAR(mean_wind_speed);
|
||||
private _windMaxDiff = GVAR(mean_wind_speed) - GVAR(max_wind_speed);
|
||||
private _windMinDiff = GVAR(min_wind_speed) - GVAR(mean_wind_speed);
|
||||
|
||||
_ratioMax = (random 1) ^ 2;
|
||||
_ratioMin = (random 1) ^ 2;
|
||||
private _ratioMax = (random 1) ^ 2;
|
||||
private _ratioMin = (random 1) ^ 2;
|
||||
|
||||
_windSpeed = GVAR(current_wind_speed);
|
||||
_windSpeedChange = 0;
|
||||
private _windSpeed = GVAR(current_wind_speed);
|
||||
private _windSpeedChange = 0;
|
||||
if ((random 1) < (0.3 max overcast)) then {
|
||||
_windSpeed = GVAR(mean_wind_speed) + _windMaxDiff * _ratioMax + _windMinDiff * _ratioMin;
|
||||
_windSpeedChange = _windSpeed - GVAR(current_wind_speed);
|
||||
};
|
||||
|
||||
_transitionTime = GVAR(wind_next_period) * GVAR(serverUpdateInterval);
|
||||
private _transitionTime = GVAR(wind_next_period) * GVAR(serverUpdateInterval);
|
||||
|
||||
TRACE_5("dirCur/dirNew/spdCur/spdNew/period",GVAR(current_wind_direction),_windDirection,GVAR(current_wind_speed),_windSpeed,_transitionTime);
|
||||
|
||||
|
@ -1,27 +1,30 @@
|
||||
/*
|
||||
* Author: ACE2 Team
|
||||
*
|
||||
* Updates GVAR(currentHumidity) based on
|
||||
* Updates GVAR(currentHumidity)
|
||||
*
|
||||
* Argument:
|
||||
* Nothing
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_updateHumidity
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_month", "_avgTemperature", "_pS1", "_pS2"];
|
||||
_month = date select 1;
|
||||
private _month = date select 1;
|
||||
|
||||
GVAR(currentHumidity) = (GVAR(Humidity) select (_month - 1)) / 100;
|
||||
|
||||
if (rain > 0 && overcast > 0.7) then {
|
||||
if ((rain > 0) && {overcast > 0.7}) then {
|
||||
GVAR(currentHumidity) = 1;
|
||||
} else {
|
||||
_avgTemperature = ((GVAR(TempDay) select (_month - 1)) + (GVAR(TempNight) select (_month - 1))) / 2;
|
||||
_pS1 = 6.112 * exp((17.62 * _avgTemperature) / (243.12 + _avgTemperature));
|
||||
_PS2 = 6.112 * exp((17.62 * GVAR(currentTemperature)) / (243.12 + GVAR(currentTemperature)));
|
||||
private _avgTemperature = ((GVAR(TempDay) select (_month - 1)) + (GVAR(TempNight) select (_month - 1))) / 2;
|
||||
private _pS1 = 6.112 * exp((17.62 * _avgTemperature) / (243.12 + _avgTemperature));
|
||||
private _PS2 = 6.112 * exp((17.62 * GVAR(currentTemperature)) / (243.12 + GVAR(currentTemperature)));
|
||||
GVAR(currentHumidity) = GVAR(currentHumidity) * _PS1 / _PS2;
|
||||
GVAR(currentHumidity) = GVAR(currentHumidity) + GVAR(humidityShift);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: ACE2 Team, Ruthberg
|
||||
*
|
||||
* Updates rain based on ACE_RAIN_PARAMS
|
||||
*
|
||||
* Argument:
|
||||
@ -8,17 +7,21 @@
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_updateRain
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!GVAR(syncRain)) exitWith {};
|
||||
|
||||
if (!isNil "ACE_RAIN_PARAMS") then {
|
||||
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;
|
||||
private _periodPosition = (ACE_time - GVAR(rain_period_start_time)) min _period;
|
||||
private _periodPercent = (_periodPosition / _period) min 1;
|
||||
|
||||
GVAR(ACE_Rain) = (_oldRain + (_newRain - _oldRain) * _periodPercent);
|
||||
GVAR(ACE_Rain) = linearConversion [GVAR(rain_period_start_time), (GVAR(rain_period_start_time) + _period), ACE_time, _oldRain, _newRain];
|
||||
|
||||
TRACE_3("Update Rain",rain,ACE_RAIN_PARAMS,GVAR(ACE_Rain));
|
||||
};
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: ACE2 Team
|
||||
*
|
||||
* Updates GVAR(currentTemperature) based on the map data
|
||||
*
|
||||
* Argument:
|
||||
@ -8,14 +7,18 @@
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_updateTemperature
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_time", "_month", "_timeRatio"];
|
||||
_time = daytime;
|
||||
_month = date select 1;
|
||||
private _time = daytime;
|
||||
private _month = date select 1;
|
||||
|
||||
_timeRatio = abs(_time - 12) / 12;
|
||||
private _timeRatio = abs(_time - 12) / 12;
|
||||
|
||||
GVAR(currentTemperature) = (GVAR(TempDay) select (_month - 1)) * (1 - _timeRatio) + (GVAR(TempNight) select (_month - 1)) * _timeRatio;
|
||||
GVAR(currentTemperature) = GVAR(currentTemperature) + GVAR(temperatureShift) - GVAR(badWeatherShift) * overcast;
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: ACE2 Team, Ruthberg
|
||||
*
|
||||
* Updates wind, gusts and waves based on ACE_wind
|
||||
*
|
||||
* Argument:
|
||||
@ -8,19 +7,22 @@
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_weather_fnc_updateWind
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!GVAR(syncWind)) exitWith { ACE_wind = wind };
|
||||
|
||||
private ["_newWaves"];
|
||||
|
||||
ACE_wind = [] call FUNC(getWind);
|
||||
setWind [ACE_wind select 0, ACE_wind select 1, true];
|
||||
2 setGusts 0;
|
||||
|
||||
// Set waves: 0 when no wind, 1 when wind >= 16 m/s
|
||||
_newWaves = ((vectorMagnitude ACE_wind) / 16.0) min 1.0;
|
||||
private _newWaves = ((vectorMagnitude ACE_wind) / 16.0) min 1.0;
|
||||
if (abs(_newWaves - waves) > 0.1) then {
|
||||
1 setWaves _newWaves;
|
||||
};
|
||||
|
@ -1,6 +1,9 @@
|
||||
#define COMPONENT weather
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
//#define DEBUG_ENABLED_WEATHER
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef DEBUG_ENABLED_WEATHER
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user