Add workaround for ballistics shields (#8418)

This commit is contained in:
10Dozen 2021-10-07 18:46:56 +03:00 committed by GitHub
parent 78f9fc964a
commit f232f84c6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
@ -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 {};