Implement some generic modes of flight

This commit is contained in:
Brandon Danyluk 2021-04-12 23:14:22 -06:00
parent 789ae1cbe4
commit 187c6d35c3
9 changed files with 124 additions and 63 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <ARRAY>
@ -18,4 +18,5 @@
* Public: No
*/
_this call FUNC(attackProfile_LIN);
params ["_seekerTargetPos"];
_seekerTargetPos

View File

@ -1,21 +0,0 @@
#include "script_component.hpp"
/*
* Author: jaynus / nou
* Attack profile: HI
* TODO: falls back to Linear
*
* 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_missileguidance_fnc_attackProfile_HI;
*
* Public: No
*/
_this call FUNC(attackProfile_LIN);

View File

@ -0,0 +1,53 @@
#include "script_component.hpp"
/*
* Author: jaynus / nou
* Attack profile: AIR
* TODO: falls back to Linear
*
* 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_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

View File

@ -1,21 +0,0 @@
#include "script_component.hpp"
/*
* Author: jaynus / nou
* Attack profile: MID
* TODO: falls back to Linear
*
* 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_missileguidance_fnc_attackProfile_MID;
*
* Public: No
*/
_this call FUNC(attackProfile_LIN);

View File

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