diff options
-rw-r--r-- | sql/updates/world/master/2024_01_05_01_world.sql | 26 | ||||
-rw-r--r-- | src/server/scripts/Draenor/Garrison/garrison_generic.cpp | 79 | ||||
-rw-r--r-- | src/server/scripts/Draenor/draenor_script_loader.cpp | 2 |
3 files changed, 107 insertions, 0 deletions
diff --git a/sql/updates/world/master/2024_01_05_01_world.sql b/sql/updates/world/master/2024_01_05_01_world.sql new file mode 100644 index 00000000000..337f8696a8d --- /dev/null +++ b/sql/updates/world/master/2024_01_05_01_world.sql @@ -0,0 +1,26 @@ +SET @ATID := 100000; +SEt @ATCP := 100000; +SET @ATIDSPAWN := 100000; + +-- AreaTrigger Alliance Garrison V1 +DELETE FROM `areatrigger_template` WHERE `Id` = @ATID+0 AND `IsCustom` = 1; +INSERT INTO `areatrigger_template` (`Id`, `IsCustom`, `Flags`, `VerifiedBuild`) VALUES +(@ATID+0, 1, 1, 0); + +DELETE FROM `areatrigger` WHERE `SpawnId` BETWEEN @ATIDSPAWN+0 AND @ATIDSPAWN+1; +INSERT INTO `areatrigger` (`SpawnId`, `AreaTriggerCreatePropertiesId`, `IsCustom`, `MapId`, `SpawnDifficulties`, `PosX`, `PosY`, `PosZ`, `Orientation`, `PhaseUseFlags`, `PhaseId`, `PhaseGroup`, `SpellForVisuals`, `ScriptName`, `Comment`, `VerifiedBuild`) VALUES +(@ATIDSPAWN+0, @ATCP+0, 1, 1116, '0', 1900.9937, 221.3306, 76.9551, 0, 0, 0, 0, NULL, 'at_garrison_enter', 'Enter Garrison Alliance V1', 0), +(@ATIDSPAWN+1, @ATCP+0, 1, 1158, '1', 1900.9937, 221.3306, 76.9551, 0, 0, 0, 0, NULL, 'at_garrison_exit', 'Leave Garrison Alliance V1', 0); + +DELETE FROM `areatrigger_create_properties` WHERE `Id`=@ATCP+0 AND `IsCustom`=1; +INSERT INTO `areatrigger_create_properties` (`Id`, `IsCustom`, `AreaTriggerId`, `IsAreatriggerCustom`, `Flags`, `MoveCurveId`, `ScaleCurveId`, `MorphCurveId`, `FacingCurveId`, `AnimId`, `AnimKitId`, `DecalPropertiesId`, `TimeToTarget`, `TimeToTargetScale`, `Shape`, `ShapeData0`, `ShapeData1`, `ShapeData2`, `ShapeData3`, `ShapeData4`, `ShapeData5`, `ShapeData6`, `ShapeData7`, `ScriptName`, `VerifiedBuild`) VALUES +(@ATCP+0, 1, @ATID+0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 3, 1000, 1000, 0, 0, 0, 0, 0, 0, '', 0); + +DELETE FROM `areatrigger_create_properties_polygon_vertex` WHERE `AreaTriggerCreatePropertiesId`=@ATCP+0 AND `IsCustom`=1; +INSERT INTO `areatrigger_create_properties_polygon_vertex` (`AreaTriggerCreatePropertiesId`, `IsCustom`, `Idx`, `VerticeX`, `VerticeY`, `VerticeTargetX`, `VerticeTargetY`, `VerifiedBuild`) VALUES +(@ATCP+0, 1, 5, 80.74610000000007, 218.2616, NULL, NULL, 0), +(@ATCP+0, 1, 4, -195.68599999999992, 173.7912, NULL, NULL, 0), +(@ATCP+0, 1, 3, -176.72000000000003, -182.52249999999998, NULL, NULL, 0), +(@ATCP+0, 1, 2, 47.75040000000013, -222.8499, NULL, NULL, 0), +(@ATCP+0, 1, 1, 153.72890000000007, -139.58939999999998, NULL, NULL, 0), +(@ATCP+0, 1, 0, 193.42909999999983, -26.468999999999994, NULL, NULL, 0); diff --git a/src/server/scripts/Draenor/Garrison/garrison_generic.cpp b/src/server/scripts/Draenor/Garrison/garrison_generic.cpp new file mode 100644 index 00000000000..7b804e2aece --- /dev/null +++ b/src/server/scripts/Draenor/Garrison/garrison_generic.cpp @@ -0,0 +1,79 @@ +/* + * 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 "AreaTrigger.h" +#include "AreaTriggerAI.h" +#include "Garrison.h" +#include "Map.h" +#include "Player.h" +#include "ScriptMgr.h" +#include "Unit.h" + +// XX - Garrison enter AreaTrigger +struct at_garrison_enter : AreaTriggerAI +{ + at_garrison_enter(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { } + + void OnInitialize() override + { + at->setActive(true); // has to be active, otherwise the at is no longer updated before we are able to leave it + } + + void OnUnitEnter(Unit* unit) override + { + Player* player = unit->ToPlayer(); + if (!player) + return; + + Garrison* garrison = player->GetGarrison(); + if (!garrison) + return; + + garrison->Enter(); + } +}; + +// XX - Garrison exit AreaTrigger +struct at_garrison_exit : AreaTriggerAI +{ + at_garrison_exit(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { } + + void OnInitialize() override + { + at->setActive(true); // has to be active, otherwise the at is no longer updated before we are able to leave it + } + + void OnUnitExit(Unit* unit) override + { + Player* player = unit->ToPlayer(); + if (!player) + return; + + Garrison* garrison = player->GetGarrison(); + if (!garrison) + return; + + garrison->Leave(); + } +}; + +void AddSC_garrison_generic() +{ + // AreaTrigger + RegisterAreaTriggerAI(at_garrison_enter); + RegisterAreaTriggerAI(at_garrison_exit); +} diff --git a/src/server/scripts/Draenor/draenor_script_loader.cpp b/src/server/scripts/Draenor/draenor_script_loader.cpp index 2d8e1f17915..b913ee77253 100644 --- a/src/server/scripts/Draenor/draenor_script_loader.cpp +++ b/src/server/scripts/Draenor/draenor_script_loader.cpp @@ -18,6 +18,7 @@ // This is where scripts' loading functions should be declared: void AddSC_assault_on_the_dark_portal(); void AddSC_draenor_shadowmoon_valley(); +void AddSC_garrison_generic(); // The name of this function should match: // void Add${NameOfDirectory}Scripts() @@ -25,4 +26,5 @@ void AddDraenorScripts() { AddSC_assault_on_the_dark_portal(); AddSC_draenor_shadowmoon_valley(); + AddSC_garrison_generic(); } |