diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 803044c..dfb7f01 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -806,6 +806,11 @@ public: { sEluna->OnBattlegroundDesertion(player, type); } + + void OnCreatureKilledByPet(Player* player, Creature* killed) override + { + sEluna->OnCreatureKilledByPet(player, killed); + } }; class Eluna_ServerScript : public ServerScript diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index f368317..a5fd28b 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -219,6 +219,7 @@ namespace Hooks PLAYER_EVENT_ON_CAN_GROUP_INVITE = 55, // (event, player, memberName) - Can return false to prevent inviting PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM = 56, // (event, player, item, count, voteType, roll) PLAYER_EVENT_ON_BG_DESERTION = 57, // (event, player, type) + PLAYER_EVENT_ON_PET_KILL = 58, // (event, player, killer) PLAYER_EVENT_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index 6955356..af0a5d5 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -490,6 +490,7 @@ public: bool OnCanGroupInvite(Player* player, std::string& memberName); void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll); void OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type); + void OnCreatureKilledByPet(Player* player, Creature* killed); #ifndef CLASSIC #ifndef TBC diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index c9aa169..58a2ae7 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -472,6 +472,7 @@ ElunaRegister PlayerMethods[] = { "GetGuild", &LuaPlayer::GetGuild }, { "GetAccountId", &LuaPlayer::GetAccountId }, { "GetAccountName", &LuaPlayer::GetAccountName }, + { "GetCompletedQuestsCount", &LuaPlayer::GetCompletedQuestsCount }, #if defined (TBC) || defined (WOTLK) { "GetArenaPoints", &LuaPlayer::GetArenaPoints }, { "GetHonorPoints", &LuaPlayer::GetHonorPoints }, @@ -492,6 +493,8 @@ ElunaRegister PlayerMethods[] = { "GetRestBonus", &LuaPlayer::GetRestBonus }, #ifdef WOTLK { "GetPhaseMaskForSpawn", &LuaPlayer::GetPhaseMaskForSpawn }, + { "GetAchievementPoints", &LuaPlayer::GetAchievementPoints }, + { "GetCompletedAchievementsCount", &LuaPlayer::GetCompletedAchievementsCount }, #endif { "GetReqKillOrCastCurrentCount", &LuaPlayer::GetReqKillOrCastCurrentCount }, { "GetQuestStatus", &LuaPlayer::GetQuestStatus }, diff --git a/src/LuaEngine/PlayerHooks.cpp b/src/LuaEngine/PlayerHooks.cpp index 6d30434..e437a2a 100644 --- a/src/LuaEngine/PlayerHooks.cpp +++ b/src/LuaEngine/PlayerHooks.cpp @@ -698,3 +698,11 @@ void Eluna::OnBattlegroundDesertion(Player* player, const BattlegroundDesertionT Push(type); CallAllFunctions(PlayerEventBindings, key); } + +void Eluna::OnCreatureKilledByPet(Player* player, Creature* killed) +{ + START_HOOK(PLAYER_EVENT_ON_PET_KILL); + Push(player); + Push(killed); + CallAllFunctions(PlayerEventBindings, key); +} diff --git a/src/LuaEngine/PlayerMethods.h b/src/LuaEngine/PlayerMethods.h index 37d7914..8b3d8c0 100644 --- a/src/LuaEngine/PlayerMethods.h +++ b/src/LuaEngine/PlayerMethods.h @@ -903,6 +903,51 @@ namespace LuaPlayer Eluna::Push(L, player->GetPhaseMaskForSpawn()); return 1; } + + /** + * Returns the [Player]s current amount of Achievement Points + * + * @return uint32 achievementPoints + */ + int GetAchievementPoints(lua_State* L, Player* player) + { + uint32 count = 0; + const CompletedAchievementMap& completedAchievements = player->GetAchievementMgr()->GetCompletedAchievements(); + for (auto& pair : completedAchievements) + { + AchievementEntry const* achievement = sAchievementStore.LookupEntry(pair.first); + if (achievement) + { + count += achievement->points; + } + } + + Eluna::Push(L, count); + return 1; + } + + /** + * Returns the [Player]s current amount of Achievements Completed + * + * @return uint32 achievementsCount + */ + int GetCompletedAchievementsCount(lua_State* L, Player* player) + { + uint32 count = 0; + bool countFeatsOfStrength = Eluna::CHECKVAL(L, 2, false); + const CompletedAchievementMap& completedAchievements = player->GetAchievementMgr()->GetCompletedAchievements(); + for (auto& pair : completedAchievements) + { + AchievementEntry const* achievement = sAchievementStore.LookupEntry(pair.first); + if (achievement && (achievement->categoryId != 81 || countFeatsOfStrength)) + { + count++; + } + } + + Eluna::Push(L, count); + return 1; + } #endif #if defined(TBC) || defined (WOTLK) @@ -1731,6 +1776,19 @@ namespace LuaPlayer return 1; } + /** + * Returns the [Player]s completed quest count + * + * @return int32 questcount + */ + int GetCompletedQuestsCount(lua_State* L, Player* player) + { + uint32 count = player->GetRewardedQuestCount(); + + Eluna::Push(L, count); + return 1; + } + /** * Returns the [Player]s [Corpse] object *