Add SDB and JDAM

This commit is contained in:
Brandon Danyluk 2021-04-19 01:27:49 -06:00
parent 3878c67c87
commit 44b7b874fd
19 changed files with 310 additions and 11 deletions

View File

@ -55,6 +55,14 @@ class GVAR(AttackProfiles) {
functionName = QFUNC(attackProfile_BEAM);
onFired = QFUNC(wire_onFired); // since Beam guidance is pretty much the same as Wire guidance, we can reuse this
};
class JDAM {
name = "";
visualName = "";
description = "";
functionName = QFUNC(attackProfile_JDAM);
onFired = QFUNC(gps_attackOnFired);
}
};
class GVAR(SeekerTypes) {
@ -104,6 +112,14 @@ class GVAR(SeekerTypes) {
functionName = QFUNC(seekerType_IR);
onFired = QFUNC(IR_onFired);
};
class GPS {
name = "";
visualName = "";
description = "";
functionName = QFUNC(seekerType_GPS);
onFired = QFUNC(gps_seekerOnFired);
};
};
class GVAR(NavigationTypes) {

View File

@ -25,6 +25,7 @@ PREP(attackProfile_LIN);
PREP(attackProfile_LOFT);
PREP(attackProfile_WIRE);
PREP(attackProfile_BEAM);
PREP(attackProfile_JDAM);
// Javelin profiles
PREP(attackProfile_JAV_DIR);
@ -43,15 +44,18 @@ PREP(seekerType_SACLOS);
PREP(seekerType_Doppler);
PREP(seekerType_MWR);
PREP(seekerType_IR);
PREP(seekerType_GPS);
// Attack Profiles OnFired
PREP(wire_onFired);
PREP(gps_attackOnFired);
// Seeker OnFired
PREP(SACLOS_onFired);
PREP(doppler_onFired);
PREP(mwr_onFired);
PREP(IR_onFired);
PREP(gps_seekerOnFired);
// Navigation OnFired
PREP(proNav_onFired);
@ -67,4 +71,5 @@ PREP(gps_confirm);
PREP(gps_modeSelect);
PREP(gps_saveAttackSettings);
PREP(gps_loadAttackSettings);
PREP(gps_getAttackData);

View File

@ -12,9 +12,9 @@ PREP_RECOMPILE_END;
if (isNil QGVAR(enabled)) then { GVAR(enabled) = 2; };
GVAR(gps_currentSettings) = [
[0, 0, 0], // attack position
-1, // impact angle
-1 // attack heading
[0, 0, 0], // attack position
-1, // impact angle
-1 // attack heading
];
GVAR(gps_pbMode) = 0;
@ -23,9 +23,17 @@ for "_i" from 0 to MAX_PB_MODES do {
GVAR(gps_settings) set [_i, GVAR(currentSettings)];
};
GVAR(mode) = "pb";
GVAR(gps_mode) = "pb";
GVAR(debug_enableMissileCamera) = false;
GVAR(debug_drawGuidanceInfo) = true;
#ifdef DRAW_GUIDANCE_INFO
GVAR(debug_drawGuidanceInfo) = true;
#endif
#ifdef ENABLE_PROJECTILE_CAMERA
GVAR(debug_enableMissileCamera) = true;
GVAR(debug_drawGuidanceInfo) = false;
#endif
ADDON = true;

View File

@ -0,0 +1,58 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Attack profile: JDAM
* Glides until attack angle, and then dives in
*
* Arguments:
* 0: Seeker Target PosASL <ARRAY>
* 1: Guidance Arg Array <ARRAY>
* 2: Seeker State <ARRAY>
*
* Return Value:
* Missile Aim PosASL <ARRAY>
*
* Example:
* [[1,2,3], [], []] call ace_missileguidance_fnc_attackProfile_jdam;
*
* Public: No
*/
params ["_seekerTargetPos", "_args", "_attackProfileStateParams"];
_args params ["_firedEH", "", "_flightParams", "", "", "_targetData"];
_firedEH params ["_shooter","","","","","","_projectile"];
_attackProfileStateParams params ["_gpsData", "_initialProjectileHeight", "_terminal"];
_gpsData params ["", "_impactAngle", "_attackDirection"];
_targetData params ["_directionToTarget", "", "_distanceToTarget"];
_flightParams params ["_pitchRate", "_yawRate"];
if (_impactAngle <= 0) then {
_impactAngle = 360; // immediate pitch over to attack
};
if (_attackDirection < 0) then {
_attackDirection = direction _projectile;
};
private _targetPos = _seekerTargetPos;
if !(_terminal) then {
_targetPos set [2, (_seekerTargetPos select 2) + 500];
private _timeToGo = ((getPosASL _projectile) distance _targetPos) / vectorMagnitude velocity _projectile;
private _pitchTime = 0.5 * _pitchRate * _timeToGo;
private _atMinRotationAngle = _pitchTime <= _impactAngle;
_attackProfileStateParams set [2, _atMinRotationAngle];
if (GVAR(debug_drawGuidanceInfo)) then {
_attackProfileName = format ["JDAM [%1]", _pitchTime];
};
};
if (GVAR(debug_drawGuidanceInfo)) then {
private _desiredAngle = [5000, 180 + _attackDirection, _impactAngle] call CBA_fnc_polar2vect;
private _projectilePosAGL = ASLtoAGL _seekerTargetPos;
drawLine3D [_projectilePosAGL, _projectilePosAGL vectorAdd _desiredAngle, [1, 0, 0, 1]];
};
_targetPos;

View File

@ -0,0 +1,23 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Sets up wireGuided state arrays (called from missileGuidance's onFired).
*
* Arguments:
* Guidance Arg Array <ARRAY>
*
* Return Value:
* None
*
* Example:
* [] call ace_missileguidance_fnc_wire_onFired
*
* Public: No
*/
params ["_firedEH", "", "", "", "_stateParams", "", ""];
_stateParams params ["", "", "_attackProfileStateParams"];
_firedEH params ["_shooter","","","","_ammo","","_projectile"];
_attackProfileStateParams set [0, [] call FUNC(gps_getAttackData)];
_attackProfileStateParams set [1, (getPosASL _projectile) select 2];
_attackProfileStateParams set [2, false];

View File

@ -14,7 +14,7 @@
*
* Public: No
*/
if (GVAR(mode) isEqualTo "pb") then {
if (GVAR(gps_mode) isEqualTo "pb") then {
[GVAR(gps_pbMode)] call FUNC(gps_saveAttackSettings);
};
closeDialog 0;

View File

@ -0,0 +1,24 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Returns attack data for GPS guided bomb
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_missileguidance_fnc_gps_getAttackData
*
* Public: No
*/
if (GVAR(gps_mode) isEqualTo "too") then {
private _target = getPilotCameraTarget (vehicle ACE_PLAYER);
_target params ["_tracking", "_position", "_object"];
GVAR(gps_currentSettings) set [0, _position]
};
GVAR(gps_currentSettings)

View File

@ -45,12 +45,12 @@ private _selectedColour = [
ctrlSetFocus (_display displayCtrl _mode);
if (_mode == GPS_UI_TOO) then {
GVAR(mode) = "too";
GVAR(gps_mode) = "too";
if !(_onLoad) then {
[GVAR(gps_pbMode)] call FUNC(gps_saveAttackSettings);
};
} else {
GVAR(mode) = "pb";
GVAR(gps_mode) = "pb";
[GVAR(gps_pbMode)] call FUNC(gps_loadAttackSettings);
};

View File

@ -18,7 +18,7 @@
params ["_display"];
uiNamespace setVariable [QGVAR(gpsAttackOptionDisplay), _display];
private _mode = if (GVAR(mode) isEqualTo "too") then {
private _mode = if (GVAR(gps_mode) isEqualTo "too") then {
GPS_UI_TOO
} else {
GPS_UI_PB
@ -29,7 +29,7 @@
// update current settings
GVAR(gps_uiPerFrameHandler) = [{
if (GVAR(mode) isEqualTo "too") then {
if (GVAR(gps_mode) isEqualTo "too") then {
// update coordinates based on TGP position
private _target = getPilotCameraTarget (vehicle ACE_PLAYER);
_target params ["_tracking", "_position", "_object"];

View File

@ -0,0 +1,20 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Sets up wireGuided state arrays (called from missileGuidance's onFired).
*
* Arguments:
* Guidance Arg Array <ARRAY>
*
* Return Value:
* None
*
* Example:
* [] call ace_missileguidance_fnc_wire_onFired
*
* Public: No
*/
params ["", "", "", "", "_stateParams", "", ""];
_stateParams params ["", "_seekerStateParams"];
_seekerStateParams set [0, [] call FUNC(gps_getAttackData)];

View File

@ -0,0 +1,28 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Returns GPS position. That's it.
*
* Arguments:
* 1: Guidance Arg Array <ARRAY>
* 2: Seeker State <ARRAY>
*
* Return Value:
* Position of wanted missile pos relative to the camera direction <ARRAY>
*
* Example:
* [] call ace_missileguidance_fnc_seekerType_gps
*
* Public: No
*/
params ["", "_args", "_seekerStateParams"];
_args params ["", "", "", "", "", "_targetData"];
(_seekerStateParams select 0) params ["_attackPosition"];
_targetData set [0, (getPosASL _projectile) vectorFromTo _attackPosition];
_targetData set [2, (getPosASL _projectile) distance _attackPosition];
_targetData set [3, [0, 0, 0]];
_targetData set [4, [0, 0, 0]];
_attackPosition

View File

@ -2,7 +2,7 @@
#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 DISABLE_COMPILE_CACHE

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

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

37
addons/sdb/CfgAmmo.hpp Normal file
View File

@ -0,0 +1,37 @@
class CfgAmmo {
class ammo_Bomb_SDB;
class GVAR(sdb): ammo_Bomb_SDB {
author = "Brandon (TCVM)";
maneuvrability = 0; // no maneuvrability so that default guidance doesnt work
class ace_missileguidance {
enabled = 1;
pitchRate = 15;
yawRate = 5;
canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode
// Guidance type for munitions
defaultSeekerType = "GPS";
seekerTypes[] = { "GPS" };
defaultSeekerLockMode = "LOBL";
seekerLockModes[] = { "LOBL" };
defaultNavigationType = "ZeroEffortMiss";
navigationTypes[] = { "ZeroEffortMiss" };
seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos]
seekerAngle = 60; // 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 = "JDAM";
attackProfiles[] = {"JDAM"};
};
};
};

View File

@ -0,0 +1,17 @@
class CfgMagazines {
class magazine_Bomb_SDB_x1;
class PylonRack_Bomb_SDB_x4;
class GVAR(magazine_bomb_SDB_x1): magazine_Bomb_SDB_x1 {
displayName = "1x GBU-39 [ACE]";
author = "Brandon (TCVM)";
ammo = QGVAR(sdb);
};
class GVAR(PylonRack_bomb_SDB_x4): PylonRack_Bomb_SDB_x4 {
displayName = "4x GBU-39 [ACE]";
author = "Brandon (TCVM)";
ammo = QGVAR(sdb);
pylonWeapon = QGVAR(sdb);
};
};

12
addons/sdb/CfgWeapons.hpp Normal file
View File

@ -0,0 +1,12 @@
class CfgWeapons {
class weapon_SDBLauncher;
class GVAR(sdb): weapon_SDBLauncher {
author = "Brandon (TCVM)";
displayName = "GBU-39 [ACE]";
magazines[] = {
QGVAR(magazine_bomb_SDB_x1),
QGVAR(PylonRack_bomb_SDB_x4)
};
};
};

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

@ -0,0 +1,12 @@
ace_sdb
===================
Adds GBU-39 SDB
## Maintainers
The people responsible for merging changes to this component or answering potential questions.
- [Brandon-TCVM](https://github.com/TheCandianVendingMachine)

20
addons/sdb/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 sdb
#define COMPONENT_BEAUTIFIED Small Diameter Bomb
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_SDB
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_SDB
#define DEBUG_SETTINGS DEBUG_SETTINGS_SDB
#endif
#include "\z\ace\addons\main\script_macros.hpp"