Guidance framework working.

This commit is contained in:
jaynus 2015-04-08 08:01:39 -07:00
parent bf70a9ba77
commit 104dd2258e
12 changed files with 184 additions and 179 deletions

View File

@ -8,7 +8,6 @@ class CfgAmmo {
irLock = 0;
laserLock = 0;
airLock = 0;
manualControl = 1;
weaponLockSystem = "2 + 16";
hit = 600;
@ -17,8 +16,6 @@ class CfgAmmo {
maxSpeed = 720;
maxControlRange = 5000;
trackOversteer = 1;
trackLead = 1;
maneuvrability = 8;
timeToLive = 60;
simulationStep = 0.01;
@ -34,16 +31,32 @@ class CfgAmmo {
whistleDist = 4;
muzzleEffect = "";
ACE_maxDeflection = 0.15; // Maximum flap deflection for guidance
ACE_minDeflection = 0.005; // Minium flap deflection for guidance
ACE_incDeflection = 0.005; // The incrmeent in which deflection adjusts.
// Turn off arma crosshair-guidance
manualControl = 0;
ACE_seekerTypes[] = { "SALH" }; // {"SALH", "LIDAR", "BeamRide", "SARH", "Optic", "Thermal"};
ACE_seekerAngle = 90; // Angle in front of the missile which can be searched
ACE_seekerAccuracy = 1; // seeker accuracy multiplier
ACE_seekerMaxRange = 2500; // Range from the missile which the seeker can visually search
ACE_attackProfiles[] = { "LOAL-LIN", "LOAL-DIR", "LOAL-MID", "LOAL-HI" };
// ACE uses these values
trackOversteer = 1;
trackLead = 0;
// Begin ACE guidance Configs
class ACE_MissileGuidance {
enabled = 1;
minDeflection = 0.005; // Minium flap deflection for guidance
maxDeflection = 0.15; // Maximum flap deflection for guidance
incDeflection = 0.005; // The incrmeent in which deflection adjusts.
// Guidance type for munitions
defaultSeekerType = "SALH";
seekerTypes[] = { "SALH", "LIDAR", "SARH", "Optic", "Thermal", "GPS", "SACLOS", "MCLOS", };
seekerAngle = 90; // Angle in front of the missile which can be searched
seekerAccuracy = 1; // seeker accuracy multiplier
seekerMaxRange = 2500; // Range from the missile which the seeker can visually search
// Attack profile type selection
defaultAttackProfile = "LOAL-LIN";
attackProfiles[] = { "LOBL-LIN", "LOBL-DIR", "LOBL-MID", "LOBL-HI", "LOBL-TOP-DOWN", "LOAL-LIN", "LOAL-DIR", "LOAL-MID", "LOAL-HI", "LOAL-TOP-DOWN" };
};
};
class ACE_Hydra70_DAGR : M_PG_AT {

View File

@ -8,7 +8,10 @@ PREP(translateToWeaponSpace);
PREP(fired);
PREP(guidance_DAGR);
PREP(guidance_LGB);
PREP(guidance_HellfireII);
FUNC(getPosASL) = {visiblePositionASL (_this select 0)};
PREP(guidancePFH);
PREP(doAttackProfile);
PREP(doSeekerSearch);
// Probably to be renamed
PREP(attackProfile_linear);
PREP(guidance_LGB);

View File

@ -0,0 +1,28 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
private["_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams", "_targetPos", "_projectilePos"];
_launchParams = _this select 1;
_seekerTargetPos = _this select 0;
_target = _launchParams select 0;
_targetLaunchParams = _launchParams select 1;
_shooterPos = getPosASL _shooter;
_projectilePos = getPosASL _projectile;
_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos;
_distanceToShooter = _projectilePos vectorDistance _shooterPos;
_addHeight = [0,0,(_projectilePos distance _seekerTargetPos)*0.02];
_seekerTargetPos = _seekerTargetPos vectorAdd _addHeight;
#ifdef DEBUG_MODE_FULL
drawLine3D [(ASLtoATL _seekerTargetPos) vectorAdd _addHeight, ASLtoATL _seekerTargetPos, [0,1,0,1]];
#endif
TRACE_1("Adjusted target position", _seekerTargetPos);
_seekerTargetPos;

View File

@ -0,0 +1,11 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
EXPLODE_7_PVT((_this select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
private["_targets", "_foundTargetPos"];
_targets = [_projectile, ACE_DEFAULT_LASER_CODE, 70, (velocity _projectile)] call ace_laser_fnc_findLaserDesignator;
_foundTargetPos = getPosASL (_targets select 1);
TRACE_1("Seeker return target pos", _foundTargetPos);
_foundTargetPos;

View File

@ -1,25 +1,46 @@
//#define DEBUG_MODE_FULL
#define DEBUG_MODE_FULL
#include "script_component.hpp"
//_this=[TEST_AI_HELICOPTER,"missiles_DAGR","missiles_DAGR","Far_AI","M_PG_AT","24Rnd_PG_missiles",163988: rocket_01_fly_f.p3d]
TRACE_1("enter", _this);
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
if(!local _shooter) exitWith { false };
// Bail on locality of the projectile, it should be local to us
if(!local _projectile) exitWith { false };
private["_config", "_enabled", "_target", "_seekerType", "_attackProfile"];
_config = configFile >> "CfgAmmo" >> _ammo >> "ACE_MissileGuidance";
_enabled = getNumber ( _config >> "enabled");
// Bail if guidance is not enabled
if(isNil "_enabled" || {_enabled != 1}) exitWith { false };
switch _ammo do {
case "M_PG_AT": { // Vanilla DAGR missile
_this call FUNC(guidance_DAGR);
};
case "ACE_Hydra70_DAGR": { // ACE DAGR
_this call FUNC(guidance_DAGR);
};
case "ACE_Hellfire_AGM114K": { // ACE Hellfire AGM-114K
_this call FUNC(guidance_HellfireII);
};
case "GBU12BombLauncher": {
_this call FUNC(guidance_LGB);
};
};
_target = _shooter getVariable[QGVAR(target), nil];
_seekerType = _shooter getVariable [QGVAR(seekerType), nil];
_attackProfile = _shooter getVariable [QGVAR(attackProfile), nil];
if ( isNil "_seekerType" || { ! ( _seekerType in (getArray (_config >> "seekerTypes" ) ) ) } ) then {
_seekerType = getText (_config >> "defaultSeekerType");
};
if ( isNil "_attackProfile" || { ! ( _attackProfile in (getArray (_config >> "attackProfiles" ) ) ) } ) then {
_attackProfile = getText (_config >> "defaultAttackProfile");
};
TRACE_4("Beginning ACE guidance system",_target,_ammo,_seekerType,_attackProfile);
[FUNC(guidancePFH), 0.1, [_this,
[ACE_player,
[_target, _targetPos, _launchPos],
_seekerType,
_attackProfile
],
[
getNumber ( _config >> "minDeflection" ),
getNumber ( _config >> "maxDeflection" ),
getNumber ( _config >> "incDeflection" )
],
[
getNumber ( _config >> "seekerAngle" ),
getNumber ( _config >> "seekerAccuracy" ),
getNumber ( _config >> "seekerMaxRange" )
]
]
] call cba_fnc_addPerFrameHandler;

View File

@ -0,0 +1,70 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
private["_args", "_launchParams", "_targetLaunchParams", "_config", "_flightParams", "_seekerParams"];
_args = _this select 0;
EXPLODE_7_PVT((_args select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_launchParams = _args select 1;
_targetLaunchParams = _launchParams select 1;
_flightParams = _args select 2;
_seekerParams = _args select 3;
_config = configFile >> "CfgAmmo" >> _ammo >> "ACE_MissileGuidance";
if(!alive _projectile || isNull _projectile || isNull _shooter) exitWith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_seekerTargetPos = _args call FUNC(doSeekerSearch);
if(!isNil "_seekerTargetPos") then {
_profileAdjustedTargetPos = [_seekerTargetPos,_args] call FUNC(doAttackProfile);
_minDeflection = _flightParams select 0;
_maxDeflection = _flightParams select 1;
_yVec = vectorDir _projectile;
_zVec = vectorUp _projectile;
_xVec = vectorNormalized (_yVec vectorCrossProduct _zVec);
_projectilePos = getPosASL _projectile;
_targetVectorSeeker = [_projectile, [_xVec, _yVec, _zVec], _profileAdjustedTargetPos] call FUNC(translateToWeaponSpace);
_targetVector = [0,0,0] vectorFromTo _targetVectorSeeker;
TRACE_1("", _targetVectorSeeker, _targetVector);
_yaw = 0;
_pitch = 0;
if((_targetVectorSeeker select 0) < 0) then {
_yaw = - ( (_minDeflection max ((_targetVector select 0) min _maxDeflection) ) );
} else {
if((_targetVectorSeeker select 0) > 0) then {
_yaw = ( (_minDeflection max ((_targetVector select 0) min _maxDeflection) ) );
};
};
if((_targetVectorSeeker select 2) < 0) then {
_pitch = - ( (_minDeflection max ((_targetVector select 2) min _maxDeflection) ) );
} else {
if((_targetVectorSeeker select 2) > 0) then {
_pitch = ( (_minDeflection max ((_targetVector select 2) min _maxDeflection) ) );
};
};
#ifdef DEBUG_MODE_FULL
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _projectilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"];
drawLine3D [ASLtoATL _projectilePos, ASLtoATL _profileAdjustedTargetPos, [1,0,0,1]];
#endif
if(accTime > 0) then {
_outVector = [_projectile, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace);
_vectorTo = _projectilePos vectorFromTo _outVector;
_projectile setVectorDirAndUp [_vectorTo, vectorUp _projectile];
};
#ifdef DEBUG_MODE_FULL
hintSilent format["d: %1", _distanceToTarget];
#endif
};

View File

@ -1,103 +0,0 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
FUNC(guidance_DIRECT_LOAL_PFH) = {
//TRACE_1("enter", _this);
private["_args", "_shooter", "_dagr", "_curVelocity", "_targets", "_target", "_yVec", "_xVec", "_zVec", "_dagrPos", "_shooterPos", "_distanceToTarget", "_distanceToShooter", "_def"];
_args = _this select 0;
//PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_shooter = _args select 0;
_dagr = _args select 6;
_curVelocity = velocity _dagr;
if(!alive _dagr || isNull _dagr || isNull _shooter) exitWith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_targets = [_dagr, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace_laser_fnc_findLaserDesignator;
if((_targets select 0)) then {
_target = _targets select 1;
TRACE_2("Targets", _target, _targets);
_yVec = vectorDir _dagr;
_zVec = vectorUp _dagr;
_xVec = vectorNormalized (_yVec vectorCrossProduct _zVec);
_dagrPos = getPosASL _dagr;
_targetPos = getPosASL _target;
_shooterPos = getPosASL _shooter;
if((count _targetPos) > 0) then {
_distanceToTarget = _dagrPos vectorDistance _targetPos;
_distanceToShooter = _dagrPos vectorDistance _shooterPos;
_addHeight = [0,0,(_dagrPos distance _targetPos)*0.02];
#ifdef DEBUG_MODE_FULL
drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]];
#endif
_targetPos = _targetPos vectorAdd _addHeight;
_minDeflection = 0.005;
_maxDeflection = 0.15;
_targetVectorSeeker = [_dagr, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace);
_targetVector = [0,0,0] vectorFromTo _targetVectorSeeker;
TRACE_1("", _targetVectorSeeker, _targetVector);
_yaw = 0;
_pitch = 0;
if((_targetVectorSeeker select 0) < 0) then {
_yaw = - ( (_minDeflection max ((_targetVector select 0) min _maxDeflection) ) );
} else {
if((_targetVectorSeeker select 0) > 0) then {
_yaw = ( (_minDeflection max ((_targetVector select 0) min _maxDeflection) ) );
};
};
if((_targetVectorSeeker select 2) < 0) then {
_pitch = - ( (_minDeflection max ((_targetVector select 2) min _maxDeflection) ) );
} else {
if((_targetVectorSeeker select 2) > 0) then {
_pitch = ( (_minDeflection max ((_targetVector select 2) min _maxDeflection) ) );
};
};
#ifdef DEBUG_MODE_FULL
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _dagrPos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"];
drawLine3D [ASLtoATL _dagrPos, ASLtoATL _targetPos, [1,0,0,1]];
#endif
if(accTime > 0) then {
_outVector = [_dagr, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace);
_vectorTo = _dagrPos vectorFromTo _outVector;
_dagr setVectorDirAndUp [_vectorTo, vectorUp _dagr];
};
#ifdef DEBUG_MODE_FULL
hintSilent format["d: %1", _distanceToTarget];
#endif
};
};
};
FUNC(guidance_DAGR_DIRECT_LOAL) = {
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
GVAR(lastTime) = time;
[FUNC(guidance_DIRECT_LOAL_PFH), 0.1, _this] call cba_fnc_addPerFrameHandler;
};
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_fireMode = _shooter getVariable ["ACE_FIRE_SELECTION", ACE_DEFAULT_FIRE_SELECTION];
switch (_fireMode select 0) do {
// Default to FIREMODE_DIRECT_LOAL
// FIREMODE_DIRECT_LOAL
default {
LOG("Initiating DAGR FIREMODE_DIRECT_LOAL");
_this call FUNC(guidance_DAGR_DIRECT_LOAL);
};
};

View File

@ -1,38 +0,0 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
FUNC(guidance_Hellfire_LOAL_HI_PFH) = {
};
FUNC(guidance_Hellfire_LOAL_DIR_PFH) = {
};
FUNC(guidance_Hellfire_LOAL_HI) = {
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
GVAR(lastTime) = time;
[FUNC(guidance_Hellfire_LOAL_HI_PFH), 0, _this] call cba_fnc_addPerFrameHandler;
};
FUNC(guidance_Hellfire_LOAL_DIR) = {
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
GVAR(lastTime) = time;
[FUNC(guidance_Hellfire_LOAL_DIR_PFH), 0, _this] call cba_fnc_addPerFrameHandler;
};
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_fireMode = _shooter getVariable ["ACE_FIRE_SELECTION", ACE_DEFAULT_FIRE_SELECTION];
switch (_fireMode select 0) do {
// Default to FIREMODE_DIRECT_LOAL
// FIREMODE_DIRECT_LOAL
default {
LOG("Initiating Hellfire II FIREMODE_LOAL_DIR");
_this call FUNC(guidance_Hellfire_LOAL_DIR);
};
};

View File

@ -97,7 +97,7 @@ FUNC(guidance_LGB_LOAL) = {
};
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_fireMode = _shooter getVariable ["ACE_FIRE_SELECTION", ACE_DEFAULT_FIRE_SELECTION];
_fireMode = _shooter getVariable [QGVAR(attackProfile), ACE_DEFAULT_FIRE_SELECTION];
switch (_fireMode select 0) do {
// Default to FIREMODE_DIRECT_LOAL

View File

@ -4,7 +4,7 @@ TRACE_1("enter", _this);
private["_player", "_currentFireMode"];
_currentFireMode = ACE_player getVariable["ACE_FIRE_SELECTION", ACE_JAV_FIREMODE_TOP];
_currentFireMode = ACE_player getVariable["ace_missileguidance_attackProfile", ACE_JAV_FIREMODE_TOP];
if(_currentFireMode == ACE_JAV_FIREMODE_DIR) then {
_currentFireMode = ACE_JAV_FIREMODE_TOP;
@ -16,4 +16,4 @@ if(_currentFireMode == ACE_JAV_FIREMODE_DIR) then {
__JavelinIGUITop ctrlSetTextColor __ColorGray;
__JavelinIGUIDir ctrlSetTextColor __ColorGreen;
};
ACE_player setVariable["ACE_FIRE_SELECTION", _currentFireMode, false];
ACE_player setVariable["ace_missileguidance_attackProfile", _currentFireMode, false];

View File

@ -268,7 +268,7 @@ FUNC(guidance_Javelin_LOBL_DIR) = {
if(!local _shooter) exitWith { false };
if(_ammo == "M_Titan_AT") then {
_fireMode = _shooter getVariable ["ACE_FIRE_SELECTION", ACE_JAV_FIREMODE_TOP];
_fireMode = _shooter getVariable ["ace_missileguidance_attackProfile", ACE_JAV_FIREMODE_TOP];
switch (_fireMode) do {
// Default to FIREMODE_DIRECT_LOAL