Skip to content

Commit

Permalink
Add new Player methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Foereaper committed Oct 14, 2023
1 parent 1edc007 commit 1e94624
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMangos/PlayerMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -3975,6 +3975,11 @@ 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
5 changes: 5 additions & 0 deletions Mangos/PlayerMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -4592,6 +4592,11 @@ namespace LuaPlayer
{ "AddTalent", nullptr }, // not implemented
{ "BindToInstance", nullptr }, // not implemented
{ "SetAchievement", nullptr }, // not implemented
{ "GetMailCount", nullptr }, // not implemented
{ "GetXP", nullptr }, // not implemented
{ "GetXPForNextLevel", nullptr }, // not implemented
{ "CanCompleteRepeatableQuest", nullptr }, // not implemented
{ "CanRewardQuest", nullptr }, // not implemented

{ NULL, NULL }
};
Expand Down
76 changes: 76 additions & 0 deletions TrinityCore/PlayerMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,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 = sObjectMgr->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 = sObjectMgr->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 @@ -1507,6 +1545,39 @@ namespace LuaPlayer
Eluna::Push(L, ChatHandler(player->GetSession()).GetNearbyGameObject());
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;
}

/**
* Returns the [Player]s current experience points
*
* @return uint32 xp
*/
int GetXP(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetXP());
return 1;
}

/**
* Returns the [Player]s required experience points for next level
*
* @return uint32 xp
*/
int GetXPForNextLevel(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetXPForNextLevel());
return 1;
}

/**
* Locks the player controls and disallows all movement and casting.
Expand Down Expand Up @@ -3811,6 +3882,9 @@ namespace LuaPlayer
#else
{ "GetShieldBlockValue", nullptr },
#endif
{ "GetMailCount", &LuaPlayer::GetMailCount },
{ "GetXP", &LuaPlayer::GetXP },
{ "GetXPForNextLevel", &LuaPlayer::GetXPForNextLevel },

// Setters
#ifndef CATA
Expand Down Expand Up @@ -3919,6 +3993,8 @@ namespace LuaPlayer
{ "CanFly", &LuaPlayer::CanFly },
{ "IsMoving", &LuaPlayer::IsMoving },
{ "IsFlying", &LuaPlayer::IsFlying },
{ "CanCompleteRepeatableQuest", &LuaPlayer::CanCompleteRepeatableQuest },
{ "CanRewardQuest", &LuaPlayer::CanRewardQuest },

// Gossip
{ "GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem },
Expand Down
5 changes: 5 additions & 0 deletions VMangos/PlayerMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -4465,6 +4465,11 @@ namespace LuaPlayer
{ "AddTalent", nullptr }, // not implemented
{ "BindToInstance", nullptr }, // not implemented
{ "SetAchievement", nullptr }, // not implemented
{ "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 1e94624

Please sign in to comment.