Skip to content

Commit

Permalink
Prevent executing use lightwell action if no lightwells are nearby
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Jul 26, 2023
1 parent fcd52f0 commit 1b90296
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions playerbot/strategy/actions/GenericActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ namespace ai
{
public:
UseLightwellAction(PlayerbotAI* ai) : MovementAction(ai, "lightwell") {}
virtual bool isUseful()
ActionThreatType getThreatType() override { return ActionThreatType::ACTION_THREAT_NONE; }

bool isUseful() override
{
return (bot->getClass() == CLASS_PRIEST || bot->GetGroup()) && bot->GetHealthPercent() < sPlayerbotAIConfig.mediumHealth && !ai->HasAura("lightwell renew", bot);
}
virtual ActionThreatType getThreatType() { return ActionThreatType::ACTION_THREAT_NONE; }
virtual bool Execute(Event& event)

bool isPossible() override
{
list<ObjectGuid> closeObjects = AI_VALUE(list<ObjectGuid>, "nearest game objects no los");
if (closeObjects.empty())
Expand All @@ -42,7 +44,6 @@ namespace ai
if (!sServerFacade.isSpawned(go) || go->GetGoState() != GO_STATE_READY || !bot->CanInteract(go))
continue;

// handle summoned traps, usually by players
if (Unit* owner = go->GetOwner())
{
if (owner->GetTypeId() == TYPEID_PLAYER)
Expand All @@ -56,6 +57,18 @@ namespace ai
}
}

lightwellGameObject = *i;
return MovementAction::isPossible();
}

return false;
}

virtual bool Execute(Event& event)
{
GameObject* go = ai->GetGameObject(lightwellGameObject);
if (go)
{
if (bot->IsWithinDistInMap(go, INTERACTION_DISTANCE, false))
{
WorldPacket data(CMSG_GAMEOBJ_USE);
Expand All @@ -68,8 +81,12 @@ namespace ai
return MoveNear(go, 4.0f);
}
}

return false;
}

private:
ObjectGuid lightwellGameObject;
};

class ChatCommandAction : public Action
Expand Down

0 comments on commit 1b90296

Please sign in to comment.