root/trunk/src/game/Unit.h @ 28

Revision 28, 62.2 kB (checked in by yumileroy, 17 years ago)

[svn] * Updated to 6743 and 685

Moved language id used by Arena to a higher place to solve conflicts
Added the empty script folders

Original author: Neo2003
Date: 2008-10-09 08:42:22-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18
19#ifndef __UNIT_H
20#define __UNIT_H
21
22#include "Common.h"
23#include "Object.h"
24#include "Opcodes.h"
25#include "Mthread.h"
26#include "SpellAuraDefines.h"
27#include "UpdateFields.h"
28#include "SharedDefines.h"
29#include "ThreatManager.h"
30#include "HostilRefManager.h"
31#include "FollowerReference.h"
32#include "FollowerRefManager.h"
33#include "Utilities/EventProcessor.h"
34#include "MotionMaster.h"
35#include "Database/DBCStructure.h"
36#include <list>
37
38enum SpellInterruptFlags
39{
40    SPELL_INTERRUPT_FLAG_MOVEMENT     = 0x01,
41    SPELL_INTERRUPT_FLAG_DAMAGE       = 0x02,
42    SPELL_INTERRUPT_FLAG_INTERRUPT    = 0x04,
43    SPELL_INTERRUPT_FLAG_AUTOATTACK   = 0x08,
44    //SPELL_INTERRUPT_FLAG_TURNING      = 0x10              // not turning - maybe _complete_ interrupt on direct damage?
45};
46
47enum SpellChannelInterruptFlags
48{
49    CHANNEL_FLAG_DAMAGE      = 0x0002,
50    CHANNEL_FLAG_MOVEMENT    = 0x0008,
51    CHANNEL_FLAG_TURNING     = 0x0010,
52    CHANNEL_FLAG_DAMAGE2     = 0x0080,
53    CHANNEL_FLAG_DELAY       = 0x4000
54};
55
56enum SpellAuraInterruptFlags
57{
58    AURA_INTERRUPT_FLAG_UNK0                = 0x00000001,   // 0    removed when getting hit by a negative spell?
59    AURA_INTERRUPT_FLAG_DAMAGE              = 0x00000002,   // 1    removed by any damage
60    AURA_INTERRUPT_FLAG_UNK2                = 0x00000004,   // 2
61    AURA_INTERRUPT_FLAG_MOVE                = 0x00000008,   // 3    removed by any movement
62    AURA_INTERRUPT_FLAG_TURNING             = 0x00000010,   // 4    removed by any turning
63    AURA_INTERRUPT_FLAG_ENTER_COMBAT        = 0x00000020,   // 5    removed by entering combat
64    AURA_INTERRUPT_FLAG_NOT_MOUNTED         = 0x00000040,   // 6    removed by unmounting
65    AURA_INTERRUPT_FLAG_NOT_ABOVEWATER      = 0x00000080,   // 7    removed by entering water
66    AURA_INTERRUPT_FLAG_NOT_UNDERWATER      = 0x00000100,   // 8    removed by leaving water
67    AURA_INTERRUPT_FLAG_NOT_SHEATHED        = 0x00000200,   // 9    removed by unsheathing
68    AURA_INTERRUPT_FLAG_UNK10               = 0x00000400,   // 10
69    AURA_INTERRUPT_FLAG_UNK11               = 0x00000800,   // 11
70    AURA_INTERRUPT_FLAG_UNK12               = 0x00001000,   // 12   removed by attack?
71    AURA_INTERRUPT_FLAG_UNK13               = 0x00002000,   // 13
72    AURA_INTERRUPT_FLAG_UNK14               = 0x00004000,   // 14
73    AURA_INTERRUPT_FLAG_UNK15               = 0x00008000,   // 15   removed by casting a spell?
74    AURA_INTERRUPT_FLAG_UNK16               = 0x00010000,   // 16
75    AURA_INTERRUPT_FLAG_MOUNTING            = 0x00020000,   // 17   removed by mounting
76    AURA_INTERRUPT_FLAG_NOT_SEATED          = 0x00040000,   // 18   removed by standing up
77    AURA_INTERRUPT_FLAG_CHANGE_MAP          = 0x00080000,   // 19   leaving map/getting teleported
78    AURA_INTERRUPT_FLAG_UNK20               = 0x00100000,   // 20
79    AURA_INTERRUPT_FLAG_UNK21               = 0x00200000,   // 21
80    AURA_INTERRUPT_FLAG_UNK22               = 0x00400000,   // 22
81    AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT    = 0x00800000,   // 23   removed by entering pvp combat
82    AURA_INTERRUPT_FLAG_DIRECT_DAMAGE       = 0x01000000    // 24   removed by any direct damage
83};
84
85enum SpellModOp
86{
87    SPELLMOD_DAMAGE                 = 0,
88    SPELLMOD_DURATION               = 1,
89    SPELLMOD_THREAT                 = 2,
90    SPELLMOD_EFFECT1                = 3,
91    SPELLMOD_CHARGES                = 4,
92    SPELLMOD_RANGE                  = 5,
93    SPELLMOD_RADIUS                 = 6,
94    SPELLMOD_CRITICAL_CHANCE        = 7,
95    SPELLMOD_ALL_EFFECTS            = 8,
96    SPELLMOD_NOT_LOSE_CASTING_TIME  = 9,
97    SPELLMOD_CASTING_TIME           = 10,
98    SPELLMOD_COOLDOWN               = 11,
99    SPELLMOD_EFFECT2                = 12,
100    // spellmod 13 unused
101    SPELLMOD_COST                   = 14,
102    SPELLMOD_CRIT_DAMAGE_BONUS      = 15,
103    SPELLMOD_RESIST_MISS_CHANCE     = 16,
104    SPELLMOD_JUMP_TARGETS           = 17,
105    SPELLMOD_CHANCE_OF_SUCCESS      = 18,
106    SPELLMOD_ACTIVATION_TIME        = 19,
107    SPELLMOD_EFFECT_PAST_FIRST      = 20,
108    SPELLMOD_CASTING_TIME_OLD       = 21,
109    SPELLMOD_DOT                    = 22,
110    SPELLMOD_EFFECT3                = 23,
111    SPELLMOD_SPELL_BONUS_DAMAGE     = 24,
112    // spellmod 25, 26 unused
113    SPELLMOD_MULTIPLE_VALUE         = 27,
114    SPELLMOD_RESIST_DISPEL_CHANCE   = 28
115};
116
117#define MAX_SPELLMOD 32
118
119enum SpellFacingFlags
120{
121    SPELL_FACING_FLAG_INFRONT = 0x0001
122};
123
124#define BASE_MINDAMAGE 1.0f
125#define BASE_MAXDAMAGE 2.0f
126#define BASE_ATTACK_TIME 2000
127
128// high byte (3 from 0..3) of UNIT_FIELD_BYTES_2
129enum ShapeshiftForm
130{
131    FORM_NONE               = 0x00,
132    FORM_CAT                = 0x01,
133    FORM_TREE               = 0x02,
134    FORM_TRAVEL             = 0x03,
135    FORM_AQUA               = 0x04,
136    FORM_BEAR               = 0x05,
137    FORM_AMBIENT            = 0x06,
138    FORM_GHOUL              = 0x07,
139    FORM_DIREBEAR           = 0x08,
140    FORM_CREATUREBEAR       = 0x0E,
141    FORM_CREATURECAT        = 0x0F,
142    FORM_GHOSTWOLF          = 0x10,
143    FORM_BATTLESTANCE       = 0x11,
144    FORM_DEFENSIVESTANCE    = 0x12,
145    FORM_BERSERKERSTANCE    = 0x13,
146    FORM_TEST               = 0x14,
147    FORM_ZOMBIE             = 0x15,
148    FORM_FLIGHT_EPIC        = 0x1B,
149    FORM_SHADOW             = 0x1C,
150    FORM_FLIGHT             = 0x1D,
151    FORM_STEALTH            = 0x1E,
152    FORM_MOONKIN            = 0x1F,
153    FORM_SPIRITOFREDEMPTION = 0x20
154};
155
156// low byte ( 0 from 0..3 ) of UNIT_FIELD_BYTES_2
157enum SheathState
158{
159    SHEATH_STATE_UNARMED  = 0,                              // non prepared weapon
160    SHEATH_STATE_MELEE    = 1,                              // prepared melee weapon
161    SHEATH_STATE_RANGED   = 2                               // prepared ranged weapon
162};
163
164// byte (1 from 0..3) of UNIT_FIELD_BYTES_2
165enum UnitBytes2_Flags
166{
167    UNIT_BYTE2_FLAG_UNK0  = 0x01,
168    UNIT_BYTE2_FLAG_UNK1  = 0x02,
169    UNIT_BYTE2_FLAG_UNK2  = 0x04,
170    UNIT_BYTE2_FLAG_UNK3  = 0x08,
171    UNIT_BYTE2_FLAG_AURAS = 0x10,                           // show possitive auras as positive, and allow its dispel
172    UNIT_BYTE2_FLAG_UNK5  = 0x20,
173    UNIT_BYTE2_FLAG_UNK6  = 0x40,
174    UNIT_BYTE2_FLAG_UNK7  = 0x80
175};
176
177// byte (2 from 0..3) of UNIT_FIELD_BYTES_2
178enum UnitRename
179{
180    UNIT_RENAME_NOT_ALLOWED = 0x02,
181    UNIT_RENAME_ALLOWED     = 0x03
182};
183
184#define CREATURE_MAX_SPELLS     4
185
186enum Swing
187{
188    NOSWING                    = 0,
189    SINGLEHANDEDSWING          = 1,
190    TWOHANDEDSWING             = 2
191};
192
193enum VictimState
194{
195    VICTIMSTATE_UNKNOWN1       = 0,
196    VICTIMSTATE_NORMAL         = 1,
197    VICTIMSTATE_DODGE          = 2,
198    VICTIMSTATE_PARRY          = 3,
199    VICTIMSTATE_INTERRUPT      = 4,
200    VICTIMSTATE_BLOCKS         = 5,
201    VICTIMSTATE_EVADES         = 6,
202    VICTIMSTATE_IS_IMMUNE      = 7,
203    VICTIMSTATE_DEFLECTS       = 8
204};
205
206enum HitInfo
207{
208    HITINFO_NORMALSWING         = 0x00000000,
209    HITINFO_UNK1                = 0x00000001,               // req correct packet structure
210    HITINFO_NORMALSWING2        = 0x00000002,
211    HITINFO_LEFTSWING           = 0x00000004,
212    HITINFO_MISS                = 0x00000010,
213    HITINFO_ABSORB              = 0x00000020,               // plays absorb sound
214    HITINFO_RESIST              = 0x00000040,               // resisted atleast some damage
215    HITINFO_CRITICALHIT         = 0x00000080,
216    HITINFO_GLANCING            = 0x00004000,
217    HITINFO_CRUSHING            = 0x00008000,
218    HITINFO_NOACTION            = 0x00010000,
219    HITINFO_SWINGNOHITSOUND     = 0x00080000
220};
221
222//i would like to remove this: (it is defined in item.h
223enum InventorySlot
224{
225    NULL_BAG                   = 0,
226    NULL_SLOT                  = 255
227};
228
229struct FactionTemplateEntry;
230struct Modifier;
231struct SpellEntry;
232struct SpellEntryExt;
233
234class Aura;
235class Creature;
236class Spell;
237class DynamicObject;
238class GameObject;
239class Item;
240class Pet;
241class Path;
242class PetAura;
243
244struct SpellImmune
245{
246    uint32 type;
247    uint32 spellId;
248};
249
250typedef std::list<SpellImmune> SpellImmuneList;
251
252enum UnitModifierType
253{
254    BASE_VALUE = 0,
255    BASE_PCT = 1,
256    TOTAL_VALUE = 2,
257    TOTAL_PCT = 3,
258    MODIFIER_TYPE_END = 4
259};
260
261enum WeaponDamageRange
262{
263    MINDAMAGE,
264    MAXDAMAGE
265};
266
267enum DamageTypeToSchool
268{
269    RESISTANCE,
270    DAMAGE_DEALT,
271    DAMAGE_TAKEN
272};
273
274enum AuraRemoveMode
275{
276    AURA_REMOVE_BY_DEFAULT,
277    AURA_REMOVE_BY_STACK,                                   // at replace by semillar aura
278    AURA_REMOVE_BY_CANCEL,
279    AURA_REMOVE_BY_DISPEL,
280    AURA_REMOVE_BY_DEATH
281};
282
283enum UnitMods
284{
285    UNIT_MOD_STAT_STRENGTH,                                 // UNIT_MOD_STAT_STRENGTH..UNIT_MOD_STAT_SPIRIT must be in existed order, it's accessed by index values of Stats enum.
286    UNIT_MOD_STAT_AGILITY,
287    UNIT_MOD_STAT_STAMINA,
288    UNIT_MOD_STAT_INTELLECT,
289    UNIT_MOD_STAT_SPIRIT,
290    UNIT_MOD_HEALTH,
291    UNIT_MOD_MANA,                                          // UNIT_MOD_MANA..UNIT_MOD_HAPPINESS must be in existed order, it's accessed by index values of Powers enum.
292    UNIT_MOD_RAGE,
293    UNIT_MOD_FOCUS,
294    UNIT_MOD_ENERGY,
295    UNIT_MOD_HAPPINESS,
296    UNIT_MOD_ARMOR,                                         // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum.
297    UNIT_MOD_RESISTANCE_HOLY,
298    UNIT_MOD_RESISTANCE_FIRE,
299    UNIT_MOD_RESISTANCE_NATURE,
300    UNIT_MOD_RESISTANCE_FROST,
301    UNIT_MOD_RESISTANCE_SHADOW,
302    UNIT_MOD_RESISTANCE_ARCANE,
303    UNIT_MOD_ATTACK_POWER,
304    UNIT_MOD_ATTACK_POWER_RANGED,
305    UNIT_MOD_DAMAGE_MAINHAND,
306    UNIT_MOD_DAMAGE_OFFHAND,
307    UNIT_MOD_DAMAGE_RANGED,
308    UNIT_MOD_END,
309    // synonyms
310    UNIT_MOD_STAT_START = UNIT_MOD_STAT_STRENGTH,
311    UNIT_MOD_STAT_END = UNIT_MOD_STAT_SPIRIT + 1,
312    UNIT_MOD_RESISTANCE_START = UNIT_MOD_ARMOR,
313    UNIT_MOD_RESISTANCE_END = UNIT_MOD_RESISTANCE_ARCANE + 1,
314    UNIT_MOD_POWER_START = UNIT_MOD_MANA,
315    UNIT_MOD_POWER_END = UNIT_MOD_HAPPINESS + 1
316};
317
318enum BaseModGroup
319{
320    CRIT_PERCENTAGE,
321    RANGED_CRIT_PERCENTAGE,
322    OFFHAND_CRIT_PERCENTAGE,
323    SHIELD_BLOCK_VALUE,
324    BASEMOD_END
325};
326
327enum BaseModType
328{
329    FLAT_MOD,
330    PCT_MOD
331};
332
333#define MOD_END (PCT_MOD+1)
334
335enum DeathState
336{
337    ALIVE       = 0,
338    JUST_DIED   = 1,
339    CORPSE      = 2,
340    DEAD        = 3,
341    JUST_ALIVED = 4
342};
343
344enum UnitState
345{
346    UNIT_STAT_DIED            = 0x0001,
347    UNIT_STAT_MELEE_ATTACKING = 0x0002,                     // player is melee attacking someone
348    //UNIT_STAT_MELEE_ATTACK_BY = 0x0004,                     // player is melee attack by someone
349    UNIT_STAT_STUNNED         = 0x0008,
350    UNIT_STAT_ROAMING         = 0x0010,
351    UNIT_STAT_CHASE           = 0x0020,
352    UNIT_STAT_SEARCHING       = 0x0040,
353    UNIT_STAT_FLEEING         = 0x0080,
354    UNIT_STAT_MOVING          = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING),
355    UNIT_STAT_IN_FLIGHT       = 0x0100,                     // player is in flight mode
356    UNIT_STAT_FOLLOW          = 0x0200,
357    UNIT_STAT_ROOT            = 0x0400,
358    UNIT_STAT_CONFUSED        = 0x0800,
359    UNIT_STAT_DISTRACTED      = 0x1000,
360    UNIT_STAT_ISOLATED        = 0x2000,                     // area auras do not affect other players
361    UNIT_STAT_ATTACK_PLAYER   = 0x4000,
362    UNIT_STAT_ALL_STATE       = 0xffff                      //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT)
363};
364
365enum UnitMoveType
366{
367    MOVE_WALK       = 0,
368    MOVE_RUN        = 1,
369    MOVE_WALKBACK   = 2,
370    MOVE_SWIM       = 3,
371    MOVE_SWIMBACK   = 4,
372    MOVE_TURN       = 5,
373    MOVE_FLY        = 6,
374    MOVE_FLYBACK    = 7
375};
376
377#define MAX_MOVE_TYPE 8
378
379extern float baseMoveSpeed[MAX_MOVE_TYPE];
380
381enum WeaponAttackType
382{
383    BASE_ATTACK   = 0,
384    OFF_ATTACK    = 1,
385    RANGED_ATTACK = 2
386};
387
388#define MAX_ATTACK  3
389
390enum CombatRating
391{
392    CR_WEAPON_SKILL             = 0,
393    CR_DEFENSE_SKILL            = 1,
394    CR_DODGE                    = 2,
395    CR_PARRY                    = 3,
396    CR_BLOCK                    = 4,
397    CR_HIT_MELEE                = 5,
398    CR_HIT_RANGED               = 6,
399    CR_HIT_SPELL                = 7,
400    CR_CRIT_MELEE               = 8,
401    CR_CRIT_RANGED              = 9,
402    CR_CRIT_SPELL               = 10,
403    CR_HIT_TAKEN_MELEE          = 11,
404    CR_HIT_TAKEN_RANGED         = 12,
405    CR_HIT_TAKEN_SPELL          = 13,
406    CR_CRIT_TAKEN_MELEE         = 14,
407    CR_CRIT_TAKEN_RANGED        = 15,
408    CR_CRIT_TAKEN_SPELL         = 16,
409    CR_HASTE_MELEE              = 17,
410    CR_HASTE_RANGED             = 18,
411    CR_HASTE_SPELL              = 19,
412    CR_WEAPON_SKILL_MAINHAND    = 20,
413    CR_WEAPON_SKILL_OFFHAND     = 21,
414    CR_WEAPON_SKILL_RANGED      = 22,
415    CR_EXPERTISE                = 23
416};
417
418#define MAX_COMBAT_RATING         24
419
420enum DamageEffectType
421{
422    DIRECT_DAMAGE           = 0,                            // used for normal weapon damage (not for class abilities or spells)
423    SPELL_DIRECT_DAMAGE     = 1,                            // spell/class abilities damage
424    DOT                     = 2,
425    HEAL                    = 3,
426    NODAMAGE                = 4,                            // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
427    SELF_DAMAGE             = 5
428};
429
430enum UnitVisibility
431{
432    VISIBILITY_OFF                = 0,                      // absolute, not detectable, GM-like, can see all other
433    VISIBILITY_ON                 = 1,
434    VISIBILITY_GROUP_STEALTH      = 2,                      // detect chance, seen and can see group members
435    VISIBILITY_GROUP_INVISIBILITY = 3,                      // invisibility, can see and can be seen only another invisible unit or invisible detection unit, set only if not stealthed, and in checks not used (mask used instead)
436    VISIBILITY_GROUP_NO_DETECT    = 4,                      // state just at stealth apply for update Grid state. Don't remove, otherwise stealth spells will break
437    VISIBILITY_RESPAWN            = 5                       // special totally not detectable visibility for force delete object at respawn command
438};
439
440// Value masks for UNIT_FIELD_FLAGS
441enum UnitFlags
442{
443    UNIT_FLAG_UNKNOWN7         = 0x00000001,
444    UNIT_FLAG_NON_ATTACKABLE   = 0x00000002,                // not attackable
445    UNIT_FLAG_DISABLE_MOVE     = 0x00000004,
446    UNIT_FLAG_PVP_ATTACKABLE   = 0x00000008,                // allow apply pvp rules to attackable state in addition to faction dependent state
447    UNIT_FLAG_RENAME           = 0x00000010,
448    UNIT_FLAG_PREPARATION      = 0x00000020,                // don't take reagents for spells with SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP
449    UNIT_FLAG_UNKNOWN9         = 0x00000040,
450    UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080,                // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE
451    UNIT_FLAG_UNKNOWN2         = 0x00000100,                // 2.0.8
452    UNIT_FLAG_UNKNOWN11        = 0x00000200,
453    UNIT_FLAG_LOOTING          = 0x00000400,                // loot animation
454    UNIT_FLAG_PET_IN_COMBAT    = 0x00000800,                // in combat?, 2.0.8
455    UNIT_FLAG_PVP              = 0x00001000,
456    UNIT_FLAG_SILENCED         = 0x00002000,                // silenced, 2.1.1
457    UNIT_FLAG_UNKNOWN4         = 0x00004000,                // 2.0.8
458    UNIT_FLAG_UNKNOWN13        = 0x00008000,
459    UNIT_FLAG_UNKNOWN14        = 0x00010000,
460    UNIT_FLAG_PACIFIED         = 0x00020000,
461    UNIT_FLAG_DISABLE_ROTATE   = 0x00040000,                // stunned, 2.1.1
462    UNIT_FLAG_IN_COMBAT        = 0x00080000,
463    UNIT_FLAG_TAXI_FLIGHT      = 0x00100000,                // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag
464    UNIT_FLAG_DISARMED         = 0x00200000,                // disable melee spells casting..., "Required melee weapon" added to melee spells tooltip.
465    UNIT_FLAG_CONFUSED         = 0x00400000,
466    UNIT_FLAG_FLEEING          = 0x00800000,
467    UNIT_FLAG_UNKNOWN5         = 0x01000000,                // used in spell Eyes of the Beast for pet...
468    UNIT_FLAG_NOT_SELECTABLE   = 0x02000000,
469    UNIT_FLAG_SKINNABLE        = 0x04000000,
470    UNIT_FLAG_MOUNT            = 0x08000000,
471    UNIT_FLAG_UNKNOWN17        = 0x10000000,
472    UNIT_FLAG_UNKNOWN6         = 0x20000000,                // used in Feing Death spell
473    UNIT_FLAG_SHEATHE          = 0x40000000
474};
475
476// Value masks for UNIT_FIELD_FLAGS_2
477enum UnitFlags2
478{
479    UNIT_FLAG2_FEIGN_DEATH    = 0x00000001,
480    UNIT_FLAG2_COMPREHEND_LANG= 0x00000008,
481    UNIT_FLAG2_FORCE_MOVE     = 0x00000040
482};
483
484/// Non Player Character flags
485enum NPCFlags
486{
487    UNIT_NPC_FLAG_NONE                  = 0x00000000,
488    UNIT_NPC_FLAG_GOSSIP                = 0x00000001,       // 100%
489    UNIT_NPC_FLAG_QUESTGIVER            = 0x00000002,       // guessed, probably ok
490    UNIT_NPC_FLAG_UNK1                  = 0x00000004,
491    UNIT_NPC_FLAG_UNK2                  = 0x00000008,
492    UNIT_NPC_FLAG_TRAINER               = 0x00000010,       // 100%
493    UNIT_NPC_FLAG_TRAINER_CLASS         = 0x00000020,       // 100%
494    UNIT_NPC_FLAG_TRAINER_PROFESSION    = 0x00000040,       // 100%
495    UNIT_NPC_FLAG_VENDOR                = 0x00000080,       // 100%
496    UNIT_NPC_FLAG_VENDOR_AMMO           = 0x00000100,       // 100%, general goods vendor
497    UNIT_NPC_FLAG_VENDOR_FOOD           = 0x00000200,       // 100%
498    UNIT_NPC_FLAG_VENDOR_POISON         = 0x00000400,       // guessed
499    UNIT_NPC_FLAG_VENDOR_REAGENT        = 0x00000800,       // 100%
500    UNIT_NPC_FLAG_REPAIR                = 0x00001000,       // 100%
501    UNIT_NPC_FLAG_FLIGHTMASTER          = 0x00002000,       // 100%
502    UNIT_NPC_FLAG_SPIRITHEALER          = 0x00004000,       // guessed
503    UNIT_NPC_FLAG_SPIRITGUIDE           = 0x00008000,       // guessed
504    UNIT_NPC_FLAG_INNKEEPER             = 0x00010000,       // 100%
505    UNIT_NPC_FLAG_BANKER                = 0x00020000,       // 100%
506    UNIT_NPC_FLAG_PETITIONER            = 0x00040000,       // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions
507    UNIT_NPC_FLAG_TABARDDESIGNER        = 0x00080000,       // 100%
508    UNIT_NPC_FLAG_BATTLEMASTER          = 0x00100000,       // 100%
509    UNIT_NPC_FLAG_AUCTIONEER            = 0x00200000,       // 100%
510    UNIT_NPC_FLAG_STABLEMASTER          = 0x00400000,       // 100%
511    UNIT_NPC_FLAG_GUILD_BANKER          = 0x00800000,       // cause client to send 997 opcode
512    UNIT_NPC_FLAG_UNK3                  = 0x01000000,       // cause client to send 1015 opcode
513    UNIT_NPC_FLAG_GUARD                 = 0x10000000,       // custom flag for guards
514};
515
516enum MovementFlags
517{
518    MOVEMENTFLAG_NONE           = 0x00000000,
519    MOVEMENTFLAG_FORWARD        = 0x00000001,
520    MOVEMENTFLAG_BACKWARD       = 0x00000002,
521    MOVEMENTFLAG_STRAFE_LEFT    = 0x00000004,
522    MOVEMENTFLAG_STRAFE_RIGHT   = 0x00000008,
523    MOVEMENTFLAG_LEFT           = 0x00000010,
524    MOVEMENTFLAG_RIGHT          = 0x00000020,
525    MOVEMENTFLAG_PITCH_UP       = 0x00000040,
526    MOVEMENTFLAG_PITCH_DOWN     = 0x00000080,
527    MOVEMENTFLAG_WALK_MODE      = 0x00000100,               // Walking
528    MOVEMENTFLAG_ONTRANSPORT    = 0x00000200,               // Used for flying on some creatures
529    MOVEMENTFLAG_LEVITATING     = 0x00000400,
530    MOVEMENTFLAG_FLY_UNK1       = 0x00000800,
531    MOVEMENTFLAG_JUMPING        = 0x00001000,
532    MOVEMENTFLAG_UNK4           = 0x00002000,
533    MOVEMENTFLAG_FALLING        = 0x00004000,
534    // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
535    MOVEMENTFLAG_SWIMMING       = 0x00200000,               // appears with fly flag also
536    MOVEMENTFLAG_FLY_UP         = 0x00400000,
537    MOVEMENTFLAG_CAN_FLY        = 0x00800000,
538    MOVEMENTFLAG_FLYING         = 0x01000000,
539    MOVEMENTFLAG_FLYING2        = 0x02000000,               // Actual flying mode
540    MOVEMENTFLAG_SPLINE         = 0x04000000,               // used for flight paths
541    MOVEMENTFLAG_SPLINE2        = 0x08000000,               // used for flight paths
542    MOVEMENTFLAG_WATERWALKING   = 0x10000000,               // prevent unit from falling through water
543    MOVEMENTFLAG_SAFE_FALL      = 0x20000000,               // active rogue safe fall spell (passive)
544    MOVEMENTFLAG_UNK3           = 0x40000000
545};
546
547enum DiminishingLevels
548{
549    DIMINISHING_LEVEL_1             = 0,
550    DIMINISHING_LEVEL_2             = 1,
551    DIMINISHING_LEVEL_3             = 2,
552    DIMINISHING_LEVEL_IMMUNE        = 3
553};
554
555struct DiminishingReturn
556{
557    DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count) : DRGroup(group), hitTime(t), hitCount(count), stack(0) {}
558
559    DiminishingGroup        DRGroup:16;
560    uint16                  stack:16;
561    uint32                  hitTime;
562    uint32                  hitCount;
563};
564
565enum MeleeHitOutcome
566{
567    MELEE_HIT_EVADE, MELEE_HIT_MISS, MELEE_HIT_DODGE, MELEE_HIT_BLOCK, MELEE_HIT_PARRY,
568    MELEE_HIT_GLANCING, MELEE_HIT_CRIT, MELEE_HIT_CRUSHING, MELEE_HIT_NORMAL, MELEE_HIT_BLOCK_CRIT
569};
570struct CleanDamage
571{
572    CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) :
573    damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {}
574
575    uint32 damage;
576    WeaponAttackType attackType;
577    MeleeHitOutcome hitOutCome;
578};
579
580struct UnitActionBarEntry
581{
582    uint32 Type;
583    uint32 SpellOrAction;
584};
585
586#define MAX_DECLINED_NAME_CASES 5
587
588struct DeclinedName
589{
590    std::string name[MAX_DECLINED_NAME_CASES];
591};
592
593enum CurrentSpellTypes
594{
595    CURRENT_MELEE_SPELL = 0,
596    CURRENT_FIRST_NON_MELEE_SPELL = 1,                      // just counter
597    CURRENT_GENERIC_SPELL = 1,
598    CURRENT_AUTOREPEAT_SPELL = 2,
599    CURRENT_CHANNELED_SPELL = 3,
600    CURRENT_MAX_SPELL = 4                                   // just counter
601};
602
603enum ActiveStates
604{
605    ACT_ENABLED  = 0xC100,
606    ACT_DISABLED = 0x8100,
607    ACT_COMMAND  = 0x0700,
608    ACT_REACTION = 0x0600,
609    ACT_CAST     = 0x0100,
610    ACT_PASSIVE  = 0x0000,
611    ACT_DECIDE   = 0x0001
612};
613
614enum ReactStates
615{
616    REACT_PASSIVE    = 0,
617    REACT_DEFENSIVE  = 1,
618    REACT_AGGRESSIVE = 2
619};
620
621enum CommandStates
622{
623    COMMAND_STAY    = 0,
624    COMMAND_FOLLOW  = 1,
625    COMMAND_ATTACK  = 2,
626    COMMAND_ABANDON = 3
627};
628
629struct CharmSpellEntry
630{
631    uint16 spellId;
632    uint16 active;
633};
634
635struct CharmInfo
636{
637    public:
638        explicit CharmInfo(Unit* unit);
639        uint32 GetPetNumber() const { return m_petnumber; }
640        void SetPetNumber(uint32 petnumber, bool statwindow);
641
642        void SetCommandState(CommandStates st) { m_CommandState = st; }
643        CommandStates GetCommandState() { return m_CommandState; }
644        bool HasCommandState(CommandStates state) { return (m_CommandState == state); }
645        void SetReactState(ReactStates st) { m_ReactSate = st; }
646        ReactStates GetReactState() { return m_ReactSate; }
647        bool HasReactState(ReactStates state) { return (m_ReactSate == state); }
648
649        void InitPossessCreateSpells();
650        void InitCharmCreateSpells();
651        void InitPetActionBar();
652        void InitEmptyActionBar();
653                                                            //return true if successful
654        bool AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate = ACT_DECIDE);
655        void ToggleCreatureAutocast(uint32 spellid, bool apply);
656
657        UnitActionBarEntry* GetActionBarEntry(uint8 index) { return &(PetActionBar[index]); }
658        CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmspells[index]); }
659    private:
660        Unit* m_unit;
661        UnitActionBarEntry PetActionBar[10];
662        CharmSpellEntry m_charmspells[4];
663        CommandStates   m_CommandState;
664        ReactStates     m_ReactSate;
665        uint32          m_petnumber;
666};
667
668// for clearing special attacks
669#define REACTIVE_TIMER_START 4000
670
671enum ReactiveType
672{
673    REACTIVE_DEFENSE      = 1,
674    REACTIVE_HUNTER_PARRY = 2,
675    REACTIVE_CRIT         = 3,
676    REACTIVE_HUNTER_CRIT  = 4,
677    REACTIVE_OVERPOWER    = 5
678};
679
680#define MAX_REACTIVE 6
681#define MAX_TOTEM 4
682
683// delay time next attack to prevent client attack animation problems
684#define ATTACK_DISPLAY_DELAY 200
685
686class MANGOS_DLL_SPEC Unit : public WorldObject
687{
688    public:
689        typedef std::set<Unit*> AttackerSet;
690        typedef std::pair<uint32, uint8> spellEffectPair;
691        typedef std::multimap< spellEffectPair, Aura*> AuraMap;
692        typedef std::list<Aura *> AuraList;
693        typedef std::list<DiminishingReturn> Diminishing;
694        typedef std::set<AuraType> AuraTypeSet;
695        typedef std::set<uint32> ComboPointHolderSet;
696
697        virtual ~Unit ( );
698
699        void AddToWorld();
700        void RemoveFromWorld();
701
702        void CleanupsBeforeDelete();                        // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
703
704        DiminishingLevels GetDiminishing(DiminishingGroup  group);
705        void IncrDiminishing(DiminishingGroup group);
706        void ApplyDiminishingToDuration(DiminishingGroup  group, int32 &duration,Unit* caster, DiminishingLevels Level);
707        void ApplyDiminishingAura(DiminishingGroup  group, bool apply);
708        void ClearDiminishings() { m_Diminishing.clear(); }
709
710        virtual void Update( uint32 time );
711
712        void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; }
713        void resetAttackTimer(WeaponAttackType type = BASE_ATTACK);
714        uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; }
715        bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const { return m_attackTimer[type] == 0; }
716        bool haveOffhandWeapon() const;
717        bool canReachWithAttack(Unit *pVictim) const;
718        uint32 m_extraAttacks;
719
720        void _addAttacker(Unit *pAttacker)                  // must be called only from Unit::Attack(Unit*)
721        {
722            AttackerSet::iterator itr = m_attackers.find(pAttacker);
723            if(itr == m_attackers.end())
724                m_attackers.insert(pAttacker);
725        }
726        void _removeAttacker(Unit *pAttacker)               // must be called only from Unit::AttackStop()
727        {
728            AttackerSet::iterator itr = m_attackers.find(pAttacker);
729            if(itr != m_attackers.end())
730                m_attackers.erase(itr);
731        }
732        Unit * getAttackerForHelper()                       // If someone wants to help, who to give them
733        {
734            if (getVictim() != NULL)
735                return getVictim();
736
737            if (!m_attackers.empty())
738                return *(m_attackers.begin());
739
740            return NULL;
741        }
742        bool Attack(Unit *victim, bool meleeAttack);
743        void CastStop(uint32 except_spellid = 0);
744        bool AttackStop();
745        void RemoveAllAttackers();
746        AttackerSet const& getAttackers() const { return m_attackers; }
747        bool isAttackingPlayer() const;
748        Unit* getVictim() const { return m_attacking; }
749        void CombatStop(bool cast = false);
750        void CombatStopWithPets(bool cast = false);
751        Unit* SelectNearbyTarget() const;
752
753        void addUnitState(uint32 f) { m_state |= f; }
754        bool hasUnitState(const uint32 f) const { return (m_state & f); }
755        void clearUnitState(uint32 f) { m_state &= ~f; }
756        bool CanFreeMove() const
757        {
758            return !hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_IN_FLIGHT |
759                UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED ) && GetOwnerGUID()==0;
760        }
761
762        uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); }
763        virtual uint32 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); }
764        void SetLevel(uint32 lvl);
765        uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); }
766        uint32 getRaceMask() const { return 1 << (getRace()-1); }
767        uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
768        uint32 getClassMask() const { return 1 << (getClass()-1); }
769        uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); }
770
771        float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); }
772        void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); }
773        uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL) ; }
774        void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); }
775
776        uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); }
777        void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school,val); }
778
779        uint32 GetHealth()    const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
780        uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
781        void SetHealth(   uint32 val);
782        void SetMaxHealth(uint32 val);
783        int32 ModifyHealth(int32 val);
784
785        Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); }
786        void setPowerType(Powers power);
787        uint32 GetPower(   Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1   +power); }
788        uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); }
789        void SetPower(   Powers power, uint32 val);
790        void SetMaxPower(Powers power, uint32 val);
791        int32 ModifyPower(Powers power, int32 val);
792        void ApplyPowerMod(Powers power, uint32 val, bool apply);
793        void ApplyMaxPowerMod(Powers power, uint32 val, bool apply);
794
795        uint32 GetAttackTime(WeaponAttackType att) const { return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME+att)/m_modAttackSpeedPct[att]); }
796        void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val*m_modAttackSpeedPct[att]); }
797        void ApplyAttackTimePercentMod(WeaponAttackType att,float val, bool apply);
798        void ApplyCastTimePercentMod(float val, bool apply);
799
800        // faction template id
801        uint32 getFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); }
802        void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction ); }
803        FactionTemplateEntry const* getFactionTemplateEntry() const;
804        bool IsHostileTo(Unit const* unit) const;
805        bool IsHostileToPlayers() const;
806        bool IsFriendlyTo(Unit const* unit) const;
807        bool IsNeutralToAll() const;
808        bool IsContestedGuard() const
809        {
810            if(FactionTemplateEntry const* entry = getFactionTemplateEntry())
811                return entry->IsContestedGuardFaction();
812
813            return false;
814        }
815        bool IsPvP() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); }
816        void SetPvP(bool state) { if(state) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); else RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); }
817        uint32 GetCreatureType() const;
818        uint32 GetCreatureTypeMask() const
819        {
820            uint32 creatureType = GetCreatureType();
821            return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0;
822        }
823
824        uint8 getStandState() const { return GetByteValue(UNIT_FIELD_BYTES_1, 0); }
825        bool IsSitState() const;
826        bool IsStandState() const;
827        void SetStandState(uint8 state);
828
829        bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); }
830        uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); }
831        void Mount(uint32 mount);
832        void Unmount();
833
834        uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
835        uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss);
836        void DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *damage, CleanDamage *cleanDamage, bool *crit = false, bool isTriggeredSpell = false);
837        void DoAttackDamage(Unit *pVictim, uint32 *damage, CleanDamage *cleanDamage, uint32 *blocked_amount, SpellSchoolMask damageSchoolMask, uint32 *hitInfo, VictimState *victimState, uint32 *absorbDamage, uint32 *resistDamage, WeaponAttackType attType, SpellEntry const *spellCasted = NULL, bool isTriggeredSpell = false);
838
839        void CastMeleeProcDamageAndSpell(Unit* pVictim, uint32 damage, SpellSchoolMask damageSchoolMask, WeaponAttackType attType, MeleeHitOutcome outcome, SpellEntry const *spellCasted = NULL, bool isTriggeredSpell = false);
840        void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 damage = 0, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NONE, SpellEntry const *procSpell = NULL, bool isTriggeredSpell = false, WeaponAttackType attType = BASE_ATTACK);
841        void HandleEmoteCommand(uint32 anim_id);
842        void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false );
843
844        float MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const;
845        SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell);
846        SpellMissInfo SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool canReflect = false);
847
848        float GetUnitDodgeChance()    const;
849        float GetUnitParryChance()    const;
850        float GetUnitBlockChance()    const;
851        float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const;
852
853        virtual uint32 GetShieldBlockValue() const =0;
854        uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
855        uint32 GetDefenseSkillValue(Unit const* target = NULL) const;
856        uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const;
857        float GetWeaponProcChance() const;
858        float GetPPMProcChance(uint32 WeaponSpeed, float PPM) const;
859        MeleeHitOutcome RollPhysicalOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, SpellEntry const *spellInfo);
860        MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType) const;
861        MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance, bool SpellCasted ) const;
862
863        bool isVendor()       const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR ); }
864        bool isTrainer()      const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER ); }
865        bool isQuestGiver()   const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER ); }
866        bool isGossip()       const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP ); }
867        bool isTaxi()         const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER ); }
868        bool isGuildMaster()  const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER ); }
869        bool isBattleMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER ); }
870        bool isBanker()       const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER ); }
871        bool isInnkeeper()    const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER ); }
872        bool isSpiritHealer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER ); }
873        bool isSpiritGuide()  const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE ); }
874        bool isTabardDesigner()const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER ); }
875        bool isAuctioner()    const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER ); }
876        bool isArmorer()      const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR ); }
877        bool isServiceProvider() const
878        {
879            return HasFlag( UNIT_NPC_FLAGS,
880                UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER |
881                UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER |
882                UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_GUARD | UNIT_NPC_FLAG_SPIRITHEALER |
883                UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER );
884        }
885        bool isSpiritService() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE ); }
886
887        //Need fix or use this
888        bool isGuard() const  { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GUARD); }
889
890        bool isInFlight()  const { return hasUnitState(UNIT_STAT_IN_FLIGHT); }
891
892        bool isInCombat()  const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); }
893        void SetInCombatState(bool PvP);
894        void SetInCombatWith(Unit* enemy);
895        void ClearInCombat();
896        uint32 GetCombatTimer() const { return m_CombatTimer; }
897
898        bool HasAuraType(AuraType auraType) const;
899        bool HasAura(uint32 spellId, uint32 effIndex) const
900            { return m_Auras.find(spellEffectPair(spellId, effIndex)) != m_Auras.end(); }
901
902        bool virtual HasSpell(uint32 /*spellID*/) const { return false; }
903
904        bool HasStealthAura()      const { return HasAuraType(SPELL_AURA_MOD_STEALTH); }
905        bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); }
906        bool isFeared()  const { return HasAuraType(SPELL_AURA_MOD_FEAR); }
907        bool isInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT); }
908        bool IsPolymorphed() const;
909
910        bool isFrozen() const;
911
912        void RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage);
913
914        bool isTargetableForAttack() const;
915        virtual bool IsInWater() const;
916        virtual bool IsUnderWater() const;
917        bool isInAccessablePlaceFor(Creature const* c) const;
918
919        void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false);
920        void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype, bool critical = false);
921        uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true);
922        void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0);
923        void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0);
924        void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0);
925        void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0);
926        void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0);
927        void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0);
928
929        bool IsDamageToThreatSpell(SpellEntry const * spellInfo) const;
930
931        void DeMorph();
932
933        void SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount);
934        void SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID,uint32 Damage, SpellSchoolMask damageSchoolMask,uint32 AbsorbedDamage, uint32 Resist,bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false);
935        void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo);
936
937        void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
938        void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uint32 MovementFlags);
939        void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 MovementFlags, uint32 transitTime = 0, Player* player = NULL);
940        void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
941
942        virtual void MoveOutOfRange(Player &) {  };
943
944        bool isAlive() const { return (m_deathState == ALIVE); };
945        bool isDead() const { return ( m_deathState == DEAD || m_deathState == CORPSE ); };
946        DeathState getDeathState() { return m_deathState; };
947        virtual void setDeathState(DeathState s);           // overwrited in Creature/Player/Pet
948
949        uint64 const& GetOwnerGUID() const { return  GetUInt64Value(UNIT_FIELD_SUMMONEDBY); }
950        uint64 GetPetGUID() const { return  GetUInt64Value(UNIT_FIELD_SUMMON); }
951        uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); }
952        uint64 GetCharmGUID() const { return  GetUInt64Value(UNIT_FIELD_CHARM); }
953        void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); }
954
955        uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
956        uint64 GetCharmerOrOwnerOrOwnGUID() const
957        {
958            if(uint64 guid = GetCharmerOrOwnerGUID())
959                return guid;
960            return GetGUID();
961        }
962        bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); }
963
964        Player* GetSpellModOwner();
965
966        Unit* GetOwner() const;
967        Pet* GetPet() const;
968        Unit* GetCharmer() const;
969        Unit* GetCharm() const;
970        Unit* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); }
971        Unit* GetCharmerOrOwnerOrSelf()
972        {
973            if(Unit* u = GetCharmerOrOwner())
974                return u;
975
976            return this;
977        }
978        Player* GetCharmerOrOwnerPlayerOrPlayerItself();
979
980        void SetPet(Pet* pet);
981        void SetCharm(Unit* pet);
982        bool isCharmed() const { return GetCharmerGUID() != 0; }
983
984        CharmInfo* GetCharmInfo() { return m_charmInfo; }
985        CharmInfo* InitCharmInfo(Unit* charm);
986
987        bool AddAura(Aura *aur);
988
989        void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
990        void RemoveAura(uint32 spellId, uint32 effindex, Aura* except = NULL);
991        void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex);
992        void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL);
993        void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId);
994        void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler);
995        void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer);
996        void RemoveAurasDueToSpellByCancel(uint32 spellId);
997        void RemoveNotOwnSingleTargetAuras();
998
999        void RemoveSpellsCausingAura(AuraType auraType);
1000        void RemoveRankAurasDueToSpell(uint32 spellId);
1001        bool RemoveNoStackAurasDueToAura(Aura *Aur);
1002        void RemoveAurasWithInterruptFlags(uint32 flags);
1003        void RemoveAurasWithDispelType( DispelType type );
1004
1005        void RemoveAllAuras();
1006        void RemoveArenaAuras(bool onleave = false);
1007        void RemoveAllAurasOnDeath();
1008        void DelayAura(uint32 spellId, uint32 effindex, int32 delaytime);
1009
1010        float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school ); }
1011        void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school,val); }
1012        void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) { ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); }
1013        void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) { ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); }
1014        void InitStatBuffMods()
1015        {
1016            for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0);
1017            for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0);
1018        }
1019        void ApplyStatBuffMod(Stats stat, float val, bool apply) { ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0+stat : UNIT_FIELD_NEGSTAT0+stat), val, apply); }
1020        void ApplyStatPercentBuffMod(Stats stat, float val, bool apply)
1021        {
1022            ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0+stat, val, apply);
1023            ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0+stat, val, apply);
1024        }
1025        void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; }
1026        void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); }
1027        uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
1028        void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); }
1029        uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); }
1030        uint32 GetCreatePowers(Powers power) const;
1031        float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0+stat); }
1032        float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); }
1033        float GetCreateStat(Stats stat) const { return m_createStats[stat]; }
1034
1035        void SetCurrentCastedSpell(Spell * pSpell);
1036        virtual void ProhibitSpellScholl(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/ ) { }
1037        void InterruptSpell(uint32 spellType, bool withDelayed = true);
1038
1039        // set withDelayed to true to account delayed spells as casted
1040        // delayed+channeled spells are always accounted as casted
1041        // we can skip channeled or delayed checks using flags
1042        bool IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false) const;
1043
1044        // set withDelayed to true to interrupt delayed spells too
1045        // delayed+channeled spells are always interrupted
1046        void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0);
1047
1048        Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
1049
1050        Spell* m_currentSpells[CURRENT_MAX_SPELL];
1051
1052        uint32 m_addDmgOnce;
1053        uint64 m_TotemSlot[MAX_TOTEM];
1054        uint64 m_ObjectSlot[4];
1055        uint32 m_detectInvisibilityMask;
1056        uint32 m_invisibilityMask;
1057        uint32 m_ShapeShiftFormSpellId;
1058        ShapeshiftForm m_form;
1059        float m_modMeleeHitChance;
1060        float m_modRangedHitChance;
1061        float m_modSpellHitChance;
1062        int32 m_baseSpellCritChance;
1063
1064        float m_threatModifier[MAX_SPELL_SCHOOL];
1065        float m_modAttackSpeedPct[3];
1066
1067        // Event handler
1068        EventProcessor m_Events;
1069
1070        // stat system
1071        bool HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply);
1072        void SetModifierValue(UnitMods unitMod, UnitModifierType modifierType, float value) { m_auraModifiersGroup[unitMod][modifierType] = value; }
1073        float GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const;
1074        float GetTotalStatValue(Stats stat) const;
1075        float GetTotalAuraModValue(UnitMods unitMod) const;
1076        SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const;
1077        Stats GetStatByAuraGroup(UnitMods unitMod) const;
1078        Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const;
1079        bool CanModifyStats() const { return m_canModifyStats; }
1080        void SetCanModifyStats(bool modifyStats) { m_canModifyStats = modifyStats; }
1081        virtual bool UpdateStats(Stats stat) = 0;
1082        virtual bool UpdateAllStats() = 0;
1083        virtual void UpdateResistances(uint32 school) = 0;
1084        virtual void UpdateArmor() = 0;
1085        virtual void UpdateMaxHealth() = 0;
1086        virtual void UpdateMaxPower(Powers power) = 0;
1087        virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0;
1088        virtual void UpdateDamagePhysical(WeaponAttackType attType) = 0;
1089        float GetTotalAttackPowerValue(WeaponAttackType attType) const;
1090        float GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const;
1091        void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; }
1092
1093        bool isInFront(Unit const* target,float distance, float arc = M_PI) const;
1094        void SetInFront(Unit const* target);
1095        bool isInBack(Unit const* target, float distance, float arc = M_PI) const;
1096
1097        // Visibility system
1098        UnitVisibility GetVisibility() const { return m_Visibility; }
1099        void SetVisibility(UnitVisibility x);
1100
1101        // common function for visibility checks for player/creatures with detection code
1102        bool isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList = false) const;
1103        bool canDetectInvisibilityOf(Unit const* u) const;
1104
1105        // virtual functions for all world objects types
1106        bool isVisibleForInState(Player const* u, bool inVisibleList) const;
1107        // function for low level grid visibility checks in player/creature cases
1108        virtual bool IsVisibleInGridForPlayer(Player* pl) const = 0;
1109
1110        bool waterbreath;
1111        AuraList      & GetSingleCastAuras()       { return m_scAuras; }
1112        AuraList const& GetSingleCastAuras() const { return m_scAuras; }
1113        SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY];
1114
1115        // Threat related methodes
1116        bool CanHaveThreatList() const;
1117        void AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell = NULL);
1118        float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL);
1119        void DeleteThreatList();
1120        bool SelectHostilTarget();
1121        void TauntApply(Unit* pVictim);
1122        void TauntFadeOut(Unit *taunter);
1123        ThreatManager& getThreatManager() { return m_ThreatManager; }
1124        void addHatedBy(HostilReference* pHostilReference) { m_HostilRefManager.insertFirst(pHostilReference); };
1125        void removeHatedBy(HostilReference* /*pHostilReference*/ ) { /* nothing to do yet */ }
1126        HostilRefManager& getHostilRefManager() { return m_HostilRefManager; }
1127
1128        Aura* GetAura(uint32 spellId, uint32 effindex);
1129        AuraMap      & GetAuras()       { return m_Auras; }
1130        AuraMap const& GetAuras() const { return m_Auras; }
1131        AuraList const& GetAurasByType(AuraType type) const { return m_modAuras[type]; }
1132        void ApplyAuraProcTriggerDamage(Aura* aura, bool apply);
1133
1134        int32 GetTotalAuraModifier(AuraType auratype) const;
1135        float GetTotalAuraMultiplier(AuraType auratype) const;
1136        int32 GetMaxPositiveAuraModifier(AuraType auratype) const;
1137        int32 GetMaxNegativeAuraModifier(AuraType auratype) const;
1138
1139        int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1140        float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1141        int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1142        int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1143
1144        int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1145        float GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const;
1146        int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1147        int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1148
1149        Aura* GetDummyAura(uint32 spell_id) const;
1150
1151        uint32 GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
1152        void SetDisplayId(uint32 modelId);
1153        uint32 GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
1154        void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); }
1155        void setTransForm(uint32 spellid) { m_transform = spellid;}
1156        uint32 getTransForm() const { return m_transform;}
1157        void AddDynObject(DynamicObject* dynObj);
1158        void RemoveDynObject(uint32 spellid);
1159        void RemoveDynObjectWithGUID(uint64 guid) { m_dynObjGUIDs.remove(guid); }
1160        void RemoveAllDynObjects();
1161        void AddGameObject(GameObject* gameObj);
1162        void RemoveGameObject(GameObject* gameObj, bool del);
1163        void RemoveGameObject(uint32 spellid, bool del);
1164        void RemoveAllGameObjects();
1165        DynamicObject *GetDynObject(uint32 spellId, uint32 effIndex);
1166        DynamicObject *GetDynObject(uint32 spellId);
1167        uint32 CalculateDamage(WeaponAttackType attType, bool normalized);
1168        float GetAPMultiplier(WeaponAttackType attType, bool normalized);
1169        void ModifyAuraState(AuraState flag, bool apply);
1170        bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); }
1171        void UnsummonAllTotems();
1172        int32 SpellBaseDamageBonus(SpellSchoolMask schoolMask);
1173        int32 SpellBaseHealingBonus(SpellSchoolMask schoolMask);
1174        int32 SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim);
1175        int32 SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim);
1176        uint32 SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 damage, DamageEffectType damagetype);
1177        uint32 SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, Unit *pVictim);
1178        bool   isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType);
1179        uint32 SpellCriticalBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim);
1180
1181        void SetLastManaUse(uint32 spellCastTime) { m_lastManaUse = spellCastTime; }
1182        bool IsUnderLastManaUseEffect() const;
1183
1184        void SetContestedPvP(Player *attackedPlayer = NULL);
1185
1186        void MeleeDamageBonus(Unit *pVictim, uint32 *damage, WeaponAttackType attType, SpellEntry const *spellProto = NULL);
1187        uint32 GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime );
1188
1189        void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
1190        void ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType type, bool apply);
1191        virtual bool IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges = false);
1192                                                            // redefined in Creature
1193        bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask, bool useCharges = false);
1194        virtual bool IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const;
1195                                                            // redefined in Creature
1196
1197        uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage);
1198        void CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist);
1199
1200        void  UpdateSpeed(UnitMoveType mtype, bool forced);
1201        float GetSpeed( UnitMoveType mtype ) const;
1202        float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; }
1203        void SetSpeed(UnitMoveType mtype, float rate, bool forced = false);
1204
1205        void SetHover(bool on);
1206        bool isHover() const { return HasAuraType(SPELL_AURA_HOVER); }
1207
1208        void _RemoveAllAuraMods();
1209        void _ApplyAllAuraMods();
1210
1211        int32 CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 basePoints, Unit const* target);
1212        int32 CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target);
1213        float CalculateLevelPenalty(SpellEntry const* spellProto) const;
1214
1215        void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); }
1216        void removeFollower(FollowerReference* /*pRef*/ ) { /* nothing to do yet */ }
1217        static Unit* GetUnit(WorldObject& object, uint64 guid);
1218
1219        MotionMaster* GetMotionMaster() { return &i_motionMaster; }
1220
1221        bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); }
1222        void StopMoving();
1223
1224        void AddUnitMovementFlag(uint32 f) { m_unit_movement_flags |= f; }
1225        void RemoveUnitMovementFlag(uint32 f)
1226        {
1227            uint32 oldval = m_unit_movement_flags;
1228            m_unit_movement_flags = oldval & ~f;
1229        }
1230        uint32 HasUnitMovementFlag(uint32 f) const { return m_unit_movement_flags & f; }
1231        uint32 GetUnitMovementFlags() const { return m_unit_movement_flags; }
1232        void SetUnitMovementFlags(uint32 f) { m_unit_movement_flags = f; }
1233
1234        void SetFeared(bool apply, uint64 casterGUID = 0, uint32 spellID = 0);
1235        void SetConfused(bool apply, uint64 casterGUID = 0, uint32 spellID = 0);
1236
1237        void AddComboPointHolder(uint32 lowguid) { m_ComboPointHolders.insert(lowguid); }
1238        void RemoveComboPointHolder(uint32 lowguid) { m_ComboPointHolders.erase(lowguid); }
1239        void ClearComboPointHolders();
1240
1241        ///----------Pet responses methods-----------------
1242        void SendPetCastFail(uint32 spellid, uint8 msg);
1243        void SendPetActionFeedback (uint8 msg);
1244        void SendPetTalk (uint32 pettalk);
1245        void SendPetSpellCooldown (uint32 spellid, time_t cooltime);
1246        void SendPetClearCooldown (uint32 spellid);
1247        void SendPetAIReaction(uint64 guid);
1248        ///----------End of Pet responses methods----------
1249
1250        void propagateSpeedChange() { GetMotionMaster()->propagateSpeedChange(); }
1251
1252        // reactive attacks
1253        void ClearAllReactives();
1254        void StartReactiveTimer( ReactiveType reactive ) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;}
1255        void UpdateReactives(uint32 p_time);
1256
1257        // group updates
1258        void UpdateAuraForGroup(uint8 slot);
1259
1260        // pet auras
1261        typedef std::set<PetAura const*> PetAuraSet;
1262        PetAuraSet m_petAuras;
1263        void AddPetAura(PetAura const* petSpell);
1264        void RemovePetAura(PetAura const* petSpell);
1265
1266    protected:
1267        explicit Unit ();
1268
1269        void _UpdateSpells(uint32 time);
1270
1271        void _UpdateAutoRepeatSpell();
1272        bool m_AutoRepeatFirstCast;
1273
1274        uint32 m_attackTimer[MAX_ATTACK];
1275
1276        float m_createStats[MAX_STATS];
1277
1278        AttackerSet m_attackers;
1279        Unit* m_attacking;
1280
1281        DeathState m_deathState;
1282
1283        AuraMap m_Auras;
1284
1285        std::list<Aura *> m_scAuras;                        // casted singlecast auras
1286
1287        typedef std::list<uint64> DynObjectGUIDs;
1288        DynObjectGUIDs m_dynObjGUIDs;
1289
1290        std::list<GameObject*> m_gameObj;
1291        bool m_isSorted;
1292        uint32 m_transform;
1293        uint32 m_removedAuras;
1294
1295        AuraList m_modAuras[TOTAL_AURAS];
1296        float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END];
1297        float m_weaponDamage[MAX_ATTACK][2];
1298        bool m_canModifyStats;
1299        //std::list< spellEffectPair > AuraSpells[TOTAL_AURAS];  // TODO: use this if ok for mem
1300
1301        float m_speed_rate[MAX_MOVE_TYPE];
1302
1303        CharmInfo *m_charmInfo;
1304
1305        virtual SpellSchoolMask GetMeleeDamageSchoolMask() const;
1306
1307        MotionMaster i_motionMaster;
1308        uint32 m_unit_movement_flags;
1309
1310        uint32 m_reactiveTimer[MAX_REACTIVE];
1311
1312    private:
1313        void SendAttackStop(Unit* victim);                  // only from AttackStop(Unit*)
1314        void SendAttackStart(Unit* pVictim);                // only from Unit::AttackStart(Unit*)
1315
1316        void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask );
1317        bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown);
1318        bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown);
1319        bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown);
1320        bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell,uint32 cooldown);
1321        uint32 m_state;                                     // Even derived shouldn't modify
1322        uint32 m_CombatTimer;
1323        uint32 m_lastManaUse;                               // msecs
1324
1325        UnitVisibility m_Visibility;
1326
1327        Diminishing m_Diminishing;
1328        // Manage all Units threatening us
1329        ThreatManager m_ThreatManager;
1330        // Manage all Units that are threatened by us
1331        HostilRefManager m_HostilRefManager;
1332
1333        FollowerRefManager m_FollowingRefManager;
1334
1335        ComboPointHolderSet m_ComboPointHolders;
1336};
1337#endif
Note: See TracBrowser for help on using the browser.