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 "Errors.h"
21#include "Log.h"
22#include "MotionMaster.h"
23#include "Player.h"
24
25GuardAI::GuardAI(Creature* creature) : ScriptedAI(creature)
26{
27}
28
30{
31 if (creature->IsGuard())
33
34 return PERMIT_BASE_NO;
35}
36
38{
39 if (!UpdateVictim())
40 return;
41
43}
44
46{
47 if (Unit const* unit = obj->ToUnit())
48 if (unit->IsControlledByPlayer() && me->IsEngagedBy(unit))
49 return true;
50 return false;
51}
52
54{
55 if (!me->IsAlive())
56 {
58 me->CombatStop(true);
60 return;
61 }
62
63 TC_LOG_TRACE("scripts.ai", "GuardAI::EnterEvadeMode: {} enters evade mode.", me->GetGUID().ToString());
64
66 me->CombatStop(true);
68
70}
71
73{
74 if (killer)
75 if (Player* player = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
77}
@ PERMIT_BASE_PROACTIVE
Definition CreatureAI.h:46
@ PERMIT_BASE_NO
Definition CreatureAI.h:43
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
#define TC_LOG_TRACE(filterType__,...)
Definition Log.h:153
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
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:99
bool CanSeeAlways(WorldObject const *obj) override
Definition GuardAI.cpp:45
static int32 Permissible(Creature const *creature)
Definition GuardAI.cpp:29
void UpdateAI(uint32 diff) override
Definition GuardAI.cpp:37
void JustDied(Unit *killer) override
Definition GuardAI.cpp:72
GuardAI(Creature *creature)
Definition GuardAI.cpp:25
void EnterEvadeMode(EvadeReason) override
Definition GuardAI.cpp:53
void MoveTargetedHome()
std::string ToString() const
static Unit * ToUnit(Object *o)
Definition Object.h:192
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
Definition Unit.h:769
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool IsAlive() const
Definition Unit.h:1234
bool IsEngagedBy(Unit const *who) const
Definition Unit.h:1127
void RemoveAllAuras()
Definition Unit.cpp:4157
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:5691
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Object.cpp:2203