mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Refactored the Kestrel4500 Code.
This commit is contained in:
parent
c98422b2c6
commit
4355df118c
@ -19,7 +19,10 @@ GVAR(RefHeading) = 0;
|
||||
GVAR(updateTimer) = 0;
|
||||
GVAR(outputData) = ["", "", "", "", "", "", "", "", "", ""];
|
||||
GVAR(MeasuredWindSpeed) = 0;
|
||||
GVAR(WheelState) = 0;
|
||||
GVAR(ImpellerState) = 0;
|
||||
|
||||
GVAR(Kestrel4500) = false;
|
||||
GVAR(Overlay) = false;
|
||||
|
||||
// TODO: Remove this, after merging the ab branch
|
||||
if (isNil QUOTE(EGVAR(weather,Altitude))) then {EGVAR(weather,Altitude) = 0};
|
||||
|
@ -9,6 +9,8 @@ PREP(collectData);
|
||||
PREP(createKestrelDialog);
|
||||
PREP(displayKestrel);
|
||||
PREP(generateOutputData);
|
||||
PREP(measureWindSpeed);
|
||||
PREP(updateDisplay);
|
||||
PREP(updateImpellerState);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -42,21 +42,13 @@ if (GVAR(MinAvgMaxMode) == 1) then {
|
||||
} forEach [1, 2, 3];
|
||||
|
||||
// Wind SPD
|
||||
_windSpeed = vectorMagnitude ACE_wind;
|
||||
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
||||
|
||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
_windSpeed = (eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed);
|
||||
_windSpeed = abs(cos(_playerDir - _windDir)) * _windSpeed;
|
||||
} else {
|
||||
_windSpeed = (eyePos ACE_player) call FUNC(calculateWindSpeed);
|
||||
};
|
||||
|
||||
_windSpeed = call FUNC(measureWindSpeed);
|
||||
GVAR(MIN) set [1, (GVAR(MIN) select 1) min abs(_windSpeed)];
|
||||
GVAR(MAX) set [1, abs(_windSpeed) max (GVAR(MAX) select 1)];
|
||||
GVAR(TOTAL) set [1, (GVAR(TOTAL) select 1) + abs(_windSpeed)];
|
||||
|
||||
// CROSSWIND
|
||||
_crosswind = 0;
|
||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
_crosswind = abs(sin(GVAR(RefHeading) - _playerDir) * _windSpeed);
|
||||
} else {
|
||||
@ -67,6 +59,7 @@ if (GVAR(MinAvgMaxMode) == 1) then {
|
||||
GVAR(TOTAL) set [2, (GVAR(TOTAL) select 2) + _crosswind];
|
||||
|
||||
// HEADWIND
|
||||
_headwind = 0;
|
||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
_headwind = abs(cos(GVAR(RefHeading) - _playerDir) * _windSpeed);
|
||||
} else {
|
||||
|
@ -52,35 +52,34 @@ GVAR(Overlay) = true;
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
_outputData = [] call FUNC(generateOutputData);
|
||||
|
||||
if (diag_tickTime > GVAR(updateTimer)) then {
|
||||
GVAR(updateTimer) = diag_tickTime + 1;
|
||||
GVAR(outputData) = _outputData;
|
||||
|
||||
_outputData = [] call FUNC(generateOutputData);
|
||||
|
||||
3 cutRsc ["RscKestrel4500", "PLAIN", 1, false];
|
||||
|
||||
__ctrlTop ctrlSetText (_outputData select 0);
|
||||
__ctrlCenterBig ctrlSetText (_outputData select 1);
|
||||
|
||||
__ctrlTop ctrlSetText (_outputData select 0);
|
||||
__ctrlCenterBig ctrlSetText (_outputData select 1);
|
||||
|
||||
__ctrlCenterLine1Left ctrlSetText (_outputData select 2);
|
||||
__ctrlCenterLine2Left ctrlSetText (_outputData select 3);
|
||||
__ctrlCenterLine3Left ctrlSetText (_outputData select 4);
|
||||
|
||||
__ctrlCenterLine1Right ctrlSetText (_outputData select 5);
|
||||
__ctrlCenterLine2Right ctrlSetText (_outputData select 6);
|
||||
__ctrlCenterLine3Right ctrlSetText (_outputData select 7);
|
||||
|
||||
__ctrlInfoLine1 ctrlSetText (_outputData select 8);
|
||||
__ctrlInfoLine2 ctrlSetText (_outputData select 9);
|
||||
};
|
||||
|
||||
_outputData = GVAR(outputData);
|
||||
call FUNC(updateImpellerState);
|
||||
__ctrlKestrel4500 ctrlSetText format [QUOTE(PATHTOF(UI\Kestrel4500_%1.paa)), floor(GVAR(ImpellerState) % 7)];
|
||||
|
||||
3 cutRsc ["RscKestrel4500", "PLAIN", 1, false];
|
||||
|
||||
__ctrlKestrel4500 ctrlSetText format [QUOTE(PATHTOF(UI\Kestrel4500_%1.paa)), floor(GVAR(WheelState) % 7)];
|
||||
|
||||
__ctrlTop ctrlSetText (_outputData select 0);
|
||||
__ctrlCenterBig ctrlSetText (_outputData select 1);
|
||||
|
||||
__ctrlTop ctrlSetText (_outputData select 0);
|
||||
__ctrlCenterBig ctrlSetText (_outputData select 1);
|
||||
|
||||
__ctrlCenterLine1Left ctrlSetText (_outputData select 2);
|
||||
__ctrlCenterLine2Left ctrlSetText (_outputData select 3);
|
||||
__ctrlCenterLine3Left ctrlSetText (_outputData select 4);
|
||||
|
||||
__ctrlCenterLine1Right ctrlSetText (_outputData select 5);
|
||||
__ctrlCenterLine2Right ctrlSetText (_outputData select 6);
|
||||
__ctrlCenterLine3Right ctrlSetText (_outputData select 7);
|
||||
|
||||
__ctrlInfoLine1 ctrlSetText (_outputData select 8);
|
||||
__ctrlInfoLine2 ctrlSetText (_outputData select 9);
|
||||
}, 0.01, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
true
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
private ["_playerDir", "_textTop", "_textCenterBig", "_textCenterLine1Left", "_textCenterLine2Left", "_textCenterLine3Left", "_textCenterLine1Right", "_textCenterLine2Right", "_textCenterLine3Right", "_textInfoLine1", "_textInfoLine2", "_temperature", "_humidity", "_windSpeed", "_windDir", "_newWindSpeed", "_windSource", "_height"];
|
||||
|
||||
if (isNil QUOTE(EGVAR(weather,Altitude))) then {EGVAR(weather,Altitude) = 0};
|
||||
|
||||
[] call FUNC(collectData);
|
||||
|
||||
_textTop = GVAR(Menus) select GVAR(Menu);
|
||||
@ -34,7 +32,7 @@ _textCenterLine3Right = "";
|
||||
_textInfoLine1 = "";
|
||||
_textInfoLine2 = "";
|
||||
|
||||
_windSpeed = vectorMagnitude ACE_wind;
|
||||
_windSpeed = call FUNC(measureWindSpeed);
|
||||
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
||||
|
||||
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
|
||||
@ -42,25 +40,6 @@ _humidity = EGVAR(weather,currentHumidity);
|
||||
|
||||
_playerDir = getDir ACE_player;
|
||||
|
||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
_windSpeed = (eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed);
|
||||
_windSpeed = abs(cos(_playerDir - _windDir)) * _windSpeed;
|
||||
} else {
|
||||
_windSpeed = (eyePos ACE_player) call FUNC(calculateWindSpeed);
|
||||
};
|
||||
|
||||
if (_windSpeed > 0.3) then {
|
||||
GVAR(MeasuredWindSpeed) = _windSpeed;
|
||||
} else {
|
||||
GVAR(MeasuredWindSpeed) = GVAR(MeasuredWindSpeed) * 0.99;
|
||||
if (GVAR(MeasuredWindSpeed) < 0.05) then {
|
||||
GVAR(MeasuredWindSpeed) = 0;
|
||||
};
|
||||
};
|
||||
|
||||
GVAR(WheelState) = GVAR(WheelState) + (ceil(GVAR(MeasuredWindSpeed)) min 1) max GVAR(MeasuredWindSpeed);
|
||||
if (GVAR(WheelState) > 1000) then { GVAR(WheelState) = 0 };
|
||||
|
||||
GVAR(Direction) = 4 * floor(_playerDir / 90);
|
||||
if (_playerDir % 90 > 10) then { GVAR(Direction) = GVAR(Direction) + 1};
|
||||
if (_playerDir % 90 > 35) then { GVAR(Direction) = GVAR(Direction) + 1};
|
||||
@ -83,7 +62,7 @@ switch (GVAR(Menu)) do {
|
||||
};
|
||||
case 1: { // Wind SPD
|
||||
if (!GVAR(MinAvgMax)) then {
|
||||
_textCenterBig = Str(round(abs(GVAR(MeasuredWindSpeed)) * 10) / 10);
|
||||
_textCenterBig = Str(round(abs(_windSpeed) * 10) / 10);
|
||||
} else {
|
||||
_textCenterLine1Left = "Max";
|
||||
_textCenterLine2Left = "Avg";
|
||||
@ -109,11 +88,11 @@ switch (GVAR(Menu)) do {
|
||||
case 2: { // CROSSWIND
|
||||
if (!GVAR(MinAvgMax)) then {
|
||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
_textCenterBig = Str(round(abs(sin(GVAR(RefHeading) - _playerDir) * GVAR(MeasuredWindSpeed)) * 10) / 10);
|
||||
_textInfoLine1 = format["%1 m/s @ %2", round((cos(_playerDir - _windDir) * GVAR(MeasuredWindSpeed)) * 10) / 10, round(_playerDir)];
|
||||
_textCenterBig = Str(round(abs(sin(GVAR(RefHeading) - _playerDir) * _windSpeed) * 10) / 10);
|
||||
_textInfoLine1 = format["%1 m/s @ %2", round((cos(_playerDir - _windDir) * _windSpeed) * 10) / 10, round(_playerDir)];
|
||||
} else {
|
||||
_textCenterBig = Str(round(abs(sin(GVAR(RefHeading)) * GVAR(MeasuredWindSpeed)) * 10) / 10);
|
||||
_textInfoLine1 = format["%1 m/s @ %2", round(GVAR(MeasuredWindSpeed) * 10) / 10, round(_windDir)];
|
||||
_textCenterBig = Str(round(abs(sin(GVAR(RefHeading)) * _windSpeed) * 10) / 10);
|
||||
_textInfoLine1 = format["%1 m/s @ %2", round(_windSpeed * 10) / 10, round(_windDir)];
|
||||
};
|
||||
_textInfoLine2 = "- set heading";
|
||||
} else {
|
||||
@ -141,11 +120,11 @@ switch (GVAR(Menu)) do {
|
||||
case 3: { // HEADWIND
|
||||
if (!GVAR(MinAvgMax)) then {
|
||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
_textCenterBig = Str(round(abs(cos(GVAR(RefHeading) - _playerDir) * GVAR(MeasuredWindSpeed)) * 10) / 10);
|
||||
_textInfoLine1 = format["%1 m/s @ %2", round((cos(_playerDir - _windDir) * GVAR(MeasuredWindSpeed)) * 10) / 10, round(_playerDir)];
|
||||
_textCenterBig = Str(round(abs(cos(GVAR(RefHeading) - _playerDir) * _windSpeed) * 10) / 10);
|
||||
_textInfoLine1 = format["%1 m/s @ %2", round((cos(_playerDir - _windDir) * _windSpeed) * 10) / 10, round(_playerDir)];
|
||||
} else {
|
||||
_textCenterBig = Str(round(abs(cos(GVAR(RefHeading)) * GVAR(MeasuredWindSpeed)) * 10) / 10);
|
||||
_textInfoLine1 = format["%1 m/s @ %2", round(GVAR(MeasuredWindSpeed) * 10) / 10, round(_windDir)];
|
||||
_textCenterBig = Str(round(abs(cos(GVAR(RefHeading)) * _windSpeed) * 10) / 10);
|
||||
_textInfoLine1 = format["%1 m/s @ %2", round(_windSpeed * 10) / 10, round(_windDir)];
|
||||
};
|
||||
_textInfoLine2 = "- set heading";
|
||||
} else {
|
||||
@ -221,7 +200,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)));
|
||||
_textCenterLine3Left = Str(round(abs(GVAR(MeasuredWindSpeed)) * 10) / 10);
|
||||
_textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10);
|
||||
_textCenterLine1Right = GVAR(Directions) select GVAR(Direction);
|
||||
_textCenterLine2Right = "m";
|
||||
_textCenterLine3Right = "m/s";
|
||||
|
42
addons/kestrel4500/functions/fnc_measureWindSpeed.sqf
Normal file
42
addons/kestrel4500/functions/fnc_measureWindSpeed.sqf
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
* Measures the wind speed, stores the information in GVAR(MeasuredWindSpeed) and updates GVAR(ImpellerState)
|
||||
*
|
||||
* Arguments:
|
||||
* Nothing
|
||||
*
|
||||
* Return Value:
|
||||
* wind speed <NUMBER>
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
#include "defines.h"
|
||||
|
||||
private ["_playerDir", "_windSpeed", "_windDir"];
|
||||
|
||||
_playerDir = getDir ACE_player;
|
||||
_windSpeed = vectorMagnitude ACE_wind;
|
||||
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
||||
|
||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||
_windSpeed = (eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed);
|
||||
_windSpeed = abs(cos(_playerDir - _windDir)) * _windSpeed;
|
||||
} else {
|
||||
_windSpeed = (eyePos ACE_player) call FUNC(calculateWindSpeed);
|
||||
};
|
||||
|
||||
hintSilent format["%1, %2", GVAR(MeasuredWindSpeed), _windSpeed];
|
||||
|
||||
if (_windSpeed > 0.3 || {GVAR(MeasuredWindSpeed) > 0.1 && _windSpeed > 0.125}) then {
|
||||
GVAR(MeasuredWindSpeed) = _windSpeed;
|
||||
} else {
|
||||
GVAR(MeasuredWindSpeed) = GVAR(MeasuredWindSpeed) * 0.99;
|
||||
if (GVAR(MeasuredWindSpeed) < 0.05) then {
|
||||
GVAR(MeasuredWindSpeed) = 0;
|
||||
};
|
||||
};
|
||||
|
||||
GVAR(MeasuredWindSpeed)
|
22
addons/kestrel4500/functions/fnc_updateImpellerState.sqf
Normal file
22
addons/kestrel4500/functions/fnc_updateImpellerState.sqf
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
* Updates the Kestrel 4500 Impeller state
|
||||
*
|
||||
* Arguments:
|
||||
* Nothing
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_windSpeed"];
|
||||
|
||||
_windSpeed = call FUNC(measureWindSpeed);
|
||||
|
||||
GVAR(ImpellerState) = GVAR(ImpellerState) + (ceil(_windSpeed) min 1) max _windSpeed;
|
||||
if (GVAR(ImpellerState) > 1000) then { GVAR(ImpellerState) = 0 };
|
Loading…
Reference in New Issue
Block a user