TrinityCore
Loading...
Searching...
No Matches
Player.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _PLAYER_H
19#define _PLAYER_H
20
21#include "GridObject.h"
22#include "Unit.h"
23#include "CUFProfile.h"
24#include "DatabaseEnvFwd.h"
25#include "DBCEnums.h"
26#include "EquipmentSet.h"
27#include "GroupReference.h"
28#include "Hash.h"
29#include "ItemDefines.h"
30#include "ItemEnchantmentMgr.h"
31#include "MapReference.h"
32#include "PetDefines.h"
33#include "PlayerTaxi.h"
34#include "QuestDef.h"
35#include "SceneMgr.h"
36
38struct AchievementEntry;
39struct AreaTableEntry;
40struct AreaTriggerEntry;
47struct CharTitlesEntry;
50struct CreatureTemplate;
52struct FactionEntry;
56struct ItemSetEffect;
57struct ItemTemplate;
58struct Loot;
59struct Mail;
60struct MapEntry;
61struct PvpTalentEntry;
63struct RewardPackEntry;
65struct TalentEntry;
66struct TrainerSpell;
68struct VendorItem;
70
71class AELootResult;
72class Bag;
73class Battleground;
74class Channel;
75class CinematicMgr;
76class Creature;
77class DynamicObject;
78class Garrison;
79class Group;
80class Guild;
81class Item;
82class LootRoll;
83class LootStore;
84class OutdoorPvP;
85class Pet;
86class PetAura;
87class PlayerAI;
89class PlayerMenu;
90class PlayerSocial;
92class ReputationMgr;
93class RestMgr;
95class TradeData;
96
97enum class ChrSpecialization : uint32;
98enum GroupCategory : uint8;
99enum class InstanceResetMethod : uint8;
100enum class InstanceResetResult : uint8;
101enum InventoryType : uint8;
102enum ItemClass : uint8;
103enum LootError : uint8;
104enum LootType : uint8;
106enum class PlayerCreateMode : int8;
107enum RestTypes : uint8;
109
110namespace BattlePets
111{
112 struct BattlePet;
113}
114
115namespace WorldPackets
116{
117 namespace Character
118 {
119 struct CharacterCreateInfo;
120 }
121
122 namespace Movement
123 {
125 }
126
127 namespace Traits
128 {
129 struct TraitConfig;
130 struct TraitEntry;
131 }
132}
133
134TC_GAME_API uint32 GetBagSize(Bag const* bag);
135TC_GAME_API Item* GetItemInBag(Bag const* bag, uint8 slot);
136
137typedef std::deque<Mail*> PlayerMails;
138
140{
141 PLAYER_MAX_SKILLS = UF::size<decltype(UF::SkillInfo::SkillLineID)>()
143
145{
146 PLAYER_EXPLORED_ZONES_SIZE = UF::size<decltype(UF::ActivePlayerData::ExploredZones)>(),
147 PLAYER_EXPLORED_ZONES_BITS = UF::size_of_value_type<decltype(UF::ActivePlayerData::ExploredZones)>() * 8
149
151{
152 SPELLMOD_FLAT = 0, // SPELL_AURA_ADD_FLAT_MODIFIER
153 SPELLMOD_PCT = 1, // SPELL_AURA_ADD_PCT_MODIFIER
154 SPELLMOD_LABEL_FLAT = 2, // SPELL_AURA_ADD_FLAT_MODIFIER_BY_SPELL_LABEL
155 SPELLMOD_LABEL_PCT = 3, // SPELL_AURA_ADD_PCT_MODIFIER_BY_SPELL_LABEL
158
159// 2^n values, Player::m_isunderwater is a bitmask. These are Trinity internal values, they are never send to any client
161{
163 UNDERWATER_INWATER = 0x01, // terrain type is water and player is afflicted by it
164 UNDERWATER_INLAVA = 0x02, // terrain type is lava and player is afflicted by it
165 UNDERWATER_INSLIME = 0x04, // terrain type is lava and player is afflicted by it
166 UNDERWATER_INDARKWATER = 0x08, // terrain type is dark water and player is afflicted by it
167
170
172{
178
180{
187
189{
191 bool active : 1; // show in spellbook
192 bool dependent : 1; // learned as result another spell learn, skill grow, quest reward, etc
193 bool disabled : 1; // first rank has been learned in result talent learn but currently talent unlearned, save max learned ranks
194 bool favorite : 1;
196};
197
199{
201
202 enum
203 {
208};
209
211{
217
218// Spell modifier (used for modify other spells)
220{
222 virtual ~SpellModifier() = default;
223
226
229};
230
232{
233 SpellModifierByClassMask(Aura* _ownerAura) : SpellModifier(_ownerAura), value(0), mask() { }
234
237};
238
239template<typename T>
241{
242 SpellModifierByLabel(Aura* _ownerAura) : SpellModifier(_ownerAura) { }
243
245};
246
249
251{
255 PLAYERCURRENCY_REMOVED = 3 //not removed just set count == 0
257
259{
267};
268
269typedef std::unordered_map<uint32, PlayerSpellState> PlayerTalentMap;
270typedef std::array<uint32, MAX_PVP_TALENT_SLOTS> PlayerPvpTalentMap;
271typedef std::unordered_map<uint32, PlayerSpell> PlayerSpellMap;
272typedef std::unordered_set<SpellModifier*> SpellModContainer;
273typedef std::unordered_map<uint32, PlayerCurrency> PlayerCurrenciesMap;
274
275typedef std::unordered_map<uint32 /*instanceId*/, time_t/*releaseTime*/> InstanceTimeMap;
276
278{
284
286{
288 ACTION_BUTTON_C = 0x01, // click?
295 ACTION_BUTTON_ITEM = 0x80
297
299{
308
309#define ACTION_BUTTON_ACTION(X) (uint64(X) & 0x00FFFFFFFFFFFFFF)
310#define ACTION_BUTTON_TYPE(X) ((uint64(X) & 0xFF00000000000000) >> 56)
311#define MAX_ACTION_BUTTON_ACTION_VALUE UI64LIT(0xFFFFFFFFFFFFFF)
312
314{
316
319
320 // helpers
324 {
325 uint64 newData = uint64(action) | (uint64(type) << 56);
326 if (newData != packedData || uState == ACTIONBUTTON_DELETED)
327 {
328 packedData = newData;
331 }
332 }
333};
334
335#define MAX_ACTION_BUTTONS 180
336
337typedef std::map<uint8, ActionButton> ActionButtonList;
338
340{
341 PvPInfo() : IsHostile(false), IsInHostileArea(false), IsInNoPvPArea(false), IsInFFAPvPArea(false), EndTimer(0) { }
342
347 time_t EndTimer;
348};
349
351{
358{
359 DuelInfo(Player* opponent, Player* initiator, bool isMounted) : Opponent(opponent), Initiator(initiator), IsMounted(isMounted) {}
360
363 bool const IsMounted;
365 time_t StartTime = 0;
366 time_t OutOfBoundsTime = 0;
367};
368
369struct Areas
370{
373 float x1;
374 float x2;
375 float y1;
376 float y2;
377};
378
379#define MAX_RUNES 7
380#define MAX_RECHARGING_RUNES 3
381
383{
385 RUNE_MISS_COOLDOWN = 1500 // cooldown applied on runes when the spell misses
387
388struct Runes
389{
390 std::deque<uint8> CooldownOrder;
392 uint8 RuneState; // mask of available runes
393
394 void SetRuneState(uint8 index, bool set = true);
395};
396
398{
400 EnchantDuration(Item* _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot),
401 leftduration(_leftduration){ ASSERT(item); }
402
406};
407
408typedef std::list<EnchantDuration> EnchantDurationList;
409typedef std::list<Item*> ItemDurationList;
410
412{
418
419#define MAX_DRUNKEN 4
420
422{
424 PLAYER_FLAGS_AFK = 0x00000002,
425 PLAYER_FLAGS_DND = 0x00000004,
426 PLAYER_FLAGS_GM = 0x00000008,
427 PLAYER_FLAGS_GHOST = 0x00000010,
430 PLAYER_FLAGS_UNK7 = 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
431 PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
435 PLAYER_FLAGS_PLAYED_LONG_TIME = 0x00001000, // played long time
436 PLAYER_FLAGS_PLAYED_TOO_LONG = 0x00002000, // played too long time
438 PLAYER_FLAGS_DEVELOPER = 0x00008000, // <Dev> prefix for something?
439 PLAYER_FLAGS_LOW_LEVEL_RAID_ENABLED = 0x00010000, // pre-3.0.3 PLAYER_FLAGS_SANCTUARY flag for player entered sanctuary
440 PLAYER_FLAGS_TAXI_BENCHMARK = 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
441 PLAYER_FLAGS_PVP_TIMER = 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
442 PLAYER_FLAGS_UBER = 0x00080000,
443 PLAYER_FLAGS_UNK20 = 0x00100000,
444 PLAYER_FLAGS_UNK21 = 0x00200000,
446 PLAYER_FLAGS_HIDE_ACCOUNT_ACHIEVEMENTS = 0x00800000, // do not send account achievments in inspect packets
447 PLAYER_FLAGS_PET_BATTLES_UNLOCKED = 0x01000000, // enables pet battles
449 PLAYER_FLAGS_UNK26 = 0x04000000,
450 PLAYER_FLAGS_AUTO_DECLINE_GUILD = 0x08000000, // Automatically declines guild invites
451 PLAYER_FLAGS_GUILD_LEVEL_ENABLED = 0x10000000, // Lua_GetGuildLevelEnabled() - enables guild leveling related UI
452 PLAYER_FLAGS_VOID_UNLOCKED = 0x20000000, // void storage
456
458
460{
464 PLAYER_FLAGS_EX_IN_PVP_COMBAT = 0x0040, // Forbids /follow
469
471
473{
474 PLAYER_LOCAL_FLAG_CONTROLLING_PET = 0x00000001, // Displays "You have an active summon already" when trying to tame new pet
476 PLAYER_LOCAL_FLAG_RELEASE_TIMER = 0x00000008, // Display time till auto release spirit
477 PLAYER_LOCAL_FLAG_NO_RELEASE_WINDOW = 0x00000010, // Display no "release spirit" window at all
478 PLAYER_LOCAL_FLAG_NO_PET_BAR = 0x00000020, // CGPetInfo::IsPetBarUsed
485 PLAYER_LOCAL_FLAG_ACCOUNT_SECURED = 0x00001000, // Script_IsAccountSecured
489};
490
492
493// used in PLAYER_FIELD_BYTES2 values
495{
500
502{
505 FIRE_TIMER = 2 // feign death
507#define MAX_TIMERS 3
508#define DISABLED_MIRROR_TIMER -1
509
510// 2^n values
512{
513 // gm abilities
518 PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages
519
520 // other states
521 PLAYER_EXTRA_PVP_DEATH = 0x0100, // store PvP death status until corpse creating.
522
523 // Character services markers
527};
528
529// 2^n values
531{
542};
543
544typedef std::map<uint32, QuestStatusData> QuestStatusMap;
545
547{
548 QuestStatusMap::iterator QuestStatusItr;
550};
551
552using QuestObjectiveStatusMap = std::unordered_multimap<std::pair<QuestObjectiveType, int32>, QuestObjectiveStatusData>;
553
554typedef std::set<uint32> RewardedQuestSet;
555
557{
562
563// quest
564typedef std::map<uint32, QuestSaveType> QuestStatusSaveMap;
565
566// Size of client completed quests bit map
568{
569 QUESTS_COMPLETED_BITS_SIZE = UF::size<decltype(UF::ActivePlayerData::QuestCompleted)>(),
570 QUESTS_COMPLETED_BITS_PER_BLOCK = UF::size_of_value_type<decltype(UF::ActivePlayerData::QuestCompleted)>() * 8
572
574{
575 MAX_QUEST_COUNTS = UF::size<decltype(UF::QuestLog::ObjectiveProgress)>()
577
579{
582 QUEST_STATE_FAIL = 0x0002
584
586{
590 SKILL_DELETED = 3
592
594{
595 SkillStatusData(uint8 _pos, SkillUpdateState _uState) : pos(_pos), uState(_uState)
596 {
597 }
600};
601
602typedef std::unordered_map<uint32, SkillStatusData> SkillStatusMap;
603
604class Quest;
605class Spell;
606class Item;
607class WorldSession;
608
610{
611 // first slot for item stored (in any way in player m_items data)
613 // last+1 slot for item stored (in any way in player m_items data)
617
618static_assert(UF::size<decltype(UF::ActivePlayerData::InvSlots)>() == PLAYER_SLOT_END);
619
620#define INVENTORY_SLOT_BAG_0 255
621#define INVENTORY_DEFAULT_SIZE 16
622
623enum EquipmentSlots : uint8 // 19 slots
624{
647
649{
661
664
667
668enum InventorySlots : uint8 // 4 slots
669{
673
674enum ReagentBagSlots : uint8 // 1 slot
675{
679
680enum InventoryPackSlots : uint8 // 28 slots
681{
685
686enum BankItemSlots // 28 slots
687{
691
692enum BankBagSlots // 7 slots
693{
697
698enum BuyBackSlots // 12 slots
699{
700 // stored in m_buybackitems
702 BUYBACK_SLOT_END = 110
704
705enum ReagentSlots // 98 slots
706{
709};
710
712{
715};
716
717// slots past 214 are guessed (unused in client)
719{
736};
737
739{
740 ItemPosCount(uint16 _pos, uint32 _count) : pos(_pos), count(_count) { }
741 bool isContainedIn(std::vector<ItemPosCount> const& vec) const;
744};
745typedef std::vector<ItemPosCount> ItemPosCountVec;
746
748{
749 Equipment = 0x01,
750 Inventory = 0x02,
751 Bank = 0x04,
752 ReagentBank = 0x08,
753
756};
757
759
761{
762 Stop,
764};
765
767{
768 NEW_WORLD_NORMAL = 16, // Normal map change
769 NEW_WORLD_SEAMLESS = 21, // Teleport to another map without a loading screen, used for outdoor scenarios
770};
771
773{
774 RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s).
775 RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)!
776 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!
777 RAID_INSTANCE_WELCOME = 4, // Welcome to %s. This raid instance is scheduled to reset in %s.
780
781// PLAYER_FIELD_ARENA_TEAM_INFO_1_1 offsets
783{
785 ARENA_TEAM_TYPE = 1, // new in 3.2 - team type?
786 ARENA_TEAM_MEMBER = 2, // 0 - captain, 1 - member
793
795{
802 TELE_TO_TRANSPORT_TELEPORT = 0x20, // 3.3.5 only
804 TELE_TO_SEAMLESS = 0x80
806
808
811{
818 DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
820
822{
826
827#define MAX_PLAYED_TIME_INDEX 2
828
829// used at player loading query list preparing, and later result selection
831{
897
899{
908
909// Player summoning auto-decline time (in secs)
910#define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
911// Maximum money amount : 2^31 - 1
913
915{
916 CHAR_DELETE_REMOVE = 0, // Completely remove from the database
917 CHAR_DELETE_UNLINK = 1 // The character gets unlinked from the account,
918 // the name gets freed up and appears as deleted ingame
920
922{
940
942{
944 CHEAT_GOD = 0x01,
948 CHEAT_WATERWALK = 0x10
950
952{
956
958{
959 NewItem = 0,
960 NewCurrency = 1,
961 Money = 2,
962 Honor = 3
963};
964
966{
967 DoNotDisplay = 0,
968 Loot = 1,
969 PetBattle = 2,
970 PersonalLoot = 3,
972 QuestUpgrade = 5,
974 Shipment = 7,
977 GarrisonCurrency = 10,
978 LessAwesomeLoot = 11,
979 UpgradedLoot = 12,
980 LegendaryLoot = 13,
981 InvasionLoot = 14,
982 Default = 15,
983 QuestComplete = 16,
984 RatedPvPReward = 17,
985 CorruptedLoot = 19
986};
987
988class Player;
989
991struct BGData
992{
995
999
1003
1005
1008
1011
1012 void ClearTaxiPath() { taxiPath[0] = taxiPath[1] = 0; }
1013 bool HasTaxiPath() const { return taxiPath[0] && taxiPath[1]; }
1014};
1015
1017{
1019 VoidStorageItem(uint64 id, uint32 entry, ObjectGuid const& creator, ItemRandomBonusListId randomBonusListId,
1020 uint32 fixedScalingLevel, uint32 artifactKnowledgeLevel, ItemContext context, std::vector<int32> const& bonuses)
1021 : ItemId(id), ItemEntry(entry), CreatorGuid(creator), RandomBonusListId(randomBonusListId),
1022 FixedScalingLevel(fixedScalingLevel), ArtifactKnowledgeLevel(artifactKnowledgeLevel), Context(context)
1023 {
1024 BonusListIDs.insert(BonusListIDs.end(), bonuses.begin(), bonuses.end());
1025 }
1026 VoidStorageItem(VoidStorageItem&& vsi) noexcept : ItemId(vsi.ItemId), ItemEntry(vsi.ItemEntry), CreatorGuid(vsi.CreatorGuid), RandomBonusListId(vsi.RandomBonusListId),
1027 FixedScalingLevel(vsi.FixedScalingLevel), ArtifactKnowledgeLevel(vsi.ArtifactKnowledgeLevel), Context(vsi.Context), BonusListIDs(std::move(vsi.BonusListIDs)) { }
1028
1036 std::vector<int32> BonusListIDs;
1037};
1038
1040{
1046};
1047
1049{
1052};
1053
1055{
1068
1070{
1071 SpecializationInfo() : PvpTalents(), ResetTalentsCost(0), ResetTalentsTime(0), ActiveGroup(0)
1072 {
1073 for (PlayerPvpTalentMap& pvpTalents : PvpTalents)
1074 pvpTalents.fill(0);
1075 }
1076
1079 std::vector<uint32> Glyphs[MAX_SPECIALIZATIONS];
1083
1084private:
1087};
1088
1092float constexpr MAX_AREA_SPIRIT_HEALER_RANGE = 20.0f;
1093
1095{
1096 None = 0,
1097 Friendly = 1,
1098 Hostile = 2,
1099 Contested = 3,
1100 Combat = 4
1101};
1102
1103class TC_GAME_API Player : public Unit, public GridObject<Player>
1104{
1105 friend class WorldSession;
1106 friend class CinematicMgr;
1107 friend class RestMgr;
1108 friend void AddItemToUpdateQueueOf(Item* item, Player* player);
1109 friend void RemoveItemFromUpdateQueueOf(Item* item, Player* player);
1110 public:
1111 explicit Player(WorldSession* session);
1112 ~Player();
1113
1114 PlayerAI* AI() const { return reinterpret_cast<PlayerAI*>(GetAI()); }
1115
1116 void CleanupsBeforeDelete(bool finalCleanup = true) override;
1117
1118 void AddToWorld() override;
1119 void RemoveFromWorld() override;
1120
1121 void SetObjectScale(float scale) override;
1122
1123 bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, TeleportToOptions options = TELE_TO_NONE, Optional<uint32> instanceId = {});
1124 bool TeleportTo(WorldLocation const& loc, TeleportToOptions options = TELE_TO_NONE, Optional<uint32> instanceId = {});
1125 bool TeleportToBGEntryPoint();
1126
1127 bool HasSummonPending() const;
1128 void SendSummonRequestFrom(Unit* summoner);
1129 void SummonIfPossible(bool agree);
1130
1131 bool Create(ObjectGuid::LowType guidlow, WorldPackets::Character::CharacterCreateInfo const* createInfo);
1132
1133 void Update(uint32 time) override;
1134
1135 bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster, bool requireImmunityPurgesEffectAttribute = false) const override;
1136
1137 bool IsInAreaTriggerRadius(AreaTriggerEntry const* trigger) const;
1138
1139 void SendInitialPacketsBeforeAddToMap();
1140 void SendInitialPacketsAfterAddToMap();
1141 void SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const;
1142 void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg = 0, int32 mapDifficultyXConditionID = 0) const;
1143
1144 bool CanInteractWithQuestGiver(Object* questGiver) const;
1145 Creature* GetNPCIfCanInteractWith(ObjectGuid const& guid, NPCFlags npcFlags, NPCFlags2 npcFlags2) const;
1146 GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid) const;
1147 GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid, GameobjectTypes type) const;
1148
1149 void ToggleAFK();
1150 void ToggleDND();
1151 bool isAFK() const { return HasPlayerFlag(PLAYER_FLAGS_AFK); }
1152 bool isDND() const { return HasPlayerFlag(PLAYER_FLAGS_DND); }
1153 uint16 GetChatFlags() const;
1154 std::string autoReplyMsg;
1155
1156 int64 GetBarberShopCost(Trinity::IteratorPair<UF::ChrCustomizationChoice const*> newCustomizations) const;
1157
1158 PlayerSocial* GetSocial() const { return m_social; }
1159 void RemoveSocial();
1160
1162 void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(GetRace(), GetClass(), GetLevel()); }
1163 bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = nullptr, uint32 spellid = 0, uint32 preferredMountDisplay = 0);
1164 bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0);
1165 void FinishTaxiFlight();
1166 void CleanupAfterTaxiFlight();
1167 void ContinueTaxiFlight() const;
1168
1169 bool IsDeveloper() const { return HasPlayerFlag(PLAYER_FLAGS_DEVELOPER); }
1170 void SetDeveloper(bool on) { if (on) SetPlayerFlag(PLAYER_FLAGS_DEVELOPER); else RemovePlayerFlag(PLAYER_FLAGS_DEVELOPER); }
1171 bool isAcceptWhispers() const { return (m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS) != 0; }
1172 void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
1173 bool IsGameMaster() const { return (m_ExtraFlags & PLAYER_EXTRA_GM_ON) != 0; }
1174 bool IsGameMasterAcceptingWhispers() const { return IsGameMaster() && isAcceptWhispers(); }
1175 bool CanBeGameMaster() const;
1176 void SetGameMaster(bool on);
1177 bool isGMChat() const { return (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT) != 0; }
1178 void SetGMChat(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
1179 bool isTaxiCheater() const { return (m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT) != 0; }
1180 void SetTaxiCheater(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
1181 bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
1182 void SetGMVisible(bool on);
1183 void SetPvPDeath(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
1184 bool HasRaceChanged() const { return (m_ExtraFlags & PLAYER_EXTRA_HAS_RACE_CHANGED) != 0; }
1186 bool HasBeenGrantedLevelsFromRaF() const { return (m_ExtraFlags & PLAYER_EXTRA_GRANTED_LEVELS_FROM_RAF) != 0; }
1188 bool HasLevelBoosted() const { return (m_ExtraFlags & PLAYER_EXTRA_LEVEL_BOOSTED) != 0; }
1190
1191 uint32 GetXP() const { return m_activePlayerData->XP; }
1192 uint32 GetXPForNextLevel() const { return m_activePlayerData->NextLevelXP; }
1193 void SetXP(uint32 xp);
1194 void GiveXP(uint32 xp, Unit* victim, float group_rate=1.0f);
1195 void GiveLevel(uint8 level);
1196 bool IsMaxLevel() const;
1197
1198 void InitStatsForLevel(bool reapplyMods = false);
1199
1200 // .cheat command related
1201 bool GetCommandStatus(uint32 command) const { return (_activeCheats & command) != 0; }
1202 void SetCommandStatusOn(uint32 command) { _activeCheats |= command; }
1203 void SetCommandStatusOff(uint32 command) { _activeCheats &= ~command; }
1204
1205 // Played Time Stuff
1208 std::array<uint32, MAX_PLAYED_TIME_INDEX> m_Played_time;
1209 uint32 GetTotalPlayedTime() const { return m_Played_time[PLAYED_TIME_TOTAL]; }
1210 uint32 GetLevelPlayedTime() const { return m_Played_time[PLAYED_TIME_LEVEL]; }
1211
1212 Gender GetNativeGender() const override { return Gender(*m_playerData->NativeSex); }
1213 void SetNativeGender(Gender gender) override { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::NativeSex), gender); }
1214
1215 void setDeathState(DeathState s) override; // overwrite Unit::setDeathState
1216
1217 PetStable* GetPetStable() { return m_petStable.get(); }
1218 PetStable& GetOrInitPetStable();
1219 PetStable const* GetPetStable() const { return m_petStable.get(); }
1220 void AddPetToUpdateFields(PetStable::PetInfo const& pet, PetSaveMode slot, PetStableFlags flags);
1221 void SetPetSlot(uint32 petNumber, PetSaveMode dstPetSlot);
1222 ObjectGuid GetStableMaster() const;
1223 void SetStableMaster(ObjectGuid stableMaster);
1224
1225 Pet* GetPet() const;
1226 Pet* SummonPet(uint32 entry, Optional<PetSaveMode> slot, float x, float y, float z, float ang, uint32 despwtime, bool* isNew = nullptr);
1227 void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
1228 void SendTameFailure(PetTameResult result);
1229
1230 // pet auras
1231 std::unordered_set<PetAura const*> m_petAuras;
1232 void AddPetAura(PetAura const* petSpell);
1233 void RemovePetAura(PetAura const* petSpell);
1234
1235 Creature* GetSummonedBattlePet();
1236 void SetBattlePetData(BattlePets::BattlePet const* pet = nullptr);
1237
1239 void Say(std::string_view text, Language language, WorldObject const* = nullptr) override;
1240 void Say(uint32 textId, WorldObject const* target = nullptr) override;
1242 void Yell(std::string_view text, Language language, WorldObject const* = nullptr) override;
1243 void Yell(uint32 textId, WorldObject const* target = nullptr) override;
1245 void TextEmote(std::string_view text, WorldObject const* = nullptr, bool = false) override;
1246 void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false) override;
1248 void Whisper(std::string_view text, Language language, Player* receiver, bool = false) override;
1249 void Whisper(uint32 textId, Player* target, bool isBossWhisper = false) override;
1250 void WhisperAddon(std::string const& text, std::string const& prefix, bool isLogged, Player* receiver);
1251
1252 bool CanUnderstandLanguage(Language language) const;
1253
1254 /*********************************************************/
1255 /*** STORAGE SYSTEM ***/
1256 /*********************************************************/
1257
1264 template <typename T>
1265 bool ForEachItem(ItemSearchLocation location, T callback) const
1266 {
1267 EnumFlag<ItemSearchLocation> flag = location;
1268
1269 if (flag.HasFlag(ItemSearchLocation::Equipment))
1270 {
1272 if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
1273 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1274 return false;
1275
1277 if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
1278 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1279 return false;
1280 }
1281
1282 if (flag.HasFlag(ItemSearchLocation::Inventory))
1283 {
1284 uint8 inventoryEnd = INVENTORY_SLOT_ITEM_START + GetInventorySlotCount();
1285 for (uint8 i = INVENTORY_SLOT_BAG_START; i < inventoryEnd; ++i)
1286 if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
1287 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1288 return false;
1289
1291 if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
1292 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1293 return false;
1294
1296 if (Bag* pBag = GetBagByPos(i))
1297 for (uint32 j = 0; j < GetBagSize(pBag); ++j)
1298 if (Item* pItem = GetItemInBag(pBag, j))
1299 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1300 return false;
1301 }
1302
1303 if (flag.HasFlag(ItemSearchLocation::Bank))
1304 {
1305 for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_BAG_END; ++i)
1306 if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
1307 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1308 return false;
1309
1310 for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
1311 if (Bag* pBag = GetBagByPos(i))
1312 for (uint32 j = 0; j < GetBagSize(pBag); ++j)
1313 if (Item* pItem = GetItemInBag(pBag, j))
1314 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1315 return false;
1316 }
1317
1318 if (flag.HasFlag(ItemSearchLocation::ReagentBank))
1319 {
1321 if (Bag* bag = GetBagByPos(i))
1322 for (uint32 j = 0; j < GetBagSize(bag); ++j)
1323 if (Item* pItem = GetItemInBag(bag, j))
1324 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1325 return false;
1326
1327 for (uint8 i = REAGENT_SLOT_START; i < REAGENT_SLOT_END; ++i)
1328 if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
1329 if (callback(pItem) == ItemSearchCallbackResult::Stop)
1330 return false;
1331 }
1332
1333 return true;
1334 }
1335
1336 public:
1337 void UpdateAverageItemLevelTotal();
1338 void UpdateAverageItemLevelEquipped();
1339
1340 uint8 FindEquipSlot(Item const* item, uint32 slot, bool swap) const;
1341 uint32 GetFreeInventorySlotCount(EnumFlag<ItemSearchLocation> location = ItemSearchLocation::Inventory) const;
1342 uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = nullptr) const;
1343 uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const;
1344 Item* GetItemByGuid(ObjectGuid guid) const;
1345 Item* GetItemByEntry(uint32 entry, ItemSearchLocation where = ItemSearchLocation::Default) const;
1346 std::vector<Item*> GetItemListByEntry(uint32 entry, bool inBankAlso = false) const;
1347 Item* GetItemByPos(uint16 pos) const;
1348 Item* GetItemByPos(uint8 bag, uint8 slot) const;
1349 Item* GetUseableItemByPos(uint8 bag, uint8 slot) const;
1350 Bag* GetBagByPos(uint8 slot) const;
1351 std::vector<Item*> GetCraftingReagentItemsToDeposit();
1352 uint32 GetFreeInventorySpace() const;
1353 Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const;
1354 Item* GetShield(bool useable = false) const;
1355 Item* GetChildItemByGuid(ObjectGuid guid) const;
1356 static WeaponAttackType GetAttackBySlot(uint8 slot, InventoryType inventoryType); // MAX_ATTACK if not weapon slot
1357 std::vector<Item*>& GetItemUpdateQueue() { return m_itemUpdateQueue; }
1358 static bool IsInventoryPos(uint16 pos) { return IsInventoryPos(pos >> 8, pos & 255); }
1359 static bool IsInventoryPos(uint8 bag, uint8 slot);
1360 static bool IsEquipmentPos(uint16 pos) { return IsEquipmentPos(pos >> 8, pos & 255); }
1361 static bool IsEquipmentPos(uint8 bag, uint8 slot);
1362 static bool IsBagPos(uint16 pos);
1363 static bool IsBankPos(uint16 pos) { return IsBankPos(pos >> 8, pos & 255); }
1364 static bool IsBankPos(uint8 bag, uint8 slot);
1365 static bool IsReagentBankPos(uint16 pos) { return IsReagentBankPos(pos >> 8, pos & 255); }
1366 static bool IsReagentBankPos(uint8 bag, uint8 slot);
1367 static bool IsChildEquipmentPos(uint16 pos) { return IsChildEquipmentPos(pos >> 8, pos & 255); }
1368 static bool IsChildEquipmentPos(uint8 bag, uint8 slot);
1369 bool IsValidPos(uint16 pos, bool explicit_pos) const { return IsValidPos(pos >> 8, pos & 255, explicit_pos); }
1370 bool IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const;
1371 uint8 GetInventorySlotCount() const { return m_activePlayerData->NumBackpackSlots; }
1372 void SetInventorySlotCount(uint8 slots);
1373 uint8 GetBankBagSlotCount() const { return m_activePlayerData->NumBankSlots; }
1374 void SetBankBagSlotCount(uint8 count) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::NumBankSlots), count); }
1375 bool HasItemCount(uint32 item, uint32 count = 1, bool inBankAlso = false) const;
1376 bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = nullptr) const;
1377 bool CanNoReagentCast(SpellInfo const* spellInfo) const;
1379 {
1380 for (uint8 i = 0; i < 4; ++i)
1381 SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::NoReagentCostMask, i), mask[i]);
1382 }
1383 bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
1384 bool HasItemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
1385 bool HasGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
1386 InventoryResult CanTakeMoreSimilarItems(Item* pItem, uint32* offendingItemId = nullptr) const;
1387 InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, uint32* offendingItemId = nullptr) const { return CanTakeMoreSimilarItems(entry, count, nullptr, nullptr, offendingItemId); }
1388 InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = nullptr) const;
1389 InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const;
1390 InventoryResult CanStoreItems(Item** items, int count, uint32* offendingItemId) const;
1391 InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const;
1392 InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading = true) const;
1393
1394 // This method must be called before equipping parent item!
1395 InventoryResult CanEquipChildItem(Item* parentItem) const;
1396
1397 InventoryResult CanEquipUniqueItem(Item* pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const;
1398 InventoryResult CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const;
1399 InventoryResult CanUnequipItems(uint32 item, uint32 count) const;
1400 InventoryResult CanUnequipItem(uint16 src, bool swap) const;
1401 InventoryResult CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap, bool not_loading = true, bool reagentBankOnly = false) const;
1402 InventoryResult CanUseItem(Item* pItem, bool not_loading = true) const;
1403 bool HasItemTotemCategory(uint32 TotemCategory) const;
1404 InventoryResult CanUseItem(ItemTemplate const* pItem, bool skipRequiredLevelCheck = false) const;
1405 InventoryResult CanRollNeedForItem(ItemTemplate const* item, Map const* map, bool restrictOnlyLfg) const;
1406 Item* StoreNewItem(ItemPosCountVec const& pos, uint32 itemId, bool update, ItemRandomBonusListId randomBonusListId = 0, GuidSet const& allowedLooters = GuidSet(),
1407 ItemContext context = ItemContext::NONE, std::vector<int32> const* bonusListIDs = nullptr, bool addToCollection = true);
1408 Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update);
1409 Item* EquipNewItem(uint16 pos, uint32 item, ItemContext context, bool update);
1410 Item* EquipItem(uint16 pos, Item* pItem, bool update);
1411 void AutoUnequipOffhandIfNeed(bool force = false);
1412 void EquipChildItem(uint8 parentBag, uint8 parentSlot, Item* parentItem);
1413 void AutoUnequipChildItem(Item* parentItem);
1414 bool StoreNewItemInBestSlots(uint32 itemId, uint32 amount, ItemContext context);
1415 void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, ItemContext context = ItemContext::NONE, bool broadcast = false, bool createdByPlayer = false);
1416 void AutoStoreLoot(uint32 loot_id, LootStore const& store, ItemContext context = ItemContext::NONE, bool broadcast = false, bool createdByPlayer = false) { AutoStoreLoot(NULL_BAG, NULL_SLOT, loot_id, store, context, broadcast, createdByPlayer); }
1417 void StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot* loot, AELootResult* aeResult = nullptr);
1418
1419 InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = nullptr, uint32* offendingItemId = nullptr) const;
1420 InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = nullptr, bool swap = false, uint32* no_space_count = nullptr) const;
1421
1422 void AddRefundReference(ObjectGuid it);
1423 void DeleteRefundReference(ObjectGuid it);
1424
1426 void SendCurrencies() const;
1428 void SendPvpRewards() const;
1430 void SetCreateCurrency(uint32 id, uint32 amount);
1432 void ModifyCurrency(uint32 id, int32 amount, CurrencyGainSource gainSource = CurrencyGainSource::Cheat, CurrencyDestroyReason destroyReason = CurrencyDestroyReason::Cheat);
1433 void AddCurrency(uint32 id, uint32 amount, CurrencyGainSource gainSource = CurrencyGainSource::Cheat);
1434 void RemoveCurrency(uint32 id, int32 amount, CurrencyDestroyReason destroyReason = CurrencyDestroyReason::Cheat);
1436 void IncreaseCurrencyCap(uint32 id, uint32 amount);
1438 void ResetCurrencyWeekCap();
1439
1440 uint32 GetCurrencyQuantity(uint32 id) const;
1441 uint32 GetCurrencyWeeklyQuantity(uint32 id) const;
1442 uint32 GetCurrencyTrackedQuantity(uint32 id) const;
1443 uint32 GetCurrencyIncreasedCapQuantity(uint32 id) const;
1444 uint32 GetCurrencyMaxQuantity(CurrencyTypesEntry const* currency, bool onLoad = false, bool onUpdateVersion = false) const;
1445 uint32 GetCurrencyWeeklyCap(uint32 id) const;
1446 uint32 GetCurrencyWeeklyCap(CurrencyTypesEntry const* currency) const;
1447 bool HasCurrency(uint32 id, uint32 amount) const;
1448
1449 void SetInvSlot(uint32 slot, ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::InvSlots, slot), guid); }
1450
1451 void ApplyEquipCooldown(Item* pItem);
1452 void QuickEquipItem(uint16 pos, Item* pItem);
1453 void VisualizeItem(uint8 slot, Item* pItem);
1454 void SetVisibleItemSlot(uint8 slot, Item* pItem);
1455 Item* BankItem(ItemPosCountVec const& dest, Item* pItem, bool update);
1456 void RemoveItem(uint8 bag, uint8 slot, bool update);
1457 void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
1458 // in trade, auction, guild bank, mail....
1459 void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
1460 // in trade, guild bank, mail....
1461 void RemoveItemDependentAurasAndCasts(Item* pItem);
1462 void DestroyItem(uint8 bag, uint8 slot, bool update);
1463 uint32 DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check = false);
1464 void DestroyItemCount(Item* item, uint32& count, bool update);
1465 void DestroyConjuredItems(bool update);
1466 void DestroyZoneLimitedItem(bool update, uint32 new_zone);
1467 void SplitItem(uint16 src, uint16 dst, uint32 count);
1468 void SwapItem(uint16 src, uint16 dst);
1469 void AddItemToBuyBackSlot(Item* pItem);
1470 void SetBuybackPrice(uint32 slot, uint32 price) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BuybackPrice, slot), price); }
1471 void SetBuybackTimestamp(uint32 slot, time_t timestamp) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BuybackTimestamp, slot), timestamp); }
1472 Item* GetItemFromBuyBackSlot(uint32 slot);
1473 void RemoveItemFromBuyBackSlot(uint32 slot, bool del);
1474 void SendEquipError(InventoryResult msg, Item const* item1 = nullptr, Item const* item2 = nullptr, uint32 itemId = 0) const;
1475 void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param) const;
1476 void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid) const;
1477 void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
1478 void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
1479 uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
1480 uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
1481 bool IsUseEquipedWeapon(bool mainhand) const;
1482 bool IsTwoHandUsed() const;
1483 bool IsUsingTwoHandedWeaponInOneHand() const;
1484 void SendNewItem(Item* item, uint32 quantity, bool received, bool created, bool broadcast = false, uint32 dungeonEncounterId = 0);
1485 bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
1486 bool BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot, uint32 currency, uint32 count);
1487 bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int64 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore);
1488
1489 float GetReputationPriceDiscount(Creature const* creature) const;
1490 float GetReputationPriceDiscount(FactionTemplateEntry const* factionTemplate) const;
1491
1492 Player* GetTrader() const;
1493 TradeData* GetTradeData() const { return m_trade; }
1494 void TradeCancel(bool sendback);
1495
1496 CinematicMgr* GetCinematicMgr() const { return _cinematicMgr.get(); }
1497
1498 void UpdateEnchantTime(uint32 time);
1499 void UpdateSoulboundTradeItems();
1500 void AddTradeableItem(Item* item);
1501 void RemoveTradeableItem(Item* item);
1502 void UpdateItemDuration(uint32 time, bool realtimeonly = false);
1503 void AddEnchantmentDurations(Item* item);
1504 void RemoveEnchantmentDurations(Item* item);
1505 void RemoveEnchantmentDurationsReferences(Item* item);
1506 void RemoveArenaEnchantments(EnchantmentSlot slot);
1507 void AddEnchantmentDuration(Item* item, EnchantmentSlot slot, uint32 duration);
1508 void ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool apply_dur = true, bool ignore_condition = false);
1509 void ApplyEnchantment(Item* item, bool apply);
1510 void UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16 new_value);
1511 void SendEnchantmentDurations();
1512 void AddItemDurations(Item* item);
1513 void RemoveItemDurations(Item* item);
1514 void SendItemDurations();
1515 void LoadCorpse(PreparedQueryResult result);
1516
1517 bool AddItem(uint32 itemId, uint32 count);
1518
1519 /*********************************************************/
1520 /*** GOSSIP SYSTEM ***/
1521 /*********************************************************/
1522
1523 void PrepareGossipMenu(WorldObject* source, uint32 menuId, bool showQuests = false);
1524 void SendPreparedGossip(WorldObject* source);
1525 void OnGossipSelect(WorldObject* source, int32 gossipOptionId, uint32 menuId);
1526
1527 uint32 GetGossipTextId(uint32 menuId, WorldObject* source);
1528 uint32 GetGossipTextId(WorldObject* source);
1529 uint32 GetGossipMenuForSource(WorldObject* source);
1530
1531 /*********************************************************/
1532 /*** QUEST SYSTEM ***/
1533 /*********************************************************/
1534
1535 int32 GetQuestMinLevel(Quest const* quest) const;
1536 int32 GetQuestMinLevel(uint32 contentTuningId) const;
1537 int32 GetQuestLevel(Quest const* quest) const;
1538 int32 GetQuestLevel(uint32 contentTuningId) const;
1539 void PrepareQuestMenu(ObjectGuid guid);
1540 void SendPreparedQuest(WorldObject* source);
1541 bool IsActiveQuest(uint32 quest_id) const;
1542 Quest const* GetNextQuest(Object const* questGiver, Quest const* quest) const;
1543 bool CanSeeStartQuest(Quest const* quest) const;
1544 bool CanTakeQuest(Quest const* quest, bool msg) const;
1545 bool CanAddQuest(Quest const* quest, bool msg) const;
1546 bool CanCompleteQuest(uint32 quest_id, uint32 ignoredQuestObjectiveId = 0);
1547 bool CanCompleteRepeatableQuest(Quest const* quest);
1548 bool CanRewardQuest(Quest const* quest, bool msg) const;
1549 bool CanRewardQuest(Quest const* quest, LootItemType rewardType, uint32 rewardId, bool msg) const;
1550 void AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver);
1551 void AddQuest(Quest const* quest, Object* questGiver);
1552 void AbandonQuest(uint32 quest_id);
1553 void CompleteQuest(uint32 quest_id);
1554 void IncompleteQuest(uint32 quest_id);
1555 uint32 GetQuestMoneyReward(Quest const* quest) const;
1556 uint32 GetQuestXPReward(Quest const* quest);
1557 bool CanSelectQuestPackageItem(QuestPackageItemEntry const* questPackageItem) const;
1558 void RewardQuestPackage(uint32 questPackageId, ItemContext context, uint32 onlyItemId = 0);
1559 void RewardQuest(Quest const* quest, LootItemType rewardType, uint32 rewardId, Object* questGiver, bool announce = true);
1560 void SetRewardedQuest(uint32 quest_id);
1561 void FailQuest(uint32 quest_id);
1562 void FailQuestsWithFlag(QuestFlags flag);
1563 bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const;
1564 bool SatisfyQuestLevel(Quest const* qInfo, bool msg) const;
1565 bool SatisfyQuestMinLevel(Quest const* qInfo, bool msg) const;
1566 bool SatisfyQuestMaxLevel(Quest const* qInfo, bool msg) const;
1567 bool SatisfyQuestLog(bool msg) const;
1568 bool SatisfyQuestDependentQuests(Quest const* qInfo, bool msg) const;
1569 bool SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const;
1570 bool SatisfyQuestDependentPreviousQuests(Quest const* qInfo, bool msg) const;
1571 bool SatisfyQuestBreadcrumbQuest(Quest const* qInfo, bool msg) const;
1572 bool SatisfyQuestDependentBreadcrumbQuests(Quest const* qInfo, bool msg) const;
1573 bool SatisfyQuestClass(Quest const* qInfo, bool msg) const;
1574 bool SatisfyQuestRace(Quest const* qInfo, bool msg) const;
1575 bool SatisfyQuestReputation(Quest const* qInfo, bool msg) const;
1576 bool SatisfyQuestStatus(Quest const* qInfo, bool msg) const;
1577 bool SatisfyQuestConditions(Quest const* qInfo, bool msg) const;
1578 bool SatisfyQuestTimed(Quest const* qInfo, bool msg) const;
1579 bool SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const;
1580 bool SatisfyQuestDay(Quest const* qInfo, bool msg) const;
1581 bool SatisfyQuestWeek(Quest const* qInfo, bool msg) const;
1582 bool SatisfyQuestMonth(Quest const* qInfo, bool msg) const;
1583 bool SatisfyQuestSeasonal(Quest const* qInfo, bool msg) const;
1584 bool SatisfyQuestExpansion(Quest const* qInfo, bool msg) const;
1585 bool GiveQuestSourceItem(Quest const* quest);
1586 bool TakeQuestSourceItem(uint32 questId, bool msg);
1587 bool GetQuestRewardStatus(uint32 quest_id) const;
1588 QuestStatus GetQuestStatus(uint32 quest_id) const;
1589 void SetQuestStatus(uint32 questId, QuestStatus status, bool update = true);
1590 void RemoveActiveQuest(uint32 questId, bool update = true);
1591 void RemoveRewardedQuest(uint32 questId, bool update = true);
1592 void SendQuestUpdate(uint32 questId);
1593 QuestGiverStatus GetQuestDialogStatus(Object const* questGiver) const;
1594
1595 void SetDailyQuestStatus(uint32 quest_id);
1596 bool IsDailyQuestDone(uint32 quest_id) const;
1597 void SetWeeklyQuestStatus(uint32 quest_id);
1598 void SetMonthlyQuestStatus(uint32 quest_id);
1599 void SetSeasonalQuestStatus(uint32 quest_id);
1600 void DailyReset();
1601 void ResetWeeklyQuestStatus();
1602 void ResetMonthlyQuestStatus();
1603 void ResetSeasonalQuestStatus(uint16 event_id, time_t eventStartTime);
1604
1605 uint16 FindQuestSlot(uint32 quest_id) const;
1606 uint32 GetQuestSlotQuestId(uint16 slot) const;
1607 uint32 GetQuestSlotState(uint16 slot) const;
1608 uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const;
1609 int64 GetQuestSlotEndTime(uint16 slot) const;
1610 bool GetQuestSlotObjectiveFlag(uint16 slot, int8 objectiveIndex) const;
1611 int32 GetQuestSlotObjectiveData(uint16 slot, QuestObjective const& objective) const;
1612 void SetQuestSlot(uint16 slot, uint32 quest_id);
1613 void SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count);
1614 void SetQuestSlotState(uint16 slot, uint32 state);
1615 void RemoveQuestSlotState(uint16 slot, uint32 state);
1616 void SetQuestSlotEndTime(uint16 slot, time_t endTime);
1617 void SetQuestSlotObjectiveFlag(uint16 slot, int8 objectiveIndex);
1618 void RemoveQuestSlotObjectiveFlag(uint16 slot, int8 objectiveIndex);
1619 void SetQuestCompletedBit(uint32 questBit, bool completed);
1620
1621 uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) const;
1622 void AreaExploredOrEventHappens(uint32 questId);
1623 void GroupEventHappens(uint32 questId, WorldObject const* pEventObject);
1624 void ItemAddedQuestCheck(uint32 entry, uint32 count);
1625 void ItemRemovedQuestCheck(uint32 entry, uint32 count);
1626 void KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid);
1627 void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid::Empty);
1628 void KilledPlayerCredit(ObjectGuid victimGuid);
1629 void KillCreditGO(uint32 entry, ObjectGuid guid = ObjectGuid::Empty);
1630 void TalkedToCreature(uint32 entry, ObjectGuid guid);
1631 void KillCreditCriteriaTreeObjective(QuestObjective const& questObjective);
1632 void MoneyChanged(uint64 value);
1633 void ReputationChanged(FactionEntry const* factionEntry, int32 change);
1634 void CurrencyChanged(uint32 currencyId, int32 change);
1635 void UpdateQuestObjectiveProgress(QuestObjectiveType objectiveType, int32 objectId, int64 addCount, ObjectGuid victimGuid = ObjectGuid::Empty);
1636 bool HasQuestForItem(uint32 itemId) const;
1637 bool HasQuestForGO(int32 goId) const;
1638 void UpdateVisibleGameobjectsOrSpellClicks();
1639 bool CanShareQuest(uint32 questId) const;
1640
1641 int32 GetQuestObjectiveData(QuestObjective const& objective) const;
1642 void SetQuestObjectiveData(QuestObjective const& objective, int32 data);
1643 bool IsQuestObjectiveCompletable(uint16 slot, Quest const* quest, QuestObjective const& objective) const;
1644 bool IsQuestObjectiveComplete(uint16 slot, Quest const* quest, QuestObjective const& objective) const;
1645 bool IsQuestObjectiveProgressBarComplete(uint16 slot, Quest const* quest) const;
1646 void SendQuestComplete(uint32 questId) const;
1647 void SendQuestReward(Quest const* quest, Creature const* questGiver, uint32 xp, bool hideChatMessage) const;
1648 void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK) const;
1649 void SendQuestTimerFailed(uint32 questId) const;
1650 void SendCanTakeQuestResponse(QuestFailedReason reason, bool sendErrorMessage = true, std::string reasonText = "") const;
1651 void SendQuestConfirmAccept(Quest const* quest, Player* receiver) const;
1652 void SendPushToPartyResponse(Player const* player, QuestPushReason reason, Quest const* quest = nullptr) const;
1653 void SendQuestUpdateAddCredit(Quest const* quest, ObjectGuid guid, QuestObjective const& obj, uint16 count) const;
1654 void SendQuestUpdateAddCreditSimple(QuestObjective const& obj) const;
1655 void SendQuestUpdateAddPlayer(Quest const* quest, uint16 newCount) const;
1656 void SendQuestGiverStatusMultiple();
1657 void SendQuestGiverStatusMultiple(GuidUnorderedSet const& guids);
1658 void SendDisplayToast(uint32 entry, DisplayToastType type, bool isBonusRoll, uint32 quantity, DisplayToastMethod method, uint32 questId = 0, Item* item = nullptr) const;
1659
1660 uint32 GetSharedQuestID() const { return m_sharedQuestId; }
1661 ObjectGuid GetPlayerSharingQuest() const { return m_playerSharingQuest; }
1662 void SetQuestSharingInfo(ObjectGuid guid, uint32 id) { m_playerSharingQuest = guid; m_sharedQuestId = id; }
1663 void ClearQuestSharingInfo() { m_playerSharingQuest = ObjectGuid::Empty; m_sharedQuestId = 0; }
1664
1665 uint32 GetInGameTime() const { return m_ingametime; }
1666 void SetInGameTime(uint32 time) { m_ingametime = time; }
1667
1668 void AddTimedQuest(uint32 questId) { m_timedquests.insert(questId); }
1669 void RemoveTimedQuest(uint32 questId) { m_timedquests.erase(questId); }
1670
1671 void SaveCUFProfile(uint8 id, std::nullptr_t) { _CUFProfiles[id] = nullptr; }
1672 void SaveCUFProfile(uint8 id, std::unique_ptr<CUFProfile> profile) { _CUFProfiles[id] = std::move(profile); }
1673 CUFProfile* GetCUFProfile(uint8 id) const { return _CUFProfiles[id].get(); }
1675 {
1676 uint8 count = 0;
1677 for (uint8 i = 0; i < MAX_CUF_PROFILES; ++i)
1678 if (_CUFProfiles[i])
1679 ++count;
1680 return count;
1681 }
1682
1683 bool HasPvPForcingQuest() const;
1684
1685 /*********************************************************/
1686 /*** LOAD SYSTEM ***/
1687 /*********************************************************/
1688
1689 bool LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& holder);
1690 bool IsLoading() const override;
1691
1692 static uint32 GetZoneIdFromDB(ObjectGuid guid);
1693 static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid);
1694
1695 static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; }
1696 static bool IsValidClass(uint8 Class) { return ((1 << (Class - 1)) & CLASSMASK_ALL_PLAYABLE) != 0; }
1698
1699 /*********************************************************/
1700 /*** SAVE SYSTEM ***/
1701 /*********************************************************/
1702
1703 void SaveToDB(bool create = false);
1704 void SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDatabaseTransaction trans, bool create = false);
1705 void SaveInventoryAndGoldToDB(CharacterDatabaseTransaction trans); // fast save function for item/money cheating preventing
1706 void SaveGoldToDB(CharacterDatabaseTransaction trans) const;
1707
1708 static void SaveCustomizations(CharacterDatabaseTransaction trans, ObjectGuid::LowType guid,
1710 static void SavePositionInDB(WorldLocation const& loc, uint16 zoneId, ObjectGuid guid, CharacterDatabaseTransaction trans);
1711
1712 static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false);
1713 static void DeleteOldCharacters();
1714 static void DeleteOldCharacters(uint32 keepDays);
1715
1717
1718 void SetBindPoint(ObjectGuid guid) const;
1719 void SendRespecWipeConfirm(ObjectGuid const& guid, uint32 cost, SpecResetType respecType) const;
1720 void RegenerateAll();
1721 void Regenerate(Powers power);
1722 void InterruptPowerRegen(Powers power);
1723 void RegenerateHealth();
1724 void setRegenTimerCount(uint32 time) {m_regenTimerCount = time;}
1725 void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
1726
1727 uint64 GetMoney() const { return m_activePlayerData->Coinage; }
1728 bool ModifyMoney(int64 amount, bool sendError = true);
1729 bool HasEnoughMoney(uint64 amount) const { return (GetMoney() >= amount); }
1730 bool HasEnoughMoney(int64 amount) const{ return (amount < 0) || HasEnoughMoney(uint64(amount)); }
1731 void SetMoney(uint64 value);
1732
1733 RewardedQuestSet const& getRewardedQuests() const { return m_RewardedQuests; }
1734 QuestStatusMap& getQuestStatusMap() { return m_QuestStatus; }
1735
1736 size_t GetRewardedQuestCount() const { return m_RewardedQuests.size(); }
1737 bool IsQuestRewarded(uint32 quest_id) const;
1738
1739 Unit* GetSelectedUnit() const;
1740 Player* GetSelectedPlayer() const;
1741
1742 void SetTarget(ObjectGuid const& /*guid*/) override { }
1743 void SetSelection(ObjectGuid const& guid) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Target), guid); }
1744
1745 void SendMailResult(uint64 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType itemGuid = UI64LIT(0), uint32 itemCount = 0) const;
1746 void SendNewMail() const;
1747 void UpdateNextMailTimeAndUnreads();
1748 void AddNewMailDeliverTime(time_t deliver_time);
1749
1750 void RemoveMail(uint64 id);
1751
1752 void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
1753 uint32 GetMailSize() const { return uint32(m_mail.size()); }
1754 Mail* GetMail(uint64 id);
1755
1756 PlayerMails const& GetMails() const { return m_mail; }
1757
1758 void SendItemRetrievalMail(uint32 itemEntry, uint32 count, ItemContext context); // Item retrieval mails sent by The Postmaster (34337), used in multiple places.
1759
1760 /*********************************************************/
1761 /*** MAILED ITEMS SYSTEM ***/
1762 /*********************************************************/
1763
1766
1767 typedef std::unordered_map<ObjectGuid::LowType, Item*> ItemMap;
1768
1769 ItemMap mMitems; //template defined in objectmgr.cpp
1770
1771 Item* GetMItem(ObjectGuid::LowType id);
1772 void AddMItem(Item* it);
1773 bool RemoveMItem(ObjectGuid::LowType id);
1774
1775 void SendOnCancelExpectedVehicleRideAura() const;
1776 void PetSpellInitialize();
1777 void CharmSpellInitialize();
1778 void PossessSpellInitialize();
1779 void VehicleSpellInitialize();
1780 void SendRemoveControlBar() const;
1781 bool HasSpell(uint32 spell) const override;
1782 bool HasActiveSpell(uint32 spell) const; // show in spellbook
1783 SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const override;
1784 bool IsSpellFitByClassAndRace(uint32 spell_id) const;
1785 bool HandlePassiveSpellLearn(SpellInfo const* spellInfo);
1786
1787 void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const;
1788 void SendKnownSpells();
1789 void SendUnlearnSpells();
1790 bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, int32 fromSkill = 0, bool favorite = false, Optional<int32> traitDefinitionId = {});
1791 void LearnSpell(uint32 spell_id, bool dependent, int32 fromSkill = 0, bool suppressMessaging = false, Optional<int32> traitDefinitionId = {});
1792 void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true, bool suppressMessaging = false);
1793 void ResetSpells(bool myClassOnly = false);
1794 void LearnCustomSpells();
1795 void LearnDefaultSkills();
1796 void LearnDefaultSkill(SkillRaceClassInfoEntry const* rcInfo);
1797 void LearnQuestRewardedSpells();
1798 void LearnQuestRewardedSpells(Quest const* quest);
1799 void AddTemporarySpell(uint32 spellId);
1800 void RemoveTemporarySpell(uint32 spellId);
1801 void SetOverrideSpellsId(int32 overrideSpellsId) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::OverrideSpellsID), overrideSpellsId); }
1802 void AddOverrideSpell(uint32 overridenSpellId, uint32 newSpellId);
1803 void RemoveOverrideSpell(uint32 overridenSpellId, uint32 newSpellId);
1804 void LearnSpecializationSpells();
1805 void RemoveSpecializationSpells();
1806 void AddSpellCategoryCooldownMod(int32 spellCategoryId, int32 mod);
1807 void RemoveSpellCategoryCooldownMod(int32 spellCategoryId, int32 mod);
1808 void SetSpellFavorite(uint32 spellId, bool favorite);
1809
1810 void AddStoredAuraTeleportLocation(uint32 spellId);
1811 void RemoveStoredAuraTeleportLocation(uint32 spellId);
1812 WorldLocation const* GetStoredAuraTeleportLocation(uint32 spellId) const;
1813
1814 void SetReputation(uint32 factionentry, int32 value);
1815 int32 GetReputation(uint32 factionentry) const;
1816 std::string GetGuildName() const;
1817
1818 // Loot Spec
1819 void SetLootSpecId(uint32 id) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::LootSpecID), id); }
1820 uint32 GetLootSpecId() const { return m_activePlayerData->LootSpecID; }
1821
1822 ZonePVPTypeOverride GetOverrideZonePVPType() const { return ZonePVPTypeOverride(*m_activePlayerData->OverrideZonePVPType); }
1823 void SetOverrideZonePVPType(ZonePVPTypeOverride type) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::OverrideZonePVPType), uint32(type)); }
1824
1825 // Talents
1826 uint32 GetTalentResetCost() const { return _specializationInfo.ResetTalentsCost; }
1827 void SetTalentResetCost(uint32 cost) { _specializationInfo.ResetTalentsCost = cost; }
1828 time_t GetTalentResetTime() const { return _specializationInfo.ResetTalentsTime; }
1829 void SetTalentResetTime(time_t time_) { _specializationInfo.ResetTalentsTime = time_; }
1830 ChrSpecialization GetPrimarySpecialization() const { return ChrSpecialization(*m_playerData->CurrentSpecID); }
1831 void SetPrimarySpecialization(uint32 spec) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::CurrentSpecID), spec); }
1832 uint8 GetActiveTalentGroup() const { return _specializationInfo.ActiveGroup; }
1833 void SetActiveTalentGroup(uint8 group){ _specializationInfo.ActiveGroup = group; }
1834 uint32 GetDefaultSpecId() const;
1835 ChrSpecializationEntry const* GetPrimarySpecializationEntry() const;
1836
1837 bool ResetTalents(bool noCost = false);
1838 void ResetPvpTalents();
1839 uint32 GetNextResetTalentsCost() const;
1840 void InitTalentForLevel();
1841 void SendTalentsInfoData();
1842 TalentLearnResult LearnTalent(uint32 talentId, int32* spellOnCooldown);
1843 bool AddTalent(TalentEntry const* talent, uint8 spec, bool learning);
1844 bool HasTalent(uint32 spell_id, uint8 spec) const;
1845 void RemoveTalent(TalentEntry const* talent);
1846 void ResetTalentSpecialization();
1847
1848 TalentLearnResult LearnPvpTalent(uint32 talentID, uint8 slot, int32* spellOnCooldown);
1849 bool AddPvpTalent(PvpTalentEntry const* talent, uint8 activeTalentGroup, uint8 slot);
1850 void RemovePvpTalent(PvpTalentEntry const* talent, uint8 activeTalentGroup);
1851 void TogglePvpTalents(bool enable);
1852 bool HasPvpTalent(uint32 talentID, uint8 activeTalentGroup) const;
1853 void EnablePvpRules(bool dueToCombat = false);
1854 void DisablePvpRules();
1855 bool HasPvpRulesEnabled() const;
1856 bool IsInAreaThatActivatesPvpTalents() const;
1857 bool IsAreaThatActivatesPvpTalents(uint32 areaID) const;
1858
1859 // Dual Spec
1860 void ActivateTalentGroup(ChrSpecializationEntry const* spec);
1861
1862 PlayerTalentMap const* GetTalentMap(uint8 spec) const { return &_specializationInfo.Talents[spec]; }
1863 PlayerTalentMap* GetTalentMap(uint8 spec) { return &_specializationInfo.Talents[spec]; }
1864 PlayerPvpTalentMap const& GetPvpTalentMap(uint8 spec) const { return _specializationInfo.PvpTalents[spec]; }
1865 PlayerPvpTalentMap& GetPvpTalentMap(uint8 spec) { return _specializationInfo.PvpTalents[spec]; }
1866 std::vector<uint32> const& GetGlyphs(uint8 spec) const { return _specializationInfo.Glyphs[spec]; }
1867 std::vector<uint32>& GetGlyphs(uint8 spec) { return _specializationInfo.Glyphs[spec]; }
1868 ActionButtonList const& GetActionButtons() const { return m_actionButtons; }
1869 void StartLoadingActionButtons(std::function<void()>&& callback = nullptr);
1870 void LoadActions(PreparedQueryResult result);
1871
1872 // Traits
1873 void CreateTraitConfig(WorldPackets::Traits::TraitConfig& traitConfig);
1874 void AddTraitConfig(WorldPackets::Traits::TraitConfig const& traitConfig);
1875 UF::TraitConfig const* GetTraitConfig(int32 configId) const;
1876 void UpdateTraitConfig(WorldPackets::Traits::TraitConfig&& newConfig, int32 savedConfigId, bool withCastTime);
1877 void ApplyTraitEntryChanges(int32 editedConfigId, WorldPackets::Traits::TraitConfig const& newConfig, bool applyTraits, bool consumeCurrencies);
1878 void RenameTraitConfig(int32 editedConfigId, std::string&& newName);
1879 void DeleteTraitConfig(int32 deletedConfigId);
1880 void ApplyTraitConfig(int32 configId, bool apply);
1881 void ApplyTraitEntry(int32 traitNodeEntryId, int32 rank, int32 grantedRanks, bool apply);
1882 void SetActiveCombatTraitConfigID(int32 traitConfigId) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ActiveCombatTraitConfigID), traitConfigId); }
1883 void SetTraitConfigUseStarterBuild(int32 traitConfigId, bool useStarterBuild);
1884 void SetTraitConfigUseSharedActionBars(int32 traitConfigId, bool usesSharedActionBars, bool isLastSelectedSavedConfig);
1885
1886 uint32 GetFreePrimaryProfessionPoints() const { return m_activePlayerData->CharacterPoints; }
1887 void SetFreePrimaryProfessions(uint16 profs) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::CharacterPoints), profs); }
1888 void InitPrimaryProfessions();
1889
1890 PlayerSpellMap const& GetSpellMap() const { return m_spells; }
1891 PlayerSpellMap & GetSpellMap() { return m_spells; }
1892
1893 void AddSpellMod(SpellModifier* mod, bool apply);
1894 static bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier const* mod, Spell* spell = nullptr);
1895 template <class T>
1896 void GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* spell, T base, int32* flat, float* pct) const;
1897 template <class T>
1898 void ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, T& basevalue, Spell* spell = nullptr) const;
1899 static void ApplyModToSpell(SpellModifier* mod, Spell* spell);
1900 void SetSpellModTakingSpell(Spell* spell, bool apply);
1901 void SendSpellModifiers() const;
1902
1903 void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false);
1904 uint32 GetLastPotionId() const { return m_lastPotionId; }
1905 void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
1906 void UpdatePotionCooldown(Spell* spell = nullptr);
1907
1908 void SetResurrectRequestData(WorldObject const* caster, uint32 health, uint32 mana, uint32 appliedAura);
1910 {
1911 _resurrectionData.reset();
1912 }
1913
1914 bool IsResurrectRequestedBy(ObjectGuid const& guid) const
1915 {
1916 if (!IsResurrectRequested())
1917 return false;
1918
1919 return !_resurrectionData->GUID.IsEmpty() && _resurrectionData->GUID == guid;
1920 }
1921
1922 bool IsResurrectRequested() const { return _resurrectionData.get() != nullptr; }
1923 void ResurrectUsingRequestData();
1924 void ResurrectUsingRequestDataImpl();
1925
1926 PlayerCreateMode GetCreateMode() const { return m_createMode; }
1927
1928 uint8 getCinematic() const { return m_cinematic; }
1929 void setCinematic(uint8 cine) { m_cinematic = cine; }
1930
1931 uint32 GetMovie() const { return m_movie; }
1932 void SetMovie(uint32 movie) { m_movie = movie; }
1933
1934 ActionButton* AddActionButton(uint8 button, uint64 action, uint8 type);
1935 void RemoveActionButton(uint8 button);
1936 ActionButton const* GetActionButton(uint8 button);
1937 void SendInitialActionButtons() const { SendActionButtons(0); }
1938 void SendActionButtons(uint32 state) const;
1939 bool IsActionButtonDataValid(uint8 button, uint64 action, uint8 type) const;
1940 void SetMultiActionBars(uint8 mask) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::MultiActionBars), mask); }
1941
1943 void InitPvP();
1944 void UpdatePvPState(bool onlyFFA = false);
1945 void SetPvP(bool state) override;
1946 void UpdatePvP(bool state, bool override = false);
1947 void UpdateZone(uint32 newZone, uint32 newArea);
1948 void UpdateArea(uint32 newArea);
1949 void UpdateHostileAreaState(AreaTableEntry const* area);
1950 void UpdateZoneDependentAuras(uint32 zone_id); // zones
1951 void UpdateAreaDependentAuras(uint32 area_id); // subzones
1952
1953 void UpdateAfkReport(time_t currTime);
1954 void UpdatePvPFlag(time_t currTime);
1955 void SetContestedPvP(Player* attackedPlayer = nullptr);
1956 void UpdateContestedPvP(uint32 currTime);
1957 void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
1958 void ResetContestedPvP();
1959
1961 std::unique_ptr<DuelInfo> duel;
1962 void UpdateDuelFlag(time_t currTime);
1963 void CheckDuelDistance(time_t currTime);
1964 void DuelComplete(DuelCompleteType type);
1965 void SetDuelArbiter(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::DuelArbiter), guid); }
1966 void SetDuelTeam(uint32 duelTeam) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::DuelTeam), duelTeam); }
1967
1968 bool IsGroupVisibleFor(Player const* p) const;
1969 bool IsInSameGroupWith(Player const* p) const;
1970 bool IsInSameRaidWith(Player const* p) const;
1971 void UninviteFromGroup();
1972 static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, char const* reason = nullptr);
1973 void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); }
1974 void SendUpdateToOutOfRangeGroupMembers();
1975
1976 void SetInGuild(ObjectGuid::LowType guildId);
1977 void SetGuildRank(uint8 rankId) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::GuildRankID), rankId); }
1978 uint8 GetGuildRank() const { return uint8(m_playerData->GuildRankID); }
1979 void SetGuildLevel(uint32 level) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::GuildLevel), level); }
1980 uint32 GetGuildLevel() const { return m_playerData->GuildLevel; }
1981 void SetGuildIdInvited(ObjectGuid::LowType GuildId) { m_GuildIdInvited = GuildId; }
1982 ObjectGuid::LowType GetGuildId() const { return m_unitData->GuildGUID->GetCounter(); /* return only lower part */ }
1983 Guild* GetGuild();
1984 Guild const* GetGuild() const;
1985 ObjectGuid::LowType GetGuildIdInvited() const { return m_GuildIdInvited; }
1986 static void RemovePetitionsAndSigns(ObjectGuid guid);
1987
1988 // Arena Team
1989 void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type);
1990 void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value);
1991 static void LeaveAllArenaTeams(ObjectGuid guid);
1992 uint32 GetArenaTeamId(uint8 /*slot*/) const { return 0; }
1993 uint32 GetArenaPersonalRating(uint8 slot) const;
1994 void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
1995 uint32 GetArenaTeamIdInvited() const { return m_ArenaTeamIdInvited; }
1996 uint32 GetRBGPersonalRating() const { return GetArenaPersonalRating(3); }
1997 UF::PVPInfo const* GetPvpInfoForBracket(int8 bracket) const;
1998
1999 Difficulty GetDifficultyID(MapEntry const* mapEntry) const;
2000 Difficulty GetDungeonDifficultyID() const { return m_dungeonDifficulty; }
2001 Difficulty GetRaidDifficultyID() const { return m_raidDifficulty; }
2002 Difficulty GetLegacyRaidDifficultyID() const { return m_legacyRaidDifficulty; }
2003 void SetDungeonDifficultyID(Difficulty dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; }
2004 void SetRaidDifficultyID(Difficulty raid_difficulty) { m_raidDifficulty = raid_difficulty; }
2005 void SetLegacyRaidDifficultyID(Difficulty raid_difficulty) { m_legacyRaidDifficulty = raid_difficulty; }
2006 static Difficulty CheckLoadedDungeonDifficultyID(Difficulty difficulty);
2007 static Difficulty CheckLoadedRaidDifficultyID(Difficulty difficulty);
2008 static Difficulty CheckLoadedLegacyRaidDifficultyID(Difficulty difficulty);
2009 void SendRaidGroupOnlyMessage(RaidGroupReason reason, int32 delay) const;
2010
2011 bool UpdateSkillPro(uint16 skillId, int32 chance, uint32 step);
2012 bool UpdateCraftSkill(SpellInfo const* spellInfo);
2013 bool UpdateGatherSkill(uint32 skillId, uint32 skillValue, uint32 redLevel, uint32 multiplicator = 1, WorldObject const* object = nullptr);
2014 bool UpdateFishingSkill(int32 expansion);
2015
2016 float GetHealthBonusFromStamina() const;
2017 Stats GetPrimaryStat() const;
2018
2019 bool UpdateStats(Stats stat) override;
2020 bool UpdateAllStats() override;
2021 void ApplySpellPenetrationBonus(int32 amount, bool apply);
2022 void ApplyModTargetResistance(int32 mod, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ModTargetResistance), mod, apply); }
2023 void ApplyModTargetPhysicalResistance(int32 mod, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ModTargetPhysicalResistance), mod, apply); }
2024 void UpdateResistances(uint32 school) override;
2025 void UpdateArmor() override;
2026 void UpdateMaxHealth() override;
2027 void UpdateMaxPower(Powers power) override;
2028 uint32 GetPowerIndex(Powers power) const override;
2029 void UpdateAttackPowerAndDamage(bool ranged = false) override;
2030 void ApplySpellPowerBonus(int32 amount, bool apply);
2031 void UpdateSpellDamageAndHealingBonus();
2032 void ApplyModDamageDonePos(SpellSchools school, int32 mod, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ModDamageDonePos, school), mod, apply); }
2033 void ApplyModDamageDoneNeg(SpellSchools school, int32 mod, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ModDamageDoneNeg, school), mod, apply); }
2034 void ApplyModDamageDonePercent(SpellSchools school, float pct, bool apply) { ApplyPercentModUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ModDamageDonePercent, school), pct, apply); }
2035 void SetModDamageDonePercent(uint8 school, float pct) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ModDamageDonePercent, school), pct); }
2036 void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
2037 void UpdateRating(CombatRating cr);
2038 void UpdateAllRatings();
2039 void UpdateMastery();
2040 void UpdateVersatilityDamageDone();
2041 void UpdateHealingDonePercentMod();
2042 bool CanUseMastery() const;
2043
2044 void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) const override;
2045
2046 void RecalculateRating(CombatRating cr) { ApplyRatingMod(cr, 0, true);}
2047 void GetDodgeFromAgility(float &diminishing, float &nondiminishing) const;
2048 float GetRatingMultiplier(CombatRating cr) const;
2049 float GetRatingBonusValue(CombatRating cr) const;
2050 float ApplyRatingDiminishing(CombatRating cr, float bonusValue) const;
2051
2053 uint32 GetBaseSpellPowerBonus() const { return m_baseSpellPower; }
2054 int32 GetSpellPenetrationItemMod() const { return m_spellPenetrationItemMod; }
2055
2056 bool CanApplyResilience() const override { return true; }
2057
2058 float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
2059 void UpdateBlockPercentage();
2060 void UpdateCritPercentage(WeaponAttackType attType);
2061 void UpdateAllCritPercentages();
2062 void UpdateParryPercentage();
2063 void UpdateDodgePercentage();
2064 void UpdateMeleeHitChances();
2065 void UpdateRangedHitChances();
2066 void UpdateSpellHitChances();
2067
2068 void UpdateSpellCritChance();
2069 void UpdateCorruption();
2070 void UpdateArmorPenetration(int32 amount);
2071 void UpdateExpertise(WeaponAttackType attType);
2072 void ApplyManaRegenBonus(int32 amount, bool apply);
2073 void ApplyHealthRegenBonus(int32 amount, bool apply);
2074 void UpdateManaRegen();
2075 void UpdateAllRunesRegen();
2076
2077 void SetPetSpellPower(uint32 spellPower) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::PetSpellPower), spellPower); }
2078
2079 ObjectGuid const& GetLootGUID() const { return m_playerData->LootTargetGUID; }
2080 void SetLootGUID(ObjectGuid const& guid) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::LootTargetGUID), guid); }
2081 Loot* GetLootByWorldObjectGUID(ObjectGuid const& lootWorldObjectGuid) const;
2082 std::unordered_map<ObjectGuid, Loot*> const& GetAELootView() const { return m_AELootView; }
2083 LootRoll* GetLootRoll(ObjectGuid const& lootObjectGuid, uint8 lootListId);
2084 void AddLootRoll(LootRoll* roll) { m_lootRolls.push_back(roll); }
2085 void RemoveLootRoll(LootRoll* roll);
2086
2087 void RemovedInsignia(Player* looterPlr);
2088
2089 WorldSession* GetSession() const { return m_session; }
2090
2091 protected:
2092 UF::UpdateFieldFlag GetUpdateFieldFlagsFor(Player const* target) const override;
2093 void BuildValuesCreate(ByteBuffer* data, Player const* target) const override;
2094 void BuildValuesUpdate(ByteBuffer* data, Player const* target) const override;
2095 void ClearUpdateMask(bool remove) override;
2096
2097 public:
2098 void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override;
2099 void BuildValuesUpdateWithFlag(ByteBuffer* data, UF::UpdateFieldFlag flags, Player const* target) const override;
2100 void BuildValuesUpdateForPlayerWithMask(UpdateData* data, UF::ObjectData::Mask const& requestedObjectMask, UF::UnitData::Mask const& requestedUnitMask,
2101 UF::PlayerData::Mask const& requestedPlayerMask, UF::ActivePlayerData::Mask const& requestedActivePlayerMask, Player const* target) const;
2102
2103 struct ValuesUpdateForPlayerWithMaskSender // sender compatible with MessageDistDeliverer
2104 {
2105 explicit ValuesUpdateForPlayerWithMaskSender(Player const* owner) : Owner(owner) { }
2106
2112
2113 void operator()(Player const* player) const;
2114 };
2115
2116 void DestroyForPlayer(Player* target) const override;
2117
2118 // notifiers
2119 void SendAttackSwingCantAttack() const;
2120 void SendAttackSwingCancelAttack() const;
2121 void SendAttackSwingDeadTarget() const;
2122 void SendAttackSwingNotInRange() const;
2123 void SendAttackSwingBadFacingAttack() const;
2124 void SendAutoRepeatCancel(Unit* target);
2125 void SendExplorationExperience(uint32 Area, uint32 Experience) const;
2126
2127 void SendDungeonDifficulty(int32 forcedDifficulty = -1) const;
2128 void SendRaidDifficulty(bool legacy, int32 forcedDifficulty = -1) const;
2129 void ResetInstances(InstanceResetMethod method);
2130 void SendResetInstanceSuccess(uint32 MapId) const;
2131 void SendResetInstanceFailed(ResetFailedReason reason, uint32 mapID) const;
2132 void SendResetFailedNotify(uint32 mapid) const;
2133 bool IsLockedToDungeonEncounter(uint32 dungeonEncounterId) const;
2134 bool IsLockedToDungeonEncounter(uint32 dungeonEncounterId, Difficulty difficulty) const;
2135
2136 bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override;
2137 bool UpdatePosition(Position const& pos, bool teleport = false) override { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
2138 void ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<LiquidData> const& newLiquidData) override;
2139 void AtEnterCombat() override;
2140 void AtExitCombat() override;
2141
2142 void SendMessageToSet(WorldPacket const* data, bool self) const override { SendMessageToSetInRange(data, GetVisibilityRange(), self); }
2143 void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self) const override;
2144 void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool own_team_only, bool required3dDist = false) const;
2145 void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const override;
2146
2147 void SendChatMessageToSetInRange(ChatMsg chatMsg, Language lanugageId, std::string&& text, float range);
2148
2149 Corpse* GetCorpse() const;
2150 void SpawnCorpseBones(bool triggerSave = true);
2151 Corpse* CreateCorpse();
2152 void KillPlayer();
2153 static void OfflineResurrect(ObjectGuid const& guid, CharacterDatabaseTransaction trans);
2154 bool HasCorpse() const { return _corpseLocation.GetMapId() != MAPID_INVALID; }
2155 WorldLocation GetCorpseLocation() const { return _corpseLocation; }
2156 void InitializeSelfResurrectionSpells();
2157 void ResurrectPlayer(float restore_percent, bool applySickness = false);
2158 void BuildPlayerRepop();
2159 void RepopAtGraveyard();
2160
2161 void DurabilityLossAll(double percent, bool inventory);
2162 void DurabilityLoss(Item* item, double percent);
2163 void DurabilityPointsLossAll(int32 points, bool inventory);
2164 void DurabilityPointsLoss(Item* item, int32 points);
2165 void DurabilityPointLossForEquipSlot(EquipmentSlots slot);
2166 void DurabilityRepairAll(bool takeCost, float discountMod, bool guildBank);
2167 void DurabilityRepair(uint16 pos, bool takeCost, float discountMod);
2168
2169 void UpdateMirrorTimers();
2170 void StopMirrorTimers();
2171 bool IsMirrorTimerActive(MirrorTimerType type) const;
2172
2173 bool CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, AreaTableEntry const* zone) const;
2174
2175 void JoinedChannel(Channel* c);
2176 void LeftChannel(Channel* c);
2177 void CleanupChannels();
2178 void UpdateLocalChannels(uint32 newZone);
2179 void LeaveLFGChannel();
2180
2181 typedef std::list<Channel*> JoinedChannelsList;
2182 JoinedChannelsList const& GetJoinedChannels() const { return m_channels; }
2183
2184 void InitializeSkillFields();
2185 void SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal);
2186 uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
2187 uint16 GetPureMaxSkillValue(uint32 skill) const; // max
2188 uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
2189 uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus
2190 uint16 GetPureSkillValue(uint32 skill) const; // skill value
2191 int16 GetSkillPermBonusValue(uint32 skill) const;
2192 int16 GetSkillTempBonusValue(uint32 skill) const;
2193 uint16 GetSkillStep(uint32 skill) const; // 0...6
2194 uint32 GetProfessionSkillForExp(uint32 skill, int32 expansion) const;
2195 bool HasSkill(uint32 skill) const;
2196 void LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue, Races race);
2197 int32 GetProfessionSlotFor(uint32 skillId) const;
2198 int32 FindEmptyProfessionSlotFor(uint32 skillId) const;
2199 void SetSkillLineId(uint32 pos, uint16 skillLineId) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillLineID, pos), skillLineId); }
2200 void SetSkillStep(uint32 pos, uint16 step) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillStep, pos), step); };
2201 void SetSkillRank(uint32 pos, uint16 rank) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillRank, pos), rank); }
2202 void SetSkillStartingRank(uint32 pos, uint16 starting) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillStartingRank, pos), starting); }
2203 void SetSkillMaxRank(uint32 pos, uint16 max) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillMaxRank, pos), max); }
2204 void SetSkillTempBonus(uint32 pos, uint16 bonus) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillTempBonus, pos), bonus); }
2205 void SetSkillPermBonus(uint32 pos, uint16 bonus) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillPermBonus, pos), bonus); }
2206
2207 WorldLocation& GetTeleportDest() { return m_teleport_dest; }
2208 Optional<uint32> GetTeleportDestInstanceId() const { return m_teleport_instanceId; }
2209 uint32 GetTeleportOptions() const { return m_teleport_options; }
2210 bool IsBeingTeleported() const { return IsBeingTeleportedNear() || IsBeingTeleportedFar(); }
2211 bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near; }
2212 bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far; }
2213 bool IsBeingTeleportedSeamlessly() const { return IsBeingTeleportedFar() && m_teleport_options & TELE_TO_SEAMLESS; }
2214 void SetSemaphoreTeleportNear(bool semphsetting) { mSemaphoreTeleport_Near = semphsetting; }
2215 void SetSemaphoreTeleportFar(bool semphsetting) { mSemaphoreTeleport_Far = semphsetting; }
2216 void ProcessDelayedOperations();
2217
2218 void CheckAreaExploreAndOutdoor(void);
2219 void AddExploredZones(uint32 pos, uint64 mask) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ExploredZones, pos), mask); }
2220 void RemoveExploredZones(uint32 pos, uint64 mask) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ExploredZones, pos), mask); }
2221
2222 static uint32 TeamForRace(uint8 race);
2223 static TeamId TeamIdForRace(uint8 race);
2224 static uint8 GetFactionGroupForRace(uint8 race);
2225 uint32 GetTeam() const { return m_team; }
2226 TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
2227 void SetFactionForRace(uint8 race);
2228
2229 Team GetEffectiveTeam() const { return HasPlayerFlagEx(PLAYER_FLAGS_EX_MERCENARY_MODE) ? (GetTeam() == ALLIANCE ? HORDE : ALLIANCE) : Team(GetTeam()); }
2230 TeamId GetEffectiveTeamId() const { return GetEffectiveTeam() == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
2231
2232 void InitDisplayIds();
2233
2234 bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
2235 bool IsAtRecruitAFriendDistance(WorldObject const* pOther) const;
2236 void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource);
2237 bool isHonorOrXPTarget(Unit const* victim) const;
2238
2239 bool GetsRecruitAFriendBonus(bool forXP);
2240
2241 ReputationMgr& GetReputationMgr() { return *m_reputationMgr; }
2242 ReputationMgr const& GetReputationMgr() const { return *m_reputationMgr; }
2243 ReputationRank GetReputationRank(uint32 faction_id) const;
2244 void RewardReputation(Unit* victim, float rate);
2245 void RewardReputation(Quest const* quest);
2246
2247 int32 CalculateReputationGain(ReputationSource source, uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool noQuestBonus = false);
2248
2249 void UpdateSkillsForLevel();
2250 void ModifySkillBonus(uint32 skillid, int32 val, bool talent);
2251
2252 /*********************************************************/
2253 /*** PVP SYSTEM ***/
2254 /*********************************************************/
2255 void UpdateHonorFields();
2256 bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, bool pvptoken = false);
2257 void ResetHonorStats();
2258 uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) const;
2259
2260 // duel health and mana reset methods
2261 void SaveHealthBeforeDuel() { healthBeforeDuel = GetHealth(); }
2262 void SaveManaBeforeDuel() { manaBeforeDuel = GetPower(POWER_MANA); }
2263 void RestoreHealthAfterDuel() { SetHealth(healthBeforeDuel); }
2264 void RestoreManaAfterDuel() { SetPower(POWER_MANA, manaBeforeDuel); }
2265
2266 uint32 GetHonorLevel() const { return m_playerData->HonorLevel; }
2267 void AddHonorXP(uint32 xp);
2268 void SetHonorLevel(uint8 honorLevel);
2269 bool IsMaxHonorLevel() const { return GetHonorLevel() == PLAYER_MAX_HONOR_LEVEL; }
2270 // Updates PLAYER_FIELD_HONOR_NEXT_LEVEL based on PLAYER_FIELD_HONOR_LEVEL
2271 void UpdateHonorNextLevel();
2272 //End of PvP System
2273
2274 void RewardPlayerWithRewardPack(uint32 rewardPackID);
2275 void RewardPlayerWithRewardPack(RewardPackEntry const* rewardPackEntry);
2276
2277 void SetDrunkValue(uint8 newDrunkValue, uint32 itemId = 0);
2278 uint8 GetDrunkValue() const { return m_playerData->Inebriation; }
2279 static DrunkenState GetDrunkenstateByValue(uint8 value);
2280
2281 uint32 GetDeathTimer() const { return m_deathTimer; }
2282 uint32 GetCorpseReclaimDelay(bool pvp) const;
2283 void UpdateCorpseReclaimDelay();
2284 int32 CalculateCorpseReclaimDelay(bool load = false) const;
2285 void SendCorpseReclaimDelay(uint32 delay) const;
2286
2287 float GetBlockPercent(uint8 attackerLevel) const override;
2288 bool CanParry() const { return m_canParry; }
2289 void SetCanParry(bool value);
2290 bool CanBlock() const { return m_canBlock; }
2291 void SetCanBlock(bool value);
2292 bool CanTitanGrip() const { return m_canTitanGrip; }
2293 void SetCanTitanGrip(bool value, uint32 penaltySpellId = 0);
2294 void CheckTitanGripPenalty();
2295 bool CanTameExoticPets() const { return IsGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); }
2296
2297 void SetRegularAttackTime();
2298
2299 void HandleBaseModFlatValue(BaseModGroup modGroup, float amount, bool apply);
2300 void ApplyBaseModPctValue(BaseModGroup modGroup, float pct);
2301
2302 void SetBaseModFlatValue(BaseModGroup modGroup, float val);
2303 void SetBaseModPctValue(BaseModGroup modGroup, float val);
2304
2305 void UpdateDamageDoneMods(WeaponAttackType attackType, int32 skipEnchantSlot = -1) override;
2306 void UpdateBaseModGroup(BaseModGroup modGroup);
2307
2308 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
2309 float GetTotalBaseModValue(BaseModGroup modGroup) const;
2310
2311 void _ApplyAllStatBonuses();
2312 void _RemoveAllStatBonuses();
2313
2314 void ResetAllPowers();
2315
2316 SpellSchoolMask GetMeleeDamageSchoolMask(WeaponAttackType attackType = BASE_ATTACK) const override;
2317
2318 void CastAllObtainSpells();
2319 void ApplyItemObtainSpells(Item* item, bool apply);
2320
2321 void UpdateWeaponDependentCritAuras(WeaponAttackType attackType);
2322 void UpdateAllWeaponDependentCritAuras();
2323
2324 void UpdateWeaponDependentAuras(WeaponAttackType attackType);
2325 void ApplyItemDependentAuras(Item* item, bool apply);
2326
2327 bool CheckAttackFitToAuraRequirement(WeaponAttackType attackType, AuraEffect const* aurEff) const override;
2328
2329 void _ApplyItemMods(Item* item, uint8 slot, bool apply, bool updateItemAuras = true);
2330 void _RemoveAllItemMods();
2331 void _ApplyAllItemMods();
2332 void _ApplyAllLevelScaleItemMods(bool apply);
2333 void ApplyAllAzeriteItemMods(bool apply);
2334 void ApplyAllAzeriteEmpoweredItemMods(bool apply);
2335 void _ApplyItemBonuses(Item* item, uint8 slot, bool apply);
2336 void _ApplyWeaponDamage(uint8 slot, Item* item, bool apply);
2337 bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) const;
2338 void ToggleMetaGemsActive(uint8 exceptslot, bool apply);
2339 void CorrectMetaGemEnchants(uint8 slot, bool apply);
2340 void InitDataForForm(bool reapplyMods = false);
2341
2342 void ApplyItemEquipSpell(Item* item, bool apply, bool formChange = false);
2343 void ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply, bool formChange = false);
2344 void UpdateEquipSpellsAtFormChange();
2345 void UpdateItemSetAuras(bool formChange = false);
2346 void ApplyArtifactPowers(Item* item, bool apply);
2347 void ApplyArtifactPowerRank(Item* artifact, ArtifactPowerRankEntry const* artifactPowerRank, bool apply);
2348 void ApplyAzeritePowers(Item* item, bool apply);
2349 void ApplyAzeriteItemMilestonePower(AzeriteItem* item, AzeriteItemMilestonePowerEntry const* azeriteItemMilestonePower, bool apply);
2350 void ApplyAzeriteEssence(AzeriteItem* item, uint32 azeriteEssenceId, uint32 rank, bool major, bool apply);
2351 void ApplyAzeriteEssencePower(AzeriteItem* item, AzeriteEssencePowerEntry const* azeriteEssencePower, bool major, bool apply);
2352 void ApplyAzeritePower(AzeriteEmpoweredItem* item, AzeritePowerEntry const* azeritePower, bool apply);
2353
2354 void CastItemCombatSpell(DamageInfo const& damageInfo);
2355 void CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemTemplate const* proto);
2356 void CastItemUseSpell(Item* item, SpellCastTargets const& targets, ObjectGuid castCount, int32* misc);
2357 void ApplyItemLootedSpell(Item* item, bool apply);
2358
2359 void SendEquipmentSetList();
2360 void SetEquipmentSet(EquipmentSetInfo::EquipmentSetData const& newEqSet);
2361 void DeleteEquipmentSet(uint64 id);
2362
2363 void SendInitWorldStates(uint32 zoneId, uint32 areaId);
2364 void SendUpdateWorldState(uint32 variable, uint32 value, bool hidden = false) const;
2365 void SendDirectMessage(WorldPacket const* data) const;
2366
2367 void SendAurasForTarget(Unit* target) const;
2368
2369 std::unique_ptr<PlayerMenu> PlayerTalkClass;
2370 std::vector<ItemSetEffect*> ItemSetEff;
2371
2372 void SendLoot(Loot& loot, bool aeLooting = false);
2373 void SendLootError(ObjectGuid const& lootObj, ObjectGuid const& owner, LootError error) const;
2374 void SendLootRelease(ObjectGuid guid) const;
2375 void SendLootReleaseAll() const;
2376 void SendNotifyLootItemRemoved(ObjectGuid lootObj, ObjectGuid owner, uint8 lootListId) const;
2377 void SendNotifyLootMoneyRemoved(ObjectGuid lootObj) const;
2378
2379 /*********************************************************/
2380 /*** BATTLEGROUND SYSTEM ***/
2381 /*********************************************************/
2382
2383 bool InBattleground() const { return m_bgData.bgInstanceID != 0; }
2384 bool InArena() const;
2385 uint32 GetBattlegroundId() const { return m_bgData.bgInstanceID; }
2386 BattlegroundTypeId GetBattlegroundTypeId() const { return m_bgData.bgTypeID; }
2387 Battleground* GetBattleground() const;
2388
2389 uint32 GetBattlegroundQueueJoinTime(BattlegroundQueueTypeId bgQueueTypeId) const;
2390 bool InBattlegroundQueue(bool ignoreArena = false) const;
2391 bool IsDeserter() const { return HasAura(26013); }
2392
2393 BattlegroundQueueTypeId GetBattlegroundQueueTypeId(uint32 index) const;
2394 uint32 GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const;
2395 bool IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const;
2396 bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const;
2397
2398 void SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId, BattlegroundQueueTypeId queueId);
2399 uint32 AddBattlegroundQueueId(BattlegroundQueueTypeId val);
2400 bool HasFreeBattlegroundQueueId() const;
2401 void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val);
2402 void SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId);
2403 bool IsInvitedForBattlegroundInstance(uint32 instanceId) const;
2404 void SetMercenaryForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, bool mercenary);
2405 bool IsMercenaryForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const;
2406 WorldLocation const& GetBattlegroundEntryPoint() const { return m_bgData.joinPos; }
2407 void SetBattlegroundEntryPoint();
2408
2409 void SetBGTeam(uint32 team);
2410 uint32 GetBGTeam() const;
2411
2412 void LeaveBattleground(bool teleportToEntryPoint = true);
2413 bool CanJoinToBattleground(BattlegroundTemplate const* bg) const;
2414 bool CanReportAfkDueToLimit();
2415 void ReportedAfkBy(Player* reporter);
2416 void ClearAfkReports() { m_bgData.bgAfkReporter.clear(); }
2417
2418 bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const;
2419 bool CanUseBattlegroundObject(GameObject* gameobject) const;
2420 bool isTotalImmune() const;
2421 bool CanCaptureTowerPoint() const;
2422
2423 bool GetRandomWinner() const { return m_IsBGRandomWinner; }
2424 void SetRandomWinner(bool isWinner);
2425
2426 /*********************************************************/
2427 /*** OUTDOOR PVP SYSTEM ***/
2428 /*********************************************************/
2429
2430 OutdoorPvP* GetOutdoorPvP() const;
2431 // returns true if the player is in active state for outdoor pvp objective capturing, false otherwise
2432 bool IsOutdoorPvPActive() const;
2433
2434 /*********************************************************/
2435 /*** ENVIROMENTAL SYSTEM ***/
2436 /*********************************************************/
2437
2438 bool IsImmuneToEnvironmentalDamage() const;
2439 uint32 EnvironmentalDamage(EnviromentalDamage type, uint32 damage);
2440
2441 /*********************************************************/
2442 /*** FLOOD FILTER SYSTEM ***/
2443 /*********************************************************/
2444
2446 {
2448 {
2449 REGULAR = 0,
2450 ADDON = 1,
2451 MAX
2453
2454 time_t Time = 0;
2456 };
2457
2458 void UpdateSpeakTime(ChatFloodThrottle::Index index);
2459
2460 /*********************************************************/
2461 /*** VARIOUS SYSTEMS ***/
2462 /*********************************************************/
2463 void UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode);
2464 // only changed for direct client control (possess, vehicle etc.), not stuff you control using pet commands
2466 void SetFallInformation(uint32 time, float z);
2467 void HandleFall(MovementInfo const& movementInfo);
2468
2469 void SetClientControl(Unit* target, bool allowMove);
2470
2471 void SetSeer(WorldObject* target) { m_seer = target; }
2472 void SetViewpoint(WorldObject* target, bool apply);
2473 WorldObject* GetViewpoint() const;
2474 void StopCastingCharm();
2475 void StopCastingBindSight() const;
2476
2477 uint32 GetSaveTimer() const { return m_nextSave; }
2478 void SetSaveTimer(uint32 timer) { m_nextSave = timer; }
2479
2481 {
2482 m_recall_location.WorldRelocate(*this);
2483 m_recall_instanceId = GetInstanceId();
2484 }
2485 void Recall() { TeleportTo(m_recall_location, TELE_TO_NONE, m_recall_instanceId); }
2486
2487 void SetHomebind(WorldLocation const& loc, uint32 areaId);
2488 void SendBindPointUpdate() const;
2489 void SendPlayerBound(ObjectGuid const& binderGuid, uint32 areaId) const;
2490
2491 // Homebind coordinates
2494
2495 uint8 GetStartLevel(uint8 race, uint8 playerClass, Optional<int32> characterTemplateId) const;
2496
2497 // currently visible objects at player client
2500
2501 bool HaveAtClient(Object const* u) const;
2502
2503 bool IsNeverVisibleFor(WorldObject const* seer, bool allowServersideObjects = false) const override;
2504
2505 bool IsVisibleGloballyFor(Player const* player) const;
2506
2507 void SendInitialVisiblePackets(Unit* target) const;
2508 void OnPhaseChange() override;
2509 void UpdateObjectVisibility(bool forced = true) override;
2510 void UpdateVisibilityForPlayer();
2511 void UpdateVisibilityOf(WorldObject* target);
2512 void UpdateVisibilityOf(Trinity::IteratorPair<WorldObject**> targets);
2513 void UpdateTriggerVisibility();
2514
2515 template<class T>
2516 void UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& visibleNow);
2517
2518 std::array<uint8, MAX_MOVE_TYPE> m_forced_speed_changes;
2520
2521 bool HasAtLoginFlag(AtLoginFlags f) const { return (m_atLoginFlags & f) != 0; }
2522 void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
2523 void RemoveAtLoginFlag(AtLoginFlags flags, bool persist = false);
2524
2525 bool isUsingLfg() const;
2526 bool inRandomLfgDungeon() const;
2527
2528 typedef std::set<uint32> DFQuestsDoneList;
2530
2531 // Temporarily removed pet cache
2532 uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
2533 void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
2534 Optional<ReactStates> GetTemporaryPetReactState() const { return m_temporaryPetReactState; }
2535 void DisablePetControlsOnMount(ReactStates reactState, CommandStates commandState);
2536 void EnablePetControlsOnDismount();
2537 void UnsummonPetTemporaryIfAny();
2538 void ResummonPetTemporaryUnSummonedIfAny();
2539 bool IsPetNeedBeTemporaryUnsummoned() const;
2540
2541 void SendCinematicStart(uint32 CinematicSequenceId) const;
2542 void SendMovieStart(uint32 movieId);
2543
2544 uint32 DoRandomRoll(uint32 minimum, uint32 maximum);
2545 uint8 GetItemLimitCategoryQuantity(ItemLimitCategoryEntry const* limitEntry) const;
2546
2547 void UpdateItemLevelAreaBasedScaling();
2548 void ActivatePvpItemLevels(bool activate) { _usePvpItemLevels = activate; }
2549 bool IsUsingPvpItemLevels() const { return _usePvpItemLevels; }
2550
2551 /*********************************************************/
2552 /*** INSTANCE SYSTEM ***/
2553 /*********************************************************/
2554
2555 void UpdateHomebindTime(uint32 time);
2556
2559 // permanent binds and solo binds by difficulty
2561 {
2562 auto itr = m_recentInstances.find(mapId);
2563 return itr != m_recentInstances.end() ? itr->second : 0;
2564 }
2565
2566 void SetRecentInstance(uint32 mapId, uint32 instanceId)
2567 {
2568 m_recentInstances[mapId] = instanceId;
2569 }
2570
2571 std::unordered_map<uint32 /*mapId*/, uint32 /*instanceId*/> m_recentInstances;
2572 void ConfirmPendingBind();
2573 void SetPendingBind(uint32 instanceId, uint32 bindTimer);
2574 bool HasPendingBind() const { return _pendingBindId > 0; }
2575 void SendRaidInfo();
2576 bool Satisfy(AccessRequirement const* ar, uint32 target_map, TransferAbortParams* params = nullptr, bool report = false);
2577 bool CheckInstanceValidity(bool /*isLogin*/);
2578 bool CheckInstanceCount(uint32 instanceId) const;
2579 void AddInstanceEnterTime(uint32 instanceId, time_t enterTime);
2580 WorldSafeLocsEntry const* GetInstanceEntrance(uint32 targetMapId);
2581
2582 // last used pet number (for BG's)
2583 uint32 GetLastPetNumber() const { return m_lastpetnumber; }
2584 void SetLastPetNumber(uint32 petnumber) { m_lastpetnumber = petnumber; }
2585
2586 /*********************************************************/
2587 /*** GROUP SYSTEM ***/
2588 /*********************************************************/
2589
2590 bool IsInGroup(ObjectGuid groupGuid) const;
2591 Group* GetGroupInvite() const { return m_groupInvite; }
2592 void SetGroupInvite(Group* group) { m_groupInvite = group; }
2593 Group* GetGroup(Optional<uint8> partyIndex) { return const_cast<Group*>(const_cast<Player const*>(this)->GetGroup(partyIndex)); }
2594 Group const* GetGroup(Optional<uint8> partyIndex) const;
2595 Group* GetGroup() { return m_group.getTarget(); }
2596 Group const* GetGroup() const { return const_cast<Group const*>(m_group.getTarget()); }
2597 GroupReference& GetGroupRef() { return m_group; }
2598 void SetGroup(Group* group, int8 subgroup = -1);
2599 uint8 GetSubGroup() const { return m_group.getSubGroup(); }
2600 uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; }
2601 void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
2602 void RemoveGroupUpdateFlag(uint32 flag) { m_groupUpdateMask &= ~flag; }
2603 void SetPartyType(GroupCategory category, uint8 type);
2604 void ResetGroupUpdateSequenceIfNeeded(Group const* group);
2605 int32 NextGroupUpdateSequenceNumber(GroupCategory category);
2606 Player* GetNextRandomRaidMember(float radius);
2607 PartyResult CanUninviteFromGroup(ObjectGuid guidMember, Optional<uint8> partyIndex) const;
2608
2609 // Battleground / Battlefield Group System
2610 void SetBattlegroundOrBattlefieldRaid(Group* group, int8 subgroup = -1);
2611 void RemoveFromBattlegroundOrBattlefieldRaid();
2612 Group* GetOriginalGroup() const { return m_originalGroup.getTarget(); }
2613 GroupReference& GetOriginalGroupRef() { return m_originalGroup; }
2614 uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); }
2615 void SetOriginalGroup(Group* group, int8 subgroup = -1);
2616
2617 void SetPassOnGroupLoot(bool bPassOnGroupLoot) { m_bPassOnGroupLoot = bPassOnGroupLoot; }
2618 bool GetPassOnGroupLoot() const { return m_bPassOnGroupLoot; }
2619
2620 MapReference &GetMapRef() { return m_mapRef; }
2621
2622 // Set map to player and add reference
2623 void SetMap(Map* map) override;
2624 void ResetMap() override;
2625
2626 bool isAllowedToLoot(Creature const* creature) const;
2627
2628 DeclinedName const* GetDeclinedNames() const { return m_declinedname.get(); }
2629 uint8 GetRunesState() const;
2630 uint32 GetRuneCooldown(uint8 index) const { return m_runes->Cooldown[index]; }
2631 uint32 GetRuneBaseCooldown() const;
2632 void SetRuneCooldown(uint8 index, uint32 cooldown);
2633 void ResyncRunes() const;
2634 void InitRunes();
2635
2636 void SendRespondInspectAchievements(Player* player) const;
2637 uint32 GetAchievementPoints() const;
2638 std::vector<uint32> GetCompletedAchievementIds() const;
2639 bool HasAchieved(uint32 achievementId) const;
2640 void ResetAchievements();
2641 void ResetCriteria(CriteriaFailEvent condition, int32 failAsset, bool evenIfCriteriaComplete = false);
2642 void UpdateCriteria(CriteriaType type, uint64 miscValue1 = 0, uint64 miscValue2 = 0, uint64 miscValue3 = 0, WorldObject* ref = nullptr);
2643 void StartCriteriaTimer(CriteriaStartEvent startEvent, uint32 entry, uint32 timeLost = 0);
2644 void RemoveCriteriaTimer(CriteriaStartEvent startEvent, uint32 entry);
2645 void CompletedAchievement(AchievementEntry const* entry);
2646 bool ModifierTreeSatisfied(uint32 modifierTreeId) const;
2647
2648 bool HasTitle(uint32 bitIndex) const;
2649 bool HasTitle(CharTitlesEntry const* title) const;
2650 void SetTitle(CharTitlesEntry const* title, bool lost = false);
2651 void SetChosenTitle(int32 title) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::PlayerTitle), title); }
2652 void SetKnownTitles(uint32 index, uint64 mask) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::KnownTitles, index), mask); }
2653
2654 //bool isActiveObject() const { return true; }
2655 bool CanSeeSpellClickOn(Creature const* creature) const;
2656
2657 uint32 GetChampioningFaction() const { return m_ChampioningFaction; }
2658 void SetChampioningFaction(uint32 faction) { m_ChampioningFaction = faction; }
2660
2661 float GetAverageItemLevel() const;
2663
2664 void ClearWhisperWhiteList() { WhisperList.clear(); }
2665 void AddWhisperWhiteList(ObjectGuid guid) { WhisperList.push_back(guid); }
2666 bool IsInWhisperWhiteList(ObjectGuid guid);
2667 void RemoveFromWhisperWhiteList(ObjectGuid guid) { WhisperList.remove(guid); }
2668
2669 void ValidateMovementInfo(MovementInfo* mi);
2670
2671 void SendMovementSetCollisionHeight(float height, WorldPackets::Movement::UpdateCollisionHeightReason reason);
2672
2673 bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }
2674 bool CanEnterWater() const override { return true; }
2675
2676 std::string GetMapAreaAndZoneString() const;
2677 std::string GetCoordsMapAreaAndZoneString() const;
2678
2679 // Void Storage
2680 bool IsVoidStorageUnlocked() const { return HasPlayerFlag(PLAYER_FLAGS_VOID_UNLOCKED); }
2682 void LockVoidStorage() { RemovePlayerFlag(PLAYER_FLAGS_VOID_UNLOCKED); }
2683 uint8 GetNextVoidStorageFreeSlot() const;
2684 uint8 GetNumOfVoidStorageFreeSlots() const;
2685 uint8 AddVoidStorageItem(VoidStorageItem&& item);
2686 void DeleteVoidStorageItem(uint8 slot);
2687 bool SwapVoidStorageItem(uint8 oldSlot, uint8 newSlot);
2688 VoidStorageItem* GetVoidStorageItem(uint8 slot) const;
2689 VoidStorageItem* GetVoidStorageItem(uint64 id, uint8& slot) const;
2690
2691 // Reagent Bank
2692 bool IsReagentBankUnlocked() const { return HasPlayerFlagEx(PLAYER_FLAGS_EX_REAGENT_BANK_UNLOCKED); }
2694
2695 void CreateGarrison(uint32 garrSiteId);
2696 void DeleteGarrison();
2697 Garrison* GetGarrison() const { return _garrison.get(); }
2698
2699 bool IsAdvancedCombatLoggingEnabled() const { return _advancedCombatLoggingEnabled; }
2700 void SetAdvancedCombatLogging(bool enabled) { _advancedCombatLoggingEnabled = enabled; }
2701
2702 SceneMgr& GetSceneMgr() { return m_sceneMgr; }
2703 SceneMgr const& GetSceneMgr() const { return m_sceneMgr; }
2704 RestMgr& GetRestMgr() const { return *_restMgr; }
2706 {
2707 SetUpdateFieldValue(m_values
2708 .ModifyValue(&Player::m_activePlayerData)
2709 .ModifyValue(&UF::ActivePlayerData::RestInfo, type)
2710 .ModifyValue(&UF::RestInfo::StateID), state);
2711 }
2712 void SetRestThreshold(RestTypes type, uint32 threshold)
2713 {
2714 SetUpdateFieldValue(m_values
2715 .ModifyValue(&Player::m_activePlayerData)
2716 .ModifyValue(&UF::ActivePlayerData::RestInfo, type)
2717 .ModifyValue(&UF::RestInfo::Threshold), threshold);
2718 }
2719
2720 void SendPlayerChoice(ObjectGuid sender, int32 choiceId);
2721
2722 bool MeetPlayerCondition(uint32 conditionId) const;
2723
2724 bool HasPlayerFlag(PlayerFlags flags) const { return (*m_playerData->PlayerFlags & flags) != 0; }
2725 void SetPlayerFlag(PlayerFlags flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::PlayerFlags), flags); }
2726 void RemovePlayerFlag(PlayerFlags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::PlayerFlags), flags); }
2727 void ReplaceAllPlayerFlags(PlayerFlags flags) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::PlayerFlags), flags); }
2728
2729 bool HasPlayerFlagEx(PlayerFlagsEx flags) const { return (*m_playerData->PlayerFlagsEx & flags) != 0; }
2730 void SetPlayerFlagEx(PlayerFlagsEx flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::PlayerFlagsEx), flags); }
2731 void RemovePlayerFlagEx(PlayerFlagsEx flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::PlayerFlagsEx), flags); }
2732 void ReplaceAllPlayerFlagsEx(PlayerFlagsEx flags) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::PlayerFlagsEx), flags); }
2733
2734 void SetAverageItemLevelTotal(float newItemLevel) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::AvgItemLevel, 0), newItemLevel); }
2735 void SetAverageItemLevelEquipped(float newItemLevel) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::AvgItemLevel, 1), newItemLevel); }
2736
2737 uint32 GetCustomizationChoice(uint32 chrCustomizationOptionId) const
2738 {
2739 int32 choiceIndex = m_playerData->Customizations.FindIndexIf([chrCustomizationOptionId](UF::ChrCustomizationChoice choice)
2740 {
2741 return choice.ChrCustomizationOptionID == chrCustomizationOptionId;
2742 });
2743
2744 if (choiceIndex >= 0)
2745 return m_playerData->Customizations[choiceIndex].ChrCustomizationChoiceID;
2746
2747 return 0;
2748 }
2749
2750 template<typename Iter>
2751 void SetCustomizations(Trinity::IteratorPair<Iter> customizations, bool markChanged = true)
2752 {
2753 if (markChanged)
2754 m_customizationsChanged = true;
2755
2756 ClearDynamicUpdateFieldValues(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::Customizations));
2757 for (auto&& customization : customizations)
2758 {
2759 UF::ChrCustomizationChoice& newChoice = AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::Customizations));
2760 newChoice.ChrCustomizationOptionID = customization.ChrCustomizationOptionID;
2761 newChoice.ChrCustomizationChoiceID = customization.ChrCustomizationChoiceID;
2762 }
2763 }
2764 void SetPvpTitle(uint8 pvpTitle) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::PvpTitle), pvpTitle); }
2765 void SetArenaFaction(uint8 arenaFaction) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::ArenaFaction), arenaFaction); }
2766 void ApplyModFakeInebriation(int32 mod, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::FakeInebriation), mod, apply); }
2767 void SetVirtualPlayerRealm(uint32 virtualRealmAddress) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::VirtualPlayerRealm), virtualRealmAddress); }
2768 void SetCurrentBattlePetBreedQuality(uint8 battlePetBreedQuality) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::CurrentBattlePetBreedQuality), battlePetBreedQuality); }
2769
2771 {
2772 AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Heirlooms)) = itemId;
2773 AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::HeirloomFlags)) = flags;
2774 }
2775 void SetHeirloom(uint32 slot, int32 itemId) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Heirlooms, slot), itemId); }
2776 void SetHeirloomFlags(uint32 slot, uint32 flags) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::HeirloomFlags, slot), flags); }
2777
2778 void AddToy(int32 itemId, uint32 flags)
2779 {
2780 AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Toys)) = itemId;
2781 AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ToyFlags)) = flags;
2782 }
2783
2784 void AddTransmogBlock(uint32 blockValue) { AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Transmog)) = blockValue; }
2785 void AddTransmogFlag(uint32 slot, uint32 flag) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Transmog, slot), flag); }
2786
2787 void AddConditionalTransmog(uint32 itemModifiedAppearanceId) { AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ConditionalTransmog)) = itemModifiedAppearanceId; }
2788 void RemoveConditionalTransmog(uint32 itemModifiedAppearanceId)
2789 {
2790 int32 index = m_activePlayerData->ConditionalTransmog.FindIndex(itemModifiedAppearanceId);
2791 if (index >= 0)
2792 RemoveDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ConditionalTransmog), uint32(index));
2793 }
2794
2795 void AddIllusionBlock(uint32 blockValue) { AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::TransmogIllusions)) = blockValue; }
2796 void AddIllusionFlag(uint32 slot, uint32 flag) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::TransmogIllusions, slot), flag); }
2797
2798 void AddSelfResSpell(int32 spellId) { AddDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::SelfResSpells)) = spellId; }
2800 {
2801 int32 index = m_activePlayerData->SelfResSpells.FindIndex(spellId);
2802 if (index >= 0)
2803 RemoveDynamicUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::SelfResSpells), uint32(index));
2804 }
2805 void ClearSelfResSpell() { ClearDynamicUpdateFieldValues(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::SelfResSpells)); }
2806
2807 ObjectGuid GetSummonedBattlePetGUID() const { return m_activePlayerData->SummonedBattlePetGUID; }
2808 void SetSummonedBattlePetGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::SummonedBattlePetGUID), guid); }
2809
2810 void SetTrackCreatureFlag(uint32 flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::TrackCreatureMask), flags); }
2811 void RemoveTrackCreatureFlag(uint32 flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::TrackCreatureMask), flags); }
2812
2813 void SetVersatilityBonus(float value) { SetUpdateFieldStatValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::VersatilityBonus), value); }
2814
2815 void ApplyModOverrideSpellPowerByAPPercent(float mod, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::OverrideSpellPowerByAPPercent), mod, apply); }
2816
2817 void ApplyModOverrideAPBySpellPowerPercent(float mod, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::OverrideAPBySpellPowerPercent), mod, apply); }
2818
2819 bool HasPlayerLocalFlag(PlayerLocalFlags flags) const { return (*m_activePlayerData->LocalFlags & flags) != 0; }
2820 void SetPlayerLocalFlag(PlayerLocalFlags flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::LocalFlags), flags); }
2821 void RemovePlayerLocalFlag(PlayerLocalFlags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::LocalFlags), flags); }
2823
2824 uint8 GetNumRespecs() const { return m_activePlayerData->NumRespecs; }
2825 void SetNumRespecs(uint8 numRespecs) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::NumRespecs), numRespecs); }
2826
2827 void SetWatchedFactionIndex(int32 index) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::WatchedFactionIndex), index); }
2828
2829 void AddAuraVision(PlayerFieldByte2Flags flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::AuraVision), flags); }
2830 void RemoveAuraVision(PlayerFieldByte2Flags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::AuraVision), flags); }
2831
2832 void SetTransportServerTime(int32 transportServerTime) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::TransportServerTime), transportServerTime); }
2833
2834 void SetRequiredMountCapabilityFlag(uint8 flag) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::RequiredMountCapabilityFlags), flag); }
2836
2837 bool IsInFriendlyArea() const;
2838 bool IsFriendlyArea(AreaTableEntry const* inArea) const;
2839
2840 void SetWarModeDesired(bool enabled);
2841 bool IsWarModeDesired() const { return HasPlayerFlag(PLAYER_FLAGS_WAR_MODE_DESIRED); }
2842 bool IsWarModeActive() const { return HasPlayerFlag(PLAYER_FLAGS_WAR_MODE_ACTIVE); }
2843 bool IsWarModeLocalActive() const { return HasPlayerLocalFlag(PLAYER_LOCAL_FLAG_WAR_MODE); }
2844 void SetWarModeLocal(bool enabled);
2845 bool CanEnableWarModeInArea() const;
2846 void UpdateWarModeAuras();
2847
2848 std::string GetDebugInfo() const override;
2849
2852
2853 void SetAreaSpiritHealer(Creature* creature);
2854 ObjectGuid const& GetSpiritHealerGUID() const { return _areaSpiritHealerGUID; }
2855 bool CanAcceptAreaSpiritHealFrom(Unit* spiritHealer) const { return spiritHealer->GetGUID() == _areaSpiritHealerGUID; }
2856 void SendAreaSpiritHealerTime(Unit* spiritHealer) const;
2857 void SendAreaSpiritHealerTime(ObjectGuid const& spiritHealerGUID, int32 timeLeft) const;
2858
2859 protected:
2860 // Gamemaster whisper whitelist
2865 std::array<float, MAX_POWERS_PER_CLASS> m_powerFraction;
2867
2868 /*********************************************************/
2869 /*** BATTLEGROUND SYSTEM ***/
2870 /*********************************************************/
2871
2872 /*
2873 this is an array of BG queues (BgTypeIDs) in which is player
2874 */
2876 {
2881 };
2882
2885
2887
2888 /*********************************************************/
2889 /*** QUEST SYSTEM ***/
2890 /*********************************************************/
2891
2892 void PushQuests();
2893
2894 //We allow only one timed quest active at the same time. Below can then be simple value instead of set.
2895 typedef std::set<uint32> QuestSet;
2896 typedef std::unordered_map<uint32, time_t> SeasonalQuestMapByQuest;
2897 typedef std::unordered_map<uint32, SeasonalQuestMapByQuest> SeasonalQuestMapByEvent;
2902
2906
2907 /*********************************************************/
2908 /*** LOAD SYSTEM ***/
2909 /*********************************************************/
2910
2911 void _LoadActions(PreparedQueryResult result);
2912 void _LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effectResult, uint32 timediff);
2913 void _LoadGlyphAuras();
2914 void _LoadInventory(PreparedQueryResult result, PreparedQueryResult artifactsResult, PreparedQueryResult azeriteResult,
2915 PreparedQueryResult azeriteItemMilestonePowersResult, PreparedQueryResult azeriteItemUnlockedEssencesResult,
2916 PreparedQueryResult azeriteEmpoweredItemResult, uint32 timeDiff);
2917 void _LoadVoidStorage(PreparedQueryResult result);
2918 void _LoadMail(PreparedQueryResult mailsResult, PreparedQueryResult mailItemsResult, PreparedQueryResult artifactResult, PreparedQueryResult azeriteItemResult,
2919 PreparedQueryResult azeriteItemMilestonePowersResult, PreparedQueryResult azeriteItemUnlockedEssencesResult, PreparedQueryResult azeriteEmpoweredItemResult);
2920 static Item* _LoadMailedItem(ObjectGuid const& playerGuid, Player* player, uint64 mailId, Mail* mail, Field* fields, ItemAdditionalLoadInfo* addionalData);
2921 void _LoadQuestStatus(PreparedQueryResult result);
2922 void _LoadQuestStatusObjectives(PreparedQueryResult result);
2923 void _LoadQuestStatusRewarded(PreparedQueryResult result);
2924 void _LoadDailyQuestStatus(PreparedQueryResult result);
2925 void _LoadWeeklyQuestStatus(PreparedQueryResult result);
2926 void _LoadMonthlyQuestStatus(PreparedQueryResult result);
2927 void _LoadSeasonalQuestStatus(PreparedQueryResult result);
2928 void _LoadRandomBGStatus(PreparedQueryResult result);
2929 void _LoadGroup(PreparedQueryResult result);
2930 void _LoadSkills(PreparedQueryResult result);
2931 void _LoadSpells(PreparedQueryResult result, PreparedQueryResult favoritesResult);
2932 void _LoadStoredAuraTeleportLocations(PreparedQueryResult result);
2933 bool _LoadHomeBind(PreparedQueryResult result);
2934 void _LoadDeclinedNames(PreparedQueryResult result);
2935 void _LoadArenaTeamInfo(PreparedQueryResult result);
2936 void _LoadEquipmentSets(PreparedQueryResult result);
2937 void _LoadTransmogOutfits(PreparedQueryResult result);
2938 void _LoadBGData(PreparedQueryResult result);
2939 void _LoadGlyphs(PreparedQueryResult result);
2940 void _LoadTalents(PreparedQueryResult result);
2941 void _LoadPvpTalents(PreparedQueryResult result);
2942 void _LoadTraits(PreparedQueryResult configsResult, PreparedQueryResult entriesResult);
2943 void _LoadInstanceTimeRestrictions(PreparedQueryResult result);
2944 void _LoadPetStable(uint32 summonedPetNumber, PreparedQueryResult result);
2945 void _LoadCurrency(PreparedQueryResult result);
2946 void _LoadCUFProfiles(PreparedQueryResult result);
2947
2948 /*********************************************************/
2949 /*** SAVE SYSTEM ***/
2950 /*********************************************************/
2951
2952 void _SaveCustomizations(CharacterDatabaseTransaction trans);
2953 void _SaveActions(CharacterDatabaseTransaction trans);
2954 void _SaveAuras(CharacterDatabaseTransaction trans);
2955 void _SaveInventory(CharacterDatabaseTransaction trans);
2956 void _SaveVoidStorage(CharacterDatabaseTransaction trans);
2957 void _SaveMail(CharacterDatabaseTransaction trans);
2958 void _SaveQuestStatus(CharacterDatabaseTransaction trans);
2959 void _SaveDailyQuestStatus(CharacterDatabaseTransaction trans);
2960 void _SaveWeeklyQuestStatus(CharacterDatabaseTransaction trans);
2961 void _SaveMonthlyQuestStatus(CharacterDatabaseTransaction trans);
2962 void _SaveSeasonalQuestStatus(CharacterDatabaseTransaction trans);
2963 void _SaveSkills(CharacterDatabaseTransaction trans);
2964 void _SaveSpells(CharacterDatabaseTransaction trans);
2965 void _SaveStoredAuraTeleportLocations(CharacterDatabaseTransaction trans);
2966 void _SaveEquipmentSets(CharacterDatabaseTransaction trans);
2967 void _SaveBGData(CharacterDatabaseTransaction trans);
2968 void _SaveGlyphs(CharacterDatabaseTransaction trans) const;
2969 void _SaveTalents(CharacterDatabaseTransaction trans);
2970 void _SaveTraits(CharacterDatabaseTransaction trans);
2971 void _SaveStats(CharacterDatabaseTransaction trans) const;
2972 void _SaveInstanceTimeRestrictions(CharacterDatabaseTransaction trans);
2973 void _SaveCurrency(CharacterDatabaseTransaction trans);
2974 void _SaveCUFProfiles(CharacterDatabaseTransaction trans);
2975
2976 /*********************************************************/
2977 /*** ENVIRONMENTAL SYSTEM ***/
2978 /*********************************************************/
2979 void HandleSobering();
2980 void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen);
2981 void StopMirrorTimer(MirrorTimerType Type);
2982 void HandleDrowning(uint32 time_diff);
2983 int32 getMaxTimer(MirrorTimerType timer) const;
2984
2985 /*********************************************************/
2986 /*** HONOR SYSTEM ***/
2987 /*********************************************************/
2989
2990 void outDebugValues() const;
2991
2995 std::array<ChatFloodThrottle, ChatFloodThrottle::MAX> m_chatFloodData;
2999
3001
3004
3006
3008
3009 std::vector<Item*> m_itemUpdateQueue;
3011
3013
3017
3020
3022
3025
3028 std::unordered_map<uint32 /*overridenSpellId*/, std::unordered_set<uint32> /*newSpellId*/> m_overrideSpells;
3029 uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use
3030 std::unordered_map<uint32, StoredAuraTeleportLocation> m_storedAuraTeleportLocations;
3031
3033
3034 std::unordered_map<int32, PlayerSpellState> m_traitConfigStates;
3035
3037
3038 std::array<float, BASEMOD_END> m_auraBaseFlatMod;
3039 std::array<float, BASEMOD_END> m_auraBasePctMod;
3040 std::array<int16, MAX_COMBAT_RATING> m_baseRatingValue;
3045
3047
3051
3052 std::unique_ptr<ResurrectionData> _resurrectionData;
3053
3055
3057
3061
3063
3065
3071
3075
3079
3082
3090
3091 // Social
3093
3094 // Groups
3100 std::array<GroupUpdateCounter, 2> m_groupUpdateSequences;
3101
3102 // last used pet number (for BG's)
3104
3105 // Player summoning
3109
3110 // Recall position
3113
3114 std::unique_ptr<DeclinedName> m_declinedname;
3115 std::unique_ptr<Runes> m_runes;
3117
3118 bool CanNeverSee(WorldObject const* obj) const override;
3119 bool CanAlwaysSee(WorldObject const* obj) const override;
3120
3121 bool IsAlwaysDetectableFor(WorldObject const* seer) const override;
3122
3124
3125 std::array<std::unique_ptr<CUFProfile>, MAX_CUF_PROFILES> _CUFProfiles;
3126
3128
3129 private:
3130 // internal common parts for CanStore/StoreItem functions
3131 InventoryResult CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const;
3132 InventoryResult CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const;
3133 InventoryResult CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const;
3134 Item* _StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update);
3135 Item* _LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint32 timeDiff, Field* fields);
3136
3137 std::unique_ptr<CinematicMgr> _cinematicMgr;
3138
3140 void SendRefundInfo(Item* item);
3141 void RefundItem(Item* item);
3142 void SendItemRefundResult(Item* item, ItemExtendedCostEntry const* iece, uint8 error) const;
3143
3144 void AdjustQuestObjectiveProgress(Quest const* quest);
3145
3146 bool IsCanDelayTeleport() const { return m_bCanDelayTeleport; }
3147 void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; }
3148 bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; }
3149 void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; }
3150 void ScheduleDelayedOperation(uint32 operation) { if (operation < DELAYED_END) m_DelayedOperations |= operation; }
3151
3152 bool IsInstanceLoginGameMasterException() const;
3153
3155
3158
3159 std::array<int32, MAX_TIMERS> m_MirrorTimer;
3162
3163 // Current teleport data
3169
3173
3174 std::unique_ptr<PetStable> m_petStable;
3175
3176 // Temporary removed pet cache
3180
3181 std::unique_ptr<PlayerAchievementMgr> m_achievementMgr;
3182 std::unique_ptr<ReputationMgr> m_reputationMgr;
3183 std::unique_ptr<QuestObjectiveCriteriaMgr> m_questObjectiveCriteriaMgr;
3184
3186
3190
3192
3193 std::unique_ptr<Garrison> _garrison;
3194
3196
3197 // variables to save health and mana before duel and restore them after duel
3200
3202
3204
3205 std::unordered_map<ObjectGuid /*LootObject*/, Loot*> m_AELootView;
3206 std::vector<LootRoll*> m_lootRolls; // loot rolls waiting for answer
3207
3208 void _InitHonorLevelOnLoadFromDB(uint32 honor, uint32 honorLevel);
3209 std::unique_ptr<RestMgr> _restMgr;
3210
3213};
3214
3215TC_GAME_API void AddItemsSetItem(Player* player, Item const* item);
3216TC_GAME_API void RemoveItemsSetItem(Player* player, Item const* item);
3217
3218// Transforms a container of customization choices with continuous storage into iterator pair that does not depend on container
3219// and doesn't force implementations in header files
3220template<typename Container>
3222{
3223 static_assert(std::is_same<typename Container::value_type, UF::ChrCustomizationChoice>::value,
3224 "MakeChrCustomizationChoiceRange must be used with containers of UF::ChrCustomizationChoice");
3225
3226 return { container.data(), container.data() + container.size() };
3227}
3228
3229#endif
uint32 GetBagSize(Bag const *bag)
Definition: Bag.cpp:303
Item * GetItemInBag(Bag const *bag, uint8 slot)
Definition: Bag.cpp:308
#define MAX_CUF_PROFILES
Maximum number of CompactUnitFrames profiles.
Definition: CUFProfile.h:26
Difficulty
Definition: DBCEnums.h:817
CriteriaType
Definition: DBCEnums.h:449
ItemContext
Definition: DBCEnums.h:1007
ChrSpecialization
Definition: DBCEnums.h:303
CriteriaStartEvent
Definition: DBCEnums.h:416
CriteriaFailEvent
Definition: DBCEnums.h:395
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
SQLTransaction< LoginDatabaseConnection > LoginDatabaseTransaction
std::shared_ptr< PreparedResultSet > PreparedQueryResult
#define TC_GAME_API
Definition: Define.h:124
uint8_t uint8
Definition: Define.h:145
int64_t int64
Definition: Define.h:138
int16_t int16
Definition: Define.h:140
int8_t int8
Definition: Define.h:141
int32_t int32
Definition: Define.h:139
uint64_t uint64
Definition: Define.h:142
#define UI64LIT(N)
Definition: Define.h:128
uint16_t uint16
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:143
std::unordered_set< uint32 > params[2]
Definition: DisableMgr.cpp:50
uint16 flags
Definition: DisableMgr.cpp:49
std::chrono::steady_clock::time_point TimePoint
time_point shorthand typedefs
Definition: Duration.h:41
#define DEFINE_ENUM_FLAG(enumType)
Definition: EnumFlag.h:26
std::map< uint64, EquipmentSetInfo > EquipmentSetContainer
Definition: EquipmentSet.h:69
std::string GetDebugInfo()
Definition: Errors.cpp:157
#define ASSERT
Definition: Errors.h:68
GroupCategory
Definition: Group.h:111
EnchantmentSlot
Definition: ItemDefines.h:178
@ MAX_ENCHANTMENT_SLOT
Definition: ItemDefines.h:195
InventoryResult
Definition: ItemDefines.h:25
@ EQUIP_ERR_OK
Definition: ItemDefines.h:26
BuyResult
Definition: ItemDefines.h:149
SellResult
Definition: ItemDefines.h:163
uint32 ItemRandomBonusListId
ItemClass
Definition: ItemTemplate.h:419
InventoryType
Definition: ItemTemplate.h:378
void RemoveItemFromUpdateQueueOf(Item *item, Player *player)
Definition: Item.cpp:1218
void AddItemToUpdateQueueOf(Item *item, Player *player)
Definition: Item.cpp:1197
LootItemType
Definition: LootItemType.h:24
LootType
Definition: Loot.h:98
LootError
Definition: Loot.h:137
ZLiquidStatus
Definition: MapDefines.h:125
InstanceResetMethod
Definition: Map.h:806
InstanceResetResult
Definition: Map.h:813
TransferAbortReason
Definition: Map.h:84
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:392
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition: ObjectGuid.h:394
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:391
PlayerCreateMode
Definition: ObjectMgr.h:612
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
PetTameResult
Definition: PetDefines.h:101
PetStableFlags
Definition: PetDefines.h:62
PetSaveMode
Definition: PetDefines.h:41
EquipmentSlots
Definition: Player.h:624
@ EQUIPMENT_SLOT_SHOULDERS
Definition: Player.h:628
@ EQUIPMENT_SLOT_BODY
Definition: Player.h:629
@ EQUIPMENT_SLOT_HANDS
Definition: Player.h:635
@ EQUIPMENT_SLOT_FINGER1
Definition: Player.h:636
@ EQUIPMENT_SLOT_NECK
Definition: Player.h:627
@ EQUIPMENT_SLOT_FINGER2
Definition: Player.h:637
@ EQUIPMENT_SLOT_MAINHAND
Definition: Player.h:641
@ EQUIPMENT_SLOT_TABARD
Definition: Player.h:644
@ EQUIPMENT_SLOT_TRINKET1
Definition: Player.h:638
@ EQUIPMENT_SLOT_END
Definition: Player.h:645
@ EQUIPMENT_SLOT_HEAD
Definition: Player.h:626
@ EQUIPMENT_SLOT_LEGS
Definition: Player.h:632
@ EQUIPMENT_SLOT_BACK
Definition: Player.h:640
@ EQUIPMENT_SLOT_OFFHAND
Definition: Player.h:642
@ EQUIPMENT_SLOT_WAIST
Definition: Player.h:631
@ EQUIPMENT_SLOT_FEET
Definition: Player.h:633
@ EQUIPMENT_SLOT_CHEST
Definition: Player.h:630
@ EQUIPMENT_SLOT_WRISTS
Definition: Player.h:634
@ EQUIPMENT_SLOT_TRINKET2
Definition: Player.h:639
@ EQUIPMENT_SLOT_START
Definition: Player.h:625
@ EQUIPMENT_SLOT_RANGED
Definition: Player.h:643
std::deque< Mail * > PlayerMails
Definition: Player.h:137
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:745
ArenaTeamInfoType
Definition: Player.h:783
@ ARENA_TEAM_GAMES_WEEK
Definition: Player.h:787
@ ARENA_TEAM_TYPE
Definition: Player.h:785
@ ARENA_TEAM_ID
Definition: Player.h:784
@ ARENA_TEAM_END