diff --git a/src/server/game/Entities/Unit/CharmInfo.cpp b/src/server/game/Entities/Unit/CharmInfo.cpp index df36bb732..d315f01a2 100644 --- a/src/server/game/Entities/Unit/CharmInfo.cpp +++ b/src/server/game/Entities/Unit/CharmInfo.cpp @@ -98,12 +98,10 @@ void CharmInfo::InitPossessCreateSpells() uint32 spellId = _unit->ToCreature()->m_spells[i]; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (spellInfo) - { if (spellInfo->IsPassive()) _unit->CastSpell(_unit, spellInfo, true); - else - AddSpellToActionBar(spellInfo, ACT_PASSIVE); - } + + AddSpellToActionBar(spellInfo, ACT_PASSIVE, i); } } else @@ -157,10 +155,16 @@ void CharmInfo::InitCharmCreateSpells() } } -bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate) +bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate, uint32 index) { - uint32 spell_id = spellInfo->Id; - uint32 first_id = spellInfo->GetFirstRankSpell()->Id; + uint32 spell_id = 0; + uint32 first_id = 0; + + if (spellInfo) + { + spell_id = spellInfo->Id; + first_id = spellInfo->GetFirstRankSpell()->Id; + } // new spell rank can be already listed for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) @@ -180,6 +184,9 @@ bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates new { if (!PetActionBar[i].GetAction() && PetActionBar[i].IsActionBarForSpell()) { + if (i != index && index <= MAX_UNIT_ACTION_BAR_INDEX) + continue; + SetActionBar(i, spell_id, newstate == ACT_DECIDE ? spellInfo->IsAutocastable() ? ACT_DISABLED : ACT_PASSIVE : newstate); if (_unit->GetCharmer() && _unit->GetCharmer()->IsPlayer()) @@ -218,7 +225,7 @@ bool CharmInfo::RemoveSpellFromActionBar(uint32 spell_id) { if (PetActionBar[i].IsActionBarForSpell() && sSpellMgr->GetFirstSpellInChain(action) == first_id) { - SetActionBar(i, 0, ACT_PASSIVE); + SetActionBar(i, 0, ACT_DISABLED); return true; } } diff --git a/src/server/game/Entities/Unit/CharmInfo.h b/src/server/game/Entities/Unit/CharmInfo.h index 6a62c6ef8..2f44c2ff4 100644 --- a/src/server/game/Entities/Unit/CharmInfo.h +++ b/src/server/game/Entities/Unit/CharmInfo.h @@ -140,7 +140,7 @@ public: void InitEmptyActionBar(bool withAttack = true); //return true if successful - bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE); + bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE, uint32 index = MAX_UNIT_ACTION_BAR_INDEX + 1); bool RemoveSpellFromActionBar(uint32 spell_id); void LoadPetActionBar(const std::string& data); void BuildActionBar(WorldPacket* data);