Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hellfire missiles #4679

Merged
merged 20 commits into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = CSTRING(AGM114K);
displayNameShort = CSTRING(AGM114K);
description = CSTRING(AGM114K);
descriptionShort = CSTRING(AGM114K);

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));
};
};
23 changes: 23 additions & 0 deletions addons/hellfire/CfgMagazines.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class CfgMagazines {
class 12Rnd_PG_missiles;
// Hellfires
class 6Rnd_ACE_Hellfire_AGM114K: 12Rnd_PG_missiles {
count = 6;
ammo = "ACE_Hellfire_AGM114K";
displayName = CSTRING(AGM114K);
displayNameShort = CSTRING(AGM114K);
descriptionShort = CSTRING(AGM114K);
};
class 8Rnd_ACE_Hellfire_AGM114K: 6Rnd_ACE_Hellfire_AGM114K {
count = 8;
};
class 12Rnd_ACE_Hellfire_AGM114K: 6Rnd_ACE_Hellfire_AGM114K {
count = 12;
};
class 16Rnd_ACE_Hellfire_AGM114K: 6Rnd_ACE_Hellfire_AGM114K {
count = 16;
};
class 24Rnd_ACE_Hellfire_AGM114K: 6Rnd_ACE_Hellfire_AGM114K {
count = 24;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@ class CfgVehicles {
};
};
class B_Heli_Attack_01_F: Heli_Attack_01_base_F {};
class ACE_Comanche_Test : B_Heli_Attack_01_F { // Comanche testbed (Hidden: Scope=1)
scope = 1;
scopeCurator = 0;
displayName = "ACE_Comanche_Test";
author = "ACE Team";
class Library {
libTextDesc = "ACE_Comanche_Test";
};
class B_Heli_Attack_01_hellfire_F: B_Heli_Attack_01_F {
displayName = CSTRING(HF_B_Heli_Attack_01);
class Turrets: Turrets {
class MainTurret: MainTurret {
weapons[] = {"gatling_20mm", "ace_missileguidance_dagr", "Laserdesignator_mounted"};
magazines[] = {"ACE_500Rnd_20mm_shells_Comanche", "6Rnd_ACE_Hydra70_DAGR", "Laserbatteries"};
weapons[] = {"ACE_gatling_20mm_Comanche", "ace_hellfire_launcher", "Laserdesignator_mounted"};
magazines[] = {"ACE_500Rnd_20mm_shells_Comanche", "6Rnd_ACE_Hellfire_AGM114K", "Laserbatteries"};
};
};
};
Expand Down
12 changes: 12 additions & 0 deletions addons/hellfire/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CfgWeapons {
class missiles_DAGR;
class GVAR(launcher): missiles_DAGR {
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;
magazines[] = {"6Rnd_ACE_Hellfire_AGM114K", "12Rnd_ACE_Hellfire_AGM114K", "24Rnd_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)
59 changes: 59 additions & 0 deletions addons/hellfire/RscTitles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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 cg: RscControlsGroupNoScrollbars {
idc = 1000;
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 Mode: RscText {
idc = 1001;
text = "LOAL-HI";
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 = 1003;
colorText[] = {1, 1, 1, 1};
colorBackground[] = {0, 0, 0, 0};
text = "1111";
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 = 1002;
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(insertFireModeActions);
PREP(turretChanged);
7 changes: 7 additions & 0 deletions addons/hellfire/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "script_component.hpp"

if (!hasInterface) exitWith {};

["ace_settingsInitialized", {
["turret", LINKFUNC(turretChanged), true] call CBA_fnc_addPlayerEventHandler;
}] 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[] = {"B_Heli_Attack_01_hellfire_F"};
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