1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +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;
oneTurnSpecialLayersLimit = true;
originalMovementRules = true;
}
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)
{
/// Hero that fly can only land on accessible tiles
if(cp->accessible != CGPathNode::ACCESSIBLE &&
dp->accessible != CGPathNode::ACCESSIBLE)
if(options.originalMovementRules)
{
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;
}
}
@ -344,9 +354,14 @@ bool CPathfinder::isMovementToDestPossible()
case ELayer::LAND:
if(!canMoveBetween(cp->coord, dp->coord) || dp->accessible == CGPathNode::BLOCKED)
return false;
if(isSourceGuarded() && !isDestinationGuardian()) // Can step into tile of guard
if(isSourceGuarded())
{
if(!(options.originalMovementRules && cp->layer == ELayer::AIR) &&
!isDestinationGuardian()) // Can step into tile of guard
{
return false;
}
}
if(cp->layer == ELayer::SAIL)
destAction = CGPathNode::DISEMBARK;
@ -418,8 +433,13 @@ bool CPathfinder::isMovementToDestPossible()
if(destAction == CGPathNode::NORMAL)
{
if(options.originalMovementRules && isDestinationGuarded())
destAction = CGPathNode::BATTLE;
else
destAction = CGPathNode::VISIT;
}
}
else if(isDestinationGuarded())
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.
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();
} options;