2015-04-14 16:36:39 +00:00
|
|
|
//#define DEBUG_MODE_FULL
|
2015-04-08 20:57:08 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-04-13 22:34:51 +00:00
|
|
|
#define STAGE_LAUNCH 1
|
|
|
|
#define STAGE_CLIMB 2
|
|
|
|
#define STAGE_COAST 3
|
|
|
|
#define STAGE_TERMINAL 4
|
|
|
|
|
2015-04-10 17:14:30 +00:00
|
|
|
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
|
|
|
|
private["_targetPos", "_projectilePos", "_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams"];
|
2015-04-13 16:56:15 +00:00
|
|
|
private["_distanceToTarget", "_distanceToShooter", "_addHeight", "_returnTargetPos", "_state"];
|
2015-04-10 17:14:30 +00:00
|
|
|
_seekerTargetPos = _this select 0;
|
|
|
|
_launchParams = _this select 1;
|
|
|
|
|
|
|
|
_target = _launchParams select 0;
|
|
|
|
_targetLaunchParams = _launchParams select 1;
|
|
|
|
|
2015-04-13 16:56:15 +00:00
|
|
|
_state = _this select 2;
|
2015-04-13 22:34:51 +00:00
|
|
|
if( (count _state) < 1) then {
|
|
|
|
_state set[0, STAGE_LAUNCH];
|
|
|
|
};
|
2015-04-13 16:56:15 +00:00
|
|
|
|
2015-04-10 17:14:30 +00:00
|
|
|
_shooterPos = getPosASL _shooter;
|
|
|
|
_projectilePos = getPosASL _projectile;
|
|
|
|
|
|
|
|
_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos;
|
|
|
|
_distanceToShooter = _projectilePos vectorDistance _shooterPos;
|
2015-04-13 22:34:51 +00:00
|
|
|
_distanceShooterToTarget = _shooterPos vectorDistance _seekerTargetPos;
|
2015-04-10 17:14:30 +00:00
|
|
|
|
|
|
|
TRACE_2("", _distanceToTarget, _distanceToShooter);
|
|
|
|
|
|
|
|
// Add height depending on distance for compensate
|
2015-04-13 22:34:51 +00:00
|
|
|
_returnTargetPos = _seekerTargetPos;
|
2015-04-10 17:14:30 +00:00
|
|
|
|
2015-04-13 22:34:51 +00:00
|
|
|
switch( (_state select 0) ) do {
|
|
|
|
case STAGE_LAUNCH: {
|
|
|
|
TRACE_1("STAGE_LAUNCH","");
|
|
|
|
if(_distanceToShooter < 10) then {
|
|
|
|
_returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*2];
|
|
|
|
} else {
|
|
|
|
_state set[0, STAGE_CLIMB];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
case STAGE_CLIMB: {
|
|
|
|
TRACE_1("STAGE_CLIMB","");
|
|
|
|
_cruisAlt = 140;
|
|
|
|
if(_distanceShooterToTarget < 1250) then {
|
|
|
|
_cruisAlt = 140 * (_distanceShooterToTarget/1250);
|
|
|
|
TRACE_1("_cruisAlt", _cruisAlt);
|
|
|
|
};
|
|
|
|
if( ((ASLToATL _projectilePos) select 2) - ((ASLToATL _seekerTargetPos) select 2) >= _cruisAlt) then {
|
2015-04-15 19:09:47 +00:00
|
|
|
if(_cruisAlt < 140) then {
|
|
|
|
_state set[0, STAGE_TERMINAL];
|
|
|
|
} else {
|
|
|
|
_state set[0, STAGE_COAST];
|
|
|
|
};
|
2015-04-13 22:34:51 +00:00
|
|
|
} else {
|
2015-04-15 19:25:57 +00:00
|
|
|
_returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*1.5];
|
2015-04-13 22:34:51 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
case STAGE_COAST: {
|
|
|
|
TRACE_1("STAGE_COAST","");
|
2015-04-15 01:18:27 +00:00
|
|
|
TRACE_1("", ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) );
|
2015-04-15 16:10:00 +00:00
|
|
|
if(_distanceToTarget < ( ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ) * 1.5) then {
|
2015-04-13 22:34:51 +00:00
|
|
|
_state set[0, STAGE_TERMINAL];
|
2015-04-15 16:10:00 +00:00
|
|
|
} else {
|
|
|
|
_returnTargetPos = _seekerTargetPos vectorAdd [0,0,(_projectilePos select 2)];
|
2015-04-13 22:34:51 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
case STAGE_TERMINAL: {
|
|
|
|
TRACE_1("STAGE_TERMINAL","");
|
2015-04-14 16:36:39 +00:00
|
|
|
//_returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget * 0.02];
|
2015-04-15 19:25:57 +00:00
|
|
|
_returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget * 0.002];
|
2015-04-13 22:34:51 +00:00
|
|
|
};
|
|
|
|
};
|
2015-04-10 17:14:30 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
2015-04-13 22:34:51 +00:00
|
|
|
drawLine3D [(ASLtoATL _returnTargetPos), (ASLtoATL _seekerTargetPos), [0,1,0,1]];
|
2015-04-10 17:14:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
TRACE_1("Adjusted target position", _returnTargetPos);
|
|
|
|
_returnTargetPos;
|