mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-01 00:45:26 +02:00
CPathfinder: move flying into options and add walk on sea
This commit is contained in:
@ -3417,7 +3417,6 @@ bool CPathfinder::checkDestinationTile()
|
||||
|
||||
void CPathfinder::calculatePaths()
|
||||
{
|
||||
bool flying = hero->hasBonusOfType(Bonus::FLYING_MOVEMENT);
|
||||
int maxMovePointsLand = hero->maxMovePoints(true);
|
||||
int maxMovePointsWater = hero->maxMovePoints(false);
|
||||
|
||||
@ -3457,7 +3456,7 @@ void CPathfinder::calculatePaths()
|
||||
if(!isMovementPossible())
|
||||
continue;
|
||||
|
||||
int cost = gs->getMovementCost(hero, cp->coord, dp->coord, flying, movement);
|
||||
int cost = gs->getMovementCost(hero, cp->coord, dp->coord, vstd::contains(options, EOptions::FLYING), movement);
|
||||
int remains = movement - cost;
|
||||
if(useEmbarkCost)
|
||||
{
|
||||
@ -3471,7 +3470,7 @@ void CPathfinder::calculatePaths()
|
||||
//occurs rarely, when hero with low movepoints tries to leave the road
|
||||
turnAtNextTile++;
|
||||
int moveAtNextTile = maxMovePoints(cp);
|
||||
cost = gs->getMovementCost(hero, cp->coord, dp->coord, flying, moveAtNextTile); //cost must be updated, movement points changed :(
|
||||
cost = gs->getMovementCost(hero, cp->coord, dp->coord, vstd::contains(options, EOptions::FLYING), moveAtNextTile); //cost must be updated, movement points changed :(
|
||||
remains = moveAtNextTile - cost;
|
||||
}
|
||||
|
||||
@ -3612,6 +3611,10 @@ CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance
|
||||
|
||||
initializeGraph();
|
||||
|
||||
if(hero->canFly())
|
||||
options.insert(EOptions::FLYING);
|
||||
else if(hero->canWalkOnSea())
|
||||
options.insert(EOptions::WALKING_ON_SEA);
|
||||
options.insert(EOptions::EMBARK_AND_DISEMBARK);
|
||||
options.insert(EOptions::TELEPORT_TWO_WAY);
|
||||
options.insert(EOptions::TELEPORT_ONE_WAY);
|
||||
|
@ -281,6 +281,8 @@ class CPathfinder : private CGameInfoCallback
|
||||
private:
|
||||
enum class EOptions
|
||||
{
|
||||
FLYING,
|
||||
WALKING_ON_SEA,
|
||||
EMBARK_AND_DISEMBARK,
|
||||
TELEPORT_TWO_WAY, // Two-way monoliths and Subterranean Gate
|
||||
TELEPORT_ONE_WAY, // One-way monoliths with one known exit only
|
||||
|
Reference in New Issue
Block a user