[10050] Implement apply non-trade slot item enchanting at trade complete.
[getmangos.git] / src / game / Player.h
blobbdaa399914378141368a8b251e629f4867bc2388
1 /*
2 * Copyright (C) 2005-2010 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 PlayerMenu;
49 class Transport;
50 class UpdateMask;
51 class SpellCastTargets;
52 class PlayerSocial;
53 class Vehicle;
54 class InstanceSave;
55 class Spell;
56 class Item;
58 typedef std::deque<Mail*> PlayerMails;
60 #define PLAYER_MAX_SKILLS 127
61 #define PLAYER_MAX_DAILY_QUESTS 25
62 #define PLAYER_EXPLORED_ZONES_SIZE 128
64 // Note: SPELLMOD_* values is aura types in fact
65 enum SpellModType
67 SPELLMOD_FLAT = 107, // SPELL_AURA_ADD_FLAT_MODIFIER
68 SPELLMOD_PCT = 108 // SPELL_AURA_ADD_PCT_MODIFIER
71 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
72 enum PlayerUnderwaterState
74 UNDERWATER_NONE = 0x00,
75 UNDERWATER_INWATER = 0x01, // terrain type is water and player is afflicted by it
76 UNDERWATER_INLAVA = 0x02, // terrain type is lava and player is afflicted by it
77 UNDERWATER_INSLIME = 0x04, // terrain type is lava and player is afflicted by it
78 UNDERWATER_INDARKWATER = 0x08, // terrain type is dark water and player is afflicted by it
80 UNDERWATER_EXIST_TIMERS = 0x10
83 enum BuyBankSlotResult
85 ERR_BANKSLOT_FAILED_TOO_MANY = 0,
86 ERR_BANKSLOT_INSUFFICIENT_FUNDS = 1,
87 ERR_BANKSLOT_NOTBANKER = 2,
88 ERR_BANKSLOT_OK = 3
91 enum PlayerSpellState
93 PLAYERSPELL_UNCHANGED = 0,
94 PLAYERSPELL_CHANGED = 1,
95 PLAYERSPELL_NEW = 2,
96 PLAYERSPELL_REMOVED = 3
99 struct PlayerSpell
101 PlayerSpellState state : 8;
102 bool active : 1; // show in spellbook
103 bool dependent : 1; // learned as result another spell learn, skill grow, quest reward, etc
104 bool disabled : 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
107 struct PlayerTalent
109 PlayerSpellState state;
110 TalentEntry const *m_talentEntry;
111 uint32 currentRank;
114 typedef UNORDERED_MAP<uint32, PlayerSpell> PlayerSpellMap;
115 typedef UNORDERED_MAP<uint32, PlayerTalent> PlayerTalentMap;
117 // Spell modifier (used for modify other spells)
118 struct SpellModifier
120 SpellModifier() : charges(0), lastAffected(NULL) {}
122 SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, uint32 _spellId, uint64 _mask, uint32 _mask2 = 0, int16 _charges = 0)
123 : op(_op), type(_type), charges(_charges), value(_value), mask(_mask), mask2(_mask2), spellId(_spellId), lastAffected(NULL)
126 SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, SpellEffectIndex eff, int16 _charges = 0);
128 SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, Aura const* aura, int16 _charges = 0);
130 bool isAffectedOnSpell(SpellEntry const *spell) const;
132 SpellModOp op : 8;
133 SpellModType type : 8;
134 int16 charges : 16;
135 int32 value;
136 uint64 mask;
137 uint32 mask2;
138 uint32 spellId;
139 Spell const* lastAffected;
142 typedef std::list<SpellModifier*> SpellModList;
144 struct SpellCooldown
146 time_t end;
147 uint16 itemid;
150 typedef std::map<uint32, SpellCooldown> SpellCooldowns;
152 enum TrainerSpellState
154 TRAINER_SPELL_GREEN = 0,
155 TRAINER_SPELL_RED = 1,
156 TRAINER_SPELL_GRAY = 2,
157 TRAINER_SPELL_GREEN_DISABLED = 10 // custom value, not send to client: formally green but learn not allowed
160 enum ActionButtonUpdateState
162 ACTIONBUTTON_UNCHANGED = 0,
163 ACTIONBUTTON_CHANGED = 1,
164 ACTIONBUTTON_NEW = 2,
165 ACTIONBUTTON_DELETED = 3
168 enum ActionButtonType
170 ACTION_BUTTON_SPELL = 0x00,
171 ACTION_BUTTON_C = 0x01, // click?
172 ACTION_BUTTON_EQSET = 0x20,
173 ACTION_BUTTON_MACRO = 0x40,
174 ACTION_BUTTON_CMACRO = ACTION_BUTTON_C | ACTION_BUTTON_MACRO,
175 ACTION_BUTTON_ITEM = 0x80
178 #define ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
179 #define ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
180 #define MAX_ACTION_BUTTON_ACTION_VALUE (0x00FFFFFF+1)
182 struct ActionButton
184 ActionButton() : packedData(0), uState( ACTIONBUTTON_NEW ) {}
186 uint32 packedData;
187 ActionButtonUpdateState uState;
189 // helpers
190 ActionButtonType GetType() const { return ActionButtonType(ACTION_BUTTON_TYPE(packedData)); }
191 uint32 GetAction() const { return ACTION_BUTTON_ACTION(packedData); }
192 void SetActionAndType(uint32 action, ActionButtonType type)
194 uint32 newData = action | (uint32(type) << 24);
195 if (newData != packedData || uState == ACTIONBUTTON_DELETED)
197 packedData = newData;
198 if (uState != ACTIONBUTTON_NEW)
199 uState = ACTIONBUTTON_CHANGED;
204 // some action button indexes used in code or clarify structure
205 enum ActionButtonIndex
207 ACTION_BUTTON_SHAMAN_TOTEMS_BAR = 132,
210 #define MAX_ACTION_BUTTONS 144 //checked in 3.2.0
212 typedef std::map<uint8,ActionButton> ActionButtonList;
214 enum GlyphUpdateState
216 GLYPH_UNCHANGED = 0,
217 GLYPH_CHANGED = 1,
218 GLYPH_NEW = 2,
219 GLYPH_DELETED = 3
222 struct Glyph
224 uint32 id;
225 GlyphUpdateState uState;
227 Glyph() : id(0), uState(GLYPH_UNCHANGED) { }
229 uint32 GetId() { return id; }
231 void SetId(uint32 newId)
233 if(newId == id)
234 return;
236 if(id == 0 && uState == GLYPH_UNCHANGED) // not exist yet in db and already saved
238 uState = GLYPH_NEW;
240 else if (newId == 0)
242 if(uState == GLYPH_NEW) // delete before add new -> no change
243 uState = GLYPH_UNCHANGED;
244 else // delete existing data
245 uState = GLYPH_DELETED;
247 else if (uState != GLYPH_NEW) // if not new data, change current data
249 uState = GLYPH_CHANGED;
252 id = newId;
256 struct PlayerCreateInfoItem
258 PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {}
260 uint32 item_id;
261 uint32 item_amount;
264 typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
266 struct PlayerClassLevelInfo
268 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
269 uint16 basehealth;
270 uint16 basemana;
273 struct PlayerClassInfo
275 PlayerClassInfo() : levelInfo(NULL) { }
277 PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
280 struct PlayerLevelInfo
282 PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
284 uint8 stats[MAX_STATS];
287 typedef std::list<uint32> PlayerCreateInfoSpells;
289 struct PlayerCreateInfoAction
291 PlayerCreateInfoAction() : button(0), type(0), action(0) {}
292 PlayerCreateInfoAction(uint8 _button, uint32 _action, uint8 _type) : button(_button), type(_type), action(_action) {}
294 uint8 button;
295 uint8 type;
296 uint32 action;
299 typedef std::list<PlayerCreateInfoAction> PlayerCreateInfoActions;
301 struct PlayerInfo
303 // existence checked by displayId != 0 // existence checked by displayId != 0
304 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL)
308 uint32 mapId;
309 uint32 areaId;
310 float positionX;
311 float positionY;
312 float positionZ;
313 uint16 displayId_m;
314 uint16 displayId_f;
315 PlayerCreateInfoItems item;
316 PlayerCreateInfoSpells spell;
317 PlayerCreateInfoActions action;
319 PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
322 struct PvPInfo
324 PvPInfo() : inHostileArea(false), endTimer(0) {}
326 bool inHostileArea;
327 time_t endTimer;
330 struct DuelInfo
332 DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {}
334 Player *initiator;
335 Player *opponent;
336 time_t startTimer;
337 time_t startTime;
338 time_t outOfBound;
341 struct Areas
343 uint32 areaID;
344 uint32 areaFlag;
345 float x1;
346 float x2;
347 float y1;
348 float y2;
351 #define MAX_RUNES 6
352 #define RUNE_COOLDOWN (2*5*IN_MILLISECONDS) // msec
354 enum RuneType
356 RUNE_BLOOD = 0,
357 RUNE_UNHOLY = 1,
358 RUNE_FROST = 2,
359 RUNE_DEATH = 3,
360 NUM_RUNE_TYPES = 4
363 struct RuneInfo
365 uint8 BaseRune;
366 uint8 CurrentRune;
367 uint16 Cooldown; // msec
370 struct Runes
372 RuneInfo runes[MAX_RUNES];
373 uint8 runeState; // mask of available runes
375 void SetRuneState(uint8 index, bool set = true)
377 if(set)
378 runeState |= (1 << index); // usable
379 else
380 runeState &= ~(1 << index); // on cooldown
384 struct EnchantDuration
386 EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {};
387 EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { ASSERT(item); };
389 Item * item;
390 EnchantmentSlot slot;
391 uint32 leftduration;
394 typedef std::list<EnchantDuration> EnchantDurationList;
395 typedef std::list<Item*> ItemDurationList;
397 enum LfgType
399 LFG_TYPE_NONE = 0,
400 LFG_TYPE_DUNGEON = 1,
401 LFG_TYPE_RAID = 2,
402 LFG_TYPE_QUEST = 3,
403 LFG_TYPE_ZONE = 4,
404 LFG_TYPE_HEROIC_DUNGEON = 5,
405 LFG_TYPE_RANDOM_DUNGEON = 6
408 enum LfgRoles
410 LEADER = 0x01,
411 TANK = 0x02,
412 HEALER = 0x04,
413 DAMAGE = 0x08
416 struct LookingForGroupSlot
418 LookingForGroupSlot() : entry(0), type(0) {}
419 bool Empty() const { return !entry && !type; }
420 void Clear() { entry = 0; type = 0; }
421 void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; }
422 bool Is(uint32 _entry, uint32 _type) const { return entry == _entry && type == _type; }
423 bool canAutoJoin() const { return entry && (type == LFG_TYPE_DUNGEON || type == LFG_TYPE_HEROIC_DUNGEON); }
425 uint32 entry;
426 uint32 type;
429 #define MAX_LOOKING_FOR_GROUP_SLOT 3
431 struct LookingForGroup
433 LookingForGroup() {}
434 bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry, slot.type); }
435 bool HaveInSlot(uint32 _entry, uint32 _type) const
437 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
438 if(slots[i].Is(_entry, _type))
439 return true;
440 return false;
443 bool canAutoJoin() const
445 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
446 if(slots[i].canAutoJoin())
447 return true;
448 return false;
451 bool Empty() const
453 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
454 if(!slots[i].Empty())
455 return false;
456 return more.Empty();
459 LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT];
460 LookingForGroupSlot more;
461 std::string comment;
462 uint8 roles;
465 enum RaidGroupError
467 ERR_RAID_GROUP_NONE = 0,
468 ERR_RAID_GROUP_LOWLEVEL = 1,
469 ERR_RAID_GROUP_ONLY = 2,
470 ERR_RAID_GROUP_FULL = 3,
471 ERR_RAID_GROUP_REQUIREMENTS_UNMATCH = 4
474 enum PlayerMovementType
476 MOVE_ROOT = 1,
477 MOVE_UNROOT = 2,
478 MOVE_WATER_WALK = 3,
479 MOVE_LAND_WALK = 4
482 enum DrunkenState
484 DRUNKEN_SOBER = 0,
485 DRUNKEN_TIPSY = 1,
486 DRUNKEN_DRUNK = 2,
487 DRUNKEN_SMASHED = 3
490 #define MAX_DRUNKEN 4
492 enum PlayerFlags
494 PLAYER_FLAGS_NONE = 0x00000000,
495 PLAYER_FLAGS_GROUP_LEADER = 0x00000001,
496 PLAYER_FLAGS_AFK = 0x00000002,
497 PLAYER_FLAGS_DND = 0x00000004,
498 PLAYER_FLAGS_GM = 0x00000008,
499 PLAYER_FLAGS_GHOST = 0x00000010,
500 PLAYER_FLAGS_RESTING = 0x00000020,
501 PLAYER_FLAGS_UNK7 = 0x00000040,
502 PLAYER_FLAGS_UNK8 = 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
503 PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
504 PLAYER_FLAGS_IN_PVP = 0x00000200,
505 PLAYER_FLAGS_HIDE_HELM = 0x00000400,
506 PLAYER_FLAGS_HIDE_CLOAK = 0x00000800,
507 PLAYER_FLAGS_PARTIAL_PLAY_TIME = 0x00001000, // played long time
508 PLAYER_FLAGS_NO_PLAY_TIME = 0x00002000, // played too long time
509 PLAYER_FLAGS_IS_OUT_OF_BOUNDS = 0x00004000, // Lua_IsOutOfBounds
510 PLAYER_FLAGS_DEVELOPER = 0x00008000, // <Dev> prefix for something?
511 PLAYER_FLAGS_UNK17 = 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
512 PLAYER_FLAGS_TAXI_BENCHMARK = 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
513 PLAYER_FLAGS_PVP_TIMER = 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
514 PLAYER_FLAGS_COMMENTATOR = 0x00080000,
515 PLAYER_FLAGS_UNK21 = 0x00100000,
516 PLAYER_FLAGS_UNK22 = 0x00200000,
517 PLAYER_FLAGS_COMMENTATOR2 = 0x00400000, // something like COMMENTATOR_CAN_USE_INSTANCE_COMMAND
518 PLAYER_FLAGS_UNK24 = 0x00800000, // EVENT_SPELL_UPDATE_USABLE and EVENT_UPDATE_SHAPESHIFT_USABLE, disabled all abilitys on tab except autoattack
519 PLAYER_FLAGS_UNK25 = 0x01000000, // EVENT_SPELL_UPDATE_USABLE and EVENT_UPDATE_SHAPESHIFT_USABLE, disabled all melee ability on tab include autoattack
520 PLAYER_FLAGS_XP_USER_DISABLED = 0x02000000,
523 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
524 // can't use enum for uint64 values
525 #define PLAYER_TITLE_DISABLED UI64LIT(0x0000000000000000)
526 #define PLAYER_TITLE_NONE UI64LIT(0x0000000000000001)
527 #define PLAYER_TITLE_PRIVATE UI64LIT(0x0000000000000002) // 1
528 #define PLAYER_TITLE_CORPORAL UI64LIT(0x0000000000000004) // 2
529 #define PLAYER_TITLE_SERGEANT_A UI64LIT(0x0000000000000008) // 3
530 #define PLAYER_TITLE_MASTER_SERGEANT UI64LIT(0x0000000000000010) // 4
531 #define PLAYER_TITLE_SERGEANT_MAJOR UI64LIT(0x0000000000000020) // 5
532 #define PLAYER_TITLE_KNIGHT UI64LIT(0x0000000000000040) // 6
533 #define PLAYER_TITLE_KNIGHT_LIEUTENANT UI64LIT(0x0000000000000080) // 7
534 #define PLAYER_TITLE_KNIGHT_CAPTAIN UI64LIT(0x0000000000000100) // 8
535 #define PLAYER_TITLE_KNIGHT_CHAMPION UI64LIT(0x0000000000000200) // 9
536 #define PLAYER_TITLE_LIEUTENANT_COMMANDER UI64LIT(0x0000000000000400) // 10
537 #define PLAYER_TITLE_COMMANDER UI64LIT(0x0000000000000800) // 11
538 #define PLAYER_TITLE_MARSHAL UI64LIT(0x0000000000001000) // 12
539 #define PLAYER_TITLE_FIELD_MARSHAL UI64LIT(0x0000000000002000) // 13
540 #define PLAYER_TITLE_GRAND_MARSHAL UI64LIT(0x0000000000004000) // 14
541 #define PLAYER_TITLE_SCOUT UI64LIT(0x0000000000008000) // 15
542 #define PLAYER_TITLE_GRUNT UI64LIT(0x0000000000010000) // 16
543 #define PLAYER_TITLE_SERGEANT_H UI64LIT(0x0000000000020000) // 17
544 #define PLAYER_TITLE_SENIOR_SERGEANT UI64LIT(0x0000000000040000) // 18
545 #define PLAYER_TITLE_FIRST_SERGEANT UI64LIT(0x0000000000080000) // 19
546 #define PLAYER_TITLE_STONE_GUARD UI64LIT(0x0000000000100000) // 20
547 #define PLAYER_TITLE_BLOOD_GUARD UI64LIT(0x0000000000200000) // 21
548 #define PLAYER_TITLE_LEGIONNAIRE UI64LIT(0x0000000000400000) // 22
549 #define PLAYER_TITLE_CENTURION UI64LIT(0x0000000000800000) // 23
550 #define PLAYER_TITLE_CHAMPION UI64LIT(0x0000000001000000) // 24
551 #define PLAYER_TITLE_LIEUTENANT_GENERAL UI64LIT(0x0000000002000000) // 25
552 #define PLAYER_TITLE_GENERAL UI64LIT(0x0000000004000000) // 26
553 #define PLAYER_TITLE_WARLORD UI64LIT(0x0000000008000000) // 27
554 #define PLAYER_TITLE_HIGH_WARLORD UI64LIT(0x0000000010000000) // 28
555 #define PLAYER_TITLE_GLADIATOR UI64LIT(0x0000000020000000) // 29
556 #define PLAYER_TITLE_DUELIST UI64LIT(0x0000000040000000) // 30
557 #define PLAYER_TITLE_RIVAL UI64LIT(0x0000000080000000) // 31
558 #define PLAYER_TITLE_CHALLENGER UI64LIT(0x0000000100000000) // 32
559 #define PLAYER_TITLE_SCARAB_LORD UI64LIT(0x0000000200000000) // 33
560 #define PLAYER_TITLE_CONQUEROR UI64LIT(0x0000000400000000) // 34
561 #define PLAYER_TITLE_JUSTICAR UI64LIT(0x0000000800000000) // 35
562 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU UI64LIT(0x0000001000000000) // 36
563 #define PLAYER_TITLE_MERCILESS_GLADIATOR UI64LIT(0x0000002000000000) // 37
564 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN UI64LIT(0x0000004000000000) // 38
565 #define PLAYER_TITLE_HAND_OF_ADAL UI64LIT(0x0000008000000000) // 39
566 #define PLAYER_TITLE_VENGEFUL_GLADIATOR UI64LIT(0x0000010000000000) // 40
568 #define KNOWN_TITLES_SIZE 3
569 #define MAX_TITLE_INDEX (KNOWN_TITLES_SIZE*64) // 3 uint64 fields
571 // used in PLAYER_FIELD_BYTES values
572 enum PlayerFieldByteFlags
574 PLAYER_FIELD_BYTE_TRACK_STEALTHED = 0x00000002,
575 PLAYER_FIELD_BYTE_RELEASE_TIMER = 0x00000008, // Display time till auto release spirit
576 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x00000010 // Display no "release spirit" window at all
579 // used in PLAYER_FIELD_BYTES2 values
580 enum PlayerFieldByte2Flags
582 PLAYER_FIELD_BYTE2_NONE = 0x0000,
583 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW = 0x4000
586 enum ActivateTaxiReplies
588 ERR_TAXIOK = 0,
589 ERR_TAXIUNSPECIFIEDSERVERERROR = 1,
590 ERR_TAXINOSUCHPATH = 2,
591 ERR_TAXINOTENOUGHMONEY = 3,
592 ERR_TAXITOOFARAWAY = 4,
593 ERR_TAXINOVENDORNEARBY = 5,
594 ERR_TAXINOTVISITED = 6,
595 ERR_TAXIPLAYERBUSY = 7,
596 ERR_TAXIPLAYERALREADYMOUNTED = 8,
597 ERR_TAXIPLAYERSHAPESHIFTED = 9,
598 ERR_TAXIPLAYERMOVING = 10,
599 ERR_TAXISAMENODE = 11,
600 ERR_TAXINOTSTANDING = 12
603 enum MirrorTimerType
605 FATIGUE_TIMER = 0,
606 BREATH_TIMER = 1,
607 FIRE_TIMER = 2
609 #define MAX_TIMERS 3
610 #define DISABLED_MIRROR_TIMER -1
612 // 2^n values
613 enum PlayerExtraFlags
615 // gm abilities
616 PLAYER_EXTRA_GM_ON = 0x0001,
617 PLAYER_EXTRA_GM_ACCEPT_TICKETS = 0x0002,
618 PLAYER_EXTRA_ACCEPT_WHISPERS = 0x0004,
619 PLAYER_EXTRA_TAXICHEAT = 0x0008,
620 PLAYER_EXTRA_GM_INVISIBLE = 0x0010,
621 PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages
623 // other states
624 PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating.
627 // 2^n values
628 enum AtLoginFlags
630 AT_LOGIN_NONE = 0x00,
631 AT_LOGIN_RENAME = 0x01,
632 AT_LOGIN_RESET_SPELLS = 0x02,
633 AT_LOGIN_RESET_TALENTS = 0x04,
634 AT_LOGIN_CUSTOMIZE = 0x08,
635 AT_LOGIN_RESET_PET_TALENTS = 0x10,
636 AT_LOGIN_FIRST = 0x20,
639 typedef std::map<uint32, QuestStatusData> QuestStatusMap;
641 enum QuestSlotOffsets
643 QUEST_ID_OFFSET = 0,
644 QUEST_STATE_OFFSET = 1,
645 QUEST_COUNTS_OFFSET = 2, // 2 and 3
646 QUEST_TIME_OFFSET = 4
649 #define MAX_QUEST_OFFSET 5
651 enum QuestSlotStateMask
653 QUEST_STATE_NONE = 0x0000,
654 QUEST_STATE_COMPLETE = 0x0001,
655 QUEST_STATE_FAIL = 0x0002
658 enum SkillUpdateState
660 SKILL_UNCHANGED = 0,
661 SKILL_CHANGED = 1,
662 SKILL_NEW = 2,
663 SKILL_DELETED = 3
666 struct SkillStatusData
668 SkillStatusData(uint8 _pos, SkillUpdateState _uState) : pos(_pos), uState(_uState)
671 uint8 pos;
672 SkillUpdateState uState;
675 typedef UNORDERED_MAP<uint32, SkillStatusData> SkillStatusMap;
677 enum PlayerSlots
679 // first slot for item stored (in any way in player m_items data)
680 PLAYER_SLOT_START = 0,
681 // last+1 slot for item stored (in any way in player m_items data)
682 PLAYER_SLOT_END = 150,
683 PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START)
686 #define INVENTORY_SLOT_BAG_0 255
688 enum EquipmentSlots // 19 slots
690 EQUIPMENT_SLOT_START = 0,
691 EQUIPMENT_SLOT_HEAD = 0,
692 EQUIPMENT_SLOT_NECK = 1,
693 EQUIPMENT_SLOT_SHOULDERS = 2,
694 EQUIPMENT_SLOT_BODY = 3,
695 EQUIPMENT_SLOT_CHEST = 4,
696 EQUIPMENT_SLOT_WAIST = 5,
697 EQUIPMENT_SLOT_LEGS = 6,
698 EQUIPMENT_SLOT_FEET = 7,
699 EQUIPMENT_SLOT_WRISTS = 8,
700 EQUIPMENT_SLOT_HANDS = 9,
701 EQUIPMENT_SLOT_FINGER1 = 10,
702 EQUIPMENT_SLOT_FINGER2 = 11,
703 EQUIPMENT_SLOT_TRINKET1 = 12,
704 EQUIPMENT_SLOT_TRINKET2 = 13,
705 EQUIPMENT_SLOT_BACK = 14,
706 EQUIPMENT_SLOT_MAINHAND = 15,
707 EQUIPMENT_SLOT_OFFHAND = 16,
708 EQUIPMENT_SLOT_RANGED = 17,
709 EQUIPMENT_SLOT_TABARD = 18,
710 EQUIPMENT_SLOT_END = 19
713 enum InventorySlots // 4 slots
715 INVENTORY_SLOT_BAG_START = 19,
716 INVENTORY_SLOT_BAG_END = 23
719 enum InventoryPackSlots // 16 slots
721 INVENTORY_SLOT_ITEM_START = 23,
722 INVENTORY_SLOT_ITEM_END = 39
725 enum BankItemSlots // 28 slots
727 BANK_SLOT_ITEM_START = 39,
728 BANK_SLOT_ITEM_END = 67
731 enum BankBagSlots // 7 slots
733 BANK_SLOT_BAG_START = 67,
734 BANK_SLOT_BAG_END = 74
737 enum BuyBackSlots // 12 slots
739 // stored in m_buybackitems
740 BUYBACK_SLOT_START = 74,
741 BUYBACK_SLOT_END = 86
744 enum KeyRingSlots // 32 slots
746 KEYRING_SLOT_START = 86,
747 KEYRING_SLOT_END = 118
750 enum CurrencyTokenSlots // 32 slots
752 CURRENCYTOKEN_SLOT_START = 118,
753 CURRENCYTOKEN_SLOT_END = 150
756 enum EquipmentSetUpdateState
758 EQUIPMENT_SET_UNCHANGED = 0,
759 EQUIPMENT_SET_CHANGED = 1,
760 EQUIPMENT_SET_NEW = 2,
761 EQUIPMENT_SET_DELETED = 3
764 struct EquipmentSet
766 EquipmentSet() : Guid(0), state(EQUIPMENT_SET_NEW)
768 for(int i = 0; i < EQUIPMENT_SLOT_END; ++i)
769 Items[i] = 0;
772 uint64 Guid;
773 std::string Name;
774 std::string IconName;
775 uint32 Items[EQUIPMENT_SLOT_END];
776 EquipmentSetUpdateState state;
779 #define MAX_EQUIPMENT_SET_INDEX 10 // client limit
781 typedef std::map<uint32, EquipmentSet> EquipmentSets;
783 struct ItemPosCount
785 ItemPosCount(uint16 _pos, uint32 _count) : pos(_pos), count(_count) {}
786 bool isContainedIn(std::vector<ItemPosCount> const& vec) const;
787 uint16 pos;
788 uint32 count;
790 typedef std::vector<ItemPosCount> ItemPosCountVec;
792 enum TradeSlots
794 TRADE_SLOT_COUNT = 7,
795 TRADE_SLOT_TRADED_COUNT = 6,
796 TRADE_SLOT_NONTRADED = 6
799 enum TransferAbortReason
801 TRANSFER_ABORT_NONE = 0x00,
802 TRANSFER_ABORT_ERROR = 0x01,
803 TRANSFER_ABORT_MAX_PLAYERS = 0x02, // Transfer Aborted: instance is full
804 TRANSFER_ABORT_NOT_FOUND = 0x03, // Transfer Aborted: instance not found
805 TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x04, // You have entered too many instances recently.
806 TRANSFER_ABORT_ZONE_IN_COMBAT = 0x06, // Unable to zone in while an encounter is in progress.
807 TRANSFER_ABORT_INSUF_EXPAN_LVL = 0x07, // You must have <TBC,WotLK> expansion installed to access this area.
808 TRANSFER_ABORT_DIFFICULTY = 0x08, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
809 TRANSFER_ABORT_UNIQUE_MESSAGE = 0x09, // Until you've escaped TLK's grasp, you cannot leave this place!
810 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 0x0A, // Additional instances cannot be launched, please try again later.
811 TRANSFER_ABORT_NEED_GROUP = 0x0B, // 3.1
812 TRANSFER_ABORT_NOT_FOUND2 = 0x0C, // 3.1
813 TRANSFER_ABORT_NOT_FOUND3 = 0x0D, // 3.1
814 TRANSFER_ABORT_NOT_FOUND4 = 0x0E, // 3.2
815 TRANSFER_ABORT_REALM_ONLY = 0x0F, // All players on party must be from the same realm.
816 TRANSFER_ABORT_MAP_NOT_ALLOWED = 0x10, // Map can't be entered at this time.
819 enum InstanceResetWarningType
821 RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s).
822 RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)!
823 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!
824 RAID_INSTANCE_WELCOME = 4, // Welcome to %s. This raid instance is scheduled to reset in %s.
825 RAID_INSTANCE_EXPIRED = 5
828 // PLAYER_FIELD_ARENA_TEAM_INFO_1_1 offsets
829 enum ArenaTeamInfoType
831 ARENA_TEAM_ID = 0,
832 ARENA_TEAM_TYPE = 1, // new in 3.2 - team type?
833 ARENA_TEAM_MEMBER = 2, // 0 - captain, 1 - member
834 ARENA_TEAM_GAMES_WEEK = 3,
835 ARENA_TEAM_GAMES_SEASON = 4,
836 ARENA_TEAM_WINS_SEASON = 5,
837 ARENA_TEAM_PERSONAL_RATING = 6,
838 ARENA_TEAM_END = 7
841 enum RestType
843 REST_TYPE_NO = 0,
844 REST_TYPE_IN_TAVERN = 1,
845 REST_TYPE_IN_CITY = 2
848 enum DuelCompleteType
850 DUEL_INTERUPTED = 0,
851 DUEL_WON = 1,
852 DUEL_FLED = 2
855 enum TeleportToOptions
857 TELE_TO_GM_MODE = 0x01,
858 TELE_TO_NOT_LEAVE_TRANSPORT = 0x02,
859 TELE_TO_NOT_LEAVE_COMBAT = 0x04,
860 TELE_TO_NOT_UNSUMMON_PET = 0x08,
861 TELE_TO_SPELL = 0x10,
864 /// Type of environmental damages
865 enum EnviromentalDamage
867 DAMAGE_EXHAUSTED = 0,
868 DAMAGE_DROWNING = 1,
869 DAMAGE_FALL = 2,
870 DAMAGE_LAVA = 3,
871 DAMAGE_SLIME = 4,
872 DAMAGE_FIRE = 5,
873 DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
876 enum PlayedTimeIndex
878 PLAYED_TIME_TOTAL = 0,
879 PLAYED_TIME_LEVEL = 1
882 #define MAX_PLAYED_TIME_INDEX 2
884 // used at player loading query list preparing, and later result selection
885 enum PlayerLoginQueryIndex
887 PLAYER_LOGIN_QUERY_LOADFROM,
888 PLAYER_LOGIN_QUERY_LOADGROUP,
889 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES,
890 PLAYER_LOGIN_QUERY_LOADAURAS,
891 PLAYER_LOGIN_QUERY_LOADSPELLS,
892 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS,
893 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,
894 PLAYER_LOGIN_QUERY_LOADREPUTATION,
895 PLAYER_LOGIN_QUERY_LOADINVENTORY,
896 PLAYER_LOGIN_QUERY_LOADACTIONS,
897 PLAYER_LOGIN_QUERY_LOADSOCIALLIST,
898 PLAYER_LOGIN_QUERY_LOADHOMEBIND,
899 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS,
900 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES,
901 PLAYER_LOGIN_QUERY_LOADGUILD,
902 PLAYER_LOGIN_QUERY_LOADARENAINFO,
903 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS,
904 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS,
905 PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS,
906 PLAYER_LOGIN_QUERY_LOADBGDATA,
907 PLAYER_LOGIN_QUERY_LOADACCOUNTDATA,
908 PLAYER_LOGIN_QUERY_LOADSKILLS,
909 PLAYER_LOGIN_QUERY_LOADGLYPHS,
910 PLAYER_LOGIN_QUERY_LOADMAILS,
911 PLAYER_LOGIN_QUERY_LOADMAILEDITEMS,
912 PLAYER_LOGIN_QUERY_LOADTALENTS,
913 PLAYER_LOGIN_QUERY_LOADWEEKLYQUESTSTATUS,
915 MAX_PLAYER_LOGIN_QUERY
918 enum PlayerDelayedOperations
920 DELAYED_SAVE_PLAYER = 0x01,
921 DELAYED_RESURRECT_PLAYER = 0x02,
922 DELAYED_SPELL_CAST_DESERTER = 0x04,
923 DELAYED_BG_MOUNT_RESTORE = 0x08, ///< Flag to restore mount state after teleport from BG
924 DELAYED_BG_TAXI_RESTORE = 0x10, ///< Flag to restore taxi state after teleport from BG
925 DELAYED_END
928 // Player summoning auto-decline time (in secs)
929 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
930 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
932 struct InstancePlayerBind
934 InstanceSave *save;
935 bool perm;
936 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
937 that aren't already permanently bound when they are inside when a boss is killed
938 or when they enter an instance that the group leader is permanently bound to. */
939 InstancePlayerBind() : save(NULL), perm(false) {}
942 class MANGOS_DLL_SPEC PlayerTaxi
944 public:
945 PlayerTaxi();
946 ~PlayerTaxi() {}
947 // Nodes
948 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level);
949 void LoadTaxiMask(const char* data);
951 bool IsTaximaskNodeKnown(uint32 nodeidx) const
953 uint8 field = uint8((nodeidx - 1) / 32);
954 uint32 submask = 1<<((nodeidx-1)%32);
955 return (m_taximask[field] & submask) == submask;
957 bool SetTaximaskNode(uint32 nodeidx)
959 uint8 field = uint8((nodeidx - 1) / 32);
960 uint32 submask = 1<<((nodeidx-1)%32);
961 if ((m_taximask[field] & submask) != submask )
963 m_taximask[field] |= submask;
964 return true;
966 else
967 return false;
969 void AppendTaximaskTo(ByteBuffer& data, bool all);
971 // Destinations
972 bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team);
973 std::string SaveTaxiDestinationsToString();
975 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
976 void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
977 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
978 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
979 uint32 GetCurrentTaxiPath() const;
980 uint32 NextTaxiDestination()
982 m_TaxiDestinations.pop_front();
983 return GetTaxiDestination();
985 bool empty() const { return m_TaxiDestinations.empty(); }
987 friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
988 private:
989 TaxiMask m_taximask;
990 std::deque<uint32> m_TaxiDestinations;
993 std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
995 /// Holder for BattleGround data
996 struct BGData
998 BGData() : bgInstanceID(0), bgTypeID(BATTLEGROUND_TYPE_NONE), bgAfkReportedCount(0), bgAfkReportedTimer(0),
999 bgTeam(0), mountSpell(0) { ClearTaxiPath(); }
1002 uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID,
1003 /// when player is teleported to BG - (it is battleground's GUID)
1004 BattleGroundTypeId bgTypeID;
1006 std::set<uint32> bgAfkReporter;
1007 uint8 bgAfkReportedCount;
1008 time_t bgAfkReportedTimer;
1010 uint32 bgTeam; ///< What side the player will be added to
1013 uint32 mountSpell;
1014 uint32 taxiPath[2];
1016 WorldLocation joinPos; ///< From where player entered BG
1018 void ClearTaxiPath() { taxiPath[0] = taxiPath[1] = 0; }
1019 bool HasTaxiPath() const { return taxiPath[0] && taxiPath[1]; }
1022 class TradeData
1024 public: // constructors
1025 TradeData(Player* player, Player* trader) :
1026 m_player(player), m_trader(trader), m_accepted(false), m_acceptProccess(false),
1027 m_money(0), m_spell(0) {}
1029 public: // access functions
1031 Player* GetTrader() const { return m_trader; }
1032 TradeData* GetTraderData() const;
1034 Item* GetItem(TradeSlots slot) const;
1035 bool HasItem(ObjectGuid item_guid) const;
1037 uint32 GetSpell() const { return m_spell; }
1038 Item* GetSpellCastItem() const;
1039 bool HasSpellCastItem() const { return !m_spellCastItem.IsEmpty(); }
1041 uint32 GetMoney() const { return m_money; }
1043 bool IsAccepted() const { return m_accepted; }
1044 bool IsInAcceptProcess() const { return m_acceptProccess; }
1045 public: // access functions
1047 void SetItem(TradeSlots slot, Item* item);
1048 void SetSpell(uint32 spell_id, Item* castItem = NULL);
1049 void SetMoney(uint32 money);
1051 void SetAccepted(bool state, bool crosssend = false);
1053 // must be called only from accept handler helper functions
1054 void SetInAcceptProcess(bool state) { m_acceptProccess = state; }
1056 private: // internal functions
1058 void Update(bool for_trader = true);
1060 private: // fields
1062 Player* m_player; // Player who own of this TradeData
1063 Player* m_trader; // Player who trade with m_player
1065 bool m_accepted; // m_player press accept for trade list
1066 bool m_acceptProccess; // one from player/trader press accept and this processed
1068 uint32 m_money; // m_player place money to trade
1070 uint32 m_spell; // m_player apply spell to non-traded slot item
1071 ObjectGuid m_spellCastItem; // applied spell casted by item use
1073 ObjectGuid m_items[TRADE_SLOT_COUNT]; // traded itmes from m_player side including non-traded slot
1076 class MANGOS_DLL_SPEC Player : public Unit
1078 friend class WorldSession;
1079 friend void Item::AddToUpdateQueueOf(Player *player);
1080 friend void Item::RemoveFromUpdateQueueOf(Player *player);
1081 public:
1082 explicit Player (WorldSession *session);
1083 ~Player ( );
1085 void CleanupsBeforeDelete();
1087 static UpdateMask updateVisualBits;
1088 static void InitVisibleBits();
1090 void AddToWorld();
1091 void RemoveFromWorld();
1093 bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
1095 bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
1097 return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation, options);
1100 bool TeleportToBGEntryPoint();
1102 void SetSummonPoint(uint32 mapid, float x, float y, float z)
1104 m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
1105 m_summon_mapid = mapid;
1106 m_summon_x = x;
1107 m_summon_y = y;
1108 m_summon_z = z;
1110 void SummonIfPossible(bool agree);
1112 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 );
1114 void Update( uint32 time );
1116 static bool BuildEnumData( QueryResult * result, WorldPacket * p_data );
1118 void SetInWater(bool apply);
1120 bool IsInWater() const { return m_isInWater; }
1121 bool IsUnderWater() const;
1123 void SendInitialPacketsBeforeAddToMap();
1124 void SendInitialPacketsAfterAddToMap();
1125 void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0);
1126 void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
1128 Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask);
1129 GameObject* GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameobject_type = MAX_GAMEOBJECT_TYPE) const;
1131 void UpdateVisibilityForPlayer();
1133 bool ToggleAFK();
1134 bool ToggleDND();
1135 bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
1136 bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
1137 uint8 chatTag() const;
1138 std::string afkMsg;
1139 std::string dndMsg;
1141 uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
1143 PlayerSocial *GetSocial() { return m_social; }
1145 PlayerTaxi m_taxi;
1146 void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1147 bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = NULL, uint32 spellid = 0);
1148 bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0);
1149 // mount_id can be used in scripting calls
1150 void ContinueTaxiFlight();
1151 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); }
1152 void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; }
1153 bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
1154 void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
1155 bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
1156 void SetGameMaster(bool on);
1157 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); }
1158 void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
1159 bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
1160 void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
1161 bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
1162 void SetGMVisible(bool on);
1163 void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
1165 void GiveXP(uint32 xp, Unit* victim);
1166 void GiveLevel(uint32 level);
1168 void InitStatsForLevel(bool reapplyMods = false);
1170 // Played Time Stuff
1171 time_t m_logintime;
1172 time_t m_Last_tick;
1174 uint32 m_Played_time[MAX_PLAYED_TIME_INDEX];
1175 uint32 GetTotalPlayedTime() { return m_Played_time[PLAYED_TIME_TOTAL]; }
1176 uint32 GetLevelPlayedTime() { return m_Played_time[PLAYED_TIME_LEVEL]; }
1178 void ResetTimeSync();
1179 void SendTimeSync();
1181 void setDeathState(DeathState s); // overwrite Unit::setDeathState
1183 float GetRestBonus() const { return m_rest_bonus; }
1184 void SetRestBonus(float rest_bonus_new);
1186 RestType GetRestType() const { return rest_type; }
1187 void SetRestType(RestType n_r_type, uint32 areaTriggerId = 0);
1189 time_t GetTimeInnEnter() const { return time_inn_enter; }
1190 void UpdateInnerTime (time_t time) { time_inn_enter = time; }
1192 void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
1193 void RemoveMiniPet();
1194 Pet* GetMiniPet();
1195 void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); }
1197 template<typename Func>
1198 void CallForAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms, bool withMiniPet);
1199 template<typename Func>
1200 bool CheckAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms, bool withMiniPet) const;
1202 uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
1204 void Say(const std::string& text, const uint32 language);
1205 void Yell(const std::string& text, const uint32 language);
1206 void TextEmote(const std::string& text);
1207 void Whisper(const std::string& text, const uint32 language,uint64 receiver);
1208 void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
1210 /*********************************************************/
1211 /*** STORAGE SYSTEM ***/
1212 /*********************************************************/
1214 void SetVirtualItemSlot( uint8 i, Item* item);
1215 void SetSheath( SheathState sheathed ); // overwrite Unit version
1216 uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const;
1217 uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const;
1218 uint32 GetItemCountWithLimitCategory(uint32 limitCategory) const;
1219 Item* GetItemByGuid(ObjectGuid uint64) const;
1220 Item* GetItemByEntry(uint32 item) const; // only for special cases
1221 Item* GetItemByLimitedCategory(uint32 limitedCategory) const;
1222 Item* GetItemByPos( uint16 pos ) const;
1223 Item* GetItemByPos( uint8 bag, uint8 slot ) const;
1224 Item* GetWeaponForAttack(WeaponAttackType attackType) const { return GetWeaponForAttack(attackType,false,false); }
1225 Item* GetWeaponForAttack(WeaponAttackType attackType, bool nonbroken, bool useable) const;
1226 Item* GetShield(bool useable = false) const;
1227 static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot
1228 std::vector<Item *> &GetItemUpdateQueue() { return m_itemUpdateQueue; }
1229 static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8, pos & 255); }
1230 static bool IsInventoryPos( uint8 bag, uint8 slot );
1231 static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8, pos & 255); }
1232 static bool IsEquipmentPos( uint8 bag, uint8 slot );
1233 static bool IsBagPos( uint16 pos );
1234 static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8, pos & 255); }
1235 static bool IsBankPos( uint8 bag, uint8 slot );
1236 bool IsValidPos( uint16 pos, bool explicit_pos ) const { return IsValidPos(pos >> 8, pos & 255, explicit_pos); }
1237 bool IsValidPos( uint8 bag, uint8 slot, bool explicit_pos ) const;
1238 uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); }
1239 void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); }
1240 bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false) const;
1241 bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL);
1242 bool CanNoReagentCast(SpellEntry const* spellInfo) const;
1243 bool HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
1244 bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
1245 uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); }
1246 uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry, count, NULL); }
1247 uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
1249 return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count );
1251 uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
1253 if(!pItem)
1254 return EQUIP_ERR_ITEM_NOT_FOUND;
1255 uint32 count = pItem->GetCount();
1256 return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL );
1259 uint8 CanStoreItems( Item **pItem,int count) const;
1260 uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
1261 uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
1263 uint8 CanEquipUniqueItem( Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
1264 uint8 CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
1265 uint8 CanUnequipItems( uint32 item, uint32 count ) const;
1266 uint8 CanUnequipItem( uint16 src, bool swap ) const;
1267 uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
1268 uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
1269 bool HasItemTotemCategory( uint32 TotemCategory ) const;
1270 bool CanUseItem( ItemPrototype const *pItem );
1271 uint8 CanUseAmmo( uint32 item ) const;
1272 Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
1273 Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
1274 Item* EquipNewItem( uint16 pos, uint32 item, bool update );
1275 Item* EquipItem( uint16 pos, Item *pItem, bool update );
1276 void AutoUnequipOffhandIfNeed();
1277 bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
1278 Item* StoreNewItemInInventorySlot(uint32 itemEntry, uint32 amount);
1280 void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false);
1281 void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG,NULL_SLOT,loot_id,store,broadcast); }
1283 uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
1284 uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
1286 void ApplyEquipCooldown( Item * pItem );
1287 void SetAmmo( uint32 item );
1288 void RemoveAmmo();
1289 float GetAmmoDPS() const { return m_ammoDPS; }
1290 bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const;
1291 void QuickEquipItem( uint16 pos, Item *pItem);
1292 void VisualizeItem( uint8 slot, Item *pItem);
1293 void SetVisibleItemSlot(uint8 slot, Item *pItem);
1294 Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update )
1296 return StoreItem( dest, pItem, update);
1298 Item* BankItem( uint16 pos, Item *pItem, bool update );
1299 void RemoveItem( uint8 bag, uint8 slot, bool update );
1300 void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
1301 // in trade, auction, guild bank, mail....
1302 void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
1303 // in trade, guild bank, mail....
1304 void RemoveItemDependentAurasAndCasts( Item * pItem );
1305 void DestroyItem( uint8 bag, uint8 slot, bool update );
1306 void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
1307 void DestroyItemCount( Item* item, uint32& count, bool update );
1308 void DestroyConjuredItems( bool update );
1309 void DestroyZoneLimitedItem( bool update, uint32 new_zone );
1310 void SplitItem( uint16 src, uint16 dst, uint32 count );
1311 void SwapItem( uint16 src, uint16 dst );
1312 void AddItemToBuyBackSlot( Item *pItem );
1313 Item* GetItemFromBuyBackSlot( uint32 slot );
1314 void RemoveItemFromBuyBackSlot( uint32 slot, bool del );
1315 uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
1316 void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 = NULL, uint32 itemid = 0 ) const;
1317 void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
1318 void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
1319 void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
1320 void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
1321 uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
1322 uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
1323 bool IsUseEquipedWeapon( bool mainhand ) const
1325 // disarm applied only to mainhand weapon
1326 return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) );
1328 bool IsTwoHandUsed() const
1330 Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
1331 return mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
1333 void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false );
1334 bool BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
1336 float GetReputationPriceDiscount( Creature const* pCreature ) const;
1338 Player* GetTrader() const { return m_trade ? m_trade->GetTrader() : NULL; }
1339 TradeData* GetTradeData() const { return m_trade; }
1340 void TradeCancel(bool sendback);
1342 void UpdateEnchantTime(uint32 time);
1343 void UpdateItemDuration(uint32 time, bool realtimeonly=false);
1344 void AddEnchantmentDurations(Item *item);
1345 void RemoveEnchantmentDurations(Item *item);
1346 void RemoveAllEnchantments(EnchantmentSlot slot);
1347 void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration);
1348 void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false);
1349 void ApplyEnchantment(Item *item,bool apply);
1350 void SendEnchantmentDurations();
1351 void BuildEnchantmentsInfoData(WorldPacket *data);
1352 void AddItemDurations(Item *item);
1353 void RemoveItemDurations(Item *item);
1354 void SendItemDurations();
1355 void LoadCorpse();
1356 void LoadPet();
1358 uint32 m_stableSlots;
1360 /*********************************************************/
1361 /*** GOSSIP SYSTEM ***/
1362 /*********************************************************/
1364 void PrepareGossipMenu(WorldObject *pSource, uint32 menuId = 0);
1365 void SendPreparedGossip(WorldObject *pSource);
1366 void OnGossipSelect(WorldObject *pSource, uint32 gossipListId, uint32 menuId);
1368 uint32 GetGossipTextId(uint32 menuId);
1369 uint32 GetGossipTextId(WorldObject *pSource);
1370 uint32 GetDefaultGossipMenuForSource(WorldObject *pSource);
1372 /*********************************************************/
1373 /*** QUEST SYSTEM ***/
1374 /*********************************************************/
1376 // Return player level when QuestLevel is dynamic (-1)
1377 uint32 GetQuestLevelForPlayer(Quest const* pQuest) const { return pQuest && (pQuest->GetQuestLevel() > 0) ? (uint32)pQuest->GetQuestLevel() : getLevel(); }
1379 void PrepareQuestMenu( uint64 guid );
1380 void SendPreparedQuest( uint64 guid );
1381 bool IsActiveQuest( uint32 quest_id ) const; // can be taken or taken
1382 bool IsCurrentQuest( uint32 quest_id ) const; // taken and not yet rewarded
1383 Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
1384 bool CanSeeStartQuest( Quest const *pQuest ) const;
1385 bool CanTakeQuest( Quest const *pQuest, bool msg ) const;
1386 bool CanAddQuest( Quest const *pQuest, bool msg ) const;
1387 bool CanCompleteQuest( uint32 quest_id ) const;
1388 bool CanCompleteRepeatableQuest(Quest const *pQuest) const;
1389 bool CanRewardQuest( Quest const *pQuest, bool msg ) const;
1390 bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg ) const;
1391 void AddQuest( Quest const *pQuest, Object *questGiver );
1392 void CompleteQuest( uint32 quest_id );
1393 void IncompleteQuest( uint32 quest_id );
1394 void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
1396 void FailQuest( uint32 quest_id );
1397 bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg ) const;
1398 bool SatisfyQuestLevel( Quest const* qInfo, bool msg ) const;
1399 bool SatisfyQuestLog( bool msg ) const;
1400 bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const;
1401 bool SatisfyQuestRace( Quest const* qInfo, bool msg ) const;
1402 bool SatisfyQuestReputation( Quest const* qInfo, bool msg ) const;
1403 bool SatisfyQuestStatus( Quest const* qInfo, bool msg ) const;
1404 bool SatisfyQuestTimed( Quest const* qInfo, bool msg ) const;
1405 bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ) const;
1406 bool SatisfyQuestNextChain( Quest const* qInfo, bool msg ) const;
1407 bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg ) const;
1408 bool SatisfyQuestDay( Quest const* qInfo, bool msg ) const;
1409 bool SatisfyQuestWeek( Quest const* qInfo, bool msg ) const;
1410 bool GiveQuestSourceItem( Quest const *pQuest );
1411 bool TakeQuestSourceItem( uint32 quest_id, bool msg );
1412 bool GetQuestRewardStatus( uint32 quest_id ) const;
1413 QuestStatus GetQuestStatus( uint32 quest_id ) const;
1414 void SetQuestStatus( uint32 quest_id, QuestStatus status );
1416 void SetDailyQuestStatus( uint32 quest_id );
1417 void SetWeeklyQuestStatus( uint32 quest_id );
1418 void ResetDailyQuestStatus();
1419 void ResetWeeklyQuestStatus();
1421 uint16 FindQuestSlot( uint32 quest_id ) const;
1422 uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
1423 uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
1424 uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const { return (uint16)(GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET) >> (counter * 16)); }
1425 uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
1426 void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0)
1428 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET, quest_id);
1429 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, 0);
1430 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, 0);
1431 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET + 1, 0);
1432 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer);
1434 void SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count)
1436 uint64 val = GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET);
1437 val &= ~((uint64)0xFFFF << (counter * 16));
1438 val |= ((uint64)count << (counter * 16));
1439 SetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, val);
1441 void SetQuestSlotState(uint16 slot, uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state); }
1442 void RemoveQuestSlotState(uint16 slot, uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state); }
1443 void SetQuestSlotTimer(uint16 slot, uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer); }
1444 void SwapQuestSlot(uint16 slot1, uint16 slot2)
1446 for (int i = 0; i < MAX_QUEST_OFFSET; ++i)
1448 uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i);
1449 uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i);
1451 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i, temp2);
1452 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i, temp1);
1455 uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
1456 void AreaExploredOrEventHappens( uint32 questId );
1457 void GroupEventHappens( uint32 questId, WorldObject const* pEventObject );
1458 void ItemAddedQuestCheck( uint32 entry, uint32 count );
1459 void ItemRemovedQuestCheck( uint32 entry, uint32 count );
1460 void KilledMonster( CreatureInfo const* cInfo, ObjectGuid guid );
1461 void KilledMonsterCredit( uint32 entry, ObjectGuid guid );
1462 void CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster = true );
1463 void TalkedToCreature( uint32 entry, ObjectGuid guid );
1464 void MoneyChanged( uint32 value );
1465 void ReputationChanged(FactionEntry const* factionEntry );
1466 bool HasQuestForItem( uint32 itemid ) const;
1467 bool HasQuestForGO(int32 GOId) const;
1468 void UpdateForQuestWorldObjects();
1469 bool CanShareQuest(uint32 quest_id) const;
1471 void SendQuestComplete( uint32 quest_id );
1472 void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
1473 void SendQuestFailed( uint32 quest_id );
1474 void SendQuestTimerFailed( uint32 quest_id );
1475 void SendCanTakeQuestResponse( uint32 msg ) const;
1476 void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver);
1477 void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
1478 void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
1479 void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count );
1481 uint64 GetDivider() { return m_divider; }
1482 void SetDivider( uint64 guid ) { m_divider = guid; }
1484 uint32 GetInGameTime() { return m_ingametime; }
1486 void SetInGameTime( uint32 time ) { m_ingametime = time; }
1488 void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); }
1489 void RemoveTimedQuest( uint32 quest_id ) { m_timedquests.erase(quest_id); }
1491 /*********************************************************/
1492 /*** LOAD SYSTEM ***/
1493 /*********************************************************/
1495 bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
1497 static uint32 GetZoneIdFromDB(uint64 guid);
1498 static uint32 GetLevelFromDB(uint64 guid);
1499 static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
1501 /*********************************************************/
1502 /*** SAVE SYSTEM ***/
1503 /*********************************************************/
1505 void SaveToDB();
1506 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1507 void SaveGoldToDB();
1508 static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value);
1509 static void SetFloatValueInArray(Tokens& data,uint16 index, float value);
1510 static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
1511 static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid);
1513 static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false);
1514 static void DeleteOldCharacters();
1515 static void DeleteOldCharacters(uint32 keepDays);
1517 bool m_mailsUpdated;
1519 void SendPetTameFailure(PetTameFailureReason reason);
1521 void SetBindPoint(uint64 guid);
1522 void SendTalentWipeConfirm(uint64 guid);
1523 void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
1524 void SendPetSkillWipeConfirm();
1525 void CalcRage( uint32 damage,bool attacker );
1526 void RegenerateAll(uint32 diff = REGEN_TIME_FULL);
1527 void Regenerate(Powers power, uint32 diff);
1528 void RegenerateHealth(uint32 diff);
1529 void setRegenTimer(uint32 time) {m_regenTimer = time;}
1530 void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
1532 uint32 GetMoney() const { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
1533 void ModifyMoney( int32 d )
1535 if(d < 0)
1536 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
1537 else
1538 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
1540 // "At Gold Limit"
1541 if(GetMoney() >= MAX_MONEY_AMOUNT)
1542 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL);
1544 void SetMoney( uint32 value )
1546 SetUInt32Value (PLAYER_FIELD_COINAGE, value);
1547 MoneyChanged( value );
1548 UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED);
1551 QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
1553 const uint64& GetSelection( ) const { return m_curSelection; }
1554 void SetSelection(const uint64 &guid) { m_curSelection = guid; SetTargetGUID(guid); }
1556 uint8 GetComboPoints() { return m_comboPoints; }
1557 const uint64& GetComboTarget() const { return m_comboTarget; }
1559 void AddComboPoints(Unit* target, int8 count);
1560 void ClearComboPoints();
1561 void SendComboPoints();
1563 void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0);
1564 void SendNewMail();
1565 void UpdateNextMailTimeAndUnreads();
1566 void AddNewMailDeliverTime(time_t deliver_time);
1568 void RemoveMail(uint32 id);
1570 void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
1571 uint32 GetMailSize() { return m_mail.size(); }
1572 Mail* GetMail(uint32 id);
1574 PlayerMails::iterator GetMailBegin() { return m_mail.begin();}
1575 PlayerMails::iterator GetMailEnd() { return m_mail.end();}
1577 /*********************************************************/
1578 /*** MAILED ITEMS SYSTEM ***/
1579 /*********************************************************/
1581 uint8 unReadMails;
1582 time_t m_nextMailDelivereTime;
1584 typedef UNORDERED_MAP<uint32, Item*> ItemMap;
1586 ItemMap mMitems; // template defined in objectmgr.cpp
1588 Item* GetMItem(uint32 id)
1590 ItemMap::const_iterator itr = mMitems.find(id);
1591 return itr != mMitems.end() ? itr->second : NULL;
1594 void AddMItem(Item* it)
1596 ASSERT( it );
1597 //ASSERT deleted, because items can be added before loading
1598 mMitems[it->GetGUIDLow()] = it;
1601 bool RemoveMItem(uint32 id)
1603 return mMitems.erase(id) ? true : false;
1606 void PetSpellInitialize();
1607 void SendPetGUIDs();
1608 void CharmSpellInitialize();
1609 void PossessSpellInitialize();
1610 void RemovePetActionBar();
1612 bool HasSpell(uint32 spell) const;
1613 bool HasActiveSpell(uint32 spell) const; // show in spellbook
1614 TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
1615 bool IsSpellFitByClassAndRace( uint32 spell_id ) const;
1616 bool IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const;
1617 bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const;
1619 void SendProficiency(uint8 pr1, uint32 pr2);
1620 void SendInitialSpells();
1621 bool addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled);
1622 void learnSpell(uint32 spell_id, bool dependent);
1623 void removeSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true, bool sendUpdate = true);
1624 void resetSpells();
1625 void learnDefaultSpells();
1626 void learnQuestRewardedSpells();
1627 void learnQuestRewardedSpells(Quest const* quest);
1628 void learnSpellHighRank(uint32 spellid);
1630 uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
1631 void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
1632 void UpdateFreeTalentPoints(bool resetIfNeed = true);
1633 bool resetTalents(bool no_cost = false, bool all_specs = false);
1634 uint32 resetTalentsCost() const;
1635 void InitTalentForLevel();
1636 void BuildPlayerTalentsInfoData(WorldPacket *data);
1637 void BuildPetTalentsInfoData(WorldPacket *data);
1638 void SendTalentsInfoData(bool pet);
1639 void LearnTalent(uint32 talentId, uint32 talentRank);
1640 void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank);
1642 uint32 CalculateTalentsPoints() const;
1644 // Dual Spec
1645 uint8 GetActiveSpec() { return m_activeSpec; }
1646 void SetActiveSpec(uint8 spec) { m_activeSpec = spec; }
1647 uint8 GetSpecsCount() { return m_specsCount; }
1648 void SetSpecsCount(uint8 count) { m_specsCount = count; }
1649 void ActivateSpec(uint8 specNum);
1650 void UpdateSpecCount(uint8 count);
1652 void InitGlyphsForLevel();
1653 void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); }
1654 uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); }
1655 void SetGlyph(uint8 slot, uint32 glyph) { m_glyphs[m_activeSpec][slot].SetId(glyph); }
1656 uint32 GetGlyph(uint8 slot) { return m_glyphs[m_activeSpec][slot].GetId(); }
1657 void ApplyGlyph(uint8 slot, bool apply);
1658 void ApplyGlyphs(bool apply);
1660 uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); }
1661 void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2, profs); }
1662 void InitPrimaryProfessions();
1664 PlayerSpellMap const& GetSpellMap() const { return m_spells; }
1665 PlayerSpellMap & GetSpellMap() { return m_spells; }
1667 SpellCooldowns const& GetSpellCooldownMap() const { return m_spellCooldowns; }
1669 void AddSpellMod(SpellModifier* mod, bool apply);
1670 bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL);
1671 template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL);
1672 void RemoveSpellMods(Spell const* spell);
1674 static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check
1675 static uint32 const infinityCooldownDelayCheck = MONTH/2;
1676 bool HasSpellCooldown(uint32 spell_id) const
1678 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1679 return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
1681 time_t GetSpellCooldownDelay(uint32 spell_id) const
1683 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1684 time_t t = time(NULL);
1685 return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
1687 void AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false );
1688 void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
1689 void SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId = 0, Spell* spell = NULL);
1690 void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs );
1691 void RemoveSpellCooldown(uint32 spell_id, bool update = false);
1692 void RemoveSpellCategoryCooldown(uint32 cat, bool update = false);
1693 void SendClearCooldown( uint32 spell_id, Unit* target );
1695 void RemoveArenaSpellCooldowns();
1696 void RemoveAllSpellCooldown();
1697 void _LoadSpellCooldowns(QueryResult *result);
1698 void _SaveSpellCooldowns();
1699 void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
1700 uint32 GetLastPotionId() { return m_lastPotionId; }
1701 void UpdatePotionCooldown(Spell* spell = NULL);
1703 void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
1705 m_resurrectGUID = guid;
1706 m_resurrectMap = mapId;
1707 m_resurrectX = X;
1708 m_resurrectY = Y;
1709 m_resurrectZ = Z;
1710 m_resurrectHealth = health;
1711 m_resurrectMana = mana;
1713 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); }
1714 bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; }
1715 bool isRessurectRequested() const { return m_resurrectGUID != 0; }
1716 void ResurectUsingRequestData();
1718 int getCinematic()
1720 return m_cinematic;
1722 void setCinematic(int cine)
1724 m_cinematic = cine;
1727 static bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Player* player, bool msg = true);
1728 ActionButton* addActionButton(uint8 spec, uint8 button, uint32 action, uint8 type);
1729 void removeActionButton(uint8 spec, uint8 button);
1730 void SendInitialActionButtons() const;
1731 ActionButton const* GetActionButton(uint8 button);
1733 PvPInfo pvpInfo;
1734 void UpdatePvP(bool state, bool ovrride=false);
1735 void UpdateZone(uint32 newZone,uint32 newArea);
1736 void UpdateArea(uint32 newArea);
1738 void UpdateZoneDependentAuras( uint32 zone_id ); // zones
1739 void UpdateAreaDependentAuras( uint32 area_id ); // subzones
1741 void UpdateAfkReport(time_t currTime);
1742 void UpdatePvPFlag(time_t currTime);
1743 void UpdateContestedPvP(uint32 currTime);
1744 void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
1745 void ResetContestedPvP()
1747 clearUnitState(UNIT_STAT_ATTACK_PLAYER);
1748 RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
1749 m_contestedPvPTimer = 0;
1752 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1753 DuelInfo *duel;
1754 void UpdateDuelFlag(time_t currTime);
1755 void CheckDuelDistance(time_t currTime);
1756 void DuelComplete(DuelCompleteType type);
1757 void SendDuelCountdown(uint32 counter);
1759 bool IsGroupVisibleFor(Player* p) const;
1760 bool IsInSameGroupWith(Player const* p) const;
1761 bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
1762 void UninviteFromGroup();
1763 static void RemoveFromGroup(Group* group, uint64 guid);
1764 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1765 void SendUpdateToOutOfRangeGroupMembers();
1767 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
1768 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
1769 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
1770 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
1771 static uint32 GetGuildIdFromDB(uint64 guid);
1772 uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
1773 static uint32 GetRankFromDB(uint64 guid);
1774 int GetGuildIdInvited() { return m_GuildIdInvited; }
1775 static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
1777 // Arena Team
1778 void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
1780 SetArenaTeamInfoField(slot, ARENA_TEAM_ID, ArenaTeamId);
1781 SetArenaTeamInfoField(slot, ARENA_TEAM_TYPE, type);
1783 void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
1785 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value);
1787 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); }
1788 uint32 GetArenaPersonalRating(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); }
1789 static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
1790 void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
1791 uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
1792 static void LeaveAllArenaTeams(uint64 guid);
1794 Difficulty GetDifficulty(bool isRaid) const { return isRaid ? m_raidDifficulty : m_dungeonDifficulty; }
1795 Difficulty GetDungeonDifficulty() const { return m_dungeonDifficulty; }
1796 Difficulty GetRaidDifficulty() const { return m_raidDifficulty; }
1797 void SetDungeonDifficulty(Difficulty dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; }
1798 void SetRaidDifficulty(Difficulty raid_difficulty) { m_raidDifficulty = raid_difficulty; }
1800 bool UpdateSkill(uint32 skill_id, uint32 step);
1801 bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step);
1803 bool UpdateCraftSkill(uint32 spellid);
1804 bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1);
1805 bool UpdateFishingSkill();
1807 uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); }
1808 uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const;
1810 uint32 GetSpellByProto(ItemPrototype *proto);
1812 float GetHealthBonusFromStamina();
1813 float GetManaBonusFromIntellect();
1815 bool UpdateStats(Stats stat);
1816 bool UpdateAllStats();
1817 void UpdateResistances(uint32 school);
1818 void UpdateArmor();
1819 void UpdateMaxHealth();
1820 void UpdateMaxPower(Powers power);
1821 void ApplyFeralAPBonus(int32 amount, bool apply);
1822 void UpdateAttackPowerAndDamage(bool ranged = false);
1823 void UpdateShieldBlockValue();
1824 void UpdateDamagePhysical(WeaponAttackType attType);
1825 void ApplySpellPowerBonus(int32 amount, bool apply);
1826 void UpdateSpellDamageAndHealingBonus();
1827 void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
1828 void UpdateRating(CombatRating cr);
1829 void UpdateAllRatings();
1831 void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage);
1833 void UpdateDefenseBonusesMod();
1834 float GetMeleeCritFromAgility();
1835 float GetDodgeFromAgility();
1836 float GetSpellCritFromIntellect();
1837 float OCTRegenHPPerSpirit();
1838 float OCTRegenMPPerSpirit();
1839 float GetRatingCoefficient(CombatRating cr) const;
1840 float GetRatingBonusValue(CombatRating cr) const;
1841 uint32 GetBaseSpellPowerBonus() { return m_baseSpellPower; }
1843 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
1844 void UpdateBlockPercentage();
1845 void UpdateCritPercentage(WeaponAttackType attType);
1846 void UpdateAllCritPercentages();
1847 void UpdateParryPercentage();
1848 void UpdateDodgePercentage();
1849 void UpdateMeleeHitChances();
1850 void UpdateRangedHitChances();
1851 void UpdateSpellHitChances();
1853 void UpdateAllSpellCritChances();
1854 void UpdateSpellCritChance(uint32 school);
1855 void UpdateExpertise(WeaponAttackType attType);
1856 void UpdateArmorPenetration();
1857 void ApplyManaRegenBonus(int32 amount, bool apply);
1858 void UpdateManaRegen();
1860 const uint64& GetLootGUID() const { return m_lootGuid.GetRawValue(); }
1861 void SetLootGUID(ObjectGuid const& guid) { m_lootGuid = guid; }
1863 void RemovedInsignia(Player* looterPlr);
1865 WorldSession* GetSession() const { return m_session; }
1866 void SetSession(WorldSession *s) { m_session = s; }
1868 void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const;
1869 void DestroyForPlayer( Player *target, bool anim = false ) const;
1870 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
1872 // notifiers
1873 void SendAttackSwingCantAttack();
1874 void SendAttackSwingCancelAttack();
1875 void SendAttackSwingDeadTarget();
1876 void SendAttackSwingNotInRange();
1877 void SendAttackSwingBadFacingAttack();
1878 void SendAutoRepeatCancel(Unit *target);
1879 void SendExplorationExperience(uint32 Area, uint32 Experience);
1881 void SendDungeonDifficulty(bool IsInGroup);
1882 void SendRaidDifficulty(bool IsInGroup);
1883 void ResetInstances(uint8 method, bool isRaid);
1884 void SendResetInstanceSuccess(uint32 MapId);
1885 void SendResetInstanceFailed(uint32 reason, uint32 MapId);
1886 void SendResetFailedNotify(uint32 mapid);
1888 bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
1889 void UpdateUnderwaterState( Map * m, float x, float y, float z );
1891 void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet
1892 void SendMessageToSetInRange(WorldPacket *data, float fist, bool self);
1893 // overwrite Object::SendMessageToSetInRange
1894 void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only);
1896 Corpse *GetCorpse() const;
1897 void SpawnCorpseBones();
1898 Corpse* CreateCorpse();
1899 void KillPlayer();
1900 uint32 GetResurrectionSpellId();
1901 void ResurrectPlayer(float restore_percent, bool applySickness = false);
1902 void BuildPlayerRepop();
1903 void RepopAtGraveyard();
1905 void DurabilityLossAll(double percent, bool inventory);
1906 void DurabilityLoss(Item* item, double percent);
1907 void DurabilityPointsLossAll(int32 points, bool inventory);
1908 void DurabilityPointsLoss(Item* item, int32 points);
1909 void DurabilityPointLossForEquipSlot(EquipmentSlots slot);
1910 uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank);
1911 uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank);
1913 void UpdateMirrorTimers();
1914 void StopMirrorTimers()
1916 StopMirrorTimer(FATIGUE_TIMER);
1917 StopMirrorTimer(BREATH_TIMER);
1918 StopMirrorTimer(FIRE_TIMER);
1921 void SetMovement(PlayerMovementType pType);
1923 void JoinedChannel(Channel *c);
1924 void LeftChannel(Channel *c);
1925 void CleanupChannels();
1926 void UpdateLocalChannels( uint32 newZone );
1927 void LeaveLFGChannel();
1929 void UpdateDefense();
1930 void UpdateWeaponSkill (WeaponAttackType attType);
1931 void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence);
1933 void SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step = 0);
1934 uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
1935 uint16 GetPureMaxSkillValue(uint32 skill) const; // max
1936 uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
1937 uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus
1938 uint16 GetPureSkillValue(uint32 skill) const; // skill value
1939 int16 GetSkillPermBonusValue(uint32 skill) const;
1940 int16 GetSkillTempBonusValue(uint32 skill) const;
1941 bool HasSkill(uint32 skill) const;
1942 void learnSkillRewardedSpells(uint32 id, uint32 value);
1944 WorldLocation& GetTeleportDest() { return m_teleport_dest; }
1945 bool IsBeingTeleported() const { return mSemaphoreTeleport_Near || mSemaphoreTeleport_Far; }
1946 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near; }
1947 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far; }
1948 void SetSemaphoreTeleportNear(bool semphsetting) { mSemaphoreTeleport_Near = semphsetting; }
1949 void SetSemaphoreTeleportFar(bool semphsetting) { mSemaphoreTeleport_Far = semphsetting; }
1950 void ProcessDelayedOperations();
1952 void CheckExploreSystem(void);
1954 static uint32 TeamForRace(uint8 race);
1955 uint32 GetTeam() const { return m_team; }
1956 static uint32 getFactionForRace(uint8 race);
1957 void setFactionForRace(uint8 race);
1959 void InitDisplayIds();
1961 bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
1962 void RewardSinglePlayerAtKill(Unit* pVictim);
1963 void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
1964 void RewardPlayerAndGroupAtCast(WorldObject* pRewardSource, uint32 spellid = 0);
1965 bool isHonorOrXPTarget(Unit* pVictim) const;
1967 ReputationMgr& GetReputationMgr() { return m_reputationMgr; }
1968 ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; }
1969 ReputationRank GetReputationRank(uint32 faction_id) const;
1970 void RewardReputation(Unit *pVictim, float rate);
1971 void RewardReputation(Quest const *pQuest);
1973 void UpdateSkillsForLevel();
1974 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1975 void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
1977 /*********************************************************/
1978 /*** PVP SYSTEM ***/
1979 /*********************************************************/
1980 void UpdateArenaFields();
1981 void UpdateHonorFields();
1982 bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1);
1983 uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
1984 uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
1985 void ModifyHonorPoints( int32 value );
1986 void ModifyArenaPoints( int32 value );
1987 uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot);
1989 //End of PvP System
1991 void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0);
1992 uint16 GetDrunkValue() const { return m_drunk; }
1993 static DrunkenState GetDrunkenstateByValue(uint16 value);
1995 uint32 GetDeathTimer() const { return m_deathTimer; }
1996 uint32 GetCorpseReclaimDelay(bool pvp) const;
1997 void UpdateCorpseReclaimDelay();
1998 void SendCorpseReclaimDelay(bool load = false);
2000 uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual)
2001 bool CanParry() const { return m_canParry; }
2002 void SetCanParry(bool value);
2003 bool CanBlock() const { return m_canBlock; }
2004 void SetCanBlock(bool value);
2005 bool CanDualWield() const { return m_canDualWield; }
2006 void SetCanDualWield(bool value) { m_canDualWield = value; }
2007 bool CanTitanGrip() const { return m_canTitanGrip; }
2008 void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
2009 bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); }
2011 void SetRegularAttackTime();
2012 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }
2013 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply);
2014 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
2015 float GetTotalBaseModValue(BaseModGroup modGroup) const;
2016 float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; }
2017 void _ApplyAllStatBonuses();
2018 void _RemoveAllStatBonuses();
2019 float GetArmorPenetrationPct() const { return m_armorPenetrationPct; }
2021 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
2022 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
2023 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
2025 void _ApplyItemMods(Item *item,uint8 slot,bool apply);
2026 void _RemoveAllItemMods();
2027 void _ApplyAllItemMods();
2028 void _ApplyAllLevelScaleItemMods(bool apply);
2029 void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply, bool only_level_scale = false);
2030 void _ApplyAmmoBonuses();
2031 bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot);
2032 void ToggleMetaGemsActive(uint8 exceptslot, bool apply);
2033 void CorrectMetaGemEnchants(uint8 slot, bool apply);
2034 void InitDataForForm(bool reapplyMods = false);
2036 void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
2037 void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
2038 void UpdateEquipSpellsAtFormChange();
2039 void CastItemCombatSpell(Unit* Target, WeaponAttackType attType);
2040 void CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex);
2042 void SendEquipmentSetList();
2043 void SetEquipmentSet(uint32 index, EquipmentSet eqset);
2044 void DeleteEquipmentSet(uint64 setGuid);
2046 void SendInitWorldStates(uint32 zone, uint32 area);
2047 void SendUpdateWorldState(uint32 Field, uint32 Value);
2048 void SendDirectMessage(WorldPacket *data);
2049 void FillBGWeekendWorldStates(WorldPacket& data, uint32& count);
2051 void SendAurasForTarget(Unit *target);
2053 PlayerMenu* PlayerTalkClass;
2054 std::vector<ItemSetEffect *> ItemSetEff;
2056 void SendLoot(ObjectGuid guid, LootType loot_type);
2057 void SendLootRelease(ObjectGuid guid );
2058 void SendNotifyLootItemRemoved(uint8 lootSlot);
2059 void SendNotifyLootMoneyRemoved();
2061 /*********************************************************/
2062 /*** BATTLEGROUND SYSTEM ***/
2063 /*********************************************************/
2065 bool InBattleGround() const { return m_bgData.bgInstanceID != 0; }
2066 bool InArena() const;
2067 uint32 GetBattleGroundId() const { return m_bgData.bgInstanceID; }
2068 BattleGroundTypeId GetBattleGroundTypeId() const { return m_bgData.bgTypeID; }
2069 BattleGround* GetBattleGround() const;
2071 bool InBattleGroundQueue() const
2073 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2074 if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
2075 return true;
2076 return false;
2079 BattleGroundQueueTypeId GetBattleGroundQueueTypeId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueTypeId; }
2080 uint32 GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId) const
2082 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2083 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
2084 return i;
2085 return PLAYER_MAX_BATTLEGROUND_QUEUES;
2087 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
2089 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2090 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
2091 return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
2092 return false;
2094 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
2096 return GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES;
2099 void SetBattleGroundId(uint32 val, BattleGroundTypeId bgTypeId)
2101 m_bgData.bgInstanceID = val;
2102 m_bgData.bgTypeID = bgTypeId;
2104 uint32 AddBattleGroundQueueId(BattleGroundQueueTypeId val)
2106 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2108 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattleGroundQueueID[i].bgQueueTypeId == val)
2110 m_bgBattleGroundQueueID[i].bgQueueTypeId = val;
2111 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
2112 return i;
2115 return PLAYER_MAX_BATTLEGROUND_QUEUES;
2117 bool HasFreeBattleGroundQueueId()
2119 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2120 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
2121 return true;
2122 return false;
2124 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val)
2126 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2128 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == val)
2130 m_bgBattleGroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
2131 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
2132 return;
2136 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId, uint32 instanceId)
2138 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2139 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
2140 m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
2142 bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
2144 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
2145 if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
2146 return true;
2147 return false;
2149 WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; }
2150 void SetBattleGroundEntryPoint();
2152 void SetBGTeam(uint32 team) { m_bgData.bgTeam = team; }
2153 uint32 GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); }
2155 void LeaveBattleground(bool teleportToEntryPoint = true);
2156 bool CanJoinToBattleground() const;
2157 bool CanReportAfkDueToLimit();
2158 void ReportedAfkBy(Player* reporter);
2159 void ClearAfkReports() { m_bgData.bgAfkReporter.clear(); }
2161 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const;
2162 bool CanUseBattleGroundObject();
2163 bool isTotalImmune();
2164 bool CanCaptureTowerPoint();
2166 /*********************************************************/
2167 /*** REST SYSTEM ***/
2168 /*********************************************************/
2170 bool isRested() const { return GetRestTime() >= 10*IN_MILLISECONDS; }
2171 uint32 GetXPRestBonus(uint32 xp);
2172 uint32 GetRestTime() const { return m_restTime; }
2173 void SetRestTime(uint32 v) { m_restTime = v; }
2175 /*********************************************************/
2176 /*** ENVIROMENTAL SYSTEM ***/
2177 /*********************************************************/
2179 uint32 EnvironmentalDamage(EnviromentalDamage type, uint32 damage);
2181 /*********************************************************/
2182 /*** FLOOD FILTER SYSTEM ***/
2183 /*********************************************************/
2185 void UpdateSpeakTime();
2186 bool CanSpeak() const;
2187 void ChangeSpeakTime(int utime);
2189 /*********************************************************/
2190 /*** VARIOUS SYSTEMS ***/
2191 /*********************************************************/
2192 bool HasMovementFlag(MovementFlags f) const; // for script access to m_movementInfo.HasMovementFlag
2193 void UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode);
2194 Unit *m_mover;
2195 void SetFallInformation(uint32 time, float z)
2197 m_lastFallTime = time;
2198 m_lastFallZ = z;
2200 void HandleFall(MovementInfo const& movementInfo);
2202 void BuildTeleportAckMsg( WorldPacket *data, float x, float y, float z, float ang) const;
2204 bool isMoving() const { return m_movementInfo.HasMovementFlag(movementFlagsMask); }
2205 bool isMovingOrTurning() const { return m_movementInfo.HasMovementFlag(movementOrTurningFlagsMask); }
2207 bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_CAN_FLY); }
2208 bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_FLYING); }
2209 bool IsKnowHowFlyIn(uint32 mapid, uint32 zone, uint32 area) const;
2211 void SetClientControl(Unit* target, uint8 allowMove);
2212 void SetMover(Unit* target) { m_mover = target ? target : this; }
2214 void EnterVehicle(Vehicle *vehicle);
2215 void ExitVehicle(Vehicle *vehicle);
2217 uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
2218 void SetFarSightGUID(uint64 guid);
2220 // Transports
2221 Transport * GetTransport() const { return m_transport; }
2222 void SetTransport(Transport * t) { m_transport = t; }
2224 float GetTransOffsetX() const { return m_movementInfo.GetTransportPos()->x; }
2225 float GetTransOffsetY() const { return m_movementInfo.GetTransportPos()->y; }
2226 float GetTransOffsetZ() const { return m_movementInfo.GetTransportPos()->z; }
2227 float GetTransOffsetO() const { return m_movementInfo.GetTransportPos()->o; }
2228 uint32 GetTransTime() const { return m_movementInfo.GetTransportTime(); }
2229 int8 GetTransSeat() const { return m_movementInfo.GetTransportSeat(); }
2231 uint32 GetSaveTimer() const { return m_nextSave; }
2232 void SetSaveTimer(uint32 timer) { m_nextSave = timer; }
2234 // Recall position
2235 uint32 m_recallMap;
2236 float m_recallX;
2237 float m_recallY;
2238 float m_recallZ;
2239 float m_recallO;
2240 void SaveRecallPosition();
2242 void SetHomebindToLocation(WorldLocation const& loc, uint32 area_id);
2243 void RelocateToHomebind() { SetLocationMapId(m_homebindMapId); Relocate(m_homebindX, m_homebindY, m_homebindZ); }
2244 bool TeleportToHomebind(uint32 options = 0) { return TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation(), options); }
2246 Object* GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask);
2248 // currently visible objects at player client
2249 ObjectGuidSet m_clientGUIDs;
2251 bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); }
2253 WorldObject const* GetViewPoint() const;
2254 bool IsVisibleInGridForPlayer(Player* pl) const;
2255 bool IsVisibleGloballyFor(Player* pl) const;
2257 void UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target);
2259 template<class T>
2260 void UpdateVisibilityOf(WorldObject const* viewPoint,T* target, UpdateData& data, std::set<WorldObject*>& visibleNow);
2262 // Stealth detection system
2263 void HandleStealthedUnitsDetection();
2265 uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
2267 bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; }
2268 void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
2269 void RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also = false);
2271 LookingForGroup m_lookingForGroup;
2273 // Temporarily removed pet cache
2274 uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
2275 void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
2276 void UnsummonPetTemporaryIfAny();
2277 void ResummonPetTemporaryUnSummonedIfAny();
2278 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
2280 void SendCinematicStart(uint32 CinematicSequenceId);
2281 void SendMovieStart(uint32 MovieId);
2283 /*********************************************************/
2284 /*** INSTANCE SYSTEM ***/
2285 /*********************************************************/
2287 typedef UNORDERED_MAP< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap;
2289 void UpdateHomebindTime(uint32 time);
2291 uint32 m_HomebindTimer;
2292 bool m_InstanceValid;
2293 // permanent binds and solo binds by difficulty
2294 BoundInstancesMap m_boundInstances[MAX_DIFFICULTY];
2295 InstancePlayerBind* GetBoundInstance(uint32 mapid, Difficulty difficulty);
2296 BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; }
2297 void UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload = false);
2298 void UnbindInstance(BoundInstancesMap::iterator &itr, Difficulty difficulty, bool unload = false);
2299 InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false);
2300 void SendRaidInfo();
2301 void SendSavedInstances();
2302 static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0);
2304 /*********************************************************/
2305 /*** GROUP SYSTEM ***/
2306 /*********************************************************/
2308 Group * GetGroupInvite() { return m_groupInvite; }
2309 void SetGroupInvite(Group *group) { m_groupInvite = group; }
2310 Group * GetGroup() { return m_group.getTarget(); }
2311 const Group * GetGroup() const { return (const Group*)m_group.getTarget(); }
2312 GroupReference& GetGroupRef() { return m_group; }
2313 void SetGroup(Group *group, int8 subgroup = -1);
2314 uint8 GetSubGroup() const { return m_group.getSubGroup(); }
2315 uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; }
2316 void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
2317 const uint64& GetAuraUpdateMask() const { return m_auraUpdateMask; }
2318 void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
2319 Player* GetNextRandomRaidMember(float radius);
2320 PartyResult CanUninviteFromGroup() const;
2321 // BattleGround Group System
2322 void SetBattleGroundRaid(Group *group, int8 subgroup = -1);
2323 void RemoveFromBattleGroundRaid();
2324 Group * GetOriginalGroup() { return m_originalGroup.getTarget(); }
2325 GroupReference& GetOriginalGroupRef() { return m_originalGroup; }
2326 uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); }
2327 void SetOriginalGroup(Group *group, int8 subgroup = -1);
2329 GridReference<Player> &GetGridRef() { return m_gridRef; }
2330 MapReference &GetMapRef() { return m_mapRef; }
2332 bool isAllowedToLoot(Creature* creature);
2334 DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
2336 // Rune functions, need check getClass() == CLASS_DEATH_KNIGHT before access
2337 uint8 GetRunesState() const { return m_runes->runeState; }
2338 RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->runes[index].BaseRune); }
2339 RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->runes[index].CurrentRune); }
2340 uint16 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; }
2341 bool IsBaseRuneSlotsOnCooldown(RuneType runeType) const;
2342 void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; }
2343 void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
2344 void SetRuneCooldown(uint8 index, uint16 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); }
2345 void ConvertRune(uint8 index, RuneType newType);
2346 void ResyncRunes(uint8 count);
2347 void AddRunePower(uint8 index);
2348 void InitRunes();
2350 AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
2351 void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0);
2352 bool HasTitle(uint32 bitIndex);
2353 bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }
2354 void SetTitle(CharTitlesEntry const* title, bool lost = false);
2356 bool isActiveObject() const { return true; }
2357 bool canSeeSpellClickOn(Creature const* creature) const;
2358 protected:
2360 uint32 m_contestedPvPTimer;
2362 /*********************************************************/
2363 /*** BATTLEGROUND SYSTEM ***/
2364 /*********************************************************/
2367 this is an array of BG queues (BgTypeIDs) in which is player
2369 struct BgBattleGroundQueueID_Rec
2371 BattleGroundQueueTypeId bgQueueTypeId;
2372 uint32 invitedToInstance;
2375 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES];
2376 BGData m_bgData;
2378 /*********************************************************/
2379 /*** QUEST SYSTEM ***/
2380 /*********************************************************/
2382 //We allow only one timed quest active at the same time. Below can then be simple value instead of set.
2383 typedef std::set<uint32> QuestSet;
2384 QuestSet m_timedquests;
2385 QuestSet m_weeklyquests;
2387 uint64 m_divider;
2388 uint32 m_ingametime;
2390 /*********************************************************/
2391 /*** LOAD SYSTEM ***/
2392 /*********************************************************/
2394 void _LoadActions(QueryResult *result);
2395 void _LoadAuras(QueryResult *result, uint32 timediff);
2396 void _LoadBoundInstances(QueryResult *result);
2397 void _LoadInventory(QueryResult *result, uint32 timediff);
2398 void _LoadMails(QueryResult *result);
2399 void _LoadMailedItems(QueryResult *result);
2400 void _LoadQuestStatus(QueryResult *result);
2401 void _LoadDailyQuestStatus(QueryResult *result);
2402 void _LoadWeeklyQuestStatus(QueryResult *result);
2403 void _LoadGroup(QueryResult *result);
2404 void _LoadSkills(QueryResult *result);
2405 void _LoadSpells(QueryResult *result);
2406 void _LoadTalents(QueryResult *result);
2407 void _LoadFriendList(QueryResult *result);
2408 bool _LoadHomeBind(QueryResult *result);
2409 void _LoadDeclinedNames(QueryResult *result);
2410 void _LoadArenaTeamInfo(QueryResult *result);
2411 void _LoadEquipmentSets(QueryResult *result);
2412 void _LoadBGData(QueryResult* result);
2413 void _LoadGlyphs(QueryResult *result);
2414 void _LoadIntoDataField(const char* data, uint32 startOffset, uint32 count);
2416 /*********************************************************/
2417 /*** SAVE SYSTEM ***/
2418 /*********************************************************/
2420 void _SaveActions();
2421 void _SaveAuras();
2422 void _SaveInventory();
2423 void _SaveMail();
2424 void _SaveQuestStatus();
2425 void _SaveDailyQuestStatus();
2426 void _SaveWeeklyQuestStatus();
2427 void _SaveSkills();
2428 void _SaveSpells();
2429 void _SaveEquipmentSets();
2430 void _SaveBGData();
2431 void _SaveGlyphs();
2432 void _SaveTalents();
2433 void _SaveStats();
2435 void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
2436 void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
2438 /*********************************************************/
2439 /*** ENVIRONMENTAL SYSTEM ***/
2440 /*********************************************************/
2441 void HandleSobering();
2442 void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen);
2443 void StopMirrorTimer(MirrorTimerType Type);
2444 void HandleDrowning(uint32 time_diff);
2445 int32 getMaxTimer(MirrorTimerType timer);
2447 /*********************************************************/
2448 /*** HONOR SYSTEM ***/
2449 /*********************************************************/
2450 time_t m_lastHonorUpdateTime;
2452 void outDebugStatsValues() const;
2453 ObjectGuid m_lootGuid;
2455 uint32 m_team;
2456 uint32 m_nextSave;
2457 time_t m_speakTime;
2458 uint32 m_speakCount;
2459 Difficulty m_dungeonDifficulty;
2460 Difficulty m_raidDifficulty;
2462 uint32 m_atLoginFlags;
2464 Item* m_items[PLAYER_SLOTS_COUNT];
2465 uint32 m_currentBuybackSlot;
2467 std::vector<Item*> m_itemUpdateQueue;
2468 bool m_itemUpdateQueueBlocked;
2470 uint32 m_ExtraFlags;
2471 uint64 m_curSelection;
2473 uint64 m_comboTarget;
2474 int8 m_comboPoints;
2476 QuestStatusMap mQuestStatus;
2478 SkillStatusMap mSkillStatus;
2480 uint32 m_GuildIdInvited;
2481 uint32 m_ArenaTeamIdInvited;
2483 PlayerMails m_mail;
2484 PlayerSpellMap m_spells;
2485 PlayerTalentMap m_talents[MAX_TALENT_SPEC_COUNT];
2486 SpellCooldowns m_spellCooldowns;
2487 uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use
2489 uint8 m_activeSpec;
2490 uint8 m_specsCount;
2492 ActionButtonList m_actionButtons[MAX_TALENT_SPEC_COUNT];
2494 Glyph m_glyphs[MAX_TALENT_SPEC_COUNT][MAX_GLYPH_SLOT_INDEX];
2496 float m_auraBaseMod[BASEMOD_END][MOD_END];
2497 int16 m_baseRatingValue[MAX_COMBAT_RATING];
2498 uint16 m_baseSpellPower;
2499 uint16 m_baseFeralAP;
2500 uint16 m_baseManaRegen;
2501 float m_armorPenetrationPct;
2503 SpellModList m_spellMods[MAX_SPELLMOD];
2504 int32 m_SpellModRemoveCount;
2505 EnchantDurationList m_enchantDuration;
2506 ItemDurationList m_itemDuration;
2508 uint64 m_resurrectGUID;
2509 uint32 m_resurrectMap;
2510 float m_resurrectX, m_resurrectY, m_resurrectZ;
2511 uint32 m_resurrectHealth, m_resurrectMana;
2513 WorldSession *m_session;
2515 typedef std::list<Channel*> JoinedChannelsList;
2516 JoinedChannelsList m_channels;
2518 int m_cinematic;
2520 TradeData* m_trade;
2522 bool m_DailyQuestChanged;
2523 bool m_WeeklyQuestChanged;
2525 uint32 m_drunkTimer;
2526 uint16 m_drunk;
2527 uint32 m_weaponChangeTimer;
2529 uint32 m_zoneUpdateId;
2530 uint32 m_zoneUpdateTimer;
2531 uint32 m_areaUpdateId;
2533 uint32 m_deathTimer;
2534 time_t m_deathExpireTime;
2536 uint32 m_restTime;
2538 uint32 m_WeaponProficiency;
2539 uint32 m_ArmorProficiency;
2540 bool m_canParry;
2541 bool m_canBlock;
2542 bool m_canDualWield;
2543 bool m_canTitanGrip;
2544 uint8 m_swingErrorMsg;
2545 float m_ammoDPS;
2547 ////////////////////Rest System/////////////////////
2548 time_t time_inn_enter;
2549 uint32 inn_trigger_id;
2550 float m_rest_bonus;
2551 RestType rest_type;
2552 ////////////////////Rest System/////////////////////
2554 // Transports
2555 Transport * m_transport;
2557 uint32 m_resetTalentsCost;
2558 time_t m_resetTalentsTime;
2559 uint32 m_usedTalentCount;
2560 uint32 m_questRewardTalentCount;
2562 // Social
2563 PlayerSocial *m_social;
2565 // Groups
2566 GroupReference m_group;
2567 GroupReference m_originalGroup;
2568 Group *m_groupInvite;
2569 uint32 m_groupUpdateMask;
2570 uint64 m_auraUpdateMask;
2572 uint64 m_miniPet;
2574 // Player summoning
2575 time_t m_summon_expire;
2576 uint32 m_summon_mapid;
2577 float m_summon_x;
2578 float m_summon_y;
2579 float m_summon_z;
2581 DeclinedName *m_declinedname;
2582 Runes *m_runes;
2583 EquipmentSets m_EquipmentSets;
2584 private:
2585 // internal common parts for CanStore/StoreItem functions
2586 uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
2587 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;
2588 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;
2589 Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
2591 void UpdateKnownCurrencies(uint32 itemId, bool apply);
2592 int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest);
2593 void AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& questStatusData );
2595 bool IsCanDelayTeleport() const { return m_bCanDelayTeleport; }
2596 void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; }
2597 bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; }
2598 void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; }
2600 void ScheduleDelayedOperation(uint32 operation)
2602 if(operation < DELAYED_END)
2603 m_DelayedOperations |= operation;
2606 GridReference<Player> m_gridRef;
2607 MapReference m_mapRef;
2609 // Homebind coordinates
2610 uint32 m_homebindMapId;
2611 uint16 m_homebindAreaId;
2612 float m_homebindX;
2613 float m_homebindY;
2614 float m_homebindZ;
2616 uint32 m_lastFallTime;
2617 float m_lastFallZ;
2619 int32 m_MirrorTimer[MAX_TIMERS];
2620 uint8 m_MirrorTimerFlags;
2621 uint8 m_MirrorTimerFlagsLast;
2622 bool m_isInWater;
2624 // Current teleport data
2625 WorldLocation m_teleport_dest;
2626 uint32 m_teleport_options;
2627 bool mSemaphoreTeleport_Near;
2628 bool mSemaphoreTeleport_Far;
2630 uint32 m_DelayedOperations;
2631 bool m_bCanDelayTeleport;
2632 bool m_bHasDelayedTeleport;
2634 uint32 m_DetectInvTimer;
2636 // Temporary removed pet cache
2637 uint32 m_temporaryUnsummonedPetNumber;
2638 uint32 m_oldpetspell;
2640 AchievementMgr m_achievementMgr;
2641 ReputationMgr m_reputationMgr;
2643 uint32 m_timeSyncCounter;
2644 uint32 m_timeSyncTimer;
2645 uint32 m_timeSyncClient;
2646 uint32 m_timeSyncServer;
2649 void AddItemsSetItem(Player*player,Item *item);
2650 void RemoveItemsSetItem(Player*player,ItemPrototype const *proto);
2652 // "the bodies of template functions must be made available in a header file"
2653 template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell)
2655 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
2656 if (!spellInfo) return 0;
2657 int32 totalpct = 0;
2658 int32 totalflat = 0;
2659 for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
2661 SpellModifier *mod = *itr;
2663 if(!IsAffectedBySpellmod(spellInfo,mod,spell))
2664 continue;
2665 if (mod->type == SPELLMOD_FLAT)
2666 totalflat += mod->value;
2667 else if (mod->type == SPELLMOD_PCT)
2669 // skip percent mods for null basevalue (most important for spell mods with charges )
2670 if(basevalue == T(0))
2671 continue;
2673 // special case (skip >10sec spell casts for instant cast setting)
2674 if( mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10*IN_MILLISECONDS) && mod->value <= -100)
2675 continue;
2677 totalpct += mod->value;
2680 if (mod->charges > 0 )
2682 --mod->charges;
2683 if (mod->charges == 0)
2685 mod->charges = -1;
2686 mod->lastAffected = spell;
2687 if(!mod->lastAffected)
2688 mod->lastAffected = FindCurrentSpellBySpellId(spellId);
2689 ++m_SpellModRemoveCount;
2694 float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat;
2695 basevalue = T((float)basevalue + diff);
2696 return T(diff);
2699 template<typename Func>
2700 void Player::CallForAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms, bool withMiniPet)
2702 if (withMiniPet)
2703 if(Unit* mini = GetMiniPet())
2704 func(mini);
2706 Unit::CallForAllControlledUnits(func,withTotems,withGuardians,withCharms);
2709 template<typename Func>
2710 bool Player::CheckAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms, bool withMiniPet) const
2712 if (withMiniPet)
2713 if(Unit* mini = GetMiniPet())
2714 if (func(mini))
2715 return true;
2717 return Unit::CheckAllControlledUnits(func,withTotems,withGuardians,withCharms);
2720 #endif