2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "ItemPrototype.h"
27 #include "Database/DatabaseEnv.h"
28 #include "NPCHandler.h"
32 #include "WorldSession.h"
34 #include "MapReference.h"
35 #include "Util.h" // for Tokens typedef
36 #include "AchievementMgr.h"
37 #include "ReputationMgr.h"
38 #include "BattleGround.h"
51 class SpellCastTargets
;
55 typedef std::deque
<Mail
*> PlayerMails
;
57 #define PLAYER_MAX_SKILLS 127
58 #define PLAYER_MAX_DAILY_QUESTS 25
60 // Note: SPELLMOD_* values is aura types in fact
63 SPELLMOD_FLAT
= 107, // SPELL_AURA_ADD_FLAT_MODIFIER
64 SPELLMOD_PCT
= 108 // SPELL_AURA_ADD_PCT_MODIFIER
67 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
68 enum PlayerUnderwaterState
70 UNDERWATER_NONE
= 0x00,
71 UNDERWATER_INWATER
= 0x01, // terrain type is water and player is afflicted by it
72 UNDERWATER_INLAVA
= 0x02, // terrain type is lava and player is afflicted by it
73 UNDERWATER_INSLIME
= 0x04, // terrain type is lava and player is afflicted by it
74 UNDERWARER_INDARKWATER
= 0x08, // terrain type is dark water and player is afflicted by it
76 UNDERWATER_EXIST_TIMERS
= 0x10
81 PLAYERSPELL_UNCHANGED
= 0,
82 PLAYERSPELL_CHANGED
= 1,
84 PLAYERSPELL_REMOVED
= 3
89 PlayerSpellState state
: 8;
90 bool active
: 1; // show in spellbook
91 bool dependent
: 1; // learned as result another spell learn, skill grow, quest reward, etc
92 bool disabled
: 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
95 // Spell modifier (used for modify other spells)
98 SpellModifier() : charges(0), lastAffected(NULL
) {}
100 SpellModType type
: 8;
106 Spell
const* lastAffected
;
109 typedef UNORDERED_MAP
<uint32
, PlayerSpell
*> PlayerSpellMap
;
110 typedef std::list
<SpellModifier
*> SpellModList
;
118 typedef std::map
<uint32
, SpellCooldown
> SpellCooldowns
;
120 enum TrainerSpellState
122 TRAINER_SPELL_GREEN
= 0,
123 TRAINER_SPELL_RED
= 1,
124 TRAINER_SPELL_GRAY
= 2,
125 TRAINER_SPELL_GREEN_DISABLED
= 10 // custom value, not send to client: formally green but learn not allowed
128 enum ActionButtonUpdateState
130 ACTIONBUTTON_UNCHANGED
= 0,
131 ACTIONBUTTON_CHANGED
= 1,
132 ACTIONBUTTON_NEW
= 2,
133 ACTIONBUTTON_DELETED
= 3
136 enum ActionButtonType
138 ACTION_BUTTON_SPELL
= 0,
139 ACTION_BUTTON_EQSET
= 32,
140 ACTION_BUTTON_MACRO
= 64,
141 ACTION_BUTTON_CMACRO
= 65,
142 ACTION_BUTTON_ITEM
= 128
145 #define ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
146 #define ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
147 #define MAX_ACTION_BUTTON_ACTION_VALUE (0x00FFFFFF+1)
151 ActionButton() : packedData(0), uState( ACTIONBUTTON_NEW
) {}
154 ActionButtonUpdateState uState
;
157 ActionButtonType
GetType() const { return ActionButtonType(ACTION_BUTTON_TYPE(packedData
)); }
158 uint32
GetAction() const { return ACTION_BUTTON_ACTION(packedData
); }
159 void SetActionAndType(uint32 action
, ActionButtonType type
)
161 uint32 newData
= action
| (uint32(type
) << 24);
162 if (newData
!= packedData
)
164 packedData
= newData
;
165 if (uState
!= ACTIONBUTTON_NEW
)
166 uState
= ACTIONBUTTON_CHANGED
;
171 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
173 typedef std::map
<uint8
,ActionButton
> ActionButtonList
;
175 struct PlayerCreateInfoItem
177 PlayerCreateInfoItem(uint32 id
, uint32 amount
) : item_id(id
), item_amount(amount
) {}
183 typedef std::list
<PlayerCreateInfoItem
> PlayerCreateInfoItems
;
185 struct PlayerClassLevelInfo
187 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
192 struct PlayerClassInfo
194 PlayerClassInfo() : levelInfo(NULL
) { }
196 PlayerClassLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
199 struct PlayerLevelInfo
201 PlayerLevelInfo() { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
203 uint8 stats
[MAX_STATS
];
206 typedef std::list
<uint32
> PlayerCreateInfoSpells
;
208 struct PlayerCreateInfoAction
210 PlayerCreateInfoAction() : button(0), type(0), action(0) {}
211 PlayerCreateInfoAction(uint8 _button
, uint32 _action
, uint8 _type
) : button(_button
), type(_type
), action(_action
) {}
218 typedef std::list
<PlayerCreateInfoAction
> PlayerCreateInfoActions
;
222 // existence checked by displayId != 0 // existence checked by displayId != 0
223 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL
)
234 PlayerCreateInfoItems item
;
235 PlayerCreateInfoSpells spell
;
236 PlayerCreateInfoActions action
;
238 PlayerLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
243 PvPInfo() : inHostileArea(false), endTimer(0) {}
251 DuelInfo() : initiator(NULL
), opponent(NULL
), startTimer(0), startTime(0), outOfBound(0) {}
271 #define RUNE_COOLDOWN 5 // 5*2=10 sec
291 RuneInfo runes
[MAX_RUNES
];
292 uint8 runeState
; // mask of available runes
294 void SetRuneState(uint8 index
, bool set
= true)
297 runeState
|= (1 << index
); // usable
299 runeState
&= ~(1 << index
); // on cooldown
303 struct EnchantDuration
305 EnchantDuration() : item(NULL
), slot(MAX_ENCHANTMENT_SLOT
), leftduration(0) {};
306 EnchantDuration(Item
* _item
, EnchantmentSlot _slot
, uint32 _leftduration
) : item(_item
), slot(_slot
), leftduration(_leftduration
) { assert(item
); };
309 EnchantmentSlot slot
;
313 typedef std::list
<EnchantDuration
> EnchantDurationList
;
314 typedef std::list
<Item
*> ItemDurationList
;
319 LFG_TYPE_DUNGEON
= 1,
323 LFG_TYPE_HEROIC_DUNGEON
= 5
334 struct LookingForGroupSlot
336 LookingForGroupSlot() : entry(0), type(0) {}
337 bool Empty() const { return !entry
&& !type
; }
338 void Clear() { entry
= 0; type
= 0; }
339 void Set(uint32 _entry
, uint32 _type
) { entry
= _entry
; type
= _type
; }
340 bool Is(uint32 _entry
, uint32 _type
) const { return entry
== _entry
&& type
== _type
; }
341 bool canAutoJoin() const { return entry
&& (type
== LFG_TYPE_DUNGEON
|| type
== LFG_TYPE_HEROIC_DUNGEON
); }
347 #define MAX_LOOKING_FOR_GROUP_SLOT 3
349 struct LookingForGroup
352 bool HaveInSlot(LookingForGroupSlot
const& slot
) const { return HaveInSlot(slot
.entry
, slot
.type
); }
353 bool HaveInSlot(uint32 _entry
, uint32 _type
) const
355 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
356 if(slots
[i
].Is(_entry
, _type
))
361 bool canAutoJoin() const
363 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
364 if(slots
[i
].canAutoJoin())
371 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
372 if(!slots
[i
].Empty())
377 LookingForGroupSlot slots
[MAX_LOOKING_FOR_GROUP_SLOT
];
378 LookingForGroupSlot more
;
383 enum PlayerMovementType
399 #define MAX_DRUNKEN 4
403 PLAYER_FLAGS_GROUP_LEADER
= 0x00000001,
404 PLAYER_FLAGS_AFK
= 0x00000002,
405 PLAYER_FLAGS_DND
= 0x00000004,
406 PLAYER_FLAGS_GM
= 0x00000008,
407 PLAYER_FLAGS_GHOST
= 0x00000010,
408 PLAYER_FLAGS_RESTING
= 0x00000020,
409 PLAYER_FLAGS_UNK7
= 0x00000040,
410 PLAYER_FLAGS_UNK8
= 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
411 PLAYER_FLAGS_CONTESTED_PVP
= 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
412 PLAYER_FLAGS_IN_PVP
= 0x00000200,
413 PLAYER_FLAGS_HIDE_HELM
= 0x00000400,
414 PLAYER_FLAGS_HIDE_CLOAK
= 0x00000800,
415 PLAYER_FLAGS_UNK13
= 0x00001000, // played long time
416 PLAYER_FLAGS_UNK14
= 0x00002000, // played too long time
417 PLAYER_FLAGS_UNK15
= 0x00004000,
418 PLAYER_FLAGS_UNK16
= 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
419 PLAYER_FLAGS_UNK17
= 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
420 PLAYER_FLAGS_UNK18
= 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
421 PLAYER_FLAGS_PVP_TIMER
= 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
422 PLAYER_FLAGS_UNK20
= 0x00080000,
423 PLAYER_FLAGS_UNK21
= 0x00100000,
424 PLAYER_FLAGS_UNK22
= 0x00200000,
425 PLAYER_FLAGS_UNK23
= 0x00400000,
426 PLAYER_FLAGS_UNK24
= 0x00800000, // disabled all abilitys on tab except autoattack
427 PLAYER_FLAGS_UNK25
= 0x01000000, // disabled all melee ability on tab include autoattack
431 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
432 // can't use enum for uint64 values
433 #define PLAYER_TITLE_DISABLED UI64LIT(0x0000000000000000)
434 #define PLAYER_TITLE_NONE UI64LIT(0x0000000000000001)
435 #define PLAYER_TITLE_PRIVATE UI64LIT(0x0000000000000002) // 1
436 #define PLAYER_TITLE_CORPORAL UI64LIT(0x0000000000000004) // 2
437 #define PLAYER_TITLE_SERGEANT_A UI64LIT(0x0000000000000008) // 3
438 #define PLAYER_TITLE_MASTER_SERGEANT UI64LIT(0x0000000000000010) // 4
439 #define PLAYER_TITLE_SERGEANT_MAJOR UI64LIT(0x0000000000000020) // 5
440 #define PLAYER_TITLE_KNIGHT UI64LIT(0x0000000000000040) // 6
441 #define PLAYER_TITLE_KNIGHT_LIEUTENANT UI64LIT(0x0000000000000080) // 7
442 #define PLAYER_TITLE_KNIGHT_CAPTAIN UI64LIT(0x0000000000000100) // 8
443 #define PLAYER_TITLE_KNIGHT_CHAMPION UI64LIT(0x0000000000000200) // 9
444 #define PLAYER_TITLE_LIEUTENANT_COMMANDER UI64LIT(0x0000000000000400) // 10
445 #define PLAYER_TITLE_COMMANDER UI64LIT(0x0000000000000800) // 11
446 #define PLAYER_TITLE_MARSHAL UI64LIT(0x0000000000001000) // 12
447 #define PLAYER_TITLE_FIELD_MARSHAL UI64LIT(0x0000000000002000) // 13
448 #define PLAYER_TITLE_GRAND_MARSHAL UI64LIT(0x0000000000004000) // 14
449 #define PLAYER_TITLE_SCOUT UI64LIT(0x0000000000008000) // 15
450 #define PLAYER_TITLE_GRUNT UI64LIT(0x0000000000010000) // 16
451 #define PLAYER_TITLE_SERGEANT_H UI64LIT(0x0000000000020000) // 17
452 #define PLAYER_TITLE_SENIOR_SERGEANT UI64LIT(0x0000000000040000) // 18
453 #define PLAYER_TITLE_FIRST_SERGEANT UI64LIT(0x0000000000080000) // 19
454 #define PLAYER_TITLE_STONE_GUARD UI64LIT(0x0000000000100000) // 20
455 #define PLAYER_TITLE_BLOOD_GUARD UI64LIT(0x0000000000200000) // 21
456 #define PLAYER_TITLE_LEGIONNAIRE UI64LIT(0x0000000000400000) // 22
457 #define PLAYER_TITLE_CENTURION UI64LIT(0x0000000000800000) // 23
458 #define PLAYER_TITLE_CHAMPION UI64LIT(0x0000000001000000) // 24
459 #define PLAYER_TITLE_LIEUTENANT_GENERAL UI64LIT(0x0000000002000000) // 25
460 #define PLAYER_TITLE_GENERAL UI64LIT(0x0000000004000000) // 26
461 #define PLAYER_TITLE_WARLORD UI64LIT(0x0000000008000000) // 27
462 #define PLAYER_TITLE_HIGH_WARLORD UI64LIT(0x0000000010000000) // 28
463 #define PLAYER_TITLE_GLADIATOR UI64LIT(0x0000000020000000) // 29
464 #define PLAYER_TITLE_DUELIST UI64LIT(0x0000000040000000) // 30
465 #define PLAYER_TITLE_RIVAL UI64LIT(0x0000000080000000) // 31
466 #define PLAYER_TITLE_CHALLENGER UI64LIT(0x0000000100000000) // 32
467 #define PLAYER_TITLE_SCARAB_LORD UI64LIT(0x0000000200000000) // 33
468 #define PLAYER_TITLE_CONQUEROR UI64LIT(0x0000000400000000) // 34
469 #define PLAYER_TITLE_JUSTICAR UI64LIT(0x0000000800000000) // 35
470 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU UI64LIT(0x0000001000000000) // 36
471 #define PLAYER_TITLE_MERCILESS_GLADIATOR UI64LIT(0x0000002000000000) // 37
472 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN UI64LIT(0x0000004000000000) // 38
473 #define PLAYER_TITLE_HAND_OF_ADAL UI64LIT(0x0000008000000000) // 39
474 #define PLAYER_TITLE_VENGEFUL_GLADIATOR UI64LIT(0x0000010000000000) // 40
476 // used in PLAYER_FIELD_BYTES values
477 enum PlayerFieldByteFlags
479 PLAYER_FIELD_BYTE_TRACK_STEALTHED
= 0x00000002,
480 PLAYER_FIELD_BYTE_RELEASE_TIMER
= 0x00000008, // Display time till auto release spirit
481 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW
= 0x00000010 // Display no "release spirit" window at all
484 // used in PLAYER_FIELD_BYTES2 values
485 enum PlayerFieldByte2Flags
487 PLAYER_FIELD_BYTE2_NONE
= 0x0000,
488 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
= 0x4000
491 enum ActivateTaxiReplies
494 ERR_TAXIUNSPECIFIEDSERVERERROR
= 1,
495 ERR_TAXINOSUCHPATH
= 2,
496 ERR_TAXINOTENOUGHMONEY
= 3,
497 ERR_TAXITOOFARAWAY
= 4,
498 ERR_TAXINOVENDORNEARBY
= 5,
499 ERR_TAXINOTVISITED
= 6,
500 ERR_TAXIPLAYERBUSY
= 7,
501 ERR_TAXIPLAYERALREADYMOUNTED
= 8,
502 ERR_TAXIPLAYERSHAPESHIFTED
= 9,
503 ERR_TAXIPLAYERMOVING
= 10,
504 ERR_TAXISAMENODE
= 11,
505 ERR_TAXINOTSTANDING
= 12
517 #define DISABLED_MIRROR_TIMER -1
520 enum PlayerExtraFlags
523 PLAYER_EXTRA_GM_ON
= 0x0001,
524 PLAYER_EXTRA_GM_ACCEPT_TICKETS
= 0x0002,
525 PLAYER_EXTRA_ACCEPT_WHISPERS
= 0x0004,
526 PLAYER_EXTRA_TAXICHEAT
= 0x0008,
527 PLAYER_EXTRA_GM_INVISIBLE
= 0x0010,
528 PLAYER_EXTRA_GM_CHAT
= 0x0020, // Show GM badge in chat messages
531 PLAYER_EXTRA_PVP_DEATH
= 0x0100 // store PvP death status until corpse creating.
537 AT_LOGIN_NONE
= 0x00,
538 AT_LOGIN_RENAME
= 0x01,
539 AT_LOGIN_RESET_SPELLS
= 0x02,
540 AT_LOGIN_RESET_TALENTS
= 0x04,
541 AT_LOGIN_CUSTOMIZE
= 0x08,
542 AT_LOGIN_RESET_PET_TALENTS
= 0x10,
545 typedef std::map
<uint32
, QuestStatusData
> QuestStatusMap
;
547 enum QuestSlotOffsets
550 QUEST_STATE_OFFSET
= 1,
551 QUEST_COUNTS_OFFSET
= 2,
552 QUEST_TIME_OFFSET
= 3
555 #define MAX_QUEST_OFFSET 4
557 enum QuestSlotStateMask
559 QUEST_STATE_NONE
= 0x0000,
560 QUEST_STATE_COMPLETE
= 0x0001,
561 QUEST_STATE_FAIL
= 0x0002
571 // first slot for item stored (in any way in player m_items data)
572 PLAYER_SLOT_START
= 0,
573 // last+1 slot for item stored (in any way in player m_items data)
574 PLAYER_SLOT_END
= 150,
575 PLAYER_SLOTS_COUNT
= (PLAYER_SLOT_END
- PLAYER_SLOT_START
)
578 #define INVENTORY_SLOT_BAG_0 255
580 enum EquipmentSlots
// 19 slots
582 EQUIPMENT_SLOT_START
= 0,
583 EQUIPMENT_SLOT_HEAD
= 0,
584 EQUIPMENT_SLOT_NECK
= 1,
585 EQUIPMENT_SLOT_SHOULDERS
= 2,
586 EQUIPMENT_SLOT_BODY
= 3,
587 EQUIPMENT_SLOT_CHEST
= 4,
588 EQUIPMENT_SLOT_WAIST
= 5,
589 EQUIPMENT_SLOT_LEGS
= 6,
590 EQUIPMENT_SLOT_FEET
= 7,
591 EQUIPMENT_SLOT_WRISTS
= 8,
592 EQUIPMENT_SLOT_HANDS
= 9,
593 EQUIPMENT_SLOT_FINGER1
= 10,
594 EQUIPMENT_SLOT_FINGER2
= 11,
595 EQUIPMENT_SLOT_TRINKET1
= 12,
596 EQUIPMENT_SLOT_TRINKET2
= 13,
597 EQUIPMENT_SLOT_BACK
= 14,
598 EQUIPMENT_SLOT_MAINHAND
= 15,
599 EQUIPMENT_SLOT_OFFHAND
= 16,
600 EQUIPMENT_SLOT_RANGED
= 17,
601 EQUIPMENT_SLOT_TABARD
= 18,
602 EQUIPMENT_SLOT_END
= 19
605 enum InventorySlots
// 4 slots
607 INVENTORY_SLOT_BAG_START
= 19,
608 INVENTORY_SLOT_BAG_END
= 23
611 enum InventoryPackSlots
// 16 slots
613 INVENTORY_SLOT_ITEM_START
= 23,
614 INVENTORY_SLOT_ITEM_END
= 39
617 enum BankItemSlots
// 28 slots
619 BANK_SLOT_ITEM_START
= 39,
620 BANK_SLOT_ITEM_END
= 67
623 enum BankBagSlots
// 7 slots
625 BANK_SLOT_BAG_START
= 67,
626 BANK_SLOT_BAG_END
= 74
629 enum BuyBackSlots
// 12 slots
631 // stored in m_buybackitems
632 BUYBACK_SLOT_START
= 74,
633 BUYBACK_SLOT_END
= 86
636 enum KeyRingSlots
// 32 slots
638 KEYRING_SLOT_START
= 86,
639 KEYRING_SLOT_END
= 118
642 enum CurrencyTokenSlots
// 32 slots
644 CURRENCYTOKEN_SLOT_START
= 118,
645 CURRENCYTOKEN_SLOT_END
= 150
648 enum EquipmentSetUpdateState
650 EQUIPMENT_SET_UNCHANGED
= 0,
651 EQUIPMENT_SET_CHANGED
= 1,
652 EQUIPMENT_SET_NEW
= 2,
653 EQUIPMENT_SET_DELETED
= 3
658 EquipmentSet() : Guid(0), state(EQUIPMENT_SET_NEW
)
660 for(int i
= 0; i
< EQUIPMENT_SLOT_END
; ++i
)
666 std::string IconName
;
667 uint32 Items
[EQUIPMENT_SLOT_END
];
668 EquipmentSetUpdateState state
;
671 #define MAX_EQUIPMENT_SET_INDEX 10 // client limit
673 typedef std::map
<uint32
, EquipmentSet
> EquipmentSets
;
677 ItemPosCount(uint16 _pos
, uint32 _count
) : pos(_pos
), count(_count
) {}
678 bool isContainedIn(std::vector
<ItemPosCount
> const& vec
) const;
682 typedef std::vector
<ItemPosCount
> ItemPosCountVec
;
686 TRADE_SLOT_COUNT
= 7,
687 TRADE_SLOT_TRADED_COUNT
= 6,
688 TRADE_SLOT_NONTRADED
= 6
691 enum TransferAbortReason
693 TRANSFER_ABORT_NONE
= 0x00,
694 TRANSFER_ABORT_ERROR
= 0x01,
695 TRANSFER_ABORT_MAX_PLAYERS
= 0x02, // Transfer Aborted: instance is full
696 TRANSFER_ABORT_NOT_FOUND
= 0x03, // Transfer Aborted: instance not found
697 TRANSFER_ABORT_TOO_MANY_INSTANCES
= 0x04, // You have entered too many instances recently.
698 TRANSFER_ABORT_ZONE_IN_COMBAT
= 0x06, // Unable to zone in while an encounter is in progress.
699 TRANSFER_ABORT_INSUF_EXPAN_LVL
= 0x07, // You must have <TBC,WotLK> expansion installed to access this area.
700 TRANSFER_ABORT_DIFFICULTY
= 0x08, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
701 TRANSFER_ABORT_UNIQUE_MESSAGE
= 0x09, // Until you've escaped TLK's grasp, you cannot leave this place!
702 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES
= 0x0A, // Additional instances cannot be launched, please try again later.
703 TRANSFER_ABORT_NEED_GROUP
= 0x0B, // 3.1
704 TRANSFER_ABORT_NOT_FOUND2
= 0x0C, // 3.1
705 TRANSFER_ABORT_NOT_FOUND3
= 0x0D, // 3.1
708 enum InstanceResetWarningType
710 RAID_INSTANCE_WARNING_HOURS
= 1, // WARNING! %s is scheduled to reset in %d hour(s).
711 RAID_INSTANCE_WARNING_MIN
= 2, // WARNING! %s is scheduled to reset in %d minute(s)!
712 RAID_INSTANCE_WARNING_MIN_SOON
= 3, // WARNING! %s is scheduled to reset in %d minute(s). Please exit the zone or you will be returned to your bind location!
713 RAID_INSTANCE_WELCOME
= 4, // Welcome to %s. This raid instance is scheduled to reset in %s.
714 RAID_INSTANCE_EXPIRED
= 5
717 // used in most movement packets (send and received)
720 MOVEMENTFLAG_NONE
= 0x00000000,
721 MOVEMENTFLAG_FORWARD
= 0x00000001,
722 MOVEMENTFLAG_BACKWARD
= 0x00000002,
723 MOVEMENTFLAG_STRAFE_LEFT
= 0x00000004,
724 MOVEMENTFLAG_STRAFE_RIGHT
= 0x00000008,
725 MOVEMENTFLAG_LEFT
= 0x00000010,
726 MOVEMENTFLAG_RIGHT
= 0x00000020,
727 MOVEMENTFLAG_PITCH_UP
= 0x00000040,
728 MOVEMENTFLAG_PITCH_DOWN
= 0x00000080,
729 MOVEMENTFLAG_WALK_MODE
= 0x00000100, // Walking
730 MOVEMENTFLAG_ONTRANSPORT
= 0x00000200, // Used for flying on some creatures
731 MOVEMENTFLAG_LEVITATING
= 0x00000400,
732 MOVEMENTFLAG_FLY_UNK1
= 0x00000800,
733 MOVEMENTFLAG_JUMPING
= 0x00001000,
734 MOVEMENTFLAG_UNK4
= 0x00002000,
735 MOVEMENTFLAG_FALLING
= 0x00004000,
736 // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
737 MOVEMENTFLAG_SWIMMING
= 0x00200000, // appears with fly flag also
738 MOVEMENTFLAG_FLY_UP
= 0x00400000,
739 MOVEMENTFLAG_CAN_FLY
= 0x00800000,
740 MOVEMENTFLAG_FLYING
= 0x01000000,
741 MOVEMENTFLAG_FLYING2
= 0x02000000, // Actual flying mode
742 MOVEMENTFLAG_SPLINE
= 0x04000000, // used for flight paths
743 MOVEMENTFLAG_SPLINE2
= 0x08000000, // used for flight paths
744 MOVEMENTFLAG_WATERWALKING
= 0x10000000, // prevent unit from falling through water
745 MOVEMENTFLAG_SAFE_FALL
= 0x20000000, // active rogue safe fall spell (passive)
746 MOVEMENTFLAG_UNK3
= 0x40000000
752 uint32 flags
; // see enum MovementFlags
758 float t_x
, t_y
, t_z
, t_o
;
761 // swimming and unknown
766 float j_unk
, j_sinAngle
, j_cosAngle
, j_xyspeed
;
772 flags
= MOVEMENTFLAG_NONE
;
773 time
= t_time
= fallTime
= 0;
775 x
= y
= z
= o
= t_x
= t_y
= t_z
= t_o
= s_pitch
= j_unk
= j_sinAngle
= j_cosAngle
= j_xyspeed
= u_unk1
= 0.0f
;
779 void AddMovementFlag(MovementFlags f
) { flags
|= f
; }
780 void RemoveMovementFlag(MovementFlags f
) { flags
&= ~f
; }
781 bool HasMovementFlag(MovementFlags f
) const { return flags
& f
; }
782 MovementFlags
GetMovementFlags() const { return MovementFlags(flags
); }
783 void SetMovementFlags(MovementFlags f
) { flags
= f
; }
786 // flags that use in movement check for example at spell casting
787 MovementFlags
const movementFlagsMask
= MovementFlags(
788 MOVEMENTFLAG_FORWARD
|MOVEMENTFLAG_BACKWARD
|MOVEMENTFLAG_STRAFE_LEFT
|MOVEMENTFLAG_STRAFE_RIGHT
|
789 MOVEMENTFLAG_PITCH_UP
|MOVEMENTFLAG_PITCH_DOWN
|MOVEMENTFLAG_FLY_UNK1
|
790 MOVEMENTFLAG_JUMPING
|MOVEMENTFLAG_FALLING
|MOVEMENTFLAG_FLY_UP
|
791 MOVEMENTFLAG_FLYING
|MOVEMENTFLAG_SPLINE
794 MovementFlags
const movementOrTurningFlagsMask
= MovementFlags(
795 movementFlagsMask
| MOVEMENTFLAG_LEFT
| MOVEMENTFLAG_RIGHT
802 REST_TYPE_IN_TAVERN
= 1,
803 REST_TYPE_IN_CITY
= 2
806 enum DuelCompleteType
813 enum TeleportToOptions
815 TELE_TO_GM_MODE
= 0x01,
816 TELE_TO_NOT_LEAVE_TRANSPORT
= 0x02,
817 TELE_TO_NOT_LEAVE_COMBAT
= 0x04,
818 TELE_TO_NOT_UNSUMMON_PET
= 0x08,
819 TELE_TO_SPELL
= 0x10,
822 /// Type of environmental damages
823 enum EnviromentalDamage
825 DAMAGE_EXHAUSTED
= 0,
831 DAMAGE_FALL_TO_VOID
= 6 // custom case for fall without durability loss
834 // used at player loading query list preparing, and later result selection
835 enum PlayerLoginQueryIndex
837 PLAYER_LOGIN_QUERY_LOADFROM
= 0,
838 PLAYER_LOGIN_QUERY_LOADGROUP
= 1,
839 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES
= 2,
840 PLAYER_LOGIN_QUERY_LOADAURAS
= 3,
841 PLAYER_LOGIN_QUERY_LOADSPELLS
= 4,
842 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS
= 5,
843 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS
= 6,
844 PLAYER_LOGIN_QUERY_LOADREPUTATION
= 7,
845 PLAYER_LOGIN_QUERY_LOADINVENTORY
= 8,
846 PLAYER_LOGIN_QUERY_LOADACTIONS
= 9,
847 PLAYER_LOGIN_QUERY_LOADMAILCOUNT
= 10,
848 PLAYER_LOGIN_QUERY_LOADMAILDATE
= 11,
849 PLAYER_LOGIN_QUERY_LOADSOCIALLIST
= 12,
850 PLAYER_LOGIN_QUERY_LOADHOMEBIND
= 13,
851 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS
= 14,
852 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES
= 15,
853 PLAYER_LOGIN_QUERY_LOADGUILD
= 16,
854 PLAYER_LOGIN_QUERY_LOADARENAINFO
= 17,
855 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS
= 18,
856 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS
= 19,
857 PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS
= 20,
858 MAX_PLAYER_LOGIN_QUERY
= 21
861 enum PlayerDelayedOperations
863 DELAYED_SAVE_PLAYER
= 1,
864 DELAYED_RESURRECT_PLAYER
= 2,
865 DELAYED_SPELL_CAST_DESERTER
= 4,
869 // Player summoning auto-decline time (in secs)
870 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
871 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
873 struct InstancePlayerBind
877 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
878 that aren't already permanently bound when they are inside when a boss is killed
879 or when they enter an instance that the group leader is permanently bound to. */
880 InstancePlayerBind() : save(NULL
), perm(false) {}
883 class MANGOS_DLL_SPEC PlayerTaxi
889 void InitTaxiNodesForLevel(uint32 race
, uint32 chrClass
, uint32 level
);
890 void LoadTaxiMask(const char* data
);
892 bool IsTaximaskNodeKnown(uint32 nodeidx
) const
894 uint8 field
= uint8((nodeidx
- 1) / 32);
895 uint32 submask
= 1<<((nodeidx
-1)%32);
896 return (m_taximask
[field
] & submask
) == submask
;
898 bool SetTaximaskNode(uint32 nodeidx
)
900 uint8 field
= uint8((nodeidx
- 1) / 32);
901 uint32 submask
= 1<<((nodeidx
-1)%32);
902 if ((m_taximask
[field
] & submask
) != submask
)
904 m_taximask
[field
] |= submask
;
910 void AppendTaximaskTo(ByteBuffer
& data
,bool all
);
913 bool LoadTaxiDestinationsFromString(const std::string
& values
, uint32 team
);
914 std::string
SaveTaxiDestinationsToString();
916 void ClearTaxiDestinations() { m_TaxiDestinations
.clear(); }
917 void AddTaxiDestination(uint32 dest
) { m_TaxiDestinations
.push_back(dest
); }
918 uint32
GetTaxiSource() const { return m_TaxiDestinations
.empty() ? 0 : m_TaxiDestinations
.front(); }
919 uint32
GetTaxiDestination() const { return m_TaxiDestinations
.size() < 2 ? 0 : m_TaxiDestinations
[1]; }
920 uint32
GetCurrentTaxiPath() const;
921 uint32
NextTaxiDestination()
923 m_TaxiDestinations
.pop_front();
924 return GetTaxiDestination();
926 bool empty() const { return m_TaxiDestinations
.empty(); }
928 friend std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
931 std::deque
<uint32
> m_TaxiDestinations
;
934 std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
936 class MANGOS_DLL_SPEC Player
: public Unit
938 friend class WorldSession
;
939 friend void Item::AddToUpdateQueueOf(Player
*player
);
940 friend void Item::RemoveFromUpdateQueueOf(Player
*player
);
942 explicit Player (WorldSession
*session
);
945 void CleanupsBeforeDelete();
947 static UpdateMask updateVisualBits
;
948 static void InitVisibleBits();
951 void RemoveFromWorld();
953 bool TeleportTo(uint32 mapid
, float x
, float y
, float z
, float orientation
, uint32 options
= 0);
955 bool TeleportTo(WorldLocation
const &loc
, uint32 options
= 0)
957 return TeleportTo(loc
.mapid
, loc
.coord_x
, loc
.coord_y
, loc
.coord_z
, loc
.orientation
, options
);
960 void SetSummonPoint(uint32 mapid
, float x
, float y
, float z
)
962 m_summon_expire
= time(NULL
) + MAX_PLAYER_SUMMON_DELAY
;
963 m_summon_mapid
= mapid
;
968 void SummonIfPossible(bool agree
);
970 bool Create( uint32 guidlow
, const std::string
& name
, uint8 race
, uint8 class_
, uint8 gender
, uint8 skin
, uint8 face
, uint8 hairStyle
, uint8 hairColor
, uint8 facialHair
, uint8 outfitId
);
972 void Update( uint32 time
);
974 static bool BuildEnumData( QueryResult
* result
, WorldPacket
* p_data
);
976 void SetInWater(bool apply
);
978 bool IsInWater() const { return m_isInWater
; }
979 bool IsUnderWater() const;
981 void SendInitialPacketsBeforeAddToMap();
982 void SendInitialPacketsAfterAddToMap();
983 void SendTransferAborted(uint32 mapid
, uint8 reason
, uint8 arg
= 0);
984 void SendInstanceResetWarning(uint32 mapid
, uint32 difficulty
, uint32 time
);
986 Creature
* GetNPCIfCanInteractWith(uint64 guid
, uint32 npcflagmask
);
987 bool CanInteractWithNPCs(bool alive
= true) const;
988 GameObject
* GetGameObjectIfCanInteractWith(uint64 guid
, GameobjectTypes type
) const;
992 bool isAFK() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_AFK
); };
993 bool isDND() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_DND
); };
994 uint8
chatTag() const;
998 uint32
GetBarberShopCost(uint8 newhairstyle
, uint8 newhaircolor
, uint8 newfacialhair
);
1000 PlayerSocial
*GetSocial() { return m_social
; }
1003 void InitTaxiNodesForLevel() { m_taxi
.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1004 bool ActivateTaxiPathTo(std::vector
<uint32
> const& nodes
, Creature
* npc
= NULL
, uint32 spellid
= 0);
1005 bool ActivateTaxiPathTo(uint32 taxi_path_id
, uint32 spellid
= 0);
1006 // mount_id can be used in scripting calls
1007 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_ACCEPT_TICKETS
); }
1008 void SetAcceptTicket(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_ACCEPT_TICKETS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS
; }
1009 bool isAcceptWhispers() const { return m_ExtraFlags
& PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1010 void SetAcceptWhispers(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_ACCEPT_WHISPERS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1011 bool isGameMaster() const { return m_ExtraFlags
& PLAYER_EXTRA_GM_ON
; }
1012 void SetGameMaster(bool on
);
1013 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_CHAT
); }
1014 void SetGMChat(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_CHAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_CHAT
; }
1015 bool isTaxiCheater() const { return m_ExtraFlags
& PLAYER_EXTRA_TAXICHEAT
; }
1016 void SetTaxiCheater(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_TAXICHEAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_TAXICHEAT
; }
1017 bool isGMVisible() const { return !(m_ExtraFlags
& PLAYER_EXTRA_GM_INVISIBLE
); }
1018 void SetGMVisible(bool on
);
1019 void SetPvPDeath(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_PVP_DEATH
; else m_ExtraFlags
&= ~PLAYER_EXTRA_PVP_DEATH
; }
1021 void GiveXP(uint32 xp
, Unit
* victim
);
1022 void GiveLevel(uint32 level
);
1024 void InitStatsForLevel(bool reapplyMods
= false);
1026 // Played Time Stuff
1029 uint32 m_Played_time
[2];
1030 uint32
GetTotalPlayedTime() { return m_Played_time
[0]; };
1031 uint32
GetLevelPlayedTime() { return m_Played_time
[1]; };
1033 void setDeathState(DeathState s
); // overwrite Unit::setDeathState
1035 void InnEnter (int time
,uint32 mapid
, float x
,float y
,float z
)
1037 inn_pos_mapid
= mapid
;
1041 time_inn_enter
= time
;
1044 float GetRestBonus() const { return m_rest_bonus
; };
1045 void SetRestBonus(float rest_bonus_new
);
1047 RestType
GetRestType() const { return rest_type
; };
1048 void SetRestType(RestType n_r_type
) { rest_type
= n_r_type
; };
1050 uint32
GetInnPosMapId() const { return inn_pos_mapid
; };
1051 float GetInnPosX() const { return inn_pos_x
; };
1052 float GetInnPosY() const { return inn_pos_y
; };
1053 float GetInnPosZ() const { return inn_pos_z
; };
1055 int GetTimeInnEnter() const { return time_inn_enter
; };
1056 void UpdateInnerTime (int time
) { time_inn_enter
= time
; };
1058 void RemovePet(Pet
* pet
, PetSaveMode mode
, bool returnreagent
= false);
1059 void RemoveMiniPet();
1061 void SetMiniPet(Pet
* pet
) { m_miniPet
= pet
->GetGUID(); }
1063 uint32
GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
1065 void Say(const std::string
& text
, const uint32 language
);
1066 void Yell(const std::string
& text
, const uint32 language
);
1067 void TextEmote(const std::string
& text
);
1068 void Whisper(const std::string
& text
, const uint32 language
,uint64 receiver
);
1069 void BuildPlayerChat(WorldPacket
*data
, uint8 msgtype
, const std::string
& text
, uint32 language
) const;
1071 /*********************************************************/
1072 /*** STORAGE SYSTEM ***/
1073 /*********************************************************/
1075 void SetVirtualItemSlot( uint8 i
, Item
* item
);
1076 void SetSheath( SheathState sheathed
); // overwrite Unit version
1077 uint8
FindEquipSlot( ItemPrototype
const* proto
, uint32 slot
, bool swap
) const;
1078 uint32
GetItemCount( uint32 item
, bool inBankAlso
= false, Item
* skipItem
= NULL
) const;
1079 Item
* GetItemByGuid( uint64 guid
) const;
1080 Item
* GetItemByPos( uint16 pos
) const;
1081 Item
* GetItemByPos( uint8 bag
, uint8 slot
) const;
1082 Item
* GetWeaponForAttack(WeaponAttackType attackType
, bool useable
= false) const;
1083 Item
* GetShield(bool useable
= false) const;
1084 static uint32
GetAttackBySlot( uint8 slot
); // MAX_ATTACK if not weapon slot
1085 std::vector
<Item
*> &GetItemUpdateQueue() { return m_itemUpdateQueue
; }
1086 static bool IsInventoryPos( uint16 pos
) { return IsInventoryPos(pos
>> 8,pos
& 255); }
1087 static bool IsInventoryPos( uint8 bag
, uint8 slot
);
1088 static bool IsEquipmentPos( uint16 pos
) { return IsEquipmentPos(pos
>> 8,pos
& 255); }
1089 static bool IsEquipmentPos( uint8 bag
, uint8 slot
);
1090 static bool IsBagPos( uint16 pos
);
1091 static bool IsBankPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1092 static bool IsBankPos( uint8 bag
, uint8 slot
);
1093 bool IsValidPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1094 bool IsValidPos( uint8 bag
, uint8 slot
);
1095 uint8
GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2
, 2); }
1096 void SetBankBagSlotCount(uint8 count
) { SetByteValue(PLAYER_BYTES_2
, 2, count
); }
1097 bool HasItemCount( uint32 item
, uint32 count
, bool inBankAlso
= false ) const;
1098 bool HasItemFitToSpellReqirements(SpellEntry
const* spellInfo
, Item
const* ignoreItem
= NULL
);
1099 bool CanNoReagentCast(SpellEntry
const* spellInfo
) const;
1100 bool HasItemOrGemWithIdEquipped( uint32 item
, uint32 count
, uint8 except_slot
= NULL_SLOT
) const;
1101 bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory
, uint32 count
, uint8 except_slot
= NULL_SLOT
) const;
1102 uint8
CanTakeMoreSimilarItems(Item
* pItem
) const { return _CanTakeMoreSimilarItems(pItem
->GetEntry(),pItem
->GetCount(),pItem
); }
1103 uint8
CanTakeMoreSimilarItems(uint32 entry
, uint32 count
) const { return _CanTakeMoreSimilarItems(entry
,count
,NULL
); }
1104 uint8
CanStoreNewItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 item
, uint32 count
, uint32
* no_space_count
= NULL
) const
1106 return _CanStoreItem(bag
, slot
, dest
, item
, count
, NULL
, false, no_space_count
);
1108 uint8
CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
= false ) const
1111 return EQUIP_ERR_ITEM_NOT_FOUND
;
1112 uint32 count
= pItem
->GetCount();
1113 return _CanStoreItem( bag
, slot
, dest
, pItem
->GetEntry(), count
, pItem
, swap
, NULL
);
1116 uint8
CanStoreItems( Item
**pItem
,int count
) const;
1117 uint8
CanEquipNewItem( uint8 slot
, uint16
&dest
, uint32 item
, bool swap
) const;
1118 uint8
CanEquipItem( uint8 slot
, uint16
&dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1120 uint8
CanEquipUniqueItem( Item
* pItem
, uint8 except_slot
= NULL_SLOT
, uint32 limit_count
= 1 ) const;
1121 uint8
CanEquipUniqueItem( ItemPrototype
const* itemProto
, uint8 except_slot
= NULL_SLOT
, uint32 limit_count
= 1 ) const;
1122 uint8
CanUnequipItems( uint32 item
, uint32 count
) const;
1123 uint8
CanUnequipItem( uint16 src
, bool swap
) const;
1124 uint8
CanBankItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1125 uint8
CanUseItem( Item
*pItem
, bool not_loading
= true ) const;
1126 bool HasItemTotemCategory( uint32 TotemCategory
) const;
1127 bool CanUseItem( ItemPrototype
const *pItem
);
1128 uint8
CanUseAmmo( uint32 item
) const;
1129 Item
* StoreNewItem( ItemPosCountVec
const& pos
, uint32 item
, bool update
,int32 randomPropertyId
= 0 );
1130 Item
* StoreItem( ItemPosCountVec
const& pos
, Item
*pItem
, bool update
);
1131 Item
* EquipNewItem( uint16 pos
, uint32 item
, bool update
);
1132 Item
* EquipItem( uint16 pos
, Item
*pItem
, bool update
);
1133 void AutoUnequipOffhandIfNeed();
1134 bool StoreNewItemInBestSlots(uint32 item_id
, uint32 item_count
);
1135 void AutoStoreLoot(uint8 bag
, uint8 slot
, uint32 loot_id
, LootStore
const& store
, bool broadcast
= false);
1136 void AutoStoreLoot(uint32 loot_id
, LootStore
const& store
, bool broadcast
= false) { AutoStoreLoot(NULL_BAG
,NULL_SLOT
,loot_id
,store
,broadcast
); }
1138 uint8
_CanTakeMoreSimilarItems(uint32 entry
, uint32 count
, Item
* pItem
, uint32
* no_space_count
= NULL
) const;
1139 uint8
_CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 entry
, uint32 count
, Item
*pItem
= NULL
, bool swap
= false, uint32
* no_space_count
= NULL
) const;
1141 void ApplyEquipCooldown( Item
* pItem
);
1142 void SetAmmo( uint32 item
);
1144 float GetAmmoDPS() const { return m_ammoDPS
; }
1145 bool CheckAmmoCompatibility(const ItemPrototype
*ammo_proto
) const;
1146 void QuickEquipItem( uint16 pos
, Item
*pItem
);
1147 void VisualizeItem( uint8 slot
, Item
*pItem
);
1148 void SetVisibleItemSlot(uint8 slot
, Item
*pItem
);
1149 Item
* BankItem( ItemPosCountVec
const& dest
, Item
*pItem
, bool update
)
1151 return StoreItem( dest
, pItem
, update
);
1153 Item
* BankItem( uint16 pos
, Item
*pItem
, bool update
);
1154 void RemoveItem( uint8 bag
, uint8 slot
, bool update
);
1155 void MoveItemFromInventory(uint8 bag
, uint8 slot
, bool update
);
1156 // in trade, auction, guild bank, mail....
1157 void MoveItemToInventory(ItemPosCountVec
const& dest
, Item
* pItem
, bool update
, bool in_characterInventoryDB
= false);
1158 // in trade, guild bank, mail....
1159 void RemoveItemDependentAurasAndCasts( Item
* pItem
);
1160 void DestroyItem( uint8 bag
, uint8 slot
, bool update
);
1161 void DestroyItemCount( uint32 item
, uint32 count
, bool update
, bool unequip_check
= false);
1162 void DestroyItemCount( Item
* item
, uint32
& count
, bool update
);
1163 void DestroyConjuredItems( bool update
);
1164 void DestroyZoneLimitedItem( bool update
, uint32 new_zone
);
1165 void SplitItem( uint16 src
, uint16 dst
, uint32 count
);
1166 void SwapItem( uint16 src
, uint16 dst
);
1167 void AddItemToBuyBackSlot( Item
*pItem
);
1168 Item
* GetItemFromBuyBackSlot( uint32 slot
);
1169 void RemoveItemFromBuyBackSlot( uint32 slot
, bool del
);
1170 uint32
GetMaxKeyringSize() const { return KEYRING_SLOT_END
-KEYRING_SLOT_START
; }
1171 void SendEquipError( uint8 msg
, Item
* pItem
, Item
*pItem2
);
1172 void SendBuyError( uint8 msg
, Creature
* pCreature
, uint32 item
, uint32 param
);
1173 void SendSellError( uint8 msg
, Creature
* pCreature
, uint64 guid
, uint32 param
);
1174 void AddWeaponProficiency(uint32 newflag
) { m_WeaponProficiency
|= newflag
; }
1175 void AddArmorProficiency(uint32 newflag
) { m_ArmorProficiency
|= newflag
; }
1176 uint32
GetWeaponProficiency() const { return m_WeaponProficiency
; }
1177 uint32
GetArmorProficiency() const { return m_ArmorProficiency
; }
1178 bool IsUseEquipedWeapon( bool mainhand
) const
1180 // disarm applied only to mainhand weapon
1181 return !IsInFeralForm() && (!mainhand
|| !HasFlag(UNIT_FIELD_FLAGS
,UNIT_FLAG_DISARMED
) );
1183 bool IsTwoHandUsed() const
1185 Item
* mainItem
= GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_MAINHAND
);
1186 return mainItem
&& mainItem
->GetProto()->InventoryType
== INVTYPE_2HWEAPON
&& !CanTitanGrip();
1188 void SendNewItem( Item
*item
, uint32 count
, bool received
, bool created
, bool broadcast
= false );
1189 bool BuyItemFromVendor(uint64 vendorguid
, uint32 item
, uint8 count
, uint8 bag
, uint8 slot
);
1191 float GetReputationPriceDiscount( Creature
const* pCreature
) const;
1192 Player
* GetTrader() const { return pTrader
; }
1194 void TradeCancel(bool sendback
);
1195 uint16
GetItemPosByTradeSlot(uint32 slot
) const { return tradeItems
[slot
]; }
1197 void UpdateEnchantTime(uint32 time
);
1198 void UpdateItemDuration(uint32 time
, bool realtimeonly
=false);
1199 void AddEnchantmentDurations(Item
*item
);
1200 void RemoveEnchantmentDurations(Item
*item
);
1201 void RemoveAllEnchantments(EnchantmentSlot slot
);
1202 void AddEnchantmentDuration(Item
*item
,EnchantmentSlot slot
,uint32 duration
);
1203 void ApplyEnchantment(Item
*item
,EnchantmentSlot slot
,bool apply
, bool apply_dur
= true, bool ignore_condition
= false);
1204 void ApplyEnchantment(Item
*item
,bool apply
);
1205 void SendEnchantmentDurations();
1206 void BuildEnchantmentsInfoData(WorldPacket
*data
);
1207 void AddItemDurations(Item
*item
);
1208 void RemoveItemDurations(Item
*item
);
1209 void SendItemDurations();
1213 uint32 m_stableSlots
;
1215 /*********************************************************/
1216 /*** QUEST SYSTEM ***/
1217 /*********************************************************/
1219 uint32
GetQuestLevel( Quest
const* pQuest
) const { return pQuest
&& pQuest
->GetQuestLevel() ? pQuest
->GetQuestLevel() : getLevel(); }
1221 void PrepareQuestMenu( uint64 guid
);
1222 void SendPreparedQuest( uint64 guid
);
1223 bool IsActiveQuest( uint32 quest_id
) const;
1224 Quest
const *GetNextQuest( uint64 guid
, Quest
const *pQuest
);
1225 bool CanSeeStartQuest( Quest
const *pQuest
);
1226 bool CanTakeQuest( Quest
const *pQuest
, bool msg
);
1227 bool CanAddQuest( Quest
const *pQuest
, bool msg
);
1228 bool CanCompleteQuest( uint32 quest_id
);
1229 bool CanCompleteRepeatableQuest(Quest
const *pQuest
);
1230 bool CanRewardQuest( Quest
const *pQuest
, bool msg
);
1231 bool CanRewardQuest( Quest
const *pQuest
, uint32 reward
, bool msg
);
1232 void AddQuest( Quest
const *pQuest
, Object
*questGiver
);
1233 void CompleteQuest( uint32 quest_id
);
1234 void IncompleteQuest( uint32 quest_id
);
1235 void RewardQuest( Quest
const *pQuest
, uint32 reward
, Object
* questGiver
, bool announce
= true );
1236 void FailQuest( uint32 quest_id
);
1237 void FailTimedQuest( uint32 quest_id
);
1238 bool SatisfyQuestSkillOrClass( Quest
const* qInfo
, bool msg
);
1239 bool SatisfyQuestLevel( Quest
const* qInfo
, bool msg
);
1240 bool SatisfyQuestLog( bool msg
);
1241 bool SatisfyQuestPreviousQuest( Quest
const* qInfo
, bool msg
);
1242 bool SatisfyQuestRace( Quest
const* qInfo
, bool msg
);
1243 bool SatisfyQuestReputation( Quest
const* qInfo
, bool msg
);
1244 bool SatisfyQuestStatus( Quest
const* qInfo
, bool msg
);
1245 bool SatisfyQuestTimed( Quest
const* qInfo
, bool msg
);
1246 bool SatisfyQuestExclusiveGroup( Quest
const* qInfo
, bool msg
);
1247 bool SatisfyQuestNextChain( Quest
const* qInfo
, bool msg
);
1248 bool SatisfyQuestPrevChain( Quest
const* qInfo
, bool msg
);
1249 bool SatisfyQuestDay( Quest
const* qInfo
, bool msg
);
1250 bool GiveQuestSourceItem( Quest
const *pQuest
);
1251 bool TakeQuestSourceItem( uint32 quest_id
, bool msg
);
1252 bool GetQuestRewardStatus( uint32 quest_id
) const;
1253 QuestStatus
GetQuestStatus( uint32 quest_id
) const;
1254 void SetQuestStatus( uint32 quest_id
, QuestStatus status
);
1256 void SetDailyQuestStatus( uint32 quest_id
);
1257 void ResetDailyQuestStatus();
1259 uint16
FindQuestSlot( uint32 quest_id
) const;
1260 uint32
GetQuestSlotQuestId(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
); }
1261 uint32
GetQuestSlotState(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
); }
1262 uint32
GetQuestSlotCounters(uint16 slot
)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
); }
1263 uint8
GetQuestSlotCounter(uint16 slot
,uint8 counter
) const { return GetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
); }
1264 uint32
GetQuestSlotTime(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
); }
1265 void SetQuestSlot(uint16 slot
,uint32 quest_id
, uint32 timer
= 0)
1267 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
,quest_id
);
1268 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,0);
1269 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,0);
1270 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
);
1272 void SetQuestSlotCounter(uint16 slot
,uint8 counter
,uint8 count
) { SetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
,count
); }
1273 void SetQuestSlotState(uint16 slot
,uint32 state
) { SetFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1274 void RemoveQuestSlotState(uint16 slot
,uint32 state
) { RemoveFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1275 void SetQuestSlotTimer(uint16 slot
,uint32 timer
) { SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
); }
1276 void SwapQuestSlot(uint16 slot1
,uint16 slot2
)
1278 for (int i
= 0; i
< MAX_QUEST_OFFSET
; ++i
)
1280 uint32 temp1
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
);
1281 uint32 temp2
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
);
1283 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
, temp2
);
1284 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
, temp1
);
1287 uint32
GetReqKillOrCastCurrentCount(uint32 quest_id
, int32 entry
);
1288 void AreaExploredOrEventHappens( uint32 questId
);
1289 void GroupEventHappens( uint32 questId
, WorldObject
const* pEventObject
);
1290 void ItemAddedQuestCheck( uint32 entry
, uint32 count
);
1291 void ItemRemovedQuestCheck( uint32 entry
, uint32 count
);
1292 void KilledMonster( uint32 entry
, uint64 guid
);
1293 void CastedCreatureOrGO( uint32 entry
, uint64 guid
, uint32 spell_id
);
1294 void TalkedToCreature( uint32 entry
, uint64 guid
);
1295 void MoneyChanged( uint32 value
);
1296 void ReputationChanged(FactionEntry
const* factionEntry
);
1297 bool HasQuestForItem( uint32 itemid
) const;
1298 bool HasQuestForGO(int32 GOId
) const;
1299 void UpdateForQuestWorldObjects();
1300 bool CanShareQuest(uint32 quest_id
) const;
1302 void SendQuestComplete( uint32 quest_id
);
1303 void SendQuestReward( Quest
const *pQuest
, uint32 XP
, Object
* questGiver
);
1304 void SendQuestFailed( uint32 quest_id
);
1305 void SendQuestTimerFailed( uint32 quest_id
);
1306 void SendCanTakeQuestResponse( uint32 msg
);
1307 void SendPushToPartyResponse( Player
*pPlayer
, uint32 msg
);
1308 void SendQuestUpdateAddItem( Quest
const* pQuest
, uint32 item_idx
, uint32 count
);
1309 void SendQuestUpdateAddCreatureOrGo( Quest
const* pQuest
, uint64 guid
, uint32 creatureOrGO_idx
, uint32 old_count
, uint32 add_count
);
1311 uint64
GetDivider() { return m_divider
; };
1312 void SetDivider( uint64 guid
) { m_divider
= guid
; };
1314 uint32
GetInGameTime() { return m_ingametime
; };
1316 void SetInGameTime( uint32 time
) { m_ingametime
= time
; };
1318 void AddTimedQuest( uint32 quest_id
) { m_timedquests
.insert(quest_id
); }
1320 /*********************************************************/
1321 /*** LOAD SYSTEM ***/
1322 /*********************************************************/
1324 bool LoadFromDB(uint32 guid
, SqlQueryHolder
*holder
);
1326 bool MinimalLoadFromDB(QueryResult
*result
, uint32 guid
);
1327 static bool LoadValuesArrayFromDB(Tokens
& data
,uint64 guid
);
1328 static uint32
GetUInt32ValueFromArray(Tokens
const& data
, uint16 index
);
1329 static float GetFloatValueFromArray(Tokens
const& data
, uint16 index
);
1330 static uint32
GetUInt32ValueFromDB(uint16 index
, uint64 guid
);
1331 static float GetFloatValueFromDB(uint16 index
, uint64 guid
);
1332 static uint32
GetZoneIdFromDB(uint64 guid
);
1333 static uint32
GetLevelFromDB(uint64 guid
);
1334 static bool LoadPositionFromDB(uint32
& mapid
, float& x
,float& y
,float& z
,float& o
, bool& in_flight
, uint64 guid
);
1336 /*********************************************************/
1337 /*** SAVE SYSTEM ***/
1338 /*********************************************************/
1341 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1342 void SaveGoldToDB();
1343 void SaveDataFieldToDB();
1344 static bool SaveValuesArrayInDB(Tokens
const& data
,uint64 guid
);
1345 static void SetUInt32ValueInArray(Tokens
& data
,uint16 index
, uint32 value
);
1346 static void SetFloatValueInArray(Tokens
& data
,uint16 index
, float value
);
1347 static void SetUInt32ValueInDB(uint16 index
, uint32 value
, uint64 guid
);
1348 static void SetFloatValueInDB(uint16 index
, float value
, uint64 guid
);
1349 static void Customize(uint64 guid
, uint8 gender
, uint8 skin
, uint8 face
, uint8 hairStyle
, uint8 hairColor
, uint8 facialHair
);
1350 static void SavePositionInDB(uint32 mapid
, float x
,float y
,float z
,float o
,uint32 zone
,uint64 guid
);
1353 bool m_mailsUpdated
;
1355 void SetBindPoint(uint64 guid
);
1356 void SendTalentWipeConfirm(uint64 guid
);
1357 void RewardRage( uint32 damage
, uint32 weaponSpeedHitFactor
, bool attacker
);
1358 void SendPetSkillWipeConfirm();
1359 void CalcRage( uint32 damage
,bool attacker
);
1360 void RegenerateAll();
1361 void Regenerate(Powers power
);
1362 void RegenerateHealth();
1363 void setRegenTimer(uint32 time
) {m_regenTimer
= time
;}
1364 void setWeaponChangeTimer(uint32 time
) {m_weaponChangeTimer
= time
;}
1366 uint32
GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE
); }
1367 void ModifyMoney( int32 d
)
1370 SetMoney (GetMoney() > uint32(-d
) ? GetMoney() + d
: 0);
1372 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT
- d
) ? GetMoney() + d
: MAX_MONEY_AMOUNT
);
1375 if(GetMoney() >= MAX_MONEY_AMOUNT
)
1376 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD
,NULL
,NULL
);
1378 void SetMoney( uint32 value
)
1380 SetUInt32Value (PLAYER_FIELD_COINAGE
, value
);
1381 MoneyChanged( value
);
1382 UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED
);
1385 QuestStatusMap
& getQuestStatusMap() { return mQuestStatus
; };
1387 const uint64
& GetSelection( ) const { return m_curSelection
; }
1388 void SetSelection(const uint64
&guid
) { m_curSelection
= guid
; SetUInt64Value(UNIT_FIELD_TARGET
, guid
); }
1390 uint8
GetComboPoints() { return m_comboPoints
; }
1391 const uint64
& GetComboTarget() const { return m_comboTarget
; }
1393 void AddComboPoints(Unit
* target
, int8 count
);
1394 void ClearComboPoints();
1395 void SendComboPoints();
1397 void SendMailResult(uint32 mailId
, MailResponseType mailAction
, MailResponseResult mailError
, uint32 equipError
= 0, uint32 item_guid
= 0, uint32 item_count
= 0);
1399 void UpdateNextMailTimeAndUnreads();
1400 void AddNewMailDeliverTime(time_t deliver_time
);
1401 bool IsMailsLoaded() const { return m_mailsLoaded
; }
1403 //void SetMail(Mail *m);
1404 void RemoveMail(uint32 id
);
1406 void AddMail(Mail
* mail
) { m_mail
.push_front(mail
);}// for call from WorldSession::SendMailTo
1407 uint32
GetMailSize() { return m_mail
.size();};
1408 Mail
* GetMail(uint32 id
);
1410 PlayerMails::iterator
GetmailBegin() { return m_mail
.begin();};
1411 PlayerMails::iterator
GetmailEnd() { return m_mail
.end();};
1413 /*********************************************************/
1414 /*** MAILED ITEMS SYSTEM ***/
1415 /*********************************************************/
1418 time_t m_nextMailDelivereTime
;
1420 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
1422 ItemMap mMitems
; //template defined in objectmgr.cpp
1424 Item
* GetMItem(uint32 id
)
1426 ItemMap::const_iterator itr
= mMitems
.find(id
);
1427 return itr
!= mMitems
.end() ? itr
->second
: NULL
;
1430 void AddMItem(Item
* it
)
1433 //assert deleted, because items can be added before loading
1434 mMitems
[it
->GetGUIDLow()] = it
;
1437 bool RemoveMItem(uint32 id
)
1439 return mMitems
.erase(id
) ? true : false;
1442 void PetSpellInitialize();
1443 void CharmSpellInitialize();
1444 void PossessSpellInitialize();
1445 bool HasSpell(uint32 spell
) const;
1446 bool HasActiveSpell(uint32 spell
) const; // show in spellbook
1447 TrainerSpellState
GetTrainerSpellState(TrainerSpell
const* trainer_spell
) const;
1448 bool IsSpellFitByClassAndRace( uint32 spell_id
) const;
1449 bool IsNeedCastPassiveSpellAtLearn(SpellEntry
const* spellInfo
) const;
1451 void SendProficiency(uint8 pr1
, uint32 pr2
);
1452 void SendInitialSpells();
1453 bool addSpell(uint32 spell_id
, bool active
, bool learning
, bool dependent
, bool disabled
);
1454 void learnSpell(uint32 spell_id
, bool dependent
);
1455 void removeSpell(uint32 spell_id
, bool disabled
= false, bool learn_low_rank
= true);
1457 void learnDefaultSpells();
1458 void learnQuestRewardedSpells();
1459 void learnQuestRewardedSpells(Quest
const* quest
);
1460 void learnSpellHighRank(uint32 spellid
);
1462 uint32
GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1
); }
1463 void SetFreeTalentPoints(uint32 points
) { SetUInt32Value(PLAYER_CHARACTER_POINTS1
,points
); }
1464 bool resetTalents(bool no_cost
= false);
1465 uint32
resetTalentsCost() const;
1466 void InitTalentForLevel();
1467 void BuildPlayerTalentsInfoData(WorldPacket
*data
);
1468 void BuildPetTalentsInfoData(WorldPacket
*data
);
1469 void SendTalentsInfoData(bool pet
);
1470 void LearnTalent(uint32 talentId
, uint32 talentRank
);
1471 void LearnPetTalent(uint64 petGuid
, uint32 talentId
, uint32 talentRank
);
1473 uint32
CalculateTalentsPoints() const;
1476 uint32
GetActiveSpec() { return m_activeSpec
; }
1477 void SetActiveSpec(uint32 spec
) { m_activeSpec
= spec
; }
1478 uint32
GetSpecsCount() { return m_specsCount
; }
1479 void SetSpecsCount(uint32 count
) { m_specsCount
= count
; }
1480 void ActivateSpec(uint32 specNum
);
1482 void InitGlyphsForLevel();
1483 void SetGlyphSlot(uint8 slot
, uint32 slottype
) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
, slottype
); }
1484 uint32
GetGlyphSlot(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
); }
1485 void SetGlyph(uint8 slot
, uint32 glyph
) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
, glyph
); }
1486 uint32
GetGlyph(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
); }
1488 uint32
GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2
); }
1489 void SetFreePrimaryProfessions(uint16 profs
) { SetUInt32Value(PLAYER_CHARACTER_POINTS2
, profs
); }
1490 void InitPrimaryProfessions();
1492 PlayerSpellMap
const& GetSpellMap() const { return m_spells
; }
1493 PlayerSpellMap
& GetSpellMap() { return m_spells
; }
1495 SpellCooldowns
const& GetSpellCooldownMap() const { return m_spellCooldowns
; }
1497 void AddSpellMod(SpellModifier
* mod
, bool apply
);
1498 bool IsAffectedBySpellmod(SpellEntry
const *spellInfo
, SpellModifier
*mod
, Spell
const* spell
= NULL
);
1499 template <class T
> T
ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
= NULL
);
1500 void RemoveSpellMods(Spell
const* spell
);
1502 static uint32
const infinityCooldownDelay
= MONTH
; // used for set "infinity cooldowns" for spells and check
1503 static uint32
const infinityCooldownDelayCheck
= MONTH
/2;
1504 bool HasSpellCooldown(uint32 spell_id
) const
1506 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1507 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> time(NULL
);
1509 uint32
GetSpellCooldownDelay(uint32 spell_id
) const
1511 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1512 time_t t
= time(NULL
);
1513 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> t
? itr
->second
.end
- t
: 0;
1515 void AddSpellAndCategoryCooldowns(SpellEntry
const* spellInfo
, uint32 itemId
, Spell
* spell
= NULL
, bool infinityCooldown
= false );
1516 void AddSpellCooldown(uint32 spell_id
, uint32 itemid
, time_t end_time
);
1517 void SendCooldownEvent(SpellEntry
const *spellInfo
, uint32 itemId
= 0, Spell
* spell
= NULL
);
1518 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask
, uint32 unTimeMs
);
1519 void RemoveSpellCooldown(uint32 spell_id
, bool update
= false);
1520 void RemoveSpellCategoryCooldown(uint32 cat
, bool update
= false);
1521 void SendClearCooldown( uint32 spell_id
, Unit
* target
);
1523 void RemoveArenaSpellCooldowns();
1524 void RemoveAllSpellCooldown();
1525 void _LoadSpellCooldowns(QueryResult
*result
);
1526 void _SaveSpellCooldowns();
1527 void SetLastPotionId(uint32 item_id
) { m_lastPotionId
= item_id
; }
1528 void UpdatePotionCooldown(Spell
* spell
= NULL
);
1530 void setResurrectRequestData(uint64 guid
, uint32 mapId
, float X
, float Y
, float Z
, uint32 health
, uint32 mana
)
1532 m_resurrectGUID
= guid
;
1533 m_resurrectMap
= mapId
;
1537 m_resurrectHealth
= health
;
1538 m_resurrectMana
= mana
;
1540 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f
,0.0f
,0.0f
,0,0); }
1541 bool isRessurectRequestedBy(uint64 guid
) const { return m_resurrectGUID
== guid
; }
1542 bool isRessurectRequested() const { return m_resurrectGUID
!= 0; }
1543 void ResurectUsingRequestData();
1549 void setCinematic(int cine
)
1554 ActionButton
* addActionButton(uint8 button
, uint32 action
, uint8 type
);
1555 void removeActionButton(uint8 button
);
1556 void SendInitialActionButtons() const;
1559 void UpdatePvP(bool state
, bool ovrride
=false);
1560 void UpdateZone(uint32 newZone
,uint32 newArea
);
1561 void UpdateArea(uint32 newArea
);
1563 void UpdateZoneDependentAuras( uint32 zone_id
); // zones
1564 void UpdateAreaDependentAuras( uint32 area_id
); // subzones
1566 void UpdateAfkReport(time_t currTime
);
1567 void UpdatePvPFlag(time_t currTime
);
1568 void UpdateContestedPvP(uint32 currTime
);
1569 void SetContestedPvPTimer(uint32 newTime
) {m_contestedPvPTimer
= newTime
;}
1570 void ResetContestedPvP()
1572 clearUnitState(UNIT_STAT_ATTACK_PLAYER
);
1573 RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_CONTESTED_PVP
);
1574 m_contestedPvPTimer
= 0;
1577 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1579 void UpdateDuelFlag(time_t currTime
);
1580 void CheckDuelDistance(time_t currTime
);
1581 void DuelComplete(DuelCompleteType type
);
1583 bool IsGroupVisibleFor(Player
* p
) const;
1584 bool IsInSameGroupWith(Player
const* p
) const;
1585 bool IsInSameRaidWith(Player
const* p
) const { return p
==this || (GetGroup() != NULL
&& GetGroup() == p
->GetGroup()); }
1586 void UninviteFromGroup();
1587 static void RemoveFromGroup(Group
* group
, uint64 guid
);
1588 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1589 void SendUpdateToOutOfRangeGroupMembers();
1591 void SetInGuild(uint32 GuildId
) { SetUInt32Value(PLAYER_GUILDID
, GuildId
); }
1592 void SetRank(uint32 rankId
){ SetUInt32Value(PLAYER_GUILDRANK
, rankId
); }
1593 void SetGuildIdInvited(uint32 GuildId
) { m_GuildIdInvited
= GuildId
; }
1594 uint32
GetGuildId() { return GetUInt32Value(PLAYER_GUILDID
); }
1595 static uint32
GetGuildIdFromDB(uint64 guid
);
1596 uint32
GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK
); }
1597 static uint32
GetRankFromDB(uint64 guid
);
1598 int GetGuildIdInvited() { return m_GuildIdInvited
; }
1599 static void RemovePetitionsAndSigns(uint64 guid
, uint32 type
);
1602 void SetInArenaTeam(uint32 ArenaTeamId
, uint8 slot
)
1604 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6), ArenaTeamId
);
1606 uint32
GetArenaTeamId(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6)); }
1607 static uint32
GetArenaTeamIdFromDB(uint64 guid
, uint8 slot
);
1608 void SetArenaTeamIdInvited(uint32 ArenaTeamId
) { m_ArenaTeamIdInvited
= ArenaTeamId
; }
1609 uint32
GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited
; }
1610 static void LeaveAllArenaTeams(uint64 guid
);
1612 void SetDifficulty(uint32 dungeon_difficulty
) { m_dungeonDifficulty
= dungeon_difficulty
; }
1613 uint8
GetDifficulty() { return m_dungeonDifficulty
; }
1614 bool IsHeroic() { return m_dungeonDifficulty
== DIFFICULTY_HEROIC
; }
1616 bool UpdateSkill(uint32 skill_id
, uint32 step
);
1617 bool UpdateSkillPro(uint16 SkillId
, int32 Chance
, uint32 step
);
1619 bool UpdateCraftSkill(uint32 spellid
);
1620 bool UpdateGatherSkill(uint32 SkillId
, uint32 SkillValue
, uint32 RedLevel
, uint32 Multiplicator
= 1);
1621 bool UpdateFishingSkill();
1623 uint32
GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE
); }
1624 uint32
GetBaseWeaponSkillValue(WeaponAttackType attType
) const;
1626 uint32
GetSpellByProto(ItemPrototype
*proto
);
1628 float GetHealthBonusFromStamina();
1629 float GetManaBonusFromIntellect();
1631 bool UpdateStats(Stats stat
);
1632 bool UpdateAllStats();
1633 void UpdateResistances(uint32 school
);
1635 void UpdateMaxHealth();
1636 void UpdateMaxPower(Powers power
);
1637 void ApplyFeralAPBonus(int32 amount
, bool apply
);
1638 void UpdateAttackPowerAndDamage(bool ranged
= false);
1639 void UpdateShieldBlockValue();
1640 void UpdateDamagePhysical(WeaponAttackType attType
);
1641 void ApplySpellDamageBonus(int32 amount
, bool apply
);
1642 void ApplySpellHealingBonus(int32 amount
, bool apply
);
1643 void UpdateSpellDamageAndHealingBonus();
1645 void CalculateMinMaxDamage(WeaponAttackType attType
, bool normalized
, float& min_damage
, float& max_damage
);
1647 void UpdateDefenseBonusesMod();
1648 void ApplyRatingMod(CombatRating cr
, int32 value
, bool apply
);
1649 float GetMeleeCritFromAgility();
1650 float GetDodgeFromAgility();
1651 float GetSpellCritFromIntellect();
1652 float OCTRegenHPPerSpirit();
1653 float OCTRegenMPPerSpirit();
1654 float GetRatingCoefficient(CombatRating cr
) const;
1655 float GetRatingBonusValue(CombatRating cr
) const;
1656 uint32
GetMeleeCritDamageReduction(uint32 damage
) const;
1657 uint32
GetRangedCritDamageReduction(uint32 damage
) const;
1658 uint32
GetSpellCritDamageReduction(uint32 damage
) const;
1659 uint32
GetDotDamageReduction(uint32 damage
) const;
1660 uint32
GetBaseSpellDamageBonus() { return m_baseSpellDamage
;}
1661 uint32
GetBaseSpellHealingBonus() { return m_baseSpellHealing
;}
1663 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType
) const;
1664 void UpdateBlockPercentage();
1665 void UpdateCritPercentage(WeaponAttackType attType
);
1666 void UpdateAllCritPercentages();
1667 void UpdateParryPercentage();
1668 void UpdateDodgePercentage();
1669 void UpdateMeleeHitChances();
1670 void UpdateRangedHitChances();
1671 void UpdateSpellHitChances();
1673 void UpdateAllSpellCritChances();
1674 void UpdateSpellCritChance(uint32 school
);
1675 void UpdateExpertise(WeaponAttackType attType
);
1676 void ApplyManaRegenBonus(int32 amount
, bool apply
);
1677 void UpdateManaRegen();
1679 const uint64
& GetLootGUID() const { return m_lootGuid
; }
1680 void SetLootGUID(const uint64
&guid
) { m_lootGuid
= guid
; }
1682 void RemovedInsignia(Player
* looterPlr
);
1684 WorldSession
* GetSession() const { return m_session
; }
1685 void SetSession(WorldSession
*s
) { m_session
= s
; }
1687 void BuildCreateUpdateBlockForPlayer( UpdateData
*data
, Player
*target
) const;
1688 void DestroyForPlayer( Player
*target
) const;
1689 void SendDelayResponse(const uint32
);
1690 void SendLogXPGain(uint32 GivenXP
,Unit
* victim
,uint32 RestXP
);
1693 void SendAttackSwingCantAttack();
1694 void SendAttackSwingCancelAttack();
1695 void SendAttackSwingDeadTarget();
1696 void SendAttackSwingNotInRange();
1697 void SendAttackSwingBadFacingAttack();
1698 void SendAutoRepeatCancel();
1699 void SendExplorationExperience(uint32 Area
, uint32 Experience
);
1701 void SendDungeonDifficulty(bool IsInGroup
);
1702 void ResetInstances(uint8 method
);
1703 void SendResetInstanceSuccess(uint32 MapId
);
1704 void SendResetInstanceFailed(uint32 reason
, uint32 MapId
);
1705 void SendResetFailedNotify(uint32 mapid
);
1707 bool SetPosition(float x
, float y
, float z
, float orientation
, bool teleport
= false);
1708 void UpdateUnderwaterState( Map
* m
, float x
, float y
, float z
);
1710 void SendMessageToSet(WorldPacket
*data
, bool self
);// overwrite Object::SendMessageToSet
1711 void SendMessageToSetInRange(WorldPacket
*data
, float fist
, bool self
);
1712 // overwrite Object::SendMessageToSetInRange
1713 void SendMessageToSetInRange(WorldPacket
*data
, float dist
, bool self
, bool own_team_only
);
1715 static void DeleteFromDB(uint64 playerguid
, uint32 accountId
, bool updateRealmChars
= true);
1717 Corpse
*GetCorpse() const;
1718 void SpawnCorpseBones();
1719 void CreateCorpse();
1721 uint32
GetResurrectionSpellId();
1722 void ResurrectPlayer(float restore_percent
, bool applySickness
= false);
1723 void BuildPlayerRepop();
1724 void RepopAtGraveyard();
1726 void DurabilityLossAll(double percent
, bool inventory
);
1727 void DurabilityLoss(Item
* item
, double percent
);
1728 void DurabilityPointsLossAll(int32 points
, bool inventory
);
1729 void DurabilityPointsLoss(Item
* item
, int32 points
);
1730 void DurabilityPointLossForEquipSlot(EquipmentSlots slot
);
1731 uint32
DurabilityRepairAll(bool cost
, float discountMod
, bool guildBank
);
1732 uint32
DurabilityRepair(uint16 pos
, bool cost
, float discountMod
, bool guildBank
);
1734 void UpdateMirrorTimers();
1735 void StopMirrorTimers()
1737 StopMirrorTimer(FATIGUE_TIMER
);
1738 StopMirrorTimer(BREATH_TIMER
);
1739 StopMirrorTimer(FIRE_TIMER
);
1742 void SetMovement(PlayerMovementType pType
);
1744 void JoinedChannel(Channel
*c
);
1745 void LeftChannel(Channel
*c
);
1746 void CleanupChannels();
1747 void UpdateLocalChannels( uint32 newZone
);
1748 void LeaveLFGChannel();
1750 void UpdateDefense();
1751 void UpdateWeaponSkill (WeaponAttackType attType
);
1752 void UpdateCombatSkills(Unit
*pVictim
, WeaponAttackType attType
, bool defence
);
1754 void SetSkill(uint32 id
, uint16 currVal
, uint16 maxVal
);
1755 uint16
GetMaxSkillValue(uint32 skill
) const; // max + perm. bonus + temp bonus
1756 uint16
GetPureMaxSkillValue(uint32 skill
) const; // max
1757 uint16
GetSkillValue(uint32 skill
) const; // skill value + perm. bonus + temp bonus
1758 uint16
GetBaseSkillValue(uint32 skill
) const; // skill value + perm. bonus
1759 uint16
GetPureSkillValue(uint32 skill
) const; // skill value
1760 int16
GetSkillPermBonusValue(uint32 skill
) const;
1761 int16
GetSkillTempBonusValue(uint32 skill
) const;
1762 bool HasSkill(uint32 skill
) const;
1763 void learnSkillRewardedSpells(uint32 id
, uint32 value
);
1765 WorldLocation
& GetTeleportDest() { return m_teleport_dest
; }
1766 bool IsBeingTeleported() const { return mSemaphoreTeleport_Near
|| mSemaphoreTeleport_Far
; }
1767 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near
; }
1768 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far
; }
1769 void SetSemaphoreTeleportNear(bool semphsetting
) { mSemaphoreTeleport_Near
= semphsetting
; }
1770 void SetSemaphoreTeleportFar(bool semphsetting
) { mSemaphoreTeleport_Far
= semphsetting
; }
1771 void ProcessDelayedOperations();
1773 void CheckExploreSystem(void);
1775 static uint32
TeamForRace(uint8 race
);
1776 uint32
GetTeam() const { return m_team
; }
1777 static uint32
getFactionForRace(uint8 race
);
1778 void setFactionForRace(uint8 race
);
1780 void InitDisplayIds();
1782 bool IsAtGroupRewardDistance(WorldObject
const* pRewardSource
) const;
1783 bool RewardPlayerAndGroupAtKill(Unit
* pVictim
);
1784 void RewardPlayerAndGroupAtEvent(uint32 creature_id
,WorldObject
* pRewardSource
);
1785 bool isHonorOrXPTarget(Unit
* pVictim
);
1787 ReputationMgr
& GetReputationMgr() { return m_reputationMgr
; }
1788 ReputationMgr
const& GetReputationMgr() const { return m_reputationMgr
; }
1789 ReputationRank
GetReputationRank(uint32 faction_id
) const;
1790 void RewardReputation(Unit
*pVictim
, float rate
);
1791 void RewardReputation(Quest
const *pQuest
);
1793 void UpdateSkillsForLevel();
1794 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1795 void ModifySkillBonus(uint32 skillid
,int32 val
, bool talent
);
1797 /*********************************************************/
1798 /*** PVP SYSTEM ***/
1799 /*********************************************************/
1800 void UpdateArenaFields();
1801 void UpdateHonorFields();
1802 bool RewardHonor(Unit
*pVictim
, uint32 groupsize
, float honor
= -1);
1803 uint32
GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
); }
1804 uint32
GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY
); }
1805 void ModifyHonorPoints( int32 value
);
1806 void ModifyArenaPoints( int32 value
);
1807 uint32
GetMaxPersonalArenaRatingRequirement();
1811 void SetDrunkValue(uint16 newDrunkValue
, uint32 itemid
=0);
1812 uint16
GetDrunkValue() const { return m_drunk
; }
1813 static DrunkenState
GetDrunkenstateByValue(uint16 value
);
1815 uint32
GetDeathTimer() const { return m_deathTimer
; }
1816 uint32
GetCorpseReclaimDelay(bool pvp
) const;
1817 void UpdateCorpseReclaimDelay();
1818 void SendCorpseReclaimDelay(bool load
= false);
1820 uint32
GetShieldBlockValue() const; // overwrite Unit version (virtual)
1821 bool CanParry() const { return m_canParry
; }
1822 void SetCanParry(bool value
);
1823 bool CanBlock() const { return m_canBlock
; }
1824 void SetCanBlock(bool value
);
1825 bool CanDualWield() const { return m_canDualWield
; }
1826 void SetCanDualWield(bool value
) { m_canDualWield
= value
; }
1827 bool CanTitanGrip() const { return m_canTitanGrip
; }
1828 void SetCanTitanGrip(bool value
) { m_canTitanGrip
= value
; }
1829 bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE
); }
1831 void SetRegularAttackTime();
1832 void SetBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float value
) { m_auraBaseMod
[modGroup
][modType
] = value
; }
1833 void HandleBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float amount
, bool apply
);
1834 float GetBaseModValue(BaseModGroup modGroup
, BaseModType modType
) const;
1835 float GetTotalBaseModValue(BaseModGroup modGroup
) const;
1836 float GetTotalPercentageModValue(BaseModGroup modGroup
) const { return m_auraBaseMod
[modGroup
][FLAT_MOD
] + m_auraBaseMod
[modGroup
][PCT_MOD
]; }
1837 void _ApplyAllStatBonuses();
1838 void _RemoveAllStatBonuses();
1840 void _ApplyWeaponDependentAuraMods(Item
*item
, WeaponAttackType attackType
, bool apply
);
1841 void _ApplyWeaponDependentAuraCritMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1842 void _ApplyWeaponDependentAuraDamageMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1844 void _ApplyItemMods(Item
*item
,uint8 slot
,bool apply
);
1845 void _RemoveAllItemMods();
1846 void _ApplyAllItemMods();
1847 void _ApplyItemBonuses(ItemPrototype
const *proto
,uint8 slot
,bool apply
);
1848 void _ApplyAmmoBonuses();
1849 bool EnchantmentFitsRequirements(uint32 enchantmentcondition
, int8 slot
);
1850 void ToggleMetaGemsActive(uint8 exceptslot
, bool apply
);
1851 void CorrectMetaGemEnchants(uint8 slot
, bool apply
);
1852 void InitDataForForm(bool reapplyMods
= false);
1854 void ApplyItemEquipSpell(Item
*item
, bool apply
, bool form_change
= false);
1855 void ApplyEquipSpell(SpellEntry
const* spellInfo
, Item
* item
, bool apply
, bool form_change
= false);
1856 void UpdateEquipSpellsAtFormChange();
1857 void CastItemCombatSpell(Unit
* Target
, WeaponAttackType attType
);
1858 void CastItemUseSpell(Item
*item
,SpellCastTargets
const& targets
,uint8 cast_count
, uint32 glyphIndex
);
1860 void SendEquipmentSetList();
1861 void SetEquipmentSet(uint32 index
, EquipmentSet eqset
);
1862 void DeleteEquipmentSet(uint64 setGuid
);
1864 void SendInitWorldStates(uint32 zone
, uint32 area
);
1865 void SendUpdateWorldState(uint32 Field
, uint32 Value
);
1866 void SendDirectMessage(WorldPacket
*data
);
1868 void SendAurasForTarget(Unit
*target
);
1870 PlayerMenu
* PlayerTalkClass
;
1871 std::vector
<ItemSetEffect
*> ItemSetEff
;
1873 void SendLoot(uint64 guid
, LootType loot_type
);
1874 void SendLootRelease( uint64 guid
);
1875 void SendNotifyLootItemRemoved(uint8 lootSlot
);
1876 void SendNotifyLootMoneyRemoved();
1878 /*********************************************************/
1879 /*** BATTLEGROUND SYSTEM ***/
1880 /*********************************************************/
1882 bool InBattleGround() const { return m_bgBattleGroundID
!= 0; }
1883 bool InArena() const;
1884 uint32
GetBattleGroundId() const { return m_bgBattleGroundID
; }
1885 BattleGroundTypeId
GetBattleGroundTypeId() const { return m_bgTypeID
; }
1886 BattleGround
* GetBattleGround() const;
1889 BGQueueIdBasedOnLevel
GetBattleGroundQueueIdFromLevel(BattleGroundTypeId bgTypeId
) const;
1891 bool InBattleGroundQueue() const
1893 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1894 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
!= BATTLEGROUND_QUEUE_NONE
)
1899 BattleGroundQueueTypeId
GetBattleGroundQueueTypeId(uint32 index
) const { return m_bgBattleGroundQueueID
[index
].bgQueueTypeId
; }
1900 uint32
GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId
) const
1902 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1903 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1905 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1907 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
1909 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1910 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1911 return m_bgBattleGroundQueueID
[i
].invitedToInstance
!= 0;
1914 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
1916 return GetBattleGroundQueueIndex(bgQueueTypeId
) < PLAYER_MAX_BATTLEGROUND_QUEUES
;
1919 void SetBattleGroundId(uint32 val
, BattleGroundTypeId bgTypeId
)
1921 m_bgBattleGroundID
= val
;
1922 m_bgTypeID
= bgTypeId
;
1924 uint32
AddBattleGroundQueueId(BattleGroundQueueTypeId val
)
1926 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1928 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
|| m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
1930 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= val
;
1931 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1935 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1937 bool HasFreeBattleGroundQueueId()
1939 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1940 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
)
1944 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val
)
1946 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1948 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
1950 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= BATTLEGROUND_QUEUE_NONE
;
1951 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1956 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
, uint32 instanceId
)
1958 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1959 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1960 m_bgBattleGroundQueueID
[i
].invitedToInstance
= instanceId
;
1962 bool IsInvitedForBattleGroundInstance(uint32 instanceId
) const
1964 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1965 if (m_bgBattleGroundQueueID
[i
].invitedToInstance
== instanceId
)
1969 WorldLocation
const& GetBattleGroundEntryPoint() const { return m_bgEntryPoint
; }
1970 void SetBattleGroundEntryPoint(uint32 Map
, float PosX
, float PosY
, float PosZ
, float PosO
)
1972 m_bgEntryPoint
= WorldLocation(Map
,PosX
,PosY
,PosZ
,PosO
);
1975 void SetBGTeam(uint32 team
) { m_bgTeam
= team
; }
1976 uint32
GetBGTeam() const { return m_bgTeam
? m_bgTeam
: GetTeam(); }
1978 void LeaveBattleground(bool teleportToEntryPoint
= true);
1979 bool CanJoinToBattleground() const;
1980 bool CanReportAfkDueToLimit();
1981 void ReportedAfkBy(Player
* reporter
);
1982 void ClearAfkReports() { m_bgAfkReporter
.clear(); }
1984 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId
) const;
1985 bool CanUseBattleGroundObject();
1986 bool isTotalImmune();
1987 bool CanCaptureTowerPoint();
1989 /*********************************************************/
1990 /*** REST SYSTEM ***/
1991 /*********************************************************/
1993 bool isRested() const { return GetRestTime() >= 10*IN_MILISECONDS
; }
1994 uint32
GetXPRestBonus(uint32 xp
);
1995 uint32
GetRestTime() const { return m_restTime
;};
1996 void SetRestTime(uint32 v
) { m_restTime
= v
;};
1998 /*********************************************************/
1999 /*** ENVIROMENTAL SYSTEM ***/
2000 /*********************************************************/
2002 void EnvironmentalDamage(EnviromentalDamage type
, uint32 damage
);
2004 /*********************************************************/
2005 /*** FLOOD FILTER SYSTEM ***/
2006 /*********************************************************/
2008 void UpdateSpeakTime();
2009 bool CanSpeak() const;
2010 void ChangeSpeakTime(int utime
);
2012 /*********************************************************/
2013 /*** VARIOUS SYSTEMS ***/
2014 /*********************************************************/
2015 MovementInfo m_movementInfo
;
2016 bool HasMovementFlag(MovementFlags f
) const; // for script access to m_movementInfo.HasMovementFlag
2017 void UpdateFallInformationIfNeed(MovementInfo
const& minfo
,uint16 opcode
);
2019 void SetFallInformation(uint32 time
, float z
)
2021 m_lastFallTime
= time
;
2024 void HandleFall(MovementInfo
const& movementInfo
);
2026 void BuildTeleportAckMsg( WorldPacket
*data
, float x
, float y
, float z
, float ang
) const;
2028 bool isMoving() const { return m_movementInfo
.HasMovementFlag(movementFlagsMask
); }
2029 bool isMovingOrTurning() const { return m_movementInfo
.HasMovementFlag(movementOrTurningFlagsMask
); }
2031 bool CanFly() const { return m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_CAN_FLY
); }
2032 bool IsFlying() const { return m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_FLYING
); }
2033 bool IsAllowUseFlyMountsHere() const;
2035 void SetClientControl(Unit
* target
, uint8 allowMove
);
2036 void SetMover(Unit
* target
) { m_mover
= target
? target
: this; }
2038 void EnterVehicle(Vehicle
*vehicle
);
2039 void ExitVehicle(Vehicle
*vehicle
);
2041 uint64
GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT
); }
2042 void SetFarSightGUID(uint64 guid
) { SetUInt64Value(PLAYER_FARSIGHT
, guid
); }
2045 Transport
* GetTransport() const { return m_transport
; }
2046 void SetTransport(Transport
* t
) { m_transport
= t
; }
2048 float GetTransOffsetX() const { return m_movementInfo
.t_x
; }
2049 float GetTransOffsetY() const { return m_movementInfo
.t_y
; }
2050 float GetTransOffsetZ() const { return m_movementInfo
.t_z
; }
2051 float GetTransOffsetO() const { return m_movementInfo
.t_o
; }
2052 uint32
GetTransTime() const { return m_movementInfo
.t_time
; }
2053 int8
GetTransSeat() const { return m_movementInfo
.t_seat
; }
2055 uint32
GetSaveTimer() const { return m_nextSave
; }
2056 void SetSaveTimer(uint32 timer
) { m_nextSave
= timer
; }
2064 void SaveRecallPosition();
2066 // Homebind coordinates
2067 uint32 m_homebindMapId
;
2068 uint16 m_homebindZoneId
;
2072 void RelocateToHomebind() { SetMapId(m_homebindMapId
); Relocate(m_homebindX
,m_homebindY
,m_homebindZ
); }
2074 // currently visible objects at player client
2075 typedef std::set
<uint64
> ClientGUIDs
;
2076 ClientGUIDs m_clientGUIDs
;
2078 bool HaveAtClient(WorldObject
const* u
) { return u
==this || m_clientGUIDs
.find(u
->GetGUID())!=m_clientGUIDs
.end(); }
2080 bool IsVisibleInGridForPlayer(Player
* pl
) const;
2081 bool IsVisibleGloballyFor(Player
* pl
) const;
2083 void UpdateVisibilityOf(WorldObject
* target
);
2086 void UpdateVisibilityOf(T
* target
, UpdateData
& data
, UpdateDataMapType
& data_updates
, std::set
<WorldObject
*>& visibleNow
);
2088 // Stealth detection system
2089 uint32 m_DetectInvTimer
;
2090 void HandleStealthedUnitsDetection();
2092 uint8 m_forced_speed_changes
[MAX_MOVE_TYPE
];
2094 bool HasAtLoginFlag(AtLoginFlags f
) const { return m_atLoginFlags
& f
; }
2095 void SetAtLoginFlag(AtLoginFlags f
) { m_atLoginFlags
|= f
; }
2096 void RemoveAtLoginFlag(AtLoginFlags f
, bool in_db_also
= false);
2098 LookingForGroup m_lookingForGroup
;
2100 // Temporarily removed pet cache
2101 uint32
GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber
; }
2102 void SetTemporaryUnsummonedPetNumber(uint32 petnumber
) { m_temporaryUnsummonedPetNumber
= petnumber
; }
2103 void UnsummonPetTemporaryIfAny();
2104 void ResummonPetTemporaryUnSummonedIfAny();
2105 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
2107 void SendCinematicStart(uint32 CinematicSequenceId
);
2108 void SendMovieStart(uint32 MovieId
);
2110 /*********************************************************/
2111 /*** INSTANCE SYSTEM ***/
2112 /*********************************************************/
2114 typedef UNORDERED_MAP
< uint32
/*mapId*/, InstancePlayerBind
> BoundInstancesMap
;
2116 void UpdateHomebindTime(uint32 time
);
2118 uint32 m_HomebindTimer
;
2119 bool m_InstanceValid
;
2120 // permanent binds and solo binds by difficulty
2121 BoundInstancesMap m_boundInstances
[TOTAL_DIFFICULTIES
];
2122 InstancePlayerBind
* GetBoundInstance(uint32 mapid
, uint8 difficulty
);
2123 BoundInstancesMap
& GetBoundInstances(uint8 difficulty
) { return m_boundInstances
[difficulty
]; }
2124 void UnbindInstance(uint32 mapid
, uint8 difficulty
, bool unload
= false);
2125 void UnbindInstance(BoundInstancesMap::iterator
&itr
, uint8 difficulty
, bool unload
= false);
2126 InstancePlayerBind
* BindToInstance(InstanceSave
*save
, bool permanent
, bool load
= false);
2127 void SendRaidInfo();
2128 void SendSavedInstances();
2129 static void ConvertInstancesToGroup(Player
*player
, Group
*group
= NULL
, uint64 player_guid
= 0);
2131 /*********************************************************/
2132 /*** GROUP SYSTEM ***/
2133 /*********************************************************/
2135 Group
* GetGroupInvite() { return m_groupInvite
; }
2136 void SetGroupInvite(Group
*group
) { m_groupInvite
= group
; }
2137 Group
* GetGroup() { return m_group
.getTarget(); }
2138 const Group
* GetGroup() const { return (const Group
*)m_group
.getTarget(); }
2139 GroupReference
& GetGroupRef() { return m_group
; }
2140 void SetGroup(Group
*group
, int8 subgroup
= -1);
2141 uint8
GetSubGroup() const { return m_group
.getSubGroup(); }
2142 uint32
GetGroupUpdateFlag() const { return m_groupUpdateMask
; }
2143 void SetGroupUpdateFlag(uint32 flag
) { m_groupUpdateMask
|= flag
; }
2144 const uint64
& GetAuraUpdateMask() const { return m_auraUpdateMask
; }
2145 void SetAuraUpdateMask(uint8 slot
) { m_auraUpdateMask
|= (uint64(1) << slot
); }
2146 Player
* GetNextRandomRaidMember(float radius
);
2147 PartyResult
CanUninviteFromGroup() const;
2148 // BattleGround Group System
2149 void SetBattleGroundRaid(Group
*group
, int8 subgroup
= -1);
2150 void RemoveFromBattleGroundRaid();
2151 Group
* GetOriginalGroup() { return m_originalGroup
.getTarget(); }
2152 GroupReference
& GetOriginalGroupRef() { return m_originalGroup
; }
2153 uint8
GetOriginalSubGroup() const { return m_originalGroup
.getSubGroup(); }
2154 void SetOriginalGroup(Group
*group
, int8 subgroup
= -1);
2156 GridReference
<Player
> &GetGridRef() { return m_gridRef
; }
2157 MapReference
&GetMapRef() { return m_mapRef
; }
2159 bool isAllowedToLoot(Creature
* creature
);
2161 DeclinedName
const* GetDeclinedNames() const { return m_declinedname
; }
2162 uint8
GetRunesState() const { return m_runes
->runeState
; }
2163 uint8
GetBaseRune(uint8 index
) const { return m_runes
->runes
[index
].BaseRune
; }
2164 uint8
GetCurrentRune(uint8 index
) const { return m_runes
->runes
[index
].CurrentRune
; }
2165 uint8
GetRuneCooldown(uint8 index
) const { return m_runes
->runes
[index
].Cooldown
; }
2166 void SetBaseRune(uint8 index
, uint8 baseRune
) { m_runes
->runes
[index
].BaseRune
= baseRune
; }
2167 void SetCurrentRune(uint8 index
, uint8 currentRune
) { m_runes
->runes
[index
].CurrentRune
= currentRune
; }
2168 void SetRuneCooldown(uint8 index
, uint8 cooldown
) { m_runes
->runes
[index
].Cooldown
= cooldown
; m_runes
->SetRuneState(index
, (cooldown
== 0) ? true : false); }
2169 void ConvertRune(uint8 index
, uint8 newType
);
2170 void ResyncRunes(uint8 count
);
2171 void AddRunePower(uint8 index
);
2173 AchievementMgr
& GetAchievementMgr() { return m_achievementMgr
; }
2174 void UpdateAchievementCriteria(AchievementCriteriaTypes type
, uint32 miscvalue1
=0, uint32 miscvalue2
=0, Unit
*unit
=NULL
, uint32 time
=0);
2175 bool HasTitle(uint32 bitIndex
);
2176 bool HasTitle(CharTitlesEntry
const* title
) { return HasTitle(title
->bit_index
); }
2177 void SetTitle(CharTitlesEntry
const* title
);
2179 bool isActiveObject() const { return true; }
2180 bool canSeeSpellClickOn(Creature
const* creature
) const;
2183 /*********************************************************/
2184 /*** BATTLEGROUND SYSTEM ***/
2185 /*********************************************************/
2187 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2188 uint32 m_bgBattleGroundID
;
2189 BattleGroundTypeId m_bgTypeID
;
2191 this is an array of BG queues (BgTypeIDs) in which is player
2193 struct BgBattleGroundQueueID_Rec
2195 BattleGroundQueueTypeId bgQueueTypeId
;
2196 uint32 invitedToInstance
;
2198 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID
[PLAYER_MAX_BATTLEGROUND_QUEUES
];
2199 WorldLocation m_bgEntryPoint
;
2201 std::set
<uint32
> m_bgAfkReporter
;
2202 uint8 m_bgAfkReportedCount
;
2203 time_t m_bgAfkReportedTimer
;
2204 uint32 m_contestedPvPTimer
;
2206 uint32 m_bgTeam
; // what side the player will be added to
2208 /*********************************************************/
2209 /*** QUEST SYSTEM ***/
2210 /*********************************************************/
2212 std::set
<uint32
> m_timedquests
;
2215 uint32 m_ingametime
;
2217 /*********************************************************/
2218 /*** LOAD SYSTEM ***/
2219 /*********************************************************/
2221 void _LoadActions(QueryResult
*result
);
2222 void _LoadAuras(QueryResult
*result
, uint32 timediff
);
2223 void _LoadGlyphAuras();
2224 void _LoadBoundInstances(QueryResult
*result
);
2225 void _LoadInventory(QueryResult
*result
, uint32 timediff
);
2226 void _LoadMailInit(QueryResult
*resultUnread
, QueryResult
*resultDelivery
);
2228 void _LoadMailedItems(Mail
*mail
);
2229 void _LoadQuestStatus(QueryResult
*result
);
2230 void _LoadDailyQuestStatus(QueryResult
*result
);
2231 void _LoadGroup(QueryResult
*result
);
2233 void _LoadSpells(QueryResult
*result
);
2234 void _LoadFriendList(QueryResult
*result
);
2235 bool _LoadHomeBind(QueryResult
*result
);
2236 void _LoadDeclinedNames(QueryResult
*result
);
2237 void _LoadArenaTeamInfo(QueryResult
*result
);
2238 void _LoadEquipmentSets(QueryResult
*result
);
2240 /*********************************************************/
2241 /*** SAVE SYSTEM ***/
2242 /*********************************************************/
2244 void _SaveActions();
2246 void _SaveInventory();
2248 void _SaveQuestStatus();
2249 void _SaveDailyQuestStatus();
2251 void _SaveEquipmentSets();
2253 void _SetCreateBits(UpdateMask
*updateMask
, Player
*target
) const;
2254 void _SetUpdateBits(UpdateMask
*updateMask
, Player
*target
) const;
2256 /*********************************************************/
2257 /*** ENVIRONMENTAL SYSTEM ***/
2258 /*********************************************************/
2259 void HandleSobering();
2260 void SendMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
, uint32 CurrentValue
, int32 Regen
);
2261 void StopMirrorTimer(MirrorTimerType Type
);
2262 void HandleDrowning(uint32 time_diff
);
2263 int32
getMaxTimer(MirrorTimerType timer
);
2265 /*********************************************************/
2266 /*** HONOR SYSTEM ***/
2267 /*********************************************************/
2268 time_t m_lastHonorUpdateTime
;
2270 void outDebugValues() const;
2276 uint32 m_speakCount
;
2277 uint32 m_dungeonDifficulty
;
2279 uint32 m_atLoginFlags
;
2281 Item
* m_items
[PLAYER_SLOTS_COUNT
];
2282 uint32 m_currentBuybackSlot
;
2284 std::vector
<Item
*> m_itemUpdateQueue
;
2285 bool m_itemUpdateQueueBlocked
;
2287 uint32 m_ExtraFlags
;
2288 uint64 m_curSelection
;
2290 uint64 m_comboTarget
;
2293 QuestStatusMap mQuestStatus
;
2295 uint32 m_GuildIdInvited
;
2296 uint32 m_ArenaTeamIdInvited
;
2299 PlayerSpellMap m_spells
;
2300 SpellCooldowns m_spellCooldowns
;
2301 uint32 m_lastPotionId
; // last used health/mana potion in combat, that block next potion use
2303 uint32 m_activeSpec
;
2304 uint32 m_specsCount
;
2306 ActionButtonList m_actionButtons
;
2308 float m_auraBaseMod
[BASEMOD_END
][MOD_END
];
2309 int16 m_baseRatingValue
[MAX_COMBAT_RATING
];
2310 uint16 m_baseSpellDamage
;
2311 uint16 m_baseSpellHealing
;
2312 uint16 m_baseFeralAP
;
2313 uint16 m_baseManaRegen
;
2315 SpellModList m_spellMods
[MAX_SPELLMOD
];
2316 int32 m_SpellModRemoveCount
;
2317 EnchantDurationList m_enchantDuration
;
2318 ItemDurationList m_itemDuration
;
2320 uint64 m_resurrectGUID
;
2321 uint32 m_resurrectMap
;
2322 float m_resurrectX
, m_resurrectY
, m_resurrectZ
;
2323 uint32 m_resurrectHealth
, m_resurrectMana
;
2325 WorldSession
*m_session
;
2327 typedef std::list
<Channel
*> JoinedChannelsList
;
2328 JoinedChannelsList m_channels
;
2334 uint16 tradeItems
[TRADE_SLOT_COUNT
];
2337 time_t m_nextThinkTime
;
2339 bool m_DailyQuestChanged
;
2340 time_t m_lastDailyQuestTime
;
2342 uint32 m_drunkTimer
;
2344 uint32 m_weaponChangeTimer
;
2346 uint32 m_zoneUpdateId
;
2347 uint32 m_zoneUpdateTimer
;
2348 uint32 m_areaUpdateId
;
2350 uint32 m_deathTimer
;
2351 time_t m_deathExpireTime
;
2355 uint32 m_WeaponProficiency
;
2356 uint32 m_ArmorProficiency
;
2359 bool m_canDualWield
;
2360 bool m_canTitanGrip
;
2361 uint8 m_swingErrorMsg
;
2364 ////////////////////Rest System/////////////////////
2366 uint32 inn_pos_mapid
;
2372 ////////////////////Rest System/////////////////////
2375 Transport
* m_transport
;
2377 uint32 m_resetTalentsCost
;
2378 time_t m_resetTalentsTime
;
2379 uint32 m_usedTalentCount
;
2380 uint32 m_questRewardTalentCount
;
2383 PlayerSocial
*m_social
;
2386 GroupReference m_group
;
2387 GroupReference m_originalGroup
;
2388 Group
*m_groupInvite
;
2389 uint32 m_groupUpdateMask
;
2390 uint64 m_auraUpdateMask
;
2395 time_t m_summon_expire
;
2396 uint32 m_summon_mapid
;
2401 DeclinedName
*m_declinedname
;
2403 EquipmentSets m_EquipmentSets
;
2405 // internal common parts for CanStore/StoreItem functions
2406 uint8
_CanStoreItem_InSpecificSlot( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool swap
, Item
*pSrcItem
) const;
2407 uint8
_CanStoreItem_InBag( uint8 bag
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool merge
, bool non_specialized
, Item
*pSrcItem
, uint8 skip_bag
, uint8 skip_slot
) const;
2408 uint8
_CanStoreItem_InInventorySlots( uint8 slot_begin
, uint8 slot_end
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool merge
, Item
*pSrcItem
, uint8 skip_bag
, uint8 skip_slot
) const;
2409 Item
* _StoreItem( uint16 pos
, Item
*pItem
, uint32 count
, bool clone
, bool update
);
2411 void UpdateKnownCurrencies(uint32 itemId
, bool apply
);
2412 int32
CalculateReputationGain(uint32 creatureOrQuestLevel
, int32 rep
, int32 faction
, bool for_quest
);
2413 void AdjustQuestReqItemCount( Quest
const* pQuest
, QuestStatusData
& questStatusData
);
2415 bool IsCanDelayTeleport() const { return m_bCanDelayTeleport
; }
2416 void SetCanDelayTeleport(bool setting
) { m_bCanDelayTeleport
= setting
; }
2417 bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport
; }
2418 void SetDelayedTeleportFlag(bool setting
) { m_bHasDelayedTeleport
= setting
; }
2420 void ScheduleDelayedOperation(uint32 operation
);
2422 GridReference
<Player
> m_gridRef
;
2423 MapReference m_mapRef
;
2425 uint32 m_lastFallTime
;
2428 int32 m_MirrorTimer
[MAX_TIMERS
];
2429 uint8 m_MirrorTimerFlags
;
2430 uint8 m_MirrorTimerFlagsLast
;
2433 // Current teleport data
2434 WorldLocation m_teleport_dest
;
2435 uint32 m_teleport_options
;
2436 bool mSemaphoreTeleport_Near
;
2437 bool mSemaphoreTeleport_Far
;
2439 uint32 m_DelayedOperations
;
2440 bool m_bCanDelayTeleport
;
2441 bool m_bHasDelayedTeleport
;
2443 // Temporary removed pet cache
2444 uint32 m_temporaryUnsummonedPetNumber
;
2445 uint32 m_oldpetspell
;
2447 AchievementMgr m_achievementMgr
;
2448 ReputationMgr m_reputationMgr
;
2451 void AddItemsSetItem(Player
*player
,Item
*item
);
2452 void RemoveItemsSetItem(Player
*player
,ItemPrototype
const *proto
);
2454 // "the bodies of template functions must be made available in a header file"
2455 template <class T
> T
Player::ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
)
2457 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
2458 if (!spellInfo
) return 0;
2460 int32 totalflat
= 0;
2461 for (SpellModList::iterator itr
= m_spellMods
[op
].begin(); itr
!= m_spellMods
[op
].end(); ++itr
)
2463 SpellModifier
*mod
= *itr
;
2465 if(!IsAffectedBySpellmod(spellInfo
,mod
,spell
))
2467 if (mod
->type
== SPELLMOD_FLAT
)
2468 totalflat
+= mod
->value
;
2469 else if (mod
->type
== SPELLMOD_PCT
)
2471 // skip percent mods for null basevalue (most important for spell mods with charges )
2472 if(basevalue
== T(0))
2475 // special case (skip >10sec spell casts for instant cast setting)
2476 if( mod
->op
==SPELLMOD_CASTING_TIME
&& basevalue
>= T(10*IN_MILISECONDS
) && mod
->value
<= -100)
2479 totalpct
+= mod
->value
;
2482 if (mod
->charges
> 0 )
2485 if (mod
->charges
== 0)
2488 mod
->lastAffected
= spell
;
2489 if(!mod
->lastAffected
)
2490 mod
->lastAffected
= FindCurrentSpellBySpellId(spellId
);
2491 ++m_SpellModRemoveCount
;
2496 float diff
= (float)basevalue
*(float)totalpct
/100.0f
+ (float)totalflat
;
2497 basevalue
= T((float)basevalue
+ diff
);