Apply ace_missileguidance to Titan. (Direct only) This is testing the extensible framework for mod makers.

This commit is contained in:
jaynus 2015-04-08 19:51:21 -07:00
parent 5a9a8d239c
commit bbfd28586b
14 changed files with 107 additions and 310 deletions

View File

@ -51,4 +51,11 @@ class GVAR(SeekerTypes) {
functionName = QFUNC(seekerType_SALH);
};
class Optic {
name = "";
visualName = "";
description = "";
functionName = QFUNC(seekerType_Optic);
};
};

View File

@ -1,3 +1,8 @@
enum {
ACE_LOBL = 1,
ACE_LOAL = 2
};
class CfgAmmo {
class MissileBase;
@ -51,7 +56,11 @@ 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" };
defaultSeekerLockMode = "LOAL";
seekerLockModes[] = { "LOAL", "LOBL" };
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
@ -78,4 +87,45 @@ class CfgAmmo {
indirectHitRange = 4.5;
effectsMissile = "missile2";
};
// Titan
class M_Titan_AT : MissileBase {
irLock = 0;
laserLock = 0;
airLock = 0;
// Turn off arma crosshair-guidance
manualControl = 0;
// 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.25; // Maximum flap deflection for guidance
incDeflection = 0.005; // The incrmeent in which deflection adjusts.
//minDeflection = 0.005;
//maxDeflection = 0.5;
//incDeflection = 0.005;
// Guidance type for munitions
defaultSeekerType = "Optic";
seekerTypes[] = { "Optic" };
defaultSeekerLockMode = "LOBL";
seekerLockModes[] = { "LOBL" };
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 = "TOP";
attackProfiles[] = { "TOP" };
};
};
};

View File

@ -5,13 +5,13 @@ class Extended_PreInit_EventHandlers {
};
class Extended_PostInit_EventHandlers {
class ADDON {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_post_init));
};
};
class Extended_FiredBIS_EventHandlers {
class AllVehicles {
class All {
ADDON = QUOTE(_this call FUNC(fired));
};
};

View File

@ -1,3 +1,2 @@
#include "script_component.hpp"
NO_DEDICATED;

View File

@ -21,4 +21,5 @@ PREP(attackProfile_TOP);
PREP(attackprofile_PYM);
// Seeker search functions
PREP(seekerType_SALH);
PREP(seekerType_SALH);
PREP(seekerType_Optic);

View File

@ -1,4 +1,4 @@
//#define DEBUG_MODE_FULL
#define DEBUG_MODE_FULL
#include "script_component.hpp"
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);

View File

@ -10,6 +10,9 @@ if(!local _projectile) exitWith { false };
private["_config", "_enabled", "_target", "_seekerType", "_attackProfile"];
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
// Bail on not missile
if(! (_ammo isKindOf "MissileBase") ) exitWith { false };
_config = configFile >> "CfgAmmo" >> _ammo >> "ACE_MissileGuidance";
_enabled = getNumber ( _config >> "enabled");
@ -19,6 +22,8 @@ if(isNil "_enabled" || {_enabled != 1}) exitWith { false };
_target = (vehicle _shooter) getVariable [QGVAR(target), nil];
_seekerType = (vehicle _shooter) getVariable [QGVAR(seekerType), nil];
_attackProfile = (vehicle _shooter) getVariable [QGVAR(attackProfile), nil];
_lockMode = (vehicle _shooter) getVariable [QGVAR(lockMode), nil];
TRACE_3("Begin guidance", _target, _seekerType, _attackProfile);
if ( isNil "_seekerType" || { ! ( _seekerType in (getArray (_config >> "seekerTypes" ) ) ) } ) then {
@ -26,14 +31,19 @@ if ( isNil "_seekerType" || { ! ( _seekerType in (getArray (_config >> "seekerTy
};
if ( isNil "_attackProfile" || { ! ( _attackProfile in (getArray (_config >> "attackProfiles" ) ) ) } ) then {
_attackProfile = getText (_config >> "defaultAttackProfile");
};
};
if ( isNil "_lockMode" || { ! ( _lockMode in (getArray (_config >> "seekerLockModes" ) ) ) } ) then {
_lockMode = getText (_config >> "defaultSeekerLockMode");
};
TRACE_4("Beginning ACE guidance system",_target,_ammo,_seekerType,_attackProfile);
[FUNC(guidancePFH), 0.1, [_this,
[ACE_player,
[_target, _targetPos, _launchPos],
_seekerType,
_attackProfile
_attackProfile,
_lockMode
],
[
getNumber ( _config >> "minDeflection" ),

View File

@ -0,0 +1,24 @@
#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;
_target = (((_launchParams select 1) select 1) select 0);
_seekerParams = _launchParams select 3;
TRACE_1("", _this);
TRACE_1("", _launchParams);
// TODO:: Make sure the missile maintains LOS
_foundTargetPos = [0,0,0];
if(!isNil "_target") then {
_foundTargetPos = getPosASL (_target);
};
TRACE_2("", _target, _foundTargetPos);
_foundTargetPos;

View File

@ -9,10 +9,4 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_post_init));
clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit));
};
};
class Extended_FiredBIS_EventHandlers {
class CAManBase {
ADDON = QUOTE(_this call FUNC(fired));
};
};

View File

@ -1,7 +1,5 @@
#include "script_component.hpp"
PREP(fired);
PREP(translateToWeaponSpace);
PREP(translateToModelSpace);

View File

@ -5,7 +5,7 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = { "ace_main", "ace_common", "ace_laser" };
requiredAddons[] = { "ace_main", "ace_common", "ace_missileguidance" };
VERSION_CONFIG;
};
};

View File

@ -4,14 +4,14 @@ TRACE_1("enter", _this);
private["_player", "_currentFireMode"];
_currentFireMode = ACE_player getVariable["ace_missileguidance_attackProfile", ACE_JAV_FIREMODE_TOP];
if(_currentFireMode == ACE_JAV_FIREMODE_DIR) then {
_currentFireMode = ACE_JAV_FIREMODE_TOP;
_currentFireMode = ACE_player getVariable["ace_missileguidance_attackProfile", "TOP"];
if(_currentFireMode == "DIR") then {
_currentFireMode = "TOP";
__JavelinIGUITop ctrlSetTextColor __ColorGreen;
__JavelinIGUIDir ctrlSetTextColor __ColorGray;
} else {
_currentFireMode = ACE_JAV_FIREMODE_DIR;
_currentFireMode = "DIR";
__JavelinIGUITop ctrlSetTextColor __ColorGray;
__JavelinIGUIDir ctrlSetTextColor __ColorGreen;

View File

@ -1,285 +0,0 @@
//#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("Launch", _this);
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
FUNC(guidance_Javelin_LOBL_DIR_PFH) = {
TRACE_1("enter", _this);
private["_pitch", "_yaw", "_wentTerminal", "_target", "_targetPos", "_curVelocity", "_missile",
"_launchPos", "_targetStartPos", "_defPitch", "_defYaw"];
_args = _this select 0;
//PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_shooter = _args select 0;
_missile = _args select 6;
if((count _args) > 7) then {
_saveArgs = _args select 7;
_target = _saveArgs select 0;
_targetStartPos = _saveArgs select 1;
_launchPos = _saveArgs select 2;
_wentTerminal = _saveArgs select 3;
} else {
_wentTerminal = false;
_launchPos = getPosASL _shooter;
_target = ACE_player getVariable[QGVAR(currentTarget), objNull];
_targetStartPos = ACE_player getVariable[QGVAR(currentTargetPos), [0,0,0]];
};
if(!alive _missile || isNull _missile || isNull _target) exitWith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_targetPos = getPosASL _target;
_curVelocity = velocity _missile;
TRACE_4("", _target, _targetPos, _launchPos, _targetStartPos);
_addHeight = [0,0,0];
if(!isNil "_target") then {
_yVec = vectorDir _missile;
_zVec = vectorUp _missile;
_xVec = vectorNormalized (_yVec vectorCrossProduct _zVec);
_missilePos = getPosASL _missile;
// player sideChat "G!";
TRACE_4("Phase Check", _launchPos, _missilePos, _targetPos, (_missilePos distance _targetPos));
if((count _targetPos) > 0) then {
_distanceToTarget = [(_missilePos select 0), (_missilePos select 1), (_targetPos select 2)] vectorDistance _targetPos;
if( (_missilePos select 2) < (_targetPos select 2) + 60 && !_wentTerminal) then {
_addHeight = [0,0,(_targetPos select 2) + 120];
_defPitch = 0.15;
_defYaw = 0.035;
TRACE_1("Climb phase", _addHeight);
} else {
_wentTerminal = true;
_this set[2, _wentTerminal];
_defPitch = 0.15;
_defYaw = 0.035;
TRACE_1("TERMINAL", "");
};
_targetPos = _targetPos vectorAdd _addHeight;
_targetVectorSeeker = [_missile, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace);
TRACE_5("", _missile, _xVec, _yVec, _zVec, _targetPos);
_yaw = 0.0;
_pitch = 0.0;
if((_targetVectorSeeker select 0) < 0) then {
_yaw = -_defYaw;
} else {
if((_targetVectorSeeker select 0) > 0) then {
_yaw = _defYaw;
};
};
if((_targetVectorSeeker select 2) < 0) then {
_pitch = -_defPitch;
} else {
if((_targetVectorSeeker select 2) > 0) then {
_pitch = _defPitch;
};
};
TRACE_3("", _targetVectorSeeker, _pitch, _yaw);
#ifdef DEBUG_MODE_FULL
drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]];
_light = "#lightpoint" createVehicleLocal (getPos _missile);
_light setLightBrightness 1.0;
_light setLightAmbient [1.0, 0.0, 0.0];
_light setLightColor [1.0, 0.0, 0.0];
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _missilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"];
drawLine3D [ASLtoATL _missilePos, ASLtoATL _targetPos, [1,0,0,1]];
MARKERCOUNT = MARKERCOUNT + 1;
#endif
if(accTime > 0) then {
TRACE_5("", _xVec, _yVec, _zVec, _yaw, _pitch);
_outVector = [_missile, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace);
_vectorTo = _missilePos vectorFromTo _outVector;
TRACE_3("", _missile, _outVector, _vectorTo);
_missile setVectorDirAndUp [_vectorTo, vectorUp _missile];
};
#ifdef DEBUG_MODE_FULL
hintSilent format["d: %1", _distanceToTarget];
#endif
};
};
_saveArgs = [_target,_targetStartPos, _launchPos, _wentTerminal];
_args set[7, _saveArgs ];
_this set[0, _args];
};
FUNC(guidance_Javelin_LOBL_TOP_PFH) = {
TRACE_1("enter", _this);
private["_pitch", "_yaw", "_wentTerminal", "_target", "_targetPos", "_curVelocity", "_missile",
"_launchPos", "_targetStartPos", "_defPitch", "_defYaw"];
_args = _this select 0;
//PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
_shooter = _args select 0;
_missile = _args select 6;
if((count _args) > 7) then {
_saveArgs = _args select 7;
_target = _saveArgs select 0;
_targetStartPos = _saveArgs select 1;
_launchPos = _saveArgs select 2;
_wentTerminal = _saveArgs select 3;
} else {
_wentTerminal = false;
_launchPos = getPosASL _shooter;
_target = ACE_player getVariable[QGVAR(currentTarget), objNull];
_targetStartPos = ACE_player getVariable[QGVAR(currentTargetPos), [0,0,0]];
};
if(!alive _missile || isNull _missile || isNull _target) exitWith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_targetPos = getPosASL _target;
_curVelocity = velocity _missile;
TRACE_4("", _target, _targetPos, _launchPos, _targetStartPos);
_addHeight = [0,0,0];
if(!isNil "_target") then {
_yVec = vectorDir _missile;
_zVec = vectorUp _missile;
_xVec = vectorNormalized (_yVec vectorCrossProduct _zVec);
_missilePos = getPosASL _missile;
// player sideChat "G!";
TRACE_4("Phase Check", _launchPos, _missilePos, _targetPos, (_missilePos distance _targetPos));
if((count _targetPos) > 0) then {
_distanceToTarget = [(_missilePos select 0), (_missilePos select 1), (_targetPos select 2)] vectorDistance _targetPos;
if( (_missilePos select 2) < (_targetPos select 2) + 200 && !_wentTerminal) then {
_addHeight = [0,0, ( (_distanceToTarget * 2) + 400)];
_defPitch = 0.25;
_defYaw = 0.035;
TRACE_1("Climb phase", _addHeight);
} else {
_wentTerminal = true;
_this set[2, _wentTerminal];
_defPitch = 0.25;
_defYaw = 0.25;
TRACE_1("TERMINAL", "");
};
_targetPos = _targetPos vectorAdd _addHeight;
_targetVectorSeeker = [_missile, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace);
TRACE_5("", _missile, _xVec, _yVec, _zVec, _targetPos);
_yaw = 0.0;
_pitch = 0.0;
// Stop jinking on terminal final decent
if((_missilePos distance _targetPos) < 150) then {
_defPitch = 0.0015;
_defYaw = 0.0015;
};
if((_targetVectorSeeker select 0) < 0) then {
_yaw = -_defYaw;
} else {
if((_targetVectorSeeker select 0) > 0) then {
_yaw = _defYaw;
};
};
if((_targetVectorSeeker select 2) < 0) then {
_pitch = -_defPitch;
} else {
if((_targetVectorSeeker select 2) > 0) then {
_pitch = _defPitch;
};
};
TRACE_3("", _targetVectorSeeker, _pitch, _yaw);
#ifdef DEBUG_MODE_FULL
drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]];
_light = "#lightpoint" createVehicleLocal (getPos _missile);
_light setLightBrightness 1.0;
_light setLightAmbient [1.0, 0.0, 0.0];
_light setLightColor [1.0, 0.0, 0.0];
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _missilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"];
drawLine3D [ASLtoATL _missilePos, ASLtoATL _targetPos, [1,0,0,1]];
MARKERCOUNT = MARKERCOUNT + 1;
#endif
if(accTime > 0) then {
TRACE_5("", _xVec, _yVec, _zVec, _yaw, _pitch);
_outVector = [_missile, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace);
_vectorTo = _missilePos vectorFromTo _outVector;
TRACE_3("", _missile, _outVector, _vectorTo);
_missile setVectorDirAndUp [_vectorTo, vectorUp _missile];
};
#ifdef DEBUG_MODE_FULL
hintSilent format["d: %1", _distanceToTarget];
#endif
};
};
_saveArgs = [_target,_targetStartPos, _launchPos, _wentTerminal];
_args set[7, _saveArgs ];
_this set[0, _args];
};
FUNC(guidance_Javelin_LOBL_TOP) = {
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
GVAR(lastTime) = time;
[FUNC(guidance_Javelin_LOBL_TOP_PFH), 0, _this] call cba_fnc_addPerFrameHandler;
};
FUNC(guidance_Javelin_LOBL_DIR) = {
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
GVAR(lastTime) = time;
[FUNC(guidance_Javelin_LOBL_DIR_PFH), 0, _this] call cba_fnc_addPerFrameHandler;
};
if(!local _shooter) exitWith { false };
if(_ammo == "M_Titan_AT") then {
_fireMode = _shooter getVariable ["ace_missileguidance_attackProfile", ACE_JAV_FIREMODE_TOP];
switch (_fireMode) do {
// Default to FIREMODE_DIRECT_LOAL
// FIREMODE_DIRECT_LOAL
case ACE_JAV_FIREMODE_DIR: {
LOG("Initiating Javelin FIREMODE_LOBL_DIR");
_this call FUNC(guidance_Javelin_LOBL_DIR);
};
default {
LOG("Initiating Javelin FIREMODE_LOBL_TOP");
_this call FUNC(guidance_Javelin_LOBL_TOP);
};
};
};

View File

@ -68,7 +68,7 @@ if (isNull _newTarget) then {
__JavelinIGUITargetingGate ctrlShow false;
__JavelinIGUITargetingLines ctrlShow false;
ACE_player setVariable [QGVAR(currentTarget),nil, false];
ACE_player setVariable ["ace_missileguidance_target",nil, false];
// Disallow fire
//if (ACE_player ammo "Javelin" > 0 || {ACE_player ammo "ACE_Javelin_Direct" > 0}) then {ACE_player setWeaponReloadingTime //[player, "Javelin", 0.2];};
@ -91,8 +91,7 @@ if (isNull _newTarget) then {
__JavelinIGUINFOV ctrlSetTextColor __ColorNull;
__JavelinIGUITargetingConstrains ctrlShow true;
ACE_player setVariable[QGVAR(currentTarget), _currentTarget, false];
ACE_player setVariable[QGVAR(currentTargetPos), getPosASL _currentTarget, false];
ACE_player setVariable["ace_missileguidance_target", _currentTarget, false];
if(diag_tickTime > _soundTime) then {
playSound "ACE_Javelin_Locked";
@ -115,7 +114,7 @@ if (isNull _newTarget) then {
__JavelinIGUITargetingGate ctrlShow false;
__JavelinIGUITargetingLines ctrlShow false;
ACE_player setVariable [QGVAR(currentTarget),nil, false];
ACE_player setVariable ["ace_missileguidance_target",nil, false];
};
};