2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-10-12 22:35:24 +00:00
|
|
|
/*
|
|
|
|
* Author: jaynus / nou
|
|
|
|
* Attack profile: Linear (used by DAGR)
|
|
|
|
*
|
|
|
|
* 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_LIN;
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-12 22:35:24 +00:00
|
|
|
params ["_seekerTargetPos", "_args"];
|
|
|
|
_args params ["_firedEH"];
|
|
|
|
_firedEH params ["_shooter","","","","","","_projectile"];
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-11-15 02:19:24 +00:00
|
|
|
if (_seekerTargetPos isEqualTo [0,0,0]) exitWith {_seekerTargetPos};
|
|
|
|
|
2016-10-12 22:35:24 +00:00
|
|
|
private _shooterPos = getPosASL _shooter;
|
|
|
|
private _projectilePos = getPosASL _projectile;
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-12 22:35:24 +00:00
|
|
|
private _distanceToTarget = _projectilePos vectorDistance _seekerTargetPos;
|
|
|
|
private _distanceToShooter = _projectilePos vectorDistance _shooterPos;
|
|
|
|
private _distanceShooterToTarget = _shooterPos vectorDistance _seekerTargetPos;
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-12 22:35:24 +00:00
|
|
|
TRACE_2("", _distanceToTarget, _distanceToShooter);
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
// Add height depending on distance for compensate
|
2016-10-12 22:35:24 +00:00
|
|
|
private _addHeight = [0,0,0];
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
// Always climb an arc on initial launch if we are close to the round
|
2016-10-12 22:35:24 +00:00
|
|
|
if ((((ASLtoAGL _projectilePos) select 2) < 5) && {_distanceToShooter < 15}) then {
|
|
|
|
_addHeight = _addHeight vectorAdd [0,0,_distanceToTarget];
|
|
|
|
TRACE_1("climb - near shooter",_addHeight);
|
2016-05-30 16:37:03 +00:00
|
|
|
} else {
|
|
|
|
// If we are below the target, increase the climbing arc
|
2016-10-12 22:35:24 +00:00
|
|
|
if (((_projectilePos select 2) < (_seekerTargetPos select 2)) && {_distanceToTarget > 100}) then {
|
2016-05-30 16:37:03 +00:00
|
|
|
_addHeight = _addHeight vectorAdd [0,0, ((_seekerTargetPos select 2) - (_projectilePos select 2))];
|
2016-10-12 22:35:24 +00:00
|
|
|
TRACE_1("climb - below target and far",_addHeight);
|
2016-05-30 16:37:03 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-06-01 02:18:47 +00:00
|
|
|
// Projectile above target
|
2016-10-12 22:35:24 +00:00
|
|
|
if ((_projectilePos select 2) > (_seekerTargetPos select 2)) then {
|
2018-06-01 02:18:47 +00:00
|
|
|
TRACE_1("above - far",_addHeight);
|
|
|
|
_addHeight = _addHeight vectorAdd [0,0, _distanceToTarget / 50];
|
2016-05-30 16:37:03 +00:00
|
|
|
};
|
|
|
|
|
2016-10-12 22:35:24 +00:00
|
|
|
private _returnTargetPos = _seekerTargetPos vectorAdd _addHeight;
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-12 22:35:24 +00:00
|
|
|
TRACE_2("Adjusted target position",_returnTargetPos,_addHeight);
|
2016-10-08 10:55:30 +00:00
|
|
|
_returnTargetPos;
|