mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-21 12:37:05 +00:00
Run clang-format
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
|
||||
* and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#ifndef _PLAYERBOT_MOVEMENTACTIONS_H
|
||||
#define _PLAYERBOT_MOVEMENTACTIONS_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "Action.h"
|
||||
#include "PlayerbotAIConfig.h"
|
||||
#include <cmath>
|
||||
|
||||
class Player;
|
||||
class PlayerbotAI;
|
||||
@@ -17,205 +19,223 @@ class Position;
|
||||
|
||||
class MovementAction : public Action
|
||||
{
|
||||
public:
|
||||
MovementAction(PlayerbotAI* botAI, std::string const name);
|
||||
public:
|
||||
MovementAction(PlayerbotAI* botAI, std::string const name);
|
||||
|
||||
protected:
|
||||
void JumpTo(uint32 mapId, float x, float y, float z);
|
||||
bool MoveNear(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->contactDistance);
|
||||
bool MoveToLOS(WorldObject* target, bool ranged = false);
|
||||
bool MoveTo(uint32 mapId, float x, float y, float z, bool idle = false, bool react = false, bool normal_only = false);
|
||||
bool MoveTo(Unit* target, float distance = 0.0f);
|
||||
bool MoveNear(WorldObject* target, float distance = sPlayerbotAIConfig->contactDistance);
|
||||
float GetFollowAngle();
|
||||
bool Follow(Unit* target, float distance = sPlayerbotAIConfig->followDistance);
|
||||
bool Follow(Unit* target, float distance, float angle);
|
||||
bool ChaseTo(WorldObject* obj, float distance = 0.0f, float angle = 0.0f);
|
||||
bool ReachCombatTo(Unit* target, float distance = 0.0f);
|
||||
float MoveDelay(float distance);
|
||||
void WaitForReach(float distance);
|
||||
bool IsMovingAllowed(Unit* target);
|
||||
bool IsMovingAllowed(uint32 mapId, float x, float y, float z);
|
||||
bool IsMovingAllowed();
|
||||
bool Flee(Unit *target);
|
||||
void ClearIdleState();
|
||||
void UpdateMovementState();
|
||||
bool MoveAway(Unit* target);
|
||||
bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance);
|
||||
void CreateWp(Player* wpOwner, float x, float y, float z, float o, uint32 entry, bool important = false);
|
||||
Position BestPositionForMeleeToFlee(Position pos, float radius);
|
||||
Position BestPositionForRangedToFlee(Position pos, float radius);
|
||||
bool FleePosition(Position pos, float radius);
|
||||
bool CheckLastFlee(float curAngle, std::list<FleeInfo>& infoList);
|
||||
protected:
|
||||
struct CheckAngle {
|
||||
float angle;
|
||||
bool strict;
|
||||
};
|
||||
private:
|
||||
// float SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range = 20.0f, bool normal_only = false, float step = 8.0f);
|
||||
const Movement::PointsArray SearchForBestPath(float x, float y, float z, float &modified_z, int maxSearchCount = 5, bool normal_only = false, float step = 8.0f);
|
||||
protected:
|
||||
void JumpTo(uint32 mapId, float x, float y, float z);
|
||||
bool MoveNear(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->contactDistance);
|
||||
bool MoveToLOS(WorldObject* target, bool ranged = false);
|
||||
bool MoveTo(uint32 mapId, float x, float y, float z, bool idle = false, bool react = false,
|
||||
bool normal_only = false);
|
||||
bool MoveTo(Unit* target, float distance = 0.0f);
|
||||
bool MoveNear(WorldObject* target, float distance = sPlayerbotAIConfig->contactDistance);
|
||||
float GetFollowAngle();
|
||||
bool Follow(Unit* target, float distance = sPlayerbotAIConfig->followDistance);
|
||||
bool Follow(Unit* target, float distance, float angle);
|
||||
bool ChaseTo(WorldObject* obj, float distance = 0.0f, float angle = 0.0f);
|
||||
bool ReachCombatTo(Unit* target, float distance = 0.0f);
|
||||
float MoveDelay(float distance);
|
||||
void WaitForReach(float distance);
|
||||
bool IsMovingAllowed(Unit* target);
|
||||
bool IsMovingAllowed(uint32 mapId, float x, float y, float z);
|
||||
bool IsMovingAllowed();
|
||||
bool Flee(Unit* target);
|
||||
void ClearIdleState();
|
||||
void UpdateMovementState();
|
||||
bool MoveAway(Unit* target);
|
||||
bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance);
|
||||
void CreateWp(Player* wpOwner, float x, float y, float z, float o, uint32 entry, bool important = false);
|
||||
Position BestPositionForMeleeToFlee(Position pos, float radius);
|
||||
Position BestPositionForRangedToFlee(Position pos, float radius);
|
||||
bool FleePosition(Position pos, float radius);
|
||||
bool CheckLastFlee(float curAngle, std::list<FleeInfo>& infoList);
|
||||
|
||||
protected:
|
||||
struct CheckAngle
|
||||
{
|
||||
float angle;
|
||||
bool strict;
|
||||
};
|
||||
|
||||
private:
|
||||
// float SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range = 20.0f, bool
|
||||
// normal_only = false, float step = 8.0f);
|
||||
const Movement::PointsArray SearchForBestPath(float x, float y, float z, float& modified_z, int maxSearchCount = 5,
|
||||
bool normal_only = false, float step = 8.0f);
|
||||
};
|
||||
|
||||
class FleeAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
FleeAction(PlayerbotAI* botAI, float distance = sPlayerbotAIConfig->spellDistance) : MovementAction(botAI, "flee"), distance(distance) { }
|
||||
public:
|
||||
FleeAction(PlayerbotAI* botAI, float distance = sPlayerbotAIConfig->spellDistance)
|
||||
: MovementAction(botAI, "flee"), distance(distance)
|
||||
{
|
||||
}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
|
||||
private:
|
||||
float distance;
|
||||
private:
|
||||
float distance;
|
||||
};
|
||||
|
||||
class FleeWithPetAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
FleeWithPetAction(PlayerbotAI* botAI) : MovementAction(botAI, "flee with pet") { }
|
||||
public:
|
||||
FleeWithPetAction(PlayerbotAI* botAI) : MovementAction(botAI, "flee with pet") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class AvoidAoeAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
AvoidAoeAction(PlayerbotAI* botAI, int moveInterval = 1000) : MovementAction(botAI, "avoid aoe"),
|
||||
moveInterval(moveInterval) { }
|
||||
public:
|
||||
AvoidAoeAction(PlayerbotAI* botAI, int moveInterval = 1000)
|
||||
: MovementAction(botAI, "avoid aoe"), moveInterval(moveInterval)
|
||||
{
|
||||
}
|
||||
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
|
||||
protected:
|
||||
bool AvoidAuraWithDynamicObj();
|
||||
bool AvoidGameObjectWithDamage();
|
||||
bool AvoidUnitWithDamageAura();
|
||||
time_t lastTellTimer = 0;
|
||||
int lastMoveTimer = 0;
|
||||
int moveInterval;
|
||||
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
|
||||
protected:
|
||||
bool AvoidAuraWithDynamicObj();
|
||||
bool AvoidGameObjectWithDamage();
|
||||
bool AvoidUnitWithDamageAura();
|
||||
time_t lastTellTimer = 0;
|
||||
int lastMoveTimer = 0;
|
||||
int moveInterval;
|
||||
};
|
||||
|
||||
class CombatFormationMoveAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
CombatFormationMoveAction(PlayerbotAI* botAI, int moveInterval = 1000) : MovementAction(botAI, "combat formation move"),
|
||||
moveInterval(moveInterval) { }
|
||||
public:
|
||||
CombatFormationMoveAction(PlayerbotAI* botAI, int moveInterval = 1000)
|
||||
: MovementAction(botAI, "combat formation move"), moveInterval(moveInterval)
|
||||
{
|
||||
}
|
||||
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
|
||||
protected:
|
||||
Position AverageGroupPos(float dis = sPlayerbotAIConfig->sightDistance);
|
||||
Player* NearestGroupMember(float dis = sPlayerbotAIConfig->sightDistance);
|
||||
int lastMoveTimer = 0;
|
||||
int moveInterval;
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
|
||||
protected:
|
||||
Position AverageGroupPos(float dis = sPlayerbotAIConfig->sightDistance);
|
||||
Player* NearestGroupMember(float dis = sPlayerbotAIConfig->sightDistance);
|
||||
int lastMoveTimer = 0;
|
||||
int moveInterval;
|
||||
};
|
||||
|
||||
class DisperseSetAction : public Action
|
||||
{
|
||||
public:
|
||||
DisperseSetAction(PlayerbotAI* botAI, std::string const name = "disperse set") : Action(botAI, name) { }
|
||||
public:
|
||||
DisperseSetAction(PlayerbotAI* botAI, std::string const name = "disperse set") : Action(botAI, name) {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
float DEFAULT_DISPERSE_DISTANCE_RANGED = 5.0f;
|
||||
float DEFAULT_DISPERSE_DISTANCE_MELEE = 2.0f;
|
||||
bool Execute(Event event) override;
|
||||
float DEFAULT_DISPERSE_DISTANCE_RANGED = 5.0f;
|
||||
float DEFAULT_DISPERSE_DISTANCE_MELEE = 2.0f;
|
||||
};
|
||||
|
||||
class RunAwayAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
RunAwayAction(PlayerbotAI* botAI) : MovementAction(botAI, "runaway") { }
|
||||
|
||||
bool Execute(Event event) override;
|
||||
public:
|
||||
RunAwayAction(PlayerbotAI* botAI) : MovementAction(botAI, "runaway") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class MoveToLootAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
MoveToLootAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to loot") { }
|
||||
public:
|
||||
MoveToLootAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to loot") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class MoveOutOfEnemyContactAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
MoveOutOfEnemyContactAction(PlayerbotAI* botAI) : MovementAction(botAI, "move out of enemy contact") { }
|
||||
public:
|
||||
MoveOutOfEnemyContactAction(PlayerbotAI* botAI) : MovementAction(botAI, "move out of enemy contact") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
};
|
||||
|
||||
class SetFacingTargetAction : public Action
|
||||
{
|
||||
public:
|
||||
SetFacingTargetAction(PlayerbotAI* botAI) : Action(botAI, "set facing") { }
|
||||
public:
|
||||
SetFacingTargetAction(PlayerbotAI* botAI) : Action(botAI, "set facing") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
};
|
||||
|
||||
class SetBehindTargetAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
SetBehindTargetAction(PlayerbotAI* botAI) : MovementAction(botAI, "set behind") { }
|
||||
public:
|
||||
SetBehindTargetAction(PlayerbotAI* botAI) : MovementAction(botAI, "set behind") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
};
|
||||
|
||||
class MoveOutOfCollisionAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
MoveOutOfCollisionAction(PlayerbotAI* botAI) : MovementAction(botAI, "move out of collision") { }
|
||||
public:
|
||||
MoveOutOfCollisionAction(PlayerbotAI* botAI) : MovementAction(botAI, "move out of collision") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
};
|
||||
|
||||
class MoveRandomAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
MoveRandomAction(PlayerbotAI* botAI) : MovementAction(botAI, "move random") { }
|
||||
public:
|
||||
MoveRandomAction(PlayerbotAI* botAI) : MovementAction(botAI, "move random") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
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;
|
||||
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) {
|
||||
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++) {
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user