2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "ItemPrototype.h"
27 #include "Database/DatabaseEnv.h"
28 #include "NPCHandler.h"
32 #include "WorldSession.h"
34 #include "MapReference.h"
35 #include "Util.h" // for Tokens typedef
36 #include "AchievementMgr.h"
37 #include "ReputationMgr.h"
38 #include "BattleGround.h"
51 class SpellCastTargets
;
55 typedef std::deque
<Mail
*> PlayerMails
;
57 #define PLAYER_MAX_SKILLS 127
58 #define PLAYER_MAX_DAILY_QUESTS 25
60 // Note: SPELLMOD_* values is aura types in fact
63 SPELLMOD_FLAT
= 107, // SPELL_AURA_ADD_FLAT_MODIFIER
64 SPELLMOD_PCT
= 108 // SPELL_AURA_ADD_PCT_MODIFIER
67 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
68 enum PlayerUnderwaterState
70 UNDERWATER_NONE
= 0x00,
71 UNDERWATER_INWATER
= 0x01, // terrain type is water and player is afflicted by it
72 UNDERWATER_INLAVA
= 0x02, // terrain type is lava and player is afflicted by it
73 UNDERWATER_INSLIME
= 0x04, // terrain type is lava and player is afflicted by it
74 UNDERWARER_INDARKWATER
= 0x08, // terrain type is dark water and player is afflicted by it
76 UNDERWATER_EXIST_TIMERS
= 0x10
81 PLAYERSPELL_UNCHANGED
= 0,
82 PLAYERSPELL_CHANGED
= 1,
84 PLAYERSPELL_REMOVED
= 3
89 PlayerSpellState state
: 8;
90 bool active
: 1; // show in spellbook
91 bool dependent
: 1; // learned as result another spell learn, skill grow, quest reward, etc
92 bool disabled
: 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
95 // Spell modifier (used for modify other spells)
98 SpellModifier() : charges(0), lastAffected(NULL
) {}
100 SpellModType type
: 8;
106 Spell
const* lastAffected
;
109 typedef UNORDERED_MAP
<uint32
, PlayerSpell
*> PlayerSpellMap
;
110 typedef std::list
<SpellModifier
*> SpellModList
;
118 typedef std::map
<uint32
, SpellCooldown
> SpellCooldowns
;
120 enum TrainerSpellState
122 TRAINER_SPELL_GREEN
= 0,
123 TRAINER_SPELL_RED
= 1,
124 TRAINER_SPELL_GRAY
= 2,
125 TRAINER_SPELL_GREEN_DISABLED
= 10 // custom value, not send to client: formally green but learn not allowed
128 enum ActionButtonUpdateState
130 ACTIONBUTTON_UNCHANGED
= 0,
131 ACTIONBUTTON_CHANGED
= 1,
132 ACTIONBUTTON_NEW
= 2,
133 ACTIONBUTTON_DELETED
= 3
138 ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW
) {}
139 ActionButton(uint16 _action
, uint8 _type
, uint8 _misc
) : action(_action
), type(_type
), misc(_misc
), uState( ACTIONBUTTON_NEW
) {}
144 ActionButtonUpdateState uState
;
147 enum ActionButtonType
149 ACTION_BUTTON_SPELL
= 0,
150 ACTION_BUTTON_EQSET
= 32,
151 ACTION_BUTTON_MACRO
= 64,
152 ACTION_BUTTON_CMACRO
= 65,
153 ACTION_BUTTON_ITEM
= 128
156 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
158 typedef std::map
<uint8
,ActionButton
> ActionButtonList
;
160 struct PlayerCreateInfoItem
162 PlayerCreateInfoItem(uint32 id
, uint32 amount
) : item_id(id
), item_amount(amount
) {}
168 typedef std::list
<PlayerCreateInfoItem
> PlayerCreateInfoItems
;
170 struct PlayerClassLevelInfo
172 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
177 struct PlayerClassInfo
179 PlayerClassInfo() : levelInfo(NULL
) { }
181 PlayerClassLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
184 struct PlayerLevelInfo
186 PlayerLevelInfo() { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
188 uint8 stats
[MAX_STATS
];
191 typedef std::list
<uint32
> PlayerCreateInfoSpells
;
195 // existence checked by displayId != 0 // existence checked by displayId != 0
196 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL
)
207 PlayerCreateInfoItems item
;
208 PlayerCreateInfoSpells spell
;
209 std::list
<uint16
> action
[4];
211 PlayerLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
216 PvPInfo() : inHostileArea(false), endTimer(0) {}
224 DuelInfo() : initiator(NULL
), opponent(NULL
), startTimer(0), startTime(0), outOfBound(0) {}
244 #define RUNE_COOLDOWN 5 // 5*2=10 sec
264 RuneInfo runes
[MAX_RUNES
];
265 uint8 runeState
; // mask of available runes
267 void SetRuneState(uint8 index
, bool set
= true)
270 runeState
|= (1 << index
); // usable
272 runeState
&= ~(1 << index
); // on cooldown
276 typedef std::set
<uint64
> GuardianPetList
;
278 struct EnchantDuration
280 EnchantDuration() : item(NULL
), slot(MAX_ENCHANTMENT_SLOT
), leftduration(0) {};
281 EnchantDuration(Item
* _item
, EnchantmentSlot _slot
, uint32 _leftduration
) : item(_item
), slot(_slot
), leftduration(_leftduration
) { assert(item
); };
284 EnchantmentSlot slot
;
288 typedef std::list
<EnchantDuration
> EnchantDurationList
;
289 typedef std::list
<Item
*> ItemDurationList
;
291 struct LookingForGroupSlot
293 LookingForGroupSlot() : entry(0), type(0) {}
294 bool Empty() const { return !entry
&& !type
; }
295 void Clear() { entry
= 0; type
= 0; }
296 void Set(uint32 _entry
, uint32 _type
) { entry
= _entry
; type
= _type
; }
297 bool Is(uint32 _entry
, uint32 _type
) const { return entry
==_entry
&& type
==_type
; }
298 bool canAutoJoin() const { return entry
&& (type
== 1 || type
== 5); }
304 #define MAX_LOOKING_FOR_GROUP_SLOT 3
306 struct LookingForGroup
309 bool HaveInSlot(LookingForGroupSlot
const& slot
) const { return HaveInSlot(slot
.entry
,slot
.type
); }
310 bool HaveInSlot(uint32 _entry
, uint32 _type
) const
312 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
313 if(slots
[i
].Is(_entry
,_type
))
318 bool canAutoJoin() const
320 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
321 if(slots
[i
].canAutoJoin())
328 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
329 if(!slots
[i
].Empty())
334 LookingForGroupSlot slots
[MAX_LOOKING_FOR_GROUP_SLOT
];
335 LookingForGroupSlot more
;
340 enum PlayerMovementType
358 PLAYER_FLAGS_GROUP_LEADER
= 0x00000001,
359 PLAYER_FLAGS_AFK
= 0x00000002,
360 PLAYER_FLAGS_DND
= 0x00000004,
361 PLAYER_FLAGS_GM
= 0x00000008,
362 PLAYER_FLAGS_GHOST
= 0x00000010,
363 PLAYER_FLAGS_RESTING
= 0x00000020,
364 PLAYER_FLAGS_UNK7
= 0x00000040,
365 PLAYER_FLAGS_UNK8
= 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
366 PLAYER_FLAGS_CONTESTED_PVP
= 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
367 PLAYER_FLAGS_IN_PVP
= 0x00000200,
368 PLAYER_FLAGS_HIDE_HELM
= 0x00000400,
369 PLAYER_FLAGS_HIDE_CLOAK
= 0x00000800,
370 PLAYER_FLAGS_UNK13
= 0x00001000, // played long time
371 PLAYER_FLAGS_UNK14
= 0x00002000, // played too long time
372 PLAYER_FLAGS_UNK15
= 0x00004000,
373 PLAYER_FLAGS_UNK16
= 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
374 PLAYER_FLAGS_UNK17
= 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
375 PLAYER_FLAGS_UNK18
= 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
376 PLAYER_FLAGS_PVP_TIMER
= 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
377 PLAYER_FLAGS_UNK20
= 0x00080000,
378 PLAYER_FLAGS_UNK21
= 0x00100000,
379 PLAYER_FLAGS_UNK22
= 0x00200000,
380 PLAYER_FLAGS_UNK23
= 0x00400000,
381 PLAYER_FLAGS_UNK24
= 0x00800000, // disabled all abilitys on tab except autoattack
382 PLAYER_FLAGS_UNK25
= 0x01000000, // disabled all melee ability on tab include autoattack
386 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
387 // can't use enum for uint64 values
388 #define PLAYER_TITLE_DISABLED 0x0000000000000000LL
389 #define PLAYER_TITLE_NONE 0x0000000000000001LL
390 #define PLAYER_TITLE_PRIVATE 0x0000000000000002LL // 1
391 #define PLAYER_TITLE_CORPORAL 0x0000000000000004LL // 2
392 #define PLAYER_TITLE_SERGEANT_A 0x0000000000000008LL // 3
393 #define PLAYER_TITLE_MASTER_SERGEANT 0x0000000000000010LL // 4
394 #define PLAYER_TITLE_SERGEANT_MAJOR 0x0000000000000020LL // 5
395 #define PLAYER_TITLE_KNIGHT 0x0000000000000040LL // 6
396 #define PLAYER_TITLE_KNIGHT_LIEUTENANT 0x0000000000000080LL // 7
397 #define PLAYER_TITLE_KNIGHT_CAPTAIN 0x0000000000000100LL // 8
398 #define PLAYER_TITLE_KNIGHT_CHAMPION 0x0000000000000200LL // 9
399 #define PLAYER_TITLE_LIEUTENANT_COMMANDER 0x0000000000000400LL // 10
400 #define PLAYER_TITLE_COMMANDER 0x0000000000000800LL // 11
401 #define PLAYER_TITLE_MARSHAL 0x0000000000001000LL // 12
402 #define PLAYER_TITLE_FIELD_MARSHAL 0x0000000000002000LL // 13
403 #define PLAYER_TITLE_GRAND_MARSHAL 0x0000000000004000LL // 14
404 #define PLAYER_TITLE_SCOUT 0x0000000000008000LL // 15
405 #define PLAYER_TITLE_GRUNT 0x0000000000010000LL // 16
406 #define PLAYER_TITLE_SERGEANT_H 0x0000000000020000LL // 17
407 #define PLAYER_TITLE_SENIOR_SERGEANT 0x0000000000040000LL // 18
408 #define PLAYER_TITLE_FIRST_SERGEANT 0x0000000000080000LL // 19
409 #define PLAYER_TITLE_STONE_GUARD 0x0000000000100000LL // 20
410 #define PLAYER_TITLE_BLOOD_GUARD 0x0000000000200000LL // 21
411 #define PLAYER_TITLE_LEGIONNAIRE 0x0000000000400000LL // 22
412 #define PLAYER_TITLE_CENTURION 0x0000000000800000LL // 23
413 #define PLAYER_TITLE_CHAMPION 0x0000000001000000LL // 24
414 #define PLAYER_TITLE_LIEUTENANT_GENERAL 0x0000000002000000LL // 25
415 #define PLAYER_TITLE_GENERAL 0x0000000004000000LL // 26
416 #define PLAYER_TITLE_WARLORD 0x0000000008000000LL // 27
417 #define PLAYER_TITLE_HIGH_WARLORD 0x0000000010000000LL // 28
418 #define PLAYER_TITLE_GLADIATOR 0x0000000020000000LL // 29
419 #define PLAYER_TITLE_DUELIST 0x0000000040000000LL // 30
420 #define PLAYER_TITLE_RIVAL 0x0000000080000000LL // 31
421 #define PLAYER_TITLE_CHALLENGER 0x0000000100000000LL // 32
422 #define PLAYER_TITLE_SCARAB_LORD 0x0000000200000000LL // 33
423 #define PLAYER_TITLE_CONQUEROR 0x0000000400000000LL // 34
424 #define PLAYER_TITLE_JUSTICAR 0x0000000800000000LL // 35
425 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36
426 #define PLAYER_TITLE_MERCILESS_GLADIATOR 0x0000002000000000LL // 37
427 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN 0x0000004000000000LL // 38
428 #define PLAYER_TITLE_HAND_OF_ADAL 0x0000008000000000LL // 39
429 #define PLAYER_TITLE_VENGEFUL_GLADIATOR 0x0000010000000000LL // 40
431 // used in PLAYER_FIELD_BYTES values
432 enum PlayerFieldByteFlags
434 PLAYER_FIELD_BYTE_TRACK_STEALTHED
= 0x00000002,
435 PLAYER_FIELD_BYTE_RELEASE_TIMER
= 0x00000008, // Display time till auto release spirit
436 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW
= 0x00000010 // Display no "release spirit" window at all
439 // used in PLAYER_FIELD_BYTES2 values
440 enum PlayerFieldByte2Flags
442 PLAYER_FIELD_BYTE2_NONE
= 0x0000,
443 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
= 0x4000
446 enum ActivateTaxiReplies
449 ERR_TAXIUNSPECIFIEDSERVERERROR
= 1,
450 ERR_TAXINOSUCHPATH
= 2,
451 ERR_TAXINOTENOUGHMONEY
= 3,
452 ERR_TAXITOOFARAWAY
= 4,
453 ERR_TAXINOVENDORNEARBY
= 5,
454 ERR_TAXINOTVISITED
= 6,
455 ERR_TAXIPLAYERBUSY
= 7,
456 ERR_TAXIPLAYERALREADYMOUNTED
= 8,
457 ERR_TAXIPLAYERSHAPESHIFTED
= 9,
458 ERR_TAXIPLAYERMOVING
= 10,
459 ERR_TAXISAMENODE
= 11,
460 ERR_TAXINOTSTANDING
= 12
472 #define DISABLED_MIRROR_TIMER -1
475 enum PlayerExtraFlags
478 PLAYER_EXTRA_GM_ON
= 0x0001,
479 PLAYER_EXTRA_GM_ACCEPT_TICKETS
= 0x0002,
480 PLAYER_EXTRA_ACCEPT_WHISPERS
= 0x0004,
481 PLAYER_EXTRA_TAXICHEAT
= 0x0008,
482 PLAYER_EXTRA_GM_INVISIBLE
= 0x0010,
483 PLAYER_EXTRA_GM_CHAT
= 0x0020, // Show GM badge in chat messages
486 PLAYER_EXTRA_PVP_DEATH
= 0x0100 // store PvP death status until corpse creating.
494 AT_LOGIN_RESET_SPELLS
= 2,
495 AT_LOGIN_RESET_TALENTS
= 4,
496 AT_LOGIN_CUSTOMIZE
= 8
499 typedef std::map
<uint32
, QuestStatusData
> QuestStatusMap
;
501 enum QuestSlotOffsets
504 QUEST_STATE_OFFSET
= 1,
505 QUEST_COUNTS_OFFSET
= 2,
506 QUEST_TIME_OFFSET
= 3
509 #define MAX_QUEST_OFFSET 4
511 enum QuestSlotStateMask
513 QUEST_STATE_NONE
= 0x0000,
514 QUEST_STATE_COMPLETE
= 0x0001,
515 QUEST_STATE_FAIL
= 0x0002
525 // first slot for item stored (in any way in player m_items data)
526 PLAYER_SLOT_START
= 0,
527 // last+1 slot for item stored (in any way in player m_items data)
528 PLAYER_SLOT_END
= 150,
529 PLAYER_SLOTS_COUNT
= (PLAYER_SLOT_END
- PLAYER_SLOT_START
)
532 #define INVENTORY_SLOT_BAG_0 255
534 enum EquipmentSlots
// 19 slots
536 EQUIPMENT_SLOT_START
= 0,
537 EQUIPMENT_SLOT_HEAD
= 0,
538 EQUIPMENT_SLOT_NECK
= 1,
539 EQUIPMENT_SLOT_SHOULDERS
= 2,
540 EQUIPMENT_SLOT_BODY
= 3,
541 EQUIPMENT_SLOT_CHEST
= 4,
542 EQUIPMENT_SLOT_WAIST
= 5,
543 EQUIPMENT_SLOT_LEGS
= 6,
544 EQUIPMENT_SLOT_FEET
= 7,
545 EQUIPMENT_SLOT_WRISTS
= 8,
546 EQUIPMENT_SLOT_HANDS
= 9,
547 EQUIPMENT_SLOT_FINGER1
= 10,
548 EQUIPMENT_SLOT_FINGER2
= 11,
549 EQUIPMENT_SLOT_TRINKET1
= 12,
550 EQUIPMENT_SLOT_TRINKET2
= 13,
551 EQUIPMENT_SLOT_BACK
= 14,
552 EQUIPMENT_SLOT_MAINHAND
= 15,
553 EQUIPMENT_SLOT_OFFHAND
= 16,
554 EQUIPMENT_SLOT_RANGED
= 17,
555 EQUIPMENT_SLOT_TABARD
= 18,
556 EQUIPMENT_SLOT_END
= 19
559 enum InventorySlots
// 4 slots
561 INVENTORY_SLOT_BAG_START
= 19,
562 INVENTORY_SLOT_BAG_END
= 23
565 enum InventoryPackSlots
// 16 slots
567 INVENTORY_SLOT_ITEM_START
= 23,
568 INVENTORY_SLOT_ITEM_END
= 39
571 enum BankItemSlots
// 28 slots
573 BANK_SLOT_ITEM_START
= 39,
574 BANK_SLOT_ITEM_END
= 67
577 enum BankBagSlots
// 7 slots
579 BANK_SLOT_BAG_START
= 67,
580 BANK_SLOT_BAG_END
= 74
583 enum BuyBackSlots
// 12 slots
585 // stored in m_buybackitems
586 BUYBACK_SLOT_START
= 74,
587 BUYBACK_SLOT_END
= 86
590 enum KeyRingSlots
// 32 slots
592 KEYRING_SLOT_START
= 86,
593 KEYRING_SLOT_END
= 118
596 enum CurrencyTokenSlots
// 32 slots
598 CURRENCYTOKEN_SLOT_START
= 118,
599 CURRENCYTOKEN_SLOT_END
= 150
602 enum EquipmentSetUpdateState
604 EQUIPMENT_SET_UNCHANGED
= 0,
605 EQUIPMENT_SET_CHANGED
= 1,
606 EQUIPMENT_SET_NEW
= 2,
607 EQUIPMENT_SET_DELETED
= 3
612 EquipmentSet() : Guid(0), state(EQUIPMENT_SET_NEW
)
614 for(int i
= 0; i
< EQUIPMENT_SLOT_END
; ++i
)
620 std::string IconName
;
621 uint32 Items
[EQUIPMENT_SLOT_END
];
622 EquipmentSetUpdateState state
;
625 #define MAX_EQUIPMENT_SET_INDEX 10 // client limit
627 typedef std::map
<uint32
, EquipmentSet
> EquipmentSets
;
631 ItemPosCount(uint16 _pos
, uint32 _count
) : pos(_pos
), count(_count
) {}
632 bool isContainedIn(std::vector
<ItemPosCount
> const& vec
) const;
636 typedef std::vector
<ItemPosCount
> ItemPosCountVec
;
640 TRADE_SLOT_COUNT
= 7,
641 TRADE_SLOT_TRADED_COUNT
= 6,
642 TRADE_SLOT_NONTRADED
= 6
645 enum TransferAbortReason
647 TRANSFER_ABORT_NONE
= 0x00,
648 TRANSFER_ABORT_ERROR
= 0x01,
649 TRANSFER_ABORT_MAX_PLAYERS
= 0x02, // Transfer Aborted: instance is full
650 TRANSFER_ABORT_NOT_FOUND
= 0x03, // Transfer Aborted: instance not found
651 TRANSFER_ABORT_TOO_MANY_INSTANCES
= 0x04, // You have entered too many instances recently.
652 TRANSFER_ABORT_ZONE_IN_COMBAT
= 0x06, // Unable to zone in while an encounter is in progress.
653 TRANSFER_ABORT_INSUF_EXPAN_LVL
= 0x07, // You must have <TBC,WotLK> expansion installed to access this area.
654 TRANSFER_ABORT_DIFFICULTY
= 0x08, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
655 TRANSFER_ABORT_UNIQUE_MESSAGE
= 0x09, // Until you've escaped TLK's grasp, you cannot leave this place!
656 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES
= 0x0A, // Additional instances cannot be launched, please try again later.
657 TRANSFER_ABORT_NEED_GROUP
= 0x0B, // 3.1
658 TRANSFER_ABORT_NOT_FOUND2
= 0x0C, // 3.1
659 TRANSFER_ABORT_NOT_FOUND3
= 0x0D, // 3.1
662 enum InstanceResetWarningType
664 RAID_INSTANCE_WARNING_HOURS
= 1, // WARNING! %s is scheduled to reset in %d hour(s).
665 RAID_INSTANCE_WARNING_MIN
= 2, // WARNING! %s is scheduled to reset in %d minute(s)!
666 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!
667 RAID_INSTANCE_WELCOME
= 4 // Welcome to %s. This raid instance is scheduled to reset in %s.
679 float t_x
, t_y
, t_z
, t_o
;
682 // swimming and unknown
687 float j_unk
, j_sinAngle
, j_cosAngle
, j_xyspeed
;
694 time
= t_time
= fallTime
= 0;
696 x
= y
= z
= o
= t_x
= t_y
= t_z
= t_o
= s_pitch
= j_unk
= j_sinAngle
= j_cosAngle
= j_xyspeed
= u_unk1
= 0.0f
;
700 uint32
GetMovementFlags() { return flags
; }
701 void AddMovementFlag(uint32 flag
) { flags
|= flag
; }
702 bool HasMovementFlag(uint32 flag
) const { return flags
& flag
; }
705 // flags that use in movement check for example at spell casting
706 MovementFlags
const movementFlagsMask
= MovementFlags(
707 MOVEMENTFLAG_FORWARD
|MOVEMENTFLAG_BACKWARD
|MOVEMENTFLAG_STRAFE_LEFT
|MOVEMENTFLAG_STRAFE_RIGHT
|
708 MOVEMENTFLAG_PITCH_UP
|MOVEMENTFLAG_PITCH_DOWN
|MOVEMENTFLAG_FLY_UNK1
|
709 MOVEMENTFLAG_JUMPING
|MOVEMENTFLAG_FALLING
|MOVEMENTFLAG_FLY_UP
|
710 MOVEMENTFLAG_FLYING
|MOVEMENTFLAG_SPLINE
713 MovementFlags
const movementOrTurningFlagsMask
= MovementFlags(
714 movementFlagsMask
| MOVEMENTFLAG_LEFT
| MOVEMENTFLAG_RIGHT
721 REST_TYPE_IN_TAVERN
= 1,
722 REST_TYPE_IN_CITY
= 2
725 enum DuelCompleteType
732 enum TeleportToOptions
734 TELE_TO_GM_MODE
= 0x01,
735 TELE_TO_NOT_LEAVE_TRANSPORT
= 0x02,
736 TELE_TO_NOT_LEAVE_COMBAT
= 0x04,
737 TELE_TO_NOT_UNSUMMON_PET
= 0x08,
738 TELE_TO_SPELL
= 0x10,
741 /// Type of environmental damages
742 enum EnviromentalDamage
744 DAMAGE_EXHAUSTED
= 0,
750 DAMAGE_FALL_TO_VOID
= 6 // custom case for fall without durability loss
753 // used at player loading query list preparing, and later result selection
754 enum PlayerLoginQueryIndex
756 PLAYER_LOGIN_QUERY_LOADFROM
= 0,
757 PLAYER_LOGIN_QUERY_LOADGROUP
= 1,
758 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES
= 2,
759 PLAYER_LOGIN_QUERY_LOADAURAS
= 3,
760 PLAYER_LOGIN_QUERY_LOADSPELLS
= 4,
761 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS
= 5,
762 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS
= 6,
763 PLAYER_LOGIN_QUERY_LOADREPUTATION
= 7,
764 PLAYER_LOGIN_QUERY_LOADINVENTORY
= 8,
765 PLAYER_LOGIN_QUERY_LOADACTIONS
= 9,
766 PLAYER_LOGIN_QUERY_LOADMAILCOUNT
= 10,
767 PLAYER_LOGIN_QUERY_LOADMAILDATE
= 11,
768 PLAYER_LOGIN_QUERY_LOADSOCIALLIST
= 12,
769 PLAYER_LOGIN_QUERY_LOADHOMEBIND
= 13,
770 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS
= 14,
771 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES
= 15,
772 PLAYER_LOGIN_QUERY_LOADGUILD
= 16,
773 PLAYER_LOGIN_QUERY_LOADARENAINFO
= 17,
774 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS
= 18,
775 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS
= 19,
776 PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS
= 20,
777 MAX_PLAYER_LOGIN_QUERY
= 21
780 // Player summoning auto-decline time (in secs)
781 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
782 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
784 struct InstancePlayerBind
788 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
789 that aren't already permanently bound when they are inside when a boss is killed
790 or when they enter an instance that the group leader is permanently bound to. */
791 InstancePlayerBind() : save(NULL
), perm(false) {}
794 class MANGOS_DLL_SPEC PlayerTaxi
800 void InitTaxiNodesForLevel(uint32 race
, uint32 chrClass
, uint32 level
);
801 void LoadTaxiMask(const char* data
);
803 bool IsTaximaskNodeKnown(uint32 nodeidx
) const
805 uint8 field
= uint8((nodeidx
- 1) / 32);
806 uint32 submask
= 1<<((nodeidx
-1)%32);
807 return (m_taximask
[field
] & submask
) == submask
;
809 bool SetTaximaskNode(uint32 nodeidx
)
811 uint8 field
= uint8((nodeidx
- 1) / 32);
812 uint32 submask
= 1<<((nodeidx
-1)%32);
813 if ((m_taximask
[field
] & submask
) != submask
)
815 m_taximask
[field
] |= submask
;
821 void AppendTaximaskTo(ByteBuffer
& data
,bool all
);
824 bool LoadTaxiDestinationsFromString(const std::string
& values
, uint32 team
);
825 std::string
SaveTaxiDestinationsToString();
827 void ClearTaxiDestinations() { m_TaxiDestinations
.clear(); }
828 void AddTaxiDestination(uint32 dest
) { m_TaxiDestinations
.push_back(dest
); }
829 uint32
GetTaxiSource() const { return m_TaxiDestinations
.empty() ? 0 : m_TaxiDestinations
.front(); }
830 uint32
GetTaxiDestination() const { return m_TaxiDestinations
.size() < 2 ? 0 : m_TaxiDestinations
[1]; }
831 uint32
GetCurrentTaxiPath() const;
832 uint32
NextTaxiDestination()
834 m_TaxiDestinations
.pop_front();
835 return GetTaxiDestination();
837 bool empty() const { return m_TaxiDestinations
.empty(); }
839 friend std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
842 std::deque
<uint32
> m_TaxiDestinations
;
845 std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
847 class MANGOS_DLL_SPEC Player
: public Unit
849 friend class WorldSession
;
850 friend void Item::AddToUpdateQueueOf(Player
*player
);
851 friend void Item::RemoveFromUpdateQueueOf(Player
*player
);
853 explicit Player (WorldSession
*session
);
856 void CleanupsBeforeDelete();
858 static UpdateMask updateVisualBits
;
859 static void InitVisibleBits();
862 void RemoveFromWorld();
864 bool TeleportTo(uint32 mapid
, float x
, float y
, float z
, float orientation
, uint32 options
= 0);
866 bool TeleportTo(WorldLocation
const &loc
, uint32 options
= 0)
868 return TeleportTo(loc
.mapid
, loc
.x
, loc
.y
, loc
.z
, options
);
871 void SetSummonPoint(uint32 mapid
, float x
, float y
, float z
)
873 m_summon_expire
= time(NULL
) + MAX_PLAYER_SUMMON_DELAY
;
874 m_summon_mapid
= mapid
;
879 void SummonIfPossible(bool agree
);
881 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
);
883 void Update( uint32 time
);
885 void BuildEnumData( QueryResult
* result
, WorldPacket
* p_data
);
887 void SetInWater(bool apply
);
889 bool IsInWater() const { return m_isInWater
; }
890 bool IsUnderWater() const;
892 void SendInitialPacketsBeforeAddToMap();
893 void SendInitialPacketsAfterAddToMap();
894 void SendTransferAborted(uint32 mapid
, uint8 reason
, uint8 arg
= 0);
895 void SendInstanceResetWarning(uint32 mapid
, uint32 time
);
897 Creature
* GetNPCIfCanInteractWith(uint64 guid
, uint32 npcflagmask
);
898 bool CanInteractWithNPCs(bool alive
= true) const;
899 GameObject
* GetGameObjectIfCanInteractWith(uint64 guid
, GameobjectTypes type
) const;
903 bool isAFK() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_AFK
); };
904 bool isDND() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_DND
); };
905 uint8
chatTag() const;
909 uint32
GetBarberShopCost(uint8 newhairstyle
, uint8 newhaircolor
, uint8 newfacialhair
);
911 PlayerSocial
*GetSocial() { return m_social
; }
914 void InitTaxiNodesForLevel() { m_taxi
.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
915 bool ActivateTaxiPathTo(std::vector
<uint32
> const& nodes
, Creature
* npc
= NULL
, uint32 spellid
= 0);
916 bool ActivateTaxiPathTo(uint32 taxi_path_id
, uint32 spellid
= 0);
917 // mount_id can be used in scripting calls
918 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_ACCEPT_TICKETS
); }
919 void SetAcceptTicket(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_ACCEPT_TICKETS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS
; }
920 bool isAcceptWhispers() const { return m_ExtraFlags
& PLAYER_EXTRA_ACCEPT_WHISPERS
; }
921 void SetAcceptWhispers(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_ACCEPT_WHISPERS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_ACCEPT_WHISPERS
; }
922 bool isGameMaster() const { return m_ExtraFlags
& PLAYER_EXTRA_GM_ON
; }
923 void SetGameMaster(bool on
);
924 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_CHAT
); }
925 void SetGMChat(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_CHAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_CHAT
; }
926 bool isTaxiCheater() const { return m_ExtraFlags
& PLAYER_EXTRA_TAXICHEAT
; }
927 void SetTaxiCheater(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_TAXICHEAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_TAXICHEAT
; }
928 bool isGMVisible() const { return !(m_ExtraFlags
& PLAYER_EXTRA_GM_INVISIBLE
); }
929 void SetGMVisible(bool on
);
930 void SetPvPDeath(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_PVP_DEATH
; else m_ExtraFlags
&= ~PLAYER_EXTRA_PVP_DEATH
; }
932 void GiveXP(uint32 xp
, Unit
* victim
);
933 void GiveLevel(uint32 level
);
934 void InitStatsForLevel(bool reapplyMods
= false);
939 uint32 m_Played_time
[2];
940 uint32
GetTotalPlayedTime() { return m_Played_time
[0]; };
941 uint32
GetLevelPlayedTime() { return m_Played_time
[1]; };
943 void setDeathState(DeathState s
); // overwrite Unit::setDeathState
945 void InnEnter (int time
,uint32 mapid
, float x
,float y
,float z
)
947 inn_pos_mapid
= mapid
;
951 time_inn_enter
= time
;
954 float GetRestBonus() const { return m_rest_bonus
; };
955 void SetRestBonus(float rest_bonus_new
);
957 RestType
GetRestType() const { return rest_type
; };
958 void SetRestType(RestType n_r_type
) { rest_type
= n_r_type
; };
960 uint32
GetInnPosMapId() const { return inn_pos_mapid
; };
961 float GetInnPosX() const { return inn_pos_x
; };
962 float GetInnPosY() const { return inn_pos_y
; };
963 float GetInnPosZ() const { return inn_pos_z
; };
965 int GetTimeInnEnter() const { return time_inn_enter
; };
966 void UpdateInnerTime (int time
) { time_inn_enter
= time
; };
968 void RemovePet(Pet
* pet
, PetSaveMode mode
, bool returnreagent
= false);
969 void RemoveMiniPet();
971 void SetMiniPet(Pet
* pet
) { m_miniPet
= pet
->GetGUID(); }
972 void RemoveGuardians();
973 bool HasGuardianWithEntry(uint32 entry
);
974 void AddGuardian(Pet
* pet
) { m_guardianPets
.insert(pet
->GetGUID()); }
975 GuardianPetList
const& GetGuardians() const { return m_guardianPets
; }
977 uint32
GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
979 void Say(const std::string
& text
, const uint32 language
);
980 void Yell(const std::string
& text
, const uint32 language
);
981 void TextEmote(const std::string
& text
);
982 void Whisper(const std::string
& text
, const uint32 language
,uint64 receiver
);
983 void BuildPlayerChat(WorldPacket
*data
, uint8 msgtype
, const std::string
& text
, uint32 language
) const;
985 /*********************************************************/
986 /*** STORAGE SYSTEM ***/
987 /*********************************************************/
989 void SetVirtualItemSlot( uint8 i
, Item
* item
);
990 void SetSheath( uint32 sheathed
);
991 uint8
FindEquipSlot( ItemPrototype
const* proto
, uint32 slot
, bool swap
) const;
992 uint32
GetItemCount( uint32 item
, bool inBankAlso
= false, Item
* skipItem
= NULL
) const;
993 Item
* GetItemByGuid( uint64 guid
) const;
994 Item
* GetItemByPos( uint16 pos
) const;
995 Item
* GetItemByPos( uint8 bag
, uint8 slot
) const;
996 Item
* GetWeaponForAttack(WeaponAttackType attackType
, bool useable
= false) const;
997 Item
* GetShield(bool useable
= false) const;
998 static uint32
GetAttackBySlot( uint8 slot
); // MAX_ATTACK if not weapon slot
999 std::vector
<Item
*> &GetItemUpdateQueue() { return m_itemUpdateQueue
; }
1000 static bool IsInventoryPos( uint16 pos
) { return IsInventoryPos(pos
>> 8,pos
& 255); }
1001 static bool IsInventoryPos( uint8 bag
, uint8 slot
);
1002 static bool IsEquipmentPos( uint16 pos
) { return IsEquipmentPos(pos
>> 8,pos
& 255); }
1003 static bool IsEquipmentPos( uint8 bag
, uint8 slot
);
1004 static bool IsBagPos( uint16 pos
);
1005 static bool IsBankPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1006 static bool IsBankPos( uint8 bag
, uint8 slot
);
1007 bool IsValidPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1008 bool IsValidPos( uint8 bag
, uint8 slot
);
1009 bool HasBankBagSlot( uint8 slot
) const;
1010 bool HasItemCount( uint32 item
, uint32 count
, bool inBankAlso
= false ) const;
1011 bool HasItemFitToSpellReqirements(SpellEntry
const* spellInfo
, Item
const* ignoreItem
= NULL
);
1012 bool CanNoReagentCast(SpellEntry
const* spellInfo
) const;
1013 bool HasItemOrGemWithIdEquipped( uint32 item
, uint32 count
, uint8 except_slot
= NULL_SLOT
) const;
1014 bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory
, uint32 count
, uint8 except_slot
= NULL_SLOT
) const;
1015 uint8
CanTakeMoreSimilarItems(Item
* pItem
) const { return _CanTakeMoreSimilarItems(pItem
->GetEntry(),pItem
->GetCount(),pItem
); }
1016 uint8
CanTakeMoreSimilarItems(uint32 entry
, uint32 count
) const { return _CanTakeMoreSimilarItems(entry
,count
,NULL
); }
1017 uint8
CanStoreNewItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 item
, uint32 count
, uint32
* no_space_count
= NULL
) const
1019 return _CanStoreItem(bag
, slot
, dest
, item
, count
, NULL
, false, no_space_count
);
1021 uint8
CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
= false ) const
1024 return EQUIP_ERR_ITEM_NOT_FOUND
;
1025 uint32 count
= pItem
->GetCount();
1026 return _CanStoreItem( bag
, slot
, dest
, pItem
->GetEntry(), count
, pItem
, swap
, NULL
);
1029 uint8
CanStoreItems( Item
**pItem
,int count
) const;
1030 uint8
CanEquipNewItem( uint8 slot
, uint16
&dest
, uint32 item
, bool swap
) const;
1031 uint8
CanEquipItem( uint8 slot
, uint16
&dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1033 uint8
CanEquipUniqueItem( Item
* pItem
, uint8 except_slot
= NULL_SLOT
, uint32 limit_count
= 1 ) const;
1034 uint8
CanEquipUniqueItem( ItemPrototype
const* itemProto
, uint8 except_slot
= NULL_SLOT
, uint32 limit_count
= 1 ) const;
1035 uint8
CanUnequipItems( uint32 item
, uint32 count
) const;
1036 uint8
CanUnequipItem( uint16 src
, bool swap
) const;
1037 uint8
CanBankItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1038 uint8
CanUseItem( Item
*pItem
, bool not_loading
= true ) const;
1039 bool HasItemTotemCategory( uint32 TotemCategory
) const;
1040 bool CanUseItem( ItemPrototype
const *pItem
);
1041 uint8
CanUseAmmo( uint32 item
) const;
1042 Item
* StoreNewItem( ItemPosCountVec
const& pos
, uint32 item
, bool update
,int32 randomPropertyId
= 0 );
1043 Item
* StoreItem( ItemPosCountVec
const& pos
, Item
*pItem
, bool update
);
1044 Item
* EquipNewItem( uint16 pos
, uint32 item
, bool update
);
1045 Item
* EquipItem( uint16 pos
, Item
*pItem
, bool update
);
1046 void AutoUnequipOffhandIfNeed();
1047 bool StoreNewItemInBestSlots(uint32 item_id
, uint32 item_count
);
1048 void AutoStoreLoot(uint8 bag
, uint8 slot
, uint32 loot_id
, LootStore
const& store
, bool broadcast
= false);
1049 void AutoStoreLoot(uint32 loot_id
, LootStore
const& store
, bool broadcast
= false) { AutoStoreLoot(NULL_BAG
,NULL_SLOT
,loot_id
,store
,broadcast
); }
1051 uint8
_CanTakeMoreSimilarItems(uint32 entry
, uint32 count
, Item
* pItem
, uint32
* no_space_count
= NULL
) const;
1052 uint8
_CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 entry
, uint32 count
, Item
*pItem
= NULL
, bool swap
= false, uint32
* no_space_count
= NULL
) const;
1054 void ApplyEquipCooldown( Item
* pItem
);
1055 void SetAmmo( uint32 item
);
1057 float GetAmmoDPS() const { return m_ammoDPS
; }
1058 bool CheckAmmoCompatibility(const ItemPrototype
*ammo_proto
) const;
1059 void QuickEquipItem( uint16 pos
, Item
*pItem
);
1060 void VisualizeItem( uint8 slot
, Item
*pItem
);
1061 void SetVisibleItemSlot(uint8 slot
, Item
*pItem
);
1062 Item
* BankItem( ItemPosCountVec
const& dest
, Item
*pItem
, bool update
)
1064 return StoreItem( dest
, pItem
, update
);
1066 Item
* BankItem( uint16 pos
, Item
*pItem
, bool update
);
1067 void RemoveItem( uint8 bag
, uint8 slot
, bool update
);
1068 void MoveItemFromInventory(uint8 bag
, uint8 slot
, bool update
);
1069 // in trade, auction, guild bank, mail....
1070 void MoveItemToInventory(ItemPosCountVec
const& dest
, Item
* pItem
, bool update
, bool in_characterInventoryDB
= false);
1071 // in trade, guild bank, mail....
1072 void RemoveItemDependentAurasAndCasts( Item
* pItem
);
1073 void DestroyItem( uint8 bag
, uint8 slot
, bool update
);
1074 void DestroyItemCount( uint32 item
, uint32 count
, bool update
, bool unequip_check
= false);
1075 void DestroyItemCount( Item
* item
, uint32
& count
, bool update
);
1076 void DestroyConjuredItems( bool update
);
1077 void DestroyZoneLimitedItem( bool update
, uint32 new_zone
);
1078 void SplitItem( uint16 src
, uint16 dst
, uint32 count
);
1079 void SwapItem( uint16 src
, uint16 dst
);
1080 void AddItemToBuyBackSlot( Item
*pItem
);
1081 Item
* GetItemFromBuyBackSlot( uint32 slot
);
1082 void RemoveItemFromBuyBackSlot( uint32 slot
, bool del
);
1083 uint32
GetMaxKeyringSize() const { return KEYRING_SLOT_END
-KEYRING_SLOT_START
; }
1084 void SendEquipError( uint8 msg
, Item
* pItem
, Item
*pItem2
);
1085 void SendBuyError( uint8 msg
, Creature
* pCreature
, uint32 item
, uint32 param
);
1086 void SendSellError( uint8 msg
, Creature
* pCreature
, uint64 guid
, uint32 param
);
1087 void AddWeaponProficiency(uint32 newflag
) { m_WeaponProficiency
|= newflag
; }
1088 void AddArmorProficiency(uint32 newflag
) { m_ArmorProficiency
|= newflag
; }
1089 uint32
GetWeaponProficiency() const { return m_WeaponProficiency
; }
1090 uint32
GetArmorProficiency() const { return m_ArmorProficiency
; }
1091 bool IsUseEquipedWeapon( bool mainhand
) const
1093 // disarm applied only to mainhand weapon
1094 return !IsInFeralForm() && (!mainhand
|| !HasFlag(UNIT_FIELD_FLAGS
,UNIT_FLAG_DISARMED
) );
1096 bool IsTwoHandUsed() const
1098 Item
* mainItem
= GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_MAINHAND
);
1099 return mainItem
&& mainItem
->GetProto()->InventoryType
== INVTYPE_2HWEAPON
&& !CanTitanGrip();
1101 void SendNewItem( Item
*item
, uint32 count
, bool received
, bool created
, bool broadcast
= false );
1102 bool BuyItemFromVendor(uint64 vendorguid
, uint32 item
, uint8 count
, uint64 bagguid
, uint8 slot
);
1104 float GetReputationPriceDiscount( Creature
const* pCreature
) const;
1105 Player
* GetTrader() const { return pTrader
; }
1107 void TradeCancel(bool sendback
);
1108 uint16
GetItemPosByTradeSlot(uint32 slot
) const { return tradeItems
[slot
]; }
1110 void UpdateEnchantTime(uint32 time
);
1111 void UpdateItemDuration(uint32 time
, bool realtimeonly
=false);
1112 void AddEnchantmentDurations(Item
*item
);
1113 void RemoveEnchantmentDurations(Item
*item
);
1114 void RemoveAllEnchantments(EnchantmentSlot slot
);
1115 void AddEnchantmentDuration(Item
*item
,EnchantmentSlot slot
,uint32 duration
);
1116 void ApplyEnchantment(Item
*item
,EnchantmentSlot slot
,bool apply
, bool apply_dur
= true, bool ignore_condition
= false);
1117 void ApplyEnchantment(Item
*item
,bool apply
);
1118 void SendEnchantmentDurations();
1119 void BuildEnchantmentsInfoData(WorldPacket
*data
);
1120 void AddItemDurations(Item
*item
);
1121 void RemoveItemDurations(Item
*item
);
1122 void SendItemDurations();
1126 uint32 m_stableSlots
;
1128 /*********************************************************/
1129 /*** QUEST SYSTEM ***/
1130 /*********************************************************/
1132 uint32
GetQuestLevel( Quest
const* pQuest
) const { return pQuest
&& pQuest
->GetQuestLevel() ? pQuest
->GetQuestLevel() : getLevel(); }
1134 void PrepareQuestMenu( uint64 guid
);
1135 void SendPreparedQuest( uint64 guid
);
1136 bool IsActiveQuest( uint32 quest_id
) const;
1137 Quest
const *GetNextQuest( uint64 guid
, Quest
const *pQuest
);
1138 bool CanSeeStartQuest( Quest
const *pQuest
);
1139 bool CanTakeQuest( Quest
const *pQuest
, bool msg
);
1140 bool CanAddQuest( Quest
const *pQuest
, bool msg
);
1141 bool CanCompleteQuest( uint32 quest_id
);
1142 bool CanCompleteRepeatableQuest(Quest
const *pQuest
);
1143 bool CanRewardQuest( Quest
const *pQuest
, bool msg
);
1144 bool CanRewardQuest( Quest
const *pQuest
, uint32 reward
, bool msg
);
1145 void AddQuest( Quest
const *pQuest
, Object
*questGiver
);
1146 void CompleteQuest( uint32 quest_id
);
1147 void IncompleteQuest( uint32 quest_id
);
1148 void RewardQuest( Quest
const *pQuest
, uint32 reward
, Object
* questGiver
, bool announce
= true );
1149 void FailQuest( uint32 quest_id
);
1150 void FailTimedQuest( uint32 quest_id
);
1151 bool SatisfyQuestSkillOrClass( Quest
const* qInfo
, bool msg
);
1152 bool SatisfyQuestLevel( Quest
const* qInfo
, bool msg
);
1153 bool SatisfyQuestLog( bool msg
);
1154 bool SatisfyQuestPreviousQuest( Quest
const* qInfo
, bool msg
);
1155 bool SatisfyQuestRace( Quest
const* qInfo
, bool msg
);
1156 bool SatisfyQuestReputation( Quest
const* qInfo
, bool msg
);
1157 bool SatisfyQuestStatus( Quest
const* qInfo
, bool msg
);
1158 bool SatisfyQuestTimed( Quest
const* qInfo
, bool msg
);
1159 bool SatisfyQuestExclusiveGroup( Quest
const* qInfo
, bool msg
);
1160 bool SatisfyQuestNextChain( Quest
const* qInfo
, bool msg
);
1161 bool SatisfyQuestPrevChain( Quest
const* qInfo
, bool msg
);
1162 bool SatisfyQuestDay( Quest
const* qInfo
, bool msg
);
1163 bool GiveQuestSourceItem( Quest
const *pQuest
);
1164 bool TakeQuestSourceItem( uint32 quest_id
, bool msg
);
1165 bool GetQuestRewardStatus( uint32 quest_id
) const;
1166 QuestStatus
GetQuestStatus( uint32 quest_id
) const;
1167 void SetQuestStatus( uint32 quest_id
, QuestStatus status
);
1169 void SetDailyQuestStatus( uint32 quest_id
);
1170 void ResetDailyQuestStatus();
1172 uint16
FindQuestSlot( uint32 quest_id
) const;
1173 uint32
GetQuestSlotQuestId(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
); }
1174 uint32
GetQuestSlotState(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
); }
1175 uint32
GetQuestSlotCounters(uint16 slot
)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
); }
1176 uint8
GetQuestSlotCounter(uint16 slot
,uint8 counter
) const { return GetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
); }
1177 uint32
GetQuestSlotTime(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
); }
1178 void SetQuestSlot(uint16 slot
,uint32 quest_id
, uint32 timer
= 0)
1180 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
,quest_id
);
1181 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,0);
1182 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,0);
1183 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
);
1185 void SetQuestSlotCounter(uint16 slot
,uint8 counter
,uint8 count
) { SetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
,count
); }
1186 void SetQuestSlotState(uint16 slot
,uint32 state
) { SetFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1187 void RemoveQuestSlotState(uint16 slot
,uint32 state
) { RemoveFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1188 void SetQuestSlotTimer(uint16 slot
,uint32 timer
) { SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
); }
1189 void SwapQuestSlot(uint16 slot1
,uint16 slot2
)
1191 for (int i
= 0; i
< MAX_QUEST_OFFSET
; ++i
)
1193 uint32 temp1
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
);
1194 uint32 temp2
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
);
1196 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
, temp2
);
1197 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
, temp1
);
1200 uint32
GetReqKillOrCastCurrentCount(uint32 quest_id
, int32 entry
);
1201 void AreaExploredOrEventHappens( uint32 questId
);
1202 void GroupEventHappens( uint32 questId
, WorldObject
const* pEventObject
);
1203 void ItemAddedQuestCheck( uint32 entry
, uint32 count
);
1204 void ItemRemovedQuestCheck( uint32 entry
, uint32 count
);
1205 void KilledMonster( uint32 entry
, uint64 guid
);
1206 void CastedCreatureOrGO( uint32 entry
, uint64 guid
, uint32 spell_id
);
1207 void TalkedToCreature( uint32 entry
, uint64 guid
);
1208 void MoneyChanged( uint32 value
);
1209 void ReputationChanged(FactionEntry
const* factionEntry
);
1210 bool HasQuestForItem( uint32 itemid
) const;
1211 bool HasQuestForGO(int32 GOId
) const;
1212 void UpdateForQuestWorldObjects();
1213 bool CanShareQuest(uint32 quest_id
) const;
1215 void SendQuestComplete( uint32 quest_id
);
1216 void SendQuestReward( Quest
const *pQuest
, uint32 XP
, Object
* questGiver
);
1217 void SendQuestFailed( uint32 quest_id
);
1218 void SendQuestTimerFailed( uint32 quest_id
);
1219 void SendCanTakeQuestResponse( uint32 msg
);
1220 void SendPushToPartyResponse( Player
*pPlayer
, uint32 msg
);
1221 void SendQuestUpdateAddItem( Quest
const* pQuest
, uint32 item_idx
, uint32 count
);
1222 void SendQuestUpdateAddCreatureOrGo( Quest
const* pQuest
, uint64 guid
, uint32 creatureOrGO_idx
, uint32 old_count
, uint32 add_count
);
1224 uint64
GetDivider() { return m_divider
; };
1225 void SetDivider( uint64 guid
) { m_divider
= guid
; };
1227 uint32
GetInGameTime() { return m_ingametime
; };
1229 void SetInGameTime( uint32 time
) { m_ingametime
= time
; };
1231 void AddTimedQuest( uint32 quest_id
) { m_timedquests
.insert(quest_id
); }
1233 /*********************************************************/
1234 /*** LOAD SYSTEM ***/
1235 /*********************************************************/
1237 bool LoadFromDB(uint32 guid
, SqlQueryHolder
*holder
);
1239 bool MinimalLoadFromDB(QueryResult
*result
, uint32 guid
);
1240 static bool LoadValuesArrayFromDB(Tokens
& data
,uint64 guid
);
1241 static uint32
GetUInt32ValueFromArray(Tokens
const& data
, uint16 index
);
1242 static float GetFloatValueFromArray(Tokens
const& data
, uint16 index
);
1243 static uint32
GetUInt32ValueFromDB(uint16 index
, uint64 guid
);
1244 static float GetFloatValueFromDB(uint16 index
, uint64 guid
);
1245 static uint32
GetZoneIdFromDB(uint64 guid
);
1246 static bool LoadPositionFromDB(uint32
& mapid
, float& x
,float& y
,float& z
,float& o
, bool& in_flight
, uint64 guid
);
1248 /*********************************************************/
1249 /*** SAVE SYSTEM ***/
1250 /*********************************************************/
1253 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1254 void SaveDataFieldToDB();
1255 static bool SaveValuesArrayInDB(Tokens
const& data
,uint64 guid
);
1256 static void SetUInt32ValueInArray(Tokens
& data
,uint16 index
, uint32 value
);
1257 static void SetFloatValueInArray(Tokens
& data
,uint16 index
, float value
);
1258 static void SetUInt32ValueInDB(uint16 index
, uint32 value
, uint64 guid
);
1259 static void SetFloatValueInDB(uint16 index
, float value
, uint64 guid
);
1260 static void Customize(uint64 guid
, uint8 gender
, uint8 skin
, uint8 face
, uint8 hairStyle
, uint8 hairColor
, uint8 facialHair
);
1261 static void SavePositionInDB(uint32 mapid
, float x
,float y
,float z
,float o
,uint32 zone
,uint64 guid
);
1264 bool m_mailsUpdated
;
1266 void SetBindPoint(uint64 guid
);
1267 void SendTalentWipeConfirm(uint64 guid
);
1268 void RewardRage( uint32 damage
, uint32 weaponSpeedHitFactor
, bool attacker
);
1269 void SendPetSkillWipeConfirm();
1270 void CalcRage( uint32 damage
,bool attacker
);
1271 void RegenerateAll();
1272 void Regenerate(Powers power
);
1273 void RegenerateHealth();
1274 void setRegenTimer(uint32 time
) {m_regenTimer
= time
;}
1275 void setWeaponChangeTimer(uint32 time
) {m_weaponChangeTimer
= time
;}
1277 uint32
GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE
); }
1278 void ModifyMoney( int32 d
)
1281 SetMoney (GetMoney() > uint32(-d
) ? GetMoney() + d
: 0);
1283 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT
- d
) ? GetMoney() + d
: MAX_MONEY_AMOUNT
);
1286 if(GetMoney() >= MAX_MONEY_AMOUNT
)
1287 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD
,NULL
,NULL
);
1289 void SetMoney( uint32 value
)
1291 SetUInt32Value (PLAYER_FIELD_COINAGE
, value
);
1292 MoneyChanged( value
);
1293 UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED
);
1296 QuestStatusMap
& getQuestStatusMap() { return mQuestStatus
; };
1298 const uint64
& GetSelection( ) const { return m_curSelection
; }
1299 void SetSelection(const uint64
&guid
) { m_curSelection
= guid
; SetUInt64Value(UNIT_FIELD_TARGET
, guid
); }
1301 uint8
GetComboPoints() { return m_comboPoints
; }
1302 const uint64
& GetComboTarget() const { return m_comboTarget
; }
1304 void AddComboPoints(Unit
* target
, int8 count
);
1305 void ClearComboPoints();
1306 void SendComboPoints();
1308 void SendMailResult(uint32 mailId
, uint32 mailAction
, uint32 mailError
, uint32 equipError
= 0, uint32 item_guid
= 0, uint32 item_count
= 0);
1310 void UpdateNextMailTimeAndUnreads();
1311 void AddNewMailDeliverTime(time_t deliver_time
);
1312 bool IsMailsLoaded() const { return m_mailsLoaded
; }
1314 //void SetMail(Mail *m);
1315 void RemoveMail(uint32 id
);
1317 void AddMail(Mail
* mail
) { m_mail
.push_front(mail
);}// for call from WorldSession::SendMailTo
1318 uint32
GetMailSize() { return m_mail
.size();};
1319 Mail
* GetMail(uint32 id
);
1321 PlayerMails::iterator
GetmailBegin() { return m_mail
.begin();};
1322 PlayerMails::iterator
GetmailEnd() { return m_mail
.end();};
1324 /*********************************************************/
1325 /*** MAILED ITEMS SYSTEM ***/
1326 /*********************************************************/
1329 time_t m_nextMailDelivereTime
;
1331 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
1333 ItemMap mMitems
; //template defined in objectmgr.cpp
1335 Item
* GetMItem(uint32 id
)
1337 ItemMap::const_iterator itr
= mMitems
.find(id
);
1338 return itr
!= mMitems
.end() ? itr
->second
: NULL
;
1341 void AddMItem(Item
* it
)
1344 //assert deleted, because items can be added before loading
1345 mMitems
[it
->GetGUIDLow()] = it
;
1348 bool RemoveMItem(uint32 id
)
1350 return mMitems
.erase(id
) ? true : false;
1353 void PetSpellInitialize();
1354 void CharmSpellInitialize();
1355 void PossessSpellInitialize();
1356 bool HasSpell(uint32 spell
) const;
1357 bool HasActiveSpell(uint32 spell
) const; // show in spellbook
1358 TrainerSpellState
GetTrainerSpellState(TrainerSpell
const* trainer_spell
) const;
1359 bool IsSpellFitByClassAndRace( uint32 spell_id
) const;
1360 bool IsNeedCastPassiveSpellAtLearn(SpellEntry
const* spellInfo
) const;
1362 void SendProficiency(uint8 pr1
, uint32 pr2
);
1363 void SendInitialSpells();
1364 bool addSpell(uint32 spell_id
, bool active
, bool learning
, bool dependent
, bool disabled
);
1365 void learnSpell(uint32 spell_id
, bool dependent
);
1366 void removeSpell(uint32 spell_id
, bool disabled
= false, bool update_action_bar_for_low_rank
= false);
1368 void learnDefaultSpells();
1369 void learnQuestRewardedSpells();
1370 void learnQuestRewardedSpells(Quest
const* quest
);
1371 void learnSpellHighRank(uint32 spellid
);
1373 uint32
GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1
); }
1374 void SetFreeTalentPoints(uint32 points
) { SetUInt32Value(PLAYER_CHARACTER_POINTS1
,points
); }
1375 bool resetTalents(bool no_cost
= false);
1376 uint32
resetTalentsCost() const;
1377 void InitTalentForLevel();
1378 void BuildPlayerTalentsInfoData(WorldPacket
*data
);
1379 void BuildPetTalentsInfoData(WorldPacket
*data
);
1380 void SendTalentsInfoData(bool pet
);
1381 void LearnTalent(uint32 talentId
, uint32 talentRank
);
1382 void LearnPetTalent(uint64 petGuid
, uint32 talentId
, uint32 talentRank
);
1384 uint32
CalculateTalentsPoints() const;
1386 void InitGlyphsForLevel();
1387 void SetGlyphSlot(uint8 slot
, uint32 slottype
) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
, slottype
); }
1388 uint32
GetGlyphSlot(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
); }
1389 void SetGlyph(uint8 slot
, uint32 glyph
) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
, glyph
); }
1390 uint32
GetGlyph(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
); }
1392 uint32
GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2
); }
1393 void SetFreePrimaryProffesions(uint16 profs
) { SetUInt32Value(PLAYER_CHARACTER_POINTS2
,profs
); }
1394 void InitPrimaryProffesions();
1396 PlayerSpellMap
const& GetSpellMap() const { return m_spells
; }
1397 PlayerSpellMap
& GetSpellMap() { return m_spells
; }
1399 void AddSpellMod(SpellModifier
* mod
, bool apply
);
1400 bool IsAffectedBySpellmod(SpellEntry
const *spellInfo
, SpellModifier
*mod
, Spell
const* spell
= NULL
);
1401 template <class T
> T
ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
= NULL
);
1402 void RemoveSpellMods(Spell
const* spell
);
1404 bool HasSpellCooldown(uint32 spell_id
) const
1406 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1407 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> time(NULL
);
1409 uint32
GetSpellCooldownDelay(uint32 spell_id
) const
1411 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1412 time_t t
= time(NULL
);
1413 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> t
? itr
->second
.end
- t
: 0;
1415 void AddSpellAndCategoryCooldowns(SpellEntry
const* spellInfo
, uint32 itemId
, Spell
* spell
= NULL
, bool infinityCooldown
= false );
1416 void AddSpellCooldown(uint32 spell_id
, uint32 itemid
, time_t end_time
);
1417 void SendCooldownEvent(SpellEntry
const *spellInfo
, uint32 itemId
= 0, Spell
* spell
= NULL
);
1418 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask
, uint32 unTimeMs
);
1419 void RemoveSpellCooldown(uint32 spell_id
) { m_spellCooldowns
.erase(spell_id
); }
1420 void RemoveArenaSpellCooldowns();
1421 void RemoveAllSpellCooldown();
1422 void _LoadSpellCooldowns(QueryResult
*result
);
1423 void _SaveSpellCooldowns();
1424 void SetLastPotionId(uint32 item_id
) { m_lastPotionId
= item_id
; }
1425 void UpdatePotionCooldown(Spell
* spell
= NULL
);
1427 void setResurrectRequestData(uint64 guid
, uint32 mapId
, float X
, float Y
, float Z
, uint32 health
, uint32 mana
)
1429 m_resurrectGUID
= guid
;
1430 m_resurrectMap
= mapId
;
1434 m_resurrectHealth
= health
;
1435 m_resurrectMana
= mana
;
1437 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f
,0.0f
,0.0f
,0,0); }
1438 bool isRessurectRequestedBy(uint64 guid
) const { return m_resurrectGUID
== guid
; }
1439 bool isRessurectRequested() const { return m_resurrectGUID
!= 0; }
1440 void ResurectUsingRequestData();
1446 void setCinematic(int cine
)
1451 bool addActionButton(uint8 button
, uint16 action
, uint8 type
, uint8 misc
);
1452 void removeActionButton(uint8 button
);
1453 void SendInitialActionButtons() const;
1456 void UpdatePvP(bool state
, bool ovrride
=false);
1457 void UpdateZone(uint32 newZone
,uint32 newArea
);
1458 void UpdateArea(uint32 newArea
);
1460 void UpdateZoneDependentAuras( uint32 zone_id
); // zones
1461 void UpdateAreaDependentAuras( uint32 area_id
); // subzones
1463 void UpdateAfkReport(time_t currTime
);
1464 void UpdatePvPFlag(time_t currTime
);
1465 void UpdateContestedPvP(uint32 currTime
);
1466 void SetContestedPvPTimer(uint32 newTime
) {m_contestedPvPTimer
= newTime
;}
1467 void ResetContestedPvP()
1469 clearUnitState(UNIT_STAT_ATTACK_PLAYER
);
1470 RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_CONTESTED_PVP
);
1471 m_contestedPvPTimer
= 0;
1474 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1476 void UpdateDuelFlag(time_t currTime
);
1477 void CheckDuelDistance(time_t currTime
);
1478 void DuelComplete(DuelCompleteType type
);
1480 bool IsGroupVisibleFor(Player
* p
) const;
1481 bool IsInSameGroupWith(Player
const* p
) const;
1482 bool IsInSameRaidWith(Player
const* p
) const { return p
==this || (GetGroup() != NULL
&& GetGroup() == p
->GetGroup()); }
1483 void UninviteFromGroup();
1484 static void RemoveFromGroup(Group
* group
, uint64 guid
);
1485 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1486 void SendUpdateToOutOfRangeGroupMembers();
1488 void SetInGuild(uint32 GuildId
) { SetUInt32Value(PLAYER_GUILDID
, GuildId
); }
1489 void SetRank(uint32 rankId
){ SetUInt32Value(PLAYER_GUILDRANK
, rankId
); }
1490 void SetGuildIdInvited(uint32 GuildId
) { m_GuildIdInvited
= GuildId
; }
1491 uint32
GetGuildId() { return GetUInt32Value(PLAYER_GUILDID
); }
1492 static uint32
GetGuildIdFromDB(uint64 guid
);
1493 uint32
GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK
); }
1494 static uint32
GetRankFromDB(uint64 guid
);
1495 int GetGuildIdInvited() { return m_GuildIdInvited
; }
1496 static void RemovePetitionsAndSigns(uint64 guid
, uint32 type
);
1499 void SetInArenaTeam(uint32 ArenaTeamId
, uint8 slot
)
1501 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6), ArenaTeamId
);
1503 uint32
GetArenaTeamId(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6)); }
1504 static uint32
GetArenaTeamIdFromDB(uint64 guid
, uint8 slot
);
1505 void SetArenaTeamIdInvited(uint32 ArenaTeamId
) { m_ArenaTeamIdInvited
= ArenaTeamId
; }
1506 uint32
GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited
; }
1507 static void LeaveAllArenaTeams(uint64 guid
);
1509 void SetDifficulty(uint32 dungeon_difficulty
) { m_dungeonDifficulty
= dungeon_difficulty
; }
1510 uint8
GetDifficulty() { return m_dungeonDifficulty
; }
1512 bool UpdateSkill(uint32 skill_id
, uint32 step
);
1513 bool UpdateSkillPro(uint16 SkillId
, int32 Chance
, uint32 step
);
1515 bool UpdateCraftSkill(uint32 spellid
);
1516 bool UpdateGatherSkill(uint32 SkillId
, uint32 SkillValue
, uint32 RedLevel
, uint32 Multiplicator
= 1);
1517 bool UpdateFishingSkill();
1519 uint32
GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE
); }
1520 uint32
GetBaseWeaponSkillValue(WeaponAttackType attType
) const;
1522 uint32
GetSpellByProto(ItemPrototype
*proto
);
1524 float GetHealthBonusFromStamina();
1525 float GetManaBonusFromIntellect();
1527 bool UpdateStats(Stats stat
);
1528 bool UpdateAllStats();
1529 void UpdateResistances(uint32 school
);
1531 void UpdateMaxHealth();
1532 void UpdateMaxPower(Powers power
);
1533 void ApplyFeralAPBonus(int32 amount
, bool apply
);
1534 void UpdateAttackPowerAndDamage(bool ranged
= false);
1535 void UpdateShieldBlockValue();
1536 void UpdateDamagePhysical(WeaponAttackType attType
);
1537 void ApplySpellDamageBonus(int32 amount
, bool apply
);
1538 void ApplySpellHealingBonus(int32 amount
, bool apply
);
1539 void UpdateSpellDamageAndHealingBonus();
1541 void CalculateMinMaxDamage(WeaponAttackType attType
, bool normalized
, float& min_damage
, float& max_damage
);
1543 void UpdateDefenseBonusesMod();
1544 void ApplyRatingMod(CombatRating cr
, int32 value
, bool apply
);
1545 float GetMeleeCritFromAgility();
1546 float GetDodgeFromAgility();
1547 float GetSpellCritFromIntellect();
1548 float OCTRegenHPPerSpirit();
1549 float OCTRegenMPPerSpirit();
1550 float GetRatingCoefficient(CombatRating cr
) const;
1551 float GetRatingBonusValue(CombatRating cr
) const;
1552 uint32
GetMeleeCritDamageReduction(uint32 damage
) const;
1553 uint32
GetRangedCritDamageReduction(uint32 damage
) const;
1554 uint32
GetSpellCritDamageReduction(uint32 damage
) const;
1555 uint32
GetDotDamageReduction(uint32 damage
) const;
1556 uint32
GetBaseSpellDamageBonus() { return m_baseSpellDamage
;}
1557 uint32
GetBaseSpellHealingBonus() { return m_baseSpellHealing
;}
1559 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType
) const;
1560 void UpdateBlockPercentage();
1561 void UpdateCritPercentage(WeaponAttackType attType
);
1562 void UpdateAllCritPercentages();
1563 void UpdateParryPercentage();
1564 void UpdateDodgePercentage();
1565 void UpdateMeleeHitChances();
1566 void UpdateRangedHitChances();
1567 void UpdateSpellHitChances();
1569 void UpdateAllSpellCritChances();
1570 void UpdateSpellCritChance(uint32 school
);
1571 void UpdateExpertise(WeaponAttackType attType
);
1572 void ApplyManaRegenBonus(int32 amount
, bool apply
);
1573 void UpdateManaRegen();
1575 const uint64
& GetLootGUID() const { return m_lootGuid
; }
1576 void SetLootGUID(const uint64
&guid
) { m_lootGuid
= guid
; }
1578 void RemovedInsignia(Player
* looterPlr
);
1580 WorldSession
* GetSession() const { return m_session
; }
1581 void SetSession(WorldSession
*s
) { m_session
= s
; }
1583 void BuildCreateUpdateBlockForPlayer( UpdateData
*data
, Player
*target
) const;
1584 void DestroyForPlayer( Player
*target
) const;
1585 void SendDelayResponse(const uint32
);
1586 void SendLogXPGain(uint32 GivenXP
,Unit
* victim
,uint32 RestXP
);
1589 void SendAttackSwingCantAttack();
1590 void SendAttackSwingCancelAttack();
1591 void SendAttackSwingDeadTarget();
1592 void SendAttackSwingNotStanding();
1593 void SendAttackSwingNotInRange();
1594 void SendAttackSwingBadFacingAttack();
1595 void SendAutoRepeatCancel();
1596 void SendExplorationExperience(uint32 Area
, uint32 Experience
);
1598 void SendDungeonDifficulty(bool IsInGroup
);
1599 void ResetInstances(uint8 method
);
1600 void SendResetInstanceSuccess(uint32 MapId
);
1601 void SendResetInstanceFailed(uint32 reason
, uint32 MapId
);
1602 void SendResetFailedNotify(uint32 mapid
);
1604 bool SetPosition(float x
, float y
, float z
, float orientation
, bool teleport
= false);
1605 void UpdateUnderwaterState( Map
* m
, float x
, float y
, float z
);
1607 void SendMessageToSet(WorldPacket
*data
, bool self
);// overwrite Object::SendMessageToSet
1608 void SendMessageToSetInRange(WorldPacket
*data
, float fist
, bool self
);
1609 // overwrite Object::SendMessageToSetInRange
1610 void SendMessageToSetInRange(WorldPacket
*data
, float dist
, bool self
, bool own_team_only
);
1612 static void DeleteFromDB(uint64 playerguid
, uint32 accountId
, bool updateRealmChars
= true);
1614 Corpse
*GetCorpse() const;
1615 void SpawnCorpseBones();
1616 void CreateCorpse();
1618 uint32
GetResurrectionSpellId();
1619 void ResurrectPlayer(float restore_percent
, bool applySickness
= false);
1620 void BuildPlayerRepop();
1621 void RepopAtGraveyard();
1623 void DurabilityLossAll(double percent
, bool inventory
);
1624 void DurabilityLoss(Item
* item
, double percent
);
1625 void DurabilityPointsLossAll(int32 points
, bool inventory
);
1626 void DurabilityPointsLoss(Item
* item
, int32 points
);
1627 void DurabilityPointLossForEquipSlot(EquipmentSlots slot
);
1628 uint32
DurabilityRepairAll(bool cost
, float discountMod
, bool guildBank
);
1629 uint32
DurabilityRepair(uint16 pos
, bool cost
, float discountMod
, bool guildBank
);
1631 void UpdateMirrorTimers();
1632 void StopMirrorTimers()
1634 StopMirrorTimer(FATIGUE_TIMER
);
1635 StopMirrorTimer(BREATH_TIMER
);
1636 StopMirrorTimer(FIRE_TIMER
);
1639 void SetMovement(PlayerMovementType pType
);
1641 void JoinedChannel(Channel
*c
);
1642 void LeftChannel(Channel
*c
);
1643 void CleanupChannels();
1644 void UpdateLocalChannels( uint32 newZone
);
1645 void LeaveLFGChannel();
1647 void UpdateDefense();
1648 void UpdateWeaponSkill (WeaponAttackType attType
);
1649 void UpdateCombatSkills(Unit
*pVictim
, WeaponAttackType attType
, bool defence
);
1651 void SetSkill(uint32 id
, uint16 currVal
, uint16 maxVal
);
1652 uint16
GetMaxSkillValue(uint32 skill
) const; // max + perm. bonus + temp bonus
1653 uint16
GetPureMaxSkillValue(uint32 skill
) const; // max
1654 uint16
GetSkillValue(uint32 skill
) const; // skill value + perm. bonus + temp bonus
1655 uint16
GetBaseSkillValue(uint32 skill
) const; // skill value + perm. bonus
1656 uint16
GetPureSkillValue(uint32 skill
) const; // skill value
1657 int16
GetSkillPermBonusValue(uint32 skill
) const;
1658 int16
GetSkillTempBonusValue(uint32 skill
) const;
1659 bool HasSkill(uint32 skill
) const;
1660 void learnSkillRewardedSpells(uint32 id
, uint32 value
);
1662 WorldLocation
& GetTeleportDest() { return m_teleport_dest
; }
1663 bool IsBeingTeleported() const { return mSemaphoreTeleport_Near
|| mSemaphoreTeleport_Far
; }
1664 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near
; }
1665 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far
; }
1666 void SetSemaphoreTeleportNear(bool semphsetting
) { mSemaphoreTeleport_Near
= semphsetting
; }
1667 void SetSemaphoreTeleportFar(bool semphsetting
) { mSemaphoreTeleport_Far
= semphsetting
; }
1669 void CheckExploreSystem(void);
1671 static uint32
TeamForRace(uint8 race
);
1672 uint32
GetTeam() const { return m_team
; }
1673 static uint32
getFactionForRace(uint8 race
);
1674 void setFactionForRace(uint8 race
);
1676 bool IsAtGroupRewardDistance(WorldObject
const* pRewardSource
) const;
1677 bool RewardPlayerAndGroupAtKill(Unit
* pVictim
);
1678 void RewardPlayerAndGroupAtEvent(uint32 creature_id
,WorldObject
* pRewardSource
);
1679 bool isHonorOrXPTarget(Unit
* pVictim
);
1681 ReputationMgr
& GetReputationMgr() { return m_reputationMgr
; }
1682 ReputationMgr
const& GetReputationMgr() const { return m_reputationMgr
; }
1683 ReputationRank
GetReputationRank(uint32 faction_id
) const;
1684 void RewardReputation(Unit
*pVictim
, float rate
);
1685 void RewardReputation(Quest
const *pQuest
);
1687 void UpdateSkillsForLevel();
1688 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1689 void ModifySkillBonus(uint32 skillid
,int32 val
, bool talent
);
1691 /*********************************************************/
1692 /*** PVP SYSTEM ***/
1693 /*********************************************************/
1694 void UpdateArenaFields();
1695 void UpdateHonorFields();
1696 bool RewardHonor(Unit
*pVictim
, uint32 groupsize
, float honor
= -1);
1697 uint32
GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
); }
1698 uint32
GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY
); }
1699 void ModifyHonorPoints( int32 value
);
1700 void ModifyArenaPoints( int32 value
);
1701 uint32
GetMaxPersonalArenaRatingRequirement();
1705 void SetDrunkValue(uint16 newDrunkValue
, uint32 itemid
=0);
1706 uint16
GetDrunkValue() const { return m_drunk
; }
1707 static DrunkenState
GetDrunkenstateByValue(uint16 value
);
1709 uint32
GetDeathTimer() const { return m_deathTimer
; }
1710 uint32
GetCorpseReclaimDelay(bool pvp
) const;
1711 void UpdateCorpseReclaimDelay();
1712 void SendCorpseReclaimDelay(bool load
= false);
1714 uint32
GetShieldBlockValue() const; // overwrite Unit version (virtual)
1715 bool CanParry() const { return m_canParry
; }
1716 void SetCanParry(bool value
);
1717 bool CanBlock() const { return m_canBlock
; }
1718 void SetCanBlock(bool value
);
1719 bool CanDualWield() const { return m_canDualWield
; }
1720 void SetCanDualWield(bool value
) { m_canDualWield
= value
; }
1721 bool CanTitanGrip() const { return m_canTitanGrip
; }
1722 void SetCanTitanGrip(bool value
) { m_canTitanGrip
= value
; }
1724 void SetRegularAttackTime();
1725 void SetBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float value
) { m_auraBaseMod
[modGroup
][modType
] = value
; }
1726 void HandleBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float amount
, bool apply
);
1727 float GetBaseModValue(BaseModGroup modGroup
, BaseModType modType
) const;
1728 float GetTotalBaseModValue(BaseModGroup modGroup
) const;
1729 float GetTotalPercentageModValue(BaseModGroup modGroup
) const { return m_auraBaseMod
[modGroup
][FLAT_MOD
] + m_auraBaseMod
[modGroup
][PCT_MOD
]; }
1730 void _ApplyAllStatBonuses();
1731 void _RemoveAllStatBonuses();
1733 void _ApplyWeaponDependentAuraMods(Item
*item
, WeaponAttackType attackType
, bool apply
);
1734 void _ApplyWeaponDependentAuraCritMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1735 void _ApplyWeaponDependentAuraDamageMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1737 void _ApplyItemMods(Item
*item
,uint8 slot
,bool apply
);
1738 void _RemoveAllItemMods();
1739 void _ApplyAllItemMods();
1740 void _ApplyItemBonuses(ItemPrototype
const *proto
,uint8 slot
,bool apply
);
1741 void _ApplyAmmoBonuses();
1742 bool EnchantmentFitsRequirements(uint32 enchantmentcondition
, int8 slot
);
1743 void ToggleMetaGemsActive(uint8 exceptslot
, bool apply
);
1744 void CorrectMetaGemEnchants(uint8 slot
, bool apply
);
1745 void InitDataForForm(bool reapplyMods
= false);
1747 void ApplyItemEquipSpell(Item
*item
, bool apply
, bool form_change
= false);
1748 void ApplyEquipSpell(SpellEntry
const* spellInfo
, Item
* item
, bool apply
, bool form_change
= false);
1749 void UpdateEquipSpellsAtFormChange();
1750 void CastItemCombatSpell(Item
*item
,Unit
* Target
, WeaponAttackType attType
);
1751 void CastItemUseSpell(Item
*item
,SpellCastTargets
const& targets
,uint8 cast_count
, uint32 glyphIndex
);
1753 void SendEquipmentSetList();
1754 void SetEquipmentSet(uint32 index
, EquipmentSet eqset
);
1755 void DeleteEquipmentSet(uint64 setGuid
);
1757 void SendInitWorldStates(uint32 zone
, uint32 area
);
1758 void SendUpdateWorldState(uint32 Field
, uint32 Value
);
1759 void SendDirectMessage(WorldPacket
*data
);
1761 void SendAurasForTarget(Unit
*target
);
1763 PlayerMenu
* PlayerTalkClass
;
1764 std::vector
<ItemSetEffect
*> ItemSetEff
;
1766 void SendLoot(uint64 guid
, LootType loot_type
);
1767 void SendLootRelease( uint64 guid
);
1768 void SendNotifyLootItemRemoved(uint8 lootSlot
);
1769 void SendNotifyLootMoneyRemoved();
1771 /*********************************************************/
1772 /*** BATTLEGROUND SYSTEM ***/
1773 /*********************************************************/
1775 bool InBattleGround() const { return m_bgBattleGroundID
!= 0; }
1776 bool InArena() const;
1777 uint32
GetBattleGroundId() const { return m_bgBattleGroundID
; }
1778 BattleGroundTypeId
GetBattleGroundTypeId() const { return m_bgTypeID
; }
1779 BattleGround
* GetBattleGround() const;
1782 BGQueueIdBasedOnLevel
GetBattleGroundQueueIdFromLevel(BattleGroundTypeId bgTypeId
) const;
1784 bool InBattleGroundQueue() const
1786 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1787 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
!= BATTLEGROUND_QUEUE_NONE
)
1792 BattleGroundQueueTypeId
GetBattleGroundQueueTypeId(uint32 index
) const { return m_bgBattleGroundQueueID
[index
].bgQueueTypeId
; }
1793 uint32
GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId
) const
1795 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1796 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1798 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1800 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
1802 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1803 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1804 return m_bgBattleGroundQueueID
[i
].invitedToInstance
!= 0;
1807 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
1809 return GetBattleGroundQueueIndex(bgQueueTypeId
) < PLAYER_MAX_BATTLEGROUND_QUEUES
;
1812 void SetBattleGroundId(uint32 val
, BattleGroundTypeId bgTypeId
)
1814 m_bgBattleGroundID
= val
;
1815 m_bgTypeID
= bgTypeId
;
1817 uint32
AddBattleGroundQueueId(BattleGroundQueueTypeId val
)
1819 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1821 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
|| m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
1823 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= val
;
1824 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1828 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1830 bool HasFreeBattleGroundQueueId()
1832 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1833 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
)
1837 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val
)
1839 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1841 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
1843 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= BATTLEGROUND_QUEUE_NONE
;
1844 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1849 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
, uint32 instanceId
)
1851 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1852 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1853 m_bgBattleGroundQueueID
[i
].invitedToInstance
= instanceId
;
1855 bool IsInvitedForBattleGroundInstance(uint32 instanceId
) const
1857 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1858 if (m_bgBattleGroundQueueID
[i
].invitedToInstance
== instanceId
)
1862 WorldLocation
const& GetBattleGroundEntryPoint() const { return m_bgEntryPoint
; }
1863 void SetBattleGroundEntryPoint(uint32 Map
, float PosX
, float PosY
, float PosZ
, float PosO
)
1865 m_bgEntryPoint
= WorldLocation(Map
,PosX
,PosY
,PosZ
,PosO
);
1868 void SetBGTeam(uint32 team
) { m_bgTeam
= team
; }
1869 uint32
GetBGTeam() const { return m_bgTeam
? m_bgTeam
: GetTeam(); }
1871 void LeaveBattleground(bool teleportToEntryPoint
= true);
1872 bool CanJoinToBattleground() const;
1873 bool CanReportAfkDueToLimit();
1874 void ReportedAfkBy(Player
* reporter
);
1875 void ClearAfkReports() { m_bgAfkReporter
.clear(); }
1877 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId
) const;
1878 bool CanUseBattleGroundObject();
1879 bool isTotalImmune();
1880 bool CanCaptureTowerPoint();
1882 /*********************************************************/
1883 /*** REST SYSTEM ***/
1884 /*********************************************************/
1886 bool isRested() const { return GetRestTime() >= 10*IN_MILISECONDS
; }
1887 uint32
GetXPRestBonus(uint32 xp
);
1888 uint32
GetRestTime() const { return m_restTime
;};
1889 void SetRestTime(uint32 v
) { m_restTime
= v
;};
1891 /*********************************************************/
1892 /*** ENVIROMENTAL SYSTEM ***/
1893 /*********************************************************/
1895 void EnvironmentalDamage(EnviromentalDamage type
, uint32 damage
);
1897 /*********************************************************/
1898 /*** FLOOD FILTER SYSTEM ***/
1899 /*********************************************************/
1901 void UpdateSpeakTime();
1902 bool CanSpeak() const;
1903 void ChangeSpeakTime(int utime
);
1905 /*********************************************************/
1906 /*** VARIOUS SYSTEMS ***/
1907 /*********************************************************/
1908 MovementInfo m_movementInfo
;
1909 void UpdateFallInformationIfNeed(MovementInfo
const& minfo
,uint16 opcode
);
1911 void SetFallInformation(uint32 time
, float z
)
1913 m_lastFallTime
= time
;
1916 void HandleFall(MovementInfo
const& movementInfo
);
1918 bool isMoving() const { return m_movementInfo
.HasMovementFlag(movementFlagsMask
); }
1919 bool isMovingOrTurning() const { return m_movementInfo
.HasMovementFlag(movementOrTurningFlagsMask
); }
1921 bool CanFly() const { return m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_CAN_FLY
); }
1922 bool IsFlying() const { return m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_FLYING
); }
1923 bool IsAllowUseFlyMountsHere() const;
1925 void SetClientControl(Unit
* target
, uint8 allowMove
);
1927 void EnterVehicle(Vehicle
*vehicle
);
1928 void ExitVehicle(Vehicle
*vehicle
);
1930 uint64
GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT
); }
1931 void SetFarSightGUID(uint64 guid
) { SetUInt64Value(PLAYER_FARSIGHT
, guid
); }
1934 Transport
* GetTransport() const { return m_transport
; }
1935 void SetTransport(Transport
* t
) { m_transport
= t
; }
1937 float GetTransOffsetX() const { return m_movementInfo
.t_x
; }
1938 float GetTransOffsetY() const { return m_movementInfo
.t_y
; }
1939 float GetTransOffsetZ() const { return m_movementInfo
.t_z
; }
1940 float GetTransOffsetO() const { return m_movementInfo
.t_o
; }
1941 uint32
GetTransTime() const { return m_movementInfo
.t_time
; }
1942 int8
GetTransSeat() const { return m_movementInfo
.t_seat
; }
1944 uint32
GetSaveTimer() const { return m_nextSave
; }
1945 void SetSaveTimer(uint32 timer
) { m_nextSave
= timer
; }
1953 void SaveRecallPosition();
1955 // Homebind coordinates
1956 uint32 m_homebindMapId
;
1957 uint16 m_homebindZoneId
;
1961 void RelocateToHomebind() { SetMapId(m_homebindMapId
); Relocate(m_homebindX
,m_homebindY
,m_homebindZ
); }
1963 // currently visible objects at player client
1964 typedef std::set
<uint64
> ClientGUIDs
;
1965 ClientGUIDs m_clientGUIDs
;
1967 bool HaveAtClient(WorldObject
const* u
) { return u
==this || m_clientGUIDs
.find(u
->GetGUID())!=m_clientGUIDs
.end(); }
1969 bool IsVisibleInGridForPlayer(Player
* pl
) const;
1970 bool IsVisibleGloballyFor(Player
* pl
) const;
1972 void UpdateVisibilityOf(WorldObject
* target
);
1975 void UpdateVisibilityOf(T
* target
, UpdateData
& data
, UpdateDataMapType
& data_updates
, std::set
<WorldObject
*>& visibleNow
);
1977 // Stealth detection system
1978 uint32 m_DetectInvTimer
;
1979 void HandleStealthedUnitsDetection();
1981 uint8 m_forced_speed_changes
[MAX_MOVE_TYPE
];
1983 bool HasAtLoginFlag(AtLoginFlags f
) const { return m_atLoginFlags
& f
; }
1984 void SetAtLoginFlag(AtLoginFlags f
) { m_atLoginFlags
|= f
; }
1986 LookingForGroup m_lookingForGroup
;
1988 // Temporarily removed pet cache
1989 uint32
GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber
; }
1990 void SetTemporaryUnsummonedPetNumber(uint32 petnumber
) { m_temporaryUnsummonedPetNumber
= petnumber
; }
1991 void UnsummonPetTemporaryIfAny();
1992 void ResummonPetTemporaryUnSummonedIfAny();
1993 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
1995 void SendCinematicStart(uint32 CinematicSequenceId
);
1996 void SendMovieStart(uint32 MovieId
);
1998 /*********************************************************/
1999 /*** INSTANCE SYSTEM ***/
2000 /*********************************************************/
2002 typedef UNORDERED_MAP
< uint32
/*mapId*/, InstancePlayerBind
> BoundInstancesMap
;
2004 void UpdateHomebindTime(uint32 time
);
2006 uint32 m_HomebindTimer
;
2007 bool m_InstanceValid
;
2008 // permanent binds and solo binds by difficulty
2009 BoundInstancesMap m_boundInstances
[TOTAL_DIFFICULTIES
];
2010 InstancePlayerBind
* GetBoundInstance(uint32 mapid
, uint8 difficulty
);
2011 BoundInstancesMap
& GetBoundInstances(uint8 difficulty
) { return m_boundInstances
[difficulty
]; }
2012 void UnbindInstance(uint32 mapid
, uint8 difficulty
, bool unload
= false);
2013 void UnbindInstance(BoundInstancesMap::iterator
&itr
, uint8 difficulty
, bool unload
= false);
2014 InstancePlayerBind
* BindToInstance(InstanceSave
*save
, bool permanent
, bool load
= false);
2015 void SendRaidInfo();
2016 void SendSavedInstances();
2017 static void ConvertInstancesToGroup(Player
*player
, Group
*group
= NULL
, uint64 player_guid
= 0);
2019 /*********************************************************/
2020 /*** GROUP SYSTEM ***/
2021 /*********************************************************/
2023 Group
* GetGroupInvite() { return m_groupInvite
; }
2024 void SetGroupInvite(Group
*group
) { m_groupInvite
= group
; }
2025 Group
* GetGroup() { return m_group
.getTarget(); }
2026 const Group
* GetGroup() const { return (const Group
*)m_group
.getTarget(); }
2027 GroupReference
& GetGroupRef() { return m_group
; }
2028 void SetGroup(Group
*group
, int8 subgroup
= -1);
2029 uint8
GetSubGroup() const { return m_group
.getSubGroup(); }
2030 uint32
GetGroupUpdateFlag() const { return m_groupUpdateMask
; }
2031 void SetGroupUpdateFlag(uint32 flag
) { m_groupUpdateMask
|= flag
; }
2032 const uint64
& GetAuraUpdateMask() const { return m_auraUpdateMask
; }
2033 void SetAuraUpdateMask(uint8 slot
) { m_auraUpdateMask
|= (uint64(1) << slot
); }
2034 Player
* GetNextRandomRaidMember(float radius
);
2035 PartyResult
CanUninviteFromGroup() const;
2036 // BattleGround Group System
2037 void SetBattleGroundRaid(Group
*group
, int8 subgroup
= -1);
2038 void RemoveFromBattleGroundRaid();
2039 Group
* GetOriginalGroup() { return m_originalGroup
.getTarget(); }
2040 GroupReference
& GetOriginalGroupRef() { return m_originalGroup
; }
2041 uint8
GetOriginalSubGroup() const { return m_originalGroup
.getSubGroup(); }
2042 void SetOriginalGroup(Group
*group
, int8 subgroup
= -1);
2044 GridReference
<Player
> &GetGridRef() { return m_gridRef
; }
2045 MapReference
&GetMapRef() { return m_mapRef
; }
2047 bool isAllowedToLoot(Creature
* creature
);
2049 DeclinedName
const* GetDeclinedNames() const { return m_declinedname
; }
2050 uint8
GetRunesState() const { return m_runes
->runeState
; }
2051 uint8
GetBaseRune(uint8 index
) const { return m_runes
->runes
[index
].BaseRune
; }
2052 uint8
GetCurrentRune(uint8 index
) const { return m_runes
->runes
[index
].CurrentRune
; }
2053 uint8
GetRuneCooldown(uint8 index
) const { return m_runes
->runes
[index
].Cooldown
; }
2054 void SetBaseRune(uint8 index
, uint8 baseRune
) { m_runes
->runes
[index
].BaseRune
= baseRune
; }
2055 void SetCurrentRune(uint8 index
, uint8 currentRune
) { m_runes
->runes
[index
].CurrentRune
= currentRune
; }
2056 void SetRuneCooldown(uint8 index
, uint8 cooldown
) { m_runes
->runes
[index
].Cooldown
= cooldown
; m_runes
->SetRuneState(index
, (cooldown
== 0) ? true : false); }
2057 void ConvertRune(uint8 index
, uint8 newType
);
2058 void ResyncRunes(uint8 count
);
2059 void AddRunePower(uint8 index
);
2061 AchievementMgr
& GetAchievementMgr() { return m_achievementMgr
; }
2062 void UpdateAchievementCriteria(AchievementCriteriaTypes type
, uint32 miscvalue1
=0, uint32 miscvalue2
=0, Unit
*unit
=NULL
, uint32 time
=0);
2063 bool HasTitle(uint32 bitIndex
);
2064 bool HasTitle(CharTitlesEntry
const* title
) { return HasTitle(title
->bit_index
); }
2065 void SetTitle(CharTitlesEntry
const* title
);
2067 bool isActiveObject() const { return true; }
2068 bool canSeeSpellClickOn(Creature
const* creature
) const;
2071 /*********************************************************/
2072 /*** BATTLEGROUND SYSTEM ***/
2073 /*********************************************************/
2075 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2076 uint32 m_bgBattleGroundID
;
2077 BattleGroundTypeId m_bgTypeID
;
2079 this is an array of BG queues (BgTypeIDs) in which is player
2081 struct BgBattleGroundQueueID_Rec
2083 BattleGroundQueueTypeId bgQueueTypeId
;
2084 uint32 invitedToInstance
;
2086 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID
[PLAYER_MAX_BATTLEGROUND_QUEUES
];
2087 WorldLocation m_bgEntryPoint
;
2089 std::set
<uint32
> m_bgAfkReporter
;
2090 uint8 m_bgAfkReportedCount
;
2091 time_t m_bgAfkReportedTimer
;
2092 uint32 m_contestedPvPTimer
;
2094 uint32 m_bgTeam
; // what side the player will be added to
2096 /*********************************************************/
2097 /*** QUEST SYSTEM ***/
2098 /*********************************************************/
2100 std::set
<uint32
> m_timedquests
;
2103 uint32 m_ingametime
;
2105 /*********************************************************/
2106 /*** LOAD SYSTEM ***/
2107 /*********************************************************/
2109 void _LoadActions(QueryResult
*result
);
2110 void _LoadAuras(QueryResult
*result
, uint32 timediff
);
2111 void _LoadGlyphAuras();
2112 void _LoadBoundInstances(QueryResult
*result
);
2113 void _LoadInventory(QueryResult
*result
, uint32 timediff
);
2114 void _LoadMailInit(QueryResult
*resultUnread
, QueryResult
*resultDelivery
);
2116 void _LoadMailedItems(Mail
*mail
);
2117 void _LoadQuestStatus(QueryResult
*result
);
2118 void _LoadDailyQuestStatus(QueryResult
*result
);
2119 void _LoadGroup(QueryResult
*result
);
2121 void _LoadSpells(QueryResult
*result
);
2122 void _LoadFriendList(QueryResult
*result
);
2123 bool _LoadHomeBind(QueryResult
*result
);
2124 void _LoadDeclinedNames(QueryResult
*result
);
2125 void _LoadArenaTeamInfo(QueryResult
*result
);
2126 void _LoadEquipmentSets(QueryResult
*result
);
2128 /*********************************************************/
2129 /*** SAVE SYSTEM ***/
2130 /*********************************************************/
2132 void _SaveActions();
2134 void _SaveInventory();
2136 void _SaveQuestStatus();
2137 void _SaveDailyQuestStatus();
2139 void _SaveEquipmentSets();
2141 void _SetCreateBits(UpdateMask
*updateMask
, Player
*target
) const;
2142 void _SetUpdateBits(UpdateMask
*updateMask
, Player
*target
) const;
2144 /*********************************************************/
2145 /*** ENVIRONMENTAL SYSTEM ***/
2146 /*********************************************************/
2147 void HandleSobering();
2148 void SendMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
, uint32 CurrentValue
, int32 Regen
);
2149 void StopMirrorTimer(MirrorTimerType Type
);
2150 void HandleDrowning(uint32 time_diff
);
2151 int32
getMaxTimer(MirrorTimerType timer
);
2153 /*********************************************************/
2154 /*** HONOR SYSTEM ***/
2155 /*********************************************************/
2156 time_t m_lastHonorUpdateTime
;
2158 void outDebugValues() const;
2166 uint32 m_speakCount
;
2167 uint32 m_dungeonDifficulty
;
2169 uint32 m_atLoginFlags
;
2171 Item
* m_items
[PLAYER_SLOTS_COUNT
];
2172 uint32 m_currentBuybackSlot
;
2174 std::vector
<Item
*> m_itemUpdateQueue
;
2175 bool m_itemUpdateQueueBlocked
;
2177 uint32 m_ExtraFlags
;
2178 uint64 m_curSelection
;
2180 uint64 m_comboTarget
;
2183 QuestStatusMap mQuestStatus
;
2185 uint32 m_GuildIdInvited
;
2186 uint32 m_ArenaTeamIdInvited
;
2189 PlayerSpellMap m_spells
;
2190 SpellCooldowns m_spellCooldowns
;
2191 uint32 m_lastPotionId
; // last used health/mana potion in combat, that block next potion use
2193 ActionButtonList m_actionButtons
;
2195 float m_auraBaseMod
[BASEMOD_END
][MOD_END
];
2196 int16 m_baseRatingValue
[MAX_COMBAT_RATING
];
2197 uint16 m_baseSpellDamage
;
2198 uint16 m_baseSpellHealing
;
2199 uint16 m_baseFeralAP
;
2200 uint16 m_baseManaRegen
;
2202 SpellModList m_spellMods
[MAX_SPELLMOD
];
2203 int32 m_SpellModRemoveCount
;
2204 EnchantDurationList m_enchantDuration
;
2205 ItemDurationList m_itemDuration
;
2207 uint64 m_resurrectGUID
;
2208 uint32 m_resurrectMap
;
2209 float m_resurrectX
, m_resurrectY
, m_resurrectZ
;
2210 uint32 m_resurrectHealth
, m_resurrectMana
;
2212 WorldSession
*m_session
;
2214 typedef std::list
<Channel
*> JoinedChannelsList
;
2215 JoinedChannelsList m_channels
;
2221 uint16 tradeItems
[TRADE_SLOT_COUNT
];
2224 time_t m_nextThinkTime
;
2226 bool m_DailyQuestChanged
;
2227 time_t m_lastDailyQuestTime
;
2229 uint32 m_drunkTimer
;
2231 uint32 m_weaponChangeTimer
;
2233 uint32 m_zoneUpdateId
;
2234 uint32 m_zoneUpdateTimer
;
2235 uint32 m_areaUpdateId
;
2237 uint32 m_deathTimer
;
2238 time_t m_deathExpireTime
;
2242 uint32 m_WeaponProficiency
;
2243 uint32 m_ArmorProficiency
;
2246 bool m_canDualWield
;
2247 bool m_canTitanGrip
;
2248 uint8 m_swingErrorMsg
;
2251 ////////////////////Rest System/////////////////////
2253 uint32 inn_pos_mapid
;
2259 ////////////////////Rest System/////////////////////
2262 Transport
* m_transport
;
2264 uint32 m_resetTalentsCost
;
2265 time_t m_resetTalentsTime
;
2266 uint32 m_usedTalentCount
;
2267 uint32 m_questRewardTalentCount
;
2270 PlayerSocial
*m_social
;
2273 GroupReference m_group
;
2274 GroupReference m_originalGroup
;
2275 Group
*m_groupInvite
;
2276 uint32 m_groupUpdateMask
;
2277 uint64 m_auraUpdateMask
;
2280 GuardianPetList m_guardianPets
;
2283 time_t m_summon_expire
;
2284 uint32 m_summon_mapid
;
2289 DeclinedName
*m_declinedname
;
2291 EquipmentSets m_EquipmentSets
;
2293 // internal common parts for CanStore/StoreItem functions
2294 uint8
_CanStoreItem_InSpecificSlot( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool swap
, Item
*pSrcItem
) const;
2295 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;
2296 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;
2297 Item
* _StoreItem( uint16 pos
, Item
*pItem
, uint32 count
, bool clone
, bool update
);
2299 void UpdateKnownCurrencies(uint32 itemId
, bool apply
);
2300 int32
CalculateReputationGain(uint32 creatureOrQuestLevel
, int32 rep
, bool for_quest
);
2301 void AdjustQuestReqItemCount( Quest
const* pQuest
, QuestStatusData
& questStatusData
);
2303 GridReference
<Player
> m_gridRef
;
2304 MapReference m_mapRef
;
2306 uint32 m_lastFallTime
;
2309 int32 m_MirrorTimer
[MAX_TIMERS
];
2310 uint8 m_MirrorTimerFlags
;
2311 uint8 m_MirrorTimerFlagsLast
;
2314 // Current teleport data
2315 WorldLocation m_teleport_dest
;
2316 bool mSemaphoreTeleport_Near
;
2317 bool mSemaphoreTeleport_Far
;
2319 // Temporary removed pet cache
2320 uint32 m_temporaryUnsummonedPetNumber
;
2321 uint32 m_oldpetspell
;
2323 AchievementMgr m_achievementMgr
;
2324 ReputationMgr m_reputationMgr
;
2327 void AddItemsSetItem(Player
*player
,Item
*item
);
2328 void RemoveItemsSetItem(Player
*player
,ItemPrototype
const *proto
);
2330 // "the bodies of template functions must be made available in a header file"
2331 template <class T
> T
Player::ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
)
2333 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
2334 if (!spellInfo
) return 0;
2336 int32 totalflat
= 0;
2337 for (SpellModList::iterator itr
= m_spellMods
[op
].begin(); itr
!= m_spellMods
[op
].end(); ++itr
)
2339 SpellModifier
*mod
= *itr
;
2341 if(!IsAffectedBySpellmod(spellInfo
,mod
,spell
))
2343 if (mod
->type
== SPELLMOD_FLAT
)
2344 totalflat
+= mod
->value
;
2345 else if (mod
->type
== SPELLMOD_PCT
)
2347 // skip percent mods for null basevalue (most important for spell mods with charges )
2348 if(basevalue
== T(0))
2351 // special case (skip >10sec spell casts for instant cast setting)
2352 if( mod
->op
==SPELLMOD_CASTING_TIME
&& basevalue
>= T(10*IN_MILISECONDS
) && mod
->value
<= -100)
2355 totalpct
+= mod
->value
;
2358 if (mod
->charges
> 0 )
2361 if (mod
->charges
== 0)
2364 mod
->lastAffected
= spell
;
2365 if(!mod
->lastAffected
)
2366 mod
->lastAffected
= FindCurrentSpellBySpellId(spellId
);
2367 ++m_SpellModRemoveCount
;
2372 float diff
= (float)basevalue
*(float)totalpct
/100.0f
+ (float)totalflat
;
2373 basevalue
= T((float)basevalue
+ diff
);