mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
Fixed paths through teleport, formatting cleanup
This commit is contained in:
@ -1236,6 +1236,9 @@ void CPlayerInterface::requestRealized( PackageApplied *pa )
|
|||||||
{
|
{
|
||||||
if(pa->packType == typeList.getTypeID<MoveHero>())
|
if(pa->packType == typeList.getTypeID<MoveHero>())
|
||||||
movementController->onMoveHeroApplied();
|
movementController->onMoveHeroApplied();
|
||||||
|
|
||||||
|
if(pa->packType == typeList.getTypeID<QueryReply>())
|
||||||
|
movementController->onQueryReplyApplied();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerInterface::showHeroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
|
void CPlayerInterface::showHeroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* CPlayerInterface.cpp, part of VCMI engine
|
* HeroMovementController.cpp, part of VCMI engine
|
||||||
*
|
*
|
||||||
* Authors: listed in file AUTHORS in main folder
|
* Authors: listed in file AUTHORS in main folder
|
||||||
*
|
*
|
||||||
@ -24,27 +24,9 @@
|
|||||||
|
|
||||||
#include "../lib/pathfinder/CGPathNode.h"
|
#include "../lib/pathfinder/CGPathNode.h"
|
||||||
#include "../lib/mapObjects/CGHeroInstance.h"
|
#include "../lib/mapObjects/CGHeroInstance.h"
|
||||||
#include "../lib/mapObjects/MiscObjects.h"
|
|
||||||
#include "../lib/RoadHandler.h"
|
#include "../lib/RoadHandler.h"
|
||||||
#include "../lib/TerrainHandler.h"
|
#include "../lib/TerrainHandler.h"
|
||||||
#include "../lib/NetPacks.h"
|
#include "../lib/NetPacks.h"
|
||||||
#include "../lib/CondSh.h"
|
|
||||||
|
|
||||||
std::optional<int3> HeroMovementController::getLastTile(const CGHeroInstance * hero) const
|
|
||||||
{
|
|
||||||
if (!LOCPLINT->localState->hasPath(hero))
|
|
||||||
return std::nullopt;
|
|
||||||
|
|
||||||
return LOCPLINT->localState->getPath(hero).endPos();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<int3> HeroMovementController::getNextTile(const CGHeroInstance * hero) const
|
|
||||||
{
|
|
||||||
if (!LOCPLINT->localState->hasPath(hero))
|
|
||||||
return std::nullopt;
|
|
||||||
|
|
||||||
return LOCPLINT->localState->getPath(hero).nextNode().coord;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HeroMovementController::isHeroMovingThroughGarrison(const CGHeroInstance * hero, const CArmedInstance * garrison) const
|
bool HeroMovementController::isHeroMovingThroughGarrison(const CGHeroInstance * hero, const CArmedInstance * garrison) const
|
||||||
{
|
{
|
||||||
@ -54,7 +36,7 @@ bool HeroMovementController::isHeroMovingThroughGarrison(const CGHeroInstance *
|
|||||||
if(!LOCPLINT->localState->hasPath(hero))
|
if(!LOCPLINT->localState->hasPath(hero))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (garrison->visitableAt(*getLastTile(hero)))
|
if(garrison->visitableAt(LOCPLINT->localState->getPath(hero).lastNode().coord))
|
||||||
return false; // hero want to enter garrison, not pass through it
|
return false; // hero want to enter garrison, not pass through it
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -83,7 +65,11 @@ void HeroMovementController::onBattleStarted()
|
|||||||
|
|
||||||
void HeroMovementController::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID)
|
void HeroMovementController::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID)
|
||||||
{
|
{
|
||||||
assert(hero == currentlyMovingHero);
|
// Player entered teleporter
|
||||||
|
// Check whether hero that has entered teleporter has paths that goes through teleporter and select appropriate exit
|
||||||
|
// othervice, ask server to select one randomly by sending invalid (-1) value as answer
|
||||||
|
assert(waitingForQueryApplyReply == false);
|
||||||
|
waitingForQueryApplyReply = true;
|
||||||
|
|
||||||
if(!LOCPLINT->localState->hasPath(hero))
|
if(!LOCPLINT->localState->hasPath(hero))
|
||||||
{
|
{
|
||||||
@ -101,6 +87,8 @@ void HeroMovementController::showTeleportDialog(const CGHeroInstance * hero, Tel
|
|||||||
|
|
||||||
if(teleporter && teleporter->visitableAt(nextNode.coord))
|
if(teleporter && teleporter->visitableAt(nextNode.coord))
|
||||||
{
|
{
|
||||||
|
// Remove this node from path - it will be covered by teleportation
|
||||||
|
//LOCPLINT->localState->removeLastNode(hero);
|
||||||
LOCPLINT->cb->selectionMade(i, askID);
|
LOCPLINT->cb->selectionMade(i, askID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -113,27 +101,28 @@ void HeroMovementController::showTeleportDialog(const CGHeroInstance * hero, Tel
|
|||||||
|
|
||||||
void HeroMovementController::updatePath(const CGHeroInstance * hero, const TryMoveHero & details)
|
void HeroMovementController::updatePath(const CGHeroInstance * hero, const TryMoveHero & details)
|
||||||
{
|
{
|
||||||
|
// Once hero moved (or attempted to move) we need to update path
|
||||||
|
// to make sure that it is still valid or remove it completely if destination has been reached
|
||||||
|
|
||||||
if(hero->tempOwner != LOCPLINT->playerID)
|
if(hero->tempOwner != LOCPLINT->playerID)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!LOCPLINT->localState->hasPath(hero))
|
if(!LOCPLINT->localState->hasPath(hero))
|
||||||
return; // may happen when hero teleports
|
return; // may happen when hero teleports
|
||||||
|
|
||||||
assert(hero == currentlyMovingHero);
|
|
||||||
assert(LOCPLINT->makingTurn);
|
assert(LOCPLINT->makingTurn);
|
||||||
assert(getNextTile(hero).has_value());
|
|
||||||
|
|
||||||
bool directlyAttackingCreature = details.attackedFrom.has_value() && getLastTile(hero) == details.attackedFrom;
|
bool directlyAttackingCreature = details.attackedFrom.has_value() && LOCPLINT->localState->getPath(hero).lastNode().coord == details.attackedFrom;
|
||||||
|
|
||||||
auto desiredTarget = getNextTile(hero);
|
int3 desiredTarget = LOCPLINT->localState->getPath(hero).nextNode().coord;
|
||||||
auto actualTarget = hero->convertToVisitablePos(details.end);
|
int3 actualTarget = hero->convertToVisitablePos(details.end);
|
||||||
|
|
||||||
//don't erase path when revisiting with spacebar
|
//don't erase path when revisiting with spacebar
|
||||||
bool heroChangedTile = details.start != details.end;
|
bool heroChangedTile = details.start != details.end;
|
||||||
|
|
||||||
if (desiredTarget && heroChangedTile)
|
if(heroChangedTile)
|
||||||
{
|
{
|
||||||
if (*desiredTarget != actualTarget)
|
if(desiredTarget != actualTarget)
|
||||||
{
|
{
|
||||||
//invalidate path - movement was not along current path
|
//invalidate path - movement was not along current path
|
||||||
//possible reasons: teleport, visit of object with "blocking visit" property
|
//possible reasons: teleport, visit of object with "blocking visit" property
|
||||||
@ -152,12 +141,20 @@ void HeroMovementController::updatePath(const CGHeroInstance * hero, const TryMo
|
|||||||
|
|
||||||
void HeroMovementController::heroMoved(const CGHeroInstance * hero, const TryMoveHero & details)
|
void HeroMovementController::heroMoved(const CGHeroInstance * hero, const TryMoveHero & details)
|
||||||
{
|
{
|
||||||
|
// Server initiated movement -> start movement animation
|
||||||
|
// Note that this movement is not necessarily of owned heroes - other players movement will also pass through this method
|
||||||
|
|
||||||
if(details.result == TryMoveHero::EMBARK || details.result == TryMoveHero::DISEMBARK)
|
if(details.result == TryMoveHero::EMBARK || details.result == TryMoveHero::DISEMBARK)
|
||||||
{
|
{
|
||||||
if(hero->getRemovalSound() && hero->tempOwner == LOCPLINT->playerID)
|
if(hero->getRemovalSound() && hero->tempOwner == LOCPLINT->playerID)
|
||||||
CCS->soundh->playSound(hero->getRemovalSound().value());
|
CCS->soundh->playSound(hero->getRemovalSound().value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool directlyAttackingCreature =
|
||||||
|
details.attackedFrom.has_value() &&
|
||||||
|
LOCPLINT->localState->hasPath(hero) &&
|
||||||
|
LOCPLINT->localState->getPath(hero).lastNode().coord == details.attackedFrom;
|
||||||
|
|
||||||
std::unordered_set<int3> changedTiles {
|
std::unordered_set<int3> changedTiles {
|
||||||
hero->convertToVisitablePos(details.start),
|
hero->convertToVisitablePos(details.start),
|
||||||
hero->convertToVisitablePos(details.end)
|
hero->convertToVisitablePos(details.end)
|
||||||
@ -167,44 +164,70 @@ void HeroMovementController::heroMoved(const CGHeroInstance * hero, const TryMov
|
|||||||
|
|
||||||
updatePath(hero, details);
|
updatePath(hero, details);
|
||||||
|
|
||||||
if(details.stopMovement()) //hero failed to move
|
if(details.stopMovement())
|
||||||
{
|
{
|
||||||
if(duringMovement)
|
if(duringMovement)
|
||||||
endHeroMove(hero);
|
endHeroMove(hero);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We are in network thread
|
||||||
|
// Block netpack processing until movement animation is over
|
||||||
CGI->mh->waitForOngoingAnimations();
|
CGI->mh->waitForOngoingAnimations();
|
||||||
|
|
||||||
//move finished
|
//move finished
|
||||||
adventureInt->onHeroChanged(hero);
|
adventureInt->onHeroChanged(hero);
|
||||||
|
|
||||||
// // Hero attacked creature directly, set direction to face it.
|
// Hero attacked creature, set direction to face it.
|
||||||
// if (directlyAttackingCreature)
|
if(directlyAttackingCreature)
|
||||||
// {
|
{
|
||||||
// // Get direction to attacker.
|
// Get direction to attacker.
|
||||||
// int3 posOffset = *details.attackedFrom - details.end + int3(2, 1, 0);
|
int3 posOffset = *details.attackedFrom - details.end + int3(2, 1, 0);
|
||||||
// static const ui8 dirLookup[3][3] =
|
static const ui8 dirLookup[3][3] =
|
||||||
// {
|
{
|
||||||
// { 1, 2, 3 },
|
{ 1, 2, 3 },
|
||||||
// { 8, 0, 4 },
|
{ 8, 0, 4 },
|
||||||
// { 7, 6, 5 }
|
{ 7, 6, 5 }
|
||||||
// };
|
};
|
||||||
// // FIXME: Avoid const_cast, make moveDir mutable in some other way?
|
|
||||||
// const_cast<CGHeroInstance *>(hero)->moveDir = dirLookup[posOffset.y][posOffset.x];
|
//FIXME: better handling of this case without const_cast
|
||||||
// }
|
const_cast<CGHeroInstance *>(hero)->moveDir = dirLookup[posOffset.y][posOffset.x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeroMovementController::onQueryReplyApplied()
|
||||||
|
{
|
||||||
|
if(duringMovement)
|
||||||
|
{
|
||||||
|
// Server accepted our TeleportDialog query reply and moved hero
|
||||||
|
// Continue moving alongside our path, if any
|
||||||
|
|
||||||
|
assert(waitingForQueryApplyReply);
|
||||||
|
waitingForQueryApplyReply = false;
|
||||||
|
onMoveHeroApplied();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeroMovementController::onMoveHeroApplied()
|
void HeroMovementController::onMoveHeroApplied()
|
||||||
{
|
{
|
||||||
//check if user cancelled movement
|
// at this point, server have finished processing of hero movement request
|
||||||
|
// as well as all side effectes from movement, such as object visit or combat start
|
||||||
|
|
||||||
|
// this was request to move alongside path from player, but either another player or teleport action
|
||||||
|
if(!duringMovement)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// hero has moved onto teleporter and activated it
|
||||||
|
// in this case next movement should be done only after query reply has been acknowledged
|
||||||
|
// and hero has been moved to teleport destination
|
||||||
|
if(waitingForQueryApplyReply)
|
||||||
|
return;
|
||||||
|
|
||||||
if(GH.input().ignoreEventsUntilInput())
|
if(GH.input().ignoreEventsUntilInput())
|
||||||
stoppingMovement = true;
|
stoppingMovement = true;
|
||||||
|
|
||||||
if (duringMovement)
|
|
||||||
{
|
|
||||||
assert(currentlyMovingHero);
|
assert(currentlyMovingHero);
|
||||||
auto const * hero = currentlyMovingHero;
|
const auto * hero = currentlyMovingHero;
|
||||||
|
|
||||||
bool canMove = LOCPLINT->localState->hasPath(hero) && LOCPLINT->localState->getPath(hero).nextNode().turns == 0;
|
bool canMove = LOCPLINT->localState->hasPath(hero) && LOCPLINT->localState->getPath(hero).nextNode().turns == 0;
|
||||||
bool wantStop = stoppingMovement;
|
bool wantStop = stoppingMovement;
|
||||||
@ -223,7 +246,6 @@ void HeroMovementController::onMoveHeroApplied()
|
|||||||
moveHeroOnce(hero, LOCPLINT->localState->getPath(hero));
|
moveHeroOnce(hero, LOCPLINT->localState->getPath(hero));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void HeroMovementController::movementAbortRequested()
|
void HeroMovementController::movementAbortRequested()
|
||||||
{
|
{
|
||||||
@ -234,6 +256,7 @@ void HeroMovementController::movementAbortRequested()
|
|||||||
void HeroMovementController::endHeroMove(const CGHeroInstance * hero)
|
void HeroMovementController::endHeroMove(const CGHeroInstance * hero)
|
||||||
{
|
{
|
||||||
assert(duringMovement == true);
|
assert(duringMovement == true);
|
||||||
|
assert(currentlyMovingHero != nullptr);
|
||||||
duringMovement = false;
|
duringMovement = false;
|
||||||
stoppingMovement = false;
|
stoppingMovement = false;
|
||||||
currentlyMovingHero = nullptr;
|
currentlyMovingHero = nullptr;
|
||||||
@ -291,6 +314,7 @@ void HeroMovementController::updateMovementSound(const CGHeroInstance * h, int3
|
|||||||
|
|
||||||
void HeroMovementController::stopMovementSound()
|
void HeroMovementController::stopMovementSound()
|
||||||
{
|
{
|
||||||
|
if(currentMovementSoundChannel != -1)
|
||||||
CCS->soundh->stopSound(currentMovementSoundChannel);
|
CCS->soundh->stopSound(currentMovementSoundChannel);
|
||||||
currentMovementSoundChannel = -1;
|
currentMovementSoundChannel = -1;
|
||||||
currentMovementSoundName = AudioPath();
|
currentMovementSoundName = AudioPath();
|
||||||
@ -313,12 +337,15 @@ void HeroMovementController::movementStartRequested(const CGHeroInstance * h, co
|
|||||||
duringMovement = true;
|
duringMovement = true;
|
||||||
currentlyMovingHero = h;
|
currentlyMovingHero = h;
|
||||||
|
|
||||||
CCS->curh->show();
|
CCS->curh->hide();
|
||||||
moveHeroOnce(h, path);
|
moveHeroOnce(h, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeroMovementController::moveHeroOnce(const CGHeroInstance * h, const CGPath & path)
|
void HeroMovementController::moveHeroOnce(const CGHeroInstance * h, const CGPath & path)
|
||||||
{
|
{
|
||||||
|
// Moves hero once, sends request to server and immediately returns
|
||||||
|
// movement alongside paths will be done on receiving response from server
|
||||||
|
|
||||||
assert(duringMovement == true);
|
assert(duringMovement == true);
|
||||||
|
|
||||||
const auto & currNode = path.currNode();
|
const auto & currNode = path.currNode();
|
||||||
@ -332,6 +359,7 @@ void HeroMovementController::moveHeroOnce(const CGHeroInstance * h, const CGPath
|
|||||||
if(nextNode.isTeleportAction())
|
if(nextNode.isTeleportAction())
|
||||||
{
|
{
|
||||||
stopMovementSound();
|
stopMovementSound();
|
||||||
|
logGlobal->trace("Requesting hero teleportation to %s", nextNode.coord.toString());
|
||||||
LOCPLINT->cb->moveHero(h, nextCoord, false);
|
LOCPLINT->cb->moveHero(h, nextCoord, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* CPlayerInterface.h, part of VCMI engine
|
* HeroMovementController.h, part of VCMI engine
|
||||||
*
|
*
|
||||||
* Authors: listed in file AUTHORS in main folder
|
* Authors: listed in file AUTHORS in main folder
|
||||||
*
|
*
|
||||||
@ -32,15 +32,12 @@ class HeroMovementController
|
|||||||
/// movement was requested to be terminated, e.g. by player or due to inability to move
|
/// movement was requested to be terminated, e.g. by player or due to inability to move
|
||||||
bool stoppingMovement = false;
|
bool stoppingMovement = false;
|
||||||
|
|
||||||
|
bool waitingForQueryApplyReply = false;
|
||||||
|
|
||||||
const CGHeroInstance * currentlyMovingHero = nullptr;
|
const CGHeroInstance * currentlyMovingHero = nullptr;
|
||||||
AudioPath currentMovementSoundName;
|
AudioPath currentMovementSoundName;
|
||||||
int currentMovementSoundChannel = -1;
|
int currentMovementSoundChannel = -1;
|
||||||
|
|
||||||
/// return final node in a path, if exists
|
|
||||||
std::optional<int3> getLastTile(const CGHeroInstance * h) const;
|
|
||||||
/// return first path in a path, if exists
|
|
||||||
std::optional<int3> getNextTile(const CGHeroInstance * h) const;
|
|
||||||
|
|
||||||
bool canHeroStopAtNode(const CGPathNode & node) const;
|
bool canHeroStopAtNode(const CGPathNode & node) const;
|
||||||
|
|
||||||
void updatePath(const CGHeroInstance * hero, const TryMoveHero & details);
|
void updatePath(const CGHeroInstance * hero, const TryMoveHero & details);
|
||||||
@ -56,11 +53,16 @@ class HeroMovementController
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// const queries
|
// const queries
|
||||||
|
|
||||||
|
/// Returns true if hero should move through garrison without displaying garrison dialog
|
||||||
bool isHeroMovingThroughGarrison(const CGHeroInstance * hero, const CArmedInstance * garrison) const;
|
bool isHeroMovingThroughGarrison(const CGHeroInstance * hero, const CArmedInstance * garrison) const;
|
||||||
|
|
||||||
|
/// Returns true if there is an ongoing hero movement process
|
||||||
bool isHeroMoving() const;
|
bool isHeroMoving() const;
|
||||||
|
|
||||||
// netpack handlers
|
// netpack handlers
|
||||||
void onMoveHeroApplied();
|
void onMoveHeroApplied();
|
||||||
|
void onQueryReplyApplied();
|
||||||
void onPlayerTurnStarted();
|
void onPlayerTurnStarted();
|
||||||
void onBattleStarted();
|
void onBattleStarted();
|
||||||
void showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID);
|
void showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID);
|
||||||
|
@ -1111,29 +1111,36 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
|||||||
const bool standAtObstacle = t.blocked && !t.visitable;
|
const bool standAtObstacle = t.blocked && !t.visitable;
|
||||||
const bool standAtWater = !h->boat && t.terType->isWater() && (t.visitableObjects.empty() || !t.visitableObjects.back()->isCoastVisitable());
|
const bool standAtWater = !h->boat && t.terType->isWater() && (t.visitableObjects.empty() || !t.visitableObjects.back()->isCoastVisitable());
|
||||||
|
|
||||||
//it's a rock or blocked and not visitable tile
|
auto const complainRet = [&](const std::string & message){
|
||||||
//OR hero is on land and dest is water and (there is not present only one object - boat)
|
|
||||||
if (((!t.terType->isPassable() || (standAtObstacle && !canFly))
|
|
||||||
&& complain("Cannot move hero, destination tile is blocked!"))
|
|
||||||
|| ((standAtWater && !canFly && !canWalkOnSea) //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)
|
|
||||||
&& complain("Cannot move hero, destination tile is on water!"))
|
|
||||||
|| ((h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand() && t.blocked)
|
|
||||||
&& complain("Cannot disembark hero, tile is blocked!"))
|
|
||||||
|| ((distance(h->pos, dst) >= 1.5 && !teleporting)
|
|
||||||
&& complain("Tiles are not neighboring!"))
|
|
||||||
|| ((h->inTownGarrison)
|
|
||||||
&& complain("Can not move garrisoned hero!"))
|
|
||||||
|| (((int)h->movementPointsRemaining() < cost && dst != h->pos && !teleporting)
|
|
||||||
&& complain("Hero doesn't have any movement points left!"))
|
|
||||||
|| ((transit && !canFly && !CGTeleport::isTeleport(t.topVisitableObj()))
|
|
||||||
&& complain("Hero cannot transit over this tile!"))
|
|
||||||
/*|| (states.checkFlag(h->tempOwner, &PlayerStatus::engagedIntoBattle)
|
|
||||||
&& complain("Cannot move hero during the battle"))*/)
|
|
||||||
{
|
|
||||||
//send info about movement failure
|
//send info about movement failure
|
||||||
|
complain(message);
|
||||||
sendAndApply(&tmh);
|
sendAndApply(&tmh);
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
//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)
|
||||||
|
if (!t.terType->isPassable() || (standAtObstacle && !canFly))
|
||||||
|
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)
|
||||||
|
if(standAtWater && !canFly && !canWalkOnSea)
|
||||||
|
complainRet("Cannot move hero, destination tile is on water!");
|
||||||
|
|
||||||
|
if(h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand() && t.blocked)
|
||||||
|
complainRet("Cannot disembark hero, tile is blocked!");
|
||||||
|
|
||||||
|
if(distance(h->pos, dst) >= 1.5 && !teleporting)
|
||||||
|
complainRet("Tiles are not neighboring!");
|
||||||
|
|
||||||
|
if(h->inTownGarrison)
|
||||||
|
complainRet("Can not move garrisoned hero!");
|
||||||
|
|
||||||
|
if(h->movementPointsRemaining() < cost && dst != h->pos && !teleporting)
|
||||||
|
complainRet("Hero doesn't have any movement points left!");
|
||||||
|
|
||||||
|
if (transit && !canFly && !CGTeleport::isTeleport(t.topVisitableObj()))
|
||||||
|
complainRet("Hero cannot transit over this tile!");
|
||||||
|
|
||||||
//several generic blocks of code
|
//several generic blocks of code
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user