Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/modules/Bots/playerbot/strategy/actions/MovementActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ bool MovementAction::FollowOnTransport(Unit* target, Player* master)
AI_VALUE(LastMovement&, "last movement").Set(target);
return true;
}
return false;
}

bool MovementAction::FollowOffTransport(Unit* target, Player* master)
Expand Down Expand Up @@ -527,6 +528,16 @@ bool RunAwayAction::Execute(Event event)

bool MoveRandomAction::Execute(Event event)
{
if (m_hasFaceTarget)
{
if (bot->IsStopped())
{
m_hasFaceTarget = false;
bot->SetFacingTo(bot->GetAngle(m_faceX, m_faceY));
}
return true;
}

WorldObject* target = NULL;

if (!(rand() % 3))
Expand Down Expand Up @@ -561,7 +572,14 @@ bool MoveRandomAction::Execute(Event event)

if (target)
{
return MoveNear(target);
bool moved = MoveNear(target);
if (moved)
{
m_faceX = target->GetPositionX();
m_faceY = target->GetPositionY();
m_hasFaceTarget = true;
}
return moved;
}

for (int i = 0; i < 10; ++i)
Expand Down
8 changes: 6 additions & 2 deletions src/modules/Bots/playerbot/strategy/actions/MovementActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ namespace ai
class MoveRandomAction : public MovementAction
{
public:
MoveRandomAction(PlayerbotAI* ai) : MovementAction(ai, "move random") {}
MoveRandomAction(PlayerbotAI* ai) : MovementAction(ai, "move random"), m_hasFaceTarget(false), m_faceX(0.0f), m_faceY(0.0f) {}
virtual bool Execute(Event event);
virtual bool isPossible()
{
return MovementAction::isPossible() &&
return !bot->GetGroup() &&
MovementAction::isPossible() &&
AI_VALUE2(uint8, "health", "self target") > sPlayerbotAIConfig.mediumHealth &&
(!AI_VALUE2(uint8, "mana", "self target") || AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.mediumMana);
}
private:
bool m_hasFaceTarget;
float m_faceX, m_faceY;
};

class MoveToLootAction : public MovementAction
Expand Down
Loading