Skip to content

Commit

Permalink
Add new Player methods
Browse files Browse the repository at this point in the history
Only the ones compatible with CMangos have been added

Co-Authored-By: Foereaper <[email protected]>
  • Loading branch information
Niam5 and Foereaper committed Oct 15, 2023
1 parent 41be34f commit 3751893
Showing 1 changed file with 53 additions and 4 deletions.
57 changes: 53 additions & 4 deletions CMangos/PlayerMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,44 @@ namespace LuaPlayer
return 1;
}

/**
* Returns 'true' if the [Player] satisfies all requirements to complete the repeatable quest entry.
*
* @param uint32 entry
* @return bool canComplete
*/
int CanCompleteRepeatableQuest(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);

Quest const* qInfo = eObjectMgr->GetQuestTemplate(entry);
if (qInfo)
Eluna::Push(L, player->CanCompleteRepeatableQuest(qInfo));
else
Eluna::Push(L, false);

return 1;
}

/**
* Returns 'true' if the [Player] satisfies all requirements to turn in the quest.
*
* @param uint32 entry
* @return bool canReward
*/
int CanRewardQuest(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);

Quest const* qInfo = eObjectMgr->GetQuestTemplate(entry);
if (qInfo)
Eluna::Push(L, player->CanRewardQuest(qInfo, true));
else
Eluna::Push(L, false);

return 1;
}

/**
* Returns 'true' if the [Player] is a part of the Horde faction, 'false' otherwise.
*
Expand Down Expand Up @@ -1504,6 +1542,17 @@ namespace LuaPlayer
Eluna::Push(L, player->GetSession()->GetSessionDbcLocale());
return 1;
}

/**
* Returns the amount of mails in the [Player]s mailbox
*
* @return uint32 count
*/
int GetMailCount(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetMailSize());
return 1;
}

/**
* Locks the player controls and disallows all movement and casting.
Expand Down Expand Up @@ -3762,6 +3811,7 @@ namespace LuaPlayer
#ifndef CATA
{ "GetShieldBlockValue", &LuaPlayer::GetShieldBlockValue },
#endif
{ "GetMailCount", &LuaPlayer::GetMailCount },

// Setters
{ "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax },
Expand Down Expand Up @@ -3852,6 +3902,8 @@ namespace LuaPlayer
{ "HasTalent", &LuaPlayer::HasTalent },
{ "CanTitanGrip", &LuaPlayer::CanTitanGrip },
#endif
{ "CanCompleteRepeatableQuest", &LuaPlayer::CanCompleteRepeatableQuest },
{ "CanRewardQuest", &LuaPlayer::CanRewardQuest },

// Gossip
{ "GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem },
Expand Down Expand Up @@ -3975,12 +4027,9 @@ namespace LuaPlayer
{ "UpdateHonor", nullptr }, // classic only
{ "ResetHonor", nullptr }, // classic only
{ "ClearHonorInfo", nullptr }, // classic only
{ "GetMailCount", nullptr }, // not implemented
{ "GetXP", nullptr }, // not implemented
{ "GetXPForNextLevel", nullptr }, // not implemented
{ "CanCompleteRepeatableQuest", nullptr }, // not implemented
{ "CanRewardQuest", nullptr }, // not implemented


{ NULL, NULL }
};
};
Expand Down

0 comments on commit 3751893

Please sign in to comment.