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:
@ -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())
|
||||||
|
{
|
||||||
|
if(!(options.originalMovementRules && cp->layer == ELayer::AIR) &&
|
||||||
|
!isDestinationGuardian()) // Can step into tile of guard
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(cp->layer == ELayer::SAIL)
|
if(cp->layer == ELayer::SAIL)
|
||||||
destAction = CGPathNode::DISEMBARK;
|
destAction = CGPathNode::DISEMBARK;
|
||||||
|
|
||||||
@ -418,8 +433,13 @@ bool CPathfinder::isMovementToDestPossible()
|
|||||||
|
|
||||||
|
|
||||||
if(destAction == CGPathNode::NORMAL)
|
if(destAction == CGPathNode::NORMAL)
|
||||||
|
{
|
||||||
|
if(options.originalMovementRules && isDestinationGuarded())
|
||||||
|
destAction = CGPathNode::BATTLE;
|
||||||
|
else
|
||||||
destAction = CGPathNode::VISIT;
|
destAction = CGPathNode::VISIT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(isDestinationGuarded())
|
else if(isDestinationGuarded())
|
||||||
destAction = CGPathNode::BATTLE;
|
destAction = CGPathNode::BATTLE;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user