1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-01 00:45:26 +02:00

* teleportation implemented

This commit is contained in:
mateuszb
2010-05-07 14:05:48 +00:00
parent 9c7e18e44d
commit 3c72644880
8 changed files with 95 additions and 15 deletions

View File

@ -3521,6 +3521,17 @@ si8 BattleInfo::hasDistancePenalty( int stackID, int destHex )
return distance > 8 && !stack->hasBonusOfType(Bonus::NO_DISTANCE_PENALTY);
}
si8 BattleInfo::sameSideOfWall(int pos1, int pos2)
{
int wallInStackLine = lineToWallHex(pos1/BFIELD_WIDTH);
int wallInDestLine = lineToWallHex(pos2/BFIELD_WIDTH);
bool stackLeft = pos1 < wallInStackLine;
bool destLeft = pos2 < wallInDestLine;
return stackLeft != destLeft;
}
si8 BattleInfo::hasWallPenalty( int stackID, int destHex )
{
if (siege == 0)
@ -3532,13 +3543,28 @@ si8 BattleInfo::hasWallPenalty( int stackID, int destHex )
{
return false;
}
int wallInStackLine = lineToWallHex(stack->position/BFIELD_WIDTH);
int wallInDestLine = lineToWallHex(destHex/BFIELD_WIDTH);
bool stackLeft = stack->position < wallInStackLine;
bool destLeft = destHex < wallInDestLine;
return !sameSideOfWall(stack->position, destHex);
}
si8 BattleInfo::canTeleportTo(int stackID, int destHex, int telportLevel)
{
bool ac[BFIELD_SIZE];
const CStack *s = getStack(stackID, false); //this function is called from healedOrResurrected, so our stack can be dead
std::set<int> occupyable;
getAccessibilityMap(ac, s->doubleWide(), s->attackerOwned, false, occupyable, s->hasBonusOfType(Bonus::FLYING), stackID);
if (siege && telportLevel < 2) //check for wall
{
return ac[destHex] && sameSideOfWall(s->position, destHex);
}
else
{
return ac[destHex];
}
return stackLeft != destLeft;
}
void BattleInfo::getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root /*= NULL*/) const