2015-04-10 19:40:58 +00:00
|
|
|
//#define DEBUG_MODE_FULL
|
2015-01-11 18:24:19 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-08 15:19:19 +00:00
|
|
|
|
|
|
|
// Bail if guidance is disabled
|
2015-04-08 15:01:39 +00:00
|
|
|
// Bail on locality of the projectile, it should be local to us
|
2015-04-15 02:19:14 +00:00
|
|
|
if(GVAR(enabled) < 1 || {!local _projectile} ) exitWith { false };
|
2015-04-15 01:25:02 +00:00
|
|
|
|
2015-04-15 02:19:14 +00:00
|
|
|
if( !isPlayer _shooter && { GVAR(enabled) < 2 } ) exitWith { false };
|
2015-01-20 04:16:33 +00:00
|
|
|
|
2015-05-01 18:31:37 +00:00
|
|
|
private["_config", "_enabled", "_target", "_seekerType", "_attackProfile", "_laserCode", "_laserInfo"];
|
2015-04-18 17:53:21 +00:00
|
|
|
private["_args", "_canUseLock", "_guidingUnit", "_launchPos", "_lockMode", "_targetPos", "_vanillaTarget"];
|
|
|
|
|
2015-04-08 15:19:19 +00:00
|
|
|
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
|
2015-04-07 05:38:34 +00:00
|
|
|
|
2015-04-09 02:51:21 +00:00
|
|
|
// Bail on not missile
|
|
|
|
if(! (_ammo isKindOf "MissileBase") ) exitWith { false };
|
|
|
|
|
2015-04-14 15:24:13 +00:00
|
|
|
_config = configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON);
|
2015-04-08 15:01:39 +00:00
|
|
|
_enabled = getNumber ( _config >> "enabled");
|
2015-01-20 04:16:33 +00:00
|
|
|
|
2015-04-08 15:01:39 +00:00
|
|
|
// Bail if guidance is not enabled
|
|
|
|
if(isNil "_enabled" || {_enabled != 1}) exitWith { false };
|
2015-04-07 05:38:34 +00:00
|
|
|
|
2015-04-08 22:52:58 +00:00
|
|
|
_target = (vehicle _shooter) getVariable [QGVAR(target), nil];
|
2015-04-15 01:25:02 +00:00
|
|
|
_targetPos = (vehicle _shooter) getVariable [QGVAR(targetPosition), nil];
|
2015-04-08 22:52:58 +00:00
|
|
|
_seekerType = (vehicle _shooter) getVariable [QGVAR(seekerType), nil];
|
|
|
|
_attackProfile = (vehicle _shooter) getVariable [QGVAR(attackProfile), nil];
|
2015-04-09 02:51:21 +00:00
|
|
|
_lockMode = (vehicle _shooter) getVariable [QGVAR(lockMode), nil];
|
|
|
|
|
2015-05-01 18:31:37 +00:00
|
|
|
_laserCode = (vehicle _shooter) getVariable [EGVAR(laser,code), ACE_DEFAULT_LASER_CODE];
|
|
|
|
_laserInfo = [_laserCode, ACE_DEFAULT_LASER_WAVELENGTH, ACE_DEFAULT_LASER_WAVELENGTH];
|
|
|
|
|
2015-04-15 01:25:02 +00:00
|
|
|
_launchPos = getPosASL (vehicle _shooter);
|
|
|
|
|
2015-04-08 21:31:44 +00:00
|
|
|
TRACE_3("Begin guidance", _target, _seekerType, _attackProfile);
|
2015-04-08 15:01:39 +00:00
|
|
|
|
|
|
|
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");
|
2015-04-09 02:51:21 +00:00
|
|
|
};
|
|
|
|
if ( isNil "_lockMode" || { ! ( _lockMode in (getArray (_config >> "seekerLockModes" ) ) ) } ) then {
|
|
|
|
_lockMode = getText (_config >> "defaultSeekerLockMode");
|
|
|
|
};
|
2015-04-08 15:01:39 +00:00
|
|
|
|
2015-04-10 19:40:58 +00:00
|
|
|
// If we didn't get a target, try to fall back on tab locking
|
|
|
|
if(isNil "_target") then {
|
2015-04-15 01:25:02 +00:00
|
|
|
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");
|
2015-04-15 16:55:40 +00:00
|
|
|
// @TODO: Get vanilla target
|
2015-04-15 17:11:13 +00:00
|
|
|
if(_canUseLock > 0 || difficulty < 1) then {
|
2015-04-15 01:25:02 +00:00
|
|
|
_vanillaTarget = cursorTarget;
|
|
|
|
|
|
|
|
TRACE_1("Using Vanilla Locking", _vanillaTarget);
|
|
|
|
if(!isNil "_vanillaTarget") then {
|
|
|
|
_target = _vanillaTarget;
|
|
|
|
};
|
2015-04-10 19:40:58 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-04-08 15:01:39 +00:00
|
|
|
TRACE_4("Beginning ACE guidance system",_target,_ammo,_seekerType,_attackProfile);
|
2015-04-16 16:35:21 +00:00
|
|
|
_args = [_this,
|
|
|
|
[_shooter,
|
|
|
|
[_target, _targetPos, _launchPos],
|
|
|
|
_seekerType,
|
|
|
|
_attackProfile,
|
2015-05-01 18:31:37 +00:00
|
|
|
_lockMode,
|
|
|
|
_laserInfo
|
2015-04-16 16:35:21 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
getNumber ( _config >> "minDeflection" ),
|
|
|
|
getNumber ( _config >> "maxDeflection" ),
|
|
|
|
getNumber ( _config >> "incDeflection" )
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getNumber ( _config >> "seekerAngle" ),
|
|
|
|
getNumber ( _config >> "seekerAccuracy" ),
|
|
|
|
getNumber ( _config >> "seekerMaxRange" )
|
|
|
|
],
|
|
|
|
[ diag_tickTime, [], [] ]
|
|
|
|
];
|
|
|
|
|
|
|
|
// Hand off to the guiding unit. We just use local player so local PFH fires for now
|
|
|
|
// Laser code needs to give us a shooter for LOBL, or the seeker unit needs to be able to shift locality
|
|
|
|
// Based on its homing laser
|
|
|
|
// Lasers need to be handled in a special LOAL/LOBL case
|
2015-04-10 18:37:03 +00:00
|
|
|
|
2015-04-18 22:44:07 +00:00
|
|
|
//if(isPlayer _shooter) then {
|
|
|
|
// _guidingUnit = ACE_player;
|
|
|
|
//
|
|
|
|
// if(local _guidingUnit) then {
|
|
|
|
// [FUNC(guidancePFH), 0, _args ] call cba_fnc_addPerFrameHandler;
|
|
|
|
// } else {
|
|
|
|
// [QGVAR(handoff), [_guidingUnit, _args] ] call FUNC(doHandoff);
|
|
|
|
// };
|
|
|
|
//} else {
|
2015-04-16 16:35:21 +00:00
|
|
|
[FUNC(guidancePFH), 0, _args ] call cba_fnc_addPerFrameHandler;
|
2015-04-18 22:44:07 +00:00
|
|
|
//};
|
|
|
|
|
|
|
|
|
2015-04-10 18:37:03 +00:00
|
|
|
/* Clears locking settings
|
|
|
|
(vehicle _shooter) setVariable [QGVAR(target), nil];
|
|
|
|
(vehicle _shooter) setVariable [QGVAR(seekerType), nil];
|
|
|
|
(vehicle _shooter) setVariable [QGVAR(attackProfile), nil];
|
|
|
|
(vehicle _shooter) setVariable [QGVAR(lockMode), nil];
|
|
|
|
*/
|