mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Weather - Add a 'check air temperature' action (#6154)
This commit is contained in:
parent
9b8cfc27af
commit
846b65864f
@ -1,24 +1,11 @@
|
|||||||
class ACE_Settings {
|
class ACE_Settings {
|
||||||
class GVAR(enabled) {
|
class GVAR(enabled) {
|
||||||
category = CSTRING(Module_DisplayName);
|
movedToSQF = 1;
|
||||||
displayName = CSTRING(enabled_DisplayName);
|
|
||||||
description = CSTRING(enabled_Description);
|
|
||||||
typeName = "BOOL";
|
|
||||||
value = 1;
|
|
||||||
};
|
};
|
||||||
class GVAR(updateInterval) {
|
class GVAR(updateInterval) {
|
||||||
category = CSTRING(Module_DisplayName);
|
movedToSQF = 1;
|
||||||
displayName = CSTRING(updateInterval_DisplayName);
|
|
||||||
description = CSTRING(updateInterval_Description);
|
|
||||||
typeName = "SCALAR";
|
|
||||||
value = 60;
|
|
||||||
sliderSettings[] = {0, 300, 0, 0};
|
|
||||||
};
|
};
|
||||||
class GVAR(windSimulation) {
|
class GVAR(windSimulation) {
|
||||||
category = CSTRING(Module_DisplayName);
|
movedToSQF = 1;
|
||||||
displayName = CSTRING(windSimulation_DisplayName);
|
|
||||||
description = CSTRING(windSimulation_Description);
|
|
||||||
typeName = "BOOL";
|
|
||||||
value = 1;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,17 @@
|
|||||||
class CfgVehicles {
|
class CfgVehicles {
|
||||||
|
class Man;
|
||||||
|
class CAManBase: Man {
|
||||||
|
class ACE_SelfActions {
|
||||||
|
class ACE_CheckAirTemperature {
|
||||||
|
displayName = CSTRING(CheckAirTemperature);
|
||||||
|
condition = QUOTE(GVAR(enabled) && GVAR(showCheckAirTemperature));
|
||||||
|
exceptions[] = {"isNotInside", "isNotSitting"};
|
||||||
|
statement = QUOTE([ACE_player] call FUNC(getApproximateAirTemp));
|
||||||
|
icon = QPATHTOF(UI\temp_ca.paa);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
class ACE_Module;
|
class ACE_Module;
|
||||||
class GVAR(ModuleSettings): ACE_Module {
|
class GVAR(ModuleSettings): ACE_Module {
|
||||||
scope = 1;
|
scope = 1;
|
||||||
|
BIN
addons/weather/UI/temp_ca.paa
Normal file
BIN
addons/weather/UI/temp_ca.paa
Normal file
Binary file not shown.
@ -10,7 +10,9 @@ PREP(calculateTemperatureAtHeight);
|
|||||||
PREP(calculateWetBulb);
|
PREP(calculateWetBulb);
|
||||||
PREP(calculateWindChill);
|
PREP(calculateWindChill);
|
||||||
PREP(calculateWindSpeed);
|
PREP(calculateWindSpeed);
|
||||||
|
PREP(displayAirTemp);
|
||||||
PREP(displayWindInfo);
|
PREP(displayWindInfo);
|
||||||
|
PREP(getApproximateAirTemp);
|
||||||
PREP(getMapData);
|
PREP(getMapData);
|
||||||
PREP(initModuleSettings);
|
PREP(initModuleSettings);
|
||||||
PREP(initWind);
|
PREP(initWind);
|
||||||
|
@ -7,6 +7,8 @@ PREP_RECOMPILE_START;
|
|||||||
#include "XEH_PREP.hpp"
|
#include "XEH_PREP.hpp"
|
||||||
PREP_RECOMPILE_END;
|
PREP_RECOMPILE_END;
|
||||||
|
|
||||||
|
#include "initSettings.sqf"
|
||||||
|
|
||||||
// Make sure this data is read before client/server postInit
|
// Make sure this data is read before client/server postInit
|
||||||
call FUNC(getMapData);
|
call FUNC(getMapData);
|
||||||
|
|
||||||
|
72
addons/weather/functions/fnc_displayAirTemp.sqf
Normal file
72
addons/weather/functions/fnc_displayAirTemp.sqf
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: LorenLuke
|
||||||
|
* Displays an abstracted depiction of air temperature to a unit.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Temperature <NUMBER>
|
||||||
|
* 1: Unit Bias range <ARRAY>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [15.8] call ace_weather_fnc_displayAirTemp
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_apparent_temperature", "_bias"];
|
||||||
|
TRACE_2("params",_temperature, _bias);
|
||||||
|
|
||||||
|
_temperature1 = floor(_temperature + (_bias select 0) - (random 2));
|
||||||
|
_temperature2 = floor(_temperature + (_bias select 1) + (random 2));
|
||||||
|
|
||||||
|
private _color1 = [
|
||||||
|
// Colors obtained by quartic regression formula of RGB values at corresponding temperatures as marked on advanced_ballistics rangecard
|
||||||
|
( (((-0.000238348 * (_temperature1 ^ 4)) - (0.00865642 * (_temperature1 ^ 3)) + (0.794548 * (_temperature1 ^2)) - (0.323314 * _temperature1) +6.78445) min 255) /255) max 0,
|
||||||
|
( (((-0.000308515 * (_temperature1 ^ 4)) + (0.000245732 * (_temperature1 ^ 3)) + (0.308531 * (_temperature1 ^2)) - (02.78916 * _temperature1) +164.326) min 255) /255) max 0,
|
||||||
|
( (((-0.000107648 * (_temperature1 ^ 4)) + (0.00106365 * (_temperature1 ^ 3)) - (0.0989707 * (_temperature1 ^2)) - (9.66256 * _temperature1) +171.402) min 255) /255) max 0
|
||||||
|
];
|
||||||
|
|
||||||
|
private _text = composeText ["", [format ["%1C", _temperature1],_color1] call EFUNC(common,stringToColoredText)];
|
||||||
|
_text = composeText [_text, [" --- ", [1,1,1]] call EFUNC(common,stringToColoredText)];
|
||||||
|
|
||||||
|
private _color2 = [
|
||||||
|
// Colors obtained by quartic regression formula of RGB values at corresponding temperatures as marked on advanced_ballistics rangecard
|
||||||
|
( (((-0.000238348 * (_temperature2 ^ 4)) - (0.00865642 * (_temperature2 ^ 3)) + (0.794548 * (_temperature2 ^2)) - (0.323314 * _temperature2) +6.78445) min 255) /255) max 0,
|
||||||
|
( (((-0.000308515 * (_temperature2 ^ 4)) + (0.000245732 * (_temperature2 ^ 3)) + (0.308531 * (_temperature2 ^2)) - (02.78916 * _temperature2) +164.326) min 255) /255) max 0,
|
||||||
|
( (((-0.000107648 * (_temperature2 ^ 4)) + (0.00106365 * (_temperature2 ^ 3)) - (0.0989707 * (_temperature2 ^2)) - (9.66256 * _temperature2) +171.402) min 255) /255) max 0
|
||||||
|
];
|
||||||
|
|
||||||
|
_text = composeText [_text, [format ["%1C", _temperature2], _color2] call EFUNC(common,stringToColoredText)];
|
||||||
|
|
||||||
|
[_text, QPATHTOF(UI\temp_ca.paa),_color, ACE_player, 2] call EFUNC(common,displayTextPicture);
|
||||||
|
|
||||||
|
/*
|
||||||
|
for "_i" from -40 to 40 step 4 do {
|
||||||
|
_temp_color = _color;
|
||||||
|
|
||||||
|
if (_i == 0) then {
|
||||||
|
_text = composeText [_text, ["[", _temp_color] call EFUNC(common,stringToColoredText)];
|
||||||
|
_text = composeText [_text, ["0", [0.6, 1, 0.6]] call EFUNC(common,stringToColoredText)];
|
||||||
|
_text = composeText [_text, ["]", _temp_color] call EFUNC(common,stringToColoredText)];
|
||||||
|
} else {
|
||||||
|
_string = "I";
|
||||||
|
};
|
||||||
|
|
||||||
|
if (abs( _i - _apparent_temperature) < 8.5) then {
|
||||||
|
_temp_color = [
|
||||||
|
// Colors obtained by quartic regression formula of RGB values at corresponding temperatures as marked on advanced_ballistics rangecard
|
||||||
|
( (((-0.000238348 * (_i ^ 4)) - (0.00865642 * (_i ^ 3)) + (0.794548 * (_i ^2)) - (0.323314 * _i) +6.78445) min 255) /255) max 0,
|
||||||
|
( (((-0.000308515 * (_i ^ 4)) + (0.000245732 * (_i ^ 3)) + (0.308531 * (_i ^2)) - (02.78916 * _i) +164.326) min 255) /255) max 0,
|
||||||
|
( (((-0.000107648 * (_i ^ 4)) + (0.00106365 * (_i ^ 3)) - (0.0989707 * (_i ^2)) - (9.66256 * _i) +171.402) min 255) /255) max 0
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
_text = composeText [_text, [_string, [_temp_color select 0, _temp_color select 1, _temp_color select 2]] call EFUNC(common,stringToColoredText)];
|
||||||
|
};
|
||||||
|
|
||||||
|
_text = composeText [_text, [" +40C", [1,0,0]] call EFUNC(common,stringToColoredText)];
|
||||||
|
*/
|
||||||
|
[_text, QPATHTOF(UI\temp_ca.paa),[1,1,1], ACE_player, 2] call EFUNC(common,displayTextPicture);
|
70
addons/weather/functions/fnc_getApproximateAirTemp.sqf
Normal file
70
addons/weather/functions/fnc_getApproximateAirTemp.sqf
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: LorenLuke
|
||||||
|
* Returns an approximate representation of temperature at a unit's location.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [ACE_player] call ace_weather_fnc_getApproximateAirTemp
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit"];
|
||||||
|
TRACE_1("params",_unit);
|
||||||
|
|
||||||
|
if (isNil (format ["%1", _unit getVariable "ACE_airTemperatureBias"])) then {
|
||||||
|
_unit setVariable ["ACE_airTemperatureBias", [-(random(3) + 1), random(3) + 1]];
|
||||||
|
};
|
||||||
|
|
||||||
|
private _temperature = ((getPosASL _unit) select 2) call EFUNC(weather,calculateTemperatureAtHeight);
|
||||||
|
private _humidity = EGVAR(weather,currentHumidity);
|
||||||
|
private _heatIndex = [_temperature, _humidity] call EFUNC(weather,calculateHeatIndex);
|
||||||
|
private _chill = [_temperature, _humidity] call EFUNC(weather,calculateWindChill);
|
||||||
|
|
||||||
|
private _e = 2^(1/(ln 2));
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Windchill calc with wind vars; https://en.wikipedia.org/wiki/Wind_chill#Australian_Apparent_Temperature
|
||||||
|
private _windspeed = [getPosASL _unit, true, true, true] call EFUNC(weather,calculateWindSpeed);
|
||||||
|
private _water_vapor_pressure = _humidity * 6.105 *(_e ^ ((17.27 * _temperature)/(237.7 + _temperature))) / 100;
|
||||||
|
private _chill = _temperature + (0.33 * _water_vapor_pressure) - (0.70 * _windspeed) - 400;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// sigmoid = f(x) = L / (1 + e^(-k * (x - x_0)));
|
||||||
|
// L max value, e = euler, k = steepness,
|
||||||
|
|
||||||
|
// L = max value
|
||||||
|
private _sigmoid_L = 1;
|
||||||
|
|
||||||
|
// x_0 = sigmoid midpoint, aka 50% proportion; 18.5C, ~65F
|
||||||
|
private _sigmoid_midpoint = 18.5;
|
||||||
|
|
||||||
|
// place +- midpoint with desired proportion
|
||||||
|
private _sigmoid_valuation = 8.5;
|
||||||
|
|
||||||
|
// desired upper and proportion on sigmoid
|
||||||
|
private _sigmoid_proportion_at_valuation = 0.95;
|
||||||
|
private _sigmoid_proportion_at_lower_valuation = 1 - _sigmoid_proportion_at_valuation;
|
||||||
|
|
||||||
|
// k = steepness
|
||||||
|
private _sigmoid_k = (ln ((_sigmoid_proportion_at_lower_valuation^-1) - 1) ) / _sigmoid_valuation;
|
||||||
|
|
||||||
|
// 5$/95% @ 10C/27C; [5% and 95% values at 50F and ~80F];
|
||||||
|
// 5% = 0.05 = 1/20 = f(_midpoint - _valuation) = L / (1 + e^(-k * ((_midpoint - _valuation) - _midpoint)
|
||||||
|
// (0.05)^-1 = 20 = (L / (1 + e^(-k * (-_valuation))) )^-1 = (1 + e^(-k * -_valuation))/L;
|
||||||
|
// L = 1;> 20 = (1 + e^(k * valuation)); 20 - 1 = e^(k * valuation);
|
||||||
|
// 19 = e^(k * 8.5); (log_e 19) = (k * 8.5); (log_e 19)/8.5 = k;
|
||||||
|
|
||||||
|
// retrieve sigmoid proportion at _temperature
|
||||||
|
private _temperature_sigmoid = _sigmoid_L / (1 + _e^(-_sigmoid_k * (_temperature - _sigmoid_midpoint)));
|
||||||
|
|
||||||
|
// Weighted average between windchill and heat index based on sigmoid levels, plus +- 4deg randomisation
|
||||||
|
private _apparent_temperature = ((_temperature_sigmoid * _heatIndex) + ((1 - _temperature_sigmoid) * _chill) + random(8) - 4);
|
||||||
|
|
||||||
|
[_apparent_temperature, (_unit getVariable "ACE_airTemperatureBias")] call FUNC(displayAirTemp);
|
39
addons/weather/initSettings.sqf
Normal file
39
addons/weather/initSettings.sqf
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
private _category = [format ["ACE %1", LLSTRING(Module_DisplayName)]];
|
||||||
|
|
||||||
|
[
|
||||||
|
QGVAR(enabled), "CHECKBOX",
|
||||||
|
[LSTRING(enabled_DisplayName), LSTRING(enabled_Description)],
|
||||||
|
_category,
|
||||||
|
true, // default value
|
||||||
|
true, // isGlobal
|
||||||
|
{[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
|
||||||
|
true // Needs mission restart
|
||||||
|
] call CBA_settings_fnc_init;
|
||||||
|
|
||||||
|
[
|
||||||
|
QGVAR(updateInterval), "SLIDER",
|
||||||
|
[LSTRING(updateInterval_DisplayName), LSTRING(updateInterval_Description)],
|
||||||
|
_category,
|
||||||
|
[0,300,60,0], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
|
||||||
|
true, // isGlobal
|
||||||
|
{[QGVAR(updateInterval), _this] call EFUNC(common,cbaSettings_settingChanged)},
|
||||||
|
true // Needs mission restart
|
||||||
|
] call CBA_settings_fnc_init;
|
||||||
|
|
||||||
|
[
|
||||||
|
QGVAR(windSimulation), "CHECKBOX",
|
||||||
|
[LSTRING(windSimulation_DisplayName), LSTRING(windSimulation_Description)],
|
||||||
|
_category,
|
||||||
|
true, // default value
|
||||||
|
true, // isGlobal
|
||||||
|
{[QGVAR(windSimulation), _this] call EFUNC(common,cbaSettings_settingChanged)},
|
||||||
|
true // Needs mission restart
|
||||||
|
] call CBA_settings_fnc_init;
|
||||||
|
|
||||||
|
[
|
||||||
|
QGVAR(showCheckAirTemperature), "CHECKBOX",
|
||||||
|
[LSTRING(showCheckAirTemperature_DisplayName)],
|
||||||
|
_category,
|
||||||
|
true, // default value
|
||||||
|
false, // isGlobal
|
||||||
|
] call CBA_settings_fnc_init;
|
@ -152,5 +152,11 @@
|
|||||||
<Portuguese>Ativar a simulação de vento dos mapas. (sobrepõe vento vanilla)</Portuguese>
|
<Portuguese>Ativar a simulação de vento dos mapas. (sobrepõe vento vanilla)</Portuguese>
|
||||||
<Czech>Povoluje simulaci větru založenou na mapě (přepíše původní vítr)</Czech>
|
<Czech>Povoluje simulaci větru založenou na mapě (přepíše původní vítr)</Czech>
|
||||||
</Key>
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Weather_CheckAirTemperature">
|
||||||
|
<English>Check Air Temperature</English>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Weather_showCheckAirTemperature_DisplayName">
|
||||||
|
<English>Show Check Air Temperature Action</English>
|
||||||
|
</Key>
|
||||||
</Package>
|
</Package>
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user