TrinityCore
Loading...
Searching...
No Matches
GuardAI.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "GuardAI.h"
19#include "Creature.h"
20#include "Log.h"
21#include "MotionMaster.h"
22#include "Player.h"
23
25{
26 if (creature->IsGuard())
28
29 return PERMIT_BASE_NO;
30}
31
33{
35}
36
38{
39 if (Unit const* unit = obj->ToUnit())
40 if (unit->IsControlledByPlayer() && me->IsEngagedBy(unit))
41 return true;
42 return false;
43}
44
46{
47 if (!me->IsAlive())
48 {
50 me->CombatStop(true);
52 return;
53 }
54
55 TC_LOG_TRACE("scripts.ai", "GuardAI::EnterEvadeMode: {} enters evade mode.", me->GetGUID().ToString());
56
58 me->CombatStop(true);
60
62}
63
65{
66 if (killer)
67 if (Player* player = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
69}
@ PERMIT_BASE_PROACTIVE
Definition CreatureAI.h:49
@ PERMIT_BASE_NO
Definition CreatureAI.h:46
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
#define TC_LOG_TRACE(filterType__, message__,...)
Definition Log.h:178
EvadeReason
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void EngagementOver()
void SendZoneUnderAttackMessage(Player *attacker)
Send a message to LocalDefense channel for players opposition team in the zone.
bool IsGuard() const
Definition Creature.h:128
bool CanSeeAlways(WorldObject const *obj) override
Definition GuardAI.cpp:37
static int32 Permissible(Creature const *creature)
Definition GuardAI.cpp:24
void UpdateAI(uint32 diff) override
Definition GuardAI.cpp:32
void JustDied(Unit *killer) override
Definition GuardAI.cpp:64
void EnterEvadeMode(EvadeReason) override
Definition GuardAI.cpp:45
void MoveTargetedHome()
std::string ToString() const
Unit * ToUnit()
Definition Object.h:116
Definition Unit.h:635
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
Definition Unit.cpp:6012
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool IsAlive() const
Definition Unit.h:1185
bool IsEngagedBy(Unit const *who) const
Definition Unit.h:1035
void RemoveAllAuras()
Definition Unit.cpp:4382
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Object.cpp:1621