New hooks OnAfterRefCount and OnBeforeDropAddItem

This commit is contained in:
Matteo Emili
2016-12-28 15:41:19 +01:00
committed by Yehonal
parent b32a9b244b
commit 1bf0f981cc
4 changed files with 21 additions and 4 deletions

View File

@@ -15,6 +15,7 @@
#include "Group.h"
#include "Player.h"
#include "Containers.h"
#include "ScriptMgr.h"
static Rates const qualityToRate[MAX_ITEM_QUALITY] =
{
@@ -461,7 +462,7 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo
items.reserve(MAX_NR_LOOT_ITEMS);
quest_items.reserve(MAX_NR_QUEST_ITEMS);
tab->Process(*this, store.IsRatesAllowed(), lootMode); // Processing is done there, callback via Loot::AddItem()
tab->Process(*this, store.IsRatesAllowed(), lootMode, lootOwner); // Processing is done there, callback via Loot::AddItem()
// Setting access rights for group loot case
Group* group = lootOwner->GetGroup();
@@ -1296,7 +1297,7 @@ void LootTemplate::CopyConditions(LootItem* li) const
}
// Rolls for every item in the template and adds the rolled items the the loot
void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId) const
void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, Player const* player, uint8 groupId) const
{
if (groupId) // Group reference uses own processing of the group
{
@@ -1327,10 +1328,12 @@ void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId
continue; // Error message already printed at loading stage
uint32 maxcount = uint32(float(item->maxcount) * sWorld->getRate(RATE_DROP_ITEM_REFERENCED_AMOUNT));
sScriptMgr->OnAfterRefCount(item, maxcount);
for (uint32 loop = 0; loop < maxcount; ++loop) // Ref multiplicator
Referenced->Process(loot, rate, lootMode, item->group);
Referenced->Process(loot, rate, lootMode, player, item->group);
}
else // Plain entries (not a reference, not grouped)
sScriptMgr->OnBeforeDropAddItem(player, loot, item);
loot.AddItem(*item); // Chance is already checked, just add
}