2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-05-30 16:37:03 +00:00
|
|
|
/*
|
|
|
|
* Author: jaynus
|
2019-06-05 01:20:07 +00:00
|
|
|
* Returns whether the seeker object can see the target position with checkVisibility
|
2016-05-30 16:37:03 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2016-10-12 22:35:24 +00:00
|
|
|
* 0: Seeker <OBJECT>
|
|
|
|
* 1: Target <OBJECT>
|
2019-12-30 18:29:08 +00:00
|
|
|
* 2: Whether or not to use checkVisibility to test for LOS <BOOLEAN>
|
2016-07-22 01:07:54 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2016-10-12 22:35:24 +00:00
|
|
|
* Has LOS <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
2020-04-25 06:41:45 +00:00
|
|
|
* [player, cursorTarget] call ace_missileguidance_fnc_checkLos;
|
2016-10-12 22:35:24 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2016-05-30 16:37:03 +00:00
|
|
|
*/
|
2016-07-22 01:07:54 +00:00
|
|
|
|
2019-12-30 18:29:08 +00:00
|
|
|
params ["_seeker", "_target", ["_checkVisibilityTest", true]];
|
|
|
|
|
|
|
|
// Boolean checkVisibilityTest so that if the seeker type is one that ignores smoke we revert back to raw LOS checking.
|
|
|
|
if (_checkVisibilityTest) exitWith {
|
|
|
|
private _visibility = [_seeker, "VIEW", _target] checkVisibility [getPosASL _seeker, aimPos _target];
|
|
|
|
_visibility > 0.001
|
|
|
|
};
|
|
|
|
if ((isNil "_seeker") || {isNil "_target"}) exitWith {
|
|
|
|
ERROR_2("nil",_seeker,_target);
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
|
|
|
private _targetPos = getPosASL _target;
|
|
|
|
private _targetAimPos = aimPos _target;
|
|
|
|
private _seekerPos = getPosASL _seeker;
|
|
|
|
private _return = true;
|
|
|
|
|
|
|
|
if (!((terrainIntersectASL [_seekerPos, _targetPos]) && {terrainIntersectASL [_seekerPos, _targetAimPos]})) then {
|
|
|
|
if (lineIntersects [_seekerPos, _targetPos, _seeker, _target]) then {
|
|
|
|
_return = false;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
_return = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
_return
|
2016-05-30 16:37:03 +00:00
|
|
|
|