Core/Spells: ported helper function from 3f28fd304d833eadefff8d343ab45caf8d0575c2
Core/Spells: Reimplemented automatic spell learning
This commit is contained in:
1 parent
87f25be0aa
commit
badef62df4
3 files changed
+20
-22
No files matched your search
@@ -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);
|
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);
|
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;
|
||||||
|
}
|
||||||
@@ -1873,6 +1873,7 @@ class Unit : public WorldObject
|
|||||||
Spell* GetCurrentSpell(uint32 spellType) const { return m_currentSpells[spellType]; }
|
Spell* GetCurrentSpell(uint32 spellType) const { return m_currentSpells[spellType]; }
|
||||||
Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
|
Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
|
||||||
int32 GetCurrentSpellCastTime(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
|
// Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING
|
||||||
bool CanMoveDuringChannel() const;
|
bool CanMoveDuringChannel() const;
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Unit* caster = mover;
|
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
|
// 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
|
// change caster to player and let him cast
|
||||||
@@ -366,33 +366,15 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
|||||||
caster = _player;
|
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
|
// not have spell in spellbook
|
||||||
recvPacket.rfinish(); // prevent spam at ignore packet
|
recvPacket.rfinish(); // prevent spam at ignore packet
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit::AuraEffectList swaps = mover->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS);
|
// Check possible spell cast overrides
|
||||||
Unit::AuraEffectList const& swaps2 = mover->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS_2);
|
spellInfo = caster->GetCastSpellInfo(spellInfo);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Client is resending autoshot cast opcode when other spell is cast during shoot rotation
|
// Client is resending autoshot cast opcode when other spell is cast during shoot rotation
|
||||||
// Skip it to prevent "interrupt" message
|
// Skip it to prevent "interrupt" message
|
||||||
|
|||||||
Reference in new issue
Block a user