1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-25 00:37:24 +02:00

CPathfinder: implemented originalMovementRules option

This commit is contained in:
ArseniyShestakov
2015-11-10 21:07:27 +03:00
parent 2b6851b3d2
commit 4aaf6191a5
2 changed files with 34 additions and 7 deletions

View File

@ -32,6 +32,7 @@ CPathfinder::PathfinderOptions::PathfinderOptions()
lightweightFlyingMode = false; lightweightFlyingMode = false;
oneTurnSpecialLayersLimit = true; oneTurnSpecialLayersLimit = true;
originalMovementRules = true;
} }
CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance *_hero) CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance *_hero)
@ -304,10 +305,19 @@ bool CPathfinder::isLayerTransitionPossible() const
} }
else if(cp->layer == ELayer::AIR && dp->layer == ELayer::LAND) else if(cp->layer == ELayer::AIR && dp->layer == ELayer::LAND)
{ {
/// Hero that fly can only land on accessible tiles if(options.originalMovementRules)
if(cp->accessible != CGPathNode::ACCESSIBLE &&
dp->accessible != CGPathNode::ACCESSIBLE)
{ {
if ((cp->accessible != CGPathNode::ACCESSIBLE &&
cp->accessible != CGPathNode::VISITABLE) &&
(dp->accessible != CGPathNode::VISITABLE &&
dp->accessible != CGPathNode::ACCESSIBLE))
{
return false;
}
}
else if(cp->accessible != CGPathNode::ACCESSIBLE && dp->accessible != CGPathNode::ACCESSIBLE)
{
/// Hero that fly can only land on accessible tiles
return false; return false;
} }
} }
@ -344,9 +354,14 @@ bool CPathfinder::isMovementToDestPossible()
case ELayer::LAND: case ELayer::LAND:
if(!canMoveBetween(cp->coord, dp->coord) || dp->accessible == CGPathNode::BLOCKED) if(!canMoveBetween(cp->coord, dp->coord) || dp->accessible == CGPathNode::BLOCKED)
return false; return false;
if(isSourceGuarded() && !isDestinationGuardian()) // Can step into tile of guard if(isSourceGuarded())
return false; {
if(!(options.originalMovementRules && cp->layer == ELayer::AIR) &&
!isDestinationGuardian()) // Can step into tile of guard
{
return false;
}
}
if(cp->layer == ELayer::SAIL) if(cp->layer == ELayer::SAIL)
destAction = CGPathNode::DISEMBARK; destAction = CGPathNode::DISEMBARK;
@ -418,7 +433,12 @@ bool CPathfinder::isMovementToDestPossible()
if(destAction == CGPathNode::NORMAL) if(destAction == CGPathNode::NORMAL)
destAction = CGPathNode::VISIT; {
if(options.originalMovementRules && isDestinationGuarded())
destAction = CGPathNode::BATTLE;
else
destAction = CGPathNode::VISIT;
}
} }
else if(isDestinationGuarded()) else if(isDestinationGuarded())
destAction = CGPathNode::BATTLE; destAction = CGPathNode::BATTLE;

View File

@ -124,6 +124,13 @@ private:
/// After all this limit should benefit performance on maps with tons of water or blocked tiles. /// After all this limit should benefit performance on maps with tons of water or blocked tiles.
bool oneTurnSpecialLayersLimit; bool oneTurnSpecialLayersLimit;
/// VCMI have different movement rules to solve flaws original engine has.
/// If this option enabled you'll able to do following things in fly:
/// - Move from blocked tiles to visitable one
/// - Move from guarded tiles to blockvis tiles without being attacked
/// - Move from guarded tiles to guarded visitable tiles with being attacked after
bool originalMovementRules;
PathfinderOptions(); PathfinderOptions();
} options; } options;