1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-13 01:20:34 +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 x = targetPosition.getX();
int y = targetPosition.getY(); int y = targetPosition.getY();
@ -1007,7 +1007,7 @@ void CGameHandler::applyBattleEffects(BattleAttack &bat, const CStack *att, cons
bsa.healedStacks.push_back(shi); bsa.healedStacks.push_back(shi);
} }
} }
bat.bsa.push_back(bsa); //add this stack to the list of victims after drain life has been calculated bat.bsa.push_back(bsa); //add this stack to the list of victims after drain life has been calculated
//fire shield handling //fire shield handling
if (!bat.shot() && !vstd::contains(def->state, EBattleStackState::CLONED) && if (!bat.shot() && !vstd::contains(def->state, EBattleStackState::CLONED) &&
@ -5358,7 +5358,7 @@ void CGameHandler::handleAfterAttackCasting(const BattleAttack & bat)
if (getRandomGenerator().getDoubleRange(0, 1)() > chanceToTrigger) if (getRandomGenerator().getDoubleRange(0, 1)() > chanceToTrigger)
return; return;
int bonusAdditionalInfo = attacker->getBonus(Selector::type(Bonus::TRANSMUTATION))->additionalInfo; int bonusAdditionalInfo = attacker->getBonus(Selector::type(Bonus::TRANSMUTATION))->additionalInfo;
if (defender->getCreature()->idNumber == bonusAdditionalInfo || if (defender->getCreature()->idNumber == bonusAdditionalInfo ||
@ -5372,7 +5372,7 @@ void CGameHandler::handleAfterAttackCasting(const BattleAttack & bat)
resurrectInfo.creID = (CreatureID)bonusAdditionalInfo; resurrectInfo.creID = (CreatureID)bonusAdditionalInfo;
else else
resurrectInfo.creID = attacker->getCreature()->idNumber; resurrectInfo.creID = attacker->getCreature()->idNumber;
if (attacker->hasBonusOfType((Bonus::TRANSMUTATION), 0)) if (attacker->hasBonusOfType((Bonus::TRANSMUTATION), 0))
{ {
resurrectInfo.amount = std::max((defender->count * defender->MaxHealth()) / resurrectInfo.creID.toCreature()->MaxHealth(), 1u); resurrectInfo.amount = std::max((defender->count * defender->MaxHealth()) / resurrectInfo.creID.toCreature()->MaxHealth(), 1u);
@ -5649,20 +5649,21 @@ void CGameHandler::runBattle()
auto accessibility = getAccesibility(); auto accessibility = getAccesibility();
CreatureID creatureData = CreatureID(summonInfo->subtype); CreatureID creatureData = CreatureID(summonInfo->subtype);
std::vector<BattleHex> targetHexes; 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. /*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). 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 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*/ 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(); targetHexes = stack->getSurroundingHexes();
else else
SummonGuardiansHelper(targetHexes, stack->position, stack->attackerOwned, stack->getCreature()->isDoubleWide()); summonGuardiansHelper(targetHexes, stack->position, stack->attackerOwned, targetIsBig);
for (auto hex : targetHexes) 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; BattleStackAdded newStack;
newStack.amount = std::max(1, (int)(stack->count * 0.01 * summonInfo->val)); newStack.amount = std::max(1, (int)(stack->count * 0.01 * summonInfo->val));