2 * Copyright (C) 2005-2008 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"
53 typedef std::deque
<Mail
*> PlayerMails
;
55 #define PLAYER_MAX_SKILLS 127
56 #define PLAYER_MAX_DAILY_QUESTS 25
58 // Note: SPELLMOD_* values is aura types in fact
61 SPELLMOD_FLAT
= 107, // SPELL_AURA_ADD_FLAT_MODIFIER
62 SPELLMOD_PCT
= 108 // SPELL_AURA_ADD_PCT_MODIFIER
67 PLAYERSPELL_UNCHANGED
= 0,
68 PLAYERSPELL_CHANGED
= 1,
70 PLAYERSPELL_REMOVED
= 3
76 PlayerSpellState state
: 8;
81 #define SPELL_WITHOUT_SLOT_ID uint16(-1)
86 SpellModType type
: 8;
92 Spell
const* lastAffected
;
95 typedef UNORDERED_MAP
<uint16
, PlayerSpell
*> PlayerSpellMap
;
96 typedef std::list
<SpellModifier
*> SpellModList
;
104 typedef std::map
<uint32
, SpellCooldown
> SpellCooldowns
;
106 enum TrainerSpellState
108 TRAINER_SPELL_GREEN
= 0,
109 TRAINER_SPELL_RED
= 1,
110 TRAINER_SPELL_GRAY
= 2
113 enum ActionButtonUpdateState
115 ACTIONBUTTON_UNCHANGED
= 0,
116 ACTIONBUTTON_CHANGED
= 1,
117 ACTIONBUTTON_NEW
= 2,
118 ACTIONBUTTON_DELETED
= 3
123 ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW
) {}
124 ActionButton(uint16 _action
, uint8 _type
, uint8 _misc
) : action(_action
), type(_type
), misc(_misc
), uState( ACTIONBUTTON_NEW
) {}
129 ActionButtonUpdateState uState
;
132 enum ActionButtonType
134 ACTION_BUTTON_SPELL
= 0,
135 ACTION_BUTTON_MACRO
= 64,
136 ACTION_BUTTON_CMACRO
= 65,
137 ACTION_BUTTON_ITEM
= 128
140 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
142 typedef std::map
<uint8
,ActionButton
> ActionButtonList
;
144 typedef std::pair
<uint16
, uint8
> CreateSpellPair
;
146 struct PlayerCreateInfoItem
148 PlayerCreateInfoItem(uint32 id
, uint32 amount
) : item_id(id
), item_amount(amount
) {}
154 typedef std::list
<PlayerCreateInfoItem
> PlayerCreateInfoItems
;
156 struct PlayerClassLevelInfo
158 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
163 struct PlayerClassInfo
165 PlayerClassInfo() : levelInfo(NULL
) { }
167 PlayerClassLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
170 struct PlayerLevelInfo
172 PlayerLevelInfo() { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
174 uint8 stats
[MAX_STATS
];
179 // existence checked by displayId != 0 // existence checked by displayId != 0
180 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL
)
191 PlayerCreateInfoItems item
;
192 std::list
<CreateSpellPair
> spell
;
193 std::list
<uint16
> action
[4];
195 PlayerLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
200 PvPInfo() : inHostileArea(false), endTimer(0) {}
208 DuelInfo() : initiator(NULL
), opponent(NULL
), startTimer(0), startTime(0), outOfBound(0) {}
228 #define RUNE_COOLDOWN 5 // 5*2=10 sec
249 uint8 runeState
; // mask of available runes
251 void SetRuneState(uint8 index
, bool set
= true)
254 runeState
|= (1 << index
); // usable
256 runeState
&= ~(1 << index
); // on cooldown
262 FACTION_FLAG_VISIBLE
= 0x01, // makes visible in client (set or can be set at interaction with target of this faction)
263 FACTION_FLAG_AT_WAR
= 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
264 FACTION_FLAG_HIDDEN
= 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
265 FACTION_FLAG_INVISIBLE_FORCED
= 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
266 FACTION_FLAG_PEACE_FORCED
= 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
267 FACTION_FLAG_INACTIVE
= 0x20, // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE )
268 FACTION_FLAG_RIVAL
= 0x40 // flag for the two competing outland factions
271 typedef uint32 RepListID
;
275 RepListID ReputationListID
;
281 typedef std::map
<RepListID
,FactionState
> FactionStateList
;
283 typedef std::map
<uint32
,ReputationRank
> ForcedReactions
;
285 typedef std::set
<uint64
> GuardianPetList
;
287 struct EnchantDuration
289 EnchantDuration() : item(NULL
), slot(MAX_ENCHANTMENT_SLOT
), leftduration(0) {};
290 EnchantDuration(Item
* _item
, EnchantmentSlot _slot
, uint32 _leftduration
) : item(_item
), slot(_slot
), leftduration(_leftduration
) { assert(item
); };
293 EnchantmentSlot slot
;
297 typedef std::list
<EnchantDuration
> EnchantDurationList
;
298 typedef std::list
<Item
*> ItemDurationList
;
300 struct LookingForGroupSlot
302 LookingForGroupSlot() : entry(0), type(0) {}
303 bool Empty() const { return !entry
&& !type
; }
304 void Clear() { entry
= 0; type
= 0; }
305 void Set(uint32 _entry
, uint32 _type
) { entry
= _entry
; type
= _type
; }
306 bool Is(uint32 _entry
, uint32 _type
) const { return entry
==_entry
&& type
==_type
; }
307 bool canAutoJoin() const { return entry
&& (type
== 1 || type
== 5); }
313 #define MAX_LOOKING_FOR_GROUP_SLOT 3
315 struct LookingForGroup
318 bool HaveInSlot(LookingForGroupSlot
const& slot
) const { return HaveInSlot(slot
.entry
,slot
.type
); }
319 bool HaveInSlot(uint32 _entry
, uint32 _type
) const
321 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
322 if(slots
[i
].Is(_entry
,_type
))
327 bool canAutoJoin() const
329 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
330 if(slots
[i
].canAutoJoin())
337 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
338 if(!slots
[i
].Empty())
343 LookingForGroupSlot slots
[MAX_LOOKING_FOR_GROUP_SLOT
];
344 LookingForGroupSlot more
;
348 enum PlayerMovementType
371 PLAYER_STATE_READYUNARMED
373 PLAYER_STATE_POINT(DNR)
374 PLAYER_STATE_NONE // not used or just no state, just standing there?
378 PLAYER_STATE_USESTANDING
379 PLAYER_STATE_STUN_NOSHEATHE
380 PLAYER_STATE_USESTANDING_NOSHEATHE
381 PLAYER_STATE_WORK_NOSHEATHE
382 PLAYER_STATE_SPELLPRECAST
383 PLAYER_STATE_READYRIFLE
384 PLAYER_STATE_WORK_NOSHEATHE_MINING
385 PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD
388 PLAYER_STATE_SPELLKNEELSTART
389 PLAYER_STATE_SUBMERGED
392 PLAYER_STATE_NONE
= 0,
393 PLAYER_STATE_SIT
= 1,
394 PLAYER_STATE_SIT_CHAIR
= 2,
395 PLAYER_STATE_SLEEP
= 3,
396 PLAYER_STATE_SIT_LOW_CHAIR
= 4,
397 PLAYER_STATE_SIT_MEDIUM_CHAIR
= 5,
398 PLAYER_STATE_SIT_HIGH_CHAIR
= 6,
399 PLAYER_STATE_DEAD
= 7,
400 PLAYER_STATE_KNEEL
= 8,
402 PLAYER_STATE_FORM_ALL
= 0x00FF0000,
404 PLAYER_STATE_FLAG_ALWAYS_STAND
= 0x01, // byte 4
405 PLAYER_STATE_FLAG_CREEP
= 0x02000000,
406 PLAYER_STATE_FLAG_UNTRACKABLE
= 0x04000000,
407 PLAYER_STATE_FLAG_ALL
= 0xFF000000,
412 PLAYER_FLAGS_GROUP_LEADER
= 0x00000001,
413 PLAYER_FLAGS_AFK
= 0x00000002,
414 PLAYER_FLAGS_DND
= 0x00000004,
415 PLAYER_FLAGS_GM
= 0x00000008,
416 PLAYER_FLAGS_GHOST
= 0x00000010,
417 PLAYER_FLAGS_RESTING
= 0x00000020,
418 PLAYER_FLAGS_FFA_PVP
= 0x00000080,
419 PLAYER_FLAGS_CONTESTED_PVP
= 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
420 PLAYER_FLAGS_IN_PVP
= 0x00000200,
421 PLAYER_FLAGS_HIDE_HELM
= 0x00000400,
422 PLAYER_FLAGS_HIDE_CLOAK
= 0x00000800,
423 PLAYER_FLAGS_UNK1
= 0x00001000, // played long time
424 PLAYER_FLAGS_UNK2
= 0x00002000, // played too long time
425 PLAYER_FLAGS_UNK3
= 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
426 PLAYER_FLAGS_SANCTUARY
= 0x00010000, // player entered sanctuary
427 PLAYER_FLAGS_UNK4
= 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
428 PLAYER_FLAGS_PVP_TIMER
= 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
431 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
432 // can't use enum for uint64 values
433 #define PLAYER_TITLE_DISABLED 0x0000000000000000LL
434 #define PLAYER_TITLE_NONE 0x0000000000000001LL
435 #define PLAYER_TITLE_PRIVATE 0x0000000000000002LL // 1
436 #define PLAYER_TITLE_CORPORAL 0x0000000000000004LL // 2
437 #define PLAYER_TITLE_SERGEANT_A 0x0000000000000008LL // 3
438 #define PLAYER_TITLE_MASTER_SERGEANT 0x0000000000000010LL // 4
439 #define PLAYER_TITLE_SERGEANT_MAJOR 0x0000000000000020LL // 5
440 #define PLAYER_TITLE_KNIGHT 0x0000000000000040LL // 6
441 #define PLAYER_TITLE_KNIGHT_LIEUTENANT 0x0000000000000080LL // 7
442 #define PLAYER_TITLE_KNIGHT_CAPTAIN 0x0000000000000100LL // 8
443 #define PLAYER_TITLE_KNIGHT_CHAMPION 0x0000000000000200LL // 9
444 #define PLAYER_TITLE_LIEUTENANT_COMMANDER 0x0000000000000400LL // 10
445 #define PLAYER_TITLE_COMMANDER 0x0000000000000800LL // 11
446 #define PLAYER_TITLE_MARSHAL 0x0000000000001000LL // 12
447 #define PLAYER_TITLE_FIELD_MARSHAL 0x0000000000002000LL // 13
448 #define PLAYER_TITLE_GRAND_MARSHAL 0x0000000000004000LL // 14
449 #define PLAYER_TITLE_SCOUT 0x0000000000008000LL // 15
450 #define PLAYER_TITLE_GRUNT 0x0000000000010000LL // 16
451 #define PLAYER_TITLE_SERGEANT_H 0x0000000000020000LL // 17
452 #define PLAYER_TITLE_SENIOR_SERGEANT 0x0000000000040000LL // 18
453 #define PLAYER_TITLE_FIRST_SERGEANT 0x0000000000080000LL // 19
454 #define PLAYER_TITLE_STONE_GUARD 0x0000000000100000LL // 20
455 #define PLAYER_TITLE_BLOOD_GUARD 0x0000000000200000LL // 21
456 #define PLAYER_TITLE_LEGIONNAIRE 0x0000000000400000LL // 22
457 #define PLAYER_TITLE_CENTURION 0x0000000000800000LL // 23
458 #define PLAYER_TITLE_CHAMPION 0x0000000001000000LL // 24
459 #define PLAYER_TITLE_LIEUTENANT_GENERAL 0x0000000002000000LL // 25
460 #define PLAYER_TITLE_GENERAL 0x0000000004000000LL // 26
461 #define PLAYER_TITLE_WARLORD 0x0000000008000000LL // 27
462 #define PLAYER_TITLE_HIGH_WARLORD 0x0000000010000000LL // 28
463 #define PLAYER_TITLE_GLADIATOR 0x0000000020000000LL // 29
464 #define PLAYER_TITLE_DUELIST 0x0000000040000000LL // 30
465 #define PLAYER_TITLE_RIVAL 0x0000000080000000LL // 31
466 #define PLAYER_TITLE_CHALLENGER 0x0000000100000000LL // 32
467 #define PLAYER_TITLE_SCARAB_LORD 0x0000000200000000LL // 33
468 #define PLAYER_TITLE_CONQUEROR 0x0000000400000000LL // 34
469 #define PLAYER_TITLE_JUSTICAR 0x0000000800000000LL // 35
470 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36
471 #define PLAYER_TITLE_MERCILESS_GLADIATOR 0x0000002000000000LL // 37
472 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN 0x0000004000000000LL // 38
473 #define PLAYER_TITLE_HAND_OF_ADAL 0x0000008000000000LL // 39
474 #define PLAYER_TITLE_VENGEFUL_GLADIATOR 0x0000010000000000LL // 40
476 // used in PLAYER_FIELD_BYTES values
477 enum PlayerFieldByteFlags
479 PLAYER_FIELD_BYTE_TRACK_STEALTHED
= 0x00000002,
480 PLAYER_FIELD_BYTE_RELEASE_TIMER
= 0x00000008, // Display time till auto release spirit
481 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW
= 0x00000010 // Display no "release spirit" window at all
484 // used in PLAYER_FIELD_BYTES2 values
485 enum PlayerFieldByte2Flags
487 PLAYER_FIELD_BYTE2_NONE
= 0x0000,
488 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
= 0x4000
491 enum ActivateTaxiReplies
494 ERR_TAXIUNSPECIFIEDSERVERERROR
= 1,
495 ERR_TAXINOSUCHPATH
= 2,
496 ERR_TAXINOTENOUGHMONEY
= 3,
497 ERR_TAXITOOFARAWAY
= 4,
498 ERR_TAXINOVENDORNEARBY
= 5,
499 ERR_TAXINOTVISITED
= 6,
500 ERR_TAXIPLAYERBUSY
= 7,
501 ERR_TAXIPLAYERALREADYMOUNTED
= 8,
502 ERR_TAXIPLAYERSHAPESHIFTED
= 9,
503 ERR_TAXIPLAYERMOVING
= 10,
504 ERR_TAXISAMENODE
= 11,
505 ERR_TAXINOTSTANDING
= 12
513 LOOT_PICKPOCKETING
= 4, // unsupported by client, sending LOOT_SKINNING instead
514 LOOT_DISENCHANTING
= 5, // unsupported by client, sending LOOT_SKINNING instead
515 LOOT_PROSPECTING
= 6, // unsupported by client, sending LOOT_SKINNING instead
516 LOOT_INSIGNIA
= 7, // unsupported by client, sending LOOT_SKINNING instead
517 LOOT_FISHINGHOLE
= 8, // unsupported by client, sending LOOT_FISHING instead
518 LOOT_MILLING
= 9 // unsupported by client, sending LOOT_SKINNING instead
529 enum PlayerExtraFlags
532 PLAYER_EXTRA_GM_ON
= 0x0001,
533 PLAYER_EXTRA_GM_ACCEPT_TICKETS
= 0x0002,
534 PLAYER_EXTRA_ACCEPT_WHISPERS
= 0x0004,
535 PLAYER_EXTRA_TAXICHEAT
= 0x0008,
536 PLAYER_EXTRA_GM_INVISIBLE
= 0x0010,
537 PLAYER_EXTRA_GM_CHAT
= 0x0020, // Show GM badge in chat messages
540 PLAYER_EXTRA_PVP_DEATH
= 0x0100 // store PvP death status until corpse creating.
548 AT_LOGIN_RESET_SPELLS
= 2,
549 AT_LOGIN_RESET_TALENTS
= 4
552 typedef std::map
<uint32
, QuestStatusData
> QuestStatusMap
;
554 enum QuestSlotOffsets
557 QUEST_STATE_OFFSET
= 1,
558 QUEST_COUNTS_OFFSET
= 2,
559 QUEST_TIME_OFFSET
= 3
562 #define MAX_QUEST_OFFSET 4
564 enum QuestSlotStateMask
566 QUEST_STATE_NONE
= 0x0000,
567 QUEST_STATE_COMPLETE
= 0x0001,
568 QUEST_STATE_FAIL
= 0x0002
578 // first slot for item stored (in any way in player m_items data)
579 PLAYER_SLOT_START
= 0,
580 // last+1 slot for item stored (in any way in player m_items data)
581 PLAYER_SLOT_END
= 200,
582 PLAYER_SLOTS_COUNT
= (PLAYER_SLOT_END
- PLAYER_SLOT_START
)
587 EQUIPMENT_SLOT_START
= 0,
588 EQUIPMENT_SLOT_HEAD
= 0,
589 EQUIPMENT_SLOT_NECK
= 1,
590 EQUIPMENT_SLOT_SHOULDERS
= 2,
591 EQUIPMENT_SLOT_BODY
= 3,
592 EQUIPMENT_SLOT_CHEST
= 4,
593 EQUIPMENT_SLOT_WAIST
= 5,
594 EQUIPMENT_SLOT_LEGS
= 6,
595 EQUIPMENT_SLOT_FEET
= 7,
596 EQUIPMENT_SLOT_WRISTS
= 8,
597 EQUIPMENT_SLOT_HANDS
= 9,
598 EQUIPMENT_SLOT_FINGER1
= 10,
599 EQUIPMENT_SLOT_FINGER2
= 11,
600 EQUIPMENT_SLOT_TRINKET1
= 12,
601 EQUIPMENT_SLOT_TRINKET2
= 13,
602 EQUIPMENT_SLOT_BACK
= 14,
603 EQUIPMENT_SLOT_MAINHAND
= 15,
604 EQUIPMENT_SLOT_OFFHAND
= 16,
605 EQUIPMENT_SLOT_RANGED
= 17,
606 EQUIPMENT_SLOT_TABARD
= 18,
607 EQUIPMENT_SLOT_END
= 19
612 INVENTORY_SLOT_BAG_0
= 255,
613 INVENTORY_SLOT_BAG_START
= 19,
614 INVENTORY_SLOT_BAG_1
= 19,
615 INVENTORY_SLOT_BAG_2
= 20,
616 INVENTORY_SLOT_BAG_3
= 21,
617 INVENTORY_SLOT_BAG_4
= 22,
618 INVENTORY_SLOT_BAG_END
= 23,
620 INVENTORY_SLOT_ITEM_START
= 23,
621 INVENTORY_SLOT_ITEM_1
= 23,
622 INVENTORY_SLOT_ITEM_2
= 24,
623 INVENTORY_SLOT_ITEM_3
= 25,
624 INVENTORY_SLOT_ITEM_4
= 26,
625 INVENTORY_SLOT_ITEM_5
= 27,
626 INVENTORY_SLOT_ITEM_6
= 28,
627 INVENTORY_SLOT_ITEM_7
= 29,
628 INVENTORY_SLOT_ITEM_8
= 30,
629 INVENTORY_SLOT_ITEM_9
= 31,
630 INVENTORY_SLOT_ITEM_10
= 32,
631 INVENTORY_SLOT_ITEM_11
= 33,
632 INVENTORY_SLOT_ITEM_12
= 34,
633 INVENTORY_SLOT_ITEM_13
= 35,
634 INVENTORY_SLOT_ITEM_14
= 36,
635 INVENTORY_SLOT_ITEM_15
= 37,
636 INVENTORY_SLOT_ITEM_16
= 38,
637 INVENTORY_SLOT_ITEM_END
= 39
642 BANK_SLOT_ITEM_START
= 39,
643 BANK_SLOT_ITEM_1
= 39,
644 BANK_SLOT_ITEM_2
= 40,
645 BANK_SLOT_ITEM_3
= 41,
646 BANK_SLOT_ITEM_4
= 42,
647 BANK_SLOT_ITEM_5
= 43,
648 BANK_SLOT_ITEM_6
= 44,
649 BANK_SLOT_ITEM_7
= 45,
650 BANK_SLOT_ITEM_8
= 46,
651 BANK_SLOT_ITEM_9
= 47,
652 BANK_SLOT_ITEM_10
= 48,
653 BANK_SLOT_ITEM_11
= 49,
654 BANK_SLOT_ITEM_12
= 50,
655 BANK_SLOT_ITEM_13
= 51,
656 BANK_SLOT_ITEM_14
= 52,
657 BANK_SLOT_ITEM_15
= 53,
658 BANK_SLOT_ITEM_16
= 54,
659 BANK_SLOT_ITEM_17
= 55,
660 BANK_SLOT_ITEM_18
= 56,
661 BANK_SLOT_ITEM_19
= 57,
662 BANK_SLOT_ITEM_20
= 58,
663 BANK_SLOT_ITEM_21
= 59,
664 BANK_SLOT_ITEM_22
= 60,
665 BANK_SLOT_ITEM_23
= 61,
666 BANK_SLOT_ITEM_24
= 62,
667 BANK_SLOT_ITEM_25
= 63,
668 BANK_SLOT_ITEM_26
= 64,
669 BANK_SLOT_ITEM_27
= 65,
670 BANK_SLOT_ITEM_28
= 66,
671 BANK_SLOT_ITEM_END
= 67,
673 BANK_SLOT_BAG_START
= 67,
674 BANK_SLOT_BAG_1
= 67,
675 BANK_SLOT_BAG_2
= 68,
676 BANK_SLOT_BAG_3
= 69,
677 BANK_SLOT_BAG_4
= 70,
678 BANK_SLOT_BAG_5
= 71,
679 BANK_SLOT_BAG_6
= 72,
680 BANK_SLOT_BAG_7
= 73,
681 BANK_SLOT_BAG_END
= 74
686 // stored in m_buybackitems
687 BUYBACK_SLOT_START
= 74,
697 BUYBACK_SLOT_10
= 83,
698 BUYBACK_SLOT_11
= 84,
699 BUYBACK_SLOT_12
= 85,
700 BUYBACK_SLOT_END
= 86
705 KEYRING_SLOT_START
= 86,
706 KEYRING_SLOT_END
= 118
711 VANITYPET_SLOT_START
= 118,
712 VANITYPET_SLOT_END
= 136
715 enum CurrencyTokenSlots
717 CURRENCYTOKEN_SLOT_START
= 136,
718 CURRENCYTOKEN_SLOT_END
= 168
723 QUESTBAG_SLOT_START
= 168,
724 QUESTBAG_SLOT_END
= 200
729 ItemPosCount(uint16 _pos
, uint8 _count
) : pos(_pos
), count(_count
) {}
730 bool isContainedIn(std::vector
<ItemPosCount
> const& vec
) const;
734 typedef std::vector
<ItemPosCount
> ItemPosCountVec
;
738 TRADE_SLOT_COUNT
= 7,
739 TRADE_SLOT_TRADED_COUNT
= 6,
740 TRADE_SLOT_NONTRADED
= 6
743 enum TransferAbortReason
745 TRANSFER_ABORT_ERROR
= 0x00,
746 TRANSFER_ABORT_MAX_PLAYERS
= 0x01, // Transfer Aborted: instance is full
747 TRANSFER_ABORT_NOT_FOUND
= 0x02, // Transfer Aborted: instance not found
748 TRANSFER_ABORT_TOO_MANY_INSTANCES
= 0x03, // You have entered too many instances recently.
749 TRANSFER_ABORT_ZONE_IN_COMBAT
= 0x05, // Unable to zone in while an encounter is in progress.
750 TRANSFER_ABORT_INSUF_EXPAN_LVL
= 0x06, // You must have <TBC,WotLK> expansion installed to access this area.
751 TRANSFER_ABORT_DIFFICULTY
= 0x07, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
752 TRANSFER_ABORT_UNIQUE_MESSAGE
= 0x08, // Until you've escaped TLK's grasp, you cannot leave this place!
753 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES
= 0x09 // Additional instances cannot be launched, please try again later.
756 enum InstanceResetWarningType
758 RAID_INSTANCE_WARNING_HOURS
= 1, // WARNING! %s is scheduled to reset in %d hour(s).
759 RAID_INSTANCE_WARNING_MIN
= 2, // WARNING! %s is scheduled to reset in %d minute(s)!
760 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!
761 RAID_INSTANCE_WELCOME
= 4 // Welcome to %s. This raid instance is scheduled to reset in %s.
773 float t_x
, t_y
, t_z
, t_o
;
776 // swimming and unknown
781 float j_unk
, j_sinAngle
, j_cosAngle
, j_xyspeed
;
788 time
= t_time
= fallTime
= 0;
790 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
;
794 void SetMovementFlags(uint32 _flags
)
800 // flags that use in movement check for example at spell casting
801 MovementFlags
const movementFlagsMask
= MovementFlags(
802 MOVEMENTFLAG_FORWARD
|MOVEMENTFLAG_BACKWARD
|MOVEMENTFLAG_STRAFE_LEFT
|MOVEMENTFLAG_STRAFE_RIGHT
|
803 MOVEMENTFLAG_PITCH_UP
|MOVEMENTFLAG_PITCH_DOWN
|MOVEMENTFLAG_FLY_UNK1
|
804 MOVEMENTFLAG_JUMPING
|MOVEMENTFLAG_FALLING
|MOVEMENTFLAG_FLY_UP
|
805 MOVEMENTFLAG_FLYING
|MOVEMENTFLAG_SPLINE
808 MovementFlags
const movementOrTurningFlagsMask
= MovementFlags(
809 movementFlagsMask
| MOVEMENTFLAG_LEFT
| MOVEMENTFLAG_RIGHT
816 REST_TYPE_IN_TAVERN
= 1,
817 REST_TYPE_IN_CITY
= 2
820 enum DuelCompleteType
827 enum TeleportToOptions
829 TELE_TO_GM_MODE
= 0x01,
830 TELE_TO_NOT_LEAVE_TRANSPORT
= 0x02,
831 TELE_TO_NOT_LEAVE_COMBAT
= 0x04,
832 TELE_TO_NOT_UNSUMMON_PET
= 0x08,
833 TELE_TO_SPELL
= 0x10,
836 /// Type of environmental damages
837 enum EnviromentalDamage
839 DAMAGE_EXHAUSTED
= 0,
845 DAMAGE_FALL_TO_VOID
= 6 // custom case for fall without durability loss
848 // used at player loading query list preparing, and later result selection
849 enum PlayerLoginQueryIndex
851 PLAYER_LOGIN_QUERY_LOADFROM
= 0,
852 PLAYER_LOGIN_QUERY_LOADGROUP
= 1,
853 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES
= 2,
854 PLAYER_LOGIN_QUERY_LOADAURAS
= 3,
855 PLAYER_LOGIN_QUERY_LOADSPELLS
= 4,
856 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS
= 5,
857 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS
= 6,
858 PLAYER_LOGIN_QUERY_LOADTUTORIALS
= 7, // common for all characters for some account at specific realm
859 PLAYER_LOGIN_QUERY_LOADREPUTATION
= 8,
860 PLAYER_LOGIN_QUERY_LOADINVENTORY
= 9,
861 PLAYER_LOGIN_QUERY_LOADACTIONS
= 10,
862 PLAYER_LOGIN_QUERY_LOADMAILCOUNT
= 11,
863 PLAYER_LOGIN_QUERY_LOADMAILDATE
= 12,
864 PLAYER_LOGIN_QUERY_LOADSOCIALLIST
= 13,
865 PLAYER_LOGIN_QUERY_LOADHOMEBIND
= 14,
866 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS
= 15,
867 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES
= 16,
868 PLAYER_LOGIN_QUERY_LOADGUILD
= 17,
869 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS
= 18,
870 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS
= 19,
871 MAX_PLAYER_LOGIN_QUERY
= 20
875 // Player summoning auto-decline time (in secs)
876 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
877 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
879 struct InstancePlayerBind
883 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
884 that aren't already permanently bound when they are inside when a boss is killed
885 or when they enter an instance that the group leader is permanently bound to. */
886 InstancePlayerBind() : save(NULL
), perm(false) {}
889 class MANGOS_DLL_SPEC PlayerTaxi
895 void InitTaxiNodesForLevel(uint32 race
, uint32 chrClass
, uint32 level
);
896 void LoadTaxiMask(const char* data
);
897 void SaveTaxiMask(const char* data
);
899 uint32
GetTaximask( uint8 index
) const { return m_taximask
[index
]; }
900 bool IsTaximaskNodeKnown(uint32 nodeidx
) const
902 uint8 field
= uint8((nodeidx
- 1) / 32);
903 uint32 submask
= 1<<((nodeidx
-1)%32);
904 return (m_taximask
[field
] & submask
) == submask
;
906 bool SetTaximaskNode(uint32 nodeidx
)
908 uint8 field
= uint8((nodeidx
- 1) / 32);
909 uint32 submask
= 1<<((nodeidx
-1)%32);
910 if ((m_taximask
[field
] & submask
) != submask
)
912 m_taximask
[field
] |= submask
;
918 void AppendTaximaskTo(ByteBuffer
& data
,bool all
);
921 bool LoadTaxiDestinationsFromString(std::string values
);
922 std::string
SaveTaxiDestinationsToString();
924 void ClearTaxiDestinations() { m_TaxiDestinations
.clear(); }
925 void AddTaxiDestination(uint32 dest
) { m_TaxiDestinations
.push_back(dest
); }
926 uint32
GetTaxiSource() const { return m_TaxiDestinations
.empty() ? 0 : m_TaxiDestinations
.front(); }
927 uint32
GetTaxiDestination() const { return m_TaxiDestinations
.size() < 2 ? 0 : m_TaxiDestinations
[1]; }
928 uint32
GetCurrentTaxiPath() const;
929 uint32
NextTaxiDestination()
931 m_TaxiDestinations
.pop_front();
932 return GetTaxiDestination();
934 bool empty() const { return m_TaxiDestinations
.empty(); }
937 std::deque
<uint32
> m_TaxiDestinations
;
940 class MANGOS_DLL_SPEC Player
: public Unit
942 friend class WorldSession
;
943 friend void Item::AddToUpdateQueueOf(Player
*player
);
944 friend void Item::RemoveFromUpdateQueueOf(Player
*player
);
946 explicit Player (WorldSession
*session
);
949 void CleanupsBeforeDelete();
951 static UpdateMask updateVisualBits
;
952 static void InitVisibleBits();
955 void RemoveFromWorld();
957 bool TeleportTo(uint32 mapid
, float x
, float y
, float z
, float orientation
, uint32 options
= 0);
959 bool TeleportTo(WorldLocation
const &loc
, uint32 options
= 0)
961 return TeleportTo(loc
.mapid
, loc
.x
, loc
.y
, loc
.z
, options
);
964 void SetSummonPoint(uint32 mapid
, float x
, float y
, float z
)
966 m_summon_expire
= time(NULL
) + MAX_PLAYER_SUMMON_DELAY
;
967 m_summon_mapid
= mapid
;
972 void SummonIfPossible(bool agree
);
974 bool Create( uint32 guidlow
, std::string name
, uint8 race
, uint8 class_
, uint8 gender
, uint8 skin
, uint8 face
, uint8 hairStyle
, uint8 hairColor
, uint8 facialHair
, uint8 outfitId
);
976 void Update( uint32 time
);
978 void BuildEnumData( QueryResult
* result
, WorldPacket
* p_data
);
980 void SetInWater(bool apply
);
982 bool IsInWater() const { return m_isInWater
; }
983 bool IsUnderWater() const;
985 void SendInitialPacketsBeforeAddToMap();
986 void SendInitialPacketsAfterAddToMap();
987 void SendTransferAborted(uint32 mapid
, uint8 reason
, uint8 arg
= 0);
988 void SendInstanceResetWarning(uint32 mapid
, uint32 time
);
990 bool CanInteractWithNPCs(bool alive
= true) const;
994 bool isAFK() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_AFK
); };
995 bool isDND() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_DND
); };
996 uint8
chatTag() const;
1000 uint32
GetBarberShopCost(uint8 newhairstyle
, uint8 newhaircolor
, uint8 newfacialhair
);
1002 PlayerSocial
*GetSocial() { return m_social
; }
1005 void InitTaxiNodesForLevel() { m_taxi
.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1006 bool ActivateTaxiPathTo(std::vector
<uint32
> const& nodes
, uint32 mount_id
= 0 , Creature
* npc
= NULL
);
1007 // mount_id can be used in scripting calls
1008 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_ACCEPT_TICKETS
); }
1009 void SetAcceptTicket(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_ACCEPT_TICKETS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS
; }
1010 bool isAcceptWhispers() const { return m_ExtraFlags
& PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1011 void SetAcceptWhispers(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_ACCEPT_WHISPERS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1012 bool isGameMaster() const { return m_ExtraFlags
& PLAYER_EXTRA_GM_ON
; }
1013 void SetGameMaster(bool on
);
1014 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_CHAT
); }
1015 void SetGMChat(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_CHAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_CHAT
; }
1016 bool isTaxiCheater() const { return m_ExtraFlags
& PLAYER_EXTRA_TAXICHEAT
; }
1017 void SetTaxiCheater(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_TAXICHEAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_TAXICHEAT
; }
1018 bool isGMVisible() const { return !(m_ExtraFlags
& PLAYER_EXTRA_GM_INVISIBLE
); }
1019 void SetGMVisible(bool on
);
1020 void SetPvPDeath(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_PVP_DEATH
; else m_ExtraFlags
&= ~PLAYER_EXTRA_PVP_DEATH
; }
1022 void GiveXP(uint32 xp
, Unit
* victim
);
1023 void GiveLevel(uint32 level
);
1024 void InitStatsForLevel(bool reapplyMods
= false);
1026 // Played Time Stuff
1029 uint32 m_Played_time
[2];
1030 uint32
GetTotalPlayedTime() { return m_Played_time
[0]; };
1031 uint32
GetLevelPlayedTime() { return m_Played_time
[1]; };
1033 void setDeathState(DeathState s
); // overwrite Unit::setDeathState
1035 void InnEnter (int time
,uint32 mapid
, float x
,float y
,float z
)
1037 inn_pos_mapid
= mapid
;
1041 time_inn_enter
= time
;
1044 float GetRestBonus() const { return m_rest_bonus
; };
1045 void SetRestBonus(float rest_bonus_new
);
1047 RestType
GetRestType() const { return rest_type
; };
1048 void SetRestType(RestType n_r_type
) { rest_type
= n_r_type
; };
1050 uint32
GetInnPosMapId() const { return inn_pos_mapid
; };
1051 float GetInnPosX() const { return inn_pos_x
; };
1052 float GetInnPosY() const { return inn_pos_y
; };
1053 float GetInnPosZ() const { return inn_pos_z
; };
1055 int GetTimeInnEnter() const { return time_inn_enter
; };
1056 void UpdateInnerTime (int time
) { time_inn_enter
= time
; };
1058 void RemovePet(Pet
* pet
, PetSaveMode mode
, bool returnreagent
= false);
1059 void RemoveMiniPet();
1061 void SetMiniPet(Pet
* pet
) { m_miniPet
= pet
->GetGUID(); }
1062 void RemoveGuardians();
1063 bool HasGuardianWithEntry(uint32 entry
);
1064 void AddGuardian(Pet
* pet
) { m_guardianPets
.insert(pet
->GetGUID()); }
1065 GuardianPetList
const& GetGuardians() const { return m_guardianPets
; }
1068 void Say(std::string text
, const uint32 language
);
1069 void Yell(std::string text
, const uint32 language
);
1070 void TextEmote(std::string text
);
1071 void Whisper(std::string text
, const uint32 language
,uint64 receiver
);
1072 void BuildPlayerChat(WorldPacket
*data
, uint8 msgtype
, std::string text
, uint32 language
) const;
1074 /*********************************************************/
1075 /*** STORAGE SYSTEM ***/
1076 /*********************************************************/
1078 void SetVirtualItemSlot( uint8 i
, Item
* item
);
1079 void SetSheath( uint32 sheathed
);
1080 uint8
FindEquipSlot( ItemPrototype
const* proto
, uint32 slot
, bool swap
) const;
1081 uint32
GetItemCount( uint32 item
, bool inBankAlso
= false, Item
* skipItem
= NULL
) const;
1082 Item
* GetItemByGuid( uint64 guid
) const;
1083 Item
* GetItemByPos( uint16 pos
) const;
1084 Item
* GetItemByPos( uint8 bag
, uint8 slot
) const;
1085 Item
* GetWeaponForAttack(WeaponAttackType attackType
, bool useable
= false) const;
1086 Item
* GetShield(bool useable
= false) const;
1087 static uint32
GetAttackBySlot( uint8 slot
); // MAX_ATTACK if not weapon slot
1088 std::vector
<Item
*> &GetItemUpdateQueue() { return m_itemUpdateQueue
; }
1089 static bool IsInventoryPos( uint16 pos
) { return IsInventoryPos(pos
>> 8,pos
& 255); }
1090 static bool IsInventoryPos( uint8 bag
, uint8 slot
);
1091 static bool IsEquipmentPos( uint16 pos
) { return IsEquipmentPos(pos
>> 8,pos
& 255); }
1092 static bool IsEquipmentPos( uint8 bag
, uint8 slot
);
1093 static bool IsBagPos( uint16 pos
);
1094 static bool IsBankPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1095 static bool IsBankPos( uint8 bag
, uint8 slot
);
1096 bool IsValidPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1097 bool IsValidPos( uint8 bag
, uint8 slot
);
1098 bool HasBankBagSlot( uint8 slot
) const;
1099 bool HasItemCount( uint32 item
, uint32 count
, bool inBankAlso
= false ) const;
1100 bool HasItemFitToSpellReqirements(SpellEntry
const* spellInfo
, Item
const* ignoreItem
= NULL
);
1101 Item
* GetItemOrItemWithGemEquipped( uint32 item
) const;
1102 uint8
CanTakeMoreSimilarItems(Item
* pItem
) const { return _CanTakeMoreSimilarItems(pItem
->GetEntry(),pItem
->GetCount(),pItem
); }
1103 uint8
CanTakeMoreSimilarItems(uint32 entry
, uint32 count
) const { return _CanTakeMoreSimilarItems(entry
,count
,NULL
); }
1104 uint8
CanStoreNewItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 item
, uint32 count
, uint32
* no_space_count
= NULL
) const
1106 return _CanStoreItem(bag
, slot
, dest
, item
, count
, NULL
, false, no_space_count
);
1108 uint8
CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
= false ) const
1111 return EQUIP_ERR_ITEM_NOT_FOUND
;
1112 uint32 count
= pItem
->GetCount();
1113 return _CanStoreItem( bag
, slot
, dest
, pItem
->GetEntry(), count
, pItem
, swap
, NULL
);
1116 uint8
CanStoreItems( Item
**pItem
,int count
) const;
1117 uint8
CanEquipNewItem( uint8 slot
, uint16
&dest
, uint32 item
, uint32 count
, bool swap
) const;
1118 uint8
CanEquipItem( uint8 slot
, uint16
&dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1119 uint8
CanUnequipItems( uint32 item
, uint32 count
) const;
1120 uint8
CanUnequipItem( uint16 src
, bool swap
) const;
1121 uint8
CanBankItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1122 uint8
CanUseItem( Item
*pItem
, bool not_loading
= true ) const;
1123 bool HasItemTotemCategory( uint32 TotemCategory
) const;
1124 bool CanUseItem( ItemPrototype
const *pItem
);
1125 uint8
CanUseAmmo( uint32 item
) const;
1126 Item
* StoreNewItem( ItemPosCountVec
const& pos
, uint32 item
, bool update
,int32 randomPropertyId
= 0 );
1127 Item
* StoreItem( ItemPosCountVec
const& pos
, Item
*pItem
, bool update
);
1128 Item
* EquipNewItem( uint16 pos
, uint32 item
, uint32 count
, bool update
);
1129 Item
* EquipItem( uint16 pos
, Item
*pItem
, bool update
);
1130 void AutoUnequipOffhandIfNeed();
1131 bool StoreNewItemInBestSlot(uint32 item_id
, uint32 item_count
);
1133 uint8
_CanTakeMoreSimilarItems(uint32 entry
, uint32 count
, Item
* pItem
, uint32
* no_space_count
= NULL
) const;
1134 uint8
_CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 entry
, uint32 count
, Item
*pItem
= NULL
, bool swap
= false, uint32
* no_space_count
= NULL
) const;
1136 void ApplyEquipCooldown( Item
* pItem
);
1137 void SetAmmo( uint32 item
);
1139 float GetAmmoDPS() const { return m_ammoDPS
; }
1140 bool CheckAmmoCompatibility(const ItemPrototype
*ammo_proto
) const;
1141 void QuickEquipItem( uint16 pos
, Item
*pItem
);
1142 void VisualizeItem( uint8 slot
, Item
*pItem
);
1143 void SetVisibleItemSlot(uint8 slot
, Item
*pItem
);
1144 Item
* BankItem( ItemPosCountVec
const& dest
, Item
*pItem
, bool update
)
1146 return StoreItem( dest
, pItem
, update
);
1148 Item
* BankItem( uint16 pos
, Item
*pItem
, bool update
);
1149 void RemoveItem( uint8 bag
, uint8 slot
, bool update
);
1150 void MoveItemFromInventory(uint8 bag
, uint8 slot
, bool update
);
1151 // in trade, auction, guild bank, mail....
1152 void MoveItemToInventory(ItemPosCountVec
const& dest
, Item
* pItem
, bool update
, bool in_characterInventoryDB
= false);
1153 // in trade, guild bank, mail....
1154 void RemoveItemDependentAurasAndCasts( Item
* pItem
);
1155 void DestroyItem( uint8 bag
, uint8 slot
, bool update
);
1156 void DestroyItemCount( uint32 item
, uint32 count
, bool update
, bool unequip_check
= false);
1157 void DestroyItemCount( Item
* item
, uint32
& count
, bool update
);
1158 void DestroyConjuredItems( bool update
);
1159 void DestroyZoneLimitedItem( bool update
, uint32 new_zone
);
1160 void SplitItem( uint16 src
, uint16 dst
, uint32 count
);
1161 void SwapItem( uint16 src
, uint16 dst
);
1162 void AddItemToBuyBackSlot( Item
*pItem
);
1163 Item
* GetItemFromBuyBackSlot( uint32 slot
);
1164 void RemoveItemFromBuyBackSlot( uint32 slot
, bool del
);
1165 uint32
GetMaxKeyringSize() const { return KEYRING_SLOT_END
-KEYRING_SLOT_START
; }
1166 void SendEquipError( uint8 msg
, Item
* pItem
, Item
*pItem2
);
1167 void SendBuyError( uint8 msg
, Creature
* pCreature
, uint32 item
, uint32 param
);
1168 void SendSellError( uint8 msg
, Creature
* pCreature
, uint64 guid
, uint32 param
);
1169 void AddWeaponProficiency(uint32 newflag
) { m_WeaponProficiency
|= newflag
; }
1170 void AddArmorProficiency(uint32 newflag
) { m_ArmorProficiency
|= newflag
; }
1171 uint32
GetWeaponProficiency() const { return m_WeaponProficiency
; }
1172 uint32
GetArmorProficiency() const { return m_ArmorProficiency
; }
1173 bool IsInFeralForm() const { return m_form
== FORM_CAT
|| m_form
== FORM_BEAR
|| m_form
== FORM_DIREBEAR
; }
1174 bool IsUseEquipedWeapon( bool mainhand
) const
1176 // disarm applied only to mainhand weapon
1177 return !IsInFeralForm() && (!mainhand
|| !HasFlag(UNIT_FIELD_FLAGS
,UNIT_FLAG_DISARMED
) );
1179 void SendNewItem( Item
*item
, uint32 count
, bool received
, bool created
, bool broadcast
= false );
1180 bool BuyItemFromVendor(uint64 vendorguid
, uint32 item
, uint8 count
, uint64 bagguid
, uint8 slot
);
1182 float GetReputationPriceDiscount( Creature
const* pCreature
) const;
1183 Player
* GetTrader() const { return pTrader
; }
1185 void TradeCancel(bool sendback
);
1186 uint16
GetItemPosByTradeSlot(uint32 slot
) const { return tradeItems
[slot
]; }
1188 void UpdateEnchantTime(uint32 time
);
1189 void UpdateItemDuration(uint32 time
, bool realtimeonly
=false);
1190 void AddEnchantmentDurations(Item
*item
);
1191 void RemoveEnchantmentDurations(Item
*item
);
1192 void RemoveAllEnchantments(EnchantmentSlot slot
);
1193 void AddEnchantmentDuration(Item
*item
,EnchantmentSlot slot
,uint32 duration
);
1194 void ApplyEnchantment(Item
*item
,EnchantmentSlot slot
,bool apply
, bool apply_dur
= true, bool ignore_condition
= false);
1195 void ApplyEnchantment(Item
*item
,bool apply
);
1196 void SendEnchantmentDurations();
1197 void AddItemDurations(Item
*item
);
1198 void RemoveItemDurations(Item
*item
);
1199 void SendItemDurations();
1203 uint32 m_stableSlots
;
1205 /*********************************************************/
1206 /*** QUEST SYSTEM ***/
1207 /*********************************************************/
1209 void PrepareQuestMenu( uint64 guid
);
1210 void SendPreparedQuest( uint64 guid
);
1211 bool IsActiveQuest( uint32 quest_id
) const;
1212 Quest
const *GetNextQuest( uint64 guid
, Quest
const *pQuest
);
1213 bool CanSeeStartQuest( Quest
const *pQuest
);
1214 bool CanTakeQuest( Quest
const *pQuest
, bool msg
);
1215 bool CanAddQuest( Quest
const *pQuest
, bool msg
);
1216 bool CanCompleteQuest( uint32 quest_id
);
1217 bool CanCompleteRepeatableQuest(Quest
const *pQuest
);
1218 bool CanRewardQuest( Quest
const *pQuest
, bool msg
);
1219 bool CanRewardQuest( Quest
const *pQuest
, uint32 reward
, bool msg
);
1220 void AddQuest( Quest
const *pQuest
, Object
*questGiver
);
1221 void CompleteQuest( uint32 quest_id
);
1222 void IncompleteQuest( uint32 quest_id
);
1223 void RewardQuest( Quest
const *pQuest
, uint32 reward
, Object
* questGiver
, bool announce
= true );
1224 void FailQuest( uint32 quest_id
);
1225 void FailTimedQuest( uint32 quest_id
);
1226 bool SatisfyQuestSkillOrClass( Quest
const* qInfo
, bool msg
);
1227 bool SatisfyQuestLevel( Quest
const* qInfo
, bool msg
);
1228 bool SatisfyQuestLog( bool msg
);
1229 bool SatisfyQuestPreviousQuest( Quest
const* qInfo
, bool msg
);
1230 bool SatisfyQuestRace( Quest
const* qInfo
, bool msg
);
1231 bool SatisfyQuestReputation( Quest
const* qInfo
, bool msg
);
1232 bool SatisfyQuestStatus( Quest
const* qInfo
, bool msg
);
1233 bool SatisfyQuestTimed( Quest
const* qInfo
, bool msg
);
1234 bool SatisfyQuestExclusiveGroup( Quest
const* qInfo
, bool msg
);
1235 bool SatisfyQuestNextChain( Quest
const* qInfo
, bool msg
);
1236 bool SatisfyQuestPrevChain( Quest
const* qInfo
, bool msg
);
1237 bool SatisfyQuestDay( Quest
const* qInfo
, bool msg
);
1238 bool GiveQuestSourceItem( Quest
const *pQuest
);
1239 bool TakeQuestSourceItem( uint32 quest_id
, bool msg
);
1240 bool GetQuestRewardStatus( uint32 quest_id
) const;
1241 QuestStatus
GetQuestStatus( uint32 quest_id
) const;
1242 void SetQuestStatus( uint32 quest_id
, QuestStatus status
);
1244 void SetDailyQuestStatus( uint32 quest_id
);
1245 void ResetDailyQuestStatus();
1247 uint16
FindQuestSlot( uint32 quest_id
) const;
1248 uint32
GetQuestSlotQuestId(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
); }
1249 uint32
GetQuestSlotState(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
); }
1250 uint32
GetQuestSlotCounters(uint16 slot
)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
); }
1251 uint8
GetQuestSlotCounter(uint16 slot
,uint8 counter
) const { return GetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
); }
1252 uint32
GetQuestSlotTime(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
); }
1253 void SetQuestSlot(uint16 slot
,uint32 quest_id
, uint32 timer
= 0)
1255 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
,quest_id
);
1256 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,0);
1257 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,0);
1258 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
);
1260 void SetQuestSlotCounter(uint16 slot
,uint8 counter
,uint8 count
) { SetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
,count
); }
1261 void SetQuestSlotState(uint16 slot
,uint32 state
) { SetFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1262 void RemoveQuestSlotState(uint16 slot
,uint32 state
) { RemoveFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1263 void SetQuestSlotTimer(uint16 slot
,uint32 timer
) { SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
); }
1264 void SwapQuestSlot(uint16 slot1
,uint16 slot2
)
1266 for (int i
= 0; i
< MAX_QUEST_OFFSET
; ++i
)
1268 uint32 temp1
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
);
1269 uint32 temp2
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
);
1271 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
, temp2
);
1272 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
, temp1
);
1275 uint32
GetReqKillOrCastCurrentCount(uint32 quest_id
, int32 entry
);
1276 void AdjustQuestReqItemCount( Quest
const* pQuest
);
1277 void AreaExploredOrEventHappens( uint32 questId
);
1278 void GroupEventHappens( uint32 questId
, WorldObject
const* pEventObject
);
1279 void ItemAddedQuestCheck( uint32 entry
, uint32 count
);
1280 void ItemRemovedQuestCheck( uint32 entry
, uint32 count
);
1281 void KilledMonster( uint32 entry
, uint64 guid
);
1282 void CastedCreatureOrGO( uint32 entry
, uint64 guid
, uint32 spell_id
);
1283 void TalkedToCreature( uint32 entry
, uint64 guid
);
1284 void MoneyChanged( uint32 value
);
1285 bool HasQuestForItem( uint32 itemid
) const;
1286 bool HasQuestForGO(int32 GOId
);
1287 void UpdateForQuestsGO();
1288 bool CanShareQuest(uint32 quest_id
) const;
1290 void SendQuestComplete( uint32 quest_id
);
1291 void SendQuestReward( Quest
const *pQuest
, uint32 XP
, Object
* questGiver
);
1292 void SendQuestFailed( uint32 quest_id
);
1293 void SendQuestTimerFailed( uint32 quest_id
);
1294 void SendCanTakeQuestResponse( uint32 msg
);
1295 void SendPushToPartyResponse( Player
*pPlayer
, uint32 msg
);
1296 void SendQuestUpdateAddItem( Quest
const* pQuest
, uint32 item_idx
, uint32 count
);
1297 void SendQuestUpdateAddCreatureOrGo( Quest
const* pQuest
, uint64 guid
, uint32 creatureOrGO_idx
, uint32 old_count
, uint32 add_count
);
1299 uint64
GetDivider() { return m_divider
; };
1300 void SetDivider( uint64 guid
) { m_divider
= guid
; };
1302 uint32
GetInGameTime() { return m_ingametime
; };
1304 void SetInGameTime( uint32 time
) { m_ingametime
= time
; };
1306 void AddTimedQuest( uint32 quest_id
) { m_timedquests
.insert(quest_id
); }
1308 /*********************************************************/
1309 /*** LOAD SYSTEM ***/
1310 /*********************************************************/
1312 bool LoadFromDB(uint32 guid
, SqlQueryHolder
*holder
);
1313 bool MinimalLoadFromDB(QueryResult
*result
, uint32 guid
);
1314 static bool LoadValuesArrayFromDB(Tokens
& data
,uint64 guid
);
1315 static uint32
GetUInt32ValueFromArray(Tokens
const& data
, uint16 index
);
1316 static float GetFloatValueFromArray(Tokens
const& data
, uint16 index
);
1317 static uint32
GetUInt32ValueFromDB(uint16 index
, uint64 guid
);
1318 static float GetFloatValueFromDB(uint16 index
, uint64 guid
);
1319 static uint32
GetZoneIdFromDB(uint64 guid
);
1320 static bool LoadPositionFromDB(uint32
& mapid
, float& x
,float& y
,float& z
,float& o
, bool& in_flight
, uint64 guid
);
1322 /*********************************************************/
1323 /*** SAVE SYSTEM ***/
1324 /*********************************************************/
1327 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1328 void SaveDataFieldToDB();
1329 static bool SaveValuesArrayInDB(Tokens
const& data
,uint64 guid
);
1330 static void SetUInt32ValueInArray(Tokens
& data
,uint16 index
, uint32 value
);
1331 static void SetFloatValueInArray(Tokens
& data
,uint16 index
, float value
);
1332 static void SetUInt32ValueInDB(uint16 index
, uint32 value
, uint64 guid
);
1333 static void SetFloatValueInDB(uint16 index
, float value
, uint64 guid
);
1334 static void SavePositionInDB(uint32 mapid
, float x
,float y
,float z
,float o
,uint32 zone
,uint64 guid
);
1337 bool m_mailsUpdated
;
1339 void SetBindPoint(uint64 guid
);
1340 void SendTalentWipeConfirm(uint64 guid
);
1341 void RewardRage( uint32 damage
, uint32 weaponSpeedHitFactor
, bool attacker
);
1342 void SendPetSkillWipeConfirm();
1343 void CalcRage( uint32 damage
,bool attacker
);
1344 void RegenerateAll();
1345 void Regenerate(Powers power
);
1346 void RegenerateHealth();
1347 void setRegenTimer(uint32 time
) {m_regenTimer
= time
;}
1348 void setWeaponChangeTimer(uint32 time
) {m_weaponChangeTimer
= time
;}
1350 uint32
GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE
); }
1351 void ModifyMoney( int32 d
)
1354 SetMoney (GetMoney() > uint32(-d
) ? GetMoney() + d
: 0);
1356 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT
- d
) ? GetMoney() + d
: MAX_MONEY_AMOUNT
);
1359 if(GetMoney() >= MAX_MONEY_AMOUNT
)
1360 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD
,NULL
,NULL
);
1362 void SetMoney( uint32 value
)
1364 SetUInt32Value (PLAYER_FIELD_COINAGE
, value
);
1365 MoneyChanged( value
);
1368 uint32
GetTutorialInt(uint32 intId
)
1370 ASSERT( (intId
< 8) );
1371 return m_Tutorials
[intId
];
1374 void SetTutorialInt(uint32 intId
, uint32 value
)
1376 ASSERT( (intId
< 8) );
1377 if(m_Tutorials
[intId
]!=value
)
1379 m_Tutorials
[intId
] = value
;
1380 m_TutorialsChanged
= true;
1384 QuestStatusMap
& getQuestStatusMap() { return mQuestStatus
; };
1386 const uint64
& GetSelection( ) const { return m_curSelection
; }
1387 void SetSelection(const uint64
&guid
) { m_curSelection
= guid
; SetUInt64Value(UNIT_FIELD_TARGET
, guid
); }
1389 uint8
GetComboPoints() { return m_comboPoints
; }
1390 uint64
GetComboTarget() { return m_comboTarget
; }
1392 void AddComboPoints(Unit
* target
, int8 count
);
1393 void ClearComboPoints();
1394 void SendComboPoints();
1396 void SendMailResult(uint32 mailId
, uint32 mailAction
, uint32 mailError
, uint32 equipError
= 0, uint32 item_guid
= 0, uint32 item_count
= 0);
1398 void UpdateNextMailTimeAndUnreads();
1399 void AddNewMailDeliverTime(time_t deliver_time
);
1400 bool IsMailsLoaded() const { return m_mailsLoaded
; }
1402 //void SetMail(Mail *m);
1403 void RemoveMail(uint32 id
);
1405 void AddMail(Mail
* mail
) { m_mail
.push_front(mail
);}// for call from WorldSession::SendMailTo
1406 uint32
GetMailSize() { return m_mail
.size();};
1407 Mail
* GetMail(uint32 id
);
1409 PlayerMails::iterator
GetmailBegin() { return m_mail
.begin();};
1410 PlayerMails::iterator
GetmailEnd() { return m_mail
.end();};
1412 /*********************************************************/
1413 /*** MAILED ITEMS SYSTEM ***/
1414 /*********************************************************/
1417 time_t m_nextMailDelivereTime
;
1419 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
1421 ItemMap mMitems
; //template defined in objectmgr.cpp
1423 Item
* GetMItem(uint32 id
)
1425 ItemMap::const_iterator itr
= mMitems
.find(id
);
1426 if (itr
!= mMitems
.end())
1432 void AddMItem(Item
* it
)
1435 //assert deleted, because items can be added before loading
1436 mMitems
[it
->GetGUIDLow()] = it
;
1439 bool RemoveMItem(uint32 id
)
1441 ItemMap::iterator i
= mMitems
.find(id
);
1442 if (i
== mMitems
.end())
1449 void PetSpellInitialize();
1450 void CharmSpellInitialize();
1451 void PossessSpellInitialize();
1452 bool HasSpell(uint32 spell
) const;
1453 TrainerSpellState
GetTrainerSpellState(TrainerSpell
const* trainer_spell
) const;
1454 bool IsSpellFitByClassAndRace( uint32 spell_id
) const;
1456 void SendProficiency(uint8 pr1
, uint32 pr2
);
1457 void SendInitialSpells();
1458 bool addSpell(uint32 spell_id
, bool active
, bool learning
= true, bool loading
= false, uint16 slot_id
=SPELL_WITHOUT_SLOT_ID
, bool disabled
= false);
1459 void learnSpell(uint32 spell_id
);
1460 void removeSpell(uint32 spell_id
, bool disabled
= false);
1462 void learnDefaultSpells(bool loading
= false);
1463 void learnQuestRewardedSpells();
1464 void learnQuestRewardedSpells(Quest
const* quest
);
1466 uint32
GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1
); }
1467 void SetFreeTalentPoints(uint32 points
) { SetUInt32Value(PLAYER_CHARACTER_POINTS1
,points
); }
1468 bool resetTalents(bool no_cost
= false);
1469 uint32
resetTalentsCost() const;
1470 void InitTalentForLevel();
1472 void InitGlyphsForLevel();
1473 void SetGlyphSlot(uint8 slot
, uint32 slottype
) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
, slottype
); }
1474 uint32
GetGlyphSlot(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
); }
1475 void SetGlyph(uint8 slot
, uint32 glyph
) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
, glyph
); }
1476 uint32
GetGlyph(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
); }
1478 uint32
GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2
); }
1479 void SetFreePrimaryProffesions(uint16 profs
) { SetUInt32Value(PLAYER_CHARACTER_POINTS2
,profs
); }
1480 void InitPrimaryProffesions();
1482 PlayerSpellMap
const& GetSpellMap() const { return m_spells
; }
1483 PlayerSpellMap
& GetSpellMap() { return m_spells
; }
1485 void AddSpellMod(SpellModifier
* mod
, bool apply
);
1486 int32
GetTotalFlatMods(uint32 spellId
, SpellModOp op
);
1487 int32
GetTotalPctMods(uint32 spellId
, SpellModOp op
);
1488 bool IsAffectedBySpellmod(SpellEntry
const *spellInfo
, SpellModifier
*mod
, Spell
const* spell
= NULL
);
1489 template <class T
> T
ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
= NULL
);
1490 void RemoveSpellMods(Spell
const* spell
);
1492 bool HasSpellCooldown(uint32 spell_id
) const
1494 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1495 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> time(NULL
);
1497 uint32
GetSpellCooldownDelay(uint32 spell_id
) const
1499 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1500 time_t t
= time(NULL
);
1501 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> t
? itr
->second
.end
- t
: 0;
1503 void AddSpellCooldown(uint32 spell_id
, uint32 itemid
, time_t end_time
);
1504 void SendCooldownEvent(SpellEntry
const *spellInfo
);
1505 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask
, uint32 unTimeMs
);
1506 void RemoveSpellCooldown(uint32 spell_id
) { m_spellCooldowns
.erase(spell_id
); }
1507 void RemoveArenaSpellCooldowns();
1508 void RemoveAllSpellCooldown();
1509 void _LoadSpellCooldowns(QueryResult
*result
);
1510 void _SaveSpellCooldowns();
1512 void setResurrectRequestData(uint64 guid
, uint32 mapId
, float X
, float Y
, float Z
, uint32 health
, uint32 mana
)
1514 m_resurrectGUID
= guid
;
1515 m_resurrectMap
= mapId
;
1519 m_resurrectHealth
= health
;
1520 m_resurrectMana
= mana
;
1522 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f
,0.0f
,0.0f
,0,0); }
1523 bool isRessurectRequestedBy(uint64 guid
) const { return m_resurrectGUID
== guid
; }
1524 bool isRessurectRequested() const { return m_resurrectGUID
!= 0; }
1525 void ResurectUsingRequestData();
1531 void setCinematic(int cine
)
1536 void addActionButton(uint8 button
, uint16 action
, uint8 type
, uint8 misc
);
1537 void removeActionButton(uint8 button
);
1538 void SendInitialActionButtons();
1541 void UpdatePvP(bool state
, bool ovrride
=false);
1542 void UpdateZone(uint32 newZone
);
1543 void UpdateArea(uint32 newArea
);
1545 void UpdateZoneDependentAuras( uint32 zone_id
); // zones
1546 void UpdateAreaDependentAuras( uint32 area_id
); // subzones
1548 void UpdateAfkReport(time_t currTime
);
1549 void UpdatePvPFlag(time_t currTime
);
1550 void UpdateContestedPvP(uint32 currTime
);
1551 void SetContestedPvPTimer(uint32 newTime
) {m_contestedPvPTimer
= newTime
;}
1552 void ResetContestedPvP()
1554 clearUnitState(UNIT_STAT_ATTACK_PLAYER
);
1555 RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_CONTESTED_PVP
);
1556 m_contestedPvPTimer
= 0;
1559 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1561 void UpdateDuelFlag(time_t currTime
);
1562 void CheckDuelDistance(time_t currTime
);
1563 void DuelComplete(DuelCompleteType type
);
1565 bool IsGroupVisibleFor(Player
* p
) const;
1566 bool IsInSameGroupWith(Player
const* p
) const;
1567 bool IsInSameRaidWith(Player
const* p
) const { return p
==this || (GetGroup() != NULL
&& GetGroup() == p
->GetGroup()); }
1568 void UninviteFromGroup();
1569 static void RemoveFromGroup(Group
* group
, uint64 guid
);
1570 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1571 void SendUpdateToOutOfRangeGroupMembers();
1573 void SetInGuild(uint32 GuildId
) { SetUInt32Value(PLAYER_GUILDID
, GuildId
); }
1574 void SetRank(uint32 rankId
){ SetUInt32Value(PLAYER_GUILDRANK
, rankId
); }
1575 void SetGuildIdInvited(uint32 GuildId
) { m_GuildIdInvited
= GuildId
; }
1576 uint32
GetGuildId() { return GetUInt32Value(PLAYER_GUILDID
); }
1577 static uint32
GetGuildIdFromDB(uint64 guid
);
1578 uint32
GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK
); }
1579 static uint32
GetRankFromDB(uint64 guid
);
1580 int GetGuildIdInvited() { return m_GuildIdInvited
; }
1581 static void RemovePetitionsAndSigns(uint64 guid
, uint32 type
);
1584 void SetInArenaTeam(uint32 ArenaTeamId
, uint8 slot
)
1586 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6), ArenaTeamId
);
1587 SaveDataFieldToDB(); // needed?
1589 uint32
GetArenaTeamId(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6)); }
1590 static uint32
GetArenaTeamIdFromDB(uint64 guid
, uint8 slot
);
1591 void SetArenaTeamIdInvited(uint32 ArenaTeamId
) { m_ArenaTeamIdInvited
= ArenaTeamId
; }
1592 uint32
GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited
; }
1594 void SetDifficulty(uint32 dungeon_difficulty
) { m_dungeonDifficulty
= dungeon_difficulty
; }
1595 uint8
GetDifficulty() { return m_dungeonDifficulty
; }
1597 bool UpdateSkill(uint32 skill_id
, uint32 step
);
1598 bool UpdateSkillPro(uint16 SkillId
, int32 Chance
, uint32 step
);
1600 bool UpdateCraftSkill(uint32 spellid
);
1601 bool UpdateGatherSkill(uint32 SkillId
, uint32 SkillValue
, uint32 RedLevel
, uint32 Multiplicator
= 1);
1602 bool UpdateFishingSkill();
1604 uint32
GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE
); }
1605 uint32
GetBaseWeaponSkillValue(WeaponAttackType attType
) const;
1607 uint32
GetSpellByProto(ItemPrototype
*proto
);
1609 float GetHealthBonusFromStamina();
1610 float GetManaBonusFromIntellect();
1612 bool UpdateStats(Stats stat
);
1613 bool UpdateAllStats();
1614 void UpdateResistances(uint32 school
);
1616 void UpdateMaxHealth();
1617 void UpdateMaxPower(Powers power
);
1618 void UpdateAttackPowerAndDamage(bool ranged
= false);
1619 void UpdateShieldBlockValue();
1620 void UpdateDamagePhysical(WeaponAttackType attType
);
1621 void UpdateSpellDamageAndHealingBonus();
1623 void CalculateMinMaxDamage(WeaponAttackType attType
, bool normalized
, float& min_damage
, float& max_damage
);
1625 void UpdateDefenseBonusesMod();
1626 void ApplyRatingMod(CombatRating cr
, int32 value
, bool apply
);
1627 float GetMeleeCritFromAgility();
1628 float GetDodgeFromAgility();
1629 float GetSpellCritFromIntellect();
1630 float OCTRegenHPPerSpirit();
1631 float OCTRegenMPPerSpirit();
1632 float GetRatingCoefficient(CombatRating cr
) const;
1633 float GetRatingBonusValue(CombatRating cr
) const;
1634 uint32
GetMeleeCritDamageReduction(uint32 damage
) const;
1635 uint32
GetRangedCritDamageReduction(uint32 damage
) const;
1636 uint32
GetSpellCritDamageReduction(uint32 damage
) const;
1637 uint32
GetDotDamageReduction(uint32 damage
) const;
1639 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType
) const;
1640 void UpdateBlockPercentage();
1641 void UpdateCritPercentage(WeaponAttackType attType
);
1642 void UpdateAllCritPercentages();
1643 void UpdateParryPercentage();
1644 void UpdateDodgePercentage();
1645 void UpdateAllSpellCritChances();
1646 void UpdateSpellCritChance(uint32 school
);
1647 void UpdateExpertise(WeaponAttackType attType
);
1648 void UpdateManaRegen();
1650 const uint64
& GetLootGUID() const { return m_lootGuid
; }
1651 void SetLootGUID(const uint64
&guid
) { m_lootGuid
= guid
; }
1653 void RemovedInsignia(Player
* looterPlr
);
1655 WorldSession
* GetSession() const { return m_session
; }
1656 void SetSession(WorldSession
*s
) { m_session
= s
; }
1658 void BuildCreateUpdateBlockForPlayer( UpdateData
*data
, Player
*target
) const;
1659 void DestroyForPlayer( Player
*target
) const;
1660 void SendDelayResponse(const uint32
);
1661 void SendLogXPGain(uint32 GivenXP
,Unit
* victim
,uint32 RestXP
);
1664 void PlaySound(uint32 Sound
, bool OnlySelf
);
1666 void SendAttackSwingCantAttack();
1667 void SendAttackSwingCancelAttack();
1668 void SendAttackSwingDeadTarget();
1669 void SendAttackSwingNotStanding();
1670 void SendAttackSwingNotInRange();
1671 void SendAttackSwingBadFacingAttack();
1672 void SendAutoRepeatCancel();
1673 void SendExplorationExperience(uint32 Area
, uint32 Experience
);
1675 void SendDungeonDifficulty(bool IsInGroup
);
1676 void ResetInstances(uint8 method
);
1677 void SendResetInstanceSuccess(uint32 MapId
);
1678 void SendResetInstanceFailed(uint32 reason
, uint32 MapId
);
1679 void SendResetFailedNotify(uint32 mapid
);
1681 bool SetPosition(float x
, float y
, float z
, float orientation
, bool teleport
= false);
1682 void UpdateUnderwaterState( Map
* m
, float x
, float y
, float z
);
1684 void SendMessageToSet(WorldPacket
*data
, bool self
);// overwrite Object::SendMessageToSet
1685 void SendMessageToSetInRange(WorldPacket
*data
, float fist
, bool self
);
1686 // overwrite Object::SendMessageToSetInRange
1687 void SendMessageToSetInRange(WorldPacket
*data
, float dist
, bool self
, bool own_team_only
);
1689 static void DeleteFromDB(uint64 playerguid
, uint32 accountId
, bool updateRealmChars
= true);
1691 Corpse
*GetCorpse() const;
1692 void SpawnCorpseBones();
1693 void CreateCorpse();
1695 uint32
GetResurrectionSpellId();
1696 void ResurrectPlayer(float restore_percent
, bool applySickness
= false);
1697 void BuildPlayerRepop();
1698 void RepopAtGraveyard();
1700 void DurabilityLossAll(double percent
, bool inventory
);
1701 void DurabilityLoss(Item
* item
, double percent
);
1702 void DurabilityPointsLossAll(int32 points
, bool inventory
);
1703 void DurabilityPointsLoss(Item
* item
, int32 points
);
1704 void DurabilityPointLossForEquipSlot(EquipmentSlots slot
);
1705 uint32
DurabilityRepairAll(bool cost
, float discountMod
, bool guildBank
);
1706 uint32
DurabilityRepair(uint16 pos
, bool cost
, float discountMod
, bool guildBank
);
1708 void StopMirrorTimers()
1710 StopMirrorTimer(FATIGUE_TIMER
);
1711 StopMirrorTimer(BREATH_TIMER
);
1712 StopMirrorTimer(FIRE_TIMER
);
1715 void SetMovement(PlayerMovementType pType
);
1717 void JoinedChannel(Channel
*c
);
1718 void LeftChannel(Channel
*c
);
1719 void CleanupChannels();
1720 void UpdateLocalChannels( uint32 newZone
);
1721 void LeaveLFGChannel();
1723 void UpdateDefense();
1724 void UpdateWeaponSkill (WeaponAttackType attType
);
1725 void UpdateCombatSkills(Unit
*pVictim
, WeaponAttackType attType
, MeleeHitOutcome outcome
, bool defence
);
1727 void SetSkill(uint32 id
, uint16 currVal
, uint16 maxVal
);
1728 uint16
GetMaxSkillValue(uint32 skill
) const; // max + perm. bonus
1729 uint16
GetPureMaxSkillValue(uint32 skill
) const; // max
1730 uint16
GetSkillValue(uint32 skill
) const; // skill value + perm. bonus + temp bonus
1731 uint16
GetBaseSkillValue(uint32 skill
) const; // skill value + perm. bonus
1732 uint16
GetPureSkillValue(uint32 skill
) const; // skill value
1733 int16
GetSkillTempBonusValue(uint32 skill
) const;
1734 bool HasSkill(uint32 skill
) const;
1735 void learnSkillRewardedSpells( uint32 id
);
1736 void learnSkillRewardedSpells();
1738 void SetDontMove(bool dontMove
);
1739 bool GetDontMove() const { return m_dontMove
; }
1741 void CheckExploreSystem(void);
1743 static uint32
TeamForRace(uint8 race
);
1744 uint32
GetTeam() const { return m_team
; }
1745 static uint32
getFactionForRace(uint8 race
);
1746 void setFactionForRace(uint8 race
);
1748 bool IsAtGroupRewardDistance(WorldObject
const* pRewardSource
) const;
1749 bool RewardPlayerAndGroupAtKill(Unit
* pVictim
);
1751 FactionStateList m_factions
;
1752 ForcedReactions m_forcedReactions
;
1753 FactionStateList
const& GetFactionStateList() { return m_factions
; }
1754 uint32
GetDefaultReputationFlags(const FactionEntry
*factionEntry
) const;
1755 int32
GetBaseReputation(const FactionEntry
*factionEntry
) const;
1756 int32
GetReputation(uint32 faction_id
) const;
1757 int32
GetReputation(const FactionEntry
*factionEntry
) const;
1758 ReputationRank
GetReputationRank(uint32 faction
) const;
1759 ReputationRank
GetReputationRank(const FactionEntry
*factionEntry
) const;
1760 ReputationRank
GetBaseReputationRank(const FactionEntry
*factionEntry
) const;
1761 ReputationRank
ReputationToRank(int32 standing
) const;
1762 const static int32 ReputationRank_Length
[MAX_REPUTATION_RANK
];
1763 const static int32 Reputation_Cap
= 42999;
1764 const static int32 Reputation_Bottom
= -42000;
1765 bool ModifyFactionReputation(uint32 FactionTemplateId
, int32 DeltaReputation
);
1766 bool ModifyFactionReputation(FactionEntry
const* factionEntry
, int32 standing
);
1767 bool ModifyOneFactionReputation(FactionEntry
const* factionEntry
, int32 standing
);
1768 bool SetFactionReputation(uint32 FactionTemplateId
, int32 standing
);
1769 bool SetFactionReputation(FactionEntry
const* factionEntry
, int32 standing
);
1770 bool SetOneFactionReputation(FactionEntry
const* factionEntry
, int32 standing
);
1771 int32
CalculateReputationGain(uint32 creatureOrQuestLevel
, int32 rep
, bool for_quest
);
1772 void RewardReputation(Unit
*pVictim
, float rate
);
1773 void RewardReputation(Quest
const *pQuest
);
1774 void SetInitialFactions();
1775 void UpdateReputation() const;
1776 void SendFactionState(FactionState
const* faction
) const;
1777 void SendInitialReputations();
1778 FactionState
const* GetFactionState( FactionEntry
const* factionEntry
) const;
1779 void SetFactionAtWar(FactionState
* faction
, bool atWar
);
1780 void SetFactionInactive(FactionState
* faction
, bool inactive
);
1781 void SetFactionVisible(FactionState
* faction
);
1782 void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId
);
1783 void SetFactionVisibleForFactionId(uint32 FactionId
);
1784 void UpdateSkillsForLevel();
1785 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1786 void ModifySkillBonus(uint32 skillid
,int32 val
, bool talent
);
1788 /*********************************************************/
1789 /*** PVP SYSTEM ***/
1790 /*********************************************************/
1791 void UpdateArenaFields();
1792 void UpdateHonorFields();
1793 bool RewardHonor(Unit
*pVictim
, uint32 groupsize
, float honor
= -1);
1794 uint32
GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
); }
1795 uint32
GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY
); }
1796 void ModifyHonorPoints( int32 value
);
1797 void ModifyArenaPoints( int32 value
);
1798 uint32
GetMaxPersonalArenaRatingRequirement();
1802 void SetDrunkValue(uint16 newDrunkValue
, uint32 itemid
=0);
1803 uint16
GetDrunkValue() const { return m_drunk
; }
1804 static DrunkenState
GetDrunkenstateByValue(uint16 value
);
1806 uint32
GetDeathTimer() const { return m_deathTimer
; }
1807 uint32
GetCorpseReclaimDelay(bool pvp
) const;
1808 void UpdateCorpseReclaimDelay();
1809 void SendCorpseReclaimDelay(bool load
= false);
1811 uint32
GetShieldBlockValue() const; // overwrite Unit version (virtual)
1812 bool CanParry() const { return m_canParry
; }
1813 void SetCanParry(bool value
);
1814 bool CanBlock() const { return m_canBlock
; }
1815 void SetCanBlock(bool value
);
1816 bool CanDualWield() const { return m_canDualWield
; }
1817 void SetCanDualWield(bool value
) { m_canDualWield
= value
; }
1819 void SetRegularAttackTime();
1820 void SetBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float value
) { m_auraBaseMod
[modGroup
][modType
] = value
; }
1821 void HandleBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float amount
, bool apply
);
1822 float GetBaseModValue(BaseModGroup modGroup
, BaseModType modType
) const;
1823 float GetTotalBaseModValue(BaseModGroup modGroup
) const;
1824 float GetTotalPercentageModValue(BaseModGroup modGroup
) const { return m_auraBaseMod
[modGroup
][FLAT_MOD
] + m_auraBaseMod
[modGroup
][PCT_MOD
]; }
1825 void _ApplyAllStatBonuses();
1826 void _RemoveAllStatBonuses();
1828 void _ApplyWeaponDependentAuraMods(Item
*item
, WeaponAttackType attackType
, bool apply
);
1829 void _ApplyWeaponDependentAuraCritMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1830 void _ApplyWeaponDependentAuraDamageMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1832 void _ApplyItemMods(Item
*item
,uint8 slot
,bool apply
);
1833 void _RemoveAllItemMods();
1834 void _ApplyAllItemMods();
1835 void _ApplyItemBonuses(ItemPrototype
const *proto
,uint8 slot
,bool apply
);
1836 void _ApplyAmmoBonuses();
1837 bool EnchantmentFitsRequirements(uint32 enchantmentcondition
, int8 slot
);
1838 void ToggleMetaGemsActive(uint8 exceptslot
, bool apply
);
1839 void CorrectMetaGemEnchants(uint8 slot
, bool apply
);
1840 void InitDataForForm(bool reapplyMods
= false);
1842 void ApplyItemEquipSpell(Item
*item
, bool apply
, bool form_change
= false);
1843 void ApplyEquipSpell(SpellEntry
const* spellInfo
, Item
* item
, bool apply
, bool form_change
= false);
1844 void UpdateEquipSpellsAtFormChange();
1845 void CastItemCombatSpell(Item
*item
,Unit
* Target
, WeaponAttackType attType
);
1847 void SendInitWorldStates();
1848 void SendUpdateWorldState(uint32 Field
, uint32 Value
);
1849 void SendDirectMessage(WorldPacket
*data
);
1851 void SendAurasForTarget(Unit
*target
);
1853 PlayerMenu
* PlayerTalkClass
;
1854 std::vector
<ItemSetEffect
*> ItemSetEff
;
1856 void SendLoot(uint64 guid
, LootType loot_type
);
1857 void SendLootRelease( uint64 guid
);
1858 void SendNotifyLootItemRemoved(uint8 lootSlot
);
1859 void SendNotifyLootMoneyRemoved();
1861 /*********************************************************/
1862 /*** BATTLEGROUND SYSTEM ***/
1863 /*********************************************************/
1865 bool InBattleGround() const { return m_bgBattleGroundID
!= 0; }
1866 uint32
GetBattleGroundId() const { return m_bgBattleGroundID
; }
1867 BattleGround
* GetBattleGround() const;
1868 bool InArena() const;
1870 static uint32
GetMinLevelForBattleGroundQueueId(uint32 queue_id
);
1871 static uint32
GetMaxLevelForBattleGroundQueueId(uint32 queue_id
);
1872 uint32
GetBattleGroundQueueIdFromLevel() const;
1874 uint32
GetBattleGroundQueueId(uint32 index
) const { return m_bgBattleGroundQueueID
[index
].bgType
; }
1875 uint32
GetBattleGroundQueueIndex(uint32 bgType
) const
1877 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1878 if (m_bgBattleGroundQueueID
[i
].bgType
== bgType
)
1880 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1882 bool IsInvitedForBattleGroundType(uint32 bgType
) const
1884 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1885 if (m_bgBattleGroundQueueID
[i
].bgType
== bgType
)
1886 return m_bgBattleGroundQueueID
[i
].invited
;
1887 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1889 bool InBattleGroundQueueForBattleGroundType(uint32 bgType
) const
1891 return GetBattleGroundQueueIndex(bgType
) < PLAYER_MAX_BATTLEGROUND_QUEUES
;
1894 void SetBattleGroundId(uint32 val
) { m_bgBattleGroundID
= val
; }
1895 uint32
AddBattleGroundQueueId(uint32 val
)
1897 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1899 if (m_bgBattleGroundQueueID
[i
].bgType
== 0 || m_bgBattleGroundQueueID
[i
].bgType
== val
)
1901 m_bgBattleGroundQueueID
[i
].bgType
= val
;
1902 m_bgBattleGroundQueueID
[i
].invited
= false;
1906 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1908 void RemoveBattleGroundQueueId(uint32 val
)
1910 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1912 if (m_bgBattleGroundQueueID
[i
].bgType
== val
)
1914 m_bgBattleGroundQueueID
[i
].bgType
= 0;
1915 m_bgBattleGroundQueueID
[i
].invited
= false;
1920 void SetInviteForBattleGroundType(uint32 bgType
)
1922 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; i
++)
1923 if (m_bgBattleGroundQueueID
[i
].bgType
== bgType
)
1924 m_bgBattleGroundQueueID
[i
].invited
= true;
1927 uint32
GetBattleGroundEntryPointMap() const { return m_bgEntryPointMap
; }
1928 float GetBattleGroundEntryPointX() const { return m_bgEntryPointX
; }
1929 float GetBattleGroundEntryPointY() const { return m_bgEntryPointY
; }
1930 float GetBattleGroundEntryPointZ() const { return m_bgEntryPointZ
; }
1931 float GetBattleGroundEntryPointO() const { return m_bgEntryPointO
; }
1932 void SetBattleGroundEntryPoint(uint32 Map
, float PosX
, float PosY
, float PosZ
, float PosO
)
1934 m_bgEntryPointMap
= Map
;
1935 m_bgEntryPointX
= PosX
;
1936 m_bgEntryPointY
= PosY
;
1937 m_bgEntryPointZ
= PosZ
;
1938 m_bgEntryPointO
= PosO
;
1941 void SetBGTeam(uint32 team
) { m_bgTeam
= team
; }
1942 uint32
GetBGTeam() const { return m_bgTeam
? m_bgTeam
: GetTeam(); }
1944 void LeaveBattleground(bool teleportToEntryPoint
= true);
1945 bool CanJoinToBattleground() const;
1946 bool CanReportAfkDueToLimit();
1947 void ReportedAfkBy(Player
* reporter
);
1948 void ClearAfkReports() { m_bgAfkReporter
.clear(); }
1950 bool GetBGAccessByLevel(uint32 bgTypeId
) const;
1951 bool isAllowUseBattleGroundObject();
1953 /*********************************************************/
1954 /*** REST SYSTEM ***/
1955 /*********************************************************/
1957 bool isRested() const { return GetRestTime() >= 10000; }
1958 uint32
GetXPRestBonus(uint32 xp
);
1959 uint32
GetRestTime() const { return m_restTime
;};
1960 void SetRestTime(uint32 v
) { m_restTime
= v
;};
1962 /*********************************************************/
1963 /*** ENVIROMENTAL SYSTEM ***/
1964 /*********************************************************/
1966 void EnvironmentalDamage(uint64 guid
, EnviromentalDamage type
, uint32 damage
);
1968 /*********************************************************/
1969 /*** FLOOD FILTER SYSTEM ***/
1970 /*********************************************************/
1972 void UpdateSpeakTime();
1973 bool CanSpeak() const;
1974 void ChangeSpeakTime(int utime
);
1976 /*********************************************************/
1977 /*** VARIOUS SYSTEMS ***/
1978 /*********************************************************/
1979 MovementInfo m_movementInfo
;
1980 MovementInfo m_fallMovementInfo
;
1982 bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask
); }
1983 bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask
); }
1985 bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY
); }
1986 bool IsFlying() const { return HasUnitMovementFlag(MOVEMENTFLAG_FLYING
); }
1988 void HandleDrowning();
1990 void SetClientControl(Unit
* target
, uint8 allowMove
);
1992 void EnterVehicle(Vehicle
*vehicle
);
1993 void ExitVehicle(Vehicle
*vehicle
);
1995 uint64
GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT
); }
1996 void SetFarSight(uint64 guid
) { SetUInt64Value(PLAYER_FARSIGHT
, guid
); }
1999 Transport
* GetTransport() const { return m_transport
; }
2000 void SetTransport(Transport
* t
) { m_transport
= t
; }
2002 float GetTransOffsetX() const { return m_movementInfo
.t_x
; }
2003 float GetTransOffsetY() const { return m_movementInfo
.t_y
; }
2004 float GetTransOffsetZ() const { return m_movementInfo
.t_z
; }
2005 float GetTransOffsetO() const { return m_movementInfo
.t_o
; }
2006 uint32
GetTransTime() const { return m_movementInfo
.t_time
; }
2007 int8
GetTransSeat() const { return m_movementInfo
.t_seat
; }
2009 uint32
GetSaveTimer() const { return m_nextSave
; }
2010 void SetSaveTimer(uint32 timer
) { m_nextSave
= timer
; }
2018 void SaveRecallPosition();
2020 // Homebind coordinates
2021 uint32 m_homebindMapId
;
2022 uint16 m_homebindZoneId
;
2027 // currently visible objects at player client
2028 typedef std::set
<uint64
> ClientGUIDs
;
2029 ClientGUIDs m_clientGUIDs
;
2031 bool HaveAtClient(WorldObject
const* u
) { return u
==this || m_clientGUIDs
.find(u
->GetGUID())!=m_clientGUIDs
.end(); }
2033 bool IsVisibleInGridForPlayer(Player
* pl
) const;
2034 bool IsVisibleGloballyFor(Player
* pl
) const;
2036 void UpdateVisibilityOf(WorldObject
* target
);
2039 void UpdateVisibilityOf(T
* target
, UpdateData
& data
, UpdateDataMapType
& data_updates
, std::set
<WorldObject
*>& visibleNow
);
2041 // Stealth detection system
2042 uint32 m_DetectInvTimer
;
2043 void HandleStealthedUnitsDetection();
2045 uint8 m_forced_speed_changes
[MAX_MOVE_TYPE
];
2047 bool HasAtLoginFlag(AtLoginFlags f
) const { return m_atLoginFlags
& f
; }
2048 void SetAtLoginFlag(AtLoginFlags f
) { m_atLoginFlags
|= f
; }
2050 LookingForGroup m_lookingForGroup
;
2052 // Temporarily removed pet cache
2053 uint32
GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber
; }
2054 void SetTemporaryUnsummonedPetNumber(uint32 petnumber
) { m_temporaryUnsummonedPetNumber
= petnumber
; }
2055 uint32
GetOldPetSpell() const { return m_oldpetspell
; }
2056 void SetOldPetSpell(uint32 petspell
) { m_oldpetspell
= petspell
; }
2058 /*********************************************************/
2059 /*** INSTANCE SYSTEM ***/
2060 /*********************************************************/
2062 typedef UNORDERED_MAP
< uint32
/*mapId*/, InstancePlayerBind
> BoundInstancesMap
;
2064 void UpdateHomebindTime(uint32 time
);
2066 uint32 m_HomebindTimer
;
2067 bool m_InstanceValid
;
2068 // permanent binds and solo binds by difficulty
2069 BoundInstancesMap m_boundInstances
[TOTAL_DIFFICULTIES
];
2070 InstancePlayerBind
* GetBoundInstance(uint32 mapid
, uint8 difficulty
);
2071 BoundInstancesMap
& GetBoundInstances(uint8 difficulty
) { return m_boundInstances
[difficulty
]; }
2072 void UnbindInstance(uint32 mapid
, uint8 difficulty
, bool unload
= false);
2073 void UnbindInstance(BoundInstancesMap::iterator
&itr
, uint8 difficulty
, bool unload
= false);
2074 InstancePlayerBind
* BindToInstance(InstanceSave
*save
, bool permanent
, bool load
= false);
2075 void SendRaidInfo();
2076 void SendSavedInstances();
2077 static void ConvertInstancesToGroup(Player
*player
, Group
*group
= NULL
, uint64 player_guid
= 0);
2079 /*********************************************************/
2080 /*** GROUP SYSTEM ***/
2081 /*********************************************************/
2083 Group
* GetGroupInvite() { return m_groupInvite
; }
2084 void SetGroupInvite(Group
*group
) { m_groupInvite
= group
; }
2085 Group
* GetGroup() { return m_group
.getTarget(); }
2086 const Group
* GetGroup() const { return (const Group
*)m_group
.getTarget(); }
2087 GroupReference
& GetGroupRef() { return m_group
; }
2088 void SetGroup(Group
*group
, int8 subgroup
= -1);
2089 uint8
GetSubGroup() const { return m_group
.getSubGroup(); }
2090 uint32
GetGroupUpdateFlag() { return m_groupUpdateMask
; }
2091 void SetGroupUpdateFlag(uint32 flag
) { m_groupUpdateMask
|= flag
; }
2092 uint64
GetAuraUpdateMask() { return m_auraUpdateMask
; }
2093 void SetAuraUpdateMask(uint8 slot
) { m_auraUpdateMask
|= (uint64(1) << slot
); }
2094 Player
* GetNextRandomRaidMember(float radius
);
2096 GridReference
<Player
> &GetGridRef() { return m_gridRef
; }
2097 MapReference
&GetMapRef() { return m_mapRef
; }
2099 bool isAllowedToLoot(Creature
* creature
);
2101 WorldLocation
& GetTeleportDest() { return m_teleport_dest
; }
2103 DeclinedName
const* GetDeclinedNames() const { return m_declinedname
; }
2104 uint8
GetRunesState() const { return m_runes
->runeState
; }
2105 uint8
GetBaseRune(uint8 index
) const { return m_runes
->runes
[index
].BaseRune
; }
2106 uint8
GetCurrentRune(uint8 index
) const { return m_runes
->runes
[index
].CurrentRune
; }
2107 uint8
GetRuneCooldown(uint8 index
) const { return m_runes
->runes
[index
].Cooldown
; }
2108 void SetBaseRune(uint8 index
, uint8 baseRune
) { m_runes
->runes
[index
].BaseRune
= baseRune
; }
2109 void SetCurrentRune(uint8 index
, uint8 currentRune
) { m_runes
->runes
[index
].CurrentRune
= currentRune
; }
2110 void SetRuneCooldown(uint8 index
, uint8 cooldown
) { m_runes
->runes
[index
].Cooldown
= cooldown
; m_runes
->SetRuneState(index
, (cooldown
== 0) ? true : false); }
2111 void ConvertRune(uint8 index
, uint8 newType
);
2112 void ResyncRunes(uint8 count
);
2113 void AddRunePower(uint8 index
);
2115 AchievementMgr
& GetAchievementMgr() { return m_achievementMgr
; }
2116 bool HasTitle(uint32 bitIndex
);
2117 bool HasTitle(CharTitlesEntry
const* title
) { return HasTitle(title
->bit_index
); }
2118 void SetTitle(CharTitlesEntry
const* title
);
2122 /*********************************************************/
2123 /*** BATTLEGROUND SYSTEM ***/
2124 /*********************************************************/
2126 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2127 uint32 m_bgBattleGroundID
;
2129 this is an array of BG queues (BgTypeIDs) in which is player
2131 struct BgBattleGroundQueueID_Rec
2136 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID
[PLAYER_MAX_BATTLEGROUND_QUEUES
];
2137 uint32 m_bgEntryPointMap
;
2138 float m_bgEntryPointX
;
2139 float m_bgEntryPointY
;
2140 float m_bgEntryPointZ
;
2141 float m_bgEntryPointO
;
2143 std::set
<uint32
> m_bgAfkReporter
;
2144 uint8 m_bgAfkReportedCount
;
2145 time_t m_bgAfkReportedTimer
;
2146 uint32 m_contestedPvPTimer
;
2148 uint32 m_bgTeam
; // what side the player will be added to
2150 /*********************************************************/
2151 /*** QUEST SYSTEM ***/
2152 /*********************************************************/
2154 std::set
<uint32
> m_timedquests
;
2157 uint32 m_ingametime
;
2159 /*********************************************************/
2160 /*** LOAD SYSTEM ***/
2161 /*********************************************************/
2163 void _LoadActions(QueryResult
*result
);
2164 void _LoadAuras(QueryResult
*result
, uint32 timediff
);
2165 void _LoadBoundInstances(QueryResult
*result
);
2166 void _LoadInventory(QueryResult
*result
, uint32 timediff
);
2167 void _LoadMailInit(QueryResult
*resultUnread
, QueryResult
*resultDelivery
);
2169 void _LoadMailedItems(Mail
*mail
);
2170 void _LoadQuestStatus(QueryResult
*result
);
2171 void _LoadDailyQuestStatus(QueryResult
*result
);
2172 void _LoadGroup(QueryResult
*result
);
2173 void _LoadReputation(QueryResult
*result
);
2174 void _LoadSpells(QueryResult
*result
);
2175 void _LoadTutorials(QueryResult
*result
);
2176 void _LoadFriendList(QueryResult
*result
);
2177 bool _LoadHomeBind(QueryResult
*result
);
2178 void _LoadDeclinedNames(QueryResult
*result
);
2180 /*********************************************************/
2181 /*** SAVE SYSTEM ***/
2182 /*********************************************************/
2184 void _SaveActions();
2186 void _SaveInventory();
2188 void _SaveQuestStatus();
2189 void _SaveDailyQuestStatus();
2190 void _SaveReputation();
2192 void _SaveTutorials();
2194 void _SetCreateBits(UpdateMask
*updateMask
, Player
*target
) const;
2195 void _SetUpdateBits(UpdateMask
*updateMask
, Player
*target
) const;
2197 /*********************************************************/
2198 /*** ENVIRONMENTAL SYSTEM ***/
2199 /*********************************************************/
2201 void HandleSobering();
2202 void StartMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
);
2203 void ModifyMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
, uint32 CurrentValue
, uint32 Regen
);
2204 void StopMirrorTimer(MirrorTimerType Type
);
2205 uint8 m_isunderwater
;
2208 /*********************************************************/
2209 /*** HONOR SYSTEM ***/
2210 /*********************************************************/
2211 time_t m_lastHonorUpdateTime
;
2213 void outDebugValues() const;
2214 bool _removeSpell(uint16 spell_id
);
2222 uint32 m_speakCount
;
2223 uint32 m_dungeonDifficulty
;
2225 uint32 m_atLoginFlags
;
2227 Item
* m_items
[PLAYER_SLOTS_COUNT
];
2228 uint32 m_currentBuybackSlot
;
2230 std::vector
<Item
*> m_itemUpdateQueue
;
2231 bool m_itemUpdateQueueBlocked
;
2233 uint32 m_ExtraFlags
;
2234 uint64 m_curSelection
;
2236 uint64 m_comboTarget
;
2239 QuestStatusMap mQuestStatus
;
2241 uint32 m_GuildIdInvited
;
2242 uint32 m_ArenaTeamIdInvited
;
2245 PlayerSpellMap m_spells
;
2246 SpellCooldowns m_spellCooldowns
;
2248 ActionButtonList m_actionButtons
;
2250 float m_auraBaseMod
[BASEMOD_END
][MOD_END
];
2252 SpellModList m_spellMods
[MAX_SPELLMOD
];
2253 int32 m_SpellModRemoveCount
;
2254 EnchantDurationList m_enchantDuration
;
2255 ItemDurationList m_itemDuration
;
2257 uint64 m_resurrectGUID
;
2258 uint32 m_resurrectMap
;
2259 float m_resurrectX
, m_resurrectY
, m_resurrectZ
;
2260 uint32 m_resurrectHealth
, m_resurrectMana
;
2262 WorldSession
*m_session
;
2264 typedef std::list
<Channel
*> JoinedChannelsList
;
2265 JoinedChannelsList m_channels
;
2273 uint16 tradeItems
[TRADE_SLOT_COUNT
];
2276 time_t m_nextThinkTime
;
2278 uint32 m_Tutorials
[8];
2279 bool m_TutorialsChanged
;
2281 bool m_DailyQuestChanged
;
2282 time_t m_lastDailyQuestTime
;
2284 uint32 m_breathTimer
;
2285 uint32 m_drunkTimer
;
2287 uint32 m_weaponChangeTimer
;
2289 uint32 m_zoneUpdateId
;
2290 uint32 m_zoneUpdateTimer
;
2291 uint32 m_areaUpdateId
;
2293 uint32 m_deathTimer
;
2294 time_t m_deathExpireTime
;
2298 uint32 m_WeaponProficiency
;
2299 uint32 m_ArmorProficiency
;
2302 bool m_canDualWield
;
2303 uint8 m_swingErrorMsg
;
2305 ////////////////////Rest System/////////////////////
2307 uint32 inn_pos_mapid
;
2313 ////////////////////Rest System/////////////////////
2316 Transport
* m_transport
;
2318 uint32 m_resetTalentsCost
;
2319 time_t m_resetTalentsTime
;
2320 uint32 m_usedTalentCount
;
2323 PlayerSocial
*m_social
;
2326 GroupReference m_group
;
2327 Group
*m_groupInvite
;
2328 uint32 m_groupUpdateMask
;
2329 uint64 m_auraUpdateMask
;
2331 // Temporarily removed pet cache
2332 uint32 m_temporaryUnsummonedPetNumber
;
2333 uint32 m_oldpetspell
;
2336 GuardianPetList m_guardianPets
;
2339 time_t m_summon_expire
;
2340 uint32 m_summon_mapid
;
2346 WorldLocation m_teleport_dest
;
2348 DeclinedName
*m_declinedname
;
2350 AchievementMgr m_achievementMgr
;
2352 // internal common parts for CanStore/StoreItem functions
2353 uint8
_CanStoreItem_InSpecificSlot( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool swap
, Item
*pSrcItem
) const;
2354 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;
2355 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;
2356 Item
* _StoreItem( uint16 pos
, Item
*pItem
, uint32 count
, bool clone
, bool update
);
2358 GridReference
<Player
> m_gridRef
;
2359 MapReference m_mapRef
;
2362 void AddItemsSetItem(Player
*player
,Item
*item
);
2363 void RemoveItemsSetItem(Player
*player
,ItemPrototype
const *proto
);
2365 // "the bodies of template functions must be made available in a header file"
2366 template <class T
> T
Player::ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
)
2368 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
2369 if (!spellInfo
) return 0;
2371 int32 totalflat
= 0;
2372 for (SpellModList::iterator itr
= m_spellMods
[op
].begin(); itr
!= m_spellMods
[op
].end(); ++itr
)
2374 SpellModifier
*mod
= *itr
;
2376 if(!IsAffectedBySpellmod(spellInfo
,mod
,spell
))
2378 if (mod
->type
== SPELLMOD_FLAT
)
2379 totalflat
+= mod
->value
;
2380 else if (mod
->type
== SPELLMOD_PCT
)
2382 // skip percent mods for null basevalue (most important for spell mods with charges )
2383 if(basevalue
== T(0))
2386 // special case (skip >10sec spell casts for instant cast setting)
2387 if( mod
->op
==SPELLMOD_CASTING_TIME
&& basevalue
>= T(10000) && mod
->value
<= -100)
2390 totalpct
+= mod
->value
;
2393 if (mod
->charges
> 0 )
2396 if (mod
->charges
== 0)
2399 mod
->lastAffected
= spell
;
2400 if(!mod
->lastAffected
)
2401 mod
->lastAffected
= FindCurrentSpellBySpellId(spellId
);
2402 ++m_SpellModRemoveCount
;
2407 float diff
= (float)basevalue
*(float)totalpct
/100.0f
+ (float)totalflat
;
2408 basevalue
= T((float)basevalue
+ diff
);