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];
|
uint32 spellId = _unit->ToCreature()->m_spells[i];
|
||||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||||
if (spellInfo)
|
if (spellInfo)
|
||||||
{
|
|
||||||
if (spellInfo->IsPassive())
|
if (spellInfo->IsPassive())
|
||||||
_unit->CastSpell(_unit, spellInfo, true);
|
_unit->CastSpell(_unit, spellInfo, true);
|
||||||
else
|
|
||||||
AddSpellToActionBar(spellInfo, ACT_PASSIVE);
|
AddSpellToActionBar(spellInfo, ACT_PASSIVE, i);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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 spell_id = 0;
|
||||||
uint32 first_id = spellInfo->GetFirstRankSpell()->Id;
|
uint32 first_id = 0;
|
||||||
|
|
||||||
|
if (spellInfo)
|
||||||
|
{
|
||||||
|
spell_id = spellInfo->Id;
|
||||||
|
first_id = spellInfo->GetFirstRankSpell()->Id;
|
||||||
|
}
|
||||||
|
|
||||||
// new spell rank can be already listed
|
// new spell rank can be already listed
|
||||||
for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
|
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 (!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);
|
SetActionBar(i, spell_id, newstate == ACT_DECIDE ? spellInfo->IsAutocastable() ? ACT_DISABLED : ACT_PASSIVE : newstate);
|
||||||
|
|
||||||
if (_unit->GetCharmer() && _unit->GetCharmer()->IsPlayer())
|
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)
|
if (PetActionBar[i].IsActionBarForSpell() && sSpellMgr->GetFirstSpellInChain(action) == first_id)
|
||||||
{
|
{
|
||||||
SetActionBar(i, 0, ACT_PASSIVE);
|
SetActionBar(i, 0, ACT_DISABLED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public:
|
|||||||
void InitEmptyActionBar(bool withAttack = true);
|
void InitEmptyActionBar(bool withAttack = true);
|
||||||
|
|
||||||
//return true if successful
|
//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);
|
bool RemoveSpellFromActionBar(uint32 spell_id);
|
||||||
void LoadPetActionBar(const std::string& data);
|
void LoadPetActionBar(const std::string& data);
|
||||||
void BuildActionBar(WorldPacket* data);
|
void BuildActionBar(WorldPacket* data);
|
||||||
|
|||||||
Reference in New Issue
Block a user