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

Revision 2, 60.7 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

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