Seeker integration.

This commit is contained in:
jaynus 2015-04-12 13:02:09 -07:00
parent 5251de8447
commit 2e83e56a73
4 changed files with 54 additions and 7 deletions

View File

@ -4,6 +4,7 @@ PREP(rotateVectLineGetMap);
PREP(rotateVectLine);
PREP(checkSeekerAngle);
PREP(checkLos);
PREP(fired);

View File

@ -0,0 +1,29 @@
/*
* Author: jaynus
* Returns whether the seeker object can see the target position with lineIntersect
*
* Argument:
* 0: Seeker [Object]
* 1: Target [Object]
*
* Return value:
* Boolean
*/
#include "script_component.hpp"
private["_seeker", "_seekerPos", "_target", "_targetPos", "_return", "_vectorTo", "_searchPos"];
_seeker = _this select 0;
_target = _this select 1;
_targetPos = getPosASL _target;
_seekerPos = getPosASL _seeker;
_return = true;
if(!(terrainIntersectASL [ _seekerPos, _targetPos])) then {
if(lineIntersects [_seekerPos, _targetPos, _seeker, _target]) then {
_return = false;
};
} else {
_return = false;
};
_return;

View File

@ -19,14 +19,31 @@ if(!isNil "_target") then {
_foundTargetPos = getPosASL _target;
};
TRACE_2("", _target, _foundTargetPos);
/* @TODO: This is seeker LOS and angle checks for LOAL only; LOBL does not need visual
_angleFov = _seekerParams select 0;
_angleOkay = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle);
_projectileSpeed = (vectorMagnitude velocity _projectile);
_distanceToTarget = (getPosASL _projectile) vectorDistance _foundTargetPos;
_losOkay = false;
if(_angleOkay) then {
_losOkay = [_projectile, _target] call FUNC(checkSeekerLos);
};
TRACE_2("", _angleOkay, _losOkay);
_eta = _distanceToTarget / _projectileSpeed;
// If we got here, it was an invalid target, just return a spot 5m in front of the missile
if(!_angleOkay || !_losOkay) then {
_foundTargetPos = _sensorPos vectorAdd ((velocity _projectile) vectorMultiply 5);
} else {
TRACE_2("", _target, _foundTargetPos);
_adjustVelocity = (velocity _target) vectorMultiply _eta;
_foundTargetPos = _foundTargetPos vectorAdd _adjustVelocity;
// @TODO: Configurable lead for seekers
_projectileSpeed = (vectorMagnitude velocity _projectile);
_distanceToTarget = (getPosASL _projectile) vectorDistance _foundTargetPos;
_eta = _distanceToTarget / _projectileSpeed;
_adjustVelocity = (velocity _target) vectorMultiply _eta;
_foundTargetPos = _foundTargetPos vectorAdd _adjustVelocity;
};
*/
_foundTargetPos;

View File

@ -1,4 +1,4 @@
#define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);