1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00
This commit is contained in:
AlexVinS 2017-03-18 13:25:12 +03:00
parent 9bf4b2a1b0
commit 5da109ad30

View File

@ -138,7 +138,7 @@ static void giveExp(BattleResult &r)
}
}
static void SummonGuardiansHelper(std::vector<BattleHex> & output, const BattleHex & targetPosition, bool targetIsAttacker, bool targetIsTwoHex) //return hexes for summoning two hex monsters in output, target = unit to guard
static void summonGuardiansHelper(std::vector<BattleHex> & output, const BattleHex & targetPosition, bool targetIsAttacker, bool targetIsTwoHex) //return hexes for summoning two hex monsters in output, target = unit to guard
{
int x = targetPosition.getX();
int y = targetPosition.getY();
@ -5649,20 +5649,21 @@ void CGameHandler::runBattle()
auto accessibility = getAccesibility();
CreatureID creatureData = CreatureID(summonInfo->subtype);
std::vector<BattleHex> targetHexes;
bool targetIsBig = stack->getCreature()->isDoubleWide(); //target = creature to guard
const bool targetIsBig = stack->getCreature()->isDoubleWide(); //target = creature to guard
const bool guardianIsBig = creatureData.toCreature()->isDoubleWide();
/*Chosen idea for two hex units was to cover all possible surrounding hexes of target unit with as small number of stacks as possible.
For one-hex targets there are four guardians - front, back and one per side (up + down).
Two-hex targets are wider and the difference is there are two guardians per side to cover 3 hexes + extra hex in the front
Additionally, there are special cases for starting positions etc., where guardians would be outside of battlefield if spawned normally*/
if (!creatureData.toCreature()->isDoubleWide())
if (!guardianIsBig)
targetHexes = stack->getSurroundingHexes();
else
SummonGuardiansHelper(targetHexes, stack->position, stack->attackerOwned, stack->getCreature()->isDoubleWide());
summonGuardiansHelper(targetHexes, stack->position, stack->attackerOwned, targetIsBig);
for (auto hex : targetHexes)
{
if (accessibility.accessible(hex, creatureData.toCreature()->isDoubleWide(), stack->attackerOwned)) //without this multiple creatures can occupy one hex
if (accessibility.accessible(hex, guardianIsBig, stack->attackerOwned)) //without this multiple creatures can occupy one hex
{
BattleStackAdded newStack;
newStack.amount = std::max(1, (int)(stack->count * 0.01 * summonInfo->val));