feat(Core): Add OnGroupRollRewardItem hook. (#12538)

Added OnGroupRollRewardItem hook.
This commit is contained in:
AnchyDev
2022-07-27 01:08:41 +01:00
committed by GitHub
parent f53b19dfd3
commit dcbf224392
3 changed files with 17 additions and 2 deletions
+4 -2
View File
@@ -1448,7 +1448,8 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
roll->getLoot()->NotifyItemRemoved(roll->itemSlot); roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
roll->getLoot()->unlootedCount--; roll->getLoot()->unlootedCount--;
AllowedLooterSet looters = item->GetAllowedLooters(); AllowedLooterSet looters = item->GetAllowedLooters();
player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters); Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
sScriptMgr->OnGroupRollRewardItem(player, _item, _item->GetCount(), NEED, roll);
player->UpdateLootAchievements(item, roll->getLoot()); player->UpdateLootAchievements(item, roll->getLoot());
} }
else else
@@ -1516,7 +1517,8 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
roll->getLoot()->NotifyItemRemoved(roll->itemSlot); roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
roll->getLoot()->unlootedCount--; roll->getLoot()->unlootedCount--;
AllowedLooterSet looters = item->GetAllowedLooters(); AllowedLooterSet looters = item->GetAllowedLooters();
player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters); Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
sScriptMgr->OnGroupRollRewardItem(player, _item, _item->GetCount(), GREED, roll);
player->UpdateLootAchievements(item, roll->getLoot()); player->UpdateLootAchievements(item, roll->getLoot());
} }
else else
@@ -590,6 +590,14 @@ void ScriptMgr::OnQuestRewardItem(Player* player, Item* item, uint32 count)
}); });
} }
void ScriptMgr::OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll)
{
ExecuteScript<PlayerScript>([&](PlayerScript* script)
{
script->OnGroupRollRewardItem(player, item, count, voteType, roll);
});
}
void ScriptMgr::OnFirstLogin(Player* player) void ScriptMgr::OnFirstLogin(Player* player)
{ {
ExecuteScript<PlayerScript>([&](PlayerScript* script) ExecuteScript<PlayerScript>([&](PlayerScript* script)
+5
View File
@@ -26,6 +26,7 @@
#include "DBCStores.h" #include "DBCStores.h"
#include "DynamicObject.h" #include "DynamicObject.h"
#include "GameEventMgr.h" #include "GameEventMgr.h"
#include "Group.h"
#include "LFGMgr.h" #include "LFGMgr.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "PetDefines.h" #include "PetDefines.h"
@@ -1172,6 +1173,9 @@ public:
// After receiving item as a quest reward // After receiving item as a quest reward
virtual void OnQuestRewardItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/) { } virtual void OnQuestRewardItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/) { }
// After receiving item as a group roll reward
virtual void OnGroupRollRewardItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, RollVote /*voteType*/, Roll* /*roll*/) { }
// After completed a quest // After completed a quest
[[nodiscard]] virtual bool OnBeforeQuestComplete(Player* /*player*/, uint32 /*quest_id*/) { return true; } [[nodiscard]] virtual bool OnBeforeQuestComplete(Player* /*player*/, uint32 /*quest_id*/) { return true; }
@@ -2244,6 +2248,7 @@ public: /* PlayerScript */
void OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid); void OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid);
void OnCreateItem(Player* player, Item* item, uint32 count); void OnCreateItem(Player* player, Item* item, uint32 count);
void OnQuestRewardItem(Player* player, Item* item, uint32 count); void OnQuestRewardItem(Player* player, Item* item, uint32 count);
void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll);
bool OnBeforePlayerQuestComplete(Player* player, uint32 quest_id); bool OnBeforePlayerQuestComplete(Player* player, uint32 quest_id);
void OnQuestComputeXP(Player* player, Quest const* quest, uint32& xpValue); void OnQuestComputeXP(Player* player, Quest const* quest, uint32& xpValue);
void OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank); void OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank);