mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Class spell] Optimize toggle pet spell
This commit is contained in:
@@ -20,6 +20,7 @@ bool TogglePetSpellAutoCastAction::Execute(Event event) {
|
|||||||
if (!pet) {
|
if (!pet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool toggled = false;
|
||||||
for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr)
|
for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr)
|
||||||
{
|
{
|
||||||
if(itr->second.state == PETSPELL_REMOVED)
|
if(itr->second.state == PETSPELL_REMOVED)
|
||||||
@@ -30,16 +31,28 @@ bool TogglePetSpellAutoCastAction::Execute(Event event) {
|
|||||||
if (spellInfo->IsPassive())
|
if (spellInfo->IsPassive())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
bool shouldApply = true;
|
||||||
// imp's spell, felhunte's intelligence, ghoul's leap, cat stealth
|
// imp's spell, felhunte's intelligence, ghoul's leap, cat stealth
|
||||||
if (spellId == 4511 || spellId == 1742 ||
|
if (spellId == 4511 || spellId == 1742 ||
|
||||||
spellId == 54424 || spellId == 57564 || spellId == 57565 || spellId == 57566 || spellId == 57567 ||
|
spellId == 54424 || spellId == 57564 || spellId == 57565 || spellId == 57566 || spellId == 57567 ||
|
||||||
spellId == 47482 || spellId == 24450) {
|
spellId == 47482 || spellId == 24450) {
|
||||||
pet->ToggleAutocast(spellInfo, false);
|
shouldApply = false;
|
||||||
} else {
|
}
|
||||||
pet->ToggleAutocast(spellInfo, true);
|
bool isAutoCast = false;
|
||||||
|
for (unsigned int &m_autospell : pet->m_autospells)
|
||||||
|
{
|
||||||
|
if (m_autospell == spellId)
|
||||||
|
{
|
||||||
|
isAutoCast = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (shouldApply != isAutoCast) {
|
||||||
|
pet->ToggleAutocast(spellInfo, shouldApply);
|
||||||
|
toggled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return toggled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PetAttackAction::Execute(Event event)
|
bool PetAttackAction::Execute(Event event)
|
||||||
|
|||||||
Reference in New Issue
Block a user