38 _escortQuest(nullptr), _activeAttacker(true), _instantRespawn(false), _returnToStart(false), _despawnAtEnd(true), _despawnAtFar(true),
39 _hasImmuneToNPCFlags(false), _started(false), _ended(false), _resume(false)
61 if (
Group* group = player->GetGroup())
63 for (
GroupReference* groupRef = group->GetFirstMember(); groupRef !=
nullptr; groupRef = groupRef->
next())
64 if (
Player* member = groupRef->GetSource())
65 if (member->IsInMap(player))
107 TC_LOG_DEBUG(
"scripts.ai.escortai",
"EscortAI::EnterEvadeMode: left combat and is now returning to last point ({})",
me->
GetGUID().
ToString());
138 TC_LOG_DEBUG(
"scripts.ai.escortai",
"EscortAI::MovementInform: returned to home location and restarting waypoint path ({})",
me->
GetGUID().
ToString());
144 ASSERT(
id <
_path.
Nodes.size(),
"EscortAI::MovementInform: referenced movement id (%u) points to non-existing node in loaded path (%s)",
id,
me->
GetGUID().
ToString().c_str());
181 float orientation = 0.f;
206 movementGenerator->Resume(0);
221 TC_LOG_DEBUG(
"scripts.ai.escortai",
"EscortAI::UpdateAI: failed because player/group was to far away or not found ({})",
me->
GetGUID().
ToString());
223 bool isEscort =
false;
314 TC_LOG_ERROR(
"scripts.ai.escortai",
"EscortAI::Start: (script: {}) is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn ({})",
me->
GetScriptName(),
me->
GetGUID().
ToString());
326 TC_LOG_ERROR(
"scripts.ai.escortai",
"EscortAI::Start: (script: {}) is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn ({})",
me->
GetScriptName(),
me->
GetGUID().
ToString());
340 TC_LOG_DEBUG(
"scripts.ai.escortai",
"EscortAI::Start: (script: {}) started with {} waypoints. ActiveAttacker = {}, Player = {} ({})",
356 movementGenerator->Pause(0);
418 if (
Group* group = player->GetGroup())
420 for (
GroupReference* groupRef = group->GetFirstMember(); groupRef !=
nullptr; groupRef = groupRef->
next())
421 if (
Player* member = groupRef->GetSource())
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
#define TC_LOG_DEBUG(filterType__, message__,...)
#define TC_LOG_ERROR(filterType__, message__,...)
std::optional< T > Optional
Optional helper class to wrap optional values within.
#define DEFAULT_MAX_PLAYER_DISTANCE
@ CREATURE_TYPE_FLAG_CAN_ASSIST
@ SPAWNGROUP_FLAG_ESCORTQUESTNPC
static float waypoint[6][3]
virtual void MoveInLineOfSight(Unit *)
bool IsTapListNotClearedOnEvade() const
void Respawn(bool force=false)
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
CreatureDifficulty const * GetCreatureDifficulty() const
void GetHomePosition(float &x, float &y, float &z, float &ori) const
bool HasReactState(ReactStates state) const
bool IsEngaged() const override
void SetTappedBy(Unit const *unit, bool withGroup=true)
bool IsImmuneToNPC() const
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
CreatureData const * GetCreatureData() const
ObjectGuid::LowType GetSpawnId() const
CreatureTemplate const * GetCreatureTemplate() const
uint32 GetRespawnDelay() const
void SetImmuneToNPC(bool apply) override
std::string GetScriptName() const
void SaveRespawnTime(uint32 forceDelay=0)
bool IsInEvadeMode() const
void Respawn(RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< Scripting::v2::ActionResultSetter< MovementStopReason > > &&scriptResult={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< Scripting::v2::ActionResultSetter< MovementStopReason > > &&scriptResult={})
MovementGenerator * GetCurrentMovementGenerator() const
std::string ToString() const
static Creature * ToCreature(Object *o)
static ObjectGuid GetGUID(Object const *o)
uint32 GetQuestId() const
virtual bool CanAIAttack(Unit const *) const
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
void ReplaceAllNpcFlags2(NPCFlags2 flags)
MotionMaster * GetMotionMaster()
bool isInAccessiblePlaceFor(Creature const *c) const
Unit * EnsureVictim() const
uint32 GetFaction() const override
bool SetWalk(bool enable)
void EngageWithTarget(Unit *who)
void ReplaceAllNpcFlags(NPCFlags flags)
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
bool IsValidAssistTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
@ CONFIG_RESPAWN_DYNAMIC_ESCORTNPC
ObjectData const creatureData[]
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
void NormalizeMapCoord(float &c)
void InitializeAI() override
float GetMaxPlayerDistance() const
void Start(bool isActiveAttacker=true, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false)
void AddWaypoint(uint32 id, float x, float y, float z, bool run)
EscortAI(Creature *creature)
void EnterEvadeMode(EvadeReason why) override
void MoveInLineOfSight(Unit *who) override
bool HasEscortState(uint32 escortState)
virtual void UpdateEscortAI(uint32 diff)
void AddEscortState(uint32 escortState)
Quest const * _escortQuest
void RemoveEscortState(uint32 escortState)
void MovementInform(uint32, uint32) override
void LoadPath(uint32 pathId)
Player * GetPlayerForEscort()
void JustDied(Unit *) override
bool IsPlayerOrGroupInRange()
void SetEscortPaused(bool on)
void UpdateAI(uint32 diff) override
bool _hasImmuneToNPCFlags
bool AssistPlayerInCombatAgainst(Unit *who)
constexpr void SetOrientation(float orientation)
std::string ToString() const
void SetCombatMovement(bool allowMovement)
bool IsCombatMovementAllowed() const
std::vector< WaypointNode > Nodes