Merge branch 'master' into 303
[getmangos.git] / src / game / Player.h
blobba9c251c1f98b04ec21b9ade6b856d4e8949fb3b
1 /*
2 * Copyright (C) 2005-2008 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 PlayerSocial;
50 class AchievementMgr;
51 class Vehicle;
53 typedef std::deque<Mail*> PlayerMails;
55 #define PLAYER_MAX_SKILLS 127
56 #define PLAYER_MAX_DAILY_QUESTS 25
58 // Note: SPELLMOD_* values is aura types in fact
59 enum SpellModType
61 SPELLMOD_FLAT = 107, // SPELL_AURA_ADD_FLAT_MODIFIER
62 SPELLMOD_PCT = 108 // SPELL_AURA_ADD_PCT_MODIFIER
65 enum PlayerSpellState
67 PLAYERSPELL_UNCHANGED = 0,
68 PLAYERSPELL_CHANGED = 1,
69 PLAYERSPELL_NEW = 2,
70 PLAYERSPELL_REMOVED = 3
73 struct PlayerSpell
75 uint16 slotId : 16;
76 PlayerSpellState state : 8;
77 bool active : 1;
78 bool disabled : 1;
81 #define SPELL_WITHOUT_SLOT_ID uint16(-1)
83 // Spell modifier (used for modify other spells)
84 struct SpellModifier
86 SpellModifier() : charges(0), lastAffected(NULL) {}
87 SpellModOp op : 8;
88 SpellModType type : 8;
89 int16 charges : 16;
90 int32 value;
91 uint64 mask;
92 uint64 mask2;
93 uint32 spellId;
94 Spell const* lastAffected;
97 typedef UNORDERED_MAP<uint16, PlayerSpell*> PlayerSpellMap;
98 typedef std::list<SpellModifier*> SpellModList;
100 struct SpellCooldown
102 time_t end;
103 uint16 itemid;
106 typedef std::map<uint32, SpellCooldown> SpellCooldowns;
108 enum TrainerSpellState
110 TRAINER_SPELL_GREEN = 0,
111 TRAINER_SPELL_RED = 1,
112 TRAINER_SPELL_GRAY = 2
115 enum ActionButtonUpdateState
117 ACTIONBUTTON_UNCHANGED = 0,
118 ACTIONBUTTON_CHANGED = 1,
119 ACTIONBUTTON_NEW = 2,
120 ACTIONBUTTON_DELETED = 3
123 struct ActionButton
125 ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW ) {}
126 ActionButton(uint16 _action, uint8 _type, uint8 _misc) : action(_action), type(_type), misc(_misc), uState( ACTIONBUTTON_NEW ) {}
128 uint16 action;
129 uint8 type;
130 uint8 misc;
131 ActionButtonUpdateState uState;
134 enum ActionButtonType
136 ACTION_BUTTON_SPELL = 0,
137 ACTION_BUTTON_MACRO = 64,
138 ACTION_BUTTON_CMACRO= 65,
139 ACTION_BUTTON_ITEM = 128
142 #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0
144 typedef std::map<uint8,ActionButton> ActionButtonList;
146 typedef std::pair<uint16, uint8> CreateSpellPair;
148 struct PlayerCreateInfoItem
150 PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {}
152 uint32 item_id;
153 uint32 item_amount;
156 typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
158 struct PlayerClassLevelInfo
160 PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
161 uint16 basehealth;
162 uint16 basemana;
165 struct PlayerClassInfo
167 PlayerClassInfo() : levelInfo(NULL) { }
169 PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
172 struct PlayerLevelInfo
174 PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
176 uint8 stats[MAX_STATS];
179 struct PlayerInfo
181 // existence checked by displayId != 0 // existence checked by displayId != 0
182 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL)
186 uint32 mapId;
187 uint32 zoneId;
188 float positionX;
189 float positionY;
190 float positionZ;
191 uint16 displayId_m;
192 uint16 displayId_f;
193 PlayerCreateInfoItems item;
194 std::list<CreateSpellPair> spell;
195 std::list<uint16> action[4];
197 PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1
200 struct PvPInfo
202 PvPInfo() : inHostileArea(false), endTimer(0) {}
204 bool inHostileArea;
205 time_t endTimer;
208 struct DuelInfo
210 DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {}
212 Player *initiator;
213 Player *opponent;
214 time_t startTimer;
215 time_t startTime;
216 time_t outOfBound;
219 struct Areas
221 uint32 areaID;
222 uint32 areaFlag;
223 float x1;
224 float x2;
225 float y1;
226 float y2;
229 #define MAX_RUNES 6
230 #define RUNE_COOLDOWN 5 // 5*2=10 sec
232 enum RuneType
234 RUNE_BLOOD = 0,
235 RUNE_UNHOLY = 1,
236 RUNE_FROST = 2,
237 RUNE_DEATH = 3,
238 NUM_RUNE_TYPES = 4
241 struct RuneInfo
243 uint8 BaseRune;
244 uint8 CurrentRune;
245 uint8 Cooldown;
248 struct Runes
250 RuneInfo runes[MAX_RUNES];
251 uint8 runeState; // mask of available runes
253 void SetRuneState(uint8 index, bool set = true)
255 if(set)
256 runeState |= (1 << index); // usable
257 else
258 runeState &= ~(1 << index); // on cooldown
262 enum FactionFlags
264 FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction)
265 FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
266 FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
267 FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
268 FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
269 FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE )
270 FACTION_FLAG_RIVAL = 0x40 // flag for the two competing outland factions
273 typedef uint32 RepListID;
274 struct FactionState
276 uint32 ID;
277 RepListID ReputationListID;
278 uint32 Flags;
279 int32 Standing;
280 bool Changed;
283 typedef std::map<RepListID,FactionState> FactionStateList;
285 typedef std::map<uint32,ReputationRank> ForcedReactions;
287 typedef std::set<uint64> GuardianPetList;
289 struct EnchantDuration
291 EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {};
292 EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { assert(item); };
294 Item * item;
295 EnchantmentSlot slot;
296 uint32 leftduration;
299 typedef std::list<EnchantDuration> EnchantDurationList;
300 typedef std::list<Item*> ItemDurationList;
302 struct LookingForGroupSlot
304 LookingForGroupSlot() : entry(0), type(0) {}
305 bool Empty() const { return !entry && !type; }
306 void Clear() { entry = 0; type = 0; }
307 void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; }
308 bool Is(uint32 _entry, uint32 _type) const { return entry==_entry && type==_type; }
309 bool canAutoJoin() const { return entry && (type == 1 || type == 5); }
311 uint32 entry;
312 uint32 type;
315 #define MAX_LOOKING_FOR_GROUP_SLOT 3
317 struct LookingForGroup
319 LookingForGroup() {}
320 bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry,slot.type); }
321 bool HaveInSlot(uint32 _entry, uint32 _type) const
323 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
324 if(slots[i].Is(_entry,_type))
325 return true;
326 return false;
329 bool canAutoJoin() const
331 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
332 if(slots[i].canAutoJoin())
333 return true;
334 return false;
337 bool Empty() const
339 for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
340 if(!slots[i].Empty())
341 return false;
342 return more.Empty();
345 LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT];
346 LookingForGroupSlot more;
347 std::string comment;
350 enum PlayerMovementType
352 MOVE_ROOT = 1,
353 MOVE_UNROOT = 2,
354 MOVE_WATER_WALK = 3,
355 MOVE_LAND_WALK = 4
358 enum DrunkenState
360 DRUNKEN_SOBER = 0,
361 DRUNKEN_TIPSY = 1,
362 DRUNKEN_DRUNK = 2,
363 DRUNKEN_SMASHED = 3
366 enum PlayerStateType
369 PLAYER_STATE_DANCE
370 PLAYER_STATE_SLEEP
371 PLAYER_STATE_SIT
372 PLAYER_STATE_STAND
373 PLAYER_STATE_READYUNARMED
374 PLAYER_STATE_WORK
375 PLAYER_STATE_POINT(DNR)
376 PLAYER_STATE_NONE // not used or just no state, just standing there?
377 PLAYER_STATE_STUN
378 PLAYER_STATE_DEAD
379 PLAYER_STATE_KNEEL
380 PLAYER_STATE_USESTANDING
381 PLAYER_STATE_STUN_NOSHEATHE
382 PLAYER_STATE_USESTANDING_NOSHEATHE
383 PLAYER_STATE_WORK_NOSHEATHE
384 PLAYER_STATE_SPELLPRECAST
385 PLAYER_STATE_READYRIFLE
386 PLAYER_STATE_WORK_NOSHEATHE_MINING
387 PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD
388 PLAYER_STATE_AT_EASE
389 PLAYER_STATE_READY1H
390 PLAYER_STATE_SPELLKNEELSTART
391 PLAYER_STATE_SUBMERGED
394 PLAYER_STATE_NONE = 0,
395 PLAYER_STATE_SIT = 1,
396 PLAYER_STATE_SIT_CHAIR = 2,
397 PLAYER_STATE_SLEEP = 3,
398 PLAYER_STATE_SIT_LOW_CHAIR = 4,
399 PLAYER_STATE_SIT_MEDIUM_CHAIR = 5,
400 PLAYER_STATE_SIT_HIGH_CHAIR = 6,
401 PLAYER_STATE_DEAD = 7,
402 PLAYER_STATE_KNEEL = 8,
404 PLAYER_STATE_FORM_ALL = 0x00FF0000,
406 PLAYER_STATE_FLAG_ALWAYS_STAND = 0x01, // byte 4
407 PLAYER_STATE_FLAG_CREEP = 0x02000000,
408 PLAYER_STATE_FLAG_UNTRACKABLE = 0x04000000,
409 PLAYER_STATE_FLAG_ALL = 0xFF000000,
412 enum PlayerFlags
414 PLAYER_FLAGS_GROUP_LEADER = 0x00000001,
415 PLAYER_FLAGS_AFK = 0x00000002,
416 PLAYER_FLAGS_DND = 0x00000004,
417 PLAYER_FLAGS_GM = 0x00000008,
418 PLAYER_FLAGS_GHOST = 0x00000010,
419 PLAYER_FLAGS_RESTING = 0x00000020,
420 PLAYER_FLAGS_FFA_PVP = 0x00000080,
421 PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
422 PLAYER_FLAGS_IN_PVP = 0x00000200,
423 PLAYER_FLAGS_HIDE_HELM = 0x00000400,
424 PLAYER_FLAGS_HIDE_CLOAK = 0x00000800,
425 PLAYER_FLAGS_UNK1 = 0x00001000, // played long time
426 PLAYER_FLAGS_UNK2 = 0x00002000, // played too long time
427 PLAYER_FLAGS_UNK3 = 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
428 PLAYER_FLAGS_SANCTUARY = 0x00010000, // player entered sanctuary
429 PLAYER_FLAGS_UNK4 = 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
430 PLAYER_FLAGS_PVP_TIMER = 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
433 // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
434 // can't use enum for uint64 values
435 #define PLAYER_TITLE_DISABLED 0x0000000000000000LL
436 #define PLAYER_TITLE_NONE 0x0000000000000001LL
437 #define PLAYER_TITLE_PRIVATE 0x0000000000000002LL // 1
438 #define PLAYER_TITLE_CORPORAL 0x0000000000000004LL // 2
439 #define PLAYER_TITLE_SERGEANT_A 0x0000000000000008LL // 3
440 #define PLAYER_TITLE_MASTER_SERGEANT 0x0000000000000010LL // 4
441 #define PLAYER_TITLE_SERGEANT_MAJOR 0x0000000000000020LL // 5
442 #define PLAYER_TITLE_KNIGHT 0x0000000000000040LL // 6
443 #define PLAYER_TITLE_KNIGHT_LIEUTENANT 0x0000000000000080LL // 7
444 #define PLAYER_TITLE_KNIGHT_CAPTAIN 0x0000000000000100LL // 8
445 #define PLAYER_TITLE_KNIGHT_CHAMPION 0x0000000000000200LL // 9
446 #define PLAYER_TITLE_LIEUTENANT_COMMANDER 0x0000000000000400LL // 10
447 #define PLAYER_TITLE_COMMANDER 0x0000000000000800LL // 11
448 #define PLAYER_TITLE_MARSHAL 0x0000000000001000LL // 12
449 #define PLAYER_TITLE_FIELD_MARSHAL 0x0000000000002000LL // 13
450 #define PLAYER_TITLE_GRAND_MARSHAL 0x0000000000004000LL // 14
451 #define PLAYER_TITLE_SCOUT 0x0000000000008000LL // 15
452 #define PLAYER_TITLE_GRUNT 0x0000000000010000LL // 16
453 #define PLAYER_TITLE_SERGEANT_H 0x0000000000020000LL // 17
454 #define PLAYER_TITLE_SENIOR_SERGEANT 0x0000000000040000LL // 18
455 #define PLAYER_TITLE_FIRST_SERGEANT 0x0000000000080000LL // 19
456 #define PLAYER_TITLE_STONE_GUARD 0x0000000000100000LL // 20
457 #define PLAYER_TITLE_BLOOD_GUARD 0x0000000000200000LL // 21
458 #define PLAYER_TITLE_LEGIONNAIRE 0x0000000000400000LL // 22
459 #define PLAYER_TITLE_CENTURION 0x0000000000800000LL // 23
460 #define PLAYER_TITLE_CHAMPION 0x0000000001000000LL // 24
461 #define PLAYER_TITLE_LIEUTENANT_GENERAL 0x0000000002000000LL // 25
462 #define PLAYER_TITLE_GENERAL 0x0000000004000000LL // 26
463 #define PLAYER_TITLE_WARLORD 0x0000000008000000LL // 27
464 #define PLAYER_TITLE_HIGH_WARLORD 0x0000000010000000LL // 28
465 #define PLAYER_TITLE_GLADIATOR 0x0000000020000000LL // 29
466 #define PLAYER_TITLE_DUELIST 0x0000000040000000LL // 30
467 #define PLAYER_TITLE_RIVAL 0x0000000080000000LL // 31
468 #define PLAYER_TITLE_CHALLENGER 0x0000000100000000LL // 32
469 #define PLAYER_TITLE_SCARAB_LORD 0x0000000200000000LL // 33
470 #define PLAYER_TITLE_CONQUEROR 0x0000000400000000LL // 34
471 #define PLAYER_TITLE_JUSTICAR 0x0000000800000000LL // 35
472 #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36
473 #define PLAYER_TITLE_MERCILESS_GLADIATOR 0x0000002000000000LL // 37
474 #define PLAYER_TITLE_OF_THE_SHATTERED_SUN 0x0000004000000000LL // 38
475 #define PLAYER_TITLE_HAND_OF_ADAL 0x0000008000000000LL // 39
476 #define PLAYER_TITLE_VENGEFUL_GLADIATOR 0x0000010000000000LL // 40
478 // used in PLAYER_FIELD_BYTES values
479 enum PlayerFieldByteFlags
481 PLAYER_FIELD_BYTE_TRACK_STEALTHED = 0x00000002,
482 PLAYER_FIELD_BYTE_RELEASE_TIMER = 0x00000008, // Display time till auto release spirit
483 PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x00000010 // Display no "release spirit" window at all
486 // used in PLAYER_FIELD_BYTES2 values
487 enum PlayerFieldByte2Flags
489 PLAYER_FIELD_BYTE2_NONE = 0x0000,
490 PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW = 0x4000
493 enum ActivateTaxiReplies
495 ERR_TAXIOK = 0,
496 ERR_TAXIUNSPECIFIEDSERVERERROR = 1,
497 ERR_TAXINOSUCHPATH = 2,
498 ERR_TAXINOTENOUGHMONEY = 3,
499 ERR_TAXITOOFARAWAY = 4,
500 ERR_TAXINOVENDORNEARBY = 5,
501 ERR_TAXINOTVISITED = 6,
502 ERR_TAXIPLAYERBUSY = 7,
503 ERR_TAXIPLAYERALREADYMOUNTED = 8,
504 ERR_TAXIPLAYERSHAPESHIFTED = 9,
505 ERR_TAXIPLAYERMOVING = 10,
506 ERR_TAXISAMENODE = 11,
507 ERR_TAXINOTSTANDING = 12
510 enum LootType
512 LOOT_CORPSE = 1,
513 LOOT_SKINNING = 2,
514 LOOT_FISHING = 3,
515 LOOT_PICKPOCKETING = 4, // unsupported by client, sending LOOT_SKINNING instead
516 LOOT_DISENCHANTING = 5, // unsupported by client, sending LOOT_SKINNING instead
517 LOOT_PROSPECTING = 6, // unsupported by client, sending LOOT_SKINNING instead
518 LOOT_INSIGNIA = 7, // unsupported by client, sending LOOT_SKINNING instead
519 LOOT_FISHINGHOLE = 8, // unsupported by client, sending LOOT_FISHING instead
520 LOOT_MILLING = 9 // unsupported by client, sending LOOT_SKINNING instead
523 enum MirrorTimerType
525 FATIGUE_TIMER = 0,
526 BREATH_TIMER = 1,
527 FIRE_TIMER = 2
530 // 2^n values
531 enum PlayerExtraFlags
533 // gm abilities
534 PLAYER_EXTRA_GM_ON = 0x0001,
535 PLAYER_EXTRA_GM_ACCEPT_TICKETS = 0x0002,
536 PLAYER_EXTRA_ACCEPT_WHISPERS = 0x0004,
537 PLAYER_EXTRA_TAXICHEAT = 0x0008,
538 PLAYER_EXTRA_GM_INVISIBLE = 0x0010,
539 PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages
541 // other states
542 PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating.
545 // 2^n values
546 enum AtLoginFlags
548 AT_LOGIN_NONE = 0,
549 AT_LOGIN_RENAME = 1,
550 AT_LOGIN_RESET_SPELLS = 2,
551 AT_LOGIN_RESET_TALENTS = 4,
552 AT_LOGIN_CUSTOMIZE = 8
555 typedef std::map<uint32, QuestStatusData> QuestStatusMap;
557 enum QuestSlotOffsets
559 QUEST_ID_OFFSET = 0,
560 QUEST_STATE_OFFSET = 1,
561 QUEST_COUNTS_OFFSET = 2,
562 QUEST_TIME_OFFSET = 3
565 #define MAX_QUEST_OFFSET 4
567 enum QuestSlotStateMask
569 QUEST_STATE_NONE = 0x0000,
570 QUEST_STATE_COMPLETE = 0x0001,
571 QUEST_STATE_FAIL = 0x0002
574 class Quest;
575 class Spell;
576 class Item;
577 class WorldSession;
579 enum PlayerSlots
581 // first slot for item stored (in any way in player m_items data)
582 PLAYER_SLOT_START = 0,
583 // last+1 slot for item stored (in any way in player m_items data)
584 PLAYER_SLOT_END = 200,
585 PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START)
588 enum EquipmentSlots
590 EQUIPMENT_SLOT_START = 0,
591 EQUIPMENT_SLOT_HEAD = 0,
592 EQUIPMENT_SLOT_NECK = 1,
593 EQUIPMENT_SLOT_SHOULDERS = 2,
594 EQUIPMENT_SLOT_BODY = 3,
595 EQUIPMENT_SLOT_CHEST = 4,
596 EQUIPMENT_SLOT_WAIST = 5,
597 EQUIPMENT_SLOT_LEGS = 6,
598 EQUIPMENT_SLOT_FEET = 7,
599 EQUIPMENT_SLOT_WRISTS = 8,
600 EQUIPMENT_SLOT_HANDS = 9,
601 EQUIPMENT_SLOT_FINGER1 = 10,
602 EQUIPMENT_SLOT_FINGER2 = 11,
603 EQUIPMENT_SLOT_TRINKET1 = 12,
604 EQUIPMENT_SLOT_TRINKET2 = 13,
605 EQUIPMENT_SLOT_BACK = 14,
606 EQUIPMENT_SLOT_MAINHAND = 15,
607 EQUIPMENT_SLOT_OFFHAND = 16,
608 EQUIPMENT_SLOT_RANGED = 17,
609 EQUIPMENT_SLOT_TABARD = 18,
610 EQUIPMENT_SLOT_END = 19
613 enum InventorySlots
615 INVENTORY_SLOT_BAG_0 = 255,
616 INVENTORY_SLOT_BAG_START = 19,
617 INVENTORY_SLOT_BAG_1 = 19,
618 INVENTORY_SLOT_BAG_2 = 20,
619 INVENTORY_SLOT_BAG_3 = 21,
620 INVENTORY_SLOT_BAG_4 = 22,
621 INVENTORY_SLOT_BAG_END = 23,
623 INVENTORY_SLOT_ITEM_START = 23,
624 INVENTORY_SLOT_ITEM_1 = 23,
625 INVENTORY_SLOT_ITEM_2 = 24,
626 INVENTORY_SLOT_ITEM_3 = 25,
627 INVENTORY_SLOT_ITEM_4 = 26,
628 INVENTORY_SLOT_ITEM_5 = 27,
629 INVENTORY_SLOT_ITEM_6 = 28,
630 INVENTORY_SLOT_ITEM_7 = 29,
631 INVENTORY_SLOT_ITEM_8 = 30,
632 INVENTORY_SLOT_ITEM_9 = 31,
633 INVENTORY_SLOT_ITEM_10 = 32,
634 INVENTORY_SLOT_ITEM_11 = 33,
635 INVENTORY_SLOT_ITEM_12 = 34,
636 INVENTORY_SLOT_ITEM_13 = 35,
637 INVENTORY_SLOT_ITEM_14 = 36,
638 INVENTORY_SLOT_ITEM_15 = 37,
639 INVENTORY_SLOT_ITEM_16 = 38,
640 INVENTORY_SLOT_ITEM_END = 39
643 enum BankSlots
645 BANK_SLOT_ITEM_START = 39,
646 BANK_SLOT_ITEM_1 = 39,
647 BANK_SLOT_ITEM_2 = 40,
648 BANK_SLOT_ITEM_3 = 41,
649 BANK_SLOT_ITEM_4 = 42,
650 BANK_SLOT_ITEM_5 = 43,
651 BANK_SLOT_ITEM_6 = 44,
652 BANK_SLOT_ITEM_7 = 45,
653 BANK_SLOT_ITEM_8 = 46,
654 BANK_SLOT_ITEM_9 = 47,
655 BANK_SLOT_ITEM_10 = 48,
656 BANK_SLOT_ITEM_11 = 49,
657 BANK_SLOT_ITEM_12 = 50,
658 BANK_SLOT_ITEM_13 = 51,
659 BANK_SLOT_ITEM_14 = 52,
660 BANK_SLOT_ITEM_15 = 53,
661 BANK_SLOT_ITEM_16 = 54,
662 BANK_SLOT_ITEM_17 = 55,
663 BANK_SLOT_ITEM_18 = 56,
664 BANK_SLOT_ITEM_19 = 57,
665 BANK_SLOT_ITEM_20 = 58,
666 BANK_SLOT_ITEM_21 = 59,
667 BANK_SLOT_ITEM_22 = 60,
668 BANK_SLOT_ITEM_23 = 61,
669 BANK_SLOT_ITEM_24 = 62,
670 BANK_SLOT_ITEM_25 = 63,
671 BANK_SLOT_ITEM_26 = 64,
672 BANK_SLOT_ITEM_27 = 65,
673 BANK_SLOT_ITEM_28 = 66,
674 BANK_SLOT_ITEM_END = 67,
676 BANK_SLOT_BAG_START = 67,
677 BANK_SLOT_BAG_1 = 67,
678 BANK_SLOT_BAG_2 = 68,
679 BANK_SLOT_BAG_3 = 69,
680 BANK_SLOT_BAG_4 = 70,
681 BANK_SLOT_BAG_5 = 71,
682 BANK_SLOT_BAG_6 = 72,
683 BANK_SLOT_BAG_7 = 73,
684 BANK_SLOT_BAG_END = 74
687 enum BuyBackSlots
689 // stored in m_buybackitems
690 BUYBACK_SLOT_START = 74,
691 BUYBACK_SLOT_1 = 74,
692 BUYBACK_SLOT_2 = 75,
693 BUYBACK_SLOT_3 = 76,
694 BUYBACK_SLOT_4 = 77,
695 BUYBACK_SLOT_5 = 78,
696 BUYBACK_SLOT_6 = 79,
697 BUYBACK_SLOT_7 = 80,
698 BUYBACK_SLOT_8 = 81,
699 BUYBACK_SLOT_9 = 82,
700 BUYBACK_SLOT_10 = 83,
701 BUYBACK_SLOT_11 = 84,
702 BUYBACK_SLOT_12 = 85,
703 BUYBACK_SLOT_END = 86
706 enum KeyRingSlots
708 KEYRING_SLOT_START = 86,
709 KEYRING_SLOT_END = 118
712 enum VanityPetSlots
714 VANITYPET_SLOT_START = 118,
715 VANITYPET_SLOT_END = 136
718 enum CurrencyTokenSlots
720 CURRENCYTOKEN_SLOT_START = 136,
721 CURRENCYTOKEN_SLOT_END = 168
724 enum QuestBagSlots
726 QUESTBAG_SLOT_START = 168,
727 QUESTBAG_SLOT_END = 200
730 struct ItemPosCount
732 ItemPosCount(uint16 _pos, uint8 _count) : pos(_pos), count(_count) {}
733 bool isContainedIn(std::vector<ItemPosCount> const& vec) const;
734 uint16 pos;
735 uint8 count;
737 typedef std::vector<ItemPosCount> ItemPosCountVec;
739 enum TradeSlots
741 TRADE_SLOT_COUNT = 7,
742 TRADE_SLOT_TRADED_COUNT = 6,
743 TRADE_SLOT_NONTRADED = 6
746 enum TransferAbortReason
748 TRANSFER_ABORT_ERROR = 0x00,
749 TRANSFER_ABORT_MAX_PLAYERS = 0x01, // Transfer Aborted: instance is full
750 TRANSFER_ABORT_NOT_FOUND = 0x02, // Transfer Aborted: instance not found
751 TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x03, // You have entered too many instances recently.
752 TRANSFER_ABORT_ZONE_IN_COMBAT = 0x05, // Unable to zone in while an encounter is in progress.
753 TRANSFER_ABORT_INSUF_EXPAN_LVL = 0x06, // You must have <TBC,WotLK> expansion installed to access this area.
754 TRANSFER_ABORT_DIFFICULTY = 0x07, // <Normal,Heroic,Epic> difficulty mode is not available for %s.
755 TRANSFER_ABORT_UNIQUE_MESSAGE = 0x08, // Until you've escaped TLK's grasp, you cannot leave this place!
756 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 0x09 // Additional instances cannot be launched, please try again later.
759 enum InstanceResetWarningType
761 RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s).
762 RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)!
763 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!
764 RAID_INSTANCE_WELCOME = 4 // Welcome to %s. This raid instance is scheduled to reset in %s.
767 struct MovementInfo
769 // common
770 uint32 flags;
771 uint16 unk1;
772 uint32 time;
773 float x, y, z, o;
774 // transport
775 uint64 t_guid;
776 float t_x, t_y, t_z, t_o;
777 uint32 t_time;
778 int8 t_seat;
779 // swimming and unknown
780 float s_pitch;
781 // last fall time
782 uint32 fallTime;
783 // jumping
784 float j_unk, j_sinAngle, j_cosAngle, j_xyspeed;
785 // spline
786 float u_unk1;
788 MovementInfo()
790 flags = 0;
791 time = t_time = fallTime = 0;
792 unk1 = 0;
793 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;
794 t_guid = 0;
797 void SetMovementFlags(uint32 _flags)
799 flags = _flags;
803 // flags that use in movement check for example at spell casting
804 MovementFlags const movementFlagsMask = MovementFlags(
805 MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
806 MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1 |
807 MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_FLY_UP |
808 MOVEMENTFLAG_FLYING |MOVEMENTFLAG_SPLINE
811 MovementFlags const movementOrTurningFlagsMask = MovementFlags(
812 movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT
814 class InstanceSave;
816 enum RestType
818 REST_TYPE_NO = 0,
819 REST_TYPE_IN_TAVERN = 1,
820 REST_TYPE_IN_CITY = 2
823 enum DuelCompleteType
825 DUEL_INTERUPTED = 0,
826 DUEL_WON = 1,
827 DUEL_FLED = 2
830 enum TeleportToOptions
832 TELE_TO_GM_MODE = 0x01,
833 TELE_TO_NOT_LEAVE_TRANSPORT = 0x02,
834 TELE_TO_NOT_LEAVE_COMBAT = 0x04,
835 TELE_TO_NOT_UNSUMMON_PET = 0x08,
836 TELE_TO_SPELL = 0x10,
839 /// Type of environmental damages
840 enum EnviromentalDamage
842 DAMAGE_EXHAUSTED = 0,
843 DAMAGE_DROWNING = 1,
844 DAMAGE_FALL = 2,
845 DAMAGE_LAVA = 3,
846 DAMAGE_SLIME = 4,
847 DAMAGE_FIRE = 5,
848 DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
851 // used at player loading query list preparing, and later result selection
852 enum PlayerLoginQueryIndex
854 PLAYER_LOGIN_QUERY_LOADFROM = 0,
855 PLAYER_LOGIN_QUERY_LOADGROUP = 1,
856 PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES = 2,
857 PLAYER_LOGIN_QUERY_LOADAURAS = 3,
858 PLAYER_LOGIN_QUERY_LOADSPELLS = 4,
859 PLAYER_LOGIN_QUERY_LOADQUESTSTATUS = 5,
860 PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS = 6,
861 PLAYER_LOGIN_QUERY_LOADTUTORIALS = 7, // common for all characters for some account at specific realm
862 PLAYER_LOGIN_QUERY_LOADREPUTATION = 8,
863 PLAYER_LOGIN_QUERY_LOADINVENTORY = 9,
864 PLAYER_LOGIN_QUERY_LOADACTIONS = 10,
865 PLAYER_LOGIN_QUERY_LOADMAILCOUNT = 11,
866 PLAYER_LOGIN_QUERY_LOADMAILDATE = 12,
867 PLAYER_LOGIN_QUERY_LOADSOCIALLIST = 13,
868 PLAYER_LOGIN_QUERY_LOADHOMEBIND = 14,
869 PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS = 15,
870 PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES = 16,
871 PLAYER_LOGIN_QUERY_LOADGUILD = 17,
872 PLAYER_LOGIN_QUERY_LOADARENAINFO = 18,
873 PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS = 19,
874 PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS = 20,
875 MAX_PLAYER_LOGIN_QUERY = 21
879 // Player summoning auto-decline time (in secs)
880 #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
881 #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
883 struct InstancePlayerBind
885 InstanceSave *save;
886 bool perm;
887 /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players
888 that aren't already permanently bound when they are inside when a boss is killed
889 or when they enter an instance that the group leader is permanently bound to. */
890 InstancePlayerBind() : save(NULL), perm(false) {}
893 class MANGOS_DLL_SPEC PlayerTaxi
895 public:
896 PlayerTaxi();
897 ~PlayerTaxi() {}
898 // Nodes
899 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level);
900 void LoadTaxiMask(const char* data);
901 void SaveTaxiMask(const char* data);
903 uint32 GetTaximask( uint8 index ) const { return m_taximask[index]; }
904 bool IsTaximaskNodeKnown(uint32 nodeidx) const
906 uint8 field = uint8((nodeidx - 1) / 32);
907 uint32 submask = 1<<((nodeidx-1)%32);
908 return (m_taximask[field] & submask) == submask;
910 bool SetTaximaskNode(uint32 nodeidx)
912 uint8 field = uint8((nodeidx - 1) / 32);
913 uint32 submask = 1<<((nodeidx-1)%32);
914 if ((m_taximask[field] & submask) != submask )
916 m_taximask[field] |= submask;
917 return true;
919 else
920 return false;
922 void AppendTaximaskTo(ByteBuffer& data,bool all);
924 // Destinations
925 bool LoadTaxiDestinationsFromString(const std::string& values);
926 std::string SaveTaxiDestinationsToString();
928 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
929 void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
930 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
931 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
932 uint32 GetCurrentTaxiPath() const;
933 uint32 NextTaxiDestination()
935 m_TaxiDestinations.pop_front();
936 return GetTaxiDestination();
938 bool empty() const { return m_TaxiDestinations.empty(); }
939 private:
940 TaxiMask m_taximask;
941 std::deque<uint32> m_TaxiDestinations;
944 class MANGOS_DLL_SPEC Player : public Unit
946 friend class WorldSession;
947 friend void Item::AddToUpdateQueueOf(Player *player);
948 friend void Item::RemoveFromUpdateQueueOf(Player *player);
949 public:
950 explicit Player (WorldSession *session);
951 ~Player ( );
953 void CleanupsBeforeDelete();
955 static UpdateMask updateVisualBits;
956 static void InitVisibleBits();
958 void AddToWorld();
959 void RemoveFromWorld();
961 bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
963 bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
965 return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options);
968 void SetSummonPoint(uint32 mapid, float x, float y, float z)
970 m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
971 m_summon_mapid = mapid;
972 m_summon_x = x;
973 m_summon_y = y;
974 m_summon_z = z;
976 void SummonIfPossible(bool agree);
978 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 );
980 void Update( uint32 time );
982 void BuildEnumData( QueryResult * result, WorldPacket * p_data );
984 void SetInWater(bool apply);
986 bool IsInWater() const { return m_isInWater; }
987 bool IsUnderWater() const;
989 void SendInitialPacketsBeforeAddToMap();
990 void SendInitialPacketsAfterAddToMap();
991 void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0);
992 void SendInstanceResetWarning(uint32 mapid, uint32 time);
994 bool CanInteractWithNPCs(bool alive = true) const;
996 bool ToggleAFK();
997 bool ToggleDND();
998 bool isAFK() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_AFK); };
999 bool isDND() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_DND); };
1000 uint8 chatTag() const;
1001 std::string afkMsg;
1002 std::string dndMsg;
1004 uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
1006 PlayerSocial *GetSocial() { return m_social; }
1008 PlayerTaxi m_taxi;
1009 void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
1010 bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, uint32 mount_id = 0 , Creature* npc = NULL);
1011 // mount_id can be used in scripting calls
1012 bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); }
1013 void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; }
1014 bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
1015 void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
1016 bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
1017 void SetGameMaster(bool on);
1018 bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); }
1019 void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
1020 bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
1021 void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
1022 bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
1023 void SetGMVisible(bool on);
1024 void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
1026 void GiveXP(uint32 xp, Unit* victim);
1027 void GiveLevel(uint32 level);
1028 void InitStatsForLevel(bool reapplyMods = false);
1030 // Played Time Stuff
1031 time_t m_logintime;
1032 time_t m_Last_tick;
1033 uint32 m_Played_time[2];
1034 uint32 GetTotalPlayedTime() { return m_Played_time[0]; };
1035 uint32 GetLevelPlayedTime() { return m_Played_time[1]; };
1037 void setDeathState(DeathState s); // overwrite Unit::setDeathState
1039 void InnEnter (int time,uint32 mapid, float x,float y,float z)
1041 inn_pos_mapid = mapid;
1042 inn_pos_x = x;
1043 inn_pos_y = y;
1044 inn_pos_z = z;
1045 time_inn_enter = time;
1048 float GetRestBonus() const { return m_rest_bonus; };
1049 void SetRestBonus(float rest_bonus_new);
1051 RestType GetRestType() const { return rest_type; };
1052 void SetRestType(RestType n_r_type) { rest_type = n_r_type; };
1054 uint32 GetInnPosMapId() const { return inn_pos_mapid; };
1055 float GetInnPosX() const { return inn_pos_x; };
1056 float GetInnPosY() const { return inn_pos_y; };
1057 float GetInnPosZ() const { return inn_pos_z; };
1059 int GetTimeInnEnter() const { return time_inn_enter; };
1060 void UpdateInnerTime (int time) { time_inn_enter = time; };
1062 void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
1063 void RemoveMiniPet();
1064 Pet* GetMiniPet();
1065 void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); }
1066 void RemoveGuardians();
1067 bool HasGuardianWithEntry(uint32 entry);
1068 void AddGuardian(Pet* pet) { m_guardianPets.insert(pet->GetGUID()); }
1069 GuardianPetList const& GetGuardians() const { return m_guardianPets; }
1070 void Uncharm();
1072 void Say(const std::string& text, const uint32 language);
1073 void Yell(const std::string& text, const uint32 language);
1074 void TextEmote(const std::string& text);
1075 void Whisper(const std::string& text, const uint32 language,uint64 receiver);
1076 void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
1078 /*********************************************************/
1079 /*** STORAGE SYSTEM ***/
1080 /*********************************************************/
1082 void SetVirtualItemSlot( uint8 i, Item* item);
1083 void SetSheath( uint32 sheathed );
1084 uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const;
1085 uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const;
1086 Item* GetItemByGuid( uint64 guid ) const;
1087 Item* GetItemByPos( uint16 pos ) const;
1088 Item* GetItemByPos( uint8 bag, uint8 slot ) const;
1089 Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const;
1090 Item* GetShield(bool useable = false) const;
1091 static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot
1092 std::vector<Item *> &GetItemUpdateQueue() { return m_itemUpdateQueue; }
1093 static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8,pos & 255); }
1094 static bool IsInventoryPos( uint8 bag, uint8 slot );
1095 static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8,pos & 255); }
1096 static bool IsEquipmentPos( uint8 bag, uint8 slot );
1097 static bool IsBagPos( uint16 pos );
1098 static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
1099 static bool IsBankPos( uint8 bag, uint8 slot );
1100 bool IsValidPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
1101 bool IsValidPos( uint8 bag, uint8 slot );
1102 bool HasBankBagSlot( uint8 slot ) const;
1103 bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
1104 bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL);
1105 Item* GetItemOrItemWithGemEquipped( uint32 item ) const;
1106 uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(),pItem->GetCount(),pItem); }
1107 uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry,count,NULL); }
1108 uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
1110 return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count );
1112 uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
1114 if(!pItem)
1115 return EQUIP_ERR_ITEM_NOT_FOUND;
1116 uint32 count = pItem->GetCount();
1117 return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL );
1120 uint8 CanStoreItems( Item **pItem,int count) const;
1121 uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
1122 uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
1123 uint8 CanUnequipItems( uint32 item, uint32 count ) const;
1124 uint8 CanUnequipItem( uint16 src, bool swap ) const;
1125 uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
1126 uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
1127 bool HasItemTotemCategory( uint32 TotemCategory ) const;
1128 bool CanUseItem( ItemPrototype const *pItem );
1129 uint8 CanUseAmmo( uint32 item ) const;
1130 Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
1131 Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
1132 Item* EquipNewItem( uint16 pos, uint32 item, bool update );
1133 Item* EquipItem( uint16 pos, Item *pItem, bool update );
1134 void AutoUnequipOffhandIfNeed();
1135 bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
1137 uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
1138 uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
1140 void ApplyEquipCooldown( Item * pItem );
1141 void SetAmmo( uint32 item );
1142 void RemoveAmmo();
1143 float GetAmmoDPS() const { return m_ammoDPS; }
1144 bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const;
1145 void QuickEquipItem( uint16 pos, Item *pItem);
1146 void VisualizeItem( uint8 slot, Item *pItem);
1147 void SetVisibleItemSlot(uint8 slot, Item *pItem);
1148 Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update )
1150 return StoreItem( dest, pItem, update);
1152 Item* BankItem( uint16 pos, Item *pItem, bool update );
1153 void RemoveItem( uint8 bag, uint8 slot, bool update );
1154 void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
1155 // in trade, auction, guild bank, mail....
1156 void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
1157 // in trade, guild bank, mail....
1158 void RemoveItemDependentAurasAndCasts( Item * pItem );
1159 void DestroyItem( uint8 bag, uint8 slot, bool update );
1160 void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
1161 void DestroyItemCount( Item* item, uint32& count, bool update );
1162 void DestroyConjuredItems( bool update );
1163 void DestroyZoneLimitedItem( bool update, uint32 new_zone );
1164 void SplitItem( uint16 src, uint16 dst, uint32 count );
1165 void SwapItem( uint16 src, uint16 dst );
1166 void AddItemToBuyBackSlot( Item *pItem );
1167 Item* GetItemFromBuyBackSlot( uint32 slot );
1168 void RemoveItemFromBuyBackSlot( uint32 slot, bool del );
1169 uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
1170 void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 );
1171 void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
1172 void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
1173 void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
1174 void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
1175 uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
1176 uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
1177 bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; }
1178 bool IsUseEquipedWeapon( bool mainhand ) const
1180 // disarm applied only to mainhand weapon
1181 return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) );
1183 bool IsTwoHandUsed() const
1185 Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
1186 return mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
1188 void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false );
1189 bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot);
1191 float GetReputationPriceDiscount( Creature const* pCreature ) const;
1192 Player* GetTrader() const { return pTrader; }
1193 void ClearTrade();
1194 void TradeCancel(bool sendback);
1195 uint16 GetItemPosByTradeSlot(uint32 slot) const { return tradeItems[slot]; }
1197 void UpdateEnchantTime(uint32 time);
1198 void UpdateItemDuration(uint32 time, bool realtimeonly=false);
1199 void AddEnchantmentDurations(Item *item);
1200 void RemoveEnchantmentDurations(Item *item);
1201 void RemoveAllEnchantments(EnchantmentSlot slot);
1202 void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration);
1203 void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false);
1204 void ApplyEnchantment(Item *item,bool apply);
1205 void SendEnchantmentDurations();
1206 void AddItemDurations(Item *item);
1207 void RemoveItemDurations(Item *item);
1208 void SendItemDurations();
1209 void LoadCorpse();
1210 void LoadPet();
1212 uint32 m_stableSlots;
1214 /*********************************************************/
1215 /*** QUEST SYSTEM ***/
1216 /*********************************************************/
1218 void PrepareQuestMenu( uint64 guid );
1219 void SendPreparedQuest( uint64 guid );
1220 bool IsActiveQuest( uint32 quest_id ) const;
1221 Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
1222 bool CanSeeStartQuest( Quest const *pQuest );
1223 bool CanTakeQuest( Quest const *pQuest, bool msg );
1224 bool CanAddQuest( Quest const *pQuest, bool msg );
1225 bool CanCompleteQuest( uint32 quest_id );
1226 bool CanCompleteRepeatableQuest(Quest const *pQuest);
1227 bool CanRewardQuest( Quest const *pQuest, bool msg );
1228 bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg );
1229 void AddQuest( Quest const *pQuest, Object *questGiver );
1230 void CompleteQuest( uint32 quest_id );
1231 void IncompleteQuest( uint32 quest_id );
1232 void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
1233 void FailQuest( uint32 quest_id );
1234 void FailTimedQuest( uint32 quest_id );
1235 bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg );
1236 bool SatisfyQuestLevel( Quest const* qInfo, bool msg );
1237 bool SatisfyQuestLog( bool msg );
1238 bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg );
1239 bool SatisfyQuestRace( Quest const* qInfo, bool msg );
1240 bool SatisfyQuestReputation( Quest const* qInfo, bool msg );
1241 bool SatisfyQuestStatus( Quest const* qInfo, bool msg );
1242 bool SatisfyQuestTimed( Quest const* qInfo, bool msg );
1243 bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg );
1244 bool SatisfyQuestNextChain( Quest const* qInfo, bool msg );
1245 bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg );
1246 bool SatisfyQuestDay( Quest const* qInfo, bool msg );
1247 bool GiveQuestSourceItem( Quest const *pQuest );
1248 bool TakeQuestSourceItem( uint32 quest_id, bool msg );
1249 bool GetQuestRewardStatus( uint32 quest_id ) const;
1250 QuestStatus GetQuestStatus( uint32 quest_id ) const;
1251 void SetQuestStatus( uint32 quest_id, QuestStatus status );
1253 void SetDailyQuestStatus( uint32 quest_id );
1254 void ResetDailyQuestStatus();
1256 uint16 FindQuestSlot( uint32 quest_id ) const;
1257 uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
1258 uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
1259 uint32 GetQuestSlotCounters(uint16 slot)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); }
1260 uint8 GetQuestSlotCounter(uint16 slot,uint8 counter) const { return GetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter); }
1261 uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
1262 void SetQuestSlot(uint16 slot,uint32 quest_id, uint32 timer = 0)
1264 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET,quest_id);
1265 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,0);
1266 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,0);
1267 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer);
1269 void SetQuestSlotCounter(uint16 slot,uint8 counter,uint8 count) { SetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter,count); }
1270 void SetQuestSlotState(uint16 slot,uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1271 void RemoveQuestSlotState(uint16 slot,uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
1272 void SetQuestSlotTimer(uint16 slot,uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); }
1273 void SwapQuestSlot(uint16 slot1,uint16 slot2)
1275 for (int i = 0; i < MAX_QUEST_OFFSET ; ++i )
1277 uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i);
1278 uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i);
1280 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i, temp2);
1281 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i, temp1);
1284 uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
1285 void AdjustQuestReqItemCount( Quest const* pQuest );
1286 void AreaExploredOrEventHappens( uint32 questId );
1287 void GroupEventHappens( uint32 questId, WorldObject const* pEventObject );
1288 void ItemAddedQuestCheck( uint32 entry, uint32 count );
1289 void ItemRemovedQuestCheck( uint32 entry, uint32 count );
1290 void KilledMonster( uint32 entry, uint64 guid );
1291 void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id );
1292 void TalkedToCreature( uint32 entry, uint64 guid );
1293 void MoneyChanged( uint32 value );
1294 bool HasQuestForItem( uint32 itemid ) const;
1295 bool HasQuestForGO(int32 GOId);
1296 void UpdateForQuestsGO();
1297 bool CanShareQuest(uint32 quest_id) const;
1299 void SendQuestComplete( uint32 quest_id );
1300 void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
1301 void SendQuestFailed( uint32 quest_id );
1302 void SendQuestTimerFailed( uint32 quest_id );
1303 void SendCanTakeQuestResponse( uint32 msg );
1304 void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
1305 void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
1306 void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count );
1308 uint64 GetDivider() { return m_divider; };
1309 void SetDivider( uint64 guid ) { m_divider = guid; };
1311 uint32 GetInGameTime() { return m_ingametime; };
1313 void SetInGameTime( uint32 time ) { m_ingametime = time; };
1315 void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); }
1317 /*********************************************************/
1318 /*** LOAD SYSTEM ***/
1319 /*********************************************************/
1321 bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
1322 bool MinimalLoadFromDB(QueryResult *result, uint32 guid);
1323 static bool LoadValuesArrayFromDB(Tokens& data,uint64 guid);
1324 static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
1325 static float GetFloatValueFromArray(Tokens const& data, uint16 index);
1326 static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid);
1327 static float GetFloatValueFromDB(uint16 index, uint64 guid);
1328 static uint32 GetZoneIdFromDB(uint64 guid);
1329 static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
1331 /*********************************************************/
1332 /*** SAVE SYSTEM ***/
1333 /*********************************************************/
1335 void SaveToDB();
1336 void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
1337 void SaveDataFieldToDB();
1338 static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
1339 static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value);
1340 static void SetFloatValueInArray(Tokens& data,uint16 index, float value);
1341 static void SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid);
1342 static void SetFloatValueInDB(uint16 index, float value, uint64 guid);
1343 static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
1344 static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid);
1346 bool m_mailsLoaded;
1347 bool m_mailsUpdated;
1349 void SetBindPoint(uint64 guid);
1350 void SendTalentWipeConfirm(uint64 guid);
1351 void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
1352 void SendPetSkillWipeConfirm();
1353 void CalcRage( uint32 damage,bool attacker );
1354 void RegenerateAll();
1355 void Regenerate(Powers power);
1356 void RegenerateHealth();
1357 void setRegenTimer(uint32 time) {m_regenTimer = time;}
1358 void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
1360 uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
1361 void ModifyMoney( int32 d )
1363 if(d < 0)
1364 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
1365 else
1366 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
1368 // "At Gold Limit"
1369 if(GetMoney() >= MAX_MONEY_AMOUNT)
1370 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL);
1372 void SetMoney( uint32 value )
1374 SetUInt32Value (PLAYER_FIELD_COINAGE, value);
1375 MoneyChanged( value );
1378 uint32 GetTutorialInt(uint32 intId )
1380 ASSERT( (intId < 8) );
1381 return m_Tutorials[intId];
1384 void SetTutorialInt(uint32 intId, uint32 value)
1386 ASSERT( (intId < 8) );
1387 if(m_Tutorials[intId]!=value)
1389 m_Tutorials[intId] = value;
1390 m_TutorialsChanged = true;
1394 QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
1396 const uint64& GetSelection( ) const { return m_curSelection; }
1397 void SetSelection(const uint64 &guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); }
1399 uint8 GetComboPoints() { return m_comboPoints; }
1400 uint64 GetComboTarget() { return m_comboTarget; }
1402 void AddComboPoints(Unit* target, int8 count);
1403 void ClearComboPoints();
1404 void SendComboPoints();
1406 void SendMailResult(uint32 mailId, uint32 mailAction, uint32 mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0);
1407 void SendNewMail();
1408 void UpdateNextMailTimeAndUnreads();
1409 void AddNewMailDeliverTime(time_t deliver_time);
1410 bool IsMailsLoaded() const { return m_mailsLoaded; }
1412 //void SetMail(Mail *m);
1413 void RemoveMail(uint32 id);
1415 void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
1416 uint32 GetMailSize() { return m_mail.size();};
1417 Mail* GetMail(uint32 id);
1419 PlayerMails::iterator GetmailBegin() { return m_mail.begin();};
1420 PlayerMails::iterator GetmailEnd() { return m_mail.end();};
1422 /*********************************************************/
1423 /*** MAILED ITEMS SYSTEM ***/
1424 /*********************************************************/
1426 uint8 unReadMails;
1427 time_t m_nextMailDelivereTime;
1429 typedef UNORDERED_MAP<uint32, Item*> ItemMap;
1431 ItemMap mMitems; //template defined in objectmgr.cpp
1433 Item* GetMItem(uint32 id)
1435 ItemMap::const_iterator itr = mMitems.find(id);
1436 if (itr != mMitems.end())
1437 return itr->second;
1439 return NULL;
1442 void AddMItem(Item* it)
1444 ASSERT( it );
1445 //assert deleted, because items can be added before loading
1446 mMitems[it->GetGUIDLow()] = it;
1449 bool RemoveMItem(uint32 id)
1451 ItemMap::iterator i = mMitems.find(id);
1452 if (i == mMitems.end())
1453 return false;
1455 mMitems.erase(i);
1456 return true;
1459 void PetSpellInitialize();
1460 void CharmSpellInitialize();
1461 void PossessSpellInitialize();
1462 bool HasSpell(uint32 spell) const;
1463 TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
1464 bool IsSpellFitByClassAndRace( uint32 spell_id ) const;
1466 void SendProficiency(uint8 pr1, uint32 pr2);
1467 void SendInitialSpells();
1468 bool addSpell(uint32 spell_id, bool active, bool learning = true, bool loading = false, uint16 slot_id=SPELL_WITHOUT_SLOT_ID, bool disabled = false);
1469 void learnSpell(uint32 spell_id);
1470 void removeSpell(uint32 spell_id, bool disabled = false);
1471 void resetSpells();
1472 void learnDefaultSpells(bool loading = false);
1473 void learnQuestRewardedSpells();
1474 void learnQuestRewardedSpells(Quest const* quest);
1476 uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
1477 void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
1478 bool resetTalents(bool no_cost = false);
1479 uint32 resetTalentsCost() const;
1480 void InitTalentForLevel();
1482 void InitGlyphsForLevel();
1483 void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); }
1484 uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); }
1485 void SetGlyph(uint8 slot, uint32 glyph) { SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); }
1486 uint32 GetGlyph(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot); }
1488 uint32 GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); }
1489 void SetFreePrimaryProffesions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2,profs); }
1490 void InitPrimaryProffesions();
1492 PlayerSpellMap const& GetSpellMap() const { return m_spells; }
1493 PlayerSpellMap & GetSpellMap() { return m_spells; }
1495 void AddSpellMod(SpellModifier* mod, bool apply);
1496 bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL);
1497 template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL);
1498 void RemoveSpellMods(Spell const* spell);
1500 bool HasSpellCooldown(uint32 spell_id) const
1502 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1503 return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
1505 uint32 GetSpellCooldownDelay(uint32 spell_id) const
1507 SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
1508 time_t t = time(NULL);
1509 return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
1511 void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
1512 void SendCooldownEvent(SpellEntry const *spellInfo);
1513 void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs );
1514 void RemoveSpellCooldown(uint32 spell_id) { m_spellCooldowns.erase(spell_id); }
1515 void RemoveArenaSpellCooldowns();
1516 void RemoveAllSpellCooldown();
1517 void _LoadSpellCooldowns(QueryResult *result);
1518 void _SaveSpellCooldowns();
1520 void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
1522 m_resurrectGUID = guid;
1523 m_resurrectMap = mapId;
1524 m_resurrectX = X;
1525 m_resurrectY = Y;
1526 m_resurrectZ = Z;
1527 m_resurrectHealth = health;
1528 m_resurrectMana = mana;
1530 void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); }
1531 bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; }
1532 bool isRessurectRequested() const { return m_resurrectGUID != 0; }
1533 void ResurectUsingRequestData();
1535 int getCinematic()
1537 return m_cinematic;
1539 void setCinematic(int cine)
1541 m_cinematic = cine;
1544 void addActionButton(uint8 button, uint16 action, uint8 type, uint8 misc);
1545 void removeActionButton(uint8 button);
1546 void SendInitialActionButtons();
1548 PvPInfo pvpInfo;
1549 void UpdatePvP(bool state, bool ovrride=false);
1550 void UpdateZone(uint32 newZone);
1551 void UpdateArea(uint32 newArea);
1553 void UpdateZoneDependentAuras( uint32 zone_id ); // zones
1554 void UpdateAreaDependentAuras( uint32 area_id ); // subzones
1556 void UpdateAfkReport(time_t currTime);
1557 void UpdatePvPFlag(time_t currTime);
1558 void UpdateContestedPvP(uint32 currTime);
1559 void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
1560 void ResetContestedPvP()
1562 clearUnitState(UNIT_STAT_ATTACK_PLAYER);
1563 RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
1564 m_contestedPvPTimer = 0;
1567 /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
1568 DuelInfo *duel;
1569 void UpdateDuelFlag(time_t currTime);
1570 void CheckDuelDistance(time_t currTime);
1571 void DuelComplete(DuelCompleteType type);
1573 bool IsGroupVisibleFor(Player* p) const;
1574 bool IsInSameGroupWith(Player const* p) const;
1575 bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
1576 void UninviteFromGroup();
1577 static void RemoveFromGroup(Group* group, uint64 guid);
1578 void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
1579 void SendUpdateToOutOfRangeGroupMembers();
1581 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
1582 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
1583 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
1584 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
1585 static uint32 GetGuildIdFromDB(uint64 guid);
1586 uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
1587 static uint32 GetRankFromDB(uint64 guid);
1588 int GetGuildIdInvited() { return m_GuildIdInvited; }
1589 static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
1591 // Arena Team
1592 void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot)
1594 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId);
1596 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); }
1597 static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
1598 void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
1599 uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
1601 void SetDifficulty(uint32 dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; }
1602 uint8 GetDifficulty() { return m_dungeonDifficulty; }
1604 bool UpdateSkill(uint32 skill_id, uint32 step);
1605 bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step);
1607 bool UpdateCraftSkill(uint32 spellid);
1608 bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1);
1609 bool UpdateFishingSkill();
1611 uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); }
1612 uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const;
1614 uint32 GetSpellByProto(ItemPrototype *proto);
1616 float GetHealthBonusFromStamina();
1617 float GetManaBonusFromIntellect();
1619 bool UpdateStats(Stats stat);
1620 bool UpdateAllStats();
1621 void UpdateResistances(uint32 school);
1622 void UpdateArmor();
1623 void UpdateMaxHealth();
1624 void UpdateMaxPower(Powers power);
1625 void UpdateAttackPowerAndDamage(bool ranged = false);
1626 void UpdateShieldBlockValue();
1627 void UpdateDamagePhysical(WeaponAttackType attType);
1628 void UpdateSpellDamageAndHealingBonus();
1630 void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage);
1632 void UpdateDefenseBonusesMod();
1633 void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
1634 float GetMeleeCritFromAgility();
1635 float GetDodgeFromAgility();
1636 float GetSpellCritFromIntellect();
1637 float OCTRegenHPPerSpirit();
1638 float OCTRegenMPPerSpirit();
1639 float GetRatingCoefficient(CombatRating cr) const;
1640 float GetRatingBonusValue(CombatRating cr) const;
1641 uint32 GetMeleeCritDamageReduction(uint32 damage) const;
1642 uint32 GetRangedCritDamageReduction(uint32 damage) const;
1643 uint32 GetSpellCritDamageReduction(uint32 damage) const;
1644 uint32 GetDotDamageReduction(uint32 damage) const;
1646 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
1647 void UpdateBlockPercentage();
1648 void UpdateCritPercentage(WeaponAttackType attType);
1649 void UpdateAllCritPercentages();
1650 void UpdateParryPercentage();
1651 void UpdateDodgePercentage();
1652 void UpdateAllSpellCritChances();
1653 void UpdateSpellCritChance(uint32 school);
1654 void UpdateExpertise(WeaponAttackType attType);
1655 void UpdateManaRegen();
1657 const uint64& GetLootGUID() const { return m_lootGuid; }
1658 void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; }
1660 void RemovedInsignia(Player* looterPlr);
1662 WorldSession* GetSession() const { return m_session; }
1663 void SetSession(WorldSession *s) { m_session = s; }
1665 void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const;
1666 void DestroyForPlayer( Player *target ) const;
1667 void SendDelayResponse(const uint32);
1668 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
1670 //Low Level Packets
1671 void PlaySound(uint32 Sound, bool OnlySelf);
1672 //notifiers
1673 void SendAttackSwingCantAttack();
1674 void SendAttackSwingCancelAttack();
1675 void SendAttackSwingDeadTarget();
1676 void SendAttackSwingNotStanding();
1677 void SendAttackSwingNotInRange();
1678 void SendAttackSwingBadFacingAttack();
1679 void SendAutoRepeatCancel();
1680 void SendExplorationExperience(uint32 Area, uint32 Experience);
1682 void SendDungeonDifficulty(bool IsInGroup);
1683 void ResetInstances(uint8 method);
1684 void SendResetInstanceSuccess(uint32 MapId);
1685 void SendResetInstanceFailed(uint32 reason, uint32 MapId);
1686 void SendResetFailedNotify(uint32 mapid);
1688 bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
1689 void UpdateUnderwaterState( Map * m, float x, float y, float z );
1691 void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet
1692 void SendMessageToSetInRange(WorldPacket *data, float fist, bool self);
1693 // overwrite Object::SendMessageToSetInRange
1694 void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only);
1696 static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true);
1698 Corpse *GetCorpse() const;
1699 void SpawnCorpseBones();
1700 void CreateCorpse();
1701 void KillPlayer();
1702 uint32 GetResurrectionSpellId();
1703 void ResurrectPlayer(float restore_percent, bool applySickness = false);
1704 void BuildPlayerRepop();
1705 void RepopAtGraveyard();
1707 void DurabilityLossAll(double percent, bool inventory);
1708 void DurabilityLoss(Item* item, double percent);
1709 void DurabilityPointsLossAll(int32 points, bool inventory);
1710 void DurabilityPointsLoss(Item* item, int32 points);
1711 void DurabilityPointLossForEquipSlot(EquipmentSlots slot);
1712 uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank);
1713 uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank);
1715 void StopMirrorTimers()
1717 StopMirrorTimer(FATIGUE_TIMER);
1718 StopMirrorTimer(BREATH_TIMER);
1719 StopMirrorTimer(FIRE_TIMER);
1722 void SetMovement(PlayerMovementType pType);
1724 void JoinedChannel(Channel *c);
1725 void LeftChannel(Channel *c);
1726 void CleanupChannels();
1727 void UpdateLocalChannels( uint32 newZone );
1728 void LeaveLFGChannel();
1730 void UpdateDefense();
1731 void UpdateWeaponSkill (WeaponAttackType attType);
1732 void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, MeleeHitOutcome outcome, bool defence);
1734 void SetSkill(uint32 id, uint16 currVal, uint16 maxVal);
1735 uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus
1736 uint16 GetPureMaxSkillValue(uint32 skill) const; // max
1737 uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
1738 uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus
1739 uint16 GetPureSkillValue(uint32 skill) const; // skill value
1740 int16 GetSkillTempBonusValue(uint32 skill) const;
1741 bool HasSkill(uint32 skill) const;
1742 void learnSkillRewardedSpells( uint32 id );
1743 void learnSkillRewardedSpells();
1745 void SetDontMove(bool dontMove);
1746 bool GetDontMove() const { return m_dontMove; }
1748 void CheckExploreSystem(void);
1750 static uint32 TeamForRace(uint8 race);
1751 uint32 GetTeam() const { return m_team; }
1752 static uint32 getFactionForRace(uint8 race);
1753 void setFactionForRace(uint8 race);
1755 bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
1756 bool RewardPlayerAndGroupAtKill(Unit* pVictim);
1758 FactionStateList m_factions;
1759 ForcedReactions m_forcedReactions;
1760 FactionStateList const& GetFactionStateList() { return m_factions; }
1761 uint32 GetDefaultReputationFlags(const FactionEntry *factionEntry) const;
1762 int32 GetBaseReputation(const FactionEntry *factionEntry) const;
1763 int32 GetReputation(uint32 faction_id) const;
1764 int32 GetReputation(const FactionEntry *factionEntry) const;
1765 ReputationRank GetReputationRank(uint32 faction) const;
1766 ReputationRank GetReputationRank(const FactionEntry *factionEntry) const;
1767 ReputationRank GetBaseReputationRank(const FactionEntry *factionEntry) const;
1768 ReputationRank ReputationToRank(int32 standing) const;
1769 const static int32 ReputationRank_Length[MAX_REPUTATION_RANK];
1770 const static int32 Reputation_Cap = 42999;
1771 const static int32 Reputation_Bottom = -42000;
1772 bool ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation);
1773 bool ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing);
1774 bool ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
1775 bool SetFactionReputation(uint32 FactionTemplateId, int32 standing);
1776 bool SetFactionReputation(FactionEntry const* factionEntry, int32 standing);
1777 bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
1778 int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest);
1779 void RewardReputation(Unit *pVictim, float rate);
1780 void RewardReputation(Quest const *pQuest);
1781 void SetInitialFactions();
1782 void UpdateReputation() const;
1783 void SendFactionState(FactionState const* faction) const;
1784 void SendInitialReputations();
1785 FactionState const* GetFactionState( FactionEntry const* factionEntry) const;
1786 void SetFactionAtWar(FactionState* faction, bool atWar);
1787 void SetFactionInactive(FactionState* faction, bool inactive);
1788 void SetFactionVisible(FactionState* faction);
1789 void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId);
1790 void SetFactionVisibleForFactionId(uint32 FactionId);
1791 void UpdateSkillsForLevel();
1792 void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
1793 void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
1795 /*********************************************************/
1796 /*** PVP SYSTEM ***/
1797 /*********************************************************/
1798 void UpdateArenaFields();
1799 void UpdateHonorFields();
1800 bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1);
1801 uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
1802 uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
1803 void ModifyHonorPoints( int32 value );
1804 void ModifyArenaPoints( int32 value );
1805 uint32 GetMaxPersonalArenaRatingRequirement();
1807 //End of PvP System
1809 void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0);
1810 uint16 GetDrunkValue() const { return m_drunk; }
1811 static DrunkenState GetDrunkenstateByValue(uint16 value);
1813 uint32 GetDeathTimer() const { return m_deathTimer; }
1814 uint32 GetCorpseReclaimDelay(bool pvp) const;
1815 void UpdateCorpseReclaimDelay();
1816 void SendCorpseReclaimDelay(bool load = false);
1818 uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual)
1819 bool CanParry() const { return m_canParry; }
1820 void SetCanParry(bool value);
1821 bool CanBlock() const { return m_canBlock; }
1822 void SetCanBlock(bool value);
1823 bool CanDualWield() const { return m_canDualWield; }
1824 void SetCanDualWield(bool value) { m_canDualWield = value; }
1825 bool CanTitanGrip() const { return m_canTitanGrip ; }
1826 void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
1828 void SetRegularAttackTime();
1829 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }
1830 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply);
1831 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
1832 float GetTotalBaseModValue(BaseModGroup modGroup) const;
1833 float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; }
1834 void _ApplyAllStatBonuses();
1835 void _RemoveAllStatBonuses();
1837 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
1838 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1839 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
1841 void _ApplyItemMods(Item *item,uint8 slot,bool apply);
1842 void _RemoveAllItemMods();
1843 void _ApplyAllItemMods();
1844 void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply);
1845 void _ApplyAmmoBonuses();
1846 bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot);
1847 void ToggleMetaGemsActive(uint8 exceptslot, bool apply);
1848 void CorrectMetaGemEnchants(uint8 slot, bool apply);
1849 void InitDataForForm(bool reapplyMods = false);
1851 void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
1852 void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
1853 void UpdateEquipSpellsAtFormChange();
1854 void CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType);
1856 void SendInitWorldStates();
1857 void SendUpdateWorldState(uint32 Field, uint32 Value);
1858 void SendDirectMessage(WorldPacket *data);
1860 void SendAurasForTarget(Unit *target);
1862 PlayerMenu* PlayerTalkClass;
1863 std::vector<ItemSetEffect *> ItemSetEff;
1865 void SendLoot(uint64 guid, LootType loot_type);
1866 void SendLootRelease( uint64 guid );
1867 void SendNotifyLootItemRemoved(uint8 lootSlot);
1868 void SendNotifyLootMoneyRemoved();
1870 /*********************************************************/
1871 /*** BATTLEGROUND SYSTEM ***/
1872 /*********************************************************/
1874 bool InBattleGround() const { return m_bgBattleGroundID != 0; }
1875 uint32 GetBattleGroundId() const { return m_bgBattleGroundID; }
1876 BattleGround* GetBattleGround() const;
1877 bool InArena() const;
1879 static uint32 GetMinLevelForBattleGroundQueueId(uint32 queue_id);
1880 static uint32 GetMaxLevelForBattleGroundQueueId(uint32 queue_id);
1881 uint32 GetBattleGroundQueueIdFromLevel() const;
1883 bool InBattleGroundQueue() const
1885 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1886 if (m_bgBattleGroundQueueID[i].bgQueueType != 0)
1887 return true;
1888 return false;
1891 uint32 GetBattleGroundQueueId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueType; }
1892 uint32 GetBattleGroundQueueIndex(uint32 bgQueueType) const
1894 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1895 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
1896 return i;
1897 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1899 bool IsInvitedForBattleGroundQueueType(uint32 bgQueueType) const
1901 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1902 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
1903 return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
1904 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1906 bool InBattleGroundQueueForBattleGroundQueueType(uint32 bgQueueType) const
1908 return GetBattleGroundQueueIndex(bgQueueType) < PLAYER_MAX_BATTLEGROUND_QUEUES;
1911 void SetBattleGroundId(uint32 val) { m_bgBattleGroundID = val; }
1912 uint32 AddBattleGroundQueueId(uint32 val)
1914 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1916 if (m_bgBattleGroundQueueID[i].bgQueueType == 0 || m_bgBattleGroundQueueID[i].bgQueueType == val)
1918 m_bgBattleGroundQueueID[i].bgQueueType = val;
1919 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
1920 return i;
1923 return PLAYER_MAX_BATTLEGROUND_QUEUES;
1925 bool HasFreeBattleGroundQueueId()
1927 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1928 if (m_bgBattleGroundQueueID[i].bgQueueType == 0)
1929 return true;
1930 return false;
1932 void RemoveBattleGroundQueueId(uint32 val)
1934 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1936 if (m_bgBattleGroundQueueID[i].bgQueueType == val)
1938 m_bgBattleGroundQueueID[i].bgQueueType = 0;
1939 m_bgBattleGroundQueueID[i].invitedToInstance = 0;
1940 return;
1944 void SetInviteForBattleGroundQueueType(uint32 bgQueueType, uint32 instanceId)
1946 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1947 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
1948 m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
1950 bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
1952 for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
1953 if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
1954 return true;
1955 return false;
1957 uint32 GetBattleGroundEntryPointMap() const { return m_bgEntryPointMap; }
1958 float GetBattleGroundEntryPointX() const { return m_bgEntryPointX; }
1959 float GetBattleGroundEntryPointY() const { return m_bgEntryPointY; }
1960 float GetBattleGroundEntryPointZ() const { return m_bgEntryPointZ; }
1961 float GetBattleGroundEntryPointO() const { return m_bgEntryPointO; }
1962 void SetBattleGroundEntryPoint(uint32 Map, float PosX, float PosY, float PosZ, float PosO )
1964 m_bgEntryPointMap = Map;
1965 m_bgEntryPointX = PosX;
1966 m_bgEntryPointY = PosY;
1967 m_bgEntryPointZ = PosZ;
1968 m_bgEntryPointO = PosO;
1971 void SetBGTeam(uint32 team) { m_bgTeam = team; }
1972 uint32 GetBGTeam() const { return m_bgTeam ? m_bgTeam : GetTeam(); }
1974 void LeaveBattleground(bool teleportToEntryPoint = true);
1975 bool CanJoinToBattleground() const;
1976 bool CanReportAfkDueToLimit();
1977 void ReportedAfkBy(Player* reporter);
1978 void ClearAfkReports() { m_bgAfkReporter.clear(); }
1980 bool GetBGAccessByLevel(uint32 bgTypeId) const;
1981 bool isAllowUseBattleGroundObject();
1983 /*********************************************************/
1984 /*** REST SYSTEM ***/
1985 /*********************************************************/
1987 bool isRested() const { return GetRestTime() >= 10000; }
1988 uint32 GetXPRestBonus(uint32 xp);
1989 uint32 GetRestTime() const { return m_restTime;};
1990 void SetRestTime(uint32 v) { m_restTime = v;};
1992 /*********************************************************/
1993 /*** ENVIROMENTAL SYSTEM ***/
1994 /*********************************************************/
1996 void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage);
1998 /*********************************************************/
1999 /*** FLOOD FILTER SYSTEM ***/
2000 /*********************************************************/
2002 void UpdateSpeakTime();
2003 bool CanSpeak() const;
2004 void ChangeSpeakTime(int utime);
2006 /*********************************************************/
2007 /*** VARIOUS SYSTEMS ***/
2008 /*********************************************************/
2009 MovementInfo m_movementInfo;
2010 uint32 m_lastFallTime;
2011 float m_lastFallZ;
2012 Unit *m_mover;
2013 void SetFallInformation(uint32 time, float z)
2015 m_lastFallTime = time;
2016 m_lastFallZ = z;
2018 bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); }
2019 bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); }
2021 bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); }
2022 bool IsFlying() const { return HasUnitMovementFlag(MOVEMENTFLAG_FLYING); }
2024 void HandleDrowning();
2026 void SetClientControl(Unit* target, uint8 allowMove);
2028 void EnterVehicle(Vehicle *vehicle);
2029 void ExitVehicle(Vehicle *vehicle);
2031 uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
2032 void SetFarSight(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); }
2034 // Transports
2035 Transport * GetTransport() const { return m_transport; }
2036 void SetTransport(Transport * t) { m_transport = t; }
2038 float GetTransOffsetX() const { return m_movementInfo.t_x; }
2039 float GetTransOffsetY() const { return m_movementInfo.t_y; }
2040 float GetTransOffsetZ() const { return m_movementInfo.t_z; }
2041 float GetTransOffsetO() const { return m_movementInfo.t_o; }
2042 uint32 GetTransTime() const { return m_movementInfo.t_time; }
2043 int8 GetTransSeat() const { return m_movementInfo.t_seat; }
2045 uint32 GetSaveTimer() const { return m_nextSave; }
2046 void SetSaveTimer(uint32 timer) { m_nextSave = timer; }
2048 // Recall position
2049 uint32 m_recallMap;
2050 float m_recallX;
2051 float m_recallY;
2052 float m_recallZ;
2053 float m_recallO;
2054 void SaveRecallPosition();
2056 // Homebind coordinates
2057 uint32 m_homebindMapId;
2058 uint16 m_homebindZoneId;
2059 float m_homebindX;
2060 float m_homebindY;
2061 float m_homebindZ;
2063 // currently visible objects at player client
2064 typedef std::set<uint64> ClientGUIDs;
2065 ClientGUIDs m_clientGUIDs;
2067 bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); }
2069 bool IsVisibleInGridForPlayer(Player* pl) const;
2070 bool IsVisibleGloballyFor(Player* pl) const;
2072 void UpdateVisibilityOf(WorldObject* target);
2074 template<class T>
2075 void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
2077 // Stealth detection system
2078 uint32 m_DetectInvTimer;
2079 void HandleStealthedUnitsDetection();
2081 uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
2083 bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; }
2084 void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
2086 LookingForGroup m_lookingForGroup;
2088 // Temporarily removed pet cache
2089 uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
2090 void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
2091 uint32 GetOldPetSpell() const { return m_oldpetspell; }
2092 void SetOldPetSpell(uint32 petspell) { m_oldpetspell = petspell; }
2094 /*********************************************************/
2095 /*** INSTANCE SYSTEM ***/
2096 /*********************************************************/
2098 typedef UNORDERED_MAP< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap;
2100 void UpdateHomebindTime(uint32 time);
2102 uint32 m_HomebindTimer;
2103 bool m_InstanceValid;
2104 // permanent binds and solo binds by difficulty
2105 BoundInstancesMap m_boundInstances[TOTAL_DIFFICULTIES];
2106 InstancePlayerBind* GetBoundInstance(uint32 mapid, uint8 difficulty);
2107 BoundInstancesMap& GetBoundInstances(uint8 difficulty) { return m_boundInstances[difficulty]; }
2108 void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false);
2109 void UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload = false);
2110 InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false);
2111 void SendRaidInfo();
2112 void SendSavedInstances();
2113 static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0);
2115 /*********************************************************/
2116 /*** GROUP SYSTEM ***/
2117 /*********************************************************/
2119 Group * GetGroupInvite() { return m_groupInvite; }
2120 void SetGroupInvite(Group *group) { m_groupInvite = group; }
2121 Group * GetGroup() { return m_group.getTarget(); }
2122 const Group * GetGroup() const { return (const Group*)m_group.getTarget(); }
2123 GroupReference& GetGroupRef() { return m_group; }
2124 void SetGroup(Group *group, int8 subgroup = -1);
2125 uint8 GetSubGroup() const { return m_group.getSubGroup(); }
2126 uint32 GetGroupUpdateFlag() { return m_groupUpdateMask; }
2127 void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
2128 uint64 GetAuraUpdateMask() { return m_auraUpdateMask; }
2129 void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
2130 Player* GetNextRandomRaidMember(float radius);
2131 PartyResult CanUninviteFromGroup() const;
2133 GridReference<Player> &GetGridRef() { return m_gridRef; }
2134 MapReference &GetMapRef() { return m_mapRef; }
2136 bool isAllowedToLoot(Creature* creature);
2138 WorldLocation& GetTeleportDest() { return m_teleport_dest; }
2140 DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
2141 uint8 GetRunesState() const { return m_runes->runeState; }
2142 uint8 GetBaseRune(uint8 index) const { return m_runes->runes[index].BaseRune; }
2143 uint8 GetCurrentRune(uint8 index) const { return m_runes->runes[index].CurrentRune; }
2144 uint8 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; }
2145 void SetBaseRune(uint8 index, uint8 baseRune) { m_runes->runes[index].BaseRune = baseRune; }
2146 void SetCurrentRune(uint8 index, uint8 currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
2147 void SetRuneCooldown(uint8 index, uint8 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); }
2148 void ConvertRune(uint8 index, uint8 newType);
2149 void ResyncRunes(uint8 count);
2150 void AddRunePower(uint8 index);
2151 void InitRunes();
2152 AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
2153 bool HasTitle(uint32 bitIndex);
2154 bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }
2155 void SetTitle(CharTitlesEntry const* title);
2157 protected:
2159 /*********************************************************/
2160 /*** BATTLEGROUND SYSTEM ***/
2161 /*********************************************************/
2163 /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
2164 uint32 m_bgBattleGroundID;
2166 this is an array of BG queues (BgTypeIDs) in which is player
2168 struct BgBattleGroundQueueID_Rec
2170 uint32 bgQueueType;
2171 uint32 invitedToInstance;
2173 BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES];
2174 uint32 m_bgEntryPointMap;
2175 float m_bgEntryPointX;
2176 float m_bgEntryPointY;
2177 float m_bgEntryPointZ;
2178 float m_bgEntryPointO;
2180 std::set<uint32> m_bgAfkReporter;
2181 uint8 m_bgAfkReportedCount;
2182 time_t m_bgAfkReportedTimer;
2183 uint32 m_contestedPvPTimer;
2185 uint32 m_bgTeam; // what side the player will be added to
2187 /*********************************************************/
2188 /*** QUEST SYSTEM ***/
2189 /*********************************************************/
2191 std::set<uint32> m_timedquests;
2193 uint64 m_divider;
2194 uint32 m_ingametime;
2196 /*********************************************************/
2197 /*** LOAD SYSTEM ***/
2198 /*********************************************************/
2200 void _LoadActions(QueryResult *result);
2201 void _LoadAuras(QueryResult *result, uint32 timediff);
2202 void _LoadBoundInstances(QueryResult *result);
2203 void _LoadInventory(QueryResult *result, uint32 timediff);
2204 void _LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery);
2205 void _LoadMail();
2206 void _LoadMailedItems(Mail *mail);
2207 void _LoadQuestStatus(QueryResult *result);
2208 void _LoadDailyQuestStatus(QueryResult *result);
2209 void _LoadGroup(QueryResult *result);
2210 void _LoadReputation(QueryResult *result);
2211 void _LoadSpells(QueryResult *result);
2212 void _LoadTutorials(QueryResult *result);
2213 void _LoadFriendList(QueryResult *result);
2214 bool _LoadHomeBind(QueryResult *result);
2215 void _LoadDeclinedNames(QueryResult *result);
2216 void _LoadArenaTeamInfo(QueryResult *result);
2218 /*********************************************************/
2219 /*** SAVE SYSTEM ***/
2220 /*********************************************************/
2222 void _SaveActions();
2223 void _SaveAuras();
2224 void _SaveInventory();
2225 void _SaveMail();
2226 void _SaveQuestStatus();
2227 void _SaveDailyQuestStatus();
2228 void _SaveReputation();
2229 void _SaveSpells();
2230 void _SaveTutorials();
2232 void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
2233 void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
2235 /*********************************************************/
2236 /*** ENVIRONMENTAL SYSTEM ***/
2237 /*********************************************************/
2238 void HandleLava();
2239 void HandleSobering();
2240 void StartMirrorTimer(MirrorTimerType Type, uint32 MaxValue);
2241 void ModifyMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, uint32 Regen);
2242 void StopMirrorTimer(MirrorTimerType Type);
2243 uint8 m_isunderwater;
2244 bool m_isInWater;
2246 /*********************************************************/
2247 /*** HONOR SYSTEM ***/
2248 /*********************************************************/
2249 time_t m_lastHonorUpdateTime;
2251 void outDebugValues() const;
2252 bool _removeSpell(uint16 spell_id);
2253 uint64 m_lootGuid;
2255 uint32 m_race;
2256 uint32 m_class;
2257 uint32 m_team;
2258 uint32 m_nextSave;
2259 time_t m_speakTime;
2260 uint32 m_speakCount;
2261 uint32 m_dungeonDifficulty;
2263 uint32 m_atLoginFlags;
2265 Item* m_items[PLAYER_SLOTS_COUNT];
2266 uint32 m_currentBuybackSlot;
2268 std::vector<Item*> m_itemUpdateQueue;
2269 bool m_itemUpdateQueueBlocked;
2271 uint32 m_ExtraFlags;
2272 uint64 m_curSelection;
2274 uint64 m_comboTarget;
2275 int8 m_comboPoints;
2277 QuestStatusMap mQuestStatus;
2279 uint32 m_GuildIdInvited;
2280 uint32 m_ArenaTeamIdInvited;
2282 PlayerMails m_mail;
2283 PlayerSpellMap m_spells;
2284 SpellCooldowns m_spellCooldowns;
2286 ActionButtonList m_actionButtons;
2288 float m_auraBaseMod[BASEMOD_END][MOD_END];
2290 SpellModList m_spellMods[MAX_SPELLMOD];
2291 int32 m_SpellModRemoveCount;
2292 EnchantDurationList m_enchantDuration;
2293 ItemDurationList m_itemDuration;
2295 uint64 m_resurrectGUID;
2296 uint32 m_resurrectMap;
2297 float m_resurrectX, m_resurrectY, m_resurrectZ;
2298 uint32 m_resurrectHealth, m_resurrectMana;
2300 WorldSession *m_session;
2302 typedef std::list<Channel*> JoinedChannelsList;
2303 JoinedChannelsList m_channels;
2305 bool m_dontMove;
2307 int m_cinematic;
2309 Player *pTrader;
2310 bool acceptTrade;
2311 uint16 tradeItems[TRADE_SLOT_COUNT];
2312 uint32 tradeGold;
2314 time_t m_nextThinkTime;
2316 uint32 m_Tutorials[8];
2317 bool m_TutorialsChanged;
2319 bool m_DailyQuestChanged;
2320 time_t m_lastDailyQuestTime;
2322 uint32 m_breathTimer;
2323 uint32 m_drunkTimer;
2324 uint16 m_drunk;
2325 uint32 m_weaponChangeTimer;
2327 uint32 m_zoneUpdateId;
2328 uint32 m_zoneUpdateTimer;
2329 uint32 m_areaUpdateId;
2331 uint32 m_deathTimer;
2332 time_t m_deathExpireTime;
2334 uint32 m_restTime;
2336 uint32 m_WeaponProficiency;
2337 uint32 m_ArmorProficiency;
2338 bool m_canParry;
2339 bool m_canBlock;
2340 bool m_canDualWield;
2341 bool m_canTitanGrip;
2342 uint8 m_swingErrorMsg;
2343 float m_ammoDPS;
2345 ////////////////////Rest System/////////////////////
2346 int time_inn_enter;
2347 uint32 inn_pos_mapid;
2348 float inn_pos_x;
2349 float inn_pos_y;
2350 float inn_pos_z;
2351 float m_rest_bonus;
2352 RestType rest_type;
2353 ////////////////////Rest System/////////////////////
2355 // Transports
2356 Transport * m_transport;
2358 uint32 m_resetTalentsCost;
2359 time_t m_resetTalentsTime;
2360 uint32 m_usedTalentCount;
2362 // Social
2363 PlayerSocial *m_social;
2365 // Groups
2366 GroupReference m_group;
2367 Group *m_groupInvite;
2368 uint32 m_groupUpdateMask;
2369 uint64 m_auraUpdateMask;
2371 // Temporarily removed pet cache
2372 uint32 m_temporaryUnsummonedPetNumber;
2373 uint32 m_oldpetspell;
2375 uint64 m_miniPet;
2376 GuardianPetList m_guardianPets;
2378 // Player summoning
2379 time_t m_summon_expire;
2380 uint32 m_summon_mapid;
2381 float m_summon_x;
2382 float m_summon_y;
2383 float m_summon_z;
2385 // Far Teleport
2386 WorldLocation m_teleport_dest;
2388 DeclinedName *m_declinedname;
2389 Runes *m_runes;
2390 AchievementMgr m_achievementMgr;
2391 private:
2392 // internal common parts for CanStore/StoreItem functions
2393 uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
2394 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;
2395 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;
2396 Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
2398 GridReference<Player> m_gridRef;
2399 MapReference m_mapRef;
2402 void AddItemsSetItem(Player*player,Item *item);
2403 void RemoveItemsSetItem(Player*player,ItemPrototype const *proto);
2405 // "the bodies of template functions must be made available in a header file"
2406 template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell)
2408 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
2409 if (!spellInfo) return 0;
2410 int32 totalpct = 0;
2411 int32 totalflat = 0;
2412 for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
2414 SpellModifier *mod = *itr;
2416 if(!IsAffectedBySpellmod(spellInfo,mod,spell))
2417 continue;
2418 if (mod->type == SPELLMOD_FLAT)
2419 totalflat += mod->value;
2420 else if (mod->type == SPELLMOD_PCT)
2422 // skip percent mods for null basevalue (most important for spell mods with charges )
2423 if(basevalue == T(0))
2424 continue;
2426 // special case (skip >10sec spell casts for instant cast setting)
2427 if( mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10000) && mod->value <= -100)
2428 continue;
2430 totalpct += mod->value;
2433 if (mod->charges > 0 )
2435 --mod->charges;
2436 if (mod->charges == 0)
2438 mod->charges = -1;
2439 mod->lastAffected = spell;
2440 if(!mod->lastAffected)
2441 mod->lastAffected = FindCurrentSpellBySpellId(spellId);
2442 ++m_SpellModRemoveCount;
2447 float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat;
2448 basevalue = T((float)basevalue + diff);
2449 return T(diff);
2451 #endif