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
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"
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
77 AURA_INTERRUPT_FLAG_CHANGE_MAP
= 0x00080000, // 19 leaving map/getting teleported
78 AURA_INTERRUPT_FLAG_UNK20
= 0x00100000, // 20
79 AURA_INTERRUPT_FLAG_UNK21
= 0x00200000, // 21
80 AURA_INTERRUPT_FLAG_UNK22
= 0x00400000, // 22
81 AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
= 0x00800000, // 23 removed by entering pvp combat
82 AURA_INTERRUPT_FLAG_DIRECT_DAMAGE
= 0x01000000 // 24 removed by any direct damage
88 SPELLMOD_DURATION
= 1,
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
102 SPELLMOD_CRIT_DAMAGE_BONUS
= 15,
103 SPELLMOD_RESIST_MISS_CHANCE
= 16,
104 SPELLMOD_JUMP_TARGETS
= 17,
105 SPELLMOD_CHANCE_OF_SUCCESS
= 18,
106 SPELLMOD_ACTIVATION_TIME
= 19,
107 SPELLMOD_EFFECT_PAST_FIRST
= 20,
108 SPELLMOD_CASTING_TIME_OLD
= 21,
110 SPELLMOD_EFFECT3
= 23,
111 SPELLMOD_SPELL_BONUS_DAMAGE
= 24,
112 // spellmod 25, 26 unused
113 SPELLMOD_MULTIPLE_VALUE
= 27,
114 SPELLMOD_RESIST_DISPEL_CHANCE
= 28
117 #define MAX_SPELLMOD 32
119 enum SpellFacingFlags
121 SPELL_FACING_FLAG_INFRONT
= 0x0001
124 #define BASE_MINDAMAGE 1.0f
125 #define BASE_MAXDAMAGE 2.0f
126 #define BASE_ATTACK_TIME 2000
128 // byte value (UNIT_FIELD_BYTES_1,0)
129 enum UnitStandStateType
131 UNIT_STAND_STATE_STAND
= 0,
132 UNIT_STAND_STATE_SIT
= 1,
133 UNIT_STAND_STATE_SIT_CHAIR
= 2,
134 UNIT_STAND_STATE_SLEEP
= 3,
135 UNIT_STAND_STATE_SIT_LOW_CHAIR
= 4,
136 UNIT_STAND_STATE_SIT_MEDIUM_CHAIR
= 5,
137 UNIT_STAND_STATE_SIT_HIGH_CHAIR
= 6,
138 UNIT_STAND_STATE_DEAD
= 7,
139 UNIT_STAND_STATE_KNEEL
= 8
142 // byte flag value (UNIT_FIELD_BYTES_1,2)
145 UNIT_STAND_FLAGS_CREEP
= 0x02,
146 UNIT_STAND_FLAGS_ALL
= 0xFF
149 // byte flags value (UNIT_FIELD_BYTES_1,3)
150 enum UnitBytes1_Flags
152 UNIT_BYTE1_FLAG_ALWAYS_STAND
= 0x01,
153 UNIT_BYTE1_FLAG_UNTRACKABLE
= 0x04,
154 UNIT_BYTE1_FLAG_ALL
= 0xFF
157 // high byte (3 from 0..3) of UNIT_FIELD_BYTES_2
168 FORM_DIREBEAR
= 0x08,
169 FORM_CREATUREBEAR
= 0x0E,
170 FORM_CREATURECAT
= 0x0F,
171 FORM_GHOSTWOLF
= 0x10,
172 FORM_BATTLESTANCE
= 0x11,
173 FORM_DEFENSIVESTANCE
= 0x12,
174 FORM_BERSERKERSTANCE
= 0x13,
177 FORM_METAMORPHOSIS
= 0x16,
178 FORM_FLIGHT_EPIC
= 0x1B,
183 FORM_SPIRITOFREDEMPTION
= 0x20
186 // low byte ( 0 from 0..3 ) of UNIT_FIELD_BYTES_2
189 SHEATH_STATE_UNARMED
= 0, // non prepared weapon
190 SHEATH_STATE_MELEE
= 1, // prepared melee weapon
191 SHEATH_STATE_RANGED
= 2 // prepared ranged weapon
194 // byte (1 from 0..3) of UNIT_FIELD_BYTES_2
195 enum UnitBytes2_Flags
197 UNIT_BYTE2_FLAG_PVP
= 0x01,
198 UNIT_BYTE2_FLAG_UNK1
= 0x02,
199 UNIT_BYTE2_FLAG_FFA_PVP
= 0x04,
200 UNIT_BYTE2_FLAG_SANCTUARY
= 0x08,
201 UNIT_BYTE2_FLAG_UNK4
= 0x10,
202 UNIT_BYTE2_FLAG_UNK5
= 0x20,
203 UNIT_BYTE2_FLAG_UNK6
= 0x40,
204 UNIT_BYTE2_FLAG_UNK7
= 0x80
207 // byte (2 from 0..3) of UNIT_FIELD_BYTES_2
210 UNIT_RENAME_NOT_ALLOWED
= 0x02,
211 UNIT_RENAME_ALLOWED
= 0x03
214 #define CREATURE_MAX_SPELLS 4
219 SINGLEHANDEDSWING
= 1,
225 VICTIMSTATE_UNKNOWN1
= 0,
226 VICTIMSTATE_NORMAL
= 1,
227 VICTIMSTATE_DODGE
= 2,
228 VICTIMSTATE_PARRY
= 3,
229 VICTIMSTATE_INTERRUPT
= 4,
230 VICTIMSTATE_BLOCKS
= 5,
231 VICTIMSTATE_EVADES
= 6,
232 VICTIMSTATE_IS_IMMUNE
= 7,
233 VICTIMSTATE_DEFLECTS
= 8
238 HITINFO_NORMALSWING
= 0x00000000,
239 HITINFO_UNK1
= 0x00000001, // req correct packet structure
240 HITINFO_NORMALSWING2
= 0x00000002,
241 HITINFO_LEFTSWING
= 0x00000004,
242 HITINFO_UNK2
= 0x00000008,
243 HITINFO_MISS
= 0x00000010,
244 HITINFO_ABSORB
= 0x00000020, // absorbed damage
245 HITINFO_ABSORB2
= 0x00000040, // absorbed damage
246 HITINFO_RESIST
= 0x00000080, // resisted atleast some damage
247 HITINFO_RESIST2
= 0x00000100, // resisted atleast some damage
248 HITINFO_CRITICALHIT
= 0x00000200, // critical hit
252 HITINFO_BLOCK
= 0x00002000, // blocked damage
255 HITINFO_GLANCING
= 0x00010000,
256 HITINFO_CRUSHING
= 0x00020000,
257 HITINFO_NOACTION
= 0x00040000, // guessed
260 HITINFO_SWINGNOHITSOUND
= 0x00200000, // guessed
262 HITINFO_UNK3
= 0x00800000
265 //i would like to remove this: (it is defined in item.h
272 struct FactionTemplateEntry
;
275 struct SpellEntryExt
;
293 typedef std::list
<SpellImmune
> SpellImmuneList
;
295 enum UnitModifierType
301 MODIFIER_TYPE_END
= 4
304 enum WeaponDamageRange
310 enum DamageTypeToSchool
319 AURA_REMOVE_BY_DEFAULT
,
320 AURA_REMOVE_BY_STACK
, // at replace by semillar aura
321 AURA_REMOVE_BY_CANCEL
,
322 AURA_REMOVE_BY_DISPEL
,
328 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.
329 UNIT_MOD_STAT_AGILITY
,
330 UNIT_MOD_STAT_STAMINA
,
331 UNIT_MOD_STAT_INTELLECT
,
332 UNIT_MOD_STAT_SPIRIT
,
334 UNIT_MOD_MANA
, // UNIT_MOD_MANA..UNIT_MOD_RUNIC_POWER must be in existed order, it's accessed by index values of Powers enum.
340 UNIT_MOD_RUNIC_POWER
,
341 UNIT_MOD_ARMOR
, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum.
342 UNIT_MOD_RESISTANCE_HOLY
,
343 UNIT_MOD_RESISTANCE_FIRE
,
344 UNIT_MOD_RESISTANCE_NATURE
,
345 UNIT_MOD_RESISTANCE_FROST
,
346 UNIT_MOD_RESISTANCE_SHADOW
,
347 UNIT_MOD_RESISTANCE_ARCANE
,
348 UNIT_MOD_ATTACK_POWER
,
349 UNIT_MOD_ATTACK_POWER_RANGED
,
350 UNIT_MOD_DAMAGE_MAINHAND
,
351 UNIT_MOD_DAMAGE_OFFHAND
,
352 UNIT_MOD_DAMAGE_RANGED
,
355 UNIT_MOD_STAT_START
= UNIT_MOD_STAT_STRENGTH
,
356 UNIT_MOD_STAT_END
= UNIT_MOD_STAT_SPIRIT
+ 1,
357 UNIT_MOD_RESISTANCE_START
= UNIT_MOD_ARMOR
,
358 UNIT_MOD_RESISTANCE_END
= UNIT_MOD_RESISTANCE_ARCANE
+ 1,
359 UNIT_MOD_POWER_START
= UNIT_MOD_MANA
,
360 UNIT_MOD_POWER_END
= UNIT_MOD_RUNIC_POWER
+ 1
366 RANGED_CRIT_PERCENTAGE
,
367 OFFHAND_CRIT_PERCENTAGE
,
378 #define MOD_END (PCT_MOD+1)
392 UNIT_STAT_DIED
= 0x0001,
393 UNIT_STAT_MELEE_ATTACKING
= 0x0002, // player is melee attacking someone
394 //UNIT_STAT_MELEE_ATTACK_BY = 0x0004, // player is melee attack by someone
395 UNIT_STAT_STUNNED
= 0x0008,
396 UNIT_STAT_ROAMING
= 0x0010,
397 UNIT_STAT_CHASE
= 0x0020,
398 UNIT_STAT_SEARCHING
= 0x0040,
399 UNIT_STAT_FLEEING
= 0x0080,
400 UNIT_STAT_MOVING
= (UNIT_STAT_ROAMING
| UNIT_STAT_CHASE
| UNIT_STAT_SEARCHING
| UNIT_STAT_FLEEING
),
401 UNIT_STAT_IN_FLIGHT
= 0x0100, // player is in flight mode
402 UNIT_STAT_FOLLOW
= 0x0200,
403 UNIT_STAT_ROOT
= 0x0400,
404 UNIT_STAT_CONFUSED
= 0x0800,
405 UNIT_STAT_DISTRACTED
= 0x1000,
406 UNIT_STAT_ISOLATED
= 0x2000, // area auras do not affect other players
407 UNIT_STAT_ATTACK_PLAYER
= 0x4000,
408 UNIT_STAT_ALL_STATE
= 0xffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT)
420 MOVE_FLIGHT_BACK
= 7,
424 #define MAX_MOVE_TYPE 9
426 extern float baseMoveSpeed
[MAX_MOVE_TYPE
];
428 enum WeaponAttackType
440 CR_DEFENSE_SKILL
= 1,
450 CR_HIT_TAKEN_MELEE
= 11,
451 CR_HIT_TAKEN_RANGED
= 12,
452 CR_HIT_TAKEN_SPELL
= 13,
453 CR_CRIT_TAKEN_MELEE
= 14,
454 CR_CRIT_TAKEN_RANGED
= 15,
455 CR_CRIT_TAKEN_SPELL
= 16,
457 CR_HASTE_RANGED
= 18,
459 CR_WEAPON_SKILL_MAINHAND
= 20,
460 CR_WEAPON_SKILL_OFFHAND
= 21,
461 CR_WEAPON_SKILL_RANGED
= 22,
463 CR_ARMOR_PENETRATION
= 24
466 #define MAX_COMBAT_RATING 25
468 enum DamageEffectType
470 DIRECT_DAMAGE
= 0, // used for normal weapon damage (not for class abilities or spells)
471 SPELL_DIRECT_DAMAGE
= 1, // spell/class abilities damage
474 NODAMAGE
= 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
480 VISIBILITY_OFF
= 0, // absolute, not detectable, GM-like, can see all other
482 VISIBILITY_GROUP_STEALTH
= 2, // detect chance, seen and can see group members
483 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)
484 VISIBILITY_GROUP_NO_DETECT
= 4, // state just at stealth apply for update Grid state. Don't remove, otherwise stealth spells will break
485 VISIBILITY_RESPAWN
= 5 // special totally not detectable visibility for force delete object at respawn command
488 // Value masks for UNIT_FIELD_FLAGS
491 UNIT_FLAG_UNK_0
= 0x00000001,
492 UNIT_FLAG_NON_ATTACKABLE
= 0x00000002, // not attackable
493 UNIT_FLAG_DISABLE_MOVE
= 0x00000004,
494 UNIT_FLAG_PVP_ATTACKABLE
= 0x00000008, // allow apply pvp rules to attackable state in addition to faction dependent state
495 UNIT_FLAG_RENAME
= 0x00000010,
496 UNIT_FLAG_PREPARATION
= 0x00000020, // don't take reagents for spells with SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP
497 UNIT_FLAG_UNK_6
= 0x00000040,
498 UNIT_FLAG_NOT_ATTACKABLE_1
= 0x00000080, // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE
499 UNIT_FLAG_UNK_8
= 0x00000100, // 2.0.8
500 UNIT_FLAG_UNK_9
= 0x00000200, // 3.0.3 - makes you unable to attack everything
501 UNIT_FLAG_LOOTING
= 0x00000400, // loot animation
502 UNIT_FLAG_PET_IN_COMBAT
= 0x00000800, // in combat?, 2.0.8
503 UNIT_FLAG_PVP
= 0x00001000, // changed in 3.0.3
504 UNIT_FLAG_SILENCED
= 0x00002000, // silenced, 2.1.1
505 UNIT_FLAG_UNK_14
= 0x00004000, // 2.0.8
506 UNIT_FLAG_UNK_15
= 0x00008000,
507 UNIT_FLAG_UNK_16
= 0x00010000,
508 UNIT_FLAG_PACIFIED
= 0x00020000, // 3.0.3 ok
509 UNIT_FLAG_STUNNED
= 0x00040000, // 3.0.3 ok
510 UNIT_FLAG_IN_COMBAT
= 0x00080000,
511 UNIT_FLAG_TAXI_FLIGHT
= 0x00100000, // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag
512 UNIT_FLAG_DISARMED
= 0x00200000, // 3.0.3, disable melee spells casting..., "Required melee weapon" added to melee spells tooltip.
513 UNIT_FLAG_CONFUSED
= 0x00400000,
514 UNIT_FLAG_FLEEING
= 0x00800000,
515 UNIT_FLAG_UNK_24
= 0x01000000, // used in spell Eyes of the Beast for pet...
516 UNIT_FLAG_NOT_SELECTABLE
= 0x02000000,
517 UNIT_FLAG_SKINNABLE
= 0x04000000,
518 UNIT_FLAG_MOUNT
= 0x08000000,
519 UNIT_FLAG_UNK_28
= 0x10000000,
520 UNIT_FLAG_UNK_29
= 0x20000000, // used in Feing Death spell
521 UNIT_FLAG_SHEATHE
= 0x40000000,
522 UNIT_FLAG_UNK_31
= 0x80000000
525 // Value masks for UNIT_FIELD_FLAGS_2
528 UNIT_FLAG2_FEIGN_DEATH
= 0x00000001,
529 UNIT_FLAG2_UNK1
= 0x00000002, // Hide unit model (show only player equip)
530 UNIT_FLAG2_COMPREHEND_LANG
= 0x00000008,
531 UNIT_FLAG2_FORCE_MOVE
= 0x00000040,
532 UNIT_FLAG2_REGENERATE_POWER
= 0x00000800
535 /// Non Player Character flags
538 UNIT_NPC_FLAG_NONE
= 0x00000000,
539 UNIT_NPC_FLAG_GOSSIP
= 0x00000001, // 100%
540 UNIT_NPC_FLAG_QUESTGIVER
= 0x00000002, // guessed, probably ok
541 UNIT_NPC_FLAG_UNK1
= 0x00000004,
542 UNIT_NPC_FLAG_UNK2
= 0x00000008,
543 UNIT_NPC_FLAG_TRAINER
= 0x00000010, // 100%
544 UNIT_NPC_FLAG_TRAINER_CLASS
= 0x00000020, // 100%
545 UNIT_NPC_FLAG_TRAINER_PROFESSION
= 0x00000040, // 100%
546 UNIT_NPC_FLAG_VENDOR
= 0x00000080, // 100%
547 UNIT_NPC_FLAG_VENDOR_AMMO
= 0x00000100, // 100%, general goods vendor
548 UNIT_NPC_FLAG_VENDOR_FOOD
= 0x00000200, // 100%
549 UNIT_NPC_FLAG_VENDOR_POISON
= 0x00000400, // guessed
550 UNIT_NPC_FLAG_VENDOR_REAGENT
= 0x00000800, // 100%
551 UNIT_NPC_FLAG_REPAIR
= 0x00001000, // 100%
552 UNIT_NPC_FLAG_FLIGHTMASTER
= 0x00002000, // 100%
553 UNIT_NPC_FLAG_SPIRITHEALER
= 0x00004000, // guessed
554 UNIT_NPC_FLAG_SPIRITGUIDE
= 0x00008000, // guessed
555 UNIT_NPC_FLAG_INNKEEPER
= 0x00010000, // 100%
556 UNIT_NPC_FLAG_BANKER
= 0x00020000, // 100%
557 UNIT_NPC_FLAG_PETITIONER
= 0x00040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions
558 UNIT_NPC_FLAG_TABARDDESIGNER
= 0x00080000, // 100%
559 UNIT_NPC_FLAG_BATTLEMASTER
= 0x00100000, // 100%
560 UNIT_NPC_FLAG_AUCTIONEER
= 0x00200000, // 100%
561 UNIT_NPC_FLAG_STABLEMASTER
= 0x00400000, // 100%
562 UNIT_NPC_FLAG_GUILD_BANKER
= 0x00800000, // cause client to send 997 opcode
563 UNIT_NPC_FLAG_SPELLCLICK
= 0x01000000, // cause client to send 1015 opcode (spell click)
564 UNIT_NPC_FLAG_GUARD
= 0x10000000, // custom flag for guards
569 MOVEMENTFLAG_NONE
= 0x00000000,
570 MOVEMENTFLAG_FORWARD
= 0x00000001,
571 MOVEMENTFLAG_BACKWARD
= 0x00000002,
572 MOVEMENTFLAG_STRAFE_LEFT
= 0x00000004,
573 MOVEMENTFLAG_STRAFE_RIGHT
= 0x00000008,
574 MOVEMENTFLAG_LEFT
= 0x00000010,
575 MOVEMENTFLAG_RIGHT
= 0x00000020,
576 MOVEMENTFLAG_PITCH_UP
= 0x00000040,
577 MOVEMENTFLAG_PITCH_DOWN
= 0x00000080,
578 MOVEMENTFLAG_WALK_MODE
= 0x00000100, // Walking
579 MOVEMENTFLAG_ONTRANSPORT
= 0x00000200, // Used for flying on some creatures
580 MOVEMENTFLAG_LEVITATING
= 0x00000400,
581 MOVEMENTFLAG_FLY_UNK1
= 0x00000800,
582 MOVEMENTFLAG_JUMPING
= 0x00001000,
583 MOVEMENTFLAG_UNK4
= 0x00002000,
584 MOVEMENTFLAG_FALLING
= 0x00004000,
585 // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
586 MOVEMENTFLAG_SWIMMING
= 0x00200000, // appears with fly flag also
587 MOVEMENTFLAG_FLY_UP
= 0x00400000,
588 MOVEMENTFLAG_CAN_FLY
= 0x00800000,
589 MOVEMENTFLAG_FLYING
= 0x01000000,
590 MOVEMENTFLAG_FLYING2
= 0x02000000, // Actual flying mode
591 MOVEMENTFLAG_SPLINE
= 0x04000000, // used for flight paths
592 MOVEMENTFLAG_SPLINE2
= 0x08000000, // used for flight paths
593 MOVEMENTFLAG_WATERWALKING
= 0x10000000, // prevent unit from falling through water
594 MOVEMENTFLAG_SAFE_FALL
= 0x20000000, // active rogue safe fall spell (passive)
595 MOVEMENTFLAG_UNK3
= 0x40000000
598 enum DiminishingLevels
600 DIMINISHING_LEVEL_1
= 0,
601 DIMINISHING_LEVEL_2
= 1,
602 DIMINISHING_LEVEL_3
= 2,
603 DIMINISHING_LEVEL_IMMUNE
= 3
606 struct DiminishingReturn
608 DiminishingReturn(DiminishingGroup group
, uint32 t
, uint32 count
) : DRGroup(group
), hitTime(t
), hitCount(count
), stack(0) {}
610 DiminishingGroup DRGroup
:16;
618 MELEE_HIT_EVADE
, MELEE_HIT_MISS
, MELEE_HIT_DODGE
, MELEE_HIT_BLOCK
, MELEE_HIT_PARRY
,
619 MELEE_HIT_GLANCING
, MELEE_HIT_CRIT
, MELEE_HIT_CRUSHING
, MELEE_HIT_NORMAL
624 CleanDamage(uint32 _damage
, WeaponAttackType _attackType
, MeleeHitOutcome _hitOutCome
) :
625 damage(_damage
), attackType(_attackType
), hitOutCome(_hitOutCome
) {}
628 WeaponAttackType attackType
;
629 MeleeHitOutcome hitOutCome
;
632 // Struct for use in Unit::CalculateMeleeDamage
633 // Need create structure like in SMSG_ATTACKERSTATEUPDATE opcode
634 struct CalcDamageInfo
636 Unit
*attacker
; // Attacker
637 Unit
*target
; // Target for damage
638 uint32 damageSchoolMask
;
642 uint32 blocked_amount
;
646 WeaponAttackType attackType
; //
650 uint32 cleanDamage
; // Used only fo rage calcultion
651 MeleeHitOutcome hitOutCome
; // TODO: remove this field (need use TargetState)
654 // Spell damage info structure based on structure sending in SMSG_SPELLNONMELEEDAMAGELOG opcode
655 struct SpellNonMeleeDamage
{
656 SpellNonMeleeDamage(Unit
*_attacker
, Unit
*_target
, uint32 _SpellID
, uint32 _schoolMask
) :
657 attacker(_attacker
), target(_target
), SpellID(_SpellID
), damage(0), schoolMask(_schoolMask
),
658 absorb(0), resist(0), phusicalLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0) {}
674 uint32
createProcExtendMask(SpellNonMeleeDamage
*damageInfo
, SpellMissInfo missCondition
);
676 struct UnitActionBarEntry
678 UnitActionBarEntry() : Raw(0) {}
684 uint16 SpellOrAction
;
694 #define MAX_DECLINED_NAME_CASES 5
698 std::string name
[MAX_DECLINED_NAME_CASES
];
701 enum CurrentSpellTypes
703 CURRENT_MELEE_SPELL
= 0,
704 CURRENT_FIRST_NON_MELEE_SPELL
= 1, // just counter
705 CURRENT_GENERIC_SPELL
= 1,
706 CURRENT_AUTOREPEAT_SPELL
= 2,
707 CURRENT_CHANNELED_SPELL
= 3,
708 CURRENT_MAX_SPELL
= 4 // just counter
713 ACT_PASSIVE
= 0x0100, // 0x0100 - passive
714 ACT_DISABLED
= 0x8100, // 0x8000 - castable
715 ACT_ENABLED
= 0xC100, // 0x4000 | 0x8000 - auto cast + castable
716 ACT_COMMAND
= 0x0700, // 0x0100 | 0x0200 | 0x0400
717 ACT_REACTION
= 0x0600, // 0x0200 | 0x0400
718 ACT_DECIDE
= 0x0001 // what is it?
736 struct CharmSpellEntry
745 explicit CharmInfo(Unit
* unit
);
746 uint32
GetPetNumber() const { return m_petnumber
; }
747 void SetPetNumber(uint32 petnumber
, bool statwindow
);
749 void SetCommandState(CommandStates st
) { m_CommandState
= st
; }
750 CommandStates
GetCommandState() { return m_CommandState
; }
751 bool HasCommandState(CommandStates state
) { return (m_CommandState
== state
); }
752 void SetReactState(ReactStates st
) { m_reactState
= st
; }
753 ReactStates
GetReactState() { return m_reactState
; }
754 bool HasReactState(ReactStates state
) { return (m_reactState
== state
); }
756 void InitPossessCreateSpells();
757 void InitCharmCreateSpells();
758 void InitPetActionBar();
759 void InitEmptyActionBar();
760 //return true if successful
761 bool AddSpellToAB(uint32 oldid
, uint32 newid
, ActiveStates newstate
= ACT_DECIDE
);
762 void ToggleCreatureAutocast(uint32 spellid
, bool apply
);
764 UnitActionBarEntry
* GetActionBarEntry(uint8 index
) { return &(PetActionBar
[index
]); }
765 CharmSpellEntry
* GetCharmSpell(uint8 index
) { return &(m_charmspells
[index
]); }
768 UnitActionBarEntry PetActionBar
[10];
769 CharmSpellEntry m_charmspells
[4];
770 CommandStates m_CommandState
;
771 ReactStates m_reactState
;
775 // for clearing special attacks
776 #define REACTIVE_TIMER_START 4000
780 REACTIVE_DEFENSE
= 0,
781 REACTIVE_HUNTER_PARRY
= 1,
782 REACTIVE_OVERPOWER
= 2
785 #define MAX_REACTIVE 3
788 // delay time next attack to prevent client attack animation problems
789 #define ATTACK_DISPLAY_DELAY 200
791 struct SpellProcEventEntry
; // used only privately
793 class MANGOS_DLL_SPEC Unit
: public WorldObject
796 typedef std::set
<Unit
*> AttackerSet
;
797 typedef std::pair
<uint32
, uint8
> spellEffectPair
;
798 typedef std::multimap
< spellEffectPair
, Aura
*> AuraMap
;
799 typedef std::list
<Aura
*> AuraList
;
800 typedef std::list
<DiminishingReturn
> Diminishing
;
801 typedef std::set
<uint32
> ComboPointHolderSet
;
802 typedef std::map
<uint8
, uint32
> VisibleAuraMap
;
807 void RemoveFromWorld();
809 void CleanupsBeforeDelete(); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
811 DiminishingLevels
GetDiminishing(DiminishingGroup group
);
812 void IncrDiminishing(DiminishingGroup group
);
813 void ApplyDiminishingToDuration(DiminishingGroup group
, int32
&duration
,Unit
* caster
, DiminishingLevels Level
);
814 void ApplyDiminishingAura(DiminishingGroup group
, bool apply
);
815 void ClearDiminishings() { m_Diminishing
.clear(); }
817 virtual void Update( uint32 time
);
819 void setAttackTimer(WeaponAttackType type
, uint32 time
) { m_attackTimer
[type
] = time
; }
820 void resetAttackTimer(WeaponAttackType type
= BASE_ATTACK
);
821 uint32
getAttackTimer(WeaponAttackType type
) const { return m_attackTimer
[type
]; }
822 bool isAttackReady(WeaponAttackType type
= BASE_ATTACK
) const { return m_attackTimer
[type
] == 0; }
823 bool haveOffhandWeapon() const;
824 bool canReachWithAttack(Unit
*pVictim
) const;
825 uint32 m_extraAttacks
;
827 void _addAttacker(Unit
*pAttacker
) // must be called only from Unit::Attack(Unit*)
829 AttackerSet::iterator itr
= m_attackers
.find(pAttacker
);
830 if(itr
== m_attackers
.end())
831 m_attackers
.insert(pAttacker
);
833 void _removeAttacker(Unit
*pAttacker
) // must be called only from Unit::AttackStop()
835 m_attackers
.erase(pAttacker
);
837 Unit
* getAttackerForHelper() // If someone wants to help, who to give them
839 if (getVictim() != NULL
)
842 if (!m_attackers
.empty())
843 return *(m_attackers
.begin());
847 bool Attack(Unit
*victim
, bool meleeAttack
);
848 void CastStop(uint32 except_spellid
= 0);
850 void RemoveAllAttackers();
851 AttackerSet
const& getAttackers() const { return m_attackers
; }
852 bool isAttackingPlayer() const;
853 Unit
* getVictim() const { return m_attacking
; }
854 void CombatStop(bool cast
= false);
855 void CombatStopWithPets(bool cast
= false);
856 Unit
* SelectNearbyTarget() const;
857 bool hasNegativeAuraWithInterruptFlag(uint32 flag
);
859 void addUnitState(uint32 f
) { m_state
|= f
; }
860 bool hasUnitState(const uint32 f
) const { return (m_state
& f
); }
861 void clearUnitState(uint32 f
) { m_state
&= ~f
; }
862 bool CanFreeMove() const
864 return !hasUnitState(UNIT_STAT_CONFUSED
| UNIT_STAT_FLEEING
| UNIT_STAT_IN_FLIGHT
|
865 UNIT_STAT_ROOT
| UNIT_STAT_STUNNED
| UNIT_STAT_DISTRACTED
) && GetOwnerGUID()==0;
868 uint32
getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL
); }
869 virtual uint32
getLevelForTarget(Unit
const* /*target*/) const { return getLevel(); }
870 void SetLevel(uint32 lvl
);
871 uint8
getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0
, 0); }
872 uint32
getRaceMask() const { return 1 << (getRace()-1); }
873 uint8
getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0
, 1); }
874 uint32
getClassMask() const { return 1 << (getClass()-1); }
875 uint8
getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0
, 2); }
877 float GetStat(Stats stat
) const { return float(GetUInt32Value(UNIT_FIELD_STAT0
+stat
)); }
878 void SetStat(Stats stat
, int32 val
) { SetStatInt32Value(UNIT_FIELD_STAT0
+stat
, val
); }
879 uint32
GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL
) ; }
880 void SetArmor(int32 val
) { SetResistance(SPELL_SCHOOL_NORMAL
, val
); }
882 uint32
GetResistance(SpellSchools school
) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES
+school
); }
883 void SetResistance(SpellSchools school
, int32 val
) { SetStatInt32Value(UNIT_FIELD_RESISTANCES
+school
,val
); }
885 uint32
GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH
); }
886 uint32
GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH
); }
887 void SetHealth( uint32 val
);
888 void SetMaxHealth(uint32 val
);
889 int32
ModifyHealth(int32 val
);
891 Powers
getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0
, 3)); }
892 void setPowerType(Powers power
);
893 uint32
GetPower( Powers power
) const { return GetUInt32Value(UNIT_FIELD_POWER1
+power
); }
894 uint32
GetMaxPower(Powers power
) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1
+power
); }
895 void SetPower( Powers power
, uint32 val
);
896 void SetMaxPower(Powers power
, uint32 val
);
897 int32
ModifyPower(Powers power
, int32 val
);
898 void ApplyPowerMod(Powers power
, uint32 val
, bool apply
);
899 void ApplyMaxPowerMod(Powers power
, uint32 val
, bool apply
);
901 uint32
GetAttackTime(WeaponAttackType att
) const { return (uint32
)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME
+att
)/m_modAttackSpeedPct
[att
]); }
902 void SetAttackTime(WeaponAttackType att
, uint32 val
) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME
+att
,val
*m_modAttackSpeedPct
[att
]); }
903 void ApplyAttackTimePercentMod(WeaponAttackType att
,float val
, bool apply
);
904 void ApplyCastTimePercentMod(float val
, bool apply
);
906 // faction template id
907 uint32
getFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
); }
908 void setFaction(uint32 faction
) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
, faction
); }
909 FactionTemplateEntry
const* getFactionTemplateEntry() const;
910 bool IsHostileTo(Unit
const* unit
) const;
911 bool IsHostileToPlayers() const;
912 bool IsFriendlyTo(Unit
const* unit
) const;
913 bool IsNeutralToAll() const;
914 bool IsContestedGuard() const
916 if(FactionTemplateEntry
const* entry
= getFactionTemplateEntry())
917 return entry
->IsContestedGuardFaction();
921 bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_PVP
); }
922 void SetPvP(bool state
)
925 SetByteFlag(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_PVP
);
927 RemoveByteFlag(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_PVP
);
929 uint32
GetCreatureType() const;
930 uint32
GetCreatureTypeMask() const
932 uint32 creatureType
= GetCreatureType();
933 return (creatureType
>= 1) ? (1 << (creatureType
- 1)) : 0;
936 uint8
getStandState() const { return GetByteValue(UNIT_FIELD_BYTES_1
, 0); }
937 bool IsSitState() const;
938 bool IsStandState() const;
939 void SetStandState(uint8 state
);
941 void SetStandFlags(uint8 flags
) { SetByteFlag(UNIT_FIELD_BYTES_1
, 2,flags
); }
942 void RemoveStandFlags(uint8 flags
) { RemoveByteFlag(UNIT_FIELD_BYTES_1
, 2,flags
); }
944 bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_MOUNT
); }
945 uint32
GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
); }
946 void Mount(uint32 mount
);
949 uint16
GetMaxSkillValueForLevel(Unit
const* target
= NULL
) const { return (target
? getLevelForTarget(target
) : getLevel()) * 5; }
950 uint32
DealDamage(Unit
*pVictim
, uint32 damage
, CleanDamage
const* cleanDamage
, DamageEffectType damagetype
, SpellSchoolMask damageSchoolMask
, SpellEntry
const *spellProto
, bool durabilityLoss
);
952 void ProcDamageAndSpell(Unit
*pVictim
, uint32 procAttacker
, uint32 procVictim
, uint32 procEx
, uint32 amount
, WeaponAttackType attType
= BASE_ATTACK
, SpellEntry
const *procSpell
= NULL
);
953 void ProcDamageAndSpellFor( bool isVictim
, Unit
* pTarget
, uint32 procFlag
, uint32 procExtra
, WeaponAttackType attType
, SpellEntry
const * procSpell
, uint32 damage
);
955 void HandleEmoteCommand(uint32 anim_id
);
956 void AttackerStateUpdate (Unit
*pVictim
, WeaponAttackType attType
= BASE_ATTACK
, bool extra
= false );
958 float MeleeMissChanceCalc(const Unit
*pVictim
, WeaponAttackType attType
) const;
960 void CalculateMeleeDamage(Unit
*pVictim
, uint32 damage
, CalcDamageInfo
*damageInfo
, WeaponAttackType attackType
= BASE_ATTACK
);
961 void DealMeleeDamage(CalcDamageInfo
*damageInfo
, bool durabilityLoss
);
963 void CalculateSpellDamage(SpellNonMeleeDamage
*damageInfo
, int32 damage
, SpellEntry
const *spellInfo
, WeaponAttackType attackType
= BASE_ATTACK
);
964 void DealSpellDamage(SpellNonMeleeDamage
*damageInfo
, bool durabilityLoss
);
966 float MeleeSpellMissChance(Unit
*pVictim
, WeaponAttackType attType
, int32 skillDiff
, SpellEntry
const *spell
);
967 SpellMissInfo
MeleeSpellHitResult(Unit
*pVictim
, SpellEntry
const *spell
);
968 SpellMissInfo
MagicSpellHitResult(Unit
*pVictim
, SpellEntry
const *spell
);
969 SpellMissInfo
SpellHitResult(Unit
*pVictim
, SpellEntry
const *spell
, bool canReflect
= false);
971 float GetUnitDodgeChance() const;
972 float GetUnitParryChance() const;
973 float GetUnitBlockChance() const;
974 float GetUnitCriticalChance(WeaponAttackType attackType
, const Unit
*pVictim
) const;
976 virtual uint32
GetShieldBlockValue() const =0;
977 uint32
GetUnitMeleeSkill(Unit
const* target
= NULL
) const { return (target
? getLevelForTarget(target
) : getLevel()) * 5; }
978 uint32
GetDefenseSkillValue(Unit
const* target
= NULL
) const;
979 uint32
GetWeaponSkillValue(WeaponAttackType attType
, Unit
const* target
= NULL
) const;
980 float GetWeaponProcChance() const;
981 float GetPPMProcChance(uint32 WeaponSpeed
, float PPM
) const;
983 MeleeHitOutcome
RollMeleeOutcomeAgainst (const Unit
*pVictim
, WeaponAttackType attType
) const;
984 MeleeHitOutcome
RollMeleeOutcomeAgainst (const Unit
*pVictim
, WeaponAttackType attType
, int32 crit_chance
, int32 miss_chance
, int32 dodge_chance
, int32 parry_chance
, int32 block_chance
) const;
986 bool isVendor() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_VENDOR
); }
987 bool isTrainer() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_TRAINER
); }
988 bool isQuestGiver() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_QUESTGIVER
); }
989 bool isGossip() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_GOSSIP
); }
990 bool isTaxi() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_FLIGHTMASTER
); }
991 bool isGuildMaster() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_PETITIONER
); }
992 bool isBattleMaster() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_BATTLEMASTER
); }
993 bool isBanker() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_BANKER
); }
994 bool isInnkeeper() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_INNKEEPER
); }
995 bool isSpiritHealer() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_SPIRITHEALER
); }
996 bool isSpiritGuide() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_SPIRITGUIDE
); }
997 bool isTabardDesigner()const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_TABARDDESIGNER
); }
998 bool isAuctioner() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_AUCTIONEER
); }
999 bool isArmorer() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_REPAIR
); }
1000 bool isServiceProvider() const
1002 return HasFlag( UNIT_NPC_FLAGS
,
1003 UNIT_NPC_FLAG_VENDOR
| UNIT_NPC_FLAG_TRAINER
| UNIT_NPC_FLAG_FLIGHTMASTER
|
1004 UNIT_NPC_FLAG_PETITIONER
| UNIT_NPC_FLAG_BATTLEMASTER
| UNIT_NPC_FLAG_BANKER
|
1005 UNIT_NPC_FLAG_INNKEEPER
| UNIT_NPC_FLAG_GUARD
| UNIT_NPC_FLAG_SPIRITHEALER
|
1006 UNIT_NPC_FLAG_SPIRITGUIDE
| UNIT_NPC_FLAG_TABARDDESIGNER
| UNIT_NPC_FLAG_AUCTIONEER
);
1008 bool isSpiritService() const { return HasFlag( UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_SPIRITHEALER
| UNIT_NPC_FLAG_SPIRITGUIDE
); }
1010 //Need fix or use this
1011 bool isGuard() const { return HasFlag(UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_GUARD
); }
1013 bool isInFlight() const { return hasUnitState(UNIT_STAT_IN_FLIGHT
); }
1015 bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_IN_COMBAT
); }
1016 void SetInCombatState(bool PvP
);
1017 void SetInCombatWith(Unit
* enemy
);
1018 void ClearInCombat();
1019 uint32
GetCombatTimer() const { return m_CombatTimer
; }
1021 bool HasAuraType(AuraType auraType
) const;
1022 bool HasAura(uint32 spellId
, uint32 effIndex
) const
1024 return m_Auras
.find(spellEffectPair(spellId
, effIndex
)) != m_Auras
.end();
1026 bool HasAura(uint32 spellId
) const;
1028 bool virtual HasSpell(uint32
/*spellID*/) const { return false; }
1030 bool HasStealthAura() const { return HasAuraType(SPELL_AURA_MOD_STEALTH
); }
1031 bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY
); }
1032 bool isFeared() const { return HasAuraType(SPELL_AURA_MOD_FEAR
); }
1033 bool isInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT
); }
1034 bool IsPolymorphed() const;
1036 bool isFrozen() const;
1038 void RemoveSpellbyDamageTaken(AuraType auraType
, uint32 damage
);
1040 bool isTargetableForAttack() const;
1041 virtual bool IsInWater() const;
1042 virtual bool IsUnderWater() const;
1043 bool isInAccessablePlaceFor(Creature
const* c
) const;
1045 void SendHealSpellLog(Unit
*pVictim
, uint32 SpellID
, uint32 Damage
, bool critical
= false);
1046 void SendEnergizeSpellLog(Unit
*pVictim
, uint32 SpellID
, uint32 Damage
,Powers powertype
);
1047 uint32
SpellNonMeleeDamageLog(Unit
*pVictim
, uint32 spellID
, uint32 damage
, bool isTriggeredSpell
= false, bool useSpellDamage
= true);
1048 void CastSpell(Unit
* Victim
, uint32 spellId
, bool triggered
, Item
*castItem
= NULL
, Aura
* triggeredByAura
= NULL
, uint64 originalCaster
= 0);
1049 void CastSpell(Unit
* Victim
,SpellEntry
const *spellInfo
, bool triggered
, Item
*castItem
= NULL
, Aura
* triggeredByAura
= NULL
, uint64 originalCaster
= 0);
1050 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);
1051 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);
1052 void CastSpell(float x
, float y
, float z
, uint32 spellId
, bool triggered
, Item
*castItem
= NULL
, Aura
* triggeredByAura
= NULL
, uint64 originalCaster
= 0);
1053 void CastSpell(float x
, float y
, float z
, SpellEntry
const *spellInfo
, bool triggered
, Item
*castItem
= NULL
, Aura
* triggeredByAura
= NULL
, uint64 originalCaster
= 0);
1055 bool IsDamageToThreatSpell(SpellEntry
const * spellInfo
) const;
1059 void SendAttackStateUpdate(CalcDamageInfo
*damageInfo
);
1060 void SendAttackStateUpdate(uint32 HitInfo
, Unit
*target
, uint8 SwingType
, SpellSchoolMask damageSchoolMask
, uint32 Damage
, uint32 AbsorbDamage
, uint32 Resist
, VictimState TargetState
, uint32 BlockedAmount
);
1061 void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage
*log
);
1062 void SendSpellNonMeleeDamageLog(Unit
*target
,uint32 SpellID
,uint32 Damage
, SpellSchoolMask damageSchoolMask
,uint32 AbsorbedDamage
, uint32 Resist
,bool PhysicalDamage
, uint32 Blocked
, bool CriticalHit
= false);
1063 void SendSpellMiss(Unit
*target
, uint32 spellID
, SpellMissInfo missInfo
);
1065 void SendMonsterMove(float NewPosX
, float NewPosY
, float NewPosZ
, uint8 type
, uint32 MovementFlags
, uint32 Time
, Player
* player
= NULL
);
1066 void SendMonsterMoveByPath(Path
const& path
, uint32 start
, uint32 end
, uint32 MovementFlags
);
1067 void SendMonsterMoveWithSpeed(float x
, float y
, float z
, uint32 MovementFlags
, uint32 transitTime
= 0, Player
* player
= NULL
);
1068 void SendMonsterMoveWithSpeedToCurrentDestination(Player
* player
= NULL
);
1070 virtual void MoveOutOfRange(Player
&) { };
1072 bool isAlive() const { return (m_deathState
== ALIVE
); };
1073 bool isDead() const { return ( m_deathState
== DEAD
|| m_deathState
== CORPSE
); };
1074 DeathState
getDeathState() { return m_deathState
; };
1075 virtual void setDeathState(DeathState s
); // overwrited in Creature/Player/Pet
1077 uint64
GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY
); }
1078 void SetOwnerGUID(uint64 owner
) { SetUInt64Value(UNIT_FIELD_SUMMONEDBY
, owner
); }
1079 uint64
GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY
); }
1080 void SetCreatorGUID(uint64 creator
) { SetUInt64Value(UNIT_FIELD_CREATEDBY
, creator
); }
1081 uint64
GetPetGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON
); }
1082 uint64
GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY
); }
1083 void SetCharmerGUID(uint64 owner
) { SetUInt64Value(UNIT_FIELD_CHARMEDBY
, owner
); }
1084 uint64
GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM
); }
1086 uint64
GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
1087 uint64
GetCharmerOrOwnerOrOwnGUID() const
1089 if(uint64 guid
= GetCharmerOrOwnerGUID())
1093 bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); }
1095 Player
* GetSpellModOwner();
1097 Unit
* GetOwner() const;
1098 Pet
* GetPet() const;
1099 Unit
* GetCharmer() const;
1100 Unit
* GetCharm() const;
1101 Unit
* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); }
1102 Unit
* GetCharmerOrOwnerOrSelf()
1104 if(Unit
* u
= GetCharmerOrOwner())
1109 Player
* GetCharmerOrOwnerPlayerOrPlayerItself();
1111 void SetPet(Pet
* pet
);
1112 void SetCharm(Unit
* pet
);
1114 bool isCharmed() const { return GetCharmerGUID() != 0; }
1116 CharmInfo
* GetCharmInfo() { return m_charmInfo
; }
1117 CharmInfo
* InitCharmInfo(Unit
* charm
);
1119 Pet
* CreateTamedPetFrom(Creature
* creatureTarget
,uint32 spell_id
= 0);
1121 bool AddAura(Aura
*aur
);
1123 void RemoveAura(AuraMap::iterator
&i
, AuraRemoveMode mode
= AURA_REMOVE_BY_DEFAULT
);
1124 void RemoveAura(uint32 spellId
, uint32 effindex
, Aura
* except
= NULL
);
1125 void RemoveSingleSpellAurasFromStack(uint32 spellId
);
1126 void RemoveSingleAuraFromStack(uint32 spellId
, uint32 effindex
);
1127 void RemoveAurasDueToSpell(uint32 spellId
, Aura
* except
= NULL
);
1128 void RemoveAurasDueToItemSpell(Item
* castItem
,uint32 spellId
);
1129 void RemoveAurasDueToSpellByDispel(uint32 spellId
, uint64 casterGUID
, Unit
*dispeler
);
1130 void RemoveAurasDueToSpellBySteal(uint32 spellId
, uint64 casterGUID
, Unit
*stealer
);
1131 void RemoveAurasDueToSpellByCancel(uint32 spellId
);
1132 void RemoveAurasAtChanneledTarget(SpellEntry
const* spellInfo
);
1133 void RemoveNotOwnSingleTargetAuras();
1135 void RemoveSpellsCausingAura(AuraType auraType
);
1136 void RemoveRankAurasDueToSpell(uint32 spellId
);
1137 bool RemoveNoStackAurasDueToAura(Aura
*Aur
);
1138 void RemoveAurasWithInterruptFlags(uint32 flags
);
1139 void RemoveAurasWithDispelType( DispelType type
);
1141 void RemoveAllAuras();
1142 void RemoveArenaAuras(bool onleave
= false);
1143 void RemoveAllAurasOnDeath();
1144 void DelayAura(uint32 spellId
, uint32 effindex
, int32 delaytime
);
1146 float GetResistanceBuffMods(SpellSchools school
, bool positive
) const { return GetFloatValue(positive
? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE
+school
: UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE
+school
); }
1147 void SetResistanceBuffMods(SpellSchools school
, bool positive
, float val
) { SetFloatValue(positive
? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE
+school
: UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE
+school
,val
); }
1148 void ApplyResistanceBuffModsMod(SpellSchools school
, bool positive
, float val
, bool apply
) { ApplyModSignedFloatValue(positive
? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE
+school
: UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE
+school
, val
, apply
); }
1149 void ApplyResistanceBuffModsPercentMod(SpellSchools school
, bool positive
, float val
, bool apply
) { ApplyPercentModFloatValue(positive
? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE
+school
: UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE
+school
, val
, apply
); }
1150 void InitStatBuffMods()
1152 for(int i
= STAT_STRENGTH
; i
< MAX_STATS
; ++i
) SetFloatValue(UNIT_FIELD_POSSTAT0
+i
, 0);
1153 for(int i
= STAT_STRENGTH
; i
< MAX_STATS
; ++i
) SetFloatValue(UNIT_FIELD_NEGSTAT0
+i
, 0);
1155 void ApplyStatBuffMod(Stats stat
, float val
, bool apply
) { ApplyModSignedFloatValue((val
> 0 ? UNIT_FIELD_POSSTAT0
+stat
: UNIT_FIELD_NEGSTAT0
+stat
), val
, apply
); }
1156 void ApplyStatPercentBuffMod(Stats stat
, float val
, bool apply
)
1158 ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0
+stat
, val
, apply
);
1159 ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0
+stat
, val
, apply
);
1161 void SetCreateStat(Stats stat
, float val
) { m_createStats
[stat
] = val
; }
1162 void SetCreateHealth(uint32 val
) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH
, val
); }
1163 uint32
GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH
); }
1164 void SetCreateMana(uint32 val
) { SetUInt32Value(UNIT_FIELD_BASE_MANA
, val
); }
1165 uint32
GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA
); }
1166 uint32
GetCreatePowers(Powers power
) const;
1167 float GetPosStat(Stats stat
) const { return GetFloatValue(UNIT_FIELD_POSSTAT0
+stat
); }
1168 float GetNegStat(Stats stat
) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0
+stat
); }
1169 float GetCreateStat(Stats stat
) const { return m_createStats
[stat
]; }
1171 void SetCurrentCastedSpell(Spell
* pSpell
);
1172 virtual void ProhibitSpellScholl(SpellSchoolMask
/*idSchoolMask*/, uint32
/*unTimeMs*/ ) { }
1173 void InterruptSpell(uint32 spellType
, bool withDelayed
= true);
1175 // set withDelayed to true to account delayed spells as casted
1176 // delayed+channeled spells are always accounted as casted
1177 // we can skip channeled or delayed checks using flags
1178 bool IsNonMeleeSpellCasted(bool withDelayed
, bool skipChanneled
= false, bool skipAutorepeat
= false) const;
1180 // set withDelayed to true to interrupt delayed spells too
1181 // delayed+channeled spells are always interrupted
1182 void InterruptNonMeleeSpells(bool withDelayed
, uint32 spellid
= 0);
1184 Spell
* FindCurrentSpellBySpellId(uint32 spell_id
) const;
1186 Spell
* m_currentSpells
[CURRENT_MAX_SPELL
];
1188 uint32 m_addDmgOnce
;
1189 uint64 m_TotemSlot
[MAX_TOTEM
];
1190 uint64 m_ObjectSlot
[4];
1191 uint32 m_detectInvisibilityMask
;
1192 uint32 m_invisibilityMask
;
1193 uint32 m_ShapeShiftFormSpellId
;
1194 ShapeshiftForm m_form
;
1195 float m_modMeleeHitChance
;
1196 float m_modRangedHitChance
;
1197 float m_modSpellHitChance
;
1198 int32 m_baseSpellCritChance
;
1200 float m_threatModifier
[MAX_SPELL_SCHOOL
];
1201 float m_modAttackSpeedPct
[3];
1204 EventProcessor m_Events
;
1207 bool HandleStatModifier(UnitMods unitMod
, UnitModifierType modifierType
, float amount
, bool apply
);
1208 void SetModifierValue(UnitMods unitMod
, UnitModifierType modifierType
, float value
) { m_auraModifiersGroup
[unitMod
][modifierType
] = value
; }
1209 float GetModifierValue(UnitMods unitMod
, UnitModifierType modifierType
) const;
1210 float GetTotalStatValue(Stats stat
) const;
1211 float GetTotalAuraModValue(UnitMods unitMod
) const;
1212 SpellSchools
GetSpellSchoolByAuraGroup(UnitMods unitMod
) const;
1213 Stats
GetStatByAuraGroup(UnitMods unitMod
) const;
1214 Powers
GetPowerTypeByAuraGroup(UnitMods unitMod
) const;
1215 bool CanModifyStats() const { return m_canModifyStats
; }
1216 void SetCanModifyStats(bool modifyStats
) { m_canModifyStats
= modifyStats
; }
1217 virtual bool UpdateStats(Stats stat
) = 0;
1218 virtual bool UpdateAllStats() = 0;
1219 virtual void UpdateResistances(uint32 school
) = 0;
1220 virtual void UpdateArmor() = 0;
1221 virtual void UpdateMaxHealth() = 0;
1222 virtual void UpdateMaxPower(Powers power
) = 0;
1223 virtual void UpdateAttackPowerAndDamage(bool ranged
= false) = 0;
1224 virtual void UpdateDamagePhysical(WeaponAttackType attType
) = 0;
1225 float GetTotalAttackPowerValue(WeaponAttackType attType
) const;
1226 float GetWeaponDamageRange(WeaponAttackType attType
,WeaponDamageRange type
) const;
1227 void SetBaseWeaponDamage(WeaponAttackType attType
,WeaponDamageRange damageRange
, float value
) { m_weaponDamage
[attType
][damageRange
] = value
; }
1229 bool isInFront(Unit
const* target
,float distance
, float arc
= M_PI
) const;
1230 void SetInFront(Unit
const* target
);
1231 bool isInBack(Unit
const* target
, float distance
, float arc
= M_PI
) const;
1233 // Visibility system
1234 UnitVisibility
GetVisibility() const { return m_Visibility
; }
1235 void SetVisibility(UnitVisibility x
);
1237 // common function for visibility checks for player/creatures with detection code
1238 bool isVisibleForOrDetect(Unit
const* u
, bool detect
, bool inVisibleList
= false, bool is3dDistance
= true) const;
1239 bool canDetectInvisibilityOf(Unit
const* u
) const;
1240 void SetPhaseMask(uint32 newPhaseMask
, bool update
);// overwrite WorldObject::SetPhaseMask
1242 // virtual functions for all world objects types
1243 bool isVisibleForInState(Player
const* u
, bool inVisibleList
) const;
1244 // function for low level grid visibility checks in player/creature cases
1245 virtual bool IsVisibleInGridForPlayer(Player
* pl
) const = 0;
1247 AuraList
& GetSingleCastAuras() { return m_scAuras
; }
1248 AuraList
const& GetSingleCastAuras() const { return m_scAuras
; }
1249 SpellImmuneList m_spellImmune
[MAX_SPELL_IMMUNITY
];
1251 // Threat related methods
1252 bool CanHaveThreatList() const;
1253 void AddThreat(Unit
* pVictim
, float threat
, SpellSchoolMask schoolMask
= SPELL_SCHOOL_MASK_NORMAL
, SpellEntry
const *threatSpell
= NULL
);
1254 float ApplyTotalThreatModifier(float threat
, SpellSchoolMask schoolMask
= SPELL_SCHOOL_MASK_NORMAL
);
1255 void DeleteThreatList();
1256 bool SelectHostilTarget();
1257 void TauntApply(Unit
* pVictim
);
1258 void TauntFadeOut(Unit
*taunter
);
1259 ThreatManager
& getThreatManager() { return m_ThreatManager
; }
1260 void addHatedBy(HostilReference
* pHostilReference
) { m_HostilRefManager
.insertFirst(pHostilReference
); };
1261 void removeHatedBy(HostilReference
* /*pHostilReference*/ ) { /* nothing to do yet */ }
1262 HostilRefManager
& getHostilRefManager() { return m_HostilRefManager
; }
1264 uint32
GetVisibleAura(uint8 slot
)
1266 VisibleAuraMap::iterator itr
= m_visibleAuras
.find(slot
);
1267 if(itr
!= m_visibleAuras
.end())
1271 void SetVisibleAura(uint8 slot
, uint32 spellid
)
1274 m_visibleAuras
.erase(slot
);
1276 m_visibleAuras
[slot
] = spellid
;
1278 VisibleAuraMap
const *GetVisibleAuras() { return &m_visibleAuras
; }
1279 uint8
GetVisibleAurasCount() { return m_visibleAuras
.size(); }
1281 Aura
* GetAura(uint32 spellId
, uint32 effindex
);
1282 AuraMap
& GetAuras() { return m_Auras
; }
1283 AuraMap
const& GetAuras() const { return m_Auras
; }
1284 AuraList
const& GetAurasByType(AuraType type
) const { return m_modAuras
[type
]; }
1285 void ApplyAuraProcTriggerDamage(Aura
* aura
, bool apply
);
1287 int32
GetTotalAuraModifier(AuraType auratype
) const;
1288 float GetTotalAuraMultiplier(AuraType auratype
) const;
1289 int32
GetMaxPositiveAuraModifier(AuraType auratype
) const;
1290 int32
GetMaxNegativeAuraModifier(AuraType auratype
) const;
1292 int32
GetTotalAuraModifierByMiscMask(AuraType auratype
, uint32 misc_mask
) const;
1293 float GetTotalAuraMultiplierByMiscMask(AuraType auratype
, uint32 misc_mask
) const;
1294 int32
GetMaxPositiveAuraModifierByMiscMask(AuraType auratype
, uint32 misc_mask
) const;
1295 int32
GetMaxNegativeAuraModifierByMiscMask(AuraType auratype
, uint32 misc_mask
) const;
1297 int32
GetTotalAuraModifierByMiscValue(AuraType auratype
, int32 misc_value
) const;
1298 float GetTotalAuraMultiplierByMiscValue(AuraType auratype
, int32 misc_value
) const;
1299 int32
GetMaxPositiveAuraModifierByMiscValue(AuraType auratype
, int32 misc_value
) const;
1300 int32
GetMaxNegativeAuraModifierByMiscValue(AuraType auratype
, int32 misc_value
) const;
1302 Aura
* GetDummyAura(uint32 spell_id
) const;
1304 uint32
GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID
); }
1305 void SetDisplayId(uint32 modelId
);
1306 uint32
GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID
); }
1307 void SetNativeDisplayId(uint32 modelId
) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID
, modelId
); }
1308 void setTransForm(uint32 spellid
) { m_transform
= spellid
;}
1309 uint32
getTransForm() const { return m_transform
;}
1310 void AddDynObject(DynamicObject
* dynObj
);
1311 void RemoveDynObject(uint32 spellid
);
1312 void RemoveDynObjectWithGUID(uint64 guid
) { m_dynObjGUIDs
.remove(guid
); }
1313 void RemoveAllDynObjects();
1314 void AddGameObject(GameObject
* gameObj
);
1315 void RemoveGameObject(GameObject
* gameObj
, bool del
);
1316 void RemoveGameObject(uint32 spellid
, bool del
);
1317 void RemoveAllGameObjects();
1318 DynamicObject
*GetDynObject(uint32 spellId
, uint32 effIndex
);
1319 DynamicObject
*GetDynObject(uint32 spellId
);
1320 uint32
CalculateDamage(WeaponAttackType attType
, bool normalized
);
1321 float GetAPMultiplier(WeaponAttackType attType
, bool normalized
);
1322 void ModifyAuraState(AuraState flag
, bool apply
);
1323 bool HasAuraState(AuraState flag
) const { return HasFlag(UNIT_FIELD_AURASTATE
, 1<<(flag
-1)); }
1324 void UnsummonAllTotems();
1325 int32
SpellBaseDamageBonus(SpellSchoolMask schoolMask
);
1326 int32
SpellBaseHealingBonus(SpellSchoolMask schoolMask
);
1327 int32
SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask
, Unit
*pVictim
);
1328 int32
SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask
, Unit
*pVictim
);
1329 uint32
SpellDamageBonus(Unit
*pVictim
, SpellEntry
const *spellProto
, uint32 damage
, DamageEffectType damagetype
, uint32 stack
= 1);
1330 uint32
SpellHealingBonus(Unit
*pVictim
, SpellEntry
const *spellProto
, uint32 healamount
, DamageEffectType damagetype
, uint32 stack
= 1);
1331 bool isSpellBlocked(Unit
*pVictim
, SpellEntry
const *spellProto
, WeaponAttackType attackType
= BASE_ATTACK
);
1332 bool isSpellCrit(Unit
*pVictim
, SpellEntry
const *spellProto
, SpellSchoolMask schoolMask
, WeaponAttackType attackType
= BASE_ATTACK
);
1333 uint32
SpellCriticalDamageBonus(SpellEntry
const *spellProto
, uint32 damage
, Unit
*pVictim
);
1334 uint32
SpellCriticalHealingBonus(SpellEntry
const *spellProto
, uint32 damage
, Unit
*pVictim
);
1336 void SetLastManaUse(uint32 spellCastTime
) { m_lastManaUse
= spellCastTime
; }
1337 bool IsUnderLastManaUseEffect() const;
1339 void SetContestedPvP(Player
*attackedPlayer
= NULL
);
1341 void MeleeDamageBonus(Unit
*pVictim
, uint32
*damage
, WeaponAttackType attType
, SpellEntry
const *spellProto
= NULL
);
1342 uint32
GetCastingTimeForBonus( SpellEntry
const *spellProto
, DamageEffectType damagetype
, uint32 CastingTime
);
1344 void ApplySpellImmune(uint32 spellId
, uint32 op
, uint32 type
, bool apply
);
1345 void ApplySpellDispelImmunity(const SpellEntry
* spellProto
, DispelType type
, bool apply
);
1346 virtual bool IsImmunedToSpell(SpellEntry
const* spellInfo
);
1347 // redefined in Creature
1348 bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask
);
1349 virtual bool IsImmunedToSpellEffect(SpellEntry
const* spellInfo
, uint32 index
) const;
1350 // redefined in Creature
1352 uint32
CalcArmorReducedDamage(Unit
* pVictim
, const uint32 damage
);
1353 void CalcAbsorbResist(Unit
*pVictim
, SpellSchoolMask schoolMask
, DamageEffectType damagetype
, const uint32 damage
, uint32
*absorb
, uint32
*resist
);
1355 void UpdateSpeed(UnitMoveType mtype
, bool forced
);
1356 float GetSpeed( UnitMoveType mtype
) const;
1357 float GetSpeedRate( UnitMoveType mtype
) const { return m_speed_rate
[mtype
]; }
1358 void SetSpeed(UnitMoveType mtype
, float rate
, bool forced
= false);
1360 void SetHover(bool on
);
1361 bool isHover() const { return HasAuraType(SPELL_AURA_HOVER
); }
1363 void _RemoveAllAuraMods();
1364 void _ApplyAllAuraMods();
1366 int32
CalculateSpellDamage(SpellEntry
const* spellProto
, uint8 effect_index
, int32 basePoints
, Unit
const* target
);
1367 int32
CalculateSpellDuration(SpellEntry
const* spellProto
, uint8 effect_index
, Unit
const* target
);
1368 float CalculateLevelPenalty(SpellEntry
const* spellProto
) const;
1370 void addFollower(FollowerReference
* pRef
) { m_FollowingRefManager
.insertFirst(pRef
); }
1371 void removeFollower(FollowerReference
* /*pRef*/ ) { /* nothing to do yet */ }
1372 static Unit
* GetUnit(WorldObject
& object
, uint64 guid
);
1374 MotionMaster
* GetMotionMaster() { return &i_motionMaster
; }
1376 bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING
)); }
1379 void AddUnitMovementFlag(uint32 f
) { m_unit_movement_flags
|= f
; }
1380 void RemoveUnitMovementFlag(uint32 f
)
1382 uint32 oldval
= m_unit_movement_flags
;
1383 m_unit_movement_flags
= oldval
& ~f
;
1385 uint32
HasUnitMovementFlag(uint32 f
) const { return m_unit_movement_flags
& f
; }
1386 uint32
GetUnitMovementFlags() const { return m_unit_movement_flags
; }
1387 void SetUnitMovementFlags(uint32 f
) { m_unit_movement_flags
= f
; }
1389 void SetFeared(bool apply
, uint64 casterGUID
= 0, uint32 spellID
= 0);
1390 void SetConfused(bool apply
, uint64 casterGUID
= 0, uint32 spellID
= 0);
1392 void AddComboPointHolder(uint32 lowguid
) { m_ComboPointHolders
.insert(lowguid
); }
1393 void RemoveComboPointHolder(uint32 lowguid
) { m_ComboPointHolders
.erase(lowguid
); }
1394 void ClearComboPointHolders();
1396 ///----------Pet responses methods-----------------
1397 void SendPetCastFail(uint32 spellid
, uint8 msg
);
1398 void SendPetActionFeedback (uint8 msg
);
1399 void SendPetTalk (uint32 pettalk
);
1400 void SendPetSpellCooldown (uint32 spellid
, time_t cooltime
);
1401 void SendPetClearCooldown (uint32 spellid
);
1402 void SendPetAIReaction(uint64 guid
);
1403 ///----------End of Pet responses methods----------
1405 void propagateSpeedChange() { GetMotionMaster()->propagateSpeedChange(); }
1408 void ClearAllReactives();
1409 void StartReactiveTimer( ReactiveType reactive
) { m_reactiveTimer
[reactive
] = REACTIVE_TIMER_START
;}
1410 void UpdateReactives(uint32 p_time
);
1413 void UpdateAuraForGroup(uint8 slot
);
1416 typedef std::set
<PetAura
const*> PetAuraSet
;
1417 PetAuraSet m_petAuras
;
1418 void AddPetAura(PetAura
const* petSpell
);
1419 void RemovePetAura(PetAura
const* petSpell
);
1424 void _UpdateSpells(uint32 time
);
1426 void _UpdateAutoRepeatSpell();
1427 bool m_AutoRepeatFirstCast
;
1429 uint32 m_attackTimer
[MAX_ATTACK
];
1431 float m_createStats
[MAX_STATS
];
1433 AttackerSet m_attackers
;
1436 DeathState m_deathState
;
1440 std::list
<Aura
*> m_scAuras
; // casted singlecast auras
1442 typedef std::list
<uint64
> DynObjectGUIDs
;
1443 DynObjectGUIDs m_dynObjGUIDs
;
1445 std::list
<GameObject
*> m_gameObj
;
1448 uint32 m_removedAuras
;
1450 AuraList m_modAuras
[TOTAL_AURAS
];
1451 float m_auraModifiersGroup
[UNIT_MOD_END
][MODIFIER_TYPE_END
];
1452 float m_weaponDamage
[MAX_ATTACK
][2];
1453 bool m_canModifyStats
;
1454 //std::list< spellEffectPair > AuraSpells[TOTAL_AURAS]; // TODO: use this if ok for mem
1455 VisibleAuraMap m_visibleAuras
;
1457 float m_speed_rate
[MAX_MOVE_TYPE
];
1459 CharmInfo
*m_charmInfo
;
1461 virtual SpellSchoolMask
GetMeleeDamageSchoolMask() const;
1463 MotionMaster i_motionMaster
;
1464 uint32 m_unit_movement_flags
;
1466 uint32 m_reactiveTimer
[MAX_REACTIVE
];
1467 uint32 m_regenTimer
;
1470 void SendAttackStop(Unit
* victim
); // only from AttackStop(Unit*)
1471 void SendAttackStart(Unit
* pVictim
); // only from Unit::AttackStart(Unit*)
1473 bool IsTriggeredAtSpellProcEvent(Unit
*pVictim
, Aura
* aura
, SpellEntry
const* procSpell
, uint32 procFlag
, uint32 procExtra
, WeaponAttackType attType
, bool isVictim
, bool active
, SpellProcEventEntry
const*& spellProcEvent
);
1474 bool HandleDummyAuraProc( Unit
*pVictim
, uint32 damage
, Aura
* triggredByAura
, SpellEntry
const *procSpell
, uint32 procFlag
, uint32 procEx
, uint32 cooldown
);
1475 bool HandleHasteAuraProc( Unit
*pVictim
, uint32 damage
, Aura
* triggredByAura
, SpellEntry
const *procSpell
, uint32 procFlag
, uint32 procEx
, uint32 cooldown
);
1476 bool HandleProcTriggerSpell(Unit
*pVictim
, uint32 damage
, Aura
* triggredByAura
, SpellEntry
const *procSpell
, uint32 procFlag
, uint32 procEx
, uint32 cooldown
);
1477 bool HandleOverrideClassScriptAuraProc(Unit
*pVictim
, uint32 damage
, Aura
* triggredByAura
, SpellEntry
const *procSpell
, uint32 cooldown
);
1478 bool HandleMeandingAuraProc(Aura
* triggeredByAura
);
1480 uint32 m_state
; // Even derived shouldn't modify
1481 uint32 m_CombatTimer
;
1482 uint32 m_lastManaUse
; // msecs
1484 UnitVisibility m_Visibility
;
1486 Diminishing m_Diminishing
;
1487 // Manage all Units threatening us
1488 ThreatManager m_ThreatManager
;
1489 // Manage all Units that are threatened by us
1490 HostilRefManager m_HostilRefManager
;
1492 FollowerRefManager m_FollowingRefManager
;
1494 ComboPointHolderSet m_ComboPointHolders
;