TrinityCore
LootHandler.cpp
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#include "WorldSession.h"
19#include "CellImpl.h"
20#include "Common.h"
21#include "Containers.h"
22#include "Corpse.h"
23#include "Creature.h"
24#include "DB2Stores.h"
25#include "GameObject.h"
26#include "GridNotifiersImpl.h"
27#include "Group.h"
28#include "Guild.h"
29#include "Item.h"
30#include "Log.h"
31#include "Loot.h"
32#include "LootItemStorage.h"
33#include "LootPackets.h"
34#include "Object.h"
35#include "ObjectAccessor.h"
36#include "ObjectMgr.h"
37#include "Player.h"
38#include "SpellMgr.h"
39#include "World.h"
40
42{
43public:
44 static float constexpr LootDistance = 30.0f;
45
46 AELootCreatureCheck(Player* looter, ObjectGuid mainLootTarget) : _looter(looter), _mainLootTarget(mainLootTarget) { }
47
48 bool operator()(Creature const* creature) const
49 {
50 return IsValidAELootTarget(creature);
51 }
52
53 bool IsValidLootTarget(Creature const* creature) const
54 {
55 if (creature->IsAlive())
56 return false;
57
58 if (!_looter->IsWithinDist(creature, LootDistance))
59 return false;
60
61 return _looter->isAllowedToLoot(creature);
62 }
63
64 bool IsValidAELootTarget(Creature const* creature) const
65 {
66 if (creature->GetGUID() == _mainLootTarget)
67 return false;
68
69 return IsValidLootTarget(creature);
70 }
71
72private:
75};
76
78{
79 Player* player = GetPlayer();
80 AELootResult aeResult;
81 AELootResult* aeResultPtr = player->GetAELootView().size() > 1 ? &aeResult : nullptr;
82
83 for (WorldPackets::Loot::LootRequest const& req : packet.Loot)
84 {
86 if (!loot)
87 {
89 continue;
90 }
91
92 ObjectGuid lguid = loot->GetOwnerGUID();
93
94 if (lguid.IsGameObject())
95 {
96 GameObject* go = player->GetMap()->GetGameObject(lguid);
97
98 // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
99 if (!go || ((go->GetOwnerGUID() != player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(player)))
100 {
101 player->SendLootRelease(lguid);
102 continue;
103 }
104 }
105 else if (lguid.IsCreatureOrVehicle())
106 {
107 Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
108 if (!creature)
109 {
110 player->SendLootError(req.Object, lguid, LOOT_ERROR_NO_LOOT);
111 continue;
112 }
113
115 {
116 player->SendLootError(req.Object, lguid, LOOT_ERROR_TOO_FAR);
117 continue;
118 }
119 }
120
121 player->StoreLootItem(lguid, req.LootListID, loot, aeResultPtr);
122
123 // If player is removing the last LootItem, delete the empty container.
124 if (loot->isLooted() && lguid.IsItem())
125 player->GetSession()->DoLootRelease(loot);
126 }
127
128 if (aeResultPtr)
129 {
130 for (AELootResult::ResultValue const& resultValue : aeResult)
131 {
132 player->SendNewItem(resultValue.item, resultValue.count, false, false, true, resultValue.dungeonEncounterId);
133 player->UpdateCriteria(CriteriaType::LootItem, resultValue.item->GetEntry(), resultValue.count);
134 player->UpdateCriteria(CriteriaType::GetLootByType, resultValue.item->GetEntry(), resultValue.count, resultValue.lootType);
135 player->UpdateCriteria(CriteriaType::LootAnyItem, resultValue.item->GetEntry(), resultValue.count);
136 }
137 }
138
140}
141
143{
144 Player* player = GetPlayer();
145 std::vector<Loot*> forceLootRelease;
146 for (std::pair<ObjectGuid const, Loot*> const& lootView : player->GetAELootView())
147 {
148 Loot* loot = lootView.second;
149 ObjectGuid guid = loot->GetOwnerGUID();
150 bool shareMoney = loot->loot_type == LOOT_CORPSE;
151
152 loot->NotifyMoneyRemoved(player->GetMap());
153 if (shareMoney && player->GetGroup()) //item, pickpocket and players can be looted only single player
154 {
155 Group* group = player->GetGroup();
156
157 std::vector<Player*> playersNear;
158 for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
159 {
160 Player* member = itr->GetSource();
161 if (!member)
162 continue;
163
164 if (!loot->HasAllowedLooter(member->GetGUID()))
165 continue;
166
167 if (player->IsAtGroupRewardDistance(member))
168 playersNear.push_back(member);
169 }
170
171 uint64 goldPerPlayer = uint64(loot->gold / playersNear.size());
172
173 for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
174 {
175 uint64 goldMod = CalculatePct(goldPerPlayer, (*i)->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MONEY_GAIN, 1));
176
177 (*i)->ModifyMoney(goldPerPlayer + goldMod);
178 (*i)->UpdateCriteria(CriteriaType::MoneyLootedFromCreatures, goldPerPlayer);
179
181 packet.Money = goldPerPlayer;
182 packet.MoneyMod = goldMod;
183 packet.SoleLooter = playersNear.size() <= 1 ? true : false;
184 (*i)->SendDirectMessage(packet.Write());
185 }
186 }
187 else
188 {
190
191 player->ModifyMoney(loot->gold + goldMod);
193
195 packet.Money = loot->gold;
196 packet.MoneyMod = goldMod;
197 packet.SoleLooter = true; // "You loot..."
198 SendPacket(packet.Write());
199 }
200
201 loot->LootMoney();
202
203 // Delete the money loot record from the DB
204 if (loot->loot_type == LOOT_ITEM)
205 sLootItemStorage->RemoveStoredMoneyForContainer(guid.GetCounter());
206
207 // Delete container if empty
208 if (loot->isLooted() && guid.IsItem())
209 forceLootRelease.push_back(loot);
210 }
211
212 for (Loot* loot : forceLootRelease)
213 player->GetSession()->DoLootRelease(loot);
214}
215
217{
218 // Check possible cheat
219 if (!GetPlayer()->IsAlive() || !packet.Unit.IsCreatureOrVehicle())
220 return;
221
222 Creature* lootTarget = ObjectAccessor::GetCreature(*GetPlayer(), packet.Unit);
223 if (!lootTarget)
224 return;
225
226 AELootCreatureCheck check(_player, packet.Unit);
227 if (!check.IsValidLootTarget(lootTarget))
228 return;
229
230 // interrupt cast
231 if (GetPlayer()->IsNonMeleeSpellCast(false))
233
235
236 bool const aeLootEnabled = sWorld->getBoolConfig(CONFIG_ENABLE_AE_LOOT);
237 std::vector<Creature*> corpses;
238 if (aeLootEnabled)
239 {
242 }
243
244 if (!corpses.empty())
246
247 GetPlayer()->SendLoot(*lootTarget->GetLootForPlayer(GetPlayer()));
248
249 if (!corpses.empty())
250 {
251 // main target
253
254 for (Creature* creature : corpses)
255 {
256 GetPlayer()->SendLoot(*creature->GetLootForPlayer(GetPlayer()), true);
258 }
259 }
260}
261
263{
264 // cheaters can modify lguid to prevent correct apply loot release code and re-loot
265 // use internal stored guid
266 if (Loot* loot = GetPlayer()->GetLootByWorldObjectGUID(packet.Unit))
267 DoLootRelease(loot);
268}
269
271{
272 ObjectGuid lguid = loot->GetOwnerGUID();
273 Player *player = GetPlayer();
274
275 if (player->GetLootGUID() == lguid)
277
278 //Player is not looking at loot list, he doesn't need to see updates on the loot list
279 loot->RemoveLooter(player->GetGUID());
280 player->SendLootRelease(lguid);
281 player->m_AELootView.erase(loot->GetGUID());
282
283 if (player->GetAELootView().empty())
285
286 if (!player->IsInWorld())
287 return;
288
289 if (lguid.IsGameObject())
290 {
291 GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid);
292
293 // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
294 if (!go || ((go->GetOwnerGUID() != player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(player)))
295 return;
296
298 {
300 {
302 }
303 else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE)
304 { // The fishing hole used once more
305 go->AddUse(); // if the max usage is reached, will be despawned in next tick
306 if (go->GetUseCount() >= go->GetGOValue()->FishingHole.MaxOpens)
308 else
310 }
311 else if (go->GetGoType() != GAMEOBJECT_TYPE_GATHERING_NODE && go->IsFullyLooted())
313
314 go->OnLootRelease(player);
315 }
316 else
317 {
318 // not fully looted object
319 go->SetLootState(GO_ACTIVATED, player);
320 }
321 }
322 else if (lguid.IsCorpse()) // ONLY remove insignia at BG
323 {
324 Corpse* corpse = ObjectAccessor::GetCorpse(*player, lguid);
325 if (!corpse || !corpse->IsWithinDistInMap(player, INTERACTION_DISTANCE))
326 return;
327
328 if (loot->isLooted())
329 {
330 corpse->m_loot = nullptr;
332 }
333 }
334 else if (lguid.IsItem())
335 {
336 Item* pItem = player->GetItemByGuid(lguid);
337 if (!pItem)
338 return;
339
340 ItemTemplate const* proto = pItem->GetTemplate();
341
342 // destroy only 5 items from stack in case prospecting and milling
343 if (loot->loot_type == LOOT_PROSPECTING || loot->loot_type == LOOT_MILLING)
344 {
345 pItem->m_lootGenerated = false;
346 pItem->m_loot = nullptr;
347
348 uint32 count = pItem->GetCount();
349
350 // >=5 checked in spell code, but will work for cheating cases also with removing from another stacks.
351 if (count > 5)
352 count = 5;
353
354 player->DestroyItemCount(pItem, count, true);
355 }
356 else
357 {
358 // Only delete item if no loot or money (unlooted loot is saved to db) or if it isn't an openable item
359 if (loot->isLooted() || !proto->HasFlag(ITEM_FLAG_HAS_LOOT))
360 player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
361 }
362 return; // item can be looted only single player
363 }
364 else
365 {
366 Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
367 if (!creature)
368 return;
369
370 if (loot->isLooted())
371 {
372 if (creature->IsFullyLooted())
373 {
375
376 // skip pickpocketing loot for speed, skinning timer reduction is no-op in fact
377 if (!creature->IsAlive())
378 creature->AllLootRemovedFromCorpse();
379 }
380 }
381 else
382 {
383 // if the round robin player release, reset it.
384 if (player->GetGUID() == loot->roundRobinPlayer)
385 {
386 loot->roundRobinPlayer.Clear();
387 loot->NotifyLootList(creature->GetMap());
388 }
389 }
390 // force dynflag update to update looter and lootable info
392 }
393}
394
396{
397 std::unordered_map<ObjectGuid, Loot*> lootView = _player->GetAELootView();
398 for (auto const& [lootGuid, loot] : lootView)
399 DoLootRelease(loot);
400}
401
403{
404 AELootResult aeResult;
405
407 {
409 return;
410 }
411
412 // player on other map
413 Player* target = ObjectAccessor::GetPlayer(*_player, masterLootItem.Target);
414 if (!target)
415 {
417 return;
418 }
419
420 TC_LOG_DEBUG("network", "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [{}].", target->GetName());
421
422 for (WorldPackets::Loot::LootRequest const& req : masterLootItem.Loot)
423 {
425
426 if (!loot || loot->GetLootMethod() != MASTER_LOOT)
427 return;
428
429 if (!_player->IsInRaidWith(target) || !_player->IsInMap(target))
430 {
432 TC_LOG_INFO("entities.player.cheat", "MasterLootItem: Player {} tried to give an item to ineligible player {} !", GetPlayer()->GetName(), target->GetName());
433 return;
434 }
435
436 if (!loot->HasAllowedLooter(masterLootItem.Target))
437 {
439 return;
440 }
441
442 if (req.LootListID >= loot->items.size())
443 {
444 TC_LOG_DEBUG("loot", "MasterLootItem: Player {} might be using a hack! (slot {}, size {})",
445 GetPlayer()->GetName(), req.LootListID, loot->items.size());
446 return;
447 }
448
449 LootItem& item = loot->items[req.LootListID];
450
451 ItemPosCountVec dest;
452 InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count);
453 if (!item.HasAllowedLooter(target->GetGUID()))
455 if (msg != EQUIP_ERR_OK)
456 {
457 if (msg == EQUIP_ERR_ITEM_MAX_COUNT)
459 else if (msg == EQUIP_ERR_INV_FULL)
461 else
463 return;
464 }
465
466 // now move item from loot to target inventory
467 if (Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, &item.BonusListIDs))
468 aeResult.Add(newitem, item.count, loot->loot_type, loot->GetDungeonEncounterId());
469 else
470 target->ApplyItemLootedSpell(sObjectMgr->GetItemTemplate(item.itemid));
471
472 // mark as looted
473 item.count = 0;
474 item.is_looted = true;
475
476 loot->NotifyItemRemoved(req.LootListID, GetPlayer()->GetMap());
477 --loot->unlootedCount;
478 }
479
480 for (AELootResult::ResultValue const& resultValue : aeResult)
481 {
482 target->SendNewItem(resultValue.item, resultValue.count, false, false, true);
483 target->UpdateCriteria(CriteriaType::LootItem, resultValue.item->GetEntry(), resultValue.count);
484 target->UpdateCriteria(CriteriaType::GetLootByType, resultValue.item->GetEntry(), resultValue.count, resultValue.lootType);
485 target->UpdateCriteria(CriteriaType::LootAnyItem, resultValue.item->GetEntry(), resultValue.count);
486 }
487}
488
490{
491 LootRoll* lootRoll = GetPlayer()->GetLootRoll(packet.LootObj, packet.LootListID);
492 if (!lootRoll)
493 return;
494
495 lootRoll->PlayerVote(GetPlayer(), RollVote(packet.RollType));
496}
497
499{
500 if (packet.SpecID)
501 {
502 if (ChrSpecializationEntry const* chrSpec = sChrSpecializationStore.LookupEntry(packet.SpecID))
503 if (chrSpec->ClassID == GetPlayer()->GetClass())
504 GetPlayer()->SetLootSpecId(packet.SpecID);
505 }
506 else
508}
DB2Storage< ChrSpecializationEntry > sChrSpecializationStore("ChrSpecialization.db2", &ChrSpecializationLoadInfo::Instance)
@ MoneyLootedFromCreatures
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
@ GO_ACTIVATED
Definition: GameObject.h:158
@ GO_READY
Definition: GameObject.h:157
@ GO_JUST_DEACTIVATED
Definition: GameObject.h:159
InventoryResult
Definition: ItemDefines.h:25
@ EQUIP_ERR_CANT_EQUIP_EVER
Definition: ItemDefines.h:36
@ EQUIP_ERR_OK
Definition: ItemDefines.h:26
@ EQUIP_ERR_INV_FULL
Definition: ItemDefines.h:77
@ EQUIP_ERR_ITEM_MAX_COUNT
Definition: ItemDefines.h:43
@ ITEM_FLAG_HAS_LOOT
Definition: ItemTemplate.h:178
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:159
#define sLootItemStorage
@ LOOT_MILLING
Definition: Loot.h:115
@ LOOT_CORPSE
Definition: Loot.h:101
@ LOOT_ITEM
Definition: Loot.h:105
@ LOOT_PROSPECTING
Definition: Loot.h:114
@ MASTER_LOOT
Definition: Loot.h:91
@ LOOT_ERROR_TOO_FAR
Definition: Loot.h:139
@ LOOT_ERROR_NO_LOOT
Definition: Loot.h:151
@ LOOT_ERROR_MASTER_OTHER
Definition: Loot.h:148
@ LOOT_ERROR_MASTER_INV_FULL
Definition: Loot.h:146
@ LOOT_ERROR_MASTER_UNIQUE_ITEM
Definition: Loot.h:147
@ LOOT_ERROR_DIDNT_KILL
Definition: Loot.h:138
@ LOOT_ERROR_PLAYER_NOT_FOUND
Definition: Loot.h:144
RollVote
Definition: Loot.h:64
#define INTERACTION_DISTANCE
Definition: ObjectDefines.h:24
#define sObjectMgr
Definition: ObjectMgr.h:1946
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:750
@ GAMEOBJECT_TYPE_FISHINGHOLE
@ GAMEOBJECT_TYPE_FISHINGNODE
@ GAMEOBJECT_TYPE_GATHERING_NODE
@ CORPSE_DYNFLAG_LOOTABLE
@ UNIT_DYNFLAG_LOOTABLE
@ SPELL_AURA_MOD_MONEY_GAIN
@ PROC_SPELL_PHASE_NONE
Definition: SpellMgr.h:262
@ PROC_SPELL_TYPE_MASK_ALL
Definition: SpellMgr.h:255
@ PROC_FLAG_LOOTED
Definition: SpellMgr.h:186
@ PROC_FLAG_NONE
Definition: SpellMgr.h:135
@ PROC_HIT_NONE
Definition: SpellMgr.h:273
@ UNIT_FLAG_LOOTING
Definition: UnitDefines.h:154
@ NULL_BAG
Definition: Unit.h:62
@ NULL_SLOT
Definition: Unit.h:63
T CalculatePct(T base, U pct)
Definition: Util.h:72
bool IsValidLootTarget(Creature const *creature) const
Definition: LootHandler.cpp:53
AELootCreatureCheck(Player *looter, ObjectGuid mainLootTarget)
Definition: LootHandler.cpp:46
ObjectGuid _mainLootTarget
Definition: LootHandler.cpp:74
bool IsValidAELootTarget(Creature const *creature) const
Definition: LootHandler.cpp:64
bool operator()(Creature const *creature) const
Definition: LootHandler.cpp:48
static float constexpr LootDistance
Definition: LootHandler.cpp:44
void Add(Item *item, uint8 count, LootType lootType, uint32 dungeonEncounterId)
Definition: Loot.cpp:1060
Definition: Corpse.h:53
void RemoveCorpseDynamicFlag(CorpseDynFlags dynamicFlags)
Definition: Corpse.h:94
std::unique_ptr< Loot > m_loot
Definition: Corpse.h:131
void AllLootRemovedFromCorpse()
Definition: Creature.cpp:2958
Loot * GetLootForPlayer(Player const *player) const override
Definition: Creature.cpp:1386
bool IsFullyLooted() const
Definition: Creature.cpp:1397
ObjectGuid GetOwnerGUID() const override
Definition: GameObject.h:242
bool IsWithinDistInMap(Player const *player) const
void AddUse()
Definition: GameObject.h:320
bool IsFullyLooted() const
GameObjectValue const * GetGOValue() const
Definition: GameObject.h:206
void OnLootRelease(Player *looter)
void SetLootState(LootState s, Unit *unit=nullptr)
GameobjectTypes GetGoType() const
Definition: GameObject.h:279
uint32 GetUseCount() const
Definition: GameObject.h:322
GroupReference * next()
Definition: Group.h:197
ObjectGuid GetMasterLooterGuid() const
Definition: Group.cpp:1685
GroupReference * GetFirstMember()
Definition: Group.h:325
Definition: Item.h:170
uint8 GetSlot() const
Definition: Item.h:280
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:1141
std::unique_ptr< Loot > m_loot
Definition: Item.h:317
bool m_lootGenerated
Definition: Item.h:318
uint32 GetCount() const
Definition: Item.h:273
uint8 GetBagSlot() const
Definition: Item.cpp:1239
Definition: Loot.h:244
bool PlayerVote(Player *player, RollVote vote)
Definition: Loot.cpp:455
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3489
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
LowType GetCounter() const
Definition: ObjectGuid.h:293
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
bool IsCorpse() const
Definition: ObjectGuid.h:331
bool IsItem() const
Definition: ObjectGuid.h:328
bool IsGameObject() const
Definition: ObjectGuid.h:329
bool IsCreatureOrVehicle() const
Definition: ObjectGuid.h:324
void Clear()
Definition: ObjectGuid.h:286
bool IsInWorld() const
Definition: Object.h:154
UF::UpdateField< UF::ObjectData, 0, TYPEID_OBJECT > m_objectData
Definition: Object.h:267
UF::UpdateFieldHolder m_values
Definition: Object.h:266
void RemoveDynamicFlag(uint32 flag)
Definition: Object.h:170
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
void ForceUpdateFieldChange(UF::UpdateFieldSetter< T > const &)
Definition: Object.h:270
void SendLootError(ObjectGuid const &lootObj, ObjectGuid const &owner, LootError error) const
Definition: Player.cpp:9148
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 itemId, bool update, ItemRandomBonusListId randomBonusListId=0, GuidSet const &allowedLooters=GuidSet(), ItemContext context=ItemContext::NONE, std::vector< int32 > const *bonusListIDs=nullptr, bool addToCollection=true)
Definition: Player.cpp:11537
bool ModifyMoney(int64 amount, bool sendError=true)
Definition: Player.cpp:24098
void ApplyItemLootedSpell(Item *item, bool apply)
Definition: Player.cpp:8869
void SendLootRelease(ObjectGuid guid) const
Definition: Player.cpp:9106
std::unordered_map< ObjectGuid, Loot * > m_AELootView
Definition: Player.h:3218
LootRoll * GetLootRoll(ObjectGuid const &lootObjectGuid, uint8 lootListId)
Definition: Player.cpp:9046
bool isAllowedToLoot(Creature const *creature) const
Definition: Player.cpp:18565
ObjectGuid const & GetLootGUID() const
Definition: Player.h:2091
void SetLootGUID(ObjectGuid const &guid)
Definition: Player.h:2092
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition: Player.cpp:25673
WorldSession * GetSession() const
Definition: Player.h:2101
void DestroyItem(uint8 bag, uint8 slot, bool update)
Definition: Player.cpp:12180
void SendLoot(Loot &loot, bool aeLooting=false)
Definition: Player.cpp:9119
void UpdateCriteria(CriteriaType type, uint64 miscValue1=0, uint64 miscValue2=0, uint64 miscValue3=0, WorldObject *ref=nullptr)
Definition: Player.cpp:26767
uint32 DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check=false)
Definition: Player.cpp:12281
std::unordered_map< ObjectGuid, Loot * > const & GetAELootView() const
Definition: Player.h:2094
void StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot *loot, AELootResult *aeResult=nullptr)
Definition: Player.cpp:26403
Group * GetGroup(Optional< uint8 > partyIndex)
Definition: Player.h:2606
void SetLootSpecId(uint32 id)
Definition: Player.h:1830
Item * GetItemByGuid(ObjectGuid guid) const
Definition: Player.cpp:9566
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition: Player.cpp:10032
void SendNewItem(Item *item, uint32 quantity, bool received, bool created, bool broadcast=false, uint32 dungeonEncounterId=0)
Definition: Player.cpp:13990
MutableFieldReference< T, false > ModifyValue(UpdateField< T, BlockBit, Bit >(Derived::*field))
Definition: UpdateField.h:683
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
bool IsAlive() const
Definition: Unit.h:1164
void RemoveAurasWithInterruptFlags(InterruptFlags flag, SpellInfo const *source=nullptr)
Definition: Unit.cpp:4101
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:11546
int32 GetTotalAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const
Definition: Unit.cpp:4989
static void ProcSkillsAndAuras(Unit *actor, Unit *actionTarget, ProcFlagsInit const &typeMaskActor, ProcFlagsInit const &typeMaskActionTarget, ProcFlagsSpellType spellTypeMask, ProcFlagsSpellPhase spellPhaseMask, ProcFlagsHit hitMask, Spell *spell, DamageInfo *damageInfo, HealInfo *healInfo)
Definition: Unit.cpp:5407
void RemoveUnitFlag(UnitFlags flags)
Definition: Unit.h:834
Map * GetMap() const
Definition: Object.h:624
std::string const & GetName() const
Definition: Object.h:555
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1147
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1142
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1115
WorldPacket const * Write() override
Array< LootRequest, 1000 > Loot
Definition: LootPackets.h:94
WorldPacket const * Write() override
Array< LootRequest, 1000 > Loot
Definition: LootPackets.h:105
void HandleLootMasterGiveOpcode(WorldPackets::Loot::MasterLootItem &masterLootItem)
void HandleLootReleaseOpcode(WorldPackets::Loot::LootRelease &packet)
void HandleLootMoneyOpcode(WorldPackets::Loot::LootMoney &packet)
void HandleLootOpcode(WorldPackets::Loot::LootUnit &packet)
void DoLootRelease(Loot *loot)
Player * GetPlayer() const
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Player * _player
void HandleAutostoreLootItemOpcode(WorldPackets::Loot::LootItem &packet)
Definition: LootHandler.cpp:77
void DoLootReleaseAll()
void HandleSetLootSpecialization(WorldPackets::Loot::SetLootSpecialization &packet)
void HandleLootRoll(WorldPackets::Loot::LootRoll &packet)
#define sWorld
Definition: World.h:931
@ CONFIG_ENABLE_AE_LOOT
Definition: World.h:200
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
auto MapGetValuePtr(M &map, typename M::key_type const &key)
Definition: MapUtils.h:29
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
bool HasFlag(ItemFlags flag) const
Definition: ItemTemplate.h:871
Definition: Loot.h:176
bool HasAllowedLooter(ObjectGuid const &looter) const
Definition: Loot.cpp:136
std::vector< int32 > BonusListIDs
Definition: Loot.h:180
uint32 itemid
Definition: Loot.h:177
uint8 count
Definition: Loot.h:185
bool is_looted
Definition: Loot.h:186
ItemRandomBonusListId randomBonusListId
Definition: Loot.h:179
ItemContext context
Definition: Loot.h:181
GuidSet const & GetAllowedLooters() const
Definition: Loot.h:213
Definition: Loot.h:281
void NotifyLootList(Map const *map) const
Definition: Loot.cpp:638
bool isLooted() const
Definition: Loot.h:307
void LootMoney()
Definition: Loot.cpp:903
void NotifyMoneyRemoved(Map const *map)
Definition: Loot.cpp:681
void NotifyItemRemoved(uint8 lootListId, Map const *map)
Definition: Loot.cpp:658
uint8 unlootedCount
Definition: Loot.h:286
ObjectGuid roundRobinPlayer
Definition: Loot.h:287
ObjectGuid const & GetOwnerGUID() const
Definition: Loot.h:299
uint32 gold
Definition: Loot.h:285
ObjectGuid const & GetGUID() const
Definition: Loot.h:298
std::vector< LootItem > items
Definition: Loot.h:284
void RemoveLooter(ObjectGuid GUID)
Definition: Loot.h:315
uint32 GetDungeonEncounterId() const
Definition: Loot.h:304
LootMethod GetLootMethod() const
Definition: Loot.h:302
LootType loot_type
Definition: Loot.h:288
bool HasAllowedLooter(ObjectGuid const &looter) const
Definition: Loot.cpp:740
UpdateField< uint32, 0, 2 > DynamicFlags
Definition: UpdateFields.h:53
struct GameObjectValue::@209 FishingHole