TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PetAI.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITY_PETAI_H
20 #define TRINITY_PETAI_H
21 
22 #include "CreatureAI.h"
23 #include "Timer.h"
24 
25 class Creature;
26 class Spell;
27 
29 {
30  public:
31 
32  explicit PetAI(Creature* c);
33 
34  void UpdateAI(uint32) override;
35  static int Permissible(const Creature*);
36 
37  void KilledUnit(Unit* /*victim*/) override;
38  void AttackStart(Unit* target) override;
39  void MovementInform(uint32 moveType, uint32 data) override;
40  void OwnerAttackedBy(Unit* attacker) override;
41  void OwnerAttacked(Unit* target) override;
42  void AttackedBy(Unit* attacker) override;
43  void ReceiveEmote(Player* player, uint32 textEmote) override;
44 
45  // The following aren't used by the PetAI but need to be defined to override
46  // default CreatureAI functions which interfere with the PetAI
47  //
48  void MoveInLineOfSight(Unit* /*who*/) override { } // CreatureAI interferes with returning pets
49  void MoveInLineOfSight_Safe(Unit* /*who*/) { } // CreatureAI interferes with returning pets
50  void EnterEvadeMode(EvadeReason /*why*/) override { } // For fleeing, pets don't use this type of Evade mechanic
51 
52  private:
53  bool _isVisible(Unit*) const;
54  bool _needToStop(void);
55  void _stopAttack(void);
56 
57  void UpdateAllies();
58 
62 
63  Unit* SelectNextTarget(bool allowAutoSelect) const;
64  void HandleReturnMovement();
65  void DoAttack(Unit* target, bool chase);
66  bool CanAttack(Unit* target);
67  void ClearCharmInfoFlags();
68 };
69 #endif
70 
uint32 m_updateAlliesTimer
Definition: PetAI.h:61
virtual void ReceiveEmote(Player *, uint32)
Definition: CreatureAI.h:153
virtual void AttackedBy(Unit *)
Definition: CreatureAI.h:136
EvadeReason
Definition: CreatureAI.h:85
virtual void UpdateAI(uint32 diff)=0
Definition: Creature.h:467
virtual void OwnerAttacked(Unit *)
Definition: CreatureAI.h:159
void EnterEvadeMode(EvadeReason) override
Definition: PetAI.h:50
GuidSet m_AllySet
Definition: PetAI.h:60
void MoveInLineOfSight_Safe(Unit *)
Definition: PetAI.h:49
virtual void KilledUnit(Unit *)
Definition: CreatureAI.h:120
TimeTracker i_tracker
Definition: PetAI.h:59
Definition: CreatureAI.h:68
uint32_t uint32
Definition: Define.h:150
Definition: PetAI.h:28
void MoveInLineOfSight(Unit *) override
Definition: PetAI.h:48
Definition: Timer.h:100
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
#define TC_GAME_API
Definition: Define.h:134
Definition: FactoryHolder.h:52
Definition: Unit.h:1305
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29
virtual void MovementInform(uint32, uint32)
Definition: CreatureAI.h:143
virtual void OwnerAttackedBy(Unit *)
Definition: CreatureAI.h:156
Definition: Spell.h:294