diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index fdda84ac61..54b556ad95 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -17114,3 +17114,18 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/ ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale); target->SendDirectMessage(&data); } + +SpellInfo const* Unit::GetCastSpellInfo(SpellInfo const* spellInfo) const +{ + Unit::AuraEffectList swaps = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS); + Unit::AuraEffectList const& swaps2 = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS_2); + if (!swaps2.empty()) + swaps.insert(swaps.end(), swaps2.begin(), swaps2.end()); + + for (AuraEffect const* aurEff : swaps) + if (aurEff->IsAffectingSpell(spellInfo)) + if (SpellInfo const* newInfo = sSpellMgr->GetSpellInfo(aurEff->GetAmount())) + return newInfo; + + return spellInfo; +} diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 957622a2a0..e911f22336 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1873,6 +1873,7 @@ class Unit : public WorldObject Spell* GetCurrentSpell(uint32 spellType) const { return m_currentSpells[spellType]; } Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; int32 GetCurrentSpellCastTime(uint32 spell_id) const; + SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const; // Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING bool CanMoveDuringChannel() const; diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index f271c0662b..2d6e0070f8 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -353,7 +353,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) } Unit* caster = mover; - if (caster->GetTypeId() == TYPEID_UNIT && !caster->ToCreature()->HasSpell(spellId)) + if (caster->GetTypeId() == TYPEID_UNIT && !caster->ToCreature()->HasSpell(spellInfo->Id)) { // If the vehicle creature does not have the spell but it allows the passenger to cast own spells // change caster to player and let him cast @@ -366,33 +366,15 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) caster = _player; } - if (caster->GetTypeId() == TYPEID_PLAYER && !caster->ToPlayer()->HasActiveSpell(spellId)) + if (caster->GetTypeId() == TYPEID_PLAYER && !caster->ToPlayer()->HasActiveSpell(spellInfo->Id)) { // not have spell in spellbook recvPacket.rfinish(); // prevent spam at ignore packet return; } - Unit::AuraEffectList swaps = mover->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS); - Unit::AuraEffectList const& swaps2 = mover->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS_2); - if (!swaps2.empty()) - swaps.insert(swaps.end(), swaps2.begin(), swaps2.end()); - - if (!swaps.empty()) - { - for (Unit::AuraEffectList::const_iterator itr = swaps.begin(); itr != swaps.end(); ++itr) - { - if ((*itr)->IsAffectingSpell(spellInfo)) - { - if (SpellInfo const* newInfo = sSpellMgr->GetSpellInfo((*itr)->GetAmount())) - { - spellInfo = newInfo; - spellId = newInfo->Id; - } - break; - } - } - } + // Check possible spell cast overrides + spellInfo = caster->GetCastSpellInfo(spellInfo); // Client is resending autoshot cast opcode when other spell is cast during shoot rotation // Skip it to prevent "interrupt" message