From 54c991bc3d60b700126b7c1f39d7d81ef9d5b4e2 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 21 Nov 2018 13:16:17 +0100 Subject: [PATCH] Scripts/Maps: ported WorldMapScript database implementation and ported Deeprun Tram script and removed unnecessary parts from it. *thx to Annakin? --- .../custom/custom_2018_11_21_00_world.sql | 14 +++ src/server/game/Globals/ObjectMgr.cpp | 2 + src/server/game/Scripting/ScriptMgr.cpp | 4 + .../scripts/World/world_map_scripts.cpp | 90 +++++++++++++++++++ .../scripts/World/world_script_loader.cpp | 2 + 5 files changed, 112 insertions(+) create mode 100644 sql/updates/world/custom/custom_2018_11_21_00_world.sql create mode 100644 src/server/scripts/World/world_map_scripts.cpp diff --git a/sql/updates/world/custom/custom_2018_11_21_00_world.sql b/sql/updates/world/custom/custom_2018_11_21_00_world.sql new file mode 100644 index 00000000000..0ae9fd35f31 --- /dev/null +++ b/sql/updates/world/custom/custom_2018_11_21_00_world.sql @@ -0,0 +1,14 @@ +DROP TABLE IF EXISTS `world_map_template`; +CREATE TABLE `world_map_template`( + `mapID` INT(11) UNSIGNED NOT NULL DEFAULT '0' , + `ScriptName` TEXT, + PRIMARY KEY (`mapID`)); + +DELETE FROM `world_map_template` WHERE `mapId`= 369; +INSERT INTO `world_map_template` (`mapID`, `ScriptName`) VALUES +(369, 'world_map_deeprun_tram'); + +DELETE FROM `gameobject` WHERE `guid` IN (18802, 18803, 18804, 18805, 18806, 18807); +DELETE FROM `gameobject_addon` WHERE `guid` IN (18802, 18803, 18804, 18805, 18806, 18807); + +UPDATE `gameobject_template` SET `data6`= 0, `data8`= 0, `data10`= 0 WHERE `entry`= 176084; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 58b99530b61..d0cd14f8de3 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -9377,6 +9377,8 @@ void ObjectMgr::LoadScriptNames() "UNION " "SELECT DISTINCT(ScriptName) FROM outdoorpvp_template WHERE ScriptName <> '' " "UNION " + "SELECT DISTINCT(ScriptName) FROM world_map_template WHERE ScriptName <> '' " + "UNION " "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''"); if (!result) diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index e5ee5086fa8..c877268a7b4 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -102,6 +102,10 @@ template<> struct is_script_database_bound : std::true_type { }; +template<> +struct is_script_database_bound + : std::true_type { }; + enum Spells { SPELL_HOTSWAP_VISUAL_SPELL_EFFECT = 40162 // 59084 diff --git a/src/server/scripts/World/world_map_scripts.cpp b/src/server/scripts/World/world_map_scripts.cpp new file mode 100644 index 00000000000..31371ea74d9 --- /dev/null +++ b/src/server/scripts/World/world_map_scripts.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2008-2018 TrinityCore + * + * 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 "ScriptMgr.h" +#include "Transport.h" +#include "ObjectMgr.h" + +enum DeeprunTram +{ + MAP_DEEPRUN_TRAM = 369, + + GO_SUBWAY = 176080, + MAX_SUBWAY_COUNT = 6 +}; + +Position const SubwaysPos[MAX_SUBWAY_COUNT] = +{ + { 4.580650f, 28.20970f, 7.01107f, 1.5708f }, + { 4.528070f, 8.435290f, 7.01107f, 1.5708f }, + { -45.4005f, 2492.790f, 6.98860f, 1.5708f }, + { -45.4007f, 2512.150f, 6.98860f, 1.5708f }, + { -45.3934f, 2472.930f, 6.98860f, 1.5708f }, + { 4.498830f, -11.3475f, 7.01107f, 1.5708f } +}; + +static QuaternionData worldRotation = QuaternionData(0.0f, 0.0f, 0.7071066f, 0.7071069f); +static QuaternionData parentRotation = QuaternionData(0.0f, 0.0f, 1.0f, -0.0000000437114f); + +class world_map_deeprun_tram: public WorldMapScript +{ + public: + world_map_deeprun_tram() : WorldMapScript("world_map_deeprun_tram", MAP_DEEPRUN_TRAM) + { + Initialize(); + } + + void Initialize() + { + _initializedTrams = false; + } + + void OnPlayerEnter(Map* map, Player* /*player*/) override + { + if (!_initializedTrams) + { + _initializedTrams = true; + + for (uint8 i = 0; i < MAX_SUBWAY_COUNT; ++i) + { + GameObject* transport = new Transport(); + + if (!transport->Create(map->GenerateLowGuid(), GO_SUBWAY + i, map, 0, SubwaysPos[i], worldRotation, 255, GO_STATE_READY)) + { + delete transport; + continue; + } + + transport->SetParentRotation(parentRotation); + + uint32 spawnId = sObjectMgr->GenerateGameObjectSpawnId(); + transport->SetSpawnId(spawnId); + + transport->setActive(true); + transport->SetFarVisible(true); + map->AddToMap(transport); + } + } + } + private: + bool _initializedTrams; +}; + +void AddSC_world_map_scripts() +{ + new world_map_deeprun_tram(); +} diff --git a/src/server/scripts/World/world_script_loader.cpp b/src/server/scripts/World/world_script_loader.cpp index 3e9fcf9f876..bf53254ac73 100644 --- a/src/server/scripts/World/world_script_loader.cpp +++ b/src/server/scripts/World/world_script_loader.cpp @@ -31,6 +31,7 @@ void AddSC_npcs_special(); void AddSC_achievement_scripts(); void AddSC_action_ip_logger(); void AddSC_duel_reset(); +void AddSC_world_map_scripts(); // player void AddSC_chat_log(); void AddSC_action_ip_logger(); @@ -49,6 +50,7 @@ void AddWorldScripts() AddSC_npc_innkeeper(); AddSC_npcs_special(); AddSC_achievement_scripts(); + AddSC_world_map_scripts(); AddSC_chat_log(); // location: scripts\World\chat_log.cpp // FIXME: This should be moved in a script validation hook.