[7645] Fixed problems wit temporary unsummoned pets and cleanup code.
[AHbot.git] / src / game / Player.h
blobabc3f6ce83a4f86b3fb1f08ce5026716c1489a67
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
127 enum ActionButtonUpdateState
129 ACTIONBUTTON_UNCHANGED = 0,
130 ACTIONBUTTON_CHANGED = 1,
131 ACTIONBUTTON_NEW = 2,
132 ACTIONBUTTON_DELETED = 3
135 struct ActionButton
137 ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW ) {}
138 ActionButton(uint16 _action, uint8 _type, uint8 _misc) : action(_action), type(_type), misc(_misc), uState( ACTIONBUTTON_NEW ) {}
140 uint16 action;
141 uint8 type;
142 uint8 misc;
143 ActionButtonUpdateState uState;
146 enum ActionButtonType
148 ACTION_BUTTON_SPELL = 0,
149 ACTION_BUTTON_MACRO = 64,
150 ACTION_BUTTON_CMACRO= 65,
151 ACTION_BUTTON_ITEM = 128
154 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
156 typedef std::map<uint8,ActionButton> ActionButtonList;
158 struct PlayerCreateInfoItem
160 PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {}
162 uint32 item_id;
163 uint32 item_amount;
166 typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
168 struct PlayerClassLevelInfo
170 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
171 uint16 basehealth;
172 uint16 basemana;
175 struct PlayerClassInfo
177 PlayerClassInfo() : levelInfo(NULL) { }
179 PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
182 struct PlayerLevelInfo
184 PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
186 uint8 stats[MAX_STATS];
189 typedef std::list<uint32> PlayerCreateInfoSpells;
191 struct PlayerInfo
193 // existence checked by displayId != 0 // existence checked by displayId != 0
194 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL)
198 uint32 mapId;
199 uint32 zoneId;
200 float positionX;
201 float positionY;
202 float positionZ;
203 uint16 displayId_m;
204 uint16 displayId_f;
205 PlayerCreateInfoItems item;
206 PlayerCreateInfoSpells spell;
207 std::list<uint16> action[4];
209 PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
212 struct PvPInfo
214 PvPInfo() : inHostileArea(false), endTimer(0) {}
216 bool inHostileArea;
217 time_t endTimer;
220 struct DuelInfo
222 DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {}
224 Player *initiator;
225 Player *opponent;
226 time_t startTimer;
227 time_t startTime;
228 time_t outOfBound;
231 struct Areas
233 uint32 areaID;
234 uint32 areaFlag;
235 float x1;
236 float x2;
237 float y1;
238 float y2;
241 #define MAX_RUNES 6
242 #define RUNE_COOLDOWN 5 // 5*2=10 sec
244 enum RuneType
246 RUNE_BLOOD = 0,
247 RUNE_UNHOLY = 1,
248 RUNE_FROST = 2,
249 RUNE_DEATH = 3,
250 NUM_RUNE_TYPES = 4
253 struct RuneInfo
255 uint8 BaseRune;
256 uint8 CurrentRune;
257 uint8 Cooldown;
260 struct Runes
262 RuneInfo runes[MAX_RUNES];
263 uint8 runeState; // mask of available runes
265 void SetRuneState(uint8 index, bool set = true)
267 if(set)
268 runeState |= (1 << index); // usable
269 else
270 runeState &= ~(1 << index); // on cooldown
274 typedef std::set<uint64> GuardianPetList;
276 struct EnchantDuration
278 EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {};
279 EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { assert(item); };
281 Item * item;
282 EnchantmentSlot slot;
283 uint32 leftduration;
286 typedef std::list<EnchantDuration> EnchantDurationList;
287 typedef std::list<Item*> ItemDurationList;
289 struct LookingForGroupSlot
291 LookingForGroupSlot() : entry(0), type(0) {}
292 bool Empty() const { return !entry && !type; }
293 void Clear() { entry = 0; type = 0; }
294 void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; }
295 bool Is(uint32 _entry, uint32 _type) const { return entry==_entry && type==_type; }
296 bool canAutoJoin() const { return entry && (type == 1 || type == 5); }
298 uint32 entry;
299 uint32 type;
302 #define MAX_LOOKING_FOR_GROUP_SLOT 3
304 struct LookingForGroup
306 LookingForGroup() {}
307 bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry,slot.type); }
308 bool HaveInSlot(uint32 _entry, uint32 _type) const
310 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
311 if(slots[i].Is(_entry,_type))
312 return true;
313 return false;
316 bool canAutoJoin() const
318 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
319 if(slots[i].canAutoJoin())
320 return true;
321 return false;
324 bool Empty() const
326 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
327 if(!slots[i].Empty())
328 return false;
329 return more.Empty();
332 LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT];
333 LookingForGroupSlot more;
334 std::string comment;
337 enum PlayerMovementType
339 MOVE_ROOT = 1,
340 MOVE_UNROOT = 2,
341 MOVE_WATER_WALK = 3,
342 MOVE_LAND_WALK = 4
345 enum DrunkenState
347 DRUNKEN_SOBER = 0,
348 DRUNKEN_TIPSY = 1,
349 DRUNKEN_DRUNK = 2,
350 DRUNKEN_SMASHED = 3
353 enum PlayerFlags
355 PLAYER_FLAGS_GROUP_LEADER = 0x00000001,
356 PLAYER_FLAGS_AFK = 0x00000002,
357 PLAYER_FLAGS_DND = 0x00000004,
358 PLAYER_FLAGS_GM = 0x00000008,
359 PLAYER_FLAGS_GHOST = 0x00000010,
360 PLAYER_FLAGS_RESTING = 0x00000020,
361 PLAYER_FLAGS_UNK7 = 0x00000040,
362 PLAYER_FLAGS_UNK8 = 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
363 PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
364 PLAYER_FLAGS_IN_PVP = 0x00000200,
365 PLAYER_FLAGS_HIDE_HELM = 0x00000400,
366 PLAYER_FLAGS_HIDE_CLOAK = 0x00000800,
367 PLAYER_FLAGS_UNK13 = 0x00001000, // played long time
368 PLAYER_FLAGS_UNK14 = 0x00002000, // played too long time
369 PLAYER_FLAGS_UNK15 = 0x00004000,
370 PLAYER_FLAGS_UNK16 = 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
371 PLAYER_FLAGS_UNK17 = 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
372 PLAYER_FLAGS_UNK18 = 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
373 PLAYER_FLAGS_PVP_TIMER = 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
374 PLAYER_FLAGS_UNK20 = 0x00080000,
375 PLAYER_FLAGS_UNK21 = 0x00100000,
376 PLAYER_FLAGS_UNK22 = 0x00200000,
377 PLAYER_FLAGS_UNK23 = 0x00400000,
378 PLAYER_FLAGS_UNK24 = 0x00800000, // disabled all abilitys on tab except autoattack
379 PLAYER_FLAGS_UNK25 = 0x01000000, // disabled all melee ability on tab include autoattack
383 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
384 // can't use enum for uint64 values
385 #define PLAYER_TITLE_DISABLED 0x0000000000000000LL
386 #define PLAYER_TITLE_NONE 0x0000000000000001LL
387 #define PLAYER_TITLE_PRIVATE 0x0000000000000002LL // 1
388 #define PLAYER_TITLE_CORPORAL 0x0000000000000004LL // 2
389 #define PLAYER_TITLE_SERGEANT_A 0x0000000000000008LL // 3
390 #define PLAYER_TITLE_MASTER_SERGEANT 0x0000000000000010LL // 4
391 #define PLAYER_TITLE_SERGEANT_MAJOR 0x0000000000000020LL // 5
392 #define PLAYER_TITLE_KNIGHT 0x0000000000000040LL // 6
393 #define PLAYER_TITLE_KNIGHT_LIEUTENANT 0x0000000000000080LL // 7
394 #define PLAYER_TITLE_KNIGHT_CAPTAIN 0x0000000000000100LL // 8
395 #define PLAYER_TITLE_KNIGHT_CHAMPION 0x0000000000000200LL // 9
396 #define PLAYER_TITLE_LIEUTENANT_COMMANDER 0x0000000000000400LL // 10
397 #define PLAYER_TITLE_COMMANDER 0x0000000000000800LL // 11
398 #define PLAYER_TITLE_MARSHAL 0x0000000000001000LL // 12
399 #define PLAYER_TITLE_FIELD_MARSHAL 0x0000000000002000LL // 13
400 #define PLAYER_TITLE_GRAND_MARSHAL 0x0000000000004000LL // 14
401 #define PLAYER_TITLE_SCOUT 0x0000000000008000LL // 15
402 #define PLAYER_TITLE_GRUNT 0x0000000000010000LL // 16
403 #define PLAYER_TITLE_SERGEANT_H 0x0000000000020000LL // 17
404 #define PLAYER_TITLE_SENIOR_SERGEANT 0x0000000000040000LL // 18
405 #define PLAYER_TITLE_FIRST_SERGEANT 0x0000000000080000LL // 19
406 #define PLAYER_TITLE_STONE_GUARD 0x0000000000100000LL // 20
407 #define PLAYER_TITLE_BLOOD_GUARD 0x0000000000200000LL // 21
408 #define PLAYER_TITLE_LEGIONNAIRE 0x0000000000400000LL // 22
409 #define PLAYER_TITLE_CENTURION 0x0000000000800000LL // 23
410 #define PLAYER_TITLE_CHAMPION 0x0000000001000000LL // 24
411 #define PLAYER_TITLE_LIEUTENANT_GENERAL 0x0000000002000000LL // 25
412 #define PLAYER_TITLE_GENERAL 0x0000000004000000LL // 26
413 #define PLAYER_TITLE_WARLORD 0x0000000008000000LL // 27
414 #define PLAYER_TITLE_HIGH_WARLORD 0x0000000010000000LL // 28
415 #define PLAYER_TITLE_GLADIATOR 0x0000000020000000LL // 29
416 #define PLAYER_TITLE_DUELIST 0x0000000040000000LL // 30
417 #define PLAYER_TITLE_RIVAL 0x0000000080000000LL // 31
418 #define PLAYER_TITLE_CHALLENGER 0x0000000100000000LL // 32
419 #define PLAYER_TITLE_SCARAB_LORD 0x0000000200000000LL // 33
420 #define PLAYER_TITLE_CONQUEROR 0x0000000400000000LL // 34
421 #define PLAYER_TITLE_JUSTICAR 0x0000000800000000LL // 35
422 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36
423 #define PLAYER_TITLE_MERCILESS_GLADIATOR 0x0000002000000000LL // 37
424 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN 0x0000004000000000LL // 38
425 #define PLAYER_TITLE_HAND_OF_ADAL 0x0000008000000000LL // 39
426 #define PLAYER_TITLE_VENGEFUL_GLADIATOR 0x0000010000000000LL // 40
428 // used in PLAYER_FIELD_BYTES values
429 enum PlayerFieldByteFlags
431 PLAYER_FIELD_BYTE_TRACK_STEALTHED = 0x00000002,
432 PLAYER_FIELD_BYTE_RELEASE_TIMER = 0x00000008, // Display time till auto release spirit
433 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x00000010 // Display no "release spirit" window at all
436 // used in PLAYER_FIELD_BYTES2 values
437 enum PlayerFieldByte2Flags
439 PLAYER_FIELD_BYTE2_NONE = 0x0000,
440 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW = 0x4000
443 enum ActivateTaxiReplies
445 ERR_TAXIOK = 0,
446 ERR_TAXIUNSPECIFIEDSERVERERROR = 1,
447 ERR_TAXINOSUCHPATH = 2,
448 ERR_TAXINOTENOUGHMONEY = 3,
449 ERR_TAXITOOFARAWAY = 4,
450 ERR_TAXINOVENDORNEARBY = 5,
451 ERR_TAXINOTVISITED = 6,
452 ERR_TAXIPLAYERBUSY = 7,
453 ERR_TAXIPLAYERALREADYMOUNTED = 8,
454 ERR_TAXIPLAYERSHAPESHIFTED = 9,
455 ERR_TAXIPLAYERMOVING = 10,
456 ERR_TAXISAMENODE = 11,
457 ERR_TAXINOTSTANDING = 12
460 enum LootType
462 LOOT_CORPSE = 1,
463 LOOT_SKINNING = 2,
464 LOOT_FISHING = 3,
465 LOOT_PICKPOCKETING = 4, // unsupported by client, sending LOOT_SKINNING instead
466 LOOT_DISENCHANTING = 5, // unsupported by client, sending LOOT_SKINNING instead
467 LOOT_PROSPECTING = 6, // unsupported by client, sending LOOT_SKINNING instead
468 LOOT_INSIGNIA = 7, // unsupported by client, sending LOOT_SKINNING instead
469 LOOT_FISHINGHOLE = 8, // unsupported by client, sending LOOT_FISHING instead
470 LOOT_MILLING = 9 // unsupported by client, sending LOOT_SKINNING instead
473 enum MirrorTimerType
475 FATIGUE_TIMER = 0,
476 BREATH_TIMER = 1,
477 FIRE_TIMER = 2
479 #define MAX_TIMERS 3
480 #define DISABLED_MIRROR_TIMER -1
482 // 2^n values
483 enum PlayerExtraFlags
485 // gm abilities
486 PLAYER_EXTRA_GM_ON = 0x0001,
487 PLAYER_EXTRA_GM_ACCEPT_TICKETS = 0x0002,
488 PLAYER_EXTRA_ACCEPT_WHISPERS = 0x0004,
489 PLAYER_EXTRA_TAXICHEAT = 0x0008,
490 PLAYER_EXTRA_GM_INVISIBLE = 0x0010,
491 PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages
493 // other states
494 PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating.
497 // 2^n values
498 enum AtLoginFlags
500 AT_LOGIN_NONE = 0,
501 AT_LOGIN_RENAME = 1,
502 AT_LOGIN_RESET_SPELLS = 2,
503 AT_LOGIN_RESET_TALENTS = 4,
504 AT_LOGIN_CUSTOMIZE = 8
507 typedef std::map<uint32, QuestStatusData> QuestStatusMap;
509 enum QuestSlotOffsets
511 QUEST_ID_OFFSET = 0,
512 QUEST_STATE_OFFSET = 1,
513 QUEST_COUNTS_OFFSET = 2,
514 QUEST_TIME_OFFSET = 3
517 #define MAX_QUEST_OFFSET 4
519 enum QuestSlotStateMask
521 QUEST_STATE_NONE = 0x0000,
522 QUEST_STATE_COMPLETE = 0x0001,
523 QUEST_STATE_FAIL = 0x0002
526 class Quest;
527 class Spell;
528 class Item;
529 class WorldSession;
531 enum PlayerSlots
533 // first slot for item stored (in any way in player m_items data)
534 PLAYER_SLOT_START = 0,
535 // last+1 slot for item stored (in any way in player m_items data)
536 PLAYER_SLOT_END = 200,
537 PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START)
540 #define INVENTORY_SLOT_BAG_0 255
542 enum EquipmentSlots // 19 slots
544 EQUIPMENT_SLOT_START = 0,
545 EQUIPMENT_SLOT_HEAD = 0,
546 EQUIPMENT_SLOT_NECK = 1,
547 EQUIPMENT_SLOT_SHOULDERS = 2,
548 EQUIPMENT_SLOT_BODY = 3,
549 EQUIPMENT_SLOT_CHEST = 4,
550 EQUIPMENT_SLOT_WAIST = 5,
551 EQUIPMENT_SLOT_LEGS = 6,
552 EQUIPMENT_SLOT_FEET = 7,
553 EQUIPMENT_SLOT_WRISTS = 8,
554 EQUIPMENT_SLOT_HANDS = 9,
555 EQUIPMENT_SLOT_FINGER1 = 10,
556 EQUIPMENT_SLOT_FINGER2 = 11,
557 EQUIPMENT_SLOT_TRINKET1 = 12,
558 EQUIPMENT_SLOT_TRINKET2 = 13,
559 EQUIPMENT_SLOT_BACK = 14,
560 EQUIPMENT_SLOT_MAINHAND = 15,
561 EQUIPMENT_SLOT_OFFHAND = 16,
562 EQUIPMENT_SLOT_RANGED = 17,
563 EQUIPMENT_SLOT_TABARD = 18,
564 EQUIPMENT_SLOT_END = 19
567 enum InventorySlots // 4 slots
569 INVENTORY_SLOT_BAG_START = 19,
570 INVENTORY_SLOT_BAG_END = 23
573 enum InventoryPackSlots // 16 slots
575 INVENTORY_SLOT_ITEM_START = 23,
576 INVENTORY_SLOT_ITEM_END = 39
579 enum BankItemSlots // 28 slots
581 BANK_SLOT_ITEM_START = 39,
582 BANK_SLOT_ITEM_END = 67
585 enum BankBagSlots // 7 slots
587 BANK_SLOT_BAG_START = 67,
588 BANK_SLOT_BAG_END = 74
591 enum BuyBackSlots // 12 slots
593 // stored in m_buybackitems
594 BUYBACK_SLOT_START = 74,
595 BUYBACK_SLOT_END = 86
598 enum KeyRingSlots // 32 slots
600 KEYRING_SLOT_START = 86,
601 KEYRING_SLOT_END = 118
604 enum VanityPetSlots // 18 slots
606 VANITYPET_SLOT_START = 118, // not use, vanity pets stored as spells
607 VANITYPET_SLOT_END = 136 // not allowed any content in.
610 enum CurrencyTokenSlots // 32 slots
612 CURRENCYTOKEN_SLOT_START = 136,
613 CURRENCYTOKEN_SLOT_END = 168
616 enum QuestBagSlots // 32 slots
618 QUESTBAG_SLOT_START = 168, // not use
619 QUESTBAG_SLOT_END = 200 // not allowed any content in.
622 struct ItemPosCount
624 ItemPosCount(uint16 _pos, uint32 _count) : pos(_pos), count(_count) {}
625 bool isContainedIn(std::vector<ItemPosCount> const& vec) const;
626 uint16 pos;
627 uint32 count;
629 typedef std::vector<ItemPosCount> ItemPosCountVec;
631 enum TradeSlots
633 TRADE_SLOT_COUNT = 7,
634 TRADE_SLOT_TRADED_COUNT = 6,
635 TRADE_SLOT_NONTRADED = 6
638 enum TransferAbortReason
640 TRANSFER_ABORT_ERROR = 0x00,
641 TRANSFER_ABORT_MAX_PLAYERS = 0x01, // Transfer Aborted: instance is full
642 TRANSFER_ABORT_NOT_FOUND = 0x02, // Transfer Aborted: instance not found
643 TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x03, // You have entered too many instances recently.
644 TRANSFER_ABORT_ZONE_IN_COMBAT = 0x05, // Unable to zone in while an encounter is in progress.
645 TRANSFER_ABORT_INSUF_EXPAN_LVL = 0x06, // You must have <TBC,WotLK> expansion installed to access this area.
646 TRANSFER_ABORT_DIFFICULTY = 0x07, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
647 TRANSFER_ABORT_UNIQUE_MESSAGE = 0x08, // Until you've escaped TLK's grasp, you cannot leave this place!
648 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 0x09 // Additional instances cannot be launched, please try again later.
651 enum InstanceResetWarningType
653 RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s).
654 RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)!
655 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!
656 RAID_INSTANCE_WELCOME = 4 // Welcome to %s. This raid instance is scheduled to reset in %s.
659 struct MovementInfo
661 // common
662 uint32 flags;
663 uint16 unk1;
664 uint32 time;
665 float x, y, z, o;
666 // transport
667 uint64 t_guid;
668 float t_x, t_y, t_z, t_o;
669 uint32 t_time;
670 int8 t_seat;
671 // swimming and unknown
672 float s_pitch;
673 // last fall time
674 uint32 fallTime;
675 // jumping
676 float j_unk, j_sinAngle, j_cosAngle, j_xyspeed;
677 // spline
678 float u_unk1;
680 MovementInfo()
682 flags = 0;
683 time = t_time = fallTime = 0;
684 unk1 = 0;
685 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;
686 t_guid = 0;
690 // flags that use in movement check for example at spell casting
691 MovementFlags const movementFlagsMask = MovementFlags(
692 MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
693 MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1 |
694 MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_FLY_UP |
695 MOVEMENTFLAG_FLYING |MOVEMENTFLAG_SPLINE
698 MovementFlags const movementOrTurningFlagsMask = MovementFlags(
699 movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT
701 class InstanceSave;
703 enum RestType
705 REST_TYPE_NO = 0,
706 REST_TYPE_IN_TAVERN = 1,
707 REST_TYPE_IN_CITY = 2
710 enum DuelCompleteType
712 DUEL_INTERUPTED = 0,
713 DUEL_WON = 1,
714 DUEL_FLED = 2
717 enum TeleportToOptions
719 TELE_TO_GM_MODE = 0x01,
720 TELE_TO_NOT_LEAVE_TRANSPORT = 0x02,
721 TELE_TO_NOT_LEAVE_COMBAT = 0x04,
722 TELE_TO_NOT_UNSUMMON_PET = 0x08,
723 TELE_TO_SPELL = 0x10,
726 /// Type of environmental damages
727 enum EnviromentalDamage
729 DAMAGE_EXHAUSTED = 0,
730 DAMAGE_DROWNING = 1,
731 DAMAGE_FALL = 2,
732 DAMAGE_LAVA = 3,
733 DAMAGE_SLIME = 4,
734 DAMAGE_FIRE = 5,
735 DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
738 // used at player loading query list preparing, and later result selection
739 enum PlayerLoginQueryIndex
741 PLAYER_LOGIN_QUERY_LOADFROM = 0,
742 PLAYER_LOGIN_QUERY_LOADGROUP = 1,
743 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES = 2,
744 PLAYER_LOGIN_QUERY_LOADAURAS = 3,
745 PLAYER_LOGIN_QUERY_LOADSPELLS = 4,
746 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS = 5,
747 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS = 6,
748 PLAYER_LOGIN_QUERY_LOADTUTORIALS = 7, // common for all characters for some account at specific realm
749 PLAYER_LOGIN_QUERY_LOADREPUTATION = 8,
750 PLAYER_LOGIN_QUERY_LOADINVENTORY = 9,
751 PLAYER_LOGIN_QUERY_LOADACTIONS = 10,
752 PLAYER_LOGIN_QUERY_LOADMAILCOUNT = 11,
753 PLAYER_LOGIN_QUERY_LOADMAILDATE = 12,
754 PLAYER_LOGIN_QUERY_LOADSOCIALLIST = 13,
755 PLAYER_LOGIN_QUERY_LOADHOMEBIND = 14,
756 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS = 15,
757 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES = 16,
758 PLAYER_LOGIN_QUERY_LOADGUILD = 17,
759 PLAYER_LOGIN_QUERY_LOADARENAINFO = 18,
760 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS = 19,
761 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS = 20,
762 MAX_PLAYER_LOGIN_QUERY = 21
765 // Player summoning auto-decline time (in secs)
766 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
767 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
769 struct InstancePlayerBind
771 InstanceSave *save;
772 bool perm;
773 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
774 that aren't already permanently bound when they are inside when a boss is killed
775 or when they enter an instance that the group leader is permanently bound to. */
776 InstancePlayerBind() : save(NULL), perm(false) {}
779 class MANGOS_DLL_SPEC PlayerTaxi
781 public:
782 PlayerTaxi();
783 ~PlayerTaxi() {}
784 // Nodes
785 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level);
786 void LoadTaxiMask(const char* data);
788 bool IsTaximaskNodeKnown(uint32 nodeidx) const
790 uint8 field = uint8((nodeidx - 1) / 32);
791 uint32 submask = 1<<((nodeidx-1)%32);
792 return (m_taximask[field] & submask) == submask;
794 bool SetTaximaskNode(uint32 nodeidx)
796 uint8 field = uint8((nodeidx - 1) / 32);
797 uint32 submask = 1<<((nodeidx-1)%32);
798 if ((m_taximask[field] & submask) != submask )
800 m_taximask[field] |= submask;
801 return true;
803 else
804 return false;
806 void AppendTaximaskTo(ByteBuffer& data,bool all);
808 // Destinations
809 bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team);
810 std::string SaveTaxiDestinationsToString();
812 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
813 void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
814 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
815 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
816 uint32 GetCurrentTaxiPath() const;
817 uint32 NextTaxiDestination()
819 m_TaxiDestinations.pop_front();
820 return GetTaxiDestination();
822 bool empty() const { return m_TaxiDestinations.empty(); }
824 friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
825 private:
826 TaxiMask m_taximask;
827 std::deque<uint32> m_TaxiDestinations;
830 std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
832 class MANGOS_DLL_SPEC Player : public Unit
834 friend class WorldSession;
835 friend void Item::AddToUpdateQueueOf(Player *player);
836 friend void Item::RemoveFromUpdateQueueOf(Player *player);
837 public:
838 explicit Player (WorldSession *session);
839 ~Player ( );
841 void CleanupsBeforeDelete();
843 static UpdateMask updateVisualBits;
844 static void InitVisibleBits();
846 void AddToWorld();
847 void RemoveFromWorld();
849 bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
851 bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
853 return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options);
856 void SetSummonPoint(uint32 mapid, float x, float y, float z)
858 m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
859 m_summon_mapid = mapid;
860 m_summon_x = x;
861 m_summon_y = y;
862 m_summon_z = z;
864 void SummonIfPossible(bool agree);
866 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 );
868 void Update( uint32 time );
870 void BuildEnumData( QueryResult * result, WorldPacket * p_data );
872 void SetInWater(bool apply);
874 bool IsInWater() const { return m_isInWater; }
875 bool IsUnderWater() const;
877 void SendInitialPacketsBeforeAddToMap();
878 void SendInitialPacketsAfterAddToMap();
879 void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0);
880 void SendInstanceResetWarning(uint32 mapid, uint32 time);
882 bool CanInteractWithNPCs(bool alive = true) const;
884 bool ToggleAFK();
885 bool ToggleDND();
886 bool isAFK() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_AFK); };
887 bool isDND() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_DND); };
888 uint8 chatTag() const;
889 std::string afkMsg;
890 std::string dndMsg;
892 uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
894 PlayerSocial *GetSocial() { return m_social; }
896 PlayerTaxi m_taxi;
897 void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
898 bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, uint32 mount_id = 0 , Creature* npc = NULL);
899 // mount_id can be used in scripting calls
900 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); }
901 void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; }
902 bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
903 void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
904 bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
905 void SetGameMaster(bool on);
906 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); }
907 void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
908 bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
909 void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
910 bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
911 void SetGMVisible(bool on);
912 void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
914 void GiveXP(uint32 xp, Unit* victim);
915 void GiveLevel(uint32 level);
916 void InitStatsForLevel(bool reapplyMods = false);
918 // Played Time Stuff
919 time_t m_logintime;
920 time_t m_Last_tick;
921 uint32 m_Played_time[2];
922 uint32 GetTotalPlayedTime() { return m_Played_time[0]; };
923 uint32 GetLevelPlayedTime() { return m_Played_time[1]; };
925 void setDeathState(DeathState s); // overwrite Unit::setDeathState
927 void InnEnter (int time,uint32 mapid, float x,float y,float z)
929 inn_pos_mapid = mapid;
930 inn_pos_x = x;
931 inn_pos_y = y;
932 inn_pos_z = z;
933 time_inn_enter = time;
936 float GetRestBonus() const { return m_rest_bonus; };
937 void SetRestBonus(float rest_bonus_new);
939 RestType GetRestType() const { return rest_type; };
940 void SetRestType(RestType n_r_type) { rest_type = n_r_type; };
942 uint32 GetInnPosMapId() const { return inn_pos_mapid; };
943 float GetInnPosX() const { return inn_pos_x; };
944 float GetInnPosY() const { return inn_pos_y; };
945 float GetInnPosZ() const { return inn_pos_z; };
947 int GetTimeInnEnter() const { return time_inn_enter; };
948 void UpdateInnerTime (int time) { time_inn_enter = time; };
950 void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
951 void RemoveMiniPet();
952 Pet* GetMiniPet();
953 void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); }
954 void RemoveGuardians();
955 bool HasGuardianWithEntry(uint32 entry);
956 void AddGuardian(Pet* pet) { m_guardianPets.insert(pet->GetGUID()); }
957 GuardianPetList const& GetGuardians() const { return m_guardianPets; }
958 void Uncharm();
959 uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
961 void Say(const std::string& text, const uint32 language);
962 void Yell(const std::string& text, const uint32 language);
963 void TextEmote(const std::string& text);
964 void Whisper(const std::string& text, const uint32 language,uint64 receiver);
965 void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
967 /*********************************************************/
968 /*** STORAGE SYSTEM ***/
969 /*********************************************************/
971 void SetVirtualItemSlot( uint8 i, Item* item);
972 void SetSheath( uint32 sheathed );
973 uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const;
974 uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const;
975 Item* GetItemByGuid( uint64 guid ) const;
976 Item* GetItemByPos( uint16 pos ) const;
977 Item* GetItemByPos( uint8 bag, uint8 slot ) const;
978 Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const;
979 Item* GetShield(bool useable = false) const;
980 static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot
981 std::vector<Item *> &GetItemUpdateQueue() { return m_itemUpdateQueue; }
982 static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8,pos & 255); }
983 static bool IsInventoryPos( uint8 bag, uint8 slot );
984 static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8,pos & 255); }
985 static bool IsEquipmentPos( uint8 bag, uint8 slot );
986 static bool IsBagPos( uint16 pos );
987 static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
988 static bool IsBankPos( uint8 bag, uint8 slot );
989 bool IsValidPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
990 bool IsValidPos( uint8 bag, uint8 slot );
991 bool HasBankBagSlot( uint8 slot ) const;
992 bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
993 bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL);
994 bool CanNoReagentCast(SpellEntry const* spellInfo) const;
995 bool HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
996 bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
997 uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(),pItem->GetCount(),pItem); }
998 uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry,count,NULL); }
999 uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
1001 return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count );
1003 uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
1005 if(!pItem)
1006 return EQUIP_ERR_ITEM_NOT_FOUND;
1007 uint32 count = pItem->GetCount();
1008 return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL );
1011 uint8 CanStoreItems( Item **pItem,int count) const;
1012 uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
1013 uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
1015 uint8 CanEquipUniqueItem( Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
1016 uint8 CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
1017 uint8 CanUnequipItems( uint32 item, uint32 count ) const;
1018 uint8 CanUnequipItem( uint16 src, bool swap ) const;
1019 uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
1020 uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
1021 bool HasItemTotemCategory( uint32 TotemCategory ) const;
1022 bool CanUseItem( ItemPrototype const *pItem );
1023 uint8 CanUseAmmo( uint32 item ) const;
1024 Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
1025 Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
1026 Item* EquipNewItem( uint16 pos, uint32 item, bool update );
1027 Item* EquipItem( uint16 pos, Item *pItem, bool update );
1028 void AutoUnequipOffhandIfNeed();
1029 bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
1030 void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false);
1031 void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG,NULL_SLOT,loot_id,store,broadcast); }
1033 uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
1034 uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
1036 void ApplyEquipCooldown( Item * pItem );
1037 void SetAmmo( uint32 item );
1038 void RemoveAmmo();
1039 float GetAmmoDPS() const { return m_ammoDPS; }
1040 bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const;
1041 void QuickEquipItem( uint16 pos, Item *pItem);
1042 void VisualizeItem( uint8 slot, Item *pItem);
1043 void SetVisibleItemSlot(uint8 slot, Item *pItem);
1044 Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update )
1046 return StoreItem( dest, pItem, update);
1048 Item* BankItem( uint16 pos, Item *pItem, bool update );
1049 void RemoveItem( uint8 bag, uint8 slot, bool update );
1050 void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
1051 // in trade, auction, guild bank, mail....
1052 void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
1053 // in trade, guild bank, mail....
1054 void RemoveItemDependentAurasAndCasts( Item * pItem );
1055 void DestroyItem( uint8 bag, uint8 slot, bool update );
1056 void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
1057 void DestroyItemCount( Item* item, uint32& count, bool update );
1058 void DestroyConjuredItems( bool update );
1059 void DestroyZoneLimitedItem( bool update, uint32 new_zone );
1060 void SplitItem( uint16 src, uint16 dst, uint32 count );
1061 void SwapItem( uint16 src, uint16 dst );
1062 void AddItemToBuyBackSlot( Item *pItem );
1063 Item* GetItemFromBuyBackSlot( uint32 slot );
1064 void RemoveItemFromBuyBackSlot( uint32 slot, bool del );
1065 uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
1066 void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 );
1067 void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
1068 void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
1069 void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
1070 void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
1071 uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
1072 uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
1073 bool IsUseEquipedWeapon( bool mainhand ) const
1075 // disarm applied only to mainhand weapon
1076 return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) );
1078 bool IsTwoHandUsed() const
1080 Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
1081 return mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
1083 void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false );
1084 bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot);
1086 float GetReputationPriceDiscount( Creature const* pCreature ) const;
1087 Player* GetTrader() const { return pTrader; }
1088 void ClearTrade();
1089 void TradeCancel(bool sendback);
1090 uint16 GetItemPosByTradeSlot(uint32 slot) const { return tradeItems[slot]; }
1092 void UpdateEnchantTime(uint32 time);
1093 void UpdateItemDuration(uint32 time, bool realtimeonly=false);
1094 void AddEnchantmentDurations(Item *item);
1095 void RemoveEnchantmentDurations(Item *item);
1096 void RemoveAllEnchantments(EnchantmentSlot slot);
1097 void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration);
1098 void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false);
1099 void ApplyEnchantment(Item *item,bool apply);
1100 void SendEnchantmentDurations();
1101 void AddItemDurations(Item *item);
1102 void RemoveItemDurations(Item *item);
1103 void SendItemDurations();
1104 void LoadCorpse();
1105 void LoadPet();
1107 uint32 m_stableSlots;
1109 /*********************************************************/
1110 /*** QUEST SYSTEM ***/
1111 /*********************************************************/
1113 uint32 GetQuestLevel( Quest const* pQuest ) const { return pQuest && pQuest->GetQuestLevel() ? pQuest->GetQuestLevel() : getLevel(); }
1115 void PrepareQuestMenu( uint64 guid );
1116 void SendPreparedQuest( uint64 guid );
1117 bool IsActiveQuest( uint32 quest_id ) const;
1118 Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
1119 bool CanSeeStartQuest( Quest const *pQuest );
1120 bool CanTakeQuest( Quest const *pQuest, bool msg );
1121 bool CanAddQuest( Quest const *pQuest, bool msg );
1122 bool CanCompleteQuest( uint32 quest_id );
1123 bool CanCompleteRepeatableQuest(Quest const *pQuest);
1124 bool CanRewardQuest( Quest const *pQuest, bool msg );
1125 bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg );
1126 void AddQuest( Quest const *pQuest, Object *questGiver );
1127 void CompleteQuest( uint32 quest_id );
1128 void IncompleteQuest( uint32 quest_id );
1129 void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
1130 void FailQuest( uint32 quest_id );
1131 void FailTimedQuest( uint32 quest_id );
1132 bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg );
1133 bool SatisfyQuestLevel( Quest const* qInfo, bool msg );
1134 bool SatisfyQuestLog( bool msg );
1135 bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg );
1136 bool SatisfyQuestRace( Quest const* qInfo, bool msg );
1137 bool SatisfyQuestReputation( Quest const* qInfo, bool msg );
1138 bool SatisfyQuestStatus( Quest const* qInfo, bool msg );
1139 bool SatisfyQuestTimed( Quest const* qInfo, bool msg );
1140 bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg );
1141 bool SatisfyQuestNextChain( Quest const* qInfo, bool msg );
1142 bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg );
1143 bool SatisfyQuestDay( Quest const* qInfo, bool msg );
1144 bool GiveQuestSourceItem( Quest const *pQuest );
1145 bool TakeQuestSourceItem( uint32 quest_id, bool msg );
1146 bool GetQuestRewardStatus( uint32 quest_id ) const;
1147 QuestStatus GetQuestStatus( uint32 quest_id ) const;
1148 void SetQuestStatus( uint32 quest_id, QuestStatus status );
1150 void SetDailyQuestStatus( uint32 quest_id );
1151 void ResetDailyQuestStatus();
1153 uint16 FindQuestSlot( uint32 quest_id ) const;
1154 uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
1155 uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
1156 uint32 GetQuestSlotCounters(uint16 slot)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); }
1157 uint8 GetQuestSlotCounter(uint16 slot,uint8 counter) const { return GetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter); }
1158 uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
1159 void SetQuestSlot(uint16 slot,uint32 quest_id, uint32 timer = 0)
1161 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET,quest_id);
1162 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,0);
1163 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,0);
1164 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer);
1166 void SetQuestSlotCounter(uint16 slot,uint8 counter,uint8 count) { SetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter,count); }
1167 void SetQuestSlotState(uint16 slot,uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1168 void RemoveQuestSlotState(uint16 slot,uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1169 void SetQuestSlotTimer(uint16 slot,uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); }
1170 void SwapQuestSlot(uint16 slot1,uint16 slot2)
1172 for (int i = 0; i < MAX_QUEST_OFFSET ; ++i )
1174 uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i);
1175 uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i);
1177 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i, temp2);
1178 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i, temp1);
1181 uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
1182 void AreaExploredOrEventHappens( uint32 questId );
1183 void GroupEventHappens( uint32 questId, WorldObject const* pEventObject );
1184 void ItemAddedQuestCheck( uint32 entry, uint32 count );
1185 void ItemRemovedQuestCheck( uint32 entry, uint32 count );
1186 void KilledMonster( uint32 entry, uint64 guid );
1187 void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id );
1188 void TalkedToCreature( uint32 entry, uint64 guid );
1189 void MoneyChanged( uint32 value );
1190 void ReputationChanged(FactionEntry const* factionEntry );
1191 bool HasQuestForItem( uint32 itemid ) const;
1192 bool HasQuestForGO(int32 GOId) const;
1193 void UpdateForQuestsGO();
1194 bool CanShareQuest(uint32 quest_id) const;
1196 void SendQuestComplete( uint32 quest_id );
1197 void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
1198 void SendQuestFailed( uint32 quest_id );
1199 void SendQuestTimerFailed( uint32 quest_id );
1200 void SendCanTakeQuestResponse( uint32 msg );
1201 void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
1202 void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
1203 void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count );
1205 uint64 GetDivider() { return m_divider; };
1206 void SetDivider( uint64 guid ) { m_divider = guid; };
1208 uint32 GetInGameTime() { return m_ingametime; };
1210 void SetInGameTime( uint32 time ) { m_ingametime = time; };
1212 void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); }
1214 /*********************************************************/
1215 /*** LOAD SYSTEM ***/
1216 /*********************************************************/
1218 bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
1220 bool MinimalLoadFromDB(QueryResult *result, uint32 guid);
1221 static bool LoadValuesArrayFromDB(Tokens& data,uint64 guid);
1222 static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
1223 static float GetFloatValueFromArray(Tokens const& data, uint16 index);
1224 static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid);
1225 static float GetFloatValueFromDB(uint16 index, uint64 guid);
1226 static uint32 GetZoneIdFromDB(uint64 guid);
1227 static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
1229 /*********************************************************/
1230 /*** SAVE SYSTEM ***/
1231 /*********************************************************/
1233 void SaveToDB();
1234 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1235 void SaveDataFieldToDB();
1236 static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
1237 static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value);
1238 static void SetFloatValueInArray(Tokens& data,uint16 index, float value);
1239 static void SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid);
1240 static void SetFloatValueInDB(uint16 index, float value, uint64 guid);
1241 static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
1242 static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid);
1244 bool m_mailsLoaded;
1245 bool m_mailsUpdated;
1247 void SetBindPoint(uint64 guid);
1248 void SendTalentWipeConfirm(uint64 guid);
1249 void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
1250 void SendPetSkillWipeConfirm();
1251 void CalcRage( uint32 damage,bool attacker );
1252 void RegenerateAll();
1253 void Regenerate(Powers power);
1254 void RegenerateHealth();
1255 void setRegenTimer(uint32 time) {m_regenTimer = time;}
1256 void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
1258 uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
1259 void ModifyMoney( int32 d )
1261 if(d < 0)
1262 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
1263 else
1264 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
1266 // "At Gold Limit"
1267 if(GetMoney() >= MAX_MONEY_AMOUNT)
1268 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL);
1270 void SetMoney( uint32 value )
1272 SetUInt32Value (PLAYER_FIELD_COINAGE, value);
1273 MoneyChanged( value );
1276 uint32 GetTutorialInt(uint32 intId )
1278 ASSERT( (intId < 8) );
1279 return m_Tutorials[intId];
1282 void SetTutorialInt(uint32 intId, uint32 value)
1284 ASSERT( (intId < 8) );
1285 if(m_Tutorials[intId]!=value)
1287 m_Tutorials[intId] = value;
1288 m_TutorialsChanged = true;
1292 QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
1294 const uint64& GetSelection( ) const { return m_curSelection; }
1295 void SetSelection(const uint64 &guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); }
1297 uint8 GetComboPoints() { return m_comboPoints; }
1298 const uint64& GetComboTarget() const { return m_comboTarget; }
1300 void AddComboPoints(Unit* target, int8 count);
1301 void ClearComboPoints();
1302 void SendComboPoints();
1304 void SendMailResult(uint32 mailId, uint32 mailAction, uint32 mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0);
1305 void SendNewMail();
1306 void UpdateNextMailTimeAndUnreads();
1307 void AddNewMailDeliverTime(time_t deliver_time);
1308 bool IsMailsLoaded() const { return m_mailsLoaded; }
1310 //void SetMail(Mail *m);
1311 void RemoveMail(uint32 id);
1313 void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
1314 uint32 GetMailSize() { return m_mail.size();};
1315 Mail* GetMail(uint32 id);
1317 PlayerMails::iterator GetmailBegin() { return m_mail.begin();};
1318 PlayerMails::iterator GetmailEnd() { return m_mail.end();};
1320 /*********************************************************/
1321 /*** MAILED ITEMS SYSTEM ***/
1322 /*********************************************************/
1324 uint8 unReadMails;
1325 time_t m_nextMailDelivereTime;
1327 typedef UNORDERED_MAP<uint32, Item*> ItemMap;
1329 ItemMap mMitems; //template defined in objectmgr.cpp
1331 Item* GetMItem(uint32 id)
1333 ItemMap::const_iterator itr = mMitems.find(id);
1334 return itr != mMitems.end() ? itr->second : NULL;
1337 void AddMItem(Item* it)
1339 ASSERT( it );
1340 //assert deleted, because items can be added before loading
1341 mMitems[it->GetGUIDLow()] = it;
1344 bool RemoveMItem(uint32 id)
1346 return mMitems.erase(id) ? true : false;
1349 void PetSpellInitialize();
1350 void CharmSpellInitialize();
1351 void PossessSpellInitialize();
1352 bool HasSpell(uint32 spell) const;
1353 bool HasActiveSpell(uint32 spell) const; // show in spellbook
1354 TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
1355 bool IsSpellFitByClassAndRace( uint32 spell_id ) const;
1356 bool IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const;
1358 void SendProficiency(uint8 pr1, uint32 pr2);
1359 void SendInitialSpells();
1360 bool addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled);
1361 void learnSpell(uint32 spell_id, bool dependent);
1362 void removeSpell(uint32 spell_id, bool disabled = false, bool update_action_bar_for_low_rank = false);
1363 void resetSpells();
1364 void learnDefaultSpells();
1365 void learnQuestRewardedSpells();
1366 void learnQuestRewardedSpells(Quest const* quest);
1367 void learnSpellHighRank(uint32 spellid);
1369 uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
1370 void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
1371 bool resetTalents(bool no_cost = false);
1372 uint32 resetTalentsCost() const;
1373 void InitTalentForLevel();
1375 void LearnTalent(uint32 talentId, uint32 talentRank);
1376 void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank);
1378 uint32 CalculateTalentsPoints() const;
1380 void InitGlyphsForLevel();
1381 void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); }
1382 uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); }
1383 void SetGlyph(uint8 slot, uint32 glyph) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); }
1384 uint32 GetGlyph(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot); }
1386 uint32 GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); }
1387 void SetFreePrimaryProffesions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2,profs); }
1388 void InitPrimaryProffesions();
1390 PlayerSpellMap const& GetSpellMap() const { return m_spells; }
1391 PlayerSpellMap & GetSpellMap() { return m_spells; }
1393 void AddSpellMod(SpellModifier* mod, bool apply);
1394 bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL);
1395 template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL);
1396 void RemoveSpellMods(Spell const* spell);
1398 bool HasSpellCooldown(uint32 spell_id) const
1400 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1401 return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
1403 uint32 GetSpellCooldownDelay(uint32 spell_id) const
1405 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1406 time_t t = time(NULL);
1407 return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
1409 void AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false );
1410 void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
1411 void SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId = 0, Spell* spell = NULL);
1412 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs );
1413 void RemoveSpellCooldown(uint32 spell_id) { m_spellCooldowns.erase(spell_id); }
1414 void RemoveArenaSpellCooldowns();
1415 void RemoveAllSpellCooldown();
1416 void _LoadSpellCooldowns(QueryResult *result);
1417 void _SaveSpellCooldowns();
1418 void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
1419 void UpdatePotionCooldown(Spell* spell = NULL);
1421 void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
1423 m_resurrectGUID = guid;
1424 m_resurrectMap = mapId;
1425 m_resurrectX = X;
1426 m_resurrectY = Y;
1427 m_resurrectZ = Z;
1428 m_resurrectHealth = health;
1429 m_resurrectMana = mana;
1431 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); }
1432 bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; }
1433 bool isRessurectRequested() const { return m_resurrectGUID != 0; }
1434 void ResurectUsingRequestData();
1436 int getCinematic()
1438 return m_cinematic;
1440 void setCinematic(int cine)
1442 m_cinematic = cine;
1445 bool addActionButton(uint8 button, uint16 action, uint8 type, uint8 misc);
1446 void removeActionButton(uint8 button);
1447 void SendInitialActionButtons();
1449 PvPInfo pvpInfo;
1450 void UpdatePvP(bool state, bool ovrride=false);
1451 void UpdateZone(uint32 newZone,uint32 newArea);
1452 void UpdateArea(uint32 newArea);
1454 void UpdateZoneDependentAuras( uint32 zone_id ); // zones
1455 void UpdateAreaDependentAuras( uint32 area_id ); // subzones
1457 void UpdateAfkReport(time_t currTime);
1458 void UpdatePvPFlag(time_t currTime);
1459 void UpdateContestedPvP(uint32 currTime);
1460 void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
1461 void ResetContestedPvP()
1463 clearUnitState(UNIT_STAT_ATTACK_PLAYER);
1464 RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
1465 m_contestedPvPTimer = 0;
1468 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1469 DuelInfo *duel;
1470 void UpdateDuelFlag(time_t currTime);
1471 void CheckDuelDistance(time_t currTime);
1472 void DuelComplete(DuelCompleteType type);
1474 bool IsGroupVisibleFor(Player* p) const;
1475 bool IsInSameGroupWith(Player const* p) const;
1476 bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
1477 void UninviteFromGroup();
1478 static void RemoveFromGroup(Group* group, uint64 guid);
1479 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1480 void SendUpdateToOutOfRangeGroupMembers();
1482 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
1483 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
1484 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
1485 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
1486 static uint32 GetGuildIdFromDB(uint64 guid);
1487 uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
1488 static uint32 GetRankFromDB(uint64 guid);
1489 int GetGuildIdInvited() { return m_GuildIdInvited; }
1490 static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
1492 // Arena Team
1493 void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot)
1495 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId);
1497 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); }
1498 static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
1499 void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
1500 uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
1501 static void LeaveAllArenaTeams(uint64 guid);
1503 void SetDifficulty(uint32 dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; }
1504 uint8 GetDifficulty() { return m_dungeonDifficulty; }
1506 bool UpdateSkill(uint32 skill_id, uint32 step);
1507 bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step);
1509 bool UpdateCraftSkill(uint32 spellid);
1510 bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1);
1511 bool UpdateFishingSkill();
1513 uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); }
1514 uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const;
1516 uint32 GetSpellByProto(ItemPrototype *proto);
1518 float GetHealthBonusFromStamina();
1519 float GetManaBonusFromIntellect();
1521 bool UpdateStats(Stats stat);
1522 bool UpdateAllStats();
1523 void UpdateResistances(uint32 school);
1524 void UpdateArmor();
1525 void UpdateMaxHealth();
1526 void UpdateMaxPower(Powers power);
1527 void ApplyFeralAPBonus(int32 amount, bool apply);
1528 void UpdateAttackPowerAndDamage(bool ranged = false);
1529 void UpdateShieldBlockValue();
1530 void UpdateDamagePhysical(WeaponAttackType attType);
1531 void ApplySpellDamageBonus(int32 amount, bool apply);
1532 void ApplySpellHealingBonus(int32 amount, bool apply);
1533 void UpdateSpellDamageAndHealingBonus();
1535 void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage);
1537 void UpdateDefenseBonusesMod();
1538 void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
1539 float GetMeleeCritFromAgility();
1540 float GetDodgeFromAgility();
1541 float GetSpellCritFromIntellect();
1542 float OCTRegenHPPerSpirit();
1543 float OCTRegenMPPerSpirit();
1544 float GetRatingCoefficient(CombatRating cr) const;
1545 float GetRatingBonusValue(CombatRating cr) const;
1546 uint32 GetMeleeCritDamageReduction(uint32 damage) const;
1547 uint32 GetRangedCritDamageReduction(uint32 damage) const;
1548 uint32 GetSpellCritDamageReduction(uint32 damage) const;
1549 uint32 GetDotDamageReduction(uint32 damage) const;
1550 uint32 GetBaseSpellDamageBonus() { return m_baseSpellDamage;}
1551 uint32 GetBaseSpellHealingBonus() { return m_baseSpellHealing;}
1553 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
1554 void UpdateBlockPercentage();
1555 void UpdateCritPercentage(WeaponAttackType attType);
1556 void UpdateAllCritPercentages();
1557 void UpdateParryPercentage();
1558 void UpdateDodgePercentage();
1559 void UpdateMeleeHitChances();
1560 void UpdateRangedHitChances();
1561 void UpdateSpellHitChances();
1563 void UpdateAllSpellCritChances();
1564 void UpdateSpellCritChance(uint32 school);
1565 void UpdateExpertise(WeaponAttackType attType);
1566 void ApplyManaRegenBonus(int32 amount, bool apply);
1567 void UpdateManaRegen();
1569 const uint64& GetLootGUID() const { return m_lootGuid; }
1570 void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; }
1572 void RemovedInsignia(Player* looterPlr);
1574 WorldSession* GetSession() const { return m_session; }
1575 void SetSession(WorldSession *s) { m_session = s; }
1577 void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const;
1578 void DestroyForPlayer( Player *target ) const;
1579 void SendDelayResponse(const uint32);
1580 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
1582 //notifiers
1583 void SendAttackSwingCantAttack();
1584 void SendAttackSwingCancelAttack();
1585 void SendAttackSwingDeadTarget();
1586 void SendAttackSwingNotStanding();
1587 void SendAttackSwingNotInRange();
1588 void SendAttackSwingBadFacingAttack();
1589 void SendAutoRepeatCancel();
1590 void SendExplorationExperience(uint32 Area, uint32 Experience);
1592 void SendDungeonDifficulty(bool IsInGroup);
1593 void ResetInstances(uint8 method);
1594 void SendResetInstanceSuccess(uint32 MapId);
1595 void SendResetInstanceFailed(uint32 reason, uint32 MapId);
1596 void SendResetFailedNotify(uint32 mapid);
1598 bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
1599 void UpdateUnderwaterState( Map * m, float x, float y, float z );
1601 void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet
1602 void SendMessageToSetInRange(WorldPacket *data, float fist, bool self);
1603 // overwrite Object::SendMessageToSetInRange
1604 void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only);
1606 static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true);
1608 Corpse *GetCorpse() const;
1609 void SpawnCorpseBones();
1610 void CreateCorpse();
1611 void KillPlayer();
1612 uint32 GetResurrectionSpellId();
1613 void ResurrectPlayer(float restore_percent, bool applySickness = false);
1614 void BuildPlayerRepop();
1615 void RepopAtGraveyard();
1617 void DurabilityLossAll(double percent, bool inventory);
1618 void DurabilityLoss(Item* item, double percent);
1619 void DurabilityPointsLossAll(int32 points, bool inventory);
1620 void DurabilityPointsLoss(Item* item, int32 points);
1621 void DurabilityPointLossForEquipSlot(EquipmentSlots slot);
1622 uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank);
1623 uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank);
1625 void UpdateMirrorTimers();
1626 void StopMirrorTimers()
1628 StopMirrorTimer(FATIGUE_TIMER);
1629 StopMirrorTimer(BREATH_TIMER);
1630 StopMirrorTimer(FIRE_TIMER);
1633 void SetMovement(PlayerMovementType pType);
1635 void JoinedChannel(Channel *c);
1636 void LeftChannel(Channel *c);
1637 void CleanupChannels();
1638 void UpdateLocalChannels( uint32 newZone );
1639 void LeaveLFGChannel();
1641 void UpdateDefense();
1642 void UpdateWeaponSkill (WeaponAttackType attType);
1643 void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence);
1645 void SetSkill(uint32 id, uint16 currVal, uint16 maxVal);
1646 uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
1647 uint16 GetPureMaxSkillValue(uint32 skill) const; // max
1648 uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
1649 uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus
1650 uint16 GetPureSkillValue(uint32 skill) const; // skill value
1651 int16 GetSkillPermBonusValue(uint32 skill) const;
1652 int16 GetSkillTempBonusValue(uint32 skill) const;
1653 bool HasSkill(uint32 skill) const;
1654 void learnSkillRewardedSpells(uint32 id, uint32 value);
1656 void SetDontMove(bool dontMove);
1657 bool GetDontMove() const { return m_dontMove; }
1659 void CheckExploreSystem(void);
1661 static uint32 TeamForRace(uint8 race);
1662 uint32 GetTeam() const { return m_team; }
1663 static uint32 getFactionForRace(uint8 race);
1664 void setFactionForRace(uint8 race);
1666 bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
1667 bool RewardPlayerAndGroupAtKill(Unit* pVictim);
1668 void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
1669 bool isHonorOrXPTarget(Unit* pVictim);
1671 ReputationMgr& GetReputationMgr() { return m_reputationMgr; }
1672 ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; }
1673 ReputationRank GetReputationRank(uint32 faction_id) const;
1674 void RewardReputation(Unit *pVictim, float rate);
1675 void RewardReputation(Quest const *pQuest);
1677 void UpdateSkillsForLevel();
1678 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1679 void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
1681 /*********************************************************/
1682 /*** PVP SYSTEM ***/
1683 /*********************************************************/
1684 void UpdateArenaFields();
1685 void UpdateHonorFields();
1686 bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1);
1687 uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
1688 uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
1689 void ModifyHonorPoints( int32 value );
1690 void ModifyArenaPoints( int32 value );
1691 uint32 GetMaxPersonalArenaRatingRequirement();
1693 //End of PvP System
1695 void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0);
1696 uint16 GetDrunkValue() const { return m_drunk; }
1697 static DrunkenState GetDrunkenstateByValue(uint16 value);
1699 uint32 GetDeathTimer() const { return m_deathTimer; }
1700 uint32 GetCorpseReclaimDelay(bool pvp) const;
1701 void UpdateCorpseReclaimDelay();
1702 void SendCorpseReclaimDelay(bool load = false);
1704 uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual)
1705 bool CanParry() const { return m_canParry; }
1706 void SetCanParry(bool value);
1707 bool CanBlock() const { return m_canBlock; }
1708 void SetCanBlock(bool value);
1709 bool CanDualWield() const { return m_canDualWield; }
1710 void SetCanDualWield(bool value) { m_canDualWield = value; }
1711 bool CanTitanGrip() const { return m_canTitanGrip ; }
1712 void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
1714 void SetRegularAttackTime();
1715 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }
1716 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply);
1717 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
1718 float GetTotalBaseModValue(BaseModGroup modGroup) const;
1719 float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; }
1720 void _ApplyAllStatBonuses();
1721 void _RemoveAllStatBonuses();
1723 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
1724 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1725 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1727 void _ApplyItemMods(Item *item,uint8 slot,bool apply);
1728 void _RemoveAllItemMods();
1729 void _ApplyAllItemMods();
1730 void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply);
1731 void _ApplyAmmoBonuses();
1732 bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot);
1733 void ToggleMetaGemsActive(uint8 exceptslot, bool apply);
1734 void CorrectMetaGemEnchants(uint8 slot, bool apply);
1735 void InitDataForForm(bool reapplyMods = false);
1737 void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
1738 void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
1739 void UpdateEquipSpellsAtFormChange();
1740 void CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType);
1741 void CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex);
1743 void SendInitWorldStates(uint32 zone, uint32 area);
1744 void SendUpdateWorldState(uint32 Field, uint32 Value);
1745 void SendDirectMessage(WorldPacket *data);
1747 void SendAurasForTarget(Unit *target);
1749 PlayerMenu* PlayerTalkClass;
1750 std::vector<ItemSetEffect *> ItemSetEff;
1752 void SendLoot(uint64 guid, LootType loot_type);
1753 void SendLootRelease( uint64 guid );
1754 void SendNotifyLootItemRemoved(uint8 lootSlot);
1755 void SendNotifyLootMoneyRemoved();
1757 /*********************************************************/
1758 /*** BATTLEGROUND SYSTEM ***/
1759 /*********************************************************/
1761 bool InBattleGround() const { return m_bgBattleGroundID != 0; }
1762 bool InArena() const;
1763 uint32 GetBattleGroundId() const { return m_bgBattleGroundID; }
1764 BattleGroundTypeId GetBattleGroundTypeId() const { return m_bgTypeID; }
1765 BattleGround* GetBattleGround() const;
1768 BGQueueIdBasedOnLevel GetBattleGroundQueueIdFromLevel(BattleGroundTypeId bgTypeId) const;
1770 bool InBattleGroundQueue() const
1772 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1773 if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
1774 return true;
1775 return false;
1778 BattleGroundQueueTypeId GetBattleGroundQueueTypeId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueTypeId; }
1779 uint32 GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId) const
1781 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1782 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
1783 return i;
1784 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1786 bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
1788 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1789 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
1790 return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
1791 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1793 bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
1795 return GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES;
1798 void SetBattleGroundId(uint32 val, BattleGroundTypeId bgTypeId)
1800 m_bgBattleGroundID = val;
1801 m_bgTypeID = bgTypeId;
1803 uint32 AddBattleGroundQueueId(BattleGroundQueueTypeId val)
1805 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1807 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattleGroundQueueID[i].bgQueueTypeId == val)
1809 m_bgBattleGroundQueueID[i].bgQueueTypeId = val;
1810 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
1811 return i;
1814 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1816 bool HasFreeBattleGroundQueueId()
1818 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1819 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
1820 return true;
1821 return false;
1823 void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val)
1825 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1827 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == val)
1829 m_bgBattleGroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
1830 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
1831 return;
1835 void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId, uint32 instanceId)
1837 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1838 if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
1839 m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
1841 bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
1843 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1844 if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
1845 return true;
1846 return false;
1848 WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgEntryPoint; }
1849 void SetBattleGroundEntryPoint(uint32 Map, float PosX, float PosY, float PosZ, float PosO )
1851 m_bgEntryPoint = WorldLocation(Map,PosX,PosY,PosZ,PosO);
1854 void SetBGTeam(uint32 team) { m_bgTeam = team; }
1855 uint32 GetBGTeam() const { return m_bgTeam ? m_bgTeam : GetTeam(); }
1857 void LeaveBattleground(bool teleportToEntryPoint = true);
1858 bool CanJoinToBattleground() const;
1859 bool CanReportAfkDueToLimit();
1860 void ReportedAfkBy(Player* reporter);
1861 void ClearAfkReports() { m_bgAfkReporter.clear(); }
1863 bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const;
1864 bool CanUseBattleGroundObject();
1865 bool isTotalImmune();
1866 bool CanCaptureTowerPoint();
1868 /*********************************************************/
1869 /*** REST SYSTEM ***/
1870 /*********************************************************/
1872 bool isRested() const { return GetRestTime() >= 10*IN_MILISECONDS; }
1873 uint32 GetXPRestBonus(uint32 xp);
1874 uint32 GetRestTime() const { return m_restTime;};
1875 void SetRestTime(uint32 v) { m_restTime = v;};
1877 /*********************************************************/
1878 /*** ENVIROMENTAL SYSTEM ***/
1879 /*********************************************************/
1881 void EnvironmentalDamage(EnviromentalDamage type, uint32 damage);
1883 /*********************************************************/
1884 /*** FLOOD FILTER SYSTEM ***/
1885 /*********************************************************/
1887 void UpdateSpeakTime();
1888 bool CanSpeak() const;
1889 void ChangeSpeakTime(int utime);
1891 /*********************************************************/
1892 /*** VARIOUS SYSTEMS ***/
1893 /*********************************************************/
1894 MovementInfo m_movementInfo;
1895 void UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode);
1896 Unit *m_mover;
1897 void SetFallInformation(uint32 time, float z)
1899 m_lastFallTime = time;
1900 m_lastFallZ = z;
1902 void HandleFall(MovementInfo const& movementInfo);
1904 bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); }
1905 bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); }
1907 bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); }
1908 bool IsFlying() const { return HasUnitMovementFlag(MOVEMENTFLAG_FLYING); }
1909 bool IsAllowUseFlyMountsHere() const;
1911 void SetClientControl(Unit* target, uint8 allowMove);
1913 void EnterVehicle(Vehicle *vehicle);
1914 void ExitVehicle(Vehicle *vehicle);
1916 uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
1917 void SetFarSightGUID(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); }
1919 // Transports
1920 Transport * GetTransport() const { return m_transport; }
1921 void SetTransport(Transport * t) { m_transport = t; }
1923 float GetTransOffsetX() const { return m_movementInfo.t_x; }
1924 float GetTransOffsetY() const { return m_movementInfo.t_y; }
1925 float GetTransOffsetZ() const { return m_movementInfo.t_z; }
1926 float GetTransOffsetO() const { return m_movementInfo.t_o; }
1927 uint32 GetTransTime() const { return m_movementInfo.t_time; }
1928 int8 GetTransSeat() const { return m_movementInfo.t_seat; }
1930 uint32 GetSaveTimer() const { return m_nextSave; }
1931 void SetSaveTimer(uint32 timer) { m_nextSave = timer; }
1933 // Recall position
1934 uint32 m_recallMap;
1935 float m_recallX;
1936 float m_recallY;
1937 float m_recallZ;
1938 float m_recallO;
1939 void SaveRecallPosition();
1941 // Homebind coordinates
1942 uint32 m_homebindMapId;
1943 uint16 m_homebindZoneId;
1944 float m_homebindX;
1945 float m_homebindY;
1946 float m_homebindZ;
1947 void RelocateToHomebind() { SetMapId(m_homebindMapId); Relocate(m_homebindX,m_homebindY,m_homebindZ); }
1949 // currently visible objects at player client
1950 typedef std::set<uint64> ClientGUIDs;
1951 ClientGUIDs m_clientGUIDs;
1953 bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); }
1955 bool IsVisibleInGridForPlayer(Player* pl) const;
1956 bool IsVisibleGloballyFor(Player* pl) const;
1958 void UpdateVisibilityOf(WorldObject* target);
1960 template<class T>
1961 void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
1963 // Stealth detection system
1964 uint32 m_DetectInvTimer;
1965 void HandleStealthedUnitsDetection();
1967 uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
1969 bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; }
1970 void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
1972 LookingForGroup m_lookingForGroup;
1974 // Temporarily removed pet cache
1975 uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
1976 void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
1977 void UnsummonPetTemporaryIfAny();
1978 void ResummonPetTemporaryUnSummonedIfAny();
1979 bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
1981 void SendCinematicStart(uint32 CinematicSequenceId);
1982 void SendMovieStart(uint32 MovieId);
1984 /*********************************************************/
1985 /*** INSTANCE SYSTEM ***/
1986 /*********************************************************/
1988 typedef UNORDERED_MAP< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap;
1990 void UpdateHomebindTime(uint32 time);
1992 uint32 m_HomebindTimer;
1993 bool m_InstanceValid;
1994 // permanent binds and solo binds by difficulty
1995 BoundInstancesMap m_boundInstances[TOTAL_DIFFICULTIES];
1996 InstancePlayerBind* GetBoundInstance(uint32 mapid, uint8 difficulty);
1997 BoundInstancesMap& GetBoundInstances(uint8 difficulty) { return m_boundInstances[difficulty]; }
1998 void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false);
1999 void UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload = false);
2000 InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false);
2001 void SendRaidInfo();
2002 void SendSavedInstances();
2003 static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0);
2005 /*********************************************************/
2006 /*** GROUP SYSTEM ***/
2007 /*********************************************************/
2009 Group * GetGroupInvite() { return m_groupInvite; }
2010 void SetGroupInvite(Group *group) { m_groupInvite = group; }
2011 Group * GetGroup() { return m_group.getTarget(); }
2012 const Group * GetGroup() const { return (const Group*)m_group.getTarget(); }
2013 GroupReference& GetGroupRef() { return m_group; }
2014 void SetGroup(Group *group, int8 subgroup = -1);
2015 uint8 GetSubGroup() const { return m_group.getSubGroup(); }
2016 uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; }
2017 void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
2018 const uint64& GetAuraUpdateMask() const { return m_auraUpdateMask; }
2019 void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
2020 Player* GetNextRandomRaidMember(float radius);
2021 PartyResult CanUninviteFromGroup() const;
2022 // BattleGround Group System
2023 void SetBattleGroundRaid(Group *group, int8 subgroup = -1);
2024 void RemoveFromBattleGroundRaid();
2025 Group * GetOriginalGroup() { return m_originalGroup.getTarget(); }
2026 GroupReference& GetOriginalGroupRef() { return m_originalGroup; }
2027 uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); }
2028 void SetOriginalGroup(Group *group, int8 subgroup = -1);
2030 GridReference<Player> &GetGridRef() { return m_gridRef; }
2031 MapReference &GetMapRef() { return m_mapRef; }
2033 bool isAllowedToLoot(Creature* creature);
2035 WorldLocation& GetTeleportDest() { return m_teleport_dest; }
2037 DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
2038 uint8 GetRunesState() const { return m_runes->runeState; }
2039 uint8 GetBaseRune(uint8 index) const { return m_runes->runes[index].BaseRune; }
2040 uint8 GetCurrentRune(uint8 index) const { return m_runes->runes[index].CurrentRune; }
2041 uint8 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; }
2042 void SetBaseRune(uint8 index, uint8 baseRune) { m_runes->runes[index].BaseRune = baseRune; }
2043 void SetCurrentRune(uint8 index, uint8 currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
2044 void SetRuneCooldown(uint8 index, uint8 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); }
2045 void ConvertRune(uint8 index, uint8 newType);
2046 void ResyncRunes(uint8 count);
2047 void AddRunePower(uint8 index);
2048 void InitRunes();
2049 AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
2050 void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0);
2051 bool HasTitle(uint32 bitIndex);
2052 bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }
2053 void SetTitle(CharTitlesEntry const* title);
2055 bool isActiveObject() const { return true; }
2056 protected:
2058 /*********************************************************/
2059 /*** BATTLEGROUND SYSTEM ***/
2060 /*********************************************************/
2062 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2063 uint32 m_bgBattleGroundID;
2064 BattleGroundTypeId m_bgTypeID;
2066 this is an array of BG queues (BgTypeIDs) in which is player
2068 struct BgBattleGroundQueueID_Rec
2070 BattleGroundQueueTypeId bgQueueTypeId;
2071 uint32 invitedToInstance;
2073 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES];
2074 WorldLocation m_bgEntryPoint;
2076 std::set<uint32> m_bgAfkReporter;
2077 uint8 m_bgAfkReportedCount;
2078 time_t m_bgAfkReportedTimer;
2079 uint32 m_contestedPvPTimer;
2081 uint32 m_bgTeam; // what side the player will be added to
2083 /*********************************************************/
2084 /*** QUEST SYSTEM ***/
2085 /*********************************************************/
2087 std::set<uint32> m_timedquests;
2089 uint64 m_divider;
2090 uint32 m_ingametime;
2092 /*********************************************************/
2093 /*** LOAD SYSTEM ***/
2094 /*********************************************************/
2096 void _LoadActions(QueryResult *result);
2097 void _LoadAuras(QueryResult *result, uint32 timediff);
2098 void _LoadGlyphAuras();
2099 void _LoadBoundInstances(QueryResult *result);
2100 void _LoadInventory(QueryResult *result, uint32 timediff);
2101 void _LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery);
2102 void _LoadMail();
2103 void _LoadMailedItems(Mail *mail);
2104 void _LoadQuestStatus(QueryResult *result);
2105 void _LoadDailyQuestStatus(QueryResult *result);
2106 void _LoadGroup(QueryResult *result);
2107 void _LoadSkills();
2108 void _LoadSpells(QueryResult *result);
2109 void _LoadTutorials(QueryResult *result);
2110 void _LoadFriendList(QueryResult *result);
2111 bool _LoadHomeBind(QueryResult *result);
2112 void _LoadDeclinedNames(QueryResult *result);
2113 void _LoadArenaTeamInfo(QueryResult *result);
2115 /*********************************************************/
2116 /*** SAVE SYSTEM ***/
2117 /*********************************************************/
2119 void _SaveActions();
2120 void _SaveAuras();
2121 void _SaveInventory();
2122 void _SaveMail();
2123 void _SaveQuestStatus();
2124 void _SaveDailyQuestStatus();
2125 void _SaveSpells();
2126 void _SaveTutorials();
2128 void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
2129 void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
2131 /*********************************************************/
2132 /*** ENVIRONMENTAL SYSTEM ***/
2133 /*********************************************************/
2134 void HandleSobering();
2135 void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen);
2136 void StopMirrorTimer(MirrorTimerType Type);
2137 void HandleDrowning(uint32 time_diff);
2138 int32 getMaxTimer(MirrorTimerType timer);
2140 /*********************************************************/
2141 /*** HONOR SYSTEM ***/
2142 /*********************************************************/
2143 time_t m_lastHonorUpdateTime;
2145 void outDebugValues() const;
2146 uint64 m_lootGuid;
2148 uint32 m_race;
2149 uint32 m_class;
2150 uint32 m_team;
2151 uint32 m_nextSave;
2152 time_t m_speakTime;
2153 uint32 m_speakCount;
2154 uint32 m_dungeonDifficulty;
2156 uint32 m_atLoginFlags;
2158 Item* m_items[PLAYER_SLOTS_COUNT];
2159 uint32 m_currentBuybackSlot;
2161 std::vector<Item*> m_itemUpdateQueue;
2162 bool m_itemUpdateQueueBlocked;
2164 uint32 m_ExtraFlags;
2165 uint64 m_curSelection;
2167 uint64 m_comboTarget;
2168 int8 m_comboPoints;
2170 QuestStatusMap mQuestStatus;
2172 uint32 m_GuildIdInvited;
2173 uint32 m_ArenaTeamIdInvited;
2175 PlayerMails m_mail;
2176 PlayerSpellMap m_spells;
2177 SpellCooldowns m_spellCooldowns;
2178 uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use
2180 ActionButtonList m_actionButtons;
2182 float m_auraBaseMod[BASEMOD_END][MOD_END];
2183 int16 m_baseRatingValue[MAX_COMBAT_RATING];
2184 uint16 m_baseSpellDamage;
2185 uint16 m_baseSpellHealing;
2186 uint16 m_baseFeralAP;
2187 uint16 m_baseManaRegen;
2189 SpellModList m_spellMods[MAX_SPELLMOD];
2190 int32 m_SpellModRemoveCount;
2191 EnchantDurationList m_enchantDuration;
2192 ItemDurationList m_itemDuration;
2194 uint64 m_resurrectGUID;
2195 uint32 m_resurrectMap;
2196 float m_resurrectX, m_resurrectY, m_resurrectZ;
2197 uint32 m_resurrectHealth, m_resurrectMana;
2199 WorldSession *m_session;
2201 typedef std::list<Channel*> JoinedChannelsList;
2202 JoinedChannelsList m_channels;
2204 bool m_dontMove;
2206 int m_cinematic;
2208 Player *pTrader;
2209 bool acceptTrade;
2210 uint16 tradeItems[TRADE_SLOT_COUNT];
2211 uint32 tradeGold;
2213 time_t m_nextThinkTime;
2215 uint32 m_Tutorials[8];
2216 bool m_TutorialsChanged;
2218 bool m_DailyQuestChanged;
2219 time_t m_lastDailyQuestTime;
2221 uint32 m_drunkTimer;
2222 uint16 m_drunk;
2223 uint32 m_weaponChangeTimer;
2225 uint32 m_zoneUpdateId;
2226 uint32 m_zoneUpdateTimer;
2227 uint32 m_areaUpdateId;
2229 uint32 m_deathTimer;
2230 time_t m_deathExpireTime;
2232 uint32 m_restTime;
2234 uint32 m_WeaponProficiency;
2235 uint32 m_ArmorProficiency;
2236 bool m_canParry;
2237 bool m_canBlock;
2238 bool m_canDualWield;
2239 bool m_canTitanGrip;
2240 uint8 m_swingErrorMsg;
2241 float m_ammoDPS;
2243 ////////////////////Rest System/////////////////////
2244 int time_inn_enter;
2245 uint32 inn_pos_mapid;
2246 float inn_pos_x;
2247 float inn_pos_y;
2248 float inn_pos_z;
2249 float m_rest_bonus;
2250 RestType rest_type;
2251 ////////////////////Rest System/////////////////////
2253 // Transports
2254 Transport * m_transport;
2256 uint32 m_resetTalentsCost;
2257 time_t m_resetTalentsTime;
2258 uint32 m_usedTalentCount;
2259 uint32 m_questRewardTalentCount;
2261 // Social
2262 PlayerSocial *m_social;
2264 // Groups
2265 GroupReference m_group;
2266 GroupReference m_originalGroup;
2267 Group *m_groupInvite;
2268 uint32 m_groupUpdateMask;
2269 uint64 m_auraUpdateMask;
2271 // Temporarily removed pet cache
2272 uint32 m_temporaryUnsummonedPetNumber;
2273 uint32 m_oldpetspell;
2275 uint64 m_miniPet;
2276 GuardianPetList m_guardianPets;
2278 // Player summoning
2279 time_t m_summon_expire;
2280 uint32 m_summon_mapid;
2281 float m_summon_x;
2282 float m_summon_y;
2283 float m_summon_z;
2285 // Far Teleport
2286 WorldLocation m_teleport_dest;
2288 DeclinedName *m_declinedname;
2289 Runes *m_runes;
2290 private:
2291 // internal common parts for CanStore/StoreItem functions
2292 uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
2293 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;
2294 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;
2295 Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
2297 void UpdateKnownCurrencies(uint32 itemId, bool apply);
2298 int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest);
2299 void AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& questStatusData );
2301 GridReference<Player> m_gridRef;
2302 MapReference m_mapRef;
2304 uint32 m_lastFallTime;
2305 float m_lastFallZ;
2307 int32 m_MirrorTimer[MAX_TIMERS];
2308 uint8 m_MirrorTimerFlags;
2309 uint8 m_MirrorTimerFlagsLast;
2310 bool m_isInWater;
2312 AchievementMgr m_achievementMgr;
2313 ReputationMgr m_reputationMgr;
2316 void AddItemsSetItem(Player*player,Item *item);
2317 void RemoveItemsSetItem(Player*player,ItemPrototype const *proto);
2319 // "the bodies of template functions must be made available in a header file"
2320 template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell)
2322 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
2323 if (!spellInfo) return 0;
2324 int32 totalpct = 0;
2325 int32 totalflat = 0;
2326 for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
2328 SpellModifier *mod = *itr;
2330 if(!IsAffectedBySpellmod(spellInfo,mod,spell))
2331 continue;
2332 if (mod->type == SPELLMOD_FLAT)
2333 totalflat += mod->value;
2334 else if (mod->type == SPELLMOD_PCT)
2336 // skip percent mods for null basevalue (most important for spell mods with charges )
2337 if(basevalue == T(0))
2338 continue;
2340 // special case (skip >10sec spell casts for instant cast setting)
2341 if( mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10*IN_MILISECONDS) && mod->value <= -100)
2342 continue;
2344 totalpct += mod->value;
2347 if (mod->charges > 0 )
2349 --mod->charges;
2350 if (mod->charges == 0)
2352 mod->charges = -1;
2353 mod->lastAffected = spell;
2354 if(!mod->lastAffected)
2355 mod->lastAffected = FindCurrentSpellBySpellId(spellId);
2356 ++m_SpellModRemoveCount;
2361 float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat;
2362 basevalue = T((float)basevalue + diff);
2363 return T(diff);
2365 #endif