2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "ItemPrototype.h"
27 #include "Database/DatabaseEnv.h"
28 #include "NPCHandler.h"
32 #include "WorldSession.h"
34 #include "MapReference.h"
35 #include "Util.h" // for Tokens typedef
36 #include "AchievementMgr.h"
37 #include "ReputationMgr.h"
38 #include "BattleGround.h"
51 class SpellCastTargets
;
55 typedef std::deque
<Mail
*> PlayerMails
;
57 #define PLAYER_MAX_SKILLS 127
58 #define PLAYER_MAX_DAILY_QUESTS 25
60 // Note: SPELLMOD_* values is aura types in fact
63 SPELLMOD_FLAT
= 107, // SPELL_AURA_ADD_FLAT_MODIFIER
64 SPELLMOD_PCT
= 108 // SPELL_AURA_ADD_PCT_MODIFIER
67 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
68 enum PlayerUnderwaterState
70 UNDERWATER_NONE
= 0x00,
71 UNDERWATER_INWATER
= 0x01, // terrain type is water and player is afflicted by it
72 UNDERWATER_INLAVA
= 0x02, // terrain type is lava and player is afflicted by it
73 UNDERWATER_INSLIME
= 0x04, // terrain type is lava and player is afflicted by it
74 UNDERWARER_INDARKWATER
= 0x08, // terrain type is dark water and player is afflicted by it
76 UNDERWATER_EXIST_TIMERS
= 0x10
81 PLAYERSPELL_UNCHANGED
= 0,
82 PLAYERSPELL_CHANGED
= 1,
84 PLAYERSPELL_REMOVED
= 3
89 PlayerSpellState state
: 8;
90 bool active
: 1; // show in spellbook
91 bool dependent
: 1; // learned as result another spell learn, skill grow, quest reward, etc
92 bool disabled
: 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
95 // Spell modifier (used for modify other spells)
98 SpellModifier() : charges(0), lastAffected(NULL
) {}
100 SpellModType type
: 8;
106 Spell
const* lastAffected
;
109 typedef UNORDERED_MAP
<uint32
, PlayerSpell
*> PlayerSpellMap
;
110 typedef std::list
<SpellModifier
*> SpellModList
;
118 typedef std::map
<uint32
, SpellCooldown
> SpellCooldowns
;
120 enum TrainerSpellState
122 TRAINER_SPELL_GREEN
= 0,
123 TRAINER_SPELL_RED
= 1,
124 TRAINER_SPELL_GRAY
= 2,
125 TRAINER_SPELL_GREEN_DISABLED
= 10 // custom value, not send to client: formally green but learn not allowed
128 enum ActionButtonUpdateState
130 ACTIONBUTTON_UNCHANGED
= 0,
131 ACTIONBUTTON_CHANGED
= 1,
132 ACTIONBUTTON_NEW
= 2,
133 ACTIONBUTTON_DELETED
= 3
136 enum ActionButtonType
138 ACTION_BUTTON_SPELL
= 0x00,
139 ACTION_BUTTON_C
= 0x01, // click?
140 ACTION_BUTTON_EQSET
= 0x20,
141 ACTION_BUTTON_MACRO
= 0x40,
142 ACTION_BUTTON_CMACRO
= ACTION_BUTTON_C
| ACTION_BUTTON_MACRO
,
143 ACTION_BUTTON_ITEM
= 0x80
146 #define ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
147 #define ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
148 #define MAX_ACTION_BUTTON_ACTION_VALUE (0x00FFFFFF+1)
152 ActionButton() : packedData(0), uState( ACTIONBUTTON_NEW
) {}
155 ActionButtonUpdateState uState
;
158 ActionButtonType
GetType() const { return ActionButtonType(ACTION_BUTTON_TYPE(packedData
)); }
159 uint32
GetAction() const { return ACTION_BUTTON_ACTION(packedData
); }
160 void SetActionAndType(uint32 action
, ActionButtonType type
)
162 uint32 newData
= action
| (uint32(type
) << 24);
163 if (newData
!= packedData
)
165 packedData
= newData
;
166 if (uState
!= ACTIONBUTTON_NEW
)
167 uState
= ACTIONBUTTON_CHANGED
;
172 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
174 typedef std::map
<uint8
,ActionButton
> ActionButtonList
;
176 struct PlayerCreateInfoItem
178 PlayerCreateInfoItem(uint32 id
, uint32 amount
) : item_id(id
), item_amount(amount
) {}
184 typedef std::list
<PlayerCreateInfoItem
> PlayerCreateInfoItems
;
186 struct PlayerClassLevelInfo
188 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
193 struct PlayerClassInfo
195 PlayerClassInfo() : levelInfo(NULL
) { }
197 PlayerClassLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
200 struct PlayerLevelInfo
202 PlayerLevelInfo() { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
204 uint8 stats
[MAX_STATS
];
207 typedef std::list
<uint32
> PlayerCreateInfoSpells
;
209 struct PlayerCreateInfoAction
211 PlayerCreateInfoAction() : button(0), type(0), action(0) {}
212 PlayerCreateInfoAction(uint8 _button
, uint32 _action
, uint8 _type
) : button(_button
), type(_type
), action(_action
) {}
219 typedef std::list
<PlayerCreateInfoAction
> PlayerCreateInfoActions
;
223 // existence checked by displayId != 0 // existence checked by displayId != 0
224 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL
)
235 PlayerCreateInfoItems item
;
236 PlayerCreateInfoSpells spell
;
237 PlayerCreateInfoActions action
;
239 PlayerLevelInfo
* levelInfo
; //[level-1] 0..MaxPlayerLevel-1
244 PvPInfo() : inHostileArea(false), endTimer(0) {}
252 DuelInfo() : initiator(NULL
), opponent(NULL
), startTimer(0), startTime(0), outOfBound(0) {}
272 #define RUNE_COOLDOWN 5 // 5*2=10 sec
292 RuneInfo runes
[MAX_RUNES
];
293 uint8 runeState
; // mask of available runes
295 void SetRuneState(uint8 index
, bool set
= true)
298 runeState
|= (1 << index
); // usable
300 runeState
&= ~(1 << index
); // on cooldown
304 struct EnchantDuration
306 EnchantDuration() : item(NULL
), slot(MAX_ENCHANTMENT_SLOT
), leftduration(0) {};
307 EnchantDuration(Item
* _item
, EnchantmentSlot _slot
, uint32 _leftduration
) : item(_item
), slot(_slot
), leftduration(_leftduration
) { assert(item
); };
310 EnchantmentSlot slot
;
314 typedef std::list
<EnchantDuration
> EnchantDurationList
;
315 typedef std::list
<Item
*> ItemDurationList
;
320 LFG_TYPE_DUNGEON
= 1,
324 LFG_TYPE_HEROIC_DUNGEON
= 5
335 struct LookingForGroupSlot
337 LookingForGroupSlot() : entry(0), type(0) {}
338 bool Empty() const { return !entry
&& !type
; }
339 void Clear() { entry
= 0; type
= 0; }
340 void Set(uint32 _entry
, uint32 _type
) { entry
= _entry
; type
= _type
; }
341 bool Is(uint32 _entry
, uint32 _type
) const { return entry
== _entry
&& type
== _type
; }
342 bool canAutoJoin() const { return entry
&& (type
== LFG_TYPE_DUNGEON
|| type
== LFG_TYPE_HEROIC_DUNGEON
); }
348 #define MAX_LOOKING_FOR_GROUP_SLOT 3
350 struct LookingForGroup
353 bool HaveInSlot(LookingForGroupSlot
const& slot
) const { return HaveInSlot(slot
.entry
, slot
.type
); }
354 bool HaveInSlot(uint32 _entry
, uint32 _type
) const
356 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
357 if(slots
[i
].Is(_entry
, _type
))
362 bool canAutoJoin() const
364 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
365 if(slots
[i
].canAutoJoin())
372 for(int i
= 0; i
< MAX_LOOKING_FOR_GROUP_SLOT
; ++i
)
373 if(!slots
[i
].Empty())
378 LookingForGroupSlot slots
[MAX_LOOKING_FOR_GROUP_SLOT
];
379 LookingForGroupSlot more
;
384 enum PlayerMovementType
400 #define MAX_DRUNKEN 4
404 PLAYER_FLAGS_GROUP_LEADER
= 0x00000001,
405 PLAYER_FLAGS_AFK
= 0x00000002,
406 PLAYER_FLAGS_DND
= 0x00000004,
407 PLAYER_FLAGS_GM
= 0x00000008,
408 PLAYER_FLAGS_GHOST
= 0x00000010,
409 PLAYER_FLAGS_RESTING
= 0x00000020,
410 PLAYER_FLAGS_UNK7
= 0x00000040,
411 PLAYER_FLAGS_UNK8
= 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
412 PLAYER_FLAGS_CONTESTED_PVP
= 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
413 PLAYER_FLAGS_IN_PVP
= 0x00000200,
414 PLAYER_FLAGS_HIDE_HELM
= 0x00000400,
415 PLAYER_FLAGS_HIDE_CLOAK
= 0x00000800,
416 PLAYER_FLAGS_UNK13
= 0x00001000, // played long time
417 PLAYER_FLAGS_UNK14
= 0x00002000, // played too long time
418 PLAYER_FLAGS_UNK15
= 0x00004000,
419 PLAYER_FLAGS_UNK16
= 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
420 PLAYER_FLAGS_UNK17
= 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
421 PLAYER_FLAGS_UNK18
= 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
422 PLAYER_FLAGS_PVP_TIMER
= 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
423 PLAYER_FLAGS_UNK20
= 0x00080000,
424 PLAYER_FLAGS_UNK21
= 0x00100000,
425 PLAYER_FLAGS_UNK22
= 0x00200000,
426 PLAYER_FLAGS_UNK23
= 0x00400000,
427 PLAYER_FLAGS_UNK24
= 0x00800000, // disabled all abilitys on tab except autoattack
428 PLAYER_FLAGS_UNK25
= 0x01000000, // disabled all melee ability on tab include autoattack
432 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
433 // can't use enum for uint64 values
434 #define PLAYER_TITLE_DISABLED UI64LIT(0x0000000000000000)
435 #define PLAYER_TITLE_NONE UI64LIT(0x0000000000000001)
436 #define PLAYER_TITLE_PRIVATE UI64LIT(0x0000000000000002) // 1
437 #define PLAYER_TITLE_CORPORAL UI64LIT(0x0000000000000004) // 2
438 #define PLAYER_TITLE_SERGEANT_A UI64LIT(0x0000000000000008) // 3
439 #define PLAYER_TITLE_MASTER_SERGEANT UI64LIT(0x0000000000000010) // 4
440 #define PLAYER_TITLE_SERGEANT_MAJOR UI64LIT(0x0000000000000020) // 5
441 #define PLAYER_TITLE_KNIGHT UI64LIT(0x0000000000000040) // 6
442 #define PLAYER_TITLE_KNIGHT_LIEUTENANT UI64LIT(0x0000000000000080) // 7
443 #define PLAYER_TITLE_KNIGHT_CAPTAIN UI64LIT(0x0000000000000100) // 8
444 #define PLAYER_TITLE_KNIGHT_CHAMPION UI64LIT(0x0000000000000200) // 9
445 #define PLAYER_TITLE_LIEUTENANT_COMMANDER UI64LIT(0x0000000000000400) // 10
446 #define PLAYER_TITLE_COMMANDER UI64LIT(0x0000000000000800) // 11
447 #define PLAYER_TITLE_MARSHAL UI64LIT(0x0000000000001000) // 12
448 #define PLAYER_TITLE_FIELD_MARSHAL UI64LIT(0x0000000000002000) // 13
449 #define PLAYER_TITLE_GRAND_MARSHAL UI64LIT(0x0000000000004000) // 14
450 #define PLAYER_TITLE_SCOUT UI64LIT(0x0000000000008000) // 15
451 #define PLAYER_TITLE_GRUNT UI64LIT(0x0000000000010000) // 16
452 #define PLAYER_TITLE_SERGEANT_H UI64LIT(0x0000000000020000) // 17
453 #define PLAYER_TITLE_SENIOR_SERGEANT UI64LIT(0x0000000000040000) // 18
454 #define PLAYER_TITLE_FIRST_SERGEANT UI64LIT(0x0000000000080000) // 19
455 #define PLAYER_TITLE_STONE_GUARD UI64LIT(0x0000000000100000) // 20
456 #define PLAYER_TITLE_BLOOD_GUARD UI64LIT(0x0000000000200000) // 21
457 #define PLAYER_TITLE_LEGIONNAIRE UI64LIT(0x0000000000400000) // 22
458 #define PLAYER_TITLE_CENTURION UI64LIT(0x0000000000800000) // 23
459 #define PLAYER_TITLE_CHAMPION UI64LIT(0x0000000001000000) // 24
460 #define PLAYER_TITLE_LIEUTENANT_GENERAL UI64LIT(0x0000000002000000) // 25
461 #define PLAYER_TITLE_GENERAL UI64LIT(0x0000000004000000) // 26
462 #define PLAYER_TITLE_WARLORD UI64LIT(0x0000000008000000) // 27
463 #define PLAYER_TITLE_HIGH_WARLORD UI64LIT(0x0000000010000000) // 28
464 #define PLAYER_TITLE_GLADIATOR UI64LIT(0x0000000020000000) // 29
465 #define PLAYER_TITLE_DUELIST UI64LIT(0x0000000040000000) // 30
466 #define PLAYER_TITLE_RIVAL UI64LIT(0x0000000080000000) // 31
467 #define PLAYER_TITLE_CHALLENGER UI64LIT(0x0000000100000000) // 32
468 #define PLAYER_TITLE_SCARAB_LORD UI64LIT(0x0000000200000000) // 33
469 #define PLAYER_TITLE_CONQUEROR UI64LIT(0x0000000400000000) // 34
470 #define PLAYER_TITLE_JUSTICAR UI64LIT(0x0000000800000000) // 35
471 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU UI64LIT(0x0000001000000000) // 36
472 #define PLAYER_TITLE_MERCILESS_GLADIATOR UI64LIT(0x0000002000000000) // 37
473 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN UI64LIT(0x0000004000000000) // 38
474 #define PLAYER_TITLE_HAND_OF_ADAL UI64LIT(0x0000008000000000) // 39
475 #define PLAYER_TITLE_VENGEFUL_GLADIATOR UI64LIT(0x0000010000000000) // 40
477 #define MAX_TITLE_INDEX (3*64) // 3 uint64 fields
479 // used in PLAYER_FIELD_BYTES values
480 enum PlayerFieldByteFlags
482 PLAYER_FIELD_BYTE_TRACK_STEALTHED
= 0x00000002,
483 PLAYER_FIELD_BYTE_RELEASE_TIMER
= 0x00000008, // Display time till auto release spirit
484 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW
= 0x00000010 // Display no "release spirit" window at all
487 // used in PLAYER_FIELD_BYTES2 values
488 enum PlayerFieldByte2Flags
490 PLAYER_FIELD_BYTE2_NONE
= 0x0000,
491 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
= 0x4000
494 enum ActivateTaxiReplies
497 ERR_TAXIUNSPECIFIEDSERVERERROR
= 1,
498 ERR_TAXINOSUCHPATH
= 2,
499 ERR_TAXINOTENOUGHMONEY
= 3,
500 ERR_TAXITOOFARAWAY
= 4,
501 ERR_TAXINOVENDORNEARBY
= 5,
502 ERR_TAXINOTVISITED
= 6,
503 ERR_TAXIPLAYERBUSY
= 7,
504 ERR_TAXIPLAYERALREADYMOUNTED
= 8,
505 ERR_TAXIPLAYERSHAPESHIFTED
= 9,
506 ERR_TAXIPLAYERMOVING
= 10,
507 ERR_TAXISAMENODE
= 11,
508 ERR_TAXINOTSTANDING
= 12
520 #define DISABLED_MIRROR_TIMER -1
523 enum PlayerExtraFlags
526 PLAYER_EXTRA_GM_ON
= 0x0001,
527 PLAYER_EXTRA_GM_ACCEPT_TICKETS
= 0x0002,
528 PLAYER_EXTRA_ACCEPT_WHISPERS
= 0x0004,
529 PLAYER_EXTRA_TAXICHEAT
= 0x0008,
530 PLAYER_EXTRA_GM_INVISIBLE
= 0x0010,
531 PLAYER_EXTRA_GM_CHAT
= 0x0020, // Show GM badge in chat messages
534 PLAYER_EXTRA_PVP_DEATH
= 0x0100 // store PvP death status until corpse creating.
540 AT_LOGIN_NONE
= 0x00,
541 AT_LOGIN_RENAME
= 0x01,
542 AT_LOGIN_RESET_SPELLS
= 0x02,
543 AT_LOGIN_RESET_TALENTS
= 0x04,
544 AT_LOGIN_CUSTOMIZE
= 0x08,
545 AT_LOGIN_RESET_PET_TALENTS
= 0x10,
548 typedef std::map
<uint32
, QuestStatusData
> QuestStatusMap
;
550 enum QuestSlotOffsets
553 QUEST_STATE_OFFSET
= 1,
554 QUEST_COUNTS_OFFSET
= 2,
555 QUEST_TIME_OFFSET
= 3
558 #define MAX_QUEST_OFFSET 4
560 enum QuestSlotStateMask
562 QUEST_STATE_NONE
= 0x0000,
563 QUEST_STATE_COMPLETE
= 0x0001,
564 QUEST_STATE_FAIL
= 0x0002
574 // first slot for item stored (in any way in player m_items data)
575 PLAYER_SLOT_START
= 0,
576 // last+1 slot for item stored (in any way in player m_items data)
577 PLAYER_SLOT_END
= 150,
578 PLAYER_SLOTS_COUNT
= (PLAYER_SLOT_END
- PLAYER_SLOT_START
)
581 #define INVENTORY_SLOT_BAG_0 255
583 enum EquipmentSlots
// 19 slots
585 EQUIPMENT_SLOT_START
= 0,
586 EQUIPMENT_SLOT_HEAD
= 0,
587 EQUIPMENT_SLOT_NECK
= 1,
588 EQUIPMENT_SLOT_SHOULDERS
= 2,
589 EQUIPMENT_SLOT_BODY
= 3,
590 EQUIPMENT_SLOT_CHEST
= 4,
591 EQUIPMENT_SLOT_WAIST
= 5,
592 EQUIPMENT_SLOT_LEGS
= 6,
593 EQUIPMENT_SLOT_FEET
= 7,
594 EQUIPMENT_SLOT_WRISTS
= 8,
595 EQUIPMENT_SLOT_HANDS
= 9,
596 EQUIPMENT_SLOT_FINGER1
= 10,
597 EQUIPMENT_SLOT_FINGER2
= 11,
598 EQUIPMENT_SLOT_TRINKET1
= 12,
599 EQUIPMENT_SLOT_TRINKET2
= 13,
600 EQUIPMENT_SLOT_BACK
= 14,
601 EQUIPMENT_SLOT_MAINHAND
= 15,
602 EQUIPMENT_SLOT_OFFHAND
= 16,
603 EQUIPMENT_SLOT_RANGED
= 17,
604 EQUIPMENT_SLOT_TABARD
= 18,
605 EQUIPMENT_SLOT_END
= 19
608 enum InventorySlots
// 4 slots
610 INVENTORY_SLOT_BAG_START
= 19,
611 INVENTORY_SLOT_BAG_END
= 23
614 enum InventoryPackSlots
// 16 slots
616 INVENTORY_SLOT_ITEM_START
= 23,
617 INVENTORY_SLOT_ITEM_END
= 39
620 enum BankItemSlots
// 28 slots
622 BANK_SLOT_ITEM_START
= 39,
623 BANK_SLOT_ITEM_END
= 67
626 enum BankBagSlots
// 7 slots
628 BANK_SLOT_BAG_START
= 67,
629 BANK_SLOT_BAG_END
= 74
632 enum BuyBackSlots
// 12 slots
634 // stored in m_buybackitems
635 BUYBACK_SLOT_START
= 74,
636 BUYBACK_SLOT_END
= 86
639 enum KeyRingSlots
// 32 slots
641 KEYRING_SLOT_START
= 86,
642 KEYRING_SLOT_END
= 118
645 enum CurrencyTokenSlots
// 32 slots
647 CURRENCYTOKEN_SLOT_START
= 118,
648 CURRENCYTOKEN_SLOT_END
= 150
651 enum EquipmentSetUpdateState
653 EQUIPMENT_SET_UNCHANGED
= 0,
654 EQUIPMENT_SET_CHANGED
= 1,
655 EQUIPMENT_SET_NEW
= 2,
656 EQUIPMENT_SET_DELETED
= 3
661 EquipmentSet() : Guid(0), state(EQUIPMENT_SET_NEW
)
663 for(int i
= 0; i
< EQUIPMENT_SLOT_END
; ++i
)
669 std::string IconName
;
670 uint32 Items
[EQUIPMENT_SLOT_END
];
671 EquipmentSetUpdateState state
;
674 #define MAX_EQUIPMENT_SET_INDEX 10 // client limit
676 typedef std::map
<uint32
, EquipmentSet
> EquipmentSets
;
680 ItemPosCount(uint16 _pos
, uint32 _count
) : pos(_pos
), count(_count
) {}
681 bool isContainedIn(std::vector
<ItemPosCount
> const& vec
) const;
685 typedef std::vector
<ItemPosCount
> ItemPosCountVec
;
689 TRADE_SLOT_COUNT
= 7,
690 TRADE_SLOT_TRADED_COUNT
= 6,
691 TRADE_SLOT_NONTRADED
= 6
694 enum TransferAbortReason
696 TRANSFER_ABORT_NONE
= 0x00,
697 TRANSFER_ABORT_ERROR
= 0x01,
698 TRANSFER_ABORT_MAX_PLAYERS
= 0x02, // Transfer Aborted: instance is full
699 TRANSFER_ABORT_NOT_FOUND
= 0x03, // Transfer Aborted: instance not found
700 TRANSFER_ABORT_TOO_MANY_INSTANCES
= 0x04, // You have entered too many instances recently.
701 TRANSFER_ABORT_ZONE_IN_COMBAT
= 0x06, // Unable to zone in while an encounter is in progress.
702 TRANSFER_ABORT_INSUF_EXPAN_LVL
= 0x07, // You must have <TBC,WotLK> expansion installed to access this area.
703 TRANSFER_ABORT_DIFFICULTY
= 0x08, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
704 TRANSFER_ABORT_UNIQUE_MESSAGE
= 0x09, // Until you've escaped TLK's grasp, you cannot leave this place!
705 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES
= 0x0A, // Additional instances cannot be launched, please try again later.
706 TRANSFER_ABORT_NEED_GROUP
= 0x0B, // 3.1
707 TRANSFER_ABORT_NOT_FOUND2
= 0x0C, // 3.1
708 TRANSFER_ABORT_NOT_FOUND3
= 0x0D, // 3.1
711 enum InstanceResetWarningType
713 RAID_INSTANCE_WARNING_HOURS
= 1, // WARNING! %s is scheduled to reset in %d hour(s).
714 RAID_INSTANCE_WARNING_MIN
= 2, // WARNING! %s is scheduled to reset in %d minute(s)!
715 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!
716 RAID_INSTANCE_WELCOME
= 4, // Welcome to %s. This raid instance is scheduled to reset in %s.
717 RAID_INSTANCE_EXPIRED
= 5
720 // used in most movement packets (send and received)
723 MOVEMENTFLAG_NONE
= 0x00000000,
724 MOVEMENTFLAG_FORWARD
= 0x00000001,
725 MOVEMENTFLAG_BACKWARD
= 0x00000002,
726 MOVEMENTFLAG_STRAFE_LEFT
= 0x00000004,
727 MOVEMENTFLAG_STRAFE_RIGHT
= 0x00000008,
728 MOVEMENTFLAG_LEFT
= 0x00000010,
729 MOVEMENTFLAG_RIGHT
= 0x00000020,
730 MOVEMENTFLAG_PITCH_UP
= 0x00000040,
731 MOVEMENTFLAG_PITCH_DOWN
= 0x00000080,
732 MOVEMENTFLAG_WALK_MODE
= 0x00000100, // Walking
733 MOVEMENTFLAG_ONTRANSPORT
= 0x00000200, // Used for flying on some creatures
734 MOVEMENTFLAG_LEVITATING
= 0x00000400,
735 MOVEMENTFLAG_FLY_UNK1
= 0x00000800,
736 MOVEMENTFLAG_JUMPING
= 0x00001000,
737 MOVEMENTFLAG_UNK4
= 0x00002000,
738 MOVEMENTFLAG_FALLING
= 0x00004000,
739 // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
740 MOVEMENTFLAG_SWIMMING
= 0x00200000, // appears with fly flag also
741 MOVEMENTFLAG_FLY_UP
= 0x00400000,
742 MOVEMENTFLAG_CAN_FLY
= 0x00800000,
743 MOVEMENTFLAG_FLYING
= 0x01000000,
744 MOVEMENTFLAG_FLYING2
= 0x02000000, // Actual flying mode
745 MOVEMENTFLAG_SPLINE
= 0x04000000, // used for flight paths
746 MOVEMENTFLAG_SPLINE2
= 0x08000000, // used for flight paths
747 MOVEMENTFLAG_WATERWALKING
= 0x10000000, // prevent unit from falling through water
748 MOVEMENTFLAG_SAFE_FALL
= 0x20000000, // active rogue safe fall spell (passive)
749 MOVEMENTFLAG_UNK3
= 0x40000000
755 uint32 flags
; // see enum MovementFlags
761 float t_x
, t_y
, t_z
, t_o
;
764 // swimming and unknown
769 float j_unk
, j_sinAngle
, j_cosAngle
, j_xyspeed
;
775 flags
= MOVEMENTFLAG_NONE
;
776 time
= t_time
= fallTime
= 0;
778 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
;
782 void AddMovementFlag(MovementFlags f
) { flags
|= f
; }
783 void RemoveMovementFlag(MovementFlags f
) { flags
&= ~f
; }
784 bool HasMovementFlag(MovementFlags f
) const { return flags
& f
; }
785 MovementFlags
GetMovementFlags() const { return MovementFlags(flags
); }
786 void SetMovementFlags(MovementFlags f
) { flags
= f
; }
789 // flags that use in movement check for example at spell casting
790 MovementFlags
const movementFlagsMask
= MovementFlags(
791 MOVEMENTFLAG_FORWARD
|MOVEMENTFLAG_BACKWARD
|MOVEMENTFLAG_STRAFE_LEFT
|MOVEMENTFLAG_STRAFE_RIGHT
|
792 MOVEMENTFLAG_PITCH_UP
|MOVEMENTFLAG_PITCH_DOWN
|MOVEMENTFLAG_FLY_UNK1
|
793 MOVEMENTFLAG_JUMPING
|MOVEMENTFLAG_FALLING
|MOVEMENTFLAG_FLY_UP
|
794 MOVEMENTFLAG_FLYING
|MOVEMENTFLAG_SPLINE
797 MovementFlags
const movementOrTurningFlagsMask
= MovementFlags(
798 movementFlagsMask
| MOVEMENTFLAG_LEFT
| MOVEMENTFLAG_RIGHT
805 REST_TYPE_IN_TAVERN
= 1,
806 REST_TYPE_IN_CITY
= 2
809 enum DuelCompleteType
816 enum TeleportToOptions
818 TELE_TO_GM_MODE
= 0x01,
819 TELE_TO_NOT_LEAVE_TRANSPORT
= 0x02,
820 TELE_TO_NOT_LEAVE_COMBAT
= 0x04,
821 TELE_TO_NOT_UNSUMMON_PET
= 0x08,
822 TELE_TO_SPELL
= 0x10,
825 /// Type of environmental damages
826 enum EnviromentalDamage
828 DAMAGE_EXHAUSTED
= 0,
834 DAMAGE_FALL_TO_VOID
= 6 // custom case for fall without durability loss
839 PLAYED_TIME_TOTAL
= 0,
840 PLAYED_TIME_LEVEL
= 1
843 #define MAX_PLAYED_TIME_INDEX 2
845 // used at player loading query list preparing, and later result selection
846 enum PlayerLoginQueryIndex
848 PLAYER_LOGIN_QUERY_LOADFROM
= 0,
849 PLAYER_LOGIN_QUERY_LOADGROUP
= 1,
850 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES
= 2,
851 PLAYER_LOGIN_QUERY_LOADAURAS
= 3,
852 PLAYER_LOGIN_QUERY_LOADSPELLS
= 4,
853 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS
= 5,
854 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS
= 6,
855 PLAYER_LOGIN_QUERY_LOADREPUTATION
= 7,
856 PLAYER_LOGIN_QUERY_LOADINVENTORY
= 8,
857 PLAYER_LOGIN_QUERY_LOADACTIONS
= 9,
858 PLAYER_LOGIN_QUERY_LOADMAILCOUNT
= 10,
859 PLAYER_LOGIN_QUERY_LOADMAILDATE
= 11,
860 PLAYER_LOGIN_QUERY_LOADSOCIALLIST
= 12,
861 PLAYER_LOGIN_QUERY_LOADHOMEBIND
= 13,
862 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS
= 14,
863 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES
= 15,
864 PLAYER_LOGIN_QUERY_LOADGUILD
= 16,
865 PLAYER_LOGIN_QUERY_LOADARENAINFO
= 17,
866 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS
= 18,
867 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS
= 19,
868 PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS
= 20,
869 PLAYER_LOGIN_QUERY_LOADBGDATA
= 21,
870 PLAYER_LOGIN_QUERY_LOADACCOUNTDATA
= 22,
871 MAX_PLAYER_LOGIN_QUERY
= 23
874 enum PlayerDelayedOperations
876 DELAYED_SAVE_PLAYER
= 0x01,
877 DELAYED_RESURRECT_PLAYER
= 0x02,
878 DELAYED_SPELL_CAST_DESERTER
= 0x04,
879 DELAYED_BG_MOUNT_RESTORE
= 0x08, ///< Flag to restore mount state after teleport from BG
880 DELAYED_BG_TAXI_RESTORE
= 0x10, ///< Flag to restore taxi state after teleport from BG
884 // Player summoning auto-decline time (in secs)
885 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
886 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
888 struct InstancePlayerBind
892 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
893 that aren't already permanently bound when they are inside when a boss is killed
894 or when they enter an instance that the group leader is permanently bound to. */
895 InstancePlayerBind() : save(NULL
), perm(false) {}
898 class MANGOS_DLL_SPEC PlayerTaxi
904 void InitTaxiNodesForLevel(uint32 race
, uint32 chrClass
, uint32 level
);
905 void LoadTaxiMask(const char* data
);
907 bool IsTaximaskNodeKnown(uint32 nodeidx
) const
909 uint8 field
= uint8((nodeidx
- 1) / 32);
910 uint32 submask
= 1<<((nodeidx
-1)%32);
911 return (m_taximask
[field
] & submask
) == submask
;
913 bool SetTaximaskNode(uint32 nodeidx
)
915 uint8 field
= uint8((nodeidx
- 1) / 32);
916 uint32 submask
= 1<<((nodeidx
-1)%32);
917 if ((m_taximask
[field
] & submask
) != submask
)
919 m_taximask
[field
] |= submask
;
925 void AppendTaximaskTo(ByteBuffer
& data
,bool all
);
928 bool LoadTaxiDestinationsFromString(const std::string
& values
, uint32 team
);
929 std::string
SaveTaxiDestinationsToString();
931 void ClearTaxiDestinations() { m_TaxiDestinations
.clear(); }
932 void AddTaxiDestination(uint32 dest
) { m_TaxiDestinations
.push_back(dest
); }
933 uint32
GetTaxiSource() const { return m_TaxiDestinations
.empty() ? 0 : m_TaxiDestinations
.front(); }
934 uint32
GetTaxiDestination() const { return m_TaxiDestinations
.size() < 2 ? 0 : m_TaxiDestinations
[1]; }
935 uint32
GetCurrentTaxiPath() const;
936 uint32
NextTaxiDestination()
938 m_TaxiDestinations
.pop_front();
939 return GetTaxiDestination();
941 bool empty() const { return m_TaxiDestinations
.empty(); }
943 friend std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
946 std::deque
<uint32
> m_TaxiDestinations
;
949 std::ostringstream
& operator<< (std::ostringstream
& ss
, PlayerTaxi
const& taxi
);
953 /// Holder for BattleGround data
956 BGData() : bgInstanceID(0), bgTypeID(BATTLEGROUND_TYPE_NONE
), bgAfkReportedCount(0), bgAfkReportedTimer(0),
957 bgTeam(0), mountSpell(0) { ClearTaxiPath(); }
960 uint32 bgInstanceID
; ///< This variable is set to bg->m_InstanceID,
961 /// when player is teleported to BG - (it is battleground's GUID)
962 BattleGroundTypeId bgTypeID
;
964 std::set
<uint32
> bgAfkReporter
;
965 uint8 bgAfkReportedCount
;
966 time_t bgAfkReportedTimer
;
968 uint32 bgTeam
; ///< What side the player will be added to
974 WorldLocation joinPos
; ///< From where player entered BG
976 void ClearTaxiPath() { taxiPath
[0] = taxiPath
[1] = 0; }
977 bool HasTaxiPath() const { return taxiPath
[0] && taxiPath
[1]; }
980 class MANGOS_DLL_SPEC Player
: public Unit
982 friend class WorldSession
;
983 friend void Item::AddToUpdateQueueOf(Player
*player
);
984 friend void Item::RemoveFromUpdateQueueOf(Player
*player
);
986 explicit Player (WorldSession
*session
);
989 void CleanupsBeforeDelete();
991 static UpdateMask updateVisualBits
;
992 static void InitVisibleBits();
995 void RemoveFromWorld();
997 bool TeleportTo(uint32 mapid
, float x
, float y
, float z
, float orientation
, uint32 options
= 0);
999 bool TeleportTo(WorldLocation
const &loc
, uint32 options
= 0)
1001 return TeleportTo(loc
.mapid
, loc
.coord_x
, loc
.coord_y
, loc
.coord_z
, loc
.orientation
, options
);
1004 bool TeleportToBGEntryPoint();
1006 void SetSummonPoint(uint32 mapid
, float x
, float y
, float z
)
1008 m_summon_expire
= time(NULL
) + MAX_PLAYER_SUMMON_DELAY
;
1009 m_summon_mapid
= mapid
;
1014 void SummonIfPossible(bool agree
);
1016 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
);
1018 void Update( uint32 time
);
1020 static bool BuildEnumData( QueryResult
* result
, WorldPacket
* p_data
);
1022 void SetInWater(bool apply
);
1024 bool IsInWater() const { return m_isInWater
; }
1025 bool IsUnderWater() const;
1027 void SendInitialPacketsBeforeAddToMap();
1028 void SendInitialPacketsAfterAddToMap();
1029 void SendTransferAborted(uint32 mapid
, uint8 reason
, uint8 arg
= 0);
1030 void SendInstanceResetWarning(uint32 mapid
, uint32 difficulty
, uint32 time
);
1032 Creature
* GetNPCIfCanInteractWith(uint64 guid
, uint32 npcflagmask
);
1033 bool CanInteractWithNPCs(bool alive
= true) const;
1034 GameObject
* GetGameObjectIfCanInteractWith(uint64 guid
, GameobjectTypes type
) const;
1038 bool isAFK() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_AFK
); };
1039 bool isDND() const { return HasFlag(PLAYER_FLAGS
,PLAYER_FLAGS_DND
); };
1040 uint8
chatTag() const;
1044 uint32
GetBarberShopCost(uint8 newhairstyle
, uint8 newhaircolor
, uint8 newfacialhair
);
1046 PlayerSocial
*GetSocial() { return m_social
; }
1049 void InitTaxiNodesForLevel() { m_taxi
.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1050 bool ActivateTaxiPathTo(std::vector
<uint32
> const& nodes
, Creature
* npc
= NULL
, uint32 spellid
= 0);
1051 bool ActivateTaxiPathTo(uint32 taxi_path_id
, uint32 spellid
= 0);
1052 // mount_id can be used in scripting calls
1053 void ContinueTaxiFlight();
1054 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_ACCEPT_TICKETS
); }
1055 void SetAcceptTicket(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_ACCEPT_TICKETS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS
; }
1056 bool isAcceptWhispers() const { return m_ExtraFlags
& PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1057 void SetAcceptWhispers(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_ACCEPT_WHISPERS
; else m_ExtraFlags
&= ~PLAYER_EXTRA_ACCEPT_WHISPERS
; }
1058 bool isGameMaster() const { return m_ExtraFlags
& PLAYER_EXTRA_GM_ON
; }
1059 void SetGameMaster(bool on
);
1060 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR
&& (m_ExtraFlags
& PLAYER_EXTRA_GM_CHAT
); }
1061 void SetGMChat(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_GM_CHAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_GM_CHAT
; }
1062 bool isTaxiCheater() const { return m_ExtraFlags
& PLAYER_EXTRA_TAXICHEAT
; }
1063 void SetTaxiCheater(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_TAXICHEAT
; else m_ExtraFlags
&= ~PLAYER_EXTRA_TAXICHEAT
; }
1064 bool isGMVisible() const { return !(m_ExtraFlags
& PLAYER_EXTRA_GM_INVISIBLE
); }
1065 void SetGMVisible(bool on
);
1066 void SetPvPDeath(bool on
) { if(on
) m_ExtraFlags
|= PLAYER_EXTRA_PVP_DEATH
; else m_ExtraFlags
&= ~PLAYER_EXTRA_PVP_DEATH
; }
1068 void GiveXP(uint32 xp
, Unit
* victim
);
1069 void GiveLevel(uint32 level
);
1071 void InitStatsForLevel(bool reapplyMods
= false);
1073 // Played Time Stuff
1076 uint32 m_Played_time
[MAX_PLAYED_TIME_INDEX
];
1077 uint32
GetTotalPlayedTime() { return m_Played_time
[PLAYED_TIME_TOTAL
]; };
1078 uint32
GetLevelPlayedTime() { return m_Played_time
[PLAYED_TIME_LEVEL
]; };
1080 void setDeathState(DeathState s
); // overwrite Unit::setDeathState
1082 void InnEnter (int time
,uint32 mapid
, float x
,float y
,float z
)
1084 inn_pos_mapid
= mapid
;
1088 time_inn_enter
= time
;
1091 float GetRestBonus() const { return m_rest_bonus
; };
1092 void SetRestBonus(float rest_bonus_new
);
1094 RestType
GetRestType() const { return rest_type
; };
1095 void SetRestType(RestType n_r_type
) { rest_type
= n_r_type
; };
1097 uint32
GetInnPosMapId() const { return inn_pos_mapid
; };
1098 float GetInnPosX() const { return inn_pos_x
; };
1099 float GetInnPosY() const { return inn_pos_y
; };
1100 float GetInnPosZ() const { return inn_pos_z
; };
1102 int GetTimeInnEnter() const { return time_inn_enter
; };
1103 void UpdateInnerTime (int time
) { time_inn_enter
= time
; };
1105 void RemovePet(Pet
* pet
, PetSaveMode mode
, bool returnreagent
= false);
1106 void RemoveMiniPet();
1108 void SetMiniPet(Pet
* pet
) { m_miniPet
= pet
->GetGUID(); }
1110 uint32
GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
1112 void Say(const std::string
& text
, const uint32 language
);
1113 void Yell(const std::string
& text
, const uint32 language
);
1114 void TextEmote(const std::string
& text
);
1115 void Whisper(const std::string
& text
, const uint32 language
,uint64 receiver
);
1116 void BuildPlayerChat(WorldPacket
*data
, uint8 msgtype
, const std::string
& text
, uint32 language
) const;
1118 /*********************************************************/
1119 /*** STORAGE SYSTEM ***/
1120 /*********************************************************/
1122 void SetVirtualItemSlot( uint8 i
, Item
* item
);
1123 void SetSheath( SheathState sheathed
); // overwrite Unit version
1124 uint8
FindEquipSlot( ItemPrototype
const* proto
, uint32 slot
, bool swap
) const;
1125 uint32
GetItemCount( uint32 item
, bool inBankAlso
= false, Item
* skipItem
= NULL
) const;
1126 Item
* GetItemByGuid( uint64 guid
) const;
1127 Item
* GetItemByPos( uint16 pos
) const;
1128 Item
* GetItemByPos( uint8 bag
, uint8 slot
) const;
1129 Item
* GetWeaponForAttack(WeaponAttackType attackType
, bool useable
= false) const;
1130 Item
* GetShield(bool useable
= false) const;
1131 static uint32
GetAttackBySlot( uint8 slot
); // MAX_ATTACK if not weapon slot
1132 std::vector
<Item
*> &GetItemUpdateQueue() { return m_itemUpdateQueue
; }
1133 static bool IsInventoryPos( uint16 pos
) { return IsInventoryPos(pos
>> 8,pos
& 255); }
1134 static bool IsInventoryPos( uint8 bag
, uint8 slot
);
1135 static bool IsEquipmentPos( uint16 pos
) { return IsEquipmentPos(pos
>> 8,pos
& 255); }
1136 static bool IsEquipmentPos( uint8 bag
, uint8 slot
);
1137 static bool IsBagPos( uint16 pos
);
1138 static bool IsBankPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1139 static bool IsBankPos( uint8 bag
, uint8 slot
);
1140 bool IsValidPos( uint16 pos
) { return IsBankPos(pos
>> 8,pos
& 255); }
1141 bool IsValidPos( uint8 bag
, uint8 slot
);
1142 uint8
GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2
, 2); }
1143 void SetBankBagSlotCount(uint8 count
) { SetByteValue(PLAYER_BYTES_2
, 2, count
); }
1144 bool HasItemCount( uint32 item
, uint32 count
, bool inBankAlso
= false ) const;
1145 bool HasItemFitToSpellReqirements(SpellEntry
const* spellInfo
, Item
const* ignoreItem
= NULL
);
1146 bool CanNoReagentCast(SpellEntry
const* spellInfo
) const;
1147 bool HasItemOrGemWithIdEquipped( uint32 item
, uint32 count
, uint8 except_slot
= NULL_SLOT
) const;
1148 bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory
, uint32 count
, uint8 except_slot
= NULL_SLOT
) const;
1149 uint8
CanTakeMoreSimilarItems(Item
* pItem
) const { return _CanTakeMoreSimilarItems(pItem
->GetEntry(),pItem
->GetCount(),pItem
); }
1150 uint8
CanTakeMoreSimilarItems(uint32 entry
, uint32 count
) const { return _CanTakeMoreSimilarItems(entry
,count
,NULL
); }
1151 uint8
CanStoreNewItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 item
, uint32 count
, uint32
* no_space_count
= NULL
) const
1153 return _CanStoreItem(bag
, slot
, dest
, item
, count
, NULL
, false, no_space_count
);
1155 uint8
CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
= false ) const
1158 return EQUIP_ERR_ITEM_NOT_FOUND
;
1159 uint32 count
= pItem
->GetCount();
1160 return _CanStoreItem( bag
, slot
, dest
, pItem
->GetEntry(), count
, pItem
, swap
, NULL
);
1163 uint8
CanStoreItems( Item
**pItem
,int count
) const;
1164 uint8
CanEquipNewItem( uint8 slot
, uint16
&dest
, uint32 item
, bool swap
) const;
1165 uint8
CanEquipItem( uint8 slot
, uint16
&dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1167 uint8
CanEquipUniqueItem( Item
* pItem
, uint8 except_slot
= NULL_SLOT
, uint32 limit_count
= 1 ) const;
1168 uint8
CanEquipUniqueItem( ItemPrototype
const* itemProto
, uint8 except_slot
= NULL_SLOT
, uint32 limit_count
= 1 ) const;
1169 uint8
CanUnequipItems( uint32 item
, uint32 count
) const;
1170 uint8
CanUnequipItem( uint16 src
, bool swap
) const;
1171 uint8
CanBankItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, Item
*pItem
, bool swap
, bool not_loading
= true ) const;
1172 uint8
CanUseItem( Item
*pItem
, bool not_loading
= true ) const;
1173 bool HasItemTotemCategory( uint32 TotemCategory
) const;
1174 bool CanUseItem( ItemPrototype
const *pItem
);
1175 uint8
CanUseAmmo( uint32 item
) const;
1176 Item
* StoreNewItem( ItemPosCountVec
const& pos
, uint32 item
, bool update
,int32 randomPropertyId
= 0 );
1177 Item
* StoreItem( ItemPosCountVec
const& pos
, Item
*pItem
, bool update
);
1178 Item
* EquipNewItem( uint16 pos
, uint32 item
, bool update
);
1179 Item
* EquipItem( uint16 pos
, Item
*pItem
, bool update
);
1180 void AutoUnequipOffhandIfNeed();
1181 bool StoreNewItemInBestSlots(uint32 item_id
, uint32 item_count
);
1182 void AutoStoreLoot(uint8 bag
, uint8 slot
, uint32 loot_id
, LootStore
const& store
, bool broadcast
= false);
1183 void AutoStoreLoot(uint32 loot_id
, LootStore
const& store
, bool broadcast
= false) { AutoStoreLoot(NULL_BAG
,NULL_SLOT
,loot_id
,store
,broadcast
); }
1185 uint8
_CanTakeMoreSimilarItems(uint32 entry
, uint32 count
, Item
* pItem
, uint32
* no_space_count
= NULL
) const;
1186 uint8
_CanStoreItem( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, uint32 entry
, uint32 count
, Item
*pItem
= NULL
, bool swap
= false, uint32
* no_space_count
= NULL
) const;
1188 void ApplyEquipCooldown( Item
* pItem
);
1189 void SetAmmo( uint32 item
);
1191 float GetAmmoDPS() const { return m_ammoDPS
; }
1192 bool CheckAmmoCompatibility(const ItemPrototype
*ammo_proto
) const;
1193 void QuickEquipItem( uint16 pos
, Item
*pItem
);
1194 void VisualizeItem( uint8 slot
, Item
*pItem
);
1195 void SetVisibleItemSlot(uint8 slot
, Item
*pItem
);
1196 Item
* BankItem( ItemPosCountVec
const& dest
, Item
*pItem
, bool update
)
1198 return StoreItem( dest
, pItem
, update
);
1200 Item
* BankItem( uint16 pos
, Item
*pItem
, bool update
);
1201 void RemoveItem( uint8 bag
, uint8 slot
, bool update
);
1202 void MoveItemFromInventory(uint8 bag
, uint8 slot
, bool update
);
1203 // in trade, auction, guild bank, mail....
1204 void MoveItemToInventory(ItemPosCountVec
const& dest
, Item
* pItem
, bool update
, bool in_characterInventoryDB
= false);
1205 // in trade, guild bank, mail....
1206 void RemoveItemDependentAurasAndCasts( Item
* pItem
);
1207 void DestroyItem( uint8 bag
, uint8 slot
, bool update
);
1208 void DestroyItemCount( uint32 item
, uint32 count
, bool update
, bool unequip_check
= false);
1209 void DestroyItemCount( Item
* item
, uint32
& count
, bool update
);
1210 void DestroyConjuredItems( bool update
);
1211 void DestroyZoneLimitedItem( bool update
, uint32 new_zone
);
1212 void SplitItem( uint16 src
, uint16 dst
, uint32 count
);
1213 void SwapItem( uint16 src
, uint16 dst
);
1214 void AddItemToBuyBackSlot( Item
*pItem
);
1215 Item
* GetItemFromBuyBackSlot( uint32 slot
);
1216 void RemoveItemFromBuyBackSlot( uint32 slot
, bool del
);
1217 uint32
GetMaxKeyringSize() const { return KEYRING_SLOT_END
-KEYRING_SLOT_START
; }
1218 void SendEquipError( uint8 msg
, Item
* pItem
, Item
*pItem2
);
1219 void SendBuyError( uint8 msg
, Creature
* pCreature
, uint32 item
, uint32 param
);
1220 void SendSellError( uint8 msg
, Creature
* pCreature
, uint64 guid
, uint32 param
);
1221 void AddWeaponProficiency(uint32 newflag
) { m_WeaponProficiency
|= newflag
; }
1222 void AddArmorProficiency(uint32 newflag
) { m_ArmorProficiency
|= newflag
; }
1223 uint32
GetWeaponProficiency() const { return m_WeaponProficiency
; }
1224 uint32
GetArmorProficiency() const { return m_ArmorProficiency
; }
1225 bool IsUseEquipedWeapon( bool mainhand
) const
1227 // disarm applied only to mainhand weapon
1228 return !IsInFeralForm() && (!mainhand
|| !HasFlag(UNIT_FIELD_FLAGS
,UNIT_FLAG_DISARMED
) );
1230 bool IsTwoHandUsed() const
1232 Item
* mainItem
= GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_MAINHAND
);
1233 return mainItem
&& mainItem
->GetProto()->InventoryType
== INVTYPE_2HWEAPON
&& !CanTitanGrip();
1235 void SendNewItem( Item
*item
, uint32 count
, bool received
, bool created
, bool broadcast
= false );
1236 bool BuyItemFromVendor(uint64 vendorguid
, uint32 item
, uint8 count
, uint8 bag
, uint8 slot
);
1238 float GetReputationPriceDiscount( Creature
const* pCreature
) const;
1239 Player
* GetTrader() const { return pTrader
; }
1241 void TradeCancel(bool sendback
);
1242 uint16
GetItemPosByTradeSlot(uint32 slot
) const { return tradeItems
[slot
]; }
1244 void UpdateEnchantTime(uint32 time
);
1245 void UpdateItemDuration(uint32 time
, bool realtimeonly
=false);
1246 void AddEnchantmentDurations(Item
*item
);
1247 void RemoveEnchantmentDurations(Item
*item
);
1248 void RemoveAllEnchantments(EnchantmentSlot slot
);
1249 void AddEnchantmentDuration(Item
*item
,EnchantmentSlot slot
,uint32 duration
);
1250 void ApplyEnchantment(Item
*item
,EnchantmentSlot slot
,bool apply
, bool apply_dur
= true, bool ignore_condition
= false);
1251 void ApplyEnchantment(Item
*item
,bool apply
);
1252 void SendEnchantmentDurations();
1253 void BuildEnchantmentsInfoData(WorldPacket
*data
);
1254 void AddItemDurations(Item
*item
);
1255 void RemoveItemDurations(Item
*item
);
1256 void SendItemDurations();
1260 uint32 m_stableSlots
;
1262 /*********************************************************/
1263 /*** QUEST SYSTEM ***/
1264 /*********************************************************/
1266 uint32
GetQuestLevel( Quest
const* pQuest
) const { return pQuest
&& pQuest
->GetQuestLevel() ? pQuest
->GetQuestLevel() : getLevel(); }
1268 void PrepareQuestMenu( uint64 guid
);
1269 void SendPreparedQuest( uint64 guid
);
1270 bool IsActiveQuest( uint32 quest_id
) const;
1271 Quest
const *GetNextQuest( uint64 guid
, Quest
const *pQuest
);
1272 bool CanSeeStartQuest( Quest
const *pQuest
);
1273 bool CanTakeQuest( Quest
const *pQuest
, bool msg
);
1274 bool CanAddQuest( Quest
const *pQuest
, bool msg
);
1275 bool CanCompleteQuest( uint32 quest_id
);
1276 bool CanCompleteRepeatableQuest(Quest
const *pQuest
);
1277 bool CanRewardQuest( Quest
const *pQuest
, bool msg
);
1278 bool CanRewardQuest( Quest
const *pQuest
, uint32 reward
, bool msg
);
1279 void AddQuest( Quest
const *pQuest
, Object
*questGiver
);
1280 void CompleteQuest( uint32 quest_id
);
1281 void IncompleteQuest( uint32 quest_id
);
1282 void RewardQuest( Quest
const *pQuest
, uint32 reward
, Object
* questGiver
, bool announce
= true );
1283 void FailQuest( uint32 quest_id
);
1284 bool SatisfyQuestSkillOrClass( Quest
const* qInfo
, bool msg
);
1285 bool SatisfyQuestLevel( Quest
const* qInfo
, bool msg
);
1286 bool SatisfyQuestLog( bool msg
);
1287 bool SatisfyQuestPreviousQuest( Quest
const* qInfo
, bool msg
);
1288 bool SatisfyQuestRace( Quest
const* qInfo
, bool msg
);
1289 bool SatisfyQuestReputation( Quest
const* qInfo
, bool msg
);
1290 bool SatisfyQuestStatus( Quest
const* qInfo
, bool msg
);
1291 bool SatisfyQuestTimed( Quest
const* qInfo
, bool msg
);
1292 bool SatisfyQuestExclusiveGroup( Quest
const* qInfo
, bool msg
);
1293 bool SatisfyQuestNextChain( Quest
const* qInfo
, bool msg
);
1294 bool SatisfyQuestPrevChain( Quest
const* qInfo
, bool msg
);
1295 bool SatisfyQuestDay( Quest
const* qInfo
, bool msg
);
1296 bool GiveQuestSourceItem( Quest
const *pQuest
);
1297 bool TakeQuestSourceItem( uint32 quest_id
, bool msg
);
1298 bool GetQuestRewardStatus( uint32 quest_id
) const;
1299 QuestStatus
GetQuestStatus( uint32 quest_id
) const;
1300 void SetQuestStatus( uint32 quest_id
, QuestStatus status
);
1302 void SetDailyQuestStatus( uint32 quest_id
);
1303 void ResetDailyQuestStatus();
1305 uint16
FindQuestSlot( uint32 quest_id
) const;
1306 uint32
GetQuestSlotQuestId(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
); }
1307 uint32
GetQuestSlotState(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
); }
1308 uint32
GetQuestSlotCounters(uint16 slot
)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
); }
1309 uint8
GetQuestSlotCounter(uint16 slot
,uint8 counter
) const { return GetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
); }
1310 uint32
GetQuestSlotTime(uint16 slot
) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
); }
1311 void SetQuestSlot(uint16 slot
,uint32 quest_id
, uint32 timer
= 0)
1313 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_ID_OFFSET
,quest_id
);
1314 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,0);
1315 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,0);
1316 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
);
1318 void SetQuestSlotCounter(uint16 slot
,uint8 counter
,uint8 count
) { SetByteValue(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_COUNTS_OFFSET
,counter
,count
); }
1319 void SetQuestSlotState(uint16 slot
,uint32 state
) { SetFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1320 void RemoveQuestSlotState(uint16 slot
,uint32 state
) { RemoveFlag(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_STATE_OFFSET
,state
); }
1321 void SetQuestSlotTimer(uint16 slot
,uint32 timer
) { SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ slot
*MAX_QUEST_OFFSET
+ QUEST_TIME_OFFSET
,timer
); }
1322 void SwapQuestSlot(uint16 slot1
,uint16 slot2
)
1324 for (int i
= 0; i
< MAX_QUEST_OFFSET
; ++i
)
1326 uint32 temp1
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
);
1327 uint32 temp2
= GetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
);
1329 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot1
+ i
, temp2
);
1330 SetUInt32Value(PLAYER_QUEST_LOG_1_1
+ MAX_QUEST_OFFSET
*slot2
+ i
, temp1
);
1333 uint32
GetReqKillOrCastCurrentCount(uint32 quest_id
, int32 entry
);
1334 void AreaExploredOrEventHappens( uint32 questId
);
1335 void GroupEventHappens( uint32 questId
, WorldObject
const* pEventObject
);
1336 void ItemAddedQuestCheck( uint32 entry
, uint32 count
);
1337 void ItemRemovedQuestCheck( uint32 entry
, uint32 count
);
1338 void KilledMonster( CreatureInfo
const* cInfo
, uint64 guid
);
1339 void KilledMonsterCredit( uint32 entry
, uint64 guid
);
1340 void CastedCreatureOrGO( uint32 entry
, uint64 guid
, uint32 spell_id
);
1341 void TalkedToCreature( uint32 entry
, uint64 guid
);
1342 void MoneyChanged( uint32 value
);
1343 void ReputationChanged(FactionEntry
const* factionEntry
);
1344 bool HasQuestForItem( uint32 itemid
) const;
1345 bool HasQuestForGO(int32 GOId
) const;
1346 void UpdateForQuestWorldObjects();
1347 bool CanShareQuest(uint32 quest_id
) const;
1349 void SendQuestComplete( uint32 quest_id
);
1350 void SendQuestReward( Quest
const *pQuest
, uint32 XP
, Object
* questGiver
);
1351 void SendQuestFailed( uint32 quest_id
);
1352 void SendQuestTimerFailed( uint32 quest_id
);
1353 void SendCanTakeQuestResponse( uint32 msg
);
1354 void SendPushToPartyResponse( Player
*pPlayer
, uint32 msg
);
1355 void SendQuestUpdateAddItem( Quest
const* pQuest
, uint32 item_idx
, uint32 count
);
1356 void SendQuestUpdateAddCreatureOrGo( Quest
const* pQuest
, uint64 guid
, uint32 creatureOrGO_idx
, uint32 old_count
, uint32 add_count
);
1358 uint64
GetDivider() { return m_divider
; };
1359 void SetDivider( uint64 guid
) { m_divider
= guid
; };
1361 uint32
GetInGameTime() { return m_ingametime
; };
1363 void SetInGameTime( uint32 time
) { m_ingametime
= time
; };
1365 void AddTimedQuest( uint32 quest_id
) { m_timedquests
.insert(quest_id
); }
1367 /*********************************************************/
1368 /*** LOAD SYSTEM ***/
1369 /*********************************************************/
1371 bool LoadFromDB(uint32 guid
, SqlQueryHolder
*holder
);
1373 static bool LoadValuesArrayFromDB(Tokens
& data
,uint64 guid
);
1374 static uint32
GetUInt32ValueFromArray(Tokens
const& data
, uint16 index
);
1375 static float GetFloatValueFromArray(Tokens
const& data
, uint16 index
);
1376 static uint32
GetUInt32ValueFromDB(uint16 index
, uint64 guid
);
1377 static float GetFloatValueFromDB(uint16 index
, uint64 guid
);
1378 static uint32
GetZoneIdFromDB(uint64 guid
);
1379 static uint32
GetLevelFromDB(uint64 guid
);
1380 static bool LoadPositionFromDB(uint32
& mapid
, float& x
,float& y
,float& z
,float& o
, bool& in_flight
, uint64 guid
);
1382 /*********************************************************/
1383 /*** SAVE SYSTEM ***/
1384 /*********************************************************/
1387 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1388 void SaveGoldToDB();
1389 void SaveDataFieldToDB();
1390 static bool SaveValuesArrayInDB(Tokens
const& data
,uint64 guid
);
1391 static void SetUInt32ValueInArray(Tokens
& data
,uint16 index
, uint32 value
);
1392 static void SetFloatValueInArray(Tokens
& data
,uint16 index
, float value
);
1393 static void SetUInt32ValueInDB(uint16 index
, uint32 value
, uint64 guid
);
1394 static void SetFloatValueInDB(uint16 index
, float value
, uint64 guid
);
1395 static void Customize(uint64 guid
, uint8 gender
, uint8 skin
, uint8 face
, uint8 hairStyle
, uint8 hairColor
, uint8 facialHair
);
1396 static void SavePositionInDB(uint32 mapid
, float x
,float y
,float z
,float o
,uint32 zone
,uint64 guid
);
1399 bool m_mailsUpdated
;
1401 void SetBindPoint(uint64 guid
);
1402 void SendTalentWipeConfirm(uint64 guid
);
1403 void RewardRage( uint32 damage
, uint32 weaponSpeedHitFactor
, bool attacker
);
1404 void SendPetSkillWipeConfirm();
1405 void CalcRage( uint32 damage
,bool attacker
);
1406 void RegenerateAll();
1407 void Regenerate(Powers power
);
1408 void RegenerateHealth();
1409 void setRegenTimer(uint32 time
) {m_regenTimer
= time
;}
1410 void setWeaponChangeTimer(uint32 time
) {m_weaponChangeTimer
= time
;}
1412 uint32
GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE
); }
1413 void ModifyMoney( int32 d
)
1416 SetMoney (GetMoney() > uint32(-d
) ? GetMoney() + d
: 0);
1418 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT
- d
) ? GetMoney() + d
: MAX_MONEY_AMOUNT
);
1421 if(GetMoney() >= MAX_MONEY_AMOUNT
)
1422 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD
,NULL
,NULL
);
1424 void SetMoney( uint32 value
)
1426 SetUInt32Value (PLAYER_FIELD_COINAGE
, value
);
1427 MoneyChanged( value
);
1428 UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED
);
1431 QuestStatusMap
& getQuestStatusMap() { return mQuestStatus
; };
1433 const uint64
& GetSelection( ) const { return m_curSelection
; }
1434 void SetSelection(const uint64
&guid
) { m_curSelection
= guid
; SetUInt64Value(UNIT_FIELD_TARGET
, guid
); }
1436 uint8
GetComboPoints() { return m_comboPoints
; }
1437 const uint64
& GetComboTarget() const { return m_comboTarget
; }
1439 void AddComboPoints(Unit
* target
, int8 count
);
1440 void ClearComboPoints();
1441 void SendComboPoints();
1443 void SendMailResult(uint32 mailId
, MailResponseType mailAction
, MailResponseResult mailError
, uint32 equipError
= 0, uint32 item_guid
= 0, uint32 item_count
= 0);
1445 void UpdateNextMailTimeAndUnreads();
1446 void AddNewMailDeliverTime(time_t deliver_time
);
1447 bool IsMailsLoaded() const { return m_mailsLoaded
; }
1449 //void SetMail(Mail *m);
1450 void RemoveMail(uint32 id
);
1452 void AddMail(Mail
* mail
) { m_mail
.push_front(mail
);}// for call from WorldSession::SendMailTo
1453 uint32
GetMailSize() { return m_mail
.size();};
1454 Mail
* GetMail(uint32 id
);
1456 PlayerMails::iterator
GetmailBegin() { return m_mail
.begin();};
1457 PlayerMails::iterator
GetmailEnd() { return m_mail
.end();};
1459 /*********************************************************/
1460 /*** MAILED ITEMS SYSTEM ***/
1461 /*********************************************************/
1464 time_t m_nextMailDelivereTime
;
1466 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
1468 ItemMap mMitems
; //template defined in objectmgr.cpp
1470 Item
* GetMItem(uint32 id
)
1472 ItemMap::const_iterator itr
= mMitems
.find(id
);
1473 return itr
!= mMitems
.end() ? itr
->second
: NULL
;
1476 void AddMItem(Item
* it
)
1479 //assert deleted, because items can be added before loading
1480 mMitems
[it
->GetGUIDLow()] = it
;
1483 bool RemoveMItem(uint32 id
)
1485 return mMitems
.erase(id
) ? true : false;
1488 void PetSpellInitialize();
1489 void CharmSpellInitialize();
1490 void PossessSpellInitialize();
1491 void RemovePetActionBar();
1493 bool HasSpell(uint32 spell
) const;
1494 bool HasActiveSpell(uint32 spell
) const; // show in spellbook
1495 TrainerSpellState
GetTrainerSpellState(TrainerSpell
const* trainer_spell
) const;
1496 bool IsSpellFitByClassAndRace( uint32 spell_id
) const;
1497 bool IsNeedCastPassiveSpellAtLearn(SpellEntry
const* spellInfo
) const;
1499 void SendProficiency(uint8 pr1
, uint32 pr2
);
1500 void SendInitialSpells();
1501 bool addSpell(uint32 spell_id
, bool active
, bool learning
, bool dependent
, bool disabled
);
1502 void learnSpell(uint32 spell_id
, bool dependent
);
1503 void removeSpell(uint32 spell_id
, bool disabled
= false, bool learn_low_rank
= true);
1505 void learnDefaultSpells();
1506 void learnQuestRewardedSpells();
1507 void learnQuestRewardedSpells(Quest
const* quest
);
1508 void learnSpellHighRank(uint32 spellid
);
1510 uint32
GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1
); }
1511 void SetFreeTalentPoints(uint32 points
) { SetUInt32Value(PLAYER_CHARACTER_POINTS1
,points
); }
1512 bool resetTalents(bool no_cost
= false);
1513 uint32
resetTalentsCost() const;
1514 void InitTalentForLevel();
1515 void BuildPlayerTalentsInfoData(WorldPacket
*data
);
1516 void BuildPetTalentsInfoData(WorldPacket
*data
);
1517 void SendTalentsInfoData(bool pet
);
1518 void LearnTalent(uint32 talentId
, uint32 talentRank
);
1519 void LearnPetTalent(uint64 petGuid
, uint32 talentId
, uint32 talentRank
);
1521 uint32
CalculateTalentsPoints() const;
1524 uint32
GetActiveSpec() { return m_activeSpec
; }
1525 void SetActiveSpec(uint32 spec
) { m_activeSpec
= spec
; }
1526 uint32
GetSpecsCount() { return m_specsCount
; }
1527 void SetSpecsCount(uint32 count
) { m_specsCount
= count
; }
1528 void ActivateSpec(uint32 specNum
);
1530 void InitGlyphsForLevel();
1531 void SetGlyphSlot(uint8 slot
, uint32 slottype
) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
, slottype
); }
1532 uint32
GetGlyphSlot(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1
+ slot
); }
1533 void SetGlyph(uint8 slot
, uint32 glyph
) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
, glyph
); }
1534 uint32
GetGlyph(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1
+ slot
); }
1536 uint32
GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2
); }
1537 void SetFreePrimaryProfessions(uint16 profs
) { SetUInt32Value(PLAYER_CHARACTER_POINTS2
, profs
); }
1538 void InitPrimaryProfessions();
1540 PlayerSpellMap
const& GetSpellMap() const { return m_spells
; }
1541 PlayerSpellMap
& GetSpellMap() { return m_spells
; }
1543 SpellCooldowns
const& GetSpellCooldownMap() const { return m_spellCooldowns
; }
1545 void AddSpellMod(SpellModifier
* mod
, bool apply
);
1546 bool IsAffectedBySpellmod(SpellEntry
const *spellInfo
, SpellModifier
*mod
, Spell
const* spell
= NULL
);
1547 template <class T
> T
ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
= NULL
);
1548 void RemoveSpellMods(Spell
const* spell
);
1550 static uint32
const infinityCooldownDelay
= MONTH
; // used for set "infinity cooldowns" for spells and check
1551 static uint32
const infinityCooldownDelayCheck
= MONTH
/2;
1552 bool HasSpellCooldown(uint32 spell_id
) const
1554 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1555 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> time(NULL
);
1557 uint32
GetSpellCooldownDelay(uint32 spell_id
) const
1559 SpellCooldowns::const_iterator itr
= m_spellCooldowns
.find(spell_id
);
1560 time_t t
= time(NULL
);
1561 return itr
!= m_spellCooldowns
.end() && itr
->second
.end
> t
? itr
->second
.end
- t
: 0;
1563 void AddSpellAndCategoryCooldowns(SpellEntry
const* spellInfo
, uint32 itemId
, Spell
* spell
= NULL
, bool infinityCooldown
= false );
1564 void AddSpellCooldown(uint32 spell_id
, uint32 itemid
, time_t end_time
);
1565 void SendCooldownEvent(SpellEntry
const *spellInfo
, uint32 itemId
= 0, Spell
* spell
= NULL
);
1566 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask
, uint32 unTimeMs
);
1567 void RemoveSpellCooldown(uint32 spell_id
, bool update
= false);
1568 void RemoveSpellCategoryCooldown(uint32 cat
, bool update
= false);
1569 void SendClearCooldown( uint32 spell_id
, Unit
* target
);
1571 void RemoveArenaSpellCooldowns();
1572 void RemoveAllSpellCooldown();
1573 void _LoadSpellCooldowns(QueryResult
*result
);
1574 void _SaveSpellCooldowns();
1575 void SetLastPotionId(uint32 item_id
) { m_lastPotionId
= item_id
; }
1576 void UpdatePotionCooldown(Spell
* spell
= NULL
);
1578 void setResurrectRequestData(uint64 guid
, uint32 mapId
, float X
, float Y
, float Z
, uint32 health
, uint32 mana
)
1580 m_resurrectGUID
= guid
;
1581 m_resurrectMap
= mapId
;
1585 m_resurrectHealth
= health
;
1586 m_resurrectMana
= mana
;
1588 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f
,0.0f
,0.0f
,0,0); }
1589 bool isRessurectRequestedBy(uint64 guid
) const { return m_resurrectGUID
== guid
; }
1590 bool isRessurectRequested() const { return m_resurrectGUID
!= 0; }
1591 void ResurectUsingRequestData();
1597 void setCinematic(int cine
)
1602 ActionButton
* addActionButton(uint8 button
, uint32 action
, uint8 type
);
1603 void removeActionButton(uint8 button
);
1604 void SendInitialActionButtons() const;
1607 void UpdatePvP(bool state
, bool ovrride
=false);
1608 void UpdateZone(uint32 newZone
,uint32 newArea
);
1609 void UpdateArea(uint32 newArea
);
1611 void UpdateZoneDependentAuras( uint32 zone_id
); // zones
1612 void UpdateAreaDependentAuras( uint32 area_id
); // subzones
1614 void UpdateAfkReport(time_t currTime
);
1615 void UpdatePvPFlag(time_t currTime
);
1616 void UpdateContestedPvP(uint32 currTime
);
1617 void SetContestedPvPTimer(uint32 newTime
) {m_contestedPvPTimer
= newTime
;}
1618 void ResetContestedPvP()
1620 clearUnitState(UNIT_STAT_ATTACK_PLAYER
);
1621 RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_CONTESTED_PVP
);
1622 m_contestedPvPTimer
= 0;
1625 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1627 void UpdateDuelFlag(time_t currTime
);
1628 void CheckDuelDistance(time_t currTime
);
1629 void DuelComplete(DuelCompleteType type
);
1631 bool IsGroupVisibleFor(Player
* p
) const;
1632 bool IsInSameGroupWith(Player
const* p
) const;
1633 bool IsInSameRaidWith(Player
const* p
) const { return p
==this || (GetGroup() != NULL
&& GetGroup() == p
->GetGroup()); }
1634 void UninviteFromGroup();
1635 static void RemoveFromGroup(Group
* group
, uint64 guid
);
1636 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1637 void SendUpdateToOutOfRangeGroupMembers();
1639 void SetInGuild(uint32 GuildId
) { SetUInt32Value(PLAYER_GUILDID
, GuildId
); }
1640 void SetRank(uint32 rankId
){ SetUInt32Value(PLAYER_GUILDRANK
, rankId
); }
1641 void SetGuildIdInvited(uint32 GuildId
) { m_GuildIdInvited
= GuildId
; }
1642 uint32
GetGuildId() { return GetUInt32Value(PLAYER_GUILDID
); }
1643 static uint32
GetGuildIdFromDB(uint64 guid
);
1644 uint32
GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK
); }
1645 static uint32
GetRankFromDB(uint64 guid
);
1646 int GetGuildIdInvited() { return m_GuildIdInvited
; }
1647 static void RemovePetitionsAndSigns(uint64 guid
, uint32 type
);
1650 void SetInArenaTeam(uint32 ArenaTeamId
, uint8 slot
)
1652 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6), ArenaTeamId
);
1654 uint32
GetArenaTeamId(uint8 slot
) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
* 6)); }
1655 static uint32
GetArenaTeamIdFromDB(uint64 guid
, uint8 slot
);
1656 void SetArenaTeamIdInvited(uint32 ArenaTeamId
) { m_ArenaTeamIdInvited
= ArenaTeamId
; }
1657 uint32
GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited
; }
1658 static void LeaveAllArenaTeams(uint64 guid
);
1660 void SetDifficulty(uint32 dungeon_difficulty
) { m_dungeonDifficulty
= dungeon_difficulty
; }
1661 uint8
GetDifficulty() { return m_dungeonDifficulty
; }
1662 bool IsHeroic() { return m_dungeonDifficulty
== DIFFICULTY_HEROIC
; }
1664 bool UpdateSkill(uint32 skill_id
, uint32 step
);
1665 bool UpdateSkillPro(uint16 SkillId
, int32 Chance
, uint32 step
);
1667 bool UpdateCraftSkill(uint32 spellid
);
1668 bool UpdateGatherSkill(uint32 SkillId
, uint32 SkillValue
, uint32 RedLevel
, uint32 Multiplicator
= 1);
1669 bool UpdateFishingSkill();
1671 uint32
GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE
); }
1672 uint32
GetBaseWeaponSkillValue(WeaponAttackType attType
) const;
1674 uint32
GetSpellByProto(ItemPrototype
*proto
);
1676 float GetHealthBonusFromStamina();
1677 float GetManaBonusFromIntellect();
1679 bool UpdateStats(Stats stat
);
1680 bool UpdateAllStats();
1681 void UpdateResistances(uint32 school
);
1683 void UpdateMaxHealth();
1684 void UpdateMaxPower(Powers power
);
1685 void ApplyFeralAPBonus(int32 amount
, bool apply
);
1686 void UpdateAttackPowerAndDamage(bool ranged
= false);
1687 void UpdateShieldBlockValue();
1688 void UpdateDamagePhysical(WeaponAttackType attType
);
1689 void ApplySpellDamageBonus(int32 amount
, bool apply
);
1690 void ApplySpellHealingBonus(int32 amount
, bool apply
);
1691 void UpdateSpellDamageAndHealingBonus();
1693 void CalculateMinMaxDamage(WeaponAttackType attType
, bool normalized
, float& min_damage
, float& max_damage
);
1695 void UpdateDefenseBonusesMod();
1696 void ApplyRatingMod(CombatRating cr
, int32 value
, bool apply
);
1697 float GetMeleeCritFromAgility();
1698 float GetDodgeFromAgility();
1699 float GetSpellCritFromIntellect();
1700 float OCTRegenHPPerSpirit();
1701 float OCTRegenMPPerSpirit();
1702 float GetRatingCoefficient(CombatRating cr
) const;
1703 float GetRatingBonusValue(CombatRating cr
) const;
1704 uint32
GetMeleeCritDamageReduction(uint32 damage
) const;
1705 uint32
GetRangedCritDamageReduction(uint32 damage
) const;
1706 uint32
GetSpellCritDamageReduction(uint32 damage
) const;
1707 uint32
GetDotDamageReduction(uint32 damage
) const;
1708 uint32
GetBaseSpellDamageBonus() { return m_baseSpellDamage
;}
1709 uint32
GetBaseSpellHealingBonus() { return m_baseSpellHealing
;}
1711 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType
) const;
1712 void UpdateBlockPercentage();
1713 void UpdateCritPercentage(WeaponAttackType attType
);
1714 void UpdateAllCritPercentages();
1715 void UpdateParryPercentage();
1716 void UpdateDodgePercentage();
1717 void UpdateMeleeHitChances();
1718 void UpdateRangedHitChances();
1719 void UpdateSpellHitChances();
1721 void UpdateAllSpellCritChances();
1722 void UpdateSpellCritChance(uint32 school
);
1723 void UpdateExpertise(WeaponAttackType attType
);
1724 void ApplyManaRegenBonus(int32 amount
, bool apply
);
1725 void UpdateManaRegen();
1727 const uint64
& GetLootGUID() const { return m_lootGuid
; }
1728 void SetLootGUID(const uint64
&guid
) { m_lootGuid
= guid
; }
1730 void RemovedInsignia(Player
* looterPlr
);
1732 WorldSession
* GetSession() const { return m_session
; }
1733 void SetSession(WorldSession
*s
) { m_session
= s
; }
1735 void BuildCreateUpdateBlockForPlayer( UpdateData
*data
, Player
*target
) const;
1736 void DestroyForPlayer( Player
*target
, bool anim
= false ) const;
1737 void SendDelayResponse(const uint32
);
1738 void SendLogXPGain(uint32 GivenXP
,Unit
* victim
,uint32 RestXP
);
1741 void SendAttackSwingCantAttack();
1742 void SendAttackSwingCancelAttack();
1743 void SendAttackSwingDeadTarget();
1744 void SendAttackSwingNotInRange();
1745 void SendAttackSwingBadFacingAttack();
1746 void SendAutoRepeatCancel(Unit
*target
);
1747 void SendExplorationExperience(uint32 Area
, uint32 Experience
);
1749 void SendDungeonDifficulty(bool IsInGroup
);
1750 void ResetInstances(uint8 method
);
1751 void SendResetInstanceSuccess(uint32 MapId
);
1752 void SendResetInstanceFailed(uint32 reason
, uint32 MapId
);
1753 void SendResetFailedNotify(uint32 mapid
);
1755 bool SetPosition(float x
, float y
, float z
, float orientation
, bool teleport
= false);
1756 void UpdateUnderwaterState( Map
* m
, float x
, float y
, float z
);
1758 void SendMessageToSet(WorldPacket
*data
, bool self
);// overwrite Object::SendMessageToSet
1759 void SendMessageToSetInRange(WorldPacket
*data
, float fist
, bool self
);
1760 // overwrite Object::SendMessageToSetInRange
1761 void SendMessageToSetInRange(WorldPacket
*data
, float dist
, bool self
, bool own_team_only
);
1763 static void DeleteFromDB(uint64 playerguid
, uint32 accountId
, bool updateRealmChars
= true);
1765 Corpse
*GetCorpse() const;
1766 void SpawnCorpseBones();
1767 void CreateCorpse();
1769 uint32
GetResurrectionSpellId();
1770 void ResurrectPlayer(float restore_percent
, bool applySickness
= false);
1771 void BuildPlayerRepop();
1772 void RepopAtGraveyard();
1774 void DurabilityLossAll(double percent
, bool inventory
);
1775 void DurabilityLoss(Item
* item
, double percent
);
1776 void DurabilityPointsLossAll(int32 points
, bool inventory
);
1777 void DurabilityPointsLoss(Item
* item
, int32 points
);
1778 void DurabilityPointLossForEquipSlot(EquipmentSlots slot
);
1779 uint32
DurabilityRepairAll(bool cost
, float discountMod
, bool guildBank
);
1780 uint32
DurabilityRepair(uint16 pos
, bool cost
, float discountMod
, bool guildBank
);
1782 void UpdateMirrorTimers();
1783 void StopMirrorTimers()
1785 StopMirrorTimer(FATIGUE_TIMER
);
1786 StopMirrorTimer(BREATH_TIMER
);
1787 StopMirrorTimer(FIRE_TIMER
);
1790 void SetMovement(PlayerMovementType pType
);
1792 void JoinedChannel(Channel
*c
);
1793 void LeftChannel(Channel
*c
);
1794 void CleanupChannels();
1795 void UpdateLocalChannels( uint32 newZone
);
1796 void LeaveLFGChannel();
1798 void UpdateDefense();
1799 void UpdateWeaponSkill (WeaponAttackType attType
);
1800 void UpdateCombatSkills(Unit
*pVictim
, WeaponAttackType attType
, bool defence
);
1802 void SetSkill(uint32 id
, uint16 currVal
, uint16 maxVal
);
1803 uint16
GetMaxSkillValue(uint32 skill
) const; // max + perm. bonus + temp bonus
1804 uint16
GetPureMaxSkillValue(uint32 skill
) const; // max
1805 uint16
GetSkillValue(uint32 skill
) const; // skill value + perm. bonus + temp bonus
1806 uint16
GetBaseSkillValue(uint32 skill
) const; // skill value + perm. bonus
1807 uint16
GetPureSkillValue(uint32 skill
) const; // skill value
1808 int16
GetSkillPermBonusValue(uint32 skill
) const;
1809 int16
GetSkillTempBonusValue(uint32 skill
) const;
1810 bool HasSkill(uint32 skill
) const;
1811 void learnSkillRewardedSpells(uint32 id
, uint32 value
);
1813 WorldLocation
& GetTeleportDest() { return m_teleport_dest
; }
1814 bool IsBeingTeleported() const { return mSemaphoreTeleport_Near
|| mSemaphoreTeleport_Far
; }
1815 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near
; }
1816 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far
; }
1817 void SetSemaphoreTeleportNear(bool semphsetting
) { mSemaphoreTeleport_Near
= semphsetting
; }
1818 void SetSemaphoreTeleportFar(bool semphsetting
) { mSemaphoreTeleport_Far
= semphsetting
; }
1819 void ProcessDelayedOperations();
1821 void CheckExploreSystem(void);
1823 static uint32
TeamForRace(uint8 race
);
1824 uint32
GetTeam() const { return m_team
; }
1825 static uint32
getFactionForRace(uint8 race
);
1826 void setFactionForRace(uint8 race
);
1828 void InitDisplayIds();
1830 bool IsAtGroupRewardDistance(WorldObject
const* pRewardSource
) const;
1831 bool RewardPlayerAndGroupAtKill(Unit
* pVictim
);
1832 void RewardPlayerAndGroupAtEvent(uint32 creature_id
,WorldObject
* pRewardSource
);
1833 bool isHonorOrXPTarget(Unit
* pVictim
);
1835 ReputationMgr
& GetReputationMgr() { return m_reputationMgr
; }
1836 ReputationMgr
const& GetReputationMgr() const { return m_reputationMgr
; }
1837 ReputationRank
GetReputationRank(uint32 faction_id
) const;
1838 void RewardReputation(Unit
*pVictim
, float rate
);
1839 void RewardReputation(Quest
const *pQuest
);
1841 void UpdateSkillsForLevel();
1842 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1843 void ModifySkillBonus(uint32 skillid
,int32 val
, bool talent
);
1845 /*********************************************************/
1846 /*** PVP SYSTEM ***/
1847 /*********************************************************/
1848 void UpdateArenaFields();
1849 void UpdateHonorFields();
1850 bool RewardHonor(Unit
*pVictim
, uint32 groupsize
, float honor
= -1);
1851 uint32
GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
); }
1852 uint32
GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY
); }
1853 void ModifyHonorPoints( int32 value
);
1854 void ModifyArenaPoints( int32 value
);
1855 uint32
GetMaxPersonalArenaRatingRequirement();
1859 void SetDrunkValue(uint16 newDrunkValue
, uint32 itemid
=0);
1860 uint16
GetDrunkValue() const { return m_drunk
; }
1861 static DrunkenState
GetDrunkenstateByValue(uint16 value
);
1863 uint32
GetDeathTimer() const { return m_deathTimer
; }
1864 uint32
GetCorpseReclaimDelay(bool pvp
) const;
1865 void UpdateCorpseReclaimDelay();
1866 void SendCorpseReclaimDelay(bool load
= false);
1868 uint32
GetShieldBlockValue() const; // overwrite Unit version (virtual)
1869 bool CanParry() const { return m_canParry
; }
1870 void SetCanParry(bool value
);
1871 bool CanBlock() const { return m_canBlock
; }
1872 void SetCanBlock(bool value
);
1873 bool CanDualWield() const { return m_canDualWield
; }
1874 void SetCanDualWield(bool value
) { m_canDualWield
= value
; }
1875 bool CanTitanGrip() const { return m_canTitanGrip
; }
1876 void SetCanTitanGrip(bool value
) { m_canTitanGrip
= value
; }
1877 bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE
); }
1879 void SetRegularAttackTime();
1880 void SetBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float value
) { m_auraBaseMod
[modGroup
][modType
] = value
; }
1881 void HandleBaseModValue(BaseModGroup modGroup
, BaseModType modType
, float amount
, bool apply
);
1882 float GetBaseModValue(BaseModGroup modGroup
, BaseModType modType
) const;
1883 float GetTotalBaseModValue(BaseModGroup modGroup
) const;
1884 float GetTotalPercentageModValue(BaseModGroup modGroup
) const { return m_auraBaseMod
[modGroup
][FLAT_MOD
] + m_auraBaseMod
[modGroup
][PCT_MOD
]; }
1885 void _ApplyAllStatBonuses();
1886 void _RemoveAllStatBonuses();
1888 void _ApplyWeaponDependentAuraMods(Item
*item
, WeaponAttackType attackType
, bool apply
);
1889 void _ApplyWeaponDependentAuraCritMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1890 void _ApplyWeaponDependentAuraDamageMod(Item
*item
, WeaponAttackType attackType
, Aura
* aura
, bool apply
);
1892 void _ApplyItemMods(Item
*item
,uint8 slot
,bool apply
);
1893 void _RemoveAllItemMods();
1894 void _ApplyAllItemMods();
1895 void _ApplyAllLevelScaleItemMods(bool apply
);
1896 void _ApplyItemBonuses(ItemPrototype
const *proto
,uint8 slot
,bool apply
, bool only_level_scale
= false);
1897 void _ApplyAmmoBonuses();
1898 bool EnchantmentFitsRequirements(uint32 enchantmentcondition
, int8 slot
);
1899 void ToggleMetaGemsActive(uint8 exceptslot
, bool apply
);
1900 void CorrectMetaGemEnchants(uint8 slot
, bool apply
);
1901 void InitDataForForm(bool reapplyMods
= false);
1903 void ApplyItemEquipSpell(Item
*item
, bool apply
, bool form_change
= false);
1904 void ApplyEquipSpell(SpellEntry
const* spellInfo
, Item
* item
, bool apply
, bool form_change
= false);
1905 void UpdateEquipSpellsAtFormChange();
1906 void CastItemCombatSpell(Unit
* Target
, WeaponAttackType attType
);
1907 void CastItemUseSpell(Item
*item
,SpellCastTargets
const& targets
,uint8 cast_count
, uint32 glyphIndex
);
1909 void SendEquipmentSetList();
1910 void SetEquipmentSet(uint32 index
, EquipmentSet eqset
);
1911 void DeleteEquipmentSet(uint64 setGuid
);
1913 void SendInitWorldStates(uint32 zone
, uint32 area
);
1914 void SendUpdateWorldState(uint32 Field
, uint32 Value
);
1915 void SendDirectMessage(WorldPacket
*data
);
1917 void SendAurasForTarget(Unit
*target
);
1919 PlayerMenu
* PlayerTalkClass
;
1920 std::vector
<ItemSetEffect
*> ItemSetEff
;
1922 void SendLoot(uint64 guid
, LootType loot_type
);
1923 void SendLootRelease( uint64 guid
);
1924 void SendNotifyLootItemRemoved(uint8 lootSlot
);
1925 void SendNotifyLootMoneyRemoved();
1927 /*********************************************************/
1928 /*** BATTLEGROUND SYSTEM ***/
1929 /*********************************************************/
1931 bool InBattleGround() const { return m_bgData
.bgInstanceID
!= 0; }
1932 bool InArena() const;
1933 uint32
GetBattleGroundId() const { return m_bgData
.bgInstanceID
; }
1934 BattleGroundTypeId
GetBattleGroundTypeId() const { return m_bgData
.bgTypeID
; }
1935 BattleGround
* GetBattleGround() const;
1938 BGQueueIdBasedOnLevel
GetBattleGroundQueueIdFromLevel(BattleGroundTypeId bgTypeId
) const;
1940 bool InBattleGroundQueue() const
1942 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1943 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
!= BATTLEGROUND_QUEUE_NONE
)
1948 BattleGroundQueueTypeId
GetBattleGroundQueueTypeId(uint32 index
) const { return m_bgBattleGroundQueueID
[index
].bgQueueTypeId
; }
1949 uint32
GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId
) const
1951 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1952 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1954 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1956 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
1958 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1959 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
1960 return m_bgBattleGroundQueueID
[i
].invitedToInstance
!= 0;
1963 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
) const
1965 return GetBattleGroundQueueIndex(bgQueueTypeId
) < PLAYER_MAX_BATTLEGROUND_QUEUES
;
1968 void SetBattleGroundId(uint32 val
, BattleGroundTypeId bgTypeId
)
1970 m_bgData
.bgInstanceID
= val
;
1971 m_bgData
.bgTypeID
= bgTypeId
;
1973 uint32
AddBattleGroundQueueId(BattleGroundQueueTypeId val
)
1975 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1977 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
|| m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
1979 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= val
;
1980 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
1984 return PLAYER_MAX_BATTLEGROUND_QUEUES
;
1986 bool HasFreeBattleGroundQueueId()
1988 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1989 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== BATTLEGROUND_QUEUE_NONE
)
1993 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val
)
1995 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
1997 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== val
)
1999 m_bgBattleGroundQueueID
[i
].bgQueueTypeId
= BATTLEGROUND_QUEUE_NONE
;
2000 m_bgBattleGroundQueueID
[i
].invitedToInstance
= 0;
2005 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId
, uint32 instanceId
)
2007 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2008 if (m_bgBattleGroundQueueID
[i
].bgQueueTypeId
== bgQueueTypeId
)
2009 m_bgBattleGroundQueueID
[i
].invitedToInstance
= instanceId
;
2011 bool IsInvitedForBattleGroundInstance(uint32 instanceId
) const
2013 for (int i
=0; i
< PLAYER_MAX_BATTLEGROUND_QUEUES
; ++i
)
2014 if (m_bgBattleGroundQueueID
[i
].invitedToInstance
== instanceId
)
2018 WorldLocation
const& GetBattleGroundEntryPoint() const { return m_bgData
.joinPos
; }
2019 void SetBattleGroundEntryPoint();
2021 void SetBGTeam(uint32 team
) { m_bgData
.bgTeam
= team
; }
2022 uint32
GetBGTeam() const { return m_bgData
.bgTeam
? m_bgData
.bgTeam
: GetTeam(); }
2024 void LeaveBattleground(bool teleportToEntryPoint
= true);
2025 bool CanJoinToBattleground() const;
2026 bool CanReportAfkDueToLimit();
2027 void ReportedAfkBy(Player
* reporter
);
2028 void ClearAfkReports() { m_bgData
.bgAfkReporter
.clear(); }
2030 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId
) const;
2031 bool CanUseBattleGroundObject();
2032 bool isTotalImmune();
2033 bool CanCaptureTowerPoint();
2035 /*********************************************************/
2036 /*** REST SYSTEM ***/
2037 /*********************************************************/
2039 bool isRested() const { return GetRestTime() >= 10*IN_MILISECONDS
; }
2040 uint32
GetXPRestBonus(uint32 xp
);
2041 uint32
GetRestTime() const { return m_restTime
;};
2042 void SetRestTime(uint32 v
) { m_restTime
= v
;};
2044 /*********************************************************/
2045 /*** ENVIROMENTAL SYSTEM ***/
2046 /*********************************************************/
2048 uint32
EnvironmentalDamage(EnviromentalDamage type
, uint32 damage
);
2050 /*********************************************************/
2051 /*** FLOOD FILTER SYSTEM ***/
2052 /*********************************************************/
2054 void UpdateSpeakTime();
2055 bool CanSpeak() const;
2056 void ChangeSpeakTime(int utime
);
2058 /*********************************************************/
2059 /*** VARIOUS SYSTEMS ***/
2060 /*********************************************************/
2061 MovementInfo m_movementInfo
;
2062 bool HasMovementFlag(MovementFlags f
) const; // for script access to m_movementInfo.HasMovementFlag
2063 void UpdateFallInformationIfNeed(MovementInfo
const& minfo
,uint16 opcode
);
2065 void SetFallInformation(uint32 time
, float z
)
2067 m_lastFallTime
= time
;
2070 void HandleFall(MovementInfo
const& movementInfo
);
2072 void BuildTeleportAckMsg( WorldPacket
*data
, float x
, float y
, float z
, float ang
) const;
2074 bool isMoving() const { return m_movementInfo
.HasMovementFlag(movementFlagsMask
); }
2075 bool isMovingOrTurning() const { return m_movementInfo
.HasMovementFlag(movementOrTurningFlagsMask
); }
2077 bool CanFly() const { return m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_CAN_FLY
); }
2078 bool IsFlying() const { return m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_FLYING
); }
2079 bool IsKnowHowFlyIn(uint32 mapid
, uint32 zone
) const;
2081 void SetClientControl(Unit
* target
, uint8 allowMove
);
2082 void SetMover(Unit
* target
) { m_mover
= target
? target
: this; }
2084 void EnterVehicle(Vehicle
*vehicle
);
2085 void ExitVehicle(Vehicle
*vehicle
);
2087 uint64
GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT
); }
2088 void SetFarSightGUID(uint64 guid
);
2091 Transport
* GetTransport() const { return m_transport
; }
2092 void SetTransport(Transport
* t
) { m_transport
= t
; }
2094 float GetTransOffsetX() const { return m_movementInfo
.t_x
; }
2095 float GetTransOffsetY() const { return m_movementInfo
.t_y
; }
2096 float GetTransOffsetZ() const { return m_movementInfo
.t_z
; }
2097 float GetTransOffsetO() const { return m_movementInfo
.t_o
; }
2098 uint32
GetTransTime() const { return m_movementInfo
.t_time
; }
2099 int8
GetTransSeat() const { return m_movementInfo
.t_seat
; }
2101 uint32
GetSaveTimer() const { return m_nextSave
; }
2102 void SetSaveTimer(uint32 timer
) { m_nextSave
= timer
; }
2110 void SaveRecallPosition();
2112 // Homebind coordinates
2113 uint32 m_homebindMapId
;
2114 uint16 m_homebindZoneId
;
2118 void RelocateToHomebind() { SetLocationMapId(m_homebindMapId
); Relocate(m_homebindX
,m_homebindY
,m_homebindZ
); }
2120 // currently visible objects at player client
2121 typedef std::set
<uint64
> ClientGUIDs
;
2122 ClientGUIDs m_clientGUIDs
;
2124 bool HaveAtClient(WorldObject
const* u
) { return u
==this || m_clientGUIDs
.find(u
->GetGUID())!=m_clientGUIDs
.end(); }
2126 WorldObject
const* GetViewPoint() const;
2127 bool IsVisibleInGridForPlayer(Player
* pl
) const;
2128 bool IsVisibleGloballyFor(Player
* pl
) const;
2130 void UpdateVisibilityOf(WorldObject
const* viewPoint
, WorldObject
* target
);
2133 void UpdateVisibilityOf(WorldObject
const* viewPoint
,T
* target
, UpdateData
& data
, UpdateDataMapType
& data_updates
, std::set
<WorldObject
*>& visibleNow
);
2135 // Stealth detection system
2136 void HandleStealthedUnitsDetection();
2138 uint8 m_forced_speed_changes
[MAX_MOVE_TYPE
];
2140 bool HasAtLoginFlag(AtLoginFlags f
) const { return m_atLoginFlags
& f
; }
2141 void SetAtLoginFlag(AtLoginFlags f
) { m_atLoginFlags
|= f
; }
2142 void RemoveAtLoginFlag(AtLoginFlags f
, bool in_db_also
= false);
2144 LookingForGroup m_lookingForGroup
;
2146 // Temporarily removed pet cache
2147 uint32
GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber
; }
2148 void SetTemporaryUnsummonedPetNumber(uint32 petnumber
) { m_temporaryUnsummonedPetNumber
= petnumber
; }
2149 void UnsummonPetTemporaryIfAny();
2150 void ResummonPetTemporaryUnSummonedIfAny();
2151 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
2153 void SendCinematicStart(uint32 CinematicSequenceId
);
2154 void SendMovieStart(uint32 MovieId
);
2156 /*********************************************************/
2157 /*** INSTANCE SYSTEM ***/
2158 /*********************************************************/
2160 typedef UNORDERED_MAP
< uint32
/*mapId*/, InstancePlayerBind
> BoundInstancesMap
;
2162 void UpdateHomebindTime(uint32 time
);
2164 uint32 m_HomebindTimer
;
2165 bool m_InstanceValid
;
2166 // permanent binds and solo binds by difficulty
2167 BoundInstancesMap m_boundInstances
[TOTAL_DIFFICULTIES
];
2168 InstancePlayerBind
* GetBoundInstance(uint32 mapid
, uint8 difficulty
);
2169 BoundInstancesMap
& GetBoundInstances(uint8 difficulty
) { return m_boundInstances
[difficulty
]; }
2170 void UnbindInstance(uint32 mapid
, uint8 difficulty
, bool unload
= false);
2171 void UnbindInstance(BoundInstancesMap::iterator
&itr
, uint8 difficulty
, bool unload
= false);
2172 InstancePlayerBind
* BindToInstance(InstanceSave
*save
, bool permanent
, bool load
= false);
2173 void SendRaidInfo();
2174 void SendSavedInstances();
2175 static void ConvertInstancesToGroup(Player
*player
, Group
*group
= NULL
, uint64 player_guid
= 0);
2177 /*********************************************************/
2178 /*** GROUP SYSTEM ***/
2179 /*********************************************************/
2181 Group
* GetGroupInvite() { return m_groupInvite
; }
2182 void SetGroupInvite(Group
*group
) { m_groupInvite
= group
; }
2183 Group
* GetGroup() { return m_group
.getTarget(); }
2184 const Group
* GetGroup() const { return (const Group
*)m_group
.getTarget(); }
2185 GroupReference
& GetGroupRef() { return m_group
; }
2186 void SetGroup(Group
*group
, int8 subgroup
= -1);
2187 uint8
GetSubGroup() const { return m_group
.getSubGroup(); }
2188 uint32
GetGroupUpdateFlag() const { return m_groupUpdateMask
; }
2189 void SetGroupUpdateFlag(uint32 flag
) { m_groupUpdateMask
|= flag
; }
2190 const uint64
& GetAuraUpdateMask() const { return m_auraUpdateMask
; }
2191 void SetAuraUpdateMask(uint8 slot
) { m_auraUpdateMask
|= (uint64(1) << slot
); }
2192 Player
* GetNextRandomRaidMember(float radius
);
2193 PartyResult
CanUninviteFromGroup() const;
2194 // BattleGround Group System
2195 void SetBattleGroundRaid(Group
*group
, int8 subgroup
= -1);
2196 void RemoveFromBattleGroundRaid();
2197 Group
* GetOriginalGroup() { return m_originalGroup
.getTarget(); }
2198 GroupReference
& GetOriginalGroupRef() { return m_originalGroup
; }
2199 uint8
GetOriginalSubGroup() const { return m_originalGroup
.getSubGroup(); }
2200 void SetOriginalGroup(Group
*group
, int8 subgroup
= -1);
2202 GridReference
<Player
> &GetGridRef() { return m_gridRef
; }
2203 MapReference
&GetMapRef() { return m_mapRef
; }
2205 bool isAllowedToLoot(Creature
* creature
);
2207 DeclinedName
const* GetDeclinedNames() const { return m_declinedname
; }
2208 uint8
GetRunesState() const { return m_runes
->runeState
; }
2209 uint8
GetBaseRune(uint8 index
) const { return m_runes
->runes
[index
].BaseRune
; }
2210 uint8
GetCurrentRune(uint8 index
) const { return m_runes
->runes
[index
].CurrentRune
; }
2211 uint8
GetRuneCooldown(uint8 index
) const { return m_runes
->runes
[index
].Cooldown
; }
2212 void SetBaseRune(uint8 index
, uint8 baseRune
) { m_runes
->runes
[index
].BaseRune
= baseRune
; }
2213 void SetCurrentRune(uint8 index
, uint8 currentRune
) { m_runes
->runes
[index
].CurrentRune
= currentRune
; }
2214 void SetRuneCooldown(uint8 index
, uint8 cooldown
) { m_runes
->runes
[index
].Cooldown
= cooldown
; m_runes
->SetRuneState(index
, (cooldown
== 0) ? true : false); }
2215 void ConvertRune(uint8 index
, uint8 newType
);
2216 void ResyncRunes(uint8 count
);
2217 void AddRunePower(uint8 index
);
2219 AchievementMgr
& GetAchievementMgr() { return m_achievementMgr
; }
2220 void UpdateAchievementCriteria(AchievementCriteriaTypes type
, uint32 miscvalue1
=0, uint32 miscvalue2
=0, Unit
*unit
=NULL
, uint32 time
=0);
2221 bool HasTitle(uint32 bitIndex
);
2222 bool HasTitle(CharTitlesEntry
const* title
) { return HasTitle(title
->bit_index
); }
2223 void SetTitle(CharTitlesEntry
const* title
, bool lost
= false);
2225 bool isActiveObject() const { return true; }
2226 bool canSeeSpellClickOn(Creature
const* creature
) const;
2229 uint32 m_contestedPvPTimer
;
2231 /*********************************************************/
2232 /*** BATTLEGROUND SYSTEM ***/
2233 /*********************************************************/
2236 this is an array of BG queues (BgTypeIDs) in which is player
2238 struct BgBattleGroundQueueID_Rec
2240 BattleGroundQueueTypeId bgQueueTypeId
;
2241 uint32 invitedToInstance
;
2244 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID
[PLAYER_MAX_BATTLEGROUND_QUEUES
];
2247 /*********************************************************/
2248 /*** QUEST SYSTEM ***/
2249 /*********************************************************/
2251 std::set
<uint32
> m_timedquests
;
2254 uint32 m_ingametime
;
2256 /*********************************************************/
2257 /*** LOAD SYSTEM ***/
2258 /*********************************************************/
2260 void _LoadActions(QueryResult
*result
);
2261 void _LoadAuras(QueryResult
*result
, uint32 timediff
);
2262 void _LoadGlyphAuras();
2263 void _LoadBoundInstances(QueryResult
*result
);
2264 void _LoadInventory(QueryResult
*result
, uint32 timediff
);
2265 void _LoadMailInit(QueryResult
*resultUnread
, QueryResult
*resultDelivery
);
2267 void _LoadMailedItems(Mail
*mail
);
2268 void _LoadQuestStatus(QueryResult
*result
);
2269 void _LoadDailyQuestStatus(QueryResult
*result
);
2270 void _LoadGroup(QueryResult
*result
);
2272 void _LoadSpells(QueryResult
*result
);
2273 void _LoadFriendList(QueryResult
*result
);
2274 bool _LoadHomeBind(QueryResult
*result
);
2275 void _LoadDeclinedNames(QueryResult
*result
);
2276 void _LoadArenaTeamInfo(QueryResult
*result
);
2277 void _LoadEquipmentSets(QueryResult
*result
);
2278 void _LoadBGData(QueryResult
* result
);
2280 /*********************************************************/
2281 /*** SAVE SYSTEM ***/
2282 /*********************************************************/
2284 void _SaveActions();
2286 void _SaveInventory();
2288 void _SaveQuestStatus();
2289 void _SaveDailyQuestStatus();
2291 void _SaveEquipmentSets();
2294 void _SetCreateBits(UpdateMask
*updateMask
, Player
*target
) const;
2295 void _SetUpdateBits(UpdateMask
*updateMask
, Player
*target
) const;
2297 /*********************************************************/
2298 /*** ENVIRONMENTAL SYSTEM ***/
2299 /*********************************************************/
2300 void HandleSobering();
2301 void SendMirrorTimer(MirrorTimerType Type
, uint32 MaxValue
, uint32 CurrentValue
, int32 Regen
);
2302 void StopMirrorTimer(MirrorTimerType Type
);
2303 void HandleDrowning(uint32 time_diff
);
2304 int32
getMaxTimer(MirrorTimerType timer
);
2306 /*********************************************************/
2307 /*** HONOR SYSTEM ***/
2308 /*********************************************************/
2309 time_t m_lastHonorUpdateTime
;
2311 void outDebugValues() const;
2317 uint32 m_speakCount
;
2318 uint32 m_dungeonDifficulty
;
2320 uint32 m_atLoginFlags
;
2322 Item
* m_items
[PLAYER_SLOTS_COUNT
];
2323 uint32 m_currentBuybackSlot
;
2325 std::vector
<Item
*> m_itemUpdateQueue
;
2326 bool m_itemUpdateQueueBlocked
;
2328 uint32 m_ExtraFlags
;
2329 uint64 m_curSelection
;
2331 uint64 m_comboTarget
;
2334 QuestStatusMap mQuestStatus
;
2336 uint32 m_GuildIdInvited
;
2337 uint32 m_ArenaTeamIdInvited
;
2340 PlayerSpellMap m_spells
;
2341 SpellCooldowns m_spellCooldowns
;
2342 uint32 m_lastPotionId
; // last used health/mana potion in combat, that block next potion use
2344 uint32 m_activeSpec
;
2345 uint32 m_specsCount
;
2347 ActionButtonList m_actionButtons
;
2349 float m_auraBaseMod
[BASEMOD_END
][MOD_END
];
2350 int16 m_baseRatingValue
[MAX_COMBAT_RATING
];
2351 uint16 m_baseSpellDamage
;
2352 uint16 m_baseSpellHealing
;
2353 uint16 m_baseFeralAP
;
2354 uint16 m_baseManaRegen
;
2356 SpellModList m_spellMods
[MAX_SPELLMOD
];
2357 int32 m_SpellModRemoveCount
;
2358 EnchantDurationList m_enchantDuration
;
2359 ItemDurationList m_itemDuration
;
2361 uint64 m_resurrectGUID
;
2362 uint32 m_resurrectMap
;
2363 float m_resurrectX
, m_resurrectY
, m_resurrectZ
;
2364 uint32 m_resurrectHealth
, m_resurrectMana
;
2366 WorldSession
*m_session
;
2368 typedef std::list
<Channel
*> JoinedChannelsList
;
2369 JoinedChannelsList m_channels
;
2375 uint16 tradeItems
[TRADE_SLOT_COUNT
];
2378 time_t m_nextThinkTime
;
2380 bool m_DailyQuestChanged
;
2381 time_t m_lastDailyQuestTime
;
2383 uint32 m_drunkTimer
;
2385 uint32 m_weaponChangeTimer
;
2387 uint32 m_zoneUpdateId
;
2388 uint32 m_zoneUpdateTimer
;
2389 uint32 m_areaUpdateId
;
2391 uint32 m_deathTimer
;
2392 time_t m_deathExpireTime
;
2396 uint32 m_WeaponProficiency
;
2397 uint32 m_ArmorProficiency
;
2400 bool m_canDualWield
;
2401 bool m_canTitanGrip
;
2402 uint8 m_swingErrorMsg
;
2405 ////////////////////Rest System/////////////////////
2407 uint32 inn_pos_mapid
;
2413 ////////////////////Rest System/////////////////////
2416 Transport
* m_transport
;
2418 uint32 m_resetTalentsCost
;
2419 time_t m_resetTalentsTime
;
2420 uint32 m_usedTalentCount
;
2421 uint32 m_questRewardTalentCount
;
2424 PlayerSocial
*m_social
;
2427 GroupReference m_group
;
2428 GroupReference m_originalGroup
;
2429 Group
*m_groupInvite
;
2430 uint32 m_groupUpdateMask
;
2431 uint64 m_auraUpdateMask
;
2436 time_t m_summon_expire
;
2437 uint32 m_summon_mapid
;
2442 DeclinedName
*m_declinedname
;
2444 EquipmentSets m_EquipmentSets
;
2446 // internal common parts for CanStore/StoreItem functions
2447 uint8
_CanStoreItem_InSpecificSlot( uint8 bag
, uint8 slot
, ItemPosCountVec
& dest
, ItemPrototype
const *pProto
, uint32
& count
, bool swap
, Item
*pSrcItem
) const;
2448 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;
2449 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;
2450 Item
* _StoreItem( uint16 pos
, Item
*pItem
, uint32 count
, bool clone
, bool update
);
2452 void UpdateKnownCurrencies(uint32 itemId
, bool apply
);
2453 int32
CalculateReputationGain(uint32 creatureOrQuestLevel
, int32 rep
, int32 faction
, bool for_quest
);
2454 void AdjustQuestReqItemCount( Quest
const* pQuest
, QuestStatusData
& questStatusData
);
2456 bool IsCanDelayTeleport() const { return m_bCanDelayTeleport
; }
2457 void SetCanDelayTeleport(bool setting
) { m_bCanDelayTeleport
= setting
; }
2458 bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport
; }
2459 void SetDelayedTeleportFlag(bool setting
) { m_bHasDelayedTeleport
= setting
; }
2461 void ScheduleDelayedOperation(uint32 operation
)
2463 if(operation
< DELAYED_END
)
2464 m_DelayedOperations
|= operation
;
2467 GridReference
<Player
> m_gridRef
;
2468 MapReference m_mapRef
;
2470 uint32 m_lastFallTime
;
2473 int32 m_MirrorTimer
[MAX_TIMERS
];
2474 uint8 m_MirrorTimerFlags
;
2475 uint8 m_MirrorTimerFlagsLast
;
2478 // Current teleport data
2479 WorldLocation m_teleport_dest
;
2480 uint32 m_teleport_options
;
2481 bool mSemaphoreTeleport_Near
;
2482 bool mSemaphoreTeleport_Far
;
2484 uint32 m_DelayedOperations
;
2485 bool m_bCanDelayTeleport
;
2486 bool m_bHasDelayedTeleport
;
2488 uint32 m_DetectInvTimer
;
2490 // Temporary removed pet cache
2491 uint32 m_temporaryUnsummonedPetNumber
;
2492 uint32 m_oldpetspell
;
2494 AchievementMgr m_achievementMgr
;
2495 ReputationMgr m_reputationMgr
;
2498 void AddItemsSetItem(Player
*player
,Item
*item
);
2499 void RemoveItemsSetItem(Player
*player
,ItemPrototype
const *proto
);
2501 // "the bodies of template functions must be made available in a header file"
2502 template <class T
> T
Player::ApplySpellMod(uint32 spellId
, SpellModOp op
, T
&basevalue
, Spell
const* spell
)
2504 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
2505 if (!spellInfo
) return 0;
2507 int32 totalflat
= 0;
2508 for (SpellModList::iterator itr
= m_spellMods
[op
].begin(); itr
!= m_spellMods
[op
].end(); ++itr
)
2510 SpellModifier
*mod
= *itr
;
2512 if(!IsAffectedBySpellmod(spellInfo
,mod
,spell
))
2514 if (mod
->type
== SPELLMOD_FLAT
)
2515 totalflat
+= mod
->value
;
2516 else if (mod
->type
== SPELLMOD_PCT
)
2518 // skip percent mods for null basevalue (most important for spell mods with charges )
2519 if(basevalue
== T(0))
2522 // special case (skip >10sec spell casts for instant cast setting)
2523 if( mod
->op
==SPELLMOD_CASTING_TIME
&& basevalue
>= T(10*IN_MILISECONDS
) && mod
->value
<= -100)
2526 totalpct
+= mod
->value
;
2529 if (mod
->charges
> 0 )
2532 if (mod
->charges
== 0)
2535 mod
->lastAffected
= spell
;
2536 if(!mod
->lastAffected
)
2537 mod
->lastAffected
= FindCurrentSpellBySpellId(spellId
);
2538 ++m_SpellModRemoveCount
;
2543 float diff
= (float)basevalue
*(float)totalpct
/100.0f
+ (float)totalflat
;
2544 basevalue
= T((float)basevalue
+ diff
);