diff --git a/addons/dragon/CfgAmmo.hpp b/addons/dragon/CfgAmmo.hpp index 4f88b7a3f2..595433e10c 100644 --- a/addons/dragon/CfgAmmo.hpp +++ b/addons/dragon/CfgAmmo.hpp @@ -74,8 +74,6 @@ class CfgAmmo { defaultSeekerLockMode = "LOAL"; seekerLockModes[] = { "LOAL", "LOBL" }; - onFired = QEFUNC(hot,onFired); - seekLastTargetPos = 0; seekerAngle = 30; seekerAccuracy = 1; diff --git a/addons/dragon/functions/fnc_attackProfile_DRAGON.sqf b/addons/dragon/functions/fnc_attackProfile_DRAGON.sqf index faf908f27a..a9e5a14c59 100644 --- a/addons/dragon/functions/fnc_attackProfile_DRAGON.sqf +++ b/addons/dragon/functions/fnc_attackProfile_DRAGON.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" /* - * Author: Brandon (TCVM) (Code inspired by NouberNou) + * Author: Brandon (TCVM) (Code inspired by NouberNou's Dragon Guidance) * Attack profile: Dragon Guidance * * Arguments: diff --git a/addons/hot/ACE_GuidanceConfig.hpp b/addons/hot/ACE_GuidanceConfig.hpp index 81f5c69261..f129a6b558 100644 --- a/addons/hot/ACE_GuidanceConfig.hpp +++ b/addons/hot/ACE_GuidanceConfig.hpp @@ -5,6 +5,7 @@ class EGVAR(missileguidance,AttackProfiles) { description = CSTRING(missileType_Description); functionName = QFUNC(attackProfile_WIRE); + onFired = QFUNC(wire_onFired); }; }; class EGVAR(missileguidance,SeekerTypes) { @@ -14,6 +15,7 @@ class EGVAR(missileguidance,SeekerTypes) { description = CSTRING(SACLOS_Description); functionName = QFUNC(seekerType_SACLOS); + onFired = QFUNC(SACLOS_onFired); }; }; diff --git a/addons/hot/CfgAmmo.hpp b/addons/hot/CfgAmmo.hpp index 168386d47f..e591d13aff 100644 --- a/addons/hot/CfgAmmo.hpp +++ b/addons/hot/CfgAmmo.hpp @@ -70,8 +70,6 @@ class CfgAmmo { defaultSeekerLockMode = "LOAL"; seekerLockModes[] = { "LOAL", "LOBL" }; - onFired = QFUNC(onFired); - seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos] seekerAngle = 30; // Angle from the shooter's view that can track the missile seekerAccuracy = 1; // seeker accuracy multiplier diff --git a/addons/hot/XEH_PREP.hpp b/addons/hot/XEH_PREP.hpp index 5942a97017..ec59d0f41f 100644 --- a/addons/hot/XEH_PREP.hpp +++ b/addons/hot/XEH_PREP.hpp @@ -1,4 +1,5 @@ PREP(seekerType_SACLOS); PREP(attackProfile_WIRE); -PREP(onFired); +PREP(wire_onFired); +PREP(SACLOS_onFired); diff --git a/addons/hot/functions/fnc_SACLOS_onFired.sqf b/addons/hot/functions/fnc_SACLOS_onFired.sqf new file mode 100644 index 0000000000..7702b330ee --- /dev/null +++ b/addons/hot/functions/fnc_SACLOS_onFired.sqf @@ -0,0 +1,35 @@ +#include "script_component.hpp" +/* + * Author: Brandon (TCVM) + * Sets up SACLOS state arrays (called from missileGuidance's onFired). + * + * Arguments: + * Guidance Arg Array + * + * Return Value: + * None + * + * Example: + * [] call ace_hot_fnc_SACLOS_onFired + * + * Public: No + */ +params ["_firedEH", "", "", "", "_stateParams"]; +_firedEH params ["_shooter","_weapon","","","","","_projectile"]; +_stateParams params ["", "_seekerStateParams"]; + +private _config = ([_projectile] call CBA_fnc_getObjectConfig) >> "ace_missileguidance"; +private _distanceAheadOfMissile = [_config >> "missileLeadDistance", "NUMBER", DEFAULT_LEAD_DISTANCE] call CBA_fnc_getConfigEntry; + +if (_shooter isKindOf "Plane") then { WARNING("SACLOS fired from planes unsupported"); }; + +private _turretPath = [_shooter, _weapon] call CBA_fnc_turretPathWeapon; +private _turretConfig = [_shooter, _turretPath] call CBA_fnc_getTurret; +private _memoryPointGunnerOptics = getText(_turretConfig >> "memoryPointGunnerOptics"); +private _animationSourceBody = getText(_turretConfig >> "animationSourceBody"); +private _animationSourceGun = getText(_turretConfig >> "animationSourceGun"); +_seekerStateParams set [0, _memoryPointGunnerOptics]; +_seekerStateParams set [1, _animationSourceBody]; +_seekerStateParams set [2, _animationSourceGun]; +_seekerStateParams set [3, _distanceAheadOfMissile]; + diff --git a/addons/hot/functions/fnc_attackProfile_WIRE.sqf b/addons/hot/functions/fnc_attackProfile_WIRE.sqf index 8aef8a702b..139939e4f7 100644 --- a/addons/hot/functions/fnc_attackProfile_WIRE.sqf +++ b/addons/hot/functions/fnc_attackProfile_WIRE.sqf @@ -19,7 +19,7 @@ params ["_seekerTargetPos", "_args", "_attackProfileStateParams"]; _args params ["_firedEH"]; _firedEH params ["_shooter","","","","","","_projectile"]; -_attackProfileStateParams params["_maxCorrectableDistance", "_wireCut", "_randomVector", "_crosshairOffset", "_seekerMaxRangeSqr", "_wireCutSource"]; +_attackProfileStateParams params["_maxCorrectableDistance", "_wireCut", "_randomVector", "_crosshairOffset", "_seekerMaxRangeSqr", "", "_wireCutSource"]; private _projectilePos = getPosASL _projectile; diff --git a/addons/hot/functions/fnc_wire_onFired.sqf b/addons/hot/functions/fnc_wire_onFired.sqf new file mode 100644 index 0000000000..1eb30a14c6 --- /dev/null +++ b/addons/hot/functions/fnc_wire_onFired.sqf @@ -0,0 +1,45 @@ +#include "script_component.hpp" +/* + * Author: Brandon (TCVM) + * Sets up wireGuided state arrays (called from missileGuidance's onFired). + * + * Arguments: + * Guidance Arg Array + * + * Return Value: + * None + * + * Example: + * [] call ace_hot_fnc_wire_onFired + * + * Public: No + */ +params ["_firedEH", "", "", "_seekerParams", "_stateParams"]; +_firedEH params ["_shooter","_weapon","","","","","_projectile", "_gunner"]; +_stateParams params ["", "", "_attackProfileStateParams"]; +_seekerParams params ["", "", "_seekerMaxRange", "_seekerMinRange"]; + +private _config = ([_projectile] call CBA_fnc_getObjectConfig) >> "ace_missileguidance"; +private _maxCorrectableDistance = [_config >> "correctionDistance", "NUMBER", DEFAULT_CORRECTION_DISTANCE] call CBA_fnc_getConfigEntry; +private _crosshairOffset = [_config >> "offsetFromCrosshair", "ARRAY", [0, 0, 0]] call CBA_fnc_getConfigEntry; +private _maxDistanceSqr = _seekerMaxRange * _seekerMaxRange; +private _minDistanceSqr = _seekerMinRange * _seekerMinRange; + +// AI don't know how to use the crosshair offset becauze they dum dum +if ((_gunner != ACE_PLAYER) && {_gunner != (ACE_controlledUAV select 1)}) then { + _crosshairOffset = [0, 0, 0]; +}; + +private _turretPath = [_shooter, _weapon] call CBA_fnc_turretPathWeapon; +private _turretConfig = [_shooter, _turretPath] call CBA_fnc_getTurret; + +private _wireCutSource = _shooter selectionPosition getText(_turretConfig >> "missileEnd"); + +_attackProfileStateParams set [0, _maxCorrectableDistance]; +_attackProfileStateParams set [1, false]; // _wireCut +_attackProfileStateParams set [2, [0, 0, 0]]; // _randomVector +_attackProfileStateParams set [3, _crosshairOffset]; // crosshair offset +_attackProfileStateParams set [4, _maxDistanceSqr]; // max distance squared used for wire cut +_attackProfileStateParams set [5, _minDistanceSqr]; +_attackProfileStateParams set [6, _wireCutSource]; + diff --git a/addons/missileguidance/functions/fnc_onFired.sqf b/addons/missileguidance/functions/fnc_onFired.sqf index eb4d2051cf..35109ef73a 100644 --- a/addons/missileguidance/functions/fnc_onFired.sqf +++ b/addons/missileguidance/functions/fnc_onFired.sqf @@ -109,19 +109,31 @@ private _args = [_this, [ getNumber ( _config >> "seekerAngle" ), getNumber ( _config >> "seekerAccuracy" ), - getNumber ( _config >> "seekerMaxRange" ) + getNumber ( _config >> "seekerMaxRange" ), + getNumber ( _config >> "seekerMinRange" ) ], [ diag_tickTime, [], [], _lastKnownPosState] ]; -// Run the "onFired" function passing the full guidance args array -private _onFiredFunc = getText (_config >> "onFired"); +private _onFiredFunc = getText (configFile >> QGVAR(AttackProfiles) >> _attackProfile >> "onFired"); +TRACE_1("",_onFiredFunc); +if (_onFiredFunc != "") then { + _args call (missionNamespace getVariable _onFiredFunc); +}; + +_onFiredFunc = getText (configFile >> QGVAR(SeekerTypes) >> _seekerType >> "onFired"); TRACE_1("",_onFiredFunc); if (_onFiredFunc != "") then { _args call (missionNamespace getVariable _onFiredFunc); }; +// Run the "onFired" function passing the full guidance args array +_onFiredFunc = getText (_config >> "onFired"); +TRACE_1("",_onFiredFunc); +if (_onFiredFunc != "") then { + _args call (missionNamespace getVariable _onFiredFunc); +}; // Reverse: // _args params ["_firedEH", "_launchParams", "_flightParams", "_seekerParams", "_stateParams"];