2010-10-07 15:54:07 +02:00
/*
2015-01-01 00:27:46 +01:00
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
2010-10-07 15:54:07 +02:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
2009-04-07 00:23:37 +02:00
*/
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
#ifndef __UNIT_H
#define __UNIT_H
2009-10-17 15:51:44 -07:00
2013-03-25 10:36:30 +01:00
#include "DBCStructure.h"
2012-11-20 14:54:33 +01:00
#include "EventProcessor.h"
2010-06-08 13:05:47 -06:00
#include "FollowerReference.h"
#include "FollowerRefManager.h"
2012-11-20 14:54:33 +01:00
#include "HostileRefManager.h"
2009-04-07 00:23:37 +02:00
#include "MotionMaster.h"
2012-11-20 14:54:33 +01:00
#include "Object.h"
#include "SpellAuraDefines.h"
#include "ThreatManager.h"
2013-06-01 12:13:36 +02:00
#include "MoveSplineInit.h"
2009-04-07 00:23:37 +02:00
#define WORLD_TRIGGER 12999
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum SpellInterruptFlags
{
SPELL_INTERRUPT_FLAG_MOVEMENT = 0x01 , // why need this for instant?
SPELL_INTERRUPT_FLAG_PUSH_BACK = 0x02 , // push back
2011-11-03 16:53:29 +07:00
SPELL_INTERRUPT_FLAG_UNK3 = 0x04 , // any info?
SPELL_INTERRUPT_FLAG_INTERRUPT = 0x08 , // interrupt
2012-09-10 13:03:38 +02:00
SPELL_INTERRUPT_FLAG_ABORT_ON_DMG = 0x10 // _complete_ interrupt on direct damage
2009-04-07 00:23:37 +02:00
//SPELL_INTERRUPT_UNK = 0x20 // unk, 564 of 727 spells having this spell start with "Glyph"
};
2009-10-17 15:51:44 -07:00
2010-01-24 18:58:06 +01:00
// See SpellAuraInterruptFlags for other values definitions
2009-04-07 00:23:37 +02:00
enum SpellChannelInterruptFlags
{
2011-11-05 05:21:37 +07:00
CHANNEL_INTERRUPT_FLAG_INTERRUPT = 0x08 , // interrupt
CHANNEL_FLAG_DELAY = 0x4000
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum SpellAuraInterruptFlags
{
2009-04-15 20:58:39 +02:00
AURA_INTERRUPT_FLAG_HITBYSPELL = 0x00000001 , // 0 removed when getting hit by a negative spell?
2009-05-26 16:00:19 -05:00
AURA_INTERRUPT_FLAG_TAKE_DAMAGE = 0x00000002 , // 1 removed by any damage
AURA_INTERRUPT_FLAG_CAST = 0x00000004 , // 2 cast any spells
2009-04-07 00:23:37 +02:00
AURA_INTERRUPT_FLAG_MOVE = 0x00000008 , // 3 removed by any movement
AURA_INTERRUPT_FLAG_TURNING = 0x00000010 , // 4 removed by any turning
AURA_INTERRUPT_FLAG_JUMP = 0x00000020 , // 5 removed by entering combat
2011-12-19 22:06:29 +01:00
AURA_INTERRUPT_FLAG_NOT_MOUNTED = 0x00000040 , // 6 removed by dismounting
2009-04-07 00:23:37 +02:00
AURA_INTERRUPT_FLAG_NOT_ABOVEWATER = 0x00000080 , // 7 removed by entering water
AURA_INTERRUPT_FLAG_NOT_UNDERWATER = 0x00000100 , // 8 removed by leaving water
AURA_INTERRUPT_FLAG_NOT_SHEATHED = 0x00000200 , // 9 removed by unsheathing
AURA_INTERRUPT_FLAG_TALK = 0x00000400 , // 10 talk to npc / loot? action on creature
AURA_INTERRUPT_FLAG_USE = 0x00000800 , // 11 mine/use/open action on gameobject
2009-05-26 16:00:19 -05:00
AURA_INTERRUPT_FLAG_MELEE_ATTACK = 0x00001000 , // 12 removed by attacking
AURA_INTERRUPT_FLAG_SPELL_ATTACK = 0x00002000 , // 13 ???
2009-04-07 00:23:37 +02:00
AURA_INTERRUPT_FLAG_UNK14 = 0x00004000 , // 14
AURA_INTERRUPT_FLAG_TRANSFORM = 0x00008000 , // 15 removed by transform?
AURA_INTERRUPT_FLAG_UNK16 = 0x00010000 , // 16
AURA_INTERRUPT_FLAG_MOUNT = 0x00020000 , // 17 misdirect, aspect, swim speed
2009-08-24 19:12:22 -05:00
AURA_INTERRUPT_FLAG_NOT_SEATED = 0x00040000 , // 18 removed by standing up (used by food and drink mostly and sleep/Fake Death like)
2009-04-07 00:23:37 +02:00
AURA_INTERRUPT_FLAG_CHANGE_MAP = 0x00080000 , // 19 leaving map/getting teleported
2010-11-14 23:46:34 +02:00
AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION = 0x00100000 , // 20 removed by auras that make you invulnerable, or make other to lose selection on you
2009-04-07 00:23:37 +02:00
AURA_INTERRUPT_FLAG_UNK21 = 0x00200000 , // 21
AURA_INTERRUPT_FLAG_TELEPORTED = 0x00400000 , // 22
AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT = 0x00800000 , // 23 removed by entering pvp combat
2009-05-20 11:44:38 -05:00
AURA_INTERRUPT_FLAG_DIRECT_DAMAGE = 0x01000000 , // 24 removed by any direct damage
2010-01-10 01:23:15 +01:00
AURA_INTERRUPT_FLAG_LANDING = 0x02000000 , // 25 removed by hitting the ground
2009-10-17 15:51:44 -07:00
2012-09-10 13:03:38 +02:00
AURA_INTERRUPT_FLAG_NOT_VICTIM = ( AURA_INTERRUPT_FLAG_HITBYSPELL | AURA_INTERRUPT_FLAG_TAKE_DAMAGE | AURA_INTERRUPT_FLAG_DIRECT_DAMAGE )
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum SpellModOp
{
SPELLMOD_DAMAGE = 0 ,
SPELLMOD_DURATION = 1 ,
SPELLMOD_THREAT = 2 ,
SPELLMOD_EFFECT1 = 3 ,
SPELLMOD_CHARGES = 4 ,
SPELLMOD_RANGE = 5 ,
SPELLMOD_RADIUS = 6 ,
SPELLMOD_CRITICAL_CHANCE = 7 ,
SPELLMOD_ALL_EFFECTS = 8 ,
SPELLMOD_NOT_LOSE_CASTING_TIME = 9 ,
SPELLMOD_CASTING_TIME = 10 ,
SPELLMOD_COOLDOWN = 11 ,
SPELLMOD_EFFECT2 = 12 ,
SPELLMOD_IGNORE_ARMOR = 13 ,
2015-01-29 18:15:59 +01:00
SPELLMOD_COST = 14 , // Used when SpellPowerEntry::PowerIndex == 0
2009-04-07 00:23:37 +02:00
SPELLMOD_CRIT_DAMAGE_BONUS = 15 ,
SPELLMOD_RESIST_MISS_CHANCE = 16 ,
SPELLMOD_JUMP_TARGETS = 17 ,
2009-07-30 11:44:23 +02:00
SPELLMOD_CHANCE_OF_SUCCESS = 18 ,
2009-04-07 00:23:37 +02:00
SPELLMOD_ACTIVATION_TIME = 19 ,
2010-08-26 19:07:55 +02:00
SPELLMOD_DAMAGE_MULTIPLIER = 20 ,
2010-04-22 21:28:04 +02:00
SPELLMOD_GLOBAL_COOLDOWN = 21 ,
2009-04-07 00:23:37 +02:00
SPELLMOD_DOT = 22 ,
SPELLMOD_EFFECT3 = 23 ,
2010-08-26 19:07:55 +02:00
SPELLMOD_BONUS_MULTIPLIER = 24 ,
2009-04-07 00:23:37 +02:00
// spellmod 25
SPELLMOD_PROC_PER_MINUTE = 26 ,
2010-08-26 19:07:55 +02:00
SPELLMOD_VALUE_MULTIPLIER = 27 ,
2009-04-07 00:23:37 +02:00
SPELLMOD_RESIST_DISPEL_CHANCE = 28 ,
SPELLMOD_CRIT_DAMAGE_BONUS_2 = 29 , //one not used spell
2015-01-29 18:15:59 +01:00
SPELLMOD_SPELL_COST_REFUND_ON_FAIL = 30 ,
SPELLMOD_STACK_AMOUNT = 31 , // has no effect on tooltip parsing
SPELLMOD_EFFECT4 = 32 ,
SPELLMOD_EFFECT5 = 33 ,
SPELLMOD_SPELL_COST2 = 34 , // Used when SpellPowerEntry::PowerIndex == 1
SPELLMOD_JUMP_DISTANCE = 35 ,
SPELLMOD_STACK_AMOUNT2 = 37 // same as SPELLMOD_STACK_AMOUNT but affects tooltips
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2015-01-29 18:15:59 +01:00
#define MAX_SPELLMOD 38
2009-10-17 15:51:44 -07:00
2009-04-19 00:54:01 -05:00
enum SpellValueMod
{
SPELLVALUE_BASE_POINT0 ,
SPELLVALUE_BASE_POINT1 ,
SPELLVALUE_BASE_POINT2 ,
2014-11-16 14:20:01 +01:00
SPELLVALUE_BASE_POINT3 ,
SPELLVALUE_BASE_POINT4 ,
SPELLVALUE_BASE_POINT5 ,
SPELLVALUE_BASE_POINT6 ,
SPELLVALUE_BASE_POINT7 ,
SPELLVALUE_BASE_POINT8 ,
SPELLVALUE_BASE_POINT9 ,
SPELLVALUE_BASE_POINT10 ,
SPELLVALUE_BASE_POINT11 ,
SPELLVALUE_BASE_POINT12 ,
SPELLVALUE_BASE_POINT13 ,
SPELLVALUE_BASE_POINT14 ,
SPELLVALUE_BASE_POINT15 ,
SPELLVALUE_BASE_POINT16 ,
SPELLVALUE_BASE_POINT17 ,
SPELLVALUE_BASE_POINT18 ,
SPELLVALUE_BASE_POINT19 ,
SPELLVALUE_BASE_POINT20 ,
SPELLVALUE_BASE_POINT21 ,
SPELLVALUE_BASE_POINT22 ,
SPELLVALUE_BASE_POINT23 ,
SPELLVALUE_BASE_POINT24 ,
SPELLVALUE_BASE_POINT25 ,
SPELLVALUE_BASE_POINT26 ,
SPELLVALUE_BASE_POINT27 ,
SPELLVALUE_BASE_POINT28 ,
SPELLVALUE_BASE_POINT29 ,
SPELLVALUE_BASE_POINT30 ,
SPELLVALUE_BASE_POINT31 ,
SPELLVALUE_BASE_POINT_END ,
2009-04-29 00:11:15 -05:00
SPELLVALUE_RADIUS_MOD ,
2009-04-19 00:54:01 -05:00
SPELLVALUE_MAX_TARGETS ,
2012-09-10 13:03:38 +02:00
SPELLVALUE_AURA_STACK
2009-04-19 00:54:01 -05:00
};
2009-10-17 15:51:44 -07:00
2013-03-25 13:26:48 +01:00
class CustomSpellValues
2009-04-19 00:54:01 -05:00
{
2013-03-25 13:26:48 +01:00
typedef std :: pair < SpellValueMod , int32 > CustomSpellValueMod ;
typedef std :: vector < CustomSpellValueMod > StorageType ;
public :
typedef StorageType :: const_iterator const_iterator ;
public :
void AddSpellMod ( SpellValueMod mod , int32 value )
{
storage_ . push_back ( CustomSpellValueMod ( mod , value ));
}
const_iterator begin () const
{
return storage_ . begin ();
}
const_iterator end () const
{
return storage_ . end ();
}
private :
StorageType storage_ ;
2009-04-19 00:54:01 -05:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum SpellFacingFlags
{
SPELL_FACING_FLAG_INFRONT = 0x0001
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
#define BASE_MINDAMAGE 1.0f
#define BASE_MAXDAMAGE 2.0f
#define BASE_ATTACK_TIME 2000
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
// byte value (UNIT_FIELD_BYTES_1, 0)
2009-04-07 00:23:37 +02:00
enum UnitStandStateType
{
UNIT_STAND_STATE_STAND = 0 ,
UNIT_STAND_STATE_SIT = 1 ,
UNIT_STAND_STATE_SIT_CHAIR = 2 ,
UNIT_STAND_STATE_SLEEP = 3 ,
UNIT_STAND_STATE_SIT_LOW_CHAIR = 4 ,
UNIT_STAND_STATE_SIT_MEDIUM_CHAIR = 5 ,
UNIT_STAND_STATE_SIT_HIGH_CHAIR = 6 ,
UNIT_STAND_STATE_DEAD = 7 ,
2009-12-19 19:11:31 +01:00
UNIT_STAND_STATE_KNEEL = 8 ,
UNIT_STAND_STATE_SUBMERGED = 9
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
// byte flag value (UNIT_FIELD_BYTES_1, 2)
2009-04-07 00:23:37 +02:00
enum UnitStandFlags
{
2009-12-19 19:11:31 +01:00
UNIT_STAND_FLAGS_UNK1 = 0x01 ,
2009-04-07 00:23:37 +02:00
UNIT_STAND_FLAGS_CREEP = 0x02 ,
2011-08-30 20:24:36 +07:00
UNIT_STAND_FLAGS_UNTRACKABLE = 0x04 ,
2009-12-19 19:11:31 +01:00
UNIT_STAND_FLAGS_UNK4 = 0x08 ,
UNIT_STAND_FLAGS_UNK5 = 0x10 ,
2009-04-07 00:23:37 +02:00
UNIT_STAND_FLAGS_ALL = 0xFF
};
2009-10-17 15:51:44 -07:00
2014-11-30 19:09:26 +01:00
enum UnitBytes0Offsets
{
UNIT_BYTES_0_OFFSET_RACE = 0 ,
UNIT_BYTES_0_OFFSET_CLASS = 1 ,
2015-01-10 01:35:47 +01:00
UNIT_BYTES_0_OFFSET_GENDER = 3
};
enum UnitBytes1Offsets
{
UNIT_BYTES_1_OFFSET_STAND_STATE = 0 ,
UNIT_BYTES_1_OFFSET_VIS_FLAG = 2 ,
UNIT_BYTES_1_OFFSET_ANIM_TIER = 3
};
enum UnitBytes2Offsets
{
UNIT_BYTES_2_OFFSET_SHEATH_STATE = 0 ,
UNIT_BYTES_2_OFFSET_PVP_FLAG = 1 ,
2014-11-30 19:09:26 +01:00
};
2011-04-29 20:47:02 +02:00
// byte flags value (UNIT_FIELD_BYTES_1, 3)
2009-04-07 00:23:37 +02:00
enum UnitBytes1_Flags
{
2012-05-30 08:01:02 +02:00
UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01 ,
UNIT_BYTE1_FLAG_HOVER = 0x02 ,
UNIT_BYTE1_FLAG_UNK_3 = 0x04 ,
UNIT_BYTE1_FLAG_ALL = 0xFF
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// high byte (3 from 0..3) of UNIT_FIELD_BYTES_2
enum ShapeshiftForm
{
FORM_NONE = 0x00 ,
FORM_CAT = 0x01 ,
FORM_TREE = 0x02 ,
FORM_TRAVEL = 0x03 ,
FORM_AQUA = 0x04 ,
FORM_BEAR = 0x05 ,
FORM_AMBIENT = 0x06 ,
FORM_GHOUL = 0x07 ,
2012-08-19 15:19:20 +02:00
FORM_DIREBEAR = 0x08 , // Removed in 4.0.1
2010-11-16 14:04:15 +01:00
FORM_STEVES_GHOUL = 0x09 ,
FORM_THARONJA_SKELETON = 0x0A ,
FORM_TEST_OF_STRENGTH = 0x0B ,
FORM_BLB_PLAYER = 0x0C ,
2009-07-23 01:01:12 +02:00
FORM_SHADOW_DANCE = 0x0D ,
2009-04-07 00:23:37 +02:00
FORM_CREATUREBEAR = 0x0E ,
FORM_CREATURECAT = 0x0F ,
FORM_GHOSTWOLF = 0x10 ,
FORM_BATTLESTANCE = 0x11 ,
FORM_DEFENSIVESTANCE = 0x12 ,
FORM_BERSERKERSTANCE = 0x13 ,
FORM_TEST = 0x14 ,
FORM_ZOMBIE = 0x15 ,
FORM_METAMORPHOSIS = 0x16 ,
2009-07-23 01:01:12 +02:00
FORM_UNDEAD = 0x19 ,
2009-12-17 13:07:38 +01:00
FORM_MASTER_ANGLER = 0x1A ,
2009-04-07 00:23:37 +02:00
FORM_FLIGHT_EPIC = 0x1B ,
FORM_SHADOW = 0x1C ,
FORM_FLIGHT = 0x1D ,
FORM_STEALTH = 0x1E ,
FORM_MOONKIN = 0x1F ,
FORM_SPIRITOFREDEMPTION = 0x20
};
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
// low byte (0 from 0..3) of UNIT_FIELD_BYTES_2
2015-03-08 22:04:34 +01:00
enum SheathState : uint8
2009-04-07 00:23:37 +02:00
{
SHEATH_STATE_UNARMED = 0 , // non prepared weapon
SHEATH_STATE_MELEE = 1 , // prepared melee weapon
SHEATH_STATE_RANGED = 2 // prepared ranged weapon
};
2009-10-17 15:51:44 -07:00
2009-05-28 18:43:57 -05:00
#define MAX_SHEATH_STATE 3
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// byte (1 from 0..3) of UNIT_FIELD_BYTES_2
2009-12-19 19:10:14 +01:00
enum UnitPVPStateFlags
2009-04-07 00:23:37 +02:00
{
UNIT_BYTE2_FLAG_PVP = 0x01 ,
UNIT_BYTE2_FLAG_UNK1 = 0x02 ,
UNIT_BYTE2_FLAG_FFA_PVP = 0x04 ,
UNIT_BYTE2_FLAG_SANCTUARY = 0x08 ,
UNIT_BYTE2_FLAG_UNK4 = 0x10 ,
UNIT_BYTE2_FLAG_UNK5 = 0x20 ,
UNIT_BYTE2_FLAG_UNK6 = 0x40 ,
UNIT_BYTE2_FLAG_UNK7 = 0x80
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// byte (2 from 0..3) of UNIT_FIELD_BYTES_2
enum UnitRename
{
2010-02-14 19:13:14 -07:00
UNIT_CAN_BE_RENAMED = 0x01 ,
2012-09-10 13:03:38 +02:00
UNIT_CAN_BE_ABANDONED = 0x02
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
#define MAX_SPELL_CHARM 4
#define MAX_SPELL_VEHICLE 6
#define MAX_SPELL_POSSESS 8
#define MAX_SPELL_CONTROL_BAR 10
2009-10-17 15:51:44 -07:00
2012-09-22 02:11:31 +01:00
#define MAX_AGGRO_RESET_TIME 10 // in seconds
2012-12-06 09:58:32 -05:00
#define MAX_AGGRO_RADIUS 45.0f // yards
2012-09-22 02:11:31 +01:00
2009-04-07 00:23:37 +02:00
enum Swing
{
NOSWING = 0 ,
SINGLEHANDEDSWING = 1 ,
TWOHANDEDSWING = 2
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum VictimState
{
2010-08-27 23:12:52 +02:00
VICTIMSTATE_INTACT = 0 , // set when attacker misses
VICTIMSTATE_HIT = 1 , // victim got clear/blocked hit
2009-04-07 00:23:37 +02:00
VICTIMSTATE_DODGE = 2 ,
VICTIMSTATE_PARRY = 3 ,
VICTIMSTATE_INTERRUPT = 4 ,
2010-08-27 23:12:52 +02:00
VICTIMSTATE_BLOCKS = 5 , // unused? not set when blocked, even on full block
2009-04-07 00:23:37 +02:00
VICTIMSTATE_EVADES = 6 ,
VICTIMSTATE_IS_IMMUNE = 7 ,
VICTIMSTATE_DEFLECTS = 8
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum HitInfo
{
HITINFO_NORMALSWING = 0x00000000 ,
HITINFO_UNK1 = 0x00000001 , // req correct packet structure
2012-05-30 08:01:02 +02:00
HITINFO_AFFECTS_VICTIM = 0x00000002 ,
HITINFO_OFFHAND = 0x00000004 ,
2009-04-07 00:23:37 +02:00
HITINFO_UNK2 = 0x00000008 ,
HITINFO_MISS = 0x00000010 ,
2012-05-30 08:01:02 +02:00
HITINFO_FULL_ABSORB = 0x00000020 ,
HITINFO_PARTIAL_ABSORB = 0x00000040 ,
HITINFO_FULL_RESIST = 0x00000080 ,
HITINFO_PARTIAL_RESIST = 0x00000100 ,
2009-04-07 00:23:37 +02:00
HITINFO_CRITICALHIT = 0x00000200 , // critical hit
// 0x00000400
// 0x00000800
2014-11-19 00:30:31 +02:00
HITINFO_UNK12 = 0x00001000 ,
2009-04-07 00:23:37 +02:00
HITINFO_BLOCK = 0x00002000 , // blocked damage
2012-05-30 08:01:02 +02:00
// 0x00004000 // Hides worldtext for 0 damage
// 0x00008000 // Related to blood visual
2009-04-07 00:23:37 +02:00
HITINFO_GLANCING = 0x00010000 ,
HITINFO_CRUSHING = 0x00020000 ,
2012-05-30 08:01:02 +02:00
HITINFO_NO_ANIMATION = 0x00040000 ,
2009-04-07 00:23:37 +02:00
// 0x00080000
// 0x00100000
2012-05-30 08:01:02 +02:00
HITINFO_SWINGNOHITSOUND = 0x00200000 , // unused?
2009-04-07 00:23:37 +02:00
// 0x00400000
2012-05-30 08:01:02 +02:00
HITINFO_RAGE_GAIN = 0x00800000
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
//i would like to remove this: (it is defined in item.h
enum InventorySlot
{
NULL_BAG = 0 ,
NULL_SLOT = 255
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
struct FactionTemplateEntry ;
2009-04-19 00:54:01 -05:00
struct SpellValue ;
2009-10-17 15:51:44 -07:00
2010-01-10 01:23:15 +01:00
class AuraApplication ;
2009-04-07 00:23:37 +02:00
class Aura ;
2010-01-16 15:12:21 +01:00
class UnitAura ;
2009-04-07 00:23:37 +02:00
class AuraEffect ;
class Creature ;
class Spell ;
2011-07-26 23:09:28 +02:00
class SpellInfo ;
2014-12-19 23:52:29 +01:00
class SpellEffectInfo ;
2015-02-17 01:01:44 +01:00
class SpellHistory ;
2009-04-07 00:23:37 +02:00
class DynamicObject ;
class GameObject ;
class Item ;
class Pet ;
class PetAura ;
2009-05-02 19:24:22 -05:00
class Minion ;
2009-04-07 00:23:37 +02:00
class Guardian ;
2009-04-07 19:38:09 -05:00
class UnitAI ;
2010-03-07 15:20:19 +01:00
class Totem ;
2009-04-21 15:43:03 -05:00
class Transport ;
2009-08-23 22:09:43 -05:00
class Vehicle ;
2013-02-16 02:11:42 +01:00
class VehicleJoinEvent ;
2012-09-09 19:56:00 +02:00
class TransportBase ;
2012-11-20 14:54:33 +01:00
class SpellCastTargets ;
2013-04-09 17:24:39 +02:00
namespace Movement
{
class ExtraMovementStatusElement ;
2013-06-01 12:13:36 +02:00
class MoveSpline ;
2013-04-09 17:24:39 +02:00
}
2009-10-17 15:51:44 -07:00
2011-06-23 13:28:52 +02:00
typedef std :: list < Unit *> UnitList ;
2012-05-30 08:01:02 +02:00
typedef std :: list < std :: pair < Aura * , uint8 > > DispelChargesList ;
2011-06-23 13:28:52 +02:00
2009-04-07 00:23:37 +02:00
struct SpellImmune
{
uint32 type ;
uint32 spellId ;
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
typedef std :: list < SpellImmune > SpellImmuneList ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum UnitModifierType
{
BASE_VALUE = 0 ,
BASE_PCT = 1 ,
TOTAL_VALUE = 2 ,
TOTAL_PCT = 3 ,
MODIFIER_TYPE_END = 4
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum WeaponDamageRange
{
MINDAMAGE ,
MAXDAMAGE
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum DamageTypeToSchool
{
RESISTANCE ,
DAMAGE_DEALT ,
DAMAGE_TAKEN
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum AuraRemoveMode
{
2010-01-10 01:23:15 +01:00
AURA_REMOVE_NONE = 0 ,
AURA_REMOVE_BY_DEFAULT = 1 , // scripted remove, remove by stack with aura with different ids and sc aura remove
2009-04-07 00:23:37 +02:00
AURA_REMOVE_BY_CANCEL ,
2010-01-10 01:23:15 +01:00
AURA_REMOVE_BY_ENEMY_SPELL , // dispel and absorb aura destroy
AURA_REMOVE_BY_EXPIRE , // aura duration has ended
2009-04-07 00:23:37 +02:00
AURA_REMOVE_BY_DEATH
};
2009-10-17 15:51:44 -07:00
2011-07-31 19:03:06 +02:00
enum TriggerCastFlags
{
TRIGGERED_NONE = 0x00000000 , //! Not triggered
TRIGGERED_IGNORE_GCD = 0x00000001 , //! Will ignore GCD
TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD = 0x00000002 , //! Will ignore Spell and Category cooldowns
2011-08-01 12:05:30 +02:00
TRIGGERED_IGNORE_POWER_AND_REAGENT_COST = 0x00000004 , //! Will ignore power and reagent cost
2011-07-31 19:03:06 +02:00
TRIGGERED_IGNORE_CAST_ITEM = 0x00000008 , //! Will not take away cast item or update related achievement criteria
TRIGGERED_IGNORE_AURA_SCALING = 0x00000010 , //! Will ignore aura scaling
TRIGGERED_IGNORE_CAST_IN_PROGRESS = 0x00000020 , //! Will not check if a current cast is in progress
TRIGGERED_IGNORE_COMBO_POINTS = 0x00000040 , //! Will ignore combo point requirement
TRIGGERED_CAST_DIRECTLY = 0x00000080 , //! In Spell::prepare, will be cast directly without setting containers for executed spell
TRIGGERED_IGNORE_AURA_INTERRUPT_FLAGS = 0x00000100 , //! Will ignore interruptible aura's at cast
TRIGGERED_IGNORE_SET_FACING = 0x00000200 , //! Will not adjust facing to target (if any)
TRIGGERED_IGNORE_SHAPESHIFT = 0x00000400 , //! Will ignore shapeshift checks
TRIGGERED_IGNORE_CASTER_AURASTATE = 0x00000800 , //! Will ignore caster aura states including combat requirements and death state
TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE = 0x00002000 , //! Will ignore mounted/on vehicle restrictions
TRIGGERED_IGNORE_CASTER_AURAS = 0x00010000 , //! Will ignore caster aura restrictions or requirements
2011-08-01 00:48:11 +02:00
TRIGGERED_DISALLOW_PROC_EVENTS = 0x00020000 , //! Disallows proc events from triggered spell (default)
2011-07-31 19:03:06 +02:00
TRIGGERED_DONT_REPORT_CAST_ERROR = 0x00040000 , //! Will return SPELL_FAILED_DONT_REPORT in CheckCast functions
2013-02-25 05:38:34 +02:00
TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT = 0x00080000 , //! Will ignore equipped item requirements
2013-04-16 02:18:43 +03:00
TRIGGERED_IGNORE_TARGET_CHECK = 0x00100000 , //! Will ignore most target checks (mostly DBC target checks)
2012-09-10 13:03:38 +02:00
TRIGGERED_FULL_MASK = 0xFFFFFFFF
2011-07-31 19:03:06 +02:00
};
2009-04-07 00:23:37 +02:00
enum UnitMods
{
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.
UNIT_MOD_STAT_AGILITY ,
UNIT_MOD_STAT_STAMINA ,
UNIT_MOD_STAT_INTELLECT ,
UNIT_MOD_STAT_SPIRIT ,
UNIT_MOD_HEALTH ,
UNIT_MOD_MANA , // UNIT_MOD_MANA..UNIT_MOD_RUNIC_POWER must be in existed order, it's accessed by index values of Powers enum.
UNIT_MOD_RAGE ,
UNIT_MOD_FOCUS ,
UNIT_MOD_ENERGY ,
2012-08-13 14:56:20 +02:00
UNIT_MOD_UNUSED , // Old UNIT_MOD_HAPPINESS
2009-04-07 00:23:37 +02:00
UNIT_MOD_RUNE ,
UNIT_MOD_RUNIC_POWER ,
2012-08-13 14:56:20 +02:00
UNIT_MOD_SOUL_SHARDS ,
UNIT_MOD_ECLIPSE ,
UNIT_MOD_HOLY_POWER ,
UNIT_MOD_ALTERNATIVE ,
2009-04-07 00:23:37 +02:00
UNIT_MOD_ARMOR , // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum.
UNIT_MOD_RESISTANCE_HOLY ,
UNIT_MOD_RESISTANCE_FIRE ,
UNIT_MOD_RESISTANCE_NATURE ,
UNIT_MOD_RESISTANCE_FROST ,
UNIT_MOD_RESISTANCE_SHADOW ,
UNIT_MOD_RESISTANCE_ARCANE ,
UNIT_MOD_ATTACK_POWER ,
UNIT_MOD_ATTACK_POWER_RANGED ,
UNIT_MOD_DAMAGE_MAINHAND ,
UNIT_MOD_DAMAGE_OFFHAND ,
UNIT_MOD_DAMAGE_RANGED ,
UNIT_MOD_END ,
// synonyms
UNIT_MOD_STAT_START = UNIT_MOD_STAT_STRENGTH ,
UNIT_MOD_STAT_END = UNIT_MOD_STAT_SPIRIT + 1 ,
UNIT_MOD_RESISTANCE_START = UNIT_MOD_ARMOR ,
UNIT_MOD_RESISTANCE_END = UNIT_MOD_RESISTANCE_ARCANE + 1 ,
UNIT_MOD_POWER_START = UNIT_MOD_MANA ,
2012-08-13 14:56:20 +02:00
UNIT_MOD_POWER_END = UNIT_MOD_ALTERNATIVE + 1
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum BaseModGroup
{
CRIT_PERCENTAGE ,
RANGED_CRIT_PERCENTAGE ,
OFFHAND_CRIT_PERCENTAGE ,
SHIELD_BLOCK_VALUE ,
BASEMOD_END
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum BaseModType
{
FLAT_MOD ,
2013-08-27 21:30:33 +01:00
PCT_MOD ,
MOD_END
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum DeathState
{
2012-09-10 13:03:38 +02:00
ALIVE = 0 ,
JUST_DIED = 1 ,
CORPSE = 2 ,
DEAD = 3 ,
JUST_RESPAWNED = 4
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum UnitState
{
2012-02-03 19:12:41 +02:00
UNIT_STATE_DIED = 0x00000001 , // player has fake death aura
UNIT_STATE_MELEE_ATTACKING = 0x00000002 , // player is melee attacking someone
//UNIT_STATE_MELEE_ATTACK_BY = 0x00000004, // player is melee attack by someone
UNIT_STATE_STUNNED = 0x00000008 ,
UNIT_STATE_ROAMING = 0x00000010 ,
UNIT_STATE_CHASE = 0x00000020 ,
//UNIT_STATE_SEARCHING = 0x00000040,
UNIT_STATE_FLEEING = 0x00000080 ,
UNIT_STATE_IN_FLIGHT = 0x00000100 , // player is in flight mode
UNIT_STATE_FOLLOW = 0x00000200 ,
UNIT_STATE_ROOT = 0x00000400 ,
UNIT_STATE_CONFUSED = 0x00000800 ,
UNIT_STATE_DISTRACTED = 0x00001000 ,
UNIT_STATE_ISOLATED = 0x00002000 , // area auras do not affect other players
UNIT_STATE_ATTACK_PLAYER = 0x00004000 ,
UNIT_STATE_CASTING = 0x00008000 ,
UNIT_STATE_POSSESSED = 0x00010000 ,
UNIT_STATE_CHARGING = 0x00020000 ,
UNIT_STATE_JUMPING = 0x00040000 ,
UNIT_STATE_MOVE = 0x00100000 ,
UNIT_STATE_ROTATING = 0x00200000 ,
UNIT_STATE_EVADE = 0x00400000 ,
UNIT_STATE_ROAMING_MOVE = 0x00800000 ,
UNIT_STATE_CONFUSED_MOVE = 0x01000000 ,
UNIT_STATE_FLEEING_MOVE = 0x02000000 ,
UNIT_STATE_CHASE_MOVE = 0x04000000 ,
UNIT_STATE_FOLLOW_MOVE = 0x08000000 ,
2012-04-09 15:11:39 +02:00
UNIT_STATE_IGNORE_PATHFINDING = 0x10000000 , // do not use pathfinding in any MovementGenerator
2014-03-20 21:34:05 +01:00
UNIT_STATE_ALL_STATE_SUPPORTED = UNIT_STATE_DIED | UNIT_STATE_MELEE_ATTACKING | UNIT_STATE_STUNNED | UNIT_STATE_ROAMING | UNIT_STATE_CHASE
| UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT | UNIT_STATE_FOLLOW | UNIT_STATE_ROOT | UNIT_STATE_CONFUSED
| UNIT_STATE_DISTRACTED | UNIT_STATE_ISOLATED | UNIT_STATE_ATTACK_PLAYER | UNIT_STATE_CASTING
| UNIT_STATE_POSSESSED | UNIT_STATE_CHARGING | UNIT_STATE_JUMPING | UNIT_STATE_MOVE | UNIT_STATE_ROTATING
| UNIT_STATE_EVADE | UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE
| UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE | UNIT_STATE_IGNORE_PATHFINDING ,
2013-06-29 15:20:15 +02:00
UNIT_STATE_UNATTACKABLE = UNIT_STATE_IN_FLIGHT ,
2012-01-14 15:34:41 +01:00
// for real move using movegen check and stop (except unstoppable flight)
2013-01-14 09:50:59 +01:00
UNIT_STATE_MOVING = UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE ,
2012-02-03 19:12:41 +02:00
UNIT_STATE_CONTROLLED = ( UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING ),
UNIT_STATE_LOST_CONTROL = ( UNIT_STATE_CONTROLLED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING ),
UNIT_STATE_SIGHTLESS = ( UNIT_STATE_LOST_CONTROL | UNIT_STATE_EVADE ),
UNIT_STATE_CANNOT_AUTOATTACK = ( UNIT_STATE_LOST_CONTROL | UNIT_STATE_CASTING ),
UNIT_STATE_CANNOT_TURN = ( UNIT_STATE_LOST_CONTROL | UNIT_STATE_ROTATING ),
2012-01-14 15:34:41 +01:00
// stay by different reasons
2012-02-03 19:12:41 +02:00
UNIT_STATE_NOT_MOVE = UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DIED | UNIT_STATE_DISTRACTED ,
UNIT_STATE_ALL_STATE = 0xffffffff //(UNIT_STATE_STOPPED | UNIT_STATE_MOVING | UNIT_STATE_IN_COMBAT | UNIT_STATE_IN_FLIGHT)
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum UnitMoveType
{
MOVE_WALK = 0 ,
MOVE_RUN = 1 ,
MOVE_RUN_BACK = 2 ,
MOVE_SWIM = 3 ,
MOVE_SWIM_BACK = 4 ,
MOVE_TURN_RATE = 5 ,
MOVE_FLIGHT = 6 ,
MOVE_FLIGHT_BACK = 7 ,
MOVE_PITCH_RATE = 8
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
#define MAX_MOVE_TYPE 9
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
extern float baseMoveSpeed [ MAX_MOVE_TYPE ];
2009-08-30 21:33:17 -07:00
extern float playerBaseMoveSpeed [ MAX_MOVE_TYPE ];
2009-10-17 15:51:44 -07:00
2015-03-08 22:04:34 +01:00
enum WeaponAttackType : uint16
2009-04-07 00:23:37 +02:00
{
BASE_ATTACK = 0 ,
OFF_ATTACK = 1 ,
RANGED_ATTACK = 2 ,
MAX_ATTACK
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum CombatRating
{
2012-12-20 19:22:14 +01:00
CR_WEAPON_SKILL = 0 ,
CR_DEFENSE_SKILL = 1 , // Removed in 4.0.1
CR_DODGE = 2 ,
CR_PARRY = 3 ,
CR_BLOCK = 4 ,
CR_HIT_MELEE = 5 ,
CR_HIT_RANGED = 6 ,
CR_HIT_SPELL = 7 ,
CR_CRIT_MELEE = 8 ,
CR_CRIT_RANGED = 9 ,
CR_CRIT_SPELL = 10 ,
CR_HIT_TAKEN_MELEE = 11 , // Deprecated since Cataclysm
CR_HIT_TAKEN_RANGED = 12 , // Deprecated since Cataclysm
CR_HIT_TAKEN_SPELL = 13 , // Deprecated since Cataclysm
CR_RESILIENCE_CRIT_TAKEN = 14 ,
CR_RESILIENCE_PLAYER_DAMAGE_TAKEN = 15 ,
CR_CRIT_TAKEN_SPELL = 16 , // Deprecated since Cataclysm
CR_HASTE_MELEE = 17 ,
CR_HASTE_RANGED = 18 ,
CR_HASTE_SPELL = 19 ,
CR_WEAPON_SKILL_MAINHAND = 20 ,
CR_WEAPON_SKILL_OFFHAND = 21 ,
CR_WEAPON_SKILL_RANGED = 22 ,
CR_EXPERTISE = 23 ,
CR_ARMOR_PENETRATION = 24 ,
CR_MASTERY = 25 ,
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2012-11-03 21:27:00 +02:00
#define MAX_COMBAT_RATING 26
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum DamageEffectType
{
DIRECT_DAMAGE = 0 , // used for normal weapon damage (not for class abilities or spells)
SPELL_DIRECT_DAMAGE = 1 , // spell/class abilities damage
DOT = 2 ,
HEAL = 3 ,
NODAMAGE = 4 , // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
SELF_DAMAGE = 5
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// Value masks for UNIT_FIELD_FLAGS
enum UnitFlags
{
2011-09-11 11:41:30 +02:00
UNIT_FLAG_SERVER_CONTROLLED = 0x00000001 , // set only when unit movement is controlled by server - by SPLINE/MONSTER_MOVE packets, together with UNIT_FLAG_STUNNED; only set to units controlled by client; client function CGUnit_C::IsClientControlled returns false when set for owner
2009-09-01 17:21:22 -05:00
UNIT_FLAG_NON_ATTACKABLE = 0x00000002 , // not attackable
UNIT_FLAG_DISABLE_MOVE = 0x00000004 ,
UNIT_FLAG_PVP_ATTACKABLE = 0x00000008 , // allow apply pvp rules to attackable state in addition to faction dependent state
UNIT_FLAG_RENAME = 0x00000010 ,
2010-12-19 05:15:47 +01:00
UNIT_FLAG_PREPARATION = 0x00000020 , // don't take reagents for spells with SPELL_ATTR5_NO_REAGENT_WHILE_PREP
2009-09-01 17:21:22 -05:00
UNIT_FLAG_UNK_6 = 0x00000040 ,
UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080 , // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE
2012-02-03 22:56:42 +01:00
UNIT_FLAG_IMMUNE_TO_PC = 0x00000100 , // disables combat/assistance with PlayerCharacters (PC) - see Unit::_IsValidAttackTarget, Unit::_IsValidAssistTarget
UNIT_FLAG_IMMUNE_TO_NPC = 0x00000200 , // disables combat/assistance with NonPlayerCharacters (NPC) - see Unit::_IsValidAttackTarget, Unit::_IsValidAssistTarget
2009-09-01 17:21:22 -05:00
UNIT_FLAG_LOOTING = 0x00000400 , // loot animation
UNIT_FLAG_PET_IN_COMBAT = 0x00000800 , // in combat?, 2.0.8
UNIT_FLAG_PVP = 0x00001000 , // changed in 3.0.3
UNIT_FLAG_SILENCED = 0x00002000 , // silenced, 2.1.1
UNIT_FLAG_UNK_14 = 0x00004000 , // 2.0.8
UNIT_FLAG_UNK_15 = 0x00008000 ,
UNIT_FLAG_UNK_16 = 0x00010000 ,
UNIT_FLAG_PACIFIED = 0x00020000 , // 3.0.3 ok
UNIT_FLAG_STUNNED = 0x00040000 , // 3.0.3 ok
UNIT_FLAG_IN_COMBAT = 0x00080000 ,
UNIT_FLAG_TAXI_FLIGHT = 0x00100000 , // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag
UNIT_FLAG_DISARMED = 0x00200000 , // 3.0.3, disable melee spells casting..., "Required melee weapon" added to melee spells tooltip.
UNIT_FLAG_CONFUSED = 0x00400000 ,
UNIT_FLAG_FLEEING = 0x00800000 ,
UNIT_FLAG_PLAYER_CONTROLLED = 0x01000000 , // used in spell Eyes of the Beast for pet... let attack by controlled creature
UNIT_FLAG_NOT_SELECTABLE = 0x02000000 ,
UNIT_FLAG_SKINNABLE = 0x04000000 ,
UNIT_FLAG_MOUNT = 0x08000000 ,
UNIT_FLAG_UNK_28 = 0x10000000 ,
UNIT_FLAG_UNK_29 = 0x20000000 , // used in Feing Death spell
UNIT_FLAG_SHEATHE = 0x40000000 ,
2013-08-05 22:55:06 +01:00
UNIT_FLAG_UNK_31 = 0x80000000 ,
MAX_UNIT_FLAGS = 33
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// Value masks for UNIT_FIELD_FLAGS_2
enum UnitFlags2
{
2012-08-30 04:52:35 +02:00
UNIT_FLAG2_FEIGN_DEATH = 0x00000001 ,
UNIT_FLAG2_UNK1 = 0x00000002 , // Hide unit model (show only player equip)
UNIT_FLAG2_IGNORE_REPUTATION = 0x00000004 ,
UNIT_FLAG2_COMPREHEND_LANG = 0x00000008 ,
UNIT_FLAG2_MIRROR_IMAGE = 0x00000010 ,
UNIT_FLAG2_INSTANTLY_APPEAR_MODEL = 0x00000020 , // Unit model instantly appears when summoned (does not fade in)
UNIT_FLAG2_FORCE_MOVEMENT = 0x00000040 ,
UNIT_FLAG2_DISARM_OFFHAND = 0x00000080 ,
UNIT_FLAG2_DISABLE_PRED_STATS = 0x00000100 , // Player has disabled predicted stats (Used by raid frames)
UNIT_FLAG2_DISARM_RANGED = 0x00000400 , // this does not disable ranged weapon display (maybe additional flag needed?)
UNIT_FLAG2_REGENERATE_POWER = 0x00000800 ,
UNIT_FLAG2_RESTRICT_PARTY_INTERACTION = 0x00001000 , // Restrict interaction to party or raid
UNIT_FLAG2_PREVENT_SPELL_CLICK = 0x00002000 , // Prevent spellclick
UNIT_FLAG2_ALLOW_ENEMY_INTERACT = 0x00004000 ,
UNIT_FLAG2_DISABLE_TURN = 0x00008000 ,
UNIT_FLAG2_UNK2 = 0x00010000 ,
UNIT_FLAG2_PLAY_DEATH_ANIM = 0x00020000 , // Plays special death animation upon death
2012-09-10 13:03:38 +02:00
UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000 // Allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
/// Non Player Character flags
2015-01-17 17:58:49 +01:00
enum NPCFlags : uint32
2009-04-07 00:23:37 +02:00
{
UNIT_NPC_FLAG_NONE = 0x00000000 ,
UNIT_NPC_FLAG_GOSSIP = 0x00000001 , // 100%
2011-12-22 04:34:26 +00:00
UNIT_NPC_FLAG_QUESTGIVER = 0x00000002 , // 100%
2009-04-07 00:23:37 +02:00
UNIT_NPC_FLAG_UNK1 = 0x00000004 ,
UNIT_NPC_FLAG_UNK2 = 0x00000008 ,
UNIT_NPC_FLAG_TRAINER = 0x00000010 , // 100%
UNIT_NPC_FLAG_TRAINER_CLASS = 0x00000020 , // 100%
UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x00000040 , // 100%
UNIT_NPC_FLAG_VENDOR = 0x00000080 , // 100%
UNIT_NPC_FLAG_VENDOR_AMMO = 0x00000100 , // 100%, general goods vendor
UNIT_NPC_FLAG_VENDOR_FOOD = 0x00000200 , // 100%
UNIT_NPC_FLAG_VENDOR_POISON = 0x00000400 , // guessed
UNIT_NPC_FLAG_VENDOR_REAGENT = 0x00000800 , // 100%
UNIT_NPC_FLAG_REPAIR = 0x00001000 , // 100%
UNIT_NPC_FLAG_FLIGHTMASTER = 0x00002000 , // 100%
UNIT_NPC_FLAG_SPIRITHEALER = 0x00004000 , // guessed
UNIT_NPC_FLAG_SPIRITGUIDE = 0x00008000 , // guessed
UNIT_NPC_FLAG_INNKEEPER = 0x00010000 , // 100%
UNIT_NPC_FLAG_BANKER = 0x00020000 , // 100%
UNIT_NPC_FLAG_PETITIONER = 0x00040000 , // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions
UNIT_NPC_FLAG_TABARDDESIGNER = 0x00080000 , // 100%
UNIT_NPC_FLAG_BATTLEMASTER = 0x00100000 , // 100%
UNIT_NPC_FLAG_AUCTIONEER = 0x00200000 , // 100%
UNIT_NPC_FLAG_STABLEMASTER = 0x00400000 , // 100%
UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000 , // cause client to send 997 opcode
2011-03-06 11:12:19 +01:00
UNIT_NPC_FLAG_SPELLCLICK = 0x01000000 , // cause client to send 1015 opcode (spell click)
2012-09-11 01:31:55 +01:00
UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x02000000 , // players with mounts that have vehicle data should have it set
2014-01-19 20:52:16 +01:00
UNIT_NPC_FLAG_MAILBOX = 0x04000000 , // mailbox
2012-07-30 16:39:46 +01:00
UNIT_NPC_FLAG_REFORGER = 0x08000000 , // reforging
2012-08-01 02:46:32 +01:00
UNIT_NPC_FLAG_TRANSMOGRIFIER = 0x10000000 , // transmogrification
2015-01-16 23:16:33 +00:00
UNIT_NPC_FLAG_VAULTKEEPER = 0x20000000 , // void storage
UNIT_NPC_FLAG_BLACK_MARKET = 0x80000000 // black market
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum MovementFlags
{
2010-08-04 14:39:45 +02:00
MOVEMENTFLAG_NONE = 0x00000000 ,
MOVEMENTFLAG_FORWARD = 0x00000001 ,
MOVEMENTFLAG_BACKWARD = 0x00000002 ,
MOVEMENTFLAG_STRAFE_LEFT = 0x00000004 ,
MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008 ,
MOVEMENTFLAG_LEFT = 0x00000010 ,
MOVEMENTFLAG_RIGHT = 0x00000020 ,
MOVEMENTFLAG_PITCH_UP = 0x00000040 ,
MOVEMENTFLAG_PITCH_DOWN = 0x00000080 ,
MOVEMENTFLAG_WALKING = 0x00000100 , // Walking
2012-07-14 23:39:12 +02:00
MOVEMENTFLAG_DISABLE_GRAVITY = 0x00000200 , // Former MOVEMENTFLAG_LEVITATING. This is used when walking is not possible.
MOVEMENTFLAG_ROOT = 0x00000400 , // Must not be set along with MOVEMENTFLAG_MASK_MOVING
MOVEMENTFLAG_FALLING = 0x00000800 , // damage dealt on that type of falling
MOVEMENTFLAG_FALLING_FAR = 0x00001000 ,
MOVEMENTFLAG_PENDING_STOP = 0x00002000 ,
MOVEMENTFLAG_PENDING_STRAFE_STOP = 0x00004000 ,
MOVEMENTFLAG_PENDING_FORWARD = 0x00008000 ,
MOVEMENTFLAG_PENDING_BACKWARD = 0x00010000 ,
MOVEMENTFLAG_PENDING_STRAFE_LEFT = 0x00020000 ,
MOVEMENTFLAG_PENDING_STRAFE_RIGHT = 0x00040000 ,
MOVEMENTFLAG_PENDING_ROOT = 0x00080000 ,
MOVEMENTFLAG_SWIMMING = 0x00100000 , // appears with fly flag also
MOVEMENTFLAG_ASCENDING = 0x00200000 , // press "space" when flying
MOVEMENTFLAG_DESCENDING = 0x00400000 ,
MOVEMENTFLAG_CAN_FLY = 0x00800000 , // Appears when unit can fly AND also walk
MOVEMENTFLAG_FLYING = 0x01000000 , // unit is actually flying. pretty sure this is only used for players. creatures use disable_gravity
MOVEMENTFLAG_SPLINE_ELEVATION = 0x02000000 , // used for flight paths
MOVEMENTFLAG_WATERWALKING = 0x04000000 , // prevent unit from falling through water
MOVEMENTFLAG_FALLING_SLOW = 0x08000000 , // active rogue safe fall spell (passive)
MOVEMENTFLAG_HOVER = 0x10000000 , // hover, cannot jump
2013-06-23 00:07:25 +02:00
MOVEMENTFLAG_DISABLE_COLLISION = 0x20000000 ,
2009-10-17 15:51:44 -07:00
2013-03-08 21:41:30 +01:00
/// @todo Check if PITCH_UP and PITCH_DOWN really belong here..
2011-07-19 20:37:17 +02:00
MOVEMENTFLAG_MASK_MOVING =
MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_BACKWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT |
2012-05-30 08:01:02 +02:00
MOVEMENTFLAG_PITCH_UP | MOVEMENTFLAG_PITCH_DOWN | MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING |
2011-07-19 20:37:17 +02:00
MOVEMENTFLAG_SPLINE_ELEVATION ,
MOVEMENTFLAG_MASK_TURNING =
2009-10-17 16:20:24 -07:00
MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT ,
2012-05-30 08:01:02 +02:00
MOVEMENTFLAG_MASK_MOVING_FLY =
MOVEMENTFLAG_FLYING | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING ,
2012-08-10 14:10:57 +02:00
// Movement flags allowed for creature in CreateObject - we need to keep all other enabled serverside
// to properly calculate all movement
MOVEMENTFLAG_MASK_CREATURE_ALLOWED =
MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_ROOT | MOVEMENTFLAG_SWIMMING |
MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_WATERWALKING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_HOVER ,
2013-03-08 21:41:30 +01:00
/// @todo if needed: add more flags to this masks that are exclusive to players
2012-05-30 08:01:02 +02:00
MOVEMENTFLAG_MASK_PLAYER_ONLY =
2013-07-13 15:26:10 +02:00
MOVEMENTFLAG_FLYING ,
/// Movement flags that have change status opcodes associated for players
MOVEMENTFLAG_MASK_HAS_PLAYER_STATUS_OPCODE = MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_ROOT |
MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_WATERWALKING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_HOVER
2009-04-07 00:23:37 +02:00
};
2013-07-13 15:26:10 +02:00
2010-08-04 14:39:45 +02:00
enum MovementFlags2
{
MOVEMENTFLAG2_NONE = 0x00000000 ,
2010-09-28 08:21:51 +03:00
MOVEMENTFLAG2_NO_STRAFE = 0x00000001 ,
MOVEMENTFLAG2_NO_JUMPING = 0x00000002 ,
2012-08-07 13:27:33 +02:00
MOVEMENTFLAG2_FULL_SPEED_TURNING = 0x00000004 ,
MOVEMENTFLAG2_FULL_SPEED_PITCHING = 0x00000008 ,
MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING = 0x00000010 ,
2013-04-01 14:45:47 +02:00
MOVEMENTFLAG2_UNK5 = 0x00000020 ,
MOVEMENTFLAG2_UNK6 = 0x00000040 ,
MOVEMENTFLAG2_UNK7 = 0x00000080 ,
MOVEMENTFLAG2_UNK8 = 0x00000100 ,
MOVEMENTFLAG2_UNK9 = 0x00000200 ,
2013-08-23 18:27:42 +02:00
MOVEMENTFLAG2_CAN_SWIM_TO_FLY_TRANS = 0x00000400 ,
2013-04-01 14:45:47 +02:00
MOVEMENTFLAG2_UNK11 = 0x00000800 ,
MOVEMENTFLAG2_UNK12 = 0x00001000 ,
MOVEMENTFLAG2_INTERPOLATED_MOVEMENT = 0x00002000 ,
MOVEMENTFLAG2_INTERPOLATED_TURNING = 0x00004000 ,
MOVEMENTFLAG2_INTERPOLATED_PITCHING = 0x00008000
2010-08-04 14:39:45 +02:00
};
2012-01-14 15:34:41 +01:00
2009-08-23 22:09:43 -05:00
enum UnitTypeMask
{
UNIT_MASK_NONE = 0x00000000 ,
UNIT_MASK_SUMMON = 0x00000001 ,
UNIT_MASK_MINION = 0x00000002 ,
UNIT_MASK_GUARDIAN = 0x00000004 ,
UNIT_MASK_TOTEM = 0x00000008 ,
UNIT_MASK_PET = 0x00000010 ,
UNIT_MASK_VEHICLE = 0x00000020 ,
UNIT_MASK_PUPPET = 0x00000040 ,
UNIT_MASK_HUNTER_PET = 0x00000080 ,
UNIT_MASK_CONTROLABLE_GUARDIAN = 0x00000100 ,
2012-09-10 13:03:38 +02:00
UNIT_MASK_ACCESSORY = 0x00000200
2009-08-23 22:09:43 -05:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
struct DiminishingReturn
{
DiminishingReturn ( DiminishingGroup group , uint32 t , uint32 count )
: DRGroup ( group ), stack ( 0 ), hitTime ( t ), hitCount ( count )
2013-10-27 22:27:46 +01:00
{ }
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
DiminishingGroup DRGroup : 16 ;
uint16 stack : 16 ;
uint32 hitTime ;
uint32 hitCount ;
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum MeleeHitOutcome
{
MELEE_HIT_EVADE , MELEE_HIT_MISS , MELEE_HIT_DODGE , MELEE_HIT_BLOCK , MELEE_HIT_PARRY ,
MELEE_HIT_GLANCING , MELEE_HIT_CRIT , MELEE_HIT_CRUSHING , MELEE_HIT_NORMAL
};
2009-10-17 15:51:44 -07:00
2012-02-04 13:32:40 +01:00
class DispelInfo
{
public :
2012-10-06 22:47:52 +02:00
explicit DispelInfo ( Unit * dispeller , uint32 dispellerSpellId , uint8 chargesRemoved ) :
2013-10-27 22:27:46 +01:00
_dispellerUnit ( dispeller ), _dispellerSpell ( dispellerSpellId ), _chargesRemoved ( chargesRemoved ) { }
2012-02-04 13:32:40 +01:00
2012-10-06 22:47:52 +02:00
Unit * GetDispeller () const { return _dispellerUnit ; }
uint32 GetDispellerSpellId () const { return _dispellerSpell ; }
uint8 GetRemovedCharges () const { return _chargesRemoved ; }
2012-02-04 13:32:40 +01:00
void SetRemovedCharges ( uint8 amount )
{
2012-10-06 22:47:52 +02:00
_chargesRemoved = amount ;
2012-02-04 13:32:40 +01:00
}
2012-10-06 22:47:52 +02:00
private :
Unit * _dispellerUnit ;
uint32 _dispellerSpell ;
uint8 _chargesRemoved ;
2012-02-04 13:32:40 +01:00
};
2009-04-07 00:23:37 +02:00
struct CleanDamage
{
2009-07-27 18:05:30 +02:00
CleanDamage ( uint32 mitigated , uint32 absorbed , WeaponAttackType _attackType , MeleeHitOutcome _hitOutCome ) :
2013-10-27 22:27:46 +01:00
absorbed_damage ( absorbed ), mitigated_damage ( mitigated ), attackType ( _attackType ), hitOutCome ( _hitOutCome ) { }
2009-10-17 15:51:44 -07:00
2009-07-27 18:05:30 +02:00
uint32 absorbed_damage ;
uint32 mitigated_damage ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
WeaponAttackType attackType ;
MeleeHitOutcome hitOutCome ;
};
2009-10-17 15:51:44 -07:00
2011-07-10 13:13:02 +02:00
struct CalcDamageInfo ;
2010-12-27 20:14:54 +01:00
class DamageInfo
{
private :
2011-06-11 22:35:29 +02:00
Unit * const m_attacker ;
Unit * const m_victim ;
2010-12-27 22:58:22 +01:00
uint32 m_damage ;
2011-07-26 23:09:28 +02:00
SpellInfo const * const m_spellInfo ;
2010-12-27 20:14:54 +01:00
SpellSchoolMask const m_schoolMask ;
2010-12-27 22:58:22 +01:00
DamageEffectType const m_damageType ;
2011-07-10 13:13:02 +02:00
WeaponAttackType m_attackType ;
2010-12-27 20:14:54 +01:00
uint32 m_absorb ;
uint32 m_resist ;
uint32 m_block ;
public :
2011-07-26 23:09:28 +02:00
explicit DamageInfo ( Unit * _attacker , Unit * _victim , uint32 _damage , SpellInfo const * _spellInfo , SpellSchoolMask _schoolMask , DamageEffectType _damageType );
2011-07-10 13:13:02 +02:00
explicit DamageInfo ( CalcDamageInfo & dmgInfo );
void ModifyDamage ( int32 amount );
void AbsorbDamage ( uint32 amount );
void ResistDamage ( uint32 amount );
void BlockDamage ( uint32 amount );
2013-03-20 14:18:26 +01:00
Unit * GetAttacker () const { return m_attacker ; }
Unit * GetVictim () const { return m_victim ; }
SpellInfo const * GetSpellInfo () const { return m_spellInfo ; }
SpellSchoolMask GetSchoolMask () const { return m_schoolMask ; }
DamageEffectType GetDamageType () const { return m_damageType ; }
WeaponAttackType GetAttackType () const { return m_attackType ; }
uint32 GetDamage () const { return m_damage ; }
uint32 GetAbsorb () const { return m_absorb ; }
uint32 GetResist () const { return m_resist ; }
uint32 GetBlock () const { return m_block ; }
2010-12-27 20:14:54 +01:00
};
2011-07-10 13:13:02 +02:00
class HealInfo
{
private :
uint32 m_heal ;
uint32 m_absorb ;
public :
2013-08-27 21:30:33 +01:00
explicit HealInfo ( uint32 heal )
: m_heal ( heal )
2011-07-10 13:13:02 +02:00
{
m_absorb = 0 ;
}
void AbsorbHeal ( uint32 amount )
{
amount = std :: min ( amount , GetHeal ());
m_absorb += amount ;
m_heal -= amount ;
}
2013-03-20 14:18:26 +01:00
uint32 GetHeal () const { return m_heal ; }
2011-07-10 13:13:02 +02:00
};
class ProcEventInfo
{
public :
2013-03-20 14:18:26 +01:00
ProcEventInfo ( Unit * actor , Unit * actionTarget , Unit * procTarget , uint32 typeMask ,
uint32 spellTypeMask , uint32 spellPhaseMask , uint32 hitMask ,
Spell * spell , DamageInfo * damageInfo , HealInfo * healInfo );
Unit * GetActor () { return _actor ; }
2011-07-10 13:13:02 +02:00
Unit * GetActionTarget () const { return _actionTarget ; }
Unit * GetProcTarget () const { return _procTarget ; }
2013-03-20 14:18:26 +01:00
2011-07-10 13:13:02 +02:00
uint32 GetTypeMask () const { return _typeMask ; }
uint32 GetSpellTypeMask () const { return _spellTypeMask ; }
uint32 GetSpellPhaseMask () const { return _spellPhaseMask ; }
uint32 GetHitMask () const { return _hitMask ; }
2013-03-20 14:18:26 +01:00
2015-01-26 23:33:51 +01:00
SpellInfo const * GetSpellInfo () const ;
SpellSchoolMask GetSchoolMask () const ;
2013-03-20 14:18:26 +01:00
2011-07-10 13:13:02 +02:00
DamageInfo * GetDamageInfo () const { return _damageInfo ; }
HealInfo * GetHealInfo () const { return _healInfo ; }
2013-03-20 14:18:26 +01:00
private :
Unit * const _actor ;
Unit * const _actionTarget ;
Unit * const _procTarget ;
uint32 _typeMask ;
uint32 _spellTypeMask ;
uint32 _spellPhaseMask ;
uint32 _hitMask ;
Spell * _spell ;
DamageInfo * _damageInfo ;
HealInfo * _healInfo ;
2011-07-10 13:13:02 +02:00
};
2009-04-07 00:23:37 +02:00
// Struct for use in Unit::CalculateMeleeDamage
// Need create structure like in SMSG_ATTACKERSTATEUPDATE opcode
struct CalcDamageInfo
{
Unit * attacker ; // Attacker
Unit * target ; // Target for damage
uint32 damageSchoolMask ;
uint32 damage ;
uint32 absorb ;
uint32 resist ;
uint32 blocked_amount ;
uint32 HitInfo ;
uint32 TargetState ;
// Helper
WeaponAttackType attackType ; //
uint32 procAttacker ;
uint32 procVictim ;
uint32 procEx ;
2009-05-31 15:56:51 -05:00
uint32 cleanDamage ; // Used only for rage calculation
2013-03-08 21:41:30 +01:00
MeleeHitOutcome hitOutCome ; /// @todo remove this field (need use TargetState)
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// Spell damage info structure based on structure sending in SMSG_SPELLNONMELEEDAMAGELOG opcode
2013-08-14 15:45:36 +02:00
struct SpellNonMeleeDamage
{
2011-09-15 14:08:17 +02:00
SpellNonMeleeDamage ( Unit * _attacker , Unit * _target , uint32 _SpellID , uint32 _schoolMask )
2009-05-08 19:01:40 -05:00
: target ( _target ), attacker ( _attacker ), SpellID ( _SpellID ), damage ( 0 ), overkill ( 0 ), schoolMask ( _schoolMask ),
absorb ( 0 ), resist ( 0 ), physicalLog ( false ), unused ( false ), blocked ( 0 ), HitInfo ( 0 ), cleanDamage ( 0 )
2013-10-27 22:27:46 +01:00
{ }
2009-10-17 15:51:44 -07:00
2009-05-08 19:01:40 -05:00
Unit * target ;
Unit * attacker ;
uint32 SpellID ;
uint32 damage ;
uint32 overkill ;
uint32 schoolMask ;
uint32 absorb ;
uint32 resist ;
bool physicalLog ;
bool unused ;
uint32 blocked ;
uint32 HitInfo ;
// Used for help
uint32 cleanDamage ;
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
struct SpellPeriodicAuraLogInfo
{
2011-09-15 14:08:17 +02:00
SpellPeriodicAuraLogInfo ( AuraEffect const * _auraEff , uint32 _damage , uint32 _overDamage , uint32 _absorb , uint32 _resist , float _multiplier , bool _critical )
2013-10-27 22:27:46 +01:00
: auraEff ( _auraEff ), damage ( _damage ), overDamage ( _overDamage ), absorb ( _absorb ), resist ( _resist ), multiplier ( _multiplier ), critical ( _critical ){ }
2009-10-17 15:51:44 -07:00
2011-06-11 22:35:29 +02:00
AuraEffect const * auraEff ;
2009-05-31 15:56:51 -05:00
uint32 damage ;
2009-09-18 14:10:37 -07:00
uint32 overDamage ; // overkill/overheal
2009-05-31 15:56:51 -05:00
uint32 absorb ;
uint32 resist ;
float multiplier ;
2009-06-25 17:55:19 +02:00
bool critical ;
2009-05-31 15:56:51 -05:00
};
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
uint32 createProcExtendMask ( SpellNonMeleeDamage * damageInfo , SpellMissInfo missCondition );
2009-10-17 15:51:44 -07:00
2013-01-22 00:20:16 +01:00
struct RedirectThreatInfo
{
2014-09-14 16:14:12 +02:00
RedirectThreatInfo () : _threatPct ( 0 ) { }
ObjectGuid _targetGUID ;
2013-01-22 00:20:16 +01:00
uint32 _threatPct ;
2014-09-14 16:14:12 +02:00
ObjectGuid GetTargetGUID () const { return _targetGUID ; }
2013-03-04 09:38:38 +01:00
uint32 GetThreatPct () const { return _threatPct ; }
2013-01-22 00:20:16 +01:00
2014-09-14 16:14:12 +02:00
void Set ( ObjectGuid guid , uint32 pct )
2013-01-22 00:20:16 +01:00
{
_targetGUID = guid ;
_threatPct = pct ;
}
void ModifyThreatPct ( int32 amount )
{
amount += _threatPct ;
_threatPct = uint32 ( std :: max ( 0 , amount ));
}
};
2009-04-07 00:23:37 +02:00
#define MAX_DECLINED_NAME_CASES 5
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
struct DeclinedName
{
std :: string name [ MAX_DECLINED_NAME_CASES ];
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum CurrentSpellTypes
{
2009-08-19 16:52:51 -05:00
CURRENT_MELEE_SPELL = 0 ,
CURRENT_GENERIC_SPELL = 1 ,
2011-11-05 05:21:37 +07:00
CURRENT_CHANNELED_SPELL = 2 ,
CURRENT_AUTOREPEAT_SPELL = 3
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-08-19 16:52:51 -05:00
#define CURRENT_FIRST_NON_MELEE_SPELL 1
#define CURRENT_MAX_SPELL 4
2009-04-07 00:23:37 +02:00
enum ActiveStates
{
2009-07-01 18:07:20 -05:00
ACT_PASSIVE = 0x01 , // 0x01 - passive
ACT_DISABLED = 0x81 , // 0x80 - castable
ACT_ENABLED = 0xC1 , // 0x40 | 0x80 - auto cast + castable
ACT_COMMAND = 0x07 , // 0x01 | 0x02 | 0x04
ACT_REACTION = 0x06 , // 0x02 | 0x04
ACT_DECIDE = 0x00 // custom
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum ReactStates
{
REACT_PASSIVE = 0 ,
REACT_DEFENSIVE = 1 ,
REACT_AGGRESSIVE = 2
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum CommandStates
{
COMMAND_STAY = 0 ,
COMMAND_FOLLOW = 1 ,
COMMAND_ATTACK = 2 ,
2012-09-09 16:35:22 -05:00
COMMAND_ABANDON = 3 ,
COMMAND_MOVE_TO = 4
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-07-01 18:07:20 -05:00
#define UNIT_ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
#define UNIT_ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
2011-04-29 20:47:02 +02:00
#define MAKE_UNIT_ACTION_BUTTON(A, T) (uint32(A) | (uint32(T) << 24))
2009-10-17 15:51:44 -07:00
2009-05-27 17:02:39 -05:00
struct UnitActionBarEntry
{
2013-10-27 22:27:46 +01:00
UnitActionBarEntry () : packedData ( uint32 ( ACT_DISABLED ) << 24 ) { }
2009-10-17 15:51:44 -07:00
2009-07-01 18:07:20 -05:00
uint32 packedData ;
2009-10-17 15:51:44 -07:00
2009-05-27 17:02:39 -05:00
// helper
2009-07-01 18:07:20 -05:00
ActiveStates GetType () const { return ActiveStates ( UNIT_ACTION_BUTTON_TYPE ( packedData )); }
uint32 GetAction () const { return UNIT_ACTION_BUTTON_ACTION ( packedData ); }
2009-05-27 17:02:39 -05:00
bool IsActionBarForSpell () const
{
2009-07-01 18:07:20 -05:00
ActiveStates Type = GetType ();
2009-05-27 17:02:39 -05:00
return Type == ACT_DISABLED || Type == ACT_ENABLED || Type == ACT_PASSIVE ;
}
2009-10-17 15:51:44 -07:00
2009-07-01 18:07:20 -05:00
void SetActionAndType ( uint32 action , ActiveStates type )
{
2011-04-29 20:47:02 +02:00
packedData = MAKE_UNIT_ACTION_BUTTON ( action , type );
2009-07-01 18:07:20 -05:00
}
2009-10-17 15:51:44 -07:00
2009-07-01 18:07:20 -05:00
void SetType ( ActiveStates type )
{
2011-04-29 20:47:02 +02:00
packedData = MAKE_UNIT_ACTION_BUTTON ( UNIT_ACTION_BUTTON_ACTION ( packedData ), type );
2009-07-01 18:07:20 -05:00
}
2009-10-17 15:51:44 -07:00
2009-07-01 18:07:20 -05:00
void SetAction ( uint32 action )
{
packedData = ( packedData & 0xFF000000 ) | UNIT_ACTION_BUTTON_ACTION ( action );
}
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
typedef std :: list < Player *> SharedVisionList ;
2009-10-17 15:51:44 -07:00
2009-06-03 13:51:05 -05:00
enum CharmType
{
CHARM_TYPE_CHARM ,
CHARM_TYPE_POSSESS ,
CHARM_TYPE_VEHICLE ,
2012-09-10 13:03:38 +02:00
CHARM_TYPE_CONVERT
2009-06-03 13:51:05 -05:00
};
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
typedef UnitActionBarEntry CharmSpellInfo ;
2009-10-17 15:51:44 -07:00
2009-06-01 21:49:42 -05:00
enum ActionBarIndex
{
ACTION_BAR_INDEX_START = 0 ,
ACTION_BAR_INDEX_PET_SPELL_START = 3 ,
ACTION_BAR_INDEX_PET_SPELL_END = 7 ,
2012-09-10 13:03:38 +02:00
ACTION_BAR_INDEX_END = 10
2009-06-01 21:49:42 -05:00
};
2009-10-17 15:51:44 -07:00
2009-06-01 21:49:42 -05:00
#define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START)
2009-10-17 15:51:44 -07:00
2009-05-27 17:02:39 -05:00
struct CharmInfo
2009-04-07 00:23:37 +02:00
{
public :
explicit CharmInfo ( Unit * unit );
~ CharmInfo ();
2011-02-04 02:51:12 +01:00
void RestoreState ();
2012-12-06 09:58:32 -05:00
uint32 GetPetNumber () const { return _petnumber ; }
2009-04-07 00:23:37 +02:00
void SetPetNumber ( uint32 petnumber , bool statwindow );
2009-10-17 15:51:44 -07:00
2012-12-06 09:58:32 -05:00
void SetCommandState ( CommandStates st ) { _CommandState = st ; }
CommandStates GetCommandState () const { return _CommandState ; }
bool HasCommandState ( CommandStates state ) const { return ( _CommandState == state ); }
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void InitPossessCreateSpells ();
void InitCharmCreateSpells ();
void InitPetActionBar ();
void InitEmptyActionBar ( bool withAttack = true );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
//return true if successful
2011-07-26 23:09:28 +02:00
bool AddSpellToActionBar ( SpellInfo const * spellInfo , ActiveStates newstate = ACT_DECIDE );
2009-05-27 17:02:39 -05:00
bool RemoveSpellFromActionBar ( uint32 spell_id );
2009-06-14 10:07:34 -05:00
void LoadPetActionBar ( const std :: string & data );
2009-05-27 17:02:39 -05:00
void BuildActionBar ( WorldPacket * data );
2011-07-26 23:09:28 +02:00
void SetSpellAutocast ( SpellInfo const * spellInfo , bool state );
2011-04-29 20:47:02 +02:00
void SetActionBar ( uint8 index , uint32 spellOrAction , ActiveStates type )
2009-05-27 17:02:39 -05:00
{
2011-04-29 20:47:02 +02:00
PetActionBar [ index ]. SetActionAndType ( spellOrAction , type );
2009-05-27 17:02:39 -05:00
}
UnitActionBarEntry const * GetActionBarEntry ( uint8 index ) const { return & ( PetActionBar [ index ]); }
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
void ToggleCreatureAutocast ( SpellInfo const * spellInfo , bool apply );
2009-10-17 15:51:44 -07:00
2012-12-06 09:58:32 -05:00
CharmSpellInfo * GetCharmSpell ( uint8 index ) { return & ( _charmspells [ index ]); }
2009-10-17 15:51:44 -07:00
2009-09-10 09:59:16 -07:00
void SetIsCommandAttack ( bool val );
bool IsCommandAttack ();
2012-12-06 09:58:32 -05:00
void SetIsCommandFollow ( bool val );
bool IsCommandFollow ();
2009-09-10 09:59:16 -07:00
void SetIsAtStay ( bool val );
bool IsAtStay ();
void SetIsFollowing ( bool val );
bool IsFollowing ();
void SetIsReturning ( bool val );
bool IsReturning ();
void SaveStayPosition ();
void GetStayPosition ( float & x , float & y , float & z );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
private :
2009-10-17 15:51:44 -07:00
2012-12-06 09:58:32 -05:00
Unit * _unit ;
2009-05-27 17:02:39 -05:00
UnitActionBarEntry PetActionBar [ MAX_UNIT_ACTION_BAR_INDEX ];
2012-12-06 09:58:32 -05:00
CharmSpellInfo _charmspells [ 4 ];
CommandStates _CommandState ;
uint32 _petnumber ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
//for restoration after charmed
2012-12-06 09:58:32 -05:00
ReactStates _oldReactState ;
bool _isCommandAttack ;
bool _isCommandFollow ;
bool _isAtStay ;
bool _isFollowing ;
bool _isReturning ;
float _stayX ;
float _stayY ;
float _stayZ ;
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// for clearing special attacks
#define REACTIVE_TIMER_START 4000
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
enum ReactiveType
{
REACTIVE_DEFENSE = 0 ,
REACTIVE_HUNTER_PARRY = 1 ,
REACTIVE_OVERPOWER = 2
};
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
#define MAX_REACTIVE 3
#define SUMMON_SLOT_PET 0
#define SUMMON_SLOT_TOTEM 1
#define MAX_TOTEM_SLOT 5
#define SUMMON_SLOT_MINIPET 5
#define SUMMON_SLOT_QUEST 6
#define MAX_SUMMON_SLOT 7
2009-10-17 15:51:44 -07:00
2011-10-31 10:46:39 -04:00
#define MAX_GAMEOBJECT_SLOT 4
2010-07-22 17:31:27 +02:00
enum PlayerTotemType
{
SUMMON_TYPE_TOTEM_FIRE = 63 ,
SUMMON_TYPE_TOTEM_EARTH = 81 ,
SUMMON_TYPE_TOTEM_WATER = 82 ,
2012-09-10 13:03:38 +02:00
SUMMON_TYPE_TOTEM_AIR = 83
2010-07-22 17:31:27 +02:00
};
2009-04-07 00:23:37 +02:00
// delay time next attack to prevent client attack animation problems
#define ATTACK_DISPLAY_DELAY 200
2010-11-13 17:18:09 +01:00
#define MAX_PLAYER_STEALTH_DETECT_RANGE 30.0f // max distance for detection targets by player
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
struct SpellProcEventEntry ; // used only privately
2009-10-17 15:51:44 -07:00
2010-02-05 00:31:28 +01:00
class Unit : public WorldObject
2009-04-07 00:23:37 +02:00
{
public :
typedef std :: set < Unit *> AttackerSet ;
typedef std :: set < Unit *> ControlList ;
2013-01-02 09:53:43 +01:00
2014-09-14 16:14:12 +02:00
typedef std :: multimap < uint32 , Aura *> AuraMap ;
2013-01-02 09:53:43 +01:00
typedef std :: pair < AuraMap :: const_iterator , AuraMap :: const_iterator > AuraMapBounds ;
typedef std :: pair < AuraMap :: iterator , AuraMap :: iterator > AuraMapBoundsNonConst ;
2010-01-10 01:23:15 +01:00
typedef std :: multimap < uint32 , AuraApplication *> AuraApplicationMap ;
2013-01-02 09:53:43 +01:00
typedef std :: pair < AuraApplicationMap :: const_iterator , AuraApplicationMap :: const_iterator > AuraApplicationMapBounds ;
typedef std :: pair < AuraApplicationMap :: iterator , AuraApplicationMap :: iterator > AuraApplicationMapBoundsNonConst ;
2011-07-26 23:09:28 +02:00
typedef std :: multimap < AuraStateType , AuraApplication *> AuraStateAurasMap ;
2013-01-02 09:53:43 +01:00
typedef std :: pair < AuraStateAurasMap :: const_iterator , AuraStateAurasMap :: const_iterator > AuraStateAurasMapBounds ;
2011-09-15 14:08:17 +02:00
typedef std :: list < AuraEffect *> AuraEffectList ;
typedef std :: list < Aura *> AuraList ;
2010-01-10 01:23:15 +01:00
typedef std :: list < AuraApplication *> AuraApplicationList ;
2009-04-07 00:23:37 +02:00
typedef std :: list < DiminishingReturn > Diminishing ;
2009-10-17 15:51:44 -07:00
2010-01-10 01:23:15 +01:00
typedef std :: map < uint8 , AuraApplication *> VisibleAuraMap ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
virtual ~ Unit ();
2009-10-17 15:51:44 -07:00
2010-10-25 11:12:47 +02:00
UnitAI * GetAI () { return i_AI ; }
void SetAI ( UnitAI * newAI ) { i_AI = newAI ; }
2014-08-09 20:17:40 +01:00
void AddToWorld () override ;
void RemoveFromWorld () override ;
2009-10-17 15:51:44 -07:00
2011-10-10 17:59:52 -04:00
void CleanupBeforeRemoveFromMap ( bool finalCleanup );
2014-06-13 11:16:17 +02:00
void CleanupsBeforeDelete ( bool finalCleanup = true ) override ; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
DiminishingLevels GetDiminishing ( DiminishingGroup group );
void IncrDiminishing ( DiminishingGroup group );
2011-04-29 20:47:02 +02:00
float ApplyDiminishingToDuration ( DiminishingGroup group , int32 & duration , Unit * caster , DiminishingLevels Level , int32 limitduration );
2009-04-07 00:23:37 +02:00
void ApplyDiminishingAura ( DiminishingGroup group , bool apply );
void ClearDiminishings () { m_Diminishing . clear (); }
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
// target dependent range checks
2011-09-24 19:40:57 +02:00
float GetSpellMaxRangeForTarget ( Unit const * target , SpellInfo const * spellInfo ) const ;
float GetSpellMinRangeForTarget ( Unit const * target , SpellInfo const * spellInfo ) const ;
2009-10-17 15:51:44 -07:00
2014-08-09 20:17:40 +01:00
virtual void Update ( uint32 time ) override ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void setAttackTimer ( WeaponAttackType type , uint32 time ) { m_attackTimer [ type ] = time ; }
void resetAttackTimer ( WeaponAttackType type = BASE_ATTACK );
uint32 getAttackTimer ( WeaponAttackType type ) const { return m_attackTimer [ type ]; }
bool isAttackReady ( WeaponAttackType type = BASE_ATTACK ) const { return m_attackTimer [ type ] == 0 ; }
bool haveOffhandWeapon () const ;
bool CanDualWield () const { return m_canDualWield ; }
2014-01-04 18:22:06 +01:00
virtual void SetCanDualWield ( bool value ) { m_canDualWield = value ; }
2009-04-07 00:23:37 +02:00
float GetCombatReach () const { return m_floatValues [ UNIT_FIELD_COMBATREACH ]; }
2013-03-04 09:38:38 +01:00
float GetMeleeReach () const ;
2011-09-15 14:08:17 +02:00
bool IsWithinCombatRange ( const Unit * obj , float dist2compare ) const ;
bool IsWithinMeleeRange ( const Unit * obj , float dist = MELEE_RANGE ) const ;
2010-04-07 22:59:46 +02:00
void GetRandomContactPoint ( const Unit * target , float & x , float & y , float & z , float distance2dMin , float distance2dMax ) const ;
2009-04-07 00:23:37 +02:00
uint32 m_extraAttacks ;
bool m_canDualWield ;
2009-10-17 15:51:44 -07:00
2013-03-04 09:38:38 +01:00
void _addAttacker ( Unit * pAttacker ); // must be called only from Unit::Attack(Unit*)
void _removeAttacker ( Unit * pAttacker ); // must be called only from Unit::AttackStop()
Unit * getAttackerForHelper () const ; // If someone wants to help, who to give them
2011-06-12 02:00:43 +02:00
bool Attack ( Unit * victim , bool meleeAttack );
2009-04-07 00:23:37 +02:00
void CastStop ( uint32 except_spellid = 0 );
bool AttackStop ();
void RemoveAllAttackers ();
AttackerSet const & getAttackers () const { return m_attackers ; }
bool isAttackingPlayer () const ;
2013-06-11 19:54:27 -02:30
Unit * GetVictim () const { return m_attacking ; }
2014-04-19 21:48:22 +02:00
// Use this only when 100% sure there is a victim
Unit * EnsureVictim () const
{
ASSERT ( m_attacking );
return m_attacking ;
}
2009-10-17 15:51:44 -07:00
2009-04-22 17:58:46 -05:00
void CombatStop ( bool includingCast = false );
void CombatStopWithPets ( bool includingCast = false );
2009-12-26 09:43:39 +01:00
void StopAttackFaction ( uint32 faction_id );
2012-02-04 21:18:30 -05:00
Unit * SelectNearbyTarget ( Unit * exclude = NULL , float dist = NOMINAL_MELEE_RANGE ) const ;
2011-11-13 02:36:51 +01:00
void SendMeleeAttackStop ( Unit * victim = NULL );
2012-05-30 08:01:02 +02:00
void SendMeleeAttackStart ( Unit * victim );
2009-10-17 15:51:44 -07:00
2010-12-17 13:43:24 +01:00
void AddUnitState ( uint32 f ) { m_state |= f ; }
2014-07-17 15:42:57 +02:00
bool HasUnitState ( const uint32 f ) const { return ( m_state & f ) != 0 ; }
2010-12-17 13:43:24 +01:00
void ClearUnitState ( uint32 f ) { m_state &= ~ f ; }
2013-03-04 09:38:38 +01:00
bool CanFreeMove () const ;
2009-10-17 15:51:44 -07:00
2009-08-23 22:09:43 -05:00
uint32 HasUnitTypeMask ( uint32 mask ) const { return mask & m_unitTypeMask ; }
void AddUnitTypeMask ( uint32 mask ) { m_unitTypeMask |= mask ; }
2014-07-17 15:42:57 +02:00
bool IsSummon () const { return ( m_unitTypeMask & UNIT_MASK_SUMMON ) != 0 ; }
bool IsGuardian () const { return ( m_unitTypeMask & UNIT_MASK_GUARDIAN ) != 0 ; }
bool IsPet () const { return ( m_unitTypeMask & UNIT_MASK_PET ) != 0 ; }
bool IsHunterPet () const { return ( m_unitTypeMask & UNIT_MASK_HUNTER_PET ) != 0 ; }
bool IsTotem () const { return ( m_unitTypeMask & UNIT_MASK_TOTEM ) != 0 ; }
bool IsVehicle () const { return ( m_unitTypeMask & UNIT_MASK_VEHICLE ) != 0 ; }
2009-10-17 15:51:44 -07:00
2009-11-01 20:50:31 -08:00
uint8 getLevel () const { return uint8 ( GetUInt32Value ( UNIT_FIELD_LEVEL )); }
2014-08-09 20:17:40 +01:00
uint8 getLevelForTarget ( WorldObject const * /*target*/ ) const override { return getLevel (); }
2009-11-01 17:53:07 -08:00
void SetLevel ( uint8 lvl );
2014-11-30 19:09:26 +01:00
uint8 getRace () const { return GetByteValue ( UNIT_FIELD_BYTES_0 , UNIT_BYTES_0_OFFSET_RACE ); }
2009-04-07 00:23:37 +02:00
uint32 getRaceMask () const { return 1 << ( getRace () - 1 ); }
2014-11-30 19:09:26 +01:00
uint8 getClass () const { return GetByteValue ( UNIT_FIELD_BYTES_0 , UNIT_BYTES_0_OFFSET_CLASS ); }
2009-04-07 00:23:37 +02:00
uint32 getClassMask () const { return 1 << ( getClass () - 1 ); }
2014-11-30 19:09:26 +01:00
uint8 getGender () const { return GetByteValue ( UNIT_FIELD_BYTES_0 , UNIT_BYTES_0_OFFSET_GENDER ); }
2009-10-17 15:51:44 -07:00
2014-10-26 22:06:48 +01:00
float GetStat ( Stats stat ) const { return float ( GetUInt32Value ( UNIT_FIELD_STAT + stat )); }
void SetStat ( Stats stat , int32 val ) { SetStatInt32Value ( UNIT_FIELD_STAT + stat , val ); }
2012-05-30 08:01:02 +02:00
uint32 GetArmor () const { return GetResistance ( SPELL_SCHOOL_NORMAL ); }
2009-04-07 00:23:37 +02:00
void SetArmor ( int32 val ) { SetResistance ( SPELL_SCHOOL_NORMAL , val ); }
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
uint32 GetResistance ( SpellSchools school ) const { return GetUInt32Value ( UNIT_FIELD_RESISTANCES + school ); }
2011-11-12 04:40:44 +07:00
uint32 GetResistance ( SpellSchoolMask mask ) const ;
2011-04-29 20:47:02 +02:00
void SetResistance ( SpellSchools school , int32 val ) { SetStatInt32Value ( UNIT_FIELD_RESISTANCES + school , val ); }
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
uint32 GetHealth () const { return GetUInt32Value ( UNIT_FIELD_HEALTH ); }
uint32 GetMaxHealth () const { return GetUInt32Value ( UNIT_FIELD_MAXHEALTH ); }
2010-08-26 01:20:57 +06:00
2011-05-11 12:08:08 +02:00
bool IsFullHealth () const { return GetHealth () == GetMaxHealth (); }
2012-06-17 00:50:21 +02:00
bool HealthBelowPct ( int32 pct ) const { return GetHealth () < CountPctFromMaxHealth ( pct ); }
bool HealthBelowPctDamaged ( int32 pct , uint32 damage ) const { return int64 ( GetHealth ()) - int64 ( damage ) < int64 ( CountPctFromMaxHealth ( pct )); }
bool HealthAbovePct ( int32 pct ) const { return GetHealth () > CountPctFromMaxHealth ( pct ); }
bool HealthAbovePctHealed ( int32 pct , uint32 heal ) const { return uint64 ( GetHealth ()) + uint64 ( heal ) > CountPctFromMaxHealth ( pct ); }
2011-05-11 12:08:08 +02:00
float GetHealthPct () const { return GetMaxHealth () ? 100.f * GetHealth () / GetMaxHealth () : 0.0f ; }
2012-10-02 12:17:42 +02:00
uint32 CountPctFromMaxHealth ( int32 pct ) const { return CalculatePct ( GetMaxHealth (), pct ); }
uint32 CountPctFromCurHealth ( int32 pct ) const { return CalculatePct ( GetHealth (), pct ); }
2010-08-26 01:20:57 +06:00
2010-04-07 22:59:46 +02:00
void SetHealth ( uint32 val );
2009-04-07 00:23:37 +02:00
void SetMaxHealth ( uint32 val );
2010-08-26 01:20:57 +06:00
inline void SetFullHealth () { SetHealth ( GetMaxHealth ()); }
2009-04-07 00:23:37 +02:00
int32 ModifyHealth ( int32 val );
2009-04-19 14:44:16 +02:00
int32 GetHealthGain ( int32 dVal );
2009-10-17 15:51:44 -07:00
2014-11-30 19:09:26 +01:00
Powers getPowerType () const { return Powers ( GetUInt32Value ( UNIT_FIELD_DISPLAY_POWER )); }
2009-04-07 00:23:37 +02:00
void setPowerType ( Powers power );
2012-01-22 00:13:57 +01:00
int32 GetPower ( Powers power ) const ;
2012-08-16 19:55:01 +01:00
int32 GetMinPower ( Powers power ) const { return power == POWER_ECLIPSE ? - 100 : 0 ; }
2012-08-17 14:30:10 +02:00
int32 GetMaxPower ( Powers power ) const ;
2015-02-08 19:40:03 +01:00
float GetPowerPct ( Powers power ) const { return GetMaxPower ( power ) ? 100.f * GetPower ( power ) / GetMaxPower ( power ) : 0.0f ; }
2013-07-19 22:33:35 +02:00
int32 CountPctFromMaxPower ( Powers power , int32 pct ) const { return CalculatePct ( GetMaxPower ( power ), pct ); }
2011-11-27 20:23:27 +01:00
void SetPower ( Powers power , int32 val );
2011-11-25 15:28:36 +01:00
void SetMaxPower ( Powers power , int32 val );
2010-12-27 20:14:54 +01:00
// returns the change in power
2009-04-07 00:23:37 +02:00
int32 ModifyPower ( Powers power , int32 val );
2011-10-12 01:11:52 +03:00
int32 ModifyPowerPct ( Powers power , float pct , bool apply = true );
2009-10-17 15:51:44 -07:00
2013-03-04 09:38:38 +01:00
uint32 GetAttackTime ( WeaponAttackType att ) const ;
2015-03-08 22:04:34 +01:00
void SetAttackTime ( WeaponAttackType att , uint32 val ) { SetFloatValue ( UNIT_FIELD_BASEATTACKTIME + att , val * m_modAttackSpeedPct [ att ]); }
2011-04-29 20:47:02 +02:00
void ApplyAttackTimePercentMod ( WeaponAttackType att , float val , bool apply );
2009-04-07 00:23:37 +02:00
void ApplyCastTimePercentMod ( float val , bool apply );
2009-10-17 15:51:44 -07:00
2009-05-28 18:43:57 -05:00
SheathState GetSheath () const { return SheathState ( GetByteValue ( UNIT_FIELD_BYTES_2 , 0 )); }
2010-04-07 22:59:46 +02:00
virtual void SetSheath ( SheathState sheathed ) { SetByteValue ( UNIT_FIELD_BYTES_2 , 0 , sheathed ); }
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// faction template id
uint32 getFaction () const { return GetUInt32Value ( UNIT_FIELD_FACTIONTEMPLATE ); }
2010-04-07 22:59:46 +02:00
void setFaction ( uint32 faction ) { SetUInt32Value ( UNIT_FIELD_FACTIONTEMPLATE , faction ); }
2013-06-11 22:02:00 -02:30
FactionTemplateEntry const * GetFactionTemplateEntry () const ;
2011-09-15 17:44:03 +02:00
ReputationRank GetReactionTo ( Unit const * target ) const ;
ReputationRank static GetFactionReactionTo ( FactionTemplateEntry const * factionTemplateEntry , Unit const * target );
2009-04-07 00:23:37 +02:00
bool IsHostileTo ( Unit const * unit ) const ;
bool IsHostileToPlayers () const ;
bool IsFriendlyTo ( Unit const * unit ) const ;
bool IsNeutralToAll () const ;
bool IsInPartyWith ( Unit const * unit ) const ;
bool IsInRaidWith ( Unit const * unit ) const ;
2009-06-10 23:44:30 +02:00
void GetPartyMembers ( std :: list < Unit *> & units );
2013-03-04 09:38:38 +01:00
bool IsContestedGuard () const ;
2009-04-07 00:23:37 +02:00
bool IsPvP () const { return HasByteFlag ( UNIT_FIELD_BYTES_2 , 1 , UNIT_BYTE2_FLAG_PVP ); }
2014-01-13 17:03:43 +00:00
bool IsFFAPvP () const { return HasByteFlag ( UNIT_FIELD_BYTES_2 , 1 , UNIT_BYTE2_FLAG_FFA_PVP ); }
2013-03-04 09:38:38 +01:00
void SetPvP ( bool state );
2009-04-07 00:23:37 +02:00
uint32 GetCreatureType () const ;
2013-03-04 09:38:38 +01:00
uint32 GetCreatureTypeMask () const ;
2009-10-17 15:51:44 -07:00
2015-01-28 19:29:31 +00:00
UnitStandStateType GetStandState () const { return UnitStandStateType ( GetByteValue ( UNIT_FIELD_BYTES_1 , 0 )); }
2009-04-07 00:23:37 +02:00
bool IsSitState () const ;
bool IsStandState () const ;
2015-01-28 19:29:31 +00:00
void SetStandState ( UnitStandStateType state );
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
void SetStandFlags ( uint8 flags ) { SetByteFlag ( UNIT_FIELD_BYTES_1 , 2 , flags ); }
void RemoveStandFlags ( uint8 flags ) { RemoveByteFlag ( UNIT_FIELD_BYTES_1 , 2 , flags ); }
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
bool IsMounted () const { return HasFlag ( UNIT_FIELD_FLAGS , UNIT_FLAG_MOUNT ); }
2009-04-07 00:23:37 +02:00
uint32 GetMountID () const { return GetUInt32Value ( UNIT_FIELD_MOUNTDISPLAYID ); }
2010-08-24 07:19:29 +03:00
void Mount ( uint32 mount , uint32 vehicleId = 0 , uint32 creatureEntry = 0 );
2011-12-19 22:06:29 +01:00
void Dismount ();
2012-01-27 11:24:41 +01:00
MountCapabilityEntry const * GetMountCapability ( uint32 mountType ) const ;
2009-10-17 15:51:44 -07:00
2012-08-08 20:59:30 -05:00
void SendDurabilityLoss ( Player * receiver , uint32 percent );
2014-08-30 21:09:46 +02:00
uint16 GetAIAnimKitId () const { return _aiAnimKitId ; }
void SetAIAnimKitId ( uint16 animKitId );
uint16 GetMovementAnimKitId () const { return _movementAnimKitId ; }
void SetMovementAnimKitId ( uint16 animKitId );
uint16 GetMeleeAnimKitId () const { return _meleeAnimKitId ; }
void SetMeleeAnimKitId ( uint16 animKitId );
void PlayOneShotAnimKit ( uint16 animKitId );
2012-08-10 14:10:57 +02:00
2009-04-07 00:23:37 +02:00
uint16 GetMaxSkillValueForLevel ( Unit const * target = NULL ) const { return ( target ? getLevelForTarget ( target ) : getLevel ()) * 5 ; }
2012-05-30 08:01:02 +02:00
void DealDamageMods ( Unit * victim , uint32 & damage , uint32 * absorb );
uint32 DealDamage ( Unit * victim , uint32 damage , CleanDamage const * cleanDamage = NULL , DamageEffectType damagetype = DIRECT_DAMAGE , SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL , SpellInfo const * spellProto = NULL , bool durabilityLoss = true );
void Kill ( Unit * victim , bool durabilityLoss = true );
int32 DealHeal ( Unit * victim , uint32 addhealth );
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
void ProcDamageAndSpell ( Unit * victim , uint32 procAttacker , uint32 procVictim , uint32 procEx , uint32 amount , WeaponAttackType attType = BASE_ATTACK , SpellInfo const * procSpell = NULL , SpellInfo const * procAura = NULL );
2011-10-07 19:45:43 -05:00
void ProcDamageAndSpellFor ( bool isVictim , Unit * target , uint32 procFlag , uint32 procExtra , WeaponAttackType attType , SpellInfo const * procSpell , uint32 damage , SpellInfo const * procAura = NULL );
2009-10-17 15:51:44 -07:00
2013-03-25 13:26:48 +01:00
void GetProcAurasTriggeredOnEvent ( AuraApplicationList & aurasTriggeringProc , AuraApplicationList * procAuras , ProcEventInfo eventInfo );
2011-07-10 13:13:02 +02:00
void TriggerAurasProcOnEvent ( CalcDamageInfo & damageInfo );
2013-03-25 13:26:48 +01:00
void TriggerAurasProcOnEvent ( AuraApplicationList * myProcAuras , AuraApplicationList * targetProcAuras ,
Unit * actionTarget , uint32 typeMaskActor , uint32 typeMaskActionTarget ,
uint32 spellTypeMask , uint32 spellPhaseMask , uint32 hitMask , Spell * spell ,
DamageInfo * damageInfo , HealInfo * healInfo );
void TriggerAurasProcOnEvent ( ProcEventInfo & eventInfo , AuraApplicationList & procAuras );
2011-07-10 13:13:02 +02:00
2009-04-07 00:23:37 +02:00
void HandleEmoteCommand ( uint32 anim_id );
2012-05-30 08:01:02 +02:00
void AttackerStateUpdate ( Unit * victim , WeaponAttackType attType = BASE_ATTACK , bool extra = false );
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
void CalculateMeleeDamage ( Unit * victim , uint32 damage , CalcDamageInfo * damageInfo , WeaponAttackType attackType = BASE_ATTACK );
2011-09-15 14:08:17 +02:00
void DealMeleeDamage ( CalcDamageInfo * damageInfo , bool durabilityLoss );
2011-09-25 16:42:12 +03:00
void HandleProcExtraAttackFor ( Unit * victim );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
void CalculateSpellDamageTaken ( SpellNonMeleeDamage * damageInfo , int32 damage , SpellInfo const * spellInfo , WeaponAttackType attackType = BASE_ATTACK , bool crit = false );
void DealSpellDamage ( SpellNonMeleeDamage * damageInfo , bool durabilityLoss );
2009-10-17 15:51:44 -07:00
2009-12-19 18:46:51 +01:00
// player or player's pet resilience (-1%)
2014-01-14 20:44:56 +01:00
uint32 GetDamageReduction ( uint32 damage ) const { return GetCombatRatingDamageReduction ( CR_RESILIENCE_PLAYER_DAMAGE_TAKEN , 1.0f , 100.0f , damage ); }
2009-12-19 18:46:51 +01:00
2014-01-14 20:44:56 +01:00
void ApplyResilience ( Unit const * victim , int32 * damage ) const ;
2010-09-12 14:29:09 +02:00
2013-05-21 09:41:13 +02:00
float MeleeSpellMissChance ( Unit const * victim , WeaponAttackType attType , uint32 spellId ) const ;
2013-08-17 00:47:44 +02:00
SpellMissInfo MeleeSpellHitResult ( Unit * victim , SpellInfo const * spellInfo );
SpellMissInfo MagicSpellHitResult ( Unit * victim , SpellInfo const * spellInfo );
SpellMissInfo SpellHitResult ( Unit * victim , SpellInfo const * spellInfo , bool canReflect = false );
2009-10-17 15:51:44 -07:00
2013-05-07 12:02:22 +02:00
float GetUnitDodgeChance () const ;
float GetUnitParryChance () const ;
float GetUnitBlockChance () const ;
float GetUnitMissChance ( WeaponAttackType attType ) const ;
2012-05-30 08:01:02 +02:00
float GetUnitCriticalChance ( WeaponAttackType attackType , const Unit * victim ) const ;
2013-08-17 00:47:44 +02:00
int32 GetMechanicResistChance ( SpellInfo const * spellInfo ) const ;
2013-03-04 09:38:38 +01:00
bool CanUseAttackType ( uint8 attacktype ) const ;
2009-10-17 15:51:44 -07:00
2013-05-16 10:30:30 +02:00
virtual uint32 GetBlockPercent () const { return 30 ; }
2012-08-14 18:11:06 +01:00
2013-03-04 09:38:38 +01:00
uint32 GetUnitMeleeSkill ( Unit const * target = NULL ) const ;
2013-03-04 19:09:57 +01:00
2009-04-07 00:23:37 +02:00
float GetWeaponProcChance () const ;
2011-09-15 14:08:17 +02:00
float GetPPMProcChance ( uint32 WeaponSpeed , float PPM , const SpellInfo * spellProto ) const ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
MeleeHitOutcome RollMeleeOutcomeAgainst ( const Unit * victim , WeaponAttackType attType ) const ;
MeleeHitOutcome RollMeleeOutcomeAgainst ( const Unit * victim , WeaponAttackType attType , int32 crit_chance , int32 miss_chance , int32 dodge_chance , int32 parry_chance , int32 block_chance ) const ;
2009-10-17 15:51:44 -07:00
2013-06-11 19:54:27 -02:30
bool IsVendor () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_VENDOR ); }
bool IsTrainer () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_TRAINER ); }
bool IsQuestGiver () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_QUESTGIVER ); }
bool IsGossip () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_GOSSIP ); }
bool IsTaxi () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_FLIGHTMASTER ); }
bool IsGuildMaster () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_PETITIONER ); }
bool IsBattleMaster () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_BATTLEMASTER ); }
bool IsBanker () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_BANKER ); }
bool IsInnkeeper () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_INNKEEPER ); }
bool IsSpiritHealer () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_SPIRITHEALER ); }
bool IsSpiritGuide () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_SPIRITGUIDE ); }
bool IsTabardDesigner () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_TABARDDESIGNER ); }
bool IsAuctioner () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_AUCTIONEER ); }
bool IsArmorer () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_REPAIR ); }
bool IsServiceProvider () const ;
bool IsSpiritService () const { return HasFlag ( UNIT_NPC_FLAGS , UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE ); }
2014-08-14 16:09:14 +02:00
bool IsCritter () const { return GetCreatureType () == CREATURE_TYPE_CRITTER ; }
2013-06-11 19:54:27 -02:30
bool IsInFlight () const { return HasUnitState ( UNIT_STATE_IN_FLIGHT ); }
bool IsInCombat () const { return HasFlag ( UNIT_FIELD_FLAGS , UNIT_FLAG_IN_COMBAT ); }
2009-07-13 15:38:48 +02:00
void CombatStart ( Unit * target , bool initialAggro = true );
2009-04-27 19:14:37 -05:00
void SetInCombatState ( bool PvP , Unit * enemy = NULL );
2009-04-07 00:23:37 +02:00
void SetInCombatWith ( Unit * enemy );
void ClearInCombat ();
uint32 GetCombatTimer () const { return m_CombatTimer ; }
2009-10-17 15:51:44 -07:00
2009-06-07 11:36:41 -05:00
bool HasAuraTypeWithFamilyFlags ( AuraType auraType , uint32 familyName , uint32 familyFlags ) const ;
2009-04-07 00:23:37 +02:00
bool virtual HasSpell ( uint32 /*spellID*/ ) const { return false ; }
2012-02-05 21:22:01 +01:00
bool HasBreakableByDamageAuraType ( AuraType type , uint32 excludeAura = 0 ) const ;
bool HasBreakableByDamageCrowdControlAura ( Unit * excludeCasterChannel = NULL ) const ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
bool HasStealthAura () const { return HasAuraType ( SPELL_AURA_MOD_STEALTH ); }
bool HasInvisibilityAura () const { return HasAuraType ( SPELL_AURA_MOD_INVISIBILITY ); }
bool isFeared () const { return HasAuraType ( SPELL_AURA_MOD_FEAR ); }
bool isInRoots () const { return HasAuraType ( SPELL_AURA_MOD_ROOT ); }
bool IsPolymorphed () const ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
bool isFrozen () const ;
2009-10-17 15:51:44 -07:00
2011-08-19 14:53:40 +02:00
bool isTargetableForAttack ( bool checkFakeDeath = true ) const ;
2011-09-16 22:16:14 +02:00
bool IsValidAttackTarget ( Unit const * target ) const ;
2012-05-30 08:01:02 +02:00
bool _IsValidAttackTarget ( Unit const * target , SpellInfo const * bySpell , WorldObject const * obj = NULL ) const ;
2011-09-16 22:16:14 +02:00
bool IsValidAssistTarget ( Unit const * target ) const ;
bool _IsValidAssistTarget ( Unit const * target , SpellInfo const * bySpell ) const ;
2009-04-07 00:23:37 +02:00
virtual bool IsInWater () const ;
virtual bool IsUnderWater () const ;
2012-05-30 08:01:02 +02:00
virtual void UpdateUnderwaterState ( Map * m , float x , float y , float z );
2009-04-07 00:23:37 +02:00
bool isInAccessiblePlaceFor ( Creature const * c ) const ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
void SendHealSpellLog ( Unit * victim , uint32 SpellID , uint32 Damage , uint32 OverHeal , uint32 Absorb , bool critical = false );
int32 HealBySpell ( Unit * victim , SpellInfo const * spellInfo , uint32 addHealth , bool critical = false );
2013-03-20 22:07:56 +01:00
void SendEnergizeSpellLog ( Unit * victim , uint32 spellID , int32 damage , Powers powertype );
2012-08-16 19:55:01 +01:00
void EnergizeBySpell ( Unit * victim , uint32 SpellID , int32 Damage , Powers powertype );
2011-09-24 16:41:04 +02:00
2014-09-14 16:14:12 +02:00
void CastSpell ( SpellCastTargets const & targets , SpellInfo const * spellInfo , CustomSpellValues const * value , TriggerCastFlags triggerFlags = TRIGGERED_NONE , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastSpell ( Unit * victim , uint32 spellId , bool triggered , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastSpell ( Unit * victim , uint32 spellId , TriggerCastFlags triggerFlags = TRIGGERED_NONE , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastSpell ( Unit * victim , SpellInfo const * spellInfo , bool triggered , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastSpell ( Unit * victim , SpellInfo const * spellInfo , TriggerCastFlags triggerFlags = TRIGGERED_NONE , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastSpell ( float x , float y , float z , uint32 spellId , bool triggered , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastSpell ( GameObject * go , uint32 spellId , bool triggered , Item * castItem = NULL , AuraEffect * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastCustomSpell ( Unit * victim , uint32 spellId , int32 const * bp0 , int32 const * bp1 , int32 const * bp2 , bool triggered , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastCustomSpell ( uint32 spellId , SpellValueMod mod , int32 value , Unit * victim , bool triggered , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastCustomSpell ( uint32 spellId , SpellValueMod mod , int32 value , Unit * victim = NULL , TriggerCastFlags triggerFlags = TRIGGERED_NONE , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
void CastCustomSpell ( uint32 spellId , CustomSpellValues const & value , Unit * victim = NULL , TriggerCastFlags triggerFlags = TRIGGERED_NONE , Item * castItem = NULL , AuraEffect const * triggeredByAura = NULL , ObjectGuid originalCaster = ObjectGuid :: Empty );
2011-09-15 14:08:17 +02:00
Aura * AddAura ( uint32 spellId , Unit * target );
2014-11-22 17:18:16 +01:00
Aura * AddAura ( SpellInfo const * spellInfo , uint32 effMask , Unit * target );
2011-06-12 02:00:43 +02:00
void SetAuraStack ( uint32 spellId , Unit * target , uint32 stack );
2012-09-01 05:03:15 +02:00
void SendPlaySpellVisualKit ( uint32 id , uint32 unkParam );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void DeMorph ();
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
void SendAttackStateUpdate ( CalcDamageInfo * damageInfo );
2011-06-12 02:00:43 +02:00
void SendAttackStateUpdate ( uint32 HitInfo , Unit * target , uint8 SwingType , SpellSchoolMask damageSchoolMask , uint32 Damage , uint32 AbsorbDamage , uint32 Resist , VictimState TargetState , uint32 BlockedAmount );
2011-09-15 14:08:17 +02:00
void SendSpellNonMeleeDamageLog ( SpellNonMeleeDamage * log );
2011-06-12 02:00:43 +02:00
void SendSpellNonMeleeDamageLog ( Unit * target , uint32 SpellID , uint32 Damage , SpellSchoolMask damageSchoolMask , uint32 AbsorbedDamage , uint32 Resist , bool PhysicalDamage , uint32 Blocked , bool CriticalHit = false );
2011-09-15 14:08:17 +02:00
void SendPeriodicAuraLog ( SpellPeriodicAuraLogInfo * pInfo );
2011-06-12 02:00:43 +02:00
void SendSpellMiss ( Unit * target , uint32 spellID , SpellMissInfo missInfo );
2011-06-28 16:17:49 +02:00
void SendSpellDamageResist ( Unit * target , uint32 spellId );
2011-06-12 02:00:43 +02:00
void SendSpellDamageImmune ( Unit * target , uint32 spellId );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void NearTeleportTo ( float x , float y , float z , float orientation , bool casting = false );
2012-12-24 17:26:42 +01:00
void SendTeleportPacket ( Position & pos );
2011-10-10 17:08:01 -04:00
virtual bool UpdatePosition ( float x , float y , float z , float ang , bool teleport = false );
2010-01-20 15:05:58 +02:00
// returns true if unit's position really changed
2013-03-04 09:38:38 +01:00
bool UpdatePosition ( const Position & pos , bool teleport = false );
2012-05-30 08:01:02 +02:00
void UpdateOrientation ( float orientation );
void UpdateHeight ( float newZ );
2009-10-17 15:51:44 -07:00
2012-08-09 19:18:31 -05:00
void SendMoveKnockBack ( Player * player , float speedXY , float speedZ , float vcos , float vsin );
2009-04-11 22:41:15 -05:00
void KnockbackFrom ( float x , float y , float speedXY , float speedZ );
void JumpTo ( float speedXY , float speedZ , bool forward = true );
2011-09-15 14:08:17 +02:00
void JumpTo ( WorldObject * obj , float speedZ );
2009-10-17 15:51:44 -07:00
2012-04-09 15:11:39 +02:00
void MonsterMoveWithSpeed ( float x , float y , float z , float speed , bool generatePath = false , bool forceDestination = false );
2012-05-30 08:01:02 +02:00
2013-05-31 22:21:07 +02:00
void SendSetPlayHoverAnim ( bool enable );
2013-06-18 16:47:12 +02:00
bool IsLevitating () const { return m_movementInfo . HasMovementFlag ( MOVEMENTFLAG_DISABLE_GRAVITY ); }
bool IsWalking () const { return m_movementInfo . HasMovementFlag ( MOVEMENTFLAG_WALKING ); }
2014-09-13 14:06:37 +01:00
bool IsHovering () const { return m_movementInfo . HasMovementFlag ( MOVEMENTFLAG_HOVER ); }
2013-08-10 13:44:08 +02:00
bool SetWalk ( bool enable );
bool SetDisableGravity ( bool disable , bool packetOnly = false );
bool SetFall ( bool enable );
bool SetSwim ( bool enable );
bool SetCanFly ( bool enable );
bool SetWaterWalking ( bool enable , bool packetOnly = false );
bool SetFeatherFall ( bool enable , bool packetOnly = false );
bool SetHover ( bool enable , bool packetOnly = false );
2009-10-17 15:51:44 -07:00
2013-03-03 23:15:54 +01:00
void SetInFront ( WorldObject const * target );
2012-01-14 15:34:41 +01:00
void SetFacingTo ( float ori );
2012-05-30 08:01:02 +02:00
void SetFacingToObject ( WorldObject * object );
2010-06-23 00:57:16 +02:00
2010-03-09 11:11:10 +01:00
void SendChangeCurrentVictimOpcode ( HostileReference * pHostileReference );
2009-07-02 00:03:57 +02:00
void SendClearThreatListOpcode ();
2010-03-09 11:11:10 +01:00
void SendRemoveFromThreatListOpcode ( HostileReference * pHostileReference );
2009-07-02 00:03:57 +02:00
void SendThreatListUpdate ();
2009-10-17 15:51:44 -07:00
2011-02-19 22:50:09 +01:00
void SendClearTarget ();
2013-06-11 19:54:27 -02:30
bool IsAlive () const { return ( m_deathState == ALIVE ); }
2013-03-20 14:18:26 +01:00
bool isDying () const { return ( m_deathState == JUST_DIED ); }
bool isDead () const { return ( m_deathState == DEAD || m_deathState == CORPSE ); }
DeathState getDeathState () const { return m_deathState ; }
2009-04-07 00:23:37 +02:00
virtual void setDeathState ( DeathState s ); // overwrited in Creature/Player/Pet
2009-10-17 15:51:44 -07:00
2014-09-14 16:14:12 +02:00
ObjectGuid GetOwnerGUID () const { return GetGuidValue ( UNIT_FIELD_SUMMONEDBY ); }
void SetOwnerGUID ( ObjectGuid owner );
ObjectGuid GetCreatorGUID () const { return GetGuidValue ( UNIT_FIELD_CREATEDBY ); }
void SetCreatorGUID ( ObjectGuid creator ) { SetGuidValue ( UNIT_FIELD_CREATEDBY , creator ); }
ObjectGuid GetMinionGUID () const { return GetGuidValue ( UNIT_FIELD_SUMMON ); }
void SetMinionGUID ( ObjectGuid guid ) { SetGuidValue ( UNIT_FIELD_SUMMON , guid ); }
ObjectGuid GetCharmerGUID () const { return GetGuidValue ( UNIT_FIELD_CHARMEDBY ); }
void SetCharmerGUID ( ObjectGuid owner ) { SetGuidValue ( UNIT_FIELD_CHARMEDBY , owner ); }
ObjectGuid GetCharmGUID () const { return GetGuidValue ( UNIT_FIELD_CHARM ); }
void SetPetGUID ( ObjectGuid guid ) { m_SummonSlot [ SUMMON_SLOT_PET ] = guid ; }
ObjectGuid GetPetGUID () const { return m_SummonSlot [ SUMMON_SLOT_PET ]; }
void SetCritterGUID ( ObjectGuid guid ) { SetGuidValue ( UNIT_FIELD_CRITTER , guid ); }
ObjectGuid GetCritterGUID () const { return GetGuidValue ( UNIT_FIELD_CRITTER ); }
2009-10-17 15:51:44 -07:00
2009-04-19 19:45:54 -05:00
bool IsControlledByPlayer () const { return m_ControlledByPlayer ; }
2014-09-14 16:14:12 +02:00
ObjectGuid GetCharmerOrOwnerGUID () const ;
ObjectGuid GetCharmerOrOwnerOrOwnGUID () const ;
bool IsCharmedOwnedByPlayerOrPlayer () const { return GetCharmerOrOwnerOrOwnGUID (). IsPlayer (); }
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
Player * GetSpellModOwner () const ;
2009-10-17 15:51:44 -07:00
2010-07-28 00:08:21 +02:00
Unit * GetOwner () const ;
2013-07-28 16:02:49 +02:00
Guardian * GetGuardianPet () const ;
Minion * GetFirstMinion () const ;
2009-04-07 00:23:37 +02:00
Unit * GetCharmer () const ;
Unit * GetCharm () const ;
2013-03-04 09:38:38 +01:00
Unit * GetCharmerOrOwner () const ;
Unit * GetCharmerOrOwnerOrSelf () const ;
2009-04-07 00:23:37 +02:00
Player * GetCharmerOrOwnerPlayerOrPlayerItself () const ;
2011-09-15 17:44:03 +02:00
Player * GetAffectingPlayer () const ;
2009-10-17 15:51:44 -07:00
2009-05-02 19:24:22 -05:00
void SetMinion ( Minion * minion , bool apply );
2014-12-29 01:00:16 +01:00
void GetAllMinionsByEntry ( std :: list < TempSummon *>& Minions , uint32 entry );
2009-08-19 20:30:11 -05:00
void RemoveAllMinionsByEntry ( uint32 entry );
2009-04-07 00:23:37 +02:00
void SetCharm ( Unit * target , bool apply );
Unit * GetNextRandomRaidMemberOrPet ( float radius );
2011-06-11 22:35:29 +02:00
bool SetCharmedBy ( Unit * charmer , CharmType type , AuraApplication const * aurApp = NULL );
2009-06-03 13:51:05 -05:00
void RemoveCharmedBy ( Unit * charmer );
2009-04-07 00:23:37 +02:00
void RestoreFaction ();
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
ControlList m_Controlled ;
Unit * GetFirstControlled () const ;
void RemoveAllControlled ();
2009-10-17 15:51:44 -07:00
2014-09-14 16:14:12 +02:00
bool IsCharmed () const { return ! GetCharmerGUID (). IsEmpty (); }
2012-02-03 19:12:41 +02:00
bool isPossessed () const { return HasUnitState ( UNIT_STATE_POSSESSED ); }
2013-03-04 09:38:38 +01:00
bool isPossessedByPlayer () const ;
bool isPossessing () const ;
bool isPossessing ( Unit * u ) const ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
CharmInfo * GetCharmInfo () { return m_charmInfo ; }
CharmInfo * InitCharmInfo ();
2010-08-08 20:32:14 +02:00
void DeleteCharmInfo ();
2009-04-07 00:23:37 +02:00
void UpdateCharmAI ();
2011-06-11 22:35:29 +02:00
//Player* GetMoverSource() const;
Player * m_movedPlayer ;
2009-04-07 00:23:37 +02:00
SharedVisionList const & GetSharedVisionList () { return m_sharedVision ; }
2011-11-07 11:06:39 -06:00
void AddPlayerToVision ( Player * player );
void RemovePlayerFromVision ( Player * player );
2009-04-07 00:23:37 +02:00
bool HasSharedVision () const { return ! m_sharedVision . empty (); }
void RemoveBindSightAuras ();
void RemoveCharmAuras ();
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
Pet * CreateTamedPetFrom ( Creature * creatureTarget , uint32 spell_id = 0 );
Pet * CreateTamedPetFrom ( uint32 creatureEntry , uint32 spell_id = 0 );
2011-09-15 14:08:17 +02:00
bool InitTamedPet ( Pet * pet , uint8 level , uint32 spell_id );
2009-10-17 15:51:44 -07:00
2010-01-10 01:23:15 +01:00
// aura apply/remove helpers - you should better not use these
2014-11-17 20:38:56 +01:00
Aura * _TryStackingOrRefreshingExistingAura ( SpellInfo const * newAura , uint32 effMask , Unit * caster , int32 * baseAmount = NULL , Item * castItem = NULL , ObjectGuid casterGUID = ObjectGuid :: Empty );
2011-06-11 22:35:29 +02:00
void _AddAura ( UnitAura * aura , Unit * caster );
2014-11-17 20:38:56 +01:00
AuraApplication * _CreateAuraApplication ( Aura * aura , uint32 effMask );
2011-09-15 14:08:17 +02:00
void _ApplyAuraEffect ( Aura * aura , uint8 effIndex );
2014-11-17 20:38:56 +01:00
void _ApplyAura ( AuraApplication * aurApp , uint32 effMask );
2010-01-10 01:23:15 +01:00
void _UnapplyAura ( AuraApplicationMap :: iterator & i , AuraRemoveMode removeMode );
void _UnapplyAura ( AuraApplication * aurApp , AuraRemoveMode removeMode );
2011-09-15 14:08:17 +02:00
void _RemoveNoStackAuraApplicationsDueToAura ( Aura * aura );
void _RemoveNoStackAurasDueToAura ( Aura * aura );
bool _IsNoStackAuraDueToAura ( Aura * appliedAura , Aura * existingAura ) const ;
void _RegisterAuraEffect ( AuraEffect * aurEff , bool apply );
2010-01-10 01:23:15 +01:00
// m_ownedAuras container management
AuraMap & GetOwnedAuras () { return m_ownedAuras ; }
AuraMap const & GetOwnedAuras () const { return m_ownedAuras ; }
void RemoveOwnedAura ( AuraMap :: iterator & i , AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT );
2014-11-22 17:18:16 +01:00
void RemoveOwnedAura ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 , AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT );
2011-09-15 14:08:17 +02:00
void RemoveOwnedAura ( Aura * aura , AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT );
2010-01-10 01:23:15 +01:00
2014-11-22 17:18:16 +01:00
Aura * GetOwnedAura ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , ObjectGuid itemCasterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 , Aura * except = NULL ) const ;
2010-01-10 01:23:15 +01:00
// m_appliedAuras container management
AuraApplicationMap & GetAppliedAuras () { return m_appliedAuras ; }
AuraApplicationMap const & GetAppliedAuras () const { return m_appliedAuras ; }
void RemoveAura ( AuraApplicationMap :: iterator & i , AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT );
2014-11-22 17:18:16 +01:00
void RemoveAura ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 , AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT );
2010-01-10 01:23:15 +01:00
void RemoveAura ( AuraApplication * aurApp , AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT );
2011-09-15 14:08:17 +02:00
void RemoveAura ( Aura * aur , AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT );
2010-01-10 01:23:15 +01:00
2014-11-22 17:18:16 +01:00
void RemoveAurasDueToSpell ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 , AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT );
2014-09-14 16:14:12 +02:00
void RemoveAuraFromStack ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT );
void RemoveAurasDueToSpellByDispel ( uint32 spellId , uint32 dispellerSpellId , ObjectGuid casterGUID , Unit * dispeller , uint8 chargesRemoved = 1 );
void RemoveAurasDueToSpellBySteal ( uint32 spellId , ObjectGuid casterGUID , Unit * stealer );
void RemoveAurasDueToItemSpell ( uint32 spellId , ObjectGuid castItemGuid );
void RemoveAurasByType ( AuraType auraType , ObjectGuid casterGUID = ObjectGuid :: Empty , Aura * except = NULL , bool negative = true , bool positive = true );
2014-06-01 22:27:29 -05:00
void RemoveNotOwnSingleTargetAuras ( uint32 newPhase = 0x0 , bool phaseid = false );
2011-04-23 15:53:48 +02:00
void RemoveAurasWithInterruptFlags ( uint32 flag , uint32 except = 0 );
2010-06-05 00:59:25 +02:00
void RemoveAurasWithAttribute ( uint32 flags );
2014-09-14 16:14:12 +02:00
void RemoveAurasWithFamily ( SpellFamilyNames family , uint32 familyFlag1 , uint32 familyFlag2 , uint32 familyFlag3 , ObjectGuid casterGUID );
void RemoveAurasWithMechanic ( uint32 mechanic_mask , AuraRemoveMode removemode = AURA_REMOVE_BY_DEFAULT , uint32 except = 0 );
2010-01-10 01:23:15 +01:00
void RemoveMovementImpairingAuras ();
void RemoveAreaAurasDueToLeaveWorld ();
2009-04-07 00:23:37 +02:00
void RemoveAllAuras ();
2011-06-16 00:20:20 +07:00
void RemoveArenaAuras ();
2009-04-07 00:23:37 +02:00
void RemoveAllAurasOnDeath ();
2010-08-30 17:32:51 +02:00
void RemoveAllAurasRequiringDeadTarget ();
2011-04-23 10:24:44 +02:00
void RemoveAllAurasExceptType ( AuraType type );
2013-08-11 15:52:23 +01:00
void RemoveAllAurasExceptType ( AuraType type1 , AuraType type2 ); /// @todo: once we support variadic templates use them here
2014-09-14 16:14:12 +02:00
void DelayOwnedAuras ( uint32 spellId , ObjectGuid caster , int32 delaytime );
2010-01-10 01:23:15 +01:00
void _RemoveAllAuraStatMods ();
void _ApplyAllAuraStatMods ();
AuraEffectList const & GetAuraEffectsByType ( AuraType type ) const { return m_modAuras [ type ]; }
2010-01-16 15:12:21 +01:00
AuraList & GetSingleCastAuras () { return m_scAuras ; }
AuraList const & GetSingleCastAuras () const { return m_scAuras ; }
2010-01-10 01:23:15 +01:00
2014-09-14 16:14:12 +02:00
AuraEffect * GetAuraEffect ( uint32 spellId , uint8 effIndex , ObjectGuid casterGUID = ObjectGuid :: Empty ) const ;
AuraEffect * GetAuraEffectOfRankedSpell ( uint32 spellId , uint8 effIndex , ObjectGuid casterGUID = ObjectGuid :: Empty ) const ;
2011-09-15 14:08:17 +02:00
AuraEffect * GetAuraEffect ( AuraType type , SpellFamilyNames name , uint32 iconId , uint8 effIndex ) const ; // spell mustn't have familyflags
2014-09-14 16:14:12 +02:00
AuraEffect * GetAuraEffect ( AuraType type , SpellFamilyNames family , uint32 familyFlag1 , uint32 familyFlag2 , uint32 familyFlag3 , ObjectGuid casterGUID = ObjectGuid :: Empty ) const ;
2013-03-04 09:38:38 +01:00
AuraEffect * GetDummyAuraEffect ( SpellFamilyNames name , uint32 iconId , uint8 effIndex ) const ;
2010-01-10 01:23:15 +01:00
2014-11-22 17:18:16 +01:00
AuraApplication * GetAuraApplication ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , ObjectGuid itemCasterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 , AuraApplication * except = NULL ) const ;
Aura * GetAura ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , ObjectGuid itemCasterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 ) const ;
2010-01-10 01:23:15 +01:00
2014-11-22 17:18:16 +01:00
AuraApplication * GetAuraApplicationOfRankedSpell ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , ObjectGuid itemCasterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 , AuraApplication * except = NULL ) const ;
Aura * GetAuraOfRankedSpell ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , ObjectGuid itemCasterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 ) const ;
2010-01-10 01:23:15 +01:00
2012-05-30 08:01:02 +02:00
void GetDispellableAuraList ( Unit * caster , uint32 dispelMask , DispelChargesList & dispelList );
2014-09-14 16:14:12 +02:00
bool HasAuraEffect ( uint32 spellId , uint8 effIndex , ObjectGuid caster = ObjectGuid :: Empty ) const ;
2010-10-17 21:14:08 +02:00
uint32 GetAuraCount ( uint32 spellId ) const ;
2014-11-22 17:18:16 +01:00
bool HasAura ( uint32 spellId , ObjectGuid casterGUID = ObjectGuid :: Empty , ObjectGuid itemCasterGUID = ObjectGuid :: Empty , uint32 reqEffMask = 0 ) const ;
2010-01-10 01:23:15 +01:00
bool HasAuraType ( AuraType auraType ) const ;
2014-09-14 16:14:12 +02:00
bool HasAuraTypeWithCaster ( AuraType auratype , ObjectGuid caster ) const ;
2010-05-01 22:25:14 +02:00
bool HasAuraTypeWithMiscvalue ( AuraType auratype , int32 miscvalue ) const ;
2011-07-26 23:09:28 +02:00
bool HasAuraTypeWithAffectMask ( AuraType auratype , SpellInfo const * affectedSpell ) const ;
2010-05-01 22:25:14 +02:00
bool HasAuraTypeWithValue ( AuraType auratype , int32 value ) const ;
2014-09-14 16:14:12 +02:00
bool HasNegativeAuraWithInterruptFlag ( uint32 flag , ObjectGuid guid = ObjectGuid :: Empty ) const ;
bool HasNegativeAuraWithAttribute ( uint32 flag , ObjectGuid guid = ObjectGuid :: Empty ) const ;
2013-05-07 12:02:22 +02:00
bool HasAuraWithMechanic ( uint32 mechanicMask ) const ;
2010-01-10 01:23:15 +01:00
2011-09-15 14:08:17 +02:00
AuraEffect * IsScriptOverriden ( SpellInfo const * spell , int32 script ) const ;
2014-09-14 16:14:12 +02:00
uint32 GetDiseasesByCaster ( ObjectGuid casterGUID , bool remove = false );
uint32 GetDoTsByCaster ( ObjectGuid casterGUID ) const ;
2010-01-10 01:23:15 +01:00
int32 GetTotalAuraModifier ( AuraType auratype ) const ;
float GetTotalAuraMultiplier ( AuraType auratype ) const ;
2013-03-20 14:18:26 +01:00
int32 GetMaxPositiveAuraModifier ( AuraType auratype ) const ;
2010-01-10 01:23:15 +01:00
int32 GetMaxNegativeAuraModifier ( AuraType auratype ) const ;
int32 GetTotalAuraModifierByMiscMask ( AuraType auratype , uint32 misc_mask ) const ;
float GetTotalAuraMultiplierByMiscMask ( AuraType auratype , uint32 misc_mask ) const ;
2010-12-17 20:31:46 +01:00
int32 GetMaxPositiveAuraModifierByMiscMask ( AuraType auratype , uint32 misc_mask , const AuraEffect * except = NULL ) const ;
2010-01-10 01:23:15 +01:00
int32 GetMaxNegativeAuraModifierByMiscMask ( AuraType auratype , uint32 misc_mask ) const ;
int32 GetTotalAuraModifierByMiscValue ( AuraType auratype , int32 misc_value ) const ;
float GetTotalAuraMultiplierByMiscValue ( AuraType auratype , int32 misc_value ) const ;
int32 GetMaxPositiveAuraModifierByMiscValue ( AuraType auratype , int32 misc_value ) const ;
int32 GetMaxNegativeAuraModifierByMiscValue ( AuraType auratype , int32 misc_value ) const ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 GetTotalAuraModifierByAffectMask ( AuraType auratype , SpellInfo const * affectedSpell ) const ;
float GetTotalAuraMultiplierByAffectMask ( AuraType auratype , SpellInfo const * affectedSpell ) const ;
int32 GetMaxPositiveAuraModifierByAffectMask ( AuraType auratype , SpellInfo const * affectedSpell ) const ;
int32 GetMaxNegativeAuraModifierByAffectMask ( AuraType auratype , SpellInfo const * affectedSpell ) const ;
2010-08-01 01:22:13 +02:00
2013-03-04 09:38:38 +01:00
float GetResistanceBuffMods ( SpellSchools school , bool positive ) const ;
void SetResistanceBuffMods ( SpellSchools school , bool positive , float val );
void ApplyResistanceBuffModsMod ( SpellSchools school , bool positive , float val , bool apply );
void ApplyResistanceBuffModsPercentMod ( SpellSchools school , bool positive , float val , bool apply );
void InitStatBuffMods ();
void ApplyStatBuffMod ( Stats stat , float val , bool apply );
void ApplyStatPercentBuffMod ( Stats stat , float val , bool apply );
2009-04-07 00:23:37 +02:00
void SetCreateStat ( Stats stat , float val ) { m_createStats [ stat ] = val ; }
void SetCreateHealth ( uint32 val ) { SetUInt32Value ( UNIT_FIELD_BASE_HEALTH , val ); }
uint32 GetCreateHealth () const { return GetUInt32Value ( UNIT_FIELD_BASE_HEALTH ); }
void SetCreateMana ( uint32 val ) { SetUInt32Value ( UNIT_FIELD_BASE_MANA , val ); }
uint32 GetCreateMana () const { return GetUInt32Value ( UNIT_FIELD_BASE_MANA ); }
2013-02-01 19:55:23 +01:00
uint32 GetPowerIndex ( uint32 powerType ) const ;
2011-11-25 15:28:36 +01:00
int32 GetCreatePowers ( Powers power ) const ;
2014-10-26 22:06:48 +01:00
float GetPosStat ( Stats stat ) const { return GetFloatValue ( UNIT_FIELD_POSSTAT + stat ); }
float GetNegStat ( Stats stat ) const { return GetFloatValue ( UNIT_FIELD_NEGSTAT + stat ); }
2009-04-07 00:23:37 +02:00
float GetCreateStat ( Stats stat ) const { return m_createStats [ stat ]; }
2009-10-17 15:51:44 -07:00
2014-09-14 16:14:12 +02:00
ObjectGuid GetChannelObjectGuid () const { return GetGuidValue ( UNIT_FIELD_CHANNEL_OBJECT ); }
void SetChannelObjectGuid ( ObjectGuid guid ) { SetGuidValue ( UNIT_FIELD_CHANNEL_OBJECT , guid ); }
2013-12-25 14:16:55 -03:30
void SetCurrentCastSpell ( Spell * pSpell );
2009-08-19 16:52:51 -05:00
void InterruptSpell ( CurrentSpellTypes spellType , bool withDelayed = true , bool withInstant = true );
void FinishSpell ( CurrentSpellTypes spellType , bool ok = true );
2009-10-17 15:51:44 -07:00
2013-12-25 14:16:55 -03:30
// set withDelayed to true to account delayed spells as cast
// delayed+channeled spells are always accounted as cast
2009-04-07 00:23:37 +02:00
// we can skip channeled or delayed checks using flags
2013-12-25 14:16:55 -03:30
bool IsNonMeleeSpellCast ( bool withDelayed , bool skipChanneled = false , bool skipAutorepeat = false , bool isAutoshoot = false , bool skipInstant = true ) const ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// set withDelayed to true to interrupt delayed spells too
// delayed+channeled spells are always interrupted
2009-04-30 09:59:16 -05:00
void InterruptNonMeleeSpells ( bool withDelayed , uint32 spellid = 0 , bool withInstant = true );
2009-10-17 15:51:44 -07:00
2009-08-19 16:52:51 -05:00
Spell * GetCurrentSpell ( CurrentSpellTypes spellType ) const { return m_currentSpells [ spellType ]; }
Spell * GetCurrentSpell ( uint32 spellType ) const { return m_currentSpells [ spellType ]; }
2009-04-07 00:23:37 +02:00
Spell * FindCurrentSpellBySpellId ( uint32 spell_id ) const ;
2009-07-28 21:34:18 +02:00
int32 GetCurrentSpellCastTime ( uint32 spell_id ) const ;
2015-01-30 23:58:16 +01:00
virtual SpellInfo const * GetCastSpellInfo ( SpellInfo const * spellInfo ) const ;
2009-10-17 15:51:44 -07:00
2015-02-17 01:01:44 +01:00
SpellHistory * GetSpellHistory () { return _spellHistory ; }
SpellHistory const * GetSpellHistory () const { return _spellHistory ; }
2014-09-14 16:14:12 +02:00
ObjectGuid m_SummonSlot [ MAX_SUMMON_SLOT ];
ObjectGuid m_ObjectSlot [ MAX_GAMEOBJECT_SLOT ];
2009-10-17 15:51:44 -07:00
2010-12-09 17:03:42 +06:00
ShapeshiftForm GetShapeshiftForm () const { return ShapeshiftForm ( GetByteValue ( UNIT_FIELD_BYTES_2 , 3 )); }
2013-03-04 09:38:38 +01:00
void SetShapeshiftForm ( ShapeshiftForm form );
2010-12-09 17:03:42 +06:00
2013-03-04 09:38:38 +01:00
bool IsInFeralForm () const ;
2010-12-09 17:03:42 +06:00
2013-03-04 09:38:38 +01:00
bool IsInDisallowedMountForm () const ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
float m_modMeleeHitChance ;
float m_modRangedHitChance ;
float m_modSpellHitChance ;
int32 m_baseSpellCritChance ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
float m_threatModifier [ MAX_SPELL_SCHOOL ];
float m_modAttackSpeedPct [ 3 ];
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// Event handler
EventProcessor m_Events ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// stat system
bool HandleStatModifier ( UnitMods unitMod , UnitModifierType modifierType , float amount , bool apply );
void SetModifierValue ( UnitMods unitMod , UnitModifierType modifierType , float value ) { m_auraModifiersGroup [ unitMod ][ modifierType ] = value ; }
float GetModifierValue ( UnitMods unitMod , UnitModifierType modifierType ) const ;
float GetTotalStatValue ( Stats stat ) const ;
float GetTotalAuraModValue ( UnitMods unitMod ) const ;
SpellSchools GetSpellSchoolByAuraGroup ( UnitMods unitMod ) const ;
Stats GetStatByAuraGroup ( UnitMods unitMod ) const ;
Powers GetPowerTypeByAuraGroup ( UnitMods unitMod ) const ;
bool CanModifyStats () const { return m_canModifyStats ; }
void SetCanModifyStats ( bool modifyStats ) { m_canModifyStats = modifyStats ; }
virtual bool UpdateStats ( Stats stat ) = 0 ;
virtual bool UpdateAllStats () = 0 ;
virtual void UpdateResistances ( uint32 school ) = 0 ;
2014-01-04 18:22:06 +01:00
virtual void UpdateAllResistances ();
2009-04-07 00:23:37 +02:00
virtual void UpdateArmor () = 0 ;
virtual void UpdateMaxHealth () = 0 ;
virtual void UpdateMaxPower ( Powers power ) = 0 ;
virtual void UpdateAttackPowerAndDamage ( bool ranged = false ) = 0 ;
2014-01-04 18:22:06 +01:00
virtual void UpdateDamagePhysical ( WeaponAttackType attType );
2009-04-07 00:23:37 +02:00
float GetTotalAttackPowerValue ( WeaponAttackType attType ) const ;
2011-09-29 12:43:05 +02:00
float GetWeaponDamageRange ( WeaponAttackType attType , WeaponDamageRange type ) const ;
void SetBaseWeaponDamage ( WeaponAttackType attType , WeaponDamageRange damageRange , float value ) { m_weaponDamage [ attType ][ damageRange ] = value ; }
2014-01-04 18:22:06 +01:00
virtual void CalculateMinMaxDamage ( WeaponAttackType attType , bool normalized , bool addTotalPct , float & minDamage , float & maxDamage ) = 0 ;
uint32 CalculateDamage ( WeaponAttackType attType , bool normalized , bool addTotalPct );
float GetAPMultiplier ( WeaponAttackType attType , bool normalized );
2009-10-17 15:51:44 -07:00
2014-08-21 16:56:11 +02:00
bool isInFrontInMap ( Unit const * target , float distance , float arc = float ( M_PI )) const ;
bool isInBackInMap ( Unit const * target , float distance , float arc = float ( M_PI )) const ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// Visibility system
2013-03-04 09:38:38 +01:00
bool IsVisible () const ;
2010-11-16 01:13:04 +01:00
void SetVisible ( bool x );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// common function for visibility checks for player/creatures with detection code
2015-04-01 11:08:56 -04:00
bool SetInPhase ( uint32 id , bool update , bool apply ) override ;
2014-08-09 20:17:40 +01:00
void UpdateObjectVisibility ( bool forced = true ) override ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
SpellImmuneList m_spellImmune [ MAX_SPELL_IMMUNITY ];
2010-11-13 18:04:56 +01:00
uint32 m_lastSanctuaryTime ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// Threat related methods
2013-12-11 09:38:24 +07:00
bool CanHaveThreatList ( bool skipAliveCheck = false ) const ;
2012-05-30 08:01:02 +02:00
void AddThreat ( Unit * victim , float fThreat , SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL , SpellInfo const * threatSpell = NULL );
2009-10-18 18:38:46 -07:00
float ApplyTotalThreatModifier ( float fThreat , SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL );
2009-04-07 00:23:37 +02:00
void DeleteThreatList ();
2012-05-30 08:01:02 +02:00
void TauntApply ( Unit * victim );
2011-09-15 14:08:17 +02:00
void TauntFadeOut ( Unit * taunter );
2009-04-07 00:23:37 +02:00
ThreatManager & getThreatManager () { return m_ThreatManager ; }
2010-03-09 11:11:10 +01:00
void addHatedBy ( HostileReference * pHostileReference ) { m_HostileRefManager . insertFirst ( pHostileReference ); };
2010-04-07 22:59:46 +02:00
void removeHatedBy ( HostileReference * /*pHostileReference*/ ) { /* nothing to do yet */ }
2010-03-09 11:11:10 +01:00
HostileRefManager & getHostileRefManager () { return m_HostileRefManager ; }
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
VisibleAuraMap const * GetVisibleAuras () { return & m_visibleAuras ; }
2013-03-04 15:56:00 +01:00
AuraApplication * GetVisibleAura ( uint8 slot ) const ;
2013-03-04 09:38:38 +01:00
void SetVisibleAura ( uint8 slot , AuraApplication * aur );
void RemoveVisibleAura ( uint8 slot );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
uint32 GetInterruptMask () const { return m_interruptMask ; }
void AddInterruptMask ( uint32 mask ) { m_interruptMask |= mask ; }
void UpdateInterruptMask ();
2009-10-17 15:51:44 -07:00
2013-03-04 15:56:00 +01:00
uint32 GetDisplayId () const { return GetUInt32Value ( UNIT_FIELD_DISPLAYID ); }
2013-06-11 17:28:16 +02:00
virtual void SetDisplayId ( uint32 modelId );
2013-03-04 15:56:00 +01:00
uint32 GetNativeDisplayId () const { return GetUInt32Value ( UNIT_FIELD_NATIVEDISPLAYID ); }
2010-12-31 18:12:20 +01:00
void RestoreDisplayId ();
2009-04-07 00:23:37 +02:00
void SetNativeDisplayId ( uint32 modelId ) { SetUInt32Value ( UNIT_FIELD_NATIVEDISPLAYID , modelId ); }
void setTransForm ( uint32 spellid ) { m_transform = spellid ;}
uint32 getTransForm () const { return m_transform ;}
2009-10-17 15:51:44 -07:00
2011-02-04 00:27:43 +01:00
// DynamicObject management
void _RegisterDynObject ( DynamicObject * dynObj );
void _UnregisterDynObject ( DynamicObject * dynObj );
2009-04-12 17:41:46 -05:00
DynamicObject * GetDynObject ( uint32 spellId );
2011-02-04 00:27:43 +01:00
void RemoveDynObject ( uint32 spellId );
2009-04-07 00:23:37 +02:00
void RemoveAllDynObjects ();
2009-10-17 15:51:44 -07:00
2009-04-12 17:41:46 -05:00
GameObject * GetGameObject ( uint32 spellId ) const ;
2009-04-07 00:23:37 +02:00
void AddGameObject ( GameObject * gameObj );
void RemoveGameObject ( GameObject * gameObj , bool del );
void RemoveGameObject ( uint32 spellid , bool del );
void RemoveAllGameObjects ();
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
void ModifyAuraState ( AuraStateType flag , bool apply );
2011-06-11 22:35:29 +02:00
uint32 BuildAuraStateUpdateForTarget ( Unit * target ) const ;
2012-05-30 08:01:02 +02:00
bool HasAuraState ( AuraStateType flag , SpellInfo const * spellProto = NULL , Unit const * Caster = NULL ) const ;
2009-04-07 00:23:37 +02:00
void UnsummonAllTotems ();
2014-10-18 21:13:37 +01:00
bool IsMagnet () const ;
2012-02-19 00:40:22 +01:00
Unit * GetMagicHitRedirectTarget ( Unit * victim , SpellInfo const * spellInfo );
Unit * GetMeleeHitRedirectTarget ( Unit * victim , SpellInfo const * spellInfo = NULL );
2012-05-30 08:01:02 +02:00
2014-06-04 15:49:48 +02:00
int32 SpellBaseDamageBonusDone ( SpellSchoolMask schoolMask ) const ;
int32 SpellBaseDamageBonusTaken ( SpellSchoolMask schoolMask ) const ;
2014-12-19 23:52:29 +01:00
uint32 SpellDamageBonusDone ( Unit * victim , SpellInfo const * spellProto , uint32 pdamage , DamageEffectType damagetype , SpellEffectInfo const * effect , uint32 stack = 1 ) const ;
2014-06-04 15:49:48 +02:00
float SpellDamagePctDone ( Unit * victim , SpellInfo const * spellProto , DamageEffectType damagetype ) const ;
2014-12-19 23:52:29 +01:00
uint32 SpellDamageBonusTaken ( Unit * caster , SpellInfo const * spellProto , uint32 pdamage , DamageEffectType damagetype , SpellEffectInfo const * effect , uint32 stack = 1 ) const ;
2014-06-04 15:49:48 +02:00
int32 SpellBaseHealingBonusDone ( SpellSchoolMask schoolMask ) const ;
int32 SpellBaseHealingBonusTaken ( SpellSchoolMask schoolMask ) const ;
2014-12-19 23:52:29 +01:00
uint32 SpellHealingBonusDone ( Unit * victim , SpellInfo const * spellProto , uint32 healamount , DamageEffectType damagetype , SpellEffectInfo const * effect , uint32 stack = 1 ) const ;
2014-06-04 15:49:48 +02:00
float SpellHealingPctDone ( Unit * victim , SpellInfo const * spellProto ) const ;
2014-12-19 23:52:29 +01:00
uint32 SpellHealingBonusTaken ( Unit * caster , SpellInfo const * spellProto , uint32 healamount , DamageEffectType damagetype , SpellEffectInfo const * effect , uint32 stack = 1 ) const ;
2012-05-30 08:01:02 +02:00
2013-01-14 09:50:59 +01:00
uint32 MeleeDamageBonusDone ( Unit * pVictim , uint32 damage , WeaponAttackType attType , SpellInfo const * spellProto = NULL );
uint32 MeleeDamageBonusTaken ( Unit * attacker , uint32 pdamage , WeaponAttackType attType , SpellInfo const * spellProto = NULL );
2012-05-30 08:01:02 +02:00
bool isSpellBlocked ( Unit * victim , SpellInfo const * spellProto , WeaponAttackType attackType = BASE_ATTACK );
2009-04-07 00:23:37 +02:00
bool isBlockCritical ();
2014-06-04 15:49:48 +02:00
bool IsSpellCrit ( Unit * victim , SpellInfo const * spellProto , SpellSchoolMask schoolMask , WeaponAttackType attackType = BASE_ATTACK ) const ;
float GetUnitSpellCriticalChance ( Unit * victim , SpellInfo const * spellProto , SpellSchoolMask schoolMask , WeaponAttackType attackType = BASE_ATTACK ) const ;
2012-05-30 08:01:02 +02:00
uint32 SpellCriticalDamageBonus ( SpellInfo const * spellProto , uint32 damage , Unit * victim );
uint32 SpellCriticalHealingBonus ( SpellInfo const * spellProto , uint32 damage , Unit * victim );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
void SetContestedPvP ( Player * attackedPlayer = NULL );
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
uint32 GetCastingTimeForBonus ( SpellInfo const * spellProto , DamageEffectType damagetype , uint32 CastingTime ) const ;
2013-01-14 09:50:59 +01:00
float CalculateDefaultCoefficient ( SpellInfo const * spellInfo , DamageEffectType damagetype ) const ;
2009-10-17 15:51:44 -07:00
2014-09-14 16:14:12 +02:00
uint32 GetRemainingPeriodicAmount ( ObjectGuid caster , uint32 spellId , AuraType auraType , uint8 effectIndex = 0 ) const ;
2010-07-21 01:42:02 +02:00
2009-04-07 00:23:37 +02:00
void ApplySpellImmune ( uint32 spellId , uint32 op , uint32 type , bool apply );
2011-09-15 14:08:17 +02:00
void ApplySpellDispelImmunity ( const SpellInfo * spellProto , DispelType type , bool apply );
2013-08-17 00:47:44 +02:00
virtual bool IsImmunedToSpell ( SpellInfo const * spellInfo ) const ; // redefined in Creature
2013-03-20 14:18:26 +01:00
bool IsImmunedToDamage ( SpellSchoolMask meleeSchoolMask ) const ;
bool IsImmunedToDamage ( SpellInfo const * spellInfo ) const ;
2013-08-17 00:47:44 +02:00
virtual bool IsImmunedToSpellEffect ( SpellInfo const * spellInfo , uint32 index ) const ; // redefined in Creature
2014-11-17 20:38:56 +01:00
bool IsDamageReducedByArmor ( SpellSchoolMask damageSchoolMask , SpellInfo const * spellInfo = NULL , uint8 effIndex = MAX_SPELL_EFFECTS );
2013-08-17 00:47:44 +02:00
uint32 CalcArmorReducedDamage ( Unit * victim , const uint32 damage , SpellInfo const * spellInfo , WeaponAttackType attackType = MAX_ATTACK );
uint32 CalcSpellResistance ( Unit * victim , SpellSchoolMask schoolMask , SpellInfo const * spellInfo ) const ;
void CalcAbsorbResist ( Unit * victim , SpellSchoolMask schoolMask , DamageEffectType damagetype , uint32 const damage , uint32 * absorb , uint32 * resist , SpellInfo const * spellInfo = NULL );
void CalcHealAbsorb ( Unit * victim , SpellInfo const * spellInfo , uint32 & healAmount , uint32 & absorb );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void UpdateSpeed ( UnitMoveType mtype , bool forced );
2010-04-07 22:59:46 +02:00
float GetSpeed ( UnitMoveType mtype ) const ;
float GetSpeedRate ( UnitMoveType mtype ) const { return m_speed_rate [ mtype ]; }
2009-04-07 00:23:37 +02:00
void SetSpeed ( UnitMoveType mtype , float rate , bool forced = false );
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
float ApplyEffectModifiers ( SpellInfo const * spellProto , uint8 effect_index , float value ) const ;
2014-12-19 18:55:09 +01:00
int32 CalculateSpellDamage ( Unit const * target , SpellInfo const * spellProto , uint8 effect_index , int32 const * basePoints = nullptr , float * variance = nullptr ) const ;
2011-07-26 23:09:28 +02:00
int32 CalcSpellDuration ( SpellInfo const * spellProto );
2011-10-20 18:28:37 +02:00
int32 ModSpellDuration ( SpellInfo const * spellProto , Unit const * target , int32 duration , bool positive , uint32 effectMask );
2013-08-18 01:41:10 +02:00
void ModSpellCastTime ( SpellInfo const * spellProto , int32 & castTime , Spell * spell = NULL );
2011-07-26 23:09:28 +02:00
float CalculateLevelPenalty ( SpellInfo const * spellProto ) const ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void addFollower ( FollowerReference * pRef ) { m_FollowingRefManager . insertFirst ( pRef ); }
2010-04-07 22:59:46 +02:00
void removeFollower ( FollowerReference * /*pRef*/ ) { /* nothing to do yet */ }
2009-10-17 15:51:44 -07:00
2013-12-12 09:50:52 +01:00
MotionMaster * GetMotionMaster () { return i_motionMaster ; }
const MotionMaster * GetMotionMaster () const { return i_motionMaster ; }
2010-04-07 18:09:10 +02:00
2012-02-03 19:12:41 +02:00
bool IsStopped () const { return ! ( HasUnitState ( UNIT_STATE_MOVING )); }
2009-04-07 00:23:37 +02:00
void StopMoving ();
2009-10-17 15:51:44 -07:00
2013-06-18 21:04:31 +02:00
void AddUnitMovementFlag ( uint32 f ) { m_movementInfo . AddMovementFlag ( f ); }
void RemoveUnitMovementFlag ( uint32 f ) { m_movementInfo . RemoveMovementFlag ( f ); }
bool HasUnitMovementFlag ( uint32 f ) const { return m_movementInfo . HasMovementFlag ( f ); }
uint32 GetUnitMovementFlags () const { return m_movementInfo . GetMovementFlags (); }
void SetUnitMovementFlags ( uint32 f ) { m_movementInfo . SetMovementFlags ( f ); }
2009-10-17 15:51:44 -07:00
2013-06-18 21:04:31 +02:00
void AddExtraUnitMovementFlag ( uint16 f ) { m_movementInfo . AddExtraMovementFlag ( f ); }
void RemoveExtraUnitMovementFlag ( uint16 f ) { m_movementInfo . RemoveExtraMovementFlag ( f ); }
uint16 HasExtraUnitMovementFlag ( uint16 f ) const { return m_movementInfo . HasExtraMovementFlag ( f ); }
uint16 GetExtraUnitMovementFlags () const { return m_movementInfo . GetExtraMovementFlags (); }
void SetExtraUnitMovementFlags ( uint16 f ) { m_movementInfo . SetExtraMovementFlags ( f ); }
2012-07-14 23:39:12 +02:00
bool IsSplineEnabled () const ;
2010-12-29 05:45:38 +01:00
2013-03-04 09:38:38 +01:00
float GetPositionZMinusOffset () const ;
2012-05-30 08:01:02 +02:00
2009-04-07 00:23:37 +02:00
void SetControlled ( bool apply , UnitState state );
2009-10-17 15:51:44 -07:00
2014-09-14 16:14:12 +02:00
void AddComboPointHolder ( ObjectGuid lowguid ) { m_ComboPointHolders . insert ( lowguid ); }
void RemoveComboPointHolder ( ObjectGuid lowguid ) { m_ComboPointHolders . erase ( lowguid ); }
2009-04-07 00:23:37 +02:00
void ClearComboPointHolders ();
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
///----------Pet responses methods-----------------
void SendPetActionFeedback ( uint8 msg );
void SendPetTalk ( uint32 pettalk );
2014-09-14 16:14:12 +02:00
void SendPetAIReaction ( ObjectGuid guid );
2009-04-07 00:23:37 +02:00
///----------End of Pet responses methods----------
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void propagateSpeedChange () { GetMotionMaster () -> propagateSpeedChange (); }
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// reactive attacks
void ClearAllReactives ();
2010-04-07 22:59:46 +02:00
void StartReactiveTimer ( ReactiveType reactive ) { m_reactiveTimer [ reactive ] = REACTIVE_TIMER_START ;}
2009-04-07 00:23:37 +02:00
void UpdateReactives ( uint32 p_time );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// group updates
void UpdateAuraForGroup ( uint8 slot );
2009-10-17 15:51:44 -07:00
2009-05-19 18:33:49 +02:00
// proc trigger system
2013-03-04 09:38:38 +01:00
bool CanProc () const { return ! m_procDeep ;}
void SetCantProc ( bool apply );
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
// pet auras
typedef std :: set < PetAura const *> PetAuraSet ;
PetAuraSet m_petAuras ;
void AddPetAura ( PetAura const * petSpell );
void RemovePetAura ( PetAura const * petSpell );
2009-10-17 15:51:44 -07:00
2012-11-25 10:23:24 +01:00
uint32 GetModelForForm ( ShapeshiftForm form ) const ;
2010-07-22 17:31:27 +02:00
uint32 GetModelForTotem ( PlayerTotemType totemType );
2009-12-17 12:25:31 +01:00
2013-01-22 00:20:16 +01:00
// Redirect Threat
2014-09-14 16:14:12 +02:00
void SetRedirectThreat ( ObjectGuid guid , uint32 pct ) { _redirectThreadInfo . Set ( guid , pct ); }
void ResetRedirectThreat () { SetRedirectThreat ( ObjectGuid :: Empty , 0 ); }
2013-01-22 00:20:16 +01:00
void ModifyRedirectThreat ( int32 amount ) { _redirectThreadInfo . ModifyThreatPct ( amount ); }
2013-03-04 09:38:38 +01:00
uint32 GetRedirectThreatPercent () const { return _redirectThreadInfo . GetThreatPct (); }
Unit * GetRedirectThreatTarget ();
2009-10-17 15:51:44 -07:00
2013-02-16 02:11:42 +01:00
friend class VehicleJoinEvent ;
2009-04-07 00:23:37 +02:00
bool IsAIEnabled , NeedChangeAI ;
2014-09-14 16:14:12 +02:00
ObjectGuid LastCharmerGUID ;
2011-02-27 03:53:24 +01:00
bool CreateVehicleKit ( uint32 id , uint32 creatureEntry );
2010-01-13 11:16:38 +01:00
void RemoveVehicleKit ();
2011-09-15 14:08:17 +02:00
Vehicle * GetVehicleKit () const { return m_vehicleKit ; }
Vehicle * GetVehicle () const { return m_vehicle ; }
2013-06-04 16:28:30 +02:00
void SetVehicle ( Vehicle * vehicle ) { m_vehicle = vehicle ; }
2013-03-04 09:38:38 +01:00
bool IsOnVehicle ( const Unit * vehicle ) const ;
2011-09-15 14:08:17 +02:00
Unit * GetVehicleBase () const ;
Creature * GetVehicleCreatureBase () const ;
2014-09-14 16:14:12 +02:00
ObjectGuid GetTransGUID () const override ;
2012-09-09 19:56:00 +02:00
/// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle)
TransportBase * GetDirectTransport () const ;
2009-10-17 15:51:44 -07:00
2009-04-19 19:45:54 -05:00
bool m_ControlledByPlayer ;
2009-10-17 15:51:44 -07:00
2011-02-26 23:00:09 +01:00
bool HandleSpellClick ( Unit * clicker , int8 seatId = - 1 );
2011-09-15 14:08:17 +02:00
void EnterVehicle ( Unit * base , int8 seatId = - 1 );
2011-02-25 01:38:21 +01:00
void ExitVehicle ( Position const * exitPosition = NULL );
2011-02-19 21:58:50 +01:00
void ChangeSeat ( int8 seatId , bool next = true );
2009-10-17 15:51:44 -07:00
2011-03-04 21:16:27 +01:00
// Should only be called by AuraEffect::HandleAuraControlVehicle(AuraApplication const* auraApp, uint8 mode, bool apply) const;
void _ExitVehicle ( Position const * exitPosition = NULL );
void _EnterVehicle ( Vehicle * vehicle , int8 seatId , AuraApplication const * aurApp = NULL );
2013-04-09 17:24:39 +02:00
void WriteMovementInfo ( WorldPacket & data , Movement :: ExtraMovementStatusElement * extras = NULL );
2009-10-17 15:51:44 -07:00
2011-07-19 20:37:17 +02:00
bool isMoving () const { return m_movementInfo . HasMovementFlag ( MOVEMENTFLAG_MASK_MOVING ); }
bool isTurning () const { return m_movementInfo . HasMovementFlag ( MOVEMENTFLAG_MASK_TURNING ); }
2012-05-30 08:01:02 +02:00
virtual bool CanFly () const = 0 ;
bool IsFlying () const { return m_movementInfo . HasMovementFlag ( MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY ); }
2013-06-07 16:05:39 +02:00
bool IsFalling () const ;
2009-10-17 15:51:44 -07:00
2012-08-12 17:49:06 -05:00
void RewardRage ( uint32 baseRage , bool attacker );
2009-10-17 15:51:44 -07:00
2010-08-22 12:39:39 -07:00
virtual float GetFollowAngle () const { return static_cast < float > ( M_PI / 2 ); }
2009-10-17 15:51:44 -07:00
2009-08-27 13:59:29 -05:00
void OutDebugInfo () const ;
2014-09-19 03:30:02 +01:00
virtual bool IsLoading () const { return false ; }
2010-08-03 06:11:03 +02:00
bool IsDuringRemoveFromWorld () const { return m_duringRemoveFromWorld ;}
2010-03-07 15:20:19 +01:00
2013-06-11 18:39:51 -02:30
Pet * ToPet () { if ( IsPet ()) return reinterpret_cast < Pet *> ( this ); else return NULL ; }
Pet const * ToPet () const { if ( IsPet ()) return reinterpret_cast < Pet const *> ( this ); else return NULL ; }
2012-09-01 05:03:15 +02:00
2013-06-11 19:54:27 -02:30
Totem * ToTotem () { if ( IsTotem ()) return reinterpret_cast < Totem *> ( this ); else return NULL ; }
Totem const * ToTotem () const { if ( IsTotem ()) return reinterpret_cast < Totem const *> ( this ); else return NULL ; }
2012-09-01 05:03:15 +02:00
2013-06-11 19:54:27 -02:30
TempSummon * ToTempSummon () { if ( IsSummon ()) return reinterpret_cast < TempSummon *> ( this ); else return NULL ; }
TempSummon const * ToTempSummon () const { if ( IsSummon ()) return reinterpret_cast < TempSummon const *> ( this ); else return NULL ; }
2010-03-07 15:20:19 +01:00
2014-09-14 16:14:12 +02:00
ObjectGuid GetTarget () const { return GetGuidValue ( UNIT_FIELD_TARGET ); }
2014-11-23 04:25:47 +01:00
virtual void SetTarget ( ObjectGuid const & /*guid*/ ) = 0 ;
2011-07-15 12:33:03 +02:00
2012-01-14 15:34:41 +01:00
// Movement info
Movement :: MoveSpline * movespline ;
2012-09-22 02:11:31 +01:00
// Part of Evade mechanics
time_t GetLastDamagedTime () const { return _lastDamagedTime ; }
void SetLastDamagedTime ( time_t val ) { _lastDamagedTime = val ; }
2014-06-16 02:48:48 +01:00
int32 GetHighestExclusiveSameEffectSpellGroupValue ( AuraEffect const * aurEff , AuraType auraType , bool checkMiscValue = false , int32 miscValue = 0 ) const ;
2014-06-15 17:27:57 +01:00
bool IsHighestExclusiveAura ( Aura const * aura , bool removeOtherAuraApplications = false );
2014-06-07 23:43:11 +01:00
2014-09-13 20:41:31 +02:00
virtual void Talk ( std :: string const & text , ChatMsg msgType , Language language , float textRange , WorldObject const * target );
virtual void Say ( std :: string const & text , Language language , WorldObject const * target = nullptr );
virtual void Yell ( std :: string const & text , Language language , WorldObject const * target = nullptr );
virtual void TextEmote ( std :: string const & text , WorldObject const * target = nullptr , bool isBossEmote = false );
virtual void Whisper ( std :: string const & text , Language language , Player * target , bool isBossWhisper = false );
void Talk ( uint32 textId , ChatMsg msgType , float textRange , WorldObject const * target );
void Say ( uint32 textId , WorldObject const * target = nullptr );
void Yell ( uint32 textId , WorldObject const * target = nullptr );
void TextEmote ( uint32 textId , WorldObject const * target = nullptr , bool isBossEmote = false );
void Whisper ( uint32 textId , Player * target , bool isBossWhisper = false );
2009-04-07 00:23:37 +02:00
protected :
2011-12-20 17:05:08 -05:00
explicit Unit ( bool isWorldObject );
2009-10-17 15:51:44 -07:00
2014-08-09 20:17:40 +01:00
void BuildValuesUpdate ( uint8 updatetype , ByteBuffer * data , Player * target ) const override ;
2015-01-01 20:38:19 +01:00
void DestroyForPlayer ( Player * target ) const override ;
2013-06-15 15:16:36 +02:00
2011-09-15 14:08:17 +02:00
UnitAI * i_AI , * i_disabledAI ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void _UpdateSpells ( uint32 time );
2010-01-10 01:23:15 +01:00
void _DeleteRemovedAuras ();
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
void _UpdateAutoRepeatSpell ();
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
bool m_AutoRepeatFirstCast ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
uint32 m_attackTimer [ MAX_ATTACK ];
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
float m_createStats [ MAX_STATS ];
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
AttackerSet m_attackers ;
Unit * m_attacking ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
DeathState m_deathState ;
2009-10-17 15:51:44 -07:00
2009-05-19 18:33:49 +02:00
int32 m_procDeep ;
2009-10-17 15:51:44 -07:00
2011-02-04 00:27:43 +01:00
typedef std :: list < DynamicObject *> DynObjectList ;
DynObjectList m_dynObj ;
2009-10-17 15:51:44 -07:00
2009-04-12 17:41:46 -05:00
typedef std :: list < GameObject *> GameObjectList ;
GameObjectList m_gameObj ;
2013-11-24 21:49:51 +01:00
2009-04-07 00:23:37 +02:00
uint32 m_transform ;
2009-10-17 15:51:44 -07:00
2011-06-21 19:58:11 +02:00
Spell * m_currentSpells [ CURRENT_MAX_SPELL ];
2010-01-10 01:23:15 +01:00
AuraMap m_ownedAuras ;
AuraApplicationMap m_appliedAuras ;
2009-04-07 20:27:34 +02:00
AuraList m_removedAuras ;
2010-01-10 01:23:15 +01:00
AuraMap :: iterator m_auraUpdateIterator ;
uint32 m_removedAurasCount ;
AuraEffectList m_modAuras [ TOTAL_AURAS ];
2013-12-25 14:16:55 -03:30
AuraList m_scAuras ; // cast singlecast auras
AuraApplicationList m_interruptableAuras ; // auras which have interrupt mask applied on unit
2010-01-10 01:23:15 +01:00
AuraStateAurasMap m_auraStateAuras ; // Used for improve performance of aura state checks on aura apply/remove
2009-04-07 00:23:37 +02:00
uint32 m_interruptMask ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
float m_auraModifiersGroup [ UNIT_MOD_END ][ MODIFIER_TYPE_END ];
float m_weaponDamage [ MAX_ATTACK ][ 2 ];
bool m_canModifyStats ;
VisibleAuraMap m_visibleAuras ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
float m_speed_rate [ MAX_MOVE_TYPE ];
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
CharmInfo * m_charmInfo ;
2009-04-07 00:23:37 +02:00
SharedVisionList m_sharedVision ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
virtual SpellSchoolMask GetMeleeDamageSchoolMask () const ;
2009-10-17 15:51:44 -07:00
2013-12-12 09:50:52 +01:00
MotionMaster * i_motionMaster ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
uint32 m_reactiveTimer [ MAX_REACTIVE ];
2009-09-22 16:14:37 -07:00
uint32 m_regenTimer ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
ThreatManager m_ThreatManager ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Vehicle * m_vehicle ;
Vehicle * m_vehicleKit ;
2009-10-17 15:51:44 -07:00
2009-08-23 22:09:43 -05:00
uint32 m_unitTypeMask ;
2012-05-30 08:01:02 +02:00
LiquidTypeEntry const * _lastLiquid ;
2009-10-17 15:51:44 -07:00
2014-08-09 20:17:40 +01:00
bool IsAlwaysVisibleFor ( WorldObject const * seer ) const override ;
bool IsAlwaysDetectableFor ( WorldObject const * seer ) const override ;
2012-01-14 15:34:41 +01:00
void DisableSpline ();
2009-04-07 00:23:37 +02:00
private :
2012-05-30 08:01:02 +02:00
bool IsTriggeredAtSpellProcEvent ( Unit * victim , Aura * aura , SpellInfo const * procSpell , uint32 procFlag , uint32 procExtra , WeaponAttackType attType , bool isVictim , bool active , SpellProcEventEntry const * & spellProcEvent );
bool HandleDummyAuraProc ( Unit * victim , uint32 damage , AuraEffect * triggeredByAura , SpellInfo const * procSpell , uint32 procFlag , uint32 procEx , uint32 cooldown );
bool HandleAuraProc ( Unit * victim , uint32 damage , Aura * triggeredByAura , SpellInfo const * procSpell , uint32 procFlag , uint32 procEx , uint32 cooldown , bool * handled );
bool HandleProcTriggerSpell ( Unit * victim , uint32 damage , AuraEffect * triggeredByAura , SpellInfo const * procSpell , uint32 procFlag , uint32 procEx , uint32 cooldown );
bool HandleOverrideClassScriptAuraProc ( Unit * victim , uint32 damage , AuraEffect * triggeredByAura , SpellInfo const * procSpell , uint32 cooldown );
2009-04-07 00:23:37 +02:00
bool HandleAuraRaidProcFromChargeWithValue ( AuraEffect * triggeredByAura );
bool HandleAuraRaidProcFromCharge ( AuraEffect * triggeredByAura );
2009-10-17 15:51:44 -07:00
2012-01-14 15:34:41 +01:00
void UpdateSplineMovement ( uint32 t_diff );
2012-08-11 20:18:00 +02:00
void UpdateSplinePosition ();
2012-01-14 15:34:41 +01:00
2009-12-19 18:46:51 +01:00
// player or player's pet
float GetCombatRatingReduction ( CombatRating cr ) const ;
uint32 GetCombatRatingDamageReduction ( CombatRating cr , float rate , float cap , uint32 damage ) const ;
2012-07-18 15:00:48 +02:00
protected :
2009-04-07 00:23:37 +02:00
void SetFeared ( bool apply );
void SetConfused ( bool apply );
void SetStunned ( bool apply );
2013-06-28 17:00:57 +02:00
void SetRooted ( bool apply , bool packetOnly = false );
2009-10-17 15:51:44 -07:00
2013-04-03 20:13:33 +02:00
uint32 m_movementCounter ; ///< Incrementing counter used in movement packets
2012-07-18 15:00:48 +02:00
private :
2010-10-05 23:02:46 -03:00
2009-04-07 00:23:37 +02:00
uint32 m_state ; // Even derived shouldn't modify
uint32 m_CombatTimer ;
2012-01-14 15:34:41 +01:00
TimeTrackerSmall m_movesplineTimer ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
Diminishing m_Diminishing ;
// Manage all Units that are threatened by us
2010-03-09 11:11:10 +01:00
HostileRefManager m_HostileRefManager ;
2009-10-17 15:51:44 -07:00
2009-04-07 00:23:37 +02:00
FollowerRefManager m_FollowingRefManager ;
2009-10-17 15:51:44 -07:00
2014-09-14 16:14:12 +02:00
GuidSet m_ComboPointHolders ;
2009-10-17 15:51:44 -07:00
2013-01-22 00:20:16 +01:00
RedirectThreatInfo _redirectThreadInfo ;
2010-01-18 18:42:36 +01:00
2010-08-03 06:11:03 +02:00
bool m_cleanupDone ; // lock made to not add stuff after cleanup before delete
bool m_duringRemoveFromWorld ; // lock made to not add stuff after begining removing from world
2011-07-15 12:33:03 +02:00
2014-01-17 01:07:37 +01:00
uint32 _oldFactionId ; ///< faction before charm
bool _isWalkingBeforeCharm ; ///< Are we walking before we were charmed?
2012-09-22 02:11:31 +01:00
time_t _lastDamagedTime ; // Part of Evade mechanics
2014-08-30 21:09:46 +02:00
uint16 _aiAnimKitId ;
uint16 _movementAnimKitId ;
uint16 _meleeAnimKitId ;
2015-02-17 01:01:44 +01:00
SpellHistory * _spellHistory ;
2009-04-07 00:23:37 +02:00
};
2009-10-17 15:51:44 -07:00
2009-04-11 13:42:34 -05:00
namespace Trinity
{
2010-05-30 04:23:27 +02:00
// Binary predicate for sorting Units based on percent value of a power
class PowerPctOrderPred
2009-04-11 13:42:34 -05:00
{
2010-05-30 04:23:27 +02:00
public :
2014-01-17 01:07:37 +01:00
PowerPctOrderPred ( Powers power , bool ascending = true ) : _power ( power ), _ascending ( ascending ) { }
2014-01-26 01:02:20 +01:00
bool operator ()( WorldObject const * objA , WorldObject const * objB ) const
{
Unit const * a = objA -> ToUnit ();
Unit const * b = objB -> ToUnit ();
float rA = ( a && a -> GetMaxPower ( _power )) ? float ( a -> GetPower ( _power )) / float ( a -> GetMaxPower ( _power )) : 0.0f ;
float rB = ( b && b -> GetMaxPower ( _power )) ? float ( b -> GetPower ( _power )) / float ( b -> GetMaxPower ( _power )) : 0.0f ;
return _ascending ? rA < rB : rA > rB ;
}
bool operator ()( Unit const * a , Unit const * b ) const
2010-08-08 19:45:53 +02:00
{
2014-01-17 01:07:37 +01:00
float rA = a -> GetMaxPower ( _power ) ? float ( a -> GetPower ( _power )) / float ( a -> GetMaxPower ( _power )) : 0.0f ;
float rB = b -> GetMaxPower ( _power ) ? float ( b -> GetPower ( _power )) / float ( b -> GetMaxPower ( _power )) : 0.0f ;
return _ascending ? rA < rB : rA > rB ;
2010-05-30 04:23:27 +02:00
}
2014-01-26 01:02:20 +01:00
2010-05-30 04:23:27 +02:00
private :
2014-01-17 01:07:37 +01:00
Powers const _power ;
bool const _ascending ;
2010-05-30 04:23:27 +02:00
};
2010-08-08 19:45:53 +02:00
2010-05-30 04:23:27 +02:00
// Binary predicate for sorting Units based on percent value of health
class HealthPctOrderPred
2010-02-27 16:29:58 +01:00
{
2010-05-30 04:23:27 +02:00
public :
2014-01-17 01:07:37 +01:00
HealthPctOrderPred ( bool ascending = true ) : _ascending ( ascending ) { }
2014-01-26 01:02:20 +01:00
bool operator ()( WorldObject const * objA , WorldObject const * objB ) const
{
Unit const * a = objA -> ToUnit ();
Unit const * b = objB -> ToUnit ();
float rA = ( a && a -> GetMaxHealth ()) ? float ( a -> GetHealth ()) / float ( a -> GetMaxHealth ()) : 0.0f ;
float rB = ( b && b -> GetMaxHealth ()) ? float ( b -> GetHealth ()) / float ( b -> GetMaxHealth ()) : 0.0f ;
return _ascending ? rA < rB : rA > rB ;
}
2014-01-17 01:07:37 +01:00
bool operator () ( Unit const * a , Unit const * b ) const
2010-08-08 19:45:53 +02:00
{
2010-05-30 04:23:27 +02:00
float rA = a -> GetMaxHealth () ? float ( a -> GetHealth ()) / float ( a -> GetMaxHealth ()) : 0.0f ;
float rB = b -> GetMaxHealth () ? float ( b -> GetHealth ()) / float ( b -> GetMaxHealth ()) : 0.0f ;
2014-01-17 01:07:37 +01:00
return _ascending ? rA < rB : rA > rB ;
2010-05-30 04:23:27 +02:00
}
2014-01-26 01:02:20 +01:00
2010-05-30 04:23:27 +02:00
private :
2014-01-17 01:07:37 +01:00
bool const _ascending ;
2010-05-30 04:23:27 +02:00
};
}
2009-04-07 00:23:37 +02:00
#endif