浏览代码

Merge pull request #4844 from kodobi/bugfix/fix-ballista-damage-range-display

Fix ballista damage range display
Ivan Savenko 11 月之前
父节点
当前提交
a9add59355
共有 1 个文件被更改,包括 15 次插入5 次删除
  1. 15 5
      client/windows/CCreatureWindow.cpp

+ 15 - 5
client/windows/CCreatureWindow.cpp

@@ -25,6 +25,7 @@
 #include "../windows/InfoWindows.h"
 #include "../gui/CGuiHandler.h"
 #include "../gui/Shortcut.h"
+#include "../battle/BattleInterface.h"
 
 #include "../../CCallback.h"
 #include "../../lib/ArtifactUtils.h"
@@ -525,6 +526,7 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s
 			CRClickPopup::createAndPush(parent->info->creature->getDescriptionTranslated());
 	});
 
+
 	if(parent->info->stackNode != nullptr && parent->info->commander == nullptr)
 	{
 		//normal stack, not a commander and not non-existing stack (e.g. recruitment dialog)
@@ -533,14 +535,22 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s
 
 	name = std::make_shared<CLabel>(215, 12, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, parent->info->getName());
 
+	const BattleInterface* battleInterface = LOCPLINT->battleInt.get();
+	const CStack* battleStack = parent->info->stack;
+
 	int dmgMultiply = 1;
-	if(parent->info->owner && parent->info->stackNode->hasBonusOfType(BonusType::SIEGE_WEAPON))
-		dmgMultiply += parent->info->owner->getPrimSkillLevel(PrimarySkill::ATTACK);
+	if (battleInterface && battleInterface->getBattle() != nullptr && battleStack->hasBonusOfType(BonusType::SIEGE_WEAPON))
+	{
+		// Determine the relevant hero based on the unit side
+		const auto hero = (battleStack->unitSide() == BattleSide::ATTACKER)
+			? battleInterface->attackingHeroInstance
+			: battleInterface->defendingHeroInstance;
 
+		dmgMultiply += hero->getPrimSkillLevel(PrimarySkill::ATTACK);
+	}
+		
 	icons = std::make_shared<CPicture>(ImagePath::builtin("stackWindow/icons"), 117, 32);
 
-	const CStack * battleStack = parent->info->stack;
-
 	morale = std::make_shared<MoraleLuckBox>(true, Rect(Point(321, 110), Point(42, 42) ));
 	luck = std::make_shared<MoraleLuckBox>(false,  Rect(Point(375, 110), Point(42, 42) ));
 
@@ -568,7 +578,7 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s
 
 		addStatLabel(EStat::ATTACK, parent->info->creature->getAttack(shooter), parent->info->stackNode->getAttack(shooter));
 		addStatLabel(EStat::DEFENCE, parent->info->creature->getDefense(shooter), parent->info->stackNode->getDefense(shooter));
-		addStatLabel(EStat::DAMAGE, parent->info->stackNode->getMinDamage(shooter) * dmgMultiply, parent->info->stackNode->getMaxDamage(shooter) * dmgMultiply);
+		addStatLabel(EStat::DAMAGE, parent->info->stackNode->getMinDamage(shooter), parent->info->stackNode->getMaxDamage(shooter));
 		addStatLabel(EStat::HEALTH, parent->info->creature->getMaxHealth(), parent->info->stackNode->getMaxHealth());
 		addStatLabel(EStat::SPEED, parent->info->creature->getMovementRange(), parent->info->stackNode->getMovementRange());