AlexVinS 8 年之前
父節點
當前提交
5da109ad30
共有 1 個文件被更改,包括 10 次插入9 次删除
  1. 10 9
      server/CGameHandler.cpp

+ 10 - 9
server/CGameHandler.cpp

@@ -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();
@@ -1007,7 +1007,7 @@ void CGameHandler::applyBattleEffects(BattleAttack &bat, const CStack *att, cons
 			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
 	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)
 			return;
-		
+
 		int bonusAdditionalInfo = attacker->getBonus(Selector::type(Bonus::TRANSMUTATION))->additionalInfo;
 
 		if (defender->getCreature()->idNumber == bonusAdditionalInfo ||
@@ -5372,7 +5372,7 @@ void CGameHandler::handleAfterAttackCasting(const BattleAttack & bat)
 			resurrectInfo.creID = (CreatureID)bonusAdditionalInfo;
 		else
 			resurrectInfo.creID = attacker->getCreature()->idNumber;
-		
+
 		if (attacker->hasBonusOfType((Bonus::TRANSMUTATION), 0))
 		{
 			resurrectInfo.amount = std::max((defender->count * defender->MaxHealth()) / resurrectInfo.creID.toCreature()->MaxHealth(), 1u);
@@ -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));