Skip to content

Commit

Permalink
Add workaround for ballistics shields (acemod#8418)
Browse files Browse the repository at this point in the history
  • Loading branch information
10Dozen authored and AndreasBrostrom committed Dec 3, 2021
1 parent 5971aa2 commit d559ead
Showing 1 changed file with 16 additions and 3 deletions.
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

0 comments on commit d559ead

Please sign in to comment.