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 void RemovePetActionBar();
1447 bool HasSpell(uint32 spell
) const;
1448 bool HasActiveSpell(uint32 spell
) const; // show in spellbook
1449 TrainerSpellState
GetTrainerSpellState(TrainerSpell
const* trainer_spell
) const;
1450 bool IsSpellFitByClassAndRace( uint32 spell_id
) const;
1451 bool IsNeedCastPassiveSpellAtLearn(SpellEntry
const* spellInfo
) const;
1453 void SendProficiency(uint8 pr1
, uint32 pr2
);
1454 void SendInitialSpells();
1455 bool addSpell(uint32 spell_id
, bool active
, bool learning
, bool dependent
, bool disabled
);
1456 void learnSpell(uint32 spell_id
, bool dependent
);
1457 void removeSpell(uint32 spell_id
, bool disabled
= false, bool learn_low_rank
= true);
1459 void learnDefaultSpells();
1460 void learnQuestRewardedSpells();
1461 void learnQuestRewardedSpells(Quest
const* quest
);
1462 void learnSpellHighRank(uint32 spellid
);
1464 uint32
GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1
); }
1465 void SetFreeTalentPoints(uint32 points
) { SetUInt32Value(PLAYER_CHARACTER_POINTS1
,points
); }
1466 bool resetTalents(bool no_cost
= false);
1467 uint32
resetTalentsCost() const;
1468 void InitTalentForLevel();
1469 void BuildPlayerTalentsInfoData(WorldPacket
*data
);
1470 void BuildPetTalentsInfoData(WorldPacket
*data
);
1471 void SendTalentsInfoData(bool pet
);
1472 void LearnTalent(uint32 talentId
, uint32 talentRank
);
1473 void LearnPetTalent(uint64 petGuid
, uint32 talentId
, uint32 talentRank
);
1475 uint32
CalculateTalentsPoints() const;
1478 uint32
GetActiveSpec() { return m_activeSpec
; }
1479 void SetActiveSpec(uint32 spec
) { m_activeSpec
= spec
; }
1480 uint32
GetSpecsCount() { return m_specsCount
; }
1481 void SetSpecsCount(uint32 count
) { m_specsCount
= count
; }
1482 void ActivateSpec(uint32 specNum
);
1484 void InitGlyphsForLevel();
1485 void SetGlyphSlot(uint8 slot
, uint32 slottype
) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
, slottype
); }
1486 uint32
GetGlyphSlot(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
); }
1487 void SetGlyph(uint8 slot
, uint32 glyph
) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
, glyph
); }
1488 uint32
GetGlyph(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
); }
1490 uint32
GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2
); }
1491 void SetFreePrimaryProfessions(uint16 profs
) { SetUInt32Value(PLAYER_CHARACTER_POINTS2
, profs
); }
1492 void InitPrimaryProfessions();
1494 PlayerSpellMap
const& GetSpellMap() const { return m_spells
; }
1495 PlayerSpellMap
& GetSpellMap() { return m_spells
; }
1497 SpellCooldowns
const& GetSpellCooldownMap() const { return m_spellCooldowns
; }
1499 void AddSpellMod(SpellModifier
* mod
, bool apply
);
1500 bool IsAffectedBySpellmod(SpellEntry
const *spellInfo
, SpellModifier
*mod
, Spell
const* spell
= NULL
);
1501 template <class T
> T
ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
= NULL
);
1502 void RemoveSpellMods(Spell
const* spell
);
1504 static uint32
const infinityCooldownDelay
= MONTH
; // used for set "infinity cooldowns" for spells and check
1505 static uint32
const infinityCooldownDelayCheck
= MONTH
/2;
1506 bool HasSpellCooldown(uint32 spell_id
) const
1508 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1509 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> time(NULL
);
1511 uint32
GetSpellCooldownDelay(uint32 spell_id
) const
1513 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1514 time_t t
= time(NULL
);
1515 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> t
? itr
->second
.end
- t
: 0;
1517 void AddSpellAndCategoryCooldowns(SpellEntry
const* spellInfo
, uint32 itemId
, Spell
* spell
= NULL
, bool infinityCooldown
= false );
1518 void AddSpellCooldown(uint32 spell_id
, uint32 itemid
, time_t end_time
);
1519 void SendCooldownEvent(SpellEntry
const *spellInfo
, uint32 itemId
= 0, Spell
* spell
= NULL
);
1520 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask
, uint32 unTimeMs
);
1521 void RemoveSpellCooldown(uint32 spell_id
, bool update
= false);
1522 void RemoveSpellCategoryCooldown(uint32 cat
, bool update
= false);
1523 void SendClearCooldown( uint32 spell_id
, Unit
* target
);
1525 void RemoveArenaSpellCooldowns();
1526 void RemoveAllSpellCooldown();
1527 void _LoadSpellCooldowns(QueryResult
*result
);
1528 void _SaveSpellCooldowns();
1529 void SetLastPotionId(uint32 item_id
) { m_lastPotionId
= item_id
; }
1530 void UpdatePotionCooldown(Spell
* spell
= NULL
);
1532 void setResurrectRequestData(uint64 guid
, uint32 mapId
, float X
, float Y
, float Z
, uint32 health
, uint32 mana
)
1534 m_resurrectGUID
= guid
;
1535 m_resurrectMap
= mapId
;
1539 m_resurrectHealth
= health
;
1540 m_resurrectMana
= mana
;
1542 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f
,0.0f
,0.0f
,0,0); }
1543 bool isRessurectRequestedBy(uint64 guid
) const { return m_resurrectGUID
== guid
; }
1544 bool isRessurectRequested() const { return m_resurrectGUID
!= 0; }
1545 void ResurectUsingRequestData();
1551 void setCinematic(int cine
)
1556 ActionButton
* addActionButton(uint8 button
, uint32 action
, uint8 type
);
1557 void removeActionButton(uint8 button
);
1558 void SendInitialActionButtons() const;
1561 void UpdatePvP(bool state
, bool ovrride
=false);
1562 void UpdateZone(uint32 newZone
,uint32 newArea
);
1563 void UpdateArea(uint32 newArea
);
1565 void UpdateZoneDependentAuras( uint32 zone_id
); // zones
1566 void UpdateAreaDependentAuras( uint32 area_id
); // subzones
1568 void UpdateAfkReport(time_t currTime
);
1569 void UpdatePvPFlag(time_t currTime
);
1570 void UpdateContestedPvP(uint32 currTime
);
1571 void SetContestedPvPTimer(uint32 newTime
) {m_contestedPvPTimer
= newTime
;}
1572 void ResetContestedPvP()
1574 clearUnitState(UNIT_STAT_ATTACK_PLAYER
);
1575 RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_CONTESTED_PVP
);
1576 m_contestedPvPTimer
= 0;
1579 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1581 void UpdateDuelFlag(time_t currTime
);
1582 void CheckDuelDistance(time_t currTime
);
1583 void DuelComplete(DuelCompleteType type
);
1585 bool IsGroupVisibleFor(Player
* p
) const;
1586 bool IsInSameGroupWith(Player
const* p
) const;
1587 bool IsInSameRaidWith(Player
const* p
) const { return p
==this || (GetGroup() != NULL
&& GetGroup() == p
->GetGroup()); }
1588 void UninviteFromGroup();
1589 static void RemoveFromGroup(Group
* group
, uint64 guid
);
1590 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1591 void SendUpdateToOutOfRangeGroupMembers();
1593 void SetInGuild(uint32 GuildId
) { SetUInt32Value(PLAYER_GUILDID
, GuildId
); }
1594 void SetRank(uint32 rankId
){ SetUInt32Value(PLAYER_GUILDRANK
, rankId
); }
1595 void SetGuildIdInvited(uint32 GuildId
) { m_GuildIdInvited
= GuildId
; }
1596 uint32
GetGuildId() { return GetUInt32Value(PLAYER_GUILDID
); }
1597 static uint32
GetGuildIdFromDB(uint64 guid
);
1598 uint32
GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK
); }
1599 static uint32
GetRankFromDB(uint64 guid
);
1600 int GetGuildIdInvited() { return m_GuildIdInvited
; }
1601 static void RemovePetitionsAndSigns(uint64 guid
, uint32 type
);
1604 void SetInArenaTeam(uint32 ArenaTeamId
, uint8 slot
)
1606 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6), ArenaTeamId
);
1608 uint32
GetArenaTeamId(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6)); }
1609 static uint32
GetArenaTeamIdFromDB(uint64 guid
, uint8 slot
);
1610 void SetArenaTeamIdInvited(uint32 ArenaTeamId
) { m_ArenaTeamIdInvited
= ArenaTeamId
; }
1611 uint32
GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited
; }
1612 static void LeaveAllArenaTeams(uint64 guid
);
1614 void SetDifficulty(uint32 dungeon_difficulty
) { m_dungeonDifficulty
= dungeon_difficulty
; }
1615 uint8
GetDifficulty() { return m_dungeonDifficulty
; }
1616 bool IsHeroic() { return m_dungeonDifficulty
== DIFFICULTY_HEROIC
; }
1618 bool UpdateSkill(uint32 skill_id
, uint32 step
);
1619 bool UpdateSkillPro(uint16 SkillId
, int32 Chance
, uint32 step
);
1621 bool UpdateCraftSkill(uint32 spellid
);
1622 bool UpdateGatherSkill(uint32 SkillId
, uint32 SkillValue
, uint32 RedLevel
, uint32 Multiplicator
= 1);
1623 bool UpdateFishingSkill();
1625 uint32
GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE
); }
1626 uint32
GetBaseWeaponSkillValue(WeaponAttackType attType
) const;
1628 uint32
GetSpellByProto(ItemPrototype
*proto
);
1630 float GetHealthBonusFromStamina();
1631 float GetManaBonusFromIntellect();
1633 bool UpdateStats(Stats stat
);
1634 bool UpdateAllStats();
1635 void UpdateResistances(uint32 school
);
1637 void UpdateMaxHealth();
1638 void UpdateMaxPower(Powers power
);
1639 void ApplyFeralAPBonus(int32 amount
, bool apply
);
1640 void UpdateAttackPowerAndDamage(bool ranged
= false);
1641 void UpdateShieldBlockValue();
1642 void UpdateDamagePhysical(WeaponAttackType attType
);
1643 void ApplySpellDamageBonus(int32 amount
, bool apply
);
1644 void ApplySpellHealingBonus(int32 amount
, bool apply
);
1645 void UpdateSpellDamageAndHealingBonus();
1647 void CalculateMinMaxDamage(WeaponAttackType attType
, bool normalized
, float& min_damage
, float& max_damage
);
1649 void UpdateDefenseBonusesMod();
1650 void ApplyRatingMod(CombatRating cr
, int32 value
, bool apply
);
1651 float GetMeleeCritFromAgility();
1652 float GetDodgeFromAgility();
1653 float GetSpellCritFromIntellect();
1654 float OCTRegenHPPerSpirit();
1655 float OCTRegenMPPerSpirit();
1656 float GetRatingCoefficient(CombatRating cr
) const;
1657 float GetRatingBonusValue(CombatRating cr
) const;
1658 uint32
GetMeleeCritDamageReduction(uint32 damage
) const;
1659 uint32
GetRangedCritDamageReduction(uint32 damage
) const;
1660 uint32
GetSpellCritDamageReduction(uint32 damage
) const;
1661 uint32
GetDotDamageReduction(uint32 damage
) const;
1662 uint32
GetBaseSpellDamageBonus() { return m_baseSpellDamage
;}
1663 uint32
GetBaseSpellHealingBonus() { return m_baseSpellHealing
;}
1665 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType
) const;
1666 void UpdateBlockPercentage();
1667 void UpdateCritPercentage(WeaponAttackType attType
);
1668 void UpdateAllCritPercentages();
1669 void UpdateParryPercentage();
1670 void UpdateDodgePercentage();
1671 void UpdateMeleeHitChances();
1672 void UpdateRangedHitChances();
1673 void UpdateSpellHitChances();
1675 void UpdateAllSpellCritChances();
1676 void UpdateSpellCritChance(uint32 school
);
1677 void UpdateExpertise(WeaponAttackType attType
);
1678 void ApplyManaRegenBonus(int32 amount
, bool apply
);
1679 void UpdateManaRegen();
1681 const uint64
& GetLootGUID() const { return m_lootGuid
; }
1682 void SetLootGUID(const uint64
&guid
) { m_lootGuid
= guid
; }
1684 void RemovedInsignia(Player
* looterPlr
);
1686 WorldSession
* GetSession() const { return m_session
; }
1687 void SetSession(WorldSession
*s
) { m_session
= s
; }
1689 void BuildCreateUpdateBlockForPlayer( UpdateData
*data
, Player
*target
) const;
1690 void DestroyForPlayer( Player
*target
) const;
1691 void SendDelayResponse(const uint32
);
1692 void SendLogXPGain(uint32 GivenXP
,Unit
* victim
,uint32 RestXP
);
1695 void SendAttackSwingCantAttack();
1696 void SendAttackSwingCancelAttack();
1697 void SendAttackSwingDeadTarget();
1698 void SendAttackSwingNotInRange();
1699 void SendAttackSwingBadFacingAttack();
1700 void SendAutoRepeatCancel();
1701 void SendExplorationExperience(uint32 Area
, uint32 Experience
);
1703 void SendDungeonDifficulty(bool IsInGroup
);
1704 void ResetInstances(uint8 method
);
1705 void SendResetInstanceSuccess(uint32 MapId
);
1706 void SendResetInstanceFailed(uint32 reason
, uint32 MapId
);
1707 void SendResetFailedNotify(uint32 mapid
);
1709 bool SetPosition(float x
, float y
, float z
, float orientation
, bool teleport
= false);
1710 void UpdateUnderwaterState( Map
* m
, float x
, float y
, float z
);
1712 void SendMessageToSet(WorldPacket
*data
, bool self
);// overwrite Object::SendMessageToSet
1713 void SendMessageToSetInRange(WorldPacket
*data
, float fist
, bool self
);
1714 // overwrite Object::SendMessageToSetInRange
1715 void SendMessageToSetInRange(WorldPacket
*data
, float dist
, bool self
, bool own_team_only
);
1717 static void DeleteFromDB(uint64 playerguid
, uint32 accountId
, bool updateRealmChars
= true);
1719 Corpse
*GetCorpse() const;
1720 void SpawnCorpseBones();
1721 void CreateCorpse();
1723 uint32
GetResurrectionSpellId();
1724 void ResurrectPlayer(float restore_percent
, bool applySickness
= false);
1725 void BuildPlayerRepop();
1726 void RepopAtGraveyard();
1728 void DurabilityLossAll(double percent
, bool inventory
);
1729 void DurabilityLoss(Item
* item
, double percent
);
1730 void DurabilityPointsLossAll(int32 points
, bool inventory
);
1731 void DurabilityPointsLoss(Item
* item
, int32 points
);
1732 void DurabilityPointLossForEquipSlot(EquipmentSlots slot
);
1733 uint32
DurabilityRepairAll(bool cost
, float discountMod
, bool guildBank
);
1734 uint32
DurabilityRepair(uint16 pos
, bool cost
, float discountMod
, bool guildBank
);
1736 void UpdateMirrorTimers();
1737 void StopMirrorTimers()
1739 StopMirrorTimer(FATIGUE_TIMER
);
1740 StopMirrorTimer(BREATH_TIMER
);
1741 StopMirrorTimer(FIRE_TIMER
);
1744 void SetMovement(PlayerMovementType pType
);
1746 void JoinedChannel(Channel
*c
);
1747 void LeftChannel(Channel
*c
);
1748 void CleanupChannels();
1749 void UpdateLocalChannels( uint32 newZone
);
1750 void LeaveLFGChannel();
1752 void UpdateDefense();
1753 void UpdateWeaponSkill (WeaponAttackType attType
);
1754 void UpdateCombatSkills(Unit
*pVictim
, WeaponAttackType attType
, bool defence
);
1756 void SetSkill(uint32 id
, uint16 currVal
, uint16 maxVal
);
1757 uint16
GetMaxSkillValue(uint32 skill
) const; // max + perm. bonus + temp bonus
1758 uint16
GetPureMaxSkillValue(uint32 skill
) const; // max
1759 uint16
GetSkillValue(uint32 skill
) const; // skill value + perm. bonus + temp bonus
1760 uint16
GetBaseSkillValue(uint32 skill
) const; // skill value + perm. bonus
1761 uint16
GetPureSkillValue(uint32 skill
) const; // skill value
1762 int16
GetSkillPermBonusValue(uint32 skill
) const;
1763 int16
GetSkillTempBonusValue(uint32 skill
) const;
1764 bool HasSkill(uint32 skill
) const;
1765 void learnSkillRewardedSpells(uint32 id
, uint32 value
);
1767 WorldLocation
& GetTeleportDest() { return m_teleport_dest
; }
1768 bool IsBeingTeleported() const { return mSemaphoreTeleport_Near
|| mSemaphoreTeleport_Far
; }
1769 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near
; }
1770 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far
; }
1771 void SetSemaphoreTeleportNear(bool semphsetting
) { mSemaphoreTeleport_Near
= semphsetting
; }
1772 void SetSemaphoreTeleportFar(bool semphsetting
) { mSemaphoreTeleport_Far
= semphsetting
; }
1773 void ProcessDelayedOperations();
1775 void CheckExploreSystem(void);
1777 static uint32
TeamForRace(uint8 race
);
1778 uint32
GetTeam() const { return m_team
; }
1779 static uint32
getFactionForRace(uint8 race
);
1780 void setFactionForRace(uint8 race
);
1782 void InitDisplayIds();
1784 bool IsAtGroupRewardDistance(WorldObject
const* pRewardSource
) const;
1785 bool RewardPlayerAndGroupAtKill(Unit
* pVictim
);
1786 void RewardPlayerAndGroupAtEvent(uint32 creature_id
,WorldObject
* pRewardSource
);
1787 bool isHonorOrXPTarget(Unit
* pVictim
);
1789 ReputationMgr
& GetReputationMgr() { return m_reputationMgr
; }
1790 ReputationMgr
const& GetReputationMgr() const { return m_reputationMgr
; }
1791 ReputationRank
GetReputationRank(uint32 faction_id
) const;
1792 void RewardReputation(Unit
*pVictim
, float rate
);
1793 void RewardReputation(Quest
const *pQuest
);
1795 void UpdateSkillsForLevel();
1796 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1797 void ModifySkillBonus(uint32 skillid
,int32 val
, bool talent
);
1799 /*********************************************************/
1800 /*** PVP SYSTEM ***/
1801 /*********************************************************/
1802 void UpdateArenaFields();
1803 void UpdateHonorFields();
1804 bool RewardHonor(Unit
*pVictim
, uint32 groupsize
, float honor
= -1);
1805 uint32
GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
); }
1806 uint32
GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY
); }
1807 void ModifyHonorPoints( int32 value
);
1808 void ModifyArenaPoints( int32 value
);
1809 uint32
GetMaxPersonalArenaRatingRequirement();
1813 void SetDrunkValue(uint16 newDrunkValue
, uint32 itemid
=0);
1814 uint16
GetDrunkValue() const { return m_drunk
; }
1815 static DrunkenState
GetDrunkenstateByValue(uint16 value
);
1817 uint32
GetDeathTimer() const { return m_deathTimer
; }
1818 uint32
GetCorpseReclaimDelay(bool pvp
) const;
1819 void UpdateCorpseReclaimDelay();
1820 void SendCorpseReclaimDelay(bool load
= false);
1822 uint32
GetShieldBlockValue() const; // overwrite Unit version (virtual)
1823 bool CanParry() const { return m_canParry
; }
1824 void SetCanParry(bool value
);
1825 bool CanBlock() const { return m_canBlock
; }
1826 void SetCanBlock(bool value
);
1827 bool CanDualWield() const { return m_canDualWield
; }
1828 void SetCanDualWield(bool value
) { m_canDualWield
= value
; }
1829 bool CanTitanGrip() const { return m_canTitanGrip
; }
1830 void SetCanTitanGrip(bool value
) { m_canTitanGrip
= value
; }
1831 bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE
); }
1833 void SetRegularAttackTime();
1834 void SetBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float value
) { m_auraBaseMod
[modGroup
][modType
] = value
; }
1835 void HandleBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float amount
, bool apply
);
1836 float GetBaseModValue(BaseModGroup modGroup
, BaseModType modType
) const;
1837 float GetTotalBaseModValue(BaseModGroup modGroup
) const;
1838 float GetTotalPercentageModValue(BaseModGroup modGroup
) const { return m_auraBaseMod
[modGroup
][FLAT_MOD
] + m_auraBaseMod
[modGroup
][PCT_MOD
]; }
1839 void _ApplyAllStatBonuses();
1840 void _RemoveAllStatBonuses();
1842 void _ApplyWeaponDependentAuraMods(Item
*item
, WeaponAttackType attackType
, bool apply
);
1843 void _ApplyWeaponDependentAuraCritMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1844 void _ApplyWeaponDependentAuraDamageMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1846 void _ApplyItemMods(Item
*item
,uint8 slot
,bool apply
);
1847 void _RemoveAllItemMods();
1848 void _ApplyAllItemMods();
1849 void _ApplyItemBonuses(ItemPrototype
const *proto
,uint8 slot
,bool apply
);
1850 void _ApplyAmmoBonuses();
1851 bool EnchantmentFitsRequirements(uint32 enchantmentcondition
, int8 slot
);
1852 void ToggleMetaGemsActive(uint8 exceptslot
, bool apply
);
1853 void CorrectMetaGemEnchants(uint8 slot
, bool apply
);
1854 void InitDataForForm(bool reapplyMods
= false);
1856 void ApplyItemEquipSpell(Item
*item
, bool apply
, bool form_change
= false);
1857 void ApplyEquipSpell(SpellEntry
const* spellInfo
, Item
* item
, bool apply
, bool form_change
= false);
1858 void UpdateEquipSpellsAtFormChange();
1859 void CastItemCombatSpell(Unit
* Target
, WeaponAttackType attType
);
1860 void CastItemUseSpell(Item
*item
,SpellCastTargets
const& targets
,uint8 cast_count
, uint32 glyphIndex
);
1862 void SendEquipmentSetList();
1863 void SetEquipmentSet(uint32 index
, EquipmentSet eqset
);
1864 void DeleteEquipmentSet(uint64 setGuid
);
1866 void SendInitWorldStates(uint32 zone
, uint32 area
);
1867 void SendUpdateWorldState(uint32 Field
, uint32 Value
);
1868 void SendDirectMessage(WorldPacket
*data
);
1870 void SendAurasForTarget(Unit
*target
);
1872 PlayerMenu
* PlayerTalkClass
;
1873 std::vector
<ItemSetEffect
*> ItemSetEff
;
1875 void SendLoot(uint64 guid
, LootType loot_type
);
1876 void SendLootRelease( uint64 guid
);
1877 void SendNotifyLootItemRemoved(uint8 lootSlot
);
1878 void SendNotifyLootMoneyRemoved();
1880 /*********************************************************/
1881 /*** BATTLEGROUND SYSTEM ***/
1882 /*********************************************************/
1884 bool InBattleGround() const { return m_bgBattleGroundID
!= 0; }
1885 bool InArena() const;
1886 uint32
GetBattleGroundId() const { return m_bgBattleGroundID
; }
1887 BattleGroundTypeId
GetBattleGroundTypeId() const { return m_bgTypeID
; }
1888 BattleGround
* GetBattleGround() const;
1891 BGQueueIdBasedOnLevel
GetBattleGroundQueueIdFromLevel(BattleGroundTypeId bgTypeId
) const;
1893 bool InBattleGroundQueue() const
1895 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1896 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
!= BATTLEGROUND_QUEUE_NONE
)
1901 BattleGroundQueueTypeId
GetBattleGroundQueueTypeId(uint32 index
) const { return m_bgBattleGroundQueueID
[index
].bgQueueTypeId
; }
1902 uint32
GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId
) const
1904 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1905 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1907 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1909 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
1911 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1912 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1913 return m_bgBattleGroundQueueID
[i
].invitedToInstance
!= 0;
1916 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
1918 return GetBattleGroundQueueIndex(bgQueueTypeId
) < PLAYER_MAX_BATTLEGROUND_QUEUES
;
1921 void SetBattleGroundId(uint32 val
, BattleGroundTypeId bgTypeId
)
1923 m_bgBattleGroundID
= val
;
1924 m_bgTypeID
= bgTypeId
;
1926 uint32
AddBattleGroundQueueId(BattleGroundQueueTypeId val
)
1928 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1930 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
|| m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
1932 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= val
;
1933 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1937 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1939 bool HasFreeBattleGroundQueueId()
1941 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1942 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
)
1946 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val
)
1948 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1950 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
1952 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= BATTLEGROUND_QUEUE_NONE
;
1953 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1958 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
, uint32 instanceId
)
1960 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1961 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1962 m_bgBattleGroundQueueID
[i
].invitedToInstance
= instanceId
;
1964 bool IsInvitedForBattleGroundInstance(uint32 instanceId
) const
1966 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1967 if (m_bgBattleGroundQueueID
[i
].invitedToInstance
== instanceId
)
1971 WorldLocation
const& GetBattleGroundEntryPoint() const { return m_bgEntryPoint
; }
1972 void SetBattleGroundEntryPoint(uint32 Map
, float PosX
, float PosY
, float PosZ
, float PosO
)
1974 m_bgEntryPoint
= WorldLocation(Map
,PosX
,PosY
,PosZ
,PosO
);
1977 void SetBGTeam(uint32 team
) { m_bgTeam
= team
; }
1978 uint32
GetBGTeam() const { return m_bgTeam
? m_bgTeam
: GetTeam(); }
1980 void LeaveBattleground(bool teleportToEntryPoint
= true);
1981 bool CanJoinToBattleground() const;
1982 bool CanReportAfkDueToLimit();
1983 void ReportedAfkBy(Player
* reporter
);
1984 void ClearAfkReports() { m_bgAfkReporter
.clear(); }
1986 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId
) const;
1987 bool CanUseBattleGroundObject();
1988 bool isTotalImmune();
1989 bool CanCaptureTowerPoint();
1991 /*********************************************************/
1992 /*** REST SYSTEM ***/
1993 /*********************************************************/
1995 bool isRested() const { return GetRestTime() >= 10*IN_MILISECONDS
; }
1996 uint32
GetXPRestBonus(uint32 xp
);
1997 uint32
GetRestTime() const { return m_restTime
;};
1998 void SetRestTime(uint32 v
) { m_restTime
= v
;};
2000 /*********************************************************/
2001 /*** ENVIROMENTAL SYSTEM ***/
2002 /*********************************************************/
2004 void EnvironmentalDamage(EnviromentalDamage type
, uint32 damage
);
2006 /*********************************************************/
2007 /*** FLOOD FILTER SYSTEM ***/
2008 /*********************************************************/
2010 void UpdateSpeakTime();
2011 bool CanSpeak() const;
2012 void ChangeSpeakTime(int utime
);
2014 /*********************************************************/
2015 /*** VARIOUS SYSTEMS ***/
2016 /*********************************************************/
2017 MovementInfo m_movementInfo
;
2018 bool HasMovementFlag(MovementFlags f
) const; // for script access to m_movementInfo.HasMovementFlag
2019 void UpdateFallInformationIfNeed(MovementInfo
const& minfo
,uint16 opcode
);
2021 void SetFallInformation(uint32 time
, float z
)
2023 m_lastFallTime
= time
;
2026 void HandleFall(MovementInfo
const& movementInfo
);
2028 void BuildTeleportAckMsg( WorldPacket
*data
, float x
, float y
, float z
, float ang
) const;
2030 bool isMoving() const { return m_movementInfo
.HasMovementFlag(movementFlagsMask
); }
2031 bool isMovingOrTurning() const { return m_movementInfo
.HasMovementFlag(movementOrTurningFlagsMask
); }
2033 bool CanFly() const { return m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_CAN_FLY
); }
2034 bool IsFlying() const { return m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_FLYING
); }
2035 bool IsAllowUseFlyMountsHere() const;
2037 void SetClientControl(Unit
* target
, uint8 allowMove
);
2038 void SetMover(Unit
* target
) { m_mover
= target
? target
: this; }
2040 void EnterVehicle(Vehicle
*vehicle
);
2041 void ExitVehicle(Vehicle
*vehicle
);
2043 uint64
GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT
); }
2044 void SetFarSightGUID(uint64 guid
) { SetUInt64Value(PLAYER_FARSIGHT
, guid
); }
2047 Transport
* GetTransport() const { return m_transport
; }
2048 void SetTransport(Transport
* t
) { m_transport
= t
; }
2050 float GetTransOffsetX() const { return m_movementInfo
.t_x
; }
2051 float GetTransOffsetY() const { return m_movementInfo
.t_y
; }
2052 float GetTransOffsetZ() const { return m_movementInfo
.t_z
; }
2053 float GetTransOffsetO() const { return m_movementInfo
.t_o
; }
2054 uint32
GetTransTime() const { return m_movementInfo
.t_time
; }
2055 int8
GetTransSeat() const { return m_movementInfo
.t_seat
; }
2057 uint32
GetSaveTimer() const { return m_nextSave
; }
2058 void SetSaveTimer(uint32 timer
) { m_nextSave
= timer
; }
2066 void SaveRecallPosition();
2068 // Homebind coordinates
2069 uint32 m_homebindMapId
;
2070 uint16 m_homebindZoneId
;
2074 void RelocateToHomebind() { SetMapId(m_homebindMapId
); Relocate(m_homebindX
,m_homebindY
,m_homebindZ
); }
2076 // currently visible objects at player client
2077 typedef std::set
<uint64
> ClientGUIDs
;
2078 ClientGUIDs m_clientGUIDs
;
2080 bool HaveAtClient(WorldObject
const* u
) { return u
==this || m_clientGUIDs
.find(u
->GetGUID())!=m_clientGUIDs
.end(); }
2082 bool IsVisibleInGridForPlayer(Player
* pl
) const;
2083 bool IsVisibleGloballyFor(Player
* pl
) const;
2085 void UpdateVisibilityOf(WorldObject
* target
);
2088 void UpdateVisibilityOf(T
* target
, UpdateData
& data
, UpdateDataMapType
& data_updates
, std::set
<WorldObject
*>& visibleNow
);
2090 // Stealth detection system
2091 uint32 m_DetectInvTimer
;
2092 void HandleStealthedUnitsDetection();
2094 uint8 m_forced_speed_changes
[MAX_MOVE_TYPE
];
2096 bool HasAtLoginFlag(AtLoginFlags f
) const { return m_atLoginFlags
& f
; }
2097 void SetAtLoginFlag(AtLoginFlags f
) { m_atLoginFlags
|= f
; }
2098 void RemoveAtLoginFlag(AtLoginFlags f
, bool in_db_also
= false);
2100 LookingForGroup m_lookingForGroup
;
2102 // Temporarily removed pet cache
2103 uint32
GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber
; }
2104 void SetTemporaryUnsummonedPetNumber(uint32 petnumber
) { m_temporaryUnsummonedPetNumber
= petnumber
; }
2105 void UnsummonPetTemporaryIfAny();
2106 void ResummonPetTemporaryUnSummonedIfAny();
2107 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
2109 void SendCinematicStart(uint32 CinematicSequenceId
);
2110 void SendMovieStart(uint32 MovieId
);
2112 /*********************************************************/
2113 /*** INSTANCE SYSTEM ***/
2114 /*********************************************************/
2116 typedef UNORDERED_MAP
< uint32
/*mapId*/, InstancePlayerBind
> BoundInstancesMap
;
2118 void UpdateHomebindTime(uint32 time
);
2120 uint32 m_HomebindTimer
;
2121 bool m_InstanceValid
;
2122 // permanent binds and solo binds by difficulty
2123 BoundInstancesMap m_boundInstances
[TOTAL_DIFFICULTIES
];
2124 InstancePlayerBind
* GetBoundInstance(uint32 mapid
, uint8 difficulty
);
2125 BoundInstancesMap
& GetBoundInstances(uint8 difficulty
) { return m_boundInstances
[difficulty
]; }
2126 void UnbindInstance(uint32 mapid
, uint8 difficulty
, bool unload
= false);
2127 void UnbindInstance(BoundInstancesMap::iterator
&itr
, uint8 difficulty
, bool unload
= false);
2128 InstancePlayerBind
* BindToInstance(InstanceSave
*save
, bool permanent
, bool load
= false);
2129 void SendRaidInfo();
2130 void SendSavedInstances();
2131 static void ConvertInstancesToGroup(Player
*player
, Group
*group
= NULL
, uint64 player_guid
= 0);
2133 /*********************************************************/
2134 /*** GROUP SYSTEM ***/
2135 /*********************************************************/
2137 Group
* GetGroupInvite() { return m_groupInvite
; }
2138 void SetGroupInvite(Group
*group
) { m_groupInvite
= group
; }
2139 Group
* GetGroup() { return m_group
.getTarget(); }
2140 const Group
* GetGroup() const { return (const Group
*)m_group
.getTarget(); }
2141 GroupReference
& GetGroupRef() { return m_group
; }
2142 void SetGroup(Group
*group
, int8 subgroup
= -1);
2143 uint8
GetSubGroup() const { return m_group
.getSubGroup(); }
2144 uint32
GetGroupUpdateFlag() const { return m_groupUpdateMask
; }
2145 void SetGroupUpdateFlag(uint32 flag
) { m_groupUpdateMask
|= flag
; }
2146 const uint64
& GetAuraUpdateMask() const { return m_auraUpdateMask
; }
2147 void SetAuraUpdateMask(uint8 slot
) { m_auraUpdateMask
|= (uint64(1) << slot
); }
2148 Player
* GetNextRandomRaidMember(float radius
);
2149 PartyResult
CanUninviteFromGroup() const;
2150 // BattleGround Group System
2151 void SetBattleGroundRaid(Group
*group
, int8 subgroup
= -1);
2152 void RemoveFromBattleGroundRaid();
2153 Group
* GetOriginalGroup() { return m_originalGroup
.getTarget(); }
2154 GroupReference
& GetOriginalGroupRef() { return m_originalGroup
; }
2155 uint8
GetOriginalSubGroup() const { return m_originalGroup
.getSubGroup(); }
2156 void SetOriginalGroup(Group
*group
, int8 subgroup
= -1);
2158 GridReference
<Player
> &GetGridRef() { return m_gridRef
; }
2159 MapReference
&GetMapRef() { return m_mapRef
; }
2161 bool isAllowedToLoot(Creature
* creature
);
2163 DeclinedName
const* GetDeclinedNames() const { return m_declinedname
; }
2164 uint8
GetRunesState() const { return m_runes
->runeState
; }
2165 uint8
GetBaseRune(uint8 index
) const { return m_runes
->runes
[index
].BaseRune
; }
2166 uint8
GetCurrentRune(uint8 index
) const { return m_runes
->runes
[index
].CurrentRune
; }
2167 uint8
GetRuneCooldown(uint8 index
) const { return m_runes
->runes
[index
].Cooldown
; }
2168 void SetBaseRune(uint8 index
, uint8 baseRune
) { m_runes
->runes
[index
].BaseRune
= baseRune
; }
2169 void SetCurrentRune(uint8 index
, uint8 currentRune
) { m_runes
->runes
[index
].CurrentRune
= currentRune
; }
2170 void SetRuneCooldown(uint8 index
, uint8 cooldown
) { m_runes
->runes
[index
].Cooldown
= cooldown
; m_runes
->SetRuneState(index
, (cooldown
== 0) ? true : false); }
2171 void ConvertRune(uint8 index
, uint8 newType
);
2172 void ResyncRunes(uint8 count
);
2173 void AddRunePower(uint8 index
);
2175 AchievementMgr
& GetAchievementMgr() { return m_achievementMgr
; }
2176 void UpdateAchievementCriteria(AchievementCriteriaTypes type
, uint32 miscvalue1
=0, uint32 miscvalue2
=0, Unit
*unit
=NULL
, uint32 time
=0);
2177 bool HasTitle(uint32 bitIndex
);
2178 bool HasTitle(CharTitlesEntry
const* title
) { return HasTitle(title
->bit_index
); }
2179 void SetTitle(CharTitlesEntry
const* title
);
2181 bool isActiveObject() const { return true; }
2182 bool canSeeSpellClickOn(Creature
const* creature
) const;
2185 /*********************************************************/
2186 /*** BATTLEGROUND SYSTEM ***/
2187 /*********************************************************/
2189 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2190 uint32 m_bgBattleGroundID
;
2191 BattleGroundTypeId m_bgTypeID
;
2193 this is an array of BG queues (BgTypeIDs) in which is player
2195 struct BgBattleGroundQueueID_Rec
2197 BattleGroundQueueTypeId bgQueueTypeId
;
2198 uint32 invitedToInstance
;
2200 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID
[PLAYER_MAX_BATTLEGROUND_QUEUES
];
2201 WorldLocation m_bgEntryPoint
;
2203 std::set
<uint32
> m_bgAfkReporter
;
2204 uint8 m_bgAfkReportedCount
;
2205 time_t m_bgAfkReportedTimer
;
2206 uint32 m_contestedPvPTimer
;
2208 uint32 m_bgTeam
; // what side the player will be added to
2210 /*********************************************************/
2211 /*** QUEST SYSTEM ***/
2212 /*********************************************************/
2214 std::set
<uint32
> m_timedquests
;
2217 uint32 m_ingametime
;
2219 /*********************************************************/
2220 /*** LOAD SYSTEM ***/
2221 /*********************************************************/
2223 void _LoadActions(QueryResult
*result
);
2224 void _LoadAuras(QueryResult
*result
, uint32 timediff
);
2225 void _LoadGlyphAuras();
2226 void _LoadBoundInstances(QueryResult
*result
);
2227 void _LoadInventory(QueryResult
*result
, uint32 timediff
);
2228 void _LoadMailInit(QueryResult
*resultUnread
, QueryResult
*resultDelivery
);
2230 void _LoadMailedItems(Mail
*mail
);
2231 void _LoadQuestStatus(QueryResult
*result
);
2232 void _LoadDailyQuestStatus(QueryResult
*result
);
2233 void _LoadGroup(QueryResult
*result
);
2235 void _LoadSpells(QueryResult
*result
);
2236 void _LoadFriendList(QueryResult
*result
);
2237 bool _LoadHomeBind(QueryResult
*result
);
2238 void _LoadDeclinedNames(QueryResult
*result
);
2239 void _LoadArenaTeamInfo(QueryResult
*result
);
2240 void _LoadEquipmentSets(QueryResult
*result
);
2242 /*********************************************************/
2243 /*** SAVE SYSTEM ***/
2244 /*********************************************************/
2246 void _SaveActions();
2248 void _SaveInventory();
2250 void _SaveQuestStatus();
2251 void _SaveDailyQuestStatus();
2253 void _SaveEquipmentSets();
2255 void _SetCreateBits(UpdateMask
*updateMask
, Player
*target
) const;
2256 void _SetUpdateBits(UpdateMask
*updateMask
, Player
*target
) const;
2258 /*********************************************************/
2259 /*** ENVIRONMENTAL SYSTEM ***/
2260 /*********************************************************/
2261 void HandleSobering();
2262 void SendMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
, uint32 CurrentValue
, int32 Regen
);
2263 void StopMirrorTimer(MirrorTimerType Type
);
2264 void HandleDrowning(uint32 time_diff
);
2265 int32
getMaxTimer(MirrorTimerType timer
);
2267 /*********************************************************/
2268 /*** HONOR SYSTEM ***/
2269 /*********************************************************/
2270 time_t m_lastHonorUpdateTime
;
2272 void outDebugValues() const;
2278 uint32 m_speakCount
;
2279 uint32 m_dungeonDifficulty
;
2281 uint32 m_atLoginFlags
;
2283 Item
* m_items
[PLAYER_SLOTS_COUNT
];
2284 uint32 m_currentBuybackSlot
;
2286 std::vector
<Item
*> m_itemUpdateQueue
;
2287 bool m_itemUpdateQueueBlocked
;
2289 uint32 m_ExtraFlags
;
2290 uint64 m_curSelection
;
2292 uint64 m_comboTarget
;
2295 QuestStatusMap mQuestStatus
;
2297 uint32 m_GuildIdInvited
;
2298 uint32 m_ArenaTeamIdInvited
;
2301 PlayerSpellMap m_spells
;
2302 SpellCooldowns m_spellCooldowns
;
2303 uint32 m_lastPotionId
; // last used health/mana potion in combat, that block next potion use
2305 uint32 m_activeSpec
;
2306 uint32 m_specsCount
;
2308 ActionButtonList m_actionButtons
;
2310 float m_auraBaseMod
[BASEMOD_END
][MOD_END
];
2311 int16 m_baseRatingValue
[MAX_COMBAT_RATING
];
2312 uint16 m_baseSpellDamage
;
2313 uint16 m_baseSpellHealing
;
2314 uint16 m_baseFeralAP
;
2315 uint16 m_baseManaRegen
;
2317 SpellModList m_spellMods
[MAX_SPELLMOD
];
2318 int32 m_SpellModRemoveCount
;
2319 EnchantDurationList m_enchantDuration
;
2320 ItemDurationList m_itemDuration
;
2322 uint64 m_resurrectGUID
;
2323 uint32 m_resurrectMap
;
2324 float m_resurrectX
, m_resurrectY
, m_resurrectZ
;
2325 uint32 m_resurrectHealth
, m_resurrectMana
;
2327 WorldSession
*m_session
;
2329 typedef std::list
<Channel
*> JoinedChannelsList
;
2330 JoinedChannelsList m_channels
;
2336 uint16 tradeItems
[TRADE_SLOT_COUNT
];
2339 time_t m_nextThinkTime
;
2341 bool m_DailyQuestChanged
;
2342 time_t m_lastDailyQuestTime
;
2344 uint32 m_drunkTimer
;
2346 uint32 m_weaponChangeTimer
;
2348 uint32 m_zoneUpdateId
;
2349 uint32 m_zoneUpdateTimer
;
2350 uint32 m_areaUpdateId
;
2352 uint32 m_deathTimer
;
2353 time_t m_deathExpireTime
;
2357 uint32 m_WeaponProficiency
;
2358 uint32 m_ArmorProficiency
;
2361 bool m_canDualWield
;
2362 bool m_canTitanGrip
;
2363 uint8 m_swingErrorMsg
;
2366 ////////////////////Rest System/////////////////////
2368 uint32 inn_pos_mapid
;
2374 ////////////////////Rest System/////////////////////
2377 Transport
* m_transport
;
2379 uint32 m_resetTalentsCost
;
2380 time_t m_resetTalentsTime
;
2381 uint32 m_usedTalentCount
;
2382 uint32 m_questRewardTalentCount
;
2385 PlayerSocial
*m_social
;
2388 GroupReference m_group
;
2389 GroupReference m_originalGroup
;
2390 Group
*m_groupInvite
;
2391 uint32 m_groupUpdateMask
;
2392 uint64 m_auraUpdateMask
;
2397 time_t m_summon_expire
;
2398 uint32 m_summon_mapid
;
2403 DeclinedName
*m_declinedname
;
2405 EquipmentSets m_EquipmentSets
;
2407 // internal common parts for CanStore/StoreItem functions
2408 uint8
_CanStoreItem_InSpecificSlot( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool swap
, Item
*pSrcItem
) const;
2409 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;
2410 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;
2411 Item
* _StoreItem( uint16 pos
, Item
*pItem
, uint32 count
, bool clone
, bool update
);
2413 void UpdateKnownCurrencies(uint32 itemId
, bool apply
);
2414 int32
CalculateReputationGain(uint32 creatureOrQuestLevel
, int32 rep
, int32 faction
, bool for_quest
);
2415 void AdjustQuestReqItemCount( Quest
const* pQuest
, QuestStatusData
& questStatusData
);
2417 bool IsCanDelayTeleport() const { return m_bCanDelayTeleport
; }
2418 void SetCanDelayTeleport(bool setting
) { m_bCanDelayTeleport
= setting
; }
2419 bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport
; }
2420 void SetDelayedTeleportFlag(bool setting
) { m_bHasDelayedTeleport
= setting
; }
2422 void ScheduleDelayedOperation(uint32 operation
);
2424 GridReference
<Player
> m_gridRef
;
2425 MapReference m_mapRef
;
2427 uint32 m_lastFallTime
;
2430 int32 m_MirrorTimer
[MAX_TIMERS
];
2431 uint8 m_MirrorTimerFlags
;
2432 uint8 m_MirrorTimerFlagsLast
;
2435 // Current teleport data
2436 WorldLocation m_teleport_dest
;
2437 uint32 m_teleport_options
;
2438 bool mSemaphoreTeleport_Near
;
2439 bool mSemaphoreTeleport_Far
;
2441 uint32 m_DelayedOperations
;
2442 bool m_bCanDelayTeleport
;
2443 bool m_bHasDelayedTeleport
;
2445 // Temporary removed pet cache
2446 uint32 m_temporaryUnsummonedPetNumber
;
2447 uint32 m_oldpetspell
;
2449 AchievementMgr m_achievementMgr
;
2450 ReputationMgr m_reputationMgr
;
2453 void AddItemsSetItem(Player
*player
,Item
*item
);
2454 void RemoveItemsSetItem(Player
*player
,ItemPrototype
const *proto
);
2456 // "the bodies of template functions must be made available in a header file"
2457 template <class T
> T
Player::ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
)
2459 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
2460 if (!spellInfo
) return 0;
2462 int32 totalflat
= 0;
2463 for (SpellModList::iterator itr
= m_spellMods
[op
].begin(); itr
!= m_spellMods
[op
].end(); ++itr
)
2465 SpellModifier
*mod
= *itr
;
2467 if(!IsAffectedBySpellmod(spellInfo
,mod
,spell
))
2469 if (mod
->type
== SPELLMOD_FLAT
)
2470 totalflat
+= mod
->value
;
2471 else if (mod
->type
== SPELLMOD_PCT
)
2473 // skip percent mods for null basevalue (most important for spell mods with charges )
2474 if(basevalue
== T(0))
2477 // special case (skip >10sec spell casts for instant cast setting)
2478 if( mod
->op
==SPELLMOD_CASTING_TIME
&& basevalue
>= T(10*IN_MILISECONDS
) && mod
->value
<= -100)
2481 totalpct
+= mod
->value
;
2484 if (mod
->charges
> 0 )
2487 if (mod
->charges
== 0)
2490 mod
->lastAffected
= spell
;
2491 if(!mod
->lastAffected
)
2492 mod
->lastAffected
= FindCurrentSpellBySpellId(spellId
);
2493 ++m_SpellModRemoveCount
;
2498 float diff
= (float)basevalue
*(float)totalpct
/100.0f
+ (float)totalflat
;
2499 basevalue
= T((float)basevalue
+ diff
);