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"
49 class SpellCastTargets
;
54 typedef std::deque
<Mail
*> PlayerMails
;
56 #define PLAYER_MAX_SKILLS 127
57 #define PLAYER_MAX_DAILY_QUESTS 25
59 // Note: SPELLMOD_* values is aura types in fact
62 SPELLMOD_FLAT
= 107, // SPELL_AURA_ADD_FLAT_MODIFIER
63 SPELLMOD_PCT
= 108 // SPELL_AURA_ADD_PCT_MODIFIER
66 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
67 enum PlayerUnderwaterState
69 UNDERWATER_NONE
= 0x00,
70 UNDERWATER_INWATER
= 0x01, // terrain type is water and player is afflicted by it
71 UNDERWATER_WATER_TRIGGER
= 0x02, // m_breathTimer has been initialized
72 UNDERWATER_WATER_BREATHB
= 0x04, // breathbar has been send to client
73 UNDERWATER_WATER_BREATHB_RETRACTING
= 0x10, // breathbar is currently refilling - the player is above water level
74 UNDERWATER_INLAVA
= 0x80 // terrain type is lava and player is afflicted by it
79 PLAYERSPELL_UNCHANGED
= 0,
80 PLAYERSPELL_CHANGED
= 1,
82 PLAYERSPELL_REMOVED
= 3
87 PlayerSpellState state
: 8;
92 // Spell modifier (used for modify other spells)
95 SpellModifier() : charges(0), lastAffected(NULL
) {}
97 SpellModType type
: 8;
103 Spell
const* lastAffected
;
106 typedef UNORDERED_MAP
<uint16
, PlayerSpell
*> PlayerSpellMap
;
107 typedef std::list
<SpellModifier
*> SpellModList
;
115 typedef std::map
<uint32
, SpellCooldown
> SpellCooldowns
;
117 enum TrainerSpellState
119 TRAINER_SPELL_GREEN
= 0,
120 TRAINER_SPELL_RED
= 1,
121 TRAINER_SPELL_GRAY
= 2
124 enum ActionButtonUpdateState
126 ACTIONBUTTON_UNCHANGED
= 0,
127 ACTIONBUTTON_CHANGED
= 1,
128 ACTIONBUTTON_NEW
= 2,
129 ACTIONBUTTON_DELETED
= 3
134 ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW
) {}
135 ActionButton(uint16 _action
, uint8 _type
, uint8 _misc
) : action(_action
), type(_type
), misc(_misc
), uState( ACTIONBUTTON_NEW
) {}
140 ActionButtonUpdateState uState
;
143 enum ActionButtonType
145 ACTION_BUTTON_SPELL
= 0,
146 ACTION_BUTTON_MACRO
= 64,
147 ACTION_BUTTON_CMACRO
= 65,
148 ACTION_BUTTON_ITEM
= 128
151 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
153 typedef std::map
<uint8
,ActionButton
> ActionButtonList
;
155 struct PlayerCreateInfoItem
157 PlayerCreateInfoItem(uint32 id
, uint32 amount
) : item_id(id
), item_amount(amount
) {}
163 typedef std::list
<PlayerCreateInfoItem
> PlayerCreateInfoItems
;
165 struct PlayerClassLevelInfo
167 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
172 struct PlayerClassInfo
174 PlayerClassInfo() : levelInfo(NULL
) { }
176 PlayerClassLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
179 struct PlayerLevelInfo
181 PlayerLevelInfo() { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
183 uint8 stats
[MAX_STATS
];
186 typedef std::list
<uint32
> PlayerCreateInfoSpells
;
190 // existence checked by displayId != 0 // existence checked by displayId != 0
191 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL
)
202 PlayerCreateInfoItems item
;
203 PlayerCreateInfoSpells spell
;
204 std::list
<uint16
> action
[4];
206 PlayerLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
211 PvPInfo() : inHostileArea(false), endTimer(0) {}
219 DuelInfo() : initiator(NULL
), opponent(NULL
), startTimer(0), startTime(0), outOfBound(0) {}
239 #define RUNE_COOLDOWN 5 // 5*2=10 sec
259 RuneInfo runes
[MAX_RUNES
];
260 uint8 runeState
; // mask of available runes
262 void SetRuneState(uint8 index
, bool set
= true)
265 runeState
|= (1 << index
); // usable
267 runeState
&= ~(1 << index
); // on cooldown
273 FACTION_FLAG_VISIBLE
= 0x01, // makes visible in client (set or can be set at interaction with target of this faction)
274 FACTION_FLAG_AT_WAR
= 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
275 FACTION_FLAG_HIDDEN
= 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
276 FACTION_FLAG_INVISIBLE_FORCED
= 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
277 FACTION_FLAG_PEACE_FORCED
= 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
278 FACTION_FLAG_INACTIVE
= 0x20, // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE )
279 FACTION_FLAG_RIVAL
= 0x40 // flag for the two competing outland factions
282 typedef uint32 RepListID
;
286 RepListID ReputationListID
;
292 typedef std::map
<RepListID
,FactionState
> FactionStateList
;
294 typedef std::map
<uint32
,ReputationRank
> ForcedReactions
;
296 typedef std::set
<uint64
> GuardianPetList
;
298 struct EnchantDuration
300 EnchantDuration() : item(NULL
), slot(MAX_ENCHANTMENT_SLOT
), leftduration(0) {};
301 EnchantDuration(Item
* _item
, EnchantmentSlot _slot
, uint32 _leftduration
) : item(_item
), slot(_slot
), leftduration(_leftduration
) { assert(item
); };
304 EnchantmentSlot slot
;
308 typedef std::list
<EnchantDuration
> EnchantDurationList
;
309 typedef std::list
<Item
*> ItemDurationList
;
311 struct LookingForGroupSlot
313 LookingForGroupSlot() : entry(0), type(0) {}
314 bool Empty() const { return !entry
&& !type
; }
315 void Clear() { entry
= 0; type
= 0; }
316 void Set(uint32 _entry
, uint32 _type
) { entry
= _entry
; type
= _type
; }
317 bool Is(uint32 _entry
, uint32 _type
) const { return entry
==_entry
&& type
==_type
; }
318 bool canAutoJoin() const { return entry
&& (type
== 1 || type
== 5); }
324 #define MAX_LOOKING_FOR_GROUP_SLOT 3
326 struct LookingForGroup
329 bool HaveInSlot(LookingForGroupSlot
const& slot
) const { return HaveInSlot(slot
.entry
,slot
.type
); }
330 bool HaveInSlot(uint32 _entry
, uint32 _type
) const
332 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
333 if(slots
[i
].Is(_entry
,_type
))
338 bool canAutoJoin() const
340 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
341 if(slots
[i
].canAutoJoin())
348 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
349 if(!slots
[i
].Empty())
354 LookingForGroupSlot slots
[MAX_LOOKING_FOR_GROUP_SLOT
];
355 LookingForGroupSlot more
;
359 enum PlayerMovementType
382 PLAYER_STATE_READYUNARMED
384 PLAYER_STATE_POINT(DNR)
385 PLAYER_STATE_NONE // not used or just no state, just standing there?
389 PLAYER_STATE_USESTANDING
390 PLAYER_STATE_STUN_NOSHEATHE
391 PLAYER_STATE_USESTANDING_NOSHEATHE
392 PLAYER_STATE_WORK_NOSHEATHE
393 PLAYER_STATE_SPELLPRECAST
394 PLAYER_STATE_READYRIFLE
395 PLAYER_STATE_WORK_NOSHEATHE_MINING
396 PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD
399 PLAYER_STATE_SPELLKNEELSTART
400 PLAYER_STATE_SUBMERGED
403 PLAYER_STATE_NONE
= 0,
404 PLAYER_STATE_SIT
= 1,
405 PLAYER_STATE_SIT_CHAIR
= 2,
406 PLAYER_STATE_SLEEP
= 3,
407 PLAYER_STATE_SIT_LOW_CHAIR
= 4,
408 PLAYER_STATE_SIT_MEDIUM_CHAIR
= 5,
409 PLAYER_STATE_SIT_HIGH_CHAIR
= 6,
410 PLAYER_STATE_DEAD
= 7,
411 PLAYER_STATE_KNEEL
= 8,
413 PLAYER_STATE_FORM_ALL
= 0x00FF0000,
415 PLAYER_STATE_FLAG_ALWAYS_STAND
= 0x01, // byte 4
416 PLAYER_STATE_FLAG_CREEP
= 0x02000000,
417 PLAYER_STATE_FLAG_UNTRACKABLE
= 0x04000000,
418 PLAYER_STATE_FLAG_ALL
= 0xFF000000,
423 PLAYER_FLAGS_GROUP_LEADER
= 0x00000001,
424 PLAYER_FLAGS_AFK
= 0x00000002,
425 PLAYER_FLAGS_DND
= 0x00000004,
426 PLAYER_FLAGS_GM
= 0x00000008,
427 PLAYER_FLAGS_GHOST
= 0x00000010,
428 PLAYER_FLAGS_RESTING
= 0x00000020,
429 PLAYER_FLAGS_UNK7
= 0x00000040,
430 PLAYER_FLAGS_UNK8
= 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
431 PLAYER_FLAGS_CONTESTED_PVP
= 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
432 PLAYER_FLAGS_IN_PVP
= 0x00000200,
433 PLAYER_FLAGS_HIDE_HELM
= 0x00000400,
434 PLAYER_FLAGS_HIDE_CLOAK
= 0x00000800,
435 PLAYER_FLAGS_UNK13
= 0x00001000, // played long time
436 PLAYER_FLAGS_UNK14
= 0x00002000, // played too long time
437 PLAYER_FLAGS_UNK15
= 0x00004000,
438 PLAYER_FLAGS_UNK16
= 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
439 PLAYER_FLAGS_UNK17
= 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
440 PLAYER_FLAGS_UNK18
= 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
441 PLAYER_FLAGS_PVP_TIMER
= 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
442 PLAYER_FLAGS_UNK20
= 0x00080000,
443 PLAYER_FLAGS_UNK21
= 0x00100000,
444 PLAYER_FLAGS_UNK22
= 0x00200000,
445 PLAYER_FLAGS_UNK23
= 0x00400000,
446 PLAYER_FLAGS_UNK24
= 0x00800000, // disabled all abilitys on tab except autoattack
447 PLAYER_FLAGS_UNK25
= 0x01000000, // disabled all melee ability on tab include autoattack
451 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
452 // can't use enum for uint64 values
453 #define PLAYER_TITLE_DISABLED 0x0000000000000000LL
454 #define PLAYER_TITLE_NONE 0x0000000000000001LL
455 #define PLAYER_TITLE_PRIVATE 0x0000000000000002LL // 1
456 #define PLAYER_TITLE_CORPORAL 0x0000000000000004LL // 2
457 #define PLAYER_TITLE_SERGEANT_A 0x0000000000000008LL // 3
458 #define PLAYER_TITLE_MASTER_SERGEANT 0x0000000000000010LL // 4
459 #define PLAYER_TITLE_SERGEANT_MAJOR 0x0000000000000020LL // 5
460 #define PLAYER_TITLE_KNIGHT 0x0000000000000040LL // 6
461 #define PLAYER_TITLE_KNIGHT_LIEUTENANT 0x0000000000000080LL // 7
462 #define PLAYER_TITLE_KNIGHT_CAPTAIN 0x0000000000000100LL // 8
463 #define PLAYER_TITLE_KNIGHT_CHAMPION 0x0000000000000200LL // 9
464 #define PLAYER_TITLE_LIEUTENANT_COMMANDER 0x0000000000000400LL // 10
465 #define PLAYER_TITLE_COMMANDER 0x0000000000000800LL // 11
466 #define PLAYER_TITLE_MARSHAL 0x0000000000001000LL // 12
467 #define PLAYER_TITLE_FIELD_MARSHAL 0x0000000000002000LL // 13
468 #define PLAYER_TITLE_GRAND_MARSHAL 0x0000000000004000LL // 14
469 #define PLAYER_TITLE_SCOUT 0x0000000000008000LL // 15
470 #define PLAYER_TITLE_GRUNT 0x0000000000010000LL // 16
471 #define PLAYER_TITLE_SERGEANT_H 0x0000000000020000LL // 17
472 #define PLAYER_TITLE_SENIOR_SERGEANT 0x0000000000040000LL // 18
473 #define PLAYER_TITLE_FIRST_SERGEANT 0x0000000000080000LL // 19
474 #define PLAYER_TITLE_STONE_GUARD 0x0000000000100000LL // 20
475 #define PLAYER_TITLE_BLOOD_GUARD 0x0000000000200000LL // 21
476 #define PLAYER_TITLE_LEGIONNAIRE 0x0000000000400000LL // 22
477 #define PLAYER_TITLE_CENTURION 0x0000000000800000LL // 23
478 #define PLAYER_TITLE_CHAMPION 0x0000000001000000LL // 24
479 #define PLAYER_TITLE_LIEUTENANT_GENERAL 0x0000000002000000LL // 25
480 #define PLAYER_TITLE_GENERAL 0x0000000004000000LL // 26
481 #define PLAYER_TITLE_WARLORD 0x0000000008000000LL // 27
482 #define PLAYER_TITLE_HIGH_WARLORD 0x0000000010000000LL // 28
483 #define PLAYER_TITLE_GLADIATOR 0x0000000020000000LL // 29
484 #define PLAYER_TITLE_DUELIST 0x0000000040000000LL // 30
485 #define PLAYER_TITLE_RIVAL 0x0000000080000000LL // 31
486 #define PLAYER_TITLE_CHALLENGER 0x0000000100000000LL // 32
487 #define PLAYER_TITLE_SCARAB_LORD 0x0000000200000000LL // 33
488 #define PLAYER_TITLE_CONQUEROR 0x0000000400000000LL // 34
489 #define PLAYER_TITLE_JUSTICAR 0x0000000800000000LL // 35
490 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36
491 #define PLAYER_TITLE_MERCILESS_GLADIATOR 0x0000002000000000LL // 37
492 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN 0x0000004000000000LL // 38
493 #define PLAYER_TITLE_HAND_OF_ADAL 0x0000008000000000LL // 39
494 #define PLAYER_TITLE_VENGEFUL_GLADIATOR 0x0000010000000000LL // 40
496 // used in PLAYER_FIELD_BYTES values
497 enum PlayerFieldByteFlags
499 PLAYER_FIELD_BYTE_TRACK_STEALTHED
= 0x00000002,
500 PLAYER_FIELD_BYTE_RELEASE_TIMER
= 0x00000008, // Display time till auto release spirit
501 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW
= 0x00000010 // Display no "release spirit" window at all
504 // used in PLAYER_FIELD_BYTES2 values
505 enum PlayerFieldByte2Flags
507 PLAYER_FIELD_BYTE2_NONE
= 0x0000,
508 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
= 0x4000
511 enum ActivateTaxiReplies
514 ERR_TAXIUNSPECIFIEDSERVERERROR
= 1,
515 ERR_TAXINOSUCHPATH
= 2,
516 ERR_TAXINOTENOUGHMONEY
= 3,
517 ERR_TAXITOOFARAWAY
= 4,
518 ERR_TAXINOVENDORNEARBY
= 5,
519 ERR_TAXINOTVISITED
= 6,
520 ERR_TAXIPLAYERBUSY
= 7,
521 ERR_TAXIPLAYERALREADYMOUNTED
= 8,
522 ERR_TAXIPLAYERSHAPESHIFTED
= 9,
523 ERR_TAXIPLAYERMOVING
= 10,
524 ERR_TAXISAMENODE
= 11,
525 ERR_TAXINOTSTANDING
= 12
533 LOOT_PICKPOCKETING
= 4, // unsupported by client, sending LOOT_SKINNING instead
534 LOOT_DISENCHANTING
= 5, // unsupported by client, sending LOOT_SKINNING instead
535 LOOT_PROSPECTING
= 6, // unsupported by client, sending LOOT_SKINNING instead
536 LOOT_INSIGNIA
= 7, // unsupported by client, sending LOOT_SKINNING instead
537 LOOT_FISHINGHOLE
= 8, // unsupported by client, sending LOOT_FISHING instead
538 LOOT_MILLING
= 9 // unsupported by client, sending LOOT_SKINNING instead
549 enum PlayerExtraFlags
552 PLAYER_EXTRA_GM_ON
= 0x0001,
553 PLAYER_EXTRA_GM_ACCEPT_TICKETS
= 0x0002,
554 PLAYER_EXTRA_ACCEPT_WHISPERS
= 0x0004,
555 PLAYER_EXTRA_TAXICHEAT
= 0x0008,
556 PLAYER_EXTRA_GM_INVISIBLE
= 0x0010,
557 PLAYER_EXTRA_GM_CHAT
= 0x0020, // Show GM badge in chat messages
560 PLAYER_EXTRA_PVP_DEATH
= 0x0100 // store PvP death status until corpse creating.
568 AT_LOGIN_RESET_SPELLS
= 2,
569 AT_LOGIN_RESET_TALENTS
= 4,
570 AT_LOGIN_CUSTOMIZE
= 8
573 typedef std::map
<uint32
, QuestStatusData
> QuestStatusMap
;
575 enum QuestSlotOffsets
578 QUEST_STATE_OFFSET
= 1,
579 QUEST_COUNTS_OFFSET
= 2,
580 QUEST_TIME_OFFSET
= 3
583 #define MAX_QUEST_OFFSET 4
585 enum QuestSlotStateMask
587 QUEST_STATE_NONE
= 0x0000,
588 QUEST_STATE_COMPLETE
= 0x0001,
589 QUEST_STATE_FAIL
= 0x0002
599 // first slot for item stored (in any way in player m_items data)
600 PLAYER_SLOT_START
= 0,
601 // last+1 slot for item stored (in any way in player m_items data)
602 PLAYER_SLOT_END
= 200,
603 PLAYER_SLOTS_COUNT
= (PLAYER_SLOT_END
- PLAYER_SLOT_START
)
608 EQUIPMENT_SLOT_START
= 0,
609 EQUIPMENT_SLOT_HEAD
= 0,
610 EQUIPMENT_SLOT_NECK
= 1,
611 EQUIPMENT_SLOT_SHOULDERS
= 2,
612 EQUIPMENT_SLOT_BODY
= 3,
613 EQUIPMENT_SLOT_CHEST
= 4,
614 EQUIPMENT_SLOT_WAIST
= 5,
615 EQUIPMENT_SLOT_LEGS
= 6,
616 EQUIPMENT_SLOT_FEET
= 7,
617 EQUIPMENT_SLOT_WRISTS
= 8,
618 EQUIPMENT_SLOT_HANDS
= 9,
619 EQUIPMENT_SLOT_FINGER1
= 10,
620 EQUIPMENT_SLOT_FINGER2
= 11,
621 EQUIPMENT_SLOT_TRINKET1
= 12,
622 EQUIPMENT_SLOT_TRINKET2
= 13,
623 EQUIPMENT_SLOT_BACK
= 14,
624 EQUIPMENT_SLOT_MAINHAND
= 15,
625 EQUIPMENT_SLOT_OFFHAND
= 16,
626 EQUIPMENT_SLOT_RANGED
= 17,
627 EQUIPMENT_SLOT_TABARD
= 18,
628 EQUIPMENT_SLOT_END
= 19
633 INVENTORY_SLOT_BAG_0
= 255,
634 INVENTORY_SLOT_BAG_START
= 19,
635 INVENTORY_SLOT_BAG_1
= 19,
636 INVENTORY_SLOT_BAG_2
= 20,
637 INVENTORY_SLOT_BAG_3
= 21,
638 INVENTORY_SLOT_BAG_4
= 22,
639 INVENTORY_SLOT_BAG_END
= 23,
641 INVENTORY_SLOT_ITEM_START
= 23,
642 INVENTORY_SLOT_ITEM_1
= 23,
643 INVENTORY_SLOT_ITEM_2
= 24,
644 INVENTORY_SLOT_ITEM_3
= 25,
645 INVENTORY_SLOT_ITEM_4
= 26,
646 INVENTORY_SLOT_ITEM_5
= 27,
647 INVENTORY_SLOT_ITEM_6
= 28,
648 INVENTORY_SLOT_ITEM_7
= 29,
649 INVENTORY_SLOT_ITEM_8
= 30,
650 INVENTORY_SLOT_ITEM_9
= 31,
651 INVENTORY_SLOT_ITEM_10
= 32,
652 INVENTORY_SLOT_ITEM_11
= 33,
653 INVENTORY_SLOT_ITEM_12
= 34,
654 INVENTORY_SLOT_ITEM_13
= 35,
655 INVENTORY_SLOT_ITEM_14
= 36,
656 INVENTORY_SLOT_ITEM_15
= 37,
657 INVENTORY_SLOT_ITEM_16
= 38,
658 INVENTORY_SLOT_ITEM_END
= 39
663 BANK_SLOT_ITEM_START
= 39,
664 BANK_SLOT_ITEM_1
= 39,
665 BANK_SLOT_ITEM_2
= 40,
666 BANK_SLOT_ITEM_3
= 41,
667 BANK_SLOT_ITEM_4
= 42,
668 BANK_SLOT_ITEM_5
= 43,
669 BANK_SLOT_ITEM_6
= 44,
670 BANK_SLOT_ITEM_7
= 45,
671 BANK_SLOT_ITEM_8
= 46,
672 BANK_SLOT_ITEM_9
= 47,
673 BANK_SLOT_ITEM_10
= 48,
674 BANK_SLOT_ITEM_11
= 49,
675 BANK_SLOT_ITEM_12
= 50,
676 BANK_SLOT_ITEM_13
= 51,
677 BANK_SLOT_ITEM_14
= 52,
678 BANK_SLOT_ITEM_15
= 53,
679 BANK_SLOT_ITEM_16
= 54,
680 BANK_SLOT_ITEM_17
= 55,
681 BANK_SLOT_ITEM_18
= 56,
682 BANK_SLOT_ITEM_19
= 57,
683 BANK_SLOT_ITEM_20
= 58,
684 BANK_SLOT_ITEM_21
= 59,
685 BANK_SLOT_ITEM_22
= 60,
686 BANK_SLOT_ITEM_23
= 61,
687 BANK_SLOT_ITEM_24
= 62,
688 BANK_SLOT_ITEM_25
= 63,
689 BANK_SLOT_ITEM_26
= 64,
690 BANK_SLOT_ITEM_27
= 65,
691 BANK_SLOT_ITEM_28
= 66,
692 BANK_SLOT_ITEM_END
= 67,
694 BANK_SLOT_BAG_START
= 67,
695 BANK_SLOT_BAG_1
= 67,
696 BANK_SLOT_BAG_2
= 68,
697 BANK_SLOT_BAG_3
= 69,
698 BANK_SLOT_BAG_4
= 70,
699 BANK_SLOT_BAG_5
= 71,
700 BANK_SLOT_BAG_6
= 72,
701 BANK_SLOT_BAG_7
= 73,
702 BANK_SLOT_BAG_END
= 74
707 // stored in m_buybackitems
708 BUYBACK_SLOT_START
= 74,
718 BUYBACK_SLOT_10
= 83,
719 BUYBACK_SLOT_11
= 84,
720 BUYBACK_SLOT_12
= 85,
721 BUYBACK_SLOT_END
= 86
726 KEYRING_SLOT_START
= 86,
727 KEYRING_SLOT_END
= 118
732 VANITYPET_SLOT_START
= 118,
733 VANITYPET_SLOT_END
= 136
736 enum CurrencyTokenSlots
738 CURRENCYTOKEN_SLOT_START
= 136,
739 CURRENCYTOKEN_SLOT_END
= 168
744 QUESTBAG_SLOT_START
= 168,
745 QUESTBAG_SLOT_END
= 200
750 ItemPosCount(uint16 _pos
, uint32 _count
) : pos(_pos
), count(_count
) {}
751 bool isContainedIn(std::vector
<ItemPosCount
> const& vec
) const;
755 typedef std::vector
<ItemPosCount
> ItemPosCountVec
;
759 TRADE_SLOT_COUNT
= 7,
760 TRADE_SLOT_TRADED_COUNT
= 6,
761 TRADE_SLOT_NONTRADED
= 6
764 enum TransferAbortReason
766 TRANSFER_ABORT_ERROR
= 0x00,
767 TRANSFER_ABORT_MAX_PLAYERS
= 0x01, // Transfer Aborted: instance is full
768 TRANSFER_ABORT_NOT_FOUND
= 0x02, // Transfer Aborted: instance not found
769 TRANSFER_ABORT_TOO_MANY_INSTANCES
= 0x03, // You have entered too many instances recently.
770 TRANSFER_ABORT_ZONE_IN_COMBAT
= 0x05, // Unable to zone in while an encounter is in progress.
771 TRANSFER_ABORT_INSUF_EXPAN_LVL
= 0x06, // You must have <TBC,WotLK> expansion installed to access this area.
772 TRANSFER_ABORT_DIFFICULTY
= 0x07, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
773 TRANSFER_ABORT_UNIQUE_MESSAGE
= 0x08, // Until you've escaped TLK's grasp, you cannot leave this place!
774 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES
= 0x09 // Additional instances cannot be launched, please try again later.
777 enum InstanceResetWarningType
779 RAID_INSTANCE_WARNING_HOURS
= 1, // WARNING! %s is scheduled to reset in %d hour(s).
780 RAID_INSTANCE_WARNING_MIN
= 2, // WARNING! %s is scheduled to reset in %d minute(s)!
781 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!
782 RAID_INSTANCE_WELCOME
= 4 // Welcome to %s. This raid instance is scheduled to reset in %s.
794 float t_x
, t_y
, t_z
, t_o
;
797 // swimming and unknown
802 float j_unk
, j_sinAngle
, j_cosAngle
, j_xyspeed
;
809 time
= t_time
= fallTime
= 0;
811 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
;
815 void SetMovementFlags(uint32 _flags
)
821 // flags that use in movement check for example at spell casting
822 MovementFlags
const movementFlagsMask
= MovementFlags(
823 MOVEMENTFLAG_FORWARD
|MOVEMENTFLAG_BACKWARD
|MOVEMENTFLAG_STRAFE_LEFT
|MOVEMENTFLAG_STRAFE_RIGHT
|
824 MOVEMENTFLAG_PITCH_UP
|MOVEMENTFLAG_PITCH_DOWN
|MOVEMENTFLAG_FLY_UNK1
|
825 MOVEMENTFLAG_JUMPING
|MOVEMENTFLAG_FALLING
|MOVEMENTFLAG_FLY_UP
|
826 MOVEMENTFLAG_FLYING
|MOVEMENTFLAG_SPLINE
829 MovementFlags
const movementOrTurningFlagsMask
= MovementFlags(
830 movementFlagsMask
| MOVEMENTFLAG_LEFT
| MOVEMENTFLAG_RIGHT
837 REST_TYPE_IN_TAVERN
= 1,
838 REST_TYPE_IN_CITY
= 2
841 enum DuelCompleteType
848 enum TeleportToOptions
850 TELE_TO_GM_MODE
= 0x01,
851 TELE_TO_NOT_LEAVE_TRANSPORT
= 0x02,
852 TELE_TO_NOT_LEAVE_COMBAT
= 0x04,
853 TELE_TO_NOT_UNSUMMON_PET
= 0x08,
854 TELE_TO_SPELL
= 0x10,
857 /// Type of environmental damages
858 enum EnviromentalDamage
860 DAMAGE_EXHAUSTED
= 0,
866 DAMAGE_FALL_TO_VOID
= 6 // custom case for fall without durability loss
869 // used at player loading query list preparing, and later result selection
870 enum PlayerLoginQueryIndex
872 PLAYER_LOGIN_QUERY_LOADFROM
= 0,
873 PLAYER_LOGIN_QUERY_LOADGROUP
= 1,
874 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES
= 2,
875 PLAYER_LOGIN_QUERY_LOADAURAS
= 3,
876 PLAYER_LOGIN_QUERY_LOADSPELLS
= 4,
877 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS
= 5,
878 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS
= 6,
879 PLAYER_LOGIN_QUERY_LOADTUTORIALS
= 7, // common for all characters for some account at specific realm
880 PLAYER_LOGIN_QUERY_LOADREPUTATION
= 8,
881 PLAYER_LOGIN_QUERY_LOADINVENTORY
= 9,
882 PLAYER_LOGIN_QUERY_LOADACTIONS
= 10,
883 PLAYER_LOGIN_QUERY_LOADMAILCOUNT
= 11,
884 PLAYER_LOGIN_QUERY_LOADMAILDATE
= 12,
885 PLAYER_LOGIN_QUERY_LOADSOCIALLIST
= 13,
886 PLAYER_LOGIN_QUERY_LOADHOMEBIND
= 14,
887 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS
= 15,
888 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES
= 16,
889 PLAYER_LOGIN_QUERY_LOADGUILD
= 17,
890 PLAYER_LOGIN_QUERY_LOADARENAINFO
= 18,
891 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS
= 19,
892 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS
= 20,
893 MAX_PLAYER_LOGIN_QUERY
= 21
897 // Player summoning auto-decline time (in secs)
898 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
899 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
901 struct InstancePlayerBind
905 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
906 that aren't already permanently bound when they are inside when a boss is killed
907 or when they enter an instance that the group leader is permanently bound to. */
908 InstancePlayerBind() : save(NULL
), perm(false) {}
911 class MANGOS_DLL_SPEC PlayerTaxi
917 void InitTaxiNodesForLevel(uint32 race
, uint32 chrClass
, uint32 level
);
918 void LoadTaxiMask(const char* data
);
920 bool IsTaximaskNodeKnown(uint32 nodeidx
) const
922 uint8 field
= uint8((nodeidx
- 1) / 32);
923 uint32 submask
= 1<<((nodeidx
-1)%32);
924 return (m_taximask
[field
] & submask
) == submask
;
926 bool SetTaximaskNode(uint32 nodeidx
)
928 uint8 field
= uint8((nodeidx
- 1) / 32);
929 uint32 submask
= 1<<((nodeidx
-1)%32);
930 if ((m_taximask
[field
] & submask
) != submask
)
932 m_taximask
[field
] |= submask
;
938 void AppendTaximaskTo(ByteBuffer
& data
,bool all
);
941 bool LoadTaxiDestinationsFromString(const std::string
& values
);
942 std::string
SaveTaxiDestinationsToString();
944 void ClearTaxiDestinations() { m_TaxiDestinations
.clear(); }
945 void AddTaxiDestination(uint32 dest
) { m_TaxiDestinations
.push_back(dest
); }
946 uint32
GetTaxiSource() const { return m_TaxiDestinations
.empty() ? 0 : m_TaxiDestinations
.front(); }
947 uint32
GetTaxiDestination() const { return m_TaxiDestinations
.size() < 2 ? 0 : m_TaxiDestinations
[1]; }
948 uint32
GetCurrentTaxiPath() const;
949 uint32
NextTaxiDestination()
951 m_TaxiDestinations
.pop_front();
952 return GetTaxiDestination();
954 bool empty() const { return m_TaxiDestinations
.empty(); }
956 friend std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
959 std::deque
<uint32
> m_TaxiDestinations
;
962 std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
964 class MANGOS_DLL_SPEC Player
: public Unit
966 friend class WorldSession
;
967 friend void Item::AddToUpdateQueueOf(Player
*player
);
968 friend void Item::RemoveFromUpdateQueueOf(Player
*player
);
970 explicit Player (WorldSession
*session
);
973 void CleanupsBeforeDelete();
975 static UpdateMask updateVisualBits
;
976 static void InitVisibleBits();
979 void RemoveFromWorld();
981 bool TeleportTo(uint32 mapid
, float x
, float y
, float z
, float orientation
, uint32 options
= 0);
983 bool TeleportTo(WorldLocation
const &loc
, uint32 options
= 0)
985 return TeleportTo(loc
.mapid
, loc
.x
, loc
.y
, loc
.z
, options
);
988 void SetSummonPoint(uint32 mapid
, float x
, float y
, float z
)
990 m_summon_expire
= time(NULL
) + MAX_PLAYER_SUMMON_DELAY
;
991 m_summon_mapid
= mapid
;
996 void SummonIfPossible(bool agree
);
998 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
);
1000 void Update( uint32 time
);
1002 void BuildEnumData( QueryResult
* result
, WorldPacket
* p_data
);
1004 void SetInWater(bool apply
);
1006 bool IsInWater() const { return m_isInWater
; }
1007 bool IsUnderWater() const;
1009 void SendInitialPacketsBeforeAddToMap();
1010 void SendInitialPacketsAfterAddToMap();
1011 void SendTransferAborted(uint32 mapid
, uint8 reason
, uint8 arg
= 0);
1012 void SendInstanceResetWarning(uint32 mapid
, uint32 time
);
1014 bool CanInteractWithNPCs(bool alive
= true) const;
1018 bool isAFK() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_AFK
); };
1019 bool isDND() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_DND
); };
1020 uint8
chatTag() const;
1024 uint32
GetBarberShopCost(uint8 newhairstyle
, uint8 newhaircolor
, uint8 newfacialhair
);
1026 PlayerSocial
*GetSocial() { return m_social
; }
1029 void InitTaxiNodesForLevel() { m_taxi
.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1030 bool ActivateTaxiPathTo(std::vector
<uint32
> const& nodes
, uint32 mount_id
= 0 , Creature
* npc
= NULL
);
1031 // mount_id can be used in scripting calls
1032 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_ACCEPT_TICKETS
); }
1033 void SetAcceptTicket(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_ACCEPT_TICKETS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS
; }
1034 bool isAcceptWhispers() const { return m_ExtraFlags
& PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1035 void SetAcceptWhispers(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_ACCEPT_WHISPERS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1036 bool isGameMaster() const { return m_ExtraFlags
& PLAYER_EXTRA_GM_ON
; }
1037 void SetGameMaster(bool on
);
1038 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_CHAT
); }
1039 void SetGMChat(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_CHAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_CHAT
; }
1040 bool isTaxiCheater() const { return m_ExtraFlags
& PLAYER_EXTRA_TAXICHEAT
; }
1041 void SetTaxiCheater(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_TAXICHEAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_TAXICHEAT
; }
1042 bool isGMVisible() const { return !(m_ExtraFlags
& PLAYER_EXTRA_GM_INVISIBLE
); }
1043 void SetGMVisible(bool on
);
1044 void SetPvPDeath(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_PVP_DEATH
; else m_ExtraFlags
&= ~PLAYER_EXTRA_PVP_DEATH
; }
1046 void GiveXP(uint32 xp
, Unit
* victim
);
1047 void GiveLevel(uint32 level
);
1048 void InitStatsForLevel(bool reapplyMods
= false);
1050 // Played Time Stuff
1053 uint32 m_Played_time
[2];
1054 uint32
GetTotalPlayedTime() { return m_Played_time
[0]; };
1055 uint32
GetLevelPlayedTime() { return m_Played_time
[1]; };
1057 void setDeathState(DeathState s
); // overwrite Unit::setDeathState
1059 void InnEnter (int time
,uint32 mapid
, float x
,float y
,float z
)
1061 inn_pos_mapid
= mapid
;
1065 time_inn_enter
= time
;
1068 float GetRestBonus() const { return m_rest_bonus
; };
1069 void SetRestBonus(float rest_bonus_new
);
1071 RestType
GetRestType() const { return rest_type
; };
1072 void SetRestType(RestType n_r_type
) { rest_type
= n_r_type
; };
1074 uint32
GetInnPosMapId() const { return inn_pos_mapid
; };
1075 float GetInnPosX() const { return inn_pos_x
; };
1076 float GetInnPosY() const { return inn_pos_y
; };
1077 float GetInnPosZ() const { return inn_pos_z
; };
1079 int GetTimeInnEnter() const { return time_inn_enter
; };
1080 void UpdateInnerTime (int time
) { time_inn_enter
= time
; };
1082 void RemovePet(Pet
* pet
, PetSaveMode mode
, bool returnreagent
= false);
1083 void RemoveMiniPet();
1085 void SetMiniPet(Pet
* pet
) { m_miniPet
= pet
->GetGUID(); }
1086 void RemoveGuardians();
1087 bool HasGuardianWithEntry(uint32 entry
);
1088 void AddGuardian(Pet
* pet
) { m_guardianPets
.insert(pet
->GetGUID()); }
1089 GuardianPetList
const& GetGuardians() const { return m_guardianPets
; }
1092 void Say(const std::string
& text
, const uint32 language
);
1093 void Yell(const std::string
& text
, const uint32 language
);
1094 void TextEmote(const std::string
& text
);
1095 void Whisper(const std::string
& text
, const uint32 language
,uint64 receiver
);
1096 void BuildPlayerChat(WorldPacket
*data
, uint8 msgtype
, const std::string
& text
, uint32 language
) const;
1098 /*********************************************************/
1099 /*** STORAGE SYSTEM ***/
1100 /*********************************************************/
1102 void SetVirtualItemSlot( uint8 i
, Item
* item
);
1103 void SetSheath( uint32 sheathed
);
1104 uint8
FindEquipSlot( ItemPrototype
const* proto
, uint32 slot
, bool swap
) const;
1105 uint32
GetItemCount( uint32 item
, bool inBankAlso
= false, Item
* skipItem
= NULL
) const;
1106 Item
* GetItemByGuid( uint64 guid
) const;
1107 Item
* GetItemByPos( uint16 pos
) const;
1108 Item
* GetItemByPos( uint8 bag
, uint8 slot
) const;
1109 Item
* GetWeaponForAttack(WeaponAttackType attackType
, bool useable
= false) const;
1110 Item
* GetShield(bool useable
= false) const;
1111 static uint32
GetAttackBySlot( uint8 slot
); // MAX_ATTACK if not weapon slot
1112 std::vector
<Item
*> &GetItemUpdateQueue() { return m_itemUpdateQueue
; }
1113 static bool IsInventoryPos( uint16 pos
) { return IsInventoryPos(pos
>> 8,pos
& 255); }
1114 static bool IsInventoryPos( uint8 bag
, uint8 slot
);
1115 static bool IsEquipmentPos( uint16 pos
) { return IsEquipmentPos(pos
>> 8,pos
& 255); }
1116 static bool IsEquipmentPos( uint8 bag
, uint8 slot
);
1117 static bool IsBagPos( uint16 pos
);
1118 static bool IsBankPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1119 static bool IsBankPos( uint8 bag
, uint8 slot
);
1120 bool IsValidPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1121 bool IsValidPos( uint8 bag
, uint8 slot
);
1122 bool HasBankBagSlot( uint8 slot
) const;
1123 bool HasItemCount( uint32 item
, uint32 count
, bool inBankAlso
= false ) const;
1124 bool HasItemFitToSpellReqirements(SpellEntry
const* spellInfo
, Item
const* ignoreItem
= NULL
);
1125 bool CanNoReagentCast(SpellEntry
const* spellInfo
) const;
1126 Item
* GetItemOrItemWithGemEquipped( uint32 item
) const;
1127 uint8
CanTakeMoreSimilarItems(Item
* pItem
) const { return _CanTakeMoreSimilarItems(pItem
->GetEntry(),pItem
->GetCount(),pItem
); }
1128 uint8
CanTakeMoreSimilarItems(uint32 entry
, uint32 count
) const { return _CanTakeMoreSimilarItems(entry
,count
,NULL
); }
1129 uint8
CanStoreNewItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 item
, uint32 count
, uint32
* no_space_count
= NULL
) const
1131 return _CanStoreItem(bag
, slot
, dest
, item
, count
, NULL
, false, no_space_count
);
1133 uint8
CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
= false ) const
1136 return EQUIP_ERR_ITEM_NOT_FOUND
;
1137 uint32 count
= pItem
->GetCount();
1138 return _CanStoreItem( bag
, slot
, dest
, pItem
->GetEntry(), count
, pItem
, swap
, NULL
);
1141 uint8
CanStoreItems( Item
**pItem
,int count
) const;
1142 uint8
CanEquipNewItem( uint8 slot
, uint16
&dest
, uint32 item
, bool swap
) const;
1143 uint8
CanEquipItem( uint8 slot
, uint16
&dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1144 uint8
CanUnequipItems( uint32 item
, uint32 count
) const;
1145 uint8
CanUnequipItem( uint16 src
, bool swap
) const;
1146 uint8
CanBankItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1147 uint8
CanUseItem( Item
*pItem
, bool not_loading
= true ) const;
1148 bool HasItemTotemCategory( uint32 TotemCategory
) const;
1149 bool CanUseItem( ItemPrototype
const *pItem
);
1150 uint8
CanUseAmmo( uint32 item
) const;
1151 Item
* StoreNewItem( ItemPosCountVec
const& pos
, uint32 item
, bool update
,int32 randomPropertyId
= 0 );
1152 Item
* StoreItem( ItemPosCountVec
const& pos
, Item
*pItem
, bool update
);
1153 Item
* EquipNewItem( uint16 pos
, uint32 item
, bool update
);
1154 Item
* EquipItem( uint16 pos
, Item
*pItem
, bool update
);
1155 void AutoUnequipOffhandIfNeed();
1156 bool StoreNewItemInBestSlots(uint32 item_id
, uint32 item_count
);
1158 uint8
_CanTakeMoreSimilarItems(uint32 entry
, uint32 count
, Item
* pItem
, uint32
* no_space_count
= NULL
) const;
1159 uint8
_CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 entry
, uint32 count
, Item
*pItem
= NULL
, bool swap
= false, uint32
* no_space_count
= NULL
) const;
1161 void ApplyEquipCooldown( Item
* pItem
);
1162 void SetAmmo( uint32 item
);
1164 float GetAmmoDPS() const { return m_ammoDPS
; }
1165 bool CheckAmmoCompatibility(const ItemPrototype
*ammo_proto
) const;
1166 void QuickEquipItem( uint16 pos
, Item
*pItem
);
1167 void VisualizeItem( uint8 slot
, Item
*pItem
);
1168 void SetVisibleItemSlot(uint8 slot
, Item
*pItem
);
1169 Item
* BankItem( ItemPosCountVec
const& dest
, Item
*pItem
, bool update
)
1171 return StoreItem( dest
, pItem
, update
);
1173 Item
* BankItem( uint16 pos
, Item
*pItem
, bool update
);
1174 void RemoveItem( uint8 bag
, uint8 slot
, bool update
);
1175 void MoveItemFromInventory(uint8 bag
, uint8 slot
, bool update
);
1176 // in trade, auction, guild bank, mail....
1177 void MoveItemToInventory(ItemPosCountVec
const& dest
, Item
* pItem
, bool update
, bool in_characterInventoryDB
= false);
1178 // in trade, guild bank, mail....
1179 void RemoveItemDependentAurasAndCasts( Item
* pItem
);
1180 void DestroyItem( uint8 bag
, uint8 slot
, bool update
);
1181 void DestroyItemCount( uint32 item
, uint32 count
, bool update
, bool unequip_check
= false);
1182 void DestroyItemCount( Item
* item
, uint32
& count
, bool update
);
1183 void DestroyConjuredItems( bool update
);
1184 void DestroyZoneLimitedItem( bool update
, uint32 new_zone
);
1185 void SplitItem( uint16 src
, uint16 dst
, uint32 count
);
1186 void SwapItem( uint16 src
, uint16 dst
);
1187 void AddItemToBuyBackSlot( Item
*pItem
);
1188 Item
* GetItemFromBuyBackSlot( uint32 slot
);
1189 void RemoveItemFromBuyBackSlot( uint32 slot
, bool del
);
1190 uint32
GetMaxKeyringSize() const { return KEYRING_SLOT_END
-KEYRING_SLOT_START
; }
1191 void SendEquipError( uint8 msg
, Item
* pItem
, Item
*pItem2
);
1192 void SendBuyError( uint8 msg
, Creature
* pCreature
, uint32 item
, uint32 param
);
1193 void SendSellError( uint8 msg
, Creature
* pCreature
, uint64 guid
, uint32 param
);
1194 void AddWeaponProficiency(uint32 newflag
) { m_WeaponProficiency
|= newflag
; }
1195 void AddArmorProficiency(uint32 newflag
) { m_ArmorProficiency
|= newflag
; }
1196 uint32
GetWeaponProficiency() const { return m_WeaponProficiency
; }
1197 uint32
GetArmorProficiency() const { return m_ArmorProficiency
; }
1198 bool IsInFeralForm() const { return m_form
== FORM_CAT
|| m_form
== FORM_BEAR
|| m_form
== FORM_DIREBEAR
; }
1199 bool IsUseEquipedWeapon( bool mainhand
) const
1201 // disarm applied only to mainhand weapon
1202 return !IsInFeralForm() && (!mainhand
|| !HasFlag(UNIT_FIELD_FLAGS
,UNIT_FLAG_DISARMED
) );
1204 bool IsTwoHandUsed() const
1206 Item
* mainItem
= GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_MAINHAND
);
1207 return mainItem
&& mainItem
->GetProto()->InventoryType
== INVTYPE_2HWEAPON
&& !CanTitanGrip();
1209 void SendNewItem( Item
*item
, uint32 count
, bool received
, bool created
, bool broadcast
= false );
1210 bool BuyItemFromVendor(uint64 vendorguid
, uint32 item
, uint8 count
, uint64 bagguid
, uint8 slot
);
1212 float GetReputationPriceDiscount( Creature
const* pCreature
) const;
1213 Player
* GetTrader() const { return pTrader
; }
1215 void TradeCancel(bool sendback
);
1216 uint16
GetItemPosByTradeSlot(uint32 slot
) const { return tradeItems
[slot
]; }
1218 void UpdateEnchantTime(uint32 time
);
1219 void UpdateItemDuration(uint32 time
, bool realtimeonly
=false);
1220 void AddEnchantmentDurations(Item
*item
);
1221 void RemoveEnchantmentDurations(Item
*item
);
1222 void RemoveAllEnchantments(EnchantmentSlot slot
);
1223 void AddEnchantmentDuration(Item
*item
,EnchantmentSlot slot
,uint32 duration
);
1224 void ApplyEnchantment(Item
*item
,EnchantmentSlot slot
,bool apply
, bool apply_dur
= true, bool ignore_condition
= false);
1225 void ApplyEnchantment(Item
*item
,bool apply
);
1226 void SendEnchantmentDurations();
1227 void AddItemDurations(Item
*item
);
1228 void RemoveItemDurations(Item
*item
);
1229 void SendItemDurations();
1233 uint32 m_stableSlots
;
1235 /*********************************************************/
1236 /*** QUEST SYSTEM ***/
1237 /*********************************************************/
1239 void PrepareQuestMenu( uint64 guid
);
1240 void SendPreparedQuest( uint64 guid
);
1241 bool IsActiveQuest( uint32 quest_id
) const;
1242 Quest
const *GetNextQuest( uint64 guid
, Quest
const *pQuest
);
1243 bool CanSeeStartQuest( Quest
const *pQuest
);
1244 bool CanTakeQuest( Quest
const *pQuest
, bool msg
);
1245 bool CanAddQuest( Quest
const *pQuest
, bool msg
);
1246 bool CanCompleteQuest( uint32 quest_id
);
1247 bool CanCompleteRepeatableQuest(Quest
const *pQuest
);
1248 bool CanRewardQuest( Quest
const *pQuest
, bool msg
);
1249 bool CanRewardQuest( Quest
const *pQuest
, uint32 reward
, bool msg
);
1250 void AddQuest( Quest
const *pQuest
, Object
*questGiver
);
1251 void CompleteQuest( uint32 quest_id
);
1252 void IncompleteQuest( uint32 quest_id
);
1253 void RewardQuest( Quest
const *pQuest
, uint32 reward
, Object
* questGiver
, bool announce
= true );
1254 void FailQuest( uint32 quest_id
);
1255 void FailTimedQuest( uint32 quest_id
);
1256 bool SatisfyQuestSkillOrClass( Quest
const* qInfo
, bool msg
);
1257 bool SatisfyQuestLevel( Quest
const* qInfo
, bool msg
);
1258 bool SatisfyQuestLog( bool msg
);
1259 bool SatisfyQuestPreviousQuest( Quest
const* qInfo
, bool msg
);
1260 bool SatisfyQuestRace( Quest
const* qInfo
, bool msg
);
1261 bool SatisfyQuestReputation( Quest
const* qInfo
, bool msg
);
1262 bool SatisfyQuestStatus( Quest
const* qInfo
, bool msg
);
1263 bool SatisfyQuestTimed( Quest
const* qInfo
, bool msg
);
1264 bool SatisfyQuestExclusiveGroup( Quest
const* qInfo
, bool msg
);
1265 bool SatisfyQuestNextChain( Quest
const* qInfo
, bool msg
);
1266 bool SatisfyQuestPrevChain( Quest
const* qInfo
, bool msg
);
1267 bool SatisfyQuestDay( Quest
const* qInfo
, bool msg
);
1268 bool GiveQuestSourceItem( Quest
const *pQuest
);
1269 bool TakeQuestSourceItem( uint32 quest_id
, bool msg
);
1270 bool GetQuestRewardStatus( uint32 quest_id
) const;
1271 QuestStatus
GetQuestStatus( uint32 quest_id
) const;
1272 void SetQuestStatus( uint32 quest_id
, QuestStatus status
);
1274 void SetDailyQuestStatus( uint32 quest_id
);
1275 void ResetDailyQuestStatus();
1277 uint16
FindQuestSlot( uint32 quest_id
) const;
1278 uint32
GetQuestSlotQuestId(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
); }
1279 uint32
GetQuestSlotState(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
); }
1280 uint32
GetQuestSlotCounters(uint16 slot
)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
); }
1281 uint8
GetQuestSlotCounter(uint16 slot
,uint8 counter
) const { return GetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
); }
1282 uint32
GetQuestSlotTime(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
); }
1283 void SetQuestSlot(uint16 slot
,uint32 quest_id
, uint32 timer
= 0)
1285 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
,quest_id
);
1286 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,0);
1287 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,0);
1288 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
);
1290 void SetQuestSlotCounter(uint16 slot
,uint8 counter
,uint8 count
) { SetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
,count
); }
1291 void SetQuestSlotState(uint16 slot
,uint32 state
) { SetFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1292 void RemoveQuestSlotState(uint16 slot
,uint32 state
) { RemoveFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1293 void SetQuestSlotTimer(uint16 slot
,uint32 timer
) { SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
); }
1294 void SwapQuestSlot(uint16 slot1
,uint16 slot2
)
1296 for (int i
= 0; i
< MAX_QUEST_OFFSET
; ++i
)
1298 uint32 temp1
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
);
1299 uint32 temp2
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
);
1301 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
, temp2
);
1302 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
, temp1
);
1305 uint32
GetReqKillOrCastCurrentCount(uint32 quest_id
, int32 entry
);
1306 void AdjustQuestReqItemCount( Quest
const* pQuest
);
1307 void AreaExploredOrEventHappens( uint32 questId
);
1308 void GroupEventHappens( uint32 questId
, WorldObject
const* pEventObject
);
1309 void ItemAddedQuestCheck( uint32 entry
, uint32 count
);
1310 void ItemRemovedQuestCheck( uint32 entry
, uint32 count
);
1311 void KilledMonster( uint32 entry
, uint64 guid
);
1312 void CastedCreatureOrGO( uint32 entry
, uint64 guid
, uint32 spell_id
);
1313 void TalkedToCreature( uint32 entry
, uint64 guid
);
1314 void MoneyChanged( uint32 value
);
1315 bool HasQuestForItem( uint32 itemid
) const;
1316 bool HasQuestForGO(int32 GOId
);
1317 void UpdateForQuestsGO();
1318 bool CanShareQuest(uint32 quest_id
) const;
1320 void SendQuestComplete( uint32 quest_id
);
1321 void SendQuestReward( Quest
const *pQuest
, uint32 XP
, Object
* questGiver
);
1322 void SendQuestFailed( uint32 quest_id
);
1323 void SendQuestTimerFailed( uint32 quest_id
);
1324 void SendCanTakeQuestResponse( uint32 msg
);
1325 void SendPushToPartyResponse( Player
*pPlayer
, uint32 msg
);
1326 void SendQuestUpdateAddItem( Quest
const* pQuest
, uint32 item_idx
, uint32 count
);
1327 void SendQuestUpdateAddCreatureOrGo( Quest
const* pQuest
, uint64 guid
, uint32 creatureOrGO_idx
, uint32 old_count
, uint32 add_count
);
1329 uint64
GetDivider() { return m_divider
; };
1330 void SetDivider( uint64 guid
) { m_divider
= guid
; };
1332 uint32
GetInGameTime() { return m_ingametime
; };
1334 void SetInGameTime( uint32 time
) { m_ingametime
= time
; };
1336 void AddTimedQuest( uint32 quest_id
) { m_timedquests
.insert(quest_id
); }
1338 /*********************************************************/
1339 /*** LOAD SYSTEM ***/
1340 /*********************************************************/
1342 bool LoadFromDB(uint32 guid
, SqlQueryHolder
*holder
);
1343 bool MinimalLoadFromDB(QueryResult
*result
, uint32 guid
);
1344 static bool LoadValuesArrayFromDB(Tokens
& data
,uint64 guid
);
1345 static uint32
GetUInt32ValueFromArray(Tokens
const& data
, uint16 index
);
1346 static float GetFloatValueFromArray(Tokens
const& data
, uint16 index
);
1347 static uint32
GetUInt32ValueFromDB(uint16 index
, uint64 guid
);
1348 static float GetFloatValueFromDB(uint16 index
, uint64 guid
);
1349 static uint32
GetZoneIdFromDB(uint64 guid
);
1350 static bool LoadPositionFromDB(uint32
& mapid
, float& x
,float& y
,float& z
,float& o
, bool& in_flight
, uint64 guid
);
1352 /*********************************************************/
1353 /*** SAVE SYSTEM ***/
1354 /*********************************************************/
1357 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1358 void SaveDataFieldToDB();
1359 static bool SaveValuesArrayInDB(Tokens
const& data
,uint64 guid
);
1360 static void SetUInt32ValueInArray(Tokens
& data
,uint16 index
, uint32 value
);
1361 static void SetFloatValueInArray(Tokens
& data
,uint16 index
, float value
);
1362 static void SetUInt32ValueInDB(uint16 index
, uint32 value
, uint64 guid
);
1363 static void SetFloatValueInDB(uint16 index
, float value
, uint64 guid
);
1364 static void Customize(uint64 guid
, uint8 gender
, uint8 skin
, uint8 face
, uint8 hairStyle
, uint8 hairColor
, uint8 facialHair
);
1365 static void SavePositionInDB(uint32 mapid
, float x
,float y
,float z
,float o
,uint32 zone
,uint64 guid
);
1368 bool m_mailsUpdated
;
1370 void SetBindPoint(uint64 guid
);
1371 void SendTalentWipeConfirm(uint64 guid
);
1372 void RewardRage( uint32 damage
, uint32 weaponSpeedHitFactor
, bool attacker
);
1373 void SendPetSkillWipeConfirm();
1374 void CalcRage( uint32 damage
,bool attacker
);
1375 void RegenerateAll();
1376 void Regenerate(Powers power
);
1377 void RegenerateHealth();
1378 void setRegenTimer(uint32 time
) {m_regenTimer
= time
;}
1379 void setWeaponChangeTimer(uint32 time
) {m_weaponChangeTimer
= time
;}
1381 uint32
GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE
); }
1382 void ModifyMoney( int32 d
)
1385 SetMoney (GetMoney() > uint32(-d
) ? GetMoney() + d
: 0);
1387 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT
- d
) ? GetMoney() + d
: MAX_MONEY_AMOUNT
);
1390 if(GetMoney() >= MAX_MONEY_AMOUNT
)
1391 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD
,NULL
,NULL
);
1393 void SetMoney( uint32 value
)
1395 SetUInt32Value (PLAYER_FIELD_COINAGE
, value
);
1396 MoneyChanged( value
);
1399 uint32
GetTutorialInt(uint32 intId
)
1401 ASSERT( (intId
< 8) );
1402 return m_Tutorials
[intId
];
1405 void SetTutorialInt(uint32 intId
, uint32 value
)
1407 ASSERT( (intId
< 8) );
1408 if(m_Tutorials
[intId
]!=value
)
1410 m_Tutorials
[intId
] = value
;
1411 m_TutorialsChanged
= true;
1415 QuestStatusMap
& getQuestStatusMap() { return mQuestStatus
; };
1417 const uint64
& GetSelection( ) const { return m_curSelection
; }
1418 void SetSelection(const uint64
&guid
) { m_curSelection
= guid
; SetUInt64Value(UNIT_FIELD_TARGET
, guid
); }
1420 uint8
GetComboPoints() { return m_comboPoints
; }
1421 const uint64
& GetComboTarget() const { return m_comboTarget
; }
1423 void AddComboPoints(Unit
* target
, int8 count
);
1424 void ClearComboPoints();
1425 void SendComboPoints();
1427 void SendMailResult(uint32 mailId
, uint32 mailAction
, uint32 mailError
, uint32 equipError
= 0, uint32 item_guid
= 0, uint32 item_count
= 0);
1429 void UpdateNextMailTimeAndUnreads();
1430 void AddNewMailDeliverTime(time_t deliver_time
);
1431 bool IsMailsLoaded() const { return m_mailsLoaded
; }
1433 //void SetMail(Mail *m);
1434 void RemoveMail(uint32 id
);
1436 void AddMail(Mail
* mail
) { m_mail
.push_front(mail
);}// for call from WorldSession::SendMailTo
1437 uint32
GetMailSize() { return m_mail
.size();};
1438 Mail
* GetMail(uint32 id
);
1440 PlayerMails::iterator
GetmailBegin() { return m_mail
.begin();};
1441 PlayerMails::iterator
GetmailEnd() { return m_mail
.end();};
1443 /*********************************************************/
1444 /*** MAILED ITEMS SYSTEM ***/
1445 /*********************************************************/
1448 time_t m_nextMailDelivereTime
;
1450 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
1452 ItemMap mMitems
; //template defined in objectmgr.cpp
1454 Item
* GetMItem(uint32 id
)
1456 ItemMap::const_iterator itr
= mMitems
.find(id
);
1457 return itr
!= mMitems
.end() ? itr
->second
: NULL
;
1460 void AddMItem(Item
* it
)
1463 //assert deleted, because items can be added before loading
1464 mMitems
[it
->GetGUIDLow()] = it
;
1467 bool RemoveMItem(uint32 id
)
1469 return mMitems
.erase(id
) ? true : false;
1472 void PetSpellInitialize();
1473 void CharmSpellInitialize();
1474 void PossessSpellInitialize();
1475 bool HasSpell(uint32 spell
) const;
1476 TrainerSpellState
GetTrainerSpellState(TrainerSpell
const* trainer_spell
) const;
1477 bool IsSpellFitByClassAndRace( uint32 spell_id
) const;
1479 void SendProficiency(uint8 pr1
, uint32 pr2
);
1480 void SendInitialSpells();
1481 bool addSpell(uint32 spell_id
, bool active
, bool learning
, bool disabled
);
1482 void learnSpell(uint32 spell_id
);
1483 void removeSpell(uint32 spell_id
, bool disabled
= false);
1485 void learnDefaultSpells();
1486 void learnQuestRewardedSpells();
1487 void learnQuestRewardedSpells(Quest
const* quest
);
1489 uint32
GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1
); }
1490 void SetFreeTalentPoints(uint32 points
) { SetUInt32Value(PLAYER_CHARACTER_POINTS1
,points
); }
1491 bool resetTalents(bool no_cost
= false);
1492 uint32
resetTalentsCost() const;
1493 void InitTalentForLevel();
1495 void InitGlyphsForLevel();
1496 void SetGlyphSlot(uint8 slot
, uint32 slottype
) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
, slottype
); }
1497 uint32
GetGlyphSlot(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
); }
1498 void SetGlyph(uint8 slot
, uint32 glyph
) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
, glyph
); }
1499 uint32
GetGlyph(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
); }
1501 uint32
GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2
); }
1502 void SetFreePrimaryProffesions(uint16 profs
) { SetUInt32Value(PLAYER_CHARACTER_POINTS2
,profs
); }
1503 void InitPrimaryProffesions();
1505 PlayerSpellMap
const& GetSpellMap() const { return m_spells
; }
1506 PlayerSpellMap
& GetSpellMap() { return m_spells
; }
1508 void AddSpellMod(SpellModifier
* mod
, bool apply
);
1509 bool IsAffectedBySpellmod(SpellEntry
const *spellInfo
, SpellModifier
*mod
, Spell
const* spell
= NULL
);
1510 template <class T
> T
ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
= NULL
);
1511 void RemoveSpellMods(Spell
const* spell
);
1513 bool HasSpellCooldown(uint32 spell_id
) const
1515 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1516 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> time(NULL
);
1518 uint32
GetSpellCooldownDelay(uint32 spell_id
) const
1520 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1521 time_t t
= time(NULL
);
1522 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> t
? itr
->second
.end
- t
: 0;
1524 void AddSpellCooldown(uint32 spell_id
, uint32 itemid
, time_t end_time
);
1525 void SendCooldownEvent(SpellEntry
const *spellInfo
);
1526 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask
, uint32 unTimeMs
);
1527 void RemoveSpellCooldown(uint32 spell_id
) { m_spellCooldowns
.erase(spell_id
); }
1528 void RemoveArenaSpellCooldowns();
1529 void RemoveAllSpellCooldown();
1530 void _LoadSpellCooldowns(QueryResult
*result
);
1531 void _SaveSpellCooldowns();
1533 void setResurrectRequestData(uint64 guid
, uint32 mapId
, float X
, float Y
, float Z
, uint32 health
, uint32 mana
)
1535 m_resurrectGUID
= guid
;
1536 m_resurrectMap
= mapId
;
1540 m_resurrectHealth
= health
;
1541 m_resurrectMana
= mana
;
1543 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f
,0.0f
,0.0f
,0,0); }
1544 bool isRessurectRequestedBy(uint64 guid
) const { return m_resurrectGUID
== guid
; }
1545 bool isRessurectRequested() const { return m_resurrectGUID
!= 0; }
1546 void ResurectUsingRequestData();
1552 void setCinematic(int cine
)
1557 void addActionButton(uint8 button
, uint16 action
, uint8 type
, uint8 misc
);
1558 void removeActionButton(uint8 button
);
1559 void SendInitialActionButtons();
1562 void UpdatePvP(bool state
, bool ovrride
=false);
1563 void UpdateZone(uint32 newZone
);
1564 void UpdateArea(uint32 newArea
);
1566 void UpdateZoneDependentAuras( uint32 zone_id
); // zones
1567 void UpdateAreaDependentAuras( uint32 area_id
); // subzones
1569 void UpdateAfkReport(time_t currTime
);
1570 void UpdatePvPFlag(time_t currTime
);
1571 void UpdateContestedPvP(uint32 currTime
);
1572 void SetContestedPvPTimer(uint32 newTime
) {m_contestedPvPTimer
= newTime
;}
1573 void ResetContestedPvP()
1575 clearUnitState(UNIT_STAT_ATTACK_PLAYER
);
1576 RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_CONTESTED_PVP
);
1577 m_contestedPvPTimer
= 0;
1580 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1582 void UpdateDuelFlag(time_t currTime
);
1583 void CheckDuelDistance(time_t currTime
);
1584 void DuelComplete(DuelCompleteType type
);
1586 bool IsGroupVisibleFor(Player
* p
) const;
1587 bool IsInSameGroupWith(Player
const* p
) const;
1588 bool IsInSameRaidWith(Player
const* p
) const { return p
==this || (GetGroup() != NULL
&& GetGroup() == p
->GetGroup()); }
1589 void UninviteFromGroup();
1590 static void RemoveFromGroup(Group
* group
, uint64 guid
);
1591 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1592 void SendUpdateToOutOfRangeGroupMembers();
1594 void SetInGuild(uint32 GuildId
) { SetUInt32Value(PLAYER_GUILDID
, GuildId
); }
1595 void SetRank(uint32 rankId
){ SetUInt32Value(PLAYER_GUILDRANK
, rankId
); }
1596 void SetGuildIdInvited(uint32 GuildId
) { m_GuildIdInvited
= GuildId
; }
1597 uint32
GetGuildId() { return GetUInt32Value(PLAYER_GUILDID
); }
1598 static uint32
GetGuildIdFromDB(uint64 guid
);
1599 uint32
GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK
); }
1600 static uint32
GetRankFromDB(uint64 guid
);
1601 int GetGuildIdInvited() { return m_GuildIdInvited
; }
1602 static void RemovePetitionsAndSigns(uint64 guid
, uint32 type
);
1605 void SetInArenaTeam(uint32 ArenaTeamId
, uint8 slot
)
1607 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6), ArenaTeamId
);
1609 uint32
GetArenaTeamId(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6)); }
1610 static uint32
GetArenaTeamIdFromDB(uint64 guid
, uint8 slot
);
1611 void SetArenaTeamIdInvited(uint32 ArenaTeamId
) { m_ArenaTeamIdInvited
= ArenaTeamId
; }
1612 uint32
GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited
; }
1613 static void LeaveAllArenaTeams(uint64 guid
);
1615 void SetDifficulty(uint32 dungeon_difficulty
) { m_dungeonDifficulty
= dungeon_difficulty
; }
1616 uint8
GetDifficulty() { return m_dungeonDifficulty
; }
1618 bool UpdateSkill(uint32 skill_id
, uint32 step
);
1619 bool UpdateSkillPro(uint16 SkillId
, int32 Chance
, uint32 step
);
1621 bool UpdateCraftSkill(uint32 spellid
);
1622 bool UpdateGatherSkill(uint32 SkillId
, uint32 SkillValue
, uint32 RedLevel
, uint32 Multiplicator
= 1);
1623 bool UpdateFishingSkill();
1625 uint32
GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE
); }
1626 uint32
GetBaseWeaponSkillValue(WeaponAttackType attType
) const;
1628 uint32
GetSpellByProto(ItemPrototype
*proto
);
1630 float GetHealthBonusFromStamina();
1631 float GetManaBonusFromIntellect();
1633 bool UpdateStats(Stats stat
);
1634 bool UpdateAllStats();
1635 void UpdateResistances(uint32 school
);
1637 void UpdateMaxHealth();
1638 void UpdateMaxPower(Powers power
);
1639 void ApplyFeralAPBonus(int32 amount
, bool apply
);
1640 void UpdateAttackPowerAndDamage(bool ranged
= false);
1641 void UpdateShieldBlockValue();
1642 void UpdateDamagePhysical(WeaponAttackType attType
);
1643 void ApplySpellDamageBonus(int32 amount
, bool apply
);
1644 void ApplySpellHealingBonus(int32 amount
, bool apply
);
1645 void UpdateSpellDamageAndHealingBonus();
1647 void CalculateMinMaxDamage(WeaponAttackType attType
, bool normalized
, float& min_damage
, float& max_damage
);
1649 void UpdateDefenseBonusesMod();
1650 void ApplyRatingMod(CombatRating cr
, int32 value
, bool apply
);
1651 float GetMeleeCritFromAgility();
1652 float GetDodgeFromAgility();
1653 float GetSpellCritFromIntellect();
1654 float OCTRegenHPPerSpirit();
1655 float OCTRegenMPPerSpirit();
1656 float GetRatingCoefficient(CombatRating cr
) const;
1657 float GetRatingBonusValue(CombatRating cr
) const;
1658 uint32
GetMeleeCritDamageReduction(uint32 damage
) const;
1659 uint32
GetRangedCritDamageReduction(uint32 damage
) const;
1660 uint32
GetSpellCritDamageReduction(uint32 damage
) const;
1661 uint32
GetDotDamageReduction(uint32 damage
) const;
1662 uint32
GetBaseSpellDamageBonus() { return m_baseSpellDamage
;}
1663 uint32
GetBaseSpellHealingBonus() { return m_baseSpellHealing
;}
1665 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType
) const;
1666 void UpdateBlockPercentage();
1667 void UpdateCritPercentage(WeaponAttackType attType
);
1668 void UpdateAllCritPercentages();
1669 void UpdateParryPercentage();
1670 void UpdateDodgePercentage();
1671 void UpdateMeleeHitChances();
1672 void UpdateRangedHitChances();
1673 void UpdateSpellHitChances();
1675 void UpdateAllSpellCritChances();
1676 void UpdateSpellCritChance(uint32 school
);
1677 void UpdateExpertise(WeaponAttackType attType
);
1678 void ApplyManaRegenBonus(int32 amount
, bool apply
);
1679 void UpdateManaRegen();
1681 const uint64
& GetLootGUID() const { return m_lootGuid
; }
1682 void SetLootGUID(const uint64
&guid
) { m_lootGuid
= guid
; }
1684 void RemovedInsignia(Player
* looterPlr
);
1686 WorldSession
* GetSession() const { return m_session
; }
1687 void SetSession(WorldSession
*s
) { m_session
= s
; }
1689 void BuildCreateUpdateBlockForPlayer( UpdateData
*data
, Player
*target
) const;
1690 void DestroyForPlayer( Player
*target
) const;
1691 void SendDelayResponse(const uint32
);
1692 void SendLogXPGain(uint32 GivenXP
,Unit
* victim
,uint32 RestXP
);
1695 void PlaySound(uint32 Sound
, bool OnlySelf
);
1697 void SendAttackSwingCantAttack();
1698 void SendAttackSwingCancelAttack();
1699 void SendAttackSwingDeadTarget();
1700 void SendAttackSwingNotStanding();
1701 void SendAttackSwingNotInRange();
1702 void SendAttackSwingBadFacingAttack();
1703 void SendAutoRepeatCancel();
1704 void SendExplorationExperience(uint32 Area
, uint32 Experience
);
1706 void SendDungeonDifficulty(bool IsInGroup
);
1707 void ResetInstances(uint8 method
);
1708 void SendResetInstanceSuccess(uint32 MapId
);
1709 void SendResetInstanceFailed(uint32 reason
, uint32 MapId
);
1710 void SendResetFailedNotify(uint32 mapid
);
1712 bool SetPosition(float x
, float y
, float z
, float orientation
, bool teleport
= false);
1713 void UpdateUnderwaterState( Map
* m
, float x
, float y
, float z
);
1715 void SendMessageToSet(WorldPacket
*data
, bool self
);// overwrite Object::SendMessageToSet
1716 void SendMessageToSetInRange(WorldPacket
*data
, float fist
, bool self
);
1717 // overwrite Object::SendMessageToSetInRange
1718 void SendMessageToSetInRange(WorldPacket
*data
, float dist
, bool self
, bool own_team_only
);
1720 static void DeleteFromDB(uint64 playerguid
, uint32 accountId
, bool updateRealmChars
= true);
1722 Corpse
*GetCorpse() const;
1723 void SpawnCorpseBones();
1724 void CreateCorpse();
1726 uint32
GetResurrectionSpellId();
1727 void ResurrectPlayer(float restore_percent
, bool applySickness
= false);
1728 void BuildPlayerRepop();
1729 void RepopAtGraveyard();
1731 void DurabilityLossAll(double percent
, bool inventory
);
1732 void DurabilityLoss(Item
* item
, double percent
);
1733 void DurabilityPointsLossAll(int32 points
, bool inventory
);
1734 void DurabilityPointsLoss(Item
* item
, int32 points
);
1735 void DurabilityPointLossForEquipSlot(EquipmentSlots slot
);
1736 uint32
DurabilityRepairAll(bool cost
, float discountMod
, bool guildBank
);
1737 uint32
DurabilityRepair(uint16 pos
, bool cost
, float discountMod
, bool guildBank
);
1739 void StopMirrorTimers()
1741 StopMirrorTimer(FATIGUE_TIMER
);
1742 StopMirrorTimer(BREATH_TIMER
);
1743 StopMirrorTimer(FIRE_TIMER
);
1746 void SetMovement(PlayerMovementType pType
);
1748 void JoinedChannel(Channel
*c
);
1749 void LeftChannel(Channel
*c
);
1750 void CleanupChannels();
1751 void UpdateLocalChannels( uint32 newZone
);
1752 void LeaveLFGChannel();
1754 void UpdateDefense();
1755 void UpdateWeaponSkill (WeaponAttackType attType
);
1756 void UpdateCombatSkills(Unit
*pVictim
, WeaponAttackType attType
, bool defence
);
1758 void SetSkill(uint32 id
, uint16 currVal
, uint16 maxVal
);
1759 uint16
GetMaxSkillValue(uint32 skill
) const; // max + perm. bonus + temp bonus
1760 uint16
GetPureMaxSkillValue(uint32 skill
) const; // max
1761 uint16
GetSkillValue(uint32 skill
) const; // skill value + perm. bonus + temp bonus
1762 uint16
GetBaseSkillValue(uint32 skill
) const; // skill value + perm. bonus
1763 uint16
GetPureSkillValue(uint32 skill
) const; // skill value
1764 int16
GetSkillPermBonusValue(uint32 skill
) const;
1765 int16
GetSkillTempBonusValue(uint32 skill
) const;
1766 bool HasSkill(uint32 skill
) const;
1767 void learnSkillRewardedSpells( uint32 id
);
1768 void learnSkillRewardedSpells();
1770 void SetDontMove(bool dontMove
);
1771 bool GetDontMove() const { return m_dontMove
; }
1773 void CheckExploreSystem(void);
1775 static uint32
TeamForRace(uint8 race
);
1776 uint32
GetTeam() const { return m_team
; }
1777 static uint32
getFactionForRace(uint8 race
);
1778 void setFactionForRace(uint8 race
);
1780 bool IsAtGroupRewardDistance(WorldObject
const* pRewardSource
) const;
1781 bool RewardPlayerAndGroupAtKill(Unit
* pVictim
);
1782 bool isHonorOrXPTarget(Unit
* pVictim
);
1784 FactionStateList m_factions
;
1785 ForcedReactions m_forcedReactions
;
1786 FactionStateList
const& GetFactionStateList() { return m_factions
; }
1787 uint32
GetDefaultReputationFlags(const FactionEntry
*factionEntry
) const;
1788 int32
GetBaseReputation(const FactionEntry
*factionEntry
) const;
1789 int32
GetReputation(uint32 faction_id
) const;
1790 int32
GetReputation(const FactionEntry
*factionEntry
) const;
1791 ReputationRank
GetReputationRank(uint32 faction
) const;
1792 ReputationRank
GetReputationRank(const FactionEntry
*factionEntry
) const;
1793 ReputationRank
GetBaseReputationRank(const FactionEntry
*factionEntry
) const;
1794 ReputationRank
ReputationToRank(int32 standing
) const;
1795 const static int32 ReputationRank_Length
[MAX_REPUTATION_RANK
];
1796 const static int32 Reputation_Cap
= 42999;
1797 const static int32 Reputation_Bottom
= -42000;
1798 bool ModifyFactionReputation(uint32 FactionTemplateId
, int32 DeltaReputation
);
1799 bool ModifyFactionReputation(FactionEntry
const* factionEntry
, int32 standing
);
1800 bool ModifyOneFactionReputation(FactionEntry
const* factionEntry
, int32 standing
);
1801 bool SetFactionReputation(uint32 FactionTemplateId
, int32 standing
);
1802 bool SetFactionReputation(FactionEntry
const* factionEntry
, int32 standing
);
1803 bool SetOneFactionReputation(FactionEntry
const* factionEntry
, int32 standing
);
1804 int32
CalculateReputationGain(uint32 creatureOrQuestLevel
, int32 rep
, bool for_quest
);
1805 void RewardReputation(Unit
*pVictim
, float rate
);
1806 void RewardReputation(Quest
const *pQuest
);
1807 void SetInitialFactions();
1808 void UpdateReputation() const;
1809 void SendFactionState(FactionState
const* faction
) const;
1810 void SendInitialReputations();
1811 FactionState
const* GetFactionState( FactionEntry
const* factionEntry
) const;
1812 void SetFactionAtWar(FactionState
* faction
, bool atWar
);
1813 void SetFactionInactive(FactionState
* faction
, bool inactive
);
1814 void SetFactionVisible(FactionState
* faction
);
1815 void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId
);
1816 void SetFactionVisibleForFactionId(uint32 FactionId
);
1817 void UpdateSkillsForLevel();
1818 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1819 void ModifySkillBonus(uint32 skillid
,int32 val
, bool talent
);
1821 /*********************************************************/
1822 /*** PVP SYSTEM ***/
1823 /*********************************************************/
1824 void UpdateArenaFields();
1825 void UpdateHonorFields();
1826 bool RewardHonor(Unit
*pVictim
, uint32 groupsize
, float honor
= -1);
1827 uint32
GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
); }
1828 uint32
GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY
); }
1829 void ModifyHonorPoints( int32 value
);
1830 void ModifyArenaPoints( int32 value
);
1831 uint32
GetMaxPersonalArenaRatingRequirement();
1835 void SetDrunkValue(uint16 newDrunkValue
, uint32 itemid
=0);
1836 uint16
GetDrunkValue() const { return m_drunk
; }
1837 static DrunkenState
GetDrunkenstateByValue(uint16 value
);
1839 uint32
GetDeathTimer() const { return m_deathTimer
; }
1840 uint32
GetCorpseReclaimDelay(bool pvp
) const;
1841 void UpdateCorpseReclaimDelay();
1842 void SendCorpseReclaimDelay(bool load
= false);
1844 uint32
GetShieldBlockValue() const; // overwrite Unit version (virtual)
1845 bool CanParry() const { return m_canParry
; }
1846 void SetCanParry(bool value
);
1847 bool CanBlock() const { return m_canBlock
; }
1848 void SetCanBlock(bool value
);
1849 bool CanDualWield() const { return m_canDualWield
; }
1850 void SetCanDualWield(bool value
) { m_canDualWield
= value
; }
1851 bool CanTitanGrip() const { return m_canTitanGrip
; }
1852 void SetCanTitanGrip(bool value
) { m_canTitanGrip
= value
; }
1854 void SetRegularAttackTime();
1855 void SetBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float value
) { m_auraBaseMod
[modGroup
][modType
] = value
; }
1856 void HandleBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float amount
, bool apply
);
1857 float GetBaseModValue(BaseModGroup modGroup
, BaseModType modType
) const;
1858 float GetTotalBaseModValue(BaseModGroup modGroup
) const;
1859 float GetTotalPercentageModValue(BaseModGroup modGroup
) const { return m_auraBaseMod
[modGroup
][FLAT_MOD
] + m_auraBaseMod
[modGroup
][PCT_MOD
]; }
1860 void _ApplyAllStatBonuses();
1861 void _RemoveAllStatBonuses();
1863 void _ApplyWeaponDependentAuraMods(Item
*item
, WeaponAttackType attackType
, bool apply
);
1864 void _ApplyWeaponDependentAuraCritMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1865 void _ApplyWeaponDependentAuraDamageMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1867 void _ApplyItemMods(Item
*item
,uint8 slot
,bool apply
);
1868 void _RemoveAllItemMods();
1869 void _ApplyAllItemMods();
1870 void _ApplyItemBonuses(ItemPrototype
const *proto
,uint8 slot
,bool apply
);
1871 void _ApplyAmmoBonuses();
1872 bool EnchantmentFitsRequirements(uint32 enchantmentcondition
, int8 slot
);
1873 void ToggleMetaGemsActive(uint8 exceptslot
, bool apply
);
1874 void CorrectMetaGemEnchants(uint8 slot
, bool apply
);
1875 void InitDataForForm(bool reapplyMods
= false);
1877 void ApplyItemEquipSpell(Item
*item
, bool apply
, bool form_change
= false);
1878 void ApplyEquipSpell(SpellEntry
const* spellInfo
, Item
* item
, bool apply
, bool form_change
= false);
1879 void UpdateEquipSpellsAtFormChange();
1880 void CastItemCombatSpell(Item
*item
,Unit
* Target
, WeaponAttackType attType
);
1881 void CastItemUseSpell(Item
*item
,SpellCastTargets
const& targets
,uint8 cast_count
, uint32 glyphIndex
);
1883 void SendInitWorldStates();
1884 void SendUpdateWorldState(uint32 Field
, uint32 Value
);
1885 void SendDirectMessage(WorldPacket
*data
);
1887 void SendAurasForTarget(Unit
*target
);
1889 PlayerMenu
* PlayerTalkClass
;
1890 std::vector
<ItemSetEffect
*> ItemSetEff
;
1892 void SendLoot(uint64 guid
, LootType loot_type
);
1893 void SendLootRelease( uint64 guid
);
1894 void SendNotifyLootItemRemoved(uint8 lootSlot
);
1895 void SendNotifyLootMoneyRemoved();
1897 /*********************************************************/
1898 /*** BATTLEGROUND SYSTEM ***/
1899 /*********************************************************/
1901 bool InBattleGround() const { return m_bgBattleGroundID
!= 0; }
1902 uint32
GetBattleGroundId() const { return m_bgBattleGroundID
; }
1903 BattleGround
* GetBattleGround() const;
1904 bool InArena() const;
1906 static uint32
GetMinLevelForBattleGroundQueueId(uint32 queue_id
);
1907 static uint32
GetMaxLevelForBattleGroundQueueId(uint32 queue_id
);
1908 uint32
GetBattleGroundQueueIdFromLevel() const;
1910 bool InBattleGroundQueue() const
1912 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1913 if (m_bgBattleGroundQueueID
[i
].bgQueueType
!= 0)
1918 uint32
GetBattleGroundQueueId(uint32 index
) const { return m_bgBattleGroundQueueID
[index
].bgQueueType
; }
1919 uint32
GetBattleGroundQueueIndex(uint32 bgQueueType
) const
1921 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1922 if (m_bgBattleGroundQueueID
[i
].bgQueueType
== bgQueueType
)
1924 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1926 bool IsInvitedForBattleGroundQueueType(uint32 bgQueueType
) const
1928 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1929 if (m_bgBattleGroundQueueID
[i
].bgQueueType
== bgQueueType
)
1930 return m_bgBattleGroundQueueID
[i
].invitedToInstance
!= 0;
1931 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1933 bool InBattleGroundQueueForBattleGroundQueueType(uint32 bgQueueType
) const
1935 return GetBattleGroundQueueIndex(bgQueueType
) < PLAYER_MAX_BATTLEGROUND_QUEUES
;
1938 void SetBattleGroundId(uint32 val
) { m_bgBattleGroundID
= val
; }
1939 uint32
AddBattleGroundQueueId(uint32 val
)
1941 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1943 if (m_bgBattleGroundQueueID
[i
].bgQueueType
== 0 || m_bgBattleGroundQueueID
[i
].bgQueueType
== val
)
1945 m_bgBattleGroundQueueID
[i
].bgQueueType
= val
;
1946 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1950 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1952 bool HasFreeBattleGroundQueueId()
1954 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1955 if (m_bgBattleGroundQueueID
[i
].bgQueueType
== 0)
1959 void RemoveBattleGroundQueueId(uint32 val
)
1961 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1963 if (m_bgBattleGroundQueueID
[i
].bgQueueType
== val
)
1965 m_bgBattleGroundQueueID
[i
].bgQueueType
= 0;
1966 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1971 void SetInviteForBattleGroundQueueType(uint32 bgQueueType
, uint32 instanceId
)
1973 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1974 if (m_bgBattleGroundQueueID
[i
].bgQueueType
== bgQueueType
)
1975 m_bgBattleGroundQueueID
[i
].invitedToInstance
= instanceId
;
1977 bool IsInvitedForBattleGroundInstance(uint32 instanceId
) const
1979 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1980 if (m_bgBattleGroundQueueID
[i
].invitedToInstance
== instanceId
)
1984 uint32
GetBattleGroundEntryPointMap() const { return m_bgEntryPointMap
; }
1985 float GetBattleGroundEntryPointX() const { return m_bgEntryPointX
; }
1986 float GetBattleGroundEntryPointY() const { return m_bgEntryPointY
; }
1987 float GetBattleGroundEntryPointZ() const { return m_bgEntryPointZ
; }
1988 float GetBattleGroundEntryPointO() const { return m_bgEntryPointO
; }
1989 void SetBattleGroundEntryPoint(uint32 Map
, float PosX
, float PosY
, float PosZ
, float PosO
)
1991 m_bgEntryPointMap
= Map
;
1992 m_bgEntryPointX
= PosX
;
1993 m_bgEntryPointY
= PosY
;
1994 m_bgEntryPointZ
= PosZ
;
1995 m_bgEntryPointO
= PosO
;
1998 void SetBGTeam(uint32 team
) { m_bgTeam
= team
; }
1999 uint32
GetBGTeam() const { return m_bgTeam
? m_bgTeam
: GetTeam(); }
2001 void LeaveBattleground(bool teleportToEntryPoint
= true);
2002 bool CanJoinToBattleground() const;
2003 bool CanReportAfkDueToLimit();
2004 void ReportedAfkBy(Player
* reporter
);
2005 void ClearAfkReports() { m_bgAfkReporter
.clear(); }
2007 bool GetBGAccessByLevel(uint32 bgTypeId
) const;
2008 bool isAllowUseBattleGroundObject();
2010 /*********************************************************/
2011 /*** REST SYSTEM ***/
2012 /*********************************************************/
2014 bool isRested() const { return GetRestTime() >= 10000; }
2015 uint32
GetXPRestBonus(uint32 xp
);
2016 uint32
GetRestTime() const { return m_restTime
;};
2017 void SetRestTime(uint32 v
) { m_restTime
= v
;};
2019 /*********************************************************/
2020 /*** ENVIROMENTAL SYSTEM ***/
2021 /*********************************************************/
2023 void EnvironmentalDamage(uint64 guid
, EnviromentalDamage type
, uint32 damage
);
2025 /*********************************************************/
2026 /*** FLOOD FILTER SYSTEM ***/
2027 /*********************************************************/
2029 void UpdateSpeakTime();
2030 bool CanSpeak() const;
2031 void ChangeSpeakTime(int utime
);
2033 /*********************************************************/
2034 /*** VARIOUS SYSTEMS ***/
2035 /*********************************************************/
2036 MovementInfo m_movementInfo
;
2037 uint32 m_lastFallTime
;
2040 void SetFallInformation(uint32 time
, float z
)
2042 m_lastFallTime
= time
;
2045 bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask
); }
2046 bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask
); }
2048 bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY
); }
2049 bool IsFlying() const { return HasUnitMovementFlag(MOVEMENTFLAG_FLYING
); }
2051 void HandleDrowning();
2053 void SetClientControl(Unit
* target
, uint8 allowMove
);
2055 void EnterVehicle(Vehicle
*vehicle
);
2056 void ExitVehicle(Vehicle
*vehicle
);
2058 uint64
GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT
); }
2059 void SetFarSightGUID(uint64 guid
) { SetUInt64Value(PLAYER_FARSIGHT
, guid
); }
2062 Transport
* GetTransport() const { return m_transport
; }
2063 void SetTransport(Transport
* t
) { m_transport
= t
; }
2065 float GetTransOffsetX() const { return m_movementInfo
.t_x
; }
2066 float GetTransOffsetY() const { return m_movementInfo
.t_y
; }
2067 float GetTransOffsetZ() const { return m_movementInfo
.t_z
; }
2068 float GetTransOffsetO() const { return m_movementInfo
.t_o
; }
2069 uint32
GetTransTime() const { return m_movementInfo
.t_time
; }
2070 int8
GetTransSeat() const { return m_movementInfo
.t_seat
; }
2072 uint32
GetSaveTimer() const { return m_nextSave
; }
2073 void SetSaveTimer(uint32 timer
) { m_nextSave
= timer
; }
2081 void SaveRecallPosition();
2083 // Homebind coordinates
2084 uint32 m_homebindMapId
;
2085 uint16 m_homebindZoneId
;
2090 // currently visible objects at player client
2091 typedef std::set
<uint64
> ClientGUIDs
;
2092 ClientGUIDs m_clientGUIDs
;
2094 bool HaveAtClient(WorldObject
const* u
) { return u
==this || m_clientGUIDs
.find(u
->GetGUID())!=m_clientGUIDs
.end(); }
2096 bool IsVisibleInGridForPlayer(Player
* pl
) const;
2097 bool IsVisibleGloballyFor(Player
* pl
) const;
2099 void UpdateVisibilityOf(WorldObject
* target
);
2102 void UpdateVisibilityOf(T
* target
, UpdateData
& data
, UpdateDataMapType
& data_updates
, std::set
<WorldObject
*>& visibleNow
);
2104 // Stealth detection system
2105 uint32 m_DetectInvTimer
;
2106 void HandleStealthedUnitsDetection();
2108 uint8 m_forced_speed_changes
[MAX_MOVE_TYPE
];
2110 bool HasAtLoginFlag(AtLoginFlags f
) const { return m_atLoginFlags
& f
; }
2111 void SetAtLoginFlag(AtLoginFlags f
) { m_atLoginFlags
|= f
; }
2113 LookingForGroup m_lookingForGroup
;
2115 // Temporarily removed pet cache
2116 uint32
GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber
; }
2117 void SetTemporaryUnsummonedPetNumber(uint32 petnumber
) { m_temporaryUnsummonedPetNumber
= petnumber
; }
2118 uint32
GetOldPetSpell() const { return m_oldpetspell
; }
2119 void SetOldPetSpell(uint32 petspell
) { m_oldpetspell
= petspell
; }
2121 /*********************************************************/
2122 /*** INSTANCE SYSTEM ***/
2123 /*********************************************************/
2125 typedef UNORDERED_MAP
< uint32
/*mapId*/, InstancePlayerBind
> BoundInstancesMap
;
2127 void UpdateHomebindTime(uint32 time
);
2129 uint32 m_HomebindTimer
;
2130 bool m_InstanceValid
;
2131 // permanent binds and solo binds by difficulty
2132 BoundInstancesMap m_boundInstances
[TOTAL_DIFFICULTIES
];
2133 InstancePlayerBind
* GetBoundInstance(uint32 mapid
, uint8 difficulty
);
2134 BoundInstancesMap
& GetBoundInstances(uint8 difficulty
) { return m_boundInstances
[difficulty
]; }
2135 void UnbindInstance(uint32 mapid
, uint8 difficulty
, bool unload
= false);
2136 void UnbindInstance(BoundInstancesMap::iterator
&itr
, uint8 difficulty
, bool unload
= false);
2137 InstancePlayerBind
* BindToInstance(InstanceSave
*save
, bool permanent
, bool load
= false);
2138 void SendRaidInfo();
2139 void SendSavedInstances();
2140 static void ConvertInstancesToGroup(Player
*player
, Group
*group
= NULL
, uint64 player_guid
= 0);
2142 /*********************************************************/
2143 /*** GROUP SYSTEM ***/
2144 /*********************************************************/
2146 Group
* GetGroupInvite() { return m_groupInvite
; }
2147 void SetGroupInvite(Group
*group
) { m_groupInvite
= group
; }
2148 Group
* GetGroup() { return m_group
.getTarget(); }
2149 const Group
* GetGroup() const { return (const Group
*)m_group
.getTarget(); }
2150 GroupReference
& GetGroupRef() { return m_group
; }
2151 void SetGroup(Group
*group
, int8 subgroup
= -1);
2152 uint8
GetSubGroup() const { return m_group
.getSubGroup(); }
2153 uint32
GetGroupUpdateFlag() const { return m_groupUpdateMask
; }
2154 void SetGroupUpdateFlag(uint32 flag
) { m_groupUpdateMask
|= flag
; }
2155 const uint64
& GetAuraUpdateMask() const { return m_auraUpdateMask
; }
2156 void SetAuraUpdateMask(uint8 slot
) { m_auraUpdateMask
|= (uint64(1) << slot
); }
2157 Player
* GetNextRandomRaidMember(float radius
);
2158 PartyResult
CanUninviteFromGroup() const;
2160 GridReference
<Player
> &GetGridRef() { return m_gridRef
; }
2161 MapReference
&GetMapRef() { return m_mapRef
; }
2163 bool isAllowedToLoot(Creature
* creature
);
2165 WorldLocation
& GetTeleportDest() { return m_teleport_dest
; }
2167 DeclinedName
const* GetDeclinedNames() const { return m_declinedname
; }
2168 uint8
GetRunesState() const { return m_runes
->runeState
; }
2169 uint8
GetBaseRune(uint8 index
) const { return m_runes
->runes
[index
].BaseRune
; }
2170 uint8
GetCurrentRune(uint8 index
) const { return m_runes
->runes
[index
].CurrentRune
; }
2171 uint8
GetRuneCooldown(uint8 index
) const { return m_runes
->runes
[index
].Cooldown
; }
2172 void SetBaseRune(uint8 index
, uint8 baseRune
) { m_runes
->runes
[index
].BaseRune
= baseRune
; }
2173 void SetCurrentRune(uint8 index
, uint8 currentRune
) { m_runes
->runes
[index
].CurrentRune
= currentRune
; }
2174 void SetRuneCooldown(uint8 index
, uint8 cooldown
) { m_runes
->runes
[index
].Cooldown
= cooldown
; m_runes
->SetRuneState(index
, (cooldown
== 0) ? true : false); }
2175 void ConvertRune(uint8 index
, uint8 newType
);
2176 void ResyncRunes(uint8 count
);
2177 void AddRunePower(uint8 index
);
2179 AchievementMgr
& GetAchievementMgr() { return m_achievementMgr
; }
2180 bool HasTitle(uint32 bitIndex
);
2181 bool HasTitle(CharTitlesEntry
const* title
) { return HasTitle(title
->bit_index
); }
2182 void SetTitle(CharTitlesEntry
const* title
);
2186 /*********************************************************/
2187 /*** BATTLEGROUND SYSTEM ***/
2188 /*********************************************************/
2190 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2191 uint32 m_bgBattleGroundID
;
2193 this is an array of BG queues (BgTypeIDs) in which is player
2195 struct BgBattleGroundQueueID_Rec
2198 uint32 invitedToInstance
;
2200 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID
[PLAYER_MAX_BATTLEGROUND_QUEUES
];
2201 uint32 m_bgEntryPointMap
;
2202 float m_bgEntryPointX
;
2203 float m_bgEntryPointY
;
2204 float m_bgEntryPointZ
;
2205 float m_bgEntryPointO
;
2207 std::set
<uint32
> m_bgAfkReporter
;
2208 uint8 m_bgAfkReportedCount
;
2209 time_t m_bgAfkReportedTimer
;
2210 uint32 m_contestedPvPTimer
;
2212 uint32 m_bgTeam
; // what side the player will be added to
2214 /*********************************************************/
2215 /*** QUEST SYSTEM ***/
2216 /*********************************************************/
2218 std::set
<uint32
> m_timedquests
;
2221 uint32 m_ingametime
;
2223 /*********************************************************/
2224 /*** LOAD SYSTEM ***/
2225 /*********************************************************/
2227 void _LoadActions(QueryResult
*result
);
2228 void _LoadAuras(QueryResult
*result
, uint32 timediff
);
2229 void _LoadGlyphAuras();
2230 void _LoadBoundInstances(QueryResult
*result
);
2231 void _LoadInventory(QueryResult
*result
, uint32 timediff
);
2232 void _LoadMailInit(QueryResult
*resultUnread
, QueryResult
*resultDelivery
);
2234 void _LoadMailedItems(Mail
*mail
);
2235 void _LoadQuestStatus(QueryResult
*result
);
2236 void _LoadDailyQuestStatus(QueryResult
*result
);
2237 void _LoadGroup(QueryResult
*result
);
2238 void _LoadReputation(QueryResult
*result
);
2239 void _LoadSpells(QueryResult
*result
);
2240 void _LoadTutorials(QueryResult
*result
);
2241 void _LoadFriendList(QueryResult
*result
);
2242 bool _LoadHomeBind(QueryResult
*result
);
2243 void _LoadDeclinedNames(QueryResult
*result
);
2244 void _LoadArenaTeamInfo(QueryResult
*result
);
2246 /*********************************************************/
2247 /*** SAVE SYSTEM ***/
2248 /*********************************************************/
2250 void _SaveActions();
2252 void _SaveInventory();
2254 void _SaveQuestStatus();
2255 void _SaveDailyQuestStatus();
2256 void _SaveReputation();
2258 void _SaveTutorials();
2260 void _SetCreateBits(UpdateMask
*updateMask
, Player
*target
) const;
2261 void _SetUpdateBits(UpdateMask
*updateMask
, Player
*target
) const;
2263 /*********************************************************/
2264 /*** ENVIRONMENTAL SYSTEM ***/
2265 /*********************************************************/
2267 void HandleSobering();
2268 void StartMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
);
2269 void ModifyMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
, uint32 CurrentValue
, uint32 Regen
);
2270 void StopMirrorTimer(MirrorTimerType Type
);
2271 uint8 m_isunderwater
;
2274 /*********************************************************/
2275 /*** HONOR SYSTEM ***/
2276 /*********************************************************/
2277 time_t m_lastHonorUpdateTime
;
2279 void outDebugValues() const;
2280 bool _removeSpell(uint16 spell_id
);
2288 uint32 m_speakCount
;
2289 uint32 m_dungeonDifficulty
;
2291 uint32 m_atLoginFlags
;
2293 Item
* m_items
[PLAYER_SLOTS_COUNT
];
2294 uint32 m_currentBuybackSlot
;
2296 std::vector
<Item
*> m_itemUpdateQueue
;
2297 bool m_itemUpdateQueueBlocked
;
2299 uint32 m_ExtraFlags
;
2300 uint64 m_curSelection
;
2302 uint64 m_comboTarget
;
2305 QuestStatusMap mQuestStatus
;
2307 uint32 m_GuildIdInvited
;
2308 uint32 m_ArenaTeamIdInvited
;
2311 PlayerSpellMap m_spells
;
2312 SpellCooldowns m_spellCooldowns
;
2314 ActionButtonList m_actionButtons
;
2316 float m_auraBaseMod
[BASEMOD_END
][MOD_END
];
2317 int16 m_baseRatingValue
[MAX_COMBAT_RATING
];
2318 uint16 m_baseSpellDamage
;
2319 uint16 m_baseSpellHealing
;
2320 uint16 m_baseFeralAP
;
2321 uint16 m_baseManaRegen
;
2323 SpellModList m_spellMods
[MAX_SPELLMOD
];
2324 int32 m_SpellModRemoveCount
;
2325 EnchantDurationList m_enchantDuration
;
2326 ItemDurationList m_itemDuration
;
2328 uint64 m_resurrectGUID
;
2329 uint32 m_resurrectMap
;
2330 float m_resurrectX
, m_resurrectY
, m_resurrectZ
;
2331 uint32 m_resurrectHealth
, m_resurrectMana
;
2333 WorldSession
*m_session
;
2335 typedef std::list
<Channel
*> JoinedChannelsList
;
2336 JoinedChannelsList m_channels
;
2344 uint16 tradeItems
[TRADE_SLOT_COUNT
];
2347 time_t m_nextThinkTime
;
2349 uint32 m_Tutorials
[8];
2350 bool m_TutorialsChanged
;
2352 bool m_DailyQuestChanged
;
2353 time_t m_lastDailyQuestTime
;
2355 uint32 m_breathTimer
;
2356 uint32 m_drunkTimer
;
2358 uint32 m_weaponChangeTimer
;
2360 uint32 m_zoneUpdateId
;
2361 uint32 m_zoneUpdateTimer
;
2362 uint32 m_areaUpdateId
;
2364 uint32 m_deathTimer
;
2365 time_t m_deathExpireTime
;
2369 uint32 m_WeaponProficiency
;
2370 uint32 m_ArmorProficiency
;
2373 bool m_canDualWield
;
2374 bool m_canTitanGrip
;
2375 uint8 m_swingErrorMsg
;
2378 ////////////////////Rest System/////////////////////
2380 uint32 inn_pos_mapid
;
2386 ////////////////////Rest System/////////////////////
2389 Transport
* m_transport
;
2391 uint32 m_resetTalentsCost
;
2392 time_t m_resetTalentsTime
;
2393 uint32 m_usedTalentCount
;
2396 PlayerSocial
*m_social
;
2399 GroupReference m_group
;
2400 Group
*m_groupInvite
;
2401 uint32 m_groupUpdateMask
;
2402 uint64 m_auraUpdateMask
;
2404 // Temporarily removed pet cache
2405 uint32 m_temporaryUnsummonedPetNumber
;
2406 uint32 m_oldpetspell
;
2409 GuardianPetList m_guardianPets
;
2412 time_t m_summon_expire
;
2413 uint32 m_summon_mapid
;
2419 WorldLocation m_teleport_dest
;
2421 DeclinedName
*m_declinedname
;
2423 AchievementMgr m_achievementMgr
;
2425 // internal common parts for CanStore/StoreItem functions
2426 uint8
_CanStoreItem_InSpecificSlot( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool swap
, Item
*pSrcItem
) const;
2427 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;
2428 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;
2429 Item
* _StoreItem( uint16 pos
, Item
*pItem
, uint32 count
, bool clone
, bool update
);
2431 GridReference
<Player
> m_gridRef
;
2432 MapReference m_mapRef
;
2435 void AddItemsSetItem(Player
*player
,Item
*item
);
2436 void RemoveItemsSetItem(Player
*player
,ItemPrototype
const *proto
);
2438 // "the bodies of template functions must be made available in a header file"
2439 template <class T
> T
Player::ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
)
2441 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
2442 if (!spellInfo
) return 0;
2444 int32 totalflat
= 0;
2445 for (SpellModList::iterator itr
= m_spellMods
[op
].begin(); itr
!= m_spellMods
[op
].end(); ++itr
)
2447 SpellModifier
*mod
= *itr
;
2449 if(!IsAffectedBySpellmod(spellInfo
,mod
,spell
))
2451 if (mod
->type
== SPELLMOD_FLAT
)
2452 totalflat
+= mod
->value
;
2453 else if (mod
->type
== SPELLMOD_PCT
)
2455 // skip percent mods for null basevalue (most important for spell mods with charges )
2456 if(basevalue
== T(0))
2459 // special case (skip >10sec spell casts for instant cast setting)
2460 if( mod
->op
==SPELLMOD_CASTING_TIME
&& basevalue
>= T(10000) && mod
->value
<= -100)
2463 totalpct
+= mod
->value
;
2466 if (mod
->charges
> 0 )
2469 if (mod
->charges
== 0)
2472 mod
->lastAffected
= spell
;
2473 if(!mod
->lastAffected
)
2474 mod
->lastAffected
= FindCurrentSpellBySpellId(spellId
);
2475 ++m_SpellModRemoveCount
;
2480 float diff
= (float)basevalue
*(float)totalpct
/100.0f
+ (float)totalflat
;
2481 basevalue
= T((float)basevalue
+ diff
);