[7915] Implement more stricted checks and limitations at loading creature addon data.
[getmangos.git] / src / game / Player.h
blob4d85a358592de06608701f4e4b9b110a67900e88
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef _PLAYER_H
20 #define _PLAYER_H
22 #include "Common.h"
23 #include "ItemPrototype.h"
24 #include "Unit.h"
25 #include "Item.h"
27 #include "Database/DatabaseEnv.h"
28 #include "NPCHandler.h"
29 #include "QuestDef.h"
30 #include "Group.h"
31 #include "Bag.h"
32 #include "WorldSession.h"
33 #include "Pet.h"
34 #include "MapReference.h"
35 #include "Util.h" // for Tokens typedef
36 #include "AchievementMgr.h"
37 #include "ReputationMgr.h"
38 #include "BattleGround.h"
40 #include<string>
41 #include<vector>
43 struct Mail;
44 class Channel;
45 class DynamicObject;
46 class Creature;
47 class Pet;
48 class PlayerMenu;
49 class Transport;
50 class UpdateMask;
51 class SpellCastTargets;
52 class PlayerSocial;
53 class Vehicle;
55 typedef std::deque<Mail*> PlayerMails;
57 #define PLAYER_MAX_SKILLS 127
58 #define PLAYER_MAX_DAILY_QUESTS 25
60 // Note: SPELLMOD_* values is aura types in fact
61 enum SpellModType
63 SPELLMOD_FLAT = 107, // SPELL_AURA_ADD_FLAT_MODIFIER
64 SPELLMOD_PCT = 108 // SPELL_AURA_ADD_PCT_MODIFIER
67 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
68 enum PlayerUnderwaterState
70 UNDERWATER_NONE = 0x00,
71 UNDERWATER_INWATER = 0x01, // terrain type is water and player is afflicted by it
72 UNDERWATER_INLAVA = 0x02, // terrain type is lava and player is afflicted by it
73 UNDERWATER_INSLIME = 0x04, // terrain type is lava and player is afflicted by it
74 UNDERWARER_INDARKWATER = 0x08, // terrain type is dark water and player is afflicted by it
76 UNDERWATER_EXIST_TIMERS = 0x10
79 enum PlayerSpellState
81 PLAYERSPELL_UNCHANGED = 0,
82 PLAYERSPELL_CHANGED = 1,
83 PLAYERSPELL_NEW = 2,
84 PLAYERSPELL_REMOVED = 3
87 struct PlayerSpell
89 PlayerSpellState state : 8;
90 bool active : 1; // show in spellbook
91 bool dependent : 1; // learned as result another spell learn, skill grow, quest reward, etc
92 bool disabled : 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
95 // Spell modifier (used for modify other spells)
96 struct SpellModifier
98 SpellModifier() : charges(0), lastAffected(NULL) {}
99 SpellModOp op : 8;
100 SpellModType type : 8;
101 int16 charges : 16;
102 int32 value;
103 uint64 mask;
104 uint64 mask2;
105 uint32 spellId;
106 Spell const* lastAffected;
109 typedef UNORDERED_MAP<uint32, PlayerSpell*> PlayerSpellMap;
110 typedef std::list<SpellModifier*> SpellModList;
112 struct SpellCooldown
114 time_t end;
115 uint16 itemid;
118 typedef std::map<uint32, SpellCooldown> SpellCooldowns;
120 enum TrainerSpellState
122 TRAINER_SPELL_GREEN = 0,
123 TRAINER_SPELL_RED = 1,
124 TRAINER_SPELL_GRAY = 2,
125 TRAINER_SPELL_GREEN_DISABLED = 10 // custom value, not send to client: formally green but learn not allowed
128 enum ActionButtonUpdateState
130 ACTIONBUTTON_UNCHANGED = 0,
131 ACTIONBUTTON_CHANGED = 1,
132 ACTIONBUTTON_NEW = 2,
133 ACTIONBUTTON_DELETED = 3
136 struct ActionButton
138 ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW ) {}
139 ActionButton(uint16 _action, uint8 _type, uint8 _misc) : action(_action), type(_type), misc(_misc), uState( ACTIONBUTTON_NEW ) {}
141 uint16 action;
142 uint8 type;
143 uint8 misc;
144 ActionButtonUpdateState uState;
147 enum ActionButtonType
149 ACTION_BUTTON_SPELL = 0,
150 ACTION_BUTTON_EQSET = 32,
151 ACTION_BUTTON_MACRO = 64,
152 ACTION_BUTTON_CMACRO= 65,
153 ACTION_BUTTON_ITEM = 128
156 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
158 typedef std::map<uint8,ActionButton> ActionButtonList;
160 struct PlayerCreateInfoItem
162 PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {}
164 uint32 item_id;
165 uint32 item_amount;
168 typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
170 struct PlayerClassLevelInfo
172 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
173 uint16 basehealth;
174 uint16 basemana;
177 struct PlayerClassInfo
179 PlayerClassInfo() : levelInfo(NULL) { }
181 PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
184 struct PlayerLevelInfo
186 PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
188 uint8 stats[MAX_STATS];
191 typedef std::list<uint32> PlayerCreateInfoSpells;
193 struct PlayerInfo
195 // existence checked by displayId != 0 // existence checked by displayId != 0
196 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL)
200 uint32 mapId;
201 uint32 zoneId;
202 float positionX;
203 float positionY;
204 float positionZ;
205 uint16 displayId_m;
206 uint16 displayId_f;
207 PlayerCreateInfoItems item;
208 PlayerCreateInfoSpells spell;
209 std::list<uint16> action[4];
211 PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
214 struct PvPInfo
216 PvPInfo() : inHostileArea(false), endTimer(0) {}
218 bool inHostileArea;
219 time_t endTimer;
222 struct DuelInfo
224 DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {}
226 Player *initiator;
227 Player *opponent;
228 time_t startTimer;
229 time_t startTime;
230 time_t outOfBound;
233 struct Areas
235 uint32 areaID;
236 uint32 areaFlag;
237 float x1;
238 float x2;
239 float y1;
240 float y2;
243 #define MAX_RUNES 6
244 #define RUNE_COOLDOWN 5 // 5*2=10 sec
246 enum RuneType
248 RUNE_BLOOD = 0,
249 RUNE_UNHOLY = 1,
250 RUNE_FROST = 2,
251 RUNE_DEATH = 3,
252 NUM_RUNE_TYPES = 4
255 struct RuneInfo
257 uint8 BaseRune;
258 uint8 CurrentRune;
259 uint8 Cooldown;
262 struct Runes
264 RuneInfo runes[MAX_RUNES];
265 uint8 runeState; // mask of available runes
267 void SetRuneState(uint8 index, bool set = true)
269 if(set)
270 runeState |= (1 << index); // usable
271 else
272 runeState &= ~(1 << index); // on cooldown
276 typedef std::set<uint64> GuardianPetList;
278 struct EnchantDuration
280 EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {};
281 EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { assert(item); };
283 Item * item;
284 EnchantmentSlot slot;
285 uint32 leftduration;
288 typedef std::list<EnchantDuration> EnchantDurationList;
289 typedef std::list<Item*> ItemDurationList;
291 enum LfgType
293 LFG_TYPE_NONE = 0,
294 LFG_TYPE_DUNGEON = 1,
295 LFG_TYPE_RAID = 2,
296 LFG_TYPE_QUEST = 3,
297 LFG_TYPE_ZONE = 4,
298 LFG_TYPE_HEROIC_DUNGEON = 5
301 enum LfgRoles
303 LEADER = 1,
304 TANK = 2,
305 HEALER = 4,
306 DAMAGE = 8
309 struct LookingForGroupSlot
311 LookingForGroupSlot() : entry(0), type(0) {}
312 bool Empty() const { return !entry && !type; }
313 void Clear() { entry = 0; type = 0; }
314 void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; }
315 bool Is(uint32 _entry, uint32 _type) const { return entry == _entry && type == _type; }
316 bool canAutoJoin() const { return entry && (type == LFG_TYPE_DUNGEON || type == LFG_TYPE_HEROIC_DUNGEON); }
318 uint32 entry;
319 uint32 type;
322 #define MAX_LOOKING_FOR_GROUP_SLOT 3
324 struct LookingForGroup
326 LookingForGroup() {}
327 bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry, slot.type); }
328 bool HaveInSlot(uint32 _entry, uint32 _type) const
330 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
331 if(slots[i].Is(_entry, _type))
332 return true;
333 return false;
336 bool canAutoJoin() const
338 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
339 if(slots[i].canAutoJoin())
340 return true;
341 return false;
344 bool Empty() const
346 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
347 if(!slots[i].Empty())
348 return false;
349 return more.Empty();
352 LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT];
353 LookingForGroupSlot more;
354 std::string comment;
357 enum PlayerMovementType
359 MOVE_ROOT = 1,
360 MOVE_UNROOT = 2,
361 MOVE_WATER_WALK = 3,
362 MOVE_LAND_WALK = 4
365 enum DrunkenState
367 DRUNKEN_SOBER = 0,
368 DRUNKEN_TIPSY = 1,
369 DRUNKEN_DRUNK = 2,
370 DRUNKEN_SMASHED = 3
373 enum PlayerFlags
375 PLAYER_FLAGS_GROUP_LEADER = 0x00000001,
376 PLAYER_FLAGS_AFK = 0x00000002,
377 PLAYER_FLAGS_DND = 0x00000004,
378 PLAYER_FLAGS_GM = 0x00000008,
379 PLAYER_FLAGS_GHOST = 0x00000010,
380 PLAYER_FLAGS_RESTING = 0x00000020,
381 PLAYER_FLAGS_UNK7 = 0x00000040,
382 PLAYER_FLAGS_UNK8 = 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
383 PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
384 PLAYER_FLAGS_IN_PVP = 0x00000200,
385 PLAYER_FLAGS_HIDE_HELM = 0x00000400,
386 PLAYER_FLAGS_HIDE_CLOAK = 0x00000800,
387 PLAYER_FLAGS_UNK13 = 0x00001000, // played long time
388 PLAYER_FLAGS_UNK14 = 0x00002000, // played too long time
389 PLAYER_FLAGS_UNK15 = 0x00004000,
390 PLAYER_FLAGS_UNK16 = 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
391 PLAYER_FLAGS_UNK17 = 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
392 PLAYER_FLAGS_UNK18 = 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
393 PLAYER_FLAGS_PVP_TIMER = 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
394 PLAYER_FLAGS_UNK20 = 0x00080000,
395 PLAYER_FLAGS_UNK21 = 0x00100000,
396 PLAYER_FLAGS_UNK22 = 0x00200000,
397 PLAYER_FLAGS_UNK23 = 0x00400000,
398 PLAYER_FLAGS_UNK24 = 0x00800000, // disabled all abilitys on tab except autoattack
399 PLAYER_FLAGS_UNK25 = 0x01000000, // disabled all melee ability on tab include autoattack
403 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
404 // can't use enum for uint64 values
405 #define PLAYER_TITLE_DISABLED 0x0000000000000000LL
406 #define PLAYER_TITLE_NONE 0x0000000000000001LL
407 #define PLAYER_TITLE_PRIVATE 0x0000000000000002LL // 1
408 #define PLAYER_TITLE_CORPORAL 0x0000000000000004LL // 2
409 #define PLAYER_TITLE_SERGEANT_A 0x0000000000000008LL // 3
410 #define PLAYER_TITLE_MASTER_SERGEANT 0x0000000000000010LL // 4
411 #define PLAYER_TITLE_SERGEANT_MAJOR 0x0000000000000020LL // 5
412 #define PLAYER_TITLE_KNIGHT 0x0000000000000040LL // 6
413 #define PLAYER_TITLE_KNIGHT_LIEUTENANT 0x0000000000000080LL // 7
414 #define PLAYER_TITLE_KNIGHT_CAPTAIN 0x0000000000000100LL // 8
415 #define PLAYER_TITLE_KNIGHT_CHAMPION 0x0000000000000200LL // 9
416 #define PLAYER_TITLE_LIEUTENANT_COMMANDER 0x0000000000000400LL // 10
417 #define PLAYER_TITLE_COMMANDER 0x0000000000000800LL // 11
418 #define PLAYER_TITLE_MARSHAL 0x0000000000001000LL // 12
419 #define PLAYER_TITLE_FIELD_MARSHAL 0x0000000000002000LL // 13
420 #define PLAYER_TITLE_GRAND_MARSHAL 0x0000000000004000LL // 14
421 #define PLAYER_TITLE_SCOUT 0x0000000000008000LL // 15
422 #define PLAYER_TITLE_GRUNT 0x0000000000010000LL // 16
423 #define PLAYER_TITLE_SERGEANT_H 0x0000000000020000LL // 17
424 #define PLAYER_TITLE_SENIOR_SERGEANT 0x0000000000040000LL // 18
425 #define PLAYER_TITLE_FIRST_SERGEANT 0x0000000000080000LL // 19
426 #define PLAYER_TITLE_STONE_GUARD 0x0000000000100000LL // 20
427 #define PLAYER_TITLE_BLOOD_GUARD 0x0000000000200000LL // 21
428 #define PLAYER_TITLE_LEGIONNAIRE 0x0000000000400000LL // 22
429 #define PLAYER_TITLE_CENTURION 0x0000000000800000LL // 23
430 #define PLAYER_TITLE_CHAMPION 0x0000000001000000LL // 24
431 #define PLAYER_TITLE_LIEUTENANT_GENERAL 0x0000000002000000LL // 25
432 #define PLAYER_TITLE_GENERAL 0x0000000004000000LL // 26
433 #define PLAYER_TITLE_WARLORD 0x0000000008000000LL // 27
434 #define PLAYER_TITLE_HIGH_WARLORD 0x0000000010000000LL // 28
435 #define PLAYER_TITLE_GLADIATOR 0x0000000020000000LL // 29
436 #define PLAYER_TITLE_DUELIST 0x0000000040000000LL // 30
437 #define PLAYER_TITLE_RIVAL 0x0000000080000000LL // 31
438 #define PLAYER_TITLE_CHALLENGER 0x0000000100000000LL // 32
439 #define PLAYER_TITLE_SCARAB_LORD 0x0000000200000000LL // 33
440 #define PLAYER_TITLE_CONQUEROR 0x0000000400000000LL // 34
441 #define PLAYER_TITLE_JUSTICAR 0x0000000800000000LL // 35
442 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36
443 #define PLAYER_TITLE_MERCILESS_GLADIATOR 0x0000002000000000LL // 37
444 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN 0x0000004000000000LL // 38
445 #define PLAYER_TITLE_HAND_OF_ADAL 0x0000008000000000LL // 39
446 #define PLAYER_TITLE_VENGEFUL_GLADIATOR 0x0000010000000000LL // 40
448 // used in PLAYER_FIELD_BYTES values
449 enum PlayerFieldByteFlags
451 PLAYER_FIELD_BYTE_TRACK_STEALTHED = 0x00000002,
452 PLAYER_FIELD_BYTE_RELEASE_TIMER = 0x00000008, // Display time till auto release spirit
453 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x00000010 // Display no "release spirit" window at all
456 // used in PLAYER_FIELD_BYTES2 values
457 enum PlayerFieldByte2Flags
459 PLAYER_FIELD_BYTE2_NONE = 0x0000,
460 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW = 0x4000
463 enum ActivateTaxiReplies
465 ERR_TAXIOK = 0,
466 ERR_TAXIUNSPECIFIEDSERVERERROR = 1,
467 ERR_TAXINOSUCHPATH = 2,
468 ERR_TAXINOTENOUGHMONEY = 3,
469 ERR_TAXITOOFARAWAY = 4,
470 ERR_TAXINOVENDORNEARBY = 5,
471 ERR_TAXINOTVISITED = 6,
472 ERR_TAXIPLAYERBUSY = 7,
473 ERR_TAXIPLAYERALREADYMOUNTED = 8,
474 ERR_TAXIPLAYERSHAPESHIFTED = 9,
475 ERR_TAXIPLAYERMOVING = 10,
476 ERR_TAXISAMENODE = 11,
477 ERR_TAXINOTSTANDING = 12
482 enum MirrorTimerType
484 FATIGUE_TIMER = 0,
485 BREATH_TIMER = 1,
486 FIRE_TIMER = 2
488 #define MAX_TIMERS 3
489 #define DISABLED_MIRROR_TIMER -1
491 // 2^n values
492 enum PlayerExtraFlags
494 // gm abilities
495 PLAYER_EXTRA_GM_ON = 0x0001,
496 PLAYER_EXTRA_GM_ACCEPT_TICKETS = 0x0002,
497 PLAYER_EXTRA_ACCEPT_WHISPERS = 0x0004,
498 PLAYER_EXTRA_TAXICHEAT = 0x0008,
499 PLAYER_EXTRA_GM_INVISIBLE = 0x0010,
500 PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages
502 // other states
503 PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating.
506 // 2^n values
507 enum AtLoginFlags
509 AT_LOGIN_NONE = 0,
510 AT_LOGIN_RENAME = 1,
511 AT_LOGIN_RESET_SPELLS = 2,
512 AT_LOGIN_RESET_TALENTS = 4,
513 AT_LOGIN_CUSTOMIZE = 8
516 typedef std::map<uint32, QuestStatusData> QuestStatusMap;
518 enum QuestSlotOffsets
520 QUEST_ID_OFFSET = 0,
521 QUEST_STATE_OFFSET = 1,
522 QUEST_COUNTS_OFFSET = 2,
523 QUEST_TIME_OFFSET = 3
526 #define MAX_QUEST_OFFSET 4
528 enum QuestSlotStateMask
530 QUEST_STATE_NONE = 0x0000,
531 QUEST_STATE_COMPLETE = 0x0001,
532 QUEST_STATE_FAIL = 0x0002
535 class Quest;
536 class Spell;
537 class Item;
538 class WorldSession;
540 enum PlayerSlots
542 // first slot for item stored (in any way in player m_items data)
543 PLAYER_SLOT_START = 0,
544 // last+1 slot for item stored (in any way in player m_items data)
545 PLAYER_SLOT_END = 200,
546 PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START)
549 #define INVENTORY_SLOT_BAG_0 255
551 enum EquipmentSlots // 19 slots
553 EQUIPMENT_SLOT_START = 0,
554 EQUIPMENT_SLOT_HEAD = 0,
555 EQUIPMENT_SLOT_NECK = 1,
556 EQUIPMENT_SLOT_SHOULDERS = 2,
557 EQUIPMENT_SLOT_BODY = 3,
558 EQUIPMENT_SLOT_CHEST = 4,
559 EQUIPMENT_SLOT_WAIST = 5,
560 EQUIPMENT_SLOT_LEGS = 6,
561 EQUIPMENT_SLOT_FEET = 7,
562 EQUIPMENT_SLOT_WRISTS = 8,
563 EQUIPMENT_SLOT_HANDS = 9,
564 EQUIPMENT_SLOT_FINGER1 = 10,
565 EQUIPMENT_SLOT_FINGER2 = 11,
566 EQUIPMENT_SLOT_TRINKET1 = 12,
567 EQUIPMENT_SLOT_TRINKET2 = 13,
568 EQUIPMENT_SLOT_BACK = 14,
569 EQUIPMENT_SLOT_MAINHAND = 15,
570 EQUIPMENT_SLOT_OFFHAND = 16,
571 EQUIPMENT_SLOT_RANGED = 17,
572 EQUIPMENT_SLOT_TABARD = 18,
573 EQUIPMENT_SLOT_END = 19
576 enum InventorySlots // 4 slots
578 INVENTORY_SLOT_BAG_START = 19,
579 INVENTORY_SLOT_BAG_END = 23
582 enum InventoryPackSlots // 16 slots
584 INVENTORY_SLOT_ITEM_START = 23,
585 INVENTORY_SLOT_ITEM_END = 39
588 enum BankItemSlots // 28 slots
590 BANK_SLOT_ITEM_START = 39,
591 BANK_SLOT_ITEM_END = 67
594 enum BankBagSlots // 7 slots
596 BANK_SLOT_BAG_START = 67,
597 BANK_SLOT_BAG_END = 74
600 enum BuyBackSlots // 12 slots
602 // stored in m_buybackitems
603 BUYBACK_SLOT_START = 74,
604 BUYBACK_SLOT_END = 86
607 enum KeyRingSlots // 32 slots
609 KEYRING_SLOT_START = 86,
610 KEYRING_SLOT_END = 118
613 enum VanityPetSlots // 18 slots
615 VANITYPET_SLOT_START = 118, // not use, vanity pets stored as spells
616 VANITYPET_SLOT_END = 136 // not allowed any content in.
619 enum CurrencyTokenSlots // 32 slots
621 CURRENCYTOKEN_SLOT_START = 136,
622 CURRENCYTOKEN_SLOT_END = 168
625 enum QuestBagSlots // 32 slots
627 QUESTBAG_SLOT_START = 168, // not use
628 QUESTBAG_SLOT_END = 200 // not allowed any content in.
631 struct ItemPosCount
633 ItemPosCount(uint16 _pos, uint32 _count) : pos(_pos), count(_count) {}
634 bool isContainedIn(std::vector<ItemPosCount> const& vec) const;
635 uint16 pos;
636 uint32 count;
638 typedef std::vector<ItemPosCount> ItemPosCountVec;
640 enum TradeSlots
642 TRADE_SLOT_COUNT = 7,
643 TRADE_SLOT_TRADED_COUNT = 6,
644 TRADE_SLOT_NONTRADED = 6
647 enum TransferAbortReason
649 TRANSFER_ABORT_ERROR = 0x00,
650 TRANSFER_ABORT_MAX_PLAYERS = 0x01, // Transfer Aborted: instance is full
651 TRANSFER_ABORT_NOT_FOUND = 0x02, // Transfer Aborted: instance not found
652 TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x03, // You have entered too many instances recently.
653 TRANSFER_ABORT_ZONE_IN_COMBAT = 0x05, // Unable to zone in while an encounter is in progress.
654 TRANSFER_ABORT_INSUF_EXPAN_LVL = 0x06, // You must have <TBC,WotLK> expansion installed to access this area.
655 TRANSFER_ABORT_DIFFICULTY = 0x07, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
656 TRANSFER_ABORT_UNIQUE_MESSAGE = 0x08, // Until you've escaped TLK's grasp, you cannot leave this place!
657 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 0x09 // Additional instances cannot be launched, please try again later.
660 enum InstanceResetWarningType
662 RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s).
663 RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)!
664 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!
665 RAID_INSTANCE_WELCOME = 4 // Welcome to %s. This raid instance is scheduled to reset in %s.
668 struct MovementInfo
670 // common
671 uint32 flags;
672 uint16 unk1;
673 uint32 time;
674 float x, y, z, o;
675 // transport
676 uint64 t_guid;
677 float t_x, t_y, t_z, t_o;
678 uint32 t_time;
679 int8 t_seat;
680 // swimming and unknown
681 float s_pitch;
682 // last fall time
683 uint32 fallTime;
684 // jumping
685 float j_unk, j_sinAngle, j_cosAngle, j_xyspeed;
686 // spline
687 float u_unk1;
689 MovementInfo()
691 flags = 0;
692 time = t_time = fallTime = 0;
693 unk1 = 0;
694 x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_unk = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f;
695 t_guid = 0;
699 // flags that use in movement check for example at spell casting
700 MovementFlags const movementFlagsMask = MovementFlags(
701 MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
702 MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1 |
703 MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_FLY_UP |
704 MOVEMENTFLAG_FLYING |MOVEMENTFLAG_SPLINE
707 MovementFlags const movementOrTurningFlagsMask = MovementFlags(
708 movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT
710 class InstanceSave;
712 enum RestType
714 REST_TYPE_NO = 0,
715 REST_TYPE_IN_TAVERN = 1,
716 REST_TYPE_IN_CITY = 2
719 enum DuelCompleteType
721 DUEL_INTERUPTED = 0,
722 DUEL_WON = 1,
723 DUEL_FLED = 2
726 enum TeleportToOptions
728 TELE_TO_GM_MODE = 0x01,
729 TELE_TO_NOT_LEAVE_TRANSPORT = 0x02,
730 TELE_TO_NOT_LEAVE_COMBAT = 0x04,
731 TELE_TO_NOT_UNSUMMON_PET = 0x08,
732 TELE_TO_SPELL = 0x10,
735 /// Type of environmental damages
736 enum EnviromentalDamage
738 DAMAGE_EXHAUSTED = 0,
739 DAMAGE_DROWNING = 1,
740 DAMAGE_FALL = 2,
741 DAMAGE_LAVA = 3,
742 DAMAGE_SLIME = 4,
743 DAMAGE_FIRE = 5,
744 DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
747 // used at player loading query list preparing, and later result selection
748 enum PlayerLoginQueryIndex
750 PLAYER_LOGIN_QUERY_LOADFROM = 0,
751 PLAYER_LOGIN_QUERY_LOADGROUP = 1,
752 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES = 2,
753 PLAYER_LOGIN_QUERY_LOADAURAS = 3,
754 PLAYER_LOGIN_QUERY_LOADSPELLS = 4,
755 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS = 5,
756 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS = 6,
757 PLAYER_LOGIN_QUERY_LOADTUTORIALS = 7, // common for all characters for some account at specific realm
758 PLAYER_LOGIN_QUERY_LOADREPUTATION = 8,
759 PLAYER_LOGIN_QUERY_LOADINVENTORY = 9,
760 PLAYER_LOGIN_QUERY_LOADACTIONS = 10,
761 PLAYER_LOGIN_QUERY_LOADMAILCOUNT = 11,
762 PLAYER_LOGIN_QUERY_LOADMAILDATE = 12,
763 PLAYER_LOGIN_QUERY_LOADSOCIALLIST = 13,
764 PLAYER_LOGIN_QUERY_LOADHOMEBIND = 14,
765 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS = 15,
766 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES = 16,
767 PLAYER_LOGIN_QUERY_LOADGUILD = 17,
768 PLAYER_LOGIN_QUERY_LOADARENAINFO = 18,
769 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS = 19,
770 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS = 20,
771 MAX_PLAYER_LOGIN_QUERY = 21
774 // Player summoning auto-decline time (in secs)
775 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
776 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
778 struct InstancePlayerBind
780 InstanceSave *save;
781 bool perm;
782 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
783 that aren't already permanently bound when they are inside when a boss is killed
784 or when they enter an instance that the group leader is permanently bound to. */
785 InstancePlayerBind() : save(NULL), perm(false) {}
788 class MANGOS_DLL_SPEC PlayerTaxi
790 public:
791 PlayerTaxi();
792 ~PlayerTaxi() {}
793 // Nodes
794 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level);
795 void LoadTaxiMask(const char* data);
797 bool IsTaximaskNodeKnown(uint32 nodeidx) const
799 uint8 field = uint8((nodeidx - 1) / 32);
800 uint32 submask = 1<<((nodeidx-1)%32);
801 return (m_taximask[field] & submask) == submask;
803 bool SetTaximaskNode(uint32 nodeidx)
805 uint8 field = uint8((nodeidx - 1) / 32);
806 uint32 submask = 1<<((nodeidx-1)%32);
807 if ((m_taximask[field] & submask) != submask )
809 m_taximask[field] |= submask;
810 return true;
812 else
813 return false;
815 void AppendTaximaskTo(ByteBuffer& data,bool all);
817 // Destinations
818 bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team);
819 std::string SaveTaxiDestinationsToString();
821 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
822 void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
823 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
824 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
825 uint32 GetCurrentTaxiPath() const;
826 uint32 NextTaxiDestination()
828 m_TaxiDestinations.pop_front();
829 return GetTaxiDestination();
831 bool empty() const { return m_TaxiDestinations.empty(); }
833 friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
834 private:
835 TaxiMask m_taximask;
836 std::deque<uint32> m_TaxiDestinations;
839 std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
841 class MANGOS_DLL_SPEC Player : public Unit
843 friend class WorldSession;
844 friend void Item::AddToUpdateQueueOf(Player *player);
845 friend void Item::RemoveFromUpdateQueueOf(Player *player);
846 public:
847 explicit Player (WorldSession *session);
848 ~Player ( );
850 void CleanupsBeforeDelete();
852 static UpdateMask updateVisualBits;
853 static void InitVisibleBits();
855 void AddToWorld();
856 void RemoveFromWorld();
858 bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
860 bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
862 return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options);
865 void SetSummonPoint(uint32 mapid, float x, float y, float z)
867 m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
868 m_summon_mapid = mapid;
869 m_summon_x = x;
870 m_summon_y = y;
871 m_summon_z = z;
873 void SummonIfPossible(bool agree);
875 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 );
877 void Update( uint32 time );
879 void BuildEnumData( QueryResult * result, WorldPacket * p_data );
881 void SetInWater(bool apply);
883 bool IsInWater() const { return m_isInWater; }
884 bool IsUnderWater() const;
886 void SendInitialPacketsBeforeAddToMap();
887 void SendInitialPacketsAfterAddToMap();
888 void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0);
889 void SendInstanceResetWarning(uint32 mapid, uint32 time);
891 Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
892 bool CanInteractWithNPCs(bool alive = true) const;
893 GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const;
895 bool ToggleAFK();
896 bool ToggleDND();
897 bool isAFK() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_AFK); };
898 bool isDND() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_DND); };
899 uint8 chatTag() const;
900 std::string afkMsg;
901 std::string dndMsg;
903 uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
905 PlayerSocial *GetSocial() { return m_social; }
907 PlayerTaxi m_taxi;
908 void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
909 bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = NULL, uint32 spellid = 0);
910 bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0);
911 // mount_id can be used in scripting calls
912 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); }
913 void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; }
914 bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
915 void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
916 bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
917 void SetGameMaster(bool on);
918 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); }
919 void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
920 bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
921 void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
922 bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
923 void SetGMVisible(bool on);
924 void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
926 void GiveXP(uint32 xp, Unit* victim);
927 void GiveLevel(uint32 level);
929 void InitStatsForLevel(bool reapplyMods = false);
931 // Played Time Stuff
932 time_t m_logintime;
933 time_t m_Last_tick;
934 uint32 m_Played_time[2];
935 uint32 GetTotalPlayedTime() { return m_Played_time[0]; };
936 uint32 GetLevelPlayedTime() { return m_Played_time[1]; };
938 void setDeathState(DeathState s); // overwrite Unit::setDeathState
940 void InnEnter (int time,uint32 mapid, float x,float y,float z)
942 inn_pos_mapid = mapid;
943 inn_pos_x = x;
944 inn_pos_y = y;
945 inn_pos_z = z;
946 time_inn_enter = time;
949 float GetRestBonus() const { return m_rest_bonus; };
950 void SetRestBonus(float rest_bonus_new);
952 RestType GetRestType() const { return rest_type; };
953 void SetRestType(RestType n_r_type) { rest_type = n_r_type; };
955 uint32 GetInnPosMapId() const { return inn_pos_mapid; };
956 float GetInnPosX() const { return inn_pos_x; };
957 float GetInnPosY() const { return inn_pos_y; };
958 float GetInnPosZ() const { return inn_pos_z; };
960 int GetTimeInnEnter() const { return time_inn_enter; };
961 void UpdateInnerTime (int time) { time_inn_enter = time; };
963 void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
964 void RemoveMiniPet();
965 Pet* GetMiniPet();
966 void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); }
967 void RemoveGuardians();
968 bool HasGuardianWithEntry(uint32 entry);
969 void AddGuardian(Pet* pet) { m_guardianPets.insert(pet->GetGUID()); }
970 GuardianPetList const& GetGuardians() const { return m_guardianPets; }
971 void Uncharm();
972 uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
974 void Say(const std::string& text, const uint32 language);
975 void Yell(const std::string& text, const uint32 language);
976 void TextEmote(const std::string& text);
977 void Whisper(const std::string& text, const uint32 language,uint64 receiver);
978 void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
980 /*********************************************************/
981 /*** STORAGE SYSTEM ***/
982 /*********************************************************/
984 void SetVirtualItemSlot( uint8 i, Item* item);
985 void SetSheath( SheathState sheathed ); // overwrite Unit version
986 uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const;
987 uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const;
988 Item* GetItemByGuid( uint64 guid ) const;
989 Item* GetItemByPos( uint16 pos ) const;
990 Item* GetItemByPos( uint8 bag, uint8 slot ) const;
991 Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const;
992 Item* GetShield(bool useable = false) const;
993 static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot
994 std::vector<Item *> &GetItemUpdateQueue() { return m_itemUpdateQueue; }
995 static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8,pos & 255); }
996 static bool IsInventoryPos( uint8 bag, uint8 slot );
997 static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8,pos & 255); }
998 static bool IsEquipmentPos( uint8 bag, uint8 slot );
999 static bool IsBagPos( uint16 pos );
1000 static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
1001 static bool IsBankPos( uint8 bag, uint8 slot );
1002 bool IsValidPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
1003 bool IsValidPos( uint8 bag, uint8 slot );
1004 uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); }
1005 void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); }
1006 bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
1007 bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL);
1008 bool CanNoReagentCast(SpellEntry const* spellInfo) const;
1009 bool HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
1010 bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
1011 uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(),pItem->GetCount(),pItem); }
1012 uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry,count,NULL); }
1013 uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
1015 return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count );
1017 uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
1019 if(!pItem)
1020 return EQUIP_ERR_ITEM_NOT_FOUND;
1021 uint32 count = pItem->GetCount();
1022 return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL );
1025 uint8 CanStoreItems( Item **pItem,int count) const;
1026 uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
1027 uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
1029 uint8 CanEquipUniqueItem( Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
1030 uint8 CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
1031 uint8 CanUnequipItems( uint32 item, uint32 count ) const;
1032 uint8 CanUnequipItem( uint16 src, bool swap ) const;
1033 uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
1034 uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
1035 bool HasItemTotemCategory( uint32 TotemCategory ) const;
1036 bool CanUseItem( ItemPrototype const *pItem );
1037 uint8 CanUseAmmo( uint32 item ) const;
1038 Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
1039 Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
1040 Item* EquipNewItem( uint16 pos, uint32 item, bool update );
1041 Item* EquipItem( uint16 pos, Item *pItem, bool update );
1042 void AutoUnequipOffhandIfNeed();
1043 bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
1044 void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false);
1045 void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG,NULL_SLOT,loot_id,store,broadcast); }
1047 uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
1048 uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
1050 void ApplyEquipCooldown( Item * pItem );
1051 void SetAmmo( uint32 item );
1052 void RemoveAmmo();
1053 float GetAmmoDPS() const { return m_ammoDPS; }
1054 bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const;
1055 void QuickEquipItem( uint16 pos, Item *pItem);
1056 void VisualizeItem( uint8 slot, Item *pItem);
1057 void SetVisibleItemSlot(uint8 slot, Item *pItem);
1058 Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update )
1060 return StoreItem( dest, pItem, update);
1062 Item* BankItem( uint16 pos, Item *pItem, bool update );
1063 void RemoveItem( uint8 bag, uint8 slot, bool update );
1064 void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
1065 // in trade, auction, guild bank, mail....
1066 void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
1067 // in trade, guild bank, mail....
1068 void RemoveItemDependentAurasAndCasts( Item * pItem );
1069 void DestroyItem( uint8 bag, uint8 slot, bool update );
1070 void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
1071 void DestroyItemCount( Item* item, uint32& count, bool update );
1072 void DestroyConjuredItems( bool update );
1073 void DestroyZoneLimitedItem( bool update, uint32 new_zone );
1074 void SplitItem( uint16 src, uint16 dst, uint32 count );
1075 void SwapItem( uint16 src, uint16 dst );
1076 void AddItemToBuyBackSlot( Item *pItem );
1077 Item* GetItemFromBuyBackSlot( uint32 slot );
1078 void RemoveItemFromBuyBackSlot( uint32 slot, bool del );
1079 uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
1080 void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 );
1081 void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
1082 void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
1083 void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
1084 void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
1085 uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
1086 uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
1087 bool IsUseEquipedWeapon( bool mainhand ) const
1089 // disarm applied only to mainhand weapon
1090 return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) );
1092 bool IsTwoHandUsed() const
1094 Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
1095 return mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
1097 void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false );
1098 bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot);
1100 float GetReputationPriceDiscount( Creature const* pCreature ) const;
1101 Player* GetTrader() const { return pTrader; }
1102 void ClearTrade();
1103 void TradeCancel(bool sendback);
1104 uint16 GetItemPosByTradeSlot(uint32 slot) const { return tradeItems[slot]; }
1106 void UpdateEnchantTime(uint32 time);
1107 void UpdateItemDuration(uint32 time, bool realtimeonly=false);
1108 void AddEnchantmentDurations(Item *item);
1109 void RemoveEnchantmentDurations(Item *item);
1110 void RemoveAllEnchantments(EnchantmentSlot slot);
1111 void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration);
1112 void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false);
1113 void ApplyEnchantment(Item *item,bool apply);
1114 void SendEnchantmentDurations();
1115 void AddItemDurations(Item *item);
1116 void RemoveItemDurations(Item *item);
1117 void SendItemDurations();
1118 void LoadCorpse();
1119 void LoadPet();
1121 uint32 m_stableSlots;
1123 /*********************************************************/
1124 /*** QUEST SYSTEM ***/
1125 /*********************************************************/
1127 uint32 GetQuestLevel( Quest const* pQuest ) const { return pQuest && pQuest->GetQuestLevel() ? pQuest->GetQuestLevel() : getLevel(); }
1129 void PrepareQuestMenu( uint64 guid );
1130 void SendPreparedQuest( uint64 guid );
1131 bool IsActiveQuest( uint32 quest_id ) const;
1132 Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
1133 bool CanSeeStartQuest( Quest const *pQuest );
1134 bool CanTakeQuest( Quest const *pQuest, bool msg );
1135 bool CanAddQuest( Quest const *pQuest, bool msg );
1136 bool CanCompleteQuest( uint32 quest_id );
1137 bool CanCompleteRepeatableQuest(Quest const *pQuest);
1138 bool CanRewardQuest( Quest const *pQuest, bool msg );
1139 bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg );
1140 void AddQuest( Quest const *pQuest, Object *questGiver );
1141 void CompleteQuest( uint32 quest_id );
1142 void IncompleteQuest( uint32 quest_id );
1143 void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
1144 void FailQuest( uint32 quest_id );
1145 void FailTimedQuest( uint32 quest_id );
1146 bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg );
1147 bool SatisfyQuestLevel( Quest const* qInfo, bool msg );
1148 bool SatisfyQuestLog( bool msg );
1149 bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg );
1150 bool SatisfyQuestRace( Quest const* qInfo, bool msg );
1151 bool SatisfyQuestReputation( Quest const* qInfo, bool msg );
1152 bool SatisfyQuestStatus( Quest const* qInfo, bool msg );
1153 bool SatisfyQuestTimed( Quest const* qInfo, bool msg );
1154 bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg );
1155 bool SatisfyQuestNextChain( Quest const* qInfo, bool msg );
1156 bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg );
1157 bool SatisfyQuestDay( Quest const* qInfo, bool msg );
1158 bool GiveQuestSourceItem( Quest const *pQuest );
1159 bool TakeQuestSourceItem( uint32 quest_id, bool msg );
1160 bool GetQuestRewardStatus( uint32 quest_id ) const;
1161 QuestStatus GetQuestStatus( uint32 quest_id ) const;
1162 void SetQuestStatus( uint32 quest_id, QuestStatus status );
1164 void SetDailyQuestStatus( uint32 quest_id );
1165 void ResetDailyQuestStatus();
1167 uint16 FindQuestSlot( uint32 quest_id ) const;
1168 uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
1169 uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
1170 uint32 GetQuestSlotCounters(uint16 slot)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); }
1171 uint8 GetQuestSlotCounter(uint16 slot,uint8 counter) const { return GetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter); }
1172 uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
1173 void SetQuestSlot(uint16 slot,uint32 quest_id, uint32 timer = 0)
1175 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET,quest_id);
1176 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,0);
1177 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,0);
1178 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer);
1180 void SetQuestSlotCounter(uint16 slot,uint8 counter,uint8 count) { SetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter,count); }
1181 void SetQuestSlotState(uint16 slot,uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1182 void RemoveQuestSlotState(uint16 slot,uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1183 void SetQuestSlotTimer(uint16 slot,uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); }
1184 void SwapQuestSlot(uint16 slot1,uint16 slot2)
1186 for (int i = 0; i < MAX_QUEST_OFFSET ; ++i )
1188 uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i);
1189 uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i);
1191 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i, temp2);
1192 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i, temp1);
1195 uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
1196 void AreaExploredOrEventHappens( uint32 questId );
1197 void GroupEventHappens( uint32 questId, WorldObject const* pEventObject );
1198 void ItemAddedQuestCheck( uint32 entry, uint32 count );
1199 void ItemRemovedQuestCheck( uint32 entry, uint32 count );
1200 void KilledMonster( uint32 entry, uint64 guid );
1201 void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id );
1202 void TalkedToCreature( uint32 entry, uint64 guid );
1203 void MoneyChanged( uint32 value );
1204 void ReputationChanged(FactionEntry const* factionEntry );
1205 bool HasQuestForItem( uint32 itemid ) const;
1206 bool HasQuestForGO(int32 GOId) const;
1207 void UpdateForQuestWorldObjects();
1208 bool CanShareQuest(uint32 quest_id) const;
1210 void SendQuestComplete( uint32 quest_id );
1211 void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
1212 void SendQuestFailed( uint32 quest_id );
1213 void SendQuestTimerFailed( uint32 quest_id );
1214 void SendCanTakeQuestResponse( uint32 msg );
1215 void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
1216 void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
1217 void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count );
1219 uint64 GetDivider() { return m_divider; };
1220 void SetDivider( uint64 guid ) { m_divider = guid; };
1222 uint32 GetInGameTime() { return m_ingametime; };
1224 void SetInGameTime( uint32 time ) { m_ingametime = time; };
1226 void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); }
1228 /*********************************************************/
1229 /*** LOAD SYSTEM ***/
1230 /*********************************************************/
1232 bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
1234 bool MinimalLoadFromDB(QueryResult *result, uint32 guid);
1235 static bool LoadValuesArrayFromDB(Tokens& data,uint64 guid);
1236 static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
1237 static float GetFloatValueFromArray(Tokens const& data, uint16 index);
1238 static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid);
1239 static float GetFloatValueFromDB(uint16 index, uint64 guid);
1240 static uint32 GetZoneIdFromDB(uint64 guid);
1241 static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
1243 /*********************************************************/
1244 /*** SAVE SYSTEM ***/
1245 /*********************************************************/
1247 void SaveToDB();
1248 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1249 void SaveDataFieldToDB();
1250 static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
1251 static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value);
1252 static void SetFloatValueInArray(Tokens& data,uint16 index, float value);
1253 static void SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid);
1254 static void SetFloatValueInDB(uint16 index, float value, uint64 guid);
1255 static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
1256 static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid);
1258 bool m_mailsLoaded;
1259 bool m_mailsUpdated;
1261 void SetBindPoint(uint64 guid);
1262 void SendTalentWipeConfirm(uint64 guid);
1263 void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
1264 void SendPetSkillWipeConfirm();
1265 void CalcRage( uint32 damage,bool attacker );
1266 void RegenerateAll();
1267 void Regenerate(Powers power);
1268 void RegenerateHealth();
1269 void setRegenTimer(uint32 time) {m_regenTimer = time;}
1270 void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
1272 uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
1273 void ModifyMoney( int32 d )
1275 if(d < 0)
1276 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
1277 else
1278 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
1280 // "At Gold Limit"
1281 if(GetMoney() >= MAX_MONEY_AMOUNT)
1282 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL);
1284 void SetMoney( uint32 value )
1286 SetUInt32Value (PLAYER_FIELD_COINAGE, value);
1287 MoneyChanged( value );
1288 UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED);
1291 uint32 GetTutorialInt(uint32 intId )
1293 ASSERT( (intId < 8) );
1294 return m_Tutorials[intId];
1297 void SetTutorialInt(uint32 intId, uint32 value)
1299 ASSERT( (intId < 8) );
1300 if(m_Tutorials[intId]!=value)
1302 m_Tutorials[intId] = value;
1303 m_TutorialsChanged = true;
1307 QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
1309 const uint64& GetSelection( ) const { return m_curSelection; }
1310 void SetSelection(const uint64 &guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); }
1312 uint8 GetComboPoints() { return m_comboPoints; }
1313 const uint64& GetComboTarget() const { return m_comboTarget; }
1315 void AddComboPoints(Unit* target, int8 count);
1316 void ClearComboPoints();
1317 void SendComboPoints();
1319 void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0);
1320 void SendNewMail();
1321 void UpdateNextMailTimeAndUnreads();
1322 void AddNewMailDeliverTime(time_t deliver_time);
1323 bool IsMailsLoaded() const { return m_mailsLoaded; }
1325 //void SetMail(Mail *m);
1326 void RemoveMail(uint32 id);
1328 void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
1329 uint32 GetMailSize() { return m_mail.size();};
1330 Mail* GetMail(uint32 id);
1332 PlayerMails::iterator GetmailBegin() { return m_mail.begin();};
1333 PlayerMails::iterator GetmailEnd() { return m_mail.end();};
1335 /*********************************************************/
1336 /*** MAILED ITEMS SYSTEM ***/
1337 /*********************************************************/
1339 uint8 unReadMails;
1340 time_t m_nextMailDelivereTime;
1342 typedef UNORDERED_MAP<uint32, Item*> ItemMap;
1344 ItemMap mMitems; //template defined in objectmgr.cpp
1346 Item* GetMItem(uint32 id)
1348 ItemMap::const_iterator itr = mMitems.find(id);
1349 return itr != mMitems.end() ? itr->second : NULL;
1352 void AddMItem(Item* it)
1354 ASSERT( it );
1355 //assert deleted, because items can be added before loading
1356 mMitems[it->GetGUIDLow()] = it;
1359 bool RemoveMItem(uint32 id)
1361 return mMitems.erase(id) ? true : false;
1364 void PetSpellInitialize();
1365 void CharmSpellInitialize();
1366 void PossessSpellInitialize();
1367 bool HasSpell(uint32 spell) const;
1368 bool HasActiveSpell(uint32 spell) const; // show in spellbook
1369 TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
1370 bool IsSpellFitByClassAndRace( uint32 spell_id ) const;
1371 bool IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const;
1373 void SendProficiency(uint8 pr1, uint32 pr2);
1374 void SendInitialSpells();
1375 bool addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled);
1376 void learnSpell(uint32 spell_id, bool dependent);
1377 void removeSpell(uint32 spell_id, bool disabled = false, bool update_action_bar_for_low_rank = false);
1378 void resetSpells();
1379 void learnDefaultSpells();
1380 void learnQuestRewardedSpells();
1381 void learnQuestRewardedSpells(Quest const* quest);
1382 void learnSpellHighRank(uint32 spellid);
1384 uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
1385 void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
1386 bool resetTalents(bool no_cost = false);
1387 uint32 resetTalentsCost() const;
1388 void InitTalentForLevel();
1390 void LearnTalent(uint32 talentId, uint32 talentRank);
1391 void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank);
1393 uint32 CalculateTalentsPoints() const;
1395 void InitGlyphsForLevel();
1396 void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); }
1397 uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); }
1398 void SetGlyph(uint8 slot, uint32 glyph) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); }
1399 uint32 GetGlyph(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot); }
1401 uint32 GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); }
1402 void SetFreePrimaryProffesions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2, profs); }
1403 void InitPrimaryProffesions();
1405 PlayerSpellMap const& GetSpellMap() const { return m_spells; }
1406 PlayerSpellMap & GetSpellMap() { return m_spells; }
1408 void AddSpellMod(SpellModifier* mod, bool apply);
1409 bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL);
1410 template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL);
1411 void RemoveSpellMods(Spell const* spell);
1413 bool HasSpellCooldown(uint32 spell_id) const
1415 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1416 return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
1418 uint32 GetSpellCooldownDelay(uint32 spell_id) const
1420 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1421 time_t t = time(NULL);
1422 return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
1424 void AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false );
1425 void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
1426 void SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId = 0, Spell* spell = NULL);
1427 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs );
1428 void RemoveSpellCooldown(uint32 spell_id, bool update = false);
1429 void RemoveArenaSpellCooldowns();
1430 void RemoveAllSpellCooldown();
1431 void _LoadSpellCooldowns(QueryResult *result);
1432 void _SaveSpellCooldowns();
1433 void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
1434 void UpdatePotionCooldown(Spell* spell = NULL);
1436 void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
1438 m_resurrectGUID = guid;
1439 m_resurrectMap = mapId;
1440 m_resurrectX = X;
1441 m_resurrectY = Y;
1442 m_resurrectZ = Z;
1443 m_resurrectHealth = health;
1444 m_resurrectMana = mana;
1446 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); }
1447 bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; }
1448 bool isRessurectRequested() const { return m_resurrectGUID != 0; }
1449 void ResurectUsingRequestData();
1451 int getCinematic()
1453 return m_cinematic;
1455 void setCinematic(int cine)
1457 m_cinematic = cine;
1460 bool addActionButton(uint8 button, uint16 action, uint8 type, uint8 misc);
1461 void removeActionButton(uint8 button);
1462 void SendInitialActionButtons() const;
1464 PvPInfo pvpInfo;
1465 void UpdatePvP(bool state, bool ovrride=false);
1466 void UpdateZone(uint32 newZone,uint32 newArea);
1467 void UpdateArea(uint32 newArea);
1469 void UpdateZoneDependentAuras( uint32 zone_id ); // zones
1470 void UpdateAreaDependentAuras( uint32 area_id ); // subzones
1472 void UpdateAfkReport(time_t currTime);
1473 void UpdatePvPFlag(time_t currTime);
1474 void UpdateContestedPvP(uint32 currTime);
1475 void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
1476 void ResetContestedPvP()
1478 clearUnitState(UNIT_STAT_ATTACK_PLAYER);
1479 RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
1480 m_contestedPvPTimer = 0;
1483 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1484 DuelInfo *duel;
1485 void UpdateDuelFlag(time_t currTime);
1486 void CheckDuelDistance(time_t currTime);
1487 void DuelComplete(DuelCompleteType type);
1489 bool IsGroupVisibleFor(Player* p) const;
1490 bool IsInSameGroupWith(Player const* p) const;
1491 bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
1492 void UninviteFromGroup();
1493 static void RemoveFromGroup(Group* group, uint64 guid);
1494 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1495 void SendUpdateToOutOfRangeGroupMembers();
1497 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
1498 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
1499 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
1500 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
1501 static uint32 GetGuildIdFromDB(uint64 guid);
1502 uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
1503 static uint32 GetRankFromDB(uint64 guid);
1504 int GetGuildIdInvited() { return m_GuildIdInvited; }
1505 static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
1507 // Arena Team
1508 void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot)
1510 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId);
1512 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); }
1513 static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
1514 void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
1515 uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
1516 static void LeaveAllArenaTeams(uint64 guid);
1518 void SetDifficulty(uint32 dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; }
1519 uint8 GetDifficulty() { return m_dungeonDifficulty; }
1521 bool UpdateSkill(uint32 skill_id, uint32 step);
1522 bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step);
1524 bool UpdateCraftSkill(uint32 spellid);
1525 bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1);
1526 bool UpdateFishingSkill();
1528 uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); }
1529 uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const;
1531 uint32 GetSpellByProto(ItemPrototype *proto);
1533 float GetHealthBonusFromStamina();
1534 float GetManaBonusFromIntellect();
1536 bool UpdateStats(Stats stat);
1537 bool UpdateAllStats();
1538 void UpdateResistances(uint32 school);
1539 void UpdateArmor();
1540 void UpdateMaxHealth();
1541 void UpdateMaxPower(Powers power);
1542 void ApplyFeralAPBonus(int32 amount, bool apply);
1543 void UpdateAttackPowerAndDamage(bool ranged = false);
1544 void UpdateShieldBlockValue();
1545 void UpdateDamagePhysical(WeaponAttackType attType);
1546 void ApplySpellDamageBonus(int32 amount, bool apply);
1547 void ApplySpellHealingBonus(int32 amount, bool apply);
1548 void UpdateSpellDamageAndHealingBonus();
1550 void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage);
1552 void UpdateDefenseBonusesMod();
1553 void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
1554 float GetMeleeCritFromAgility();
1555 float GetDodgeFromAgility();
1556 float GetSpellCritFromIntellect();
1557 float OCTRegenHPPerSpirit();
1558 float OCTRegenMPPerSpirit();
1559 float GetRatingCoefficient(CombatRating cr) const;
1560 float GetRatingBonusValue(CombatRating cr) const;
1561 uint32 GetMeleeCritDamageReduction(uint32 damage) const;
1562 uint32 GetRangedCritDamageReduction(uint32 damage) const;
1563 uint32 GetSpellCritDamageReduction(uint32 damage) const;
1564 uint32 GetDotDamageReduction(uint32 damage) const;
1565 uint32 GetBaseSpellDamageBonus() { return m_baseSpellDamage;}
1566 uint32 GetBaseSpellHealingBonus() { return m_baseSpellHealing;}
1568 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
1569 void UpdateBlockPercentage();
1570 void UpdateCritPercentage(WeaponAttackType attType);
1571 void UpdateAllCritPercentages();
1572 void UpdateParryPercentage();
1573 void UpdateDodgePercentage();
1574 void UpdateMeleeHitChances();
1575 void UpdateRangedHitChances();
1576 void UpdateSpellHitChances();
1578 void UpdateAllSpellCritChances();
1579 void UpdateSpellCritChance(uint32 school);
1580 void UpdateExpertise(WeaponAttackType attType);
1581 void ApplyManaRegenBonus(int32 amount, bool apply);
1582 void UpdateManaRegen();
1584 const uint64& GetLootGUID() const { return m_lootGuid; }
1585 void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; }
1587 void RemovedInsignia(Player* looterPlr);
1589 WorldSession* GetSession() const { return m_session; }
1590 void SetSession(WorldSession *s) { m_session = s; }
1592 void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const;
1593 void DestroyForPlayer( Player *target ) const;
1594 void SendDelayResponse(const uint32);
1595 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
1597 //notifiers
1598 void SendAttackSwingCantAttack();
1599 void SendAttackSwingCancelAttack();
1600 void SendAttackSwingDeadTarget();
1601 void SendAttackSwingNotStanding();
1602 void SendAttackSwingNotInRange();
1603 void SendAttackSwingBadFacingAttack();
1604 void SendAutoRepeatCancel();
1605 void SendExplorationExperience(uint32 Area, uint32 Experience);
1607 void SendDungeonDifficulty(bool IsInGroup);
1608 void ResetInstances(uint8 method);
1609 void SendResetInstanceSuccess(uint32 MapId);
1610 void SendResetInstanceFailed(uint32 reason, uint32 MapId);
1611 void SendResetFailedNotify(uint32 mapid);
1613 bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
1614 void UpdateUnderwaterState( Map * m, float x, float y, float z );
1616 void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet
1617 void SendMessageToSetInRange(WorldPacket *data, float fist, bool self);
1618 // overwrite Object::SendMessageToSetInRange
1619 void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only);
1621 static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true);
1623 Corpse *GetCorpse() const;
1624 void SpawnCorpseBones();
1625 void CreateCorpse();
1626 void KillPlayer();
1627 uint32 GetResurrectionSpellId();
1628 void ResurrectPlayer(float restore_percent, bool applySickness = false);
1629 void BuildPlayerRepop();
1630 void RepopAtGraveyard();
1632 void DurabilityLossAll(double percent, bool inventory);
1633 void DurabilityLoss(Item* item, double percent);
1634 void DurabilityPointsLossAll(int32 points, bool inventory);
1635 void DurabilityPointsLoss(Item* item, int32 points);
1636 void DurabilityPointLossForEquipSlot(EquipmentSlots slot);
1637 uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank);
1638 uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank);
1640 void UpdateMirrorTimers();
1641 void StopMirrorTimers()
1643 StopMirrorTimer(FATIGUE_TIMER);
1644 StopMirrorTimer(BREATH_TIMER);
1645 StopMirrorTimer(FIRE_TIMER);
1648 void SetMovement(PlayerMovementType pType);
1650 void JoinedChannel(Channel *c);
1651 void LeftChannel(Channel *c);
1652 void CleanupChannels();
1653 void UpdateLocalChannels( uint32 newZone );
1654 void LeaveLFGChannel();
1656 void UpdateDefense();
1657 void UpdateWeaponSkill (WeaponAttackType attType);
1658 void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence);
1660 void SetSkill(uint32 id, uint16 currVal, uint16 maxVal);
1661 uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
1662 uint16 GetPureMaxSkillValue(uint32 skill) const; // max
1663 uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
1664 uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus
1665 uint16 GetPureSkillValue(uint32 skill) const; // skill value
1666 int16 GetSkillPermBonusValue(uint32 skill) const;
1667 int16 GetSkillTempBonusValue(uint32 skill) const;
1668 bool HasSkill(uint32 skill) const;
1669 void learnSkillRewardedSpells(uint32 id, uint32 value);
1671 WorldLocation& GetTeleportDest() { return m_teleport_dest; }
1672 bool IsBeingTeleported() const { return mSemaphoreTeleport_Near || mSemaphoreTeleport_Far; }
1673 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near; }
1674 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far; }
1675 void SetSemaphoreTeleportNear(bool semphsetting) { mSemaphoreTeleport_Near = semphsetting; }
1676 void SetSemaphoreTeleportFar(bool semphsetting) { mSemaphoreTeleport_Far = semphsetting; }
1678 void CheckExploreSystem(void);
1680 static uint32 TeamForRace(uint8 race);
1681 uint32 GetTeam() const { return m_team; }
1682 static uint32 getFactionForRace(uint8 race);
1683 void setFactionForRace(uint8 race);
1685 bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
1686 bool RewardPlayerAndGroupAtKill(Unit* pVictim);
1687 void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
1688 bool isHonorOrXPTarget(Unit* pVictim);
1690 ReputationMgr& GetReputationMgr() { return m_reputationMgr; }
1691 ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; }
1692 ReputationRank GetReputationRank(uint32 faction_id) const;
1693 void RewardReputation(Unit *pVictim, float rate);
1694 void RewardReputation(Quest const *pQuest);
1696 void UpdateSkillsForLevel();
1697 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1698 void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
1700 /*********************************************************/
1701 /*** PVP SYSTEM ***/
1702 /*********************************************************/
1703 void UpdateArenaFields();
1704 void UpdateHonorFields();
1705 bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1);
1706 uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
1707 uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
1708 void ModifyHonorPoints( int32 value );
1709 void ModifyArenaPoints( int32 value );
1710 uint32 GetMaxPersonalArenaRatingRequirement();
1712 //End of PvP System
1714 void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0);
1715 uint16 GetDrunkValue() const { return m_drunk; }
1716 static DrunkenState GetDrunkenstateByValue(uint16 value);
1718 uint32 GetDeathTimer() const { return m_deathTimer; }
1719 uint32 GetCorpseReclaimDelay(bool pvp) const;
1720 void UpdateCorpseReclaimDelay();
1721 void SendCorpseReclaimDelay(bool load = false);
1723 uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual)
1724 bool CanParry() const { return m_canParry; }
1725 void SetCanParry(bool value);
1726 bool CanBlock() const { return m_canBlock; }
1727 void SetCanBlock(bool value);
1728 bool CanDualWield() const { return m_canDualWield; }
1729 void SetCanDualWield(bool value) { m_canDualWield = value; }
1730 bool CanTitanGrip() const { return m_canTitanGrip ; }
1731 void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
1733 void SetRegularAttackTime();
1734 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }
1735 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply);
1736 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
1737 float GetTotalBaseModValue(BaseModGroup modGroup) const;
1738 float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; }
1739 void _ApplyAllStatBonuses();
1740 void _RemoveAllStatBonuses();
1742 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
1743 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1744 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1746 void _ApplyItemMods(Item *item,uint8 slot,bool apply);
1747 void _RemoveAllItemMods();
1748 void _ApplyAllItemMods();
1749 void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply);
1750 void _ApplyAmmoBonuses();
1751 bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot);
1752 void ToggleMetaGemsActive(uint8 exceptslot, bool apply);
1753 void CorrectMetaGemEnchants(uint8 slot, bool apply);
1754 void InitDataForForm(bool reapplyMods = false);
1756 void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
1757 void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
1758 void UpdateEquipSpellsAtFormChange();
1759 void CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType);
1760 void CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex);
1762 void SendInitWorldStates(uint32 zone, uint32 area);
1763 void SendUpdateWorldState(uint32 Field, uint32 Value);
1764 void SendDirectMessage(WorldPacket *data);
1766 void SendAurasForTarget(Unit *target);
1768 PlayerMenu* PlayerTalkClass;
1769 std::vector<ItemSetEffect *> ItemSetEff;
1771 void SendLoot(uint64 guid, LootType loot_type);
1772 void SendLootRelease( uint64 guid );
1773 void SendNotifyLootItemRemoved(uint8 lootSlot);
1774 void SendNotifyLootMoneyRemoved();
1776 /*********************************************************/
1777 /*** BATTLEGROUND SYSTEM ***/
1778 /*********************************************************/
1780 bool InBattleGround() const { return m_bgBattleGroundID != 0; }
1781 bool InArena() const;
1782 uint32 GetBattleGroundId() const { return m_bgBattleGroundID; }
1783 BattleGroundTypeId GetBattleGroundTypeId() const { return m_bgTypeID; }
1784 BattleGround* GetBattleGround() const;
1787 BGQueueIdBasedOnLevel GetBattleGroundQueueIdFromLevel(BattleGroundTypeId bgTypeId) const;
1789 bool InBattleGroundQueue() const
1791 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1792 if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
1793 return true;
1794 return false;
1797 BattleGroundQueueTypeId GetBattleGroundQueueTypeId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueTypeId; }
1798 uint32 GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId) const
1800 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1801 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
1802 return i;
1803 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1805 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
1807 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1808 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
1809 return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
1810 return false;
1812 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
1814 return GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES;
1817 void SetBattleGroundId(uint32 val, BattleGroundTypeId bgTypeId)
1819 m_bgBattleGroundID = val;
1820 m_bgTypeID = bgTypeId;
1822 uint32 AddBattleGroundQueueId(BattleGroundQueueTypeId val)
1824 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1826 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattleGroundQueueID[i].bgQueueTypeId == val)
1828 m_bgBattleGroundQueueID[i].bgQueueTypeId = val;
1829 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
1830 return i;
1833 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1835 bool HasFreeBattleGroundQueueId()
1837 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1838 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
1839 return true;
1840 return false;
1842 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val)
1844 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1846 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == val)
1848 m_bgBattleGroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
1849 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
1850 return;
1854 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId, uint32 instanceId)
1856 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1857 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
1858 m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
1860 bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
1862 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1863 if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
1864 return true;
1865 return false;
1867 WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgEntryPoint; }
1868 void SetBattleGroundEntryPoint(uint32 Map, float PosX, float PosY, float PosZ, float PosO )
1870 m_bgEntryPoint = WorldLocation(Map,PosX,PosY,PosZ,PosO);
1873 void SetBGTeam(uint32 team) { m_bgTeam = team; }
1874 uint32 GetBGTeam() const { return m_bgTeam ? m_bgTeam : GetTeam(); }
1876 void LeaveBattleground(bool teleportToEntryPoint = true);
1877 bool CanJoinToBattleground() const;
1878 bool CanReportAfkDueToLimit();
1879 void ReportedAfkBy(Player* reporter);
1880 void ClearAfkReports() { m_bgAfkReporter.clear(); }
1882 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const;
1883 bool CanUseBattleGroundObject();
1884 bool isTotalImmune();
1885 bool CanCaptureTowerPoint();
1887 /*********************************************************/
1888 /*** REST SYSTEM ***/
1889 /*********************************************************/
1891 bool isRested() const { return GetRestTime() >= 10*IN_MILISECONDS; }
1892 uint32 GetXPRestBonus(uint32 xp);
1893 uint32 GetRestTime() const { return m_restTime;};
1894 void SetRestTime(uint32 v) { m_restTime = v;};
1896 /*********************************************************/
1897 /*** ENVIROMENTAL SYSTEM ***/
1898 /*********************************************************/
1900 void EnvironmentalDamage(EnviromentalDamage type, uint32 damage);
1902 /*********************************************************/
1903 /*** FLOOD FILTER SYSTEM ***/
1904 /*********************************************************/
1906 void UpdateSpeakTime();
1907 bool CanSpeak() const;
1908 void ChangeSpeakTime(int utime);
1910 /*********************************************************/
1911 /*** VARIOUS SYSTEMS ***/
1912 /*********************************************************/
1913 MovementInfo m_movementInfo;
1914 void UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode);
1915 Unit *m_mover;
1916 void SetFallInformation(uint32 time, float z)
1918 m_lastFallTime = time;
1919 m_lastFallZ = z;
1921 void HandleFall(MovementInfo const& movementInfo);
1923 bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); }
1924 bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); }
1926 bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); }
1927 bool IsFlying() const { return HasUnitMovementFlag(MOVEMENTFLAG_FLYING); }
1928 bool IsAllowUseFlyMountsHere() const;
1930 void SetClientControl(Unit* target, uint8 allowMove);
1932 void EnterVehicle(Vehicle *vehicle);
1933 void ExitVehicle(Vehicle *vehicle);
1935 uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
1936 void SetFarSightGUID(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); }
1938 // Transports
1939 Transport * GetTransport() const { return m_transport; }
1940 void SetTransport(Transport * t) { m_transport = t; }
1942 float GetTransOffsetX() const { return m_movementInfo.t_x; }
1943 float GetTransOffsetY() const { return m_movementInfo.t_y; }
1944 float GetTransOffsetZ() const { return m_movementInfo.t_z; }
1945 float GetTransOffsetO() const { return m_movementInfo.t_o; }
1946 uint32 GetTransTime() const { return m_movementInfo.t_time; }
1947 int8 GetTransSeat() const { return m_movementInfo.t_seat; }
1949 uint32 GetSaveTimer() const { return m_nextSave; }
1950 void SetSaveTimer(uint32 timer) { m_nextSave = timer; }
1952 // Recall position
1953 uint32 m_recallMap;
1954 float m_recallX;
1955 float m_recallY;
1956 float m_recallZ;
1957 float m_recallO;
1958 void SaveRecallPosition();
1960 // Homebind coordinates
1961 uint32 m_homebindMapId;
1962 uint16 m_homebindZoneId;
1963 float m_homebindX;
1964 float m_homebindY;
1965 float m_homebindZ;
1966 void RelocateToHomebind() { SetMapId(m_homebindMapId); Relocate(m_homebindX,m_homebindY,m_homebindZ); }
1968 // currently visible objects at player client
1969 typedef std::set<uint64> ClientGUIDs;
1970 ClientGUIDs m_clientGUIDs;
1972 bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); }
1974 bool IsVisibleInGridForPlayer(Player* pl) const;
1975 bool IsVisibleGloballyFor(Player* pl) const;
1977 void UpdateVisibilityOf(WorldObject* target);
1979 template<class T>
1980 void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
1982 // Stealth detection system
1983 uint32 m_DetectInvTimer;
1984 void HandleStealthedUnitsDetection();
1986 uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
1988 bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; }
1989 void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
1991 LookingForGroup m_lookingForGroup;
1993 // Temporarily removed pet cache
1994 uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
1995 void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
1996 void UnsummonPetTemporaryIfAny();
1997 void ResummonPetTemporaryUnSummonedIfAny();
1998 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
2000 void SendCinematicStart(uint32 CinematicSequenceId);
2001 void SendMovieStart(uint32 MovieId);
2003 /*********************************************************/
2004 /*** INSTANCE SYSTEM ***/
2005 /*********************************************************/
2007 typedef UNORDERED_MAP< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap;
2009 void UpdateHomebindTime(uint32 time);
2011 uint32 m_HomebindTimer;
2012 bool m_InstanceValid;
2013 // permanent binds and solo binds by difficulty
2014 BoundInstancesMap m_boundInstances[TOTAL_DIFFICULTIES];
2015 InstancePlayerBind* GetBoundInstance(uint32 mapid, uint8 difficulty);
2016 BoundInstancesMap& GetBoundInstances(uint8 difficulty) { return m_boundInstances[difficulty]; }
2017 void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false);
2018 void UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload = false);
2019 InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false);
2020 void SendRaidInfo();
2021 void SendSavedInstances();
2022 static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0);
2024 /*********************************************************/
2025 /*** GROUP SYSTEM ***/
2026 /*********************************************************/
2028 Group * GetGroupInvite() { return m_groupInvite; }
2029 void SetGroupInvite(Group *group) { m_groupInvite = group; }
2030 Group * GetGroup() { return m_group.getTarget(); }
2031 const Group * GetGroup() const { return (const Group*)m_group.getTarget(); }
2032 GroupReference& GetGroupRef() { return m_group; }
2033 void SetGroup(Group *group, int8 subgroup = -1);
2034 uint8 GetSubGroup() const { return m_group.getSubGroup(); }
2035 uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; }
2036 void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
2037 const uint64& GetAuraUpdateMask() const { return m_auraUpdateMask; }
2038 void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
2039 Player* GetNextRandomRaidMember(float radius);
2040 PartyResult CanUninviteFromGroup() const;
2041 // BattleGround Group System
2042 void SetBattleGroundRaid(Group *group, int8 subgroup = -1);
2043 void RemoveFromBattleGroundRaid();
2044 Group * GetOriginalGroup() { return m_originalGroup.getTarget(); }
2045 GroupReference& GetOriginalGroupRef() { return m_originalGroup; }
2046 uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); }
2047 void SetOriginalGroup(Group *group, int8 subgroup = -1);
2049 GridReference<Player> &GetGridRef() { return m_gridRef; }
2050 MapReference &GetMapRef() { return m_mapRef; }
2052 bool isAllowedToLoot(Creature* creature);
2054 DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
2055 uint8 GetRunesState() const { return m_runes->runeState; }
2056 uint8 GetBaseRune(uint8 index) const { return m_runes->runes[index].BaseRune; }
2057 uint8 GetCurrentRune(uint8 index) const { return m_runes->runes[index].CurrentRune; }
2058 uint8 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; }
2059 void SetBaseRune(uint8 index, uint8 baseRune) { m_runes->runes[index].BaseRune = baseRune; }
2060 void SetCurrentRune(uint8 index, uint8 currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
2061 void SetRuneCooldown(uint8 index, uint8 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); }
2062 void ConvertRune(uint8 index, uint8 newType);
2063 void ResyncRunes(uint8 count);
2064 void AddRunePower(uint8 index);
2065 void InitRunes();
2066 AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
2067 void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0);
2068 bool HasTitle(uint32 bitIndex);
2069 bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }
2070 void SetTitle(CharTitlesEntry const* title);
2072 bool isActiveObject() const { return true; }
2073 bool canSeeSpellClickOn(Creature const* creature) const;
2074 protected:
2076 /*********************************************************/
2077 /*** BATTLEGROUND SYSTEM ***/
2078 /*********************************************************/
2080 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2081 uint32 m_bgBattleGroundID;
2082 BattleGroundTypeId m_bgTypeID;
2084 this is an array of BG queues (BgTypeIDs) in which is player
2086 struct BgBattleGroundQueueID_Rec
2088 BattleGroundQueueTypeId bgQueueTypeId;
2089 uint32 invitedToInstance;
2091 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES];
2092 WorldLocation m_bgEntryPoint;
2094 std::set<uint32> m_bgAfkReporter;
2095 uint8 m_bgAfkReportedCount;
2096 time_t m_bgAfkReportedTimer;
2097 uint32 m_contestedPvPTimer;
2099 uint32 m_bgTeam; // what side the player will be added to
2101 /*********************************************************/
2102 /*** QUEST SYSTEM ***/
2103 /*********************************************************/
2105 std::set<uint32> m_timedquests;
2107 uint64 m_divider;
2108 uint32 m_ingametime;
2110 /*********************************************************/
2111 /*** LOAD SYSTEM ***/
2112 /*********************************************************/
2114 void _LoadActions(QueryResult *result);
2115 void _LoadAuras(QueryResult *result, uint32 timediff);
2116 void _LoadGlyphAuras();
2117 void _LoadBoundInstances(QueryResult *result);
2118 void _LoadInventory(QueryResult *result, uint32 timediff);
2119 void _LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery);
2120 void _LoadMail();
2121 void _LoadMailedItems(Mail *mail);
2122 void _LoadQuestStatus(QueryResult *result);
2123 void _LoadDailyQuestStatus(QueryResult *result);
2124 void _LoadGroup(QueryResult *result);
2125 void _LoadSkills();
2126 void _LoadSpells(QueryResult *result);
2127 void _LoadTutorials(QueryResult *result);
2128 void _LoadFriendList(QueryResult *result);
2129 bool _LoadHomeBind(QueryResult *result);
2130 void _LoadDeclinedNames(QueryResult *result);
2131 void _LoadArenaTeamInfo(QueryResult *result);
2133 /*********************************************************/
2134 /*** SAVE SYSTEM ***/
2135 /*********************************************************/
2137 void _SaveActions();
2138 void _SaveAuras();
2139 void _SaveInventory();
2140 void _SaveMail();
2141 void _SaveQuestStatus();
2142 void _SaveDailyQuestStatus();
2143 void _SaveSpells();
2144 void _SaveTutorials();
2146 void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
2147 void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
2149 /*********************************************************/
2150 /*** ENVIRONMENTAL SYSTEM ***/
2151 /*********************************************************/
2152 void HandleSobering();
2153 void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen);
2154 void StopMirrorTimer(MirrorTimerType Type);
2155 void HandleDrowning(uint32 time_diff);
2156 int32 getMaxTimer(MirrorTimerType timer);
2158 /*********************************************************/
2159 /*** HONOR SYSTEM ***/
2160 /*********************************************************/
2161 time_t m_lastHonorUpdateTime;
2163 void outDebugValues() const;
2164 uint64 m_lootGuid;
2166 uint32 m_race;
2167 uint32 m_class;
2168 uint32 m_team;
2169 uint32 m_nextSave;
2170 time_t m_speakTime;
2171 uint32 m_speakCount;
2172 uint32 m_dungeonDifficulty;
2174 uint32 m_atLoginFlags;
2176 Item* m_items[PLAYER_SLOTS_COUNT];
2177 uint32 m_currentBuybackSlot;
2179 std::vector<Item*> m_itemUpdateQueue;
2180 bool m_itemUpdateQueueBlocked;
2182 uint32 m_ExtraFlags;
2183 uint64 m_curSelection;
2185 uint64 m_comboTarget;
2186 int8 m_comboPoints;
2188 QuestStatusMap mQuestStatus;
2190 uint32 m_GuildIdInvited;
2191 uint32 m_ArenaTeamIdInvited;
2193 PlayerMails m_mail;
2194 PlayerSpellMap m_spells;
2195 SpellCooldowns m_spellCooldowns;
2196 uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use
2198 ActionButtonList m_actionButtons;
2200 float m_auraBaseMod[BASEMOD_END][MOD_END];
2201 int16 m_baseRatingValue[MAX_COMBAT_RATING];
2202 uint16 m_baseSpellDamage;
2203 uint16 m_baseSpellHealing;
2204 uint16 m_baseFeralAP;
2205 uint16 m_baseManaRegen;
2207 SpellModList m_spellMods[MAX_SPELLMOD];
2208 int32 m_SpellModRemoveCount;
2209 EnchantDurationList m_enchantDuration;
2210 ItemDurationList m_itemDuration;
2212 uint64 m_resurrectGUID;
2213 uint32 m_resurrectMap;
2214 float m_resurrectX, m_resurrectY, m_resurrectZ;
2215 uint32 m_resurrectHealth, m_resurrectMana;
2217 WorldSession *m_session;
2219 typedef std::list<Channel*> JoinedChannelsList;
2220 JoinedChannelsList m_channels;
2222 int m_cinematic;
2224 Player *pTrader;
2225 bool acceptTrade;
2226 uint16 tradeItems[TRADE_SLOT_COUNT];
2227 uint32 tradeGold;
2229 time_t m_nextThinkTime;
2231 uint32 m_Tutorials[8];
2232 bool m_TutorialsChanged;
2234 bool m_DailyQuestChanged;
2235 time_t m_lastDailyQuestTime;
2237 uint32 m_drunkTimer;
2238 uint16 m_drunk;
2239 uint32 m_weaponChangeTimer;
2241 uint32 m_zoneUpdateId;
2242 uint32 m_zoneUpdateTimer;
2243 uint32 m_areaUpdateId;
2245 uint32 m_deathTimer;
2246 time_t m_deathExpireTime;
2248 uint32 m_restTime;
2250 uint32 m_WeaponProficiency;
2251 uint32 m_ArmorProficiency;
2252 bool m_canParry;
2253 bool m_canBlock;
2254 bool m_canDualWield;
2255 bool m_canTitanGrip;
2256 uint8 m_swingErrorMsg;
2257 float m_ammoDPS;
2259 ////////////////////Rest System/////////////////////
2260 int time_inn_enter;
2261 uint32 inn_pos_mapid;
2262 float inn_pos_x;
2263 float inn_pos_y;
2264 float inn_pos_z;
2265 float m_rest_bonus;
2266 RestType rest_type;
2267 ////////////////////Rest System/////////////////////
2269 // Transports
2270 Transport * m_transport;
2272 uint32 m_resetTalentsCost;
2273 time_t m_resetTalentsTime;
2274 uint32 m_usedTalentCount;
2275 uint32 m_questRewardTalentCount;
2277 // Social
2278 PlayerSocial *m_social;
2280 // Groups
2281 GroupReference m_group;
2282 GroupReference m_originalGroup;
2283 Group *m_groupInvite;
2284 uint32 m_groupUpdateMask;
2285 uint64 m_auraUpdateMask;
2287 uint64 m_miniPet;
2288 GuardianPetList m_guardianPets;
2290 // Player summoning
2291 time_t m_summon_expire;
2292 uint32 m_summon_mapid;
2293 float m_summon_x;
2294 float m_summon_y;
2295 float m_summon_z;
2297 DeclinedName *m_declinedname;
2298 Runes *m_runes;
2299 private:
2300 // internal common parts for CanStore/StoreItem functions
2301 uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
2302 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;
2303 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;
2304 Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
2306 void UpdateKnownCurrencies(uint32 itemId, bool apply);
2307 int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest);
2308 void AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& questStatusData );
2310 GridReference<Player> m_gridRef;
2311 MapReference m_mapRef;
2313 uint32 m_lastFallTime;
2314 float m_lastFallZ;
2316 int32 m_MirrorTimer[MAX_TIMERS];
2317 uint8 m_MirrorTimerFlags;
2318 uint8 m_MirrorTimerFlagsLast;
2319 bool m_isInWater;
2321 // Current teleport data
2322 WorldLocation m_teleport_dest;
2323 bool mSemaphoreTeleport_Near;
2324 bool mSemaphoreTeleport_Far;
2326 // Temporary removed pet cache
2327 uint32 m_temporaryUnsummonedPetNumber;
2328 uint32 m_oldpetspell;
2330 AchievementMgr m_achievementMgr;
2331 ReputationMgr m_reputationMgr;
2334 void AddItemsSetItem(Player*player,Item *item);
2335 void RemoveItemsSetItem(Player*player,ItemPrototype const *proto);
2337 // "the bodies of template functions must be made available in a header file"
2338 template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell)
2340 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
2341 if (!spellInfo) return 0;
2342 int32 totalpct = 0;
2343 int32 totalflat = 0;
2344 for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
2346 SpellModifier *mod = *itr;
2348 if(!IsAffectedBySpellmod(spellInfo,mod,spell))
2349 continue;
2350 if (mod->type == SPELLMOD_FLAT)
2351 totalflat += mod->value;
2352 else if (mod->type == SPELLMOD_PCT)
2354 // skip percent mods for null basevalue (most important for spell mods with charges )
2355 if(basevalue == T(0))
2356 continue;
2358 // special case (skip >10sec spell casts for instant cast setting)
2359 if( mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10*IN_MILISECONDS) && mod->value <= -100)
2360 continue;
2362 totalpct += mod->value;
2365 if (mod->charges > 0 )
2367 --mod->charges;
2368 if (mod->charges == 0)
2370 mod->charges = -1;
2371 mod->lastAffected = spell;
2372 if(!mod->lastAffected)
2373 mod->lastAffected = FindCurrentSpellBySpellId(spellId);
2374 ++m_SpellModRemoveCount;
2379 float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat;
2380 basevalue = T((float)basevalue + diff);
2381 return T(diff);
2383 #endif