TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CombatAI.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_COMBATAI_H
20 #define TRINITY_COMBATAI_H
21 
22 #include "CreatureAI.h"
23 #include "CreatureAIImpl.h"
24 #include "ConditionMgr.h"
25 
26 class Creature;
27 
29 {
30  public:
31  explicit AggressorAI(Creature* c) : CreatureAI(c) { }
32 
33  void UpdateAI(uint32) override;
34  static int Permissible(const Creature*);
35 };
36 
37 typedef std::vector<uint32> SpellVct;
38 
40 {
41  public:
42  explicit CombatAI(Creature* c) : CreatureAI(c) { }
43 
44  void InitializeAI() override;
45  void Reset() override;
46  void EnterCombat(Unit* who) override;
47  void JustDied(Unit* killer) override;
48  void UpdateAI(uint32 diff) override;
49  void SpellInterrupted(uint32 spellId, uint32 unTimeMs) override;
50 
51  static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
52 
53  protected:
56 };
57 
59 {
60  public:
61  explicit CasterAI(Creature* c) : CombatAI(c) { m_attackDist = MELEE_RANGE; }
62  void InitializeAI() override;
63  void AttackStart(Unit* victim) override { AttackStartCaster(victim, m_attackDist); }
64  void UpdateAI(uint32 diff) override;
65  void EnterCombat(Unit* /*who*/) override;
66  private:
67  float m_attackDist;
68 };
69 
71 {
72  public:
73  explicit ArcherAI(Creature* c);
74  void AttackStart(Unit* who) override;
75  void UpdateAI(uint32 diff) override;
76 
77  static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
78 
79  protected:
80  float m_minRange;
81 };
82 
84 {
85  public:
86  explicit TurretAI(Creature* c);
87  bool CanAIAttack(Unit const* who) const override;
88  void AttackStart(Unit* who) override;
89  void UpdateAI(uint32 diff) override;
90 
91  static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
92 
93  protected:
94  float m_minRange;
95 };
96 
97 #define VEHICLE_CONDITION_CHECK_TIME 1000
98 #define VEHICLE_DISMISS_TIME 5000
99 
101 {
102  public:
103  explicit VehicleAI(Creature* creature);
104 
105  void UpdateAI(uint32 diff) override;
106  void MoveInLineOfSight(Unit*) override { }
107  void AttackStart(Unit*) override { }
108  void OnCharmed(bool apply) override;
109 
110  static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
111 
112  private:
113  void LoadConditions();
114  void CheckConditions(uint32 diff);
119 };
120 
121 #endif
Definition: CombatAI.h:70
bool m_DoDismiss
Definition: CombatAI.h:117
Definition: CombatAI.h:83
SpellVct spells
Definition: CombatAI.h:55
EventMap events
Definition: CombatAI.h:54
std::vector< uint32 > SpellVct
Definition: CombatAI.h:37
static int Permissible(Creature const *)
Definition: CombatAI.h:91
static int Permissible(Creature const *)
Definition: CombatAI.h:110
Definition: CreatureAI.h:207
void OnCharmed(bool apply) override
Definition: CreatureAI.cpp:32
void InitializeAI() override
Definition: CombatAI.cpp:51
static int Permissible(Creature const *)
Definition: CombatAI.h:51
virtual void UpdateAI(uint32 diff)=0
Definition: Creature.h:467
uint32 m_DismissTimer
Definition: CombatAI.h:118
void apply(T *val)
Definition: ByteConverter.h:41
virtual bool CanAIAttack(Unit const *) const
Definition: UnitAI.h:126
CasterAI(Creature *c)
Definition: CombatAI.h:61
virtual void InitializeAI()
Definition: UnitAI.h:130
virtual void EnterCombat(Unit *)
Definition: CreatureAI.h:114
bool m_HasConditions
Definition: CombatAI.h:115
CombatAI(Creature *c)
Definition: CombatAI.h:42
Definition: CombatAI.h:58
Definition: CombatAI.h:39
Definition: EventMap.h:25
Definition: CreatureAI.h:68
virtual void JustDied(Unit *)
Definition: CreatureAI.h:117
uint32_t uint32
Definition: Define.h:150
void EnterCombat(Unit *who) override
Definition: CombatAI.cpp:72
float m_minRange
Definition: CombatAI.h:94
AggressorAI(Creature *c)
Definition: CombatAI.h:31
void MoveInLineOfSight(Unit *) override
Definition: CombatAI.h:106
#define TC_GAME_API
Definition: Define.h:134
Definition: CombatAI.h:100
void AttackStart(Unit *victim) override
Definition: CombatAI.h:63
#define MELEE_RANGE
Definition: Object.h:48
Definition: FactoryHolder.h:52
virtual void Reset()
Definition: UnitAI.h:132
Definition: Unit.h:1305
void UpdateAI(uint32 diff) override
Definition: CombatAI.cpp:83
void AttackStart(Unit *) override
Definition: CombatAI.h:107
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29
uint32 m_ConditionsTimer
Definition: CombatAI.h:116
virtual void SpellInterrupted(uint32, uint32)
Definition: UnitAI.h:238
Definition: CombatAI.h:28
float m_minRange
Definition: CombatAI.h:80
static int Permissible(Creature const *)
Definition: CombatAI.h:77
void AttackStartCaster(Unit *victim, float dist)
Definition: UnitAI.cpp:43
float m_attackDist
Definition: CombatAI.h:67