From 5da1ba94da3b12b01d5ee256307ce72202ae1218 Mon Sep 17 00:00:00 2001 From: Krisande <95944184+New-HavenWotLK@users.noreply.github.com> Date: Sat, 27 May 2023 12:36:41 +0200 Subject: [PATCH 1/4] Feature: Added player:CanRewardQuest(questId)/player:CanCompleteRepeatableQuest(questId) --- src/LuaEngine/LuaFunctions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 7e3b6b9..c4dfa33 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -606,6 +606,8 @@ ElunaRegister PlayerMethods[] = #ifndef CLASSIC { "IsInArenaTeam", &LuaPlayer::IsInArenaTeam }, #endif + { "CanRewardQuest", &LuaPlayer::CanRewardQuest }, + { "CanCompleteRepeatableQuest", &LuaPlayer::CanCompleteRepeatableQuest }, { "CanCompleteQuest", &LuaPlayer::CanCompleteQuest }, { "CanEquipItem", &LuaPlayer::CanEquipItem }, { "IsFalling", &LuaPlayer::IsFalling }, From 9ea7f9834b21ed4ebc7cea1ffd40de8d1d9668da Mon Sep 17 00:00:00 2001 From: Krisande <95944184+New-HavenWotLK@users.noreply.github.com> Date: Sat, 27 May 2023 12:38:14 +0200 Subject: [PATCH 2/4] Feature: Added player:CanRewardQuest(questId)/player:CanCompleteRepeatableQuest(questId) --- src/LuaEngine/PlayerMethods.h | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/LuaEngine/PlayerMethods.h b/src/LuaEngine/PlayerMethods.h index 04143b1..108216e 100644 --- a/src/LuaEngine/PlayerMethods.h +++ b/src/LuaEngine/PlayerMethods.h @@ -472,6 +472,46 @@ namespace LuaPlayer Eluna::Push(L, player->isTotalImmune()); return 1; } + + /** + * Returns 'true' if the [Player] satisfies all requirements to complete the quest entry. + * + * @param uint32 questId + * @return bool CanCompleteRepeatableQuest + */ + int CanCompleteRepeatableQuest(lua_State* L, Player* player) + { + uint32 questId = Eluna::CHECKVAL(L, 2); + const Quest* quest = sObjectMgr->GetQuestTemplate(questId); // Retrieve the Quest object + if (!quest) + { + Eluna::Push(L, false); + return 0; + } + + Eluna::Push(L, player->CanCompleteRepeatableQuest(quest)); + return 1; + } + + /** + * Returns 'true' if the [Player] satisfies all requirements to reward the quest entry. + * + * @param uint32 questId + * @return bool CanRewardQuest + */ + int CanRewardQuest(lua_State* L, Player* player) + { + uint32 questId = Eluna::CHECKVAL(L, 2); + const Quest* quest = sObjectMgr->GetQuestTemplate(questId); // Retrieve the Quest object + if (!quest) + { + Eluna::Push(L, false); + return 0; + } + + Eluna::Push(L, player->CanRewardQuest(quest, true)); // Modify the second argument as needed + return 1; + } /** * Returns 'true' if the [Player] satisfies all requirements to complete the quest entry. From 11e6fb49475d04315061ff6adef7fd9120c4f33d Mon Sep 17 00:00:00 2001 From: Krisande <95944184+New-HavenWotLK@users.noreply.github.com> Date: Sat, 27 May 2023 12:41:12 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index da84ed8..6d49cf0 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ Eluna API for AC: - Added `RegisterPlayerEvent` `56` (`PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM`): https://github.com/azerothcore/mod-eluna/pull/119 - Added `RegisterPlayerEvent` `57` (`PLAYER_EVENT_ON_APPLY_AURA`): https://github.com/azerothcore/mod-eluna/pull/137 - Added `RegisterPlayerEvent` `58` (`PLAYER_EVENT_ON_REMOVE_AURA`): https://github.com/azerothcore/mod-eluna/pull/137 +- Added `Player:CanCompleteRepeatableQuest(questId)`: https://github.com/azerothcore/mod-eluna/pull/141 +- Added `Player:CanRewardQuest(questId)`: https://github.com/azerothcore/mod-eluna/pull/141 - Added `Player:GetMailCount()`: https://github.com/azerothcore/mod-eluna/pull/76 - Added `Player:GetXP()`: https://github.com/azerothcore/mod-eluna/pull/77 - Added `Player:GetAchievementCriteriaProgress()`: https://github.com/azerothcore/mod-eluna/pull/78 From c359f72bb11a661701e5a45f4492edc084acdec7 Mon Sep 17 00:00:00 2001 From: Krisande <95944184+New-HavenWotLK@users.noreply.github.com> Date: Sat, 27 May 2023 16:56:36 +0200 Subject: [PATCH 4/4] Update README.md Fixed a little fail with the positioning of the new added methods at the readme file --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d49cf0..4c89f64 100644 --- a/README.md +++ b/README.md @@ -93,14 +93,14 @@ Eluna API for AC: - Added `RegisterPlayerEvent` `56` (`PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM`): https://github.com/azerothcore/mod-eluna/pull/119 - Added `RegisterPlayerEvent` `57` (`PLAYER_EVENT_ON_APPLY_AURA`): https://github.com/azerothcore/mod-eluna/pull/137 - Added `RegisterPlayerEvent` `58` (`PLAYER_EVENT_ON_REMOVE_AURA`): https://github.com/azerothcore/mod-eluna/pull/137 -- Added `Player:CanCompleteRepeatableQuest(questId)`: https://github.com/azerothcore/mod-eluna/pull/141 -- Added `Player:CanRewardQuest(questId)`: https://github.com/azerothcore/mod-eluna/pull/141 - Added `Player:GetMailCount()`: https://github.com/azerothcore/mod-eluna/pull/76 - Added `Player:GetXP()`: https://github.com/azerothcore/mod-eluna/pull/77 - Added `Player:GetAchievementCriteriaProgress()`: https://github.com/azerothcore/mod-eluna/pull/78 - Added vendor entry as argument to `Player:SendListInventory(object, vendorentry)`: https://github.com/azerothcore/mod-eluna/pull/48 - Added `Player:GetPlayerSettingValue()` and `Player:UpdatePlayerSetting()`: https://github.com/azerothcore/mod-eluna/pull/125 - Added `Player:GetTrader()`: https://github.com/azerothcore/mod-eluna/pull/126 +- Added `Player:CanCompleteRepeatableQuest(questId)`: https://github.com/azerothcore/mod-eluna/pull/141 +- Added `Player:CanRewardQuest(questId)`: https://github.com/azerothcore/mod-eluna/pull/141 ### Group - Added `Group:GetGroupType()`: https://github.com/azerothcore/mod-eluna/pull/82