TrinityCore
Loading...
Searching...
No Matches
arena_enigma_crucible.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 "Battleground.h"
19#include "BattlegroundScript.h"
20#include "ConditionMgr.h"
21#include "Containers.h"
22#include "Conversation.h"
23#include "Creature.h"
24#include "CreatureAI.h"
25#include "GameObject.h"
26#include "Map.h"
27#include "Player.h"
28#include "ScriptedCreature.h"
29#include "ScriptMgr.h"
30#include "SpellScript.h"
31
33{
34 namespace Actions
35 {
36 static constexpr uint32 ReactionTrigger = 1;
37 static constexpr uint32 ReactionDead = 2;
38 }
39
40 namespace Creatures
41 {
42 static constexpr uint32 ZoSorg = 188479;
43 }
44
45 namespace GameObjects
46 {
47 static constexpr uint32 Door01 = 376876;
48 static constexpr uint32 Door02 = 376861;
49 }
50
51 namespace MapIds
52 {
53 static constexpr uint32 EnigmaCrucible = 2547;
54 }
55
56 namespace Positions
57 {
58 static constexpr Position PurpleWarningTeleport = { 327.70486f, 278.69965f, 90.0686f, 3.1415927f };
59 static constexpr Position GoldWarningTeleport = { 201.601f, 268.516f, 90.0686f, 0.0f };
60 }
61
62 namespace Spells
63 {
64 static constexpr uint32 ArenaLowHealthCooldownAura = 234031;
65 static constexpr uint32 EnigmaArenaVOCooldownAura = 371330;
66 static constexpr uint32 EnigmaArenaReactionTrigger = 371601;
67 static constexpr uint32 Warning = 370437;
68 static constexpr uint32 WarningTeleport = 371319;
69 static constexpr uint32 ArenaStartingAreaMarker = 228212;
70 }
71
72 namespace Texts
73 {
74 namespace ZoSorg
75 {
76 static constexpr uint8 Prepare = 0;
77 static constexpr uint8 Prepare2 = 1;
78 static constexpr uint8 Start = 2;
79 static constexpr uint8 ReactionTrigger = 3;
80 }
81 }
82}
83
85{
87
88 void OnUpdate(uint32 diff) override
89 {
90 _scheduler.Update(diff);
91 }
92
93 void OnStart() override
94 {
95 for (ObjectGuid const& guid : _doorGUIDs)
96 {
97 if (GameObject* door = battlegroundMap->GetGameObject(guid))
98 {
99 door->UseDoorOrButton();
100 door->DespawnOrUnsummon(5s);
101 }
102 }
103
104 if (Creature const* creature = battlegroundMap->GetCreature(_zoSorgGUID))
105 creature->AI()->Talk(EnigmaCrucible::Texts::ZoSorg::Start);
106
107 _scheduler.Schedule(10s, [&](TaskContext& context)
108 {
110 {
112 return;
113
115 return;
116
119 });
120 });
121
122 context.Repeat();
123 });
124 }
125
126 void DoAction(uint32 actionId, WorldObject* source, WorldObject* target) override
127 {
128 switch (actionId)
129 {
132 break;
135 break;
136 default:
137 break;
138 }
139 }
140
141 void OnPrepareStage2() override
142 {
143 if (Creature const* creature = battlegroundMap->GetCreature(_zoSorgGUID))
144 creature->AI()->Talk(EnigmaCrucible::Texts::ZoSorg::Prepare);
145
146 _scheduler.Schedule(10s, [&](TaskContext const&)
147 {
148 if (Creature const* creature = battlegroundMap->GetCreature(_zoSorgGUID))
149 creature->AI()->Talk(EnigmaCrucible::Texts::ZoSorg::Prepare2);
150 });
151 }
152
153 void OnCreatureCreate(Creature* creature) override
154 {
155 switch (creature->GetEntry())
156 {
158 _zoSorgGUID = creature->GetGUID();
159 break;
160 default:
161 break;
162 }
163 }
164
165 void OnGameObjectCreate(GameObject* gameobject) override
166 {
167 switch (gameobject->GetEntry())
168 {
171 _doorGUIDs.emplace_back(gameobject->GetGUID());
172 break;
173 default:
174 break;
175 }
176 }
177
184
185 void HandleKill(Player const* victim) const
186 {
187 if (!victim)
188 return;
189
191 {
193 return;
194
195 creature->AI()->Talk(EnigmaCrucible::Texts::ZoSorg::ReactionTrigger, victim);
196
199 });
200 }
201 }
202
203 void HandleReactionLowHealth(Player const* victim) const
204 {
205 if (!victim)
206 return;
207
209 {
211 return;
212
213 creature->AI()->Talk(EnigmaCrucible::Texts::ZoSorg::ReactionTrigger, victim);
214
217 });
218 }
219 }
220
221private:
224
226};
227
228// 371602 - Enigma Arena Reaction Trigger - Low Health
255
256// 371601 - Enigma Arena Reaction Trigger
258{
259 bool Load() override
260 {
262 }
263
264 void HandleProc(ProcEventInfo const& eventInfo) const
265 {
266 if (ZoneScript* zonescript = GetTarget()->FindZoneScript())
267 zonescript->DoAction(EnigmaCrucible::Actions::ReactionDead, eventInfo.GetActor(), eventInfo.GetProcTarget());
268 }
269
274};
275
276// 370437 - Warning (countdown)
278{
279 bool Load() override
280 {
282 }
283
284 bool Validate(SpellInfo const* /*spellInfo*/) override
285 {
287 }
288
289 void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) const
290 {
291 Player* target = GetTarget()->ToPlayer();
292 if (!target)
293 return;
294
296 return;
297
300 });
301 }
302
307};
308
309// 371319 - Warning Teleport
311{
312 bool Load() override
313 {
315 }
316
317 void HandleTeleport(SpellEffIndex /*effIndex*/) const
318 {
319 Player* target = GetHitPlayer();
320 if (!target)
321 return;
322
323 if (target->GetBGTeam() == ALLIANCE)
325 else
327 }
328
333};
334
336{
337public:
338 condition_enigma_arena_collision_doors() : ConditionScript("condition_enigma_arena_collision_doors") {}
339
340 bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& sourceInfo) override
341 {
342 if (!sourceInfo.mConditionMap)
343 return false;
344
345 if (BattlegroundMap const* bgMap = sourceInfo.mConditionMap->ToBattlegroundMap())
346 if (Battleground const* bg = bgMap->GetBG())
347 if (bg->GetStatus() >= STATUS_IN_PROGRESS)
348 return bg->GetInProgressDuration() >= 15s;
349
350 return false;
351 }
352};
353
@ STATUS_IN_PROGRESS
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:434
Spells
Definition PlayerAI.cpp:32
#define RegisterBattlegroundMapScript(script_name, mapId)
Definition ScriptMgr.h:1447
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ ALLIANCE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ 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.
#define AuraProcFn(F)
#define SpellEffectFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
Creatures
void AddSC_arena_enigma_crucible()
WorldObject * GetOwner() const
Unit * GetTarget() const
HookList< EffectApplyHandler > OnEffectRemove
HookList< AuraProcHandler > OnProc
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
BattlegroundMap * battlegroundMap
void DoOnPlayers(T &&fn)
Definition Map.h:406
BattlegroundMap * ToBattlegroundMap()
Definition Map.h:493
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3552
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
Player * ToPlayer()
Definition Object.h:126
uint32 GetEntry() const
Definition Object.h:89
Team GetBGTeam() const
Definition Player.cpp:24358
Unit * GetProcTarget() const
Definition Unit.h:501
Unit * GetActor() const
Definition Unit.h:499
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Player * GetHitPlayer() const
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
Definition Unit.h:635
void NearTeleportTo(TeleportLocation const &target, bool casting=false)
Definition Unit.cpp:12958
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
constexpr uint32 GetMapId() const
Definition Position.h:216
ZoneScript * FindZoneScript() const
Definition Object.cpp:1365
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
bool OnConditionCheck(Condition const *, ConditionSourceInfo &sourceInfo) override
void HandleProc(ProcEventInfo const &eventInfo) const
bool Validate(SpellInfo const *) override
void HandleRemove(AuraEffect const *, AuraEffectHandleModes) const
static constexpr uint32 ReactionDead
static constexpr uint32 ReactionTrigger
static constexpr uint32 ZoSorg
static constexpr uint32 EnigmaCrucible
static constexpr Position GoldWarningTeleport
static constexpr Position PurpleWarningTeleport
static constexpr uint32 EnigmaArenaReactionTrigger
static constexpr uint32 WarningTeleport
static constexpr uint32 Warning
static constexpr uint32 ArenaLowHealthCooldownAura
static constexpr uint32 ArenaStartingAreaMarker
static constexpr uint32 EnigmaArenaVOCooldownAura
TriggerCastFlags TriggerFlags
Map const * mConditionMap
void HandleReactionLowHealth(Player const *victim) const
void HandleKill(Player const *victim) const
void OnUpdate(uint32 diff) override
void OnCreatureCreate(Creature *creature) override
void OnGameObjectCreate(GameObject *gameobject) override
void OnPlayerJoined(Player *player, bool) override
void DoAction(uint32 actionId, WorldObject *source, WorldObject *target) override
arena_enigma_crucible(BattlegroundMap *map)