mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
@@ -736,6 +736,11 @@ public:
|
||||
{
|
||||
sEluna->OnLearnSpell(player, spellId);
|
||||
}
|
||||
|
||||
void OnAchiComplete(Player* player, AchievementEntry const* achievement) override
|
||||
{
|
||||
sEluna->OnAchiComplete(player, achievement);
|
||||
}
|
||||
};
|
||||
|
||||
class Eluna_ServerScript : public ServerScript
|
||||
|
||||
23
src/LuaEngine/AchievementMethods.h
Normal file
23
src/LuaEngine/AchievementMethods.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef ACHIEVEMENTMETHODS_H
|
||||
#define ACHIEVEMENTMETHODS_H
|
||||
|
||||
namespace LuaAchievement
|
||||
{
|
||||
/**
|
||||
* Returns the [Achievement]s ID
|
||||
*
|
||||
* @return uint32 id
|
||||
*/
|
||||
int GetId(lua_State* L, AchievementEntry* const achievement)
|
||||
{
|
||||
Eluna::Push(L, achievement->ID);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
@@ -706,7 +706,8 @@ namespace LuaGlobalFunctions
|
||||
* // UNUSED = 41, // (event, player)
|
||||
* PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command, chatHandler) - player is nil if command used from console. Can return false
|
||||
* PLAYER_EVENT_ON_PET_ADDED_TO_WORLD = 43, // (event, player, pet)
|
||||
* * PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId)
|
||||
* PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId)
|
||||
* PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE = 45, // (event, player, achievement)
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
|
||||
@@ -206,6 +206,7 @@ namespace Hooks
|
||||
PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command, chatHandler) - player is nil if command used from console. Can return false
|
||||
PLAYER_EVENT_ON_PET_ADDED_TO_WORLD = 43, // (event, player, pet)
|
||||
PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId)
|
||||
PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE = 45, // (event, player, achievement)
|
||||
|
||||
PLAYER_EVENT_COUNT
|
||||
};
|
||||
|
||||
@@ -473,6 +473,7 @@ public:
|
||||
void OnMapChanged(Player* pPlayer);
|
||||
void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, const std::string& code);
|
||||
void OnLearnSpell(Player* player, uint32 spellId);
|
||||
void OnAchiComplete(Player* player, AchievementEntry const* achievement);
|
||||
|
||||
#ifndef CLASSIC
|
||||
#ifndef TBC
|
||||
|
||||
@@ -37,6 +37,7 @@ extern "C"
|
||||
#include "VehicleMethods.h"
|
||||
#include "BattleGroundMethods.h"
|
||||
#include "ChatHandlerMethods.h"
|
||||
#include "AchievementMethods.h"
|
||||
|
||||
luaL_Reg GlobalMethods[] =
|
||||
{
|
||||
@@ -1319,6 +1320,13 @@ ElunaRegister<ChatHandler> ChatHandlerMethods[] =
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
ElunaRegister<AchievementEntry> AchievementMethods[] =
|
||||
{
|
||||
{ "GetId", &LuaAchievement::GetId },
|
||||
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
// fix compile error about accessing vehicle destructor
|
||||
template<> int ElunaTemplate<Vehicle>::CollectGarbage(lua_State* L)
|
||||
@@ -1461,6 +1469,9 @@ void RegisterFunctions(Eluna* E)
|
||||
ElunaTemplate<ElunaQuery>::Register(E, "ElunaQuery", true);
|
||||
ElunaTemplate<ElunaQuery>::SetMethods(E, QueryMethods);
|
||||
|
||||
ElunaTemplate<AchievementEntry>::Register(E, "AchievementEntry", true);
|
||||
ElunaTemplate<AchievementEntry>::SetMethods(E, AchievementMethods);
|
||||
|
||||
ElunaTemplate<long long>::Register(E, "long long", true);
|
||||
|
||||
ElunaTemplate<unsigned long long>::Register(E, "unsigned long long", true);
|
||||
|
||||
@@ -566,3 +566,11 @@ void Eluna::OnLearnSpell(Player* player, uint32 spellId)
|
||||
Push(spellId);
|
||||
CallAllFunctions(PlayerEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnAchiComplete(Player* player, AchievementEntry const* achievement)
|
||||
{
|
||||
START_HOOK(PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE);
|
||||
Push(player);
|
||||
Push(achievement);
|
||||
CallAllFunctions(PlayerEventBindings, key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user