ACE3/addons/missileguidance/functions/fnc_attackProfile_WIRE.sqf

64 lines
2.7 KiB
Plaintext
Raw Normal View History

SACLOS and HOT Missiles (#6708) * abc * Revert "abc" This reverts commit bcb4214bd99bba3fec692efa4dca950323da582d. * Update to current commit * Added HOT1 Missile and SACLOS/Wire guidance * Added all HOT variants. Added polish to code * Fixed bug with pylons * Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance * Replaced Wiesel FireFIST launcher with HOT Launcher * Remove debug defines * Tweak thrust * Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics * Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values * Moved wire-snapping logic to attack profile * Missile flight dynamics tweaked * Add a crosshair offset. The missile sits in this offset relative to the crosshair * Add LOS checks. Fix bug where wire-cutting didnt work. * Tweak explosive range for a kill radius of ~20m. Add fragmentation * Add AI Flags * Person in control of missile may not be the shooter * Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue * Fix bug where missile didn't go to a fake target in front of it when out of LOS * Use a better, more generic way to calculate direction camera is facing * Use ACE Macros for frag values. Get config entry with CBA * Add Wiki entry * Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance * Add CPP code tag * Fix wiki grammer error * Re-convert back to CBA_fnc_getConfigEntry * UAV Gunner support, cleanup * Fix bug where SACLOS for launcher guided weapons was off * Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-07 02:27:30 +00:00
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Attack profile: Wire guided
*
* Arguments:
* 0: Seeker Target PosASL <ARRAY>
* 1: Guidance Arg Array <ARRAY>
* 2: Attack Profile State <ARRAY>
*
* Return Value:
* Missile Aim PosASL <ARRAY>
*
* Example:
* [[1,2,3], [], []] call ace_missileguidance_fnc_attackProfile_WIRE;
SACLOS and HOT Missiles (#6708) * abc * Revert "abc" This reverts commit bcb4214bd99bba3fec692efa4dca950323da582d. * Update to current commit * Added HOT1 Missile and SACLOS/Wire guidance * Added all HOT variants. Added polish to code * Fixed bug with pylons * Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance * Replaced Wiesel FireFIST launcher with HOT Launcher * Remove debug defines * Tweak thrust * Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics * Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values * Moved wire-snapping logic to attack profile * Missile flight dynamics tweaked * Add a crosshair offset. The missile sits in this offset relative to the crosshair * Add LOS checks. Fix bug where wire-cutting didnt work. * Tweak explosive range for a kill radius of ~20m. Add fragmentation * Add AI Flags * Person in control of missile may not be the shooter * Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue * Fix bug where missile didn't go to a fake target in front of it when out of LOS * Use a better, more generic way to calculate direction camera is facing * Use ACE Macros for frag values. Get config entry with CBA * Add Wiki entry * Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance * Add CPP code tag * Fix wiki grammer error * Re-convert back to CBA_fnc_getConfigEntry * UAV Gunner support, cleanup * Fix bug where SACLOS for launcher guided weapons was off * Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-07 02:27:30 +00:00
*
* Public: No
*/
params ["_seekerTargetPos", "_args", "_attackProfileStateParams"];
_args params ["_firedEH"];
_firedEH params ["_shooter","","","","","","_projectile"];
_attackProfileStateParams params["_maxCorrectableDistance", "_wireCut", "_randomVector", "_crosshairOffset", "_seekerMaxRangeSqr", "_seekerMinRangeSqr", "_wireCutSource", "_distanceAheadOfMissile"];
SACLOS and HOT Missiles (#6708) * abc * Revert "abc" This reverts commit bcb4214bd99bba3fec692efa4dca950323da582d. * Update to current commit * Added HOT1 Missile and SACLOS/Wire guidance * Added all HOT variants. Added polish to code * Fixed bug with pylons * Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance * Replaced Wiesel FireFIST launcher with HOT Launcher * Remove debug defines * Tweak thrust * Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics * Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values * Moved wire-snapping logic to attack profile * Missile flight dynamics tweaked * Add a crosshair offset. The missile sits in this offset relative to the crosshair * Add LOS checks. Fix bug where wire-cutting didnt work. * Tweak explosive range for a kill radius of ~20m. Add fragmentation * Add AI Flags * Person in control of missile may not be the shooter * Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue * Fix bug where missile didn't go to a fake target in front of it when out of LOS * Use a better, more generic way to calculate direction camera is facing * Use ACE Macros for frag values. Get config entry with CBA * Add Wiki entry * Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance * Add CPP code tag * Fix wiki grammer error * Re-convert back to CBA_fnc_getConfigEntry * UAV Gunner support, cleanup * Fix bug where SACLOS for launcher guided weapons was off * Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-07 02:27:30 +00:00
private _projectilePos = getPosASL _projectile;
private _shooterPos = getPosASL _shooter;
SACLOS and HOT Missiles (#6708) * abc * Revert "abc" This reverts commit bcb4214bd99bba3fec692efa4dca950323da582d. * Update to current commit * Added HOT1 Missile and SACLOS/Wire guidance * Added all HOT variants. Added polish to code * Fixed bug with pylons * Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance * Replaced Wiesel FireFIST launcher with HOT Launcher * Remove debug defines * Tweak thrust * Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics * Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values * Moved wire-snapping logic to attack profile * Missile flight dynamics tweaked * Add a crosshair offset. The missile sits in this offset relative to the crosshair * Add LOS checks. Fix bug where wire-cutting didnt work. * Tweak explosive range for a kill radius of ~20m. Add fragmentation * Add AI Flags * Person in control of missile may not be the shooter * Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue * Fix bug where missile didn't go to a fake target in front of it when out of LOS * Use a better, more generic way to calculate direction camera is facing * Use ACE Macros for frag values. Get config entry with CBA * Add Wiki entry * Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance * Add CPP code tag * Fix wiki grammer error * Re-convert back to CBA_fnc_getConfigEntry * UAV Gunner support, cleanup * Fix bug where SACLOS for launcher guided weapons was off * Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-07 02:27:30 +00:00
private _shooterDir = vectorNormalized(_seekerTargetPos vectorDiff _shooterPos);
private _distanceToProjectile = _shooterPos vectorDistanceSqr _projectilePos;
if ((_distanceToProjectile > _seekerMaxRangeSqr) || { _wireCut }) exitWith {
SACLOS and HOT Missiles (#6708) * abc * Revert "abc" This reverts commit bcb4214bd99bba3fec692efa4dca950323da582d. * Update to current commit * Added HOT1 Missile and SACLOS/Wire guidance * Added all HOT variants. Added polish to code * Fixed bug with pylons * Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance * Replaced Wiesel FireFIST launcher with HOT Launcher * Remove debug defines * Tweak thrust * Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics * Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values * Moved wire-snapping logic to attack profile * Missile flight dynamics tweaked * Add a crosshair offset. The missile sits in this offset relative to the crosshair * Add LOS checks. Fix bug where wire-cutting didnt work. * Tweak explosive range for a kill radius of ~20m. Add fragmentation * Add AI Flags * Person in control of missile may not be the shooter * Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue * Fix bug where missile didn't go to a fake target in front of it when out of LOS * Use a better, more generic way to calculate direction camera is facing * Use ACE Macros for frag values. Get config entry with CBA * Add Wiki entry * Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance * Add CPP code tag * Fix wiki grammer error * Re-convert back to CBA_fnc_getConfigEntry * UAV Gunner support, cleanup * Fix bug where SACLOS for launcher guided weapons was off * Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-07 02:27:30 +00:00
// wire snap, random direction
if (_randomVector isEqualTo [0, 0, 0]) then {
_randomVector = RANDOM_VECTOR_3D vectorMultiply 300;
_attackProfileStateParams set [1, true];
_attackProfileStateParams set [2, _randomVector];
2019-11-05 18:14:33 +00:00
playSound3D ["a3\sounds_f\air\sfx\SL_rope_break.wss", objNull, false, AGLtoASL (_shooter modelToWorld _wireCutSource), 5, 1, 150];
SACLOS and HOT Missiles (#6708) * abc * Revert "abc" This reverts commit bcb4214bd99bba3fec692efa4dca950323da582d. * Update to current commit * Added HOT1 Missile and SACLOS/Wire guidance * Added all HOT variants. Added polish to code * Fixed bug with pylons * Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance * Replaced Wiesel FireFIST launcher with HOT Launcher * Remove debug defines * Tweak thrust * Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics * Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values * Moved wire-snapping logic to attack profile * Missile flight dynamics tweaked * Add a crosshair offset. The missile sits in this offset relative to the crosshair * Add LOS checks. Fix bug where wire-cutting didnt work. * Tweak explosive range for a kill radius of ~20m. Add fragmentation * Add AI Flags * Person in control of missile may not be the shooter * Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue * Fix bug where missile didn't go to a fake target in front of it when out of LOS * Use a better, more generic way to calculate direction camera is facing * Use ACE Macros for frag values. Get config entry with CBA * Add Wiki entry * Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance * Add CPP code tag * Fix wiki grammer error * Re-convert back to CBA_fnc_getConfigEntry * UAV Gunner support, cleanup * Fix bug where SACLOS for launcher guided weapons was off * Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-07 02:27:30 +00:00
};
_projectilePos vectorAdd _randomVector
};
if (_seekerTargetPos isEqualTo [0, 0, 0] || { _distanceToProjectile < _seekerMinRangeSqr }) exitWith {
SACLOS and HOT Missiles (#6708) * abc * Revert "abc" This reverts commit bcb4214bd99bba3fec692efa4dca950323da582d. * Update to current commit * Added HOT1 Missile and SACLOS/Wire guidance * Added all HOT variants. Added polish to code * Fixed bug with pylons * Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance * Replaced Wiesel FireFIST launcher with HOT Launcher * Remove debug defines * Tweak thrust * Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics * Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values * Moved wire-snapping logic to attack profile * Missile flight dynamics tweaked * Add a crosshair offset. The missile sits in this offset relative to the crosshair * Add LOS checks. Fix bug where wire-cutting didnt work. * Tweak explosive range for a kill radius of ~20m. Add fragmentation * Add AI Flags * Person in control of missile may not be the shooter * Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue * Fix bug where missile didn't go to a fake target in front of it when out of LOS * Use a better, more generic way to calculate direction camera is facing * Use ACE Macros for frag values. Get config entry with CBA * Add Wiki entry * Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance * Add CPP code tag * Fix wiki grammer error * Re-convert back to CBA_fnc_getConfigEntry * UAV Gunner support, cleanup * Fix bug where SACLOS for launcher guided weapons was off * Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-07 02:27:30 +00:00
// cut wire if its caught on terrain
/*if (lineIntersectsSurfaces [getPosASL _shooter, _projectilePos, _shooter] isNotEqualTo []) then {
SACLOS and HOT Missiles (#6708) * abc * Revert "abc" This reverts commit bcb4214bd99bba3fec692efa4dca950323da582d. * Update to current commit * Added HOT1 Missile and SACLOS/Wire guidance * Added all HOT variants. Added polish to code * Fixed bug with pylons * Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance * Replaced Wiesel FireFIST launcher with HOT Launcher * Remove debug defines * Tweak thrust * Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics * Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values * Moved wire-snapping logic to attack profile * Missile flight dynamics tweaked * Add a crosshair offset. The missile sits in this offset relative to the crosshair * Add LOS checks. Fix bug where wire-cutting didnt work. * Tweak explosive range for a kill radius of ~20m. Add fragmentation * Add AI Flags * Person in control of missile may not be the shooter * Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue * Fix bug where missile didn't go to a fake target in front of it when out of LOS * Use a better, more generic way to calculate direction camera is facing * Use ACE Macros for frag values. Get config entry with CBA * Add Wiki entry * Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance * Add CPP code tag * Fix wiki grammer error * Re-convert back to CBA_fnc_getConfigEntry * UAV Gunner support, cleanup * Fix bug where SACLOS for launcher guided weapons was off * Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-07 02:27:30 +00:00
_attackProfileStateParams set [1, true];
};*/
// return position 50m infront of projectile
_projectilePos vectorAdd (_projectile vectorModelToWorld [0, 50, 0])
};
private _relativeCorrection = _projectile vectorWorldToModel (_projectilePos vectorDiff _seekerTargetPos);
_relativeCorrection = _relativeCorrection vectorDiff _crosshairOffset;
private _magnitude = vectorMagnitude [_relativeCorrection select 0, 0, _relativeCorrection select 2];
private _fovImpulse = 1 min (_magnitude / _maxCorrectableDistance); // the simulated impulse for the missile being close to the center of the crosshair
// Adjust the impulse due to near-zero values creating wobbly missiles?
private _correction = _fovImpulse;
_relativeCorrection = (vectorNormalized _relativeCorrection) vectorMultiply _correction;
private _returnPos = _projectilePos vectorDiff (_projectile vectorModelToWorld _relativeCorrection);
_returnPos vectorAdd (_shooterDir vectorMultiply _distanceAheadOfMissile)