[9033] Fixed percent mana regneration from spell 53228 and ranks buff.
[getmangos.git] / src / game / Player.h
blob75e8e3163148fea9e258ad800b03583c14e53cf4
1 /*
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
19 #ifndef _PLAYER_H
20 #define _PLAYER_H
22 #include "Common.h"
23 #include "ItemPrototype.h"
24 #include "Unit.h"
25 #include "Item.h"
27 #include "Database/DatabaseEnv.h"
28 #include "NPCHandler.h"
29 #include "QuestDef.h"
30 #include "Group.h"
31 #include "Bag.h"
32 #include "WorldSession.h"
33 #include "Pet.h"
34 #include "MapReference.h"
35 #include "Util.h" // for Tokens typedef
36 #include "AchievementMgr.h"
37 #include "ReputationMgr.h"
38 #include "BattleGround.h"
39 #include "DBCEnums.h"
41 #include<string>
42 #include<vector>
44 struct Mail;
45 class Channel;
46 class DynamicObject;
47 class Creature;
48 class Pet;
49 class PlayerMenu;
50 class Transport;
51 class UpdateMask;
52 class SpellCastTargets;
53 class PlayerSocial;
54 class Vehicle;
56 typedef std::deque<Mail*> PlayerMails;
58 #define PLAYER_MAX_SKILLS 127
59 #define PLAYER_MAX_DAILY_QUESTS 25
61 // Note: SPELLMOD_* values is aura types in fact
62 enum SpellModType
64 SPELLMOD_FLAT = 107, // SPELL_AURA_ADD_FLAT_MODIFIER
65 SPELLMOD_PCT = 108 // SPELL_AURA_ADD_PCT_MODIFIER
68 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
69 enum PlayerUnderwaterState
71 UNDERWATER_NONE = 0x00,
72 UNDERWATER_INWATER = 0x01, // terrain type is water and player is afflicted by it
73 UNDERWATER_INLAVA = 0x02, // terrain type is lava and player is afflicted by it
74 UNDERWATER_INSLIME = 0x04, // terrain type is lava and player is afflicted by it
75 UNDERWARER_INDARKWATER = 0x08, // terrain type is dark water and player is afflicted by it
77 UNDERWATER_EXIST_TIMERS = 0x10
80 enum PlayerSpellState
82 PLAYERSPELL_UNCHANGED = 0,
83 PLAYERSPELL_CHANGED = 1,
84 PLAYERSPELL_NEW = 2,
85 PLAYERSPELL_REMOVED = 3
88 struct PlayerSpell
90 PlayerSpellState state : 8;
91 bool active : 1; // show in spellbook
92 bool dependent : 1; // learned as result another spell learn, skill grow, quest reward, etc
93 bool disabled : 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
96 // Spell modifier (used for modify other spells)
97 struct SpellModifier
99 SpellModifier() : charges(0), lastAffected(NULL) {}
100 SpellModOp op : 8;
101 SpellModType type : 8;
102 int16 charges : 16;
103 int32 value;
104 uint64 mask;
105 uint64 mask2;
106 uint32 spellId;
107 Spell const* lastAffected;
110 typedef UNORDERED_MAP<uint32, PlayerSpell*> PlayerSpellMap;
111 typedef std::list<SpellModifier*> SpellModList;
113 struct SpellCooldown
115 time_t end;
116 uint16 itemid;
119 typedef std::map<uint32, SpellCooldown> SpellCooldowns;
121 enum TrainerSpellState
123 TRAINER_SPELL_GREEN = 0,
124 TRAINER_SPELL_RED = 1,
125 TRAINER_SPELL_GRAY = 2,
126 TRAINER_SPELL_GREEN_DISABLED = 10 // custom value, not send to client: formally green but learn not allowed
129 enum ActionButtonUpdateState
131 ACTIONBUTTON_UNCHANGED = 0,
132 ACTIONBUTTON_CHANGED = 1,
133 ACTIONBUTTON_NEW = 2,
134 ACTIONBUTTON_DELETED = 3
137 enum ActionButtonType
139 ACTION_BUTTON_SPELL = 0x00,
140 ACTION_BUTTON_C = 0x01, // click?
141 ACTION_BUTTON_EQSET = 0x20,
142 ACTION_BUTTON_MACRO = 0x40,
143 ACTION_BUTTON_CMACRO = ACTION_BUTTON_C | ACTION_BUTTON_MACRO,
144 ACTION_BUTTON_ITEM = 0x80
147 #define ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
148 #define ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
149 #define MAX_ACTION_BUTTON_ACTION_VALUE (0x00FFFFFF+1)
151 struct ActionButton
153 ActionButton() : packedData(0), uState( ACTIONBUTTON_NEW ) {}
155 uint32 packedData;
156 ActionButtonUpdateState uState;
158 // helpers
159 ActionButtonType GetType() const { return ActionButtonType(ACTION_BUTTON_TYPE(packedData)); }
160 uint32 GetAction() const { return ACTION_BUTTON_ACTION(packedData); }
161 void SetActionAndType(uint32 action, ActionButtonType type)
163 uint32 newData = action | (uint32(type) << 24);
164 if (newData != packedData || uState == ACTIONBUTTON_DELETED)
166 packedData = newData;
167 if (uState != ACTIONBUTTON_NEW)
168 uState = ACTIONBUTTON_CHANGED;
173 #define MAX_ACTION_BUTTONS 144 //checked in 3.2.0
175 typedef std::map<uint8,ActionButton> ActionButtonList;
177 struct PlayerCreateInfoItem
179 PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {}
181 uint32 item_id;
182 uint32 item_amount;
185 typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
187 struct PlayerClassLevelInfo
189 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
190 uint16 basehealth;
191 uint16 basemana;
194 struct PlayerClassInfo
196 PlayerClassInfo() : levelInfo(NULL) { }
198 PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
201 struct PlayerLevelInfo
203 PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
205 uint8 stats[MAX_STATS];
208 typedef std::list<uint32> PlayerCreateInfoSpells;
210 struct PlayerCreateInfoAction
212 PlayerCreateInfoAction() : button(0), type(0), action(0) {}
213 PlayerCreateInfoAction(uint8 _button, uint32 _action, uint8 _type) : button(_button), type(_type), action(_action) {}
215 uint8 button;
216 uint8 type;
217 uint32 action;
220 typedef std::list<PlayerCreateInfoAction> PlayerCreateInfoActions;
222 struct PlayerInfo
224 // existence checked by displayId != 0 // existence checked by displayId != 0
225 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL)
229 uint32 mapId;
230 uint32 zoneId;
231 float positionX;
232 float positionY;
233 float positionZ;
234 uint16 displayId_m;
235 uint16 displayId_f;
236 PlayerCreateInfoItems item;
237 PlayerCreateInfoSpells spell;
238 PlayerCreateInfoActions action;
240 PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
243 struct PvPInfo
245 PvPInfo() : inHostileArea(false), endTimer(0) {}
247 bool inHostileArea;
248 time_t endTimer;
251 struct DuelInfo
253 DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {}
255 Player *initiator;
256 Player *opponent;
257 time_t startTimer;
258 time_t startTime;
259 time_t outOfBound;
262 struct Areas
264 uint32 areaID;
265 uint32 areaFlag;
266 float x1;
267 float x2;
268 float y1;
269 float y2;
272 #define MAX_RUNES 6
273 #define RUNE_COOLDOWN 10000 // msec
275 enum RuneType
277 RUNE_BLOOD = 0,
278 RUNE_UNHOLY = 1,
279 RUNE_FROST = 2,
280 RUNE_DEATH = 3,
281 NUM_RUNE_TYPES = 4
284 struct RuneInfo
286 uint8 BaseRune;
287 uint8 CurrentRune;
288 uint16 Cooldown; // msec
291 struct Runes
293 RuneInfo runes[MAX_RUNES];
294 uint8 runeState; // mask of available runes
296 void SetRuneState(uint8 index, bool set = true)
298 if(set)
299 runeState |= (1 << index); // usable
300 else
301 runeState &= ~(1 << index); // on cooldown
305 struct EnchantDuration
307 EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {};
308 EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { assert(item); };
310 Item * item;
311 EnchantmentSlot slot;
312 uint32 leftduration;
315 typedef std::list<EnchantDuration> EnchantDurationList;
316 typedef std::list<Item*> ItemDurationList;
318 enum LfgType
320 LFG_TYPE_NONE = 0,
321 LFG_TYPE_DUNGEON = 1,
322 LFG_TYPE_RAID = 2,
323 LFG_TYPE_QUEST = 3,
324 LFG_TYPE_ZONE = 4,
325 LFG_TYPE_HEROIC_DUNGEON = 5
328 enum LfgRoles
330 LEADER = 0x01,
331 TANK = 0x02,
332 HEALER = 0x04,
333 DAMAGE = 0x08
336 struct LookingForGroupSlot
338 LookingForGroupSlot() : entry(0), type(0) {}
339 bool Empty() const { return !entry && !type; }
340 void Clear() { entry = 0; type = 0; }
341 void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; }
342 bool Is(uint32 _entry, uint32 _type) const { return entry == _entry && type == _type; }
343 bool canAutoJoin() const { return entry && (type == LFG_TYPE_DUNGEON || type == LFG_TYPE_HEROIC_DUNGEON); }
345 uint32 entry;
346 uint32 type;
349 #define MAX_LOOKING_FOR_GROUP_SLOT 3
351 struct LookingForGroup
353 LookingForGroup() {}
354 bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry, slot.type); }
355 bool HaveInSlot(uint32 _entry, uint32 _type) const
357 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
358 if(slots[i].Is(_entry, _type))
359 return true;
360 return false;
363 bool canAutoJoin() const
365 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
366 if(slots[i].canAutoJoin())
367 return true;
368 return false;
371 bool Empty() const
373 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
374 if(!slots[i].Empty())
375 return false;
376 return more.Empty();
379 LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT];
380 LookingForGroupSlot more;
381 std::string comment;
382 uint8 roles;
385 enum PlayerMovementType
387 MOVE_ROOT = 1,
388 MOVE_UNROOT = 2,
389 MOVE_WATER_WALK = 3,
390 MOVE_LAND_WALK = 4
393 enum DrunkenState
395 DRUNKEN_SOBER = 0,
396 DRUNKEN_TIPSY = 1,
397 DRUNKEN_DRUNK = 2,
398 DRUNKEN_SMASHED = 3
401 #define MAX_DRUNKEN 4
403 enum PlayerFlags
405 PLAYER_FLAGS_GROUP_LEADER = 0x00000001,
406 PLAYER_FLAGS_AFK = 0x00000002,
407 PLAYER_FLAGS_DND = 0x00000004,
408 PLAYER_FLAGS_GM = 0x00000008,
409 PLAYER_FLAGS_GHOST = 0x00000010,
410 PLAYER_FLAGS_RESTING = 0x00000020,
411 PLAYER_FLAGS_UNK7 = 0x00000040,
412 PLAYER_FLAGS_UNK8 = 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
413 PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
414 PLAYER_FLAGS_IN_PVP = 0x00000200,
415 PLAYER_FLAGS_HIDE_HELM = 0x00000400,
416 PLAYER_FLAGS_HIDE_CLOAK = 0x00000800,
417 PLAYER_FLAGS_UNK13 = 0x00001000, // played long time
418 PLAYER_FLAGS_UNK14 = 0x00002000, // played too long time
419 PLAYER_FLAGS_UNK15 = 0x00004000,
420 PLAYER_FLAGS_UNK16 = 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
421 PLAYER_FLAGS_UNK17 = 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
422 PLAYER_FLAGS_UNK18 = 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
423 PLAYER_FLAGS_PVP_TIMER = 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
424 PLAYER_FLAGS_UNK20 = 0x00080000,
425 PLAYER_FLAGS_UNK21 = 0x00100000,
426 PLAYER_FLAGS_UNK22 = 0x00200000,
427 PLAYER_FLAGS_UNK23 = 0x00400000,
428 PLAYER_FLAGS_UNK24 = 0x00800000, // disabled all abilitys on tab except autoattack
429 PLAYER_FLAGS_UNK25 = 0x01000000, // disabled all melee ability on tab include autoattack
430 PLAYER_FLAGS_NO_XP_GAIN = 0x02000000,
433 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
434 // can't use enum for uint64 values
435 #define PLAYER_TITLE_DISABLED UI64LIT(0x0000000000000000)
436 #define PLAYER_TITLE_NONE UI64LIT(0x0000000000000001)
437 #define PLAYER_TITLE_PRIVATE UI64LIT(0x0000000000000002) // 1
438 #define PLAYER_TITLE_CORPORAL UI64LIT(0x0000000000000004) // 2
439 #define PLAYER_TITLE_SERGEANT_A UI64LIT(0x0000000000000008) // 3
440 #define PLAYER_TITLE_MASTER_SERGEANT UI64LIT(0x0000000000000010) // 4
441 #define PLAYER_TITLE_SERGEANT_MAJOR UI64LIT(0x0000000000000020) // 5
442 #define PLAYER_TITLE_KNIGHT UI64LIT(0x0000000000000040) // 6
443 #define PLAYER_TITLE_KNIGHT_LIEUTENANT UI64LIT(0x0000000000000080) // 7
444 #define PLAYER_TITLE_KNIGHT_CAPTAIN UI64LIT(0x0000000000000100) // 8
445 #define PLAYER_TITLE_KNIGHT_CHAMPION UI64LIT(0x0000000000000200) // 9
446 #define PLAYER_TITLE_LIEUTENANT_COMMANDER UI64LIT(0x0000000000000400) // 10
447 #define PLAYER_TITLE_COMMANDER UI64LIT(0x0000000000000800) // 11
448 #define PLAYER_TITLE_MARSHAL UI64LIT(0x0000000000001000) // 12
449 #define PLAYER_TITLE_FIELD_MARSHAL UI64LIT(0x0000000000002000) // 13
450 #define PLAYER_TITLE_GRAND_MARSHAL UI64LIT(0x0000000000004000) // 14
451 #define PLAYER_TITLE_SCOUT UI64LIT(0x0000000000008000) // 15
452 #define PLAYER_TITLE_GRUNT UI64LIT(0x0000000000010000) // 16
453 #define PLAYER_TITLE_SERGEANT_H UI64LIT(0x0000000000020000) // 17
454 #define PLAYER_TITLE_SENIOR_SERGEANT UI64LIT(0x0000000000040000) // 18
455 #define PLAYER_TITLE_FIRST_SERGEANT UI64LIT(0x0000000000080000) // 19
456 #define PLAYER_TITLE_STONE_GUARD UI64LIT(0x0000000000100000) // 20
457 #define PLAYER_TITLE_BLOOD_GUARD UI64LIT(0x0000000000200000) // 21
458 #define PLAYER_TITLE_LEGIONNAIRE UI64LIT(0x0000000000400000) // 22
459 #define PLAYER_TITLE_CENTURION UI64LIT(0x0000000000800000) // 23
460 #define PLAYER_TITLE_CHAMPION UI64LIT(0x0000000001000000) // 24
461 #define PLAYER_TITLE_LIEUTENANT_GENERAL UI64LIT(0x0000000002000000) // 25
462 #define PLAYER_TITLE_GENERAL UI64LIT(0x0000000004000000) // 26
463 #define PLAYER_TITLE_WARLORD UI64LIT(0x0000000008000000) // 27
464 #define PLAYER_TITLE_HIGH_WARLORD UI64LIT(0x0000000010000000) // 28
465 #define PLAYER_TITLE_GLADIATOR UI64LIT(0x0000000020000000) // 29
466 #define PLAYER_TITLE_DUELIST UI64LIT(0x0000000040000000) // 30
467 #define PLAYER_TITLE_RIVAL UI64LIT(0x0000000080000000) // 31
468 #define PLAYER_TITLE_CHALLENGER UI64LIT(0x0000000100000000) // 32
469 #define PLAYER_TITLE_SCARAB_LORD UI64LIT(0x0000000200000000) // 33
470 #define PLAYER_TITLE_CONQUEROR UI64LIT(0x0000000400000000) // 34
471 #define PLAYER_TITLE_JUSTICAR UI64LIT(0x0000000800000000) // 35
472 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU UI64LIT(0x0000001000000000) // 36
473 #define PLAYER_TITLE_MERCILESS_GLADIATOR UI64LIT(0x0000002000000000) // 37
474 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN UI64LIT(0x0000004000000000) // 38
475 #define PLAYER_TITLE_HAND_OF_ADAL UI64LIT(0x0000008000000000) // 39
476 #define PLAYER_TITLE_VENGEFUL_GLADIATOR UI64LIT(0x0000010000000000) // 40
478 #define MAX_TITLE_INDEX (3*64) // 3 uint64 fields
480 // used in PLAYER_FIELD_BYTES values
481 enum PlayerFieldByteFlags
483 PLAYER_FIELD_BYTE_TRACK_STEALTHED = 0x00000002,
484 PLAYER_FIELD_BYTE_RELEASE_TIMER = 0x00000008, // Display time till auto release spirit
485 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x00000010 // Display no "release spirit" window at all
488 // used in PLAYER_FIELD_BYTES2 values
489 enum PlayerFieldByte2Flags
491 PLAYER_FIELD_BYTE2_NONE = 0x0000,
492 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW = 0x4000
495 enum ActivateTaxiReplies
497 ERR_TAXIOK = 0,
498 ERR_TAXIUNSPECIFIEDSERVERERROR = 1,
499 ERR_TAXINOSUCHPATH = 2,
500 ERR_TAXINOTENOUGHMONEY = 3,
501 ERR_TAXITOOFARAWAY = 4,
502 ERR_TAXINOVENDORNEARBY = 5,
503 ERR_TAXINOTVISITED = 6,
504 ERR_TAXIPLAYERBUSY = 7,
505 ERR_TAXIPLAYERALREADYMOUNTED = 8,
506 ERR_TAXIPLAYERSHAPESHIFTED = 9,
507 ERR_TAXIPLAYERMOVING = 10,
508 ERR_TAXISAMENODE = 11,
509 ERR_TAXINOTSTANDING = 12
512 enum MirrorTimerType
514 FATIGUE_TIMER = 0,
515 BREATH_TIMER = 1,
516 FIRE_TIMER = 2
518 #define MAX_TIMERS 3
519 #define DISABLED_MIRROR_TIMER -1
521 // 2^n values
522 enum PlayerExtraFlags
524 // gm abilities
525 PLAYER_EXTRA_GM_ON = 0x0001,
526 PLAYER_EXTRA_GM_ACCEPT_TICKETS = 0x0002,
527 PLAYER_EXTRA_ACCEPT_WHISPERS = 0x0004,
528 PLAYER_EXTRA_TAXICHEAT = 0x0008,
529 PLAYER_EXTRA_GM_INVISIBLE = 0x0010,
530 PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages
532 // other states
533 PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating.
536 // 2^n values
537 enum AtLoginFlags
539 AT_LOGIN_NONE = 0x00,
540 AT_LOGIN_RENAME = 0x01,
541 AT_LOGIN_RESET_SPELLS = 0x02,
542 AT_LOGIN_RESET_TALENTS = 0x04,
543 AT_LOGIN_CUSTOMIZE = 0x08,
544 AT_LOGIN_RESET_PET_TALENTS = 0x10,
547 typedef std::map<uint32, QuestStatusData> QuestStatusMap;
549 enum QuestSlotOffsets
551 QUEST_ID_OFFSET = 0,
552 QUEST_STATE_OFFSET = 1,
553 QUEST_COUNTS_OFFSET = 2,
554 QUEST_TIME_OFFSET = 3
557 #define MAX_QUEST_OFFSET 4
559 enum QuestSlotStateMask
561 QUEST_STATE_NONE = 0x0000,
562 QUEST_STATE_COMPLETE = 0x0001,
563 QUEST_STATE_FAIL = 0x0002
566 enum SkillUpdateState
568 SKILL_UNCHANGED = 0,
569 SKILL_CHANGED = 1,
570 SKILL_NEW = 2,
571 SKILL_DELETED = 3
574 struct SkillStatusData
576 SkillStatusData(uint8 _pos, SkillUpdateState _uState) : pos(_pos), uState(_uState)
579 uint8 pos;
580 SkillUpdateState uState;
583 typedef UNORDERED_MAP<uint32, SkillStatusData> SkillStatusMap;
585 class Quest;
586 class Spell;
587 class Item;
588 class WorldSession;
590 enum PlayerSlots
592 // first slot for item stored (in any way in player m_items data)
593 PLAYER_SLOT_START = 0,
594 // last+1 slot for item stored (in any way in player m_items data)
595 PLAYER_SLOT_END = 150,
596 PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START)
599 #define INVENTORY_SLOT_BAG_0 255
601 enum EquipmentSlots // 19 slots
603 EQUIPMENT_SLOT_START = 0,
604 EQUIPMENT_SLOT_HEAD = 0,
605 EQUIPMENT_SLOT_NECK = 1,
606 EQUIPMENT_SLOT_SHOULDERS = 2,
607 EQUIPMENT_SLOT_BODY = 3,
608 EQUIPMENT_SLOT_CHEST = 4,
609 EQUIPMENT_SLOT_WAIST = 5,
610 EQUIPMENT_SLOT_LEGS = 6,
611 EQUIPMENT_SLOT_FEET = 7,
612 EQUIPMENT_SLOT_WRISTS = 8,
613 EQUIPMENT_SLOT_HANDS = 9,
614 EQUIPMENT_SLOT_FINGER1 = 10,
615 EQUIPMENT_SLOT_FINGER2 = 11,
616 EQUIPMENT_SLOT_TRINKET1 = 12,
617 EQUIPMENT_SLOT_TRINKET2 = 13,
618 EQUIPMENT_SLOT_BACK = 14,
619 EQUIPMENT_SLOT_MAINHAND = 15,
620 EQUIPMENT_SLOT_OFFHAND = 16,
621 EQUIPMENT_SLOT_RANGED = 17,
622 EQUIPMENT_SLOT_TABARD = 18,
623 EQUIPMENT_SLOT_END = 19
626 enum InventorySlots // 4 slots
628 INVENTORY_SLOT_BAG_START = 19,
629 INVENTORY_SLOT_BAG_END = 23
632 enum InventoryPackSlots // 16 slots
634 INVENTORY_SLOT_ITEM_START = 23,
635 INVENTORY_SLOT_ITEM_END = 39
638 enum BankItemSlots // 28 slots
640 BANK_SLOT_ITEM_START = 39,
641 BANK_SLOT_ITEM_END = 67
644 enum BankBagSlots // 7 slots
646 BANK_SLOT_BAG_START = 67,
647 BANK_SLOT_BAG_END = 74
650 enum BuyBackSlots // 12 slots
652 // stored in m_buybackitems
653 BUYBACK_SLOT_START = 74,
654 BUYBACK_SLOT_END = 86
657 enum KeyRingSlots // 32 slots
659 KEYRING_SLOT_START = 86,
660 KEYRING_SLOT_END = 118
663 enum CurrencyTokenSlots // 32 slots
665 CURRENCYTOKEN_SLOT_START = 118,
666 CURRENCYTOKEN_SLOT_END = 150
669 enum EquipmentSetUpdateState
671 EQUIPMENT_SET_UNCHANGED = 0,
672 EQUIPMENT_SET_CHANGED = 1,
673 EQUIPMENT_SET_NEW = 2,
674 EQUIPMENT_SET_DELETED = 3
677 struct EquipmentSet
679 EquipmentSet() : Guid(0), state(EQUIPMENT_SET_NEW)
681 for(int i = 0; i < EQUIPMENT_SLOT_END; ++i)
682 Items[i] = 0;
685 uint64 Guid;
686 std::string Name;
687 std::string IconName;
688 uint32 Items[EQUIPMENT_SLOT_END];
689 EquipmentSetUpdateState state;
692 #define MAX_EQUIPMENT_SET_INDEX 10 // client limit
694 typedef std::map<uint32, EquipmentSet> EquipmentSets;
696 struct ItemPosCount
698 ItemPosCount(uint16 _pos, uint32 _count) : pos(_pos), count(_count) {}
699 bool isContainedIn(std::vector<ItemPosCount> const& vec) const;
700 uint16 pos;
701 uint32 count;
703 typedef std::vector<ItemPosCount> ItemPosCountVec;
705 enum TradeSlots
707 TRADE_SLOT_COUNT = 7,
708 TRADE_SLOT_TRADED_COUNT = 6,
709 TRADE_SLOT_NONTRADED = 6
712 enum TransferAbortReason
714 TRANSFER_ABORT_NONE = 0x00,
715 TRANSFER_ABORT_ERROR = 0x01,
716 TRANSFER_ABORT_MAX_PLAYERS = 0x02, // Transfer Aborted: instance is full
717 TRANSFER_ABORT_NOT_FOUND = 0x03, // Transfer Aborted: instance not found
718 TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x04, // You have entered too many instances recently.
719 TRANSFER_ABORT_ZONE_IN_COMBAT = 0x06, // Unable to zone in while an encounter is in progress.
720 TRANSFER_ABORT_INSUF_EXPAN_LVL = 0x07, // You must have <TBC,WotLK> expansion installed to access this area.
721 TRANSFER_ABORT_DIFFICULTY = 0x08, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
722 TRANSFER_ABORT_UNIQUE_MESSAGE = 0x09, // Until you've escaped TLK's grasp, you cannot leave this place!
723 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 0x0A, // Additional instances cannot be launched, please try again later.
724 TRANSFER_ABORT_NEED_GROUP = 0x0B, // 3.1
725 TRANSFER_ABORT_NOT_FOUND2 = 0x0C, // 3.1
726 TRANSFER_ABORT_NOT_FOUND3 = 0x0D, // 3.1
727 TRANSFER_ABORT_NOT_FOUND4 = 0x0E, // 3.2
728 TRANSFER_ABORT_REALM_ONLY = 0x0F, // All players on party must be from the same realm.
729 TRANSFER_ABORT_MAP_NOT_ALLOWED = 0x10, // Map can't be entered at this time.
732 enum InstanceResetWarningType
734 RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s).
735 RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)!
736 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!
737 RAID_INSTANCE_WELCOME = 4, // Welcome to %s. This raid instance is scheduled to reset in %s.
738 RAID_INSTANCE_EXPIRED = 5
741 // PLAYER_FIELD_ARENA_TEAM_INFO_1_1 offsets
742 enum ArenaTeamInfoType
744 ARENA_TEAM_ID = 0,
745 ARENA_TEAM_TYPE = 1, // new in 3.2 - team type?
746 ARENA_TEAM_MEMBER = 2, // 0 - captain, 1 - member
747 ARENA_TEAM_GAMES_WEEK = 3,
748 ARENA_TEAM_GAMES_SEASON = 4,
749 ARENA_TEAM_WINS_SEASON = 5,
750 ARENA_TEAM_PERSONAL_RATING = 6,
751 ARENA_TEAM_END = 7
754 // used in most movement packets (send and received)
755 enum MovementFlags
757 MOVEMENTFLAG_NONE = 0x00000000,
758 MOVEMENTFLAG_FORWARD = 0x00000001,
759 MOVEMENTFLAG_BACKWARD = 0x00000002,
760 MOVEMENTFLAG_STRAFE_LEFT = 0x00000004,
761 MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008,
762 MOVEMENTFLAG_LEFT = 0x00000010,
763 MOVEMENTFLAG_RIGHT = 0x00000020,
764 MOVEMENTFLAG_PITCH_UP = 0x00000040,
765 MOVEMENTFLAG_PITCH_DOWN = 0x00000080,
766 MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking
767 MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures
768 MOVEMENTFLAG_LEVITATING = 0x00000400,
769 MOVEMENTFLAG_FLY_UNK1 = 0x00000800,
770 MOVEMENTFLAG_JUMPING = 0x00001000,
771 MOVEMENTFLAG_UNK4 = 0x00002000,
772 MOVEMENTFLAG_FALLING = 0x00004000,
773 // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
774 MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
775 MOVEMENTFLAG_FLY_UP = 0x00400000,
776 MOVEMENTFLAG_CAN_FLY = 0x00800000,
777 MOVEMENTFLAG_FLYING = 0x01000000,
778 MOVEMENTFLAG_FLYING2 = 0x02000000, // Actual flying mode
779 MOVEMENTFLAG_SPLINE = 0x04000000, // used for flight paths
780 MOVEMENTFLAG_SPLINE2 = 0x08000000, // used for flight paths
781 MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water
782 MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive)
783 MOVEMENTFLAG_UNK3 = 0x40000000
786 struct MovementInfo
788 // common
789 uint64 guid;
790 uint32 flags; // see enum MovementFlags
791 uint16 unk1;
792 uint32 time;
793 float x, y, z, o;
794 // transport
795 uint64 t_guid;
796 float t_x, t_y, t_z, t_o;
797 uint32 t_time;
798 int8 t_seat;
799 // swimming and unknown
800 float s_pitch;
801 // last fall time
802 uint32 fallTime;
803 // jumping
804 float j_unk, j_sinAngle, j_cosAngle, j_xyspeed;
805 // spline
806 float u_unk1;
808 MovementInfo()
810 flags = MOVEMENTFLAG_NONE;
811 time = t_time = fallTime = 0;
812 unk1 = 0;
813 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;
814 t_guid = 0;
817 void AddMovementFlag(MovementFlags f) { flags |= f; }
818 void RemoveMovementFlag(MovementFlags f) { flags &= ~f; }
819 bool HasMovementFlag(MovementFlags f) const { return flags & f; }
820 MovementFlags GetMovementFlags() const { return MovementFlags(flags); }
821 void SetMovementFlags(MovementFlags f) { flags = f; }
824 // flags that use in movement check for example at spell casting
825 MovementFlags const movementFlagsMask = MovementFlags(
826 MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
827 MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1 |
828 MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_FLY_UP |
829 MOVEMENTFLAG_FLYING |MOVEMENTFLAG_SPLINE
832 MovementFlags const movementOrTurningFlagsMask = MovementFlags(
833 movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT
835 class InstanceSave;
837 enum RestType
839 REST_TYPE_NO = 0,
840 REST_TYPE_IN_TAVERN = 1,
841 REST_TYPE_IN_CITY = 2
844 enum DuelCompleteType
846 DUEL_INTERUPTED = 0,
847 DUEL_WON = 1,
848 DUEL_FLED = 2
851 enum TeleportToOptions
853 TELE_TO_GM_MODE = 0x01,
854 TELE_TO_NOT_LEAVE_TRANSPORT = 0x02,
855 TELE_TO_NOT_LEAVE_COMBAT = 0x04,
856 TELE_TO_NOT_UNSUMMON_PET = 0x08,
857 TELE_TO_SPELL = 0x10,
860 /// Type of environmental damages
861 enum EnviromentalDamage
863 DAMAGE_EXHAUSTED = 0,
864 DAMAGE_DROWNING = 1,
865 DAMAGE_FALL = 2,
866 DAMAGE_LAVA = 3,
867 DAMAGE_SLIME = 4,
868 DAMAGE_FIRE = 5,
869 DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
872 enum PlayedTimeIndex
874 PLAYED_TIME_TOTAL = 0,
875 PLAYED_TIME_LEVEL = 1
878 #define MAX_PLAYED_TIME_INDEX 2
880 // used at player loading query list preparing, and later result selection
881 enum PlayerLoginQueryIndex
883 PLAYER_LOGIN_QUERY_LOADFROM = 0,
884 PLAYER_LOGIN_QUERY_LOADGROUP = 1,
885 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES = 2,
886 PLAYER_LOGIN_QUERY_LOADAURAS = 3,
887 PLAYER_LOGIN_QUERY_LOADSPELLS = 4,
888 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS = 5,
889 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS = 6,
890 PLAYER_LOGIN_QUERY_LOADREPUTATION = 7,
891 PLAYER_LOGIN_QUERY_LOADINVENTORY = 8,
892 PLAYER_LOGIN_QUERY_LOADACTIONS = 9,
893 PLAYER_LOGIN_QUERY_LOADMAILCOUNT = 10,
894 PLAYER_LOGIN_QUERY_LOADMAILDATE = 11,
895 PLAYER_LOGIN_QUERY_LOADSOCIALLIST = 12,
896 PLAYER_LOGIN_QUERY_LOADHOMEBIND = 13,
897 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS = 14,
898 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES = 15,
899 PLAYER_LOGIN_QUERY_LOADGUILD = 16,
900 PLAYER_LOGIN_QUERY_LOADARENAINFO = 17,
901 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS = 18,
902 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS = 19,
903 PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS = 20,
904 PLAYER_LOGIN_QUERY_LOADBGDATA = 21,
905 PLAYER_LOGIN_QUERY_LOADACCOUNTDATA = 22,
906 PLAYER_LOGIN_QUERY_LOADSKILLS = 23,
907 MAX_PLAYER_LOGIN_QUERY = 24
910 enum PlayerDelayedOperations
912 DELAYED_SAVE_PLAYER = 0x01,
913 DELAYED_RESURRECT_PLAYER = 0x02,
914 DELAYED_SPELL_CAST_DESERTER = 0x04,
915 DELAYED_BG_MOUNT_RESTORE = 0x08, ///< Flag to restore mount state after teleport from BG
916 DELAYED_BG_TAXI_RESTORE = 0x10, ///< Flag to restore taxi state after teleport from BG
917 DELAYED_END
920 // Player summoning auto-decline time (in secs)
921 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
922 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
924 struct InstancePlayerBind
926 InstanceSave *save;
927 bool perm;
928 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
929 that aren't already permanently bound when they are inside when a boss is killed
930 or when they enter an instance that the group leader is permanently bound to. */
931 InstancePlayerBind() : save(NULL), perm(false) {}
934 class MANGOS_DLL_SPEC PlayerTaxi
936 public:
937 PlayerTaxi();
938 ~PlayerTaxi() {}
939 // Nodes
940 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level);
941 void LoadTaxiMask(const char* data);
943 bool IsTaximaskNodeKnown(uint32 nodeidx) const
945 uint8 field = uint8((nodeidx - 1) / 32);
946 uint32 submask = 1<<((nodeidx-1)%32);
947 return (m_taximask[field] & submask) == submask;
949 bool SetTaximaskNode(uint32 nodeidx)
951 uint8 field = uint8((nodeidx - 1) / 32);
952 uint32 submask = 1<<((nodeidx-1)%32);
953 if ((m_taximask[field] & submask) != submask )
955 m_taximask[field] |= submask;
956 return true;
958 else
959 return false;
961 void AppendTaximaskTo(ByteBuffer& data, bool all);
963 // Destinations
964 bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team);
965 std::string SaveTaxiDestinationsToString();
967 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
968 void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
969 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
970 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
971 uint32 GetCurrentTaxiPath() const;
972 uint32 NextTaxiDestination()
974 m_TaxiDestinations.pop_front();
975 return GetTaxiDestination();
977 bool empty() const { return m_TaxiDestinations.empty(); }
979 friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
980 private:
981 TaxiMask m_taximask;
982 std::deque<uint32> m_TaxiDestinations;
985 std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
987 class Player;
989 /// Holder for BattleGround data
990 struct BGData
992 BGData() : bgInstanceID(0), bgTypeID(BATTLEGROUND_TYPE_NONE), bgAfkReportedCount(0), bgAfkReportedTimer(0),
993 bgTeam(0), mountSpell(0) { ClearTaxiPath(); }
996 uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID,
997 /// when player is teleported to BG - (it is battleground's GUID)
998 BattleGroundTypeId bgTypeID;
1000 std::set<uint32> bgAfkReporter;
1001 uint8 bgAfkReportedCount;
1002 time_t bgAfkReportedTimer;
1004 uint32 bgTeam; ///< What side the player will be added to
1007 uint32 mountSpell;
1008 uint32 taxiPath[2];
1010 WorldLocation joinPos; ///< From where player entered BG
1012 void ClearTaxiPath() { taxiPath[0] = taxiPath[1] = 0; }
1013 bool HasTaxiPath() const { return taxiPath[0] && taxiPath[1]; }
1016 class MANGOS_DLL_SPEC Player : public Unit
1018 friend class WorldSession;
1019 friend void Item::AddToUpdateQueueOf(Player *player);
1020 friend void Item::RemoveFromUpdateQueueOf(Player *player);
1021 public:
1022 explicit Player (WorldSession *session);
1023 ~Player ( );
1025 void CleanupsBeforeDelete();
1027 static UpdateMask updateVisualBits;
1028 static void InitVisibleBits();
1030 void AddToWorld();
1031 void RemoveFromWorld();
1033 bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
1035 bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
1037 return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation, options);
1040 bool TeleportToBGEntryPoint();
1042 void SetSummonPoint(uint32 mapid, float x, float y, float z)
1044 m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
1045 m_summon_mapid = mapid;
1046 m_summon_x = x;
1047 m_summon_y = y;
1048 m_summon_z = z;
1050 void SummonIfPossible(bool agree);
1052 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 );
1054 void Update( uint32 time );
1056 static bool BuildEnumData( QueryResult * result, WorldPacket * p_data );
1058 void SetInWater(bool apply);
1060 bool IsInWater() const { return m_isInWater; }
1061 bool IsUnderWater() const;
1063 void SendInitialPacketsBeforeAddToMap();
1064 void SendInitialPacketsAfterAddToMap();
1065 void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0);
1066 void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
1068 Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
1069 GameObject* GetGameObjectIfCanInteractWith(uint64 guid, uint32 gameobject_type = MAX_GAMEOBJECT_TYPE) const;
1071 void UpdateVisibilityForPlayer();
1073 bool ToggleAFK();
1074 bool ToggleDND();
1075 bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
1076 bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
1077 uint8 chatTag() const;
1078 std::string afkMsg;
1079 std::string dndMsg;
1081 uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
1083 PlayerSocial *GetSocial() { return m_social; }
1085 PlayerTaxi m_taxi;
1086 void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1087 bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = NULL, uint32 spellid = 0);
1088 bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0);
1089 // mount_id can be used in scripting calls
1090 void ContinueTaxiFlight();
1091 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); }
1092 void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; }
1093 bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
1094 void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
1095 bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
1096 void SetGameMaster(bool on);
1097 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); }
1098 void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
1099 bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
1100 void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
1101 bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
1102 void SetGMVisible(bool on);
1103 void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
1105 void GiveXP(uint32 xp, Unit* victim);
1106 void GiveLevel(uint32 level);
1108 void InitStatsForLevel(bool reapplyMods = false);
1110 // Played Time Stuff
1111 time_t m_logintime;
1112 time_t m_Last_tick;
1113 uint32 m_Played_time[MAX_PLAYED_TIME_INDEX];
1114 uint32 GetTotalPlayedTime() { return m_Played_time[PLAYED_TIME_TOTAL]; }
1115 uint32 GetLevelPlayedTime() { return m_Played_time[PLAYED_TIME_LEVEL]; }
1117 void setDeathState(DeathState s); // overwrite Unit::setDeathState
1119 void InnEnter (int time, uint32 mapid, float x, float y, float z)
1121 inn_pos_mapid = mapid;
1122 inn_pos_x = x;
1123 inn_pos_y = y;
1124 inn_pos_z = z;
1125 time_inn_enter = time;
1128 float GetRestBonus() const { return m_rest_bonus; }
1129 void SetRestBonus(float rest_bonus_new);
1131 RestType GetRestType() const { return rest_type; }
1132 void SetRestType(RestType n_r_type) { rest_type = n_r_type; }
1134 uint32 GetInnPosMapId() const { return inn_pos_mapid; }
1135 float GetInnPosX() const { return inn_pos_x; }
1136 float GetInnPosY() const { return inn_pos_y; }
1137 float GetInnPosZ() const { return inn_pos_z; }
1139 int GetTimeInnEnter() const { return time_inn_enter; }
1140 void UpdateInnerTime (int time) { time_inn_enter = time; }
1142 void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
1143 void RemoveMiniPet();
1144 Pet* GetMiniPet();
1145 void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); }
1146 uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
1148 void Say(const std::string& text, const uint32 language);
1149 void Yell(const std::string& text, const uint32 language);
1150 void TextEmote(const std::string& text);
1151 void Whisper(const std::string& text, const uint32 language,uint64 receiver);
1152 void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
1154 /*********************************************************/
1155 /*** STORAGE SYSTEM ***/
1156 /*********************************************************/
1158 void SetVirtualItemSlot( uint8 i, Item* item);
1159 void SetSheath( SheathState sheathed ); // overwrite Unit version
1160 uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const;
1161 uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const;
1162 Item* GetItemByGuid( uint64 guid ) const;
1163 Item* GetItemByPos( uint16 pos ) const;
1164 Item* GetItemByPos( uint8 bag, uint8 slot ) const;
1165 Item* GetWeaponForAttack(WeaponAttackType attackType) const { return GetWeaponForAttack(attackType,false,false); }
1166 Item* GetWeaponForAttack(WeaponAttackType attackType, bool nonbroken, bool useable) const;
1167 Item* GetShield(bool useable = false) const;
1168 static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot
1169 std::vector<Item *> &GetItemUpdateQueue() { return m_itemUpdateQueue; }
1170 static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8, pos & 255); }
1171 static bool IsInventoryPos( uint8 bag, uint8 slot );
1172 static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8, pos & 255); }
1173 static bool IsEquipmentPos( uint8 bag, uint8 slot );
1174 static bool IsBagPos( uint16 pos );
1175 static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8, pos & 255); }
1176 static bool IsBankPos( uint8 bag, uint8 slot );
1177 bool IsValidPos( uint16 pos, bool explicit_pos ) { return IsValidPos(pos >> 8, pos & 255, explicit_pos); }
1178 bool IsValidPos( uint8 bag, uint8 slot, bool explicit_pos );
1179 uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); }
1180 void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); }
1181 bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
1182 bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL);
1183 bool CanNoReagentCast(SpellEntry const* spellInfo) const;
1184 bool HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
1185 bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
1186 uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); }
1187 uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry, count, NULL); }
1188 uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
1190 return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count );
1192 uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
1194 if(!pItem)
1195 return EQUIP_ERR_ITEM_NOT_FOUND;
1196 uint32 count = pItem->GetCount();
1197 return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL );
1200 uint8 CanStoreItems( Item **pItem,int count) const;
1201 uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
1202 uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
1204 uint8 CanEquipUniqueItem( Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
1205 uint8 CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
1206 uint8 CanUnequipItems( uint32 item, uint32 count ) const;
1207 uint8 CanUnequipItem( uint16 src, bool swap ) const;
1208 uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
1209 uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
1210 bool HasItemTotemCategory( uint32 TotemCategory ) const;
1211 bool CanUseItem( ItemPrototype const *pItem );
1212 uint8 CanUseAmmo( uint32 item ) const;
1213 Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
1214 Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
1215 Item* EquipNewItem( uint16 pos, uint32 item, bool update );
1216 Item* EquipItem( uint16 pos, Item *pItem, bool update );
1217 void AutoUnequipOffhandIfNeed();
1218 bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
1219 void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false);
1220 void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG,NULL_SLOT,loot_id,store,broadcast); }
1222 uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
1223 uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
1225 void ApplyEquipCooldown( Item * pItem );
1226 void SetAmmo( uint32 item );
1227 void RemoveAmmo();
1228 float GetAmmoDPS() const { return m_ammoDPS; }
1229 bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const;
1230 void QuickEquipItem( uint16 pos, Item *pItem);
1231 void VisualizeItem( uint8 slot, Item *pItem);
1232 void SetVisibleItemSlot(uint8 slot, Item *pItem);
1233 Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update )
1235 return StoreItem( dest, pItem, update);
1237 Item* BankItem( uint16 pos, Item *pItem, bool update );
1238 void RemoveItem( uint8 bag, uint8 slot, bool update );
1239 void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
1240 // in trade, auction, guild bank, mail....
1241 void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
1242 // in trade, guild bank, mail....
1243 void RemoveItemDependentAurasAndCasts( Item * pItem );
1244 void DestroyItem( uint8 bag, uint8 slot, bool update );
1245 void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
1246 void DestroyItemCount( Item* item, uint32& count, bool update );
1247 void DestroyConjuredItems( bool update );
1248 void DestroyZoneLimitedItem( bool update, uint32 new_zone );
1249 void SplitItem( uint16 src, uint16 dst, uint32 count );
1250 void SwapItem( uint16 src, uint16 dst );
1251 void AddItemToBuyBackSlot( Item *pItem );
1252 Item* GetItemFromBuyBackSlot( uint32 slot );
1253 void RemoveItemFromBuyBackSlot( uint32 slot, bool del );
1254 uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
1255 void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 );
1256 void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
1257 void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
1258 void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
1259 void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
1260 uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
1261 uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
1262 bool IsUseEquipedWeapon( bool mainhand ) const
1264 // disarm applied only to mainhand weapon
1265 return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) );
1267 bool IsTwoHandUsed() const
1269 Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
1270 return mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
1272 void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false );
1273 bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot);
1275 float GetReputationPriceDiscount( Creature const* pCreature ) const;
1276 Player* GetTrader() const { return pTrader; }
1277 void ClearTrade();
1278 void TradeCancel(bool sendback);
1279 uint16 GetItemPosByTradeSlot(uint32 slot) const { return tradeItems[slot]; }
1281 void UpdateEnchantTime(uint32 time);
1282 void UpdateItemDuration(uint32 time, bool realtimeonly=false);
1283 void AddEnchantmentDurations(Item *item);
1284 void RemoveEnchantmentDurations(Item *item);
1285 void RemoveAllEnchantments(EnchantmentSlot slot);
1286 void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration);
1287 void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false);
1288 void ApplyEnchantment(Item *item,bool apply);
1289 void SendEnchantmentDurations();
1290 void BuildEnchantmentsInfoData(WorldPacket *data);
1291 void AddItemDurations(Item *item);
1292 void RemoveItemDurations(Item *item);
1293 void SendItemDurations();
1294 void LoadCorpse();
1295 void LoadPet();
1297 uint32 m_stableSlots;
1299 /*********************************************************/
1300 /*** GOSSIP SYSTEM ***/
1301 /*********************************************************/
1303 void PrepareGossipMenu(WorldObject *pSource, uint32 menuId = 0);
1304 void SendPreparedGossip(WorldObject *pSource);
1305 void OnGossipSelect(WorldObject *pSource, uint32 gossipListId, uint32 menuId);
1307 uint32 GetGossipTextId(uint32 menuId);
1308 uint32 GetGossipTextId(WorldObject *pSource);
1309 uint32 GetDefaultGossipMenuForSource(WorldObject *pSource);
1311 /*********************************************************/
1312 /*** QUEST SYSTEM ***/
1313 /*********************************************************/
1315 // Return player level when QuestLevel is dynamic (-1)
1316 uint32 GetQuestLevelForPlayer(Quest const* pQuest) const { return pQuest && (pQuest->GetQuestLevel() > 0) ? (uint32)pQuest->GetQuestLevel() : getLevel(); }
1318 void PrepareQuestMenu( uint64 guid );
1319 void SendPreparedQuest( uint64 guid );
1320 bool IsActiveQuest( uint32 quest_id ) const;
1321 Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
1322 bool CanSeeStartQuest( Quest const *pQuest );
1323 bool CanTakeQuest( Quest const *pQuest, bool msg );
1324 bool CanAddQuest( Quest const *pQuest, bool msg );
1325 bool CanCompleteQuest( uint32 quest_id );
1326 bool CanCompleteRepeatableQuest(Quest const *pQuest);
1327 bool CanRewardQuest( Quest const *pQuest, bool msg );
1328 bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg );
1329 void AddQuest( Quest const *pQuest, Object *questGiver );
1330 void CompleteQuest( uint32 quest_id );
1331 void IncompleteQuest( uint32 quest_id );
1332 void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
1334 void FailQuest( uint32 quest_id );
1335 bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg );
1336 bool SatisfyQuestLevel( Quest const* qInfo, bool msg );
1337 bool SatisfyQuestLog( bool msg );
1338 bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg );
1339 bool SatisfyQuestRace( Quest const* qInfo, bool msg );
1340 bool SatisfyQuestReputation( Quest const* qInfo, bool msg );
1341 bool SatisfyQuestStatus( Quest const* qInfo, bool msg );
1342 bool SatisfyQuestTimed( Quest const* qInfo, bool msg );
1343 bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg );
1344 bool SatisfyQuestNextChain( Quest const* qInfo, bool msg );
1345 bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg );
1346 bool SatisfyQuestDay( Quest const* qInfo, bool msg );
1347 bool GiveQuestSourceItem( Quest const *pQuest );
1348 bool TakeQuestSourceItem( uint32 quest_id, bool msg );
1349 bool GetQuestRewardStatus( uint32 quest_id ) const;
1350 QuestStatus GetQuestStatus( uint32 quest_id ) const;
1351 void SetQuestStatus( uint32 quest_id, QuestStatus status );
1353 void SetDailyQuestStatus( uint32 quest_id );
1354 void ResetDailyQuestStatus();
1356 uint16 FindQuestSlot( uint32 quest_id ) const;
1357 uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
1358 uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
1359 uint32 GetQuestSlotCounters(uint16 slot)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); }
1360 uint8 GetQuestSlotCounter(uint16 slot,uint8 counter) const { return GetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter); }
1361 uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
1362 void SetQuestSlot(uint16 slot,uint32 quest_id, uint32 timer = 0)
1364 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET,quest_id);
1365 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,0);
1366 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,0);
1367 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer);
1369 void SetQuestSlotCounter(uint16 slot,uint8 counter,uint8 count) { SetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter,count); }
1370 void SetQuestSlotState(uint16 slot,uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1371 void RemoveQuestSlotState(uint16 slot,uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1372 void SetQuestSlotTimer(uint16 slot,uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); }
1373 void SwapQuestSlot(uint16 slot1,uint16 slot2)
1375 for (int i = 0; i < MAX_QUEST_OFFSET ; ++i )
1377 uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i);
1378 uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i);
1380 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i, temp2);
1381 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i, temp1);
1384 uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
1385 void AreaExploredOrEventHappens( uint32 questId );
1386 void GroupEventHappens( uint32 questId, WorldObject const* pEventObject );
1387 void ItemAddedQuestCheck( uint32 entry, uint32 count );
1388 void ItemRemovedQuestCheck( uint32 entry, uint32 count );
1389 void KilledMonster( CreatureInfo const* cInfo, uint64 guid );
1390 void KilledMonsterCredit( uint32 entry, uint64 guid );
1391 void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id );
1392 void TalkedToCreature( uint32 entry, uint64 guid );
1393 void MoneyChanged( uint32 value );
1394 void ReputationChanged(FactionEntry const* factionEntry );
1395 bool HasQuestForItem( uint32 itemid ) const;
1396 bool HasQuestForGO(int32 GOId) const;
1397 void UpdateForQuestWorldObjects();
1398 bool CanShareQuest(uint32 quest_id) const;
1400 void SendQuestComplete( uint32 quest_id );
1401 void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
1402 void SendQuestFailed( uint32 quest_id );
1403 void SendQuestTimerFailed( uint32 quest_id );
1404 void SendCanTakeQuestResponse( uint32 msg );
1405 void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver);
1406 void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
1407 void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
1408 void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count );
1410 uint64 GetDivider() { return m_divider; }
1411 void SetDivider( uint64 guid ) { m_divider = guid; }
1413 uint32 GetInGameTime() { return m_ingametime; }
1415 void SetInGameTime( uint32 time ) { m_ingametime = time; }
1417 void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); }
1418 void RemoveTimedQuest( uint32 quest_id ) { m_timedquests.erase(quest_id); }
1420 /*********************************************************/
1421 /*** LOAD SYSTEM ***/
1422 /*********************************************************/
1424 bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
1426 static bool LoadValuesArrayFromDB(Tokens& data,uint64 guid);
1427 static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
1428 static float GetFloatValueFromArray(Tokens const& data, uint16 index);
1429 static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid);
1430 static float GetFloatValueFromDB(uint16 index, uint64 guid);
1431 static uint32 GetZoneIdFromDB(uint64 guid);
1432 static uint32 GetLevelFromDB(uint64 guid);
1433 static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
1435 /*********************************************************/
1436 /*** SAVE SYSTEM ***/
1437 /*********************************************************/
1439 void SaveToDB();
1440 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1441 void SaveGoldToDB();
1442 void SaveDataFieldToDB();
1443 static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
1444 static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value);
1445 static void SetFloatValueInArray(Tokens& data,uint16 index, float value);
1446 static void SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid);
1447 static void SetFloatValueInDB(uint16 index, float value, uint64 guid);
1448 static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
1449 static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid);
1451 bool m_mailsLoaded;
1452 bool m_mailsUpdated;
1454 void SendPetTameFailure(PetTameFailureReason reason);
1456 void SetBindPoint(uint64 guid);
1457 void SendTalentWipeConfirm(uint64 guid);
1458 void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
1459 void SendPetSkillWipeConfirm();
1460 void CalcRage( uint32 damage,bool attacker );
1461 void RegenerateAll(uint32 diff = REGEN_TIME_FULL);
1462 void Regenerate(Powers power, uint32 diff);
1463 void RegenerateHealth(uint32 diff);
1464 void setRegenTimer(uint32 time) {m_regenTimer = time;}
1465 void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
1467 uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
1468 void ModifyMoney( int32 d )
1470 if(d < 0)
1471 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
1472 else
1473 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
1475 // "At Gold Limit"
1476 if(GetMoney() >= MAX_MONEY_AMOUNT)
1477 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL);
1479 void SetMoney( uint32 value )
1481 SetUInt32Value (PLAYER_FIELD_COINAGE, value);
1482 MoneyChanged( value );
1483 UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED);
1486 QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
1488 const uint64& GetSelection( ) const { return m_curSelection; }
1489 void SetSelection(const uint64 &guid) { m_curSelection = guid; SetTargetGUID(guid); }
1491 uint8 GetComboPoints() { return m_comboPoints; }
1492 const uint64& GetComboTarget() const { return m_comboTarget; }
1494 void AddComboPoints(Unit* target, int8 count);
1495 void ClearComboPoints();
1496 void SendComboPoints();
1498 void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0);
1499 void SendNewMail();
1500 void UpdateNextMailTimeAndUnreads();
1501 void AddNewMailDeliverTime(time_t deliver_time);
1502 bool IsMailsLoaded() const { return m_mailsLoaded; }
1504 void RemoveMail(uint32 id);
1506 void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
1507 uint32 GetMailSize() { return m_mail.size(); }
1508 Mail* GetMail(uint32 id);
1510 PlayerMails::iterator GetMailBegin() { return m_mail.begin();}
1511 PlayerMails::iterator GetMailEnd() { return m_mail.end();}
1513 /*********************************************************/
1514 /*** MAILED ITEMS SYSTEM ***/
1515 /*********************************************************/
1517 uint8 unReadMails;
1518 time_t m_nextMailDelivereTime;
1520 typedef UNORDERED_MAP<uint32, Item*> ItemMap;
1522 ItemMap mMitems; // template defined in objectmgr.cpp
1524 Item* GetMItem(uint32 id)
1526 ItemMap::const_iterator itr = mMitems.find(id);
1527 return itr != mMitems.end() ? itr->second : NULL;
1530 void AddMItem(Item* it)
1532 ASSERT( it );
1533 //assert deleted, because items can be added before loading
1534 mMitems[it->GetGUIDLow()] = it;
1537 bool RemoveMItem(uint32 id)
1539 return mMitems.erase(id) ? true : false;
1542 void PetSpellInitialize();
1543 void CharmSpellInitialize();
1544 void PossessSpellInitialize();
1545 void RemovePetActionBar();
1547 bool HasSpell(uint32 spell) const;
1548 bool HasActiveSpell(uint32 spell) const; // show in spellbook
1549 TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
1550 bool IsSpellFitByClassAndRace( uint32 spell_id ) const;
1551 bool IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const;
1552 bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
1554 void SendProficiency(uint8 pr1, uint32 pr2);
1555 void SendInitialSpells();
1556 bool addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled);
1557 void learnSpell(uint32 spell_id, bool dependent);
1558 void removeSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true, bool sendUpdate = true);
1559 void resetSpells();
1560 void learnDefaultSpells();
1561 void learnQuestRewardedSpells();
1562 void learnQuestRewardedSpells(Quest const* quest);
1563 void learnSpellHighRank(uint32 spellid);
1565 uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
1566 void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
1567 bool resetTalents(bool no_cost = false);
1568 uint32 resetTalentsCost() const;
1569 void InitTalentForLevel();
1570 void BuildPlayerTalentsInfoData(WorldPacket *data);
1571 void BuildPetTalentsInfoData(WorldPacket *data);
1572 void SendTalentsInfoData(bool pet);
1573 void LearnTalent(uint32 talentId, uint32 talentRank);
1574 void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank);
1576 uint32 CalculateTalentsPoints() const;
1578 // Dual Spec
1579 uint32 GetActiveSpec() { return m_activeSpec; }
1580 void SetActiveSpec(uint32 spec) { m_activeSpec = spec; }
1581 uint32 GetSpecsCount() { return m_specsCount; }
1582 void SetSpecsCount(uint32 count) { m_specsCount = count; }
1583 void ActivateSpec(uint32 specNum);
1585 void InitGlyphsForLevel();
1586 void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); }
1587 uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); }
1588 void SetGlyph(uint8 slot, uint32 glyph) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); }
1589 uint32 GetGlyph(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot); }
1591 uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); }
1592 void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2, profs); }
1593 void InitPrimaryProfessions();
1595 PlayerSpellMap const& GetSpellMap() const { return m_spells; }
1596 PlayerSpellMap & GetSpellMap() { return m_spells; }
1598 SpellCooldowns const& GetSpellCooldownMap() const { return m_spellCooldowns; }
1600 void AddSpellMod(SpellModifier* mod, bool apply);
1601 bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL);
1602 template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL);
1603 void RemoveSpellMods(Spell const* spell);
1605 static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check
1606 static uint32 const infinityCooldownDelayCheck = MONTH/2;
1607 bool HasSpellCooldown(uint32 spell_id) const
1609 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1610 return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
1612 uint32 GetSpellCooldownDelay(uint32 spell_id) const
1614 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1615 time_t t = time(NULL);
1616 return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
1618 void AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false );
1619 void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
1620 void SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId = 0, Spell* spell = NULL);
1621 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs );
1622 void RemoveSpellCooldown(uint32 spell_id, bool update = false);
1623 void RemoveSpellCategoryCooldown(uint32 cat, bool update = false);
1624 void SendClearCooldown( uint32 spell_id, Unit* target );
1626 void RemoveArenaSpellCooldowns();
1627 void RemoveAllSpellCooldown();
1628 void _LoadSpellCooldowns(QueryResult *result);
1629 void _SaveSpellCooldowns();
1630 void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
1631 void UpdatePotionCooldown(Spell* spell = NULL);
1633 void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
1635 m_resurrectGUID = guid;
1636 m_resurrectMap = mapId;
1637 m_resurrectX = X;
1638 m_resurrectY = Y;
1639 m_resurrectZ = Z;
1640 m_resurrectHealth = health;
1641 m_resurrectMana = mana;
1643 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); }
1644 bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; }
1645 bool isRessurectRequested() const { return m_resurrectGUID != 0; }
1646 void ResurectUsingRequestData();
1648 int getCinematic()
1650 return m_cinematic;
1652 void setCinematic(int cine)
1654 m_cinematic = cine;
1657 static bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Player* player);
1658 ActionButton* addActionButton(uint8 button, uint32 action, uint8 type);
1659 void removeActionButton(uint8 button);
1660 void SendInitialActionButtons() const;
1662 PvPInfo pvpInfo;
1663 void UpdatePvP(bool state, bool ovrride=false);
1664 void UpdateZone(uint32 newZone,uint32 newArea);
1665 void UpdateArea(uint32 newArea);
1667 void UpdateZoneDependentAuras( uint32 zone_id ); // zones
1668 void UpdateAreaDependentAuras( uint32 area_id ); // subzones
1670 void UpdateAfkReport(time_t currTime);
1671 void UpdatePvPFlag(time_t currTime);
1672 void UpdateContestedPvP(uint32 currTime);
1673 void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
1674 void ResetContestedPvP()
1676 clearUnitState(UNIT_STAT_ATTACK_PLAYER);
1677 RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
1678 m_contestedPvPTimer = 0;
1681 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1682 DuelInfo *duel;
1683 void UpdateDuelFlag(time_t currTime);
1684 void CheckDuelDistance(time_t currTime);
1685 void DuelComplete(DuelCompleteType type);
1686 void SendDuelCountdown(uint32 counter);
1688 bool IsGroupVisibleFor(Player* p) const;
1689 bool IsInSameGroupWith(Player const* p) const;
1690 bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
1691 void UninviteFromGroup();
1692 static void RemoveFromGroup(Group* group, uint64 guid);
1693 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1694 void SendUpdateToOutOfRangeGroupMembers();
1696 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
1697 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
1698 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
1699 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
1700 static uint32 GetGuildIdFromDB(uint64 guid);
1701 uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
1702 static uint32 GetRankFromDB(uint64 guid);
1703 int GetGuildIdInvited() { return m_GuildIdInvited; }
1704 static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
1706 // Arena Team
1707 void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
1709 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID, ArenaTeamId);
1710 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_TYPE, type);
1712 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END)); }
1713 static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
1714 void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
1715 uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
1716 static void LeaveAllArenaTeams(uint64 guid);
1718 Difficulty GetDifficulty(bool isRaid) const { return isRaid ? m_raidDifficulty : m_dungeonDifficulty; }
1719 Difficulty GetDungeonDifficulty() const { return m_dungeonDifficulty; }
1720 Difficulty GetRaidDifficulty() const { return m_raidDifficulty; }
1721 void SetDungeonDifficulty(Difficulty dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; }
1722 void SetRaidDifficulty(Difficulty raid_difficulty) { m_raidDifficulty = raid_difficulty; }
1724 bool UpdateSkill(uint32 skill_id, uint32 step);
1725 bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step);
1727 bool UpdateCraftSkill(uint32 spellid);
1728 bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1);
1729 bool UpdateFishingSkill();
1731 uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); }
1732 uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const;
1734 uint32 GetSpellByProto(ItemPrototype *proto);
1736 float GetHealthBonusFromStamina();
1737 float GetManaBonusFromIntellect();
1739 bool UpdateStats(Stats stat);
1740 bool UpdateAllStats();
1741 void UpdateResistances(uint32 school);
1742 void UpdateArmor();
1743 void UpdateMaxHealth();
1744 void UpdateMaxPower(Powers power);
1745 void ApplyFeralAPBonus(int32 amount, bool apply);
1746 void UpdateAttackPowerAndDamage(bool ranged = false);
1747 void UpdateShieldBlockValue();
1748 void UpdateDamagePhysical(WeaponAttackType attType);
1749 void ApplySpellPowerBonus(int32 amount, bool apply);
1750 void UpdateSpellDamageAndHealingBonus();
1752 void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage);
1754 void UpdateDefenseBonusesMod();
1755 void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
1756 float GetMeleeCritFromAgility();
1757 float GetDodgeFromAgility();
1758 float GetSpellCritFromIntellect();
1759 float OCTRegenHPPerSpirit();
1760 float OCTRegenMPPerSpirit();
1761 float GetRatingCoefficient(CombatRating cr) const;
1762 float GetRatingBonusValue(CombatRating cr) const;
1763 uint32 GetBaseSpellPowerBonus() { return m_baseSpellPower; }
1765 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
1766 void UpdateBlockPercentage();
1767 void UpdateCritPercentage(WeaponAttackType attType);
1768 void UpdateAllCritPercentages();
1769 void UpdateParryPercentage();
1770 void UpdateDodgePercentage();
1771 void UpdateMeleeHitChances();
1772 void UpdateRangedHitChances();
1773 void UpdateSpellHitChances();
1775 void UpdateAllSpellCritChances();
1776 void UpdateSpellCritChance(uint32 school);
1777 void UpdateExpertise(WeaponAttackType attType);
1778 void UpdateArmorPenetration();
1779 void ApplyManaRegenBonus(int32 amount, bool apply);
1780 void UpdateManaRegen();
1782 const uint64& GetLootGUID() const { return m_lootGuid; }
1783 void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; }
1785 void RemovedInsignia(Player* looterPlr);
1787 WorldSession* GetSession() const { return m_session; }
1788 void SetSession(WorldSession *s) { m_session = s; }
1790 void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const;
1791 void DestroyForPlayer( Player *target, bool anim = false ) const;
1792 void SendDelayResponse(const uint32);
1793 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
1795 // notifiers
1796 void SendAttackSwingCantAttack();
1797 void SendAttackSwingCancelAttack();
1798 void SendAttackSwingDeadTarget();
1799 void SendAttackSwingNotInRange();
1800 void SendAttackSwingBadFacingAttack();
1801 void SendAutoRepeatCancel(Unit *target);
1802 void SendExplorationExperience(uint32 Area, uint32 Experience);
1804 void SendDungeonDifficulty(bool IsInGroup);
1805 void SendRaidDifficulty(bool IsInGroup);
1806 void ResetInstances(uint8 method, bool isRaid);
1807 void SendResetInstanceSuccess(uint32 MapId);
1808 void SendResetInstanceFailed(uint32 reason, uint32 MapId);
1809 void SendResetFailedNotify(uint32 mapid);
1811 bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
1812 void UpdateUnderwaterState( Map * m, float x, float y, float z );
1814 void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet
1815 void SendMessageToSetInRange(WorldPacket *data, float fist, bool self);
1816 // overwrite Object::SendMessageToSetInRange
1817 void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only);
1819 static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true);
1821 Corpse *GetCorpse() const;
1822 void SpawnCorpseBones();
1823 void CreateCorpse();
1824 void KillPlayer();
1825 uint32 GetResurrectionSpellId();
1826 void ResurrectPlayer(float restore_percent, bool applySickness = false);
1827 void BuildPlayerRepop();
1828 void RepopAtGraveyard();
1830 void DurabilityLossAll(double percent, bool inventory);
1831 void DurabilityLoss(Item* item, double percent);
1832 void DurabilityPointsLossAll(int32 points, bool inventory);
1833 void DurabilityPointsLoss(Item* item, int32 points);
1834 void DurabilityPointLossForEquipSlot(EquipmentSlots slot);
1835 uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank);
1836 uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank);
1838 void UpdateMirrorTimers();
1839 void StopMirrorTimers()
1841 StopMirrorTimer(FATIGUE_TIMER);
1842 StopMirrorTimer(BREATH_TIMER);
1843 StopMirrorTimer(FIRE_TIMER);
1846 void SetMovement(PlayerMovementType pType);
1848 void JoinedChannel(Channel *c);
1849 void LeftChannel(Channel *c);
1850 void CleanupChannels();
1851 void UpdateLocalChannels( uint32 newZone );
1852 void LeaveLFGChannel();
1854 void UpdateDefense();
1855 void UpdateWeaponSkill (WeaponAttackType attType);
1856 void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence);
1858 void SetSkill(uint32 id, uint16 currVal, uint16 maxVal);
1859 uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
1860 uint16 GetPureMaxSkillValue(uint32 skill) const; // max
1861 uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
1862 uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus
1863 uint16 GetPureSkillValue(uint32 skill) const; // skill value
1864 int16 GetSkillPermBonusValue(uint32 skill) const;
1865 int16 GetSkillTempBonusValue(uint32 skill) const;
1866 bool HasSkill(uint32 skill) const;
1867 void learnSkillRewardedSpells(uint32 id, uint32 value);
1869 WorldLocation& GetTeleportDest() { return m_teleport_dest; }
1870 bool IsBeingTeleported() const { return mSemaphoreTeleport_Near || mSemaphoreTeleport_Far; }
1871 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near; }
1872 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far; }
1873 void SetSemaphoreTeleportNear(bool semphsetting) { mSemaphoreTeleport_Near = semphsetting; }
1874 void SetSemaphoreTeleportFar(bool semphsetting) { mSemaphoreTeleport_Far = semphsetting; }
1875 void ProcessDelayedOperations();
1877 void CheckExploreSystem(void);
1879 static uint32 TeamForRace(uint8 race);
1880 uint32 GetTeam() const { return m_team; }
1881 static uint32 getFactionForRace(uint8 race);
1882 void setFactionForRace(uint8 race);
1884 void InitDisplayIds();
1886 bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
1887 bool RewardPlayerAndGroupAtKill(Unit* pVictim);
1888 void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
1889 bool isHonorOrXPTarget(Unit* pVictim);
1891 ReputationMgr& GetReputationMgr() { return m_reputationMgr; }
1892 ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; }
1893 ReputationRank GetReputationRank(uint32 faction_id) const;
1894 void RewardReputation(Unit *pVictim, float rate);
1895 void RewardReputation(Quest const *pQuest);
1897 void UpdateSkillsForLevel();
1898 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1899 void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
1901 /*********************************************************/
1902 /*** PVP SYSTEM ***/
1903 /*********************************************************/
1904 void UpdateArenaFields();
1905 void UpdateHonorFields();
1906 bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1);
1907 uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
1908 uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
1909 void ModifyHonorPoints( int32 value );
1910 void ModifyArenaPoints( int32 value );
1911 uint32 GetMaxPersonalArenaRatingRequirement();
1913 //End of PvP System
1915 void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0);
1916 uint16 GetDrunkValue() const { return m_drunk; }
1917 static DrunkenState GetDrunkenstateByValue(uint16 value);
1919 uint32 GetDeathTimer() const { return m_deathTimer; }
1920 uint32 GetCorpseReclaimDelay(bool pvp) const;
1921 void UpdateCorpseReclaimDelay();
1922 void SendCorpseReclaimDelay(bool load = false);
1924 uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual)
1925 bool CanParry() const { return m_canParry; }
1926 void SetCanParry(bool value);
1927 bool CanBlock() const { return m_canBlock; }
1928 void SetCanBlock(bool value);
1929 bool CanDualWield() const { return m_canDualWield; }
1930 void SetCanDualWield(bool value) { m_canDualWield = value; }
1931 bool CanTitanGrip() const { return m_canTitanGrip; }
1932 void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
1933 bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); }
1935 void SetRegularAttackTime();
1936 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }
1937 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply);
1938 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
1939 float GetTotalBaseModValue(BaseModGroup modGroup) const;
1940 float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; }
1941 void _ApplyAllStatBonuses();
1942 void _RemoveAllStatBonuses();
1943 float GetArmorPenetrationPct() const { return m_armorPenetrationPct; }
1945 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
1946 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1947 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1949 void _ApplyItemMods(Item *item,uint8 slot,bool apply);
1950 void _RemoveAllItemMods();
1951 void _ApplyAllItemMods();
1952 void _ApplyAllLevelScaleItemMods(bool apply);
1953 void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply, bool only_level_scale = false);
1954 void _ApplyAmmoBonuses();
1955 bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot);
1956 void ToggleMetaGemsActive(uint8 exceptslot, bool apply);
1957 void CorrectMetaGemEnchants(uint8 slot, bool apply);
1958 void InitDataForForm(bool reapplyMods = false);
1960 void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
1961 void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
1962 void UpdateEquipSpellsAtFormChange();
1963 void CastItemCombatSpell(Unit* Target, WeaponAttackType attType);
1964 void CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex);
1966 void SendEquipmentSetList();
1967 void SetEquipmentSet(uint32 index, EquipmentSet eqset);
1968 void DeleteEquipmentSet(uint64 setGuid);
1970 void SendInitWorldStates(uint32 zone, uint32 area);
1971 void SendUpdateWorldState(uint32 Field, uint32 Value);
1972 void SendDirectMessage(WorldPacket *data);
1974 void SendAurasForTarget(Unit *target);
1976 PlayerMenu* PlayerTalkClass;
1977 std::vector<ItemSetEffect *> ItemSetEff;
1979 void SendLoot(uint64 guid, LootType loot_type);
1980 void SendLootRelease( uint64 guid );
1981 void SendNotifyLootItemRemoved(uint8 lootSlot);
1982 void SendNotifyLootMoneyRemoved();
1984 /*********************************************************/
1985 /*** BATTLEGROUND SYSTEM ***/
1986 /*********************************************************/
1988 bool InBattleGround() const { return m_bgData.bgInstanceID != 0; }
1989 bool InArena() const;
1990 uint32 GetBattleGroundId() const { return m_bgData.bgInstanceID; }
1991 BattleGroundTypeId GetBattleGroundTypeId() const { return m_bgData.bgTypeID; }
1992 BattleGround* GetBattleGround() const;
1995 BGQueueIdBasedOnLevel GetBattleGroundQueueIdFromLevel() const;
1997 bool InBattleGroundQueue() const
1999 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2000 if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
2001 return true;
2002 return false;
2005 BattleGroundQueueTypeId GetBattleGroundQueueTypeId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueTypeId; }
2006 uint32 GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId) const
2008 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2009 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
2010 return i;
2011 return PLAYER_MAX_BATTLEGROUND_QUEUES;
2013 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
2015 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2016 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
2017 return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
2018 return false;
2020 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
2022 return GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES;
2025 void SetBattleGroundId(uint32 val, BattleGroundTypeId bgTypeId)
2027 m_bgData.bgInstanceID = val;
2028 m_bgData.bgTypeID = bgTypeId;
2030 uint32 AddBattleGroundQueueId(BattleGroundQueueTypeId val)
2032 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2034 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattleGroundQueueID[i].bgQueueTypeId == val)
2036 m_bgBattleGroundQueueID[i].bgQueueTypeId = val;
2037 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
2038 return i;
2041 return PLAYER_MAX_BATTLEGROUND_QUEUES;
2043 bool HasFreeBattleGroundQueueId()
2045 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2046 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
2047 return true;
2048 return false;
2050 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val)
2052 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2054 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == val)
2056 m_bgBattleGroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
2057 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
2058 return;
2062 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId, uint32 instanceId)
2064 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2065 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
2066 m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
2068 bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
2070 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2071 if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
2072 return true;
2073 return false;
2075 WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; }
2076 void SetBattleGroundEntryPoint();
2078 void SetBGTeam(uint32 team) { m_bgData.bgTeam = team; }
2079 uint32 GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); }
2081 void LeaveBattleground(bool teleportToEntryPoint = true);
2082 bool CanJoinToBattleground() const;
2083 bool CanReportAfkDueToLimit();
2084 void ReportedAfkBy(Player* reporter);
2085 void ClearAfkReports() { m_bgData.bgAfkReporter.clear(); }
2087 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const;
2088 bool CanUseBattleGroundObject();
2089 bool isTotalImmune();
2090 bool CanCaptureTowerPoint();
2092 /*********************************************************/
2093 /*** REST SYSTEM ***/
2094 /*********************************************************/
2096 bool isRested() const { return GetRestTime() >= 10*IN_MILISECONDS; }
2097 uint32 GetXPRestBonus(uint32 xp);
2098 uint32 GetRestTime() const { return m_restTime; }
2099 void SetRestTime(uint32 v) { m_restTime = v; }
2101 /*********************************************************/
2102 /*** ENVIROMENTAL SYSTEM ***/
2103 /*********************************************************/
2105 uint32 EnvironmentalDamage(EnviromentalDamage type, uint32 damage);
2107 /*********************************************************/
2108 /*** FLOOD FILTER SYSTEM ***/
2109 /*********************************************************/
2111 void UpdateSpeakTime();
2112 bool CanSpeak() const;
2113 void ChangeSpeakTime(int utime);
2115 /*********************************************************/
2116 /*** VARIOUS SYSTEMS ***/
2117 /*********************************************************/
2118 MovementInfo m_movementInfo;
2119 bool HasMovementFlag(MovementFlags f) const; // for script access to m_movementInfo.HasMovementFlag
2120 void UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode);
2121 Unit *m_mover;
2122 void SetFallInformation(uint32 time, float z)
2124 m_lastFallTime = time;
2125 m_lastFallZ = z;
2127 void HandleFall(MovementInfo const& movementInfo);
2129 void BuildTeleportAckMsg( WorldPacket *data, float x, float y, float z, float ang) const;
2131 bool isMoving() const { return m_movementInfo.HasMovementFlag(movementFlagsMask); }
2132 bool isMovingOrTurning() const { return m_movementInfo.HasMovementFlag(movementOrTurningFlagsMask); }
2134 bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }
2135 bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING); }
2136 bool IsKnowHowFlyIn(uint32 mapid, uint32 zone) const;
2138 void SetClientControl(Unit* target, uint8 allowMove);
2139 void SetMover(Unit* target) { m_mover = target ? target : this; }
2141 void EnterVehicle(Vehicle *vehicle);
2142 void ExitVehicle(Vehicle *vehicle);
2144 uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
2145 void SetFarSightGUID(uint64 guid);
2147 // Transports
2148 Transport * GetTransport() const { return m_transport; }
2149 void SetTransport(Transport * t) { m_transport = t; }
2151 float GetTransOffsetX() const { return m_movementInfo.t_x; }
2152 float GetTransOffsetY() const { return m_movementInfo.t_y; }
2153 float GetTransOffsetZ() const { return m_movementInfo.t_z; }
2154 float GetTransOffsetO() const { return m_movementInfo.t_o; }
2155 uint32 GetTransTime() const { return m_movementInfo.t_time; }
2156 int8 GetTransSeat() const { return m_movementInfo.t_seat; }
2158 uint32 GetSaveTimer() const { return m_nextSave; }
2159 void SetSaveTimer(uint32 timer) { m_nextSave = timer; }
2161 // Recall position
2162 uint32 m_recallMap;
2163 float m_recallX;
2164 float m_recallY;
2165 float m_recallZ;
2166 float m_recallO;
2167 void SaveRecallPosition();
2169 void SetHomebindToCurrentPos();
2170 void RelocateToHomebind() { SetLocationMapId(m_homebindMapId); Relocate(m_homebindX,m_homebindY,m_homebindZ); }
2171 bool TeleportToHomebind(uint32 options = 0) { return TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation(),options); }
2173 // currently visible objects at player client
2174 typedef std::set<uint64> ClientGUIDs;
2175 ClientGUIDs m_clientGUIDs;
2177 bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); }
2179 WorldObject const* GetViewPoint() const;
2180 bool IsVisibleInGridForPlayer(Player* pl) const;
2181 bool IsVisibleGloballyFor(Player* pl) const;
2183 void UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target);
2185 template<class T>
2186 void UpdateVisibilityOf(WorldObject const* viewPoint,T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
2188 // Stealth detection system
2189 void HandleStealthedUnitsDetection();
2191 uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
2193 bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; }
2194 void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
2195 void RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also = false);
2197 LookingForGroup m_lookingForGroup;
2199 // Temporarily removed pet cache
2200 uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
2201 void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
2202 void UnsummonPetTemporaryIfAny();
2203 void ResummonPetTemporaryUnSummonedIfAny();
2204 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
2206 void SendCinematicStart(uint32 CinematicSequenceId);
2207 void SendMovieStart(uint32 MovieId);
2209 /*********************************************************/
2210 /*** INSTANCE SYSTEM ***/
2211 /*********************************************************/
2213 typedef UNORDERED_MAP< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap;
2215 void UpdateHomebindTime(uint32 time);
2217 uint32 m_HomebindTimer;
2218 bool m_InstanceValid;
2219 // permanent binds and solo binds by difficulty
2220 BoundInstancesMap m_boundInstances[MAX_DIFFICULTY];
2221 InstancePlayerBind* GetBoundInstance(uint32 mapid, Difficulty difficulty);
2222 BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; }
2223 void UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload = false);
2224 void UnbindInstance(BoundInstancesMap::iterator &itr, Difficulty difficulty, bool unload = false);
2225 InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false);
2226 void SendRaidInfo();
2227 void SendSavedInstances();
2228 static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0);
2230 /*********************************************************/
2231 /*** GROUP SYSTEM ***/
2232 /*********************************************************/
2234 Group * GetGroupInvite() { return m_groupInvite; }
2235 void SetGroupInvite(Group *group) { m_groupInvite = group; }
2236 Group * GetGroup() { return m_group.getTarget(); }
2237 const Group * GetGroup() const { return (const Group*)m_group.getTarget(); }
2238 GroupReference& GetGroupRef() { return m_group; }
2239 void SetGroup(Group *group, int8 subgroup = -1);
2240 uint8 GetSubGroup() const { return m_group.getSubGroup(); }
2241 uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; }
2242 void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
2243 const uint64& GetAuraUpdateMask() const { return m_auraUpdateMask; }
2244 void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
2245 Player* GetNextRandomRaidMember(float radius);
2246 PartyResult CanUninviteFromGroup() const;
2247 // BattleGround Group System
2248 void SetBattleGroundRaid(Group *group, int8 subgroup = -1);
2249 void RemoveFromBattleGroundRaid();
2250 Group * GetOriginalGroup() { return m_originalGroup.getTarget(); }
2251 GroupReference& GetOriginalGroupRef() { return m_originalGroup; }
2252 uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); }
2253 void SetOriginalGroup(Group *group, int8 subgroup = -1);
2255 GridReference<Player> &GetGridRef() { return m_gridRef; }
2256 MapReference &GetMapRef() { return m_mapRef; }
2258 bool isAllowedToLoot(Creature* creature);
2260 DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
2262 // Rune functions, need check getClass() == CLASS_DEATH_KNIGHT before access
2263 uint8 GetRunesState() const { return m_runes->runeState; }
2264 RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->runes[index].BaseRune); }
2265 RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->runes[index].CurrentRune); }
2266 uint16 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; }
2267 bool IsBaseRuneSlotsOnCooldown(RuneType runeType) const;
2268 void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; }
2269 void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
2270 void SetRuneCooldown(uint8 index, uint16 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); }
2271 void ConvertRune(uint8 index, RuneType newType);
2272 void ResyncRunes(uint8 count);
2273 void AddRunePower(uint8 index);
2274 void InitRunes();
2276 AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
2277 void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0);
2278 bool HasTitle(uint32 bitIndex);
2279 bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }
2280 void SetTitle(CharTitlesEntry const* title, bool lost = false);
2282 bool isActiveObject() const { return true; }
2283 bool canSeeSpellClickOn(Creature const* creature) const;
2284 protected:
2286 uint32 m_contestedPvPTimer;
2288 /*********************************************************/
2289 /*** BATTLEGROUND SYSTEM ***/
2290 /*********************************************************/
2293 this is an array of BG queues (BgTypeIDs) in which is player
2295 struct BgBattleGroundQueueID_Rec
2297 BattleGroundQueueTypeId bgQueueTypeId;
2298 uint32 invitedToInstance;
2301 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES];
2302 BGData m_bgData;
2304 /*********************************************************/
2305 /*** QUEST SYSTEM ***/
2306 /*********************************************************/
2308 //We allow only one timed quest active at the same time. Below can then be simple value instead of set.
2309 std::set<uint32> m_timedquests;
2311 uint64 m_divider;
2312 uint32 m_ingametime;
2314 /*********************************************************/
2315 /*** LOAD SYSTEM ***/
2316 /*********************************************************/
2318 void _LoadActions(QueryResult *result);
2319 void _LoadAuras(QueryResult *result, uint32 timediff);
2320 void _LoadGlyphAuras();
2321 void _LoadBoundInstances(QueryResult *result);
2322 void _LoadInventory(QueryResult *result, uint32 timediff);
2323 void _LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery);
2324 void _LoadMail();
2325 void _LoadMailedItems(Mail *mail);
2326 void _LoadQuestStatus(QueryResult *result);
2327 void _LoadDailyQuestStatus(QueryResult *result);
2328 void _LoadGroup(QueryResult *result);
2329 void _LoadSkills(QueryResult *result);
2330 void _LoadSpells(QueryResult *result);
2331 void _LoadFriendList(QueryResult *result);
2332 bool _LoadHomeBind(QueryResult *result);
2333 void _LoadDeclinedNames(QueryResult *result);
2334 void _LoadArenaTeamInfo(QueryResult *result);
2335 void _LoadEquipmentSets(QueryResult *result);
2336 void _LoadBGData(QueryResult* result);
2338 /*********************************************************/
2339 /*** SAVE SYSTEM ***/
2340 /*********************************************************/
2342 void _SaveActions();
2343 void _SaveAuras();
2344 void _SaveInventory();
2345 void _SaveMail();
2346 void _SaveQuestStatus();
2347 void _SaveDailyQuestStatus();
2348 void _SaveSkills();
2349 void _SaveSpells();
2350 void _SaveEquipmentSets();
2351 void _SaveBGData();
2353 void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
2354 void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
2356 /*********************************************************/
2357 /*** ENVIRONMENTAL SYSTEM ***/
2358 /*********************************************************/
2359 void HandleSobering();
2360 void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen);
2361 void StopMirrorTimer(MirrorTimerType Type);
2362 void HandleDrowning(uint32 time_diff);
2363 int32 getMaxTimer(MirrorTimerType timer);
2365 /*********************************************************/
2366 /*** HONOR SYSTEM ***/
2367 /*********************************************************/
2368 time_t m_lastHonorUpdateTime;
2370 void outDebugValues() const;
2371 uint64 m_lootGuid;
2373 uint32 m_team;
2374 uint32 m_nextSave;
2375 time_t m_speakTime;
2376 uint32 m_speakCount;
2377 Difficulty m_dungeonDifficulty;
2378 Difficulty m_raidDifficulty;
2380 uint32 m_atLoginFlags;
2382 Item* m_items[PLAYER_SLOTS_COUNT];
2383 uint32 m_currentBuybackSlot;
2385 std::vector<Item*> m_itemUpdateQueue;
2386 bool m_itemUpdateQueueBlocked;
2388 uint32 m_ExtraFlags;
2389 uint64 m_curSelection;
2391 uint64 m_comboTarget;
2392 int8 m_comboPoints;
2394 QuestStatusMap mQuestStatus;
2396 SkillStatusMap mSkillStatus;
2398 uint32 m_GuildIdInvited;
2399 uint32 m_ArenaTeamIdInvited;
2401 PlayerMails m_mail;
2402 PlayerSpellMap m_spells;
2403 SpellCooldowns m_spellCooldowns;
2404 uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use
2406 uint32 m_activeSpec;
2407 uint32 m_specsCount;
2409 ActionButtonList m_actionButtons;
2411 float m_auraBaseMod[BASEMOD_END][MOD_END];
2412 int16 m_baseRatingValue[MAX_COMBAT_RATING];
2413 uint16 m_baseSpellPower;
2414 uint16 m_baseFeralAP;
2415 uint16 m_baseManaRegen;
2416 float m_armorPenetrationPct;
2418 SpellModList m_spellMods[MAX_SPELLMOD];
2419 int32 m_SpellModRemoveCount;
2420 EnchantDurationList m_enchantDuration;
2421 ItemDurationList m_itemDuration;
2423 uint64 m_resurrectGUID;
2424 uint32 m_resurrectMap;
2425 float m_resurrectX, m_resurrectY, m_resurrectZ;
2426 uint32 m_resurrectHealth, m_resurrectMana;
2428 WorldSession *m_session;
2430 typedef std::list<Channel*> JoinedChannelsList;
2431 JoinedChannelsList m_channels;
2433 int m_cinematic;
2435 Player *pTrader;
2436 bool acceptTrade;
2437 uint16 tradeItems[TRADE_SLOT_COUNT];
2438 uint32 tradeGold;
2440 bool m_DailyQuestChanged;
2441 time_t m_lastDailyQuestTime;
2443 uint32 m_drunkTimer;
2444 uint16 m_drunk;
2445 uint32 m_weaponChangeTimer;
2447 uint32 m_zoneUpdateId;
2448 uint32 m_zoneUpdateTimer;
2449 uint32 m_areaUpdateId;
2451 uint32 m_deathTimer;
2452 time_t m_deathExpireTime;
2454 uint32 m_restTime;
2456 uint32 m_WeaponProficiency;
2457 uint32 m_ArmorProficiency;
2458 bool m_canParry;
2459 bool m_canBlock;
2460 bool m_canDualWield;
2461 bool m_canTitanGrip;
2462 uint8 m_swingErrorMsg;
2463 float m_ammoDPS;
2465 ////////////////////Rest System/////////////////////
2466 int time_inn_enter;
2467 uint32 inn_pos_mapid;
2468 float inn_pos_x;
2469 float inn_pos_y;
2470 float inn_pos_z;
2471 float m_rest_bonus;
2472 RestType rest_type;
2473 ////////////////////Rest System/////////////////////
2475 // Transports
2476 Transport * m_transport;
2478 uint32 m_resetTalentsCost;
2479 time_t m_resetTalentsTime;
2480 uint32 m_usedTalentCount;
2481 uint32 m_questRewardTalentCount;
2483 // Social
2484 PlayerSocial *m_social;
2486 // Groups
2487 GroupReference m_group;
2488 GroupReference m_originalGroup;
2489 Group *m_groupInvite;
2490 uint32 m_groupUpdateMask;
2491 uint64 m_auraUpdateMask;
2493 uint64 m_miniPet;
2495 // Player summoning
2496 time_t m_summon_expire;
2497 uint32 m_summon_mapid;
2498 float m_summon_x;
2499 float m_summon_y;
2500 float m_summon_z;
2502 DeclinedName *m_declinedname;
2503 Runes *m_runes;
2504 EquipmentSets m_EquipmentSets;
2505 private:
2506 // internal common parts for CanStore/StoreItem functions
2507 uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
2508 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;
2509 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;
2510 Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
2512 void UpdateKnownCurrencies(uint32 itemId, bool apply);
2513 int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest);
2514 void AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& questStatusData );
2516 bool IsCanDelayTeleport() const { return m_bCanDelayTeleport; }
2517 void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; }
2518 bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; }
2519 void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; }
2521 void ScheduleDelayedOperation(uint32 operation)
2523 if(operation < DELAYED_END)
2524 m_DelayedOperations |= operation;
2527 GridReference<Player> m_gridRef;
2528 MapReference m_mapRef;
2530 // Homebind coordinates
2531 uint32 m_homebindMapId;
2532 uint16 m_homebindZoneId;
2533 float m_homebindX;
2534 float m_homebindY;
2535 float m_homebindZ;
2537 uint32 m_lastFallTime;
2538 float m_lastFallZ;
2540 int32 m_MirrorTimer[MAX_TIMERS];
2541 uint8 m_MirrorTimerFlags;
2542 uint8 m_MirrorTimerFlagsLast;
2543 bool m_isInWater;
2545 // Current teleport data
2546 WorldLocation m_teleport_dest;
2547 uint32 m_teleport_options;
2548 bool mSemaphoreTeleport_Near;
2549 bool mSemaphoreTeleport_Far;
2551 uint32 m_DelayedOperations;
2552 bool m_bCanDelayTeleport;
2553 bool m_bHasDelayedTeleport;
2555 uint32 m_DetectInvTimer;
2557 // Temporary removed pet cache
2558 uint32 m_temporaryUnsummonedPetNumber;
2559 uint32 m_oldpetspell;
2561 AchievementMgr m_achievementMgr;
2562 ReputationMgr m_reputationMgr;
2565 void AddItemsSetItem(Player*player,Item *item);
2566 void RemoveItemsSetItem(Player*player,ItemPrototype const *proto);
2568 // "the bodies of template functions must be made available in a header file"
2569 template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell)
2571 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
2572 if (!spellInfo) return 0;
2573 int32 totalpct = 0;
2574 int32 totalflat = 0;
2575 for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
2577 SpellModifier *mod = *itr;
2579 if(!IsAffectedBySpellmod(spellInfo,mod,spell))
2580 continue;
2581 if (mod->type == SPELLMOD_FLAT)
2582 totalflat += mod->value;
2583 else if (mod->type == SPELLMOD_PCT)
2585 // skip percent mods for null basevalue (most important for spell mods with charges )
2586 if(basevalue == T(0))
2587 continue;
2589 // special case (skip >10sec spell casts for instant cast setting)
2590 if( mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10*IN_MILISECONDS) && mod->value <= -100)
2591 continue;
2593 totalpct += mod->value;
2596 if (mod->charges > 0 )
2598 --mod->charges;
2599 if (mod->charges == 0)
2601 mod->charges = -1;
2602 mod->lastAffected = spell;
2603 if(!mod->lastAffected)
2604 mod->lastAffected = FindCurrentSpellBySpellId(spellId);
2605 ++m_SpellModRemoveCount;
2610 float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat;
2611 basevalue = T((float)basevalue + diff);
2612 return T(diff);
2614 #endif