From 5a55d2d25766a04004feedc565a91c4023c80b83 Mon Sep 17 00:00:00 2001 From: Bailey Danyluk Date: Thu, 2 Jun 2022 20:11:35 -0600 Subject: [PATCH] Add ability to disable iron dome (disabled by default) --- addons/hellfire/functions/fnc_attackProfile.sqf | 3 ++- addons/iron_dome/CfgEventHandlers.hpp | 6 ++++++ addons/iron_dome/XEH_postInit.sqf | 7 +++++++ addons/iron_dome/XEH_preInit.sqf | 3 --- addons/iron_dome/initSettings.sqf | 10 ++++++++++ addons/iron_dome/stringtable.xml | 3 +++ .../functions/fnc_attackProfile_JDAM.sqf | 1 + addons/missileguidance/functions/fnc_line_onFired.sqf | 2 +- 8 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 addons/iron_dome/XEH_postInit.sqf diff --git a/addons/hellfire/functions/fnc_attackProfile.sqf b/addons/hellfire/functions/fnc_attackProfile.sqf index 9d03a69d5d..7e098a8ae6 100644 --- a/addons/hellfire/functions/fnc_attackProfile.sqf +++ b/addons/hellfire/functions/fnc_attackProfile.sqf @@ -38,7 +38,7 @@ private _heightAboveLaunch = (_projectilePos select 2) - (_launchPos select 2); // Add height depending on distance for compensate private _returnTargetPos = _seekerTargetPos; if (_returnTargetPos isEqualTo [0, 0, 0]) then { - _initialDistanceToTarget = 8000; + private _initialDistanceToTarget = 8000; _returnTargetPos = _launchPos vectorAdd (_launchDir vectorMultiply _initialDistanceToTarget); }; @@ -109,6 +109,7 @@ switch (_attackStage) do { }; // missile guidance defines this variable in doAttackProfile +//IGNORE_PRIVATE_WARNING ["_attackProfileName"]; _attackProfileName = ["na", "hellfire - LAUNCH", "hellfire - SEEK CRUISE", "hellfire - ATTACK CRUISE", "hellfire - TERMINAL"] select _attackStage; TRACE_1("Adjusted target position", _returnTargetPos); diff --git a/addons/iron_dome/CfgEventHandlers.hpp b/addons/iron_dome/CfgEventHandlers.hpp index d1317048c8..03808bcdba 100644 --- a/addons/iron_dome/CfgEventHandlers.hpp +++ b/addons/iron_dome/CfgEventHandlers.hpp @@ -9,3 +9,9 @@ class Extended_PreInit_EventHandlers { }; }; +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_postInit)); + }; +}; + diff --git a/addons/iron_dome/XEH_postInit.sqf b/addons/iron_dome/XEH_postInit.sqf new file mode 100644 index 0000000000..0e50e4038c --- /dev/null +++ b/addons/iron_dome/XEH_postInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +if (isServer && { GVAR(enable) }) then { + [LINKFUNC(projectileTrackerPFH)] call CBA_fnc_addPerFrameHandler; + [LINKFUNC(proximityFusePFH)] call CBA_fnc_addPerFrameHandler; +}; + diff --git a/addons/iron_dome/XEH_preInit.sqf b/addons/iron_dome/XEH_preInit.sqf index e08a9e69da..de9bcc8b53 100644 --- a/addons/iron_dome/XEH_preInit.sqf +++ b/addons/iron_dome/XEH_preInit.sqf @@ -31,9 +31,6 @@ if (isServer) then { GVAR(interceptors) pushBack [_interceptor, _target, getPosASLVisual _interceptor, _interceptor distance _target]; [GVAR(toBeShot), _target] call CBA_fnc_hashRem; }] call CBA_fnc_addEventHandler; - - [LINKFUNC(projectileTrackerPFH)] call CBA_fnc_addPerFrameHandler; - [LINKFUNC(proximityFusePFH)] call CBA_fnc_addPerFrameHandler; }; [QGVAR(registerLaunchers), { diff --git a/addons/iron_dome/initSettings.sqf b/addons/iron_dome/initSettings.sqf index a4d72004be..cd9feed432 100644 --- a/addons/iron_dome/initSettings.sqf +++ b/addons/iron_dome/initSettings.sqf @@ -1,3 +1,13 @@ +[ + QGVAR(enable), "CHECKBOX", + [ELSTRING(common,Enabled), LSTRING(enable_description)], + LSTRING(category), + false, // default value + true, // isGlobal + {[QGVAR(enable), _this] call EFUNC(common,cbaSettings_settingChanged)}, + true // Needs mission restart +] call CBA_fnc_addSetting; + [ QGVAR(targetRecycleTime), "SLIDER", [LSTRING(targetRecycleTime_setting), LSTRING(targetRecycleTime_description)], diff --git a/addons/iron_dome/stringtable.xml b/addons/iron_dome/stringtable.xml index cf51881db8..5ced0a510c 100644 --- a/addons/iron_dome/stringtable.xml +++ b/addons/iron_dome/stringtable.xml @@ -1,6 +1,9 @@ + + Enable the Iron Dome system + ACE Iron Dome diff --git a/addons/missileguidance/functions/fnc_attackProfile_JDAM.sqf b/addons/missileguidance/functions/fnc_attackProfile_JDAM.sqf index c6affc83ff..68d9cddf2b 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_JDAM.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_JDAM.sqf @@ -48,6 +48,7 @@ _targetData set [2, (_projectilePos vectorDistance _missilePosProjected)]; if (GVAR(debug_drawGuidanceInfo)) then { private _projectilePitch = ((vectorDir _projectile) call CBA_fnc_vect2polar) select 2; + //IGNORE_PRIVATE_WARNING ["_attackProfileName"]; _attackProfileName = format ["JDAM [Pitch - %1 Impact Pitch - %2]", _projectilePitch, _impactAngle]; drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _missilePosProjected, 0.75, 0.75, 0, "P", 1, 0.025, "TahomaB"]; private _desiredAngle = _lineDir vectorMultiply 5000; diff --git a/addons/missileguidance/functions/fnc_line_onFired.sqf b/addons/missileguidance/functions/fnc_line_onFired.sqf index 67af1febcf..ac4e792284 100644 --- a/addons/missileguidance/functions/fnc_line_onFired.sqf +++ b/addons/missileguidance/functions/fnc_line_onFired.sqf @@ -27,7 +27,7 @@ if (_correctionDistance == 0) then { }; private _navigationParams = [ - _p, _i, _d, + _p, 0, _d, 0, 0, _correctionDistance