[7182] Finally remove vanity pet slots related code. Vanity pets stored as learned...
[getmangos.git] / src / game / Player.h
blobf1d16025e7faf847636ede4e6fed352366692b68
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"
38 #include<string>
39 #include<vector>
41 struct Mail;
42 class Channel;
43 class DynamicObject;
44 class Creature;
45 class Pet;
46 class PlayerMenu;
47 class Transport;
48 class UpdateMask;
49 class SpellCastTargets;
50 class PlayerSocial;
51 class AchievementMgr;
52 class Vehicle;
54 typedef std::deque<Mail*> PlayerMails;
56 #define PLAYER_MAX_SKILLS 127
57 #define PLAYER_MAX_DAILY_QUESTS 25
59 // Note: SPELLMOD_* values is aura types in fact
60 enum SpellModType
62 SPELLMOD_FLAT = 107, // SPELL_AURA_ADD_FLAT_MODIFIER
63 SPELLMOD_PCT = 108 // SPELL_AURA_ADD_PCT_MODIFIER
66 // 2^n values, Player::m_isunderwater is a bitmask. These are mangos internal values, they are never send to any client
67 enum PlayerUnderwaterState
69 UNDERWATER_NONE = 0x00,
70 UNDERWATER_INWATER = 0x01, // terrain type is water and player is afflicted by it
71 UNDERWATER_WATER_TRIGGER = 0x02, // m_breathTimer has been initialized
72 UNDERWATER_WATER_BREATHB = 0x04, // breathbar has been send to client
73 UNDERWATER_WATER_BREATHB_RETRACTING = 0x10, // breathbar is currently refilling - the player is above water level
74 UNDERWATER_INLAVA = 0x80 // terrain type is lava and player is afflicted by it
77 enum PlayerSpellState
79 PLAYERSPELL_UNCHANGED = 0,
80 PLAYERSPELL_CHANGED = 1,
81 PLAYERSPELL_NEW = 2,
82 PLAYERSPELL_REMOVED = 3
85 struct PlayerSpell
87 PlayerSpellState state : 8;
88 bool active : 1; // show in spellbook
89 bool dependent : 1; // learned as result another spell learn, skill grow, quest reward, etc
90 bool disabled : 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
93 // Spell modifier (used for modify other spells)
94 struct SpellModifier
96 SpellModifier() : charges(0), lastAffected(NULL) {}
97 SpellModOp op : 8;
98 SpellModType type : 8;
99 int16 charges : 16;
100 int32 value;
101 uint64 mask;
102 uint64 mask2;
103 uint32 spellId;
104 Spell const* lastAffected;
107 typedef UNORDERED_MAP<uint32, PlayerSpell*> PlayerSpellMap;
108 typedef std::list<SpellModifier*> SpellModList;
110 struct SpellCooldown
112 time_t end;
113 uint16 itemid;
116 typedef std::map<uint32, SpellCooldown> SpellCooldowns;
118 enum TrainerSpellState
120 TRAINER_SPELL_GREEN = 0,
121 TRAINER_SPELL_RED = 1,
122 TRAINER_SPELL_GRAY = 2
125 enum ActionButtonUpdateState
127 ACTIONBUTTON_UNCHANGED = 0,
128 ACTIONBUTTON_CHANGED = 1,
129 ACTIONBUTTON_NEW = 2,
130 ACTIONBUTTON_DELETED = 3
133 struct ActionButton
135 ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW ) {}
136 ActionButton(uint16 _action, uint8 _type, uint8 _misc) : action(_action), type(_type), misc(_misc), uState( ACTIONBUTTON_NEW ) {}
138 uint16 action;
139 uint8 type;
140 uint8 misc;
141 ActionButtonUpdateState uState;
144 enum ActionButtonType
146 ACTION_BUTTON_SPELL = 0,
147 ACTION_BUTTON_MACRO = 64,
148 ACTION_BUTTON_CMACRO= 65,
149 ACTION_BUTTON_ITEM = 128
152 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
154 typedef std::map<uint8,ActionButton> ActionButtonList;
156 struct PlayerCreateInfoItem
158 PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {}
160 uint32 item_id;
161 uint32 item_amount;
164 typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
166 struct PlayerClassLevelInfo
168 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
169 uint16 basehealth;
170 uint16 basemana;
173 struct PlayerClassInfo
175 PlayerClassInfo() : levelInfo(NULL) { }
177 PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
180 struct PlayerLevelInfo
182 PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
184 uint8 stats[MAX_STATS];
187 typedef std::list<uint32> PlayerCreateInfoSpells;
189 struct PlayerInfo
191 // existence checked by displayId != 0 // existence checked by displayId != 0
192 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL)
196 uint32 mapId;
197 uint32 zoneId;
198 float positionX;
199 float positionY;
200 float positionZ;
201 uint16 displayId_m;
202 uint16 displayId_f;
203 PlayerCreateInfoItems item;
204 PlayerCreateInfoSpells spell;
205 std::list<uint16> action[4];
207 PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
210 struct PvPInfo
212 PvPInfo() : inHostileArea(false), endTimer(0) {}
214 bool inHostileArea;
215 time_t endTimer;
218 struct DuelInfo
220 DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {}
222 Player *initiator;
223 Player *opponent;
224 time_t startTimer;
225 time_t startTime;
226 time_t outOfBound;
229 struct Areas
231 uint32 areaID;
232 uint32 areaFlag;
233 float x1;
234 float x2;
235 float y1;
236 float y2;
239 #define MAX_RUNES 6
240 #define RUNE_COOLDOWN 5 // 5*2=10 sec
242 enum RuneType
244 RUNE_BLOOD = 0,
245 RUNE_UNHOLY = 1,
246 RUNE_FROST = 2,
247 RUNE_DEATH = 3,
248 NUM_RUNE_TYPES = 4
251 struct RuneInfo
253 uint8 BaseRune;
254 uint8 CurrentRune;
255 uint8 Cooldown;
258 struct Runes
260 RuneInfo runes[MAX_RUNES];
261 uint8 runeState; // mask of available runes
263 void SetRuneState(uint8 index, bool set = true)
265 if(set)
266 runeState |= (1 << index); // usable
267 else
268 runeState &= ~(1 << index); // on cooldown
272 enum FactionFlags
274 FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction)
275 FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
276 FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
277 FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
278 FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
279 FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE )
280 FACTION_FLAG_RIVAL = 0x40 // flag for the two competing outland factions
283 typedef uint32 RepListID;
284 struct FactionState
286 uint32 ID;
287 RepListID ReputationListID;
288 uint32 Flags;
289 int32 Standing;
290 bool Changed;
293 typedef std::map<RepListID,FactionState> FactionStateList;
295 typedef std::map<uint32,ReputationRank> ForcedReactions;
297 typedef std::set<uint64> GuardianPetList;
299 struct EnchantDuration
301 EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {};
302 EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { assert(item); };
304 Item * item;
305 EnchantmentSlot slot;
306 uint32 leftduration;
309 typedef std::list<EnchantDuration> EnchantDurationList;
310 typedef std::list<Item*> ItemDurationList;
312 struct LookingForGroupSlot
314 LookingForGroupSlot() : entry(0), type(0) {}
315 bool Empty() const { return !entry && !type; }
316 void Clear() { entry = 0; type = 0; }
317 void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; }
318 bool Is(uint32 _entry, uint32 _type) const { return entry==_entry && type==_type; }
319 bool canAutoJoin() const { return entry && (type == 1 || type == 5); }
321 uint32 entry;
322 uint32 type;
325 #define MAX_LOOKING_FOR_GROUP_SLOT 3
327 struct LookingForGroup
329 LookingForGroup() {}
330 bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry,slot.type); }
331 bool HaveInSlot(uint32 _entry, uint32 _type) const
333 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
334 if(slots[i].Is(_entry,_type))
335 return true;
336 return false;
339 bool canAutoJoin() const
341 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
342 if(slots[i].canAutoJoin())
343 return true;
344 return false;
347 bool Empty() const
349 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
350 if(!slots[i].Empty())
351 return false;
352 return more.Empty();
355 LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT];
356 LookingForGroupSlot more;
357 std::string comment;
360 enum PlayerMovementType
362 MOVE_ROOT = 1,
363 MOVE_UNROOT = 2,
364 MOVE_WATER_WALK = 3,
365 MOVE_LAND_WALK = 4
368 enum DrunkenState
370 DRUNKEN_SOBER = 0,
371 DRUNKEN_TIPSY = 1,
372 DRUNKEN_DRUNK = 2,
373 DRUNKEN_SMASHED = 3
376 enum PlayerStateType
379 PLAYER_STATE_DANCE
380 PLAYER_STATE_SLEEP
381 PLAYER_STATE_SIT
382 PLAYER_STATE_STAND
383 PLAYER_STATE_READYUNARMED
384 PLAYER_STATE_WORK
385 PLAYER_STATE_POINT(DNR)
386 PLAYER_STATE_NONE // not used or just no state, just standing there?
387 PLAYER_STATE_STUN
388 PLAYER_STATE_DEAD
389 PLAYER_STATE_KNEEL
390 PLAYER_STATE_USESTANDING
391 PLAYER_STATE_STUN_NOSHEATHE
392 PLAYER_STATE_USESTANDING_NOSHEATHE
393 PLAYER_STATE_WORK_NOSHEATHE
394 PLAYER_STATE_SPELLPRECAST
395 PLAYER_STATE_READYRIFLE
396 PLAYER_STATE_WORK_NOSHEATHE_MINING
397 PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD
398 PLAYER_STATE_AT_EASE
399 PLAYER_STATE_READY1H
400 PLAYER_STATE_SPELLKNEELSTART
401 PLAYER_STATE_SUBMERGED
404 PLAYER_STATE_NONE = 0,
405 PLAYER_STATE_SIT = 1,
406 PLAYER_STATE_SIT_CHAIR = 2,
407 PLAYER_STATE_SLEEP = 3,
408 PLAYER_STATE_SIT_LOW_CHAIR = 4,
409 PLAYER_STATE_SIT_MEDIUM_CHAIR = 5,
410 PLAYER_STATE_SIT_HIGH_CHAIR = 6,
411 PLAYER_STATE_DEAD = 7,
412 PLAYER_STATE_KNEEL = 8,
414 PLAYER_STATE_FORM_ALL = 0x00FF0000,
416 PLAYER_STATE_FLAG_ALWAYS_STAND = 0x01, // byte 4
417 PLAYER_STATE_FLAG_CREEP = 0x02000000,
418 PLAYER_STATE_FLAG_UNTRACKABLE = 0x04000000,
419 PLAYER_STATE_FLAG_ALL = 0xFF000000,
422 enum PlayerFlags
424 PLAYER_FLAGS_GROUP_LEADER = 0x00000001,
425 PLAYER_FLAGS_AFK = 0x00000002,
426 PLAYER_FLAGS_DND = 0x00000004,
427 PLAYER_FLAGS_GM = 0x00000008,
428 PLAYER_FLAGS_GHOST = 0x00000010,
429 PLAYER_FLAGS_RESTING = 0x00000020,
430 PLAYER_FLAGS_UNK7 = 0x00000040,
431 PLAYER_FLAGS_UNK8 = 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
432 PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
433 PLAYER_FLAGS_IN_PVP = 0x00000200,
434 PLAYER_FLAGS_HIDE_HELM = 0x00000400,
435 PLAYER_FLAGS_HIDE_CLOAK = 0x00000800,
436 PLAYER_FLAGS_UNK13 = 0x00001000, // played long time
437 PLAYER_FLAGS_UNK14 = 0x00002000, // played too long time
438 PLAYER_FLAGS_UNK15 = 0x00004000,
439 PLAYER_FLAGS_UNK16 = 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
440 PLAYER_FLAGS_UNK17 = 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
441 PLAYER_FLAGS_UNK18 = 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
442 PLAYER_FLAGS_PVP_TIMER = 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
443 PLAYER_FLAGS_UNK20 = 0x00080000,
444 PLAYER_FLAGS_UNK21 = 0x00100000,
445 PLAYER_FLAGS_UNK22 = 0x00200000,
446 PLAYER_FLAGS_UNK23 = 0x00400000,
447 PLAYER_FLAGS_UNK24 = 0x00800000, // disabled all abilitys on tab except autoattack
448 PLAYER_FLAGS_UNK25 = 0x01000000, // disabled all melee ability on tab include autoattack
452 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
453 // can't use enum for uint64 values
454 #define PLAYER_TITLE_DISABLED 0x0000000000000000LL
455 #define PLAYER_TITLE_NONE 0x0000000000000001LL
456 #define PLAYER_TITLE_PRIVATE 0x0000000000000002LL // 1
457 #define PLAYER_TITLE_CORPORAL 0x0000000000000004LL // 2
458 #define PLAYER_TITLE_SERGEANT_A 0x0000000000000008LL // 3
459 #define PLAYER_TITLE_MASTER_SERGEANT 0x0000000000000010LL // 4
460 #define PLAYER_TITLE_SERGEANT_MAJOR 0x0000000000000020LL // 5
461 #define PLAYER_TITLE_KNIGHT 0x0000000000000040LL // 6
462 #define PLAYER_TITLE_KNIGHT_LIEUTENANT 0x0000000000000080LL // 7
463 #define PLAYER_TITLE_KNIGHT_CAPTAIN 0x0000000000000100LL // 8
464 #define PLAYER_TITLE_KNIGHT_CHAMPION 0x0000000000000200LL // 9
465 #define PLAYER_TITLE_LIEUTENANT_COMMANDER 0x0000000000000400LL // 10
466 #define PLAYER_TITLE_COMMANDER 0x0000000000000800LL // 11
467 #define PLAYER_TITLE_MARSHAL 0x0000000000001000LL // 12
468 #define PLAYER_TITLE_FIELD_MARSHAL 0x0000000000002000LL // 13
469 #define PLAYER_TITLE_GRAND_MARSHAL 0x0000000000004000LL // 14
470 #define PLAYER_TITLE_SCOUT 0x0000000000008000LL // 15
471 #define PLAYER_TITLE_GRUNT 0x0000000000010000LL // 16
472 #define PLAYER_TITLE_SERGEANT_H 0x0000000000020000LL // 17
473 #define PLAYER_TITLE_SENIOR_SERGEANT 0x0000000000040000LL // 18
474 #define PLAYER_TITLE_FIRST_SERGEANT 0x0000000000080000LL // 19
475 #define PLAYER_TITLE_STONE_GUARD 0x0000000000100000LL // 20
476 #define PLAYER_TITLE_BLOOD_GUARD 0x0000000000200000LL // 21
477 #define PLAYER_TITLE_LEGIONNAIRE 0x0000000000400000LL // 22
478 #define PLAYER_TITLE_CENTURION 0x0000000000800000LL // 23
479 #define PLAYER_TITLE_CHAMPION 0x0000000001000000LL // 24
480 #define PLAYER_TITLE_LIEUTENANT_GENERAL 0x0000000002000000LL // 25
481 #define PLAYER_TITLE_GENERAL 0x0000000004000000LL // 26
482 #define PLAYER_TITLE_WARLORD 0x0000000008000000LL // 27
483 #define PLAYER_TITLE_HIGH_WARLORD 0x0000000010000000LL // 28
484 #define PLAYER_TITLE_GLADIATOR 0x0000000020000000LL // 29
485 #define PLAYER_TITLE_DUELIST 0x0000000040000000LL // 30
486 #define PLAYER_TITLE_RIVAL 0x0000000080000000LL // 31
487 #define PLAYER_TITLE_CHALLENGER 0x0000000100000000LL // 32
488 #define PLAYER_TITLE_SCARAB_LORD 0x0000000200000000LL // 33
489 #define PLAYER_TITLE_CONQUEROR 0x0000000400000000LL // 34
490 #define PLAYER_TITLE_JUSTICAR 0x0000000800000000LL // 35
491 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36
492 #define PLAYER_TITLE_MERCILESS_GLADIATOR 0x0000002000000000LL // 37
493 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN 0x0000004000000000LL // 38
494 #define PLAYER_TITLE_HAND_OF_ADAL 0x0000008000000000LL // 39
495 #define PLAYER_TITLE_VENGEFUL_GLADIATOR 0x0000010000000000LL // 40
497 // used in PLAYER_FIELD_BYTES values
498 enum PlayerFieldByteFlags
500 PLAYER_FIELD_BYTE_TRACK_STEALTHED = 0x00000002,
501 PLAYER_FIELD_BYTE_RELEASE_TIMER = 0x00000008, // Display time till auto release spirit
502 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x00000010 // Display no "release spirit" window at all
505 // used in PLAYER_FIELD_BYTES2 values
506 enum PlayerFieldByte2Flags
508 PLAYER_FIELD_BYTE2_NONE = 0x0000,
509 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW = 0x4000
512 enum ActivateTaxiReplies
514 ERR_TAXIOK = 0,
515 ERR_TAXIUNSPECIFIEDSERVERERROR = 1,
516 ERR_TAXINOSUCHPATH = 2,
517 ERR_TAXINOTENOUGHMONEY = 3,
518 ERR_TAXITOOFARAWAY = 4,
519 ERR_TAXINOVENDORNEARBY = 5,
520 ERR_TAXINOTVISITED = 6,
521 ERR_TAXIPLAYERBUSY = 7,
522 ERR_TAXIPLAYERALREADYMOUNTED = 8,
523 ERR_TAXIPLAYERSHAPESHIFTED = 9,
524 ERR_TAXIPLAYERMOVING = 10,
525 ERR_TAXISAMENODE = 11,
526 ERR_TAXINOTSTANDING = 12
529 enum LootType
531 LOOT_CORPSE = 1,
532 LOOT_SKINNING = 2,
533 LOOT_FISHING = 3,
534 LOOT_PICKPOCKETING = 4, // unsupported by client, sending LOOT_SKINNING instead
535 LOOT_DISENCHANTING = 5, // unsupported by client, sending LOOT_SKINNING instead
536 LOOT_PROSPECTING = 6, // unsupported by client, sending LOOT_SKINNING instead
537 LOOT_INSIGNIA = 7, // unsupported by client, sending LOOT_SKINNING instead
538 LOOT_FISHINGHOLE = 8, // unsupported by client, sending LOOT_FISHING instead
539 LOOT_MILLING = 9 // unsupported by client, sending LOOT_SKINNING instead
542 enum MirrorTimerType
544 FATIGUE_TIMER = 0,
545 BREATH_TIMER = 1,
546 FIRE_TIMER = 2
549 // 2^n values
550 enum PlayerExtraFlags
552 // gm abilities
553 PLAYER_EXTRA_GM_ON = 0x0001,
554 PLAYER_EXTRA_GM_ACCEPT_TICKETS = 0x0002,
555 PLAYER_EXTRA_ACCEPT_WHISPERS = 0x0004,
556 PLAYER_EXTRA_TAXICHEAT = 0x0008,
557 PLAYER_EXTRA_GM_INVISIBLE = 0x0010,
558 PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages
560 // other states
561 PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating.
564 // 2^n values
565 enum AtLoginFlags
567 AT_LOGIN_NONE = 0,
568 AT_LOGIN_RENAME = 1,
569 AT_LOGIN_RESET_SPELLS = 2,
570 AT_LOGIN_RESET_TALENTS = 4,
571 AT_LOGIN_CUSTOMIZE = 8
574 typedef std::map<uint32, QuestStatusData> QuestStatusMap;
576 enum QuestSlotOffsets
578 QUEST_ID_OFFSET = 0,
579 QUEST_STATE_OFFSET = 1,
580 QUEST_COUNTS_OFFSET = 2,
581 QUEST_TIME_OFFSET = 3
584 #define MAX_QUEST_OFFSET 4
586 enum QuestSlotStateMask
588 QUEST_STATE_NONE = 0x0000,
589 QUEST_STATE_COMPLETE = 0x0001,
590 QUEST_STATE_FAIL = 0x0002
593 class Quest;
594 class Spell;
595 class Item;
596 class WorldSession;
598 enum PlayerSlots
600 // first slot for item stored (in any way in player m_items data)
601 PLAYER_SLOT_START = 0,
602 // last+1 slot for item stored (in any way in player m_items data)
603 PLAYER_SLOT_END = 200,
604 PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START)
607 enum EquipmentSlots
609 EQUIPMENT_SLOT_START = 0,
610 EQUIPMENT_SLOT_HEAD = 0,
611 EQUIPMENT_SLOT_NECK = 1,
612 EQUIPMENT_SLOT_SHOULDERS = 2,
613 EQUIPMENT_SLOT_BODY = 3,
614 EQUIPMENT_SLOT_CHEST = 4,
615 EQUIPMENT_SLOT_WAIST = 5,
616 EQUIPMENT_SLOT_LEGS = 6,
617 EQUIPMENT_SLOT_FEET = 7,
618 EQUIPMENT_SLOT_WRISTS = 8,
619 EQUIPMENT_SLOT_HANDS = 9,
620 EQUIPMENT_SLOT_FINGER1 = 10,
621 EQUIPMENT_SLOT_FINGER2 = 11,
622 EQUIPMENT_SLOT_TRINKET1 = 12,
623 EQUIPMENT_SLOT_TRINKET2 = 13,
624 EQUIPMENT_SLOT_BACK = 14,
625 EQUIPMENT_SLOT_MAINHAND = 15,
626 EQUIPMENT_SLOT_OFFHAND = 16,
627 EQUIPMENT_SLOT_RANGED = 17,
628 EQUIPMENT_SLOT_TABARD = 18,
629 EQUIPMENT_SLOT_END = 19
632 enum InventorySlots
634 INVENTORY_SLOT_BAG_0 = 255,
635 INVENTORY_SLOT_BAG_START = 19,
636 INVENTORY_SLOT_BAG_1 = 19,
637 INVENTORY_SLOT_BAG_2 = 20,
638 INVENTORY_SLOT_BAG_3 = 21,
639 INVENTORY_SLOT_BAG_4 = 22,
640 INVENTORY_SLOT_BAG_END = 23,
642 INVENTORY_SLOT_ITEM_START = 23,
643 INVENTORY_SLOT_ITEM_1 = 23,
644 INVENTORY_SLOT_ITEM_2 = 24,
645 INVENTORY_SLOT_ITEM_3 = 25,
646 INVENTORY_SLOT_ITEM_4 = 26,
647 INVENTORY_SLOT_ITEM_5 = 27,
648 INVENTORY_SLOT_ITEM_6 = 28,
649 INVENTORY_SLOT_ITEM_7 = 29,
650 INVENTORY_SLOT_ITEM_8 = 30,
651 INVENTORY_SLOT_ITEM_9 = 31,
652 INVENTORY_SLOT_ITEM_10 = 32,
653 INVENTORY_SLOT_ITEM_11 = 33,
654 INVENTORY_SLOT_ITEM_12 = 34,
655 INVENTORY_SLOT_ITEM_13 = 35,
656 INVENTORY_SLOT_ITEM_14 = 36,
657 INVENTORY_SLOT_ITEM_15 = 37,
658 INVENTORY_SLOT_ITEM_16 = 38,
659 INVENTORY_SLOT_ITEM_END = 39
662 enum BankSlots
664 BANK_SLOT_ITEM_START = 39,
665 BANK_SLOT_ITEM_1 = 39,
666 BANK_SLOT_ITEM_2 = 40,
667 BANK_SLOT_ITEM_3 = 41,
668 BANK_SLOT_ITEM_4 = 42,
669 BANK_SLOT_ITEM_5 = 43,
670 BANK_SLOT_ITEM_6 = 44,
671 BANK_SLOT_ITEM_7 = 45,
672 BANK_SLOT_ITEM_8 = 46,
673 BANK_SLOT_ITEM_9 = 47,
674 BANK_SLOT_ITEM_10 = 48,
675 BANK_SLOT_ITEM_11 = 49,
676 BANK_SLOT_ITEM_12 = 50,
677 BANK_SLOT_ITEM_13 = 51,
678 BANK_SLOT_ITEM_14 = 52,
679 BANK_SLOT_ITEM_15 = 53,
680 BANK_SLOT_ITEM_16 = 54,
681 BANK_SLOT_ITEM_17 = 55,
682 BANK_SLOT_ITEM_18 = 56,
683 BANK_SLOT_ITEM_19 = 57,
684 BANK_SLOT_ITEM_20 = 58,
685 BANK_SLOT_ITEM_21 = 59,
686 BANK_SLOT_ITEM_22 = 60,
687 BANK_SLOT_ITEM_23 = 61,
688 BANK_SLOT_ITEM_24 = 62,
689 BANK_SLOT_ITEM_25 = 63,
690 BANK_SLOT_ITEM_26 = 64,
691 BANK_SLOT_ITEM_27 = 65,
692 BANK_SLOT_ITEM_28 = 66,
693 BANK_SLOT_ITEM_END = 67,
695 BANK_SLOT_BAG_START = 67,
696 BANK_SLOT_BAG_1 = 67,
697 BANK_SLOT_BAG_2 = 68,
698 BANK_SLOT_BAG_3 = 69,
699 BANK_SLOT_BAG_4 = 70,
700 BANK_SLOT_BAG_5 = 71,
701 BANK_SLOT_BAG_6 = 72,
702 BANK_SLOT_BAG_7 = 73,
703 BANK_SLOT_BAG_END = 74
706 enum BuyBackSlots
708 // stored in m_buybackitems
709 BUYBACK_SLOT_START = 74,
710 BUYBACK_SLOT_1 = 74,
711 BUYBACK_SLOT_2 = 75,
712 BUYBACK_SLOT_3 = 76,
713 BUYBACK_SLOT_4 = 77,
714 BUYBACK_SLOT_5 = 78,
715 BUYBACK_SLOT_6 = 79,
716 BUYBACK_SLOT_7 = 80,
717 BUYBACK_SLOT_8 = 81,
718 BUYBACK_SLOT_9 = 82,
719 BUYBACK_SLOT_10 = 83,
720 BUYBACK_SLOT_11 = 84,
721 BUYBACK_SLOT_12 = 85,
722 BUYBACK_SLOT_END = 86
725 enum KeyRingSlots
727 KEYRING_SLOT_START = 86,
728 KEYRING_SLOT_END = 118
731 enum VanityPetSlots
733 VANITYPET_SLOT_START = 118, // not use, vanity pets stored as spells
734 VANITYPET_SLOT_END = 136 // not alloed any content in.
737 enum CurrencyTokenSlots
739 CURRENCYTOKEN_SLOT_START = 136,
740 CURRENCYTOKEN_SLOT_END = 168
743 enum QuestBagSlots
745 QUESTBAG_SLOT_START = 168,
746 QUESTBAG_SLOT_END = 200
749 struct ItemPosCount
751 ItemPosCount(uint16 _pos, uint32 _count) : pos(_pos), count(_count) {}
752 bool isContainedIn(std::vector<ItemPosCount> const& vec) const;
753 uint16 pos;
754 uint32 count;
756 typedef std::vector<ItemPosCount> ItemPosCountVec;
758 enum TradeSlots
760 TRADE_SLOT_COUNT = 7,
761 TRADE_SLOT_TRADED_COUNT = 6,
762 TRADE_SLOT_NONTRADED = 6
765 enum TransferAbortReason
767 TRANSFER_ABORT_ERROR = 0x00,
768 TRANSFER_ABORT_MAX_PLAYERS = 0x01, // Transfer Aborted: instance is full
769 TRANSFER_ABORT_NOT_FOUND = 0x02, // Transfer Aborted: instance not found
770 TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x03, // You have entered too many instances recently.
771 TRANSFER_ABORT_ZONE_IN_COMBAT = 0x05, // Unable to zone in while an encounter is in progress.
772 TRANSFER_ABORT_INSUF_EXPAN_LVL = 0x06, // You must have <TBC,WotLK> expansion installed to access this area.
773 TRANSFER_ABORT_DIFFICULTY = 0x07, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
774 TRANSFER_ABORT_UNIQUE_MESSAGE = 0x08, // Until you've escaped TLK's grasp, you cannot leave this place!
775 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 0x09 // Additional instances cannot be launched, please try again later.
778 enum InstanceResetWarningType
780 RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s).
781 RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)!
782 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!
783 RAID_INSTANCE_WELCOME = 4 // Welcome to %s. This raid instance is scheduled to reset in %s.
786 struct MovementInfo
788 // common
789 uint32 flags;
790 uint16 unk1;
791 uint32 time;
792 float x, y, z, o;
793 // transport
794 uint64 t_guid;
795 float t_x, t_y, t_z, t_o;
796 uint32 t_time;
797 int8 t_seat;
798 // swimming and unknown
799 float s_pitch;
800 // last fall time
801 uint32 fallTime;
802 // jumping
803 float j_unk, j_sinAngle, j_cosAngle, j_xyspeed;
804 // spline
805 float u_unk1;
807 MovementInfo()
809 flags = 0;
810 time = t_time = fallTime = 0;
811 unk1 = 0;
812 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;
813 t_guid = 0;
816 void SetMovementFlags(uint32 _flags)
818 flags = _flags;
822 // flags that use in movement check for example at spell casting
823 MovementFlags const movementFlagsMask = MovementFlags(
824 MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
825 MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1 |
826 MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_FLY_UP |
827 MOVEMENTFLAG_FLYING |MOVEMENTFLAG_SPLINE
830 MovementFlags const movementOrTurningFlagsMask = MovementFlags(
831 movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT
833 class InstanceSave;
835 enum RestType
837 REST_TYPE_NO = 0,
838 REST_TYPE_IN_TAVERN = 1,
839 REST_TYPE_IN_CITY = 2
842 enum DuelCompleteType
844 DUEL_INTERUPTED = 0,
845 DUEL_WON = 1,
846 DUEL_FLED = 2
849 enum TeleportToOptions
851 TELE_TO_GM_MODE = 0x01,
852 TELE_TO_NOT_LEAVE_TRANSPORT = 0x02,
853 TELE_TO_NOT_LEAVE_COMBAT = 0x04,
854 TELE_TO_NOT_UNSUMMON_PET = 0x08,
855 TELE_TO_SPELL = 0x10,
858 /// Type of environmental damages
859 enum EnviromentalDamage
861 DAMAGE_EXHAUSTED = 0,
862 DAMAGE_DROWNING = 1,
863 DAMAGE_FALL = 2,
864 DAMAGE_LAVA = 3,
865 DAMAGE_SLIME = 4,
866 DAMAGE_FIRE = 5,
867 DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
870 // used at player loading query list preparing, and later result selection
871 enum PlayerLoginQueryIndex
873 PLAYER_LOGIN_QUERY_LOADFROM = 0,
874 PLAYER_LOGIN_QUERY_LOADGROUP = 1,
875 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES = 2,
876 PLAYER_LOGIN_QUERY_LOADAURAS = 3,
877 PLAYER_LOGIN_QUERY_LOADSPELLS = 4,
878 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS = 5,
879 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS = 6,
880 PLAYER_LOGIN_QUERY_LOADTUTORIALS = 7, // common for all characters for some account at specific realm
881 PLAYER_LOGIN_QUERY_LOADREPUTATION = 8,
882 PLAYER_LOGIN_QUERY_LOADINVENTORY = 9,
883 PLAYER_LOGIN_QUERY_LOADACTIONS = 10,
884 PLAYER_LOGIN_QUERY_LOADMAILCOUNT = 11,
885 PLAYER_LOGIN_QUERY_LOADMAILDATE = 12,
886 PLAYER_LOGIN_QUERY_LOADSOCIALLIST = 13,
887 PLAYER_LOGIN_QUERY_LOADHOMEBIND = 14,
888 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS = 15,
889 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES = 16,
890 PLAYER_LOGIN_QUERY_LOADGUILD = 17,
891 PLAYER_LOGIN_QUERY_LOADARENAINFO = 18,
892 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS = 19,
893 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS = 20,
894 MAX_PLAYER_LOGIN_QUERY = 21
898 // Player summoning auto-decline time (in secs)
899 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
900 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
902 struct InstancePlayerBind
904 InstanceSave *save;
905 bool perm;
906 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
907 that aren't already permanently bound when they are inside when a boss is killed
908 or when they enter an instance that the group leader is permanently bound to. */
909 InstancePlayerBind() : save(NULL), perm(false) {}
912 class MANGOS_DLL_SPEC PlayerTaxi
914 public:
915 PlayerTaxi();
916 ~PlayerTaxi() {}
917 // Nodes
918 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level);
919 void LoadTaxiMask(const char* data);
921 bool IsTaximaskNodeKnown(uint32 nodeidx) const
923 uint8 field = uint8((nodeidx - 1) / 32);
924 uint32 submask = 1<<((nodeidx-1)%32);
925 return (m_taximask[field] & submask) == submask;
927 bool SetTaximaskNode(uint32 nodeidx)
929 uint8 field = uint8((nodeidx - 1) / 32);
930 uint32 submask = 1<<((nodeidx-1)%32);
931 if ((m_taximask[field] & submask) != submask )
933 m_taximask[field] |= submask;
934 return true;
936 else
937 return false;
939 void AppendTaximaskTo(ByteBuffer& data,bool all);
941 // Destinations
942 bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team);
943 std::string SaveTaxiDestinationsToString();
945 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
946 void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
947 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
948 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
949 uint32 GetCurrentTaxiPath() const;
950 uint32 NextTaxiDestination()
952 m_TaxiDestinations.pop_front();
953 return GetTaxiDestination();
955 bool empty() const { return m_TaxiDestinations.empty(); }
957 friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
958 private:
959 TaxiMask m_taximask;
960 std::deque<uint32> m_TaxiDestinations;
963 std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
965 class MANGOS_DLL_SPEC Player : public Unit
967 friend class WorldSession;
968 friend void Item::AddToUpdateQueueOf(Player *player);
969 friend void Item::RemoveFromUpdateQueueOf(Player *player);
970 public:
971 explicit Player (WorldSession *session);
972 ~Player ( );
974 void CleanupsBeforeDelete();
976 static UpdateMask updateVisualBits;
977 static void InitVisibleBits();
979 void AddToWorld();
980 void RemoveFromWorld();
982 bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
984 bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
986 return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options);
989 void SetSummonPoint(uint32 mapid, float x, float y, float z)
991 m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
992 m_summon_mapid = mapid;
993 m_summon_x = x;
994 m_summon_y = y;
995 m_summon_z = z;
997 void SummonIfPossible(bool agree);
999 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 );
1001 void Update( uint32 time );
1003 void BuildEnumData( QueryResult * result, WorldPacket * p_data );
1005 void SetInWater(bool apply);
1007 bool IsInWater() const { return m_isInWater; }
1008 bool IsUnderWater() const;
1010 void SendInitialPacketsBeforeAddToMap();
1011 void SendInitialPacketsAfterAddToMap();
1012 void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0);
1013 void SendInstanceResetWarning(uint32 mapid, uint32 time);
1015 bool CanInteractWithNPCs(bool alive = true) const;
1017 bool ToggleAFK();
1018 bool ToggleDND();
1019 bool isAFK() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_AFK); };
1020 bool isDND() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_DND); };
1021 uint8 chatTag() const;
1022 std::string afkMsg;
1023 std::string dndMsg;
1025 uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
1027 PlayerSocial *GetSocial() { return m_social; }
1029 PlayerTaxi m_taxi;
1030 void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1031 bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, uint32 mount_id = 0 , Creature* npc = NULL);
1032 // mount_id can be used in scripting calls
1033 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); }
1034 void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; }
1035 bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
1036 void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
1037 bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
1038 void SetGameMaster(bool on);
1039 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); }
1040 void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
1041 bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
1042 void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
1043 bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
1044 void SetGMVisible(bool on);
1045 void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
1047 void GiveXP(uint32 xp, Unit* victim);
1048 void GiveLevel(uint32 level);
1049 void InitStatsForLevel(bool reapplyMods = false);
1051 // Played Time Stuff
1052 time_t m_logintime;
1053 time_t m_Last_tick;
1054 uint32 m_Played_time[2];
1055 uint32 GetTotalPlayedTime() { return m_Played_time[0]; };
1056 uint32 GetLevelPlayedTime() { return m_Played_time[1]; };
1058 void setDeathState(DeathState s); // overwrite Unit::setDeathState
1060 void InnEnter (int time,uint32 mapid, float x,float y,float z)
1062 inn_pos_mapid = mapid;
1063 inn_pos_x = x;
1064 inn_pos_y = y;
1065 inn_pos_z = z;
1066 time_inn_enter = time;
1069 float GetRestBonus() const { return m_rest_bonus; };
1070 void SetRestBonus(float rest_bonus_new);
1072 RestType GetRestType() const { return rest_type; };
1073 void SetRestType(RestType n_r_type) { rest_type = n_r_type; };
1075 uint32 GetInnPosMapId() const { return inn_pos_mapid; };
1076 float GetInnPosX() const { return inn_pos_x; };
1077 float GetInnPosY() const { return inn_pos_y; };
1078 float GetInnPosZ() const { return inn_pos_z; };
1080 int GetTimeInnEnter() const { return time_inn_enter; };
1081 void UpdateInnerTime (int time) { time_inn_enter = time; };
1083 void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
1084 void RemoveMiniPet();
1085 Pet* GetMiniPet();
1086 void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); }
1087 void RemoveGuardians();
1088 bool HasGuardianWithEntry(uint32 entry);
1089 void AddGuardian(Pet* pet) { m_guardianPets.insert(pet->GetGUID()); }
1090 GuardianPetList const& GetGuardians() const { return m_guardianPets; }
1091 void Uncharm();
1093 void Say(const std::string& text, const uint32 language);
1094 void Yell(const std::string& text, const uint32 language);
1095 void TextEmote(const std::string& text);
1096 void Whisper(const std::string& text, const uint32 language,uint64 receiver);
1097 void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
1099 /*********************************************************/
1100 /*** STORAGE SYSTEM ***/
1101 /*********************************************************/
1103 void SetVirtualItemSlot( uint8 i, Item* item);
1104 void SetSheath( uint32 sheathed );
1105 uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const;
1106 uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const;
1107 Item* GetItemByGuid( uint64 guid ) const;
1108 Item* GetItemByPos( uint16 pos ) const;
1109 Item* GetItemByPos( uint8 bag, uint8 slot ) const;
1110 Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const;
1111 Item* GetShield(bool useable = false) const;
1112 static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot
1113 std::vector<Item *> &GetItemUpdateQueue() { return m_itemUpdateQueue; }
1114 static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8,pos & 255); }
1115 static bool IsInventoryPos( uint8 bag, uint8 slot );
1116 static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8,pos & 255); }
1117 static bool IsEquipmentPos( uint8 bag, uint8 slot );
1118 static bool IsBagPos( uint16 pos );
1119 static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
1120 static bool IsBankPos( uint8 bag, uint8 slot );
1121 bool IsValidPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
1122 bool IsValidPos( uint8 bag, uint8 slot );
1123 bool HasBankBagSlot( uint8 slot ) const;
1124 bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
1125 bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL);
1126 bool CanNoReagentCast(SpellEntry const* spellInfo) const;
1127 Item* GetItemOrItemWithGemEquipped( uint32 item ) const;
1128 uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(),pItem->GetCount(),pItem); }
1129 uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry,count,NULL); }
1130 uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
1132 return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count );
1134 uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
1136 if(!pItem)
1137 return EQUIP_ERR_ITEM_NOT_FOUND;
1138 uint32 count = pItem->GetCount();
1139 return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL );
1142 uint8 CanStoreItems( Item **pItem,int count) const;
1143 uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
1144 uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
1145 uint8 CanUnequipItems( uint32 item, uint32 count ) const;
1146 uint8 CanUnequipItem( uint16 src, bool swap ) const;
1147 uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
1148 uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
1149 bool HasItemTotemCategory( uint32 TotemCategory ) const;
1150 bool CanUseItem( ItemPrototype const *pItem );
1151 uint8 CanUseAmmo( uint32 item ) const;
1152 Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
1153 Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
1154 Item* EquipNewItem( uint16 pos, uint32 item, bool update );
1155 Item* EquipItem( uint16 pos, Item *pItem, bool update );
1156 void AutoUnequipOffhandIfNeed();
1157 bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
1158 void AutoStoreLootItem(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store);
1159 void AutoStoreLootItem(uint32 loot_id, LootStore const& store) { AutoStoreLootItem(NULL_BAG,NULL_SLOT,loot_id,store); }
1161 uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
1162 uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
1164 void ApplyEquipCooldown( Item * pItem );
1165 void SetAmmo( uint32 item );
1166 void RemoveAmmo();
1167 float GetAmmoDPS() const { return m_ammoDPS; }
1168 bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const;
1169 void QuickEquipItem( uint16 pos, Item *pItem);
1170 void VisualizeItem( uint8 slot, Item *pItem);
1171 void SetVisibleItemSlot(uint8 slot, Item *pItem);
1172 Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update )
1174 return StoreItem( dest, pItem, update);
1176 Item* BankItem( uint16 pos, Item *pItem, bool update );
1177 void RemoveItem( uint8 bag, uint8 slot, bool update );
1178 void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
1179 // in trade, auction, guild bank, mail....
1180 void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
1181 // in trade, guild bank, mail....
1182 void RemoveItemDependentAurasAndCasts( Item * pItem );
1183 void DestroyItem( uint8 bag, uint8 slot, bool update );
1184 void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
1185 void DestroyItemCount( Item* item, uint32& count, bool update );
1186 void DestroyConjuredItems( bool update );
1187 void DestroyZoneLimitedItem( bool update, uint32 new_zone );
1188 void SplitItem( uint16 src, uint16 dst, uint32 count );
1189 void SwapItem( uint16 src, uint16 dst );
1190 void AddItemToBuyBackSlot( Item *pItem );
1191 Item* GetItemFromBuyBackSlot( uint32 slot );
1192 void RemoveItemFromBuyBackSlot( uint32 slot, bool del );
1193 uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
1194 void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 );
1195 void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
1196 void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
1197 void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
1198 void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
1199 uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
1200 uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
1201 bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; }
1202 bool IsUseEquipedWeapon( bool mainhand ) const
1204 // disarm applied only to mainhand weapon
1205 return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) );
1207 bool IsTwoHandUsed() const
1209 Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
1210 return mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
1212 void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false );
1213 bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot);
1215 float GetReputationPriceDiscount( Creature const* pCreature ) const;
1216 Player* GetTrader() const { return pTrader; }
1217 void ClearTrade();
1218 void TradeCancel(bool sendback);
1219 uint16 GetItemPosByTradeSlot(uint32 slot) const { return tradeItems[slot]; }
1221 void UpdateEnchantTime(uint32 time);
1222 void UpdateItemDuration(uint32 time, bool realtimeonly=false);
1223 void AddEnchantmentDurations(Item *item);
1224 void RemoveEnchantmentDurations(Item *item);
1225 void RemoveAllEnchantments(EnchantmentSlot slot);
1226 void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration);
1227 void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false);
1228 void ApplyEnchantment(Item *item,bool apply);
1229 void SendEnchantmentDurations();
1230 void AddItemDurations(Item *item);
1231 void RemoveItemDurations(Item *item);
1232 void SendItemDurations();
1233 void LoadCorpse();
1234 void LoadPet();
1236 uint32 m_stableSlots;
1238 /*********************************************************/
1239 /*** QUEST SYSTEM ***/
1240 /*********************************************************/
1242 void PrepareQuestMenu( uint64 guid );
1243 void SendPreparedQuest( uint64 guid );
1244 bool IsActiveQuest( uint32 quest_id ) const;
1245 Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
1246 bool CanSeeStartQuest( Quest const *pQuest );
1247 bool CanTakeQuest( Quest const *pQuest, bool msg );
1248 bool CanAddQuest( Quest const *pQuest, bool msg );
1249 bool CanCompleteQuest( uint32 quest_id );
1250 bool CanCompleteRepeatableQuest(Quest const *pQuest);
1251 bool CanRewardQuest( Quest const *pQuest, bool msg );
1252 bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg );
1253 void AddQuest( Quest const *pQuest, Object *questGiver );
1254 void CompleteQuest( uint32 quest_id );
1255 void IncompleteQuest( uint32 quest_id );
1256 void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
1257 void FailQuest( uint32 quest_id );
1258 void FailTimedQuest( uint32 quest_id );
1259 bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg );
1260 bool SatisfyQuestLevel( Quest const* qInfo, bool msg );
1261 bool SatisfyQuestLog( bool msg );
1262 bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg );
1263 bool SatisfyQuestRace( Quest const* qInfo, bool msg );
1264 bool SatisfyQuestReputation( Quest const* qInfo, bool msg );
1265 bool SatisfyQuestStatus( Quest const* qInfo, bool msg );
1266 bool SatisfyQuestTimed( Quest const* qInfo, bool msg );
1267 bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg );
1268 bool SatisfyQuestNextChain( Quest const* qInfo, bool msg );
1269 bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg );
1270 bool SatisfyQuestDay( Quest const* qInfo, bool msg );
1271 bool GiveQuestSourceItem( Quest const *pQuest );
1272 bool TakeQuestSourceItem( uint32 quest_id, bool msg );
1273 bool GetQuestRewardStatus( uint32 quest_id ) const;
1274 QuestStatus GetQuestStatus( uint32 quest_id ) const;
1275 void SetQuestStatus( uint32 quest_id, QuestStatus status );
1277 void SetDailyQuestStatus( uint32 quest_id );
1278 void ResetDailyQuestStatus();
1280 uint16 FindQuestSlot( uint32 quest_id ) const;
1281 uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
1282 uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
1283 uint32 GetQuestSlotCounters(uint16 slot)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); }
1284 uint8 GetQuestSlotCounter(uint16 slot,uint8 counter) const { return GetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter); }
1285 uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
1286 void SetQuestSlot(uint16 slot,uint32 quest_id, uint32 timer = 0)
1288 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET,quest_id);
1289 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,0);
1290 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,0);
1291 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer);
1293 void SetQuestSlotCounter(uint16 slot,uint8 counter,uint8 count) { SetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter,count); }
1294 void SetQuestSlotState(uint16 slot,uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1295 void RemoveQuestSlotState(uint16 slot,uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1296 void SetQuestSlotTimer(uint16 slot,uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); }
1297 void SwapQuestSlot(uint16 slot1,uint16 slot2)
1299 for (int i = 0; i < MAX_QUEST_OFFSET ; ++i )
1301 uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i);
1302 uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i);
1304 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i, temp2);
1305 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i, temp1);
1308 uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
1309 void AdjustQuestReqItemCount( Quest const* pQuest );
1310 void AreaExploredOrEventHappens( uint32 questId );
1311 void GroupEventHappens( uint32 questId, WorldObject const* pEventObject );
1312 void ItemAddedQuestCheck( uint32 entry, uint32 count );
1313 void ItemRemovedQuestCheck( uint32 entry, uint32 count );
1314 void KilledMonster( uint32 entry, uint64 guid );
1315 void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id );
1316 void TalkedToCreature( uint32 entry, uint64 guid );
1317 void MoneyChanged( uint32 value );
1318 bool HasQuestForItem( uint32 itemid ) const;
1319 bool HasQuestForGO(int32 GOId);
1320 void UpdateForQuestsGO();
1321 bool CanShareQuest(uint32 quest_id) const;
1323 void SendQuestComplete( uint32 quest_id );
1324 void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
1325 void SendQuestFailed( uint32 quest_id );
1326 void SendQuestTimerFailed( uint32 quest_id );
1327 void SendCanTakeQuestResponse( uint32 msg );
1328 void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
1329 void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
1330 void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count );
1332 uint64 GetDivider() { return m_divider; };
1333 void SetDivider( uint64 guid ) { m_divider = guid; };
1335 uint32 GetInGameTime() { return m_ingametime; };
1337 void SetInGameTime( uint32 time ) { m_ingametime = time; };
1339 void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); }
1341 /*********************************************************/
1342 /*** LOAD SYSTEM ***/
1343 /*********************************************************/
1345 bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
1347 bool MinimalLoadFromDB(QueryResult *result, uint32 guid);
1348 static bool LoadValuesArrayFromDB(Tokens& data,uint64 guid);
1349 static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
1350 static float GetFloatValueFromArray(Tokens const& data, uint16 index);
1351 static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid);
1352 static float GetFloatValueFromDB(uint16 index, uint64 guid);
1353 static uint32 GetZoneIdFromDB(uint64 guid);
1354 static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
1356 /*********************************************************/
1357 /*** SAVE SYSTEM ***/
1358 /*********************************************************/
1360 void SaveToDB();
1361 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1362 void SaveDataFieldToDB();
1363 static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
1364 static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value);
1365 static void SetFloatValueInArray(Tokens& data,uint16 index, float value);
1366 static void SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid);
1367 static void SetFloatValueInDB(uint16 index, float value, uint64 guid);
1368 static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
1369 static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid);
1371 bool m_mailsLoaded;
1372 bool m_mailsUpdated;
1374 void SetBindPoint(uint64 guid);
1375 void SendTalentWipeConfirm(uint64 guid);
1376 void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
1377 void SendPetSkillWipeConfirm();
1378 void CalcRage( uint32 damage,bool attacker );
1379 void RegenerateAll();
1380 void Regenerate(Powers power);
1381 void RegenerateHealth();
1382 void setRegenTimer(uint32 time) {m_regenTimer = time;}
1383 void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
1385 uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
1386 void ModifyMoney( int32 d )
1388 if(d < 0)
1389 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
1390 else
1391 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
1393 // "At Gold Limit"
1394 if(GetMoney() >= MAX_MONEY_AMOUNT)
1395 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL);
1397 void SetMoney( uint32 value )
1399 SetUInt32Value (PLAYER_FIELD_COINAGE, value);
1400 MoneyChanged( value );
1403 uint32 GetTutorialInt(uint32 intId )
1405 ASSERT( (intId < 8) );
1406 return m_Tutorials[intId];
1409 void SetTutorialInt(uint32 intId, uint32 value)
1411 ASSERT( (intId < 8) );
1412 if(m_Tutorials[intId]!=value)
1414 m_Tutorials[intId] = value;
1415 m_TutorialsChanged = true;
1419 QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
1421 const uint64& GetSelection( ) const { return m_curSelection; }
1422 void SetSelection(const uint64 &guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); }
1424 uint8 GetComboPoints() { return m_comboPoints; }
1425 const uint64& GetComboTarget() const { return m_comboTarget; }
1427 void AddComboPoints(Unit* target, int8 count);
1428 void ClearComboPoints();
1429 void SendComboPoints();
1431 void SendMailResult(uint32 mailId, uint32 mailAction, uint32 mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0);
1432 void SendNewMail();
1433 void UpdateNextMailTimeAndUnreads();
1434 void AddNewMailDeliverTime(time_t deliver_time);
1435 bool IsMailsLoaded() const { return m_mailsLoaded; }
1437 //void SetMail(Mail *m);
1438 void RemoveMail(uint32 id);
1440 void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
1441 uint32 GetMailSize() { return m_mail.size();};
1442 Mail* GetMail(uint32 id);
1444 PlayerMails::iterator GetmailBegin() { return m_mail.begin();};
1445 PlayerMails::iterator GetmailEnd() { return m_mail.end();};
1447 /*********************************************************/
1448 /*** MAILED ITEMS SYSTEM ***/
1449 /*********************************************************/
1451 uint8 unReadMails;
1452 time_t m_nextMailDelivereTime;
1454 typedef UNORDERED_MAP<uint32, Item*> ItemMap;
1456 ItemMap mMitems; //template defined in objectmgr.cpp
1458 Item* GetMItem(uint32 id)
1460 ItemMap::const_iterator itr = mMitems.find(id);
1461 return itr != mMitems.end() ? itr->second : NULL;
1464 void AddMItem(Item* it)
1466 ASSERT( it );
1467 //assert deleted, because items can be added before loading
1468 mMitems[it->GetGUIDLow()] = it;
1471 bool RemoveMItem(uint32 id)
1473 return mMitems.erase(id) ? true : false;
1476 void PetSpellInitialize();
1477 void CharmSpellInitialize();
1478 void PossessSpellInitialize();
1479 bool HasSpell(uint32 spell) const;
1480 bool HasActiveSpell(uint32 spell) const; // show in spellbook
1481 TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
1482 bool IsSpellFitByClassAndRace( uint32 spell_id ) const;
1483 bool IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const;
1485 void SendProficiency(uint8 pr1, uint32 pr2);
1486 void SendInitialSpells();
1487 bool addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled);
1488 void learnSpell(uint32 spell_id, bool dependent);
1489 void removeSpell(uint32 spell_id, bool disabled = false, bool update_action_bar_for_low_rank = false);
1490 void resetSpells();
1491 void learnDefaultSpells();
1492 void learnQuestRewardedSpells();
1493 void learnQuestRewardedSpells(Quest const* quest);
1494 void learnSpellHighRank(uint32 spellid);
1496 uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
1497 void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
1498 bool resetTalents(bool no_cost = false);
1499 uint32 resetTalentsCost() const;
1500 void InitTalentForLevel();
1502 uint32 CalculateTalentsPoints() const;
1504 void InitGlyphsForLevel();
1505 void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); }
1506 uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); }
1507 void SetGlyph(uint8 slot, uint32 glyph) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); }
1508 uint32 GetGlyph(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot); }
1510 uint32 GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); }
1511 void SetFreePrimaryProffesions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2,profs); }
1512 void InitPrimaryProffesions();
1514 PlayerSpellMap const& GetSpellMap() const { return m_spells; }
1515 PlayerSpellMap & GetSpellMap() { return m_spells; }
1517 void AddSpellMod(SpellModifier* mod, bool apply);
1518 bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL);
1519 template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL);
1520 void RemoveSpellMods(Spell const* spell);
1522 bool HasSpellCooldown(uint32 spell_id) const
1524 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1525 return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
1527 uint32 GetSpellCooldownDelay(uint32 spell_id) const
1529 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1530 time_t t = time(NULL);
1531 return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
1533 void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
1534 void SendCooldownEvent(SpellEntry const *spellInfo);
1535 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs );
1536 void RemoveSpellCooldown(uint32 spell_id) { m_spellCooldowns.erase(spell_id); }
1537 void RemoveArenaSpellCooldowns();
1538 void RemoveAllSpellCooldown();
1539 void _LoadSpellCooldowns(QueryResult *result);
1540 void _SaveSpellCooldowns();
1542 void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
1544 m_resurrectGUID = guid;
1545 m_resurrectMap = mapId;
1546 m_resurrectX = X;
1547 m_resurrectY = Y;
1548 m_resurrectZ = Z;
1549 m_resurrectHealth = health;
1550 m_resurrectMana = mana;
1552 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); }
1553 bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; }
1554 bool isRessurectRequested() const { return m_resurrectGUID != 0; }
1555 void ResurectUsingRequestData();
1557 int getCinematic()
1559 return m_cinematic;
1561 void setCinematic(int cine)
1563 m_cinematic = cine;
1566 void addActionButton(uint8 button, uint16 action, uint8 type, uint8 misc);
1567 void removeActionButton(uint8 button);
1568 void SendInitialActionButtons();
1570 PvPInfo pvpInfo;
1571 void UpdatePvP(bool state, bool ovrride=false);
1572 void UpdateZone(uint32 newZone);
1573 void UpdateArea(uint32 newArea);
1575 void UpdateZoneDependentAuras( uint32 zone_id ); // zones
1576 void UpdateAreaDependentAuras( uint32 area_id ); // subzones
1578 void UpdateAfkReport(time_t currTime);
1579 void UpdatePvPFlag(time_t currTime);
1580 void UpdateContestedPvP(uint32 currTime);
1581 void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
1582 void ResetContestedPvP()
1584 clearUnitState(UNIT_STAT_ATTACK_PLAYER);
1585 RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
1586 m_contestedPvPTimer = 0;
1589 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1590 DuelInfo *duel;
1591 void UpdateDuelFlag(time_t currTime);
1592 void CheckDuelDistance(time_t currTime);
1593 void DuelComplete(DuelCompleteType type);
1595 bool IsGroupVisibleFor(Player* p) const;
1596 bool IsInSameGroupWith(Player const* p) const;
1597 bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
1598 void UninviteFromGroup();
1599 static void RemoveFromGroup(Group* group, uint64 guid);
1600 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1601 void SendUpdateToOutOfRangeGroupMembers();
1603 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
1604 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
1605 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
1606 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
1607 static uint32 GetGuildIdFromDB(uint64 guid);
1608 uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
1609 static uint32 GetRankFromDB(uint64 guid);
1610 int GetGuildIdInvited() { return m_GuildIdInvited; }
1611 static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
1613 // Arena Team
1614 void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot)
1616 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId);
1618 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); }
1619 static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
1620 void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
1621 uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
1622 static void LeaveAllArenaTeams(uint64 guid);
1624 void SetDifficulty(uint32 dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; }
1625 uint8 GetDifficulty() { return m_dungeonDifficulty; }
1627 bool UpdateSkill(uint32 skill_id, uint32 step);
1628 bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step);
1630 bool UpdateCraftSkill(uint32 spellid);
1631 bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1);
1632 bool UpdateFishingSkill();
1634 uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); }
1635 uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const;
1637 uint32 GetSpellByProto(ItemPrototype *proto);
1639 float GetHealthBonusFromStamina();
1640 float GetManaBonusFromIntellect();
1642 bool UpdateStats(Stats stat);
1643 bool UpdateAllStats();
1644 void UpdateResistances(uint32 school);
1645 void UpdateArmor();
1646 void UpdateMaxHealth();
1647 void UpdateMaxPower(Powers power);
1648 void ApplyFeralAPBonus(int32 amount, bool apply);
1649 void UpdateAttackPowerAndDamage(bool ranged = false);
1650 void UpdateShieldBlockValue();
1651 void UpdateDamagePhysical(WeaponAttackType attType);
1652 void ApplySpellDamageBonus(int32 amount, bool apply);
1653 void ApplySpellHealingBonus(int32 amount, bool apply);
1654 void UpdateSpellDamageAndHealingBonus();
1656 void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage);
1658 void UpdateDefenseBonusesMod();
1659 void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
1660 float GetMeleeCritFromAgility();
1661 float GetDodgeFromAgility();
1662 float GetSpellCritFromIntellect();
1663 float OCTRegenHPPerSpirit();
1664 float OCTRegenMPPerSpirit();
1665 float GetRatingCoefficient(CombatRating cr) const;
1666 float GetRatingBonusValue(CombatRating cr) const;
1667 uint32 GetMeleeCritDamageReduction(uint32 damage) const;
1668 uint32 GetRangedCritDamageReduction(uint32 damage) const;
1669 uint32 GetSpellCritDamageReduction(uint32 damage) const;
1670 uint32 GetDotDamageReduction(uint32 damage) const;
1671 uint32 GetBaseSpellDamageBonus() { return m_baseSpellDamage;}
1672 uint32 GetBaseSpellHealingBonus() { return m_baseSpellHealing;}
1674 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
1675 void UpdateBlockPercentage();
1676 void UpdateCritPercentage(WeaponAttackType attType);
1677 void UpdateAllCritPercentages();
1678 void UpdateParryPercentage();
1679 void UpdateDodgePercentage();
1680 void UpdateMeleeHitChances();
1681 void UpdateRangedHitChances();
1682 void UpdateSpellHitChances();
1684 void UpdateAllSpellCritChances();
1685 void UpdateSpellCritChance(uint32 school);
1686 void UpdateExpertise(WeaponAttackType attType);
1687 void ApplyManaRegenBonus(int32 amount, bool apply);
1688 void UpdateManaRegen();
1690 const uint64& GetLootGUID() const { return m_lootGuid; }
1691 void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; }
1693 void RemovedInsignia(Player* looterPlr);
1695 WorldSession* GetSession() const { return m_session; }
1696 void SetSession(WorldSession *s) { m_session = s; }
1698 void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const;
1699 void DestroyForPlayer( Player *target ) const;
1700 void SendDelayResponse(const uint32);
1701 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
1703 //Low Level Packets
1704 void PlaySound(uint32 Sound, bool OnlySelf);
1705 //notifiers
1706 void SendAttackSwingCantAttack();
1707 void SendAttackSwingCancelAttack();
1708 void SendAttackSwingDeadTarget();
1709 void SendAttackSwingNotStanding();
1710 void SendAttackSwingNotInRange();
1711 void SendAttackSwingBadFacingAttack();
1712 void SendAutoRepeatCancel();
1713 void SendExplorationExperience(uint32 Area, uint32 Experience);
1715 void SendDungeonDifficulty(bool IsInGroup);
1716 void ResetInstances(uint8 method);
1717 void SendResetInstanceSuccess(uint32 MapId);
1718 void SendResetInstanceFailed(uint32 reason, uint32 MapId);
1719 void SendResetFailedNotify(uint32 mapid);
1721 bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
1722 void UpdateUnderwaterState( Map * m, float x, float y, float z );
1724 void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet
1725 void SendMessageToSetInRange(WorldPacket *data, float fist, bool self);
1726 // overwrite Object::SendMessageToSetInRange
1727 void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only);
1729 static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true);
1731 Corpse *GetCorpse() const;
1732 void SpawnCorpseBones();
1733 void CreateCorpse();
1734 void KillPlayer();
1735 uint32 GetResurrectionSpellId();
1736 void ResurrectPlayer(float restore_percent, bool applySickness = false);
1737 void BuildPlayerRepop();
1738 void RepopAtGraveyard();
1740 void DurabilityLossAll(double percent, bool inventory);
1741 void DurabilityLoss(Item* item, double percent);
1742 void DurabilityPointsLossAll(int32 points, bool inventory);
1743 void DurabilityPointsLoss(Item* item, int32 points);
1744 void DurabilityPointLossForEquipSlot(EquipmentSlots slot);
1745 uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank);
1746 uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank);
1748 void StopMirrorTimers()
1750 StopMirrorTimer(FATIGUE_TIMER);
1751 StopMirrorTimer(BREATH_TIMER);
1752 StopMirrorTimer(FIRE_TIMER);
1755 void SetMovement(PlayerMovementType pType);
1757 void JoinedChannel(Channel *c);
1758 void LeftChannel(Channel *c);
1759 void CleanupChannels();
1760 void UpdateLocalChannels( uint32 newZone );
1761 void LeaveLFGChannel();
1763 void UpdateDefense();
1764 void UpdateWeaponSkill (WeaponAttackType attType);
1765 void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence);
1767 void SetSkill(uint32 id, uint16 currVal, uint16 maxVal);
1768 uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
1769 uint16 GetPureMaxSkillValue(uint32 skill) const; // max
1770 uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
1771 uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus
1772 uint16 GetPureSkillValue(uint32 skill) const; // skill value
1773 int16 GetSkillPermBonusValue(uint32 skill) const;
1774 int16 GetSkillTempBonusValue(uint32 skill) const;
1775 bool HasSkill(uint32 skill) const;
1776 void learnSkillRewardedSpells(uint32 id, uint32 value);
1778 void SetDontMove(bool dontMove);
1779 bool GetDontMove() const { return m_dontMove; }
1781 void CheckExploreSystem(void);
1783 static uint32 TeamForRace(uint8 race);
1784 uint32 GetTeam() const { return m_team; }
1785 static uint32 getFactionForRace(uint8 race);
1786 void setFactionForRace(uint8 race);
1788 bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
1789 bool RewardPlayerAndGroupAtKill(Unit* pVictim);
1790 bool isHonorOrXPTarget(Unit* pVictim);
1792 FactionStateList m_factions;
1793 ForcedReactions m_forcedReactions;
1794 FactionStateList const& GetFactionStateList() { return m_factions; }
1795 uint32 GetDefaultReputationFlags(const FactionEntry *factionEntry) const;
1796 int32 GetBaseReputation(const FactionEntry *factionEntry) const;
1797 int32 GetReputation(uint32 faction_id) const;
1798 int32 GetReputation(const FactionEntry *factionEntry) const;
1799 ReputationRank GetReputationRank(uint32 faction) const;
1800 ReputationRank GetReputationRank(const FactionEntry *factionEntry) const;
1801 ReputationRank GetBaseReputationRank(const FactionEntry *factionEntry) const;
1802 ReputationRank ReputationToRank(int32 standing) const;
1803 const static int32 ReputationRank_Length[MAX_REPUTATION_RANK];
1804 const static int32 Reputation_Cap = 42999;
1805 const static int32 Reputation_Bottom = -42000;
1806 bool ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation);
1807 bool ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing);
1808 bool ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
1809 bool SetFactionReputation(uint32 FactionTemplateId, int32 standing);
1810 bool SetFactionReputation(FactionEntry const* factionEntry, int32 standing);
1811 bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
1812 int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest);
1813 void RewardReputation(Unit *pVictim, float rate);
1814 void RewardReputation(Quest const *pQuest);
1815 void SetInitialFactions();
1816 void UpdateReputation() const;
1817 void SendFactionState(FactionState const* faction) const;
1818 void SendInitialReputations();
1819 FactionState const* GetFactionState( FactionEntry const* factionEntry) const;
1820 void SetFactionAtWar(FactionState* faction, bool atWar);
1821 void SetFactionInactive(FactionState* faction, bool inactive);
1822 void SetFactionVisible(FactionState* faction);
1823 void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId);
1824 void SetFactionVisibleForFactionId(uint32 FactionId);
1825 void UpdateSkillsForLevel();
1826 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1827 void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
1829 /*********************************************************/
1830 /*** PVP SYSTEM ***/
1831 /*********************************************************/
1832 void UpdateArenaFields();
1833 void UpdateHonorFields();
1834 bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1);
1835 uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
1836 uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
1837 void ModifyHonorPoints( int32 value );
1838 void ModifyArenaPoints( int32 value );
1839 uint32 GetMaxPersonalArenaRatingRequirement();
1841 //End of PvP System
1843 void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0);
1844 uint16 GetDrunkValue() const { return m_drunk; }
1845 static DrunkenState GetDrunkenstateByValue(uint16 value);
1847 uint32 GetDeathTimer() const { return m_deathTimer; }
1848 uint32 GetCorpseReclaimDelay(bool pvp) const;
1849 void UpdateCorpseReclaimDelay();
1850 void SendCorpseReclaimDelay(bool load = false);
1852 uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual)
1853 bool CanParry() const { return m_canParry; }
1854 void SetCanParry(bool value);
1855 bool CanBlock() const { return m_canBlock; }
1856 void SetCanBlock(bool value);
1857 bool CanDualWield() const { return m_canDualWield; }
1858 void SetCanDualWield(bool value) { m_canDualWield = value; }
1859 bool CanTitanGrip() const { return m_canTitanGrip ; }
1860 void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
1862 void SetRegularAttackTime();
1863 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }
1864 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply);
1865 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
1866 float GetTotalBaseModValue(BaseModGroup modGroup) const;
1867 float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; }
1868 void _ApplyAllStatBonuses();
1869 void _RemoveAllStatBonuses();
1871 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
1872 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1873 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1875 void _ApplyItemMods(Item *item,uint8 slot,bool apply);
1876 void _RemoveAllItemMods();
1877 void _ApplyAllItemMods();
1878 void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply);
1879 void _ApplyAmmoBonuses();
1880 bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot);
1881 void ToggleMetaGemsActive(uint8 exceptslot, bool apply);
1882 void CorrectMetaGemEnchants(uint8 slot, bool apply);
1883 void InitDataForForm(bool reapplyMods = false);
1885 void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
1886 void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
1887 void UpdateEquipSpellsAtFormChange();
1888 void CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType);
1889 void CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex);
1891 void SendInitWorldStates();
1892 void SendUpdateWorldState(uint32 Field, uint32 Value);
1893 void SendDirectMessage(WorldPacket *data);
1895 void SendAurasForTarget(Unit *target);
1897 PlayerMenu* PlayerTalkClass;
1898 std::vector<ItemSetEffect *> ItemSetEff;
1900 void SendLoot(uint64 guid, LootType loot_type);
1901 void SendLootRelease( uint64 guid );
1902 void SendNotifyLootItemRemoved(uint8 lootSlot);
1903 void SendNotifyLootMoneyRemoved();
1905 /*********************************************************/
1906 /*** BATTLEGROUND SYSTEM ***/
1907 /*********************************************************/
1909 bool InBattleGround() const { return m_bgBattleGroundID != 0; }
1910 uint32 GetBattleGroundId() const { return m_bgBattleGroundID; }
1911 BattleGround* GetBattleGround() const;
1912 bool InArena() const;
1914 static uint32 GetMinLevelForBattleGroundQueueId(uint32 queue_id);
1915 static uint32 GetMaxLevelForBattleGroundQueueId(uint32 queue_id);
1916 uint32 GetBattleGroundQueueIdFromLevel() const;
1918 bool InBattleGroundQueue() const
1920 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1921 if (m_bgBattleGroundQueueID[i].bgQueueType != 0)
1922 return true;
1923 return false;
1926 uint32 GetBattleGroundQueueId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueType; }
1927 uint32 GetBattleGroundQueueIndex(uint32 bgQueueType) const
1929 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1930 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
1931 return i;
1932 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1934 bool IsInvitedForBattleGroundQueueType(uint32 bgQueueType) const
1936 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1937 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
1938 return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
1939 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1941 bool InBattleGroundQueueForBattleGroundQueueType(uint32 bgQueueType) const
1943 return GetBattleGroundQueueIndex(bgQueueType) < PLAYER_MAX_BATTLEGROUND_QUEUES;
1946 void SetBattleGroundId(uint32 val) { m_bgBattleGroundID = val; }
1947 uint32 AddBattleGroundQueueId(uint32 val)
1949 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1951 if (m_bgBattleGroundQueueID[i].bgQueueType == 0 || m_bgBattleGroundQueueID[i].bgQueueType == val)
1953 m_bgBattleGroundQueueID[i].bgQueueType = val;
1954 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
1955 return i;
1958 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1960 bool HasFreeBattleGroundQueueId()
1962 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1963 if (m_bgBattleGroundQueueID[i].bgQueueType == 0)
1964 return true;
1965 return false;
1967 void RemoveBattleGroundQueueId(uint32 val)
1969 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1971 if (m_bgBattleGroundQueueID[i].bgQueueType == val)
1973 m_bgBattleGroundQueueID[i].bgQueueType = 0;
1974 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
1975 return;
1979 void SetInviteForBattleGroundQueueType(uint32 bgQueueType, uint32 instanceId)
1981 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1982 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
1983 m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
1985 bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
1987 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1988 if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
1989 return true;
1990 return false;
1992 uint32 GetBattleGroundEntryPointMap() const { return m_bgEntryPointMap; }
1993 float GetBattleGroundEntryPointX() const { return m_bgEntryPointX; }
1994 float GetBattleGroundEntryPointY() const { return m_bgEntryPointY; }
1995 float GetBattleGroundEntryPointZ() const { return m_bgEntryPointZ; }
1996 float GetBattleGroundEntryPointO() const { return m_bgEntryPointO; }
1997 void SetBattleGroundEntryPoint(uint32 Map, float PosX, float PosY, float PosZ, float PosO )
1999 m_bgEntryPointMap = Map;
2000 m_bgEntryPointX = PosX;
2001 m_bgEntryPointY = PosY;
2002 m_bgEntryPointZ = PosZ;
2003 m_bgEntryPointO = PosO;
2006 void SetBGTeam(uint32 team) { m_bgTeam = team; }
2007 uint32 GetBGTeam() const { return m_bgTeam ? m_bgTeam : GetTeam(); }
2009 void LeaveBattleground(bool teleportToEntryPoint = true);
2010 bool CanJoinToBattleground() const;
2011 bool CanReportAfkDueToLimit();
2012 void ReportedAfkBy(Player* reporter);
2013 void ClearAfkReports() { m_bgAfkReporter.clear(); }
2015 bool GetBGAccessByLevel(uint32 bgTypeId) const;
2016 bool isAllowUseBattleGroundObject();
2018 /*********************************************************/
2019 /*** REST SYSTEM ***/
2020 /*********************************************************/
2022 bool isRested() const { return GetRestTime() >= 10000; }
2023 uint32 GetXPRestBonus(uint32 xp);
2024 uint32 GetRestTime() const { return m_restTime;};
2025 void SetRestTime(uint32 v) { m_restTime = v;};
2027 /*********************************************************/
2028 /*** ENVIROMENTAL SYSTEM ***/
2029 /*********************************************************/
2031 void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage);
2033 /*********************************************************/
2034 /*** FLOOD FILTER SYSTEM ***/
2035 /*********************************************************/
2037 void UpdateSpeakTime();
2038 bool CanSpeak() const;
2039 void ChangeSpeakTime(int utime);
2041 /*********************************************************/
2042 /*** VARIOUS SYSTEMS ***/
2043 /*********************************************************/
2044 MovementInfo m_movementInfo;
2045 uint32 m_lastFallTime;
2046 float m_lastFallZ;
2047 Unit *m_mover;
2048 void SetFallInformation(uint32 time, float z)
2050 m_lastFallTime = time;
2051 m_lastFallZ = z;
2053 bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); }
2054 bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); }
2056 bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); }
2057 bool IsFlying() const { return HasUnitMovementFlag(MOVEMENTFLAG_FLYING); }
2058 bool IsAllowUseFlyMountsHere() const;
2060 void HandleDrowning();
2062 void SetClientControl(Unit* target, uint8 allowMove);
2064 void EnterVehicle(Vehicle *vehicle);
2065 void ExitVehicle(Vehicle *vehicle);
2067 uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
2068 void SetFarSightGUID(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); }
2070 // Transports
2071 Transport * GetTransport() const { return m_transport; }
2072 void SetTransport(Transport * t) { m_transport = t; }
2074 float GetTransOffsetX() const { return m_movementInfo.t_x; }
2075 float GetTransOffsetY() const { return m_movementInfo.t_y; }
2076 float GetTransOffsetZ() const { return m_movementInfo.t_z; }
2077 float GetTransOffsetO() const { return m_movementInfo.t_o; }
2078 uint32 GetTransTime() const { return m_movementInfo.t_time; }
2079 int8 GetTransSeat() const { return m_movementInfo.t_seat; }
2081 uint32 GetSaveTimer() const { return m_nextSave; }
2082 void SetSaveTimer(uint32 timer) { m_nextSave = timer; }
2084 // Recall position
2085 uint32 m_recallMap;
2086 float m_recallX;
2087 float m_recallY;
2088 float m_recallZ;
2089 float m_recallO;
2090 void SaveRecallPosition();
2092 // Homebind coordinates
2093 uint32 m_homebindMapId;
2094 uint16 m_homebindZoneId;
2095 float m_homebindX;
2096 float m_homebindY;
2097 float m_homebindZ;
2099 // currently visible objects at player client
2100 typedef std::set<uint64> ClientGUIDs;
2101 ClientGUIDs m_clientGUIDs;
2103 bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); }
2105 bool IsVisibleInGridForPlayer(Player* pl) const;
2106 bool IsVisibleGloballyFor(Player* pl) const;
2108 void UpdateVisibilityOf(WorldObject* target);
2110 template<class T>
2111 void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
2113 // Stealth detection system
2114 uint32 m_DetectInvTimer;
2115 void HandleStealthedUnitsDetection();
2117 uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
2119 bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; }
2120 void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
2122 LookingForGroup m_lookingForGroup;
2124 // Temporarily removed pet cache
2125 uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
2126 void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
2127 uint32 GetOldPetSpell() const { return m_oldpetspell; }
2128 void SetOldPetSpell(uint32 petspell) { m_oldpetspell = petspell; }
2130 /*********************************************************/
2131 /*** INSTANCE SYSTEM ***/
2132 /*********************************************************/
2134 typedef UNORDERED_MAP< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap;
2136 void UpdateHomebindTime(uint32 time);
2138 uint32 m_HomebindTimer;
2139 bool m_InstanceValid;
2140 // permanent binds and solo binds by difficulty
2141 BoundInstancesMap m_boundInstances[TOTAL_DIFFICULTIES];
2142 InstancePlayerBind* GetBoundInstance(uint32 mapid, uint8 difficulty);
2143 BoundInstancesMap& GetBoundInstances(uint8 difficulty) { return m_boundInstances[difficulty]; }
2144 void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false);
2145 void UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload = false);
2146 InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false);
2147 void SendRaidInfo();
2148 void SendSavedInstances();
2149 static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0);
2151 /*********************************************************/
2152 /*** GROUP SYSTEM ***/
2153 /*********************************************************/
2155 Group * GetGroupInvite() { return m_groupInvite; }
2156 void SetGroupInvite(Group *group) { m_groupInvite = group; }
2157 Group * GetGroup() { return m_group.getTarget(); }
2158 const Group * GetGroup() const { return (const Group*)m_group.getTarget(); }
2159 GroupReference& GetGroupRef() { return m_group; }
2160 void SetGroup(Group *group, int8 subgroup = -1);
2161 uint8 GetSubGroup() const { return m_group.getSubGroup(); }
2162 uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; }
2163 void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
2164 const uint64& GetAuraUpdateMask() const { return m_auraUpdateMask; }
2165 void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
2166 Player* GetNextRandomRaidMember(float radius);
2167 PartyResult CanUninviteFromGroup() const;
2169 GridReference<Player> &GetGridRef() { return m_gridRef; }
2170 MapReference &GetMapRef() { return m_mapRef; }
2172 bool isAllowedToLoot(Creature* creature);
2174 WorldLocation& GetTeleportDest() { return m_teleport_dest; }
2176 DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
2177 uint8 GetRunesState() const { return m_runes->runeState; }
2178 uint8 GetBaseRune(uint8 index) const { return m_runes->runes[index].BaseRune; }
2179 uint8 GetCurrentRune(uint8 index) const { return m_runes->runes[index].CurrentRune; }
2180 uint8 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; }
2181 void SetBaseRune(uint8 index, uint8 baseRune) { m_runes->runes[index].BaseRune = baseRune; }
2182 void SetCurrentRune(uint8 index, uint8 currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
2183 void SetRuneCooldown(uint8 index, uint8 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); }
2184 void ConvertRune(uint8 index, uint8 newType);
2185 void ResyncRunes(uint8 count);
2186 void AddRunePower(uint8 index);
2187 void InitRunes();
2188 AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
2189 bool HasTitle(uint32 bitIndex);
2190 bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }
2191 void SetTitle(CharTitlesEntry const* title);
2193 protected:
2195 /*********************************************************/
2196 /*** BATTLEGROUND SYSTEM ***/
2197 /*********************************************************/
2199 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2200 uint32 m_bgBattleGroundID;
2202 this is an array of BG queues (BgTypeIDs) in which is player
2204 struct BgBattleGroundQueueID_Rec
2206 uint32 bgQueueType;
2207 uint32 invitedToInstance;
2209 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES];
2210 uint32 m_bgEntryPointMap;
2211 float m_bgEntryPointX;
2212 float m_bgEntryPointY;
2213 float m_bgEntryPointZ;
2214 float m_bgEntryPointO;
2216 std::set<uint32> m_bgAfkReporter;
2217 uint8 m_bgAfkReportedCount;
2218 time_t m_bgAfkReportedTimer;
2219 uint32 m_contestedPvPTimer;
2221 uint32 m_bgTeam; // what side the player will be added to
2223 /*********************************************************/
2224 /*** QUEST SYSTEM ***/
2225 /*********************************************************/
2227 std::set<uint32> m_timedquests;
2229 uint64 m_divider;
2230 uint32 m_ingametime;
2232 /*********************************************************/
2233 /*** LOAD SYSTEM ***/
2234 /*********************************************************/
2236 void _LoadActions(QueryResult *result);
2237 void _LoadAuras(QueryResult *result, uint32 timediff);
2238 void _LoadGlyphAuras();
2239 void _LoadBoundInstances(QueryResult *result);
2240 void _LoadInventory(QueryResult *result, uint32 timediff);
2241 void _LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery);
2242 void _LoadMail();
2243 void _LoadMailedItems(Mail *mail);
2244 void _LoadQuestStatus(QueryResult *result);
2245 void _LoadDailyQuestStatus(QueryResult *result);
2246 void _LoadGroup(QueryResult *result);
2247 void _LoadReputation(QueryResult *result);
2248 void _LoadSkills();
2249 void _LoadSpells(QueryResult *result);
2250 void _LoadTutorials(QueryResult *result);
2251 void _LoadFriendList(QueryResult *result);
2252 bool _LoadHomeBind(QueryResult *result);
2253 void _LoadDeclinedNames(QueryResult *result);
2254 void _LoadArenaTeamInfo(QueryResult *result);
2256 /*********************************************************/
2257 /*** SAVE SYSTEM ***/
2258 /*********************************************************/
2260 void _SaveActions();
2261 void _SaveAuras();
2262 void _SaveInventory();
2263 void _SaveMail();
2264 void _SaveQuestStatus();
2265 void _SaveDailyQuestStatus();
2266 void _SaveReputation();
2267 void _SaveSpells();
2268 void _SaveTutorials();
2270 void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
2271 void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
2273 /*********************************************************/
2274 /*** ENVIRONMENTAL SYSTEM ***/
2275 /*********************************************************/
2276 void HandleLava();
2277 void HandleSobering();
2278 void StartMirrorTimer(MirrorTimerType Type, uint32 MaxValue);
2279 void ModifyMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, uint32 Regen);
2280 void StopMirrorTimer(MirrorTimerType Type);
2281 uint8 m_isunderwater;
2282 bool m_isInWater;
2284 /*********************************************************/
2285 /*** HONOR SYSTEM ***/
2286 /*********************************************************/
2287 time_t m_lastHonorUpdateTime;
2289 void outDebugValues() const;
2290 uint64 m_lootGuid;
2292 uint32 m_race;
2293 uint32 m_class;
2294 uint32 m_team;
2295 uint32 m_nextSave;
2296 time_t m_speakTime;
2297 uint32 m_speakCount;
2298 uint32 m_dungeonDifficulty;
2300 uint32 m_atLoginFlags;
2302 Item* m_items[PLAYER_SLOTS_COUNT];
2303 uint32 m_currentBuybackSlot;
2305 std::vector<Item*> m_itemUpdateQueue;
2306 bool m_itemUpdateQueueBlocked;
2308 uint32 m_ExtraFlags;
2309 uint64 m_curSelection;
2311 uint64 m_comboTarget;
2312 int8 m_comboPoints;
2314 QuestStatusMap mQuestStatus;
2316 uint32 m_GuildIdInvited;
2317 uint32 m_ArenaTeamIdInvited;
2319 PlayerMails m_mail;
2320 PlayerSpellMap m_spells;
2321 SpellCooldowns m_spellCooldowns;
2323 ActionButtonList m_actionButtons;
2325 float m_auraBaseMod[BASEMOD_END][MOD_END];
2326 int16 m_baseRatingValue[MAX_COMBAT_RATING];
2327 uint16 m_baseSpellDamage;
2328 uint16 m_baseSpellHealing;
2329 uint16 m_baseFeralAP;
2330 uint16 m_baseManaRegen;
2332 SpellModList m_spellMods[MAX_SPELLMOD];
2333 int32 m_SpellModRemoveCount;
2334 EnchantDurationList m_enchantDuration;
2335 ItemDurationList m_itemDuration;
2337 uint64 m_resurrectGUID;
2338 uint32 m_resurrectMap;
2339 float m_resurrectX, m_resurrectY, m_resurrectZ;
2340 uint32 m_resurrectHealth, m_resurrectMana;
2342 WorldSession *m_session;
2344 typedef std::list<Channel*> JoinedChannelsList;
2345 JoinedChannelsList m_channels;
2347 bool m_dontMove;
2349 int m_cinematic;
2351 Player *pTrader;
2352 bool acceptTrade;
2353 uint16 tradeItems[TRADE_SLOT_COUNT];
2354 uint32 tradeGold;
2356 time_t m_nextThinkTime;
2358 uint32 m_Tutorials[8];
2359 bool m_TutorialsChanged;
2361 bool m_DailyQuestChanged;
2362 time_t m_lastDailyQuestTime;
2364 uint32 m_breathTimer;
2365 uint32 m_drunkTimer;
2366 uint16 m_drunk;
2367 uint32 m_weaponChangeTimer;
2369 uint32 m_zoneUpdateId;
2370 uint32 m_zoneUpdateTimer;
2371 uint32 m_areaUpdateId;
2373 uint32 m_deathTimer;
2374 time_t m_deathExpireTime;
2376 uint32 m_restTime;
2378 uint32 m_WeaponProficiency;
2379 uint32 m_ArmorProficiency;
2380 bool m_canParry;
2381 bool m_canBlock;
2382 bool m_canDualWield;
2383 bool m_canTitanGrip;
2384 uint8 m_swingErrorMsg;
2385 float m_ammoDPS;
2387 ////////////////////Rest System/////////////////////
2388 int time_inn_enter;
2389 uint32 inn_pos_mapid;
2390 float inn_pos_x;
2391 float inn_pos_y;
2392 float inn_pos_z;
2393 float m_rest_bonus;
2394 RestType rest_type;
2395 ////////////////////Rest System/////////////////////
2397 // Transports
2398 Transport * m_transport;
2400 uint32 m_resetTalentsCost;
2401 time_t m_resetTalentsTime;
2402 uint32 m_usedTalentCount;
2403 uint32 m_questRewardTalentCount;
2405 // Social
2406 PlayerSocial *m_social;
2408 // Groups
2409 GroupReference m_group;
2410 Group *m_groupInvite;
2411 uint32 m_groupUpdateMask;
2412 uint64 m_auraUpdateMask;
2414 // Temporarily removed pet cache
2415 uint32 m_temporaryUnsummonedPetNumber;
2416 uint32 m_oldpetspell;
2418 uint64 m_miniPet;
2419 GuardianPetList m_guardianPets;
2421 // Player summoning
2422 time_t m_summon_expire;
2423 uint32 m_summon_mapid;
2424 float m_summon_x;
2425 float m_summon_y;
2426 float m_summon_z;
2428 // Far Teleport
2429 WorldLocation m_teleport_dest;
2431 DeclinedName *m_declinedname;
2432 Runes *m_runes;
2433 AchievementMgr m_achievementMgr;
2434 private:
2435 // internal common parts for CanStore/StoreItem functions
2436 uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
2437 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;
2438 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;
2439 Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
2441 GridReference<Player> m_gridRef;
2442 MapReference m_mapRef;
2445 void AddItemsSetItem(Player*player,Item *item);
2446 void RemoveItemsSetItem(Player*player,ItemPrototype const *proto);
2448 // "the bodies of template functions must be made available in a header file"
2449 template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell)
2451 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
2452 if (!spellInfo) return 0;
2453 int32 totalpct = 0;
2454 int32 totalflat = 0;
2455 for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
2457 SpellModifier *mod = *itr;
2459 if(!IsAffectedBySpellmod(spellInfo,mod,spell))
2460 continue;
2461 if (mod->type == SPELLMOD_FLAT)
2462 totalflat += mod->value;
2463 else if (mod->type == SPELLMOD_PCT)
2465 // skip percent mods for null basevalue (most important for spell mods with charges )
2466 if(basevalue == T(0))
2467 continue;
2469 // special case (skip >10sec spell casts for instant cast setting)
2470 if( mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10000) && mod->value <= -100)
2471 continue;
2473 totalpct += mod->value;
2476 if (mod->charges > 0 )
2478 --mod->charges;
2479 if (mod->charges == 0)
2481 mod->charges = -1;
2482 mod->lastAffected = spell;
2483 if(!mod->lastAffected)
2484 mod->lastAffected = FindCurrentSpellBySpellId(spellId);
2485 ++m_SpellModRemoveCount;
2490 float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat;
2491 basevalue = T((float)basevalue + diff);
2492 return T(diff);
2494 #endif