add GBU-12 to missile guidance

This commit is contained in:
Brandon Danyluk 2021-04-12 02:51:02 -06:00
parent 35c48c8915
commit 46abb93cb8
13 changed files with 128 additions and 77 deletions

1
addons/gbu/$PBOPREFIX$ Normal file
View File

@ -0,0 +1 @@
z\ace\addons\gbu

38
addons/gbu/CfgAmmo.hpp Normal file
View File

@ -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"};
};
};
};

View File

@ -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);
};
};

19
addons/gbu/CfgWeapons.hpp Normal file
View File

@ -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
};
};

12
addons/gbu/README.md Normal file
View File

@ -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)

20
addons/gbu/config.cpp Normal file
View File

@ -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"

View File

@ -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"

View File

@ -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);

View File

@ -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);

View File

@ -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 <ARRAY>
*
* Return Value:
* Commanded acceleration normal to LOS in world space <ARRAY>
*
* 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

View File

@ -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 {};

View File

@ -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 <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]]];

View File

@ -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