TrinityCore
Loading...
Searching...
No Matches
arena_cage_of_carnage.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 "Creature.h"
21#include "CreatureAI.h"
22#include "GameObject.h"
23#include "Map.h"
24#include "Player.h"
25#include "ScriptMgr.h"
26#include "SpellScript.h"
27#include "TaskScheduler.h"
28
30{
31 namespace Actions
32 {
33 static constexpr uint32 ReactionTrigger = 1;
34 static constexpr uint32 ReactionDead = 2;
35 }
36
37 namespace Creatures
38 {
39 static constexpr uint32 NaminzeBoltfingers = 232750;
40 }
41
42 namespace GameObjects
43 {
44 static constexpr uint32 GoblinArenaTrapDoor01 = 505683;
45 }
46
47 namespace MapIds
48 {
49 static constexpr uint32 CageOfCarnage = 2759;
50 }
51
52 namespace Positions
53 {
54 static constexpr Position PurpleWarningTeleport = { 442.311f, 343.167f, -34.1166f, 1.7453293f };
55 static constexpr Position GoldWarningTeleport = { 443.167f, 439.243f, -42.6562f, 4.5902157f };
56 }
57
58 namespace Spells
59 {
60 static constexpr uint32 UndermineArenaVOCooldownAura = 472905;
62 static constexpr uint32 UndermineArenaReactionTrigger = 472885;
63 static constexpr uint32 ArenaLowHealthCooldownAura = 234031;
64 static constexpr uint32 Warning = 1214676;
65 static constexpr uint32 WarningTeleport = 371319;
66 static constexpr uint32 ArenaStartingAreaMarker = 228212;
67 }
68
69 namespace Texts
70 {
71 namespace Naminze
72 {
73 static constexpr uint8 Prepare = 0;
74 static constexpr uint8 Start = 1;
75 static constexpr uint8 ReactionAlmostDead = 2;
76 static constexpr uint8 ReactionKill = 3;
77 }
78 }
79}
80
82{
84
85 void OnUpdate(uint32 diff) override
86 {
87 _scheduler.Update(diff);
88 }
89
90 void OnStart() override
91 {
92 for (ObjectGuid const& guid : _doorGUIDs)
93 {
94 if (GameObject* door = battlegroundMap->GetGameObject(guid))
95 {
96 door->UseDoorOrButton();
97 door->DespawnOrUnsummon(5s);
98 }
99 }
100
101 if (Creature const* creature = battlegroundMap->GetCreature(_naminzeGUID))
102 creature->AI()->Talk(CageOfCarnage::Texts::Naminze::Start);
103
104 _scheduler.Schedule(5s, [&](TaskContext& context)
105 {
107 {
109 return;
110
112 return;
113
116 });
117 });
118
119 context.Repeat();
120 });
121 }
122
123 void DoAction(uint32 actionId, WorldObject* source, WorldObject* target) override
124 {
125 switch (actionId)
126 {
129 break;
132 break;
133 default:
134 break;
135 }
136 }
137
138 void OnPrepareStage2() override
139 {
140 if (Creature const* creature = battlegroundMap->GetCreature(_naminzeGUID))
141 creature->AI()->Talk(CageOfCarnage::Texts::Naminze::Prepare);
142 }
143
144 void OnCreatureCreate(Creature* creature) override
145 {
146 switch (creature->GetEntry())
147 {
149 _naminzeGUID = creature->GetGUID();
150 break;
151 default:
152 break;
153 }
154 }
155
156 void OnGameObjectCreate(GameObject* gameobject) override
157 {
158 switch (gameobject->GetEntry())
159 {
161 _doorGUIDs.emplace_back(gameobject->GetGUID());
162 break;
163 default:
164 break;
165 }
166 }
167
174
175 void HandleKill(Player const* victim) const
176 {
177 if (!victim)
178 return;
179
181 {
183 return;
184
185 creature->AI()->Talk(CageOfCarnage::Texts::Naminze::ReactionKill, victim);
186
189 });
190 }
191 }
192
193 void HandleReactionLowHealth(Player const* victim) const
194 {
195 if (!victim)
196 return;
197
199 {
201 return;
202
203 creature->AI()->Talk(CageOfCarnage::Texts::Naminze::ReactionAlmostDead, victim);
204
207 });
208 }
209 }
210
211private:
214
216};
217
218// 472883 - Undermine Arena Reaction Trigger - Low Health
245
246// 472885 - Undermine Arena Reaction Trigger
248{
249 bool Load() override
250 {
252 }
253
254 void HandleProc(ProcEventInfo const& eventInfo) const
255 {
256 if (ZoneScript* zonescript = GetTarget()->FindZoneScript())
257 zonescript->DoAction(CageOfCarnage::Actions::ReactionDead, eventInfo.GetActor(), eventInfo.GetProcTarget());
258 }
259
264};
265
266// 1214676 - Warning (countdown)
298
299// 371319 - Warning Teleport
301{
302 bool Load() override
303 {
305 }
306
307 void HandleTeleport(SpellEffIndex /*effIndex*/) const
308 {
309 Player* target = GetHitPlayer();
310 if (!target)
311 return;
312
313 if (target->GetBGTeam() == ALLIANCE)
315 else
317 }
318
323};
324
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_cage_of_carnage()
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
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
void HandleProc(ProcEventInfo const &eventInfo) const
bool Validate(SpellInfo const *) override
void HandleRemove(AuraEffect const *, AuraEffectHandleModes) const
static constexpr uint32 ReactionTrigger
static constexpr uint32 ReactionDead
static constexpr uint32 NaminzeBoltfingers
static constexpr uint32 GoblinArenaTrapDoor01
static constexpr uint32 CageOfCarnage
static constexpr Position GoldWarningTeleport
static constexpr Position PurpleWarningTeleport
static constexpr uint32 WarningTeleport
static constexpr uint32 UndermineArenaVOCooldownAuraPlayerDeath
static constexpr uint32 Warning
static constexpr uint32 UndermineArenaVOCooldownAura
static constexpr uint32 ArenaStartingAreaMarker
static constexpr uint32 ArenaLowHealthCooldownAura
static constexpr uint32 UndermineArenaReactionTrigger
static constexpr uint8 ReactionAlmostDead
TriggerCastFlags TriggerFlags
void OnPlayerJoined(Player *player, bool) override
void OnUpdate(uint32 diff) override
void DoAction(uint32 actionId, WorldObject *source, WorldObject *target) override
void OnGameObjectCreate(GameObject *gameobject) override
void OnCreatureCreate(Creature *creature) override
void HandleKill(Player const *victim) const
arena_cage_of_carnage(BattlegroundMap *map)
void HandleReactionLowHealth(Player const *victim) const