mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Loot: Send DungeonEncounter id in SMSG_ITEM_PUSH_RESULT
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Log.h"
|
||||
#include "Loot.h"
|
||||
#include "MotionMaster.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "PhasingHandler.h"
|
||||
@@ -520,7 +521,13 @@ void BossAI::_JustDied()
|
||||
summons.DespawnAll();
|
||||
scheduler.CancelAll();
|
||||
if (instance)
|
||||
{
|
||||
if (me->m_loot)
|
||||
if (DungeonEncounterEntry const* dungeonEncounter = instance->GetBossDungeonEncounter(_bossId))
|
||||
me->m_loot->SetDungeonEncounterId(dungeonEncounter->ID);
|
||||
|
||||
instance->SetBossState(_bossId, DONE);
|
||||
}
|
||||
}
|
||||
|
||||
void BossAI::_JustReachedHome()
|
||||
|
||||
@@ -13585,7 +13585,7 @@ void Player::SendItemDurations()
|
||||
(*itr)->SendTimeUpdate(this);
|
||||
}
|
||||
|
||||
void Player::SendNewItem(Item* item, uint32 quantity, bool pushed, bool created, bool broadcast)
|
||||
void Player::SendNewItem(Item* item, uint32 quantity, bool pushed, bool created, bool broadcast /*= false*/, uint32 dungeonEncounterId /*= 0*/)
|
||||
{
|
||||
if (!item) // prevent crash
|
||||
return;
|
||||
@@ -13602,7 +13602,6 @@ void Player::SendNewItem(Item* item, uint32 quantity, bool pushed, bool created,
|
||||
//packet.QuestLogItemID;
|
||||
packet.Quantity = quantity;
|
||||
packet.QuantityInInventory = GetItemCount(item->GetEntry());
|
||||
//packet.DungeonEncounterID;
|
||||
packet.BattlePetSpeciesID = item->GetModifier(ITEM_MODIFIER_BATTLE_PET_SPECIES_ID);
|
||||
packet.BattlePetBreedID = item->GetModifier(ITEM_MODIFIER_BATTLE_PET_BREED_DATA) & 0xFFFFFF;
|
||||
packet.BattlePetBreedQuality = (item->GetModifier(ITEM_MODIFIER_BATTLE_PET_BREED_DATA) >> 24) & 0xFF;
|
||||
@@ -13614,7 +13613,13 @@ void Player::SendNewItem(Item* item, uint32 quantity, bool pushed, bool created,
|
||||
packet.DisplayText = WorldPackets::Item::ItemPushResult::DISPLAY_TYPE_NORMAL;
|
||||
packet.Created = created;
|
||||
//packet.IsBonusRoll;
|
||||
//packet.IsEncounterLoot;
|
||||
|
||||
if (dungeonEncounterId)
|
||||
{
|
||||
packet.DisplayText = WorldPackets::Item::ItemPushResult::DISPLAY_TYPE_ENCOUNTER_LOOT;
|
||||
packet.DungeonEncounterID = dungeonEncounterId;
|
||||
packet.IsEncounterLoot = true;
|
||||
}
|
||||
|
||||
if (broadcast && GetGroup() && !item->GetTemplate()->HasFlag(ITEM_FLAG3_DONT_REPORT_LOOT_LOG_TO_PARTY))
|
||||
GetGroup()->BroadcastPacket(packet.Write(), true);
|
||||
@@ -25477,13 +25482,13 @@ void Player::StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot*
|
||||
// if aeLooting then we must delay sending out item so that it appears properly stacked in chat
|
||||
if (!aeResult)
|
||||
{
|
||||
SendNewItem(newitem, uint32(item->count), false, false, true);
|
||||
SendNewItem(newitem, uint32(item->count), false, false, true, loot->GetDungeonEncounterId());
|
||||
UpdateCriteria(CriteriaType::LootItem, item->itemid, item->count);
|
||||
UpdateCriteria(CriteriaType::GetLootByType, item->itemid, item->count, GetLootTypeForClient(loot->loot_type));
|
||||
UpdateCriteria(CriteriaType::LootAnyItem, item->itemid, item->count);
|
||||
}
|
||||
else
|
||||
aeResult->Add(newitem, item->count, GetLootTypeForClient(loot->loot_type));
|
||||
aeResult->Add(newitem, item->count, GetLootTypeForClient(loot->loot_type), loot->GetDungeonEncounterId());
|
||||
|
||||
// LootItem is being removed (looted) from the container, delete it from the DB.
|
||||
if (loot->loot_type == LOOT_ITEM)
|
||||
|
||||
@@ -1463,7 +1463,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
bool IsUseEquipedWeapon(bool mainhand) const;
|
||||
bool IsTwoHandUsed() const;
|
||||
bool IsUsingTwoHandedWeaponInOneHand() const;
|
||||
void SendNewItem(Item* item, uint32 quantity, bool received, bool created, bool broadcast = false);
|
||||
void SendNewItem(Item* item, uint32 quantity, bool received, bool created, bool broadcast = false, uint32 dungeonEncounterId = 0);
|
||||
bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
|
||||
bool BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot, uint32 currency, uint32 count);
|
||||
bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int64 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore);
|
||||
|
||||
@@ -128,7 +128,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPackets::Loot::LootItem& p
|
||||
{
|
||||
for (AELootResult::ResultValue const& resultValue : aeResult)
|
||||
{
|
||||
player->SendNewItem(resultValue.item, resultValue.count, false, false, true);
|
||||
player->SendNewItem(resultValue.item, resultValue.count, false, false, true, resultValue.dungeonEncounterId);
|
||||
player->UpdateCriteria(CriteriaType::LootItem, resultValue.item->GetEntry(), resultValue.count);
|
||||
player->UpdateCriteria(CriteriaType::GetLootByType, resultValue.item->GetEntry(), resultValue.count, resultValue.lootType);
|
||||
player->UpdateCriteria(CriteriaType::LootAnyItem, resultValue.item->GetEntry(), resultValue.count);
|
||||
@@ -440,7 +440,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPackets::Loot::MasterLootItem
|
||||
|
||||
// now move item from loot to target inventory
|
||||
Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, item.BonusListIDs);
|
||||
aeResult.Add(newitem, item.count, loot->loot_type);
|
||||
aeResult.Add(newitem, item.count, loot->loot_type, loot->GetDungeonEncounterId());
|
||||
|
||||
// mark as looted
|
||||
item.count = 0;
|
||||
|
||||
@@ -718,6 +718,11 @@ bool InstanceScript::ServerAllowsTwoSideGroups()
|
||||
return sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP);
|
||||
}
|
||||
|
||||
DungeonEncounterEntry const* InstanceScript::GetBossDungeonEncounter(uint32 id) const
|
||||
{
|
||||
return id < bosses.size() ? bosses[id].GetDungeonEncounterForDifficulty(instance->GetDifficultyID()) : nullptr;
|
||||
}
|
||||
|
||||
bool InstanceScript::CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= nullptr*/, uint32 /*miscvalue1*/ /*= 0*/)
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Achievement system call InstanceScript::CheckAchievementCriteriaMeet but instance script for map %u not have implementation for achievement criteria %u",
|
||||
|
||||
@@ -267,6 +267,7 @@ class TC_GAME_API InstanceScript : public ZoneScript
|
||||
EncounterState GetBossState(uint32 id) const { return id < bosses.size() ? bosses[id].state : TO_BE_DECIDED; }
|
||||
static char const* GetBossStateName(uint8 state);
|
||||
CreatureBoundary const* GetBossBoundary(uint32 id) const { return id < bosses.size() ? &bosses[id].boundary : nullptr; }
|
||||
DungeonEncounterEntry const* GetBossDungeonEncounter(uint32 id) const;
|
||||
|
||||
// Achievement criteria additional requirements check
|
||||
// NOTE: not use this if same can be checked existed requirement types from AchievementCriteriaRequirementType
|
||||
|
||||
@@ -613,7 +613,7 @@ void LootRoll::Finish(RollVoteMap::const_iterator winnerItr)
|
||||
Loot::Loot(Map* map, ObjectGuid owner, LootType type, Group const* group) : gold(0), unlootedCount(0), loot_type(type), maxDuplicates(1),
|
||||
_guid(map ? ObjectGuid::Create<HighGuid::LootObject>(map->GetId(), 0, map->GenerateLowGuid<HighGuid::LootObject>()) : ObjectGuid::Empty),
|
||||
_owner(owner), _itemContext(ItemContext::NONE), _lootMethod(group ? group->GetLootMethod() : FREE_FOR_ALL),
|
||||
_lootMaster(group ? group->GetMasterLooterGuid() : ObjectGuid::Empty), _wasOpened(false)
|
||||
_lootMaster(group ? group->GetMasterLooterGuid() : ObjectGuid::Empty), _wasOpened(false), _dungeonEncounterId(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1044,7 +1044,7 @@ void Loot::FillNotNormalLootFor(Player const* player)
|
||||
// --------- AELootResult ---------
|
||||
//
|
||||
|
||||
void AELootResult::Add(Item* item, uint8 count, LootType lootType)
|
||||
void AELootResult::Add(Item* item, uint8 count, LootType lootType, uint32 dungeonEncounterId)
|
||||
{
|
||||
auto itr = _byItem.find(item);
|
||||
if (itr != _byItem.end())
|
||||
@@ -1056,6 +1056,7 @@ void AELootResult::Add(Item* item, uint8 count, LootType lootType)
|
||||
value.item = item;
|
||||
value.count = count;
|
||||
value.lootType = lootType;
|
||||
value.dungeonEncounterId = dungeonEncounterId;
|
||||
_byOrder.push_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,6 +284,8 @@ struct TC_GAME_API Loot
|
||||
ObjectGuid const& GetOwnerGUID() const { return _owner; }
|
||||
LootMethod GetLootMethod() const { return _lootMethod; }
|
||||
ObjectGuid const& GetLootMasterGUID() const { return _lootMaster; }
|
||||
uint32 GetDungeonEncounterId() const { return _dungeonEncounterId; }
|
||||
void SetDungeonEncounterId(uint32 dungeonEncounterId) { _dungeonEncounterId = dungeonEncounterId; }
|
||||
|
||||
void clear();
|
||||
|
||||
@@ -331,6 +333,7 @@ private:
|
||||
ObjectGuid _lootMaster;
|
||||
GuidUnorderedSet _allowedLooters;
|
||||
bool _wasOpened; // true if at least one player received the loot content
|
||||
uint32 _dungeonEncounterId;
|
||||
};
|
||||
|
||||
class TC_GAME_API AELootResult
|
||||
@@ -341,11 +344,12 @@ public:
|
||||
Item* item;
|
||||
uint8 count;
|
||||
LootType lootType;
|
||||
uint32 dungeonEncounterId;
|
||||
};
|
||||
|
||||
typedef std::vector<ResultValue> OrderedStorage;
|
||||
|
||||
void Add(Item* item, uint8 count, LootType lootType);
|
||||
void Add(Item* item, uint8 count, LootType lootType, uint32 dungeonEncounterId);
|
||||
|
||||
OrderedStorage::const_iterator begin() const;
|
||||
OrderedStorage::const_iterator end() const;
|
||||
|
||||
@@ -1575,6 +1575,8 @@ void Spell::SendLoot(ObjectGuid guid, LootType loottype)
|
||||
if (gameObjTarget->GetLootMode() > 0)
|
||||
if (GameObjectTemplateAddon const* addon = gameObjTarget->GetTemplateAddon())
|
||||
loot->generateMoneyLoot(addon->Mingold, addon->Maxgold);
|
||||
|
||||
loot->SetDungeonEncounterId(gameObjTarget->GetGOInfo()->chest.DungeonEncounter);
|
||||
}
|
||||
|
||||
/// @todo possible must be moved to loot release (in different from linked triggering)
|
||||
|
||||
Reference in New Issue
Block a user