Skip to content

Commit 4b47847

Browse files
authored
Merge ef6706f into aeac978
2 parents aeac978 + ef6706f commit 4b47847

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/modules/Bots/playerbot/strategy/actions/MovementActions.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ bool MovementAction::FollowOnTransport(Unit* target, Player* master)
286286
AI_VALUE(LastMovement&, "last movement").Set(target);
287287
return true;
288288
}
289+
return false;
289290
}
290291

291292
bool MovementAction::FollowOffTransport(Unit* target, Player* master)
@@ -540,6 +541,16 @@ bool RunAwayAction::Execute(Event event)
540541

541542
bool MoveRandomAction::Execute(Event event)
542543
{
544+
if (m_hasFaceTarget)
545+
{
546+
if (bot->IsStopped())
547+
{
548+
m_hasFaceTarget = false;
549+
bot->SetFacingTo(bot->GetAngle(m_faceX, m_faceY));
550+
}
551+
return true;
552+
}
553+
543554
WorldObject* target = NULL;
544555

545556
if (!(rand() % 3))
@@ -574,7 +585,14 @@ bool MoveRandomAction::Execute(Event event)
574585

575586
if (target)
576587
{
577-
return MoveNear(target);
588+
bool moved = MoveNear(target);
589+
if (moved)
590+
{
591+
m_faceX = target->GetPositionX();
592+
m_faceY = target->GetPositionY();
593+
m_hasFaceTarget = true;
594+
}
595+
return moved;
578596
}
579597

580598
for (int i = 0; i < 10; ++i)

src/modules/Bots/playerbot/strategy/actions/MovementActions.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,18 @@ namespace ai
6262
class MoveRandomAction : public MovementAction
6363
{
6464
public:
65-
MoveRandomAction(PlayerbotAI* ai) : MovementAction(ai, "move random") {}
65+
MoveRandomAction(PlayerbotAI* ai) : MovementAction(ai, "move random"), m_hasFaceTarget(false), m_faceX(0.0f), m_faceY(0.0f) {}
6666
virtual bool Execute(Event event);
6767
virtual bool isPossible()
6868
{
69-
return MovementAction::isPossible() &&
69+
return !bot->GetGroup() &&
70+
MovementAction::isPossible() &&
7071
AI_VALUE2(uint8, "health", "self target") > sPlayerbotAIConfig.mediumHealth &&
7172
(!AI_VALUE2(uint8, "mana", "self target") || AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.mediumMana);
7273
}
74+
private:
75+
bool m_hasFaceTarget;
76+
float m_faceX, m_faceY;
7377
};
7478

7579
class MoveToLootAction : public MovementAction

0 commit comments

Comments
 (0)