diff --git a/src/Bot/Factory/PlayerbotFactory.cpp b/src/Bot/Factory/PlayerbotFactory.cpp index 9e1b30a73..9bf987fef 100644 --- a/src/Bot/Factory/PlayerbotFactory.cpp +++ b/src/Bot/Factory/PlayerbotFactory.cpp @@ -3342,18 +3342,36 @@ void PlayerbotFactory::InitReagents() items.push_back({44615, 40}); // Devout Candle break; case CLASS_SHAMAN: - if (level >= 4) - items.push_back({5175, 1}); // Earth Totem - if (level >= 10) - items.push_back({5176, 1}); // Flame Totem - if (level >= 20) - items.push_back({5177, 1}); // Water Totem + { + HasRelicBySubclassVisitor relicVisitor(ITEM_SUBCLASS_ARMOR_TOTEM); + IterateItems(&relicVisitor, (IterateItemsMask)(ITERATE_ITEMS_IN_BAGS | ITERATE_ITEMS_IN_EQUIP)); + bool hasRelic = relicVisitor.found; + + if (!hasRelic) + { + if (level >= 4) + items.push_back({5175, 1}); // Earth Totem + if (level >= 10) + items.push_back({5176, 1}); // Flame Totem + if (level >= 20) + items.push_back({5177, 1}); // Water Totem + } + else + { + ItemIds totemIds = {5175, 5176, 5177, 5178}; + FindItemByIdsVisitor totemVisitor(totemIds); + IterateItems(&totemVisitor, (IterateItemsMask)(ITERATE_ITEMS_IN_BAGS | ITERATE_ITEMS_IN_EQUIP | ITERATE_ITEMS_IN_BANK)); + for (Item* item : totemVisitor.GetResult()) + bot->DestroyItem(item->GetBagSlot(), item->GetSlot(), true); + } if (level >= 30) { - items.push_back({5178, 1}); // Air Totem + if (!hasRelic) + items.push_back({5178, 1}); // Air Totem items.push_back({17030, 20}); // Ankh } break; + } case CLASS_WARLOCK: items.push_back({6265, 5}); // Soul Shard break; diff --git a/src/Mgr/Item/ItemVisitors.h b/src/Mgr/Item/ItemVisitors.h index e42b14f89..930aa1f4a 100644 --- a/src/Mgr/Item/ItemVisitors.h +++ b/src/Mgr/Item/ItemVisitors.h @@ -66,6 +66,29 @@ private: Player* bot; }; +class HasRelicBySubclassVisitor : public IterateItemsVisitor +{ +public: + HasRelicBySubclassVisitor(uint32 subClass) : subClass(subClass) {} + + bool Visit(Item* item) override + { + ItemTemplate const* proto = item->GetTemplate(); + if (proto && proto->InventoryType == INVTYPE_RELIC && proto->SubClass == subClass) + { + found = true; + return false; + } + + return true; + } + + bool found = false; + +private: + uint32 subClass; +}; + class FindItemsByQualityVisitor : public IterateItemsVisitor { public: