mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 22:26:22 +00:00
New hooks OnAfterRefCount and OnBeforeDropAddItem
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ class LootTemplate
|
||||
// Adds an entry to the group (at loading stage)
|
||||
void AddEntry(LootStoreItem* item);
|
||||
// Rolls for every item in the template and adds the rolled items the the loot
|
||||
void Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId = 0) const;
|
||||
void Process(Loot& loot, bool rate, uint16 lootMode, Player const* player, uint8 groupId = 0) const;
|
||||
void CopyConditions(ConditionList conditions);
|
||||
void CopyConditions(LootItem* li) const;
|
||||
|
||||
|
||||
@@ -1475,6 +1475,16 @@ void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<uint32, uint32
|
||||
FOREACH_SCRIPT(GlobalScript)->OnBeforeUpdateArenaPoints(at,ap);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterRefCount(LootStoreItem* LootStoreItem, uint32 &maxcount)
|
||||
{
|
||||
FOREACH_SCRIPT(GlobalScript)->OnAfterRefCount(LootStoreItem, maxcount);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnBeforeDropAddItem(Player const* player, Loot& loot, LootStoreItem* LootStoreItem)
|
||||
{
|
||||
FOREACH_SCRIPT(GlobalScript)->OnBeforeDropAddItem(player, loot, LootStoreItem);
|
||||
}
|
||||
|
||||
uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit *pVictim, uint32 damage, DamageEffectType damagetype)
|
||||
{
|
||||
FOR_SCRIPTS_RET(UnitScript, itr, end, damage)
|
||||
|
||||
@@ -965,6 +965,8 @@ class GlobalScript : public ScriptObject
|
||||
// items
|
||||
virtual void OnItemDelFromDB(SQLTransaction& /*trans*/, uint32 /*itemGuid*/) { }
|
||||
virtual void OnMirrorImageDisplayItem(const Item* /*item*/, uint32& /*display*/) { }
|
||||
virtual void OnAfterRefCount(LootStoreItem* /*LootStoreItem*/, uint32& /*maxcount*/) { }
|
||||
virtual void OnBeforeDropAddItem(Player const* /*player*/, Loot& /*loot*/, LootStoreItem* /*LootStoreItem*/) { }
|
||||
|
||||
// On Before arena points distribution
|
||||
virtual void OnBeforeUpdateArenaPoints(ArenaTeam* /*at*/, std::map<uint32, uint32> & /*ap*/) { }
|
||||
@@ -1217,6 +1219,8 @@ class ScriptMgr
|
||||
void OnGlobalItemDelFromDB(SQLTransaction& trans, uint32 itemGuid);
|
||||
void OnGlobalMirrorImageDisplayItem(const Item *item, uint32 &display);
|
||||
void OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<uint32, uint32> &ap);
|
||||
void OnAfterRefCount(LootStoreItem* LootStoreItem, uint32 &maxcount);
|
||||
void OnBeforeDropAddItem(Player const* player, Loot& loot, LootStoreItem* LootStoreItem);
|
||||
|
||||
public: /* Scheduled scripts */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user