diff --git a/src/strategy/shaman/ShamanActions.cpp b/src/strategy/shaman/ShamanActions.cpp index dbb83a0c..d4d0f98a 100644 --- a/src/strategy/shaman/ShamanActions.cpp +++ b/src/strategy/shaman/ShamanActions.cpp @@ -93,19 +93,26 @@ bool CastSpiritWalkAction::Execute(Event event) bool SetTotemAction::Execute(Event event) { - size_t spellIdsCount = sizeof(totemSpellIds) / sizeof(uint32); + const size_t spellIdsCount = sizeof(totemSpellIds) / sizeof(uint32); + if (spellIdsCount == 0) + return false; // early return uint32 totemSpell = 0; - for (int i = spellIdsCount - 1; i >= 0; --i) + + // Iterate backwards to prioritize the highest-rank totem spell the bot knows + for (size_t i = spellIdsCount; i-- > 0;) { - if (bot->HasSpell(totemSpellIds[i])) + const uint32 spellId = totemSpellIds[i]; + if (bot->HasSpell(spellId)) { - totemSpell = totemSpellIds[i]; + totemSpell = spellId; break; } } - if (!totemSpell) + + if (totemSpell == 0) return false; + bot->addActionButton(actionButtonId, totemSpell, ACTION_BUTTON_SPELL); return true; } diff --git a/src/strategy/shaman/ShamanTriggers.cpp b/src/strategy/shaman/ShamanTriggers.cpp index 35afbea1..cdee870c 100644 --- a/src/strategy/shaman/ShamanTriggers.cpp +++ b/src/strategy/shaman/ShamanTriggers.cpp @@ -424,6 +424,7 @@ bool SetTotemTrigger::IsActive() { if (!bot->HasSpell(SPELL_CALL_OF_THE_ELEMENTS)) return false; + if (!bot->HasSpell(requiredSpellId)) return false; @@ -431,13 +432,20 @@ bool SetTotemTrigger::IsActive() if (!button || button->GetType() != ACTION_BUTTON_SPELL || button->GetAction() == 0) return true; - size_t totemSpellIdsCount = sizeof(totemSpellIds) / sizeof(uint32); - for (size_t i = 0; i < totemSpellIdsCount; ++i) + const size_t totemSpellIdsCount = sizeof(totemSpellIds) / sizeof(uint32); + if (totemSpellIdsCount == 0) { - if (button->GetAction() == totemSpellIds[i]) + return false; + } + + for (int i = (int)totemSpellIdsCount - 1; i >= 0; --i) + { + const uint32 spellId = totemSpellIds[i]; + if (bot->HasSpell(spellId)) { - return false; + return button->GetAction() != spellId; } } - return true; + + return false; }