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