diff --git a/src/game/BattleGround/BattleGround.cpp b/src/game/BattleGround/BattleGround.cpp index c291f3250..3bdeb68e7 100644 --- a/src/game/BattleGround/BattleGround.cpp +++ b/src/game/BattleGround/BattleGround.cpp @@ -41,6 +41,9 @@ #include "Formulas.h" #include "GridNotifiersImpl.h" #include "Chat.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ namespace MaNGOS { @@ -256,6 +259,10 @@ BattleGround::BattleGround(): m_BuffChange(false), m_ArenaBuffSpawned(false), m_ BattleGround::~BattleGround() { +#ifdef ENABLE_ELUNA + // sEluna->OnBGDestroy(this, GetTypeID(), GetInstanceID()); +#endif /* ENABLE_ELUNA */ + // remove objects and creatures // (this is done automatically in mapmanager update, when the instance is reset after the reset time) sBattleGroundMgr.RemoveBattleGround(GetInstanceID(), GetTypeID()); @@ -656,6 +663,9 @@ void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* void BattleGround::EndBattleGround(Team winner) { +#ifdef ENABLE_ELUNA + sEluna->OnBGEnd(this, GetTypeID(), GetInstanceID(), winner); +#endif /* ENABLE_ELUNA */ this->RemoveFromBGFreeSlotQueue(); ArenaTeam* winner_arena_team = NULL; @@ -1205,6 +1215,10 @@ void BattleGround::StartBattleGround() // This must be done here, because we need to have already invited some players when first BG::Update() method is executed // and it doesn't matter if we call StartBattleGround() more times, because m_BattleGrounds is a map and instance id never changes sBattleGroundMgr.AddBattleGround(GetInstanceID(), GetTypeID(), this); + +#ifdef ENABLE_ELUNA + sEluna->OnBGStart(this, GetTypeID(), GetInstanceID()); +#endif /* ENABLE_ELUNA */ } void BattleGround::StartTimedAchievement(AchievementCriteriaTypes type, uint32 entry) diff --git a/src/game/BattleGround/BattleGroundMgr.cpp b/src/game/BattleGround/BattleGroundMgr.cpp index 71b9bf29f..c75861f76 100644 --- a/src/game/BattleGround/BattleGroundMgr.cpp +++ b/src/game/BattleGround/BattleGroundMgr.cpp @@ -48,6 +48,9 @@ #include "World.h" #include "WorldPacket.h" #include "GameEventMgr.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ #include "Policies/Singleton.h" @@ -1857,6 +1860,10 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsA // add bg to update list AddBattleGround(bg->GetInstanceID(), bg->GetTypeID(), bg); + +#ifdef ENABLE_ELUNA + sEluna->OnBGCreate(bg, bgTypeId, bg->GetInstanceID()); +#endif /* ENABLE_ELUNA */ // return some not-null value, bgTypeId is good enough for me return bgTypeId; diff --git a/src/game/Object/Creature.cpp b/src/game/Object/Creature.cpp index 95f34a0fe..c711e57e0 100644 --- a/src/game/Object/Creature.cpp +++ b/src/game/Object/Creature.cpp @@ -212,6 +212,11 @@ void Creature::AddToWorld() // Make active if required if (sWorld.isForceLoadMap(GetMapId()) || (GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_ACTIVE)) SetActiveObjectState(true); + +#ifdef ENABLE_ELUNA + if (!IsInWorld()) + sEluna->OnAddToWorld(this); +#endif /* ENABLE_ELUNA */ } void Creature::RemoveFromWorld() diff --git a/src/game/Object/GameObject.cpp b/src/game/Object/GameObject.cpp index 8e27dd5d0..2a8ebee0f 100644 --- a/src/game/Object/GameObject.cpp +++ b/src/game/Object/GameObject.cpp @@ -108,6 +108,11 @@ void GameObject::AddToWorld() // After Object::AddToWorld so that for initial state the GO is added to the world (and hence handled correctly) UpdateCollisionState(); + +#ifdef ENABLE_ELUNA + if (!IsInWorld()) + sEluna->OnAddToWorld(this); +#endif /* ENABLE_ELUNA */ } void GameObject::RemoveFromWorld() diff --git a/src/game/Object/Guild.cpp b/src/game/Object/Guild.cpp index cfccb7927..b40352ced 100644 --- a/src/game/Object/Guild.cpp +++ b/src/game/Object/Guild.cpp @@ -36,6 +36,9 @@ #include "Language.h" #include "World.h" #include "Calendar.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ //// MemberSlot //////////////////////////////////////////// void MemberSlot::SetMemberStats(Player* player) @@ -148,6 +151,11 @@ bool Guild::Create(Player* leader, std::string gname) CreateDefaultGuildRanks(lSession->GetSessionDbLocaleIndex()); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnCreate(this, leader, gname.c_str()); +#endif /* ENABLE_ELUNA */ + return AddMember(m_LeaderGuid, (uint32)GR_GUILDMASTER); } @@ -249,6 +257,11 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank) UpdateAccountsNumber(); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnAddMember(this, pl, newmember.RankId); +#endif /* ENABLE_ELUNA */ + return true; } @@ -259,6 +272,11 @@ void Guild::SetMOTD(std::string motd) // motd now can be used for encoding to DB CharacterDatabase.escape_string(motd); CharacterDatabase.PExecute("UPDATE guild SET motd='%s' WHERE guildid='%u'", motd.c_str(), m_Id); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnMOTDChanged(this, motd); +#endif /* ENABLE_ELUNA */ } void Guild::SetGINFO(std::string ginfo) @@ -268,6 +286,11 @@ void Guild::SetGINFO(std::string ginfo) // ginfo now can be used for encoding to DB CharacterDatabase.escape_string(ginfo); CharacterDatabase.PExecute("UPDATE guild SET info='%s' WHERE guildid='%u'", ginfo.c_str(), m_Id); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnInfoChanged(this, ginfo); +#endif /* ENABLE_ELUNA */ } bool Guild::LoadGuildFromDB(QueryResult* guildDataResult) @@ -567,6 +590,11 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding) if (!isDisbanding) UpdateAccountsNumber(); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnRemoveMember(this, player, isDisbanding); // IsKicked not a part of Mangos, implement? +#endif /* ENABLE_ELUNA */ + return members.empty(); } @@ -861,6 +889,12 @@ void Guild::Disband() CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid = '%u'", m_Id); CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid = '%u'", m_Id); CharacterDatabase.CommitTransaction(); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnDisband(this); +#endif /* ENABLE_ELUNA */ + sGuildMgr.RemoveGuild(m_Id); } diff --git a/src/game/Object/Player.cpp b/src/game/Object/Player.cpp index e2341e69d..76c92f8ea 100644 --- a/src/game/Object/Player.cpp +++ b/src/game/Object/Player.cpp @@ -2573,6 +2573,11 @@ void Player::GiveXP(uint32 xp, Unit* victim) uint32 level = getLevel(); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnGiveXP(this, xp, victim); +#endif /* ENABLE_ELUNA */ + // XP to money conversion processed in Player::RewardQuest if (level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) return; @@ -2690,6 +2695,11 @@ void Player::GiveLevel(uint32 level) // resend quests status directly SendQuestGiverStatusMultiple(); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnLevelChanged(this, level); +#endif /* ENABLE_ELUNA */ } void Player::UpdateFreeTalentPoints(bool resetIfNeed) @@ -3864,6 +3874,11 @@ uint32 Player::resetTalentsCost() const bool Player::resetTalents(bool no_cost, bool all_specs) { + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnTalentsReset(this, no_cost); +#endif /* ENABLE_ELUNA */ + // not need after this call if (HasAtLoginFlag(AT_LOGIN_RESET_TALENTS) && all_specs) RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS, true); @@ -4678,6 +4693,10 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) // update visibility of player for nearby cameras UpdateObjectVisibility(); +#ifdef ENABLE_ELUNA + sEluna->OnResurrect(this); +#endif /* ENABLE_ELUNA */ + if (!applySickness) return; @@ -6953,9 +6972,10 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) } } + // Used by Eluna #ifdef ENABLE_ELUNA sEluna->OnUpdateZone(this, newZone, newArea); -#endif +#endif /* ENABLE_ELUNA */ m_zoneUpdateId = newZone; m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL; @@ -7096,6 +7116,11 @@ void Player::DuelComplete(DuelCompleteType type) duel->opponent->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1); } + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnDuelEnd(duel->opponent, this, type); +#endif /* ENABLE_ELUNA */ + // Remove Duel Flag object if (GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER))) duel->initiator->RemoveGameObject(obj, true); @@ -10542,6 +10567,12 @@ InventoryResult Player::CanUseItem(ItemPrototype const* pProto) const if (getLevel() < pProto->RequiredLevel) return EQUIP_ERR_CANT_EQUIP_LEVEL_I; +#ifdef ENABLE_ELUNA + InventoryResult eres = sEluna->OnCanUseItem(this, pProto->ItemId); + if (eres != EQUIP_ERR_OK) + return eres; +#endif + return EQUIP_ERR_OK; } return EQUIP_ERR_ITEM_NOT_FOUND; @@ -10866,6 +10897,11 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) ApplyEquipCooldown(pItem2); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnEquip(this, pItem2, bag, slot); +#endif /* ENABLE_ELUNA */ + return pItem2; } // Apply Titan's Grip damage penalty if necessary @@ -10875,6 +10911,10 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) // only for full equip instead adding to stack GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, slot + 1); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnEquip(this, pItem, bag, slot); +#endif /* ENABLE_ELUNA */ return pItem; } @@ -11104,6 +11144,9 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) ApplyItemOnStoreSpell(pItem, false); ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount()); +#ifdef ENABLE_ELUNA + sEluna->OnRemove(this, pItem); +#endif /* ENABLE_ELUNA */ if (bag == INVENTORY_SLOT_BAG_0) { @@ -17059,6 +17102,10 @@ InstancePlayerBind* Player::BindToInstance(DungeonPersistentState* state, bool p if (!load) DEBUG_LOG("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), state->GetMapId(), state->GetInstanceId(), state->GetDifficulty()); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnBindToInstance(this, (Difficulty)0, state->GetMapId(), permanent); +#endif /* ENABLE_ELUNA */ return &bind; } else @@ -17291,6 +17338,13 @@ void Player::SaveToDB() CharacterDatabase.BeginTransaction(); + +#ifdef ENABLE_ELUNA + // Hack to check that this is not on create save + if (!HasAtLoginFlag(AT_LOGIN_FIRST)) + sEluna->OnSave(this); +#endif /* ENABLE_ELUNA */ + static SqlStatementID delChar ; static SqlStatementID insChar ; @@ -18383,6 +18437,11 @@ void Player::UpdateDuelFlag(time_t currTime) if (!duel || duel->startTimer == 0 || currTime < duel->startTimer + 3) return; + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnDuelStart(this, duel->opponent); +#endif /* ENABLE_ELUNA */ + SetUInt32Value(PLAYER_DUEL_TEAM, 1); duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 2); @@ -22776,6 +22835,9 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa // learn! (other talent ranks will unlearned at learning) pet->learnSpell(spellid); DETAIL_LOG("PetTalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid); +#ifdef ENABLE_ELUNA + sEluna->OnLearnTalents(this, talentId, talentRank, spellid); +#endif /*ENABLE_ELUNA*/ } void Player::UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode) diff --git a/src/game/Object/ReputationMgr.cpp b/src/game/Object/ReputationMgr.cpp index 6eaec99ae..03f8256fd 100644 --- a/src/game/Object/ReputationMgr.cpp +++ b/src/game/Object/ReputationMgr.cpp @@ -27,6 +27,9 @@ #include "Player.h" #include "WorldPacket.h" #include "ObjectMgr.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ const int32 ReputationMgr::PointsInRank[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000}; @@ -240,6 +243,11 @@ void ReputationMgr::Initialize() void ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental) { + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnReputationChange(m_player, factionEntry->ID, standing, incremental); +#endif /* ENABLE_ELUNA */ + bool anyRankIncreased = false; // if spillover definition exists in DB, override DBC diff --git a/src/game/Object/Totem.cpp b/src/game/Object/Totem.cpp index 7f470bbfa..aa60cabc0 100644 --- a/src/game/Object/Totem.cpp +++ b/src/game/Object/Totem.cpp @@ -31,6 +31,9 @@ #include "SpellMgr.h" #include "CreatureAI.h" #include "InstanceData.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM) { @@ -102,6 +105,9 @@ void Totem::Summon(Unit* owner) if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->AI()) ((Creature*)owner)->AI()->JustSummoned((Creature*)this); +#ifdef ENABLE_ELUNA + sEluna->OnSummoned(this, owner); +#endif /* ENABLE_ELUNA */ // there are some totems, which exist just for their visual appeareance if (!GetSpell()) diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index a24165039..ad6798b10 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -1138,13 +1138,14 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) { ((Creature*)this)->AI()->KilledUnit(pVictim); } -#ifdef ENABLE_ELUNA if (Creature* killer = ToCreature()) { + // Used by Eluna +#ifdef ENABLE_ELUNA if (Player* killed = pVictim->ToPlayer()) sEluna->OnPlayerKilledByCreature(killer, killed); +#endif /* ENABLE_ELUNA */ } -#endif // Call AI OwnerKilledUnit (for any current summoned minipet/guardian/protector) PetOwnerKilledUnit(pVictim); @@ -1210,9 +1211,10 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa { outdoorPvP->HandlePlayerKill(player_tap, playerVictim); } } + // Used by Eluna #ifdef ENABLE_ELUNA sEluna->OnPVPKill(player_tap, playerVictim); -#endif +#endif /* ENABLE_ELUNA */ } } else // Killed creature diff --git a/src/game/Server/WorldSocket.cpp b/src/game/Server/WorldSocket.cpp index bfe7afaaf..f8e99048e 100644 --- a/src/game/Server/WorldSocket.cpp +++ b/src/game/Server/WorldSocket.cpp @@ -48,6 +48,9 @@ #include "WorldSocketMgr.h" #include "Log.h" #include "DBCStores.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ #if defined( __GNUC__ ) #pragma pack(1) @@ -172,6 +175,11 @@ int WorldSocket::SendPacket(const WorldPacket& pct) // Dump outgoing packet. sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), pct.GetOpcodeName(), &pct, false); +//#ifdef ENABLE_ELUNA +// if (!sEluna->OnPacketSend(m_Session, pct)) +// { return 0; } +//#endif /* ENABLE_ELUNA */ + ServerPktHeader header(pct.size() + 2, pct.GetOpcode()); m_Crypt.EncryptSend((uint8*)header.header, header.getHeaderLength()); @@ -700,10 +708,17 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) return -1; } +#ifdef ENABLE_ELUNA + if (!sEluna->OnPacketReceive(m_Session, *new_pct)) + return 0; +#endif /* ENABLE_ELUNA */ return HandleAuthSession(*new_pct); case CMSG_KEEP_ALIVE: DEBUG_LOG("CMSG_KEEP_ALIVE ,size: " SIZEFMTD " ", new_pct->size()); +#ifdef ENABLE_ELUNA + sEluna->OnPacketReceive(m_Session, *new_pct); +#endif /* ENABLE_ELUNA */ return 0; default: { diff --git a/src/game/WorldHandlers/AuctionHouseHandler.cpp b/src/game/WorldHandlers/AuctionHouseHandler.cpp index e0f7e52ab..b70adc250 100644 --- a/src/game/WorldHandlers/AuctionHouseHandler.cpp +++ b/src/game/WorldHandlers/AuctionHouseHandler.cpp @@ -35,6 +35,9 @@ #include "Mail.h" #include "Util.h" #include "Chat.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ // please DO NOT use iterator++, because it is slower than ++iterator!!! // post-incrementation is always slower than pre-incrementation ! @@ -366,6 +369,11 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data) SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK); GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnAdd(auctionHouse, AH); +#endif /* ENABLE_ELUNA */ } } @@ -512,6 +520,11 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recv_data) CharacterDatabase.CommitTransaction(); sAuctionMgr.RemoveAItem(auction->itemGuidLow); auctionHouse->RemoveAuction(auction->Id); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnRemove(auctionHouse, auction); +#endif /* ENABLE_ELUNA */ delete auction; } diff --git a/src/game/WorldHandlers/CharacterHandler.cpp b/src/game/WorldHandlers/CharacterHandler.cpp index 0c4643db0..f0512cffb 100644 --- a/src/game/WorldHandlers/CharacterHandler.cpp +++ b/src/game/WorldHandlers/CharacterHandler.cpp @@ -46,6 +46,9 @@ #include "Language.h" #include "SpellMgr.h" #include "Calendar.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ // config option SkipCinematics supported values enum CinematicsSkipMode @@ -552,6 +555,11 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data) BASIC_LOG("Account: %d (IP: %s) Create Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), pNewChar->GetGUIDLow()); sLog.outChar("Account: %d (IP: %s) Create Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), pNewChar->GetGUIDLow()); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnCreate(pNewChar); +#endif /* ENABLE_ELUNA */ + delete pNewChar; // created only to call SaveToDB() } @@ -604,6 +612,11 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recv_data) BASIC_LOG("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid); sLog.outChar("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnDelete(lowguid); +#endif /* ENABLE_ELUNA */ + if (sLog.IsOutCharDump()) // optimize GetPlayerDump call { std::string dump = PlayerDumpWriter().GetDump(lowguid); @@ -884,10 +897,20 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) SendNotification(LANG_RESET_TALENTS); // we can use SMSG_TALENTS_INVOLUNTARILY_RESET here } + // Used by Eluna +#ifdef ENABLE_ELUNA if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST)) - pCurrChar->RemoveAtLoginFlag(AT_LOGIN_FIRST); + sEluna->OnFirstLogin(pCurrChar); +#endif /* ENABLE_ELUNA */ - // show time before shutdown if shutdown planned. + + /* We've done what we need to, remove the flag */ + if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST)) + { + pCurrChar->RemoveAtLoginFlag(AT_LOGIN_FIRST); + } + + /* If the server is shutting down, show shutdown time remaining */ if (sWorld.IsShutdowning()) sWorld.ShutdownMsg(true, pCurrChar); @@ -917,6 +940,11 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) // Handle Login-Achievements (should be handled after loading) pCurrChar->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, 1); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnLogin(pCurrChar); +#endif /* ENABLE_ELUNA */ + delete holder; } diff --git a/src/game/WorldHandlers/Chat.cpp b/src/game/WorldHandlers/Chat.cpp index f646210f2..c6b3a1581 100644 --- a/src/game/WorldHandlers/Chat.cpp +++ b/src/game/WorldHandlers/Chat.cpp @@ -41,6 +41,9 @@ #include "PoolManager.h" #include "GameEventMgr.h" #include "AuctionHouseBot/AuctionHouseBot.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ // Supported shift-links (client generated and server side) // |color|Hachievement:achievement_id:player_guid_hex:completed_0_1:mm:dd:yy_from_2000:criteriaMask1:criteriaMask2:criteriaMask3:criteriaMask4|h[name]|h|r @@ -1270,6 +1273,10 @@ void ChatHandler::ExecuteCommand(const char* text) } case CHAT_COMMAND_UNKNOWN_SUBCOMMAND: { +#ifdef ENABLE_ELUNA + if (!sEluna->OnCommand(m_session ? m_session->GetPlayer() : NULL, fullcmd.c_str())) + return; +#endif /* ENABLE_ELUNA */ SendSysMessage(LANG_NO_SUBCMD); ShowHelpForCommand(command->ChildCommands, text); SetSentErrorMessage(true); @@ -1277,6 +1284,10 @@ void ChatHandler::ExecuteCommand(const char* text) } case CHAT_COMMAND_UNKNOWN: { +#ifdef ENABLE_ELUNA + if (!sEluna->OnCommand(m_session ? m_session->GetPlayer() : NULL, fullcmd.c_str())) + return; +#endif /* ENABLE_ELUNA */ SendSysMessage(LANG_NO_CMD); SetSentErrorMessage(true); break; diff --git a/src/game/WorldHandlers/ChatHandler.cpp b/src/game/WorldHandlers/ChatHandler.cpp index 4829c79de..de9dd947e 100644 --- a/src/game/WorldHandlers/ChatHandler.cpp +++ b/src/game/WorldHandlers/ChatHandler.cpp @@ -41,6 +41,9 @@ #include "Util.h" #include "GridNotifiersImpl.h" #include "CellImpl.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg, uint32 lang) { @@ -207,12 +210,30 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) break; if (type == CHAT_MSG_SAY) - GetPlayer()->Say(msg, lang); + { +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) + return; +#endif /* ENABLE_ELUNA */ + GetPlayer()->Say(msg, lang); + } else if (type == CHAT_MSG_EMOTE) - GetPlayer()->TextEmote(msg); + { +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, LANG_UNIVERSAL, msg)) + return; +#endif /* ENABLE_ELUNA */ + GetPlayer()->TextEmote(msg); + } else if (type == CHAT_MSG_YELL) - GetPlayer()->Yell(msg, lang); - } break; + { +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) + return; +#endif /* ENABLE_ELUNA */ + GetPlayer()->Yell(msg, lang); + } + } break; case CHAT_MSG_WHISPER: { @@ -255,6 +276,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) } } + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnChat(GetPlayer(), type, lang, msg, player); +#endif /* ENABLE_ELUNA */ GetPlayer()->Whisper(msg, lang, player->GetObjectGuid()); } break; @@ -287,6 +312,11 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) if ((type == CHAT_MSG_PARTY_LEADER) && !group->IsLeader(_player->GetObjectGuid())) return; + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + return; +#endif /* ENABLE_ELUNA */ WorldPacket data; ChatHandler::BuildChatPacket(data, ChatMsg(type), msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName()); @@ -313,7 +343,15 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) if (GetPlayer()->GetGuildId()) if (Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId())) + { + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild)) + return; +#endif /* ENABLE_ELUNA */ + guild->BroadcastToGuild(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL); + } break; } @@ -336,7 +374,15 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) if (GetPlayer()->GetGuildId()) if (Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId())) + { + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild)) + return; +#endif /* ENABLE_ELUNA */ + guild->BroadcastToOfficers(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL); + } break; } @@ -366,6 +412,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) return; } + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + return; +#endif /* ENABLE_ELUNA */ + WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName()); group->BroadcastPacket(&data, false); @@ -396,6 +448,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) return; } + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + return; +#endif /* ENABLE_ELUNA */ + WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID_LEADER, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName()); group->BroadcastPacket(&data, false); @@ -417,6 +475,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) !(group->IsLeader(GetPlayer()->GetObjectGuid()) || group->IsAssistant(GetPlayer()->GetObjectGuid()))) return; + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + return; +#endif /* ENABLE_ELUNA */ + WorldPacket data; // in battleground, raid warning is sent only to players in battleground - code is ok ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID_WARNING, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName()); @@ -439,6 +503,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) if (!group || !group->isBGGroup()) return; + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + return; +#endif /* ENABLE_ELUNA */ + WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_BATTLEGROUND, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName()); group->BroadcastPacket(&data, false); @@ -460,6 +530,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetObjectGuid())) return; + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + return; +#endif /* ENABLE_ELUNA */ + WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_BATTLEGROUND_LEADER, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName()); group->BroadcastPacket(&data, false); @@ -480,8 +556,18 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) break; if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + { if (Channel* chn = cMgr->GetChannel(channel, _player)) - chn->Say(_player, msg.c_str(), lang); + { + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, chn)) + return; +#endif /* ENABLE_ELUNA */ + chn->Say(_player, msg.c_str(), lang); + } + } + } break; case CHAT_MSG_AFK: @@ -507,6 +593,11 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) _player->ToggleAFK(); } + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) + return; +#endif /* ENABLE_ELUNA */ } break; } @@ -531,6 +622,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) _player->ToggleDND(); } + // Used by Eluna +#ifdef ENABLE_ELUNA + if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) + return; +#endif /* ENABLE_ELUNA */ + break; } @@ -659,7 +756,11 @@ void WorldSession::HandleEmoteOpcode(WorldPacket& recv_data) uint32 emote; recv_data >> emote; - DEBUG_LOG("CMSG_EMOTE %u", emote); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnEmote(GetPlayer(), emote); +#endif /* ENABLE_ELUNA */ GetPlayer()->HandleEmoteCommand(emote); } @@ -717,6 +818,11 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recv_data) recv_data >> emoteNum; recv_data >> guid; + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnTextEmote(GetPlayer(), text_emote, emoteNum, guid); +#endif /* ENABLE_ELUNA */ + EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(text_emote); if (!em) return; diff --git a/src/game/WorldHandlers/Group.cpp b/src/game/WorldHandlers/Group.cpp index 52ffc1cdb..3debbd12f 100644 --- a/src/game/WorldHandlers/Group.cpp +++ b/src/game/WorldHandlers/Group.cpp @@ -39,6 +39,10 @@ #include "Util.h" #include "LootMgr.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ + #define LOOT_ROLL_TIMEOUT (1*MINUTE*IN_MILLISECONDS) //=================================================== @@ -172,6 +176,11 @@ bool Group::Create(ObjectGuid guid, const char* name) _updateLeaderFlag(); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnCreate(this, m_leaderGuid, m_groupType); +#endif /* ENABLE_ELUNA */ + return true; } @@ -264,6 +273,11 @@ bool Group::AddInvite(Player* player) player->SetGroupInvite(this); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnInviteMember(this, player->GetObjectGuid()); +#endif /* ENABLE_ELUNA */ + return true; } @@ -347,6 +361,11 @@ bool Group::AddMember(ObjectGuid guid, const char* name) player->SetGroupUpdateFlag(GROUP_UPDATE_FULL); UpdatePlayerOutOfRange(player); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnAddMember(this, player->GetObjectGuid()); +#endif /* ENABLE_ELUNA */ + // quest related GO state dependent from raid membership if (isRaidGroup()) player->UpdateForQuestWorldObjects(); @@ -405,6 +424,11 @@ uint32 Group::RemoveMember(ObjectGuid guid, uint8 method) else Disband(true); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnRemoveMember(this, guid, method); // Kicker and Reason not a part of Mangos, implement? +#endif /* ENABLE_ELUNA */ + return m_memberSlots.size(); } @@ -414,6 +438,11 @@ void Group::ChangeLeader(ObjectGuid guid) if (slot == m_memberSlots.end()) return; + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnChangeLeader(this, guid, GetLeaderGuid()); +#endif /* ENABLE_ELUNA */ + _setLeader(guid); WorldPacket data(SMSG_GROUP_SET_LEADER, slot->name.size() + 1); @@ -490,6 +519,11 @@ void Group::Disband(bool hideDestroy) } _updateLeaderFlag(true); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnDisband(this); +#endif /* ENABLE_ELUNA */ + m_leaderGuid.Clear(); m_leaderName.clear(); } diff --git a/src/game/WorldHandlers/GuildHandler.cpp b/src/game/WorldHandlers/GuildHandler.cpp index 11c164cd3..9fd93e112 100644 --- a/src/game/WorldHandlers/GuildHandler.cpp +++ b/src/game/WorldHandlers/GuildHandler.cpp @@ -34,6 +34,9 @@ #include "GossipDef.h" #include "SocialMgr.h" #include "Calendar.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket) { diff --git a/src/game/WorldHandlers/LootHandler.cpp b/src/game/WorldHandlers/LootHandler.cpp index 37b4dc98c..711bfc920 100644 --- a/src/game/WorldHandlers/LootHandler.cpp +++ b/src/game/WorldHandlers/LootHandler.cpp @@ -37,6 +37,9 @@ #include "World.h" #include "Util.h" #include "DBCStores.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data) { @@ -294,6 +297,11 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/) player->GetSession()->SendPacket(&data); } + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnLootMoney(player, pLoot->gold); +#endif /* ENABLE_ELUNA */ + pLoot->gold = 0; if (pItem) @@ -598,6 +606,11 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data) target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count); + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnLootItem(target, newitem, item.count, lootguid); +#endif /* ENABLE_ELUNA */ + // mark as looted item.count = 0; item.is_looted = true; diff --git a/src/game/WorldHandlers/Map.cpp b/src/game/WorldHandlers/Map.cpp index 134fdf7b0..ffea5df86 100644 --- a/src/game/WorldHandlers/Map.cpp +++ b/src/game/WorldHandlers/Map.cpp @@ -64,6 +64,11 @@ Map::~Map() if (m_persistentState) { m_persistentState->SetUsedByMapState(NULL); } // field pointer can be deleted after this +//#ifdef ENABLE_ELUNA +// if (Instanceable()) +// sEluna->FreeInstanceId(GetInstanceId()); +//#endif /* ENABLE_ELUNA */ + delete i_data; i_data = NULL; @@ -118,6 +123,9 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode) m_persistentState->SetUsedByMapState(this); m_weatherSystem = new WeatherSystem(this); +#ifdef ENABLE_ELUNA + sEluna->OnCreate(this); +#endif /* ENABLE_ELUNA */ } void Map::InitVisibilityDistance() @@ -323,6 +331,11 @@ bool Map::Add(Player* player) player->GetViewPoint().Event_AddedToWorld(&(*grid)(cell.CellX(), cell.CellY())); UpdateObjectVisibility(player, cell, p); +#ifdef ENABLE_ELUNA + sEluna->OnMapChanged(player); + sEluna->OnPlayerEnter(this, player); +#endif /* ENABLE_ELUNA */ + if (i_data) { i_data->OnPlayerEnter(player); } @@ -587,6 +600,10 @@ void Map::Update(const uint32& t_diff) if (!m_scriptSchedule.empty()) { ScriptsProcess(); } +#ifdef ENABLE_ELUNA + sEluna->OnUpdate(this, t_diff); +#endif /* ENABLE_ELUNA */ + if (i_data) { i_data->Update(t_diff); } @@ -595,6 +612,10 @@ void Map::Update(const uint32& t_diff) void Map::Remove(Player* player, bool remove) { +#ifdef ENABLE_ELUNA + sEluna->OnPlayerLeave(this, player); +#endif /* ENABLE_ELUNA */ + if (i_data) { i_data->OnPlayerLeave(player); } @@ -1015,6 +1036,13 @@ void Map::AddObjectToRemoveList(WorldObject* obj) { MANGOS_ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId()); +#ifdef ENABLE_ELUNA + if (Creature* creature = obj->ToCreature()) + sEluna->OnRemove(creature); + else if (GameObject* gameobject = obj->ToGameObject()) + sEluna->OnRemove(gameobject); +#endif /* ENABLE_ELUNA */ + obj->CleanupsBeforeDelete(); // remove or simplify at least cross referenced links i_objectsToRemove.insert(obj); @@ -1202,6 +1230,10 @@ void Map::CreateInstanceData(bool load) return; } +//#ifdef ENABLE_ELUNA +// i_data = sEluna->GetInstanceData(this); +//#endif /* ENABLE_ELUNA */ + uint32 i_script_id = GetScriptId(); if (!i_script_id) @@ -1595,7 +1627,7 @@ void DungeonMap::PermBindAllPlayers(Player* player) void DungeonMap::UnloadAll(bool pForce) { TeleportAllPlayersTo(TELEPORT_LOCATION_HOMEBIND); - + if (m_resetAfterUnload == true) { GetPersistanceState()->DeleteRespawnTimes(); } @@ -2195,6 +2227,7 @@ bool Map::ContainsGameObjectModel(const GameObjectModel& mdl) const { return m_dyn_tree.contains(mdl); } + // This will generate a random point to all directions in water for the provided point in radius range. bool Map::GetRandomPointUnderWater(uint32 phaseMask, float& x, float& y, float& z, float radius, GridMapLiquidData& liquid_status) { diff --git a/src/game/WorldHandlers/MiscHandler.cpp b/src/game/WorldHandlers/MiscHandler.cpp index 25b33f060..7e7cab627 100644 --- a/src/game/WorldHandlers/MiscHandler.cpp +++ b/src/game/WorldHandlers/MiscHandler.cpp @@ -49,6 +49,9 @@ #include "Pet.h" #include "SocialMgr.h" #include "DBCEnums.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data) { @@ -73,6 +76,11 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data) GetPlayer()->KillPlayer(); } + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnRepop(GetPlayer()); +#endif /* ENABLE_ELUNA */ + // this is spirit release confirm? GetPlayer()->RemovePet(PET_SAVE_REAGENTS); GetPlayer()->BuildPlayerRepop(); diff --git a/src/game/WorldHandlers/NPCHandler.cpp b/src/game/WorldHandlers/NPCHandler.cpp index a91a105ef..d238b76ac 100644 --- a/src/game/WorldHandlers/NPCHandler.cpp +++ b/src/game/WorldHandlers/NPCHandler.cpp @@ -40,6 +40,9 @@ #include "Guild.h" #include "GuildMgr.h" #include "Chat.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ enum StableResultCode { diff --git a/src/game/WorldHandlers/QuestHandler.cpp b/src/game/WorldHandlers/QuestHandler.cpp index ab5ae23c2..21361bdc0 100644 --- a/src/game/WorldHandlers/QuestHandler.cpp +++ b/src/game/WorldHandlers/QuestHandler.cpp @@ -35,6 +35,9 @@ #include "ObjectAccessor.h" #include "ScriptMgr.h" #include "Group.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recv_data) { @@ -347,6 +350,11 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data) } _player->SetQuestStatus(quest, QUEST_STATUS_NONE); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnQuestAbandon(_player, quest); +#endif /* ENABLE_ELUNA */ } _player->SetQuestSlot(slot, 0); diff --git a/src/game/WorldHandlers/Spell.cpp b/src/game/WorldHandlers/Spell.cpp index 18290962f..d210c8fc6 100644 --- a/src/game/WorldHandlers/Spell.cpp +++ b/src/game/WorldHandlers/Spell.cpp @@ -55,6 +55,9 @@ #include "Vehicle.h" #include "TemporarySummon.h" #include "SQLStorages.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS]; @@ -3504,6 +3507,11 @@ void Spell::cast(bool skipCheck) ((Player*)m_caster)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, m_CastItem->GetEntry()); ((Player*)m_caster)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, m_spellInfo->Id); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnSpellCast(m_caster->ToPlayer(), this, skipCheck); +#endif /* ENABLE_ELUNA */ } FillTargetMap(); diff --git a/src/game/WorldHandlers/SpellEffects.cpp b/src/game/WorldHandlers/SpellEffects.cpp index 11bd0e2b4..a9fa04aab 100644 --- a/src/game/WorldHandlers/SpellEffects.cpp +++ b/src/game/WorldHandlers/SpellEffects.cpp @@ -66,6 +66,9 @@ #include "Vehicle.h" #include "G3D/Vector3.h" #include "LootMgr.h" +#ifdef ENABLE_ELUNA +#include "LuaEngine.h" +#endif /* ENABLE_ELUNA */ pEffect SpellEffects[TOTAL_SPELL_EFFECTS] = { @@ -6042,7 +6045,13 @@ bool Spell::DoSummonVehicle(CreatureSummonPositions& list, SummonPropertiesEntry // Notify Summoner if (m_originalCaster && m_originalCaster != m_caster && m_originalCaster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_originalCaster)->AI()) ((Creature*)m_originalCaster)->AI()->JustSummoned(spawnCreature); - +#ifdef ENABLE_ELUNA + if (Unit* summoner = m_caster->ToUnit()) + sEluna->OnSummoned(spawnCreature, summoner); + else if (m_originalCaster) + if (Unit* summoner = m_originalCaster->ToUnit()) + sEluna->OnSummoned(spawnCreature, summoner); +#endif /* ENABLE_ELUNA */ return true; } @@ -10218,6 +10227,11 @@ void Spell::EffectDuel(SpellEffectEntry const* effect) caster->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetObjectGuid()); target->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetObjectGuid()); + + // Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnDuelRequest(target, caster); +#endif /* ENABLE_ELUNA */ } void Spell::EffectStuck(SpellEffectEntry const* effect /*effect*/) @@ -10474,6 +10488,10 @@ void Spell::EffectApplyGlyph(SpellEffectEntry const* effect) player->SendTalentsInfoData(false); } } +//#ifdef ENABLE_ELUNA +// if (Unit* summoner = m_originalCaster->ToUnit()) +// sEluna->OnSummoned(spawnCreature, summoner); +//#endif /* ENABLE_ELUNA */ } void Spell::EffectEnchantHeldItem(SpellEffectEntry const* effect) diff --git a/src/game/WorldHandlers/World.cpp b/src/game/WorldHandlers/World.cpp index d821da97d..947a45d02 100644 --- a/src/game/WorldHandlers/World.cpp +++ b/src/game/WorldHandlers/World.cpp @@ -1985,6 +1985,10 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) m_ShutdownTimer = time; ShutdownMsg(true); } + ///- Used by Eluna +#ifdef ENABLE_ELUNA + sEluna->OnShutdownInitiate(ShutdownExitCode(exitcode), ShutdownMask(options)); +#endif /* ENABLE_ELUNA */ } /// Display a shutdown message to the user(s)