aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp7
-rw-r--r--src/server/game/Entities/Player/Player.cpp15
-rw-r--r--src/server/game/Entities/Player/Player.h2
-rw-r--r--src/server/game/Handlers/LootHandler.cpp4
-rw-r--r--src/server/game/Instances/InstanceScript.cpp5
-rw-r--r--src/server/game/Instances/InstanceScript.h1
-rw-r--r--src/server/game/Loot/Loot.cpp5
-rw-r--r--src/server/game/Loot/Loot.h6
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
9 files changed, 36 insertions, 11 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 7c8ecfae7f9..fc9477a85d1 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -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()
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 121fa09436b..8983ebf69c4 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -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)
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index aba0480d681..c23b658998e 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -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);
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp
index 28442b1abf8..eb27319992e 100644
--- a/src/server/game/Handlers/LootHandler.cpp
+++ b/src/server/game/Handlers/LootHandler.cpp
@@ -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;
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp
index 79cfe925f5b..fd3d16a2772 100644
--- a/src/server/game/Instances/InstanceScript.cpp
+++ b/src/server/game/Instances/InstanceScript.cpp
@@ -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",
diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h
index 43cb58622fc..b7a2e2fc15e 100644
--- a/src/server/game/Instances/InstanceScript.h
+++ b/src/server/game/Instances/InstanceScript.h
@@ -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
diff --git a/src/server/game/Loot/Loot.cpp b/src/server/game/Loot/Loot.cpp
index ff3a77279c4..91eac407aaa 100644
--- a/src/server/game/Loot/Loot.cpp
+++ b/src/server/game/Loot/Loot.cpp
@@ -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);
}
}
diff --git a/src/server/game/Loot/Loot.h b/src/server/game/Loot/Loot.h
index 3af9963aa06..fda1cb0e9c7 100644
--- a/src/server/game/Loot/Loot.h
+++ b/src/server/game/Loot/Loot.h
@@ -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;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index b5e4c8aa87a..9bc89995523 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -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)