AzeorthCore 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
385{
386 itemid = li.itemid;
387 itemIndex = 0;
388 conditions = li.conditions;
389
390 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemid);
391 freeforall = proto && (proto->Flags & ITEM_FLAG_MULTI_DROP);
393
394 needs_quest = li.needs_quest;
395
398 count = 0;
399 is_looted = 0;
400 is_blocked = 0;
402 is_counted = 0;
404 groupid = li.groupid;
405}
uint32 GenerateEnchSuffixFactor(uint32 item_id)
Definition: ItemEnchantmentMgr.cpp:122
@ ITEM_FLAG_MULTI_DROP
Definition: ItemTemplate.h:159
@ ITEM_FLAGS_CU_FOLLOW_LOOT_RULES
Definition: ItemTemplate.h:230
#define sObjectMgr
Definition: ObjectMgr.h:1606
static int32 GenerateItemRandomPropertyId(uint32 item_id)
Definition: Item.cpp:624
Definition: ItemTemplate.h:628
uint32 Flags
Definition: ItemTemplate.h:636
uint32 FlagsCu
Definition: ItemTemplate.h:703
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
uint32 itemid
Definition: LootMgr.h:156
bool is_blocked
Definition: LootMgr.h:165
uint8 groupid
Definition: LootMgr.h:171
ObjectGuid rollWinnerGUID
Definition: LootMgr.h:162
bool needs_quest
Definition: LootMgr.h:169
bool follow_loot_rules
Definition: LootMgr.h:170
bool is_underthreshold
Definition: LootMgr.h:167
int32 randomPropertyId
Definition: LootMgr.h:159
uint32 itemIndex
Definition: LootMgr.h:157
uint8 count
Definition: LootMgr.h:163
bool is_looted
Definition: LootMgr.h:164
ConditionList conditions
Definition: LootMgr.h:160
bool freeforall
Definition: LootMgr.h:166
uint32 randomSuffix
Definition: LootMgr.h:158
bool is_counted
Definition: LootMgr.h:168

References LootStoreItem::conditions, conditions, count, ObjectGuid::Empty, ItemTemplate::Flags, ItemTemplate::FlagsCu, follow_loot_rules, freeforall, GenerateEnchSuffixFactor(), Item::GenerateItemRandomPropertyId(), LootStoreItem::groupid, groupid, 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)
477{
478 allowedGUIDs.insert(player->GetGUID());
479}
AllowedLooterSet allowedGUIDs
Definition: LootMgr.h:161

References allowedGUIDs, and Object::GetGUID().

Referenced by Loot::FillNonQuestNonFFAConditionalLoot().

◆ AllowedForPlayer()

bool LootItem::AllowedForPlayer ( Player const *  player,
ObjectGuid  source 
) const
409{
410 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(itemid);
411 if (!pProto)
412 {
413 return false;
414 }
415
416 bool isMasterLooter = player->GetGroup() && player->GetGroup()->GetMasterLooterGuid() == player->GetGUID();
417
418 // DB conditions check
419 if (!sConditionMgr->IsObjectMeetToConditions(const_cast<Player*>(player), conditions))
420 {
421 // Master Looter can see conditioned recipes
422 if (isMasterLooter && follow_loot_rules && !is_underthreshold)
423 {
424 if ((pProto->Flags & ITEM_FLAG_HIDE_UNUSABLE_RECIPE) || (pProto->Class == ITEM_CLASS_RECIPE && pProto->Bonding == BIND_WHEN_PICKED_UP && pProto->Spells[1].SpellId != 0))
425 {
426 return true;
427 }
428 }
429
430 return false;
431 }
432
433 // not show loot for not own team
434 if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && player->GetTeamId(true) != TEAM_HORDE)
435 {
436 return false;
437 }
438
439 if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && player->GetTeamId(true) != TEAM_ALLIANCE)
440 {
441 return false;
442 }
443
444 // Master looter can see all items even if the character can't loot them
445 if (isMasterLooter && follow_loot_rules && !is_underthreshold)
446 {
447 return true;
448 }
449
450 // Don't allow loot for players without profession or those who already know the recipe
451 if ((pProto->Flags & ITEM_FLAG_HIDE_UNUSABLE_RECIPE) && (!player->HasSkill(pProto->RequiredSkill) || player->HasSpell(pProto->Spells[1].SpellId)))
452 {
453 return false;
454 }
455
456 // Don't allow to loot soulbound recipes that the player has already learned
457 if (pProto->Class == ITEM_CLASS_RECIPE && pProto->Bonding == BIND_WHEN_PICKED_UP && pProto->Spells[1].SpellId != 0 && player->HasSpell(pProto->Spells[1].SpellId))
458 {
459 return false;
460 }
461
462 // check quest requirements
463 if (!(pProto->FlagsCu & ITEM_FLAGS_CU_IGNORE_QUEST_STATUS) && ((needs_quest || (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE)) && !player->HasQuestForItem(itemid)))
464 {
465 return false;
466 }
467
468 if (!sScriptMgr->OnAllowedForPlayerLootCheck(player, source))
469 {
470 return false;
471 }
472
473 return true;
474}
#define sConditionMgr
Definition: ConditionMgr.h:289
@ ITEM_FLAG_HIDE_UNUSABLE_RECIPE
Definition: ItemTemplate.h:173
@ ITEM_FLAGS_EXTRA_ALLIANCE_ONLY
Definition: ItemTemplate.h:221
@ ITEM_FLAGS_EXTRA_HORDE_ONLY
Definition: ItemTemplate.h:220
@ BIND_WHEN_PICKED_UP
Definition: ItemTemplate.h:97
@ ITEM_CLASS_RECIPE
Definition: ItemTemplate.h:309
@ ITEM_FLAGS_CU_IGNORE_QUEST_STATUS
Definition: ItemTemplate.h:229
@ QUEST_STATUS_NONE
Definition: QuestDef.h:100
#define sScriptMgr
Definition: ScriptMgr.h:2690
@ TEAM_ALLIANCE
Definition: SharedDefines.h:732
@ TEAM_HORDE
Definition: SharedDefines.h:733
int32 SpellId
Definition: ItemTemplate.h:600
uint32 RequiredSkill
Definition: ItemTemplate.h:646
_Spell Spells[MAX_ITEM_PROTO_SPELLS]
Definition: ItemTemplate.h:671
uint32 Class
Definition: ItemTemplate.h:630
uint32 Flags2
Definition: ItemTemplate.h:637
uint32 StartQuest
Definition: ItemTemplate.h:677
uint32 Bonding
Definition: ItemTemplate.h:672
Definition: Player.h:1046

References BIND_WHEN_PICKED_UP, ItemTemplate::Bonding, ItemTemplate::Class, conditions, ItemTemplate::Flags, ItemTemplate::Flags2, ItemTemplate::FlagsCu, follow_loot_rules, Player::GetGroup(), Object::GetGUID(), Group::GetMasterLooterGuid(), Player::GetQuestStatus(), Player::GetTeamId(), Player::HasQuestForItem(), Player::HasSkill(), Player::HasSpell(), is_underthreshold, ITEM_CLASS_RECIPE, ITEM_FLAG_HIDE_UNUSABLE_RECIPE, ITEM_FLAGS_CU_IGNORE_QUEST_STATUS, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY, ITEM_FLAGS_EXTRA_HORDE_ONLY, itemid, 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(), 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