mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fixed boat boarding
This commit is contained in:
@@ -1119,8 +1119,9 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
|||||||
const bool canWalkOnSea = pathfinderHelper->hasBonusOfType(BonusType::WATER_WALKING) || (h->boat && h->boat->layer == EPathfindingLayer::WATER);
|
const bool canWalkOnSea = pathfinderHelper->hasBonusOfType(BonusType::WATER_WALKING) || (h->boat && h->boat->layer == EPathfindingLayer::WATER);
|
||||||
const int cost = pathfinderHelper->getMovementCost(h->visitablePos(), hmpos, nullptr, nullptr, h->movementPointsRemaining());
|
const int cost = pathfinderHelper->getMovementCost(h->visitablePos(), hmpos, nullptr, nullptr, h->movementPointsRemaining());
|
||||||
|
|
||||||
const bool standAtObstacle = t.blocked && !t.visitable;
|
const bool movingOntoObstacle = t.blocked && !t.visitable;
|
||||||
const bool standAtWater = !h->boat && t.terType->isWater() && (objectToVisit || !objectToVisit->isCoastVisitable());
|
const bool objectCoastVisitable = objectToVisit && objectToVisit->isCoastVisitable();
|
||||||
|
const bool movingOntoWater = !h->boat && t.terType->isWater() && !objectCoastVisitable;
|
||||||
|
|
||||||
const auto complainRet = [&](const std::string & message)
|
const auto complainRet = [&](const std::string & message)
|
||||||
{
|
{
|
||||||
@@ -1144,11 +1145,11 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
|||||||
|
|
||||||
//it's a rock or blocked and not visitable tile
|
//it's a rock or blocked and not visitable tile
|
||||||
//OR hero is on land and dest is water and (there is not present only one object - boat)
|
//OR hero is on land and dest is water and (there is not present only one object - boat)
|
||||||
if (!t.terType->isPassable() || (standAtObstacle && !canFly))
|
if (!t.terType->isPassable() || (movingOntoObstacle && !canFly))
|
||||||
return complainRet("Cannot move hero, destination tile is blocked!");
|
return complainRet("Cannot move hero, destination tile is blocked!");
|
||||||
|
|
||||||
//hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
|
//hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
|
||||||
if(standAtWater && !canFly && !canWalkOnSea)
|
if(movingOntoWater && !canFly && !canWalkOnSea)
|
||||||
return complainRet("Cannot move hero, destination tile is on water!");
|
return complainRet("Cannot move hero, destination tile is on water!");
|
||||||
|
|
||||||
if(h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand() && t.blocked)
|
if(h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand() && t.blocked)
|
||||||
@@ -1294,7 +1295,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
|||||||
if(h->boat && !h->boat->onboardAssaultAllowed)
|
if(h->boat && !h->boat->onboardAssaultAllowed)
|
||||||
lookForGuards = IGNORE_GUARDS;
|
lookForGuards = IGNORE_GUARDS;
|
||||||
|
|
||||||
turnTimerHandler.setEndTurnAllowed(h->getOwner(), !standAtWater && !standAtObstacle);
|
turnTimerHandler.setEndTurnAllowed(h->getOwner(), !movingOntoWater && !movingOntoObstacle);
|
||||||
doMove(TryMoveHero::SUCCESS, lookForGuards, visitDest, LEAVING_TILE);
|
doMove(TryMoveHero::SUCCESS, lookForGuards, visitDest, LEAVING_TILE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user