Moved all temperature calculations into the weather module.

This commit is contained in:
ulteq 2015-05-14 16:07:41 +02:00
parent ddbf274c89
commit cf487b544e
9 changed files with 38 additions and 25 deletions

View File

@ -76,7 +76,7 @@ if (GVAR(barrelLengthInfluenceEnabled)) then {
};
if (GVAR(ammoTemperatureEnabled)) then {
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL _unit) select 2);
_temperature = ((getPosASL _unit) select 2) call EFUNC(weather,calculateTemperatureAtHeight);
_muzzleVelocityShift = [_AmmoCacheEntry select 9, _temperature] call FUNC(calculateAmmoTemperatureVelocityShift);
if (_muzzleVelocityShift != 0) then {
_bulletVelocity = _bulletVelocity vectorAdd ((vectorNormalized _bulletVelocity) vectorMultiply (_muzzleVelocityShift));
@ -105,7 +105,7 @@ _barrelTwist = _WeaponCacheEntry select 0;
_stabilityFactor = 1.5;
if (_caliber > 0 && _bulletLength > 0 && _bulletMass > 0 && _barrelTwist > 0) then {
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL _unit) select 2);
_temperature = ((getPosASL _unit) select 2) call EFUNC(weather,calculateTemperatureAtHeight);
_barometricPressure = ((getPosASL _bullet) select 2) call EFUNC(weather,calculateBarometricPressure);
_stabilityFactor = [_caliber, _bulletLength, _bulletMass, _barrelTwist, _muzzleVelocity, _temperature, _barometricPressure] call FUNC(calculateStabilityFactor);
};

View File

@ -21,6 +21,5 @@
#define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058
#define STD_AIR_DENSITY_ICAO 1.22498
#define STD_AIR_DENSITY_ASM 1.20885
#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h))
#define EXTENSION_REQUIRED_VERSION "1.0"

View File

@ -14,13 +14,14 @@
*/
#include "script_component.hpp"
private ["_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"];
private ["_playerAltitude", "_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"];
_playerAltitude = (getPosASL ACE_player) select 2;
if (isNil QGVAR(MIN) || isNil QGVAR(MAX)) then {
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight);
_humidity = EGVAR(weather,currentHumidity);
_barometricPressure = ((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure);
_altitude = EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2);
_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure);
_altitude = EGVAR(weather,Altitude) + _playerAltitude;
GVAR(MIN) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude];
GVAR(MAX) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude];
};
@ -70,7 +71,7 @@ if (GVAR(MinAvgMaxMode) == 1) then {
};
// TEMP
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight);
GVAR(MIN) set [4, (GVAR(MIN) select 4) min _temperature];
GVAR(MAX) set [4, _temperature max (GVAR(MAX) select 4)];
GVAR(TOTAL) set [4, (GVAR(TOTAL) select 4) + _temperature];
@ -82,13 +83,13 @@ GVAR(MAX) set [5, _humidity max (GVAR(MAX) select 5)];
GVAR(TOTAL) set [5, (GVAR(TOTAL) select 5) + _humidity];
// BARO
_barometricPressure = ((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure);
_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure);
GVAR(MIN) set [6, (GVAR(MIN) select 6) min _barometricPressure];
GVAR(MAX) set [6, _barometricPressure max (GVAR(MAX) select 6)];
GVAR(TOTAL) set [6, (GVAR(TOTAL) select 6) + _barometricPressure];
// ALTITUDE
_altitude = EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2);
_altitude = EGVAR(weather,Altitude) + _playerAltitude;
GVAR(MIN) set [7, (GVAR(MIN) select 7) min _altitude];
GVAR(MAX) set [7, _altitude max (GVAR(MAX) select 7)];
GVAR(TOTAL) set [7, (GVAR(TOTAL) select 7) + _altitude];

View File

@ -34,10 +34,11 @@ _textInfoLine2 = "";
_windSpeed = call FUNC(measureWindSpeed);
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
_humidity = EGVAR(weather,currentHumidity);
_playerDir = getDir ACE_player;
_playerAltitude = (getPosASL ACE_player) select 2;
_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight);
_humidity = EGVAR(weather,currentHumidity);
GVAR(Direction) = 4 * floor(_playerDir / 90);
if (_playerDir % 90 > 10) then { GVAR(Direction) = GVAR(Direction) + 1};
@ -174,7 +175,7 @@ switch (GVAR(Menu)) do {
};
case 6: { // BARO
if (!GVAR(MinAvgMax)) then {
_textCenterBig = Str(round((((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure)) * 10) / 10);
_textCenterBig = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10);
} else {
_textCenterLine1Left = "Min";
_textCenterLine2Left = "Avg";
@ -186,7 +187,7 @@ switch (GVAR(Menu)) do {
};
case 7: { // ALTITUDE
if (!GVAR(MinAvgMax)) then {
_textCenterBig = Str(round(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2)));
_textCenterBig = Str(round(EGVAR(weather,Altitude) + _playerAltitude));
} else {
_textCenterLine1Left = "Min";
_textCenterLine2Left = "Avg";
@ -198,7 +199,7 @@ switch (GVAR(Menu)) do {
};
case 8: { // User Screen 1
_textCenterLine1Left = Str(round(_playerDir));
_textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2)));
_textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + _playerAltitude));
_textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10);
_textCenterLine1Right = GVAR(Directions) select GVAR(Direction);
_textCenterLine2Right = "m";
@ -207,7 +208,7 @@ switch (GVAR(Menu)) do {
case 9: { // User Screen 2
_textCenterLine1Left = Str(round(_temperature * 10) / 10);
_textCenterLine2Left = Str(round(_humidity * 100 * 10) / 10);
_textCenterLine3Left = Str(round((1013.25 * exp(-(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2)) / 7990) - 10 * overcast) * 10) / 10);
_textCenterLine3Left = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10);
_textCenterLine1Right = "C";
_textCenterLine2Right = "%";
_textCenterLine3Right = "hPA";

View File

@ -10,5 +10,3 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h))

View File

@ -42,8 +42,7 @@ if (_bisAirFriction != 0) exitWith {ERROR("Non zero base airFriction");};
//Calculate air density:
_altitude = (getPosASL _vehicle) select 2;
#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h))
_temperature = GET_TEMPERATURE_AT_HEIGHT(_altitude);
_temperature = _altitude call EFUNC(weather,calculateTemperatureAtHeight);
_pressure = _altitude call EFUNC(weather,calculateBarometricPressure);
_relativeHumidity = EGVAR(weather,currentHumidity);
_airDensity = [_temperature, _pressure, _relativeHumidity] call EFUNC(weather,calculateAirDensity);

View File

@ -6,6 +6,7 @@ ADDON = false;
PREP(calculateAirDensity);
PREP(calculateBarometricPressure);
PREP(calculateRoughnessLength);
PREP(calculateTemperatureAtHeight);
PREP(calculateWindSpeed);
PREP(displayWindInfo);
PREP(getMapData);

View File

@ -14,7 +14,4 @@
*/
#include "script_component.hpp"
private ["_altitude"];
_altitude = _this;
(1013.25 * exp(-(GVAR(Altitude) + _altitude) / 7990) - 10 * overcast)
(1013.25 * exp(-(GVAR(Altitude) + _this) / 7990) - 10 * overcast)

View File

@ -0,0 +1,17 @@
/*
* Author: Ruthberg
*
* Calculates the temperature based on altitude and weather
*
* Arguments:
* 0: height - meters <NUMBER>
*
* Return Value:
* 0: temperature - degrees celsius <NUMBER>
*
* Return value:
* None
*/
#include "script_component.hpp"
(GVAR(currentTemperature) - 0.0065 * _this)