2023-09-12 18:58:10 +00:00
#include "..\script_component.hpp"
2018-12-07 02:27:30 +00:00
/*
2023-08-16 23:18:01 +00:00
* Author: tcvm
2019-12-17 02:01:30 +00:00
* Attack profile: Beam guided. Exact same as wire-guided, except no wire cutting
2018-12-07 02:27:30 +00:00
*
* Arguments:
* 0: Seeker Target PosASL <ARRAY>
* 1: Guidance Arg Array <ARRAY>
* 2: Attack Profile State <ARRAY>
*
* Return Value:
* Missile Aim PosASL <ARRAY>
*
* Example:
2019-12-17 02:01:30 +00:00
* [[1,2,3], [], []] call ace_missileguidance_fnc_attackProfile_BEAM;
2018-12-07 02:27:30 +00:00
*
* Public: No
*/
params ["_seekerTargetPos", "_args", "_attackProfileStateParams"];
_args params ["_firedEH"];
_firedEH params ["_shooter","","","","","","_projectile"];
2019-12-17 02:01:30 +00:00
_attackProfileStateParams params["_maxCorrectableDistance", "_wireCut", "_randomVector", "_crosshairOffset", "_seekerMaxRangeSqr", "_seekerMinRangeSqr", "_wireCutSource", "_distanceAheadOfMissile"];
2018-12-07 02:27:30 +00:00
private _projectilePos = getPosASL _projectile;
2019-12-17 02:01:30 +00:00
private _shooterPos = getPosASL _shooter;
2018-12-07 02:27:30 +00:00
2019-12-17 02:01:30 +00:00
private _shooterDir = vectorNormalized(_seekerTargetPos vectorDiff _shooterPos);
private _distanceToProjectile = _shooterPos vectorDistanceSqr _projectilePos;
2018-12-07 02:27:30 +00:00
2019-12-17 02:01:30 +00:00
if (_distanceToProjectile > _seekerMaxRangeSqr || { _seekerTargetPos isEqualTo [0, 0, 0] } || { _distanceToProjectile < _seekerMinRangeSqr }) exitWith {
2018-12-07 02:27:30 +00:00
// 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;
2019-12-17 02:01:30 +00:00
_relativeCorrection = (vectorNormalized _relativeCorrection) vectorMultiply _correction;
private _returnPos = _projectilePos vectorDiff (_projectile vectorModelToWorld _relativeCorrection);
_returnPos vectorAdd (_shooterDir vectorMultiply _distanceAheadOfMissile)