diff --git a/playerbot/strategy/actions/ActionContext.h b/playerbot/strategy/actions/ActionContext.h index f618002b4..ce7ca20aa 100644 --- a/playerbot/strategy/actions/ActionContext.h +++ b/playerbot/strategy/actions/ActionContext.h @@ -397,7 +397,7 @@ namespace ai static Action* food(PlayerbotAI* ai) { return new EatAction(ai); } static Action* mana_potion(PlayerbotAI* ai) { return new UseManaPotionAction(ai); } static Action* healing_potion(PlayerbotAI* ai) { return new UseHealingPotionAction(ai); } - static Action* healthstone(PlayerbotAI* ai) { return new UseItemAction(ai, "healthstone"); } + static Action* healthstone(PlayerbotAI* ai) { return new UseHealthstoneAction(ai); } static Action* move_out_of_enemy_contact(PlayerbotAI* ai) { return new MoveOutOfEnemyContactAction(ai); } static Action* set_facing(PlayerbotAI* ai) { return new SetFacingTargetAction(ai); } static Action* set_behind(PlayerbotAI* ai) { return new SetBehindTargetAction(ai); } diff --git a/playerbot/strategy/actions/UseItemAction.h b/playerbot/strategy/actions/UseItemAction.h index 395fd70ae..c203b76e2 100644 --- a/playerbot/strategy/actions/UseItemAction.h +++ b/playerbot/strategy/actions/UseItemAction.h @@ -119,6 +119,57 @@ namespace ai bool ShouldReactionInterruptMovement() const override { return true; } }; + class UseHealthstoneAction : public UseItemIdAction + { + public: + UseHealthstoneAction(PlayerbotAI* ai) : UseItemIdAction(ai, "healthstone") {} + + bool isUseful() override { return AI_VALUE2(bool, "combat", "self target"); } + + uint32 GetItemId() override + { + list items = AI_VALUE2(list, "inventory items", getName()); + if (items.empty()) + { + const uint32 level = bot->GetLevel(); + if(level < 12) + { + return 5512; + } + else if(level >= 12 && level < 24) + { + return 5511; + } + else if(level >= 24 && level < 36) + { + return 5509; + } + else if(level >= 36 && level < 48) + { + return 5510; + } + else if(level >= 48 && level < 61) + { + return 9421; + } + else if(level >= 61 && level < 63) + { + return 22103; + } + else if(level >= 63 && level < 71) + { + return 36889; + } + else + { + return 36892; + } + } + + return items.front()->GetProto()->ItemId; + } + }; + class UseRandomRecipeAction : public UseItemAction { public: