AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
LootItem Struct Reference

#include "LootMgr.h"

Public Member Functions

 LootItem (LootStoreItem const &li)
 
 LootItem ()=default
 
bool AllowedForPlayer (Player const *player, ObjectGuid source) const
 
void AddAllowedLooter (Player const *player)
 
const AllowedLooterSetGetAllowedLooters () const
 

Public Attributes

uint32 itemid
 
uint32 itemIndex
 
uint32 randomSuffix
 
int32 randomPropertyId
 
ConditionList conditions
 
AllowedLooterSet allowedGUIDs
 
ObjectGuid rollWinnerGUID
 
uint8 count: 8
 
bool is_looted: 1
 
bool is_blocked: 1
 
bool freeforall: 1
 
bool is_underthreshold: 1
 
bool is_counted: 1
 
bool needs_quest: 1
 
bool follow_loot_rules: 1
 
uint8 groupid: 7
 

Detailed Description

Constructor & Destructor Documentation

◆ LootItem() [1/2]

LootItem::LootItem ( LootStoreItem const &  li)
explicit
393{
394 itemid = li.itemid;
395 itemIndex = 0;
396 conditions = li.conditions;
397
398 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemid);
399 freeforall = proto && proto->HasFlag(ITEM_FLAG_MULTI_DROP);
401
402 needs_quest = li.needs_quest;
403
406 count = 0;
407 is_looted = 0;
408 is_blocked = 0;
410 is_counted = 0;
412 groupid = li.groupid;
413}
#define sObjectMgr
Definition: ObjectMgr.h:1635
uint32 GenerateEnchSuffixFactor(uint32 item_id)
Definition: ItemEnchantmentMgr.cpp:124
@ ITEM_FLAG_MULTI_DROP
Definition: ItemTemplate.h:158
@ ITEM_FLAGS_CU_FOLLOW_LOOT_RULES
Definition: ItemTemplate.h:221
static int32 GenerateItemRandomPropertyId(uint32 item_id)
Definition: Item.cpp:622
Definition: ItemTemplate.h:619
bool HasFlagCu(ItemFlagsCustom flag) const
Definition: ItemTemplate.h:829
bool HasFlag(ItemFlags flag) const
Definition: ItemTemplate.h:827
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
uint32 itemid
Definition: LootMgr.h:155
bool is_blocked
Definition: LootMgr.h:164
uint8 groupid
Definition: LootMgr.h:170
ObjectGuid rollWinnerGUID
Definition: LootMgr.h:161
bool needs_quest
Definition: LootMgr.h:168
bool follow_loot_rules
Definition: LootMgr.h:169
bool is_underthreshold
Definition: LootMgr.h:166
int32 randomPropertyId
Definition: LootMgr.h:158
uint32 itemIndex
Definition: LootMgr.h:156
uint8 count
Definition: LootMgr.h:162
bool is_looted
Definition: LootMgr.h:163
ConditionList conditions
Definition: LootMgr.h:159
bool freeforall
Definition: LootMgr.h:165
uint32 randomSuffix
Definition: LootMgr.h:157
bool is_counted
Definition: LootMgr.h:167

References LootStoreItem::conditions, conditions, count, ObjectGuid::Empty, follow_loot_rules, freeforall, GenerateEnchSuffixFactor(), Item::GenerateItemRandomPropertyId(), LootStoreItem::groupid, groupid, ItemTemplate::HasFlag(), ItemTemplate::HasFlagCu(), is_blocked, is_counted, is_looted, is_underthreshold, ITEM_FLAG_MULTI_DROP, ITEM_FLAGS_CU_FOLLOW_LOOT_RULES, LootStoreItem::itemid, itemid, itemIndex, LootStoreItem::needs_quest, needs_quest, randomPropertyId, randomSuffix, rollWinnerGUID, and sObjectMgr.

◆ LootItem() [2/2]

LootItem::LootItem ( )
default

Member Function Documentation

◆ AddAllowedLooter()

void LootItem::AddAllowedLooter ( Player const *  player)
502{
503 allowedGUIDs.insert(player->GetGUID());
504}
AllowedLooterSet allowedGUIDs
Definition: LootMgr.h:160

References allowedGUIDs, and Object::GetGUID().

Referenced by Loot::FillNonQuestNonFFAConditionalLoot().

◆ AllowedForPlayer()

bool LootItem::AllowedForPlayer ( Player const *  player,
ObjectGuid  source 
) const
417{
418 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(itemid);
419 if (!pProto)
420 {
421 return false;
422 }
423
425 {
426 return false;
427 }
428
429 bool isMasterLooter = player->GetGroup() && player->GetGroup()->GetMasterLooterGuid() == player->GetGUID();
430 bool itemVisibleForMasterLooter = !needs_quest && (!follow_loot_rules || !is_underthreshold);
431
432 // DB conditions check
433 if (!sConditionMgr->IsObjectMeetToConditions(const_cast<Player*>(player), conditions))
434 {
435 // Master Looter can see conditioned recipes
436 if (isMasterLooter && itemVisibleForMasterLooter)
437 {
438 if (pProto->HasFlag(ITEM_FLAG_HIDE_UNUSABLE_RECIPE) || (pProto->Class == ITEM_CLASS_RECIPE && pProto->Bonding == BIND_WHEN_PICKED_UP && pProto->Spells[1].SpellId != 0))
439 {
440 return true;
441 }
442 }
443
444 return false;
445 }
446
447 // not show loot for not own team
448 if (pProto->HasFlag2(ITEM_FLAG2_FACTION_HORDE) && player->GetTeamId(true) != TEAM_HORDE)
449 {
450 return false;
451 }
452
453 if (pProto->HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE) && player->GetTeamId(true) != TEAM_ALLIANCE)
454 {
455 return false;
456 }
457
458 // Master looter can see all items even if the character can't loot them
459 if (isMasterLooter && itemVisibleForMasterLooter)
460 {
461 return true;
462 }
463
464 // Don't allow loot for players without profession or those who already know the recipe
465 if (pProto->HasFlag(ITEM_FLAG_HIDE_UNUSABLE_RECIPE) && (!player->HasSkill(pProto->RequiredSkill) || player->HasSpell(pProto->Spells[1].SpellId)))
466 {
467 return false;
468 }
469
470 // Don't allow to loot soulbound recipes that the player has already learned
471 if (pProto->Class == ITEM_CLASS_RECIPE && pProto->Bonding == BIND_WHEN_PICKED_UP && pProto->Spells[1].SpellId != 0 && player->HasSpell(pProto->Spells[1].SpellId))
472 {
473 return false;
474 }
475
476 // check quest requirements
478 {
479 // Don't drop quest items if the player is missing the relevant quest
480 if (needs_quest && !player->HasQuestForItem(itemid))
481 return false;
482
483 // for items that start quests
484 if (pProto->StartQuest)
485 {
486 // Don't drop the item if the player has already finished the quest OR player already has the item in their inventory, and that item is unique OR the player has not finished a prerequisite quest
487 uint32 prevQuestId = sObjectMgr->GetQuestTemplate(pProto->StartQuest) ? sObjectMgr->GetQuestTemplate(pProto->StartQuest)->GetPrevQuestId() : 0;
488 if (player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE || (player->HasItemCount(itemid, pProto->MaxCount) && pProto->MaxCount) || (prevQuestId && !player->GetQuestRewardStatus(prevQuestId)))
489 return false;
490 }
491 }
492
493 if (!sScriptMgr->OnAllowedForPlayerLootCheck(player, source))
494 {
495 return false;
496 }
497
498 return true;
499}
std::uint32_t uint32
Definition: Define.h:107
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
@ QUEST_STATUS_NONE
Definition: QuestDef.h:100
@ ITEM_FLAG2_FACTION_HORDE
Definition: ItemTemplate.h:183
@ ITEM_FLAG2_FACTION_ALLIANCE
Definition: ItemTemplate.h:184
@ ITEM_FLAG_HIDE_UNUSABLE_RECIPE
Definition: ItemTemplate.h:172
@ BIND_WHEN_PICKED_UP
Definition: ItemTemplate.h:96
@ ITEM_FLAGS_CU_IGNORE_QUEST_STATUS
Definition: ItemTemplate.h:220
@ ITEM_CLASS_RECIPE
Definition: ItemTemplate.h:300
@ DISABLE_TYPE_LOOT
Definition: DisableMgr.h:37
#define sConditionMgr
Definition: ConditionMgr.h:290
#define sScriptMgr
Definition: ScriptMgr.h:709
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:307
int32 SpellId
Definition: ItemTemplate.h:591
uint32 RequiredSkill
Definition: ItemTemplate.h:637
int32 MaxCount
Definition: ItemTemplate.h:644
_Spell Spells[MAX_ITEM_PROTO_SPELLS]
Definition: ItemTemplate.h:662
bool HasFlag2(ItemFlags2 flag) const
Definition: ItemTemplate.h:828
uint32 Class
Definition: ItemTemplate.h:621
uint32 StartQuest
Definition: ItemTemplate.h:668
uint32 Bonding
Definition: ItemTemplate.h:663
Definition: Player.h:1081

References BIND_WHEN_PICKED_UP, ItemTemplate::Bonding, ItemTemplate::Class, conditions, DISABLE_TYPE_LOOT, follow_loot_rules, Player::GetGroup(), Object::GetGUID(), Group::GetMasterLooterGuid(), Player::GetQuestRewardStatus(), Player::GetQuestStatus(), Player::GetTeamId(), ItemTemplate::HasFlag(), ItemTemplate::HasFlag2(), ItemTemplate::HasFlagCu(), Player::HasItemCount(), Player::HasQuestForItem(), Player::HasSkill(), Player::HasSpell(), is_underthreshold, DisableMgr::IsDisabledFor(), ITEM_CLASS_RECIPE, ITEM_FLAG2_FACTION_ALLIANCE, ITEM_FLAG2_FACTION_HORDE, ITEM_FLAG_HIDE_UNUSABLE_RECIPE, ITEM_FLAGS_CU_IGNORE_QUEST_STATUS, itemid, ItemTemplate::MaxCount, needs_quest, QUEST_STATUS_NONE, ItemTemplate::RequiredSkill, sConditionMgr, sObjectMgr, _Spell::SpellId, ItemTemplate::Spells, sScriptMgr, ItemTemplate::StartQuest, TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by Loot::AddItem(), CanRollOnItem(), Loot::FillFFALoot(), Loot::FillNonQuestNonFFAConditionalLoot(), Loot::FillNotNormalLootFor(), Loot::FillQuestLoot(), WorldSession::HandleLootMasterGiveOpcode(), Loot::LootItemInSlot(), and Player::StoreLootItem().

◆ GetAllowedLooters()

const AllowedLooterSet & LootItem::GetAllowedLooters ( ) const
inline

Member Data Documentation

◆ allowedGUIDs

AllowedLooterSet LootItem::allowedGUIDs

◆ conditions

◆ count

◆ follow_loot_rules

bool LootItem::follow_loot_rules

◆ freeforall

◆ groupid

uint8 LootItem::groupid

◆ is_blocked

◆ is_counted

◆ is_looted

◆ is_underthreshold

bool LootItem::is_underthreshold

◆ itemid

◆ itemIndex

◆ needs_quest

bool LootItem::needs_quest

◆ randomPropertyId

◆ randomSuffix

uint32 LootItem::randomSuffix

◆ rollWinnerGUID