Skip to content

Commit

Permalink
Fix use healthstone not working with item cheats enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Jul 26, 2023
1 parent 1b90296 commit f67a3b1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion playerbot/strategy/actions/ActionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down
51 changes: 51 additions & 0 deletions playerbot/strategy/actions/UseItemAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item*> items = AI_VALUE2(list<Item*>, "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:
Expand Down

0 comments on commit f67a3b1

Please sign in to comment.