Working configuration based guidance framework.

This commit is contained in:
jaynus 2015-04-08 13:45:43 -07:00
parent 6f9203262a
commit cf876116a9
12 changed files with 128 additions and 145 deletions

View File

@ -0,0 +1,19 @@
class GVAR(AttackProfiles) {
class LIN {
name = "";
visualName = "";
description = "";
functionName = QFUNC(attackProfile_LIN);
};
};
class GVAR(SeekerTypes) {
class SALH {
name = "";
visualName = "";
description = "";
functionName = QFUNC(seekerType_SALH);
};
};

View File

@ -6,4 +6,4 @@ class ACE_Settings {
displayName = "$STR_ACE_MissileGuidance";
description = "$STR_ACE_MissileGuidance_Desc";
};
};
};

View File

@ -48,14 +48,14 @@ class CfgAmmo {
// Guidance type for munitions
defaultSeekerType = "SALH";
seekerTypes[] = { "SALH", "LIDAR", "SARH", "Optic", "Thermal", "GPS", "SACLOS", "MCLOS", };
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" };
defaultAttackProfile = "LIN";
attackProfiles[] = { "LIN", "DIR", "MID", "HI", "TOP" };
};
};

View File

@ -12,6 +12,13 @@ PREP(guidancePFH);
PREP(doAttackProfile);
PREP(doSeekerSearch);
// Probably to be renamed
PREP(attackProfile_linear);
PREP(guidance_LGB);
// Attack Profiles
PREP(attackProfile_LIN);
//PREP(attackProfile_HI);
//PREP(attackProfile_DIR);
//PREP(attackProfile_MID);
//PREP(attackProfile_TOP);
// Seeker search functions
PREP(seekerType_SALH);

View File

@ -9,7 +9,10 @@ class CfgPatches {
VERSION_CONFIG;
};
};
#include "ACE_GuidanceConfig.hpp"
#include "ACE_Settings.hpp"
#include "CfgEventhandlers.hpp"
#include "CfgAmmo.hpp"
#include "CfgMagazines.hpp"

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"];
_seekerTargetPos = _this select 0;
_launchParams = _this select 1;
_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

@ -2,27 +2,30 @@
#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"];
private["_attackProfilePos"];
_launchParams = _this select 1;
_seekerTargetPos = _this select 0;
_launchParams = ((_this select 1) select 1);
_attackProfileName = _launchParams select 3;
_target = _launchParams select 0;
_targetLaunchParams = _launchParams select 1;
TRACE_1("Attacking profile", _attackProfileName);
_shooterPos = getPosASL _shooter;
_projectilePos = getPosASL _projectile;
_attackProfilesCfg = ( configFile >> QGVAR(AttackProfiles) );
_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos;
_distanceToShooter = _projectilePos vectorDistance _shooterPos;
_attackProfile = nil;
for [{_i=0}, {_i< (count _attackProfilesCfg) }, {_i=_i+1}] do {
_testProfile = _attackProfilesCfg select _i;
_testName = configName _testProfile;
TRACE_3("", _testName, _testProfile, _attackProfilesCfg);
if( _testName == _attackProfileName) exitWith {
_attackProfile = _attackProfilesCfg select _i;
};
};
_addHeight = [0,0,(_projectilePos distance _seekerTargetPos)*0.02];
_attackProfilePos = [0,0,0];
if(!isNil "_attackProfile") then {
_attackProfileExecCode = "_this call " + getText (_attackProfile >> "functionName");
_attackProfilePos = call compile _attackProfileExecCode;
};
_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;
_attackProfilePos;

View File

@ -1,17 +1,31 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
EXPLODE_7_PVT((_this select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
private["_targets", "_foundTargetPos", "_launchParams", "_seekerParams", "_targetLaunchParams"];
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
private["_seekerProfilePos"];
_launchParams = _this select 1;
_targetLaunchParams = _launchParams select 1;
_launchParams = ((_this select 1) select 1);
_seekerTypeName = _launchParams select 2;
_seekerParams = _this select 3;
TRACE_1("Seeker type", _seekerTypeName);
// TODO: this needs to be shootCone/findStrongestRay after testing
_targets = [_projectile, ACE_DEFAULT_LASER_CODE, (_seekerParams select 0)] call ace_laser_fnc_findLaserDesignator;
_foundTargetPos = getPosASL (_targets select 1);
_seekerTypesCfg = ( configFile >> QGVAR(SeekerTypes) );
TRACE_1("Seeker return target pos", _foundTargetPos);
_foundTargetPos;
_seekerType = nil;
for [{_i=0}, {_i< (count _seekerTypesCfg) }, {_i=_i+1}] do {
_testProfile = _seekerTypesCfg select _i;
_testName = configName _testProfile;
TRACE_3("", _testName, _testProfile, _seekerTypesCfg);
if( _testName == _seekerTypeName) exitWith {
_seekerType = _seekerTypesCfg select _i;
};
};
_seekerProfilePos = [0,0,0];
if(!isNil "_seekerType") then {
_seekerProfileExecCode = "_this call " + getText (_seekerType >> "functionName");
_seekerProfilePos = call compile _seekerProfileExecCode;
};
_seekerProfilePos;

View File

@ -16,7 +16,8 @@ if(!alive _projectile || isNull _projectile || isNull _shooter) exitWith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_seekerTargetPos = _args call FUNC(doSeekerSearch);
// TODO: placeholder for "last seek target position"
_seekerTargetPos = [ [0,0,0], _args] call FUNC(doSeekerSearch);
if(!isNil "_seekerTargetPos") then {
_profileAdjustedTargetPos = [_seekerTargetPos,_args] call FUNC(doAttackProfile);

View File

@ -1,109 +0,0 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
FUNC(guidance_LGB_LOAL_PFH) = {
//TRACE_1("enter", _this);
_args = _this select 0;
//PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_lgb = _args select 6;
_curVelocity = velocity _lgb;
if(!alive _lgb) exitWith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_targets = [_lgb, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call uo_laser_fnc_findLaserDesignator;
//TRACE_2("Targets", _target, _targets);
if((_targets select 0)) then {
_target = _targets select 1;
// player sideChat "FUCK!";
// drop ["\a3\data_f\Cl_basic","","Billboard",1,20,(getPos _lgb),[0,0,0],1,1.275,1.0,0.0,[5],[[1,0,0,1]],[0],0.0,2.0,"","",""];
_yVec = vectorDir _lgb;
_zVec = vectorUp _lgb;
_xVec = vectorNormalized (_yVec vectorCrossProduct _zVec);
_lgbPos = getPosASL _lgb;
// player sideChat "G!";
_targetPos = getPosASL _target;
if((count _targetPos) > 0) then {
// player sideChat format["f: %1", _targetPos];
_addHeight = [0,0,(_lgbPos distance _targetPos)*0.06];
// drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]];
_targetPos = _targetPos vectorAdd _addHeight;
_def = 0.0025;
_targetVectorSeeker = [_lgb, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace);
// _targetVectorSeeker = _lgb worldToModel (ASLtoATL _targetPos);
// _targetVectorSeeker = [0,0,0] vectorFromTo _targetVectorSeeker;
_yaw = 0.0;
if((_targetVectorSeeker select 0) < 0) then {
_yaw = -_def;
} else {
if((_targetVectorSeeker select 0) > 0) then {
_yaw = _def;
};
};
_pitch = 0.0;
if((_targetVectorSeeker select 2) < 0) then {
_pitch = -_def;
} else {
if((_targetVectorSeeker select 2) > 0) then {
_pitch = _def;
};
};
#ifdef DEBUG_MODE_FULL
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _lgbPos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"];
drawLine3D [ASLtoATL _lgbPos, ASLtoATL _targetPos, [1,0,0,1]];
_distance = ([getPos startPos, _lgbPos] call BIS_fnc_distance2D);
_marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _lgbPos select 2]];
_marker setMarkerTypeLocal "mil_dot";
_marker setMarkerColorLocal "ColorRed";
MARKERCOUNT = MARKERCOUNT + 1;
#endif
if(accTime > 0) then {
_outVector = [_lgb, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace);
// _outVector = _lgb modelToWorldVisual [_yaw, 1, _pitch];
// _outVector = ATLtoASL _outVector;
_vectorTo = _lgbPos vectorFromTo _outVector;
// hintSilent format["v: %1", _vectorTo];
// _lgb setVectorDir _vectorTo;
_lgb setVectorDirAndUp [_vectorTo, vectorUp _lgb];
};
#ifdef DEBUG_MODE_FULL
hintSilent format["d: %1", _lgbPos vectorDistance _targetPos];
#endif
};
};
};
FUNC(guidance_LGB_LOAL) = {
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
[FUNC(guidance_LGB_LOAL_PFH), 0, _this] call cba_fnc_addPerFrameHandler;
};
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_fireMode = _shooter getVariable [QGVAR(attackProfile), ACE_DEFAULT_FIRE_SELECTION];
switch (_fireMode select 0) do {
// Default to FIREMODE_DIRECT_LOAL
// FIREMODE_DIRECT_LOAL
default {
LOG("Initiating FIREMODE_DIRECT_LOAL");
_this call FUNC(guidance_LGB_LOAL);
};
};

View File

@ -0,0 +1,17 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
private["_targets", "_foundTargetPos", "_launchParams", "_seekerParams", "_targetLaunchParams"];
_seekerTargetPos = _this select 0;
_launchParams = _this select 1;
_seekerParams = _launchParams select 3;
// TODO: this needs to be shootCone/findStrongestRay after testing
_targets = [_projectile, ACE_DEFAULT_LASER_CODE, (_seekerParams select 0)] call ace_laser_fnc_findLaserDesignator;
_foundTargetPos = getPosASL (_targets select 1);
TRACE_1("Seeker return target pos", _foundTargetPos);
_foundTargetPos;