diff options
Diffstat (limited to 'src/server')
17 files changed, 700 insertions, 48 deletions
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 2739854926b..b6716c248ae 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -32,6 +32,7 @@ #include "Player.h" #include "SharedDefines.h" #include "World.h" +#include "WorldSession.h" bool BattlegroundTemplate::IsArena() const { @@ -64,7 +65,7 @@ uint8 BattlegroundTemplate::GetMaxLevel() const BattlegroundMgr::BattlegroundMgr() : m_NextRatedArenaUpdate(sWorld->getIntConfig(CONFIG_ARENA_RATED_UPDATE_TIMER)), - m_UpdateTimer(0), m_ArenaTesting(false), m_Testing(false) + m_UpdateTimer(0), m_ArenaTesting(0), m_Testing(false) { } BattlegroundMgr::~BattlegroundMgr() @@ -300,6 +301,15 @@ BattlegroundScriptTemplate const* BattlegroundMgr::FindBattlegroundScriptTemplat return Trinity::Containers::MapGetValuePtr(_battlegroundScriptTemplates, { mapId, BATTLEGROUND_TYPE_NONE }); } +void BattlegroundMgr::QueuePlayerForArena(Player const* player, uint8 teamSize, uint8 roles) +{ + WorldPackets::Battleground::BattlemasterJoinArena packet((WorldPacket(CMSG_BATTLEMASTER_JOIN_ARENA))); + packet.TeamSizeIndex = teamSize; + packet.Roles = roles; + + player->GetSession()->HandleBattlemasterJoinArena(packet); +} + uint32 BattlegroundMgr::CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id) { if (IsArenaType(bgTypeId)) @@ -507,10 +517,23 @@ void BattlegroundMgr::ToggleTesting() sWorld->SendWorldText(m_Testing ? LANG_DEBUG_BG_ON : LANG_DEBUG_BG_OFF); } -void BattlegroundMgr::ToggleArenaTesting() +bool BattlegroundMgr::ToggleArenaTesting(uint32 battlemasterListId) { - m_ArenaTesting = !m_ArenaTesting; - sWorld->SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF); + if (battlemasterListId != 0) + { + BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(static_cast<BattlegroundTypeId>(battlemasterListId)); + if (!bgTemplate) + return false; + + if (!bgTemplate->IsArena()) + return false; + } + + if (m_ArenaTesting != battlemasterListId) + sWorld->SendWorldText((battlemasterListId != 0) ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF); + + m_ArenaTesting = battlemasterListId; + return true; } bool BattlegroundMgr::IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId) @@ -686,6 +709,9 @@ BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId) { if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId)) { + if (bgTemplate->IsArena() && isArenaTesting()) + return static_cast<BattlegroundTypeId>(m_ArenaTesting); + std::vector<BattlegroundTemplate const*> ids; ids.reserve(bgTemplate->MapIDs.size()); for (int32 mapId : bgTemplate->MapIDs) diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index b31b0193af0..8aa341cbca8 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -126,10 +126,11 @@ class TC_GAME_API BattlegroundMgr void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id); uint32 GetPrematureFinishTime() const; - void ToggleArenaTesting(); + // Return whether toggling was successful. In case of a non-existing battlemasterListId, or this battlemasterListId is not an arena, this would return false. + bool ToggleArenaTesting(uint32 battlemasterListId); void ToggleTesting(); - bool isArenaTesting() const { return m_ArenaTesting; } + bool isArenaTesting() const { return m_ArenaTesting != 0; } bool isTesting() const { return m_Testing; } static bool IsRandomBattleground(uint32 battlemasterListId); @@ -162,6 +163,8 @@ class TC_GAME_API BattlegroundMgr void LoadBattlegroundScriptTemplate(); BattlegroundScriptTemplate const* FindBattlegroundScriptTemplate(uint32 mapId, BattlegroundTypeId bgTypeId) const; + static void QueuePlayerForArena(Player const* player, uint8 teamSize, uint8 roles); + private: uint32 CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id); static bool IsArenaType(BattlegroundTypeId bgTypeId); @@ -185,7 +188,7 @@ class TC_GAME_API BattlegroundMgr std::vector<ScheduledQueueUpdate> m_QueueUpdateScheduler; uint32 m_NextRatedArenaUpdate; uint32 m_UpdateTimer; - bool m_ArenaTesting; + uint32 m_ArenaTesting; bool m_Testing; BattleMastersMap mBattleMastersMap; diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 8fb5a150793..e78a52042b9 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -540,9 +540,16 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPackets::Battleground::Battl return; Group* grp = _player->GetGroup(); + if (!grp) + { + grp = new Group(); + grp->Create(_player); + } + // no group found, error if (!grp) return; + if (grp->GetLeaderGUID() != _player->GetGUID()) return; @@ -559,7 +566,10 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPackets::Battleground::Battl GroupQueueInfo* ginfo = nullptr; ObjectGuid errorGuid; - GroupJoinBattlegroundResult err = grp->CanJoinBattlegroundQueue(bgTemplate, bgQueueTypeId, arenatype, arenatype, true, packet.TeamSizeIndex, errorGuid); + GroupJoinBattlegroundResult err = ERR_BATTLEGROUND_NONE; + if (!sBattlegroundMgr->isArenaTesting()) + err = grp->CanJoinBattlegroundQueue(bgTemplate, bgQueueTypeId, arenatype, arenatype, true, packet.TeamSizeIndex, errorGuid); + if (!err) { TC_LOG_DEBUG("bg.battleground", "Battleground: arena team id {}, leader {} queued with matchmaker rating {} for type {}", _player->GetArenaTeamId(packet.TeamSizeIndex), _player->GetName(), matchmakerRating, arenatype); diff --git a/src/server/game/Maps/TerrainMgr.cpp b/src/server/game/Maps/TerrainMgr.cpp index a18373dc248..65655e6e84b 100644 --- a/src/server/game/Maps/TerrainMgr.cpp +++ b/src/server/game/Maps/TerrainMgr.cpp @@ -22,7 +22,7 @@ #include "GridMap.h" #include "Log.h" #include "Memory.h" -#include "MMapFactory.h" +#include "MMapManager.h" #include "PhasingHandler.h" #include "Random.h" #include "ScriptMgr.h" @@ -39,7 +39,7 @@ TerrainInfo::TerrainInfo(uint32 mapId) : _mapId(mapId), _parentTerrain(nullptr), TerrainInfo::~TerrainInfo() { VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId()); - MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(GetId()); + MMAP::MMapManager::instance()->unloadMap(GetId()); } char const* TerrainInfo::GetMapName() const @@ -185,7 +185,7 @@ void TerrainInfo::LoadMapAndVMapImpl(int32 gx, int32 gy) void TerrainInfo::LoadMMapInstanceImpl(uint32 mapId, uint32 instanceId) { - MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld->GetDataPath(), _mapId, mapId, instanceId); + MMAP::MMapManager::instance()->loadMapInstance(sWorld->GetDataPath(), _mapId, mapId, instanceId); } void TerrainInfo::LoadMap(int32 gx, int32 gy) @@ -239,12 +239,21 @@ void TerrainInfo::LoadMMap(int32 gx, int32 gy) if (!DisableMgr::IsPathfindingEnabled(GetId())) return; - bool mmapLoadResult = MMAP::MMapFactory::createOrGetMMapManager()->loadMap(sWorld->GetDataPath(), GetId(), gx, gy); - - if (mmapLoadResult) - TC_LOG_DEBUG("mmaps.tiles", "MMAP loaded name:{}, id:{}, x:{}, y:{} (mmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy); - else - TC_LOG_WARN("mmaps.tiles", "Could not load MMAP name:{}, id:{}, x:{}, y:{} (mmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy); + switch (MMAP::LoadResult mmapLoadResult = MMAP::MMapManager::instance()->loadMap(sWorld->GetDataPath(), GetId(), gx, gy)) + { + case MMAP::LoadResult::Success: + TC_LOG_DEBUG("mmaps.tiles", "MMAP loaded name:{}, id:{}, x:{}, y:{} (mmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy); + break; + case MMAP::LoadResult::AlreadyLoaded: + break; + case MMAP::LoadResult::FileNotFound: + if (_parentTerrain) + break; // don't log tile not found errors for child maps + [[fallthrough]]; + default: + TC_LOG_WARN("mmaps.tiles", "Could not load MMAP name:{}, id:{}, x:{}, y:{} (mmap rep.: x:{}, y:{}) result: {}", GetMapName(), GetId(), gx, gy, gx, gy, AsUnderlyingType(mmapLoadResult)); + break; + } } void TerrainInfo::UnloadMap(int32 gx, int32 gy) @@ -265,7 +274,7 @@ void TerrainInfo::UnloadMapImpl(int32 gx, int32 gy) { _gridMap[gx][gy] = nullptr; VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gx, gy); - MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(GetId(), gx, gy); + MMAP::MMapManager::instance()->unloadMap(GetId(), gx, gy); for (std::shared_ptr<TerrainInfo> const& childTerrain : _childTerrain) childTerrain->UnloadMapImpl(gx, gy); @@ -275,7 +284,7 @@ void TerrainInfo::UnloadMapImpl(int32 gx, int32 gy) void TerrainInfo::UnloadMMapInstanceImpl(uint32 mapId, uint32 instanceId) { - MMAP::MMapFactory::createOrGetMMapManager()->unloadMapInstance(_mapId, mapId, instanceId); + MMAP::MMapManager::instance()->unloadMapInstance(_mapId, mapId, instanceId); } GridMap* TerrainInfo::GetGrid(uint32 mapId, float x, float y, bool loadIfMissing /*= true*/) diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index 1d8285822ec..49f2f0150fa 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -22,7 +22,6 @@ #include "DisableMgr.h" #include "G3DPosition.hpp" #include "Log.h" -#include "MMapFactory.h" #include "MMapManager.h" #include "Map.h" #include "Metric.h" @@ -42,7 +41,7 @@ PathGenerator::PathGenerator(WorldObject const* owner) : uint32 mapId = PhasingHandler::GetTerrainMapId(_source->GetPhaseShift(), _source->GetMapId(), _source->GetMap()->GetTerrain(), _startPosition.x, _startPosition.y); if (DisableMgr::IsPathfindingEnabled(_source->GetMapId())) { - MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager(); + MMAP::MMapManager* mmap = MMAP::MMapManager::instance(); _navMeshQuery = mmap->GetNavMeshQuery(mapId, _source->GetMapId(), _source->GetInstanceId()); _navMesh = _navMeshQuery ? _navMeshQuery->getAttachedNavMesh() : mmap->GetNavMesh(mapId); } diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 2776b10628e..d4436a76e96 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -69,7 +69,7 @@ #include "LootItemStorage.h" #include "LootMgr.h" #include "M2Stores.h" -#include "MMapFactory.h" +#include "MMapManager.h" #include "Map.h" #include "MapManager.h" #include "MapUtils.h" @@ -188,7 +188,6 @@ World::~World() delete command; VMAP::VMapFactory::clear(); - MMAP::MMapFactory::clear(); /// @todo free addSessQueue } @@ -1356,7 +1355,7 @@ bool World::SetInitialWorldSettings() vmmgr2->InitializeThreadUnsafe(mapData); - MMAP::MMapManager* mmmgr = MMAP::MMapFactory::createOrGetMMapManager(); + MMAP::MMapManager* mmmgr = MMAP::MMapManager::instance(); mmmgr->InitializeThreadUnsafe(mapData); ///- Initialize static helper structures diff --git a/src/server/scripts/Battlegrounds/MaldraxxusColiseum/arena_maldraxxus_coliseum.cpp b/src/server/scripts/Battlegrounds/MaldraxxusColiseum/arena_maldraxxus_coliseum.cpp new file mode 100644 index 00000000000..643f582e3fa --- /dev/null +++ b/src/server/scripts/Battlegrounds/MaldraxxusColiseum/arena_maldraxxus_coliseum.cpp @@ -0,0 +1,125 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "Battleground.h" +#include "BattlegroundScript.h" +#include "Creature.h" +#include "GameObject.h" +#include "Map.h" +#include "MotionMaster.h" +#include "ScriptMgr.h" + +namespace MaldraxxusColiseum +{ + namespace MapIds + { + static constexpr uint32 MaldraxxusColiseum = 2509; + } + + namespace Creatures + { + static constexpr uint32 MaldraxxianGladiator = 185764; + } + + namespace GameObjects + { + static constexpr uint32 Door = 375890; + } + + namespace Destinations + { + static constexpr Position Guard1 = { 2875.89f, 2285.57f, 3260.1755f }; + static constexpr Position Guard2 = { 2816.69f, 2300.51f, 3260.1885f }; + static constexpr Position Guard3 = { 2873.62f, 2219.39f, 3260.7085f }; + static constexpr Position Guard4 = { 2823.31f, 2204.30f, 3260.0960f }; + } + + namespace StringIds + { + static constexpr std::string_view Guard1 = "arena_maldraxxus_coliseum_1"; + static constexpr std::string_view Guard2 = "arena_maldraxxus_coliseum_2"; + static constexpr std::string_view Guard3 = "arena_maldraxxus_coliseum_3"; + static constexpr std::string_view Guard4 = "arena_maldraxxus_coliseum_4"; + } +} + +struct arena_maldraxxus_coliseum : ArenaScript +{ + explicit arena_maldraxxus_coliseum(BattlegroundMap* map) : ArenaScript(map) { } + + void OnStart() override + { + for (ObjectGuid const& guid : _doorGUIDs) + { + if (GameObject* door = battlegroundMap->GetGameObject(guid)) + { + door->UseDoorOrButton(); + door->DespawnOrUnsummon(5s); + } + } + + for (ObjectGuid const& guid : _gladiatorGUIDs) + { + if (Creature* creature = battlegroundMap->GetCreature(guid)) + { + if (creature->HasStringId(MaldraxxusColiseum::StringIds::Guard1)) + creature->GetMotionMaster()->MovePoint(1, MaldraxxusColiseum::Destinations::Guard1); + else if (creature->HasStringId(MaldraxxusColiseum::StringIds::Guard2)) + creature->GetMotionMaster()->MovePoint(1, MaldraxxusColiseum::Destinations::Guard2); + else if (creature->HasStringId(MaldraxxusColiseum::StringIds::Guard3)) + creature->GetMotionMaster()->MovePoint(1, MaldraxxusColiseum::Destinations::Guard3); + else if (creature->HasStringId(MaldraxxusColiseum::StringIds::Guard4)) + creature->GetMotionMaster()->MovePoint(1, MaldraxxusColiseum::Destinations::Guard4); + + creature->DespawnOrUnsummon(2s); + } + } + } + + void OnCreatureCreate(Creature* creature) override + { + switch (creature->GetEntry()) + { + case MaldraxxusColiseum::Creatures::MaldraxxianGladiator: + _gladiatorGUIDs.emplace_back(creature->GetGUID()); + break; + default: + break; + } + } + + void OnGameObjectCreate(GameObject* gameobject) override + { + switch (gameobject->GetEntry()) + { + case MaldraxxusColiseum::GameObjects::Door: + _doorGUIDs.emplace_back(gameobject->GetGUID()); + break; + default: + break; + } + } + +private: + GuidVector _doorGUIDs; + GuidVector _gladiatorGUIDs; +}; + +void AddSC_arena_maldraxxus_coliseum() +{ + RegisterBattlegroundMapScript(arena_maldraxxus_coliseum, MaldraxxusColiseum::MapIds::MaldraxxusColiseum); +} diff --git a/src/server/scripts/Battlegrounds/TheRobodrome/arena_the_robodrome.cpp b/src/server/scripts/Battlegrounds/TheRobodrome/arena_the_robodrome.cpp new file mode 100644 index 00000000000..b7e00b73969 --- /dev/null +++ b/src/server/scripts/Battlegrounds/TheRobodrome/arena_the_robodrome.cpp @@ -0,0 +1,136 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "Battleground.h" +#include "BattlegroundScript.h" +#include "Creature.h" +#include "CreatureAI.h" +#include "GameObject.h" +#include "Map.h" +#include "Player.h" +#include "ScriptMgr.h" +#include "SpellScript.h" +#include "TaskScheduler.h" + +namespace TheRobodrome +{ + namespace MapIds + { + static constexpr uint32 TheRobodrome = 2167; + } + + namespace Creatures + { + static constexpr uint32 PowerCoil = 154593; + } + + namespace GameObjects + { + static constexpr uint32 Door01 = 329742; + static constexpr uint32 Door02 = 329743; + } + + namespace Spells + { + static constexpr uint32 Zap = 300642; + } +} + +struct arena_the_robodrome : ArenaScript +{ + explicit arena_the_robodrome(BattlegroundMap* map) : ArenaScript(map) { } + + void OnUpdate(uint32 diff) override + { + _scheduler.Update(diff); + } + + void OnStart() override + { + for (ObjectGuid const& guid : _doorGUIDs) + { + if (GameObject* door = battlegroundMap->GetGameObject(guid)) + { + door->UseDoorOrButton(); + door->DespawnOrUnsummon(5s); + } + } + + _scheduler.Schedule(5s, [&](TaskContext context) + { + for (ObjectGuid const& guid : _powerCoilGUIDs) + if (Creature* coil = battlegroundMap->GetCreature(guid)) + coil->CastSpell(nullptr, TheRobodrome::Spells::Zap); + + context.Repeat(); + }); + } + + void OnGameObjectCreate(GameObject* gameobject) override + { + switch (gameobject->GetEntry()) + { + case TheRobodrome::GameObjects::Door01: + case TheRobodrome::GameObjects::Door02: + _doorGUIDs.emplace_back(gameobject->GetGUID()); + break; + default: + break; + } + } + + void OnCreatureCreate(Creature* creature) override + { + switch (creature->GetEntry()) + { + case TheRobodrome::Creatures::PowerCoil: + _powerCoilGUIDs.emplace_back(creature->GetGUID()); + break; + default: + break; + } + } + +private: + GuidVector _doorGUIDs; + GuidVector _powerCoilGUIDs; + + TaskScheduler _scheduler; +}; + +// 300642 - Zap (Damage mod) +class spell_the_robodrome_zap_damage : public SpellScript +{ + void HandleHitTarget(SpellEffIndex /*effIndex*/) + { + uint32 basePct = 16; + uint32 stackCount = GetHitUnit()->GetAuraCount(TheRobodrome::Spells::Zap); + + SetEffectValue(basePct + basePct * stackCount); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_the_robodrome_zap_damage::HandleHitTarget, EFFECT_2, SPELL_EFFECT_DAMAGE_FROM_MAX_HEALTH_PCT); + } +}; + +void AddSC_arena_the_robodrome() +{ + RegisterBattlegroundMapScript(arena_the_robodrome, TheRobodrome::MapIds::TheRobodrome); + RegisterSpellScript(spell_the_robodrome_zap_damage); +} diff --git a/src/server/scripts/Battlegrounds/battlegrounds_script_loader.cpp b/src/server/scripts/Battlegrounds/battlegrounds_script_loader.cpp index 65f831fae9e..5bf00c0a80a 100644 --- a/src/server/scripts/Battlegrounds/battlegrounds_script_loader.cpp +++ b/src/server/scripts/Battlegrounds/battlegrounds_script_loader.cpp @@ -66,6 +66,9 @@ void AddSC_battleground_deephaul_ravine(); void AddSC_arena_blades_edge_legion(); void AddSC_arena_mugambala(); +void AddSC_arena_the_robodrome(); + +void AddSC_arena_maldraxxus_coliseum(); // The name of this function should match: // void Add${NameOfDirectory}Scripts() @@ -118,4 +121,7 @@ void AddBattlegroundsScripts() AddSC_arena_blades_edge_legion(); AddSC_arena_mugambala(); + AddSC_arena_the_robodrome(); + + AddSC_arena_maldraxxus_coliseum(); } diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 68020eb435d..3785f81f70a 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -39,6 +39,7 @@ EndScriptData */ #include "GridNotifiersImpl.h" #include "InstanceScript.h" #include "Language.h" +#include "LFG.h" #include "Log.h" #include "M2Stores.h" #include "MapManager.h" @@ -856,9 +857,20 @@ public: return true; } - static bool HandleDebugArenaCommand(ChatHandler* /*handler*/) + static bool HandleDebugArenaCommand(ChatHandler* handler, uint32 battlemasterListId) { - sBattlegroundMgr->ToggleArenaTesting(); + bool successful = sBattlegroundMgr->ToggleArenaTesting(battlemasterListId); + if (!successful) + { + handler->PSendSysMessage("BattlemasterListId %u does not exist or is not an arena.", battlemasterListId); + handler->SetSentErrorMessage(true); + return true; + } + + if (!battlemasterListId || !handler || !handler->GetSession()) + return true; + + BattlegroundMgr::QueuePlayerForArena(handler->GetSession()->GetPlayer(), 0, lfg::PLAYER_ROLE_DAMAGE); return true; } diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 3e5fe709ee0..5e87cf376fb 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -32,7 +32,7 @@ #include "ItemBonusMgr.h" #include "Language.h" #include "MiscPackets.h" -#include "MMapFactory.h" +#include "MMapManager.h" #include "MotionMaster.h" #include "MovementDefines.h" #include "ObjectAccessor.h" @@ -258,7 +258,7 @@ public: uint32 haveMap = TerrainInfo::ExistMap(mapId, gridX, gridY) ? 1 : 0; uint32 haveVMap = TerrainInfo::ExistVMap(mapId, gridX, gridY) ? 1 : 0; - uint32 haveMMap = (DisableMgr::IsPathfindingEnabled(mapId) && MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) ? 1 : 0; + uint32 haveMMap = (DisableMgr::IsPathfindingEnabled(mapId) && MMAP::MMapManager::instance()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) ? 1 : 0; if (haveVMap) { diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp index 94004eb8125..d30bfcdc746 100644 --- a/src/server/scripts/Commands/cs_mmaps.cpp +++ b/src/server/scripts/Commands/cs_mmaps.cpp @@ -29,7 +29,7 @@ #include "ChatCommand.h" #include "DisableMgr.h" #include "GridNotifiersImpl.h" -#include "MMapFactory.h" +#include "MMapManager.h" #include "PathGenerator.h" #include "PhasingHandler.h" #include "Player.h" @@ -66,7 +66,7 @@ public: static bool HandleMmapPathCommand(ChatHandler* handler, char const* args) { - if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) + if (!MMAP::MMapManager::instance()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) { handler->PSendSysMessage("NavMesh not loaded for current map."); return true; @@ -138,13 +138,14 @@ public: float x, y, z; player->GetPosition(x, y, z); - handler->PSendSysMessage("%04u%02i%02i.mmtile", player->GetMapId(), gx, gy); - handler->PSendSysMessage("tileloc [%i, %i]", gy, gx); - // calculate navmesh tile location uint32 terrainMapId = PhasingHandler::GetTerrainMapId(player->GetPhaseShift(), player->GetMapId(), player->GetMap()->GetTerrain(), x, y); - dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(terrainMapId); - dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(terrainMapId, player->GetMapId(), player->GetInstanceId()); + + handler->PSendSysMessage("%04u%02i%02i.mmtile", terrainMapId, gx, gy); + handler->PSendSysMessage("tileloc [%i, %i]", gy, gx); + + dtNavMesh const* navmesh = MMAP::MMapManager::instance()->GetNavMesh(terrainMapId); + dtNavMeshQuery const* navmeshquery = MMAP::MMapManager::instance()->GetNavMeshQuery(terrainMapId, player->GetMapId(), player->GetInstanceId()); if (!navmesh || !navmeshquery) { handler->PSendSysMessage("NavMesh not loaded for current map."); @@ -194,8 +195,8 @@ public: { Player* player = handler->GetSession()->GetPlayer(); uint32 terrainMapId = PhasingHandler::GetTerrainMapId(player->GetPhaseShift(), player->GetMapId(), player->GetMap()->GetTerrain(), player->GetPositionX(), player->GetPositionY()); - dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(terrainMapId); - dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(terrainMapId, player->GetMapId(), player->GetInstanceId()); + dtNavMesh const* navmesh = MMAP::MMapManager::instance()->GetNavMesh(terrainMapId); + dtNavMeshQuery const* navmeshquery = MMAP::MMapManager::instance()->GetNavMeshQuery(terrainMapId, player->GetMapId(), player->GetInstanceId()); if (!navmesh || !navmeshquery) { handler->PSendSysMessage("NavMesh not loaded for current map."); @@ -223,7 +224,7 @@ public: handler->PSendSysMessage("mmap stats:"); handler->PSendSysMessage(" global mmap pathfinding is %sabled", DisableMgr::IsPathfindingEnabled(player->GetMapId()) ? "en" : "dis"); - MMAP::MMapManager* manager = MMAP::MMapFactory::createOrGetMMapManager(); + MMAP::MMapManager* manager = MMAP::MMapManager::instance(); handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount()); dtNavMesh const* navmesh = manager->GetNavMesh(terrainMapId); diff --git a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp index 1cdad52feb1..8eef765a5b0 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp @@ -41,11 +41,11 @@ DoorData const doorData[] = DungeonEncounterData const encounters[] = { - { BOSS_GLUBTOK, {{ 1064 }} }, - { BOSS_HELIX_GEARBREAKER, {{ 1065 }} }, - { BOSS_FOE_REAPER_5000, {{ 1063 }} }, - { BOSS_ADMIRAL_RIPSNARL, {{ 1062 }} }, - { BOSS_CAPTAIN_COOKIE, {{ 1060 }} }, + { BOSS_GLUBTOK, {{ 2976, 2981 }} }, + { BOSS_HELIX_GEARBREAKER, {{ 2977, 2982 }} }, + { BOSS_FOE_REAPER_5000, {{ 2975, 2980 }} }, + { BOSS_ADMIRAL_RIPSNARL, {{ 2974, 2979 }} }, + { BOSS_CAPTAIN_COOKIE, {{ 2973, 2978 }} }, { BOSS_VANESSA_VANCLEEF, {{ 1081 }} } }; diff --git a/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_1.cpp b/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_1.cpp new file mode 100644 index 00000000000..a249d16a0f5 --- /dev/null +++ b/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_1.cpp @@ -0,0 +1,176 @@ +/* +* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information +* +* 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 <http://www.gnu.org/licenses/>. +*/ + +#include "ScriptMgr.h" +#include "CreatureAIImpl.h" +#include "MotionMaster.h" +#include "ObjectAccessor.h" +#include "Player.h" +#include "PhasingHandler.h" +#include "ScriptedCreature.h" +#include "SpellInfo.h" +#include "SpellScript.h" +#include "TemporarySummon.h" + +namespace Scripts::EasternKingdoms::Gilneas::Chapter1 +{ + namespace Creatures + { + static constexpr uint32 EvacuationStalkerFirst = 35830; + static constexpr uint32 EvacuationStalkerNear = 35010; + static constexpr uint32 EvacuationStalkerFar = 35011; + } + + namespace Events + { + namespace EvacuateTheMerchantSquare + { + static constexpr uint32 TalkFrightened = 1; + static constexpr uint32 MoveToNearStalker = 2; + static constexpr uint32 MoveToFarStalker = 3; + static constexpr uint32 FrightenedDespawn = 4; + } + } + + namespace Texts + { + namespace FrightenedCitizen + { + static constexpr uint32 SayFrightenedCitizenRescue = 0; + } + } + + namespace Points + { + static constexpr uint32 PointStalkerFirst = 1; + static constexpr uint32 PointStalkerNear = 2; + static constexpr uint32 PointStalkerFar = 3; + } + +// 34981 - Frightened Citizen +// 35836 - Frightened Citizen +struct npc_frightened_citizen : public ScriptedAI +{ + npc_frightened_citizen(Creature* creature) : ScriptedAI(creature) {} + + void IsSummonedBy(WorldObject* /*summoner*/) override + { + me->SetReactState(REACT_PASSIVE); + + if (Creature* stalkerNear = me->FindNearestCreature(Creatures::EvacuationStalkerFirst, 20.0f)) + me->GetMotionMaster()->MovePoint(Points::PointStalkerFirst, stalkerNear->GetPosition(), true); + } + + void MovementInform(uint32 type, uint32 id) override + { + if (type != POINT_MOTION_TYPE) + return; + + switch (id) + { + case Points::PointStalkerFirst: + _events.ScheduleEvent(Events::EvacuateTheMerchantSquare::TalkFrightened, 1s); + break; + case Points::PointStalkerNear: + _events.ScheduleEvent(Events::EvacuateTheMerchantSquare::MoveToFarStalker, 1ms); + break; + case Points::PointStalkerFar: + _events.ScheduleEvent(Events::EvacuateTheMerchantSquare::FrightenedDespawn, 1ms); + break; + default: + break; + } + } + + void UpdateAI(uint32 diff) override + { + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case Events::EvacuateTheMerchantSquare::TalkFrightened: + if (TempSummon* summon = me->ToTempSummon()) + { + if (Unit* summoner = summon->GetSummonerUnit()) + { + if (Player* player = summoner->ToPlayer()) + { + player->KilledMonsterCredit(Creatures::EvacuationStalkerFirst); + Talk(Texts::FrightenedCitizen::SayFrightenedCitizenRescue, summoner); + } + } + } + _events.ScheduleEvent(Events::EvacuateTheMerchantSquare::MoveToNearStalker, 2s); + break; + case Events::EvacuateTheMerchantSquare::MoveToNearStalker: + if (Creature* stalker = me->FindNearestCreature(Creatures::EvacuationStalkerFar, 50.0f)) + me->GetMotionMaster()->MovePoint(Points::PointStalkerFar, stalker->GetPosition(), true); + else if (Creature* stalker = me->FindNearestCreature(Creatures::EvacuationStalkerNear, 100.0f)) + me->GetMotionMaster()->MovePoint(Points::PointStalkerNear, stalker->GetPosition(), true); + break; + case Events::EvacuateTheMerchantSquare::MoveToFarStalker: + if (Creature* stalker = me->FindNearestCreature(Creatures::EvacuationStalkerFar, 500.0f)) + me->GetMotionMaster()->MovePoint(Points::PointStalkerFar, stalker->GetPosition(), true); + break; + case Events::EvacuateTheMerchantSquare::FrightenedDespawn: + me->DespawnOrUnsummon(); + break; + default: + break; + } + } + } +private: + EventMap _events; +}; + +// 67869 - Knocking +class spell_gilneas_knocking : public SpellScript +{ + bool Validate(SpellInfo const* spellInfo) override + { + return ValidateSpellInfo( + { + uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()), + uint32(spellInfo->GetEffect(EFFECT_2).CalcValue()) + }); + } + + void HandleEffect() + { + GetCaster()->CastSpell(GetCaster(), GetEffectInfo(RAND(EFFECT_1, EFFECT_2)).CalcValue(), true); + } + + void Register() override + { + OnCast += SpellCastFn(spell_gilneas_knocking::HandleEffect); + } +}; +} + +void AddSC_gilneas_chapter_1() +{ + using namespace Scripts::EasternKingdoms::Gilneas::Chapter1; + + // Creatures + RegisterCreatureAI(npc_frightened_citizen); + + // Spells + RegisterSpellScript(spell_gilneas_knocking); +} diff --git a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp index 283eed704a0..13f41362243 100644 --- a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp +++ b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp @@ -65,6 +65,7 @@ void AddSC_boss_chromaggus(); void AddSC_boss_nefarian(); void AddSC_instance_blackwing_lair(); void AddSC_instance_deadmines(); //Deadmines +void AddSC_gilneas_chapter_1(); //Gilneas void AddSC_gnomeregan(); //Gnomeregan void AddSC_instance_gnomeregan(); void AddSC_instance_grim_batol(); //Grim Batol @@ -264,6 +265,7 @@ void AddEasternKingdomsScripts() AddSC_boss_nefarian(); AddSC_instance_blackwing_lair(); AddSC_instance_deadmines(); //Deadmines + AddSC_gilneas_chapter_1(); //Gilneas AddSC_gnomeregan(); //Gnomeregan AddSC_instance_gnomeregan(); AddSC_instance_grim_batol(); //Grim Batol diff --git a/src/server/scripts/EasternKingdoms/zone_westfall.cpp b/src/server/scripts/EasternKingdoms/zone_westfall.cpp index 17b5a2de406..60162630e80 100644 --- a/src/server/scripts/EasternKingdoms/zone_westfall.cpp +++ b/src/server/scripts/EasternKingdoms/zone_westfall.cpp @@ -15,11 +15,45 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "CombatAI.h" #include "Containers.h" +#include "CreatureAIImpl.h" +#include "Player.h" #include "ScriptedCreature.h" #include "ScriptMgr.h" +#include "SpellAuraEffects.h" #include "SpellScript.h" +namespace Scripts::EasternKingdoms::Westfall +{ +namespace Creatures +{ + static constexpr uint32 EnergizedHarvestReaper = 42342; + static constexpr uint32 OverloadedHarvestGolem = 42601; +} + +namespace Events +{ + namespace ItsAlive + { + static constexpr uint32 CheckArea = 1; + static constexpr uint32 DespawnHarvester = 2; + } +} + +namespace Text +{ + namespace HarvestGolem + { + static constexpr uint32 AnnounceOutOfArea = 0; + } +} + +namespace Area +{ + static constexpr uint32 TheMoestFarm = 918; +} + // 79084 - Unbound Energy class spell_westfall_unbound_energy : public SpellScript { @@ -44,7 +78,121 @@ class spell_westfall_unbound_energy : public SpellScript } }; +// 42601 - Overloaded Harvest Golem +struct npc_westfall_overloaded_harvest_golem : public ScriptedAI +{ + npc_westfall_overloaded_harvest_golem(Creature* creature) : ScriptedAI(creature) {} + + void JustAppeared() override + { + _events.ScheduleEvent(Events::ItsAlive::CheckArea, 1s); + } + + void PassengerBoarded(Unit* /*passenger*/, int8 /*seatId*/, bool apply) override + { + if (!apply) + me->DespawnOrUnsummon(); + } + + void UpdateAI(uint32 diff) override + { + _events.Update(diff); + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case Events::ItsAlive::CheckArea: + if (me->GetAreaId() != Area::TheMoestFarm) + { + if (Unit* owner = me->GetCharmerOrOwner()) + Talk(Text::HarvestGolem::AnnounceOutOfArea, owner); + _events.ScheduleEvent(Events::ItsAlive::DespawnHarvester, 8s); + } + else + _events.Repeat(1s); + break; + case Events::ItsAlive::DespawnHarvester: + if (me->GetAreaId() != Area::TheMoestFarm) + me->DespawnOrUnsummon(); + else + _events.ScheduleEvent(Events::ItsAlive::CheckArea, 1s); + break; + default: + break; + } + } + } + +private: + EventMap _events; +}; + +// 79425 - Reaping Blows +class spell_westfall_reaping_blows : public AuraScript +{ + bool Validate(SpellInfo const* spellInfo) override + { + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).TriggerSpell) }); + } + + void HandlePeriodic(AuraEffect const* /*aurEff*/) + { + // HACK + // periodic ticks are forcing to cast the spell onto himself instead of target + // ref AuraEffect::HandlePeriodicTriggerSpellAuraTick + PreventDefaultAction(); + if (Creature* reaper = GetTarget()->FindNearestCreature(Creatures::EnergizedHarvestReaper, 5.f, true)) + GetTarget()->CastSpell(reaper, GetSpellInfo()->GetEffect(EFFECT_1).TriggerSpell, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_westfall_reaping_blows::HandlePeriodic, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } +}; + +// 79436 - Wake Harvest Golem +class spell_westfall_wake_harvest_golem : public SpellScript +{ + SpellCastResult CheckTarget() + { + Unit* target = GetExplTargetUnit(); + if (!target || !target->IsCreature()) + return SPELL_FAILED_BAD_TARGETS; + + return SPELL_CAST_OK; + } + + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (!caster || !caster->IsPlayer()) + return; + + if (Creature* target = GetHitCreature()) + { + caster->ToPlayer()->KilledMonsterCredit(Creatures::OverloadedHarvestGolem); + target->DespawnOrUnsummon(100ms); + } + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_westfall_wake_harvest_golem::CheckTarget); + OnEffectHitTarget += SpellEffectFn(spell_westfall_wake_harvest_golem::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } +}; +} + void AddSC_westfall() { + using namespace Scripts::EasternKingdoms::Westfall; + + // Creature + RegisterCreatureAI(npc_westfall_overloaded_harvest_golem); + + // Spells RegisterSpellScript(spell_westfall_unbound_energy); + RegisterSpellScript(spell_westfall_reaping_blows); + RegisterSpellScript(spell_westfall_wake_harvest_golem); } diff --git a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp index f586c3c50a4..065c65a3110 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp @@ -24,11 +24,11 @@ DungeonEncounterData const encounters[] = { - { DATA_COMMANDER, {{ 519 }} }, - { DATA_MAGUS_TELESTRA, {{ 520, 521, 2010 }} }, - { DATA_ANOMALUS, {{ 522, 523, 2009 }} }, - { DATA_ORMOROK, {{ 524, 525, 2012 }} }, - { DATA_KERISTRASZA, {{ 526, 527, 2011 }} } + { DATA_COMMANDER, {{ 519, 3017 }} }, + { DATA_MAGUS_TELESTRA, {{ 2010 }} }, + { DATA_ANOMALUS, {{ 2009 }} }, + { DATA_ORMOROK, {{ 2012 }} }, + { DATA_KERISTRASZA, {{ 2011 }} } }; class instance_nexus : public InstanceMapScript |