From 7bd0288658fc135744f0c6a274a8b0e610a1d4ec Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Wed, 23 Apr 2014 01:44:04 +0300 Subject: [PATCH] Eluna implement more hooks, remove unnecessary hooks and code. Can now use Reset to reset timed events and on spawn should be used for events that happen on spawn instead of reset. --- HookMgr.cpp | 178 ++++++++++++++++++++++++----------------------- HookMgr.h | 128 +++++++++++++++++++--------------- LuaEngine.h | 3 - LuaFunctions.cpp | 8 ++- VehicleMethods.h | 4 +- 5 files changed, 173 insertions(+), 148 deletions(-) diff --git a/HookMgr.cpp b/HookMgr.cpp index 5968327..d644bfe 100644 --- a/HookMgr.cpp +++ b/HookMgr.cpp @@ -55,19 +55,6 @@ void HookMgr::OnChange(Weather* weather, WeatherState state, float grade) sEluna->ServerEventBindings.ExecuteCall(); sEluna->ServerEventBindings.EndCall(); } -// transport -void HookMgr::OnAddPassenger(Transport* transport, Player* player) -{ -} -void HookMgr::OnAddCreaturePassenger(Transport* transport, Creature* creature) -{ -} -void HookMgr::OnRemovePassenger(Transport* transport, Player* player) -{ -} -void HookMgr::OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z) -{ -} // Auction House void HookMgr::OnAdd(AuctionHouseObject* ah) { @@ -479,6 +466,20 @@ bool HookMgr::OnExpire(Player* pPlayer, ItemTemplate const* pProto) return true; } +bool HookMgr::OnRemove(Player* pPlayer, Item* item) +{ + int bind = sEluna->ItemEventBindings.GetBind(item->GetEntry(), ITEM_EVENT_ON_REMOVE); + if (!bind) + return false; + ELUNA_GUARD(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, ITEM_EVENT_ON_REMOVE); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, item); + sEluna->ExecuteCall(3, 0); + return true; +} + // Player extern bool StartEluna(); bool HookMgr::OnCommand(Player* player, const char* text) @@ -1136,7 +1137,8 @@ bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg return result; } -#ifndef MANGOS +#ifndef CLASSIC +#ifndef TBC // Vehicle void HookMgr::OnInstall(Vehicle* vehicle) { @@ -1160,17 +1162,6 @@ void HookMgr::OnUninstall(Vehicle* vehicle) sEluna->VehicleEventBindings.EndCall(); } -void HookMgr::OnReset(Vehicle* vehicle) -{ - if (!sEluna->VehicleEventBindings.HasEvents(VEHICLE_EVENT_ON_RESET)) - return; - ELUNA_GUARD(); - sEluna->VehicleEventBindings.BeginCall(VEHICLE_EVENT_ON_RESET); - sEluna->Push(sEluna->L, vehicle); - sEluna->VehicleEventBindings.ExecuteCall(); - sEluna->VehicleEventBindings.EndCall(); -} - void HookMgr::OnInstallAccessory(Vehicle* vehicle, Creature* accessory) { if (!sEluna->VehicleEventBindings.HasEvents(VEHICLE_EVENT_ON_INSTALL_ACCESSORY)) @@ -1208,6 +1199,7 @@ void HookMgr::OnRemovePassenger(Vehicle* vehicle, Unit* passenger) sEluna->VehicleEventBindings.EndCall(); } #endif +#endif void HookMgr::OnAddMember(Guild* guild, Player* player, uint32 plRank) { @@ -1436,6 +1428,61 @@ void HookMgr::OnCreate(Group* group, uint64 leaderGuid, GroupType groupType) sEluna->GroupEventBindings.EndCall(); } +/* Map */ +void HookMgr::OnCreate(Map* map) +{ + if (!sEluna->ServerEventBindings.HasEvents(MAP_EVENT_ON_CREATE)) + return; + ELUNA_GUARD(); + sEluna->ServerEventBindings.BeginCall(MAP_EVENT_ON_CREATE); + sEluna->Push(sEluna->L, map); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} +void HookMgr::OnDestroy(Map* map) +{ + if (!sEluna->ServerEventBindings.HasEvents(MAP_EVENT_ON_DESTROY)) + return; + ELUNA_GUARD(); + sEluna->ServerEventBindings.BeginCall(MAP_EVENT_ON_DESTROY); + sEluna->Push(sEluna->L, map); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} +void HookMgr::OnPlayerEnter(Map* map, Player* player) +{ + if (!sEluna->ServerEventBindings.HasEvents(MAP_EVENT_ON_PLAYER_ENTER)) + return; + ELUNA_GUARD(); + sEluna->ServerEventBindings.BeginCall(MAP_EVENT_ON_PLAYER_ENTER); + sEluna->Push(sEluna->L, map); + sEluna->Push(sEluna->L, player); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} +void HookMgr::OnPlayerLeave(Map* map, Player* player) +{ + if (!sEluna->ServerEventBindings.HasEvents(MAP_EVENT_ON_PLAYER_LEAVE)) + return; + ELUNA_GUARD(); + sEluna->ServerEventBindings.BeginCall(MAP_EVENT_ON_PLAYER_LEAVE); + sEluna->Push(sEluna->L, map); + sEluna->Push(sEluna->L, player); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} +void HookMgr::OnUpdate(Map* map, uint32 diff) +{ + if (!sEluna->ServerEventBindings.HasEvents(MAP_EVENT_ON_UPDATE)) + return; + ELUNA_GUARD(); + sEluna->ServerEventBindings.BeginCall(MAP_EVENT_ON_UPDATE); + sEluna->Push(sEluna->L, map); + sEluna->Push(sEluna->L, diff); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} + // creature bool HookMgr::OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Creature* pTarget) { @@ -1599,10 +1646,6 @@ struct ElunaCreatureAI : ScriptedAI ElunaCreatureAI(Creature* creature) : ScriptedAI(creature) { JustRespawned(); -#ifdef MANGOS - if (!me->isDead()) - Reset(); -#endif } ~ElunaCreatureAI() {} @@ -1661,9 +1704,7 @@ struct ElunaCreatureAI : ScriptedAI void JustDied(Unit* killer) OVERRIDE { ScriptedAI::JustDied(killer); -#ifdef MANGOS - Reset(); -#endif + On_Reset(); int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_DIED); if (!bind) return; @@ -1755,9 +1796,7 @@ struct ElunaCreatureAI : ScriptedAI void EnterEvadeMode() OVERRIDE { ScriptedAI::EnterEvadeMode(); -#ifdef MANGOS - Reset(); -#endif + On_Reset(); int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_LEAVE_COMBAT); if (!bind) return; @@ -1787,6 +1826,7 @@ struct ElunaCreatureAI : ScriptedAI void JustRespawned() OVERRIDE { ScriptedAI::JustRespawned(); + On_Reset(); int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_SPAWN); if (!bind) return; @@ -1843,6 +1883,7 @@ struct ElunaCreatureAI : ScriptedAI } #ifdef MANGOS + // Enables use of MoveInLineOfSight bool IsVisible(Unit* who) const OVERRIDE { return me->IsWithinLOSInMap(who); @@ -1863,12 +1904,9 @@ struct ElunaCreatureAI : ScriptedAI sEluna->ExecuteCall(3, 0); } - //Called at creature reset either by death or evade - void Reset() + // Called on creature initial spawn, respawn, death, evade (leave combat) + void On_Reset() // Not an override, custom { -#ifdef TRINITY - ScriptedAI::Reset(); -#endif int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_RESET); if (!bind) return; @@ -1964,22 +2002,6 @@ struct ElunaCreatureAI : ScriptedAI sEluna->Push(sEluna->L, target); sEluna->ExecuteCall(3, 0); } - - void PassengerBoarded(Unit* passenger, int8 seatId, bool apply) OVERRIDE - { - ScriptedAI::PassengerBoarded(passenger, seatId, apply); - int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_PASSANGER_BOARDED); - if (!bind) - return; - ELUNA_GUARD(); - sEluna->BeginCall(bind); - sEluna->Push(sEluna->L, CREATURE_EVENT_ON_PASSANGER_BOARDED); - sEluna->Push(sEluna->L, me); - sEluna->Push(sEluna->L, passenger); - sEluna->Push(sEluna->L, seatId); - sEluna->Push(sEluna->L, apply); - sEluna->ExecuteCall(5, 0); - } #endif #ifdef MANGOS @@ -2097,28 +2119,6 @@ void HookMgr::UpdateAI(GameObject* pGameObject, uint32 diff) sEluna->ExecuteCall(3, 0); } -#ifndef MANGOS -struct ElunaGameObjectAI : public GameObjectAI -{ - ElunaGameObjectAI(GameObject* _go) : GameObjectAI(_go) {} - ~ElunaGameObjectAI() - { - } - - void Reset() OVERRIDE - { - int bind = sEluna->GameObjectEventBindings.GetBind(go->GetEntry(), GAMEOBJECT_EVENT_ON_RESET); - if (!bind) - return; - ELUNA_GUARD(); - sEluna->BeginCall(bind); - sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_RESET); - sEluna->Push(sEluna->L, go); - sEluna->ExecuteCall(2, 0); - } -}; -#endif - bool HookMgr::OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest) { int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_QUEST_REWARD); @@ -2148,6 +2148,8 @@ uint32 HookMgr::GetDialogStatus(Player* pPlayer, GameObject* pGameObject) return DIALOG_STATUS_SCRIPTED_NO_STATUS; // DIALOG_STATUS_UNDEFINED } +#ifndef CLASSIC +#ifndef TBC void HookMgr::OnDestroyed(GameObject* pGameObject, Player* pPlayer) { int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_DESTROYED); @@ -2173,8 +2175,10 @@ void HookMgr::OnDamaged(GameObject* pGameObject, Player* pPlayer) sEluna->Push(sEluna->L, pPlayer); sEluna->ExecuteCall(3, 0); } +#endif +#endif -void HookMgr::OnLootStateChanged(GameObject* pGameObject, uint32 state, Unit* pUnit) +void HookMgr::OnLootStateChanged(GameObject* pGameObject, uint32 state) { int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_LOOT_STATE_CHANGE); if (!bind) @@ -2184,7 +2188,6 @@ void HookMgr::OnLootStateChanged(GameObject* pGameObject, uint32 state, Unit* pU sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_LOOT_STATE_CHANGE); sEluna->Push(sEluna->L, pGameObject); sEluna->Push(sEluna->L, state); - sEluna->Push(sEluna->L, pUnit); sEluna->ExecuteCall(4, 0); } @@ -2208,14 +2211,17 @@ CreatureAI* HookMgr::GetAI(Creature* creature) return new ElunaCreatureAI(creature); } -#ifndef MANGOS -GameObjectAI* HookMgr::GetAI(GameObject* gameObject) +void HookMgr::OnSpawn(GameObject* gameobject) { - if (!sEluna->GameObjectEventBindings.GetBindMap(gameObject->GetEntry())) - return NULL; - return new ElunaGameObjectAI(gameObject); + int bind = sEluna->GameObjectEventBindings.GetBind(gameobject->GetEntry(), GAMEOBJECT_EVENT_ON_SPAWN); + if (!bind) + return; + ELUNA_GUARD(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_SPAWN); + sEluna->Push(sEluna->L, gameobject); + sEluna->ExecuteCall(2, 0); } -#endif void AddElunaScripts() { diff --git a/HookMgr.h b/HookMgr.h index 3d6eee7..d3ecf50 100644 --- a/HookMgr.h +++ b/HookMgr.h @@ -55,6 +55,16 @@ class Transport; class Unit; class Weather; class WorldPacket; +#ifndef CLASSIC +#ifndef TBC +#ifdef TRINITY +class Vehicle; +#else +class VehicleInfo; +typedef VehicleInfo Vehicle; +#endif +#endif +#endif enum RegisterTypes { @@ -105,13 +115,13 @@ enum ServerEvents ELUNA_EVENT_ON_RESTART = 16, // (event) // Map - MAP_EVENT_ON_CREATE = 17, // Not Implemented - MAP_EVENT_ON_DESTROY = 18, // Not Implemented - MAP_EVENT_ON_LOAD = 19, // Not Implemented - MAP_EVENT_ON_UNLOAD = 20, // Not Implemented - MAP_EVENT_ON_PLAYER_ENTER = 21, // Not Implemented - MAP_EVENT_ON_PLAYER_LEAVE = 22, // Not Implemented - MAP_EVENT_ON_UPDATE = 23, // Not Implemented + MAP_EVENT_ON_CREATE = 17, // (event, map) + MAP_EVENT_ON_DESTROY = 18, // (event, map) + MAP_EVENT_ON_GRID_LOAD = 19, // Not Implemented + MAP_EVENT_ON_GRID_UNLOAD = 20, // Not Implemented + MAP_EVENT_ON_PLAYER_ENTER = 21, // (event, map, player) + MAP_EVENT_ON_PLAYER_LEAVE = 22, // (event, map, player) + MAP_EVENT_ON_UPDATE = 23, // (event, map, diff) // Area trigger TRIGGER_EVENT_ON_TRIGGER = 24, // (event, player, triggerId) @@ -122,8 +132,8 @@ enum ServerEvents // Auction house AUCTION_EVENT_ON_ADD = 26, // (event, AHObject) AUCTION_EVENT_ON_REMOVE = 27, // (event, AHObject) - AUCTION_EVENT_ON_SUCCESSFUL = 28, // (event, AHObject) // NOT SUPPORTED YET - AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // NOT SUPPORTED YET + AUCTION_EVENT_ON_SUCCESSFUL = 28, // (event, AHObject) // Not Implemented + AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // Not Implemented // AddOns ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, type, prefix, msg, target) - target can be nil/whisper_target/guid/group/channel @@ -173,10 +183,10 @@ enum PlayerEvents PLAYER_EVENT_ON_REPOP = 35, // (event, player) PLAYER_EVENT_ON_RESURRECT = 36, // (event, player) PLAYER_EVENT_ON_LOOT_MONEY = 37, // (event, player, amount) - PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId) - PLAYER_EVENT_ON_GM_TICKET_CREATE = 39, // (event, player, ticketText) - PLAYER_EVENT_ON_GM_TICKET_UPDATE = 40, // (event, player, ticketText) - PLAYER_EVENT_ON_GM_TICKET_DELETE = 41, // (event, player) + PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId) // Not on TC + PLAYER_EVENT_ON_GM_TICKET_CREATE = 39, // (event, player, ticketText) // Not on TC + PLAYER_EVENT_ON_GM_TICKET_UPDATE = 40, // (event, player, ticketText) // Not on TC + PLAYER_EVENT_ON_GM_TICKET_DELETE = 41, // (event, player) // Not on TC PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command) - Can return false PLAYER_EVENT_COUNT @@ -190,12 +200,12 @@ enum GuildEventTypes GUILD_EVENT_ON_REMOVE_MEMBER = 2, // (event, guild, isDisbanding) GUILD_EVENT_ON_MOTD_CHANGE = 3, // (event, guild, newMotd) GUILD_EVENT_ON_INFO_CHANGE = 4, // (event, guild, newInfo) - GUILD_EVENT_ON_CREATE = 5, // (event, guild, leader, name) + GUILD_EVENT_ON_CREATE = 5, // (event, guild, leader, name) // Not on TC GUILD_EVENT_ON_DISBAND = 6, // (event, guild) GUILD_EVENT_ON_MONEY_WITHDRAW = 7, // (event, guild, player, amount, isRepair) GUILD_EVENT_ON_MONEY_DEPOSIT = 8, // (event, guild, player, amount) - GUILD_EVENT_ON_ITEM_MOVE = 9, // (event, guild, player, item, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId) - GUILD_EVENT_ON_EVENT = 10, // (event, guild, eventType, plrGUIDLow1, plrGUIDLow2, newRank) + GUILD_EVENT_ON_ITEM_MOVE = 9, // (event, guild, player, item, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId) // TODO + GUILD_EVENT_ON_EVENT = 10, // (event, guild, eventType, plrGUIDLow1, plrGUIDLow2, newRank) // TODO GUILD_EVENT_ON_BANK_EVENT = 11, // (event, guild, eventType, tabId, playerGUIDLow, itemOrMoney, itemStackCount, destTabId) GUILD_EVENT_COUNT @@ -218,12 +228,12 @@ enum GroupEvents // RegisterVehicleEvent(eventId, function) enum VehicleEvents { - VEHICLE_EVENT_ON_INSTALL = 1, - VEHICLE_EVENT_ON_UNINSTALL = 2, - VEHICLE_EVENT_ON_RESET = 3, - VEHICLE_EVENT_ON_INSTALL_ACCESSORY = 4, - VEHICLE_EVENT_ON_ADD_PASSENGER = 5, - VEHICLE_EVENT_ON_REMOVE_PASSENGER = 6, + VEHICLE_EVENT_ON_INSTALL = 1, // (event, vehicle) + VEHICLE_EVENT_ON_UNINSTALL = 2, // (event, vehicle) + // UNUSED = 3, // (event, vehicle) + VEHICLE_EVENT_ON_INSTALL_ACCESSORY = 4, // (event, vehicle, creature) + VEHICLE_EVENT_ON_ADD_PASSENGER = 5, // (event, vehicle, unit, seatId) + VEHICLE_EVENT_ON_REMOVE_PASSENGER = 6, // (event, vehicle, unit) VEHICLE_EVENT_COUNT }; @@ -242,8 +252,8 @@ enum CreatureEvents CREATURE_EVENT_ON_DAMAGE_TAKEN = 9, // (event, creature, attacker, damage) CREATURE_EVENT_ON_PRE_COMBAT = 10, // (event, creature, target) CREATURE_EVENT_ON_ATTACKED_AT = 11, // (event, creature, attacker) - CREATURE_EVENT_ON_OWNER_ATTACKED = 12, // (event, creature, target) // Not on mangos - CREATURE_EVENT_ON_OWNER_ATTACKED_AT = 13, // (event, creature, attacker) // Not on mangos + CREATURE_EVENT_ON_OWNER_ATTACKED = 12, // (event, creature, target) // Not on mangos + CREATURE_EVENT_ON_OWNER_ATTACKED_AT = 13, // (event, creature, attacker) // Not on mangos CREATURE_EVENT_ON_HIT_BY_SPELL = 14, // (event, creature, caster, spellid) CREATURE_EVENT_ON_SPELL_HIT_TARGET = 15, // (event, creature, target, spellid) // UNUSED = 16, // (event, creature) @@ -251,7 +261,7 @@ enum CreatureEvents // UNUSED = 18, // (event, creature) CREATURE_EVENT_ON_JUST_SUMMONED_CREATURE = 19, // (event, creature, summon) CREATURE_EVENT_ON_SUMMONED_CREATURE_DESPAWN = 20, // (event, creature, summon) - CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED = 21, // (event, creature, summon, killer) // Not on mangos + CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED = 21, // (event, creature, summon, killer) // Not on mangos CREATURE_EVENT_ON_SUMMONED = 22, // (event, creature, summoner) CREATURE_EVENT_ON_RESET = 23, // (event, creature) CREATURE_EVENT_ON_REACH_HOME = 24, // (event, creature) @@ -259,7 +269,7 @@ enum CreatureEvents CREATURE_EVENT_ON_CORPSE_REMOVED = 26, // (event, creature, respawndelay) CREATURE_EVENT_ON_MOVE_IN_LOS = 27, // (event, creature, unit) // UNUSED = 28, // (event, creature) - CREATURE_EVENT_ON_PASSANGER_BOARDED = 29, // (event, creature, passanger, seatid, apply) // Not on mangos + // UNUSED = 29, // (event, creature) CREATURE_EVENT_ON_DUMMY_EFFECT = 30, // (event, caster, spellid, effindex, creature) CREATURE_EVENT_ON_QUEST_ACCEPT = 31, // (event, player, creature, quest) CREATURE_EVENT_ON_QUEST_SELECT = 32, // (event, player, creature, quest) @@ -273,15 +283,15 @@ enum CreatureEvents enum GameObjectEvents { GAMEOBJECT_EVENT_ON_AIUPDATE = 1, // (event, go, diff) - GAMEOBJECT_EVENT_ON_RESET = 2, // (event, go) // TODO + GAMEOBJECT_EVENT_ON_SPAWN = 2, // (event, go) GAMEOBJECT_EVENT_ON_DUMMY_EFFECT = 3, // (event, caster, spellid, effindex, go) GAMEOBJECT_EVENT_ON_QUEST_ACCEPT = 4, // (event, player, go, quest) GAMEOBJECT_EVENT_ON_QUEST_REWARD = 5, // (event, player, go, quest, opt) GAMEOBJECT_EVENT_ON_DIALOG_STATUS = 6, // (event, player, go) - GAMEOBJECT_EVENT_ON_DESTROYED = 7, // (event, go, player) // TODO - GAMEOBJECT_EVENT_ON_DAMAGED = 8, // (event, go, player) // TODO - GAMEOBJECT_EVENT_ON_LOOT_STATE_CHANGE = 9, // (event, go, state, unit) // TODO - GAMEOBJECT_EVENT_ON_GO_STATE_CHANGED = 10, // (event, go, state) // TODO + GAMEOBJECT_EVENT_ON_DESTROYED = 7, // (event, go, player) + GAMEOBJECT_EVENT_ON_DAMAGED = 8, // (event, go, player) + GAMEOBJECT_EVENT_ON_LOOT_STATE_CHANGE = 9, // (event, go, state) + GAMEOBJECT_EVENT_ON_GO_STATE_CHANGED = 10, // (event, go, state) GAMEOBJECT_EVENT_ON_QUEST_COMPLETE = 11, // (event, player, go, quest) GAMEOBJECT_EVENT_COUNT }; @@ -293,6 +303,7 @@ enum ItemEvents ITEM_EVENT_ON_USE = 2, // (event, player, item, target) ITEM_EVENT_ON_QUEST_ACCEPT = 3, // (event, player, item, quest) ITEM_EVENT_ON_EXPIRE = 4, // (event, player, itemid) + ITEM_EVENT_ON_REMOVE = 5, // (event, player, item) ITEM_EVENT_COUNT }; @@ -327,10 +338,10 @@ public: void OnEquip(Player* pPlayer, Item* pItem, uint8 bag, uint8 slot); void OnRepop(Player* pPlayer); void OnResurrect(Player* pPlayer); - void OnQuestAbandon(Player* pPlayer, uint32 questId); // Not on TC - void OnGmTicketCreate(Player* pPlayer, std::string& ticketText); // Not on TC - void OnGmTicketUpdate(Player* pPlayer, std::string& ticketText); // Not on TC - void OnGmTicketDelete(Player* pPlayer); // Not on TC + void OnQuestAbandon(Player* pPlayer, uint32 questId); + void OnGmTicketCreate(Player* pPlayer, std::string& ticketText); + void OnGmTicketUpdate(Player* pPlayer, std::string& ticketText); + void OnGmTicketDelete(Player* pPlayer); InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry); void OnEngineRestart(); bool OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel); @@ -340,6 +351,7 @@ public: bool OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest); bool OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets); bool OnExpire(Player* pPlayer, ItemTemplate const* pProto); + bool OnRemove(Player* pPlayer, Item* item); void HandleGossipSelectOption(Player* pPlayer, Item* item, uint32 sender, uint32 action, std::string code); /* Creature */ @@ -351,7 +363,7 @@ public: bool OnQuestSelect(Player* pPlayer, Creature* pCreature, Quest const* pQuest); bool OnQuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest); bool OnQuestReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest); - uint32 GetDialogStatus(Player* pPlayer, Creature* pCreature); // Not on TC + uint32 GetDialogStatus(Player* pPlayer, Creature* pCreature); void OnSummoned(Creature* creature, Unit* summoner); /* GameObject */ @@ -362,13 +374,17 @@ public: bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest); bool OnQuestComplete(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest); bool OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest); - bool OnGameObjectUse(Player* pPlayer, GameObject* pGameObject) { return false; }; // TODO? Not on TC uint32 GetDialogStatus(Player* pPlayer, GameObject* pGameObject); - void OnDestroyed(GameObject* pGameObject, Player* pPlayer); // TODO - void OnDamaged(GameObject* pGameObject, Player* pPlayer); // TODO - void OnLootStateChanged(GameObject* pGameObject, uint32 state, Unit* pUnit); // TODO - void OnGameObjectStateChanged(GameObject* pGameObject, uint32 state); // TODO +#ifndef CLASSIC +#ifndef TBC + void OnDestroyed(GameObject* pGameObject, Player* pPlayer); + void OnDamaged(GameObject* pGameObject, Player* pPlayer); +#endif +#endif + void OnLootStateChanged(GameObject* pGameObject, uint32 state); + void OnGameObjectStateChanged(GameObject* pGameObject, uint32 state); void UpdateAI(GameObject* pGameObject, uint32 diff); + void OnSpawn(GameObject* gameobject); /* Packet */ bool OnPacketSend(WorldSession* session, WorldPacket& packet); @@ -404,24 +420,25 @@ public: void OnSave(Player* pPlayer); void OnBindToInstance(Player* pPlayer, Difficulty difficulty, uint32 mapid, bool permanent); void OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea); - void OnMapChanged(Player* pPlayer); // TODO + void OnMapChanged(Player* pPlayer); void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, std::string code); -#ifndef MANGOS +#ifndef CLASSIC +#ifndef TBC /* Vehicle */ void OnInstall(Vehicle* vehicle); void OnUninstall(Vehicle* vehicle); - void OnReset(Vehicle* vehicle); void OnInstallAccessory(Vehicle* vehicle, Creature* accessory); void OnAddPassenger(Vehicle* vehicle, Unit* passenger, int8 seatId); void OnRemovePassenger(Vehicle* vehicle, Unit* passenger); +#endif #endif /* AreaTrigger */ bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger); /* Weather */ - void OnChange(Weather* weather, WeatherState state, float grade); // TODO + void OnChange(Weather* weather, WeatherState state, float grade); /* Auction House */ void OnAdd(AuctionHouseObject* auctionHouse); @@ -429,25 +446,17 @@ public: void OnSuccessful(AuctionHouseObject* auctionHouse); void OnExpire(AuctionHouseObject* auctionHouse); - /* Condition */ - - /* Transport */ - void OnAddPassenger(Transport* transport, Player* player); // TODO - void OnAddCreaturePassenger(Transport* transport, Creature* creature); // TODO - void OnRemovePassenger(Transport* transport, Player* player); // TODO - void OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z); // TODO - /* Guild */ void OnAddMember(Guild* guild, Player* player, uint32 plRank); void OnRemoveMember(Guild* guild, Player* player, bool isDisbanding); void OnMOTDChanged(Guild* guild, const std::string& newMotd); void OnInfoChanged(Guild* guild, const std::string& newInfo); - void OnCreate(Guild* guild, Player* leader, const std::string& name); // TODO: Implement to TC + void OnCreate(Guild* guild, Player* leader, const std::string& name); void OnDisband(Guild* guild); void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair); void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount); - void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId); // TODO: Implement - void OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank); // TODO: Implement + void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId); + void OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank); void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); /* Group */ @@ -457,6 +466,13 @@ public: void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid); void OnDisband(Group* group); void OnCreate(Group* group, uint64 leaderGuid, GroupType groupType); + + /* Map */ + void OnCreate(Map* map); + void OnDestroy(Map* map); + void OnPlayerEnter(Map* map, Player* player); + void OnPlayerLeave(Map* map, Player* player); + void OnUpdate(Map* map, uint32 diff); }; #ifdef MANGOS #define sHookMgr (&MaNGOS::Singleton::Instance()) diff --git a/LuaEngine.h b/LuaEngine.h index 0aa77ec..2a97c36 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -95,9 +95,6 @@ typedef std::set ScriptPaths; typedef TemporarySummon TempSummon; #ifndef CLASSIC #define PLAYER_FIELD_LIFETIME_HONORABLE_KILLS PLAYER_FIELD_LIFETIME_HONORBALE_KILLS -#ifndef TBC -typedef VehicleInfo Vehicle; -#endif #endif #define MAX_TALENT_SPECS MAX_TALENT_SPEC_COUNT #define GUID_ENPART(guid) ObjectGuid(guid).GetEntry() diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 3579139..54d1b98 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -1039,7 +1039,8 @@ ElunaRegister GuildMethods[] = { NULL, NULL }, }; -#if (!defined(TBC) && !defined(CLASSIC)) +#ifndef CLASSIC +#ifndef TBC ElunaRegister VehicleMethods[] = { // Getters @@ -1057,6 +1058,7 @@ ElunaRegister VehicleMethods[] = { NULL, NULL }, }; #endif +#endif ElunaRegister QueryMethods[] = { @@ -1228,9 +1230,11 @@ void RegisterFunctions(lua_State* L) ElunaTemplate::SetMethods(L, ObjectMethods); ElunaTemplate::SetMethods(L, ItemMethods); -#if (!defined(TBC) && !defined(CLASSIC)) +#ifndef CLASSIC +#ifndef TBC ElunaTemplate::Register(L, "Vehicle"); ElunaTemplate::SetMethods(L, VehicleMethods); +#endif #endif ElunaTemplate::Register(L, "Group"); diff --git a/VehicleMethods.h b/VehicleMethods.h index f235d6e..2345948 100644 --- a/VehicleMethods.h +++ b/VehicleMethods.h @@ -6,7 +6,8 @@ #ifndef VEHICLEMETHODS_H #define VEHICLEMETHODS_H -#if (!defined(TBC) && !defined(CLASSIC)) +#ifndef CLASSIC +#ifndef TBC namespace LuaVehicle { @@ -76,5 +77,6 @@ namespace LuaVehicle } } +#endif #endif #endif \ No newline at end of file