Skip to content

Commit

Permalink
Hellfire missiles (#4679)
Browse files Browse the repository at this point in the history
* Hellfire

* Cleanup dev macros

* Cleanup some debug

* Add base interaction node for firemode actions

* Handle bad data in attack profile variable

* Skip ammo checks (returns bad data on added weaps)

* Add mags sizes for apache

* Add Hellfire Wiki Doc

* Cleanup doc

* Add pylon support

* Add support for pilot controlled weapons

* Add label to pylon mags

* Cleanup vehicle configs, autoAdd laser des, fix ineractions for driver
  • Loading branch information
PabstMirror authored Jun 2, 2017
1 parent 49374fe commit 3898202
Show file tree
Hide file tree
Showing 28 changed files with 741 additions and 86 deletions.
1 change: 1 addition & 0 deletions addons/hellfire/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\ace\addons\hellfire
17 changes: 17 additions & 0 deletions addons/hellfire/ACE_GuidanceConfig.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class EGVAR(missileguidance,AttackProfiles) {
class hellfire {
// LOBL and LOAL-DIR behaive the same
name = "LOAL-DIR";
nameLocked = "LOBL";
functionName = QFUNC(attackProfile);
GVAR(launchHeightClear) = 0;
};
class hellfire_hi: hellfire {
name = "LOAL-HI";
GVAR(launchHeightClear) = 304.8; // clear 1000 ft by 1500m
};
class hellfire_lo: hellfire_hi {
name = "LOAL-LO";
GVAR(launchHeightClear) = 91.5; // clear 300 ft by 600m
};
};
57 changes: 57 additions & 0 deletions addons/hellfire/CfgAmmo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
class CfgAmmo {
class M_PG_AT;

class ACE_Hellfire_AGM114K: M_PG_AT {
displayName = "AGM-114K";
displayNameShort = "AGM-114K";
description = "AGM-114K";
descriptionShort = "AGM-114K";

model = "\A3\Weapons_F\Ammo\Missile_AT_03_fly_F";
proxyShape = "\A3\Weapons_F\Ammo\Missile_AT_03_F";

hit = 1400;
indirectHit = 71;
indirectHitRange = 4.5;
effectsMissile = "missile2";

irLock = 0;
laserLock = 0;
manualControl = 0;
maxSpeed = 450;

thrustTime = 2.5; // motor burn 2-3 sec
thrust = 250;
timeToLive = 40;

EGVAR(rearm,caliber) = 178;

class ace_missileguidance {
enabled = 1;

minDeflection = 0.0005; // Minium flap deflection for guidance
maxDeflection = 0.01; // Maximum flap deflection for guidance
incDeflection = 0.0005; // The incrmeent in which deflection adjusts.

canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode

// Guidance type for munitions
defaultSeekerType = "SALH";
seekerTypes[] = { "SALH", "LIDAR", "SARH", "Optic", "Thermal", "GPS", "SACLOS", "MCLOS" };

defaultSeekerLockMode = "LOAL";
seekerLockModes[] = { "LOAL", "LOBL" };

seekLastTargetPos = 1; // seek last target position [if seeker loses LOS of target, continue to last known pos]
seekerAngle = 70; // Angle in front of the missile which can be searched
seekerAccuracy = 1; // seeker accuracy multiplier

seekerMinRange = 1;
seekerMaxRange = 5000; // Range from the missile which the seeker can visually search

// Attack profile type selection
defaultAttackProfile = "hellfire";
attackProfiles[] = {"hellfire", "hellfire_hi", "hellfire_lo"};
};
};
};
15 changes: 15 additions & 0 deletions addons/hellfire/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
47 changes: 47 additions & 0 deletions addons/hellfire/CfgMagazines.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class CfgMagazines {
class 12Rnd_PG_missiles;

class 6Rnd_ACE_Hellfire_AGM114K: 12Rnd_PG_missiles { // Old style vehicle magazine
count = 6;
ammo = "ACE_Hellfire_AGM114K";
displayName = "AGM-114K [ACE]";
displayNameShort = "AGM-114K";
descriptionShort = "AGM-114K";
};

// 1.70 pylon magazines:
class PylonMissile_1Rnd_ACE_Hellfire_AGM114K: 6Rnd_ACE_Hellfire_AGM114K { // Bare missle
displayName = "1x AGM-114K [ACE]";
count = 1;
mass = 70;
pylonWeapon = QGVAR(launcher);
hardpoints[] = {"SCALPEL_1RND"};
model = "\A3\Weapons_F\DynamicLoadout\PylonMissile_1x_Bomb_04_F.p3d";
};
class PylonRack_1Rnd_ACE_Hellfire_AGM114K: 6Rnd_ACE_Hellfire_AGM114K { // 1x Launcher Support Rack
displayName = "1x AGM-114K [ACE]";
count = 1;
mass = 85;
pylonWeapon = QGVAR(launcher);
hardpoints[] = {"B_MISSILE_PYLON", "SCALPEL_1RND_EJECTOR", "B_ASRRAM_EJECTOR", "UNI_SCALPEL"};
model = "\A3\Weapons_F\DynamicLoadout\PylonPod_1x_Missile_AA_04_F.p3d";
};
class PylonRack_3Rnd_ACE_Hellfire_AGM114K: 6Rnd_ACE_Hellfire_AGM114K { // 3x Launcher Support Rack
displayName = "3x AGM-114K [ACE]";
count = 3;
mass = 250;
pylonWeapon = QGVAR(launcher);
hardpoints[] = {"B_MISSILE_PYLON", "UNI_SCALPEL"};
model = "\A3\Weapons_F\DynamicLoadout\PylonPod_3x_Missile_LG_scalpel_F.p3d";
mirrorMissilesIndexes[] = {2, 1, 3};
};
class PylonRack_4Rnd_ACE_Hellfire_AGM114K: 6Rnd_ACE_Hellfire_AGM114K { // 4x Launcher Support Rack
displayName = "4x AGM-114K [ACE]";
count = 4;
mass = 340;
pylonWeapon = QGVAR(launcher);
hardpoints[] = {"UNI_SCALPEL"};
model = "\A3\Weapons_F\DynamicLoadout\PylonPod_4x_Missile_LG_scalpel_F.p3d";
mirrorMissilesIndexes[] = {2, 1, 4, 3};
};
};
6 changes: 6 additions & 0 deletions addons/hellfire/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CfgVehicles {
class Heli_Attack_01_base_F;
class Heli_Attack_01_dynamicLoadout_base_F: Heli_Attack_01_base_F {
GVAR(addLaserDesignator) = 1;
};
};
13 changes: 13 additions & 0 deletions addons/hellfire/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CfgWeapons {
class missiles_SCALPEL;
class GVAR(launcher): missiles_SCALPEL {
displayName = CSTRING(Hellfire);
GVAR(enabled) = 1; // show attack profile / lock on hud
EGVAR(laser,canSelect) = 1; // can ace_laser lock (allows switching laser code)
canLock = 0;
weaponLockSystem = 0;
magazines[] = {"6Rnd_ACE_Hellfire_AGM114K", "PylonMissile_1Rnd_ACE_Hellfire_AGM114K", "PylonRack_1Rnd_ACE_Hellfire_AGM114K", "PylonRack_3Rnd_ACE_Hellfire_AGM114K", "PylonRack_4Rnd_ACE_Hellfire_AGM114K"};
lockingTargetSound[] = {"",0,1};
lockedTargetSound[] = {"",0,1};
};
};
10 changes: 10 additions & 0 deletions addons/hellfire/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ace_hellfire
==========

Adds AGM-114K Hellfire missiles.

## Maintainers

The people responsible for merging changes to this component or answering potential questions.

- [PabstMirror](https://github.com/PabstMirror)
57 changes: 57 additions & 0 deletions addons/hellfire/RscTitles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
class RscControlsGroupNoScrollbars;
class RscPictureKeepAspect;
class RscText;

class RscTitles {
class GVAR(modeDisplay) {
idd = -1;
onLoad = QUOTE(with uiNameSpace do { GVAR(display) = _this select 0 };);
movingEnable = 0;
duration = 60;
fadeIn = "false";
fadeOut = "false";
class controls {
class ModeControlGroup: RscControlsGroupNoScrollbars {
idc = IDC_MODECONTROLGROUP;
x = "3.8 * (((safezoneW / safezoneH) min 1.2) / 40) + (profilenamespace getvariable ['IGUI_GRID_WEAPON_X',((safezoneX + safezoneW) - (10 * (((safezoneW / safezoneH) min 1.2) / 40)) - 4.3 * (((safezoneW / safezoneH) min 1.2) / 40))])";
y = "2.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (profilenamespace getVariable ['IGUI_GRID_WEAPON_Y', (safezoneY + 0.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25))])";
w = "10 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";

class controls {
class AttackMode: RscText {
idc = IDC_ATTACKMODE;
colorText[] = {1, 1, 1, 1};
colorBackground[] = {0, 0, 0, 0};
x = "0";
y = "0";
w = "(2.6) * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
sizeEx = "0.8 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class LaserCode: RscText {
idc = IDC_LASERCODE;
colorText[] = {1, 1, 1, 1};
colorBackground[] = {0, 0, 0, 0};
x = "(3.6) * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
y = "0";
w = "(2.5) * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
h = "(1) * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
sizeEx = "0.8 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class LaserIcon: RscPictureKeepAspect {
idc = IDC_LASERICON;
colorText[] = {1, 0, 0, 1};
colorBackground[] = {0, 0, 0, 0};
text = "\a3\Ui_F_Curator\Data\CfgCurator\laser_ca.paa";
x = "(6.1) * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
y = "0";
w = "(1) * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
h = "(1) * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
};
};

};
};
};
5 changes: 5 additions & 0 deletions addons/hellfire/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LOG("prep");
PREP(attackProfile);
PREP(getAttackProfileSettings);
PREP(setupVehicle);
PREP(showHud);
10 changes: 10 additions & 0 deletions addons/hellfire/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "script_component.hpp"

if (!hasInterface) exitWith {};

GVAR(pfID) = -1;

["ace_settingsInitialized", {
["turret", LINKFUNC(showHud), false] call CBA_fnc_addPlayerEventHandler;
["vehicle", LINKFUNC(showHud), true] call CBA_fnc_addPlayerEventHandler; // only one of these needs the retro flag
}] call CBA_fnc_addEventHandler;
9 changes: 9 additions & 0 deletions addons/hellfire/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

ADDON = true;
3 changes: 3 additions & 0 deletions addons/hellfire/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
23 changes: 23 additions & 0 deletions addons/hellfire/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction", "ace_missileguidance"};
author = ECSTRING(common,ACETeam);
authors[] = {"PabstMirror"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};

#include "ACE_GuidanceConfig.hpp"
#include "CfgAmmo.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgMagazines.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "RscTitles.hpp"
85 changes: 85 additions & 0 deletions addons/hellfire/functions/fnc_attackProfile.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Author: PabstMirror
* Hellfire attack profile. Handles all 4 modes LOBL, LOAL-DIR, LOAL-HI, LOAL-LO
*
* Arguments:
* 0: Seeker Target PosASL <ARRAY>
* 1: Guidance Arg Array <ARRAY>
* 2: Attack Profile State <ARRAY>
*
* Return Value:
* Missile Aim PosASL <ARRAY>
*
* Example:
* [[1,2,3], [], []] call ace_hellfire_fnc_attackProfile
*
* Public: No
*/
// #define DEBUG_MODE_FULL
#include "script_component.hpp"

params ["_seekerTargetPos", "_args", "_attackProfileStateParams"];
_args params ["_firedEH", "_launchParams"];
_launchParams params ["","_targetLaunchParams"];
_targetLaunchParams params ["", "", "_launchPos"];
_firedEH params ["","","","","","","_projectile"];

// Get state params:
if (_attackProfileStateParams isEqualTo []) then {
_this call FUNC(getAttackProfileSettings);
};
_attackProfileStateParams params ["_attackStage", "_configLaunchHeightClear"];


private _projectilePos = getPosASL _projectile;
private _distanceFromLaunch2d = _launchPos distance2d _projectilePos;
private _heightAboveLaunch = (_projectilePos select 2) - (_launchPos select 2);

// Add height depending on distance for compensate
private _returnTargetPos = nil;

switch (_attackStage) do {
case STAGE_LAUNCH: { // Gain height quickly to pass terrain mask
_returnTargetPos = _projectilePos getPos [100, getDir _projectile];
_returnTargetPos set [2, (_projectilePos select 2) + 36.4]; // 100 and 36.4 gives a 20 deg angle

if (_heightAboveLaunch > _configLaunchHeightClear) then {
_attackProfileStateParams set [0, STAGE_SEEK_CRUISE];
TRACE_2("New Stage: STAGE_SEEK_CRUISE",_distanceFromLaunch2d,_heightAboveLaunch);
};
};
case STAGE_SEEK_CRUISE: { // Slowly gain altitude while searching for target
// Before 4000 cruise at 5.7 degrees up, then level out
private _cruiseHeight = linearConversion [3000, 5000, _distanceFromLaunch2d, 10, 0, true];

_returnTargetPos = _projectilePos getPos [100, getDir _projectile];
_returnTargetPos set [2, (_projectilePos select 2) + _cruiseHeight];

if (!(_seekerTargetPos isEqualTo [0,0,0])) then {
_attackProfileStateParams set [0, STAGE_ATTACK_CRUISE];
TRACE_1("New Stage: STAGE_ATTACK_CRUISE",_distanceFromLaunch2d);
};
};
case STAGE_ATTACK_CRUISE: {
private _currentHeightOverTarget = (_projectilePos select 2) - (_seekerTargetPos select 2);
private _distanceToTarget2d = _seekerTargetPos distance2d _projectilePos;
private _distToGoRatio = _distanceToTarget2d / (_launchPos distance2d _seekerTargetPos);

// arcing up at 7 degrees to start until 50% left, then smooth curve to a downward attack
private _gainSlope = linearConversion [0.5, 0.1, _distToGoRatio, 7, -7, true];
_returnTargetPos = +_seekerTargetPos;
_returnTargetPos set [2, ((_projectilePos select 2) + (_distanceToTarget2d * sin _gainSlope)) max (_seekerTargetPos select 2)];

if ((_distanceToTarget2d < 500) || {(_currentHeightOverTarget atan2 _distanceToTarget2d) > 15}) then { // Wait until we can come down at a sharp angle
_attackProfileStateParams set [0, STAGE_ATTACK_TERMINAL];
TRACE_2("New Stage: STAGE_ATTACK_TERMINAL",_distanceToTarget2d,_currentHeightOverTarget);
};
};
case STAGE_ATTACK_TERMINAL: {
private _distanceToTarget2d = _seekerTargetPos distance2d _projectilePos;
_returnTargetPos = _seekerTargetPos vectorAdd [0, 0, _distanceToTarget2d * 0.02];
};
};

// TRACE_1("Adjusted target position", _returnTargetPos);
_returnTargetPos;
Loading

0 comments on commit 3898202

Please sign in to comment.