mirror of
https://github.com/azerothcore/mod-ale
synced 2025-12-01 21:15:19 +08:00
feat: Add 4 methods (#158)
1: Player:GetAchievementPoints 2: Player:GetCompletedQuestsCount This should have been GetCompletedQuestsCount, not sure how to update that now. 3: You also have an option to include feats of strength or not (not included by default, blizzard like) Player:GetCompletedAchievementsCount 4: RegisterPlayerEvent OnCreatureKilledByPet
This commit is contained in:
@@ -806,6 +806,11 @@ public:
|
|||||||
{
|
{
|
||||||
sEluna->OnBattlegroundDesertion(player, type);
|
sEluna->OnBattlegroundDesertion(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnCreatureKilledByPet(Player* player, Creature* killed) override
|
||||||
|
{
|
||||||
|
sEluna->OnCreatureKilledByPet(player, killed);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Eluna_ServerScript : public ServerScript
|
class Eluna_ServerScript : public ServerScript
|
||||||
|
|||||||
@@ -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_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_GROUP_ROLL_REWARD_ITEM = 56, // (event, player, item, count, voteType, roll)
|
||||||
PLAYER_EVENT_ON_BG_DESERTION = 57, // (event, player, type)
|
PLAYER_EVENT_ON_BG_DESERTION = 57, // (event, player, type)
|
||||||
|
PLAYER_EVENT_ON_PET_KILL = 58, // (event, player, killer)
|
||||||
|
|
||||||
PLAYER_EVENT_COUNT
|
PLAYER_EVENT_COUNT
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -490,6 +490,7 @@ public:
|
|||||||
bool OnCanGroupInvite(Player* player, std::string& memberName);
|
bool OnCanGroupInvite(Player* player, std::string& memberName);
|
||||||
void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll);
|
void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll);
|
||||||
void OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type);
|
void OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type);
|
||||||
|
void OnCreatureKilledByPet(Player* player, Creature* killed);
|
||||||
|
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
#ifndef TBC
|
#ifndef TBC
|
||||||
|
|||||||
@@ -472,6 +472,7 @@ ElunaRegister<Player> PlayerMethods[] =
|
|||||||
{ "GetGuild", &LuaPlayer::GetGuild },
|
{ "GetGuild", &LuaPlayer::GetGuild },
|
||||||
{ "GetAccountId", &LuaPlayer::GetAccountId },
|
{ "GetAccountId", &LuaPlayer::GetAccountId },
|
||||||
{ "GetAccountName", &LuaPlayer::GetAccountName },
|
{ "GetAccountName", &LuaPlayer::GetAccountName },
|
||||||
|
{ "GetCompletedQuestsCount", &LuaPlayer::GetCompletedQuestsCount },
|
||||||
#if defined (TBC) || defined (WOTLK)
|
#if defined (TBC) || defined (WOTLK)
|
||||||
{ "GetArenaPoints", &LuaPlayer::GetArenaPoints },
|
{ "GetArenaPoints", &LuaPlayer::GetArenaPoints },
|
||||||
{ "GetHonorPoints", &LuaPlayer::GetHonorPoints },
|
{ "GetHonorPoints", &LuaPlayer::GetHonorPoints },
|
||||||
@@ -492,6 +493,8 @@ ElunaRegister<Player> PlayerMethods[] =
|
|||||||
{ "GetRestBonus", &LuaPlayer::GetRestBonus },
|
{ "GetRestBonus", &LuaPlayer::GetRestBonus },
|
||||||
#ifdef WOTLK
|
#ifdef WOTLK
|
||||||
{ "GetPhaseMaskForSpawn", &LuaPlayer::GetPhaseMaskForSpawn },
|
{ "GetPhaseMaskForSpawn", &LuaPlayer::GetPhaseMaskForSpawn },
|
||||||
|
{ "GetAchievementPoints", &LuaPlayer::GetAchievementPoints },
|
||||||
|
{ "GetCompletedAchievementsCount", &LuaPlayer::GetCompletedAchievementsCount },
|
||||||
#endif
|
#endif
|
||||||
{ "GetReqKillOrCastCurrentCount", &LuaPlayer::GetReqKillOrCastCurrentCount },
|
{ "GetReqKillOrCastCurrentCount", &LuaPlayer::GetReqKillOrCastCurrentCount },
|
||||||
{ "GetQuestStatus", &LuaPlayer::GetQuestStatus },
|
{ "GetQuestStatus", &LuaPlayer::GetQuestStatus },
|
||||||
|
|||||||
@@ -698,3 +698,11 @@ void Eluna::OnBattlegroundDesertion(Player* player, const BattlegroundDesertionT
|
|||||||
Push(type);
|
Push(type);
|
||||||
CallAllFunctions(PlayerEventBindings, key);
|
CallAllFunctions(PlayerEventBindings, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Eluna::OnCreatureKilledByPet(Player* player, Creature* killed)
|
||||||
|
{
|
||||||
|
START_HOOK(PLAYER_EVENT_ON_PET_KILL);
|
||||||
|
Push(player);
|
||||||
|
Push(killed);
|
||||||
|
CallAllFunctions(PlayerEventBindings, key);
|
||||||
|
}
|
||||||
|
|||||||
@@ -903,6 +903,51 @@ namespace LuaPlayer
|
|||||||
Eluna::Push(L, player->GetPhaseMaskForSpawn());
|
Eluna::Push(L, player->GetPhaseMaskForSpawn());
|
||||||
return 1;
|
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<bool>(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
|
#endif
|
||||||
|
|
||||||
#if defined(TBC) || defined (WOTLK)
|
#if defined(TBC) || defined (WOTLK)
|
||||||
@@ -1731,6 +1776,19 @@ namespace LuaPlayer
|
|||||||
return 1;
|
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
|
* Returns the [Player]s [Corpse] object
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user