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