mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-14 23:56:13 +00:00
refactor: naxxramas and kel'thuzad strategy
This commit is contained in:
@@ -104,18 +104,16 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
|
||||
|
||||
if (Pet* pet = bot->GetPet())
|
||||
{
|
||||
pet->SetReactState(REACT_PASSIVE);
|
||||
if (with_pet) {
|
||||
pet->SetTarget(target->GetGUID());
|
||||
// pet->GetCharmInfo()->SetCommandState(COMMAND_ATTACK);
|
||||
pet->GetCharmInfo()->SetIsCommandAttack(true);
|
||||
pet->AI()->AttackStart(target);
|
||||
pet->SetReactState(REACT_DEFENSIVE);
|
||||
// pet->SetReactState(REACT_DEFENSIVE);
|
||||
} else {
|
||||
// pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
||||
pet->GetCharmInfo()->SetIsCommandFollow(true);
|
||||
pet->GetCharmInfo()->IsReturning();
|
||||
pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle());
|
||||
pet->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1399,3 +1399,17 @@ bool MoveRandomAction::isUseful()
|
||||
return !botAI->HasRealPlayerMaster() && botAI->GetAiObjectContext()->GetValue<GuidVector>("nearest friendly players")->Get().size() > urand(25, 100);
|
||||
}
|
||||
|
||||
bool MoveInsideAction::Execute(Event event)
|
||||
{
|
||||
return MoveInside(bot->GetMapId(), x, y, bot->GetPositionZ(), distance);
|
||||
}
|
||||
|
||||
bool RotateAroundTheCenterPointAction::Execute(Event event)
|
||||
{
|
||||
uint32 next_point = GetCurrWaypoint();
|
||||
if (MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ())) {
|
||||
call_counters += 1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "Action.h"
|
||||
#include "PlayerbotAIConfig.h"
|
||||
#include <cmath>
|
||||
|
||||
class Player;
|
||||
class PlayerbotAI;
|
||||
@@ -123,4 +124,43 @@ class MoveRandomAction : public MovementAction
|
||||
bool isUseful() override;
|
||||
};
|
||||
|
||||
class MoveInsideAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
MoveInsideAction(PlayerbotAI* ai, float x, float y, float distance = 5.0f) : MovementAction(ai, "move inside") {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->distance = distance;
|
||||
}
|
||||
virtual bool Execute(Event event);
|
||||
protected:
|
||||
float x, y, distance;
|
||||
};
|
||||
|
||||
class RotateAroundTheCenterPointAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
RotateAroundTheCenterPointAction(PlayerbotAI* ai, std::string name,
|
||||
float center_x, float center_y, float radius = 40.0f,
|
||||
uint32 intervals = 16, bool clockwise = true, float start_angle = 0) : MovementAction(ai, name) {
|
||||
this->center_x = center_x;
|
||||
this->center_y = center_y;
|
||||
this->radius = radius;
|
||||
this->intervals = intervals;
|
||||
this->clockwise = clockwise;
|
||||
this->call_counters = 0;
|
||||
for (int i = 0; i < intervals; i++) {
|
||||
float angle = start_angle + 2 * M_PI * i / intervals;
|
||||
waypoints.push_back(std::make_pair(center_x + cos(angle) * radius, center_y + sin(angle) * radius));
|
||||
}
|
||||
}
|
||||
virtual bool Execute(Event event);
|
||||
protected:
|
||||
virtual uint32 GetCurrWaypoint() { return 0; }
|
||||
uint32 FindNearestWaypoint();
|
||||
float center_x, center_y, radius;
|
||||
uint32 intervals, call_counters;
|
||||
bool clockwise;
|
||||
std::vector<std::pair<float, float>> waypoints;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user