From 1b000d658a3aaafeb3af5ff4b9d299f204332484 Mon Sep 17 00:00:00 2001 From: Brandon Danyluk Date: Fri, 16 Apr 2021 15:43:31 -0600 Subject: [PATCH] Allow for debug info to be displayed via variable --- addons/missileguidance/XEH_post_init.sqf | 3 +- addons/missileguidance/XEH_pre_init.sqf | 3 ++ .../missileguidance/dev/projectileCamera.sqf | 6 ++-- .../functions/fnc_doAttackProfile.sqf | 8 +++--- .../functions/fnc_doSeekerSearch.sqf | 12 ++++---- .../functions/fnc_guidancePFH.sqf | 28 +++++++++---------- .../fnc_navigationType_augmentedProNav.sqf | 2 +- .../functions/fnc_navigationType_proNav.sqf | 2 +- .../missileguidance/functions/fnc_onFired.sqf | 6 ++-- .../functions/fnc_seekerType_Doppler.sqf | 12 ++++---- .../functions/fnc_seekerType_IR.sqf | 20 ++++++------- .../functions/fnc_seekerType_MWR.sqf | 12 ++++---- .../functions/fnc_shouldFilterRadarHit.sqf | 20 ++++++------- addons/missileguidance/script_component.hpp | 4 +-- 14 files changed, 71 insertions(+), 67 deletions(-) diff --git a/addons/missileguidance/XEH_post_init.sqf b/addons/missileguidance/XEH_post_init.sqf index 38a4df2a05..4093aa994e 100644 --- a/addons/missileguidance/XEH_post_init.sqf +++ b/addons/missileguidance/XEH_post_init.sqf @@ -12,6 +12,5 @@ }, [15, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key -#ifdef ENABLE_PROJECTILE_CAMERA GVAR(dev_fnc_projectileCamera) = compile preprocessFileLineNumbers QPATHTOF(dev\projectileCamera.sqf); -#endif + diff --git a/addons/missileguidance/XEH_pre_init.sqf b/addons/missileguidance/XEH_pre_init.sqf index f377efddb6..65970b6d65 100644 --- a/addons/missileguidance/XEH_pre_init.sqf +++ b/addons/missileguidance/XEH_pre_init.sqf @@ -11,4 +11,7 @@ PREP_RECOMPILE_END; // As weapons take config changes, there is little point in being able to disable guidance if (isNil QGVAR(enabled)) then { GVAR(enabled) = 2; }; +GVAR(debug_enableMissileCamera) = true; +GVAR(debug_drawGuidanceInfo) = false; + ADDON = true; diff --git a/addons/missileguidance/dev/projectileCamera.sqf b/addons/missileguidance/dev/projectileCamera.sqf index 8f70fa808a..4d50d56238 100644 --- a/addons/missileguidance/dev/projectileCamera.sqf +++ b/addons/missileguidance/dev/projectileCamera.sqf @@ -26,8 +26,10 @@ _camera camCommitPrepared 0; [_pfh] call CBA_fnc_removePerFrameHandler; }; - _camera camPrepareTarget _projectile; - _camera camPrepareRelPos [0, -5, 1]; + private _currentProjectilePos = getPosATLVisual _projectile; + + _camera camPrepareTarget _currentProjectilePos; + _camera camPreparePos (_currentProjectilePos vectorDiff ((vectorNormalized velocity _projectile) vectorMultiply 5)); _camera camCommitPrepared 0; _args set [2, getPosATL _projectile]; diff --git a/addons/missileguidance/functions/fnc_doAttackProfile.sqf b/addons/missileguidance/functions/fnc_doAttackProfile.sqf index d239e08e0c..7c8e9e7b92 100644 --- a/addons/missileguidance/functions/fnc_doAttackProfile.sqf +++ b/addons/missileguidance/functions/fnc_doAttackProfile.sqf @@ -29,10 +29,10 @@ if ((isNil "_attackProfilePos") || {_attackProfilePos isEqualTo [0,0,0]}) exitWi [0,0,0] }; -#ifdef DRAW_GUIDANCE_INFO -drawLine3D [(ASLtoAGL _attackProfilePos), (ASLtoAGL _seekerTargetPos), [0,1,1,1]]; -drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [0,0,1,1], ASLtoAGL _attackProfilePos, 0.5, 0.5, 0, _attackProfileName, 1, 0.025, "TahomaB"]; -#endif +if (GVAR(debug_drawGuidanceInfo)) then { + drawLine3D [(ASLtoAGL _attackProfilePos), (ASLtoAGL _seekerTargetPos), [0,1,1,1]]; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [0,0,1,1], ASLtoAGL _attackProfilePos, 0.5, 0.5, 0, _attackProfileName, 1, 0.025, "TahomaB"]; +}; TRACE_2("return",_attackProfilePos,_attackProfileName); _attackProfilePos; diff --git a/addons/missileguidance/functions/fnc_doSeekerSearch.sqf b/addons/missileguidance/functions/fnc_doSeekerSearch.sqf index de01b476b6..c2db184e5a 100644 --- a/addons/missileguidance/functions/fnc_doSeekerSearch.sqf +++ b/addons/missileguidance/functions/fnc_doSeekerSearch.sqf @@ -30,9 +30,9 @@ if ((isNil "_seekerTargetPos") || {_seekerTargetPos isEqualTo [0,0,0]}) then { / if (_seekLastTargetPos && {_lastKnownPos isNotEqualTo [0,0,0]}) then { // if enabled for the ammo, use last known position if we have one stored TRACE_2("seeker returned bad pos - using last known",_seekLastTargetPos,_lastKnownPos); _seekerTargetPos = _lastKnownPos; - #ifdef DRAW_GUIDANCE_INFO - drawIcon3D ["\A3\ui_f\data\map\markers\military\unknown_CA.paa", [1,1,0,1], ASLtoAGL _lastKnownPos, 0.25, 0.25, 0, "LastKnownPos", 1, 0.02, "TahomaB"]; - #endif + if (GVAR(debug_drawGuidanceInfo)) then { + drawIcon3D ["\A3\ui_f\data\map\markers\military\unknown_CA.paa", [1,1,0,1], ASLtoAGL _lastKnownPos, 0.25, 0.25, 0, "LastKnownPos", 1, 0.02, "TahomaB"]; + }; } else { TRACE_1("seeker returned no pos",_seekerTargetPos); _seekerTargetPos = [0,0,0]; @@ -44,9 +44,9 @@ if ((isNil "_seekerTargetPos") || {_seekerTargetPos isEqualTo [0,0,0]}) then { / }; }; -#ifdef DRAW_GUIDANCE_INFO -drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [0,1,0,1], ASLtoAGL _seekerTargetPos, 0.5, 0.5, 0, _seekerTypeName, 1, 0.025, "TahomaB"]; -#endif +if (GVAR(debug_drawGuidanceInfo)) then { + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [0,1,0,1], ASLtoAGL _seekerTargetPos, 0.5, 0.5, 0, _seekerTypeName, 1, 0.025, "TahomaB"]; +}; TRACE_2("return",_seekerTargetPos,_seekerTypeName); _seekerTargetPos; diff --git a/addons/missileguidance/functions/fnc_guidancePFH.sqf b/addons/missileguidance/functions/fnc_guidancePFH.sqf index 6dbcb2aba2..e2ce237b70 100644 --- a/addons/missileguidance/functions/fnc_guidancePFH.sqf +++ b/addons/missileguidance/functions/fnc_guidancePFH.sqf @@ -68,12 +68,12 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua ERROR_MSG("_commandedAcceleration is nil! Guidance cancelled"); }; - #ifdef DRAW_GUIDANCE_INFO - private _projectilePosAGL = ASLToAGL _projectilePos; - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], _projectilePosAGL vectorAdd [0, 0, 1], 0.75, 0.75, 0, str _commandedAcceleration, 1, 0.025, "TahomaB"]; - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,0,1], _projectilePosAGL vectorAdd [0, 0, 2], 0.75, 0.75, 0, _navigationType, 1, 0.025, "TahomaB"]; - drawLine3D [_projectilePosAGL, _projectilePosAGL vectorAdd _commandedAcceleration, [1, 0, 1, 1]]; - #endif + if (GVAR(debug_drawGuidanceInfo)) then { + private _projectilePosAGL = ASLToAGL _projectilePos; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], _projectilePosAGL vectorAdd [0, 0, 1], 0.75, 0.75, 0, str _commandedAcceleration, 1, 0.025, "TahomaB"]; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,0,1], _projectilePosAGL vectorAdd [0, 0, 2], 0.75, 0.75, 0, _navigationType, 1, 0.025, "TahomaB"]; + drawLine3D [_projectilePosAGL, _projectilePosAGL vectorAdd _commandedAcceleration, [1, 0, 1, 1]]; + }; // activate missile servos and change direction if (!isGamePaused && accTime > 0) then { @@ -127,16 +127,16 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua _args set [4, _stateParams]; }; -#ifdef DRAW_GUIDANCE_INFO -TRACE_3("",_projectilePos,_seekerTargetPos,_profileAdjustedTargetPos); -drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _projectilePos, 0.75, 0.75, 0, _ammo, 1, 0.025, "TahomaB"]; +if (GVAR(debug_drawGuidanceInfo)) then { + TRACE_3("",_projectilePos,_seekerTargetPos,_profileAdjustedTargetPos); + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _projectilePos, 0.75, 0.75, 0, _ammo, 1, 0.025, "TahomaB"]; -if (!isGamePaused && accTime > 0) then { - private _ps = "#particlesource" createVehicleLocal (ASLtoAGL _projectilePos); - _PS setParticleParams [["\A3\Data_f\cl_basic", 8, 3, 1], "", "Billboard", 1, 3.0141, [0, 0, 2], [0, 0, 0], 1, 1.275, 1, 0, [1, 1], [[1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1]], [1], 1, 0, "", "", nil]; - _PS setDropInterval 1.0; + if (!isGamePaused && accTime > 0) then { + private _ps = "#particlesource" createVehicleLocal (ASLtoAGL _projectilePos); + _PS setParticleParams [["\A3\Data_f\cl_basic", 8, 3, 1], "", "Billboard", 1, 3.0141, [0, 0, 2], [0, 0, 0], 1, 1.275, 1, 0, [1, 1], [[1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1]], [1], 1, 0, "", "", nil]; + _PS setDropInterval 1.0; + }; }; -#endif _stateParams set [0, diag_tickTime]; diff --git a/addons/missileguidance/functions/fnc_navigationType_augmentedProNav.sqf b/addons/missileguidance/functions/fnc_navigationType_augmentedProNav.sqf index f76d3f68f1..810b4cc3c3 100644 --- a/addons/missileguidance/functions/fnc_navigationType_augmentedProNav.sqf +++ b/addons/missileguidance/functions/fnc_navigationType_augmentedProNav.sqf @@ -34,7 +34,7 @@ private _losDelta = _attackProfileDirection vectorDiff _lastLineOfSight; private _losRate = if (_timestep == 0) then { 0 } else { - 10 * (vectorMagnitude _losDelta) / _timestep; + 1 * (vectorMagnitude _losDelta) / _timestep; }; private _lateralAcceleration = _navigationGain * _losRate; diff --git a/addons/missileguidance/functions/fnc_navigationType_proNav.sqf b/addons/missileguidance/functions/fnc_navigationType_proNav.sqf index 6349e3aab7..335f18ef3e 100644 --- a/addons/missileguidance/functions/fnc_navigationType_proNav.sqf +++ b/addons/missileguidance/functions/fnc_navigationType_proNav.sqf @@ -31,7 +31,7 @@ private _losDelta = _attackProfileDirection vectorDiff _lastLineOfSight; private _losRate = if (_timestep == 0) then { 0 } else { - 10 * (vectorMagnitude _losDelta) / _timestep; + 1 * (vectorMagnitude _losDelta) / _timestep; }; private _lateralAcceleration = _navigationGain * _losRate; diff --git a/addons/missileguidance/functions/fnc_onFired.sqf b/addons/missileguidance/functions/fnc_onFired.sqf index 0086dbac19..47da733638 100644 --- a/addons/missileguidance/functions/fnc_onFired.sqf +++ b/addons/missileguidance/functions/fnc_onFired.sqf @@ -206,9 +206,9 @@ if (_onFiredFunc != "") then { [LINKFUNC(guidancePFH),0, _args ] call CBA_fnc_addPerFrameHandler; -#ifdef ENABLE_PROJECTILE_CAMERA -[_projectile] call GVAR(dev_fnc_projectileCamera); -#endif +if (GVAR(debug_enableMissileCamera)) then { + [_projectile] call GVAR(dev_fnc_projectileCamera); +}; /* Clears locking settings diff --git a/addons/missileguidance/functions/fnc_seekerType_Doppler.sqf b/addons/missileguidance/functions/fnc_seekerType_Doppler.sqf index 6709a574b9..147a972dd9 100644 --- a/addons/missileguidance/functions/fnc_seekerType_Doppler.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_Doppler.sqf @@ -97,9 +97,9 @@ if (_isActive || { CBA_missionTime >= _timeWhenActive }) then { _expectedTargetPos = _searchPos; }; } else { - #ifdef DRAW_GUIDANCE_INFO - _seekerTypeName = "DOPPLER - EXT"; - #endif + if (GVAR(debug_drawGuidanceInfo)) then { + _seekerTypeName = "DOPPLER - EXT"; + }; // External radar homing // if the target is in the remote targets for the side, whoever the donor is will "datalink" the target for the hellfire. private _remoteTargets = listRemoteTargets side _shooter; @@ -112,9 +112,9 @@ if (_isActive || { CBA_missionTime >= _timeWhenActive }) then { }; }; -#ifdef DRAW_GUIDANCE_INFO -drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _expectedTargetPos, 0.75, 0.75, 0, "expected target pos", 1, 0.025, "TahomaB"]; -#endif +if (GVAR(debug_drawGuidanceInfo)) then { + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _expectedTargetPos, 0.75, 0.75, 0, "expected target pos", 1, 0.025, "TahomaB"]; +}; if !(isNull _target) then { // we check if the target is moving away from us or perpendicular to see if we maintain lock diff --git a/addons/missileguidance/functions/fnc_seekerType_IR.sqf b/addons/missileguidance/functions/fnc_seekerType_IR.sqf index 8fb819e9d1..a4556a7b13 100644 --- a/addons/missileguidance/functions/fnc_seekerType_IR.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_IR.sqf @@ -101,17 +101,17 @@ if (TRACK_ON_PAUSE || {accTime > 0 && !isGamePaused}) then { }; }; - #ifdef DRAW_GUIDANCE_INFO - private _flarePos = ASLToAGL getPosASLVisual _x; - private _colour = [1, 0, 0, 1]; - if (_considering) then { - _colour = [0, 1, 0, 1]; + if (GVAR(debug_drawGuidanceInfo)) then { + private _flarePos = ASLToAGL getPosASLVisual _x; + private _colour = [1, 0, 0, 1]; + if (_considering) then { + _colour = [0, 1, 0, 1]; + }; + if (_trackingTarget isEqualTo _x) then { + _colour = [0, 0, 1, 1]; + }; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", _colour, _flarePos, 0.75, 0.75, 0, "F", 1, 0.025, "TahomaB"]; }; - if (_trackingTarget isEqualTo _x) then { - _colour = [0, 0, 1, 1]; - }; - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", _colour, _flarePos, 0.75, 0.75, 0, "F", 1, 0.025, "TahomaB"]; - #endif }; } forEach _nearby; diff --git a/addons/missileguidance/functions/fnc_seekerType_MWR.sqf b/addons/missileguidance/functions/fnc_seekerType_MWR.sqf index 90047b2e46..bb3804c7a3 100644 --- a/addons/missileguidance/functions/fnc_seekerType_MWR.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_MWR.sqf @@ -89,9 +89,9 @@ if (_isActive || { CBA_missionTime >= _timeWhenActive }) then { _projectile setMissileTarget _target; } else { - #ifdef DRAW_GUIDANCE_INFO - _seekerTypeName = "AHR - EXT"; - #endif + if (GVAR(debug_drawGuidanceInfo)) then { + _seekerTypeName = "MWR - EXT"; + }; // External radar homing // if the target is in the remote targets for the side, whoever the donor is will "datalink" the target for the hellfire. private _remoteTargets = listRemoteTargets side _shooter; @@ -104,9 +104,9 @@ if (_isActive || { CBA_missionTime >= _timeWhenActive }) then { }; }; -#ifdef DRAW_GUIDANCE_INFO -drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _expectedTargetPos, 0.75, 0.75, 0, "expected target pos", 1, 0.025, "TahomaB"]; -#endif +if (GVAR(debug_drawGuidanceInfo)) then { + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _expectedTargetPos, 0.75, 0.75, 0, "expected target pos", 1, 0.025, "TahomaB"]; +}; if !(isNull _target) then { private _centerOfObject = getCenterOfMass _target; diff --git a/addons/missileguidance/functions/fnc_shouldFilterRadarHit.sqf b/addons/missileguidance/functions/fnc_shouldFilterRadarHit.sqf index 0f7b0f9584..e60de80887 100644 --- a/addons/missileguidance/functions/fnc_shouldFilterRadarHit.sqf +++ b/addons/missileguidance/functions/fnc_shouldFilterRadarHit.sqf @@ -103,17 +103,17 @@ if !(_maskedByGround) exitWith { }; }; - #ifdef DRAW_GUIDANCE_INFO - private _chaffPos = ASLToAGL getPosASLVisual _x; - private _colour = [1, 0, 0, 1]; - if (_considering) then { - _colour = [0, 1, 0, 1]; + if (GVAR(debug_drawGuidanceInfo)) then { + private _chaffPos = ASLToAGL getPosASLVisual _x; + private _colour = [1, 0, 0, 1]; + if (_considering) then { + _colour = [0, 1, 0, 1]; + }; + if (_foundDecoy) then { + _colour = [0, 0, 1, 1]; + }; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", _colour, _chaffPos, 0.75, 0.75, 0, "C", 1, 0.025, "TahomaB"]; }; - if (_foundDecoy) then { - _colour = [0, 0, 1, 1]; - }; - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", _colour, _chaffPos, 0.75, 0.75, 0, "C", 1, 0.025, "TahomaB"]; - #endif } forEach _nearby; _foundDecoy diff --git a/addons/missileguidance/script_component.hpp b/addons/missileguidance/script_component.hpp index a4a4f51906..9aa0ec530a 100644 --- a/addons/missileguidance/script_component.hpp +++ b/addons/missileguidance/script_component.hpp @@ -2,9 +2,9 @@ #define COMPONENT_BEAUTIFIED Missile Guidance #include "\z\ace\addons\main\script_mod.hpp" - #define DRAW_GUIDANCE_INFO +// #define DRAW_GUIDANCE_INFO // #define ENABLE_PROJECTILE_CAMERA - #define DEBUG_MODE_FULL +// #define DEBUG_MODE_FULL #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS