2015-04-09 02:51:21 +00:00
|
|
|
#define DEBUG_MODE_FULL
|
2015-04-08 20:45:43 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
|
2015-04-08 21:51:19 +00:00
|
|
|
private["_targetPos", "_projectilePos", "_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams"];
|
|
|
|
private["_distanceToTarget", "_distanceToShooter", "_addHeight", "_returnTargetPos"];
|
2015-04-08 20:45:43 +00:00
|
|
|
_seekerTargetPos = _this select 0;
|
|
|
|
_launchParams = _this select 1;
|
|
|
|
|
|
|
|
_target = _launchParams select 0;
|
|
|
|
_targetLaunchParams = _launchParams select 1;
|
|
|
|
|
|
|
|
_shooterPos = getPosASL _shooter;
|
|
|
|
_projectilePos = getPosASL _projectile;
|
|
|
|
|
2015-04-08 21:51:19 +00:00
|
|
|
_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos;
|
|
|
|
_distanceToShooter = _projectilePos vectorDistance _shooterPos;
|
|
|
|
|
|
|
|
TRACE_2("", _distanceToTarget, _distanceToShooter);
|
|
|
|
|
2015-04-09 21:11:15 +00:00
|
|
|
// Add height depending on distance for compensate
|
2015-04-09 22:34:42 +00:00
|
|
|
_addHeight = [0,0,0];
|
|
|
|
|
|
|
|
// Always climb an arc on initial launch if we are close to the round
|
|
|
|
if( ((ASLtoATL _projectilePos) select 2) < 20 && _distanceToShooter < 50) then {
|
|
|
|
_addHeight = _addHeight vectorAdd [0,0,_distanceToTarget];
|
2015-04-09 23:31:14 +00:00
|
|
|
} else {
|
|
|
|
// If we are below the target, increase the climbing arc
|
|
|
|
if((_projectilePos select 2) < (_seekerTargetPos select 2) && _distanceToTarget > 100) then {
|
|
|
|
_addHeight = _addHeight vectorAdd [0,0, ((_seekerTargetPos select 2) - (_projectilePos select 2))];
|
|
|
|
};
|
2015-04-09 22:34:42 +00:00
|
|
|
};
|
2015-04-09 21:11:15 +00:00
|
|
|
|
2015-04-09 22:34:42 +00:00
|
|
|
// Handle arcing terminal low for high decent
|
|
|
|
if( (_projectilePos select 2) > (_seekerTargetPos select 2) && _distanceToTarget < 100) then {
|
2015-04-09 23:31:14 +00:00
|
|
|
_addHeight = _addHeight vectorDiff [0,0, ((_projectilePos select 2) - (_seekerTargetPos select 2)) * 0.5];
|
|
|
|
} else {
|
|
|
|
if((_projectilePos select 2) > (_seekerTargetPos select 2) && _distanceToTarget > 100) then {
|
|
|
|
_addHeight = _addHeight vectorAdd [0,0, _distanceToTarget*0.02];
|
|
|
|
};
|
2015-04-09 21:11:15 +00:00
|
|
|
};
|
2015-04-08 20:45:43 +00:00
|
|
|
|
2015-04-09 22:34:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
TRACE_3("", _distanceToTarget,_distanceToShooter,_addHeight);
|
|
|
|
|
|
|
|
_returnTargetPos = _seekerTargetPos vectorAdd _addHeight;
|
|
|
|
|
2015-04-08 20:45:43 +00:00
|
|
|
#ifdef DEBUG_MODE_FULL
|
2015-04-08 21:51:19 +00:00
|
|
|
drawLine3D [(ASLtoATL _returnTargetPos) vectorAdd _addHeight, ASLtoATL _returnTargetPos, [0,1,0,1]];
|
2015-04-08 20:45:43 +00:00
|
|
|
#endif
|
|
|
|
|
2015-04-08 21:51:19 +00:00
|
|
|
TRACE_1("Adjusted target position", _returnTargetPos);
|
|
|
|
_returnTargetPos;
|