From 94e2b9332a1f6ceec024338b8f41cd3dca099a40 Mon Sep 17 00:00:00 2001 From: Spp Date: Fri, 8 Nov 2013 10:50:51 +0100 Subject: Core/Logging: Remove LOG_FILTER_XXX defines with it's value (remember logger names are case-sensitive) --- src/server/scripts/Commands/cs_account.cpp | 22 ++-- src/server/scripts/Commands/cs_arena.cpp | 12 +- src/server/scripts/Commands/cs_debug.cpp | 6 +- src/server/scripts/Commands/cs_gobject.cpp | 2 +- src/server/scripts/Commands/cs_misc.cpp | 4 +- src/server/scripts/Commands/cs_modify.cpp | 6 +- src/server/scripts/Commands/cs_npc.cpp | 8 +- src/server/scripts/Commands/cs_pet.cpp | 2 +- src/server/scripts/Commands/cs_reload.cpp | 188 ++++++++++++++--------------- src/server/scripts/Commands/cs_reset.cpp | 2 +- 10 files changed, 126 insertions(+), 126 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 45ab88e9688..6e9dbea8b21 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -133,7 +133,7 @@ public: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); if (handler->GetSession()) { - TC_LOG_INFO(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) created Account %s (Email: '%s')", + TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Character:[%s] (GUID: %u) created Account %s (Email: '%s')", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), accountName, email.c_str()); @@ -298,7 +298,7 @@ public: else { handler->PSendSysMessage("[IP2NATION] Table empty"); - TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[IP2NATION] Table empty"); + TC_LOG_DEBUG("server.authserver", "[IP2NATION] Table empty"); } } else if (param == "off") @@ -378,7 +378,7 @@ public: { handler->SendSysMessage(LANG_COMMAND_WRONGEMAIL); handler->SetSentErrorMessage(true); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided email [%s] is not equal to registration email [%s].", + TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided email [%s] is not equal to registration email [%s].", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), email, oldEmail); @@ -389,7 +389,7 @@ public: { handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); handler->SetSentErrorMessage(true); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided password is wrong.", + TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided password is wrong.", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow()); return false; @@ -406,7 +406,7 @@ public: { handler->SendSysMessage(LANG_NEW_EMAILS_NOT_MATCH); handler->SetSentErrorMessage(true); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided password is wrong.", + TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided password is wrong.", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow()); return false; @@ -418,7 +418,7 @@ public: { case AOR_OK: handler->SendSysMessage(LANG_COMMAND_EMAIL); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "Account: %u (IP: %s) Character:[%s] (GUID: %u) Changed Email from [%s] to [%s].", + TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Changed Email from [%s] to [%s].", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), oldEmail, email); @@ -470,7 +470,7 @@ public: { handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); handler->SetSentErrorMessage(true); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the provided old password is wrong.", + TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the provided old password is wrong.", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow()); return false; @@ -482,7 +482,7 @@ public: { handler->SendSysMessage(LANG_COMMAND_WRONGEMAIL); handler->SetSentErrorMessage(true); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the entered email [%s] is wrong.", + TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the entered email [%s] is wrong.", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), emailConfirmation); @@ -503,7 +503,7 @@ public: { case AOR_OK: handler->SendSysMessage(LANG_COMMAND_PASSWORD); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "Account: %u (IP: %s) Character:[%s] (GUID: %u) Changed Password.", + TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Changed Password.", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow()); break; @@ -845,7 +845,7 @@ public: { case AOR_OK: handler->SendSysMessage(LANG_COMMAND_EMAIL); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "ChangeEmail: Account %s [Id: %u] had it's email changed to %s.", + TC_LOG_INFO("entities.player.character", "ChangeEmail: Account %s [Id: %u] had it's email changed to %s.", accountName.c_str(), targetAccountId, email); break; case AOR_NAME_NOT_EXIST: @@ -921,7 +921,7 @@ public: { case AOR_OK: handler->SendSysMessage(LANG_COMMAND_EMAIL); - TC_LOG_INFO(LOG_FILTER_CHARACTER, "ChangeRegEmail: Account %s [Id: %u] had it's Registration Email changed to %s.", + TC_LOG_INFO("entities.player.character", "ChangeRegEmail: Account %s [Id: %u] had it's Registration Email changed to %s.", accountName.c_str(), targetAccountId, email); break; case AOR_NAME_NOT_EXIST: diff --git a/src/server/scripts/Commands/cs_arena.cpp b/src/server/scripts/Commands/cs_arena.cpp index 57eb87d0ef8..42cfa50bc05 100644 --- a/src/server/scripts/Commands/cs_arena.cpp +++ b/src/server/scripts/Commands/cs_arena.cpp @@ -143,10 +143,10 @@ public: std::string name = arena->GetName(); arena->Disband(); if (handler->GetSession()) - TC_LOG_DEBUG(LOG_FILTER_ARENAS, "GameMaster: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", + TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), arena->GetType(), teamId); else - TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Console: disbanded arena team type: %u [Id: %u].", arena->GetType(), teamId); + TC_LOG_DEBUG("bg.arena", "Console: disbanded arena team type: %u [Id: %u].", arena->GetType(), teamId); delete(arena); @@ -208,10 +208,10 @@ public: handler->PSendSysMessage(LANG_ARENA_RENAME, arena->GetId(), oldArenaStr, newArenaStr); if (handler->GetSession()) - TC_LOG_DEBUG(LOG_FILTER_ARENAS, "GameMaster: %s [GUID: %u] rename arena team \"%s\"[Id: %u] to \"%s\"", + TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] rename arena team \"%s\"[Id: %u] to \"%s\"", handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), oldArenaStr, arena->GetId(), newArenaStr); else - TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Console: rename arena team \"%s\"[Id: %u] to \"%s\"", oldArenaStr, arena->GetId(), newArenaStr); + TC_LOG_DEBUG("bg.arena", "Console: rename arena team \"%s\"[Id: %u] to \"%s\"", oldArenaStr, arena->GetId(), newArenaStr); return true; } @@ -284,10 +284,10 @@ public: handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->m_name.c_str(), target->GetName().c_str()); if (handler->GetSession()) - TC_LOG_DEBUG(LOG_FILTER_ARENAS, "GameMaster: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]", + TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]", handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), target->GetName().c_str(), target->GetGUIDLow(), arena->GetName().c_str(), arena->GetId()); else - TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Console: promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]", + TC_LOG_DEBUG("bg.arena", "Console: promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]", target->GetName().c_str(), target->GetGUIDLow(), arena->GetName().c_str(), arena->GetId()); return true; diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index f33e583522e..a4ccbc40211 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -413,11 +413,11 @@ public: } else { - TC_LOG_ERROR(LOG_FILTER_GENERAL, "Sending opcode that has unknown type '%s'", type.c_str()); + TC_LOG_ERROR("misc", "Sending opcode that has unknown type '%s'", type.c_str()); break; } } - TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Sending opcode %u", data.GetOpcode()); + TC_LOG_DEBUG("network", "Sending opcode %u", data.GetOpcode()); data.hexlike(); player->GetSession()->SendPacket(&data); handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName().c_str()); @@ -1360,7 +1360,7 @@ public: { Player* player = handler->GetSession()->GetPlayer(); - TC_LOG_INFO(LOG_FILTER_SQL_DEV, "(@PATH, XX, %.3f, %.3f, %.5f, 0, 0, 0, 100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + TC_LOG_INFO("sql.dev", "(@PATH, XX, %.3f, %.3f, %.5f, 0, 0, 0, 100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); handler->PSendSysMessage("Waypoint SQL written to SQL Developer log"); return true; diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index cdc67b884ca..6bb927fec5e 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -136,7 +136,7 @@ public: if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId)) { // report to DB errors log as in loading case - TC_LOG_ERROR(LOG_FILTER_SQL, "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId); + TC_LOG_ERROR("sql.sql", "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId); handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId); handler->SetSentErrorMessage(true); return false; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index f608423e9cf..019a962c4b1 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1110,7 +1110,7 @@ public: if (!playerTarget) playerTarget = player; - TC_LOG_DEBUG(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEM), itemId, count); + TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_ADDITEM), itemId, count); ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId); if (!itemTemplate) @@ -1189,7 +1189,7 @@ public: if (!playerTarget) playerTarget = player; - TC_LOG_DEBUG(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEMSET), itemSetId); + TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_ADDITEMSET), itemSetId); bool found = false; ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index 81a440ad42c..4aa7c19fea6 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -203,7 +203,7 @@ public: target->SetMaxPower(POWER_ENERGY, energym); target->SetPower(POWER_ENERGY, energy); - TC_LOG_DEBUG(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_CURRENT_ENERGY), target->GetMaxPower(POWER_ENERGY)); + TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_CURRENT_ENERGY), target->GetMaxPower(POWER_ENERGY)); return true; } @@ -1009,7 +1009,7 @@ public: { int32 newmoney = int32(targetMoney) + moneyToAdd; - TC_LOG_DEBUG(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_CURRENT_MONEY), targetMoney, moneyToAdd, newmoney); + TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_CURRENT_MONEY), targetMoney, moneyToAdd, newmoney); if (newmoney <= 0) { handler->PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, handler->GetNameLink(target).c_str()); @@ -1044,7 +1044,7 @@ public: target->ModifyMoney(moneyToAdd); } - TC_LOG_DEBUG(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_NEW_MONEY), targetMoney, moneyToAdd, target->GetMoney()); + TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_NEW_MONEY), targetMoney, moneyToAdd, target->GetMoney()); return true; } diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index a1b23fd5935..b472ba48a5c 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -965,7 +965,7 @@ public: if (dontdel_str) { - //TC_LOG_ERROR(LOG_FILTER_GENERAL, "DEBUG: All 3 params are set"); + //TC_LOG_ERROR("misc", "DEBUG: All 3 params are set"); // All 3 params are set // GUID @@ -973,7 +973,7 @@ public: // doNotDEL if (stricmp(dontdel_str, "NODEL") == 0) { - //TC_LOG_ERROR(LOG_FILTER_GENERAL, "DEBUG: doNotDelete = true;"); + //TC_LOG_ERROR("misc", "DEBUG: doNotDelete = true;"); doNotDelete = true; } } @@ -982,10 +982,10 @@ public: // Only 2 params - but maybe NODEL is set if (type_str) { - TC_LOG_ERROR(LOG_FILTER_GENERAL, "DEBUG: Only 2 params "); + TC_LOG_ERROR("misc", "DEBUG: Only 2 params "); if (stricmp(type_str, "NODEL") == 0) { - //TC_LOG_ERROR(LOG_FILTER_GENERAL, "DEBUG: type_str, NODEL "); + //TC_LOG_ERROR("misc", "DEBUG: type_str, NODEL "); doNotDelete = true; type_str = NULL; } diff --git a/src/server/scripts/Commands/cs_pet.cpp b/src/server/scripts/Commands/cs_pet.cpp index 963537f0320..9a61250d193 100644 --- a/src/server/scripts/Commands/cs_pet.cpp +++ b/src/server/scripts/Commands/cs_pet.cpp @@ -90,7 +90,7 @@ public: if (!pet->InitStatsForLevel(creatureTarget->getLevel())) { - TC_LOG_ERROR(LOG_FILTER_GENERAL, "InitStatsForLevel() in EffectTameCreature failed! Pet deleted."); + TC_LOG_ERROR("misc", "InitStatsForLevel() in EffectTameCreature failed! Pet deleted."); handler->PSendSysMessage("Error 2"); delete pet; return false; diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index fe0f3ee6ce3..039766177c1 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -225,7 +225,7 @@ public: static bool HandleReloadAllLootCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables..."); + TC_LOG_INFO("misc", "Re-Loading Loot Tables..."); LoadLootTables(); handler->SendGlobalGMSysMessage("DB tables `*_loot_template` reloaded."); sConditionMgr->LoadConditions(true); @@ -248,7 +248,7 @@ public: HandleReloadQuestPOICommand(handler, "a"); HandleReloadQuestTemplateCommand(handler, "a"); - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Quests Relations..."); + TC_LOG_INFO("misc", "Re-Loading Quests Relations..."); sObjectMgr->LoadQuestStartersAndEnders(); handler->SendGlobalGMSysMessage("DB tables `*_queststarter` and `*_questender` reloaded."); return true; @@ -263,7 +263,7 @@ public: return false; } - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Scripts..."); + TC_LOG_INFO("misc", "Re-Loading Scripts..."); HandleReloadEventScriptsCommand(handler, "a"); HandleReloadSpellScriptsCommand(handler, "a"); handler->SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); @@ -332,7 +332,7 @@ public: static bool HandleReloadConfigCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading config settings..."); + TC_LOG_INFO("misc", "Re-Loading config settings..."); sWorld->LoadConfigSettings(true); sMapMgr->InitializeVisibilityDistanceInfo(); handler->SendGlobalGMSysMessage("World config settings reloaded."); @@ -341,7 +341,7 @@ public: static bool HandleReloadAccessRequirementCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Access Requirement definitions..."); + TC_LOG_INFO("misc", "Re-Loading Access Requirement definitions..."); sObjectMgr->LoadAccessRequirements(); handler->SendGlobalGMSysMessage("DB table `access_requirement` reloaded."); return true; @@ -349,7 +349,7 @@ public: static bool HandleReloadAchievementCriteriaDataCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Additional Achievement Criteria Data..."); + TC_LOG_INFO("misc", "Re-Loading Additional Achievement Criteria Data..."); sAchievementMgr->LoadAchievementCriteriaData(); handler->SendGlobalGMSysMessage("DB table `achievement_criteria_data` reloaded."); return true; @@ -357,7 +357,7 @@ public: static bool HandleReloadAchievementRewardCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Achievement Reward Data..."); + TC_LOG_INFO("misc", "Re-Loading Achievement Reward Data..."); sAchievementMgr->LoadRewards(); handler->SendGlobalGMSysMessage("DB table `achievement_reward` reloaded."); return true; @@ -365,7 +365,7 @@ public: static bool HandleReloadAreaTriggerTavernCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Tavern Area Triggers..."); + TC_LOG_INFO("misc", "Re-Loading Tavern Area Triggers..."); sObjectMgr->LoadTavernAreaTriggers(); handler->SendGlobalGMSysMessage("DB table `areatrigger_tavern` reloaded."); return true; @@ -373,7 +373,7 @@ public: static bool HandleReloadAreaTriggerTeleportCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading AreaTrigger teleport definitions..."); + TC_LOG_INFO("misc", "Re-Loading AreaTrigger teleport definitions..."); sObjectMgr->LoadAreaTriggerTeleports(); handler->SendGlobalGMSysMessage("DB table `areatrigger_teleport` reloaded."); return true; @@ -381,7 +381,7 @@ public: static bool HandleReloadAutobroadcastCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Autobroadcasts..."); + TC_LOG_INFO("misc", "Re-Loading Autobroadcasts..."); sWorld->LoadAutobroadcasts(); handler->SendGlobalGMSysMessage("DB table `autobroadcast` reloaded."); return true; @@ -396,7 +396,7 @@ public: static bool HandleReloadOnKillReputationCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading creature award reputation definitions..."); + TC_LOG_INFO("misc", "Re-Loading creature award reputation definitions..."); sObjectMgr->LoadReputationOnKill(); handler->SendGlobalGMSysMessage("DB table `creature_onkill_reputation` reloaded."); return true; @@ -404,7 +404,7 @@ public: static bool HandleReloadCreatureSummonGroupsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Reloading creature summon groups..."); + TC_LOG_INFO("misc", "Reloading creature summon groups..."); sObjectMgr->LoadTempSummons(); handler->SendGlobalGMSysMessage("DB table `creature_summon_groups` reloaded."); return true; @@ -438,7 +438,7 @@ public: continue; } - TC_LOG_INFO(LOG_FILTER_GENERAL, "Reloading creature template entry %u", entry); + TC_LOG_INFO("misc", "Reloading creature template entry %u", entry); Field* fields = result->Fetch(); @@ -534,7 +534,7 @@ public: static bool HandleReloadCreatureQuestStarterCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Loading Quests Relations... (`creature_queststarter`)"); + TC_LOG_INFO("misc", "Loading Quests Relations... (`creature_queststarter`)"); sObjectMgr->LoadCreatureQuestStarters(); handler->SendGlobalGMSysMessage("DB table `creature_queststarter` reloaded."); return true; @@ -542,7 +542,7 @@ public: static bool HandleReloadLinkedRespawnCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Loading Linked Respawns... (`creature_linked_respawn`)"); + TC_LOG_INFO("misc", "Loading Linked Respawns... (`creature_linked_respawn`)"); sObjectMgr->LoadLinkedRespawn(); handler->SendGlobalGMSysMessage("DB table `creature_linked_respawn` (creature linked respawns) reloaded."); return true; @@ -550,7 +550,7 @@ public: static bool HandleReloadCreatureQuestEnderCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Loading Quests Relations... (`creature_questender`)"); + TC_LOG_INFO("misc", "Loading Quests Relations... (`creature_questender`)"); sObjectMgr->LoadCreatureQuestEnders(); handler->SendGlobalGMSysMessage("DB table `creature_questender` reloaded."); return true; @@ -558,7 +558,7 @@ public: static bool HandleReloadGossipMenuCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading `gossip_menu` Table!"); + TC_LOG_INFO("misc", "Re-Loading `gossip_menu` Table!"); sObjectMgr->LoadGossipMenu(); handler->SendGlobalGMSysMessage("DB table `gossip_menu` reloaded."); sConditionMgr->LoadConditions(true); @@ -567,7 +567,7 @@ public: static bool HandleReloadGossipMenuOptionCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading `gossip_menu_option` Table!"); + TC_LOG_INFO("misc", "Re-Loading `gossip_menu_option` Table!"); sObjectMgr->LoadGossipMenuItems(); handler->SendGlobalGMSysMessage("DB table `gossip_menu_option` reloaded."); sConditionMgr->LoadConditions(true); @@ -576,7 +576,7 @@ public: static bool HandleReloadGOQuestStarterCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Loading Quests Relations... (`gameobject_queststarter`)"); + TC_LOG_INFO("misc", "Loading Quests Relations... (`gameobject_queststarter`)"); sObjectMgr->LoadGameobjectQuestStarters(); handler->SendGlobalGMSysMessage("DB table `gameobject_queststarter` reloaded."); return true; @@ -584,7 +584,7 @@ public: static bool HandleReloadGOQuestEnderCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Loading Quests Relations... (`gameobject_questender`)"); + TC_LOG_INFO("misc", "Loading Quests Relations... (`gameobject_questender`)"); sObjectMgr->LoadGameobjectQuestEnders(); handler->SendGlobalGMSysMessage("DB table `gameobject_questender` reloaded."); return true; @@ -592,7 +592,7 @@ public: static bool HandleReloadQuestAreaTriggersCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Quest Area Triggers..."); + TC_LOG_INFO("misc", "Re-Loading Quest Area Triggers..."); sObjectMgr->LoadQuestAreaTriggers(); handler->SendGlobalGMSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); return true; @@ -600,12 +600,12 @@ public: static bool HandleReloadQuestTemplateCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Quest Templates..."); + TC_LOG_INFO("misc", "Re-Loading Quest Templates..."); sObjectMgr->LoadQuests(); handler->SendGlobalGMSysMessage("DB table `quest_template` (quest definitions) reloaded."); /// dependent also from `gameobject` but this table not reloaded anyway - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading GameObjects for quests..."); + TC_LOG_INFO("misc", "Re-Loading GameObjects for quests..."); sObjectMgr->LoadGameObjectForQuests(); handler->SendGlobalGMSysMessage("Data GameObjects for quests reloaded."); return true; @@ -613,7 +613,7 @@ public: static bool HandleReloadLootTemplatesCreatureCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`creature_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`creature_loot_template`)"); LoadLootTemplates_Creature(); LootTemplates_Creature.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `creature_loot_template` reloaded."); @@ -623,7 +623,7 @@ public: static bool HandleReloadLootTemplatesDisenchantCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`disenchant_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`disenchant_loot_template`)"); LoadLootTemplates_Disenchant(); LootTemplates_Disenchant.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `disenchant_loot_template` reloaded."); @@ -633,7 +633,7 @@ public: static bool HandleReloadLootTemplatesFishingCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`fishing_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`fishing_loot_template`)"); LoadLootTemplates_Fishing(); LootTemplates_Fishing.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `fishing_loot_template` reloaded."); @@ -643,7 +643,7 @@ public: static bool HandleReloadLootTemplatesGameobjectCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`gameobject_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`gameobject_loot_template`)"); LoadLootTemplates_Gameobject(); LootTemplates_Gameobject.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `gameobject_loot_template` reloaded."); @@ -653,7 +653,7 @@ public: static bool HandleReloadLootTemplatesItemCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`item_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`item_loot_template`)"); LoadLootTemplates_Item(); LootTemplates_Item.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `item_loot_template` reloaded."); @@ -663,7 +663,7 @@ public: static bool HandleReloadLootTemplatesMillingCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`milling_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`milling_loot_template`)"); LoadLootTemplates_Milling(); LootTemplates_Milling.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `milling_loot_template` reloaded."); @@ -673,7 +673,7 @@ public: static bool HandleReloadLootTemplatesPickpocketingCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`pickpocketing_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`pickpocketing_loot_template`)"); LoadLootTemplates_Pickpocketing(); LootTemplates_Pickpocketing.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `pickpocketing_loot_template` reloaded."); @@ -683,7 +683,7 @@ public: static bool HandleReloadLootTemplatesProspectingCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`prospecting_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`prospecting_loot_template`)"); LoadLootTemplates_Prospecting(); LootTemplates_Prospecting.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `prospecting_loot_template` reloaded."); @@ -693,7 +693,7 @@ public: static bool HandleReloadLootTemplatesMailCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`mail_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`mail_loot_template`)"); LoadLootTemplates_Mail(); LootTemplates_Mail.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `mail_loot_template` reloaded."); @@ -703,7 +703,7 @@ public: static bool HandleReloadLootTemplatesReferenceCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`reference_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`reference_loot_template`)"); LoadLootTemplates_Reference(); handler->SendGlobalGMSysMessage("DB table `reference_loot_template` reloaded."); sConditionMgr->LoadConditions(true); @@ -712,7 +712,7 @@ public: static bool HandleReloadLootTemplatesSkinningCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`skinning_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`skinning_loot_template`)"); LoadLootTemplates_Skinning(); LootTemplates_Skinning.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `skinning_loot_template` reloaded."); @@ -722,7 +722,7 @@ public: static bool HandleReloadLootTemplatesSpellCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Loot Tables... (`spell_loot_template`)"); + TC_LOG_INFO("misc", "Re-Loading Loot Tables... (`spell_loot_template`)"); LoadLootTemplates_Spell(); LootTemplates_Spell.CheckLootRefs(); handler->SendGlobalGMSysMessage("DB table `spell_loot_template` reloaded."); @@ -732,7 +732,7 @@ public: static bool HandleReloadTrinityStringCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading trinity_string Table!"); + TC_LOG_INFO("misc", "Re-Loading trinity_string Table!"); sObjectMgr->LoadTrinityStrings(); handler->SendGlobalGMSysMessage("DB table `trinity_string` reloaded."); return true; @@ -747,7 +747,7 @@ public: return false; } - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading warden_action Table!"); + TC_LOG_INFO("misc", "Re-Loading warden_action Table!"); sWardenCheckMgr->LoadWardenOverrides(); handler->SendGlobalGMSysMessage("DB table `warden_action` reloaded."); return true; @@ -755,7 +755,7 @@ public: static bool HandleReloadNpcTrainerCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading `npc_trainer` Table!"); + TC_LOG_INFO("misc", "Re-Loading `npc_trainer` Table!"); sObjectMgr->LoadTrainerSpell(); handler->SendGlobalGMSysMessage("DB table `npc_trainer` reloaded."); return true; @@ -763,7 +763,7 @@ public: static bool HandleReloadNpcVendorCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading `npc_vendor` Table!"); + TC_LOG_INFO("misc", "Re-Loading `npc_vendor` Table!"); sObjectMgr->LoadVendors(); handler->SendGlobalGMSysMessage("DB table `npc_vendor` reloaded."); return true; @@ -771,7 +771,7 @@ public: static bool HandleReloadPointsOfInterestCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading `points_of_interest` Table!"); + TC_LOG_INFO("misc", "Re-Loading `points_of_interest` Table!"); sObjectMgr->LoadPointsOfInterest(); handler->SendGlobalGMSysMessage("DB table `points_of_interest` reloaded."); return true; @@ -779,7 +779,7 @@ public: static bool HandleReloadQuestPOICommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Quest POI ..." ); + TC_LOG_INFO("misc", "Re-Loading Quest POI ..." ); sObjectMgr->LoadQuestPOI(); handler->SendGlobalGMSysMessage("DB Table `quest_poi` and `quest_poi_points` reloaded."); return true; @@ -787,7 +787,7 @@ public: static bool HandleReloadSpellClickSpellsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading `npc_spellclick_spells` Table!"); + TC_LOG_INFO("misc", "Re-Loading `npc_spellclick_spells` Table!"); sObjectMgr->LoadNPCSpellClickSpells(); handler->SendGlobalGMSysMessage("DB table `npc_spellclick_spells` reloaded."); return true; @@ -795,7 +795,7 @@ public: static bool HandleReloadReservedNameCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Loading ReservedNames... (`reserved_name`)"); + TC_LOG_INFO("misc", "Loading ReservedNames... (`reserved_name`)"); sObjectMgr->LoadReservedPlayersNames(); handler->SendGlobalGMSysMessage("DB table `reserved_name` (player reserved names) reloaded."); return true; @@ -803,7 +803,7 @@ public: static bool HandleReloadReputationRewardRateCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading `reputation_reward_rate` Table!" ); + TC_LOG_INFO("misc", "Re-Loading `reputation_reward_rate` Table!" ); sObjectMgr->LoadReputationRewardRate(); handler->SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded."); return true; @@ -811,7 +811,7 @@ public: static bool HandleReloadReputationSpilloverTemplateCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading `reputation_spillover_template` Table!" ); + TC_LOG_INFO("misc", "Re-Loading `reputation_spillover_template` Table!" ); sObjectMgr->LoadReputationSpilloverTemplate(); handler->SendGlobalSysMessage("DB table `reputation_spillover_template` reloaded."); return true; @@ -819,7 +819,7 @@ public: static bool HandleReloadSkillDiscoveryTemplateCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Skill Discovery Table..."); + TC_LOG_INFO("misc", "Re-Loading Skill Discovery Table..."); LoadSkillDiscoveryTable(); handler->SendGlobalGMSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); return true; @@ -827,7 +827,7 @@ public: static bool HandleReloadSkillExtraItemTemplateCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Skill Extra Item Table..."); + TC_LOG_INFO("misc", "Re-Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); handler->SendGlobalGMSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); return true; @@ -835,7 +835,7 @@ public: static bool HandleReloadSkillFishingBaseLevelCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Skill Fishing base level requirements..."); + TC_LOG_INFO("misc", "Re-Loading Skill Fishing base level requirements..."); sObjectMgr->LoadFishingBaseSkillLevel(); handler->SendGlobalGMSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); return true; @@ -843,7 +843,7 @@ public: static bool HandleReloadSpellAreaCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading SpellArea Data..."); + TC_LOG_INFO("misc", "Re-Loading SpellArea Data..."); sSpellMgr->LoadSpellAreas(); handler->SendGlobalGMSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded."); return true; @@ -851,7 +851,7 @@ public: static bool HandleReloadSpellRequiredCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell Required Data... "); + TC_LOG_INFO("misc", "Re-Loading Spell Required Data... "); sSpellMgr->LoadSpellRequired(); handler->SendGlobalGMSysMessage("DB table `spell_required` reloaded."); return true; @@ -859,7 +859,7 @@ public: static bool HandleReloadSpellGroupsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell Groups..."); + TC_LOG_INFO("misc", "Re-Loading Spell Groups..."); sSpellMgr->LoadSpellGroups(); handler->SendGlobalGMSysMessage("DB table `spell_group` (spell groups) reloaded."); return true; @@ -867,7 +867,7 @@ public: static bool HandleReloadSpellLearnSpellCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell Learn Spells..."); + TC_LOG_INFO("misc", "Re-Loading Spell Learn Spells..."); sSpellMgr->LoadSpellLearnSpells(); handler->SendGlobalGMSysMessage("DB table `spell_learn_spell` reloaded."); return true; @@ -875,7 +875,7 @@ public: static bool HandleReloadSpellLinkedSpellCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell Linked Spells..."); + TC_LOG_INFO("misc", "Re-Loading Spell Linked Spells..."); sSpellMgr->LoadSpellLinked(); handler->SendGlobalGMSysMessage("DB table `spell_linked_spell` reloaded."); return true; @@ -883,7 +883,7 @@ public: static bool HandleReloadSpellProcEventCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell Proc Event conditions..."); + TC_LOG_INFO("misc", "Re-Loading Spell Proc Event conditions..."); sSpellMgr->LoadSpellProcEvents(); handler->SendGlobalGMSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); return true; @@ -891,7 +891,7 @@ public: static bool HandleReloadSpellProcsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell Proc conditions and data..."); + TC_LOG_INFO("misc", "Re-Loading Spell Proc conditions and data..."); sSpellMgr->LoadSpellProcs(); handler->SendGlobalGMSysMessage("DB table `spell_proc` (spell proc conditions and data) reloaded."); return true; @@ -899,7 +899,7 @@ public: static bool HandleReloadSpellBonusesCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell Bonus Data..."); + TC_LOG_INFO("misc", "Re-Loading Spell Bonus Data..."); sSpellMgr->LoadSpellBonusess(); handler->SendGlobalGMSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); return true; @@ -907,7 +907,7 @@ public: static bool HandleReloadSpellTargetPositionCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell target coordinates..."); + TC_LOG_INFO("misc", "Re-Loading Spell target coordinates..."); sSpellMgr->LoadSpellTargetPositions(); handler->SendGlobalGMSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); return true; @@ -915,7 +915,7 @@ public: static bool HandleReloadSpellThreatsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Aggro Spells Definitions..."); + TC_LOG_INFO("misc", "Re-Loading Aggro Spells Definitions..."); sSpellMgr->LoadSpellThreats(); handler->SendGlobalGMSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); return true; @@ -923,7 +923,7 @@ public: static bool HandleReloadSpellGroupStackRulesCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell Group Stack Rules..."); + TC_LOG_INFO("misc", "Re-Loading Spell Group Stack Rules..."); sSpellMgr->LoadSpellGroupStackRules(); handler->SendGlobalGMSysMessage("DB table `spell_group_stack_rules` (spell stacking definitions) reloaded."); return true; @@ -931,7 +931,7 @@ public: static bool HandleReloadSpellPetAurasCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Spell pet auras..."); + TC_LOG_INFO("misc", "Re-Loading Spell pet auras..."); sSpellMgr->LoadSpellPetAuras(); handler->SendGlobalGMSysMessage("DB table `spell_pet_auras` reloaded."); return true; @@ -939,7 +939,7 @@ public: static bool HandleReloadPageTextsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Page Texts..."); + TC_LOG_INFO("misc", "Re-Loading Page Texts..."); sObjectMgr->LoadPageTexts(); handler->SendGlobalGMSysMessage("DB table `page_texts` reloaded."); return true; @@ -947,7 +947,7 @@ public: static bool HandleReloadItemEnchantementsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Item Random Enchantments Table..."); + TC_LOG_INFO("misc", "Re-Loading Item Random Enchantments Table..."); LoadRandomEnchantmentsTable(); handler->SendGlobalGMSysMessage("DB table `item_enchantment_template` reloaded."); return true; @@ -955,7 +955,7 @@ public: static bool HandleReloadItemSetNamesCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Item set names..."); + TC_LOG_INFO("misc", "Re-Loading Item set names..."); sObjectMgr->LoadItemSetNames(); handler->SendGlobalGMSysMessage("DB table `item_set_names` reloaded."); return true; @@ -971,7 +971,7 @@ public: } if (*args != 'a') - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Scripts from `event_scripts`..."); + TC_LOG_INFO("misc", "Re-Loading Scripts from `event_scripts`..."); sObjectMgr->LoadEventScripts(); @@ -991,7 +991,7 @@ public: } if (*args != 'a') - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Scripts from `waypoint_scripts`..."); + TC_LOG_INFO("misc", "Re-Loading Scripts from `waypoint_scripts`..."); sObjectMgr->LoadWaypointScripts(); @@ -1004,7 +1004,7 @@ public: static bool HandleReloadWpCommand(ChatHandler* handler, const char* args) { if (*args != 'a') - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Waypoints data from 'waypoints_data'"); + TC_LOG_INFO("misc", "Re-Loading Waypoints data from 'waypoints_data'"); sWaypointMgr->Load(); @@ -1017,7 +1017,7 @@ public: static bool HandleReloadEventAITextsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Texts from `creature_ai_texts`..."); + TC_LOG_INFO("misc", "Re-Loading Texts from `creature_ai_texts`..."); sEventAIMgr->LoadCreatureEventAI_Texts(); handler->SendGlobalGMSysMessage("DB table `creature_ai_texts` reloaded."); return true; @@ -1025,7 +1025,7 @@ public: static bool HandleReloadEventAIScriptsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Scripts from `creature_ai_scripts`..."); + TC_LOG_INFO("misc", "Re-Loading Scripts from `creature_ai_scripts`..."); sEventAIMgr->LoadCreatureEventAI_Scripts(); handler->SendGlobalGMSysMessage("DB table `creature_ai_scripts` reloaded."); return true; @@ -1041,7 +1041,7 @@ public: } if (*args != 'a') - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Scripts from `spell_scripts`..."); + TC_LOG_INFO("misc", "Re-Loading Scripts from `spell_scripts`..."); sObjectMgr->LoadSpellScripts(); @@ -1053,7 +1053,7 @@ public: static bool HandleReloadDbScriptStringCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Script strings from `db_script_string`..."); + TC_LOG_INFO("misc", "Re-Loading Script strings from `db_script_string`..."); sObjectMgr->LoadDbScriptStrings(); handler->SendGlobalGMSysMessage("DB table `db_script_string` reloaded."); return true; @@ -1061,7 +1061,7 @@ public: static bool HandleReloadGameGraveyardZoneCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Graveyard-zone links..."); + TC_LOG_INFO("misc", "Re-Loading Graveyard-zone links..."); sObjectMgr->LoadGraveyardZones(); @@ -1072,7 +1072,7 @@ public: static bool HandleReloadGameTeleCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Game Tele coordinates..."); + TC_LOG_INFO("misc", "Re-Loading Game Tele coordinates..."); sObjectMgr->LoadGameTele(); @@ -1083,9 +1083,9 @@ public: static bool HandleReloadDisablesCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading disables table..."); + TC_LOG_INFO("misc", "Re-Loading disables table..."); DisableMgr::LoadDisables(); - TC_LOG_INFO(LOG_FILTER_GENERAL, "Checking quest disables..."); + TC_LOG_INFO("misc", "Checking quest disables..."); DisableMgr::CheckQuestDisables(); handler->SendGlobalGMSysMessage("DB table `disables` reloaded."); return true; @@ -1093,7 +1093,7 @@ public: static bool HandleReloadLocalesAchievementRewardCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Achievement Reward Data..."); + TC_LOG_INFO("misc", "Re-Loading Locales Achievement Reward Data..."); sAchievementMgr->LoadRewardLocales(); handler->SendGlobalGMSysMessage("DB table `locales_achievement_reward` reloaded."); return true; @@ -1101,7 +1101,7 @@ public: static bool HandleReloadLfgRewardsCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading lfg dungeon rewards..."); + TC_LOG_INFO("misc", "Re-Loading lfg dungeon rewards..."); sLFGMgr->LoadRewards(); handler->SendGlobalGMSysMessage("DB table `lfg_dungeon_rewards` reloaded."); return true; @@ -1109,7 +1109,7 @@ public: static bool HandleReloadLocalesCreatureCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Creature ..."); + TC_LOG_INFO("misc", "Re-Loading Locales Creature ..."); sObjectMgr->LoadCreatureLocales(); handler->SendGlobalGMSysMessage("DB table `locales_creature` reloaded."); return true; @@ -1117,7 +1117,7 @@ public: static bool HandleReloadLocalesCreatureTextCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Creature Texts..."); + TC_LOG_INFO("misc", "Re-Loading Locales Creature Texts..."); sCreatureTextMgr->LoadCreatureTextLocales(); handler->SendGlobalGMSysMessage("DB table `locales_creature_text` reloaded."); return true; @@ -1125,7 +1125,7 @@ public: static bool HandleReloadLocalesGameobjectCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Gameobject ... "); + TC_LOG_INFO("misc", "Re-Loading Locales Gameobject ... "); sObjectMgr->LoadGameObjectLocales(); handler->SendGlobalGMSysMessage("DB table `locales_gameobject` reloaded."); return true; @@ -1133,7 +1133,7 @@ public: static bool HandleReloadLocalesGossipMenuOptionCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Gossip Menu Option ... "); + TC_LOG_INFO("misc", "Re-Loading Locales Gossip Menu Option ... "); sObjectMgr->LoadGossipMenuItemsLocales(); handler->SendGlobalGMSysMessage("DB table `locales_gossip_menu_option` reloaded."); return true; @@ -1141,7 +1141,7 @@ public: static bool HandleReloadLocalesItemCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Item ... "); + TC_LOG_INFO("misc", "Re-Loading Locales Item ... "); sObjectMgr->LoadItemLocales(); handler->SendGlobalGMSysMessage("DB table `locales_item` reloaded."); return true; @@ -1149,7 +1149,7 @@ public: static bool HandleReloadLocalesItemSetNameCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Item set name... "); + TC_LOG_INFO("misc", "Re-Loading Locales Item set name... "); sObjectMgr->LoadItemSetNameLocales(); handler->SendGlobalGMSysMessage("DB table `locales_item_set_name` reloaded."); return true; @@ -1157,7 +1157,7 @@ public: static bool HandleReloadLocalesNpcTextCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales NPC Text ... "); + TC_LOG_INFO("misc", "Re-Loading Locales NPC Text ... "); sObjectMgr->LoadNpcTextLocales(); handler->SendGlobalGMSysMessage("DB table `locales_npc_text` reloaded."); return true; @@ -1165,7 +1165,7 @@ public: static bool HandleReloadLocalesPageTextCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Page Text ... "); + TC_LOG_INFO("misc", "Re-Loading Locales Page Text ... "); sObjectMgr->LoadPageTextLocales(); handler->SendGlobalGMSysMessage("DB table `locales_page_text` reloaded."); return true; @@ -1173,7 +1173,7 @@ public: static bool HandleReloadLocalesPointsOfInterestCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Points Of Interest ... "); + TC_LOG_INFO("misc", "Re-Loading Locales Points Of Interest ... "); sObjectMgr->LoadPointOfInterestLocales(); handler->SendGlobalGMSysMessage("DB table `locales_points_of_interest` reloaded."); return true; @@ -1181,7 +1181,7 @@ public: static bool HandleReloadLocalesQuestCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Locales Quest ... "); + TC_LOG_INFO("misc", "Re-Loading Locales Quest ... "); sObjectMgr->LoadQuestLocales(); handler->SendGlobalGMSysMessage("DB table `locales_quest` reloaded."); return true; @@ -1189,7 +1189,7 @@ public: static bool HandleReloadMailLevelRewardCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Player level dependent mail rewards..."); + TC_LOG_INFO("misc", "Re-Loading Player level dependent mail rewards..."); sObjectMgr->LoadMailLevelRewards(); handler->SendGlobalGMSysMessage("DB table `mail_level_reward` reloaded."); return true; @@ -1198,7 +1198,7 @@ public: static bool HandleReloadAuctionsCommand(ChatHandler* handler, const char* /*args*/) { ///- Reload dynamic data tables from the database - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Auctions..."); + TC_LOG_INFO("misc", "Re-Loading Auctions..."); sAuctionMgr->LoadAuctionItems(); sAuctionMgr->LoadAuctions(); handler->SendGlobalGMSysMessage("Auctions reloaded."); @@ -1207,7 +1207,7 @@ public: static bool HandleReloadConditions(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Conditions..."); + TC_LOG_INFO("misc", "Re-Loading Conditions..."); sConditionMgr->LoadConditions(true); handler->SendGlobalGMSysMessage("Conditions reloaded."); return true; @@ -1215,7 +1215,7 @@ public: static bool HandleReloadCreatureText(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Creature Texts..."); + TC_LOG_INFO("misc", "Re-Loading Creature Texts..."); sCreatureTextMgr->LoadCreatureTexts(); handler->SendGlobalGMSysMessage("Creature Texts reloaded."); return true; @@ -1223,7 +1223,7 @@ public: static bool HandleReloadSmartScripts(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Re-Loading Smart Scripts..."); + TC_LOG_INFO("misc", "Re-Loading Smart Scripts..."); sSmartScriptMgr->LoadSmartAIFromDB(); handler->SendGlobalGMSysMessage("Smart Scripts reloaded."); return true; @@ -1231,7 +1231,7 @@ public: static bool HandleReloadVehicleAccessoryCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Reloading vehicle_accessory table..."); + TC_LOG_INFO("misc", "Reloading vehicle_accessory table..."); sObjectMgr->LoadVehicleAccessories(); handler->SendGlobalGMSysMessage("Vehicle accessories reloaded."); return true; @@ -1239,7 +1239,7 @@ public: static bool HandleReloadVehicleTemplateAccessoryCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Reloading vehicle_template_accessory table..."); + TC_LOG_INFO("misc", "Reloading vehicle_template_accessory table..."); sObjectMgr->LoadVehicleTemplateAccessories(); handler->SendGlobalGMSysMessage("Vehicle template accessories reloaded."); return true; @@ -1247,7 +1247,7 @@ public: static bool HandleReloadRBACCommand(ChatHandler* handler, const char* /*args*/) { - TC_LOG_INFO(LOG_FILTER_GENERAL, "Reloading RBAC tables..."); + TC_LOG_INFO("misc", "Reloading RBAC tables..."); sAccountMgr->LoadRBAC(); sWorld->ReloadRBAC(); handler->SendGlobalGMSysMessage("RBAC data reloaded."); diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index 891445df976..2b27fcf56fd 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -92,7 +92,7 @@ public: ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(player->getClass()); if (!classEntry) { - TC_LOG_ERROR(LOG_FILTER_GENERAL, "Class %u not found in DBC (Wrong DBC files?)", player->getClass()); + TC_LOG_ERROR("misc", "Class %u not found in DBC (Wrong DBC files?)", player->getClass()); return false; } -- cgit v1.2.3 From 6e13263c7a0ae4c8eecdf4fd9560339e2d3d9787 Mon Sep 17 00:00:00 2001 From: Vincent_Michael Date: Sun, 1 Dec 2013 01:27:08 +0100 Subject: Core/AI: Good bye, Good bye my beloved EventAI system :( --- .../auth/2013_12_01_00_auth_rbac_permissions.sql | 1 + .../world/2013_12_01_00_world_creature_ai.sql | 4 + src/server/game/AI/CreatureAIRegistry.cpp | 2 - src/server/game/AI/EventAI/CreatureEventAI.cpp | 1327 -------------------- src/server/game/AI/EventAI/CreatureEventAI.h | 630 ---------- src/server/game/AI/EventAI/CreatureEventAIMgr.cpp | 680 ---------- src/server/game/AI/EventAI/CreatureEventAIMgr.h | 46 - src/server/game/CMakeLists.txt | 1 - src/server/game/World/World.cpp | 7 - src/server/scripts/CMakeLists.txt | 1 - src/server/scripts/Commands/cs_reload.cpp | 29 - src/server/worldserver/CMakeLists.txt | 1 - 12 files changed, 5 insertions(+), 2724 deletions(-) create mode 100644 sql/updates/auth/2013_12_01_00_auth_rbac_permissions.sql create mode 100644 sql/updates/world/2013_12_01_00_world_creature_ai.sql delete mode 100644 src/server/game/AI/EventAI/CreatureEventAI.cpp delete mode 100644 src/server/game/AI/EventAI/CreatureEventAI.h delete mode 100644 src/server/game/AI/EventAI/CreatureEventAIMgr.cpp delete mode 100644 src/server/game/AI/EventAI/CreatureEventAIMgr.h (limited to 'src/server/scripts/Commands') diff --git a/sql/updates/auth/2013_12_01_00_auth_rbac_permissions.sql b/sql/updates/auth/2013_12_01_00_auth_rbac_permissions.sql new file mode 100644 index 00000000000..4db0cc4b509 --- /dev/null +++ b/sql/updates/auth/2013_12_01_00_auth_rbac_permissions.sql @@ -0,0 +1 @@ +DELETE FROM `rbac_permissions` WHERE `id`=614 diff --git a/sql/updates/world/2013_12_01_00_world_creature_ai.sql b/sql/updates/world/2013_12_01_00_world_creature_ai.sql new file mode 100644 index 00000000000..e10c64a59fe --- /dev/null +++ b/sql/updates/world/2013_12_01_00_world_creature_ai.sql @@ -0,0 +1,4 @@ +DROP TABLE `creature_ai_scripts`; +DROP TABLE `creature_ai_texts`; + +DELETE FROM `command` WHERE `name`='reload all eventai'; diff --git a/src/server/game/AI/CreatureAIRegistry.cpp b/src/server/game/AI/CreatureAIRegistry.cpp index 8f035667a34..8b74db24a42 100644 --- a/src/server/game/AI/CreatureAIRegistry.cpp +++ b/src/server/game/AI/CreatureAIRegistry.cpp @@ -22,7 +22,6 @@ #include "GuardAI.h" #include "PetAI.h" #include "TotemAI.h" -#include "CreatureEventAI.h" #include "RandomMovementGenerator.h" #include "MovementGeneratorImpl.h" #include "CreatureAIRegistry.h" @@ -46,7 +45,6 @@ namespace AIRegistry (new CreatureAIFactory("CombatAI"))->RegisterSelf(); (new CreatureAIFactory("ArcherAI"))->RegisterSelf(); (new CreatureAIFactory("TurretAI"))->RegisterSelf(); - (new CreatureAIFactory("EventAI"))->RegisterSelf(); (new CreatureAIFactory("VehicleAI"))->RegisterSelf(); (new CreatureAIFactory("SmartAI"))->RegisterSelf(); diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp deleted file mode 100644 index 8e2e4e8dc2e..00000000000 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ /dev/null @@ -1,1327 +0,0 @@ -/* - * Copyright (C) 2008-2013 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "Common.h" -#include "CreatureEventAI.h" -#include "CreatureEventAIMgr.h" -#include "ObjectMgr.h" -#include "Spell.h" -#include "World.h" -#include "Cell.h" -#include "CellImpl.h" -#include "GameEventMgr.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "InstanceScript.h" -#include "SpellMgr.h" -#include "CreatureAIImpl.h" -#include "ConditionMgr.h" - -bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax) -{ - if (repeatMin == repeatMax) - Time = repeatMin; - else if (repeatMax > repeatMin) - Time = urand(repeatMin, repeatMax); - else - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", creature->GetEntry(), Event.event_id, Event.event_type); - Enabled = false; - return false; - } - - return true; -} - -int CreatureEventAI::Permissible(const Creature* creature) -{ - if (creature->GetAIName() == "EventAI") - return PERMIT_BASE_SPECIAL; - return PERMIT_BASE_NO; -} - -CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c) -{ - // Need make copy for filter unneeded steps and safe in case table reload - CreatureEventAI_Event_Map::const_iterator CreatureEvents = sEventAIMgr->GetCreatureEventAIMap().find(me->GetEntry()); - if (CreatureEvents != sEventAIMgr->GetCreatureEventAIMap().end()) - { - std::vector::const_iterator i; - for (i = (*CreatureEvents).second.begin(); i != (*CreatureEvents).second.end(); ++i) - { - //Debug check - #ifndef TRINITY_DEBUG - if ((*i).event_flags & EFLAG_DEBUG_ONLY) - continue; - #endif - if (me->GetMap()->IsDungeon()) - { - if ((1 << (me->GetMap()->GetSpawnMode()+1)) & (*i).event_flags) - { - //event flagged for instance mode - m_CreatureEventAIList.push_back(CreatureEventAIHolder(*i)); - } - continue; - } - m_CreatureEventAIList.push_back(CreatureEventAIHolder(*i)); - } - //EventMap had events but they were not added because they must be for instance - if (m_CreatureEventAIList.empty()) - TC_LOG_ERROR("misc", "CreatureEventAI: Creature %u has events but no events added to list because of instance flags.", me->GetEntry()); - } - else - TC_LOG_ERROR("misc", "CreatureEventAI: EventMap for Creature %u is empty but creature is using CreatureEventAI.", me->GetEntry()); - - m_bEmptyList = m_CreatureEventAIList.empty(); - m_Phase = 0; - m_CombatMovementEnabled = true; - m_MeleeEnabled = true; - m_AttackDistance = 0.0f; - m_AttackAngle = 0.0f; - - m_InvincibilityHpLevel = 0; - - //Handle Spawned Events - if (!m_bEmptyList) - { - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - if (SpawnedEventConditionsCheck((*i).Event)) - ProcessEvent(*i); - } -} - -bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& holder, Unit* actionInvoker /*=NULL*/) -{ - if (!holder.Enabled || holder.Time) - return false; - - //Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask) - if (holder.Event.event_inverse_phase_mask & (1 << m_Phase)) - return false; - - CreatureEventAI_Event const& event = holder.Event; - - //Check event conditions based on the event type, also reset events - switch (event.event_type) - { - case EVENT_T_TIMER: - if (!me->IsInCombat()) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); - break; - case EVENT_T_TIMER_OOC: - if (me->IsInCombat()) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); - break; - case EVENT_T_HP: - { - if (!me->IsInCombat() || !me->GetMaxHealth()) - return false; - - uint32 perc = uint32(me->GetHealthPct()); - - if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); - break; - } - case EVENT_T_MANA: - { - if (!me->IsInCombat() || !me->GetMaxPower(POWER_MANA)) - return false; - - uint32 perc = (me->GetPower(POWER_MANA)*100) / me->GetMaxPower(POWER_MANA); - - if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); - break; - } - case EVENT_T_AGGRO: - break; - case EVENT_T_KILL: - //Repeat Timers - holder.UpdateRepeatTimer(me, event.kill.repeatMin, event.kill.repeatMax); - break; - case EVENT_T_DEATH: - case EVENT_T_EVADE: - break; - case EVENT_T_SPELLHIT: - //Spell hit is special case, param1 and param2 handled within CreatureEventAI::SpellHit - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.spell_hit.repeatMin, event.spell_hit.repeatMax); - break; - case EVENT_T_RANGE: - //Repeat Timers - holder.UpdateRepeatTimer(me, event.range.repeatMin, event.range.repeatMax); - break; - case EVENT_T_OOC_LOS: - //Repeat Timers - holder.UpdateRepeatTimer(me, event.ooc_los.repeatMin, event.ooc_los.repeatMax); - break; - case EVENT_T_RESET: - case EVENT_T_SPAWNED: - break; - case EVENT_T_TARGET_HP: - { - if (!me->IsInCombat() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth()) - return false; - - uint32 perc = uint32(me->GetVictim()->GetHealthPct()); - - if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); - break; - } - case EVENT_T_TARGET_CASTING: - if (!me->IsInCombat() || !me->GetVictim() || !me->GetVictim()->IsNonMeleeSpellCasted(false, false, true)) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.target_casting.repeatMin, event.target_casting.repeatMax); - break; - case EVENT_T_FRIENDLY_HP: - { - if (!me->IsInCombat()) - return false; - - Unit* unit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit); - if (!unit) - return false; - - actionInvoker = unit; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.friendly_hp.repeatMin, event.friendly_hp.repeatMax); - break; - } - case EVENT_T_FRIENDLY_IS_CC: - { - if (!me->IsInCombat()) - return false; - - std::list pList; - DoFindFriendlyCC(pList, (float)event.friendly_is_cc.radius); - - //List is empty - if (pList.empty()) - return false; - - //We don't really care about the whole list, just return first available - actionInvoker = *(pList.begin()); - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax); - break; - } - case EVENT_T_FRIENDLY_MISSING_BUFF: - { - std::list pList; - DoFindFriendlyMissingBuff(pList, (float)event.friendly_buff.radius, event.friendly_buff.spellId); - - //List is empty - if (pList.empty()) - return false; - - //We don't really care about the whole list, just return first available - actionInvoker = *(pList.begin()); - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.friendly_buff.repeatMin, event.friendly_buff.repeatMax); - break; - } - case EVENT_T_SUMMONED_UNIT: - { - //Prevent event from occuring on no unit or non creatures - if (!actionInvoker || actionInvoker->GetTypeId() != TYPEID_UNIT) - return false; - - //Creature id doesn't match up - if (actionInvoker->ToCreature()->GetEntry() != event.summon_unit.creatureId) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.summon_unit.repeatMin, event.summon_unit.repeatMax); - break; - } - case EVENT_T_TARGET_MANA: - { - if (!me->IsInCombat() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA)) - return false; - - uint32 perc = (me->GetVictim()->GetPower(POWER_MANA)*100) / me->GetVictim()->GetMaxPower(POWER_MANA); - - if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); - break; - } - case EVENT_T_REACHED_HOME: - case EVENT_T_RECEIVE_EMOTE: - break; - case EVENT_T_BUFFED: - { - //Note: checked only aura for effect 0, if need check aura for effect 1/2 then - // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx) - Aura const* aura = me->GetAura(event.buffed.spellId); - if (!aura || aura->GetStackAmount() < event.buffed.amount) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); - break; - } - case EVENT_T_TARGET_BUFFED: - { - //Prevent event from occuring on no unit - if (!actionInvoker) - return false; - - //Note: checked only aura for effect 0, if need check aura for effect 1/2 then - // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx) - Aura const* aura = actionInvoker->GetAura(event.buffed.spellId); - if (!aura || aura->GetStackAmount() < event.buffed.amount) - return false; - - //Repeat Timers - holder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); - break; - } - default: - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", me->GetEntry(), holder.Event.event_id, holder.Event.event_type); - break; - } - - //Disable non-repeatable events - if (!(holder.Event.event_flags & EFLAG_REPEATABLE)) - holder.Enabled = false; - - //Store random here so that all random actions match up - uint32 rnd = rand(); - - //Return if chance for event is not met - if (holder.Event.event_chance <= rnd % 100) - return false; - - //Process actions - for (uint8 j = 0; j < MAX_ACTIONS; ++j) - ProcessAction(holder.Event.action[j], rnd, holder.Event.event_id, actionInvoker); - - return true; -} - -void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 eventId, Unit* actionInvoker) -{ - switch (action.type) - { - case ACTION_T_TEXT: - { - if (!action.text.TextId1) - return; - - int32 temp = action.text.TextId1; - - if (action.text.TextId2 && action.text.TextId3) - temp = RAND(action.text.TextId1, action.text.TextId2, action.text.TextId3); - else if (action.text.TextId2 && urand(0, 1)) - temp = action.text.TextId2; - - if (temp) - { - Unit* target = NULL; - - if (actionInvoker) - { - if (actionInvoker->GetTypeId() == TYPEID_PLAYER) - target = actionInvoker; - else if (Unit* owner = actionInvoker->GetOwner()) - { - if (owner->GetTypeId() == TYPEID_PLAYER) - target = owner; - } - } - else - { - target = me->GetVictim(); - if (target && target->GetTypeId() != TYPEID_PLAYER) - if (Unit* owner = target->GetOwner()) - if (owner->GetTypeId() == TYPEID_PLAYER) - target = owner; - } - - DoScriptText(temp, me, target); - } - break; - } - case ACTION_T_SET_FACTION: - { - if (action.set_faction.factionId) - me->setFaction(action.set_faction.factionId); - else - { - if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(me->GetEntry())) - { - //if no id provided, assume reset and then use default - if (me->getFaction() != ci->faction_A) - me->setFaction(ci->faction_A); - } - } - break; - } - case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: - { - if (action.morph.creatureId || action.morph.modelId) - { - //set model based on entry from creature_template - if (action.morph.creatureId) - { - if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(action.morph.creatureId)) - me->SetDisplayId(ObjectMgr::ChooseDisplayId(ci)); - } - //if no param1, then use value from param2 (modelId) - else - me->SetDisplayId(action.morph.modelId); - } - else - me->DeMorph(); - break; - } - case ACTION_T_SOUND: - me->PlayDirectSound(action.sound.soundId); - break; - case ACTION_T_EMOTE: - me->HandleEmoteCommand(action.emote.emoteId); - break; - case ACTION_T_RANDOM_SOUND: - { - int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3); - if (temp >= 0) - me->PlayDirectSound(temp); - break; - } - case ACTION_T_RANDOM_EMOTE: - { - int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3); - if (temp >= 0) - me->HandleEmoteCommand(temp); - break; - } - case ACTION_T_CAST: - { - Unit* target = GetTargetByType(action.cast.target, actionInvoker); - Unit* caster = me; - - if (!target) - return; - - if (action.cast.castFlags & CAST_FORCE_TARGET_SELF) - caster = target; - - //Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered - bool canCast = !caster->IsNonMeleeSpellCasted(false) || (action.cast.castFlags & (CAST_TRIGGERED | CAST_INTERRUPT_PREVIOUS)); - - // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them - if (action.cast.castFlags & CAST_AURA_NOT_PRESENT) - { - if (target->HasAura(action.cast.spellId)) - return; - } - - if (canCast) - { - const SpellInfo* tSpell = sSpellMgr->GetSpellInfo(action.cast.spellId); - - //Verify that spell exists - if (tSpell) - { - //Check if cannot cast spell - if (!(action.cast.castFlags & (CAST_FORCE_TARGET_SELF | CAST_FORCE_CAST)) && - !CanCast(target, tSpell, (action.cast.castFlags & CAST_TRIGGERED))) - { - //Melee current victim if flag not set - if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM)) - { - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) - { - m_AttackDistance = 0.0f; - m_AttackAngle = 0.0f; - - me->GetMotionMaster()->MoveChase(me->GetVictim(), m_AttackDistance, m_AttackAngle); - } - } - } - else - { - //Interrupt any previous spell - if (caster->IsNonMeleeSpellCasted(false) && action.cast.castFlags & CAST_INTERRUPT_PREVIOUS) - caster->InterruptNonMeleeSpells(false); - - caster->CastSpell(target, action.cast.spellId, (action.cast.castFlags & CAST_TRIGGERED)); - } - } - else - TC_LOG_ERROR("sql.sql", "CreatureEventAI: event %d creature %d attempt to cast spell that doesn't exist %d", eventId, me->GetEntry(), action.cast.spellId); - } - break; - } - case ACTION_T_THREAT_SINGLE_PCT: - if (Unit* target = GetTargetByType(action.threat_single_pct.target, actionInvoker)) - me->getThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); - break; - case ACTION_T_THREAT_ALL_PCT: - { - ThreatContainer::StorageType const& threatList = me->getThreatManager().getThreatList(); - for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) - if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) - me->getThreatManager().modifyThreatPercent(unit, action.threat_all_pct.percent); - break; - } - case ACTION_T_QUEST_EVENT: - if (Unit* target = GetTargetByType(action.quest_event.target, actionInvoker)) - if (target->GetTypeId() == TYPEID_PLAYER) - target->ToPlayer()->AreaExploredOrEventHappens(action.quest_event.questId); - break; - case ACTION_T_SET_UNIT_FIELD: - { - Unit* target = GetTargetByType(action.set_unit_field.target, actionInvoker); - - // not allow modify important for integrity object fields - if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) - return; - - if (target) - target->SetUInt32Value(action.set_unit_field.field, action.set_unit_field.value); - - break; - } - case ACTION_T_SET_UNIT_FLAG: - if (Unit* target = GetTargetByType(action.unit_flag.target, actionInvoker)) - target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); - break; - case ACTION_T_REMOVE_UNIT_FLAG: - if (Unit* target = GetTargetByType(action.unit_flag.target, actionInvoker)) - target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); - break; - case ACTION_T_AUTO_ATTACK: - m_MeleeEnabled = action.auto_attack.state != 0; - break; - case ACTION_T_COMBAT_MOVEMENT: - // ignore no affect case - if (m_CombatMovementEnabled == (action.combat_movement.state != 0)) - return; - - m_CombatMovementEnabled = action.combat_movement.state != 0; - - //Allow movement (create new targeted movement gen only if idle) - if (m_CombatMovementEnabled) - { - Unit* victim = me->GetVictim(); - if (me->IsInCombat() && victim) - { - if (action.combat_movement.melee) - { - me->AddUnitState(UNIT_STATE_MELEE_ATTACKING); - me->SendMeleeAttackStart(victim); - } - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE) - me->GetMotionMaster()->MoveChase(victim, m_AttackDistance, m_AttackAngle); // Targeted movement generator will start melee automatically, no need to send it explicitly - } - } - else - { - if (me->IsInCombat()) - { - Unit* victim = me->GetVictim(); - if (action.combat_movement.melee && victim) - { - me->ClearUnitState(UNIT_STATE_MELEE_ATTACKING); - me->SendMeleeAttackStop(victim); - } - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) - me->GetMotionMaster()->MoveIdle(); - } - } - break; - case ACTION_T_SET_PHASE: - m_Phase = action.set_phase.phase; - break; - case ACTION_T_INC_PHASE: - { - int32 new_phase = int32(m_Phase)+action.set_inc_phase.step; - if (new_phase < 0) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %d decrease m_Phase under 0. CreatureEntry = %d", eventId, me->GetEntry()); - m_Phase = 0; - } - else if (new_phase >= MAX_PHASE) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %d incremented m_Phase above %u. m_Phase mask cannot be used with phases past %u. CreatureEntry = %d", eventId, MAX_PHASE-1, MAX_PHASE-1, me->GetEntry()); - m_Phase = MAX_PHASE-1; - } - else - m_Phase = new_phase; - - break; - } - case ACTION_T_EVADE: - EnterEvadeMode(); - break; - case ACTION_T_FLEE_FOR_ASSIST: - me->DoFleeToGetAssistance(); - break; - case ACTION_T_QUEST_EVENT_ALL: - if (actionInvoker && actionInvoker->GetTypeId() == TYPEID_PLAYER) - { - if (Unit* Temp = Unit::GetUnit(*me, actionInvoker->GetGUID())) - if (Temp->GetTypeId() == TYPEID_PLAYER) - Temp->ToPlayer()->GroupEventHappens(action.quest_event_all.questId, me); - } - break; - case ACTION_T_REMOVEAURASFROMSPELL: - if (Unit* target = GetTargetByType(action.remove_aura.target, actionInvoker)) - target->RemoveAurasDueToSpell(action.remove_aura.spellId); - break; - case ACTION_T_RANGED_MOVEMENT: - m_AttackDistance = (float)action.ranged_movement.distance; - m_AttackAngle = action.ranged_movement.angle/180.0f*M_PI; - - if (m_CombatMovementEnabled) - { - me->GetMotionMaster()->MoveChase(me->GetVictim(), m_AttackDistance, m_AttackAngle); - } - break; - case ACTION_T_RANDOM_PHASE: - m_Phase = GetRandActionParam(rnd, action.random_phase.phase1, action.random_phase.phase2, action.random_phase.phase3); - break; - case ACTION_T_RANDOM_PHASE_RANGE: - if (action.random_phase_range.phaseMin <= action.random_phase_range.phaseMax) - m_Phase = urand(action.random_phase_range.phaseMin, action.random_phase_range.phaseMax); - else - TC_LOG_ERROR("sql.sql", "CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", eventId, me->GetEntry()); - break; - case ACTION_T_KILLED_MONSTER: - //first attempt player who tapped creature - if (Player* player = me->GetLootRecipient()) - player->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, player); // player as param is a hacky solution not to use GUID - else - { - //if not available, use actionInvoker - if (Unit* target = GetTargetByType(action.killed_monster.target, actionInvoker)) - if (Player* player2 = target->GetCharmerOrOwnerPlayerOrPlayerItself()) - player2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, player2); - } - break; - case ACTION_T_SET_INST_DATA: - { - InstanceScript* instance = me->GetInstanceScript(); - if (!instance) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", eventId, me->GetEntry()); - return; - } - - instance->SetData(action.set_inst_data.field, action.set_inst_data.value); - break; - } - case ACTION_T_SET_INST_DATA64: - { - Unit* target = GetTargetByType(action.set_inst_data64.target, actionInvoker); - if (!target) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", eventId, me->GetEntry()); - return; - } - - InstanceScript* instance = me->GetInstanceScript(); - if (!instance) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", eventId, me->GetEntry()); - return; - } - - instance->SetData64(action.set_inst_data64.field, target->GetGUID()); - break; - } - case ACTION_T_UPDATE_TEMPLATE: - if (me->GetEntry() == action.update_template.creatureId) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", eventId, me->GetEntry()); - return; - } - - me->UpdateEntry(action.update_template.creatureId, action.update_template.team ? HORDE : ALLIANCE); - break; - case ACTION_T_DIE: - if (me->isDead()) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", eventId, me->GetEntry()); - return; - } - me->Kill(me); - break; - case ACTION_T_ZONE_COMBAT_PULSE: - { - me->SetInCombatWithZone(); - break; - } - case ACTION_T_CALL_FOR_HELP: - { - me->CallForHelp((float)action.call_for_help.radius); - break; - } - break; - - // TRINITY ONLY - case ACTION_T_MOVE_RANDOM_POINT: //dosen't work in combat - { - float x, y, z; - me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)action.raw.param1); - me->GetMotionMaster()->MovePoint(0, x, y, z); - break; - } - case ACTION_T_SET_STAND_STATE: - me->SetStandState(UnitStandStateType(action.raw.param1)); - break; - case ACTION_T_SET_PHASE_MASK: - me->SetPhaseMask(action.raw.param1, true); - break; - case ACTION_T_SET_VISIBILITY: - me->SetVisible(bool(action.raw.param1)); - break; - case ACTION_T_SET_ACTIVE: - me->setActive(action.raw.param1 ? true : false); - break; - case ACTION_T_SET_AGGRESSIVE: - me->SetReactState(ReactStates(action.raw.param1)); - break; - case ACTION_T_ATTACK_START_PULSE: - AttackStart(me->SelectNearestTarget((float)action.raw.param1)); - break; - case ACTION_T_SUMMON_GO: - { - float x, y, z; - me->GetPosition(x, y, z); - GameObject* object = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2); - if (!object) - TC_LOG_ERROR("scripts", "EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, eventId, me->GetEntry()); - - break; - } - case ACTION_T_SET_SHEATH: - { - me->SetSheath(SheathState(action.set_sheath.sheath)); - break; - } - case ACTION_T_FORCE_DESPAWN: - { - me->DespawnOrUnsummon(action.forced_despawn.msDelay); - break; - } - case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: - { - if (action.invincibility_hp_level.is_percent) - m_InvincibilityHpLevel = me->CountPctFromMaxHealth(action.invincibility_hp_level.hp_level); - else - m_InvincibilityHpLevel = action.invincibility_hp_level.hp_level; - break; - } - case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL: - { - if (action.mount.creatureId || action.mount.modelId) - { - // set model based on entry from creature_template - if (action.mount.creatureId) - { - if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(action.mount.creatureId)) - me->Mount(ObjectMgr::ChooseDisplayId(cInfo)); - } - //if no param1, then use value from param2 (modelId) - else - me->Mount(action.mount.modelId); - } - else - me->Dismount(); - - break; - } - default: - break; - } -} - -void CreatureEventAI::JustRespawned() -{ - Reset(); - - if (m_bEmptyList) - return; - - //Handle Spawned Events - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - if (SpawnedEventConditionsCheck((*i).Event)) - ProcessEvent(*i); -} - -void CreatureEventAI::Reset() -{ - m_EventUpdateTime = EVENT_UPDATE_TIME; - m_EventDiff = 0; - - if (m_bEmptyList) - return; - - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - if ((*i).Event.event_type == EVENT_T_RESET) - ProcessEvent(*i); - } - - //Reset all events to enabled - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - CreatureEventAI_Event const& event = (*i).Event; - switch (event.event_type) - { - //Reset all out of combat timers - case EVENT_T_TIMER_OOC: - { - if ((*i).UpdateRepeatTimer(me, event.timer.initialMin, event.timer.initialMax)) - (*i).Enabled = true; - break; - } - default: - /// @todo enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void EnterCombat() - //(*i).Enabled = true; - //(*i).Time = 0; - break; - } - } -} - -void CreatureEventAI::JustReachedHome() -{ - if (!m_bEmptyList) - { - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - if ((*i).Event.event_type == EVENT_T_REACHED_HOME) - ProcessEvent(*i); - } - } - - Reset(); -} - -void CreatureEventAI::EnterEvadeMode() -{ - CreatureAI::EnterEvadeMode(); - - if (m_bEmptyList) - return; - - //Handle Evade events - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - if ((*i).Event.event_type == EVENT_T_EVADE) - ProcessEvent(*i); - } -} - -void CreatureEventAI::JustDied(Unit* killer) -{ - Reset(); - - if (m_bEmptyList) - return; - - //Handle Evade events - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - if ((*i).Event.event_type == EVENT_T_DEATH) - ProcessEvent(*i, killer); - } - - // reset phase after any death state events - m_Phase = 0; -} - -void CreatureEventAI::KilledUnit(Unit* victim) -{ - if (m_bEmptyList || victim->GetTypeId() != TYPEID_PLAYER) - return; - - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - if ((*i).Event.event_type == EVENT_T_KILL) - ProcessEvent(*i, victim); - } -} - -void CreatureEventAI::JustSummoned(Creature* unit) -{ - if (m_bEmptyList || !unit) - return; - - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - if ((*i).Event.event_type == EVENT_T_SUMMONED_UNIT) - ProcessEvent(*i, unit); - } -} - -void CreatureEventAI::EnterCombat(Unit* enemy) -{ - //Check for on combat start events - if (!m_bEmptyList) - { - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - CreatureEventAI_Event const& event = (*i).Event; - switch (event.event_type) - { - case EVENT_T_AGGRO: - (*i).Enabled = true; - ProcessEvent(*i, enemy); - break; - //Reset all in combat timers - case EVENT_T_TIMER: - if ((*i).UpdateRepeatTimer(me, event.timer.initialMin, event.timer.initialMax)) - (*i).Enabled = true; - break; - //All normal events need to be re-enabled and their time set to 0 - default: - (*i).Enabled = true; - (*i).Time = 0; - break; - } - } - } - - m_EventUpdateTime = EVENT_UPDATE_TIME; - m_EventDiff = 0; -} - -void CreatureEventAI::AttackStart(Unit* who) -{ - if (!who) - return; - - if (me->Attack(who, m_MeleeEnabled)) - { - if (m_CombatMovementEnabled) - { - me->GetMotionMaster()->MoveChase(who, m_AttackDistance, m_AttackAngle); - } - else - { - me->GetMotionMaster()->MoveIdle(); - } - } -} - -void CreatureEventAI::MoveInLineOfSight(Unit* who) -{ - if (me->GetVictim()) - return; - - //Check for OOC LOS Event - if (!m_bEmptyList) - { - for (CreatureEventAIList::iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr) - { - if ((*itr).Event.event_type == EVENT_T_OOC_LOS) - { - //can trigger if closer than fMaxAllowedRange - float fMaxAllowedRange = (float)((*itr).Event.ooc_los.maxRange); - - //if range is ok and we are actually in LOS - if (me->IsWithinDistInMap(who, fMaxAllowedRange) && me->IsWithinLOSInMap(who)) - { - //if friendly event&&who is not hostile OR hostile event&&who is hostile - if (((*itr).Event.ooc_los.noHostile && !me->IsHostileTo(who)) || - ((!(*itr).Event.ooc_los.noHostile) && me->IsHostileTo(who))) - ProcessEvent(*itr, who); - } - } - } - } - - CreatureAI::MoveInLineOfSight(who); -} - -void CreatureEventAI::SpellHit(Unit* unit, const SpellInfo* spell) -{ - if (m_bEmptyList) - return; - - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - if ((*i).Event.event_type == EVENT_T_SPELLHIT) - //If spell id matches (or no spell id) & if spell school matches (or no spell school) - if (!(*i).Event.spell_hit.spellId || spell->Id == (*i).Event.spell_hit.spellId) - if (spell->SchoolMask & (*i).Event.spell_hit.schoolMask) - ProcessEvent(*i, unit); -} - -void CreatureEventAI::UpdateAI(uint32 diff) -{ - //Check if we are in combat (also updates calls threat update code) - bool Combat = UpdateVictim(); - - if (!m_bEmptyList) - { - //Events are only updated once every EVENT_UPDATE_TIME ms to prevent lag with large amount of events - if (m_EventUpdateTime <= diff) - { - m_EventDiff += diff; - - //Check for time based events - for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) - { - //Decrement Timers - if ((*i).Time) - { - if (m_EventDiff <= (*i).Time) - { - //Do not decrement timers if event cannot trigger in this phase - if (!((*i).Event.event_inverse_phase_mask & (1 << m_Phase))) - (*i).Time -= m_EventDiff; - - //Skip processing of events that have time remaining - continue; - } - else (*i).Time = 0; - } - - //Events that are updated every EVENT_UPDATE_TIME - switch ((*i).Event.event_type) - { - case EVENT_T_TIMER_OOC: - ProcessEvent(*i); - break; - case EVENT_T_TIMER: - case EVENT_T_MANA: - case EVENT_T_HP: - case EVENT_T_TARGET_HP: - case EVENT_T_TARGET_CASTING: - case EVENT_T_FRIENDLY_HP: - if (me->GetVictim()) - ProcessEvent(*i); - break; - case EVENT_T_RANGE: - if (me->GetVictim()) - if (me->IsInMap(me->GetVictim()) && me->InSamePhase(me->GetVictim())) - if (me->IsInRange(me->GetVictim(), (float)(*i).Event.range.minDist, (float)(*i).Event.range.maxDist)) - ProcessEvent(*i); - break; - default: - break; - } - } - - m_EventDiff = 0; - m_EventUpdateTime = EVENT_UPDATE_TIME; - } - else - { - m_EventDiff += diff; - m_EventUpdateTime -= diff; - } - } - - //Melee Auto-Attack - if (Combat && m_MeleeEnabled) - DoMeleeAttackIfReady(); -} - -inline uint32 CreatureEventAI::GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3) -{ - switch (rnd % 3) - { - case 0: return param1; - case 1: return param2; - case 2: break; - } - - return param3; -} - -inline int32 CreatureEventAI::GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3) -{ - switch (rnd % 3) - { - case 0: return param1; - case 1: return param2; - case 2: break; - } - - return param3; -} - -inline Unit* CreatureEventAI::GetTargetByType(uint32 target, Unit* actionInvoker) -{ - switch (target) - { - case TARGET_T_SELF: - return me; - case TARGET_T_HOSTILE: - return me->GetVictim(); - case TARGET_T_HOSTILE_SECOND_AGGRO: - return SelectTarget(SELECT_TARGET_TOPAGGRO, 1); - case TARGET_T_HOSTILE_LAST_AGGRO: - return SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); - case TARGET_T_HOSTILE_RANDOM: - return SelectTarget(SELECT_TARGET_RANDOM, 0); - case TARGET_T_HOSTILE_RANDOM_NOT_TOP: - return SelectTarget(SELECT_TARGET_RANDOM, 1); - case TARGET_T_ACTION_INVOKER: - return actionInvoker; - default: - return NULL; - }; -} - -Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) -{ - CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); - - Unit* unit = NULL; - - Trinity::MostHPMissingInRange u_check(me, range, minHPDiff); - Trinity::UnitLastSearcher searcher(me, unit, u_check); - - /* - typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; - This means that if we only search grid then we cannot possibly return pets or players so this is safe - */ - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, range); - return unit; -} - -void CreatureEventAI::DoFindFriendlyCC(std::list& _list, float range) -{ - CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); - - Trinity::FriendlyCCedInRange u_check(me, range); - Trinity::CreatureListSearcher searcher(me, _list, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range); -} - -void CreatureEventAI::DoFindFriendlyMissingBuff(std::list& _list, float range, uint32 spellid) -{ - CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); - - Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid); - Trinity::CreatureListSearcher searcher(me, _list, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range); -} - -// ********************************* -// *** Functions used globally *** - -void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* source, Unit* target) -{ - if (!source) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: DoScriptText entry %i, invalid Source pointer.", textEntry); - return; - } - - if (textEntry >= 0) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", source->GetEntry(), source->GetTypeId(), source->GetGUIDLow(), textEntry); - return; - } - - CreatureEventAI_TextMap::const_iterator i = sEventAIMgr->GetCreatureEventAITextMap().find(textEntry); - - if (i == sEventAIMgr->GetCreatureEventAITextMap().end()) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", source->GetEntry(), source->GetTypeId(), source->GetGUIDLow(), textEntry); - return; - } - - TC_LOG_DEBUG("scripts.ai", "CreatureEventAI: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", textEntry, (*i).second.SoundId, (*i).second.Type, (*i).second.Language, (*i).second.Emote); - - if ((*i).second.SoundId) - { - if (sSoundEntriesStore.LookupEntry((*i).second.SoundId)) - source->PlayDirectSound((*i).second.SoundId); - else - TC_LOG_ERROR("sql.sql", "CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.", textEntry, (*i).second.SoundId); - } - - if ((*i).second.Emote) - { - if (source->GetTypeId() == TYPEID_UNIT || source->GetTypeId() == TYPEID_PLAYER) - { - ((Unit*)source)->HandleEmoteCommand((*i).second.Emote); - } - else - TC_LOG_ERROR("sql.sql", "CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", textEntry, source->GetTypeId()); - } - - switch ((*i).second.Type) - { - case CHAT_TYPE_SAY: - source->MonsterSay(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); - break; - case CHAT_TYPE_YELL: - source->MonsterYell(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); - break; - case CHAT_TYPE_TEXT_EMOTE: - source->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0); - break; - case CHAT_TYPE_BOSS_EMOTE: - source->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0, true); - break; - case CHAT_TYPE_WHISPER: - { - if (target && target->GetTypeId() == TYPEID_PLAYER) - source->MonsterWhisper(textEntry, target->GetGUID()); - else TC_LOG_ERROR("sql.sql", "CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); - }break; - case CHAT_TYPE_BOSS_WHISPER: - { - if (target && target->GetTypeId() == TYPEID_PLAYER) - source->MonsterWhisper(textEntry, target->GetGUID(), true); - else TC_LOG_ERROR("sql.sql", "CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); - }break; - case CHAT_TYPE_ZONE_YELL: - source->MonsterYellToZone(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); - break; - } -} - -bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool triggered) -{ - //No target so we can't cast - if (!target || !spell) - return false; - - //Silenced so we can't cast - if (!triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - return false; - - //Check for power - if (!triggered && me->GetPower((Powers)spell->PowerType) < uint32(spell->CalcPowerCost(me, spell->GetSchoolMask()))) - return false; - - //Unit is out of range of this spell - if (!me->IsInRange(target, spell->GetMinRange(false), spell->GetMaxRange(false))) - return false; - - //Spell is on cooldown - if (me->HasSpellCooldown(spell->Id)) - return false; - - return true; -} - -void CreatureEventAI::ReceiveEmote(Player* player, uint32 textEmote) -{ - if (m_bEmptyList) - return; - - for (CreatureEventAIList::iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr) - { - if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE) - { - if ((*itr).Event.receive_emote.emoteId != textEmote) - return; - - Condition cond; - cond.ConditionType = ConditionTypes((*itr).Event.receive_emote.condition); - cond.ConditionValue1 = (*itr).Event.receive_emote.conditionValue1; - cond.ConditionValue2 = (*itr).Event.receive_emote.conditionValue2; - - ConditionSourceInfo srcInfo = ConditionSourceInfo(player); - if (cond.Meets(srcInfo)) - { - TC_LOG_DEBUG("scripts.ai", "CreatureEventAI: ReceiveEmote CreatureEventAI: Condition ok, processing"); - ProcessEvent(*itr, player); - } - } - } -} - -void CreatureEventAI::DamageTaken(Unit* /*done_by*/, uint32& damage) -{ - if (m_InvincibilityHpLevel > 0 && me->GetHealth() < m_InvincibilityHpLevel+damage) - { - if (me->GetHealth() <= m_InvincibilityHpLevel) - damage = 0; - else - damage = me->GetHealth() - m_InvincibilityHpLevel; - } -} - -bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event) -{ - if (event.event_type != EVENT_T_SPAWNED) - return false; - - switch (event.spawned.condition) - { - case SPAWNED_EVENT_ALWAY: - // always - return true; - case SPAWNED_EVENT_MAP: - // map ID check - return me->GetMapId() == event.spawned.conditionValue1; - case SPAWNED_EVENT_ZONE: - { - // zone ID check - uint32 zone, area; - me->GetZoneAndAreaId(zone, area); - return zone == event.spawned.conditionValue1 || area == event.spawned.conditionValue1; - } - default: - break; - } - - return false; -} diff --git a/src/server/game/AI/EventAI/CreatureEventAI.h b/src/server/game/AI/EventAI/CreatureEventAI.h deleted file mode 100644 index c16f0901b05..00000000000 --- a/src/server/game/AI/EventAI/CreatureEventAI.h +++ /dev/null @@ -1,630 +0,0 @@ -/* - * Copyright (C) 2008-2013 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef TRINITY_CREATURE_EAI_H -#define TRINITY_CREATURE_EAI_H - -#include "Common.h" -#include "Creature.h" -#include "CreatureAI.h" -#include "Unit.h" - -class Player; -class WorldObject; - -#define EVENT_UPDATE_TIME 500 -#define MAX_ACTIONS 3 -#define MAX_PHASE 32 - -enum EventAI_Type -{ - EVENT_T_TIMER = 0, // InitialMin, InitialMax, RepeatMin, RepeatMax - EVENT_T_TIMER_OOC = 1, // InitialMin, InitialMax, RepeatMin, RepeatMax - EVENT_T_HP = 2, // HPMax%, HPMin%, RepeatMin, RepeatMax - EVENT_T_MANA = 3, // ManaMax%, ManaMin% RepeatMin, RepeatMax - EVENT_T_AGGRO = 4, // NONE - EVENT_T_KILL = 5, // RepeatMin, RepeatMax - EVENT_T_DEATH = 6, // NONE - EVENT_T_EVADE = 7, // NONE - EVENT_T_SPELLHIT = 8, // SpellID, School, RepeatMin, RepeatMax - EVENT_T_RANGE = 9, // MinDist, MaxDist, RepeatMin, RepeatMax - EVENT_T_OOC_LOS = 10, // NoHostile, MaxRnage, RepeatMin, RepeatMax - EVENT_T_SPAWNED = 11, // Condition, CondValue1 - EVENT_T_TARGET_HP = 12, // HPMax%, HPMin%, RepeatMin, RepeatMax - EVENT_T_TARGET_CASTING = 13, // RepeatMin, RepeatMax - EVENT_T_FRIENDLY_HP = 14, // HPDeficit, Radius, RepeatMin, RepeatMax - EVENT_T_FRIENDLY_IS_CC = 15, // DispelType, Radius, RepeatMin, RepeatMax - EVENT_T_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax - EVENT_T_SUMMONED_UNIT = 17, // CreatureId, RepeatMin, RepeatMax - EVENT_T_TARGET_MANA = 18, // ManaMax%, ManaMin%, RepeatMin, RepeatMax - EVENT_T_QUEST_ACCEPT = 19, // QuestID - EVENT_T_QUEST_COMPLETE = 20, // - EVENT_T_REACHED_HOME = 21, // NONE - EVENT_T_RECEIVE_EMOTE = 22, // EmoteId, Condition, CondValue1, CondValue2 - EVENT_T_BUFFED = 23, // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max - EVENT_T_TARGET_BUFFED = 24, // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max - EVENT_T_RESET = 35, // Is it called after combat, when the creature respawn and spawn. -- TRINITY ONLY - - EVENT_T_END -}; - -enum EventAI_ActionType -{ - ACTION_T_NONE = 0, // No action - ACTION_T_TEXT = 1, // TextId1, optionally -TextId2, optionally -TextId3(if -TextId2 exist). If more than just -TextId1 is defined, randomize. Negative values. - ACTION_T_SET_FACTION = 2, // FactionId (or 0 for default) - ACTION_T_MORPH_TO_ENTRY_OR_MODEL = 3, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to demorph) - ACTION_T_SOUND = 4, // SoundId - ACTION_T_EMOTE = 5, // EmoteId - ACTION_T_RANDOM_SAY = 6, // UNUSED - ACTION_T_RANDOM_YELL = 7, // UNUSED - ACTION_T_RANDOM_TEXTEMOTE = 8, // UNUSED - ACTION_T_RANDOM_SOUND = 9, // SoundId1, SoundId2, SoundId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_EMOTE = 10, // EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field) - ACTION_T_CAST = 11, // SpellId, Target, CastFlags - ACTION_T_SUMMON = 12, // CreatureID, Target, Duration in ms - ACTION_T_THREAT_SINGLE_PCT = 13, // Threat%, Target - ACTION_T_THREAT_ALL_PCT = 14, // Threat% - ACTION_T_QUEST_EVENT = 15, // QuestID, Target - // none = 16, - ACTION_T_SET_UNIT_FIELD = 17, // Field_Number, Value, Target - ACTION_T_SET_UNIT_FLAG = 18, // Flags (may be more than one field OR'd together), Target - ACTION_T_REMOVE_UNIT_FLAG = 19, // Flags (may be more than one field OR'd together), Target - ACTION_T_AUTO_ATTACK = 20, // AllowAttackState (0 = stop attack, anything else means continue attacking) - ACTION_T_COMBAT_MOVEMENT = 21, // AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) - ACTION_T_SET_PHASE = 22, // Phase - ACTION_T_INC_PHASE = 23, // Value (may be negative to decrement phase, should not be 0) - ACTION_T_EVADE = 24, // No Params - ACTION_T_FLEE_FOR_ASSIST = 25, // No Params - ACTION_T_QUEST_EVENT_ALL = 26, // QuestID - // none = 27, - ACTION_T_REMOVEAURASFROMSPELL = 28, // Target, Spellid - ACTION_T_RANGED_MOVEMENT = 29, // Distance, Angle - ACTION_T_RANDOM_PHASE = 30, // PhaseId1, PhaseId2, PhaseId3 - ACTION_T_RANDOM_PHASE_RANGE = 31, // PhaseMin, PhaseMax - ACTION_T_SUMMON_ID = 32, // CreatureId, Target, SpawnId - ACTION_T_KILLED_MONSTER = 33, // CreatureId, Target - ACTION_T_SET_INST_DATA = 34, // Field, Data - ACTION_T_SET_INST_DATA64 = 35, // Field, Target - ACTION_T_UPDATE_TEMPLATE = 36, // Entry, Team - ACTION_T_DIE = 37, // No Params - ACTION_T_ZONE_COMBAT_PULSE = 38, // No Params - ACTION_T_CALL_FOR_HELP = 39, // Radius - ACTION_T_SET_SHEATH = 40, // Sheath (0-passive, 1-melee, 2-ranged) - ACTION_T_FORCE_DESPAWN = 41, // No Params - ACTION_T_SET_INVINCIBILITY_HP_LEVEL = 42, // MinHpValue, format(0-flat, 1-percent from max health) - ACTION_T_MOUNT_TO_ENTRY_OR_MODEL = 43, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to dismount) - - ACTION_T_SET_PHASE_MASK = 97, - ACTION_T_SET_STAND_STATE = 98, - ACTION_T_MOVE_RANDOM_POINT = 99, - ACTION_T_SET_VISIBILITY = 100, - ACTION_T_SET_ACTIVE = 101, //Apply - ACTION_T_SET_AGGRESSIVE = 102, //Apply - ACTION_T_ATTACK_START_PULSE = 103, //Distance - ACTION_T_SUMMON_GO = 104, //GameObjectID, DespawnTime in ms - - ACTION_T_END = 105 -}; - -enum Target -{ - //Self (me) - TARGET_T_SELF = 0, //Self cast - - //Hostile targets (if pet then returns pet owner) - TARGET_T_HOSTILE, //Our current target (ie: highest aggro) - TARGET_T_HOSTILE_SECOND_AGGRO, //Second highest aggro (generaly used for cleaves and some special attacks) - TARGET_T_HOSTILE_LAST_AGGRO, //Dead last on aggro (no idea what this could be used for) - TARGET_T_HOSTILE_RANDOM, //Just any random target on our threat list - TARGET_T_HOSTILE_RANDOM_NOT_TOP, //Any random target except top threat - - //Invoker targets (if pet then returns pet owner) - TARGET_T_ACTION_INVOKER, //Unit who caused this Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF) - - //Hostile targets (including pets) - TARGET_T_HOSTILE_WPET, //Current target (can be a pet) - TARGET_T_HOSTILE_WPET_SECOND_AGGRO, //Second highest aggro (generaly used for cleaves and some special attacks) - TARGET_T_HOSTILE_WPET_LAST_AGGRO, //Dead last on aggro (no idea what this could be used for) - TARGET_T_HOSTILE_WPET_RANDOM, //Just any random target on our threat list - TARGET_T_HOSTILE_WPET_RANDOM_NOT_TOP, //Any random target except top threat - - TARGET_T_ACTION_INVOKER_WPET, - - TARGET_T_END -}; - -enum CastFlags -{ - CAST_INTERRUPT_PREVIOUS = 0x01, //Interrupt any spell casting - CAST_TRIGGERED = 0x02, //Triggered (this makes spell cost zero mana and have no cast time) - CAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range - CAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range - CAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself - CAST_AURA_NOT_PRESENT = 0x20 //Only casts the spell if the target does not have an aura from the spell -}; - -enum EventFlags -{ - EFLAG_REPEATABLE = 0x01, //Event repeats - EFLAG_DIFFICULTY_0 = 0x02, //Event only occurs in instance difficulty 0 - EFLAG_DIFFICULTY_1 = 0x04, //Event only occurs in instance difficulty 1 - EFLAG_DIFFICULTY_2 = 0x08, //Event only occurs in instance difficulty 2 - EFLAG_DIFFICULTY_3 = 0x10, //Event only occurs in instance difficulty 3 - EFLAG_RESERVED_5 = 0x20, - EFLAG_RESERVED_6 = 0x40, - EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build - - EFLAG_DIFFICULTY_ALL = (EFLAG_DIFFICULTY_0|EFLAG_DIFFICULTY_1|EFLAG_DIFFICULTY_2|EFLAG_DIFFICULTY_3) -}; - -enum SpawnedEventMode -{ - SPAWNED_EVENT_ALWAY = 0, - SPAWNED_EVENT_MAP = 1, - SPAWNED_EVENT_ZONE = 2 -}; - -// String text additional data, used in (CreatureEventAI) -struct StringTextData -{ - uint32 SoundId; - uint8 Type; - uint32 Language; - uint32 Emote; -}; -// Text Maps -typedef UNORDERED_MAP CreatureEventAI_TextMap; - -struct CreatureEventAI_Action -{ - EventAI_ActionType type: 16; - union - { - // ACTION_T_TEXT = 1 - struct - { - int32 TextId1; - int32 TextId2; - int32 TextId3; - } text; - // ACTION_T_SET_FACTION = 2 - struct - { - uint32 factionId; // faction or 0 for default) - } set_faction; - // ACTION_T_MORPH_TO_ENTRY_OR_MODEL = 3 - struct - { - uint32 creatureId; // set one from fields (or 0 for both to demorph) - uint32 modelId; - } morph; - // ACTION_T_SOUND = 4 - struct - { - uint32 soundId; - } sound; - // ACTION_T_EMOTE = 5 - struct - { - uint32 emoteId; - } emote; - // ACTION_T_RANDOM_SOUND = 9 - struct - { - int32 soundId1; // (-1 in any field means no output if randomed that field) - int32 soundId2; - int32 soundId3; - } random_sound; - // ACTION_T_RANDOM_EMOTE = 10 - struct - { - int32 emoteId1; // (-1 in any field means no output if randomed that field) - int32 emoteId2; - int32 emoteId3; - } random_emote; - // ACTION_T_CAST = 11 - struct - { - uint32 spellId; - uint32 target; - uint32 castFlags; - } cast; - // ACTION_T_SUMMON = 12 - struct - { - uint32 creatureId; - uint32 target; - uint32 duration; - } summon; - // ACTION_T_THREAT_SINGLE_PCT = 13 - struct - { - int32 percent; - uint32 target; - } threat_single_pct; - // ACTION_T_THREAT_ALL_PCT = 14 - struct - { - int32 percent; - } threat_all_pct; - // ACTION_T_QUEST_EVENT = 15 - struct - { - uint32 questId; - uint32 target; - } quest_event; - // ACTION_T_SET_UNIT_FIELD = 17 - struct - { - uint32 field; - uint32 value; - uint32 target; - } set_unit_field; - // ACTION_T_SET_UNIT_FLAG = 18, // value provided mask bits that will be set - // ACTION_T_REMOVE_UNIT_FLAG = 19, // value provided mask bits that will be clear - struct - { - uint32 value; - uint32 target; - } unit_flag; - // ACTION_T_AUTO_ATTACK = 20 - struct - { - uint32 state; // 0 = stop attack, anything else means continue attacking - } auto_attack; - // ACTION_T_COMBAT_MOVEMENT = 21 - struct - { - uint32 state; // 0 = stop combat based movement, anything else continue attacking - uint32 melee; // if set: at stop send melee combat stop if in combat, use for terminate melee fighting state for switch to ranged - } combat_movement; - // ACTION_T_SET_PHASE = 22 - struct - { - uint32 phase; - } set_phase; - // ACTION_T_INC_PHASE = 23 - struct - { - int32 step; - } set_inc_phase; - // ACTION_T_QUEST_EVENT_ALL = 26 - struct - { - uint32 questId; - } quest_event_all; - // ACTION_T_REMOVEAURASFROMSPELL = 28 - struct - { - uint32 target; - uint32 spellId; - } remove_aura; - // ACTION_T_RANGED_MOVEMENT = 29 - struct - { - uint32 distance; - int32 angle; - } ranged_movement; - // ACTION_T_RANDOM_PHASE = 30 - struct - { - uint32 phase1; - uint32 phase2; - uint32 phase3; - } random_phase; - // ACTION_T_RANDOM_PHASE_RANGE = 31 - struct - { - uint32 phaseMin; - uint32 phaseMax; - } random_phase_range; - // ACTION_T_SUMMON_ID = 32 - struct - { - uint32 creatureId; - uint32 target; - uint32 spawnId; - } summon_id; - // ACTION_T_KILLED_MONSTER = 33 - struct - { - uint32 creatureId; - uint32 target; - } killed_monster; - // ACTION_T_SET_INST_DATA = 34 - struct - { - uint32 field; - uint32 value; - } set_inst_data; - // ACTION_T_SET_INST_DATA64 = 35 - struct - { - uint32 field; - uint32 target; - } set_inst_data64; - // ACTION_T_UPDATE_TEMPLATE = 36 - struct - { - uint32 creatureId; - uint32 team; - } update_template; - // ACTION_T_CALL_FOR_HELP = 39 - struct - { - uint32 radius; - } call_for_help; - // ACTION_T_SET_SHEATH = 40 - struct - { - uint32 sheath; - } set_sheath; - // ACTION_T_FORCE_DESPAWN = 41 - struct - { - uint32 msDelay; - } forced_despawn; - // ACTION_T_SET_INVINCIBILITY_HP_LEVEL = 42 - struct - { - uint32 hp_level; - uint32 is_percent; - } invincibility_hp_level; - // ACTION_T_MOUNT_TO_ENTRY_OR_MODEL = 43 - struct - { - uint32 creatureId; // set one from fields (or 0 for both to dismount) - uint32 modelId; - } mount; - // RAW - struct - { - uint32 param1; - uint32 param2; - uint32 param3; - } raw; - }; -}; - -struct CreatureEventAI_Event -{ - uint32 event_id; - - uint32 creature_id; - - uint32 event_inverse_phase_mask; - - EventAI_Type event_type : 16; - uint8 event_chance : 8; - uint8 event_flags : 8; - - union - { - // EVENT_T_TIMER = 0 - // EVENT_T_TIMER_OOC = 1 - struct - { - uint32 initialMin; - uint32 initialMax; - uint32 repeatMin; - uint32 repeatMax; - } timer; - // EVENT_T_HP = 2 - // EVENT_T_MANA = 3 - // EVENT_T_TARGET_HP = 12 - // EVENT_T_TARGET_MANA = 18 - struct - { - uint32 percentMax; - uint32 percentMin; - uint32 repeatMin; - uint32 repeatMax; - } percent_range; - // EVENT_T_KILL = 5 - struct - { - uint32 repeatMin; - uint32 repeatMax; - } kill; - // EVENT_T_SPELLHIT = 8 - struct - { - uint32 spellId; - uint32 schoolMask; // -1 ( == 0xffffffff) is ok value for full mask, or must be more limited mask like (0 < 1) = 1 for normal/physical school - uint32 repeatMin; - uint32 repeatMax; - } spell_hit; - // EVENT_T_RANGE = 9 - struct - { - uint32 minDist; - uint32 maxDist; - uint32 repeatMin; - uint32 repeatMax; - } range; - // EVENT_T_OOC_LOS = 10 - struct - { - uint32 noHostile; - uint32 maxRange; - uint32 repeatMin; - uint32 repeatMax; - } ooc_los; - // EVENT_T_SPAWNED = 11 - struct - { - uint32 condition; - uint32 conditionValue1; - } spawned; - // EVENT_T_TARGET_CASTING = 13 - struct - { - uint32 repeatMin; - uint32 repeatMax; - } target_casting; - // EVENT_T_FRIENDLY_HP = 14 - struct - { - uint32 hpDeficit; - uint32 radius; - uint32 repeatMin; - uint32 repeatMax; - } friendly_hp; - // EVENT_T_FRIENDLY_IS_CC = 15 - struct - { - uint32 dispelType; // unused ? - uint32 radius; - uint32 repeatMin; - uint32 repeatMax; - } friendly_is_cc; - // EVENT_T_FRIENDLY_MISSING_BUFF = 16 - struct - { - uint32 spellId; - uint32 radius; - uint32 repeatMin; - uint32 repeatMax; - } friendly_buff; - // EVENT_T_SUMMONED_UNIT = 17 - struct - { - uint32 creatureId; - uint32 repeatMin; - uint32 repeatMax; - } summon_unit; - // EVENT_T_QUEST_ACCEPT = 19 - // EVENT_T_QUEST_COMPLETE = 20 - struct - { - uint32 questId; - } quest; - // EVENT_T_RECEIVE_EMOTE = 22 - struct - { - uint32 emoteId; - uint32 condition; - uint32 conditionValue1; - uint32 conditionValue2; - } receive_emote; - // EVENT_T_BUFFED = 23 - // EVENT_T_TARGET_BUFFED = 24 - struct - { - uint32 spellId; - uint32 amount; - uint32 repeatMin; - uint32 repeatMax; - } buffed; - - // RAW - struct - { - uint32 param1; - uint32 param2; - uint32 param3; - uint32 param4; - } raw; - }; - - CreatureEventAI_Action action[MAX_ACTIONS]; -}; -//Event_Map -typedef UNORDERED_MAP > CreatureEventAI_Event_Map; - -struct CreatureEventAI_Summon -{ - //uint32 id; - - float position_x; - float position_y; - float position_z; - float orientation; - uint32 SpawnTimeSecs; -}; - -//EventSummon_Map -typedef UNORDERED_MAP CreatureEventAI_Summon_Map; - -struct CreatureEventAIHolder -{ - CreatureEventAIHolder(CreatureEventAI_Event const& p) : Event(p), Time(0), Enabled(true){ } - - CreatureEventAI_Event Event; - uint32 Time; - bool Enabled; - - // helper - bool UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax); -}; - -class CreatureEventAI : public CreatureAI -{ - public: - explicit CreatureEventAI(Creature* c); - ~CreatureEventAI() { } - - void JustRespawned(); - void Reset(); - void JustReachedHome(); - void EnterCombat(Unit* enemy); - void EnterEvadeMode(); - void JustDied(Unit* /*killer*/); - void KilledUnit(Unit* victim); - void JustSummoned(Creature* unit); - void AttackStart(Unit* who); - void MoveInLineOfSight(Unit* who); - void SpellHit(Unit* unit, const SpellInfo* spell); - void DamageTaken(Unit* done_by, uint32& damage); - void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) { } - void UpdateAI(uint32 diff); - void ReceiveEmote(Player* player, uint32 textEmote); - static int Permissible(const Creature*); - - bool ProcessEvent(CreatureEventAIHolder& holder, Unit* actionInvoker = NULL); - void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 eventId, Unit* actionInvoker); - inline uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3); - inline int32 GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3); - inline Unit* GetTargetByType(uint32 target, Unit* actionInvoker); - - void DoScriptText(int32 textEntry, WorldObject* source, Unit* target); - bool CanCast(Unit* target, SpellInfo const* spell, bool triggered); - - bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event); - - Unit* DoSelectLowestHpFriendly(float range, uint32 minHPDiff); - void DoFindFriendlyMissingBuff(std::list& _list, float range, uint32 spellid); - void DoFindFriendlyCC(std::list& _list, float range); - - protected: - uint32 m_EventUpdateTime; // Time between event updates - uint32 m_EventDiff; // Time between the last event call - bool m_bEmptyList; - - typedef std::vector CreatureEventAIList; - CreatureEventAIList m_CreatureEventAIList; // Holder for events (stores enabled, time, and eventid) - // Variables used by Events themselves - uint8 m_Phase; // Current phase, max 32 phases - bool m_CombatMovementEnabled; // If we allow targeted movment gen (movement twoards top threat) - bool m_MeleeEnabled; // If we allow melee auto attack - float m_AttackDistance; // Distance to attack from - float m_AttackAngle; // Angle of attack - uint32 m_InvincibilityHpLevel; // Minimal health level allowed at damage apply -}; -#endif diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp deleted file mode 100644 index daaf531dbda..00000000000 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp +++ /dev/null @@ -1,680 +0,0 @@ -/* - * Copyright (C) 2008-2013 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "Common.h" -#include "DatabaseEnv.h" -#include "CreatureEventAI.h" -#include "CreatureEventAIMgr.h" -#include "ObjectMgr.h" -#include "ObjectDefines.h" -#include "GridDefines.h" -#include "ConditionMgr.h" -#include "SpellMgr.h" -#include "SpellInfo.h" -#include "Player.h" - -// ------------------- -void CreatureEventAIMgr::LoadCreatureEventAI_Texts() -{ - uint32 oldMSTime = getMSTime(); - - // Drop Existing Text Map, only done once and we are ready to add data from multiple sources. - m_CreatureEventAI_TextMap.clear(); - - // Load EventAI Text - sObjectMgr->LoadTrinityStrings("creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID); - - // Gather Additional data from EventAI Texts 0 1 2 3 4 - QueryResult result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM creature_ai_texts"); - - if (!result) - { - TC_LOG_INFO("server.loading", ">> Loaded 0 additional CreatureEventAI Texts data. DB table `creature_ai_texts` is empty."); - return; - } - - uint32 count = 0; - - do - { - Field* fields = result->Fetch(); - StringTextData temp; - - int32 i = fields[0].GetInt32(); - temp.SoundId = fields[1].GetUInt32(); - temp.Type = fields[2].GetUInt8(); - temp.Language = fields[3].GetUInt8(); - temp.Emote = fields[4].GetUInt16(); - - // range negative - if (i > MIN_CREATURE_AI_TEXT_STRING_ID || i <= MAX_CREATURE_AI_TEXT_STRING_ID) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Entry %i in table `creature_ai_texts` is not in valid range(%d-%d)", i, MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID); - continue; - } - - // range negative (must not happen, loaded from same table) - if (!sObjectMgr->GetTrinityStringLocale(i)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Entry %i in table `creature_ai_texts` not found", i); - continue; - } - - if (temp.SoundId) - { - if (!sSoundEntriesStore.LookupEntry(temp.SoundId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Entry %i in table `creature_ai_texts` has Sound %u but sound does not exist.", i, temp.SoundId); - } - - if (!GetLanguageDescByID(temp.Language)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Entry %i in table `creature_ai_texts` using Language %u but Language does not exist.", i, temp.Language); - - if (temp.Type > CHAT_TYPE_ZONE_YELL) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Entry %i in table `creature_ai_texts` has Type %u but this Chat Type does not exist.", i, temp.Type); - - if (temp.Emote) - { - if (!sEmotesStore.LookupEntry(temp.Emote)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Entry %i in table `creature_ai_texts` has Emote %u but emote does not exist.", i, temp.Emote); - } - - m_CreatureEventAI_TextMap[i] = temp; - ++count; - } - while (result->NextRow()); - - TC_LOG_INFO("server.loading", ">> Loaded %u additional CreatureEventAI Texts data in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); -} - -void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() -{ - uint32 oldMSTime = getMSTime(); - - //Drop Existing EventAI List - m_CreatureEventAI_Event_Map.clear(); - - // Gather event data - QueryResult result = WorldDatabase.Query("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, " - "event_param1, event_param2, event_param3, event_param4, " - "action1_type, action1_param1, action1_param2, action1_param3, " - "action2_type, action2_param1, action2_param2, action2_param3, " - "action3_type, action3_param1, action3_param2, action3_param3 " - "FROM creature_ai_scripts"); - - if (!result) - { - TC_LOG_INFO("server.loading", ">> Loaded 0 CreatureEventAI scripts. DB table `creature_ai_scripts` is empty."); - return; - } - - uint32 count = 0; - - do - { - Field* fields = result->Fetch(); - - CreatureEventAI_Event temp; - temp.event_id = EventAI_Type(fields[0].GetUInt32()); - uint32 i = temp.event_id; - - temp.creature_id = fields[1].GetUInt32(); - uint32 creature_id = temp.creature_id; - - uint32 e_type = fields[2].GetUInt8(); - //Report any errors in event - if (e_type >= EVENT_T_END) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u have wrong type (%u), skipping.", i, e_type); - continue; - } - temp.event_type = EventAI_Type(e_type); - - temp.event_inverse_phase_mask = fields[3].GetInt32(); - temp.event_chance = fields[4].GetUInt32(); - temp.event_flags = fields[5].GetUInt32(); - temp.raw.param1 = fields[6].GetInt32(); - temp.raw.param2 = fields[7].GetInt32(); - temp.raw.param3 = fields[8].GetInt32(); - temp.raw.param4 = fields[9].GetInt32(); - - CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creature_id); - //Creature does not exist in database - if (!cInfo) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u has script for non-existing creature entry (%u), skipping.", i, creature_id); - continue; - } - - // Only on the first script - if (cInfo->AIName != "EventAI" && m_CreatureEventAI_Event_Map[creature_id].empty()) - TC_LOG_ERROR("sql.sql", "Creature entry %u has EventAI scripts, but its AIName is not 'EventAI' - possible AI-mismatch?", temp.creature_id); - - //No chance of this event occuring - if (temp.event_chance == 0) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u has 0 percent chance. Event will never trigger!", i); - //Chance above 100, force it to be 100 - else if (temp.event_chance > 100) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using event %u with more than 100 percent chance. Adjusting to 100 percent.", temp.creature_id, i); - temp.event_chance = 100; - } - - //Individual event checks - switch (temp.event_type) - { - case EVENT_T_TIMER: - case EVENT_T_TIMER_OOC: - if (temp.timer.initialMax < temp.timer.initialMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); - if (temp.timer.repeatMax < temp.timer.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_HP: - case EVENT_T_MANA: - case EVENT_T_TARGET_HP: - case EVENT_T_TARGET_MANA: - if (temp.percent_range.percentMax > 100) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i); - - if (temp.percent_range.percentMax <= temp.percent_range.percentMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i); - - if (temp.event_flags & EFLAG_REPEATABLE && !temp.percent_range.repeatMin && !temp.percent_range.repeatMax) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but cannot be repeatable without timers. Removing EFLAG_REPEATABLE for event %u.", temp.creature_id, i); - temp.event_flags &= ~EFLAG_REPEATABLE; - } - break; - case EVENT_T_SPELLHIT: - if (temp.spell_hit.spellId) - { - SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); - if (!spell) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); - continue; - } - - if ((temp.spell_hit.schoolMask & spell->SchoolMask) != spell->SchoolMask) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", - temp.creature_id, temp.spell_hit.schoolMask, i); - } - } - - if (!temp.spell_hit.schoolMask) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i); - - if (temp.spell_hit.repeatMax < temp.spell_hit.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_RANGE: - if (temp.range.maxDist < temp.range.minDist) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using event(%u) with param2 < param1 (MaxDist < MinDist). Event will never repeat.", temp.creature_id, i); - if (temp.range.repeatMax < temp.range.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_OOC_LOS: - if (temp.ooc_los.repeatMax < temp.ooc_los.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_SPAWNED: - switch (temp.spawned.condition) - { - case SPAWNED_EVENT_ALWAY: - break; - case SPAWNED_EVENT_MAP: - if (!sMapStore.LookupEntry(temp.spawned.conditionValue1)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'map specific' but with not existed map (%u) in param2. Event will never repeat.", - temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); - } - break; - case SPAWNED_EVENT_ZONE: - if (!GetAreaEntryByAreaID(temp.spawned.conditionValue1)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'area specific' but with not existed area (%u) in param2. Event will never repeat.", - temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); - } - break; - default: - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition); - break; - } - break; - case EVENT_T_FRIENDLY_HP: - if (temp.friendly_hp.repeatMax < temp.friendly_hp.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_FRIENDLY_IS_CC: - if (temp.friendly_is_cc.repeatMax < temp.friendly_is_cc.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_FRIENDLY_MISSING_BUFF: - { - SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); - if (!spell) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); - continue; - } - if (temp.friendly_buff.repeatMax < temp.friendly_buff.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - } - case EVENT_T_KILL: - if (temp.kill.repeatMax < temp.kill.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_TARGET_CASTING: - if (temp.target_casting.repeatMax < temp.target_casting.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_SUMMONED_UNIT: - if (!sObjectMgr->GetCreatureTemplate(temp.summon_unit.creatureId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using event(%u) with not existed creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summon_unit.creatureId); - if (temp.summon_unit.repeatMax < temp.summon_unit.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - case EVENT_T_QUEST_ACCEPT: - case EVENT_T_QUEST_COMPLETE: - if (!sObjectMgr->GetQuestTemplate(temp.quest.questId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using event(%u) with not existed qyest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId); - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i); - continue; - - case EVENT_T_AGGRO: - case EVENT_T_DEATH: - case EVENT_T_EVADE: - case EVENT_T_REACHED_HOME: - { - if (temp.event_flags & EFLAG_REPEATABLE) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u has EFLAG_REPEATABLE set. Event can never be repeatable. Removing flag for event %u.", temp.creature_id, i); - temp.event_flags &= ~EFLAG_REPEATABLE; - } - - break; - } - - case EVENT_T_RECEIVE_EMOTE: - { - if (!sEmotesTextStore.LookupEntry(temp.receive_emote.emoteId)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u using event %u: param1 (EmoteTextId: %u) are not valid.", temp.creature_id, i, temp.receive_emote.emoteId); - continue; - } - if (temp.receive_emote.condition) - { - Condition cond; - cond.ConditionType = ConditionTypes(temp.receive_emote.condition); - cond.ConditionValue1 = temp.receive_emote.conditionValue1; - cond.ConditionValue2 = temp.receive_emote.conditionValue2; - if (!sConditionMgr->isConditionTypeValid(&cond)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u using event %u: param2 (Condition: %u) are not valid.", temp.creature_id, i, temp.receive_emote.condition); - continue; - } - } - - if (!(temp.event_flags & EFLAG_REPEATABLE)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u using event %u: EFLAG_REPEATABLE not set. Event must always be repeatable. Flag applied.", temp.creature_id, i); - temp.event_flags |= EFLAG_REPEATABLE; - } - - break; - } - - case EVENT_T_BUFFED: - case EVENT_T_TARGET_BUFFED: - { - SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.buffed.spellId); - if (!spell) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); - continue; - } - if (temp.buffed.repeatMax < temp.buffed.repeatMin) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - break; - } - - default: - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Creature %u using not checked at load event (%u) in event %u. Need check code update?", temp.creature_id, temp.event_id, i); - break; - } - - for (uint32 j = 0; j < MAX_ACTIONS; j++) - { - uint16 action_type = fields[10+(j*4)].GetUInt8(); - if (action_type >= ACTION_T_END) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u has incorrect action type (%u), replace by ACTION_T_NONE.", i, j+1, action_type); - temp.action[j].type = ACTION_T_NONE; - continue; - } - - CreatureEventAI_Action& action = temp.action[j]; - - action.type = EventAI_ActionType(action_type); - action.raw.param1 = fields[11+(j*4)].GetInt32(); - action.raw.param2 = fields[12+(j*4)].GetInt32(); - action.raw.param3 = fields[13+(j*4)].GetInt32(); - - //Report any errors in actions - switch (action.type) - { - case ACTION_T_NONE: - break; - case ACTION_T_TEXT: - { - if (action.text.TextId1 < 0) - { - if (m_CreatureEventAI_TextMap.find(action.text.TextId1) == m_CreatureEventAI_TextMap.end()) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param1 refrences non-existing entry in texts table.", i, j+1); - } - if (action.text.TextId2 < 0) - { - if (m_CreatureEventAI_TextMap.find(action.text.TextId2) == m_CreatureEventAI_TextMap.end()) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param2 refrences non-existing entry in texts table.", i, j+1); - - if (!action.text.TextId1) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u has param2, but param1 is not set. Required for randomized text.", i, j+1); - } - if (action.text.TextId3 < 0) - { - if (m_CreatureEventAI_TextMap.find(action.text.TextId3) == m_CreatureEventAI_TextMap.end()) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param3 refrences non-existing entry in texts table.", i, j+1); - - if (!action.text.TextId1 || !action.text.TextId2) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u has param3, but param1 and/or param2 is not set. Required for randomized text.", i, j+1); - } - break; - } - case ACTION_T_SET_FACTION: - if (action.set_faction.factionId !=0 && !sFactionStore.LookupEntry(action.set_faction.factionId)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existent FactionId %u.", i, j+1, action.set_faction.factionId); - action.set_faction.factionId = 0; - } - break; - case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: - if (action.morph.creatureId !=0 || action.morph.modelId !=0) - { - if (action.morph.creatureId && !sObjectMgr->GetCreatureTemplate(action.morph.creatureId)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existant Creature entry %u.", i, j+1, action.morph.creatureId); - action.morph.creatureId = 0; - } - - if (action.morph.modelId) - { - if (action.morph.creatureId) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j+1, action.morph.modelId, action.morph.creatureId); - action.morph.modelId = 0; - } - else if (!sCreatureDisplayInfoStore.LookupEntry(action.morph.modelId)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existant ModelId %u.", i, j+1, action.morph.modelId); - action.morph.modelId = 0; - } - } - } - break; - case ACTION_T_SOUND: - if (!sSoundEntriesStore.LookupEntry(action.sound.soundId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existant SoundID %u.", i, j+1, action.sound.soundId); - break; - case ACTION_T_EMOTE: - if (!sEmotesStore.LookupEntry(action.emote.emoteId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, action.emote.emoteId); - break; - case ACTION_T_RANDOM_SOUND: - if (!sSoundEntriesStore.LookupEntry(action.random_sound.soundId1)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param1 uses non-existant SoundID %u.", i, j+1, action.random_sound.soundId1); - if (action.random_sound.soundId2 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId2)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param2 uses non-existant SoundID %u.", i, j+1, action.random_sound.soundId2); - if (action.random_sound.soundId3 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId3)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param3 uses non-existant SoundID %u.", i, j+1, action.random_sound.soundId3); - break; - case ACTION_T_RANDOM_EMOTE: - if (!sEmotesStore.LookupEntry(action.random_emote.emoteId1)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, action.random_emote.emoteId1); - if (action.random_emote.emoteId2 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId2)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j+1, action.random_emote.emoteId2); - if (action.random_emote.emoteId3 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId3)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j+1, action.random_emote.emoteId3); - break; - case ACTION_T_CAST: - { - const SpellInfo* spell = sSpellMgr->GetSpellInfo(action.cast.spellId); - if (!spell) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.cast.spellId); - /* FIXME: temp.raw.param3 not have event tipes with recovery time in it.... - else - { - if (spell->RecoveryTime > 0 && temp.event_flags & EFLAG_REPEATABLE) - { - //output as debug for now, also because there's no general rule all spells have RecoveryTime - if (temp.event_param3 < spell->RecoveryTime) - TC_LOG_DEBUG("CreatureEventAI: Event %u Action %u uses SpellID %u but cooldown is longer(%u) than minumum defined in event param3(%u).", i, j+1, action.cast.spellId, spell->RecoveryTime, temp.event_param3); - } - } - */ - - //Cast is always triggered if target is forced to cast on self - if (action.cast.castFlags & CAST_FORCE_TARGET_SELF) - action.cast.castFlags |= CAST_TRIGGERED; - - if (action.cast.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - break; - } - case ACTION_T_SUMMON: - if (!sObjectMgr->GetCreatureTemplate(action.summon.creatureId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.summon.creatureId); - - if (action.summon.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - break; - case ACTION_T_THREAT_SINGLE_PCT: - if (std::abs(action.threat_single_pct.percent) > 100) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses invalid percent value %u.", i, j+1, action.threat_single_pct.percent); - if (action.threat_single_pct.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - break; - case ACTION_T_THREAT_ALL_PCT: - if (std::abs(action.threat_all_pct.percent) > 100) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses invalid percent value %u.", i, j+1, action.threat_all_pct.percent); - break; - case ACTION_T_QUEST_EVENT: - if (Quest const* qid = sObjectMgr->GetQuestTemplate(action.quest_event.questId)) - { - if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j+1, action.quest_event.questId); - } - else - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existent Quest entry %u.", i, j+1, action.quest_event.questId); - - if (action.quest_event.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - - break; - case ACTION_T_SET_UNIT_FIELD: - if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j+1); - if (action.set_unit_field.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - break; - case ACTION_T_SET_UNIT_FLAG: - case ACTION_T_REMOVE_UNIT_FLAG: - if (action.unit_flag.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - break; - case ACTION_T_SET_PHASE: - if (action.set_phase.phase >= MAX_PHASE) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u attempts to set phase >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); - break; - case ACTION_T_INC_PHASE: - if (action.set_inc_phase.step == 0) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u is incrementing phase by 0. Was this intended?", i, j+1); - else if (std::abs(action.set_inc_phase.step) > MAX_PHASE-1) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u is change phase by too large for any use %i.", i, j+1, action.set_inc_phase.step); - break; - case ACTION_T_QUEST_EVENT_ALL: - if (Quest const* qid = sObjectMgr->GetQuestTemplate(action.quest_event_all.questId)) - { - if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j+1, action.quest_event_all.questId); - } - else - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existent Quest entry %u.", i, j+1, action.quest_event_all.questId); - break; - case ACTION_T_REMOVEAURASFROMSPELL: - if (!sSpellMgr->GetSpellInfo(action.remove_aura.spellId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.remove_aura.spellId); - if (action.remove_aura.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - break; - case ACTION_T_RANDOM_PHASE: //PhaseId1, PhaseId2, PhaseId3 - if (action.random_phase.phase1 >= MAX_PHASE) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u attempts to set phase1 >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); - if (action.random_phase.phase2 >= MAX_PHASE) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u attempts to set phase2 >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); - if (action.random_phase.phase3 >= MAX_PHASE) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u attempts to set phase3 >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); - break; - case ACTION_T_RANDOM_PHASE_RANGE: //PhaseMin, PhaseMax - if (action.random_phase_range.phaseMin >= MAX_PHASE) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u attempts to set phaseMin >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); - if (action.random_phase_range.phaseMin >= MAX_PHASE) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u attempts to set phaseMax >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); - if (action.random_phase_range.phaseMin >= action.random_phase_range.phaseMax) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u attempts to set phaseMax <= phaseMin.", i, j+1); - std::swap(action.random_phase_range.phaseMin, action.random_phase_range.phaseMax); - // equal case processed at call - } - break; - case ACTION_T_KILLED_MONSTER: - if (!sObjectMgr->GetCreatureTemplate(action.killed_monster.creatureId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.killed_monster.creatureId); - if (action.killed_monster.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - break; - case ACTION_T_SET_INST_DATA: - if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j+1); - if (action.set_inst_data.value > 4/*SPECIAL*/) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j+1); - break; - case ACTION_T_SET_INST_DATA64: - if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j+1); - if (action.set_inst_data64.target >= TARGET_T_END) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - break; - case ACTION_T_UPDATE_TEMPLATE: - if (!sObjectMgr->GetCreatureTemplate(action.update_template.creatureId)) - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.update_template.creatureId); - break; - case ACTION_T_SET_SHEATH: - if (action.set_sheath.sheath >= MAX_SHEATH_STATE) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses wrong sheath state %u.", i, j+1, action.set_sheath.sheath); - action.set_sheath.sheath = SHEATH_STATE_UNARMED; - } - break; - case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: - if (action.invincibility_hp_level.is_percent) - { - if (action.invincibility_hp_level.hp_level > 100) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses wrong percent value %u.", i, j+1, action.invincibility_hp_level.hp_level); - action.invincibility_hp_level.hp_level = 100; - } - } - break; - case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL: - if (action.mount.creatureId != 0 || action.mount.modelId != 0) - { - if (action.mount.creatureId && !sObjectMgr->GetCreatureTemplate(action.mount.creatureId)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses nonexistent Creature entry %u.", i, j+1, action.mount.creatureId); - action.morph.creatureId = 0; - } - - if (action.mount.modelId) - { - if (action.mount.creatureId) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j+1, action.mount.modelId, action.mount.creatureId); - action.mount.modelId = 0; - } - else if (!sCreatureDisplayInfoStore.LookupEntry(action.mount.modelId)) - { - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u uses nonexistent ModelId %u.", i, j+1, action.mount.modelId); - action.mount.modelId = 0; - } - } - } - break; - case ACTION_T_EVADE: //No Params - case ACTION_T_FLEE_FOR_ASSIST: //No Params - case ACTION_T_DIE: //No Params - case ACTION_T_ZONE_COMBAT_PULSE: //No Params - case ACTION_T_FORCE_DESPAWN: //No Params - case ACTION_T_AUTO_ATTACK: //AllowAttackState (0 = stop attack, anything else means continue attacking) - case ACTION_T_COMBAT_MOVEMENT: //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) - case ACTION_T_RANGED_MOVEMENT: //Distance, Angle - case ACTION_T_CALL_FOR_HELP: //Distance - break; - - case ACTION_T_RANDOM_SAY: - case ACTION_T_RANDOM_YELL: - case ACTION_T_RANDOM_TEXTEMOTE: - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u currently unused ACTION type. Did you forget to update database?", i, j+1); - break; - - case ACTION_T_MOVE_RANDOM_POINT: - case ACTION_T_SET_STAND_STATE: - case ACTION_T_SET_PHASE_MASK: - case ACTION_T_SET_VISIBILITY: - case ACTION_T_SET_ACTIVE: - case ACTION_T_SET_AGGRESSIVE: - case ACTION_T_ATTACK_START_PULSE: - case ACTION_T_SUMMON_GO: - break; - - default: - TC_LOG_ERROR("sql.sql", "CreatureEventAI: Event %u Action %u have currently not checked at load action type (%u). Need check code update?", i, j+1, action.type); - break; - } - } - - //Add to list - m_CreatureEventAI_Event_Map[creature_id].push_back(temp); - ++count; - - } - while (result->NextRow()); - - TC_LOG_INFO("server.loading", ">> Loaded %u CreatureEventAI scripts in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); -} diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.h b/src/server/game/AI/EventAI/CreatureEventAIMgr.h deleted file mode 100644 index 577958b6f5b..00000000000 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008-2013 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef TRINITY_CREATURE_EAI_MGR_H -#define TRINITY_CREATURE_EAI_MGR_H - -#include "Common.h" -#include "CreatureEventAI.h" - -class CreatureEventAIMgr -{ - friend class ACE_Singleton; - - private: - CreatureEventAIMgr(){ } - ~CreatureEventAIMgr(){ } - - public: - void LoadCreatureEventAI_Texts(); - void LoadCreatureEventAI_Scripts(); - - CreatureEventAI_Event_Map const& GetCreatureEventAIMap() const { return m_CreatureEventAI_Event_Map; } - CreatureEventAI_TextMap const& GetCreatureEventAITextMap() const { return m_CreatureEventAI_TextMap; } - - private: - CreatureEventAI_Event_Map m_CreatureEventAI_Event_Map; - CreatureEventAI_TextMap m_CreatureEventAI_TextMap; -}; - -#define sEventAIMgr ACE_Singleton::instance() -#endif diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt index f455610666e..be3997243e4 100644 --- a/src/server/game/CMakeLists.txt +++ b/src/server/game/CMakeLists.txt @@ -130,7 +130,6 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Addons ${CMAKE_CURRENT_SOURCE_DIR}/AI ${CMAKE_CURRENT_SOURCE_DIR}/AI/CoreAI - ${CMAKE_CURRENT_SOURCE_DIR}/AI/EventAI ${CMAKE_CURRENT_SOURCE_DIR}/AI/ScriptedAI ${CMAKE_CURRENT_SOURCE_DIR}/AI/SmartScripts ${CMAKE_CURRENT_SOURCE_DIR}/AuctionHouse diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 0869e44b9dc..d8dc19c5dcd 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -41,7 +41,6 @@ #include "ArenaTeamMgr.h" #include "GuildMgr.h" #include "TicketMgr.h" -#include "CreatureEventAIMgr.h" #include "SpellMgr.h" #include "GroupMgr.h" #include "Chat.h" @@ -1692,12 +1691,6 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading Scripts text locales..."); // must be after Load*Scripts calls sObjectMgr->LoadDbScriptStrings(); - TC_LOG_INFO("server.loading", "Loading CreatureEventAI Texts..."); - sEventAIMgr->LoadCreatureEventAI_Texts(); - - TC_LOG_INFO("server.loading", "Loading CreatureEventAI Scripts..."); - sEventAIMgr->LoadCreatureEventAI_Scripts(); - TC_LOG_INFO("server.loading", "Loading spell script names..."); sObjectMgr->LoadSpellScriptNames(); diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 5be634d2060..20e4c4c7fdd 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -73,7 +73,6 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/Addons ${CMAKE_SOURCE_DIR}/src/server/game/AI ${CMAKE_SOURCE_DIR}/src/server/game/AI/CoreAI - ${CMAKE_SOURCE_DIR}/src/server/game/AI/EventAI ${CMAKE_SOURCE_DIR}/src/server/game/AI/ScriptedAI ${CMAKE_SOURCE_DIR}/src/server/game/AI/SmartScripts ${CMAKE_SOURCE_DIR}/src/server/game/AuctionHouse diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 039766177c1..59477c6684f 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -26,7 +26,6 @@ EndScriptData */ #include "AchievementMgr.h" #include "AuctionHouseMgr.h" #include "Chat.h" -#include "CreatureEventAIMgr.h" #include "CreatureTextMgr.h" #include "DisableMgr.h" #include "Language.h" @@ -53,7 +52,6 @@ public: { { "achievement", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ACHIEVEMENT, true, &HandleReloadAllAchievementCommand, "", NULL }, { "area", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_AREA, true, &HandleReloadAllAreaCommand, "", NULL }, - { "eventai", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_EVENTAI, true, &HandleReloadAllEventAICommand, "", NULL }, { "gossips", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_GOSSIP, true, &HandleReloadAllGossipsCommand, "", NULL }, { "item", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ITEM, true, &HandleReloadAllItemCommand, "", NULL }, { "locales", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOCALES, true, &HandleReloadAllLocalesCommand, "", NULL }, @@ -80,8 +78,6 @@ public: { "conditions", rbac::RBAC_PERM_COMMAND_RELOAD_CONDITIONS, true, &HandleReloadConditions, "", NULL }, { "config", rbac::RBAC_PERM_COMMAND_RELOAD_CONFIG, true, &HandleReloadConfigCommand, "", NULL }, { "creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEXT, true, &HandleReloadCreatureText, "", NULL }, - { "creature_ai_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_AI_SCRIPTS, true, &HandleReloadEventAIScriptsCommand, "", NULL }, - { "creature_ai_texts", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_AI_TEXTS, true, &HandleReloadEventAITextsCommand, "", NULL }, { "creature_questender", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTENDER, true, &HandleReloadCreatureQuestEnderCommand, "", NULL }, { "creature_linked_respawn", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LINKED_RESPAWN, true, &HandleReloadLinkedRespawnCommand, "", NULL }, { "creature_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesCreatureCommand, "", NULL }, @@ -182,7 +178,6 @@ public: HandleReloadAllAchievementCommand(handler, ""); HandleReloadAllAreaCommand(handler, ""); - HandleReloadAllEventAICommand(handler, ""); HandleReloadAllLootCommand(handler, ""); HandleReloadAllNpcCommand(handler, ""); HandleReloadAllQuestCommand(handler, ""); @@ -273,13 +268,6 @@ public: return true; } - static bool HandleReloadAllEventAICommand(ChatHandler* handler, const char* /*args*/) - { - HandleReloadEventAITextsCommand(handler, "a"); - HandleReloadEventAIScriptsCommand(handler, "a"); - return true; - } - static bool HandleReloadAllSpellCommand(ChatHandler* handler, const char* /*args*/) { HandleReloadSkillDiscoveryTemplateCommand(handler, "a"); @@ -1014,23 +1002,6 @@ public: return true; } - static bool HandleReloadEventAITextsCommand(ChatHandler* handler, const char* /*args*/) - { - - TC_LOG_INFO("misc", "Re-Loading Texts from `creature_ai_texts`..."); - sEventAIMgr->LoadCreatureEventAI_Texts(); - handler->SendGlobalGMSysMessage("DB table `creature_ai_texts` reloaded."); - return true; - } - - static bool HandleReloadEventAIScriptsCommand(ChatHandler* handler, const char* /*args*/) - { - TC_LOG_INFO("misc", "Re-Loading Scripts from `creature_ai_scripts`..."); - sEventAIMgr->LoadCreatureEventAI_Scripts(); - handler->SendGlobalGMSysMessage("DB table `creature_ai_scripts` reloaded."); - return true; - } - static bool HandleReloadSpellScriptsCommand(ChatHandler* handler, const char* args) { if (sScriptMgr->IsScriptScheduled()) diff --git a/src/server/worldserver/CMakeLists.txt b/src/server/worldserver/CMakeLists.txt index e48197aeb2c..99ea60ba76f 100644 --- a/src/server/worldserver/CMakeLists.txt +++ b/src/server/worldserver/CMakeLists.txt @@ -70,7 +70,6 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/Addons ${CMAKE_SOURCE_DIR}/src/server/game/AI ${CMAKE_SOURCE_DIR}/src/server/game/AI/CoreAI - ${CMAKE_SOURCE_DIR}/src/server/game/AI/EventAI ${CMAKE_SOURCE_DIR}/src/server/game/AI/ScriptedAI ${CMAKE_SOURCE_DIR}/src/server/game/AI/SmartScripts ${CMAKE_SOURCE_DIR}/src/server/game/AuctionHouse -- cgit v1.2.3 From eddf1b5a6407de5a40e04916dd41427d7dc0dc3d Mon Sep 17 00:00:00 2001 From: joschiwald Date: Tue, 10 Dec 2013 18:46:11 +0100 Subject: Scripts: replace some SetOrientation() calls with spline packets and some random changes --- src/server/game/AI/CoreAI/PetAI.cpp | 2 +- src/server/game/AI/SmartScripts/SmartScript.cpp | 6 ++-- src/server/game/Battlefield/Battlefield.cpp | 2 +- src/server/game/Battlegrounds/Battleground.cpp | 2 +- src/server/game/Events/GameEventMgr.cpp | 2 +- src/server/game/Pools/PoolMgr.cpp | 2 +- src/server/scripts/Commands/cs_debug.cpp | 2 +- src/server/scripts/Commands/cs_wp.cpp | 8 ++--- .../Scholomance/boss_ras_frostwhisper.cpp | 2 +- .../SunwellPlateau/boss_felmyst.cpp | 3 +- .../EasternKingdoms/ZulGurub/boss_jindo.cpp | 2 +- .../scripts/EasternKingdoms/zone_ghostlands.cpp | 6 ++-- .../Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp | 11 +++---- src/server/scripts/Northrend/zone_storm_peaks.cpp | 7 ++-- src/server/scripts/Outland/zone_netherstorm.cpp | 38 ++++++---------------- 15 files changed, 36 insertions(+), 59 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 1f312de73f6..18daf1ef8de 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -409,7 +409,7 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const if (me->HasReactState(REACT_AGGRESSIVE) && allowAutoSelect) { if (!me->GetCharmInfo()->IsReturning() || me->GetCharmInfo()->IsFollowing() || me->GetCharmInfo()->IsAtStay()) - if (Unit* nearTarget = me->ToCreature()->SelectNearestHostileUnitInAggroRange(true)) + if (Unit* nearTarget = me->SelectNearestHostileUnitInAggroRange(true)) return nearTarget; } diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 7555471e091..ecfe35345f2 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -525,9 +525,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.cast.spell); int32 mana = me->GetPower(POWER_MANA); - if (me->GetDistance((*itr)->ToUnit()) > spellInfo->GetMaxRange(true) || - me->GetDistance((*itr)->ToUnit()) < spellInfo->GetMinRange(true) || - !me->ToUnit()->IsWithinLOSInMap((*itr)->ToUnit()) || + if (me->GetDistance(*itr) > spellInfo->GetMaxRange(true) || + me->GetDistance(*itr) < spellInfo->GetMinRange(true) || + !me->IsWithinLOSInMap(*itr) || mana < spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask())) _allowMove = true; diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 07dfb45150c..c446b26722d 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -821,7 +821,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl return 0; } - Creature* creature = new Creature; + Creature* creature = new Creature(); if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, team, x, y, z, o)) { TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry); diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 044036ef860..58ca7b9d639 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1574,7 +1574,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, uint32 teamval, f if (!map) return NULL; - Creature* creature = new Creature; + Creature* creature = new Creature(); if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, teamval, x, y, z, o)) { TC_LOG_ERROR("bg.battleground", "Battleground::AddCreature: cannot create creature (entry: %u) for BG (map: %u, instance id: %u)!", diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index b0428de6e28..55550dc019b 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -1180,7 +1180,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) // We use spawn coords to spawn if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { - Creature* creature = new Creature; + Creature* creature = new Creature(); //TC_LOG_DEBUG("misc", "Spawning creature %u", *itr); if (!creature->LoadCreatureFromDB(*itr, map)) delete creature; diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index d4211f83a11..1eed9feb289 100644 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -364,7 +364,7 @@ void PoolGroup::Spawn1Object(PoolObject* obj) // We use spawn coords to spawn if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { - Creature* creature = new Creature; + Creature* creature = new Creature(); //TC_LOG_DEBUG("pool", "Spawning creature %u", guid); if (!creature->LoadCreatureFromDB(obj->guid, map)) { diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index a4ccbc40211..d84cf140ac1 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -923,7 +923,7 @@ public: if (!ve) return false; - Creature* v = new Creature; + Creature* v = new Creature(); Map* map = handler->GetSession()->GetPlayer()->GetMap(); diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index dc731985588..daa760c9c56 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -689,7 +689,7 @@ public: wpCreature->AddObjectToRemoveList(); } // re-create - Creature* wpCreature2 = new Creature; + Creature* wpCreature2 = new Creature(); if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation())) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); @@ -913,7 +913,7 @@ public: Map* map = chr->GetMap(); float o = chr->GetOrientation(); - Creature* wpCreature = new Creature; + Creature* wpCreature = new Creature(); if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); @@ -977,7 +977,7 @@ public: float o = chr->GetOrientation(); Map* map = chr->GetMap(); - Creature* creature = new Creature; + Creature* creature = new Creature(); if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); @@ -1026,7 +1026,7 @@ public: Player* chr = handler->GetSession()->GetPlayer(); Map* map = chr->GetMap(); - Creature* creature = new Creature; + Creature* creature = new Creature(); if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) { handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_ras_frostwhisper.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_ras_frostwhisper.cpp index 451fd46938d..f93f0a94414 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_ras_frostwhisper.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_ras_frostwhisper.cpp @@ -69,7 +69,7 @@ public: DoCast(me, SPELL_ICEARMOR, true); } - void EnterCombat(Unit* /*who*/)OVERRIDE { } + void EnterCombat(Unit* /*who*/) OVERRIDE { } void UpdateAI(uint32 diff) OVERRIDE { diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index ca5dcf5360e..80b4b98b0a4 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -351,8 +351,7 @@ public: break; } case 6: - me->SetOrientation(me->GetAngle(breathX, breathY)); - me->StopMoving(); + me->SetFacingTo(me->GetAngle(breathX, breathY)); //DoTextEmote("takes a deep breath.", NULL); events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000); break; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp index 886e000c093..4a37f3cf597 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp @@ -258,7 +258,7 @@ class npc_shade_of_jindo : public CreatureScript DoCast(me, SPELL_INVISIBLE, true); } - void EnterCombat(Unit* /*who*/)OVERRIDE { } + void EnterCombat(Unit* /*who*/) OVERRIDE { } void UpdateAI(uint32 diff) OVERRIDE { diff --git a/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp b/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp index 1b181581f5e..cf7ea882135 100644 --- a/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp @@ -161,7 +161,7 @@ public: break; case 11: Talk(SAY_PROGRESS2, player->GetGUID()); - me->SetOrientation(4.762841f); + me->SetFacingTo(4.762841f); break; case 18: { @@ -186,11 +186,11 @@ public: player->GroupEventHappens(QUEST_ESCAPE_FROM_THE_CATACOMBS, me); break; case 32: - me->SetOrientation(2.978281f); + me->SetFacingTo(2.978281f); Talk(SAY_END1, player->GetGUID()); break; case 33: - me->SetOrientation(5.858011f); + me->SetFacingTo(5.858011f); Talk(SAY_END2, player->GetGUID()); Creature* CaptainHelios = me->FindNearestCreature(NPC_CAPTAIN_HELIOS, 50); if (CaptainHelios) diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp index 53e09c918ea..8dd009cdb32 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp @@ -308,18 +308,15 @@ public: { if (instance) { - Unit* pKri = Unit::GetUnit(*me, instance->GetData64(DATA_KRI)); - Unit* pVem = Unit::GetUnit(*me, instance->GetData64(DATA_VEM)); - switch (urand(0, 2)) { case 0: - if (pKri) - DoCast(pKri, SPELL_HEAL); + if (Creature* kri = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_KRI))) + DoCast(kri, SPELL_HEAL); break; case 1: - if (pVem) - DoCast(pVem, SPELL_HEAL); + if (Creature* vem = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VEM))) + DoCast(vem, SPELL_HEAL); break; case 2: DoCast(me, SPELL_HEAL); diff --git a/src/server/scripts/Northrend/zone_storm_peaks.cpp b/src/server/scripts/Northrend/zone_storm_peaks.cpp index d08c60d373d..7a2afe5505f 100644 --- a/src/server/scripts/Northrend/zone_storm_peaks.cpp +++ b/src/server/scripts/Northrend/zone_storm_peaks.cpp @@ -551,14 +551,13 @@ public: events.ScheduleEvent(EVENT_SCRIPT_11, 6000); break; case EVENT_SCRIPT_11: - me->SetOrientation(2.932153f); - me->SendMovementFlagUpdate(true); + me->SetFacingTo(2.932153f); Talk(SAY_BRANN_3, playerGUID); + for (uint8 i = 0; i < 5; ++i) - { if (GameObject* go = ObjectAccessor::GetGameObject(*me, objectGUID[i])) go->Delete(); - } + events.ScheduleEvent(EVENT_SCRIPT_12, 6000); break; case EVENT_SCRIPT_12: diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp index 5cf152bd6e2..e1b95aea972 100644 --- a/src/server/scripts/Outland/zone_netherstorm.cpp +++ b/src/server/scripts/Outland/zone_netherstorm.cpp @@ -400,7 +400,7 @@ public: struct npc_commander_dawnforgeAI : public ScriptedAI { - npc_commander_dawnforgeAI(Creature* creature) : ScriptedAI(creature) { Reset(); } + npc_commander_dawnforgeAI(Creature* creature) : ScriptedAI(creature) { } uint64 PlayerGUID; uint64 ardonisGUID; @@ -411,9 +411,6 @@ public: uint32 Phase_Timer; bool isEvent; - float angle_dawnforge; - float angle_ardonis; - void Reset() OVERRIDE { PlayerGUID = 0; @@ -438,21 +435,15 @@ public: { Creature* ardonis = ObjectAccessor::GetCreature(*me, ardonisGUID); Creature* pathaleon = ObjectAccessor::GetCreature(*me, pathaleonGUID); - Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID); - if (!ardonis || !pathaleon || !player) + if (!ardonis || !pathaleon) return; - //Calculate the angle to Pathaleon - angle_dawnforge = me->GetAngle(pathaleon->GetPositionX(), pathaleon->GetPositionY()); - angle_ardonis = ardonis->GetAngle(pathaleon->GetPositionX(), pathaleon->GetPositionY()); + // Turn Dawnforge + me->SetFacingToObject(pathaleon); - //Turn Dawnforge and update - me->SetOrientation(angle_dawnforge); - me->SendUpdateToPlayer(player); - //Turn Ardonis and update - ardonis->SetOrientation(angle_ardonis); - ardonis->SendUpdateToPlayer(player); + // Turn Ardonis + ardonis->SetFacingToObject(pathaleon); //Set them to kneel me->SetStandState(UNIT_STAND_STATE_KNEEL); @@ -464,20 +455,11 @@ public: { if (Unit* ardonis = ObjectAccessor::GetUnit(*me, ardonisGUID)) { - Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID); - - if (!player) - return; - - angle_dawnforge = me->GetAngle(ardonis->GetPositionX(), ardonis->GetPositionY()); - angle_ardonis = ardonis->GetAngle(me->GetPositionX(), me->GetPositionY()); + // Turn Dawnforge + me->SetFacingToObject(ardonis); - //Turn Dawnforge and update - me->SetOrientation(angle_dawnforge); - me->SendUpdateToPlayer(player); - //Turn Ardonis and update - ardonis->SetOrientation(angle_ardonis); - ardonis->SendUpdateToPlayer(player); + // Turn Ardonis + ardonis->SetFacingToObject(me); //Set state me->SetStandState(UNIT_STAND_STATE_STAND); -- cgit v1.2.3 From ec8e94c6ac9079981378e6ca0cd1380f02a092dd Mon Sep 17 00:00:00 2001 From: Discover- Date: Sat, 14 Dec 2013 19:39:47 +0100 Subject: Core/AI: Fix an issue where the OnQuestAccept hooks were not called for auto-completed quests. Fixes #11304 --- src/server/game/Entities/Player/Player.cpp | 54 +++++++++++++++++++++++++++--- src/server/game/Entities/Player/Player.h | 1 + src/server/game/Handlers/QuestHandler.cpp | 25 +++----------- src/server/scripts/Commands/cs_quest.cpp | 2 +- 4 files changed, 56 insertions(+), 26 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a8e9a3567ff..94c2f2e9f26 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -77,6 +77,7 @@ #include "World.h" #include "WorldPacket.h" #include "WorldSession.h" +#include "GameObjectAI.h" #define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS) @@ -14770,11 +14771,7 @@ void Player::SendPreparedQuest(uint64 guid) } if (quest->IsAutoAccept() && CanAddQuest(quest, true) && CanTakeQuest(quest, true)) - { - AddQuest(quest, object); - if (CanCompleteQuest(questId)) - CompleteQuest(questId); - } + AddQuestAndCheckCompletion(quest, object); if ((quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly()) || quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE)) PlayerTalkClass->SendQuestGiverRequestItems(quest, guid, CanCompleteRepeatableQuest(quest), true); @@ -15042,6 +15039,53 @@ bool Player::CanRewardQuest(Quest const* quest, bool msg) return true; } +void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver) +{ + AddQuest(quest, questGiver); + + if (CanCompleteQuest(quest->GetQuestId())) + CompleteQuest(quest->GetQuestId()); + + if (!questGiver) + return; + + switch (questGiver->GetTypeId()) + { + case TYPEID_UNIT: + sScriptMgr->OnQuestAccept(this, (questGiver->ToCreature()), quest); + questGiver->ToCreature()->AI()->sQuestAccept(this, quest); + break; + case TYPEID_ITEM: + case TYPEID_CONTAINER: + { + Item* item = (Item*)questGiver; + sScriptMgr->OnQuestAccept(this, item, quest); + + // destroy not required for quest finish quest starting item + bool destroyItem = true; + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + { + if (quest->RequiredItemId[i] == item->GetEntry() && item->GetTemplate()->MaxCount > 0) + { + destroyItem = false; + break; + } + } + + if (destroyItem) + DestroyItem(item->GetBagSlot(), item->GetSlot(), true); + + break; + } + case TYPEID_GAMEOBJECT: + sScriptMgr->OnQuestAccept(this, questGiver->ToGameObject(), quest); + questGiver->ToGameObject()->AI()->QuestAccept(this, quest); + break; + default: + break; + } +} + bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg) { // prevent receive reward with quest items in bank or for not completed quest diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 6aa19b5395a..c445bd9027a 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1357,6 +1357,7 @@ class Player : public Unit, public GridObject bool CanCompleteRepeatableQuest(Quest const* quest); bool CanRewardQuest(Quest const* quest, bool msg); bool CanRewardQuest(Quest const* quest, uint32 reward, bool msg); + void AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver); void AddQuest(Quest const* quest, Object* questGiver); void CompleteQuest(uint32 quest_id); void IncompleteQuest(uint32 quest_id); diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 1e2d3aff4ee..f3baed1e260 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -239,6 +239,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData) default: break; } + _player->PlayerTalkClass->SendCloseGossip(); if (quest->GetSrcSpell() > 0) @@ -278,11 +279,7 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket& recvData) return; if (quest->IsAutoAccept() && _player->CanAddQuest(quest, true)) - { - _player->AddQuest(quest, object); - if (_player->CanCompleteQuest(questId)) - _player->CompleteQuest(questId); - } + _player->AddQuestAndCheckCompletion(quest, object); if (quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE)) _player->PlayerTalkClass->SendQuestGiverRequestItems(quest, object->GetGUID(), _player->CanCompleteQuest(quest->GetQuestId()), true); @@ -348,11 +345,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData) if (Quest const* nextQuest = _player->GetNextQuest(guid, quest)) { if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true) && _player->CanTakeQuest(nextQuest, true)) - { - _player->AddQuest(nextQuest, object); - if (_player->CanCompleteQuest(nextQuest->GetQuestId())) - _player->CompleteQuest(nextQuest->GetQuestId()); - } + _player->AddQuestAndCheckCompletion(nextQuest, object); _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true); } @@ -367,11 +360,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData) if (Quest const* nextQuest = _player->GetNextQuest(guid, quest)) { if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true) && _player->CanTakeQuest(nextQuest, true)) - { - _player->AddQuest(nextQuest, object); - if (_player->CanCompleteQuest(nextQuest->GetQuestId())) - _player->CompleteQuest(nextQuest->GetQuestId()); - } + _player->AddQuestAndCheckCompletion(nextQuest, object); _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true); } @@ -615,11 +604,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_SHARING_QUEST); if (quest->IsAutoAccept() && receiver->CanAddQuest(quest, true) && receiver->CanTakeQuest(quest, true)) - { - receiver->AddQuest(quest, sender); - if (receiver->CanCompleteQuest(questId)) - receiver->CompleteQuest(questId); - } + receiver->AddQuestAndCheckCompletion(quest, sender); if ((quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly()) || quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE)) receiver->PlayerTalkClass->SendQuestGiverRequestItems(quest, sender->GetGUID(), receiver->CanCompleteRepeatableQuest(quest), true); diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 84adeb3417c..83e65d2f01f 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -92,7 +92,7 @@ public: // ok, normal (creature/GO starting) quest if (player->CanAddQuest(quest, true)) { - player->AddQuest(quest, NULL); + player->AddQuestAndCheckCompletion(quest, NULL); if (player->CanCompleteQuest(entry)) player->CompleteQuest(entry); -- cgit v1.2.3