From 46abb93cb8bf2deefa97f207121a336a82cc2b24 Mon Sep 17 00:00:00 2001 From: Brandon Danyluk Date: Mon, 12 Apr 2021 02:51:02 -0600 Subject: [PATCH] add GBU-12 to missile guidance --- addons/gbu/$PBOPREFIX$ | 1 + addons/gbu/CfgAmmo.hpp | 38 ++++++++++++++++ addons/gbu/CfgMagazines.hpp | 17 ++++++++ addons/gbu/CfgWeapons.hpp | 19 ++++++++ addons/gbu/README.md | 12 ++++++ addons/gbu/config.cpp | 20 +++++++++ addons/gbu/script_component.hpp | 18 ++++++++ addons/missileguidance/ACE_GuidanceConfig.hpp | 4 -- .../functions/fnc_guidancePFH.sqf | 4 +- .../fnc_navigationType_simpleProNav.sqf | 43 ------------------- .../missileguidance/functions/fnc_onFired.sqf | 3 -- .../functions/fnc_simpleProNav_onFired.sqf | 24 ----------- addons/missileguidance/todo.txt | 2 +- 13 files changed, 128 insertions(+), 77 deletions(-) create mode 100644 addons/gbu/$PBOPREFIX$ create mode 100644 addons/gbu/CfgAmmo.hpp create mode 100644 addons/gbu/CfgMagazines.hpp create mode 100644 addons/gbu/CfgWeapons.hpp create mode 100644 addons/gbu/README.md create mode 100644 addons/gbu/config.cpp create mode 100644 addons/gbu/script_component.hpp delete mode 100644 addons/missileguidance/functions/fnc_navigationType_simpleProNav.sqf delete mode 100644 addons/missileguidance/functions/fnc_simpleProNav_onFired.sqf diff --git a/addons/gbu/$PBOPREFIX$ b/addons/gbu/$PBOPREFIX$ new file mode 100644 index 0000000000..402fc93e89 --- /dev/null +++ b/addons/gbu/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\gbu \ No newline at end of file diff --git a/addons/gbu/CfgAmmo.hpp b/addons/gbu/CfgAmmo.hpp new file mode 100644 index 0000000000..9ff007e342 --- /dev/null +++ b/addons/gbu/CfgAmmo.hpp @@ -0,0 +1,38 @@ +class CfgAmmo { + class Bo_GBU12_LGB; + class GVAR(12): Bo_GBU12_LGB { + maneuvrability = 0; // no maneuvrability so that default guidance doesnt work + class ace_missileguidance { + enabled = 1; + + pitchRate = 15; + yawRate = 15; + + bangBangGuidance = 1; + + canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode + + // Guidance type for munitions + defaultSeekerType = "SALH"; + seekerTypes[] = { "SALH" }; + + defaultSeekerLockMode = "LOAL"; + seekerLockModes[] = { "LOAL" }; + + defaultNavigationType = "LineOfSight"; + navigationTypes[] = { "LineOfSight" }; + + seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos] + seekerAngle = 90; // Angle from the shooter's view that can track the missile + seekerAccuracy = 1; // seeker accuracy multiplier + + seekerMinRange = 5; + seekerMaxRange = 4000; // Range from the missile which the seeker can visually search + + // Attack profile type selection + defaultAttackProfile = "LIN"; + attackProfiles[] = {"LIN"}; + }; + }; +}; + diff --git a/addons/gbu/CfgMagazines.hpp b/addons/gbu/CfgMagazines.hpp new file mode 100644 index 0000000000..531a9bc774 --- /dev/null +++ b/addons/gbu/CfgMagazines.hpp @@ -0,0 +1,17 @@ +class CfgMagazines { + class 2Rnd_GBU12_LGB; + class GVAR(2Rnd_12): 2Rnd_GBU12_LGB { + displayName = "GBU-12 [ACE]"; + author = "Brandon (TCVM)"; + ammo = QGVAR(12); + }; + + class PylonMissile_1Rnd_Bomb_04_F; + class GVAR(1_PylonMissile_1Rnd_12): PylonMissile_1Rnd_Bomb_04_F { + displayName = "GBU-12 [ACE]"; + author = "Brandon (TCVM)"; + ammo = QGVAR(12); + pylonWeapon = QGVAR(12); + }; +}; + diff --git a/addons/gbu/CfgWeapons.hpp b/addons/gbu/CfgWeapons.hpp new file mode 100644 index 0000000000..a155b37682 --- /dev/null +++ b/addons/gbu/CfgWeapons.hpp @@ -0,0 +1,19 @@ +class CfgWeapons { + class weapon_LGBLauncherBase; + class GVAR(12): weapon_LGBLauncherBase { + displayName = "GBU-12 [ACE]"; + magazines[] = { QGVAR(2Rnd_12), QGVAR(1_PylonMissile_1Rnd_12) }; + + EGVAR(laser,canSelect) = 1; // can ace_laser lock (allows switching laser code) + EGVAR(laser,showHud) = 1; // show attack profile / lock on hud + }; + + class GVAR(lom250): weapon_LGBLauncherBase { + displayName = "FAB-250M-54 [ACE]"; + magazines[] = {"2Rnd_Bomb_03_F","PylonMissile_1Rnd_Bomb_03_F"}; + + EGVAR(laser,canSelect) = 1; // can ace_laser lock (allows switching laser code) + EGVAR(laser,showHud) = 1; // show attack profile / lock on hud + }; +}; + diff --git a/addons/gbu/README.md b/addons/gbu/README.md new file mode 100644 index 0000000000..391ad79581 --- /dev/null +++ b/addons/gbu/README.md @@ -0,0 +1,12 @@ +ace_gbu +=================== + +Adds GBU-12 LGB + + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [Brandon-TCVM](https://github.com/TheCandianVendingMachine) + diff --git a/addons/gbu/config.cpp b/addons/gbu/config.cpp new file mode 100644 index 0000000000..c3fa764832 --- /dev/null +++ b/addons/gbu/config.cpp @@ -0,0 +1,20 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common","ace_missileguidance"}; + author = ECSTRING(common,ACETeam); + authors[] = {"Brandon (TCVM)"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "CfgAmmo.hpp" +#include "CfgMagazines.hpp" +#include "CfgWeapons.hpp" + diff --git a/addons/gbu/script_component.hpp b/addons/gbu/script_component.hpp new file mode 100644 index 0000000000..1bf7b69404 --- /dev/null +++ b/addons/gbu/script_component.hpp @@ -0,0 +1,18 @@ +#define COMPONENT gbu +#define COMPONENT_BEAUTIFIED Guided Bomb Unit +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_GBU + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_HOT + #define DEBUG_SETTINGS DEBUG_SETTINGS_GBU +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + diff --git a/addons/missileguidance/ACE_GuidanceConfig.hpp b/addons/missileguidance/ACE_GuidanceConfig.hpp index 387fafa4ba..59dacde74f 100644 --- a/addons/missileguidance/ACE_GuidanceConfig.hpp +++ b/addons/missileguidance/ACE_GuidanceConfig.hpp @@ -96,10 +96,6 @@ class GVAR(NavigationTypes) { class LineOfSight { functionName = QFUNC(navigationType_lineOfSight); }; - class SimpleProportionalNavigation { - functionName = QFUNC(navigationType_simpleProNav); - onFired = QFUNC(simpleProNav_onFired); - }; class ProportionalNavigation { functionName = QFUNC(navigationType_proNav); onFired = QFUNC(proNav_onFired); diff --git a/addons/missileguidance/functions/fnc_guidancePFH.sqf b/addons/missileguidance/functions/fnc_guidancePFH.sqf index 43c38ab64f..bed8dde167 100644 --- a/addons/missileguidance/functions/fnc_guidancePFH.sqf +++ b/addons/missileguidance/functions/fnc_guidancePFH.sqf @@ -75,8 +75,8 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua } else { _clampedYaw / abs _clampedYaw }; - _clampedPitch = _pitchSign * _pitchRate; - _clampedYaw = _yawSign * _clampedYaw; + _clampedPitch = _pitchSign * 50; + _clampedYaw = _yawSign * 50; }; TRACE_9("pitch/yaw/roll",_pitch,_yaw,_roll,_yawChange,_pitchChange,_pitchRate,_yawRate,_clampedPitch,_clampedYaw); diff --git a/addons/missileguidance/functions/fnc_navigationType_simpleProNav.sqf b/addons/missileguidance/functions/fnc_navigationType_simpleProNav.sqf deleted file mode 100644 index fc8b46f352..0000000000 --- a/addons/missileguidance/functions/fnc_navigationType_simpleProNav.sqf +++ /dev/null @@ -1,43 +0,0 @@ -#include "script_component.hpp" -/* - * Author: Brandon (TCVM) - * Simple form of proportional navigation: does not take into account target velocity - * - * Arguments: - * Guidance Arg Array - * - * Return Value: - * Commanded acceleration normal to LOS in world space - * - * Example: - * [] call ace_missileguidance_fnc_navigationType_simpleProNav - * - * Public: No - */ -params ["_args", "_timestep", "_seekerTargetPos", "_profileAdjustedTargetPos"]; -_args params ["_firedEH", "", "", "", "_stateParams"]; -_firedEH params ["","","","","","","_projectile"]; -_stateParams params ["", "", "", "","_navigationParams"]; -_navigationParams params ["_lastLineOfSight"]; - -// LOS navigation implemented via https://apps.dtic.mil/sti/pdfs/ADA481330.pdf (called bang-bang) - -private _closingVelocity = vectorMagnitude velocity _projectile; -private _lineOfSight = vectorNormalized (_profileAdjustedTargetPos vectorDiff getPosASLVisual _projectile); - -// the los rate is tiny, so we multiply by a constant of a power of ten to get more aggressive acceleration -// this is just due to how we measure our LOS delta, the vectors involved are _tiny_ -private _losDelta = _lineOfSight vectorDiff _lastLineOfSight; -private _losRate = 1000 * (vectorMagnitude _losDelta) / _timestep; - -private _commandedAcceleration = _closingVelocity vectorMultiply _losRate; - -// we need acceleration normal to our LOS -private _commandedAccelerationProjected = _lineOfSight vectorMultiply (_commandedAcceleration vectorDotProduct _lineOfSight); -_commandedAcceleration = _commandedAcceleration vectorDiff _commandedAccelerationProjected; - -if (accTime > 0) then { - _navigationParams set [0, _lineOfSight]; -}; - -_commandedAcceleration diff --git a/addons/missileguidance/functions/fnc_onFired.sqf b/addons/missileguidance/functions/fnc_onFired.sqf index 4e28c1e8e4..79c871ec8b 100644 --- a/addons/missileguidance/functions/fnc_onFired.sqf +++ b/addons/missileguidance/functions/fnc_onFired.sqf @@ -19,9 +19,6 @@ params ["_shooter","_weapon","","_mode","_ammo","","_projectile"]; -// Bail on not missile -if (!(_ammo isKindOf "MissileBase")) exitWith {}; - // Bail if guidance is disabled for this ammo if ((getNumber (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON) >> "enabled")) != 1) exitWith {}; diff --git a/addons/missileguidance/functions/fnc_simpleProNav_onFired.sqf b/addons/missileguidance/functions/fnc_simpleProNav_onFired.sqf deleted file mode 100644 index 66a03d7c30..0000000000 --- a/addons/missileguidance/functions/fnc_simpleProNav_onFired.sqf +++ /dev/null @@ -1,24 +0,0 @@ -#include "script_component.hpp" -/* - * Author: Brandon (TCVM) - * Sets up LOS navigation state arrays (called from missileGuidance's onFired). - * - * Arguments: - * Guidance Arg Array - * - * Return Value: - * None - * - * Example: - * [] call ace_missileguidance_fnc_proNav_onFired - * - * Public: No - */ -params ["_firedEH", "", "", "", "_stateParams"]; -_firedEH params ["_shooter","","","","_ammo","","_projectile"]; -_launchParams params ["_shooter","_targetLaunchParams","_seekerType","_attackProfile","_lockMode","_laserInfo","_navigationType"]; -_targetLaunchParams params ["_target", "_targetPos", "_launchPos"]; -_stateParams params ["_lastRunTime", "_seekerStateParams", "_attackProfileStateParams", "_lastKnownPosState","_navigationParams"]; -_seekerParams params ["_seekerAngle", "_seekerAccuracy", "_seekerMaxRange", "_seekerMinRange"]; - -_stateParams set [4, [[0, 0, 0]]]; diff --git a/addons/missileguidance/todo.txt b/addons/missileguidance/todo.txt index 0d3cb11e1b..c3bc422283 100644 --- a/addons/missileguidance/todo.txt +++ b/addons/missileguidance/todo.txt @@ -15,7 +15,7 @@ Seeker Types: X Laser - causes lots of weapon noise, causing bad guidance Navigation Types: - GBU-12 - Simple ProNav Guidance + X GBU-12 - LOS Guidance X NLAW - LOS Guidance X Dragon - LOS Guidance X Metis - LOS Guidance