diff --git a/GlobalMethods.h b/GlobalMethods.h index a87cda3..1326b5d 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -568,9 +568,9 @@ namespace LuaGlobalFunctions * SERVER_EVENT_ON_NETWORK_STOP = 2, // Not Implemented * SERVER_EVENT_ON_SOCKET_OPEN = 3, // Not Implemented * SERVER_EVENT_ON_SOCKET_CLOSE = 4, // Not Implemented - * SERVER_EVENT_ON_PACKET_RECEIVE = 5, // (event, packet, player) - Player only if accessible. Can return false or a new packet + * SERVER_EVENT_ON_PACKET_RECEIVE = 5, // (event, packet, player) - Player only if accessible. Can return false, newPacket * SERVER_EVENT_ON_PACKET_RECEIVE_UNKNOWN = 6, // Not Implemented - * SERVER_EVENT_ON_PACKET_SEND = 7, // (event, packet, player) - Player only if accessible. Can return false or a new packet + * SERVER_EVENT_ON_PACKET_SEND = 7, // (event, packet, player) - Player only if accessible. Can return false, newPacket * * // World * WORLD_EVENT_ON_OPEN_STATE_CHANGE = 8, // (event, open) - Needs core support on Mangos @@ -584,7 +584,6 @@ namespace LuaGlobalFunctions * * // Eluna * ELUNA_EVENT_ON_LUA_STATE_CLOSE = 16, // (event) - triggers just before shutting down eluna (on shutdown and restart) - * ELUNA_EVENT_ON_LUA_STATE_OPEN = 33, // (event) - triggers after all scripts are loaded * * // Map * MAP_EVENT_ON_CREATE = 17, // (event, map) @@ -596,24 +595,28 @@ namespace LuaGlobalFunctions * MAP_EVENT_ON_UPDATE = 23, // (event, map, diff) * * // Area trigger - * TRIGGER_EVENT_ON_TRIGGER = 24, // (event, player, triggerId) + * TRIGGER_EVENT_ON_TRIGGER = 24, // (event, player, triggerId) - Can return true * * // Weather - * WEATHER_EVENT_ON_CHANGE = 25, // (event, weather, state, grade) + * WEATHER_EVENT_ON_CHANGE = 25, // (event, zoneId, state, grade) * * // Auction house - * AUCTION_EVENT_ON_ADD = 26, // (event, AHObject) - * AUCTION_EVENT_ON_REMOVE = 27, // (event, AHObject) - * AUCTION_EVENT_ON_SUCCESSFUL = 28, // (event, AHObject) // Not Implemented - * AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // Not Implemented + * AUCTION_EVENT_ON_ADD = 26, // (event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow) + * AUCTION_EVENT_ON_REMOVE = 27, // (event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow) + * AUCTION_EVENT_ON_SUCCESSFUL = 28, // (event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow) + * AUCTION_EVENT_ON_EXPIRE = 29, // (event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow) * * // AddOns - * ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, type, prefix, msg, target) - target can be nil/whisper_target/guild/group/channel + * ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, type, prefix, msg, target) - target can be nil/whisper_target/guild/group/channel. Can return false * * WORLD_EVENT_ON_DELETE_CREATURE = 31, // (event, creature) * WORLD_EVENT_ON_DELETE_GAMEOBJECT = 32, // (event, gameobject) * - * SERVER_EVENT_COUNT + * // Eluna + * ELUNA_EVENT_ON_LUA_STATE_OPEN = 33, // (event) - triggers after all scripts are loaded + * + * GAME_EVENT_START = 34, // (event, gameeventid) + * GAME_EVENT_STOP = 35, // (event, gameeventid) * }; * * @proto cancel = (event, function) diff --git a/Hooks.h b/Hooks.h index 4791db3..95e29f5 100644 --- a/Hooks.h +++ b/Hooks.h @@ -152,6 +152,9 @@ namespace Hooks // Eluna ELUNA_EVENT_ON_LUA_STATE_OPEN = 33, // (event) - triggers after all scripts are loaded + GAME_EVENT_START = 34, // (event, gameeventid) + GAME_EVENT_STOP = 35, // (event, gameeventid) + SERVER_EVENT_COUNT }; diff --git a/LuaEngine.h b/LuaEngine.h index 6a84648..38eccf9 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -523,6 +523,8 @@ public: void OnShutdownCancel(); void OnStartup(); void OnShutdown(); + void OnGameEventStart(uint32 eventid); + void OnGameEventStop(uint32 eventid); /* Battle Ground */ void OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId); diff --git a/ServerHooks.cpp b/ServerHooks.cpp index 5f99c58..a6ecdda 100644 --- a/ServerHooks.cpp +++ b/ServerHooks.cpp @@ -85,6 +85,20 @@ void Eluna::OnTimedEvent(int funcRef, uint32 delay, uint32 calls, WorldObject* o InvalidateObjects(); } +void Eluna::OnGameEventStart(uint32 eventid) +{ + START_HOOK(GAME_EVENT_START); + Push(eventid); + CallAllFunctions(ServerEventBindings, key); +} + +void Eluna::OnGameEventStop(uint32 eventid) +{ + START_HOOK(GAME_EVENT_STOP); + Push(eventid); + CallAllFunctions(ServerEventBindings, key); +} + void Eluna::OnLuaStateClose() { START_HOOK(ELUNA_EVENT_ON_LUA_STATE_CLOSE);