Skip to content

Commit a1abb24

Browse files
committed
fix weird LOS issue
big units being spotted through walls due to improper handling
1 parent 3e5507e commit a1abb24

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Battlescape/TileEngine.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,12 @@ bool TileEngine::canTargetUnit(Position *originVoxel, Tile *tile, Position *scan
552552

553553
int unitRadius = potentialUnit->getLoftemps(); //width == loft in default loftemps set
554554
int targetSize = potentialUnit->getArmor()->getSize() - 1;
555+
int xOffset = potentialUnit->getPosition().x - tile->getPosition().x;
556+
int yOffset = potentialUnit->getPosition().y - tile->getPosition().y;
555557
if (targetSize > 0)
556558
{
557559
unitRadius = 3;
558560
}
559-
560561
// vector manipulation to make scan work in view-space
561562
Position relPos = targetVoxel - *originVoxel;
562563
float normal = unitRadius/sqrt((float)(relPos.x*relPos.x + relPos.y*relPos.y));
@@ -598,8 +599,8 @@ bool TileEngine::canTargetUnit(Position *originVoxel, Tile *tile, Position *scan
598599
for (int y = 0; y <= targetSize; ++y)
599600
{
600601
//voxel of hit must be inside of scanned box
601-
if (_trajectory.at(0).x/16 == (scanVoxel->x/16) + x &&
602-
_trajectory.at(0).y/16 == (scanVoxel->y/16) + y &&
602+
if (_trajectory.at(0).x/16 == (scanVoxel->x/16) + x + xOffset &&
603+
_trajectory.at(0).y/16 == (scanVoxel->y/16) + y + yOffset &&
603604
_trajectory.at(0).z >= targetMinHeight &&
604605
_trajectory.at(0).z <= targetMaxHeight)
605606
{

0 commit comments

Comments
 (0)