mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-19 03:45:43 +00:00
fix(Core/CharmInfo): Respect charm spell indices when adding to action bar. (#19811)
Init.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user