Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added player:CanRewardQuest(questId)/player:CanCompleteRepeatableQuest(questId) #141

Merged
merged 4 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Eluna API for AC:
- 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
Expand Down
2 changes: 2 additions & 0 deletions src/LuaEngine/LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ ElunaRegister<Player> PlayerMethods[] =
#ifndef CLASSIC
{ "IsInArenaTeam", &LuaPlayer::IsInArenaTeam },
#endif
{ "CanRewardQuest", &LuaPlayer::CanRewardQuest },
{ "CanCompleteRepeatableQuest", &LuaPlayer::CanCompleteRepeatableQuest },
{ "CanCompleteQuest", &LuaPlayer::CanCompleteQuest },
{ "CanEquipItem", &LuaPlayer::CanEquipItem },
{ "IsFalling", &LuaPlayer::IsFalling },
Expand Down
40 changes: 40 additions & 0 deletions src/LuaEngine/PlayerMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32>(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<uint32>(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.
Expand Down