feat: add Player:GetAchievementCriteriaProgress() (#78)

This commit is contained in:
Axel Cocat
2022-12-29 11:51:29 +01:00
committed by GitHub
parent 9b0eedc6f7
commit 03f1948b2d
2 changed files with 23 additions and 0 deletions

View File

@@ -612,6 +612,7 @@ ElunaRegister<Player> PlayerMethods[] =
// {"HasPendingBind", &LuaPlayer::HasPendingBind}, // :HasPendingBind() - UNDOCUMENTED - Returns true if the player has a pending instance bind
#if (!defined(TBC) && !defined(CLASSIC))
{ "HasAchieved", &LuaPlayer::HasAchieved },
{ "GetAchievementCriteriaProgress", &LuaPlayer::GetAchievementCriteriaProgress },
#if defined(TRINITY) || defined(AZEROTHCORE)
{ "SetAchievement", &LuaPlayer::SetAchievement },
#endif

View File

@@ -64,6 +64,28 @@ namespace LuaPlayer
#endif
return 1;
}
/**
* Returns the progress of the [Player] for the specified achievement criteria.
*
* @param uint32 criteriaId
* @return uint32 progress : progress value or nil
*/
int GetAchievementCriteriaProgress(lua_State* L, Player* player)
{
uint32 criteriaId = Eluna::CHECKVAL<uint32>(L, 2);
const AchievementCriteriaEntry* criteria = sAchievementCriteriaStore.LookupEntry(criteriaId);
CriteriaProgress* progress = player->GetAchievementMgr()->GetCriteriaProgress(criteria);
if (progress)
{
Eluna::Push(L, progress->counter);
}
else
{
Eluna::Push(L, (void*)nullptr);
}
return 1;
}
#endif
/**