Added and enabled AMG for AI.

This commit is contained in:
jaynus 2015-04-14 18:25:02 -07:00
parent ef6d090238
commit ad95105508
7 changed files with 59 additions and 18 deletions

View File

@ -6,4 +6,11 @@ class ACE_Settings {
displayName = "$STR_ACE_MissileGuidance";
description = "$STR_ACE_MissileGuidance_Desc";
};
class GVAR(enabledForAI) {
value = 1;
typeName = "BOOL";
isClientSetable = 1;
displayName = "$STR_ACE_MissileGuidance_AI";
description = "$STR_ACE_MissileGuidance_AI_Desc";
};
};

View File

@ -12,6 +12,12 @@ class Extended_PostInit_EventHandlers {
class Extended_FiredBIS_EventHandlers {
class All {
ADDON = QUOTE(_this call FUNC(fired));
ADDON = QUOTE(_this call FUNC(onFired));
};
};
class Extended_IncomingMissile_EventHandlers {
class All {
ADDON = QUOTE(_this call FUNC(onIncomingMissile));
};
};

View File

@ -7,7 +7,8 @@ PREP(changeMissileDirection);
PREP(checkSeekerAngle);
PREP(checkLos);
PREP(fired);
PREP(onFired);
PREP(onIncomingMissile);
PREP(guidancePFH);
PREP(doAttackProfile);

View File

@ -2,10 +2,10 @@
#include "script_component.hpp"
// Bail if guidance is disabled
if(!GVAR(enabled)) exitWith { false };
// Bail on locality of the projectile, it should be local to us
if(!local _projectile) exitWith { false };
if(!GVAR(enabled) || {!local _projectile} ) exitWith { false };
if(!GVAR(enableForAI) && {!isPlayer _shooter} ) exitWith { false };
private["_config", "_enabled", "_target", "_seekerType", "_attackProfile"];
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
@ -20,10 +20,13 @@ _enabled = getNumber ( _config >> "enabled");
if(isNil "_enabled" || {_enabled != 1}) exitWith { false };
_target = (vehicle _shooter) getVariable [QGVAR(target), nil];
_targetPos = (vehicle _shooter) getVariable [QGVAR(targetPosition), nil];
_seekerType = (vehicle _shooter) getVariable [QGVAR(seekerType), nil];
_attackProfile = (vehicle _shooter) getVariable [QGVAR(attackProfile), nil];
_lockMode = (vehicle _shooter) getVariable [QGVAR(lockMode), nil];
_launchPos = getPosASL (vehicle _shooter);
TRACE_3("Begin guidance", _target, _seekerType, _attackProfile);
if ( isNil "_seekerType" || { ! ( _seekerType in (getArray (_config >> "seekerTypes" ) ) ) } ) then {
@ -38,21 +41,28 @@ if ( isNil "_lockMode" || { ! ( _lockMode in (getArray (_config >> "seekerLockMo
// If we didn't get a target, try to fall back on tab locking
if(isNil "_target") then {
_canUseLock = getNumber (_config >> "canVanillaLock");
if(_canUseLock > 0) then {
// @TODO: Get vanilla target
_vanillaTarget = cursorTarget;
TRACE_1("Using Vanilla Locking", _vanillaTarget);
if(!isNil "_vanillaTarget") then {
_target = _vanillaTarget;
if(!isPlayer _shooter) then {
// This was an AI shot, lets still guide it on the AI target
_target = _shooter getVariable[QGVAR(vanilla_target), nil];
TRACE_1("Detected AI Shooter!", _target);
} else {
_canUseLock = getNumber (_config >> "canVanillaLock");
if(_canUseLock > 0) then {
// @TODO: Get vanilla target
_vanillaTarget = cursorTarget;
TRACE_1("Using Vanilla Locking", _vanillaTarget);
if(!isNil "_vanillaTarget") then {
_target = _vanillaTarget;
};
};
};
};
TRACE_4("Beginning ACE guidance system",_target,_ammo,_seekerType,_attackProfile);
[FUNC(guidancePFH), 0, [_this,
[ACE_player,
[_shooter,
[_target, _targetPos, _launchPos],
_seekerType,
_attackProfile,

View File

@ -0,0 +1,7 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_3(_target,_ammo,_shooter);
if !(local (gunner _shooter) || {local _shooter}) exitWith {};
_shooter setVariable [QGVAR(vanilla_target),_target, false];

View File

@ -8,10 +8,14 @@ _launchParams = _this select 1;
_seekerParams = _launchParams select 3;
_angleFov = _seekerParams select 0;
_laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot);
_foundTargetPos = _laserResult select 0;
TRACE_1("Search", _laserResult);
if(!isNil "_target") then {
// Handle AI or moving vanilla lasers
_foundTargetPos = getPosASL _target;
} else {
_laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot);
_foundTargetPos = _laserResult select 0;
TRACE_1("Search", _laserResult);
};
if(!isNil "_foundTargetPos") then {
//_canSeeTarget = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle);

View File

@ -12,6 +12,12 @@
<Portuguese>Avançado Missile Guidance</Portuguese>
<Hungarian>Részletes rakéta irányító</Hungarian>
<Russian>Расширенный ракетой</Russian>
</Key>
<Key ID="STR_ACE_MissileGuidance_AI">
<English>Advanced Missile Guidance for AI</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_AI_Desc">
<English>Enables advanced guidance on AI units.</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_Desc">
<English>Enables advanced guidance mechanics and selection for different missiles and fire modes.</English>