[8483] Implement glyph 43361.
[getmangos.git] / src / game / Unit.h
blob20c17547172659ca9228dc09c65ef44441387dc2
1 /*
2 * Copyright (C) 2005-2009 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 "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_ABORT_ON_DMG = 0x10, // _complete_ interrupt on direct damage
44 //SPELL_INTERRUPT_UNK = 0x20 // unk, 564 of 727 spells having this spell start with "Glyph"
47 enum SpellChannelInterruptFlags
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
56 enum SpellAuraInterruptFlags
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 (used by food and drink mostly and sleep/Fake Death like)
77 AURA_INTERRUPT_FLAG_CHANGE_MAP = 0x00080000, // 19 leaving map/getting teleported
78 AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION = 0x00100000, // 20 removed by auras that make you invulnerable, or make other to loose selection on you
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
85 enum SpellModOp
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, // Only used with SPELL_AURA_ADD_FLAT_MODIFIER and affects proc spells
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 unused
113 SPELLMOD_FREQUENCY_OF_SUCCESS = 26, // Only used with SPELL_AURA_ADD_PCT_MODIFIER and affects used on proc spells
114 SPELLMOD_MULTIPLE_VALUE = 27,
115 SPELLMOD_RESIST_DISPEL_CHANCE = 28
118 #define MAX_SPELLMOD 32
120 enum SpellFacingFlags
122 SPELL_FACING_FLAG_INFRONT = 0x0001
125 #define BASE_MINDAMAGE 1.0f
126 #define BASE_MAXDAMAGE 2.0f
127 #define BASE_ATTACK_TIME 2000
129 // byte value (UNIT_FIELD_BYTES_1,0)
130 enum UnitStandStateType
132 UNIT_STAND_STATE_STAND = 0,
133 UNIT_STAND_STATE_SIT = 1,
134 UNIT_STAND_STATE_SIT_CHAIR = 2,
135 UNIT_STAND_STATE_SLEEP = 3,
136 UNIT_STAND_STATE_SIT_LOW_CHAIR = 4,
137 UNIT_STAND_STATE_SIT_MEDIUM_CHAIR = 5,
138 UNIT_STAND_STATE_SIT_HIGH_CHAIR = 6,
139 UNIT_STAND_STATE_DEAD = 7,
140 UNIT_STAND_STATE_KNEEL = 8
143 // byte flag value (UNIT_FIELD_BYTES_1,2)
144 enum UnitStandFlags
146 UNIT_STAND_FLAGS_CREEP = 0x02,
147 UNIT_STAND_FLAGS_ALL = 0xFF
150 // byte flags value (UNIT_FIELD_BYTES_1,3)
151 enum UnitBytes1_Flags
153 UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01,
154 UNIT_BYTE1_FLAG_UNTRACKABLE = 0x04,
155 UNIT_BYTE1_FLAG_ALL = 0xFF
158 // high byte (3 from 0..3) of UNIT_FIELD_BYTES_2
159 enum ShapeshiftForm
161 FORM_NONE = 0x00,
162 FORM_CAT = 0x01,
163 FORM_TREE = 0x02,
164 FORM_TRAVEL = 0x03,
165 FORM_AQUA = 0x04,
166 FORM_BEAR = 0x05,
167 FORM_AMBIENT = 0x06,
168 FORM_GHOUL = 0x07,
169 FORM_DIREBEAR = 0x08,
170 FORM_CREATUREBEAR = 0x0E,
171 FORM_CREATURECAT = 0x0F,
172 FORM_GHOSTWOLF = 0x10,
173 FORM_BATTLESTANCE = 0x11,
174 FORM_DEFENSIVESTANCE = 0x12,
175 FORM_BERSERKERSTANCE = 0x13,
176 FORM_TEST = 0x14,
177 FORM_ZOMBIE = 0x15,
178 FORM_METAMORPHOSIS = 0x16,
179 FORM_FLIGHT_EPIC = 0x1B,
180 FORM_SHADOW = 0x1C,
181 FORM_FLIGHT = 0x1D,
182 FORM_STEALTH = 0x1E,
183 FORM_MOONKIN = 0x1F,
184 FORM_SPIRITOFREDEMPTION = 0x20
187 // low byte ( 0 from 0..3 ) of UNIT_FIELD_BYTES_2
188 enum SheathState
190 SHEATH_STATE_UNARMED = 0, // non prepared weapon
191 SHEATH_STATE_MELEE = 1, // prepared melee weapon
192 SHEATH_STATE_RANGED = 2 // prepared ranged weapon
195 #define MAX_SHEATH_STATE 3
197 // byte (1 from 0..3) of UNIT_FIELD_BYTES_2
198 enum UnitBytes2_Flags
200 UNIT_BYTE2_FLAG_PVP = 0x01,
201 UNIT_BYTE2_FLAG_UNK1 = 0x02,
202 UNIT_BYTE2_FLAG_FFA_PVP = 0x04,
203 UNIT_BYTE2_FLAG_SANCTUARY = 0x08,
204 UNIT_BYTE2_FLAG_UNK4 = 0x10,
205 UNIT_BYTE2_FLAG_UNK5 = 0x20,
206 UNIT_BYTE2_FLAG_UNK6 = 0x40,
207 UNIT_BYTE2_FLAG_UNK7 = 0x80
210 // byte (2 from 0..3) of UNIT_FIELD_BYTES_2
211 enum UnitRename
213 UNIT_RENAME_NOT_ALLOWED = 0x02,
214 UNIT_RENAME_ALLOWED = 0x03
217 #define CREATURE_MAX_SPELLS 4
219 enum Swing
221 NOSWING = 0,
222 SINGLEHANDEDSWING = 1,
223 TWOHANDEDSWING = 2
226 enum VictimState
228 VICTIMSTATE_UNKNOWN1 = 0,
229 VICTIMSTATE_NORMAL = 1,
230 VICTIMSTATE_DODGE = 2,
231 VICTIMSTATE_PARRY = 3,
232 VICTIMSTATE_INTERRUPT = 4,
233 VICTIMSTATE_BLOCKS = 5,
234 VICTIMSTATE_EVADES = 6,
235 VICTIMSTATE_IS_IMMUNE = 7,
236 VICTIMSTATE_DEFLECTS = 8
239 enum HitInfo
241 HITINFO_NORMALSWING = 0x00000000,
242 HITINFO_UNK1 = 0x00000001, // req correct packet structure
243 HITINFO_NORMALSWING2 = 0x00000002,
244 HITINFO_LEFTSWING = 0x00000004,
245 HITINFO_UNK2 = 0x00000008,
246 HITINFO_MISS = 0x00000010,
247 HITINFO_ABSORB = 0x00000020, // absorbed damage
248 HITINFO_ABSORB2 = 0x00000040, // absorbed damage
249 HITINFO_RESIST = 0x00000080, // resisted atleast some damage
250 HITINFO_RESIST2 = 0x00000100, // resisted atleast some damage
251 HITINFO_CRITICALHIT = 0x00000200, // critical hit
252 // 0x00000400
253 // 0x00000800
254 // 0x00001000
255 HITINFO_BLOCK = 0x00002000, // blocked damage
256 // 0x00004000
257 // 0x00008000
258 HITINFO_GLANCING = 0x00010000,
259 HITINFO_CRUSHING = 0x00020000,
260 HITINFO_NOACTION = 0x00040000, // guessed
261 // 0x00080000
262 // 0x00100000
263 HITINFO_SWINGNOHITSOUND = 0x00200000, // guessed
264 // 0x00400000
265 HITINFO_UNK3 = 0x00800000
268 //i would like to remove this: (it is defined in item.h
269 enum InventorySlot
271 NULL_BAG = 0,
272 NULL_SLOT = 255
275 struct FactionTemplateEntry;
276 struct Modifier;
277 struct SpellEntry;
278 struct SpellEntryExt;
280 class Aura;
281 class Creature;
282 class Spell;
283 class DynamicObject;
284 class GameObject;
285 class Item;
286 class Pet;
287 class Path;
288 class PetAura;
290 struct SpellImmune
292 uint32 type;
293 uint32 spellId;
296 typedef std::list<SpellImmune> SpellImmuneList;
298 enum UnitModifierType
300 BASE_VALUE = 0,
301 BASE_PCT = 1,
302 TOTAL_VALUE = 2,
303 TOTAL_PCT = 3,
304 MODIFIER_TYPE_END = 4
307 enum WeaponDamageRange
309 MINDAMAGE,
310 MAXDAMAGE
313 enum DamageTypeToSchool
315 RESISTANCE,
316 DAMAGE_DEALT,
317 DAMAGE_TAKEN
320 enum AuraRemoveMode
322 AURA_REMOVE_BY_DEFAULT,
323 AURA_REMOVE_BY_STACK, // at replace by similar aura
324 AURA_REMOVE_BY_CANCEL,
325 AURA_REMOVE_BY_DISPEL,
326 AURA_REMOVE_BY_DEATH
329 enum UnitMods
331 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.
332 UNIT_MOD_STAT_AGILITY,
333 UNIT_MOD_STAT_STAMINA,
334 UNIT_MOD_STAT_INTELLECT,
335 UNIT_MOD_STAT_SPIRIT,
336 UNIT_MOD_HEALTH,
337 UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_RUNIC_POWER must be in existed order, it's accessed by index values of Powers enum.
338 UNIT_MOD_RAGE,
339 UNIT_MOD_FOCUS,
340 UNIT_MOD_ENERGY,
341 UNIT_MOD_HAPPINESS,
342 UNIT_MOD_RUNE,
343 UNIT_MOD_RUNIC_POWER,
344 UNIT_MOD_ARMOR, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum.
345 UNIT_MOD_RESISTANCE_HOLY,
346 UNIT_MOD_RESISTANCE_FIRE,
347 UNIT_MOD_RESISTANCE_NATURE,
348 UNIT_MOD_RESISTANCE_FROST,
349 UNIT_MOD_RESISTANCE_SHADOW,
350 UNIT_MOD_RESISTANCE_ARCANE,
351 UNIT_MOD_ATTACK_POWER,
352 UNIT_MOD_ATTACK_POWER_RANGED,
353 UNIT_MOD_DAMAGE_MAINHAND,
354 UNIT_MOD_DAMAGE_OFFHAND,
355 UNIT_MOD_DAMAGE_RANGED,
356 UNIT_MOD_END,
357 // synonyms
358 UNIT_MOD_STAT_START = UNIT_MOD_STAT_STRENGTH,
359 UNIT_MOD_STAT_END = UNIT_MOD_STAT_SPIRIT + 1,
360 UNIT_MOD_RESISTANCE_START = UNIT_MOD_ARMOR,
361 UNIT_MOD_RESISTANCE_END = UNIT_MOD_RESISTANCE_ARCANE + 1,
362 UNIT_MOD_POWER_START = UNIT_MOD_MANA,
363 UNIT_MOD_POWER_END = UNIT_MOD_RUNIC_POWER + 1
366 enum BaseModGroup
368 CRIT_PERCENTAGE,
369 RANGED_CRIT_PERCENTAGE,
370 OFFHAND_CRIT_PERCENTAGE,
371 SHIELD_BLOCK_VALUE,
372 BASEMOD_END
375 enum BaseModType
377 FLAT_MOD,
378 PCT_MOD
381 #define MOD_END (PCT_MOD+1)
383 enum DeathState
385 ALIVE = 0,
386 JUST_DIED = 1,
387 CORPSE = 2,
388 DEAD = 3,
389 JUST_ALIVED = 4,
390 DEAD_FALLING= 5
393 enum UnitState
395 UNIT_STAT_DIED = 0x0001,
396 UNIT_STAT_MELEE_ATTACKING = 0x0002, // player is melee attacking someone
397 //UNIT_STAT_MELEE_ATTACK_BY = 0x0004, // player is melee attack by someone
398 UNIT_STAT_STUNNED = 0x0008,
399 UNIT_STAT_ROAMING = 0x0010,
400 UNIT_STAT_CHASE = 0x0020,
401 UNIT_STAT_SEARCHING = 0x0040,
402 UNIT_STAT_FLEEING = 0x0080,
403 UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING),
404 UNIT_STAT_IN_FLIGHT = 0x0100, // player is in flight mode
405 UNIT_STAT_FOLLOW = 0x0200,
406 UNIT_STAT_ROOT = 0x0400,
407 UNIT_STAT_CONFUSED = 0x0800,
408 UNIT_STAT_DISTRACTED = 0x1000,
409 UNIT_STAT_ISOLATED = 0x2000, // area auras do not affect other players
410 UNIT_STAT_ATTACK_PLAYER = 0x4000,
411 UNIT_STAT_ALL_STATE = 0xffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT)
414 enum UnitMoveType
416 MOVE_WALK = 0,
417 MOVE_RUN = 1,
418 MOVE_RUN_BACK = 2,
419 MOVE_SWIM = 3,
420 MOVE_SWIM_BACK = 4,
421 MOVE_TURN_RATE = 5,
422 MOVE_FLIGHT = 6,
423 MOVE_FLIGHT_BACK = 7,
424 MOVE_PITCH_RATE = 8
427 #define MAX_MOVE_TYPE 9
429 extern float baseMoveSpeed[MAX_MOVE_TYPE];
431 enum WeaponAttackType
433 BASE_ATTACK = 0,
434 OFF_ATTACK = 1,
435 RANGED_ATTACK = 2
438 #define MAX_ATTACK 3
440 enum CombatRating
442 CR_WEAPON_SKILL = 0,
443 CR_DEFENSE_SKILL = 1,
444 CR_DODGE = 2,
445 CR_PARRY = 3,
446 CR_BLOCK = 4,
447 CR_HIT_MELEE = 5,
448 CR_HIT_RANGED = 6,
449 CR_HIT_SPELL = 7,
450 CR_CRIT_MELEE = 8,
451 CR_CRIT_RANGED = 9,
452 CR_CRIT_SPELL = 10,
453 CR_HIT_TAKEN_MELEE = 11,
454 CR_HIT_TAKEN_RANGED = 12,
455 CR_HIT_TAKEN_SPELL = 13,
456 CR_CRIT_TAKEN_MELEE = 14,
457 CR_CRIT_TAKEN_RANGED = 15,
458 CR_CRIT_TAKEN_SPELL = 16,
459 CR_HASTE_MELEE = 17,
460 CR_HASTE_RANGED = 18,
461 CR_HASTE_SPELL = 19,
462 CR_WEAPON_SKILL_MAINHAND = 20,
463 CR_WEAPON_SKILL_OFFHAND = 21,
464 CR_WEAPON_SKILL_RANGED = 22,
465 CR_EXPERTISE = 23,
466 CR_ARMOR_PENETRATION = 24
469 #define MAX_COMBAT_RATING 25
471 enum DamageEffectType
473 DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells)
474 SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage
475 DOT = 2,
476 HEAL = 3,
477 NODAMAGE = 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
478 SELF_DAMAGE = 5
481 enum UnitVisibility
483 VISIBILITY_OFF = 0, // absolute, not detectable, GM-like, can see all other
484 VISIBILITY_ON = 1,
485 VISIBILITY_GROUP_STEALTH = 2, // detect chance, seen and can see group members
486 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)
487 VISIBILITY_GROUP_NO_DETECT = 4, // state just at stealth apply for update Grid state. Don't remove, otherwise stealth spells will break
488 VISIBILITY_RESPAWN = 5 // special totally not detectable visibility for force delete object at respawn command
491 // Value masks for UNIT_FIELD_FLAGS
492 enum UnitFlags
494 UNIT_FLAG_UNK_0 = 0x00000001,
495 UNIT_FLAG_NON_ATTACKABLE = 0x00000002, // not attackable
496 UNIT_FLAG_DISABLE_MOVE = 0x00000004,
497 UNIT_FLAG_PVP_ATTACKABLE = 0x00000008, // allow apply pvp rules to attackable state in addition to faction dependent state
498 UNIT_FLAG_RENAME = 0x00000010,
499 UNIT_FLAG_PREPARATION = 0x00000020, // don't take reagents for spells with SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP
500 UNIT_FLAG_UNK_6 = 0x00000040,
501 UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080, // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE
502 UNIT_FLAG_OOC_NOT_ATTACKABLE = 0x00000100, // 2.0.8 - (OOC Out Of Combat) Can not be attacked when not in combat. Removed if unit for some reason enter combat.
503 UNIT_FLAG_UNK_9 = 0x00000200, // 3.0.3 - makes you unable to attack everything
504 UNIT_FLAG_LOOTING = 0x00000400, // loot animation
505 UNIT_FLAG_PET_IN_COMBAT = 0x00000800, // in combat?, 2.0.8
506 UNIT_FLAG_PVP = 0x00001000, // changed in 3.0.3
507 UNIT_FLAG_SILENCED = 0x00002000, // silenced, 2.1.1
508 UNIT_FLAG_UNK_14 = 0x00004000, // 2.0.8
509 UNIT_FLAG_UNK_15 = 0x00008000,
510 UNIT_FLAG_UNK_16 = 0x00010000,
511 UNIT_FLAG_PACIFIED = 0x00020000, // 3.0.3 ok
512 UNIT_FLAG_STUNNED = 0x00040000, // 3.0.3 ok
513 UNIT_FLAG_IN_COMBAT = 0x00080000,
514 UNIT_FLAG_TAXI_FLIGHT = 0x00100000, // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag
515 UNIT_FLAG_DISARMED = 0x00200000, // 3.0.3, disable melee spells casting..., "Required melee weapon" added to melee spells tooltip.
516 UNIT_FLAG_CONFUSED = 0x00400000,
517 UNIT_FLAG_FLEEING = 0x00800000,
518 UNIT_FLAG_PLAYER_CONTROLLED = 0x01000000, // used in spell Eyes of the Beast for pet... let attack by controlled creature
519 UNIT_FLAG_NOT_SELECTABLE = 0x02000000,
520 UNIT_FLAG_SKINNABLE = 0x04000000,
521 UNIT_FLAG_MOUNT = 0x08000000,
522 UNIT_FLAG_UNK_28 = 0x10000000,
523 UNIT_FLAG_UNK_29 = 0x20000000, // used in Feing Death spell
524 UNIT_FLAG_SHEATHE = 0x40000000,
525 UNIT_FLAG_UNK_31 = 0x80000000
528 // Value masks for UNIT_FIELD_FLAGS_2
529 enum UnitFlags2
531 UNIT_FLAG2_FEIGN_DEATH = 0x00000001,
532 UNIT_FLAG2_UNK1 = 0x00000002, // Hide unit model (show only player equip)
533 UNIT_FLAG2_COMPREHEND_LANG = 0x00000008,
534 UNIT_FLAG2_FORCE_MOVE = 0x00000040,
535 UNIT_FLAG2_REGENERATE_POWER = 0x00000800
538 /// Non Player Character flags
539 enum NPCFlags
541 UNIT_NPC_FLAG_NONE = 0x00000000,
542 UNIT_NPC_FLAG_GOSSIP = 0x00000001, // 100%
543 UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // guessed, probably ok
544 UNIT_NPC_FLAG_UNK1 = 0x00000004,
545 UNIT_NPC_FLAG_UNK2 = 0x00000008,
546 UNIT_NPC_FLAG_TRAINER = 0x00000010, // 100%
547 UNIT_NPC_FLAG_TRAINER_CLASS = 0x00000020, // 100%
548 UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x00000040, // 100%
549 UNIT_NPC_FLAG_VENDOR = 0x00000080, // 100%
550 UNIT_NPC_FLAG_VENDOR_AMMO = 0x00000100, // 100%, general goods vendor
551 UNIT_NPC_FLAG_VENDOR_FOOD = 0x00000200, // 100%
552 UNIT_NPC_FLAG_VENDOR_POISON = 0x00000400, // guessed
553 UNIT_NPC_FLAG_VENDOR_REAGENT = 0x00000800, // 100%
554 UNIT_NPC_FLAG_REPAIR = 0x00001000, // 100%
555 UNIT_NPC_FLAG_FLIGHTMASTER = 0x00002000, // 100%
556 UNIT_NPC_FLAG_SPIRITHEALER = 0x00004000, // guessed
557 UNIT_NPC_FLAG_SPIRITGUIDE = 0x00008000, // guessed
558 UNIT_NPC_FLAG_INNKEEPER = 0x00010000, // 100%
559 UNIT_NPC_FLAG_BANKER = 0x00020000, // 100%
560 UNIT_NPC_FLAG_PETITIONER = 0x00040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions
561 UNIT_NPC_FLAG_TABARDDESIGNER = 0x00080000, // 100%
562 UNIT_NPC_FLAG_BATTLEMASTER = 0x00100000, // 100%
563 UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100%
564 UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100%
565 UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode
566 UNIT_NPC_FLAG_SPELLCLICK = 0x01000000, // cause client to send 1015 opcode (spell click), dynamic, set at loading and don't must be set in DB
567 UNIT_NPC_FLAG_GUARD = 0x10000000, // custom flag for guards
570 // used in SMSG_MONSTER_MOVE
571 enum MonsterMovementFlags
573 MONSTER_MOVE_NONE = 0x00000000,
574 MONSTER_MOVE_FORWARD = 0x00000001,
575 MONSTER_MOVE_BACKWARD = 0x00000002,
576 MONSTER_MOVE_STRAFE_LEFT = 0x00000004,
577 MONSTER_MOVE_STRAFE_RIGHT = 0x00000008,
578 MONSTER_MOVE_LEFT = 0x00000010, // turn
579 MONSTER_MOVE_RIGHT = 0x00000020, // turn
580 MONSTER_MOVE_PITCH_UP = 0x00000040,
581 MONSTER_MOVE_PITCH_DOWN = 0x00000080,
582 MONSTER_MOVE_TELEPORT = 0x00000100,
583 MONSTER_MOVE_TELEPORT2 = 0x00000200,
584 MONSTER_MOVE_LEVITATING = 0x00000400,
585 MONSTER_MOVE_UNK1 = 0x00000800, // float+uint32
586 MONSTER_MOVE_WALK = 0x00001000, // run2?
587 MONSTER_MOVE_SPLINE = 0x00002000, // spline n*(float x,y,z)
588 // 0x4000, 0x8000, 0x10000, 0x20000 run
589 MONSTER_MOVE_SPLINE2 = 0x00040000, // spline n*(float x,y,z)
590 MONSTER_MOVE_UNK2 = 0x00080000, // used for flying mobs
591 MONSTER_MOVE_UNK3 = 0x00100000, // used for flying mobs
592 MONSTER_MOVE_UNK4 = 0x00200000, // uint8+uint32
593 MONSTER_MOVE_UNK5 = 0x00400000, // run in place, then teleport to final point
594 MONSTER_MOVE_UNK6 = 0x00800000, // teleport
595 MONSTER_MOVE_UNK7 = 0x01000000, // run
596 MONSTER_MOVE_FLY = 0x02000000, // swimming/flying (depends on mob?)
597 MONSTER_MOVE_UNK9 = 0x04000000, // run
598 MONSTER_MOVE_UNK10 = 0x08000000, // run
599 MONSTER_MOVE_UNK11 = 0x10000000, // run
600 MONSTER_MOVE_UNK12 = 0x20000000, // run
601 MONSTER_MOVE_UNK13 = 0x40000000, // levitating
603 // masks
604 MONSTER_MOVE_SPLINE_FLY = 0x00003000, // fly by points
607 enum DiminishingLevels
609 DIMINISHING_LEVEL_1 = 0,
610 DIMINISHING_LEVEL_2 = 1,
611 DIMINISHING_LEVEL_3 = 2,
612 DIMINISHING_LEVEL_IMMUNE = 3
615 struct DiminishingReturn
617 DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count)
618 : DRGroup(group), stack(0), hitTime(t), hitCount(count)
621 DiminishingGroup DRGroup:16;
622 uint16 stack:16;
623 uint32 hitTime;
624 uint32 hitCount;
627 enum MeleeHitOutcome
629 MELEE_HIT_EVADE, MELEE_HIT_MISS, MELEE_HIT_DODGE, MELEE_HIT_BLOCK, MELEE_HIT_PARRY,
630 MELEE_HIT_GLANCING, MELEE_HIT_CRIT, MELEE_HIT_CRUSHING, MELEE_HIT_NORMAL
633 struct CleanDamage
635 CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) :
636 damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {}
638 uint32 damage;
639 WeaponAttackType attackType;
640 MeleeHitOutcome hitOutCome;
643 // Struct for use in Unit::CalculateMeleeDamage
644 // Need create structure like in SMSG_ATTACKERSTATEUPDATE opcode
645 struct CalcDamageInfo
647 Unit *attacker; // Attacker
648 Unit *target; // Target for damage
649 uint32 damageSchoolMask;
650 uint32 damage;
651 uint32 absorb;
652 uint32 resist;
653 uint32 blocked_amount;
654 uint32 HitInfo;
655 uint32 TargetState;
656 // Helper
657 WeaponAttackType attackType; //
658 uint32 procAttacker;
659 uint32 procVictim;
660 uint32 procEx;
661 uint32 cleanDamage; // Used only for rage calculation
662 MeleeHitOutcome hitOutCome; // TODO: remove this field (need use TargetState)
665 // Spell damage info structure based on structure sending in SMSG_SPELLNONMELEEDAMAGELOG opcode
666 struct SpellNonMeleeDamage{
667 SpellNonMeleeDamage(Unit *_attacker, Unit *_target, uint32 _SpellID, uint32 _schoolMask)
668 : target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), overkill(0), schoolMask(_schoolMask),
669 absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0)
672 Unit *target;
673 Unit *attacker;
674 uint32 SpellID;
675 uint32 damage;
676 uint32 overkill;
677 uint32 schoolMask;
678 uint32 absorb;
679 uint32 resist;
680 bool physicalLog;
681 bool unused;
682 uint32 blocked;
683 uint32 HitInfo;
684 // Used for help
685 uint32 cleanDamage;
688 struct SpellPeriodicAuraLogInfo
690 SpellPeriodicAuraLogInfo(Aura *_aura, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical = false)
691 : aura(_aura), damage(_damage), overDamage(_overDamage), absorb(_absorb), resist(_resist), multiplier(_multiplier), critical(_critical) {}
693 Aura *aura;
694 uint32 damage;
695 uint32 overDamage; // overkill/overheal
696 uint32 absorb;
697 uint32 resist;
698 float multiplier;
699 bool critical;
702 uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missCondition);
704 #define MAX_DECLINED_NAME_CASES 5
706 struct DeclinedName
708 std::string name[MAX_DECLINED_NAME_CASES];
711 enum CurrentSpellTypes
713 CURRENT_MELEE_SPELL = 0,
714 CURRENT_GENERIC_SPELL = 1,
715 CURRENT_AUTOREPEAT_SPELL = 2,
716 CURRENT_CHANNELED_SPELL = 3
719 #define CURRENT_FIRST_NON_MELEE_SPELL 1
720 #define CURRENT_MAX_SPELL 4
723 enum ActiveStates
725 ACT_PASSIVE = 0x01, // 0x01 - passive
726 ACT_DISABLED = 0x81, // 0x80 - castable
727 ACT_ENABLED = 0xC1, // 0x40 | 0x80 - auto cast + castable
728 ACT_COMMAND = 0x07, // 0x01 | 0x02 | 0x04
729 ACT_REACTION = 0x06, // 0x02 | 0x04
730 ACT_DECIDE = 0x00 // custom
733 enum ReactStates
735 REACT_PASSIVE = 0,
736 REACT_DEFENSIVE = 1,
737 REACT_AGGRESSIVE = 2
740 enum CommandStates
742 COMMAND_STAY = 0,
743 COMMAND_FOLLOW = 1,
744 COMMAND_ATTACK = 2,
745 COMMAND_ABANDON = 3
748 #define UNIT_ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
749 #define UNIT_ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
750 #define MAX_UNIT_ACTION_BUTTON_ACTION_VALUE (0x00FFFFFF+1)
751 #define MAKE_UNIT_ACTION_BUTTON(A,T) (uint32(A) | (uint32(T) << 24))
753 struct UnitActionBarEntry
755 UnitActionBarEntry() : packedData(uint32(ACT_DISABLED) << 24) {}
757 uint32 packedData;
759 // helper
760 ActiveStates GetType() const { return ActiveStates(UNIT_ACTION_BUTTON_TYPE(packedData)); }
761 uint32 GetAction() const { return UNIT_ACTION_BUTTON_ACTION(packedData); }
762 bool IsActionBarForSpell() const
764 ActiveStates Type = GetType();
765 return Type == ACT_DISABLED || Type == ACT_ENABLED || Type == ACT_PASSIVE;
768 void SetActionAndType(uint32 action, ActiveStates type)
770 packedData = MAKE_UNIT_ACTION_BUTTON(action,type);
773 void SetType(ActiveStates type)
775 packedData = MAKE_UNIT_ACTION_BUTTON(UNIT_ACTION_BUTTON_ACTION(packedData),type);
778 void SetAction(uint32 action)
780 packedData = (packedData & 0xFF000000) | UNIT_ACTION_BUTTON_ACTION(action);
784 typedef UnitActionBarEntry CharmSpellEntry;
786 enum ActionBarIndex
788 ACTION_BAR_INDEX_START = 0,
789 ACTION_BAR_INDEX_PET_SPELL_START = 3,
790 ACTION_BAR_INDEX_PET_SPELL_END = 7,
791 ACTION_BAR_INDEX_END = 10,
794 #define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START)
796 struct CharmInfo
798 public:
799 explicit CharmInfo(Unit* unit);
800 uint32 GetPetNumber() const { return m_petnumber; }
801 void SetPetNumber(uint32 petnumber, bool statwindow);
803 void SetCommandState(CommandStates st) { m_CommandState = st; }
804 CommandStates GetCommandState() { return m_CommandState; }
805 bool HasCommandState(CommandStates state) { return (m_CommandState == state); }
806 void SetReactState(ReactStates st) { m_reactState = st; }
807 ReactStates GetReactState() { return m_reactState; }
808 bool HasReactState(ReactStates state) { return (m_reactState == state); }
810 void InitPossessCreateSpells();
811 void InitCharmCreateSpells();
812 void InitPetActionBar();
813 void InitEmptyActionBar();
815 //return true if successful
816 bool AddSpellToActionBar(uint32 spellid, ActiveStates newstate = ACT_DECIDE);
817 bool RemoveSpellFromActionBar(uint32 spell_id);
818 void LoadPetActionBar(const std::string& data);
819 void BuildActionBar(WorldPacket* data);
820 void SetSpellAutocast(uint32 spell_id, bool state);
821 void SetActionBar(uint8 index, uint32 spellOrAction,ActiveStates type)
823 PetActionBar[index].SetActionAndType(spellOrAction,type);
825 UnitActionBarEntry const* GetActionBarEntry(uint8 index) const { return &(PetActionBar[index]); }
827 void ToggleCreatureAutocast(uint32 spellid, bool apply);
829 CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmspells[index]); }
830 private:
832 Unit* m_unit;
833 UnitActionBarEntry PetActionBar[MAX_UNIT_ACTION_BAR_INDEX];
834 CharmSpellEntry m_charmspells[CREATURE_MAX_SPELLS];
835 CommandStates m_CommandState;
836 ReactStates m_reactState;
837 uint32 m_petnumber;
840 // for clearing special attacks
841 #define REACTIVE_TIMER_START 4000
843 enum ReactiveType
845 REACTIVE_DEFENSE = 0,
846 REACTIVE_HUNTER_PARRY = 1,
847 REACTIVE_OVERPOWER = 2
850 #define MAX_REACTIVE 3
851 #define MAX_TOTEM 4
853 typedef std::set<uint64> GuardianPetList;
855 // delay time next attack to prevent client attack animation problems
856 #define ATTACK_DISPLAY_DELAY 200
857 #define MAX_PLAYER_STEALTH_DETECT_RANGE 45.0f // max distance for detection targets by player
859 // Regeneration defines
860 #define REGEN_TIME_FULL 2000 // For this time difference is computed regen value
861 #define REGEN_TIME_PRECISE 500 // Used in Spell::CheckPower for precise regeneration in spell cast time
863 struct SpellProcEventEntry; // used only privately
865 class MANGOS_DLL_SPEC Unit : public WorldObject
867 public:
868 typedef std::set<Unit*> AttackerSet;
869 typedef std::pair<uint32, uint8> spellEffectPair;
870 typedef std::multimap< spellEffectPair, Aura*> AuraMap;
871 typedef std::list<Aura *> AuraList;
872 typedef std::list<DiminishingReturn> Diminishing;
873 typedef std::set<uint32> ComboPointHolderSet;
874 typedef std::map<uint8, uint32> VisibleAuraMap;
876 virtual ~Unit ( );
878 void AddToWorld();
879 void RemoveFromWorld();
881 void CleanupsBeforeDelete(); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
883 DiminishingLevels GetDiminishing(DiminishingGroup group);
884 void IncrDiminishing(DiminishingGroup group);
885 void ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster, DiminishingLevels Level, int32 limitduration);
886 void ApplyDiminishingAura(DiminishingGroup group, bool apply);
887 void ClearDiminishings() { m_Diminishing.clear(); }
889 virtual void Update( uint32 time );
891 void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; }
892 void resetAttackTimer(WeaponAttackType type = BASE_ATTACK);
893 uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; }
894 bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const { return m_attackTimer[type] == 0; }
895 bool haveOffhandWeapon() const;
896 bool canReachWithAttack(Unit *pVictim) const;
897 uint32 m_extraAttacks;
899 void _addAttacker(Unit *pAttacker) // must be called only from Unit::Attack(Unit*)
901 AttackerSet::const_iterator itr = m_attackers.find(pAttacker);
902 if(itr == m_attackers.end())
903 m_attackers.insert(pAttacker);
905 void _removeAttacker(Unit *pAttacker) // must be called only from Unit::AttackStop()
907 m_attackers.erase(pAttacker);
909 Unit * getAttackerForHelper() // If someone wants to help, who to give them
911 if (getVictim() != NULL)
912 return getVictim();
914 if (!m_attackers.empty())
915 return *(m_attackers.begin());
917 return NULL;
919 bool Attack(Unit *victim, bool meleeAttack);
920 void CastStop(uint32 except_spellid = 0);
921 bool AttackStop(bool targetSwitch = false);
922 void RemoveAllAttackers();
923 AttackerSet const& getAttackers() const { return m_attackers; }
924 bool isAttackingPlayer() const;
925 Unit* getVictim() const { return m_attacking; }
926 void CombatStop(bool includingCast = false);
927 void CombatStopWithPets(bool includingCast = false);
928 Unit* SelectNearbyTarget(Unit* except = NULL) const;
929 bool hasNegativeAuraWithInterruptFlag(uint32 flag);
930 void SendMeleeAttackStop(Unit* victim);
931 void SendMeleeAttackStart(Unit* pVictim);
933 void addUnitState(uint32 f) { m_state |= f; }
934 bool hasUnitState(const uint32 f) const { return (m_state & f); }
935 void clearUnitState(uint32 f) { m_state &= ~f; }
936 bool CanFreeMove() const
938 return !hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_IN_FLIGHT |
939 UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED ) && GetOwnerGUID()==0;
942 uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); }
943 virtual uint32 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); }
944 void SetLevel(uint32 lvl);
945 uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); }
946 uint32 getRaceMask() const { return 1 << (getRace()-1); }
947 uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
948 uint32 getClassMask() const { return 1 << (getClass()-1); }
949 uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); }
951 float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); }
952 void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); }
953 uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL) ; }
954 void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); }
956 uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); }
957 void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school,val); }
959 uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
960 uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
961 void SetHealth( uint32 val);
962 void SetMaxHealth(uint32 val);
963 int32 ModifyHealth(int32 val);
965 Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); }
966 void setPowerType(Powers power);
967 uint32 GetPower( Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); }
968 uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); }
969 void SetPower( Powers power, uint32 val);
970 void SetMaxPower(Powers power, uint32 val);
971 int32 ModifyPower(Powers power, int32 val);
972 void ApplyPowerMod(Powers power, uint32 val, bool apply);
973 void ApplyMaxPowerMod(Powers power, uint32 val, bool apply);
975 uint32 GetAttackTime(WeaponAttackType att) const { return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME+att)/m_modAttackSpeedPct[att]); }
976 void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val*m_modAttackSpeedPct[att]); }
977 void ApplyAttackTimePercentMod(WeaponAttackType att,float val, bool apply);
978 void ApplyCastTimePercentMod(float val, bool apply);
980 SheathState GetSheath() const { return SheathState(GetByteValue(UNIT_FIELD_BYTES_2, 0)); }
981 virtual void SetSheath( SheathState sheathed ) { SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); }
983 // faction template id
984 uint32 getFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); }
985 void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction ); }
986 FactionTemplateEntry const* getFactionTemplateEntry() const;
987 bool IsHostileTo(Unit const* unit) const;
988 bool IsHostileToPlayers() const;
989 bool IsFriendlyTo(Unit const* unit) const;
990 bool IsNeutralToAll() const;
991 bool IsContestedGuard() const
993 if(FactionTemplateEntry const* entry = getFactionTemplateEntry())
994 return entry->IsContestedGuardFaction();
996 return false;
998 bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); }
999 void SetPvP(bool state);
1000 uint32 GetCreatureType() const;
1001 uint32 GetCreatureTypeMask() const
1003 uint32 creatureType = GetCreatureType();
1004 return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0;
1007 uint8 getStandState() const { return GetByteValue(UNIT_FIELD_BYTES_1, 0); }
1008 bool IsSitState() const;
1009 bool IsStandState() const;
1010 void SetStandState(uint8 state);
1012 void SetStandFlags(uint8 flags) { SetByteFlag(UNIT_FIELD_BYTES_1, 2,flags); }
1013 void RemoveStandFlags(uint8 flags) { RemoveByteFlag(UNIT_FIELD_BYTES_1, 2,flags); }
1015 bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); }
1016 uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); }
1017 void Mount(uint32 mount);
1018 void Unmount();
1020 uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
1021 void DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb);
1022 uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss);
1023 int32 DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical = false);
1025 void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const *procSpell = NULL);
1026 void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage );
1028 void HandleEmoteCommand(uint32 anim_id);
1029 void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false );
1031 float MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const;
1033 void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK);
1034 void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss);
1036 void CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK);
1037 void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss);
1039 float MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell);
1040 SpellMissInfo MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell);
1041 SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell);
1042 SpellMissInfo SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool canReflect = false);
1044 float GetUnitDodgeChance() const;
1045 float GetUnitParryChance() const;
1046 float GetUnitBlockChance() const;
1047 float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const;
1049 virtual uint32 GetShieldBlockValue() const =0;
1050 uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
1051 uint32 GetDefenseSkillValue(Unit const* target = NULL) const;
1052 uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const;
1053 float GetWeaponProcChance() const;
1054 float GetPPMProcChance(uint32 WeaponSpeed, float PPM) const;
1056 MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType) const;
1057 MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const;
1059 bool isVendor() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR ); }
1060 bool isTrainer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER ); }
1061 bool isQuestGiver() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER ); }
1062 bool isGossip() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP ); }
1063 bool isTaxi() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER ); }
1064 bool isGuildMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER ); }
1065 bool isBattleMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER ); }
1066 bool isBanker() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER ); }
1067 bool isInnkeeper() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER ); }
1068 bool isSpiritHealer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER ); }
1069 bool isSpiritGuide() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE ); }
1070 bool isTabardDesigner()const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER ); }
1071 bool isAuctioner() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER ); }
1072 bool isArmorer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR ); }
1073 bool isServiceProvider() const
1075 return HasFlag( UNIT_NPC_FLAGS,
1076 UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER |
1077 UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER |
1078 UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_GUARD | UNIT_NPC_FLAG_SPIRITHEALER |
1079 UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER );
1081 bool isSpiritService() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE ); }
1083 //Need fix or use this
1084 bool isGuard() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GUARD); }
1086 bool isInFlight() const { return hasUnitState(UNIT_STAT_IN_FLIGHT); }
1088 bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); }
1089 void SetInCombatState(bool PvP, Unit* enemy = NULL);
1090 void SetInCombatWith(Unit* enemy);
1091 void ClearInCombat();
1092 uint32 GetCombatTimer() const { return m_CombatTimer; }
1094 bool HasAuraType(AuraType auraType) const;
1095 bool HasAura(uint32 spellId, uint32 effIndex) const
1097 return m_Auras.find(spellEffectPair(spellId, effIndex)) != m_Auras.end();
1099 bool HasAura(uint32 spellId) const;
1101 bool virtual HasSpell(uint32 /*spellID*/) const { return false; }
1103 bool HasStealthAura() const { return HasAuraType(SPELL_AURA_MOD_STEALTH); }
1104 bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); }
1105 bool isFeared() const { return HasAuraType(SPELL_AURA_MOD_FEAR); }
1106 bool isInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT); }
1107 bool IsPolymorphed() const;
1109 bool isFrozen() const;
1111 void RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage);
1113 bool isTargetableForAttack() const;
1114 virtual bool IsInWater() const;
1115 virtual bool IsUnderWater() const;
1116 bool isInAccessablePlaceFor(Creature const* c) const;
1118 void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, uint32 OverHeal, bool critical = false);
1119 void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype);
1120 void EnergizeBySpell(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype);
1121 uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage);
1122 void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1123 void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1124 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);
1125 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);
1126 void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1127 void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1129 bool IsDamageToThreatSpell(SpellEntry const * spellInfo) const;
1131 void DeMorph();
1133 void SendAttackStateUpdate(CalcDamageInfo *damageInfo);
1134 void SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount);
1135 void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log);
1136 void SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false);
1137 void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo);
1138 void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo);
1140 void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false);
1142 void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, MonsterMovementFlags flags, uint32 Time, Player* player = NULL);
1143 void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, MonsterMovementFlags flags);
1145 void BuildHeartBeatMsg( WorldPacket *data ) const;
1147 virtual void MoveOutOfRange(Player &) { };
1149 bool isAlive() const { return (m_deathState == ALIVE); };
1150 bool isDead() const { return ( m_deathState == DEAD || m_deathState == CORPSE ); };
1151 DeathState getDeathState() { return m_deathState; };
1152 virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet
1154 uint64 GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); }
1155 void SetOwnerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner); }
1156 uint64 GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY); }
1157 void SetCreatorGUID(uint64 creator) { SetUInt64Value(UNIT_FIELD_CREATEDBY, creator); }
1158 uint64 GetPetGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); }
1159 uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); }
1160 void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); }
1161 uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); }
1163 uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
1164 uint64 GetCharmerOrOwnerOrOwnGUID() const
1166 if(uint64 guid = GetCharmerOrOwnerGUID())
1167 return guid;
1168 return GetGUID();
1170 bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); }
1172 Player* GetSpellModOwner();
1174 Unit* GetOwner() const;
1175 Pet* GetPet() const;
1176 Unit* GetCharmer() const;
1177 Unit* GetCharm() const;
1178 Unit* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); }
1179 Unit* GetCharmerOrOwnerOrSelf()
1181 if(Unit* u = GetCharmerOrOwner())
1182 return u;
1184 return this;
1186 Player* GetCharmerOrOwnerPlayerOrPlayerItself();
1187 float GetCombatDistance( const Unit* target ) const;
1189 void SetPet(Pet* pet);
1190 void SetCharm(Unit* pet);
1192 void AddGuardian(Pet* pet);
1193 void RemoveGuardian(Pet* pet);
1194 void RemoveGuardians();
1195 Pet* FindGuardianWithEntry(uint32 entry);
1197 bool isCharmed() const { return GetCharmerGUID() != 0; }
1199 CharmInfo* GetCharmInfo() { return m_charmInfo; }
1200 CharmInfo* InitCharmInfo(Unit* charm);
1202 Pet* CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id = 0);
1204 bool AddAura(Aura *aur);
1206 void RemoveAura(Aura* aura);
1207 void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
1208 void RemoveAura(uint32 spellId, uint32 effindex, Aura* except = NULL);
1209 void RemoveSingleSpellAurasFromStack(uint32 spellId);
1210 void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex);
1211 void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL);
1212 void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId);
1213 void RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID);
1214 void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler);
1215 void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer);
1216 void RemoveAurasDueToSpellByCancel(uint32 spellId);
1217 void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo);
1218 void RemoveNotOwnSingleTargetAuras(uint32 newPhase = 0x0);
1220 void RemoveSpellsCausingAura(AuraType auraType);
1221 void RemoveRankAurasDueToSpell(uint32 spellId);
1222 bool RemoveNoStackAurasDueToAura(Aura *Aur);
1223 void RemoveAurasWithInterruptFlags(uint32 flags);
1224 void RemoveAurasWithDispelType( DispelType type );
1226 void RemoveAllAuras();
1227 void RemoveArenaAuras(bool onleave = false);
1228 void RemoveAllAurasOnDeath();
1229 void DelayAura(uint32 spellId, uint32 effindex, int32 delaytime);
1231 float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school ); }
1232 void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school,val); }
1233 void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) { ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); }
1234 void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) { ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); }
1235 void InitStatBuffMods()
1237 for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0);
1238 for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0);
1240 void ApplyStatBuffMod(Stats stat, float val, bool apply) { ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0+stat : UNIT_FIELD_NEGSTAT0+stat), val, apply); }
1241 void ApplyStatPercentBuffMod(Stats stat, float val, bool apply)
1243 ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0+stat, val, apply);
1244 ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0+stat, val, apply);
1246 void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; }
1247 void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); }
1248 uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
1249 void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); }
1250 uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); }
1251 uint32 GetCreatePowers(Powers power) const;
1252 float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0+stat); }
1253 float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); }
1254 float GetCreateStat(Stats stat) const { return m_createStats[stat]; }
1256 void SetCurrentCastedSpell(Spell * pSpell);
1257 virtual void ProhibitSpellScholl(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/ ) { }
1258 void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true);
1259 void FinishSpell(CurrentSpellTypes spellType, bool ok = true);
1261 // set withDelayed to true to account delayed spells as casted
1262 // delayed+channeled spells are always accounted as casted
1263 // we can skip channeled or delayed checks using flags
1264 bool IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false) const;
1266 // set withDelayed to true to interrupt delayed spells too
1267 // delayed+channeled spells are always interrupted
1268 void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0);
1270 Spell* GetCurrentSpell(CurrentSpellTypes spellType) const { return m_currentSpells[spellType]; }
1271 Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
1273 uint32 m_addDmgOnce;
1274 uint64 m_TotemSlot[MAX_TOTEM];
1275 uint64 m_ObjectSlot[4];
1276 uint32 m_detectInvisibilityMask;
1277 uint32 m_invisibilityMask;
1279 uint32 m_ShapeShiftFormSpellId;
1280 ShapeshiftForm m_form;
1281 bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; }
1283 float m_modMeleeHitChance;
1284 float m_modRangedHitChance;
1285 float m_modSpellHitChance;
1286 int32 m_baseSpellCritChance;
1288 float m_threatModifier[MAX_SPELL_SCHOOL];
1289 float m_modAttackSpeedPct[3];
1291 // Event handler
1292 EventProcessor m_Events;
1294 // stat system
1295 bool HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply);
1296 void SetModifierValue(UnitMods unitMod, UnitModifierType modifierType, float value) { m_auraModifiersGroup[unitMod][modifierType] = value; }
1297 float GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const;
1298 float GetTotalStatValue(Stats stat) const;
1299 float GetTotalAuraModValue(UnitMods unitMod) const;
1300 SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const;
1301 Stats GetStatByAuraGroup(UnitMods unitMod) const;
1302 Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const;
1303 bool CanModifyStats() const { return m_canModifyStats; }
1304 void SetCanModifyStats(bool modifyStats) { m_canModifyStats = modifyStats; }
1305 virtual bool UpdateStats(Stats stat) = 0;
1306 virtual bool UpdateAllStats() = 0;
1307 virtual void UpdateResistances(uint32 school) = 0;
1308 virtual void UpdateArmor() = 0;
1309 virtual void UpdateMaxHealth() = 0;
1310 virtual void UpdateMaxPower(Powers power) = 0;
1311 virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0;
1312 virtual void UpdateDamagePhysical(WeaponAttackType attType) = 0;
1313 float GetTotalAttackPowerValue(WeaponAttackType attType) const;
1314 float GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const;
1315 void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; }
1317 void SetInFront(Unit const* target);
1319 // Visibility system
1320 UnitVisibility GetVisibility() const { return m_Visibility; }
1321 void SetVisibility(UnitVisibility x);
1323 // common function for visibility checks for player/creatures with detection code
1324 bool isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
1325 bool canDetectInvisibilityOf(Unit const* u) const;
1326 void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask
1328 // virtual functions for all world objects types
1329 bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
1330 // function for low level grid visibility checks in player/creature cases
1331 virtual bool IsVisibleInGridForPlayer(Player* pl) const = 0;
1333 AuraList & GetSingleCastAuras() { return m_scAuras; }
1334 AuraList const& GetSingleCastAuras() const { return m_scAuras; }
1335 SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY];
1337 // Threat related methods
1338 bool CanHaveThreatList() const;
1339 void AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell = NULL);
1340 float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL);
1341 void DeleteThreatList();
1342 bool SelectHostilTarget();
1343 void TauntApply(Unit* pVictim);
1344 void TauntFadeOut(Unit *taunter);
1345 ThreatManager& getThreatManager() { return m_ThreatManager; }
1346 void addHatedBy(HostilReference* pHostilReference) { m_HostilRefManager.insertFirst(pHostilReference); };
1347 void removeHatedBy(HostilReference* /*pHostilReference*/ ) { /* nothing to do yet */ }
1348 HostilRefManager& getHostilRefManager() { return m_HostilRefManager; }
1350 uint32 GetVisibleAura(uint8 slot)
1352 VisibleAuraMap::const_iterator itr = m_visibleAuras.find(slot);
1353 if(itr != m_visibleAuras.end())
1354 return itr->second;
1355 return 0;
1357 void SetVisibleAura(uint8 slot, uint32 spellid)
1359 if(spellid == 0)
1360 m_visibleAuras.erase(slot);
1361 else
1362 m_visibleAuras[slot] = spellid;
1364 VisibleAuraMap const *GetVisibleAuras() { return &m_visibleAuras; }
1365 uint8 GetVisibleAurasCount() { return m_visibleAuras.size(); }
1367 Aura* GetAura(uint32 spellId, uint32 effindex);
1368 Aura* GetAura(AuraType type, uint32 family, uint64 familyFlag, uint32 familyFlag2 = 0, uint64 casterGUID = 0);
1370 AuraMap & GetAuras() { return m_Auras; }
1371 AuraMap const& GetAuras() const { return m_Auras; }
1372 AuraList const& GetAurasByType(AuraType type) const { return m_modAuras[type]; }
1373 void ApplyAuraProcTriggerDamage(Aura* aura, bool apply);
1375 int32 GetTotalAuraModifier(AuraType auratype) const;
1376 float GetTotalAuraMultiplier(AuraType auratype) const;
1377 int32 GetMaxPositiveAuraModifier(AuraType auratype) const;
1378 int32 GetMaxNegativeAuraModifier(AuraType auratype) const;
1380 int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1381 float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1382 int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1383 int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1385 int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1386 float GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const;
1387 int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1388 int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1390 Aura* GetDummyAura(uint32 spell_id) const;
1392 uint32 GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
1393 void SetDisplayId(uint32 modelId);
1394 uint32 GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
1395 void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); }
1396 void setTransForm(uint32 spellid) { m_transform = spellid;}
1397 uint32 getTransForm() const { return m_transform;}
1399 DynamicObject* GetDynObject(uint32 spellId, uint32 effIndex);
1400 DynamicObject* GetDynObject(uint32 spellId);
1401 void AddDynObject(DynamicObject* dynObj);
1402 void RemoveDynObject(uint32 spellid);
1403 void RemoveDynObjectWithGUID(uint64 guid) { m_dynObjGUIDs.remove(guid); }
1404 void RemoveAllDynObjects();
1406 GameObject* GetGameObject(uint32 spellId) const;
1407 void AddGameObject(GameObject* gameObj);
1408 void RemoveGameObject(GameObject* gameObj, bool del);
1409 void RemoveGameObject(uint32 spellid, bool del);
1410 void RemoveAllGameObjects();
1412 uint32 CalculateDamage(WeaponAttackType attType, bool normalized);
1413 float GetAPMultiplier(WeaponAttackType attType, bool normalized);
1414 void ModifyAuraState(AuraState flag, bool apply);
1415 bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); }
1416 bool HasAuraStateForCaster(AuraState flag, uint64 caster) const;
1417 void UnsummonAllTotems();
1418 Unit* SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo = NULL);
1419 int32 SpellBaseDamageBonus(SpellSchoolMask schoolMask);
1420 int32 SpellBaseHealingBonus(SpellSchoolMask schoolMask);
1421 int32 SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim);
1422 int32 SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim);
1423 uint32 SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 damage, DamageEffectType damagetype, uint32 stack = 1);
1424 uint32 SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1);
1425 bool isSpellBlocked(Unit *pVictim, SpellEntry const *spellProto, WeaponAttackType attackType = BASE_ATTACK);
1426 bool isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK);
1427 uint32 SpellCriticalDamageBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim);
1428 uint32 SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim);
1430 void SetLastManaUse()
1432 if (GetTypeId() == TYPEID_PLAYER && !IsUnderLastManaUseEffect())
1433 RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
1435 m_lastManaUseTimer = 5000;
1437 bool IsUnderLastManaUseEffect() const { return m_lastManaUseTimer; }
1439 uint32 GetRegenTimer() const { return m_regenTimer; }
1441 void SetContestedPvP(Player *attackedPlayer = NULL);
1443 void MeleeDamageBonus(Unit *pVictim, uint32 *damage, WeaponAttackType attType, SpellEntry const *spellProto = NULL);
1444 uint32 GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime );
1446 void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
1447 void ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType type, bool apply);
1448 virtual bool IsImmunedToSpell(SpellEntry const* spellInfo);
1449 // redefined in Creature
1450 bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask);
1451 virtual bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
1452 // redefined in Creature
1454 uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage);
1455 void CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist);
1457 void UpdateSpeed(UnitMoveType mtype, bool forced);
1458 float GetSpeed( UnitMoveType mtype ) const;
1459 float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; }
1460 void SetSpeed(UnitMoveType mtype, float rate, bool forced = false);
1462 void SetHover(bool on);
1463 bool isHover() const { return HasAuraType(SPELL_AURA_HOVER); }
1465 void KnockBackFrom(Unit* target, float horizintalSpeed, float verticalSpeed);
1467 void _RemoveAllAuraMods();
1468 void _ApplyAllAuraMods();
1470 int32 CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 basePoints, Unit const* target);
1471 int32 CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target);
1472 float CalculateLevelPenalty(SpellEntry const* spellProto) const;
1474 void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); }
1475 void removeFollower(FollowerReference* /*pRef*/ ) { /* nothing to do yet */ }
1476 static Unit* GetUnit(WorldObject& object, uint64 guid);
1478 MotionMaster* GetMotionMaster() { return &i_motionMaster; }
1480 bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); }
1481 void StopMoving();
1483 void SetFeared(bool apply, uint64 casterGUID = 0, uint32 spellID = 0, uint32 time = 0);
1484 void SetConfused(bool apply, uint64 casterGUID = 0, uint32 spellID = 0);
1486 void AddComboPointHolder(uint32 lowguid) { m_ComboPointHolders.insert(lowguid); }
1487 void RemoveComboPointHolder(uint32 lowguid) { m_ComboPointHolders.erase(lowguid); }
1488 void ClearComboPointHolders();
1490 ///----------Pet responses methods-----------------
1491 void SendPetCastFail(uint32 spellid, SpellCastResult msg);
1492 void SendPetActionFeedback (uint8 msg);
1493 void SendPetTalk (uint32 pettalk);
1494 void SendPetAIReaction(uint64 guid);
1495 ///----------End of Pet responses methods----------
1497 void propagateSpeedChange() { GetMotionMaster()->propagateSpeedChange(); }
1499 // reactive attacks
1500 void ClearAllReactives();
1501 void StartReactiveTimer( ReactiveType reactive ) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;}
1502 void UpdateReactives(uint32 p_time);
1504 // group updates
1505 void UpdateAuraForGroup(uint8 slot);
1507 // pet auras
1508 typedef std::set<PetAura const*> PetAuraSet;
1509 PetAuraSet m_petAuras;
1510 void AddPetAura(PetAura const* petSpell);
1511 void RemovePetAura(PetAura const* petSpell);
1513 protected:
1514 explicit Unit ();
1516 void _UpdateSpells(uint32 time);
1518 void _UpdateAutoRepeatSpell();
1519 bool m_AutoRepeatFirstCast;
1521 uint32 m_attackTimer[MAX_ATTACK];
1523 float m_createStats[MAX_STATS];
1525 AttackerSet m_attackers;
1526 Unit* m_attacking;
1528 DeathState m_deathState;
1530 AuraMap m_Auras;
1531 AuraMap::iterator m_AurasUpdateIterator; // != end() in Unit::m_Auras update and point to next element
1532 AuraList m_deletedAuras; // auras removed while in ApplyModifier and waiting deleted
1534 AuraList m_scAuras; // casted by unit single per-caster auras
1536 typedef std::list<uint64> DynObjectGUIDs;
1537 DynObjectGUIDs m_dynObjGUIDs;
1539 typedef std::list<GameObject*> GameObjectList;
1540 GameObjectList m_gameObj;
1541 bool m_isSorted;
1542 uint32 m_transform;
1544 AuraList m_modAuras[TOTAL_AURAS];
1545 float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END];
1546 float m_weaponDamage[MAX_ATTACK][2];
1547 bool m_canModifyStats;
1548 //std::list< spellEffectPair > AuraSpells[TOTAL_AURAS]; // TODO: use this if ok for mem
1549 VisibleAuraMap m_visibleAuras;
1551 float m_speed_rate[MAX_MOVE_TYPE];
1553 CharmInfo *m_charmInfo;
1555 virtual SpellSchoolMask GetMeleeDamageSchoolMask() const;
1557 MotionMaster i_motionMaster;
1559 uint32 m_reactiveTimer[MAX_REACTIVE];
1560 uint32 m_regenTimer;
1561 uint32 m_lastManaUseTimer;
1563 private:
1564 bool IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const*& spellProcEvent );
1565 bool HandleDummyAuraProc( Unit *pVictim, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
1566 bool HandleHasteAuraProc( Unit *pVictim, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
1567 bool HandleSpellCritChanceAuraProc( Unit *pVictim, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
1568 bool HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
1569 bool HandleOverrideClassScriptAuraProc(Unit *pVictim, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 cooldown);
1570 bool HandleMendingAuraProc(Aura* triggeredByAura);
1572 uint32 m_state; // Even derived shouldn't modify
1573 uint32 m_CombatTimer;
1575 Spell* m_currentSpells[CURRENT_MAX_SPELL];
1577 UnitVisibility m_Visibility;
1579 Diminishing m_Diminishing;
1580 // Manage all Units threatening us
1581 ThreatManager m_ThreatManager;
1582 // Manage all Units that are threatened by us
1583 HostilRefManager m_HostilRefManager;
1585 FollowerRefManager m_FollowingRefManager;
1587 ComboPointHolderSet m_ComboPointHolders;
1589 GuardianPetList m_guardianPets;
1591 #endif