Permalink
Browse files

fix melee on ramps

  • Loading branch information...
Warboy1982 committed Feb 17, 2018
1 parent 02e2b8e commit 3969f48e3b4c41a33f3e70037e0748d39b386d64
Showing with 19 additions and 4 deletions.
  1. +19 −4 src/Battlescape/TileEngine.cpp
@@ -2532,16 +2532,31 @@ int TileEngine::voxelCheck(Position voxel, BattleUnit *excludeUnit, bool exclude
BattleUnit *unit = tile->getUnit();
// sometimes there is unit on the tile below, but sticks up to this tile with his head,
// in this case we couldn't have unit standing at current tile.
if (unit == 0 && tile->hasNoFloor(0))
if (unit == 0 && tile->hasNoFloor(tileBelow))
{
if (tileBelow) unit = tileBelow->getUnit();
if (tileBelow)
{
tile = tileBelow;
unit = tile->getUnit();
}
}
if (unit != 0 && unit != excludeUnit && (!excludeAllBut || unit == excludeAllBut) && (!onlyVisible || unit->getVisible() ) )
{
Position tilepos;
Position unitpos = unit->getPosition();
int tz = unitpos.z*24 + unit->getFloatHeight()+(-tile->getTerrainLevel());//bottom
int terrainHeight = 0;
for (int x = 0; x < unit->getArmor()->getSize(); ++x)
{
for (int y = 0; y < unit->getArmor()->getSize(); ++y)
{
Tile *tempTile = _save->getTile(unitpos + Position(x,y,0));
if (tempTile->getTerrainLevel() < terrainHeight)
{
terrainHeight = tempTile->getTerrainLevel();
}
}
}
int tz = unitpos.z*24 + unit->getFloatHeight() - terrainHeight; //bottom most voxel, terrain heights are negative, so we subtract.
if ((voxel.z > tz) && (voxel.z <= tz + unit->getHeight()) )
{
int x = voxel.x%16;

0 comments on commit 3969f48

Please sign in to comment.