diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 6564c70d..99005314 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2485,7 +2485,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy bool canDodge = victim->GetTypeId() != TYPEID_PLAYER || canParryOrBlock; // if victim is casting or cc'd it can't avoid attacks - if (victim->IsNonMeleeSpellCast(false, false, true) || victim->HasUnitState(UNIT_STATE_CONTROLLED)) + if ((victim->IsNonMeleeSpellCast(false, false, true) && !victim->CanDefendWhileCasting()) || victim->HasUnitState(UNIT_STATE_CONTROLLED)) { canDodge = false; canParryOrBlock = false; @@ -2720,7 +2720,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo bool canBlock = !spellInfo->HasAttribute(SPELL_ATTR8_NO_ATTACK_BLOCK); // if victim is casting or cc'd it can't avoid attacks - if (victim->IsNonMeleeSpellCast(false, false, true) || victim->HasUnitState(UNIT_STATE_CONTROLLED)) + if ((victim->IsNonMeleeSpellCast(false, false, true) && !victim->CanDefendWhileCasting()) || victim->HasUnitState(UNIT_STATE_CONTROLLED)) { canDodge = false; canParry = false; @@ -3327,6 +3327,20 @@ bool Unit::IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled /*= false*/, return false; } +bool Unit::CanDefendWhileCasting() const +{ + if (Spell const* spell = m_currentSpells[CURRENT_GENERIC_SPELL]) + if (spell->getState() != SPELL_STATE_FINISHED && spell->getState() != SPELL_STATE_LAUNCHED && !spell->m_spellInfo->HasAttribute(SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING)) + return false; + + if (Spell const* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) + if (spell->getState() != SPELL_STATE_FINISHED && !spell->m_spellInfo->HasAttribute(SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING) + && !spell->m_spellInfo->HasAttribute(SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CHANNELING)) + return false; + + return true; +} + void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id, bool withInstant) { // generic spells are interrupted if they are not finished or delayed diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 9656c84e..88044aed 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1497,6 +1497,7 @@ class TC_GAME_API Unit : public WorldObject // we can skip channeled or delayed checks using flags bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false, bool isAutoshoot = false, bool skipInstant = true, bool skipChanneledAllowingActions = false) const; + bool CanDefendWhileCasting() const; // set withDelayed to true to interrupt delayed spells too // delayed+channeled spells are always interrupted diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 12c9c1c3..8da881a3 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -820,8 +820,8 @@ enum SpellAttr10 : uint32 SPELL_ATTR10_ROLLING_PERIODIC = 0x00004000, // TITLE Rolling Periodic DESCRIPTION Add remaining periodic damage to new aura when refreshed SPELL_ATTR10_UNK15 = 0x00008000, // TITLE Unknown attribute 15@Attr10 SPELL_ATTR10_UNK16 = 0x00010000, // TITLE Unknown attribute 16@Attr10 - SPELL_ATTR10_CAN_DODGE_PARRY_WHILE_CASTING = 0x00020000, // TITLE Allow Defense While Casting - SPELL_ATTR10_UNK18 = 0x00040000, // TITLE Unknown attribute 18@Attr10 + SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING = 0x00020000, // TITLE Allow Defense While Casting + SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CHANNELING = 0x00040000, // TITLE Allow Defense While Channeling SPELL_ATTR10_UNK19 = 0x00080000, // TITLE Unknown attribute 19@Attr10 SPELL_ATTR10_UNK20 = 0x00100000, // TITLE Unknown attribute 20@Attr10 SPELL_ATTR10_UNK21 = 0x00200000, // TITLE Unknown attribute 21@Attr10 diff --git a/src/server/game/Miscellaneous/enuminfo_SharedDefines.cpp b/src/server/game/Miscellaneous/enuminfo_SharedDefines.cpp index dadf3e3b..aa9023c6 100644 --- a/src/server/game/Miscellaneous/enuminfo_SharedDefines.cpp +++ b/src/server/game/Miscellaneous/enuminfo_SharedDefines.cpp @@ -1584,8 +1584,8 @@ namespace Trinity::Impl::EnumUtilsImpl case SPELL_ATTR10_ROLLING_PERIODIC: return { "SPELL_ATTR10_ROLLING_PERIODIC", "Rolling Periodic", "Add remaining periodic damage to new aura when refreshed" }; case SPELL_ATTR10_UNK15: return { "SPELL_ATTR10_UNK15", "Unknown attribute 15@Attr10", "" }; case SPELL_ATTR10_UNK16: return { "SPELL_ATTR10_UNK16", "Unknown attribute 16@Attr10", "" }; - case SPELL_ATTR10_CAN_DODGE_PARRY_WHILE_CASTING: return { "SPELL_ATTR10_CAN_DODGE_PARRY_WHILE_CASTING", "Allow Defense While Casting", "" }; - case SPELL_ATTR10_UNK18: return { "SPELL_ATTR10_UNK18", "Unknown attribute 18@Attr10", "" }; + case SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING: return { "SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING", "Allow Defense While Casting", "" }; + case SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CHANNELING: return { "SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CHANNELING", "Allow Defense While Channeling", "" }; case SPELL_ATTR10_UNK19: return { "SPELL_ATTR10_UNK19", "Unknown attribute 19@Attr10", "" }; case SPELL_ATTR10_UNK20: return { "SPELL_ATTR10_UNK20", "Unknown attribute 20@Attr10", "" }; case SPELL_ATTR10_UNK21: return { "SPELL_ATTR10_UNK21", "Unknown attribute 21@Attr10", "" }; @@ -1628,8 +1628,8 @@ namespace Trinity::Impl::EnumUtilsImpl case 14: return SPELL_ATTR10_ROLLING_PERIODIC; case 15: return SPELL_ATTR10_UNK15; case 16: return SPELL_ATTR10_UNK16; - case 17: return SPELL_ATTR10_CAN_DODGE_PARRY_WHILE_CASTING; - case 18: return SPELL_ATTR10_UNK18; + case 17: return SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING; + case 18: return SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CHANNELING; case 19: return SPELL_ATTR10_UNK19; case 20: return SPELL_ATTR10_UNK20; case 21: return SPELL_ATTR10_UNK21; @@ -1669,8 +1669,8 @@ namespace Trinity::Impl::EnumUtilsImpl case SPELL_ATTR10_ROLLING_PERIODIC: return 14; case SPELL_ATTR10_UNK15: return 15; case SPELL_ATTR10_UNK16: return 16; - case SPELL_ATTR10_CAN_DODGE_PARRY_WHILE_CASTING: return 17; - case SPELL_ATTR10_UNK18: return 18; + case SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING: return 17; + case SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CHANNELING: return 18; case SPELL_ATTR10_UNK19: return 19; case SPELL_ATTR10_UNK20: return 20; case SPELL_ATTR10_UNK21: return 21;