feat(PlayerHooks): Add tweaks for OnPlayerQuestAccept (#282)

This commit is contained in:
iThorgrim
2025-09-02 21:46:14 +02:00
committed by GitHub
parent 1c63eacec9
commit f5ac976642
4 changed files with 18 additions and 1 deletions

View File

@@ -69,6 +69,7 @@ public:
bool CanCreatureQuestAccept(Player* player, Creature* creature, Quest const* quest) override bool CanCreatureQuestAccept(Player* player, Creature* creature, Quest const* quest) override
{ {
sEluna->OnPlayerQuestAccept(player, quest);
sEluna->OnQuestAccept(player, creature, quest); sEluna->OnQuestAccept(player, creature, quest);
return false; return false;
} }
@@ -146,6 +147,7 @@ public:
bool CanGameObjectQuestAccept(Player* player, GameObject* go, Quest const* quest) override bool CanGameObjectQuestAccept(Player* player, GameObject* go, Quest const* quest) override
{ {
sEluna->OnPlayerQuestAccept(player, quest);
sEluna->OnQuestAccept(player, go, quest); sEluna->OnQuestAccept(player, go, quest);
return false; return false;
} }
@@ -169,7 +171,10 @@ public:
bool CanGameObjectQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt) override bool CanGameObjectQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt) override
{ {
if (sEluna->OnQuestAccept(player, go, quest)) if (sEluna->OnQuestAccept(player, go, quest))
{
sEluna->OnPlayerQuestAccept(player, quest);
return false; return false;
}
if (sEluna->OnQuestReward(player, go, quest, opt)) if (sEluna->OnQuestReward(player, go, quest, opt))
return false; return false;
@@ -192,7 +197,10 @@ public:
bool CanItemQuestAccept(Player* player, Item* item, Quest const* quest) override bool CanItemQuestAccept(Player* player, Item* item, Quest const* quest) override
{ {
if (sEluna->OnQuestAccept(player, item, quest)) if (sEluna->OnQuestAccept(player, item, quest))
{
sEluna->OnPlayerQuestAccept(player, quest);
return false; return false;
}
return true; return true;
} }

View File

@@ -226,6 +226,7 @@ namespace Hooks
PLAYER_EVENT_ON_CAN_UPDATE_SKILL = 60, // (event, player, skill_id) -- Can return true or false PLAYER_EVENT_ON_CAN_UPDATE_SKILL = 60, // (event, player, skill_id) -- Can return true or false
PLAYER_EVENT_ON_BEFORE_UPDATE_SKILL = 61, // (event, player, skill_id, value, max, step) -- Can return new amount PLAYER_EVENT_ON_BEFORE_UPDATE_SKILL = 61, // (event, player, skill_id, value, max, step) -- Can return new amount
PLAYER_EVENT_ON_UPDATE_SKILL = 62, // (event, player, skill_id, value, max, step, new_value) PLAYER_EVENT_ON_UPDATE_SKILL = 62, // (event, player, skill_id, value, max, step, new_value)
PLAYER_EVENT_ON_QUEST_ACCEPT = 63, // (event, player, quest)
PLAYER_EVENT_COUNT PLAYER_EVENT_COUNT
}; };

View File

@@ -491,6 +491,7 @@ public:
void OnPlayerBeforeUpdateSkill(Player* player, uint32 skill_id, uint32& value, uint32 max, uint32 step); void OnPlayerBeforeUpdateSkill(Player* player, uint32 skill_id, uint32& value, uint32 max, uint32 step);
void OnPlayerUpdateSkill(Player* player, uint32 skill_id, uint32 value, uint32 max, uint32 step, uint32 new_value); void OnPlayerUpdateSkill(Player* player, uint32 skill_id, uint32 value, uint32 max, uint32 step, uint32 new_value);
bool CanPlayerResurrect(Player* player); bool CanPlayerResurrect(Player* player);
void OnPlayerQuestAccept(Player* player, Quest const* quest);
/* Vehicle */ /* Vehicle */
void OnInstall(Vehicle* vehicle); void OnInstall(Vehicle* vehicle);

View File

@@ -754,10 +754,17 @@ void Eluna::OnPlayerUpdateSkill(Player* player, uint32 skill_id, uint32 value, u
CallAllFunctions(PlayerEventBindings, key); CallAllFunctions(PlayerEventBindings, key);
} }
bool Eluna::CanPlayerResurrect(Player* player) bool Eluna::CanPlayerResurrect(Player* player)
{ {
START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_CAN_RESURRECT, true); START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_CAN_RESURRECT, true);
Push(player); Push(player);
return CallAllFunctionsBool(PlayerEventBindings, key); return CallAllFunctionsBool(PlayerEventBindings, key);
} }
void Eluna::OnPlayerQuestAccept(Player* player, Quest const* quest)
{
START_HOOK(PLAYER_EVENT_ON_QUEST_ACCEPT);
Push(player);
Push(quest);
CallAllFunctions(PlayerEventBindings, key);
}