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