diff --git a/addons/aim120/CfgAmmo.hpp b/addons/aim120/CfgAmmo.hpp index af64a2c79a..b2008d625e 100644 --- a/addons/aim120/CfgAmmo.hpp +++ b/addons/aim120/CfgAmmo.hpp @@ -3,6 +3,9 @@ class CfgAmmo { class GVAR(c): ammo_Missile_AMRAAM_C { author = "Brandon (TCVM)"; maneuvrability = 0; + flightProfiles[] = {"Direct", "Loft"}; + class Direct {}; // dummy to allow for F cycling of missile mode + class Loft {}; class ace_missileguidance { enabled = 1; @@ -30,8 +33,9 @@ class CfgAmmo { seekerMaxRange = 2500; // Range from the missile which the seeker can visually search // Attack profile type selection - defaultAttackProfile = "LIN"; - attackProfiles[] = {"LIN"}; + defaultAttackProfile = "DIR"; + attackProfiles[] = {"DIR", "LOFT"}; + useModeForAttackProfile = 1; }; }; @@ -39,6 +43,9 @@ class CfgAmmo { class GVAR(d): ammo_Missile_AMRAAM_D { author = "Brandon (TCVM)"; maneuvrability = 0; + flightProfiles[] = {"Direct", "TopDown"}; + class Direct {}; // dummy to allow for F cycling of missile mode + class TopDown {}; class ace_missileguidance { enabled = 1; @@ -66,8 +73,9 @@ class CfgAmmo { seekerMaxRange = 2500; // Range from the missile which the seeker can visually search // Attack profile type selection - defaultAttackProfile = "LIN"; - attackProfiles[] = {"LIN"}; + defaultAttackProfile = "DIR"; + attackProfiles[] = {"DIR", "LOFT"}; + useModeForAttackProfile = 1; }; }; }; diff --git a/addons/aim120/CfgWeapons.hpp b/addons/aim120/CfgWeapons.hpp index 3efc628e03..ba1aa6d05c 100644 --- a/addons/aim120/CfgWeapons.hpp +++ b/addons/aim120/CfgWeapons.hpp @@ -1,10 +1,53 @@ class CfgWeapons { class weapon_AMRAAMLauncher; + class MissileLauncher; class GVAR(aim120Launcher): weapon_AMRAAMLauncher { author = "Brandon (TCVM)"; displayName = "AIM-120 [ACE]"; + weaponLockDelay = 0.5; magazines[] = { QGVAR(c), QGVAR(PylonMissile_Missile_c_x1), QGVAR(PylonRack_Missile_c_x1), QGVAR(PylonRack_Missile_c_x2), QGVAR(PylonMissile_Missile_d_x1), QGVAR(PylonMissile_Missile_d_INT_x1), QGVAR(PylonRack_Missile_d_x1), QGVAR(PylonRack_Missile_d_x2)}; + + modes[] = {"Direct", "Loft"}; + class Direct: MissileLauncher { + displayName = "Direct"; + textureType = "direct"; + reloadTime = 0.1; + magazineReloadTime = 0.1; + aiRateOfFire = 15; + aiRateOfFireDispersion = -10; + aiRateOfFireDistance = 10000; + minRange = 800; + minRangeProbab = 0.5; + midRange = 2500; + midRangeProbab = 0.95; + maxRange = 4000; + maxRangeProbab = 1; + sounds[] = {"StandardSound"}; + class StandardSound { + begin1[] = {"A3\Sounds_F\weapons\Rockets\missile_2", 1.12202, 1.3, 1000}; + soundBegin[] = {"begin1", 1}; + weaponSoundEffect = "DefaultRifle"; + }; + soundFly[] = {"A3\Sounds_F\weapons\Rockets\rocket_fly_1", 1, 1.5, 700}; + lockingTargetSound[] = {"\A3\Sounds_F\weapons\Rockets\locked_1", 0.562341, 1}; + lockedTargetSound[] = {"\A3\Sounds_F\weapons\Rockets\locked_3", 0.562341, 2.5}; + + EGVAR(missileGuidance,attackProfile) = "DIR"; + }; + class Loft: Direct { + displayName = "Loft"; + textureType = "topdown"; + + minRange = 4000; + minRangeProbab = 0.5; + midRange = 7000; + midRangeProbab = 0.95; + maxRange = 13000; + maxRangeProbab = 1; + + EGVAR(missileGuidance,attackProfile) = "LOFT"; + }; }; }; diff --git a/addons/missileguidance/ACE_GuidanceConfig.hpp b/addons/missileguidance/ACE_GuidanceConfig.hpp index 59dacde74f..d815641bea 100644 --- a/addons/missileguidance/ACE_GuidanceConfig.hpp +++ b/addons/missileguidance/ACE_GuidanceConfig.hpp @@ -6,6 +6,11 @@ class GVAR(AttackProfiles) { functionName = QFUNC(attackProfile_LIN); }; + // empty classes for backwards compat + class MID: LIN { + }; + class HI: LIN { + }; class DIR { name = ""; visualName = ""; @@ -13,21 +18,14 @@ class GVAR(AttackProfiles) { functionName = QFUNC(attackProfile_DIR); }; - class MID { + class LOFT { name = ""; visualName = ""; description = ""; - functionName = QFUNC(attackProfile_MID); + functionName = QFUNC(attackProfile_LOFT); }; - class HI { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(attackProfile_HI); - }; - class JAV_DIR { + class JAV_DIR { name = ""; visualName = ""; description = ""; diff --git a/addons/missileguidance/XEH_PREP.hpp b/addons/missileguidance/XEH_PREP.hpp index fca49e77a8..75b891da12 100644 --- a/addons/missileguidance/XEH_PREP.hpp +++ b/addons/missileguidance/XEH_PREP.hpp @@ -19,9 +19,8 @@ PREP(handleHandoff); // Attack Profiles PREP(attackProfile_AIR); PREP(attackProfile_DIR); -PREP(attackProfile_HI); PREP(attackProfile_LIN); -PREP(attackProfile_MID); +PREP(attackProfile_LOFT); PREP(attackProfile_WIRE); PREP(attackProfile_BEAM); diff --git a/addons/missileguidance/functions/fnc_attackProfile_DIR.sqf b/addons/missileguidance/functions/fnc_attackProfile_DIR.sqf index cddd70807e..a3c310293a 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_DIR.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_DIR.sqf @@ -1,8 +1,8 @@ #include "script_component.hpp" /* - * Author: jaynus / nou + * Author: Brandon (TCVM) * Attack profile: DIR - * TODO: falls back to Linear + * Returns target position with no modifications * * Arguments: * 0: Seeker Target PosASL @@ -18,4 +18,5 @@ * Public: No */ -_this call FUNC(attackProfile_LIN); +params ["_seekerTargetPos"]; +_seekerTargetPos diff --git a/addons/missileguidance/functions/fnc_attackProfile_HI.sqf b/addons/missileguidance/functions/fnc_attackProfile_HI.sqf deleted file mode 100644 index 6f1fbe67d3..0000000000 --- a/addons/missileguidance/functions/fnc_attackProfile_HI.sqf +++ /dev/null @@ -1,21 +0,0 @@ -#include "script_component.hpp" -/* - * Author: jaynus / nou - * Attack profile: HI - * TODO: falls back to Linear - * - * Arguments: - * 0: Seeker Target PosASL - * 1: Guidance Arg Array - * 2: Attack Profile State - * - * Return Value: - * Missile Aim PosASL - * - * Example: - * [[1,2,3], [], []] call ace_missileguidance_fnc_attackProfile_HI; - * - * Public: No - */ - -_this call FUNC(attackProfile_LIN); diff --git a/addons/missileguidance/functions/fnc_attackProfile_LOFT.sqf b/addons/missileguidance/functions/fnc_attackProfile_LOFT.sqf new file mode 100644 index 0000000000..eb3a9583ee --- /dev/null +++ b/addons/missileguidance/functions/fnc_attackProfile_LOFT.sqf @@ -0,0 +1,53 @@ +#include "script_component.hpp" +/* + * Author: jaynus / nou + * Attack profile: AIR + * TODO: falls back to Linear + * + * Arguments: + * 0: Seeker Target PosASL + * 1: Guidance Arg Array + * 2: Seeker State + * + * Return Value: + * Missile Aim PosASL + * + * Example: + * [[1,2,3], [], []] call ace_missileguidance_fnc_attackProfile_AIR; + * + * Public: No + */ + +params ["_seekerTargetPos", "_args"]; +_args params ["_firedEH", "_launchParams", "_flightParams", "_seekerParams", "_stateParams"]; +_firedEH params ["_shooter","","","","_ammo","","_projectile"]; +_launchParams params ["_shooter","_targetLaunchParams","_seekerType","_attackProfile","_lockMode","_laserInfo","_navigationType"]; +_targetLaunchParams params ["_target", "_targetPos", "_launchPos", "_launchDir", "_launchTime"]; +_flightParams params ["_pitchRate", "_yawRate", "_isBangBangGuidance"]; +_stateParams params ["_lastRunTime", "_seekerStateParams", "_attackProfileStateParams", "_lastKnownPosState","_navigationParams"]; +_seekerParams params ["_seekerAngle", "_seekerAccuracy", "_seekerMaxRange", "_seekerMinRange"]; + +if (_seekerTargetPos isEqualTo [0, 0, 0]) exitWith { + _seekerTargetPos +}; + +private _projectilePos = getPosASLVisual _projectile; + +private _closingRate = vectorMagnitude velocity _projectile; +private _timeToGo = (_projectilePos distance _seekerTargetPos) / _closingRate; + +// we could do stuff like desired attack angle, but I'm not going that far today +private _los = vectorNormalized (_seekerTargetPos vectorDiff _projectilePos); + +private _angleToTarget = acos ((vectorDir _projectile) vectorCos _los); +private _atMinRotationAngle = _angleToTarget >= (0.5 * _pitchRate * _timeToGo); + +private _returnTargetPos = _seekerTargetPos; + +if !(_atMinRotationAngle) then { + // 10 degree pitch up + _returnTargetPos = _seekerTargetPos vectorAdd [0, 0, (_projectilePos distance _seekerTargetPos) * sin 10]; +}; + +_returnTargetPos + diff --git a/addons/missileguidance/functions/fnc_attackProfile_MID.sqf b/addons/missileguidance/functions/fnc_attackProfile_MID.sqf deleted file mode 100644 index f66088844c..0000000000 --- a/addons/missileguidance/functions/fnc_attackProfile_MID.sqf +++ /dev/null @@ -1,21 +0,0 @@ -#include "script_component.hpp" -/* - * Author: jaynus / nou - * Attack profile: MID - * TODO: falls back to Linear - * - * Arguments: - * 0: Seeker Target PosASL - * 1: Guidance Arg Array - * 2: Attack Profile State - * - * Return Value: - * Missile Aim PosASL - * - * Example: - * [[1,2,3], [], []] call ace_missileguidance_fnc_attackProfile_MID; - * - * Public: No - */ - -_this call FUNC(attackProfile_LIN); diff --git a/addons/missileguidance/functions/fnc_onFired.sqf b/addons/missileguidance/functions/fnc_onFired.sqf index f41a089cff..d1b5fc87c0 100644 --- a/addons/missileguidance/functions/fnc_onFired.sqf +++ b/addons/missileguidance/functions/fnc_onFired.sqf @@ -119,7 +119,7 @@ private _pitchYaw = (vectorDir _projectile) call CBA_fnc_vect2Polar; TRACE_5("Beginning ACE guidance system",_target,_ammo,_seekerType,_attackProfile,_navigationType); private _args = [_this, [ _shooter, - [_target, _targetPos, _launchPos, vectorDirVisual vehicle _shooter], + [_target, _targetPos, _launchPos, vectorDirVisual vehicle _shooter, CBA_missionTime], _seekerType, _attackProfile, _lockMode, @@ -169,7 +169,8 @@ if (_onFiredFunc != "") then { // _args params ["_firedEH", "_launchParams", "_flightParams", "_seekerParams", "_stateParams"]; // _firedEH params ["_shooter","","","","_ammo","","_projectile"]; // _launchParams params ["_shooter","_targetLaunchParams","_seekerType","_attackProfile","_lockMode","_laserInfo","_navigationType"]; -// _targetLaunchParams params ["_target", "_targetPos", "_launchPos"m "_launchDir"]; +// _targetLaunchParams params ["_target", "_targetPos", "_launchPos", "_launchDir", "_launchTime"]; +// _flightParams params ["_pitchRate", "_yawRate", "_isBangBangGuidance"]; // _stateParams params ["_lastRunTime", "_seekerStateParams", "_attackProfileStateParams", "_lastKnownPosState","_navigationParams"]; // _seekerParams params ["_seekerAngle", "_seekerAccuracy", "_seekerMaxRange", "_seekerMinRange"];