TrinityCore
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:47
@ PERMIT_BASE_NO
Definition: CreatureAI.h:44
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:153
EvadeReason
Definition: UnitAICommon.h:30
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void EngagementOver()
Definition: CreatureAI.cpp:287
void SendZoneUnderAttackMessage(Player *attacker)
Send a message to LocalDefense channel for players opposition team in the zone.
Definition: Creature.cpp:2814
bool IsGuard() const
Definition: Creature.h:114
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
Definition: ObjectGuid.cpp:554
static Unit * ToUnit(Object *o)
Definition: Object.h:225
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Definition: Unit.h:627
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
Definition: Unit.cpp:5827
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsAlive() const
Definition: Unit.h:1164
bool IsEngagedBy(Unit const *who) const
Definition: Unit.h:1020
void RemoveAllAuras()
Definition: Unit.cpp:4242
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Object.cpp:2252