TrinityCore
Loading...
Searching...
No Matches
arena_empyrean_domain.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "AreaTrigger.h"
19#include "Battleground.h"
20#include "BattlegroundScript.h"
21#include "Creature.h"
22#include "GameObject.h"
24#include "Map.h"
25#include "MotionMaster.h"
26#include "Player.h"
27#include "ScriptActions.h"
28#include "ScriptMgr.h"
29#include "TaskScheduler.h"
30
31#include <G3D/Vector3.h>
32
34{
35 namespace AreaTriggers
36 {
37 static constexpr uint32 FlyDownAreaTrigger = 11990000; // TODO CHANGE ME ON PR MERGE
38 }
39
40 namespace Creatures
41 {
42 static constexpr uint32 InvisibleStalker = 169468;
43 static constexpr uint32 Guard = 169472;
44 }
45
46 namespace GameObjects
47 {
48 static constexpr uint32 CollisionWall = 352927;
49 }
50
51 namespace Points
52 {
53 static constexpr Position Guard01Dest = { -1177.7396f, 665.9167f, 7266.0874f };
54 static constexpr Position Guard02Dest = { -1323.2205f, 794.5243f, 7266.0874f };
55 static constexpr Position Guard03Dest = { -1314.2778f, 800.59375f, 7266.283f };
56 static constexpr Position Guard04Dest = { -1186.4219f, 657.78125f, 7266.283f };
57
59 {
60 G3D::Vector3(-1317.3438f, 796.5417f, 7269.4243f),
61 G3D::Vector3(-1300.9236f, 780.2049f, 7265.0225f),
62 G3D::Vector3(-1279.941f, 759.81946f, 7250.053f)
63 };
64
66 {
67 G3D::Vector3(-1186.2604f, 668.684f, 7271.891f),
68 G3D::Vector3(-1199.6632f, 680.2934f, 7260.527f),
69 G3D::Vector3(-1209.1146f, 688.5243f, 7251.5713f)
70 };
71 }
72
73 namespace Spells
74 {
75 static constexpr uint32 BastionArenaPvpReactionTrigger = 329820;
76 static constexpr uint32 WindDrift = 329804;
77 static constexpr uint32 WingsCosmetic = 329819;
78 static constexpr uint32 ArenaStartingAreaMarker = 228212;
79 }
80
81 namespace StringIds
82 {
83 static constexpr std::string_view Guard01 = "empyrean_domain_guard_01"sv;
84 static constexpr std::string_view Guard02 = "empyrean_domain_guard_02"sv;
85 static constexpr std::string_view Guard03 = "empyrean_domain_guard_03"sv;
86 static constexpr std::string_view Guard04 = "empyrean_domain_guard_04"sv;
87 }
88
90 {
91 public:
92 explicit PlayerMoveDownEvent(Player* player, std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> const& action) : _player(player), _action(action) { }
93
94 bool Execute(uint64 /*time*/, uint32 /*diff*/) override
95 {
96 if (!_action->IsReady())
97 {
98 _player->m_Events.AddEventAtOffset(this, 500ms);
99 return false;
100 }
101
103 return true;
104 }
105
106 private:
108 std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> _action;
109 };
110}
111
113{
115
116 void OnStart() override
117 {
118 for (ObjectGuid const& guid : _wallGUIDs)
119 if (GameObject* door = battlegroundMap->GetGameObject(guid))
120 door->Delete();
121
122 for (ObjectGuid const& guid : _guardGUIDs)
123 {
124 if (Creature* guard = battlegroundMap->GetCreature(guid))
125 {
126 if (guard->HasStringId(EmpyreanDomain::StringIds::Guard01))
127 guard->GetMotionMaster()->MovePoint(1, EmpyreanDomain::Points::Guard01Dest);
128 else if (guard->HasStringId(EmpyreanDomain::StringIds::Guard02))
129 guard->GetMotionMaster()->MovePoint(1, EmpyreanDomain::Points::Guard02Dest);
130 else if (guard->HasStringId(EmpyreanDomain::StringIds::Guard03))
131 guard->GetMotionMaster()->MovePoint(1, EmpyreanDomain::Points::Guard03Dest);
132 else if (guard->HasStringId(EmpyreanDomain::StringIds::Guard04))
133 guard->GetMotionMaster()->MovePoint(1, EmpyreanDomain::Points::Guard04Dest);
134 }
135 }
136
137 for (ObjectGuid const& guid : _stalkerGUIDs)
138 if (Creature* stalker = battlegroundMap->GetCreature(guid))
139 stalker->CastSpell(nullptr, EmpyreanDomain::Spells::WindDrift);
140
141 _scheduler.Schedule(5s, [&](TaskContext& context)
142 {
144 {
146 return;
147
149 return;
150
151 MovePlayerDown(player);
152 });
153
154 context.Repeat();
155 });
156
157 for (ObjectGuid const& guid : _flyDownAreaTriggerGUIDs)
158 if (AreaTrigger const* areaTrigger = battlegroundMap->GetAreaTrigger(guid))
159 for (ObjectGuid const& insideUnitGuid : areaTrigger->GetInsideUnits())
160 if (insideUnitGuid.IsPlayer())
161 if (Player* player = battlegroundMap->GetPlayer(insideUnitGuid))
162 MovePlayerDown(player);
163 }
164
165 void OnUpdate(uint32 diff) override
166 {
167 _scheduler.Update(diff);
168 }
169
170 void OnGameObjectCreate(GameObject* gameobject) override
171 {
172 switch (gameobject->GetEntry())
173 {
175 _wallGUIDs.emplace_back(gameobject->GetGUID());
176 break;
177 default:
178 break;
179 }
180 }
181
182 void OnCreatureCreate(Creature* creature) override
183 {
184 switch (creature->GetEntry())
185 {
187 _guardGUIDs.emplace_back(creature->GetGUID());
188 break;
190 _stalkerGUIDs.emplace_back(creature->GetGUID());
191 break;
192 default:
193 break;
194 }
195 }
196
197 void OnAreaTriggerCreate(AreaTrigger* areaTrigger) override
198 {
199 if (!areaTrigger->IsStaticSpawn())
200 return;
201
202 switch (areaTrigger->GetEntry())
203 {
205 _flyDownAreaTriggerGUIDs.emplace_back(areaTrigger->GetGUID());
206 break;
207 default:
208 break;
209 }
210 }
211
218
219 static void MovePlayerDown(Player* player)
220 {
221 if (!player)
222 return;
223
226 });
227
229 if (player->GetBGTeam() == ALLIANCE)
231 else
233
234 std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
235 {
236 init.MovebyPath(path);
237 init.SetWalk(false);
238 init.SetFly();
239 init.SetUncompressed();
240 init.SetSmooth();
241 init.SetVelocity(17.5f);
242 };
243
244 std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> waitEvent = std::make_shared<Scripting::v2::ActionResult<MovementStopReason>>();
246 player->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 1, MOTION_PRIORITY_NORMAL, EFFECT_MOTION_TYPE, std::move(actionResultSetter));
247
248 player->m_Events.AddEventAtOffset(new EmpyreanDomain::PlayerMoveDownEvent(player, waitEvent), 500ms);
249 }
250
251private:
256
258};
259
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
@ MOTION_PRIORITY_NORMAL
@ EFFECT_MOTION_TYPE
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:434
Spells
Definition PlayerAI.cpp:32
#define RegisterBattlegroundMapScript(script_name, mapId)
Definition ScriptMgr.h:1447
@ ALLIANCE
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will not check if a current cast is in progress.
@ TRIGGERED_DONT_REPORT_CAST_ERROR
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Creatures
void AddSC_arena_empyrean_domain()
bool IsStaticSpawn() const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
BattlegroundMap * battlegroundMap
PlayerMoveDownEvent(Player *player, std::shared_ptr< Scripting::v2::ActionResult< MovementStopReason > > const &action)
std::shared_ptr< Scripting::v2::ActionResult< MovementStopReason > > _action
bool Execute(uint64, uint32) override
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
Player * GetPlayer(ObjectGuid const &guid)
Definition Map.cpp:3532
void DoOnPlayers(T &&fn)
Definition Map.h:406
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3552
AreaTrigger * GetAreaTrigger(ObjectGuid const &guid)
Definition Map.cpp:3517
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
void LaunchMoveSpline(std::function< void(Movement::MoveSplineInit &init)> &&initializer, uint32 id=0, MovementGeneratorPriority priority=MOTION_PRIORITY_NORMAL, MovementGeneratorType type=EFFECT_MOTION_TYPE, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 GetEntry() const
Definition Object.h:89
Team GetBGTeam() const
Definition Player.cpp:24358
static ActionResultSetter< T > GetResultSetter(std::shared_ptr< ActionResult > action)
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
EventProcessor m_Events
Definition Object.h:561
static constexpr uint32 FlyDownAreaTrigger
static constexpr uint32 InvisibleStalker
static constexpr uint32 Guard
static constexpr uint32 CollisionWall
static constexpr Position Guard01Dest
static constexpr Position Guard04Dest
static const Movement::PointsArray PurplePath
static constexpr Position Guard03Dest
static const Movement::PointsArray GoldPath
static constexpr Position Guard02Dest
static constexpr uint32 WindDrift
static constexpr uint32 ArenaStartingAreaMarker
static constexpr uint32 WingsCosmetic
static constexpr uint32 BastionArenaPvpReactionTrigger
static constexpr std::string_view Guard02
static constexpr std::string_view Guard01
static constexpr std::string_view Guard03
static constexpr std::string_view Guard04
std::vector< Vector3 > PointsArray
TriggerCastFlags TriggerFlags
void OnUpdate(uint32 diff) override
void OnCreatureCreate(Creature *creature) override
void OnAreaTriggerCreate(AreaTrigger *areaTrigger) override
void OnGameObjectCreate(GameObject *gameobject) override
arena_empyrean_domain(BattlegroundMap *map)
static void MovePlayerDown(Player *player)
void OnPlayerJoined(Player *player, bool) override