2 * Copyright (C) 2005-2010 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
;
58 typedef std::deque
<Mail
*> PlayerMails
;
60 #define PLAYER_MAX_SKILLS 127
61 #define PLAYER_MAX_DAILY_QUESTS 25
63 // Note: SPELLMOD_* values is aura types in fact
66 SPELLMOD_FLAT
= 107, // SPELL_AURA_ADD_FLAT_MODIFIER
67 SPELLMOD_PCT
= 108 // SPELL_AURA_ADD_PCT_MODIFIER
70 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
71 enum PlayerUnderwaterState
73 UNDERWATER_NONE
= 0x00,
74 UNDERWATER_INWATER
= 0x01, // terrain type is water and player is afflicted by it
75 UNDERWATER_INLAVA
= 0x02, // terrain type is lava and player is afflicted by it
76 UNDERWATER_INSLIME
= 0x04, // terrain type is lava and player is afflicted by it
77 UNDERWARER_INDARKWATER
= 0x08, // terrain type is dark water and player is afflicted by it
79 UNDERWATER_EXIST_TIMERS
= 0x10
84 PLAYERSPELL_UNCHANGED
= 0,
85 PLAYERSPELL_CHANGED
= 1,
87 PLAYERSPELL_REMOVED
= 3
92 PlayerSpellState state
: 8;
93 bool active
: 1; // show in spellbook
94 bool dependent
: 1; // learned as result another spell learn, skill grow, quest reward, etc
95 bool disabled
: 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
98 typedef UNORDERED_MAP
<uint32
, PlayerSpell
> PlayerSpellMap
;
100 // Spell modifier (used for modify other spells)
103 SpellModifier() : charges(0), lastAffected(NULL
) {}
105 SpellModifier(SpellModOp _op
, SpellModType _type
, int32 _value
, uint32 _spellId
, uint64 _mask
, uint32 _mask2
= 0, int16 _charges
= 0)
106 : op(_op
), type(_type
), charges(_charges
), value(_value
), mask(_mask
), mask2(_mask2
), spellId(_spellId
), lastAffected(NULL
)
109 SpellModifier(SpellModOp _op
, SpellModType _type
, int32 _value
, SpellEntry
const* spellEntry
, SpellEffectIndex eff
, int16 _charges
= 0);
111 SpellModifier(SpellModOp _op
, SpellModType _type
, int32 _value
, Aura
const* aura
, int16 _charges
= 0);
113 bool isAffectedOnSpell(SpellEntry
const *spell
) const;
116 SpellModType type
: 8;
122 Spell
const* lastAffected
;
125 typedef std::list
<SpellModifier
*> SpellModList
;
133 typedef std::map
<uint32
, SpellCooldown
> SpellCooldowns
;
135 enum TrainerSpellState
137 TRAINER_SPELL_GREEN
= 0,
138 TRAINER_SPELL_RED
= 1,
139 TRAINER_SPELL_GRAY
= 2,
140 TRAINER_SPELL_GREEN_DISABLED
= 10 // custom value, not send to client: formally green but learn not allowed
143 enum ActionButtonUpdateState
145 ACTIONBUTTON_UNCHANGED
= 0,
146 ACTIONBUTTON_CHANGED
= 1,
147 ACTIONBUTTON_NEW
= 2,
148 ACTIONBUTTON_DELETED
= 3
151 enum ActionButtonType
153 ACTION_BUTTON_SPELL
= 0x00,
154 ACTION_BUTTON_C
= 0x01, // click?
155 ACTION_BUTTON_EQSET
= 0x20,
156 ACTION_BUTTON_MACRO
= 0x40,
157 ACTION_BUTTON_CMACRO
= ACTION_BUTTON_C
| ACTION_BUTTON_MACRO
,
158 ACTION_BUTTON_ITEM
= 0x80
161 #define ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
162 #define ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
163 #define MAX_ACTION_BUTTON_ACTION_VALUE (0x00FFFFFF+1)
167 ActionButton() : packedData(0), uState( ACTIONBUTTON_NEW
) {}
170 ActionButtonUpdateState uState
;
173 ActionButtonType
GetType() const { return ActionButtonType(ACTION_BUTTON_TYPE(packedData
)); }
174 uint32
GetAction() const { return ACTION_BUTTON_ACTION(packedData
); }
175 void SetActionAndType(uint32 action
, ActionButtonType type
)
177 uint32 newData
= action
| (uint32(type
) << 24);
178 if (newData
!= packedData
|| uState
== ACTIONBUTTON_DELETED
)
180 packedData
= newData
;
181 if (uState
!= ACTIONBUTTON_NEW
)
182 uState
= ACTIONBUTTON_CHANGED
;
187 // some action button indexes used in code or clarify structure
188 enum ActionButtonIndex
190 ACTION_BUTTON_SHAMAN_TOTEMS_BAR
= 132,
193 #define MAX_ACTION_BUTTONS 144 //checked in 3.2.0
195 typedef std::map
<uint8
,ActionButton
> ActionButtonList
;
197 enum GlyphUpdateState
208 GlyphUpdateState uState
;
210 Glyph() : id(0), uState(GLYPH_UNCHANGED
) { }
212 uint32
GetId() { return id
; }
214 void SetId(uint32 newId
)
219 if(id
== 0 && uState
== GLYPH_UNCHANGED
) // not exist yet in db and already saved
225 if(uState
== GLYPH_NEW
) // delete before add new -> no change
226 uState
= GLYPH_UNCHANGED
;
227 else // delete existing data
228 uState
= GLYPH_DELETED
;
230 else if (uState
!= GLYPH_NEW
) // if not new data, change current data
232 uState
= GLYPH_CHANGED
;
239 struct PlayerCreateInfoItem
241 PlayerCreateInfoItem(uint32 id
, uint32 amount
) : item_id(id
), item_amount(amount
) {}
247 typedef std::list
<PlayerCreateInfoItem
> PlayerCreateInfoItems
;
249 struct PlayerClassLevelInfo
251 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
256 struct PlayerClassInfo
258 PlayerClassInfo() : levelInfo(NULL
) { }
260 PlayerClassLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
263 struct PlayerLevelInfo
265 PlayerLevelInfo() { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
267 uint8 stats
[MAX_STATS
];
270 typedef std::list
<uint32
> PlayerCreateInfoSpells
;
272 struct PlayerCreateInfoAction
274 PlayerCreateInfoAction() : button(0), type(0), action(0) {}
275 PlayerCreateInfoAction(uint8 _button
, uint32 _action
, uint8 _type
) : button(_button
), type(_type
), action(_action
) {}
282 typedef std::list
<PlayerCreateInfoAction
> PlayerCreateInfoActions
;
286 // existence checked by displayId != 0 // existence checked by displayId != 0
287 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL
)
298 PlayerCreateInfoItems item
;
299 PlayerCreateInfoSpells spell
;
300 PlayerCreateInfoActions action
;
302 PlayerLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
307 PvPInfo() : inHostileArea(false), endTimer(0) {}
315 DuelInfo() : initiator(NULL
), opponent(NULL
), startTimer(0), startTime(0), outOfBound(0) {}
335 #define RUNE_COOLDOWN (2*5*IN_MILISECONDS) // msec
350 uint16 Cooldown
; // msec
355 RuneInfo runes
[MAX_RUNES
];
356 uint8 runeState
; // mask of available runes
358 void SetRuneState(uint8 index
, bool set
= true)
361 runeState
|= (1 << index
); // usable
363 runeState
&= ~(1 << index
); // on cooldown
367 struct EnchantDuration
369 EnchantDuration() : item(NULL
), slot(MAX_ENCHANTMENT_SLOT
), leftduration(0) {};
370 EnchantDuration(Item
* _item
, EnchantmentSlot _slot
, uint32 _leftduration
) : item(_item
), slot(_slot
), leftduration(_leftduration
) { assert(item
); };
373 EnchantmentSlot slot
;
377 typedef std::list
<EnchantDuration
> EnchantDurationList
;
378 typedef std::list
<Item
*> ItemDurationList
;
383 LFG_TYPE_DUNGEON
= 1,
387 LFG_TYPE_HEROIC_DUNGEON
= 5,
388 LFG_TYPE_RANDOM_DUNGEON
= 6
399 struct LookingForGroupSlot
401 LookingForGroupSlot() : entry(0), type(0) {}
402 bool Empty() const { return !entry
&& !type
; }
403 void Clear() { entry
= 0; type
= 0; }
404 void Set(uint32 _entry
, uint32 _type
) { entry
= _entry
; type
= _type
; }
405 bool Is(uint32 _entry
, uint32 _type
) const { return entry
== _entry
&& type
== _type
; }
406 bool canAutoJoin() const { return entry
&& (type
== LFG_TYPE_DUNGEON
|| type
== LFG_TYPE_HEROIC_DUNGEON
); }
412 #define MAX_LOOKING_FOR_GROUP_SLOT 3
414 struct LookingForGroup
417 bool HaveInSlot(LookingForGroupSlot
const& slot
) const { return HaveInSlot(slot
.entry
, slot
.type
); }
418 bool HaveInSlot(uint32 _entry
, uint32 _type
) const
420 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
421 if(slots
[i
].Is(_entry
, _type
))
426 bool canAutoJoin() const
428 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
429 if(slots
[i
].canAutoJoin())
436 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
437 if(!slots
[i
].Empty())
442 LookingForGroupSlot slots
[MAX_LOOKING_FOR_GROUP_SLOT
];
443 LookingForGroupSlot more
;
450 ERR_RAID_GROUP_NONE
= 0,
451 ERR_RAID_GROUP_LOWLEVEL
= 1,
452 ERR_RAID_GROUP_ONLY
= 2,
453 ERR_RAID_GROUP_FULL
= 3,
454 ERR_RAID_GROUP_REQUIREMENTS_UNMATCH
= 4
457 enum PlayerMovementType
473 #define MAX_DRUNKEN 4
477 PLAYER_FLAGS_NONE
= 0x00000000,
478 PLAYER_FLAGS_GROUP_LEADER
= 0x00000001,
479 PLAYER_FLAGS_AFK
= 0x00000002,
480 PLAYER_FLAGS_DND
= 0x00000004,
481 PLAYER_FLAGS_GM
= 0x00000008,
482 PLAYER_FLAGS_GHOST
= 0x00000010,
483 PLAYER_FLAGS_RESTING
= 0x00000020,
484 PLAYER_FLAGS_UNK7
= 0x00000040,
485 PLAYER_FLAGS_UNK8
= 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
486 PLAYER_FLAGS_CONTESTED_PVP
= 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
487 PLAYER_FLAGS_IN_PVP
= 0x00000200,
488 PLAYER_FLAGS_HIDE_HELM
= 0x00000400,
489 PLAYER_FLAGS_HIDE_CLOAK
= 0x00000800,
490 PLAYER_FLAGS_PARTIAL_PLAY_TIME
= 0x00001000, // played long time
491 PLAYER_FLAGS_NO_PLAY_TIME
= 0x00002000, // played too long time
492 PLAYER_FLAGS_IS_OUT_OF_BOUNDS
= 0x00004000, // Lua_IsOutOfBounds
493 PLAYER_FLAGS_DEVELOPER
= 0x00008000, // <Dev> prefix for something?
494 PLAYER_FLAGS_UNK17
= 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
495 PLAYER_FLAGS_TAXI_BENCHMARK
= 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
496 PLAYER_FLAGS_PVP_TIMER
= 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
497 PLAYER_FLAGS_COMMENTATOR
= 0x00080000,
498 PLAYER_FLAGS_UNK21
= 0x00100000,
499 PLAYER_FLAGS_UNK22
= 0x00200000,
500 PLAYER_FLAGS_COMMENTATOR2
= 0x00400000, // something like COMMENTATOR_CAN_USE_INSTANCE_COMMAND
501 PLAYER_FLAGS_UNK24
= 0x00800000, // EVENT_SPELL_UPDATE_USABLE and EVENT_UPDATE_SHAPESHIFT_USABLE, disabled all abilitys on tab except autoattack
502 PLAYER_FLAGS_UNK25
= 0x01000000, // EVENT_SPELL_UPDATE_USABLE and EVENT_UPDATE_SHAPESHIFT_USABLE, disabled all melee ability on tab include autoattack
503 PLAYER_FLAGS_XP_USER_DISABLED
= 0x02000000,
506 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
507 // can't use enum for uint64 values
508 #define PLAYER_TITLE_DISABLED UI64LIT(0x0000000000000000)
509 #define PLAYER_TITLE_NONE UI64LIT(0x0000000000000001)
510 #define PLAYER_TITLE_PRIVATE UI64LIT(0x0000000000000002) // 1
511 #define PLAYER_TITLE_CORPORAL UI64LIT(0x0000000000000004) // 2
512 #define PLAYER_TITLE_SERGEANT_A UI64LIT(0x0000000000000008) // 3
513 #define PLAYER_TITLE_MASTER_SERGEANT UI64LIT(0x0000000000000010) // 4
514 #define PLAYER_TITLE_SERGEANT_MAJOR UI64LIT(0x0000000000000020) // 5
515 #define PLAYER_TITLE_KNIGHT UI64LIT(0x0000000000000040) // 6
516 #define PLAYER_TITLE_KNIGHT_LIEUTENANT UI64LIT(0x0000000000000080) // 7
517 #define PLAYER_TITLE_KNIGHT_CAPTAIN UI64LIT(0x0000000000000100) // 8
518 #define PLAYER_TITLE_KNIGHT_CHAMPION UI64LIT(0x0000000000000200) // 9
519 #define PLAYER_TITLE_LIEUTENANT_COMMANDER UI64LIT(0x0000000000000400) // 10
520 #define PLAYER_TITLE_COMMANDER UI64LIT(0x0000000000000800) // 11
521 #define PLAYER_TITLE_MARSHAL UI64LIT(0x0000000000001000) // 12
522 #define PLAYER_TITLE_FIELD_MARSHAL UI64LIT(0x0000000000002000) // 13
523 #define PLAYER_TITLE_GRAND_MARSHAL UI64LIT(0x0000000000004000) // 14
524 #define PLAYER_TITLE_SCOUT UI64LIT(0x0000000000008000) // 15
525 #define PLAYER_TITLE_GRUNT UI64LIT(0x0000000000010000) // 16
526 #define PLAYER_TITLE_SERGEANT_H UI64LIT(0x0000000000020000) // 17
527 #define PLAYER_TITLE_SENIOR_SERGEANT UI64LIT(0x0000000000040000) // 18
528 #define PLAYER_TITLE_FIRST_SERGEANT UI64LIT(0x0000000000080000) // 19
529 #define PLAYER_TITLE_STONE_GUARD UI64LIT(0x0000000000100000) // 20
530 #define PLAYER_TITLE_BLOOD_GUARD UI64LIT(0x0000000000200000) // 21
531 #define PLAYER_TITLE_LEGIONNAIRE UI64LIT(0x0000000000400000) // 22
532 #define PLAYER_TITLE_CENTURION UI64LIT(0x0000000000800000) // 23
533 #define PLAYER_TITLE_CHAMPION UI64LIT(0x0000000001000000) // 24
534 #define PLAYER_TITLE_LIEUTENANT_GENERAL UI64LIT(0x0000000002000000) // 25
535 #define PLAYER_TITLE_GENERAL UI64LIT(0x0000000004000000) // 26
536 #define PLAYER_TITLE_WARLORD UI64LIT(0x0000000008000000) // 27
537 #define PLAYER_TITLE_HIGH_WARLORD UI64LIT(0x0000000010000000) // 28
538 #define PLAYER_TITLE_GLADIATOR UI64LIT(0x0000000020000000) // 29
539 #define PLAYER_TITLE_DUELIST UI64LIT(0x0000000040000000) // 30
540 #define PLAYER_TITLE_RIVAL UI64LIT(0x0000000080000000) // 31
541 #define PLAYER_TITLE_CHALLENGER UI64LIT(0x0000000100000000) // 32
542 #define PLAYER_TITLE_SCARAB_LORD UI64LIT(0x0000000200000000) // 33
543 #define PLAYER_TITLE_CONQUEROR UI64LIT(0x0000000400000000) // 34
544 #define PLAYER_TITLE_JUSTICAR UI64LIT(0x0000000800000000) // 35
545 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU UI64LIT(0x0000001000000000) // 36
546 #define PLAYER_TITLE_MERCILESS_GLADIATOR UI64LIT(0x0000002000000000) // 37
547 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN UI64LIT(0x0000004000000000) // 38
548 #define PLAYER_TITLE_HAND_OF_ADAL UI64LIT(0x0000008000000000) // 39
549 #define PLAYER_TITLE_VENGEFUL_GLADIATOR UI64LIT(0x0000010000000000) // 40
551 #define MAX_TITLE_INDEX (3*64) // 3 uint64 fields
553 // used in PLAYER_FIELD_BYTES values
554 enum PlayerFieldByteFlags
556 PLAYER_FIELD_BYTE_TRACK_STEALTHED
= 0x00000002,
557 PLAYER_FIELD_BYTE_RELEASE_TIMER
= 0x00000008, // Display time till auto release spirit
558 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW
= 0x00000010 // Display no "release spirit" window at all
561 // used in PLAYER_FIELD_BYTES2 values
562 enum PlayerFieldByte2Flags
564 PLAYER_FIELD_BYTE2_NONE
= 0x0000,
565 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
= 0x4000
568 enum ActivateTaxiReplies
571 ERR_TAXIUNSPECIFIEDSERVERERROR
= 1,
572 ERR_TAXINOSUCHPATH
= 2,
573 ERR_TAXINOTENOUGHMONEY
= 3,
574 ERR_TAXITOOFARAWAY
= 4,
575 ERR_TAXINOVENDORNEARBY
= 5,
576 ERR_TAXINOTVISITED
= 6,
577 ERR_TAXIPLAYERBUSY
= 7,
578 ERR_TAXIPLAYERALREADYMOUNTED
= 8,
579 ERR_TAXIPLAYERSHAPESHIFTED
= 9,
580 ERR_TAXIPLAYERMOVING
= 10,
581 ERR_TAXISAMENODE
= 11,
582 ERR_TAXINOTSTANDING
= 12
592 #define DISABLED_MIRROR_TIMER -1
595 enum PlayerExtraFlags
598 PLAYER_EXTRA_GM_ON
= 0x0001,
599 PLAYER_EXTRA_GM_ACCEPT_TICKETS
= 0x0002,
600 PLAYER_EXTRA_ACCEPT_WHISPERS
= 0x0004,
601 PLAYER_EXTRA_TAXICHEAT
= 0x0008,
602 PLAYER_EXTRA_GM_INVISIBLE
= 0x0010,
603 PLAYER_EXTRA_GM_CHAT
= 0x0020, // Show GM badge in chat messages
606 PLAYER_EXTRA_PVP_DEATH
= 0x0100 // store PvP death status until corpse creating.
612 AT_LOGIN_NONE
= 0x00,
613 AT_LOGIN_RENAME
= 0x01,
614 AT_LOGIN_RESET_SPELLS
= 0x02,
615 AT_LOGIN_RESET_TALENTS
= 0x04,
616 AT_LOGIN_CUSTOMIZE
= 0x08,
617 AT_LOGIN_RESET_PET_TALENTS
= 0x10,
618 AT_LOGIN_FIRST
= 0x20,
621 typedef std::map
<uint32
, QuestStatusData
> QuestStatusMap
;
623 enum QuestSlotOffsets
626 QUEST_STATE_OFFSET
= 1,
627 QUEST_COUNTS_OFFSET
= 2, // 2 and 3
628 QUEST_TIME_OFFSET
= 4
631 #define MAX_QUEST_OFFSET 5
633 enum QuestSlotStateMask
635 QUEST_STATE_NONE
= 0x0000,
636 QUEST_STATE_COMPLETE
= 0x0001,
637 QUEST_STATE_FAIL
= 0x0002
640 enum SkillUpdateState
648 struct SkillStatusData
650 SkillStatusData(uint8 _pos
, SkillUpdateState _uState
) : pos(_pos
), uState(_uState
)
654 SkillUpdateState uState
;
657 typedef UNORDERED_MAP
<uint32
, SkillStatusData
> SkillStatusMap
;
661 // first slot for item stored (in any way in player m_items data)
662 PLAYER_SLOT_START
= 0,
663 // last+1 slot for item stored (in any way in player m_items data)
664 PLAYER_SLOT_END
= 150,
665 PLAYER_SLOTS_COUNT
= (PLAYER_SLOT_END
- PLAYER_SLOT_START
)
668 #define INVENTORY_SLOT_BAG_0 255
670 enum EquipmentSlots
// 19 slots
672 EQUIPMENT_SLOT_START
= 0,
673 EQUIPMENT_SLOT_HEAD
= 0,
674 EQUIPMENT_SLOT_NECK
= 1,
675 EQUIPMENT_SLOT_SHOULDERS
= 2,
676 EQUIPMENT_SLOT_BODY
= 3,
677 EQUIPMENT_SLOT_CHEST
= 4,
678 EQUIPMENT_SLOT_WAIST
= 5,
679 EQUIPMENT_SLOT_LEGS
= 6,
680 EQUIPMENT_SLOT_FEET
= 7,
681 EQUIPMENT_SLOT_WRISTS
= 8,
682 EQUIPMENT_SLOT_HANDS
= 9,
683 EQUIPMENT_SLOT_FINGER1
= 10,
684 EQUIPMENT_SLOT_FINGER2
= 11,
685 EQUIPMENT_SLOT_TRINKET1
= 12,
686 EQUIPMENT_SLOT_TRINKET2
= 13,
687 EQUIPMENT_SLOT_BACK
= 14,
688 EQUIPMENT_SLOT_MAINHAND
= 15,
689 EQUIPMENT_SLOT_OFFHAND
= 16,
690 EQUIPMENT_SLOT_RANGED
= 17,
691 EQUIPMENT_SLOT_TABARD
= 18,
692 EQUIPMENT_SLOT_END
= 19
695 enum InventorySlots
// 4 slots
697 INVENTORY_SLOT_BAG_START
= 19,
698 INVENTORY_SLOT_BAG_END
= 23
701 enum InventoryPackSlots
// 16 slots
703 INVENTORY_SLOT_ITEM_START
= 23,
704 INVENTORY_SLOT_ITEM_END
= 39
707 enum BankItemSlots
// 28 slots
709 BANK_SLOT_ITEM_START
= 39,
710 BANK_SLOT_ITEM_END
= 67
713 enum BankBagSlots
// 7 slots
715 BANK_SLOT_BAG_START
= 67,
716 BANK_SLOT_BAG_END
= 74
719 enum BuyBackSlots
// 12 slots
721 // stored in m_buybackitems
722 BUYBACK_SLOT_START
= 74,
723 BUYBACK_SLOT_END
= 86
726 enum KeyRingSlots
// 32 slots
728 KEYRING_SLOT_START
= 86,
729 KEYRING_SLOT_END
= 118
732 enum CurrencyTokenSlots
// 32 slots
734 CURRENCYTOKEN_SLOT_START
= 118,
735 CURRENCYTOKEN_SLOT_END
= 150
738 enum EquipmentSetUpdateState
740 EQUIPMENT_SET_UNCHANGED
= 0,
741 EQUIPMENT_SET_CHANGED
= 1,
742 EQUIPMENT_SET_NEW
= 2,
743 EQUIPMENT_SET_DELETED
= 3
748 EquipmentSet() : Guid(0), state(EQUIPMENT_SET_NEW
)
750 for(int i
= 0; i
< EQUIPMENT_SLOT_END
; ++i
)
756 std::string IconName
;
757 uint32 Items
[EQUIPMENT_SLOT_END
];
758 EquipmentSetUpdateState state
;
761 #define MAX_EQUIPMENT_SET_INDEX 10 // client limit
763 typedef std::map
<uint32
, EquipmentSet
> EquipmentSets
;
767 ItemPosCount(uint16 _pos
, uint32 _count
) : pos(_pos
), count(_count
) {}
768 bool isContainedIn(std::vector
<ItemPosCount
> const& vec
) const;
772 typedef std::vector
<ItemPosCount
> ItemPosCountVec
;
776 TRADE_SLOT_COUNT
= 7,
777 TRADE_SLOT_TRADED_COUNT
= 6,
778 TRADE_SLOT_NONTRADED
= 6
781 enum TransferAbortReason
783 TRANSFER_ABORT_NONE
= 0x00,
784 TRANSFER_ABORT_ERROR
= 0x01,
785 TRANSFER_ABORT_MAX_PLAYERS
= 0x02, // Transfer Aborted: instance is full
786 TRANSFER_ABORT_NOT_FOUND
= 0x03, // Transfer Aborted: instance not found
787 TRANSFER_ABORT_TOO_MANY_INSTANCES
= 0x04, // You have entered too many instances recently.
788 TRANSFER_ABORT_ZONE_IN_COMBAT
= 0x06, // Unable to zone in while an encounter is in progress.
789 TRANSFER_ABORT_INSUF_EXPAN_LVL
= 0x07, // You must have <TBC,WotLK> expansion installed to access this area.
790 TRANSFER_ABORT_DIFFICULTY
= 0x08, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
791 TRANSFER_ABORT_UNIQUE_MESSAGE
= 0x09, // Until you've escaped TLK's grasp, you cannot leave this place!
792 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES
= 0x0A, // Additional instances cannot be launched, please try again later.
793 TRANSFER_ABORT_NEED_GROUP
= 0x0B, // 3.1
794 TRANSFER_ABORT_NOT_FOUND2
= 0x0C, // 3.1
795 TRANSFER_ABORT_NOT_FOUND3
= 0x0D, // 3.1
796 TRANSFER_ABORT_NOT_FOUND4
= 0x0E, // 3.2
797 TRANSFER_ABORT_REALM_ONLY
= 0x0F, // All players on party must be from the same realm.
798 TRANSFER_ABORT_MAP_NOT_ALLOWED
= 0x10, // Map can't be entered at this time.
801 enum InstanceResetWarningType
803 RAID_INSTANCE_WARNING_HOURS
= 1, // WARNING! %s is scheduled to reset in %d hour(s).
804 RAID_INSTANCE_WARNING_MIN
= 2, // WARNING! %s is scheduled to reset in %d minute(s)!
805 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!
806 RAID_INSTANCE_WELCOME
= 4, // Welcome to %s. This raid instance is scheduled to reset in %s.
807 RAID_INSTANCE_EXPIRED
= 5
810 // PLAYER_FIELD_ARENA_TEAM_INFO_1_1 offsets
811 enum ArenaTeamInfoType
814 ARENA_TEAM_TYPE
= 1, // new in 3.2 - team type?
815 ARENA_TEAM_MEMBER
= 2, // 0 - captain, 1 - member
816 ARENA_TEAM_GAMES_WEEK
= 3,
817 ARENA_TEAM_GAMES_SEASON
= 4,
818 ARENA_TEAM_WINS_SEASON
= 5,
819 ARENA_TEAM_PERSONAL_RATING
= 6,
826 REST_TYPE_IN_TAVERN
= 1,
827 REST_TYPE_IN_CITY
= 2
830 enum DuelCompleteType
837 enum TeleportToOptions
839 TELE_TO_GM_MODE
= 0x01,
840 TELE_TO_NOT_LEAVE_TRANSPORT
= 0x02,
841 TELE_TO_NOT_LEAVE_COMBAT
= 0x04,
842 TELE_TO_NOT_UNSUMMON_PET
= 0x08,
843 TELE_TO_SPELL
= 0x10,
846 /// Type of environmental damages
847 enum EnviromentalDamage
849 DAMAGE_EXHAUSTED
= 0,
855 DAMAGE_FALL_TO_VOID
= 6 // custom case for fall without durability loss
860 PLAYED_TIME_TOTAL
= 0,
861 PLAYED_TIME_LEVEL
= 1
864 #define MAX_PLAYED_TIME_INDEX 2
866 // used at player loading query list preparing, and later result selection
867 enum PlayerLoginQueryIndex
869 PLAYER_LOGIN_QUERY_LOADFROM
= 0,
870 PLAYER_LOGIN_QUERY_LOADGROUP
= 1,
871 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES
= 2,
872 PLAYER_LOGIN_QUERY_LOADAURAS
= 3,
873 PLAYER_LOGIN_QUERY_LOADSPELLS
= 4,
874 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS
= 5,
875 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS
= 6,
876 PLAYER_LOGIN_QUERY_LOADREPUTATION
= 7,
877 PLAYER_LOGIN_QUERY_LOADINVENTORY
= 8,
878 PLAYER_LOGIN_QUERY_LOADACTIONS
= 9,
879 PLAYER_LOGIN_QUERY_LOADSOCIALLIST
= 10,
880 PLAYER_LOGIN_QUERY_LOADHOMEBIND
= 11,
881 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS
= 12,
882 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES
= 13,
883 PLAYER_LOGIN_QUERY_LOADGUILD
= 14,
884 PLAYER_LOGIN_QUERY_LOADARENAINFO
= 15,
885 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS
= 16,
886 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS
= 17,
887 PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS
= 18,
888 PLAYER_LOGIN_QUERY_LOADBGDATA
= 19,
889 PLAYER_LOGIN_QUERY_LOADACCOUNTDATA
= 20,
890 PLAYER_LOGIN_QUERY_LOADSKILLS
= 21,
891 PLAYER_LOGIN_QUERY_LOADGLYPHS
= 22,
892 MAX_PLAYER_LOGIN_QUERY
= 23
895 enum PlayerDelayedOperations
897 DELAYED_SAVE_PLAYER
= 0x01,
898 DELAYED_RESURRECT_PLAYER
= 0x02,
899 DELAYED_SPELL_CAST_DESERTER
= 0x04,
900 DELAYED_BG_MOUNT_RESTORE
= 0x08, ///< Flag to restore mount state after teleport from BG
901 DELAYED_BG_TAXI_RESTORE
= 0x10, ///< Flag to restore taxi state after teleport from BG
905 // Player summoning auto-decline time (in secs)
906 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
907 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
909 struct InstancePlayerBind
913 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
914 that aren't already permanently bound when they are inside when a boss is killed
915 or when they enter an instance that the group leader is permanently bound to. */
916 InstancePlayerBind() : save(NULL
), perm(false) {}
919 class MANGOS_DLL_SPEC PlayerTaxi
925 void InitTaxiNodesForLevel(uint32 race
, uint32 chrClass
, uint32 level
);
926 void LoadTaxiMask(const char* data
);
928 bool IsTaximaskNodeKnown(uint32 nodeidx
) const
930 uint8 field
= uint8((nodeidx
- 1) / 32);
931 uint32 submask
= 1<<((nodeidx
-1)%32);
932 return (m_taximask
[field
] & submask
) == submask
;
934 bool SetTaximaskNode(uint32 nodeidx
)
936 uint8 field
= uint8((nodeidx
- 1) / 32);
937 uint32 submask
= 1<<((nodeidx
-1)%32);
938 if ((m_taximask
[field
] & submask
) != submask
)
940 m_taximask
[field
] |= submask
;
946 void AppendTaximaskTo(ByteBuffer
& data
, bool all
);
949 bool LoadTaxiDestinationsFromString(const std::string
& values
, uint32 team
);
950 std::string
SaveTaxiDestinationsToString();
952 void ClearTaxiDestinations() { m_TaxiDestinations
.clear(); }
953 void AddTaxiDestination(uint32 dest
) { m_TaxiDestinations
.push_back(dest
); }
954 uint32
GetTaxiSource() const { return m_TaxiDestinations
.empty() ? 0 : m_TaxiDestinations
.front(); }
955 uint32
GetTaxiDestination() const { return m_TaxiDestinations
.size() < 2 ? 0 : m_TaxiDestinations
[1]; }
956 uint32
GetCurrentTaxiPath() const;
957 uint32
NextTaxiDestination()
959 m_TaxiDestinations
.pop_front();
960 return GetTaxiDestination();
962 bool empty() const { return m_TaxiDestinations
.empty(); }
964 friend std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
967 std::deque
<uint32
> m_TaxiDestinations
;
970 std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
972 /// Holder for BattleGround data
975 BGData() : bgInstanceID(0), bgTypeID(BATTLEGROUND_TYPE_NONE
), bgAfkReportedCount(0), bgAfkReportedTimer(0),
976 bgTeam(0), mountSpell(0) { ClearTaxiPath(); }
979 uint32 bgInstanceID
; ///< This variable is set to bg->m_InstanceID,
980 /// when player is teleported to BG - (it is battleground's GUID)
981 BattleGroundTypeId bgTypeID
;
983 std::set
<uint32
> bgAfkReporter
;
984 uint8 bgAfkReportedCount
;
985 time_t bgAfkReportedTimer
;
987 uint32 bgTeam
; ///< What side the player will be added to
993 WorldLocation joinPos
; ///< From where player entered BG
995 void ClearTaxiPath() { taxiPath
[0] = taxiPath
[1] = 0; }
996 bool HasTaxiPath() const { return taxiPath
[0] && taxiPath
[1]; }
999 class MANGOS_DLL_SPEC Player
: public Unit
1001 friend class WorldSession
;
1002 friend void Item::AddToUpdateQueueOf(Player
*player
);
1003 friend void Item::RemoveFromUpdateQueueOf(Player
*player
);
1005 explicit Player (WorldSession
*session
);
1008 void CleanupsBeforeDelete();
1010 static UpdateMask updateVisualBits
;
1011 static void InitVisibleBits();
1014 void RemoveFromWorld();
1016 bool TeleportTo(uint32 mapid
, float x
, float y
, float z
, float orientation
, uint32 options
= 0);
1018 bool TeleportTo(WorldLocation
const &loc
, uint32 options
= 0)
1020 return TeleportTo(loc
.mapid
, loc
.coord_x
, loc
.coord_y
, loc
.coord_z
, loc
.orientation
, options
);
1023 bool TeleportToBGEntryPoint();
1025 void SetSummonPoint(uint32 mapid
, float x
, float y
, float z
)
1027 m_summon_expire
= time(NULL
) + MAX_PLAYER_SUMMON_DELAY
;
1028 m_summon_mapid
= mapid
;
1033 void SummonIfPossible(bool agree
);
1035 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
);
1037 void Update( uint32 time
);
1039 static bool BuildEnumData( QueryResult
* result
, WorldPacket
* p_data
);
1041 void SetInWater(bool apply
);
1043 bool IsInWater() const { return m_isInWater
; }
1044 bool IsUnderWater() const;
1046 void SendInitialPacketsBeforeAddToMap();
1047 void SendInitialPacketsAfterAddToMap();
1048 void SendTransferAborted(uint32 mapid
, uint8 reason
, uint8 arg
= 0);
1049 void SendInstanceResetWarning(uint32 mapid
, Difficulty difficulty
, uint32 time
);
1051 Creature
* GetNPCIfCanInteractWith(uint64 guid
, uint32 npcflagmask
);
1052 GameObject
* GetGameObjectIfCanInteractWith(uint64 guid
, uint32 gameobject_type
= MAX_GAMEOBJECT_TYPE
) const;
1054 void UpdateVisibilityForPlayer();
1058 bool isAFK() const { return HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_AFK
); }
1059 bool isDND() const { return HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_DND
); }
1060 uint8
chatTag() const;
1064 uint32
GetBarberShopCost(uint8 newhairstyle
, uint8 newhaircolor
, uint8 newfacialhair
);
1066 PlayerSocial
*GetSocial() { return m_social
; }
1069 void InitTaxiNodesForLevel() { m_taxi
.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1070 bool ActivateTaxiPathTo(std::vector
<uint32
> const& nodes
, Creature
* npc
= NULL
, uint32 spellid
= 0);
1071 bool ActivateTaxiPathTo(uint32 taxi_path_id
, uint32 spellid
= 0);
1072 // mount_id can be used in scripting calls
1073 void ContinueTaxiFlight();
1074 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_ACCEPT_TICKETS
); }
1075 void SetAcceptTicket(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_ACCEPT_TICKETS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS
; }
1076 bool isAcceptWhispers() const { return m_ExtraFlags
& PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1077 void SetAcceptWhispers(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_ACCEPT_WHISPERS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1078 bool isGameMaster() const { return m_ExtraFlags
& PLAYER_EXTRA_GM_ON
; }
1079 void SetGameMaster(bool on
);
1080 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_CHAT
); }
1081 void SetGMChat(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_CHAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_CHAT
; }
1082 bool isTaxiCheater() const { return m_ExtraFlags
& PLAYER_EXTRA_TAXICHEAT
; }
1083 void SetTaxiCheater(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_TAXICHEAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_TAXICHEAT
; }
1084 bool isGMVisible() const { return !(m_ExtraFlags
& PLAYER_EXTRA_GM_INVISIBLE
); }
1085 void SetGMVisible(bool on
);
1086 void SetPvPDeath(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_PVP_DEATH
; else m_ExtraFlags
&= ~PLAYER_EXTRA_PVP_DEATH
; }
1088 void GiveXP(uint32 xp
, Unit
* victim
);
1089 void GiveLevel(uint32 level
);
1091 void InitStatsForLevel(bool reapplyMods
= false);
1093 // Played Time Stuff
1096 uint32 m_Played_time
[MAX_PLAYED_TIME_INDEX
];
1097 uint32
GetTotalPlayedTime() { return m_Played_time
[PLAYED_TIME_TOTAL
]; }
1098 uint32
GetLevelPlayedTime() { return m_Played_time
[PLAYED_TIME_LEVEL
]; }
1100 void setDeathState(DeathState s
); // overwrite Unit::setDeathState
1102 void InnEnter (time_t time
, uint32 mapid
, float x
, float y
, float z
)
1104 inn_pos_mapid
= mapid
;
1108 time_inn_enter
= time
;
1111 float GetRestBonus() const { return m_rest_bonus
; }
1112 void SetRestBonus(float rest_bonus_new
);
1114 RestType
GetRestType() const { return rest_type
; }
1115 void SetRestType(RestType n_r_type
) { rest_type
= n_r_type
; }
1117 uint32
GetInnPosMapId() const { return inn_pos_mapid
; }
1118 float GetInnPosX() const { return inn_pos_x
; }
1119 float GetInnPosY() const { return inn_pos_y
; }
1120 float GetInnPosZ() const { return inn_pos_z
; }
1122 time_t GetTimeInnEnter() const { return time_inn_enter
; }
1123 void UpdateInnerTime (time_t time
) { time_inn_enter
= time
; }
1125 void RemovePet(Pet
* pet
, PetSaveMode mode
, bool returnreagent
= false);
1126 void RemoveMiniPet();
1128 void SetMiniPet(Pet
* pet
) { m_miniPet
= pet
->GetGUID(); }
1130 template<typename Func
>
1131 void CallForAllControlledUnits(Func
const& func
, bool withTotems
, bool withGuardians
, bool withCharms
, bool withMiniPet
);
1132 template<typename Func
>
1133 bool CheckAllControlledUnits(Func
const& func
, bool withTotems
, bool withGuardians
, bool withCharms
, bool withMiniPet
) const;
1135 uint32
GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
1137 void Say(const std::string
& text
, const uint32 language
);
1138 void Yell(const std::string
& text
, const uint32 language
);
1139 void TextEmote(const std::string
& text
);
1140 void Whisper(const std::string
& text
, const uint32 language
,uint64 receiver
);
1141 void BuildPlayerChat(WorldPacket
*data
, uint8 msgtype
, const std::string
& text
, uint32 language
) const;
1143 /*********************************************************/
1144 /*** STORAGE SYSTEM ***/
1145 /*********************************************************/
1147 void SetVirtualItemSlot( uint8 i
, Item
* item
);
1148 void SetSheath( SheathState sheathed
); // overwrite Unit version
1149 uint8
FindEquipSlot( ItemPrototype
const* proto
, uint32 slot
, bool swap
) const;
1150 uint32
GetItemCount( uint32 item
, bool inBankAlso
= false, Item
* skipItem
= NULL
) const;
1151 Item
* GetItemByGuid( uint64 guid
) const;
1152 Item
* GetItemByPos( uint16 pos
) const;
1153 Item
* GetItemByPos( uint8 bag
, uint8 slot
) const;
1154 Item
* GetWeaponForAttack(WeaponAttackType attackType
) const { return GetWeaponForAttack(attackType
,false,false); }
1155 Item
* GetWeaponForAttack(WeaponAttackType attackType
, bool nonbroken
, bool useable
) const;
1156 Item
* GetShield(bool useable
= false) const;
1157 static uint32
GetAttackBySlot( uint8 slot
); // MAX_ATTACK if not weapon slot
1158 std::vector
<Item
*> &GetItemUpdateQueue() { return m_itemUpdateQueue
; }
1159 static bool IsInventoryPos( uint16 pos
) { return IsInventoryPos(pos
>> 8, pos
& 255); }
1160 static bool IsInventoryPos( uint8 bag
, uint8 slot
);
1161 static bool IsEquipmentPos( uint16 pos
) { return IsEquipmentPos(pos
>> 8, pos
& 255); }
1162 static bool IsEquipmentPos( uint8 bag
, uint8 slot
);
1163 static bool IsBagPos( uint16 pos
);
1164 static bool IsBankPos( uint16 pos
) { return IsBankPos(pos
>> 8, pos
& 255); }
1165 static bool IsBankPos( uint8 bag
, uint8 slot
);
1166 bool IsValidPos( uint16 pos
, bool explicit_pos
) { return IsValidPos(pos
>> 8, pos
& 255, explicit_pos
); }
1167 bool IsValidPos( uint8 bag
, uint8 slot
, bool explicit_pos
);
1168 uint8
GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2
, 2); }
1169 void SetBankBagSlotCount(uint8 count
) { SetByteValue(PLAYER_BYTES_2
, 2, count
); }
1170 bool HasItemCount( uint32 item
, uint32 count
, bool inBankAlso
= false ) const;
1171 bool HasItemFitToSpellReqirements(SpellEntry
const* spellInfo
, Item
const* ignoreItem
= NULL
);
1172 bool CanNoReagentCast(SpellEntry
const* spellInfo
) const;
1173 bool HasItemOrGemWithIdEquipped( uint32 item
, uint32 count
, uint8 except_slot
= NULL_SLOT
) const;
1174 bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory
, uint32 count
, uint8 except_slot
= NULL_SLOT
) const;
1175 uint8
CanTakeMoreSimilarItems(Item
* pItem
) const { return _CanTakeMoreSimilarItems(pItem
->GetEntry(), pItem
->GetCount(), pItem
); }
1176 uint8
CanTakeMoreSimilarItems(uint32 entry
, uint32 count
) const { return _CanTakeMoreSimilarItems(entry
, count
, NULL
); }
1177 uint8
CanStoreNewItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 item
, uint32 count
, uint32
* no_space_count
= NULL
) const
1179 return _CanStoreItem(bag
, slot
, dest
, item
, count
, NULL
, false, no_space_count
);
1181 uint8
CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
= false ) const
1184 return EQUIP_ERR_ITEM_NOT_FOUND
;
1185 uint32 count
= pItem
->GetCount();
1186 return _CanStoreItem( bag
, slot
, dest
, pItem
->GetEntry(), count
, pItem
, swap
, NULL
);
1189 uint8
CanStoreItems( Item
**pItem
,int count
) const;
1190 uint8
CanEquipNewItem( uint8 slot
, uint16
&dest
, uint32 item
, bool swap
) const;
1191 uint8
CanEquipItem( uint8 slot
, uint16
&dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1193 uint8
CanEquipUniqueItem( Item
* pItem
, uint8 except_slot
= NULL_SLOT
, uint32 limit_count
= 1 ) const;
1194 uint8
CanEquipUniqueItem( ItemPrototype
const* itemProto
, uint8 except_slot
= NULL_SLOT
, uint32 limit_count
= 1 ) const;
1195 uint8
CanUnequipItems( uint32 item
, uint32 count
) const;
1196 uint8
CanUnequipItem( uint16 src
, bool swap
) const;
1197 uint8
CanBankItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1198 uint8
CanUseItem( Item
*pItem
, bool not_loading
= true ) const;
1199 bool HasItemTotemCategory( uint32 TotemCategory
) const;
1200 bool CanUseItem( ItemPrototype
const *pItem
);
1201 uint8
CanUseAmmo( uint32 item
) const;
1202 Item
* StoreNewItem( ItemPosCountVec
const& pos
, uint32 item
, bool update
,int32 randomPropertyId
= 0 );
1203 Item
* StoreItem( ItemPosCountVec
const& pos
, Item
*pItem
, bool update
);
1204 Item
* EquipNewItem( uint16 pos
, uint32 item
, bool update
);
1205 Item
* EquipItem( uint16 pos
, Item
*pItem
, bool update
);
1206 void AutoUnequipOffhandIfNeed();
1207 bool StoreNewItemInBestSlots(uint32 item_id
, uint32 item_count
);
1208 Item
* StoreNewItemInInventorySlot(uint32 itemEntry
, uint32 amount
);
1210 void AutoStoreLoot(uint8 bag
, uint8 slot
, uint32 loot_id
, LootStore
const& store
, bool broadcast
= false);
1211 void AutoStoreLoot(uint32 loot_id
, LootStore
const& store
, bool broadcast
= false) { AutoStoreLoot(NULL_BAG
,NULL_SLOT
,loot_id
,store
,broadcast
); }
1213 uint8
_CanTakeMoreSimilarItems(uint32 entry
, uint32 count
, Item
* pItem
, uint32
* no_space_count
= NULL
) const;
1214 uint8
_CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 entry
, uint32 count
, Item
*pItem
= NULL
, bool swap
= false, uint32
* no_space_count
= NULL
) const;
1216 void ApplyEquipCooldown( Item
* pItem
);
1217 void SetAmmo( uint32 item
);
1219 float GetAmmoDPS() const { return m_ammoDPS
; }
1220 bool CheckAmmoCompatibility(const ItemPrototype
*ammo_proto
) const;
1221 void QuickEquipItem( uint16 pos
, Item
*pItem
);
1222 void VisualizeItem( uint8 slot
, Item
*pItem
);
1223 void SetVisibleItemSlot(uint8 slot
, Item
*pItem
);
1224 Item
* BankItem( ItemPosCountVec
const& dest
, Item
*pItem
, bool update
)
1226 return StoreItem( dest
, pItem
, update
);
1228 Item
* BankItem( uint16 pos
, Item
*pItem
, bool update
);
1229 void RemoveItem( uint8 bag
, uint8 slot
, bool update
);
1230 void MoveItemFromInventory(uint8 bag
, uint8 slot
, bool update
);
1231 // in trade, auction, guild bank, mail....
1232 void MoveItemToInventory(ItemPosCountVec
const& dest
, Item
* pItem
, bool update
, bool in_characterInventoryDB
= false);
1233 // in trade, guild bank, mail....
1234 void RemoveItemDependentAurasAndCasts( Item
* pItem
);
1235 void DestroyItem( uint8 bag
, uint8 slot
, bool update
);
1236 void DestroyItemCount( uint32 item
, uint32 count
, bool update
, bool unequip_check
= false);
1237 void DestroyItemCount( Item
* item
, uint32
& count
, bool update
);
1238 void DestroyConjuredItems( bool update
);
1239 void DestroyZoneLimitedItem( bool update
, uint32 new_zone
);
1240 void SplitItem( uint16 src
, uint16 dst
, uint32 count
);
1241 void SwapItem( uint16 src
, uint16 dst
);
1242 void AddItemToBuyBackSlot( Item
*pItem
);
1243 Item
* GetItemFromBuyBackSlot( uint32 slot
);
1244 void RemoveItemFromBuyBackSlot( uint32 slot
, bool del
);
1245 uint32
GetMaxKeyringSize() const { return KEYRING_SLOT_END
-KEYRING_SLOT_START
; }
1246 void SendEquipError( uint8 msg
, Item
* pItem
, Item
*pItem2
);
1247 void SendBuyError( uint8 msg
, Creature
* pCreature
, uint32 item
, uint32 param
);
1248 void SendSellError( uint8 msg
, Creature
* pCreature
, uint64 guid
, uint32 param
);
1249 void AddWeaponProficiency(uint32 newflag
) { m_WeaponProficiency
|= newflag
; }
1250 void AddArmorProficiency(uint32 newflag
) { m_ArmorProficiency
|= newflag
; }
1251 uint32
GetWeaponProficiency() const { return m_WeaponProficiency
; }
1252 uint32
GetArmorProficiency() const { return m_ArmorProficiency
; }
1253 bool IsUseEquipedWeapon( bool mainhand
) const
1255 // disarm applied only to mainhand weapon
1256 return !IsInFeralForm() && (!mainhand
|| !HasFlag(UNIT_FIELD_FLAGS
,UNIT_FLAG_DISARMED
) );
1258 bool IsTwoHandUsed() const
1260 Item
* mainItem
= GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_MAINHAND
);
1261 return mainItem
&& mainItem
->GetProto()->InventoryType
== INVTYPE_2HWEAPON
&& !CanTitanGrip();
1263 void SendNewItem( Item
*item
, uint32 count
, bool received
, bool created
, bool broadcast
= false );
1264 bool BuyItemFromVendor(uint64 vendorguid
, uint32 item
, uint8 count
, uint8 bag
, uint8 slot
);
1266 float GetReputationPriceDiscount( Creature
const* pCreature
) const;
1267 Player
* GetTrader() const { return pTrader
; }
1269 void TradeCancel(bool sendback
);
1270 uint16
GetItemPosByTradeSlot(uint32 slot
) const { return tradeItems
[slot
]; }
1272 void UpdateEnchantTime(uint32 time
);
1273 void UpdateItemDuration(uint32 time
, bool realtimeonly
=false);
1274 void AddEnchantmentDurations(Item
*item
);
1275 void RemoveEnchantmentDurations(Item
*item
);
1276 void RemoveAllEnchantments(EnchantmentSlot slot
);
1277 void AddEnchantmentDuration(Item
*item
,EnchantmentSlot slot
,uint32 duration
);
1278 void ApplyEnchantment(Item
*item
,EnchantmentSlot slot
,bool apply
, bool apply_dur
= true, bool ignore_condition
= false);
1279 void ApplyEnchantment(Item
*item
,bool apply
);
1280 void SendEnchantmentDurations();
1281 void BuildEnchantmentsInfoData(WorldPacket
*data
);
1282 void AddItemDurations(Item
*item
);
1283 void RemoveItemDurations(Item
*item
);
1284 void SendItemDurations();
1288 uint32 m_stableSlots
;
1290 /*********************************************************/
1291 /*** GOSSIP SYSTEM ***/
1292 /*********************************************************/
1294 void PrepareGossipMenu(WorldObject
*pSource
, uint32 menuId
= 0);
1295 void SendPreparedGossip(WorldObject
*pSource
);
1296 void OnGossipSelect(WorldObject
*pSource
, uint32 gossipListId
, uint32 menuId
);
1298 uint32
GetGossipTextId(uint32 menuId
);
1299 uint32
GetGossipTextId(WorldObject
*pSource
);
1300 uint32
GetDefaultGossipMenuForSource(WorldObject
*pSource
);
1302 /*********************************************************/
1303 /*** QUEST SYSTEM ***/
1304 /*********************************************************/
1306 // Return player level when QuestLevel is dynamic (-1)
1307 uint32
GetQuestLevelForPlayer(Quest
const* pQuest
) const { return pQuest
&& (pQuest
->GetQuestLevel() > 0) ? (uint32
)pQuest
->GetQuestLevel() : getLevel(); }
1309 void PrepareQuestMenu( uint64 guid
);
1310 void SendPreparedQuest( uint64 guid
);
1311 bool IsActiveQuest( uint32 quest_id
) const;
1312 Quest
const *GetNextQuest( uint64 guid
, Quest
const *pQuest
);
1313 bool CanSeeStartQuest( Quest
const *pQuest
);
1314 bool CanTakeQuest( Quest
const *pQuest
, bool msg
);
1315 bool CanAddQuest( Quest
const *pQuest
, bool msg
);
1316 bool CanCompleteQuest( uint32 quest_id
);
1317 bool CanCompleteRepeatableQuest(Quest
const *pQuest
);
1318 bool CanRewardQuest( Quest
const *pQuest
, bool msg
);
1319 bool CanRewardQuest( Quest
const *pQuest
, uint32 reward
, bool msg
);
1320 void AddQuest( Quest
const *pQuest
, Object
*questGiver
);
1321 void CompleteQuest( uint32 quest_id
);
1322 void IncompleteQuest( uint32 quest_id
);
1323 void RewardQuest( Quest
const *pQuest
, uint32 reward
, Object
* questGiver
, bool announce
= true );
1325 void FailQuest( uint32 quest_id
);
1326 bool SatisfyQuestSkillOrClass( Quest
const* qInfo
, bool msg
);
1327 bool SatisfyQuestLevel( Quest
const* qInfo
, bool msg
);
1328 bool SatisfyQuestLog( bool msg
);
1329 bool SatisfyQuestPreviousQuest( Quest
const* qInfo
, bool msg
);
1330 bool SatisfyQuestRace( Quest
const* qInfo
, bool msg
);
1331 bool SatisfyQuestReputation( Quest
const* qInfo
, bool msg
);
1332 bool SatisfyQuestStatus( Quest
const* qInfo
, bool msg
);
1333 bool SatisfyQuestTimed( Quest
const* qInfo
, bool msg
);
1334 bool SatisfyQuestExclusiveGroup( Quest
const* qInfo
, bool msg
);
1335 bool SatisfyQuestNextChain( Quest
const* qInfo
, bool msg
);
1336 bool SatisfyQuestPrevChain( Quest
const* qInfo
, bool msg
);
1337 bool SatisfyQuestDay( Quest
const* qInfo
, bool msg
);
1338 bool GiveQuestSourceItem( Quest
const *pQuest
);
1339 bool TakeQuestSourceItem( uint32 quest_id
, bool msg
);
1340 bool GetQuestRewardStatus( uint32 quest_id
) const;
1341 QuestStatus
GetQuestStatus( uint32 quest_id
) const;
1342 void SetQuestStatus( uint32 quest_id
, QuestStatus status
);
1344 void SetDailyQuestStatus( uint32 quest_id
);
1345 void ResetDailyQuestStatus();
1347 uint16
FindQuestSlot( uint32 quest_id
) const;
1348 uint32
GetQuestSlotQuestId(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
); }
1349 uint32
GetQuestSlotState(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
); }
1350 uint16
GetQuestSlotCounter(uint16 slot
, uint8 counter
) const { return (uint16
)(GetUInt64Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
) >> (counter
* 16)); }
1351 uint32
GetQuestSlotTime(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
); }
1352 void SetQuestSlot(uint16 slot
, uint32 quest_id
, uint32 timer
= 0)
1354 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
, quest_id
);
1355 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
, 0);
1356 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
, 0);
1357 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
+ 1, 0);
1358 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
, timer
);
1360 void SetQuestSlotCounter(uint16 slot
, uint8 counter
, uint16 count
)
1362 uint64 val
= GetUInt64Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
);
1363 val
&= ~((uint64
)0xFFFF << (counter
* 16));
1364 val
|= ((uint64
)count
<< (counter
* 16));
1365 SetUInt64Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
, val
);
1367 void SetQuestSlotState(uint16 slot
, uint32 state
) { SetFlag(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
, state
); }
1368 void RemoveQuestSlotState(uint16 slot
, uint32 state
) { RemoveFlag(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
, state
); }
1369 void SetQuestSlotTimer(uint16 slot
, uint32 timer
) { SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
* MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
, timer
); }
1370 void SwapQuestSlot(uint16 slot1
, uint16 slot2
)
1372 for (int i
= 0; i
< MAX_QUEST_OFFSET
; ++i
)
1374 uint32 temp1
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
* slot1
+ i
);
1375 uint32 temp2
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
* slot2
+ i
);
1377 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
* slot1
+ i
, temp2
);
1378 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
* slot2
+ i
, temp1
);
1381 uint32
GetReqKillOrCastCurrentCount(uint32 quest_id
, int32 entry
);
1382 void AreaExploredOrEventHappens( uint32 questId
);
1383 void GroupEventHappens( uint32 questId
, WorldObject
const* pEventObject
);
1384 void ItemAddedQuestCheck( uint32 entry
, uint32 count
);
1385 void ItemRemovedQuestCheck( uint32 entry
, uint32 count
);
1386 void KilledMonster( CreatureInfo
const* cInfo
, uint64 guid
);
1387 void KilledMonsterCredit( uint32 entry
, uint64 guid
);
1388 void CastedCreatureOrGO( uint32 entry
, uint64 guid
, uint32 spell_id
);
1389 void TalkedToCreature( uint32 entry
, uint64 guid
);
1390 void MoneyChanged( uint32 value
);
1391 void ReputationChanged(FactionEntry
const* factionEntry
);
1392 bool HasQuestForItem( uint32 itemid
) const;
1393 bool HasQuestForGO(int32 GOId
) const;
1394 void UpdateForQuestWorldObjects();
1395 bool CanShareQuest(uint32 quest_id
) const;
1397 void SendQuestComplete( uint32 quest_id
);
1398 void SendQuestReward( Quest
const *pQuest
, uint32 XP
, Object
* questGiver
);
1399 void SendQuestFailed( uint32 quest_id
);
1400 void SendQuestTimerFailed( uint32 quest_id
);
1401 void SendCanTakeQuestResponse( uint32 msg
);
1402 void SendQuestConfirmAccept(Quest
const* pQuest
, Player
* pReceiver
);
1403 void SendPushToPartyResponse( Player
*pPlayer
, uint32 msg
);
1404 void SendQuestUpdateAddItem( Quest
const* pQuest
, uint32 item_idx
, uint32 count
);
1405 void SendQuestUpdateAddCreatureOrGo( Quest
const* pQuest
, uint64 guid
, uint32 creatureOrGO_idx
, uint32 old_count
, uint32 add_count
);
1407 uint64
GetDivider() { return m_divider
; }
1408 void SetDivider( uint64 guid
) { m_divider
= guid
; }
1410 uint32
GetInGameTime() { return m_ingametime
; }
1412 void SetInGameTime( uint32 time
) { m_ingametime
= time
; }
1414 void AddTimedQuest( uint32 quest_id
) { m_timedquests
.insert(quest_id
); }
1415 void RemoveTimedQuest( uint32 quest_id
) { m_timedquests
.erase(quest_id
); }
1417 /*********************************************************/
1418 /*** LOAD SYSTEM ***/
1419 /*********************************************************/
1421 bool LoadFromDB(uint32 guid
, SqlQueryHolder
*holder
);
1423 static bool LoadValuesArrayFromDB(Tokens
& data
,uint64 guid
);
1424 static uint32
GetUInt32ValueFromArray(Tokens
const& data
, uint16 index
);
1425 static float GetFloatValueFromArray(Tokens
const& data
, uint16 index
);
1426 static uint32
GetUInt32ValueFromDB(uint16 index
, uint64 guid
);
1427 static float GetFloatValueFromDB(uint16 index
, uint64 guid
);
1428 static uint32
GetZoneIdFromDB(uint64 guid
);
1429 static uint32
GetLevelFromDB(uint64 guid
);
1430 static bool LoadPositionFromDB(uint32
& mapid
, float& x
,float& y
,float& z
,float& o
, bool& in_flight
, uint64 guid
);
1432 /*********************************************************/
1433 /*** SAVE SYSTEM ***/
1434 /*********************************************************/
1437 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1438 void SaveGoldToDB();
1439 void SaveDataFieldToDB();
1440 static bool SaveValuesArrayInDB(Tokens
const& data
,uint64 guid
);
1441 static void SetUInt32ValueInArray(Tokens
& data
,uint16 index
, uint32 value
);
1442 static void SetFloatValueInArray(Tokens
& data
,uint16 index
, float value
);
1443 static void SetUInt32ValueInDB(uint16 index
, uint32 value
, uint64 guid
);
1444 static void SetFloatValueInDB(uint16 index
, float value
, uint64 guid
);
1445 static void Customize(uint64 guid
, uint8 gender
, uint8 skin
, uint8 face
, uint8 hairStyle
, uint8 hairColor
, uint8 facialHair
);
1446 static void SavePositionInDB(uint32 mapid
, float x
,float y
,float z
,float o
,uint32 zone
,uint64 guid
);
1448 bool m_mailsUpdated
;
1450 void SendPetTameFailure(PetTameFailureReason reason
);
1452 void SetBindPoint(uint64 guid
);
1453 void SendTalentWipeConfirm(uint64 guid
);
1454 void RewardRage( uint32 damage
, uint32 weaponSpeedHitFactor
, bool attacker
);
1455 void SendPetSkillWipeConfirm();
1456 void CalcRage( uint32 damage
,bool attacker
);
1457 void RegenerateAll(uint32 diff
= REGEN_TIME_FULL
);
1458 void Regenerate(Powers power
, uint32 diff
);
1459 void RegenerateHealth(uint32 diff
);
1460 void setRegenTimer(uint32 time
) {m_regenTimer
= time
;}
1461 void setWeaponChangeTimer(uint32 time
) {m_weaponChangeTimer
= time
;}
1463 uint32
GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE
); }
1464 void ModifyMoney( int32 d
)
1467 SetMoney (GetMoney() > uint32(-d
) ? GetMoney() + d
: 0);
1469 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT
- d
) ? GetMoney() + d
: MAX_MONEY_AMOUNT
);
1472 if(GetMoney() >= MAX_MONEY_AMOUNT
)
1473 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD
,NULL
,NULL
);
1475 void SetMoney( uint32 value
)
1477 SetUInt32Value (PLAYER_FIELD_COINAGE
, value
);
1478 MoneyChanged( value
);
1479 UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED
);
1482 QuestStatusMap
& getQuestStatusMap() { return mQuestStatus
; };
1484 const uint64
& GetSelection( ) const { return m_curSelection
; }
1485 void SetSelection(const uint64
&guid
) { m_curSelection
= guid
; SetTargetGUID(guid
); }
1487 uint8
GetComboPoints() { return m_comboPoints
; }
1488 const uint64
& GetComboTarget() const { return m_comboTarget
; }
1490 void AddComboPoints(Unit
* target
, int8 count
);
1491 void ClearComboPoints();
1492 void SendComboPoints();
1494 void SendMailResult(uint32 mailId
, MailResponseType mailAction
, MailResponseResult mailError
, uint32 equipError
= 0, uint32 item_guid
= 0, uint32 item_count
= 0);
1496 void UpdateNextMailTimeAndUnreads();
1497 void AddNewMailDeliverTime(time_t deliver_time
);
1499 void RemoveMail(uint32 id
);
1501 void AddMail(Mail
* mail
) { m_mail
.push_front(mail
);}// for call from WorldSession::SendMailTo
1502 uint32
GetMailSize() { return m_mail
.size(); }
1503 Mail
* GetMail(uint32 id
);
1505 PlayerMails::iterator
GetMailBegin() { return m_mail
.begin();}
1506 PlayerMails::iterator
GetMailEnd() { return m_mail
.end();}
1508 /*********************************************************/
1509 /*** MAILED ITEMS SYSTEM ***/
1510 /*********************************************************/
1513 time_t m_nextMailDelivereTime
;
1515 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
1517 ItemMap mMitems
; // template defined in objectmgr.cpp
1519 Item
* GetMItem(uint32 id
)
1521 ItemMap::const_iterator itr
= mMitems
.find(id
);
1522 return itr
!= mMitems
.end() ? itr
->second
: NULL
;
1525 void AddMItem(Item
* it
)
1528 //assert deleted, because items can be added before loading
1529 mMitems
[it
->GetGUIDLow()] = it
;
1532 bool RemoveMItem(uint32 id
)
1534 return mMitems
.erase(id
) ? true : false;
1537 void PetSpellInitialize();
1538 void SendPetGUIDs();
1539 void CharmSpellInitialize();
1540 void PossessSpellInitialize();
1541 void RemovePetActionBar();
1543 bool HasSpell(uint32 spell
) const;
1544 bool HasActiveSpell(uint32 spell
) const; // show in spellbook
1545 TrainerSpellState
GetTrainerSpellState(TrainerSpell
const* trainer_spell
) const;
1546 bool IsSpellFitByClassAndRace( uint32 spell_id
) const;
1547 bool IsNeedCastPassiveSpellAtLearn(SpellEntry
const* spellInfo
) const;
1548 bool IsImmunedToSpellEffect(SpellEntry
const* spellInfo
, SpellEffectIndex index
) const;
1550 void SendProficiency(uint8 pr1
, uint32 pr2
);
1551 void SendInitialSpells();
1552 bool addSpell(uint32 spell_id
, bool active
, bool learning
, bool dependent
, bool disabled
);
1553 void learnSpell(uint32 spell_id
, bool dependent
);
1554 void removeSpell(uint32 spell_id
, bool disabled
= false, bool learn_low_rank
= true, bool sendUpdate
= true);
1556 void learnDefaultSpells();
1557 void learnQuestRewardedSpells();
1558 void learnQuestRewardedSpells(Quest
const* quest
);
1559 void learnSpellHighRank(uint32 spellid
);
1561 uint32
GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1
); }
1562 void SetFreeTalentPoints(uint32 points
) { SetUInt32Value(PLAYER_CHARACTER_POINTS1
,points
); }
1563 bool resetTalents(bool no_cost
= false);
1564 uint32
resetTalentsCost() const;
1565 void InitTalentForLevel();
1566 void BuildPlayerTalentsInfoData(WorldPacket
*data
);
1567 void BuildPetTalentsInfoData(WorldPacket
*data
);
1568 void SendTalentsInfoData(bool pet
);
1569 void LearnTalent(uint32 talentId
, uint32 talentRank
);
1570 void LearnPetTalent(uint64 petGuid
, uint32 talentId
, uint32 talentRank
);
1572 uint32
CalculateTalentsPoints() const;
1575 uint8
GetActiveSpec() { return m_activeSpec
; }
1576 void SetActiveSpec(uint8 spec
) { m_activeSpec
= spec
; }
1577 uint8
GetSpecsCount() { return m_specsCount
; }
1578 void SetSpecsCount(uint8 count
) { m_specsCount
= count
; }
1579 void ActivateSpec(uint8 specNum
);
1580 void UpdateSpecCount(uint8 count
);
1582 void InitGlyphsForLevel();
1583 void SetGlyphSlot(uint8 slot
, uint32 slottype
) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
, slottype
); }
1584 uint32
GetGlyphSlot(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
); }
1585 void SetGlyph(uint8 slot
, uint32 glyph
) { m_glyphs
[m_activeSpec
][slot
].SetId(glyph
); }
1586 uint32
GetGlyph(uint8 slot
) { return m_glyphs
[m_activeSpec
][slot
].GetId(); }
1587 void ApplyGlyph(uint8 slot
, bool apply
);
1588 void ApplyGlyphs(bool apply
);
1590 uint32
GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2
); }
1591 void SetFreePrimaryProfessions(uint16 profs
) { SetUInt32Value(PLAYER_CHARACTER_POINTS2
, profs
); }
1592 void InitPrimaryProfessions();
1594 PlayerSpellMap
const& GetSpellMap() const { return m_spells
; }
1595 PlayerSpellMap
& GetSpellMap() { return m_spells
; }
1597 SpellCooldowns
const& GetSpellCooldownMap() const { return m_spellCooldowns
; }
1599 void AddSpellMod(SpellModifier
* mod
, bool apply
);
1600 bool IsAffectedBySpellmod(SpellEntry
const *spellInfo
, SpellModifier
*mod
, Spell
const* spell
= NULL
);
1601 template <class T
> T
ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
= NULL
);
1602 void RemoveSpellMods(Spell
const* spell
);
1604 static uint32
const infinityCooldownDelay
= MONTH
; // used for set "infinity cooldowns" for spells and check
1605 static uint32
const infinityCooldownDelayCheck
= MONTH
/2;
1606 bool HasSpellCooldown(uint32 spell_id
) const
1608 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1609 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> time(NULL
);
1611 time_t GetSpellCooldownDelay(uint32 spell_id
) const
1613 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1614 time_t t
= time(NULL
);
1615 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> t
? itr
->second
.end
- t
: 0;
1617 void AddSpellAndCategoryCooldowns(SpellEntry
const* spellInfo
, uint32 itemId
, Spell
* spell
= NULL
, bool infinityCooldown
= false );
1618 void AddSpellCooldown(uint32 spell_id
, uint32 itemid
, time_t end_time
);
1619 void SendCooldownEvent(SpellEntry
const *spellInfo
, uint32 itemId
= 0, Spell
* spell
= NULL
);
1620 void ProhibitSpellSchool(SpellSchoolMask idSchoolMask
, uint32 unTimeMs
);
1621 void RemoveSpellCooldown(uint32 spell_id
, bool update
= false);
1622 void RemoveSpellCategoryCooldown(uint32 cat
, bool update
= false);
1623 void SendClearCooldown( uint32 spell_id
, Unit
* target
);
1625 void RemoveArenaSpellCooldowns();
1626 void RemoveAllSpellCooldown();
1627 void _LoadSpellCooldowns(QueryResult
*result
);
1628 void _SaveSpellCooldowns();
1629 void SetLastPotionId(uint32 item_id
) { m_lastPotionId
= item_id
; }
1630 void UpdatePotionCooldown(Spell
* spell
= NULL
);
1632 void setResurrectRequestData(uint64 guid
, uint32 mapId
, float X
, float Y
, float Z
, uint32 health
, uint32 mana
)
1634 m_resurrectGUID
= guid
;
1635 m_resurrectMap
= mapId
;
1639 m_resurrectHealth
= health
;
1640 m_resurrectMana
= mana
;
1642 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f
,0.0f
,0.0f
,0,0); }
1643 bool isRessurectRequestedBy(uint64 guid
) const { return m_resurrectGUID
== guid
; }
1644 bool isRessurectRequested() const { return m_resurrectGUID
!= 0; }
1645 void ResurectUsingRequestData();
1651 void setCinematic(int cine
)
1656 static bool IsActionButtonDataValid(uint8 button
, uint32 action
, uint8 type
, Player
* player
, bool msg
= true);
1657 ActionButton
* addActionButton(uint8 spec
, uint8 button
, uint32 action
, uint8 type
);
1658 void removeActionButton(uint8 spec
, uint8 button
);
1659 void SendInitialActionButtons() const;
1660 ActionButton
const* GetActionButton(uint8 button
);
1663 void UpdatePvP(bool state
, bool ovrride
=false);
1664 void UpdateZone(uint32 newZone
,uint32 newArea
);
1665 void UpdateArea(uint32 newArea
);
1667 void UpdateZoneDependentAuras( uint32 zone_id
); // zones
1668 void UpdateAreaDependentAuras( uint32 area_id
); // subzones
1670 void UpdateAfkReport(time_t currTime
);
1671 void UpdatePvPFlag(time_t currTime
);
1672 void UpdateContestedPvP(uint32 currTime
);
1673 void SetContestedPvPTimer(uint32 newTime
) {m_contestedPvPTimer
= newTime
;}
1674 void ResetContestedPvP()
1676 clearUnitState(UNIT_STAT_ATTACK_PLAYER
);
1677 RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_CONTESTED_PVP
);
1678 m_contestedPvPTimer
= 0;
1681 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1683 void UpdateDuelFlag(time_t currTime
);
1684 void CheckDuelDistance(time_t currTime
);
1685 void DuelComplete(DuelCompleteType type
);
1686 void SendDuelCountdown(uint32 counter
);
1688 bool IsGroupVisibleFor(Player
* p
) const;
1689 bool IsInSameGroupWith(Player
const* p
) const;
1690 bool IsInSameRaidWith(Player
const* p
) const { return p
==this || (GetGroup() != NULL
&& GetGroup() == p
->GetGroup()); }
1691 void UninviteFromGroup();
1692 static void RemoveFromGroup(Group
* group
, uint64 guid
);
1693 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1694 void SendUpdateToOutOfRangeGroupMembers();
1696 void SetInGuild(uint32 GuildId
) { SetUInt32Value(PLAYER_GUILDID
, GuildId
); }
1697 void SetRank(uint32 rankId
){ SetUInt32Value(PLAYER_GUILDRANK
, rankId
); }
1698 void SetGuildIdInvited(uint32 GuildId
) { m_GuildIdInvited
= GuildId
; }
1699 uint32
GetGuildId() { return GetUInt32Value(PLAYER_GUILDID
); }
1700 static uint32
GetGuildIdFromDB(uint64 guid
);
1701 uint32
GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK
); }
1702 static uint32
GetRankFromDB(uint64 guid
);
1703 int GetGuildIdInvited() { return m_GuildIdInvited
; }
1704 static void RemovePetitionsAndSigns(uint64 guid
, uint32 type
);
1707 void SetInArenaTeam(uint32 ArenaTeamId
, uint8 slot
, uint8 type
)
1709 SetArenaTeamInfoField(slot
, ARENA_TEAM_ID
, ArenaTeamId
);
1710 SetArenaTeamInfoField(slot
, ARENA_TEAM_TYPE
, type
);
1712 void SetArenaTeamInfoField(uint8 slot
, ArenaTeamInfoType type
, uint32 value
)
1714 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* ARENA_TEAM_END
) + type
, value
);
1716 uint32
GetArenaTeamId(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* ARENA_TEAM_END
) + ARENA_TEAM_ID
); }
1717 uint32
GetArenaPersonalRating(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* ARENA_TEAM_END
) + ARENA_TEAM_PERSONAL_RATING
); }
1718 static uint32
GetArenaTeamIdFromDB(uint64 guid
, uint8 slot
);
1719 void SetArenaTeamIdInvited(uint32 ArenaTeamId
) { m_ArenaTeamIdInvited
= ArenaTeamId
; }
1720 uint32
GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited
; }
1721 static void LeaveAllArenaTeams(uint64 guid
);
1723 Difficulty
GetDifficulty(bool isRaid
) const { return isRaid
? m_raidDifficulty
: m_dungeonDifficulty
; }
1724 Difficulty
GetDungeonDifficulty() const { return m_dungeonDifficulty
; }
1725 Difficulty
GetRaidDifficulty() const { return m_raidDifficulty
; }
1726 void SetDungeonDifficulty(Difficulty dungeon_difficulty
) { m_dungeonDifficulty
= dungeon_difficulty
; }
1727 void SetRaidDifficulty(Difficulty raid_difficulty
) { m_raidDifficulty
= raid_difficulty
; }
1729 bool UpdateSkill(uint32 skill_id
, uint32 step
);
1730 bool UpdateSkillPro(uint16 SkillId
, int32 Chance
, uint32 step
);
1732 bool UpdateCraftSkill(uint32 spellid
);
1733 bool UpdateGatherSkill(uint32 SkillId
, uint32 SkillValue
, uint32 RedLevel
, uint32 Multiplicator
= 1);
1734 bool UpdateFishingSkill();
1736 uint32
GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE
); }
1737 uint32
GetBaseWeaponSkillValue(WeaponAttackType attType
) const;
1739 uint32
GetSpellByProto(ItemPrototype
*proto
);
1741 float GetHealthBonusFromStamina();
1742 float GetManaBonusFromIntellect();
1744 bool UpdateStats(Stats stat
);
1745 bool UpdateAllStats();
1746 void UpdateResistances(uint32 school
);
1748 void UpdateMaxHealth();
1749 void UpdateMaxPower(Powers power
);
1750 void ApplyFeralAPBonus(int32 amount
, bool apply
);
1751 void UpdateAttackPowerAndDamage(bool ranged
= false);
1752 void UpdateShieldBlockValue();
1753 void UpdateDamagePhysical(WeaponAttackType attType
);
1754 void ApplySpellPowerBonus(int32 amount
, bool apply
);
1755 void UpdateSpellDamageAndHealingBonus();
1756 void ApplyRatingMod(CombatRating cr
, int32 value
, bool apply
);
1757 void UpdateRating(CombatRating cr
);
1758 void UpdateAllRatings();
1760 void CalculateMinMaxDamage(WeaponAttackType attType
, bool normalized
, float& min_damage
, float& max_damage
);
1762 void UpdateDefenseBonusesMod();
1763 float GetMeleeCritFromAgility();
1764 float GetDodgeFromAgility();
1765 float GetSpellCritFromIntellect();
1766 float OCTRegenHPPerSpirit();
1767 float OCTRegenMPPerSpirit();
1768 float GetRatingCoefficient(CombatRating cr
) const;
1769 float GetRatingBonusValue(CombatRating cr
) const;
1770 uint32
GetBaseSpellPowerBonus() { return m_baseSpellPower
; }
1772 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType
) const;
1773 void UpdateBlockPercentage();
1774 void UpdateCritPercentage(WeaponAttackType attType
);
1775 void UpdateAllCritPercentages();
1776 void UpdateParryPercentage();
1777 void UpdateDodgePercentage();
1778 void UpdateMeleeHitChances();
1779 void UpdateRangedHitChances();
1780 void UpdateSpellHitChances();
1782 void UpdateAllSpellCritChances();
1783 void UpdateSpellCritChance(uint32 school
);
1784 void UpdateExpertise(WeaponAttackType attType
);
1785 void UpdateArmorPenetration();
1786 void ApplyManaRegenBonus(int32 amount
, bool apply
);
1787 void UpdateManaRegen();
1789 const uint64
& GetLootGUID() const { return m_lootGuid
; }
1790 void SetLootGUID(const uint64
&guid
) { m_lootGuid
= guid
; }
1792 void RemovedInsignia(Player
* looterPlr
);
1794 WorldSession
* GetSession() const { return m_session
; }
1795 void SetSession(WorldSession
*s
) { m_session
= s
; }
1797 void BuildCreateUpdateBlockForPlayer( UpdateData
*data
, Player
*target
) const;
1798 void DestroyForPlayer( Player
*target
, bool anim
= false ) const;
1799 void SendLogXPGain(uint32 GivenXP
,Unit
* victim
,uint32 RestXP
);
1802 void SendAttackSwingCantAttack();
1803 void SendAttackSwingCancelAttack();
1804 void SendAttackSwingDeadTarget();
1805 void SendAttackSwingNotInRange();
1806 void SendAttackSwingBadFacingAttack();
1807 void SendAutoRepeatCancel(Unit
*target
);
1808 void SendExplorationExperience(uint32 Area
, uint32 Experience
);
1810 void SendDungeonDifficulty(bool IsInGroup
);
1811 void SendRaidDifficulty(bool IsInGroup
);
1812 void ResetInstances(uint8 method
, bool isRaid
);
1813 void SendResetInstanceSuccess(uint32 MapId
);
1814 void SendResetInstanceFailed(uint32 reason
, uint32 MapId
);
1815 void SendResetFailedNotify(uint32 mapid
);
1817 bool SetPosition(float x
, float y
, float z
, float orientation
, bool teleport
= false);
1818 void UpdateUnderwaterState( Map
* m
, float x
, float y
, float z
);
1820 void SendMessageToSet(WorldPacket
*data
, bool self
);// overwrite Object::SendMessageToSet
1821 void SendMessageToSetInRange(WorldPacket
*data
, float fist
, bool self
);
1822 // overwrite Object::SendMessageToSetInRange
1823 void SendMessageToSetInRange(WorldPacket
*data
, float dist
, bool self
, bool own_team_only
);
1825 static void DeleteFromDB(uint64 playerguid
, uint32 accountId
, bool updateRealmChars
= true);
1827 Corpse
*GetCorpse() const;
1828 void SpawnCorpseBones();
1829 void CreateCorpse();
1831 uint32
GetResurrectionSpellId();
1832 void ResurrectPlayer(float restore_percent
, bool applySickness
= false);
1833 void BuildPlayerRepop();
1834 void RepopAtGraveyard();
1836 void DurabilityLossAll(double percent
, bool inventory
);
1837 void DurabilityLoss(Item
* item
, double percent
);
1838 void DurabilityPointsLossAll(int32 points
, bool inventory
);
1839 void DurabilityPointsLoss(Item
* item
, int32 points
);
1840 void DurabilityPointLossForEquipSlot(EquipmentSlots slot
);
1841 uint32
DurabilityRepairAll(bool cost
, float discountMod
, bool guildBank
);
1842 uint32
DurabilityRepair(uint16 pos
, bool cost
, float discountMod
, bool guildBank
);
1844 void UpdateMirrorTimers();
1845 void StopMirrorTimers()
1847 StopMirrorTimer(FATIGUE_TIMER
);
1848 StopMirrorTimer(BREATH_TIMER
);
1849 StopMirrorTimer(FIRE_TIMER
);
1852 void SetMovement(PlayerMovementType pType
);
1854 void JoinedChannel(Channel
*c
);
1855 void LeftChannel(Channel
*c
);
1856 void CleanupChannels();
1857 void UpdateLocalChannels( uint32 newZone
);
1858 void LeaveLFGChannel();
1860 void UpdateDefense();
1861 void UpdateWeaponSkill (WeaponAttackType attType
);
1862 void UpdateCombatSkills(Unit
*pVictim
, WeaponAttackType attType
, bool defence
);
1864 void SetSkill(uint32 id
, uint16 currVal
, uint16 maxVal
);
1865 uint16
GetMaxSkillValue(uint32 skill
) const; // max + perm. bonus + temp bonus
1866 uint16
GetPureMaxSkillValue(uint32 skill
) const; // max
1867 uint16
GetSkillValue(uint32 skill
) const; // skill value + perm. bonus + temp bonus
1868 uint16
GetBaseSkillValue(uint32 skill
) const; // skill value + perm. bonus
1869 uint16
GetPureSkillValue(uint32 skill
) const; // skill value
1870 int16
GetSkillPermBonusValue(uint32 skill
) const;
1871 int16
GetSkillTempBonusValue(uint32 skill
) const;
1872 bool HasSkill(uint32 skill
) const;
1873 void learnSkillRewardedSpells(uint32 id
, uint32 value
);
1875 WorldLocation
& GetTeleportDest() { return m_teleport_dest
; }
1876 bool IsBeingTeleported() const { return mSemaphoreTeleport_Near
|| mSemaphoreTeleport_Far
; }
1877 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near
; }
1878 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far
; }
1879 void SetSemaphoreTeleportNear(bool semphsetting
) { mSemaphoreTeleport_Near
= semphsetting
; }
1880 void SetSemaphoreTeleportFar(bool semphsetting
) { mSemaphoreTeleport_Far
= semphsetting
; }
1881 void ProcessDelayedOperations();
1883 void CheckExploreSystem(void);
1885 static uint32
TeamForRace(uint8 race
);
1886 uint32
GetTeam() const { return m_team
; }
1887 static uint32
getFactionForRace(uint8 race
);
1888 void setFactionForRace(uint8 race
);
1890 void InitDisplayIds();
1892 bool IsAtGroupRewardDistance(WorldObject
const* pRewardSource
) const;
1893 bool RewardPlayerAndGroupAtKill(Unit
* pVictim
);
1894 void RewardPlayerAndGroupAtEvent(uint32 creature_id
,WorldObject
* pRewardSource
);
1895 bool isHonorOrXPTarget(Unit
* pVictim
);
1897 ReputationMgr
& GetReputationMgr() { return m_reputationMgr
; }
1898 ReputationMgr
const& GetReputationMgr() const { return m_reputationMgr
; }
1899 ReputationRank
GetReputationRank(uint32 faction_id
) const;
1900 void RewardReputation(Unit
*pVictim
, float rate
);
1901 void RewardReputation(Quest
const *pQuest
);
1903 void UpdateSkillsForLevel();
1904 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1905 void ModifySkillBonus(uint32 skillid
,int32 val
, bool talent
);
1907 /*********************************************************/
1908 /*** PVP SYSTEM ***/
1909 /*********************************************************/
1910 void UpdateArenaFields();
1911 void UpdateHonorFields();
1912 bool RewardHonor(Unit
*pVictim
, uint32 groupsize
, float honor
= -1);
1913 uint32
GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
); }
1914 uint32
GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY
); }
1915 void ModifyHonorPoints( int32 value
);
1916 void ModifyArenaPoints( int32 value
);
1917 uint32
GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot
);
1921 void SetDrunkValue(uint16 newDrunkValue
, uint32 itemid
=0);
1922 uint16
GetDrunkValue() const { return m_drunk
; }
1923 static DrunkenState
GetDrunkenstateByValue(uint16 value
);
1925 uint32
GetDeathTimer() const { return m_deathTimer
; }
1926 uint32
GetCorpseReclaimDelay(bool pvp
) const;
1927 void UpdateCorpseReclaimDelay();
1928 void SendCorpseReclaimDelay(bool load
= false);
1930 uint32
GetShieldBlockValue() const; // overwrite Unit version (virtual)
1931 bool CanParry() const { return m_canParry
; }
1932 void SetCanParry(bool value
);
1933 bool CanBlock() const { return m_canBlock
; }
1934 void SetCanBlock(bool value
);
1935 bool CanDualWield() const { return m_canDualWield
; }
1936 void SetCanDualWield(bool value
) { m_canDualWield
= value
; }
1937 bool CanTitanGrip() const { return m_canTitanGrip
; }
1938 void SetCanTitanGrip(bool value
) { m_canTitanGrip
= value
; }
1939 bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE
); }
1941 void SetRegularAttackTime();
1942 void SetBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float value
) { m_auraBaseMod
[modGroup
][modType
] = value
; }
1943 void HandleBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float amount
, bool apply
);
1944 float GetBaseModValue(BaseModGroup modGroup
, BaseModType modType
) const;
1945 float GetTotalBaseModValue(BaseModGroup modGroup
) const;
1946 float GetTotalPercentageModValue(BaseModGroup modGroup
) const { return m_auraBaseMod
[modGroup
][FLAT_MOD
] + m_auraBaseMod
[modGroup
][PCT_MOD
]; }
1947 void _ApplyAllStatBonuses();
1948 void _RemoveAllStatBonuses();
1949 float GetArmorPenetrationPct() const { return m_armorPenetrationPct
; }
1951 void _ApplyWeaponDependentAuraMods(Item
*item
, WeaponAttackType attackType
, bool apply
);
1952 void _ApplyWeaponDependentAuraCritMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1953 void _ApplyWeaponDependentAuraDamageMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1955 void _ApplyItemMods(Item
*item
,uint8 slot
,bool apply
);
1956 void _RemoveAllItemMods();
1957 void _ApplyAllItemMods();
1958 void _ApplyAllLevelScaleItemMods(bool apply
);
1959 void _ApplyItemBonuses(ItemPrototype
const *proto
,uint8 slot
,bool apply
, bool only_level_scale
= false);
1960 void _ApplyAmmoBonuses();
1961 bool EnchantmentFitsRequirements(uint32 enchantmentcondition
, int8 slot
);
1962 void ToggleMetaGemsActive(uint8 exceptslot
, bool apply
);
1963 void CorrectMetaGemEnchants(uint8 slot
, bool apply
);
1964 void InitDataForForm(bool reapplyMods
= false);
1966 void ApplyItemEquipSpell(Item
*item
, bool apply
, bool form_change
= false);
1967 void ApplyEquipSpell(SpellEntry
const* spellInfo
, Item
* item
, bool apply
, bool form_change
= false);
1968 void UpdateEquipSpellsAtFormChange();
1969 void CastItemCombatSpell(Unit
* Target
, WeaponAttackType attType
);
1970 void CastItemUseSpell(Item
*item
,SpellCastTargets
const& targets
,uint8 cast_count
, uint32 glyphIndex
);
1972 void SendEquipmentSetList();
1973 void SetEquipmentSet(uint32 index
, EquipmentSet eqset
);
1974 void DeleteEquipmentSet(uint64 setGuid
);
1976 void SendInitWorldStates(uint32 zone
, uint32 area
);
1977 void SendUpdateWorldState(uint32 Field
, uint32 Value
);
1978 void SendDirectMessage(WorldPacket
*data
);
1980 void SendAurasForTarget(Unit
*target
);
1982 PlayerMenu
* PlayerTalkClass
;
1983 std::vector
<ItemSetEffect
*> ItemSetEff
;
1985 void SendLoot(uint64 guid
, LootType loot_type
);
1986 void SendLootRelease( uint64 guid
);
1987 void SendNotifyLootItemRemoved(uint8 lootSlot
);
1988 void SendNotifyLootMoneyRemoved();
1990 /*********************************************************/
1991 /*** BATTLEGROUND SYSTEM ***/
1992 /*********************************************************/
1994 bool InBattleGround() const { return m_bgData
.bgInstanceID
!= 0; }
1995 bool InArena() const;
1996 uint32
GetBattleGroundId() const { return m_bgData
.bgInstanceID
; }
1997 BattleGroundTypeId
GetBattleGroundTypeId() const { return m_bgData
.bgTypeID
; }
1998 BattleGround
* GetBattleGround() const;
2000 bool InBattleGroundQueue() const
2002 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2003 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
!= BATTLEGROUND_QUEUE_NONE
)
2008 BattleGroundQueueTypeId
GetBattleGroundQueueTypeId(uint32 index
) const { return m_bgBattleGroundQueueID
[index
].bgQueueTypeId
; }
2009 uint32
GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId
) const
2011 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2012 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
2014 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
2016 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
2018 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2019 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
2020 return m_bgBattleGroundQueueID
[i
].invitedToInstance
!= 0;
2023 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
2025 return GetBattleGroundQueueIndex(bgQueueTypeId
) < PLAYER_MAX_BATTLEGROUND_QUEUES
;
2028 void SetBattleGroundId(uint32 val
, BattleGroundTypeId bgTypeId
)
2030 m_bgData
.bgInstanceID
= val
;
2031 m_bgData
.bgTypeID
= bgTypeId
;
2033 uint32
AddBattleGroundQueueId(BattleGroundQueueTypeId val
)
2035 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2037 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
|| m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
2039 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= val
;
2040 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
2044 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
2046 bool HasFreeBattleGroundQueueId()
2048 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2049 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
)
2053 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val
)
2055 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2057 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
2059 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= BATTLEGROUND_QUEUE_NONE
;
2060 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
2065 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
, uint32 instanceId
)
2067 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2068 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
2069 m_bgBattleGroundQueueID
[i
].invitedToInstance
= instanceId
;
2071 bool IsInvitedForBattleGroundInstance(uint32 instanceId
) const
2073 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2074 if (m_bgBattleGroundQueueID
[i
].invitedToInstance
== instanceId
)
2078 WorldLocation
const& GetBattleGroundEntryPoint() const { return m_bgData
.joinPos
; }
2079 void SetBattleGroundEntryPoint();
2081 void SetBGTeam(uint32 team
) { m_bgData
.bgTeam
= team
; }
2082 uint32
GetBGTeam() const { return m_bgData
.bgTeam
? m_bgData
.bgTeam
: GetTeam(); }
2084 void LeaveBattleground(bool teleportToEntryPoint
= true);
2085 bool CanJoinToBattleground() const;
2086 bool CanReportAfkDueToLimit();
2087 void ReportedAfkBy(Player
* reporter
);
2088 void ClearAfkReports() { m_bgData
.bgAfkReporter
.clear(); }
2090 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId
) const;
2091 bool CanUseBattleGroundObject();
2092 bool isTotalImmune();
2093 bool CanCaptureTowerPoint();
2095 /*********************************************************/
2096 /*** REST SYSTEM ***/
2097 /*********************************************************/
2099 bool isRested() const { return GetRestTime() >= 10*IN_MILISECONDS
; }
2100 uint32
GetXPRestBonus(uint32 xp
);
2101 uint32
GetRestTime() const { return m_restTime
; }
2102 void SetRestTime(uint32 v
) { m_restTime
= v
; }
2104 /*********************************************************/
2105 /*** ENVIROMENTAL SYSTEM ***/
2106 /*********************************************************/
2108 uint32
EnvironmentalDamage(EnviromentalDamage type
, uint32 damage
);
2110 /*********************************************************/
2111 /*** FLOOD FILTER SYSTEM ***/
2112 /*********************************************************/
2114 void UpdateSpeakTime();
2115 bool CanSpeak() const;
2116 void ChangeSpeakTime(int utime
);
2118 /*********************************************************/
2119 /*** VARIOUS SYSTEMS ***/
2120 /*********************************************************/
2121 bool HasMovementFlag(MovementFlags f
) const; // for script access to m_movementInfo.HasMovementFlag
2122 void UpdateFallInformationIfNeed(MovementInfo
const& minfo
,uint16 opcode
);
2124 void SetFallInformation(uint32 time
, float z
)
2126 m_lastFallTime
= time
;
2129 void HandleFall(MovementInfo
const& movementInfo
);
2131 void BuildTeleportAckMsg( WorldPacket
*data
, float x
, float y
, float z
, float ang
) const;
2133 bool isMoving() const { return m_movementInfo
.HasMovementFlag(movementFlagsMask
); }
2134 bool isMovingOrTurning() const { return m_movementInfo
.HasMovementFlag(movementOrTurningFlagsMask
); }
2136 bool CanFly() const { return m_movementInfo
.HasMovementFlag(MOVEFLAG_CAN_FLY
); }
2137 bool IsFlying() const { return m_movementInfo
.HasMovementFlag(MOVEFLAG_FLYING
); }
2138 bool IsKnowHowFlyIn(uint32 mapid
, uint32 zone
) const;
2140 void SetClientControl(Unit
* target
, uint8 allowMove
);
2141 void SetMover(Unit
* target
) { m_mover
= target
? target
: this; }
2143 void EnterVehicle(Vehicle
*vehicle
);
2144 void ExitVehicle(Vehicle
*vehicle
);
2146 uint64
GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT
); }
2147 void SetFarSightGUID(uint64 guid
);
2150 Transport
* GetTransport() const { return m_transport
; }
2151 void SetTransport(Transport
* t
) { m_transport
= t
; }
2153 float GetTransOffsetX() const { return m_movementInfo
.GetTransportPos()->x
; }
2154 float GetTransOffsetY() const { return m_movementInfo
.GetTransportPos()->y
; }
2155 float GetTransOffsetZ() const { return m_movementInfo
.GetTransportPos()->z
; }
2156 float GetTransOffsetO() const { return m_movementInfo
.GetTransportPos()->o
; }
2157 uint32
GetTransTime() const { return m_movementInfo
.GetTransportTime(); }
2158 int8
GetTransSeat() const { return m_movementInfo
.GetTransportSeat(); }
2160 uint32
GetSaveTimer() const { return m_nextSave
; }
2161 void SetSaveTimer(uint32 timer
) { m_nextSave
= timer
; }
2169 void SaveRecallPosition();
2171 void SetHomebindToLocation(WorldLocation
const& loc
, uint32 area_id
);
2172 void RelocateToHomebind() { SetLocationMapId(m_homebindMapId
); Relocate(m_homebindX
, m_homebindY
, m_homebindZ
); }
2173 bool TeleportToHomebind(uint32 options
= 0) { return TeleportTo(m_homebindMapId
, m_homebindX
, m_homebindY
, m_homebindZ
, GetOrientation(), options
); }
2175 // currently visible objects at player client
2176 typedef std::set
<uint64
> ClientGUIDs
;
2177 ClientGUIDs m_clientGUIDs
;
2179 bool HaveAtClient(WorldObject
const* u
) { return u
==this || m_clientGUIDs
.find(u
->GetGUID())!=m_clientGUIDs
.end(); }
2181 WorldObject
const* GetViewPoint() const;
2182 bool IsVisibleInGridForPlayer(Player
* pl
) const;
2183 bool IsVisibleGloballyFor(Player
* pl
) const;
2185 void UpdateVisibilityOf(WorldObject
const* viewPoint
, WorldObject
* target
);
2188 void UpdateVisibilityOf(WorldObject
const* viewPoint
,T
* target
, UpdateData
& data
, UpdateDataMapType
& data_updates
, std::set
<WorldObject
*>& visibleNow
);
2190 // Stealth detection system
2191 void HandleStealthedUnitsDetection();
2193 uint8 m_forced_speed_changes
[MAX_MOVE_TYPE
];
2195 bool HasAtLoginFlag(AtLoginFlags f
) const { return m_atLoginFlags
& f
; }
2196 void SetAtLoginFlag(AtLoginFlags f
) { m_atLoginFlags
|= f
; }
2197 void RemoveAtLoginFlag(AtLoginFlags f
, bool in_db_also
= false);
2199 LookingForGroup m_lookingForGroup
;
2201 // Temporarily removed pet cache
2202 uint32
GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber
; }
2203 void SetTemporaryUnsummonedPetNumber(uint32 petnumber
) { m_temporaryUnsummonedPetNumber
= petnumber
; }
2204 void UnsummonPetTemporaryIfAny();
2205 void ResummonPetTemporaryUnSummonedIfAny();
2206 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
2208 void SendCinematicStart(uint32 CinematicSequenceId
);
2209 void SendMovieStart(uint32 MovieId
);
2211 /*********************************************************/
2212 /*** INSTANCE SYSTEM ***/
2213 /*********************************************************/
2215 typedef UNORDERED_MAP
< uint32
/*mapId*/, InstancePlayerBind
> BoundInstancesMap
;
2217 void UpdateHomebindTime(uint32 time
);
2219 uint32 m_HomebindTimer
;
2220 bool m_InstanceValid
;
2221 // permanent binds and solo binds by difficulty
2222 BoundInstancesMap m_boundInstances
[MAX_DIFFICULTY
];
2223 InstancePlayerBind
* GetBoundInstance(uint32 mapid
, Difficulty difficulty
);
2224 BoundInstancesMap
& GetBoundInstances(Difficulty difficulty
) { return m_boundInstances
[difficulty
]; }
2225 void UnbindInstance(uint32 mapid
, Difficulty difficulty
, bool unload
= false);
2226 void UnbindInstance(BoundInstancesMap::iterator
&itr
, Difficulty difficulty
, bool unload
= false);
2227 InstancePlayerBind
* BindToInstance(InstanceSave
*save
, bool permanent
, bool load
= false);
2228 void SendRaidInfo();
2229 void SendSavedInstances();
2230 static void ConvertInstancesToGroup(Player
*player
, Group
*group
= NULL
, uint64 player_guid
= 0);
2232 /*********************************************************/
2233 /*** GROUP SYSTEM ***/
2234 /*********************************************************/
2236 Group
* GetGroupInvite() { return m_groupInvite
; }
2237 void SetGroupInvite(Group
*group
) { m_groupInvite
= group
; }
2238 Group
* GetGroup() { return m_group
.getTarget(); }
2239 const Group
* GetGroup() const { return (const Group
*)m_group
.getTarget(); }
2240 GroupReference
& GetGroupRef() { return m_group
; }
2241 void SetGroup(Group
*group
, int8 subgroup
= -1);
2242 uint8
GetSubGroup() const { return m_group
.getSubGroup(); }
2243 uint32
GetGroupUpdateFlag() const { return m_groupUpdateMask
; }
2244 void SetGroupUpdateFlag(uint32 flag
) { m_groupUpdateMask
|= flag
; }
2245 const uint64
& GetAuraUpdateMask() const { return m_auraUpdateMask
; }
2246 void SetAuraUpdateMask(uint8 slot
) { m_auraUpdateMask
|= (uint64(1) << slot
); }
2247 Player
* GetNextRandomRaidMember(float radius
);
2248 PartyResult
CanUninviteFromGroup() const;
2249 // BattleGround Group System
2250 void SetBattleGroundRaid(Group
*group
, int8 subgroup
= -1);
2251 void RemoveFromBattleGroundRaid();
2252 Group
* GetOriginalGroup() { return m_originalGroup
.getTarget(); }
2253 GroupReference
& GetOriginalGroupRef() { return m_originalGroup
; }
2254 uint8
GetOriginalSubGroup() const { return m_originalGroup
.getSubGroup(); }
2255 void SetOriginalGroup(Group
*group
, int8 subgroup
= -1);
2257 GridReference
<Player
> &GetGridRef() { return m_gridRef
; }
2258 MapReference
&GetMapRef() { return m_mapRef
; }
2260 bool isAllowedToLoot(Creature
* creature
);
2262 DeclinedName
const* GetDeclinedNames() const { return m_declinedname
; }
2264 // Rune functions, need check getClass() == CLASS_DEATH_KNIGHT before access
2265 uint8
GetRunesState() const { return m_runes
->runeState
; }
2266 RuneType
GetBaseRune(uint8 index
) const { return RuneType(m_runes
->runes
[index
].BaseRune
); }
2267 RuneType
GetCurrentRune(uint8 index
) const { return RuneType(m_runes
->runes
[index
].CurrentRune
); }
2268 uint16
GetRuneCooldown(uint8 index
) const { return m_runes
->runes
[index
].Cooldown
; }
2269 bool IsBaseRuneSlotsOnCooldown(RuneType runeType
) const;
2270 void SetBaseRune(uint8 index
, RuneType baseRune
) { m_runes
->runes
[index
].BaseRune
= baseRune
; }
2271 void SetCurrentRune(uint8 index
, RuneType currentRune
) { m_runes
->runes
[index
].CurrentRune
= currentRune
; }
2272 void SetRuneCooldown(uint8 index
, uint16 cooldown
) { m_runes
->runes
[index
].Cooldown
= cooldown
; m_runes
->SetRuneState(index
, (cooldown
== 0) ? true : false); }
2273 void ConvertRune(uint8 index
, RuneType newType
);
2274 void ResyncRunes(uint8 count
);
2275 void AddRunePower(uint8 index
);
2278 AchievementMgr
& GetAchievementMgr() { return m_achievementMgr
; }
2279 void UpdateAchievementCriteria(AchievementCriteriaTypes type
, uint32 miscvalue1
=0, uint32 miscvalue2
=0, Unit
*unit
=NULL
, uint32 time
=0);
2280 bool HasTitle(uint32 bitIndex
);
2281 bool HasTitle(CharTitlesEntry
const* title
) { return HasTitle(title
->bit_index
); }
2282 void SetTitle(CharTitlesEntry
const* title
, bool lost
= false);
2284 bool isActiveObject() const { return true; }
2285 bool canSeeSpellClickOn(Creature
const* creature
) const;
2288 uint32 m_contestedPvPTimer
;
2290 /*********************************************************/
2291 /*** BATTLEGROUND SYSTEM ***/
2292 /*********************************************************/
2295 this is an array of BG queues (BgTypeIDs) in which is player
2297 struct BgBattleGroundQueueID_Rec
2299 BattleGroundQueueTypeId bgQueueTypeId
;
2300 uint32 invitedToInstance
;
2303 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID
[PLAYER_MAX_BATTLEGROUND_QUEUES
];
2306 /*********************************************************/
2307 /*** QUEST SYSTEM ***/
2308 /*********************************************************/
2310 //We allow only one timed quest active at the same time. Below can then be simple value instead of set.
2311 std::set
<uint32
> m_timedquests
;
2314 uint32 m_ingametime
;
2316 /*********************************************************/
2317 /*** LOAD SYSTEM ***/
2318 /*********************************************************/
2320 void _LoadActions(QueryResult
*result
);
2321 void _LoadAuras(QueryResult
*result
, uint32 timediff
);
2322 void _LoadBoundInstances(QueryResult
*result
);
2323 void _LoadInventory(QueryResult
*result
, uint32 timediff
);
2325 void _LoadMailedItems(Mail
*mail
);
2326 void _LoadQuestStatus(QueryResult
*result
);
2327 void _LoadDailyQuestStatus(QueryResult
*result
);
2328 void _LoadGroup(QueryResult
*result
);
2329 void _LoadSkills(QueryResult
*result
);
2330 void _LoadSpells(QueryResult
*result
);
2331 void _LoadFriendList(QueryResult
*result
);
2332 bool _LoadHomeBind(QueryResult
*result
);
2333 void _LoadDeclinedNames(QueryResult
*result
);
2334 void _LoadArenaTeamInfo(QueryResult
*result
);
2335 void _LoadEquipmentSets(QueryResult
*result
);
2336 void _LoadBGData(QueryResult
* result
);
2337 void _LoadGlyphs(QueryResult
*result
);
2339 /*********************************************************/
2340 /*** SAVE SYSTEM ***/
2341 /*********************************************************/
2343 void _SaveActions();
2345 void _SaveInventory();
2347 void _SaveQuestStatus();
2348 void _SaveDailyQuestStatus();
2351 void _SaveEquipmentSets();
2355 void _SetCreateBits(UpdateMask
*updateMask
, Player
*target
) const;
2356 void _SetUpdateBits(UpdateMask
*updateMask
, Player
*target
) const;
2358 /*********************************************************/
2359 /*** ENVIRONMENTAL SYSTEM ***/
2360 /*********************************************************/
2361 void HandleSobering();
2362 void SendMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
, uint32 CurrentValue
, int32 Regen
);
2363 void StopMirrorTimer(MirrorTimerType Type
);
2364 void HandleDrowning(uint32 time_diff
);
2365 int32
getMaxTimer(MirrorTimerType timer
);
2367 /*********************************************************/
2368 /*** HONOR SYSTEM ***/
2369 /*********************************************************/
2370 time_t m_lastHonorUpdateTime
;
2372 void outDebugValues() const;
2378 uint32 m_speakCount
;
2379 Difficulty m_dungeonDifficulty
;
2380 Difficulty m_raidDifficulty
;
2382 uint32 m_atLoginFlags
;
2384 Item
* m_items
[PLAYER_SLOTS_COUNT
];
2385 uint32 m_currentBuybackSlot
;
2387 std::vector
<Item
*> m_itemUpdateQueue
;
2388 bool m_itemUpdateQueueBlocked
;
2390 uint32 m_ExtraFlags
;
2391 uint64 m_curSelection
;
2393 uint64 m_comboTarget
;
2396 QuestStatusMap mQuestStatus
;
2398 SkillStatusMap mSkillStatus
;
2400 uint32 m_GuildIdInvited
;
2401 uint32 m_ArenaTeamIdInvited
;
2404 PlayerSpellMap m_spells
;
2405 SpellCooldowns m_spellCooldowns
;
2406 uint32 m_lastPotionId
; // last used health/mana potion in combat, that block next potion use
2411 ActionButtonList m_actionButtons
[MAX_TALENT_SPEC_COUNT
];
2413 Glyph m_glyphs
[MAX_TALENT_SPEC_COUNT
][MAX_GLYPH_SLOT_INDEX
];
2415 float m_auraBaseMod
[BASEMOD_END
][MOD_END
];
2416 int16 m_baseRatingValue
[MAX_COMBAT_RATING
];
2417 uint16 m_baseSpellPower
;
2418 uint16 m_baseFeralAP
;
2419 uint16 m_baseManaRegen
;
2420 float m_armorPenetrationPct
;
2422 SpellModList m_spellMods
[MAX_SPELLMOD
];
2423 int32 m_SpellModRemoveCount
;
2424 EnchantDurationList m_enchantDuration
;
2425 ItemDurationList m_itemDuration
;
2427 uint64 m_resurrectGUID
;
2428 uint32 m_resurrectMap
;
2429 float m_resurrectX
, m_resurrectY
, m_resurrectZ
;
2430 uint32 m_resurrectHealth
, m_resurrectMana
;
2432 WorldSession
*m_session
;
2434 typedef std::list
<Channel
*> JoinedChannelsList
;
2435 JoinedChannelsList m_channels
;
2441 uint16 tradeItems
[TRADE_SLOT_COUNT
];
2444 bool m_DailyQuestChanged
;
2445 time_t m_lastDailyQuestTime
;
2447 uint32 m_drunkTimer
;
2449 uint32 m_weaponChangeTimer
;
2451 uint32 m_zoneUpdateId
;
2452 uint32 m_zoneUpdateTimer
;
2453 uint32 m_areaUpdateId
;
2455 uint32 m_deathTimer
;
2456 time_t m_deathExpireTime
;
2460 uint32 m_WeaponProficiency
;
2461 uint32 m_ArmorProficiency
;
2464 bool m_canDualWield
;
2465 bool m_canTitanGrip
;
2466 uint8 m_swingErrorMsg
;
2469 ////////////////////Rest System/////////////////////
2470 time_t time_inn_enter
;
2471 uint32 inn_pos_mapid
;
2477 ////////////////////Rest System/////////////////////
2480 Transport
* m_transport
;
2482 uint32 m_resetTalentsCost
;
2483 time_t m_resetTalentsTime
;
2484 uint32 m_usedTalentCount
;
2485 uint32 m_questRewardTalentCount
;
2488 PlayerSocial
*m_social
;
2491 GroupReference m_group
;
2492 GroupReference m_originalGroup
;
2493 Group
*m_groupInvite
;
2494 uint32 m_groupUpdateMask
;
2495 uint64 m_auraUpdateMask
;
2500 time_t m_summon_expire
;
2501 uint32 m_summon_mapid
;
2506 DeclinedName
*m_declinedname
;
2508 EquipmentSets m_EquipmentSets
;
2510 // internal common parts for CanStore/StoreItem functions
2511 uint8
_CanStoreItem_InSpecificSlot( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool swap
, Item
*pSrcItem
) const;
2512 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;
2513 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;
2514 Item
* _StoreItem( uint16 pos
, Item
*pItem
, uint32 count
, bool clone
, bool update
);
2516 void UpdateKnownCurrencies(uint32 itemId
, bool apply
);
2517 int32
CalculateReputationGain(uint32 creatureOrQuestLevel
, int32 rep
, int32 faction
, bool for_quest
);
2518 void AdjustQuestReqItemCount( Quest
const* pQuest
, QuestStatusData
& questStatusData
);
2520 bool IsCanDelayTeleport() const { return m_bCanDelayTeleport
; }
2521 void SetCanDelayTeleport(bool setting
) { m_bCanDelayTeleport
= setting
; }
2522 bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport
; }
2523 void SetDelayedTeleportFlag(bool setting
) { m_bHasDelayedTeleport
= setting
; }
2525 void ScheduleDelayedOperation(uint32 operation
)
2527 if(operation
< DELAYED_END
)
2528 m_DelayedOperations
|= operation
;
2531 GridReference
<Player
> m_gridRef
;
2532 MapReference m_mapRef
;
2534 // Homebind coordinates
2535 uint32 m_homebindMapId
;
2536 uint16 m_homebindAreaId
;
2541 uint32 m_lastFallTime
;
2544 int32 m_MirrorTimer
[MAX_TIMERS
];
2545 uint8 m_MirrorTimerFlags
;
2546 uint8 m_MirrorTimerFlagsLast
;
2549 // Current teleport data
2550 WorldLocation m_teleport_dest
;
2551 uint32 m_teleport_options
;
2552 bool mSemaphoreTeleport_Near
;
2553 bool mSemaphoreTeleport_Far
;
2555 uint32 m_DelayedOperations
;
2556 bool m_bCanDelayTeleport
;
2557 bool m_bHasDelayedTeleport
;
2559 uint32 m_DetectInvTimer
;
2561 // Temporary removed pet cache
2562 uint32 m_temporaryUnsummonedPetNumber
;
2563 uint32 m_oldpetspell
;
2565 AchievementMgr m_achievementMgr
;
2566 ReputationMgr m_reputationMgr
;
2569 void AddItemsSetItem(Player
*player
,Item
*item
);
2570 void RemoveItemsSetItem(Player
*player
,ItemPrototype
const *proto
);
2572 // "the bodies of template functions must be made available in a header file"
2573 template <class T
> T
Player::ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
)
2575 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
2576 if (!spellInfo
) return 0;
2578 int32 totalflat
= 0;
2579 for (SpellModList::iterator itr
= m_spellMods
[op
].begin(); itr
!= m_spellMods
[op
].end(); ++itr
)
2581 SpellModifier
*mod
= *itr
;
2583 if(!IsAffectedBySpellmod(spellInfo
,mod
,spell
))
2585 if (mod
->type
== SPELLMOD_FLAT
)
2586 totalflat
+= mod
->value
;
2587 else if (mod
->type
== SPELLMOD_PCT
)
2589 // skip percent mods for null basevalue (most important for spell mods with charges )
2590 if(basevalue
== T(0))
2593 // special case (skip >10sec spell casts for instant cast setting)
2594 if( mod
->op
==SPELLMOD_CASTING_TIME
&& basevalue
>= T(10*IN_MILISECONDS
) && mod
->value
<= -100)
2597 totalpct
+= mod
->value
;
2600 if (mod
->charges
> 0 )
2603 if (mod
->charges
== 0)
2606 mod
->lastAffected
= spell
;
2607 if(!mod
->lastAffected
)
2608 mod
->lastAffected
= FindCurrentSpellBySpellId(spellId
);
2609 ++m_SpellModRemoveCount
;
2614 float diff
= (float)basevalue
*(float)totalpct
/100.0f
+ (float)totalflat
;
2615 basevalue
= T((float)basevalue
+ diff
);
2619 template<typename Func
>
2620 void Player::CallForAllControlledUnits(Func
const& func
, bool withTotems
, bool withGuardians
, bool withCharms
, bool withMiniPet
)
2623 if(Unit
* mini
= GetMiniPet())
2626 Unit::CallForAllControlledUnits(func
,withTotems
,withGuardians
,withCharms
);
2629 template<typename Func
>
2630 bool Player::CheckAllControlledUnits(Func
const& func
, bool withTotems
, bool withGuardians
, bool withCharms
, bool withMiniPet
) const
2633 if(Unit
* mini
= GetMiniPet())
2637 return Unit::CheckAllControlledUnits(func
,withTotems
,withGuardians
,withCharms
);