From 1f70f27b2d4a718d87f0febd3efbbde3fcfcbc14 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 11 Apr 2025 18:01:49 +0300 Subject: [PATCH] Fix hypnotize spell - Fix testing for Hypnotized status - Fix handling of three-headed & all-around attack (Cerberi / Hydras) while hypnotized --- lib/battle/CBattleInfoCallback.cpp | 6 +++--- lib/battle/CUnitState.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index 87fb42f4d..531b7d4ae 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -325,7 +325,7 @@ BattleHexArray CBattleInfoCallback::battleGetAttackedHexes(const battle::Unit * for (const BattleHex & tile : at.hostileCreaturePositions) { const auto * st = battleGetUnitByPos(tile, true); - if(st && st->unitOwner() != attacker->unitOwner()) //only hostile stacks - does it work well with Berserk? + if(st && battleGetOwner(st) != battleGetOwner(attacker)) //only hostile stacks - does it work well with Berserk? { attackedHexes.insert(tile); } @@ -1347,7 +1347,7 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes( if((BattleHex::mutualPosition(tile, destinationTile) > -1 && BattleHex::mutualPosition(tile, attackOriginHex) > -1)) //adjacent both to attacker's head and attacked tile { const auto * st = battleGetUnitByPos(tile, true); - if(st && battleMatchOwner(st, attacker)) //only hostile stacks - does it work well with Berserk? + if(st && battleGetOwner(st) != battleGetOwner(attacker)) //only hostile stacks - does it work well with Berserk? at.hostileCreaturePositions.insert(tile); } } @@ -1488,7 +1488,7 @@ std::set CBattleInfoCallback::getAttackedCreatures(const CStack* for (const BattleHex & tile : at.hostileCreaturePositions) //all around & three-headed attack { const CStack * st = battleGetStackByPos(tile, true); - if(st && st->unitOwner() != attacker->unitOwner()) //only hostile stacks - does it work well with Berserk? + if(st && battleGetOwner(st) != battleGetOwner(attacker)) //only hostile stacks - does it work well with Berserk? { attackedCres.insert(st); } diff --git a/lib/battle/CUnitState.cpp b/lib/battle/CUnitState.cpp index b339fec2b..069d60c65 100644 --- a/lib/battle/CUnitState.cpp +++ b/lib/battle/CUnitState.cpp @@ -116,7 +116,7 @@ CCasts::CCasts(const battle::Unit * Owner): CRetaliations::CRetaliations(const battle::Unit * Owner) : CAmmo(Owner, Selector::type()(BonusType::ADDITIONAL_RETALIATION)), totalCache(0), - noRetaliation(Owner, Selector::type()(BonusType::SIEGE_WEAPON).Or(Selector::type()(BonusType::HYPNOTIZED)).Or(Selector::type()(BonusType::NO_RETALIATION))), + noRetaliation(Owner, Selector::type()(BonusType::SIEGE_WEAPON).Or(Selector::type()(BonusType::NO_RETALIATION))), unlimited(Owner, Selector::type()(BonusType::UNLIMITED_RETALIATIONS)) { } @@ -698,12 +698,12 @@ BattlePhases::Type CUnitState::battleQueuePhase(int turn) const bool CUnitState::isHypnotized() const { - return bonusCache.getBonusValue(UnitBonusValuesProxy::HYPNOTIZED); + return bonusCache.hasBonus(UnitBonusValuesProxy::HYPNOTIZED); } bool CUnitState::isInvincible() const { - return bonusCache.getBonusValue(UnitBonusValuesProxy::INVINCIBLE); + return bonusCache.hasBonus(UnitBonusValuesProxy::INVINCIBLE); } int CUnitState::getTotalAttacks(bool ranged) const