Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaserPointer - Adds workaround to make Visible lasers work with ballistic shields #8418

Merged
merged 2 commits into from
Oct 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions addons/laserpointer/functions/fnc_drawLaserpoint.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private _p1 = _p0 vectorAdd (_v1 vectorMultiply _range);

private _pL = lineIntersectsSurfaces [_p0, _p1, _unit, vehicle _unit] select 0 select 0;

// no intersection found, quit
// no intersection found, quit (pointed to the sky or too far)
if (isNil "_pL") exitWith {};

private _distance = _p0 vectorDistance _pL;
Expand All @@ -72,12 +72,25 @@ drawLine3D [

private _camPos = positionCameraToWorld [0,0,0.2];

if (count ([_target, "FIRE"] intersect [_camPos, _pL]) > 0) exitWith {};
if (count ([_unit, "FIRE"] intersect [_camPos, _pL]) > 0) exitWith {};
// Check for blocking laser by player or external laser source (other player)
private _blocked = false;
if (_unit isEqualTo _target && {cameraView in ["INTERNAL","GUNNER"]}) then {
// Laser belongs to player: check VIEW LOD
// (it's less detailed & fallbacks to GEO if not present, but allows to draw laser mark behind bulletproof glass)
if (count ([_unit, "VIEW"] intersect [_camPos, _pL]) > 0) exitWith { _blocked = true; };
} else {
// External laser: check FIRE GEO LOD (more detailed)
if (count ([_target, "FIRE"] intersect [_camPos, _pL]) > 0) exitWith { _blocked = true; };
if (count ([_unit, "FIRE"] intersect [_camPos, _pL]) > 0) exitWith { _blocked = true; };
};

// Exit due to LOS blocked by source/player
if (_blocked) exitWith {};

// Convert _camPos to ASL
_camPos = AGLToASL _camPos;

// Check for blocking by terrain or object
if (terrainIntersectASL [_camPos, _pL2]) exitWith {};
if (lineIntersects [_camPos, _pL2]) exitWith {};

Expand Down