TrinityCore
Loading...
Searching...
No Matches
arena_hook_point.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 "Conversation.h"
21#include "Creature.h"
22#include "CreatureAI.h"
23#include "GameObject.h"
24#include "Map.h"
25#include "MotionMaster.h"
26#include "Player.h"
27#include "ScriptMgr.h"
28#include "SpellScript.h"
29#include "TaskScheduler.h"
30
31namespace HookPoint
32{
33 namespace Actions
34 {
35 static constexpr uint32 ReactionTrigger = 1;
36 static constexpr uint32 ReactionDead = 2;
37 static constexpr uint32 ReactionCheer = 3;
38 static constexpr uint32 PennyMove = 4;
39 }
40
41 namespace BouncerPaths
42 {
43 static constexpr uint64 Path1 = 14324500;
44 static constexpr uint64 Path2 = 14324501;
45 static constexpr uint64 Path3 = 14324502;
46 static constexpr uint64 Path4 = 14324503;
47 }
48
49 namespace Conversations
50 {
51 static constexpr uint32 Prepare = 9450;
52 }
53
54 namespace Creatures
55 {
56 static constexpr uint32 DanielPoole = 137530;
57 static constexpr uint32 Bouncer = 143245;
58 static constexpr uint32 Penny = 143121;
59 }
60
61 namespace GameObjects
62 {
63 static constexpr uint32 InvisWall = 296728;
64 static constexpr uint32 SlideDoor = 297144;
65 }
66
67 namespace MapIds
68 {
69 static constexpr uint32 HookPoint = 1825;
70 }
71
72 namespace Spells
73 {
74 static constexpr uint32 KulTirasArenaVOCooldownAura = 275002;
75 static constexpr uint32 ArenaReactionTrigger = 278776;
76 static constexpr uint32 KulTirasArenaCrowdCheers = 278937;
77 static constexpr uint32 ArenaLowHealthDyingTrigger = 279047;
78 static constexpr uint32 KulTirasArenaCrowdBoos = 278926;
79 }
80
81 namespace StringIds
82 {
83 static constexpr std::string_view Bouncer1 = "hook_point_bouncer_1"sv;
84 static constexpr std::string_view Bouncer2 = "hook_point_bouncer_2"sv;
85 static constexpr std::string_view Bouncer3 = "hook_point_bouncer_3"sv;
86 static constexpr std::string_view Bouncer4 = "hook_point_bouncer_4"sv;
87 }
88
89 namespace Texts
90 {
91 namespace DanielPoole
92 {
93 static constexpr uint8 Start = 0;
94 static constexpr uint8 ReactionLowHealth = 1;
95 static constexpr uint8 ReactionKill = 2;
96 }
97 }
98}
99
101{
103
104 void OnStart() override
105 {
106 for (ObjectGuid const& guid : _doorGUIDs)
107 {
108 if (GameObject* door = battlegroundMap->GetGameObject(guid))
109 {
110 door->UseDoorOrButton();
111 door->DespawnOrUnsummon(5s);
112 }
113 }
114
116 creature->AI()->Talk(HookPoint::Texts::DanielPoole::Start);
117
118 for (ObjectGuid const& guid : _bouncerGUIDs)
119 {
120 if (Creature* bouncer = battlegroundMap->GetCreature(guid))
121 {
122 bouncer->SetAIAnimKitId(0);
123 if (bouncer->HasStringId(HookPoint::StringIds::Bouncer1))
124 bouncer->GetMotionMaster()->MovePath(HookPoint::BouncerPaths::Path1, false, {}, {}, MovementWalkRunSpeedSelectionMode::Default, {}, {}, {}, true, false);
125 else if (bouncer->HasStringId(HookPoint::StringIds::Bouncer2))
126 {
127 bouncer->m_Events.AddEventAtOffset([bouncer]()
128 {
129 bouncer->GetMotionMaster()->MovePath(HookPoint::BouncerPaths::Path2, false, {}, {}, MovementWalkRunSpeedSelectionMode::Default, {}, {}, {}, true, false);
130 }, 500ms);
131 }
132 else if (bouncer->HasStringId(HookPoint::StringIds::Bouncer3))
133 bouncer->GetMotionMaster()->MovePath(HookPoint::BouncerPaths::Path3, false, {}, {}, MovementWalkRunSpeedSelectionMode::Default, {}, {}, {}, true, false);
134 else if (bouncer->HasStringId(HookPoint::StringIds::Bouncer4))
135 {
136 bouncer->m_Events.AddEventAtOffset([bouncer]()
137 {
138 bouncer->GetMotionMaster()->MovePath(HookPoint::BouncerPaths::Path4, false, {}, {}, MovementWalkRunSpeedSelectionMode::Default, {}, {}, {}, true, false);
139 }, 500ms);
140 }
141 }
142 }
143
145 {
146 creature->SetAIAnimKitId(0);
147 creature->AI()->DoAction(HookPoint::Actions::PennyMove);
148 }
149 }
150
151 void OnUpdate(uint32 diff) override
152 {
153 _scheduler.Update(diff);
154 }
155
156 void OnPrepareStage1() override
157 {
158 _scheduler.Schedule(20s, [&](TaskContext const&)
159 {
161 slideDoor->UseDoorOrButton();
162
165 });
166 }
167
168 void DoAction(uint32 actionId, WorldObject* source, WorldObject* target) override
169 {
170 switch (actionId)
171 {
174 break;
177 break;
180 break;
181 default:
182 break;
183 }
184 }
185
186 void OnCreatureCreate(Creature* creature) override
187 {
188 switch (creature->GetEntry())
189 {
191 _danielPooleGUID = creature->GetGUID();
192 break;
194 _bouncerGUIDs.emplace_back(creature->GetGUID());
195 break;
197 _pennyGUID = creature->GetGUID();
198 break;
199 default:
200 break;
201 }
202 }
203
204 void OnGameObjectCreate(GameObject* gameobject) override
205 {
206 switch (gameobject->GetEntry())
207 {
209 _doorGUIDs.emplace_back(gameobject->GetGUID());
210 break;
212 _slideDoorGUID = gameobject->GetGUID();
213 break;
214 default:
215 break;
216 }
217 }
218
225
226 void HandleKill(Player const* victim) const
227 {
228 if (!victim)
229 return;
230
232 {
234 return;
235
236 creature->AI()->Talk(HookPoint::Texts::DanielPoole::ReactionKill, victim);
237
240 });
241 }
242 }
243
244 void HandleReactionCheer(Player const* victim) const
245 {
246 if (!victim)
247 return;
248
249 Team const otherTeam = GetOtherTeam(victim->GetBGTeam());
250
252 {
253 if (player->GetBGTeam() == otherTeam)
254 {
255 player->CastSpell(nullptr, HookPoint::Spells::KulTirasArenaCrowdCheers, CastSpellExtraArgsInit{
256 .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR
257 });
258 }
259 });
260 }
261
262 void HandleReactionLowHealth(Player const* victim) const
263 {
264 if (!victim)
265 return;
266
267 Team const victimTeam = victim->GetBGTeam();
268 battlegroundMap->DoOnPlayers([&](Player* player)
269 {
270 if (player->GetBGTeam() == victimTeam)
271 {
272 player->CastSpell(nullptr, HookPoint::Spells::KulTirasArenaCrowdBoos, CastSpellExtraArgsInit{
273 .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR
274 });
275 }
276 });
277
278 if (Creature* creature = battlegroundMap->GetCreature(_danielPooleGUID))
279 {
281 return;
282
283 creature->AI()->Talk(HookPoint::Texts::DanielPoole::ReactionLowHealth, victim);
284
287 });
288 }
289 }
290
291private:
297
299};
300
301// 278775 - Arena Reaction Trigger - Low Health
303{
304 bool Load() override
305 {
307 }
308
309 bool Validate(SpellInfo const* /*spellInfo*/) override
310 {
312 }
313
314 void HandleHit(SpellEffIndex /*effIndex*/) const
315 {
316 Unit* target = GetHitUnit();
319 });
320
321 if (ZoneScript* zoneScript = target->FindZoneScript())
322 zoneScript->DoAction(HookPoint::Actions::ReactionCheer, GetCaster(), target);
323 }
324
329};
330
331// 278776 - Arena Reaction Trigger
333{
334 bool Load() override
335 {
337 }
338
339 void HandleProc(ProcEventInfo const& eventInfo) const
340 {
341 if (ZoneScript* zonescript = GetTarget()->FindZoneScript())
342 zonescript->DoAction(HookPoint::Actions::ReactionDead, eventInfo.GetActor(), eventInfo.GetProcTarget());
343 }
344
349};
350
351// 279047 - Arena Low Health Dying Trigger
353{
354 bool Load() override
355 {
357 }
358
359 bool Validate(SpellInfo const* /*spellInfo*/) override
360 {
362 }
363
364 void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) const
365 {
366 Unit* target = GetTarget();
367
368 if (ZoneScript* zoneScript = target->FindZoneScript())
369 zoneScript->DoAction(HookPoint::Actions::ReactionTrigger, GetCaster(), target);
370 }
371
376};
377
uint8_t uint8
Definition Define.h:156
uint64_t uint64
Definition Define.h:153
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
constexpr TeamId GetOtherTeam(TeamId team)
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PERIODIC_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_hook_point()
HookList< EffectApplyHandler > AfterEffectRemove
WorldObject * GetOwner() const
Unit * GetCaster() const
Unit * GetTarget() const
HookList< AuraProcHandler > OnProc
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
BattlegroundMap * battlegroundMap
static Conversation * CreateConversation(uint32 conversationEntry, Unit *creator, Position const &pos, ObjectGuid privateObjectOwner, SpellInfo const *spellInfo=nullptr, bool autoStart=true)
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
static ObjectGuid const Empty
Definition ObjectGuid.h:314
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)
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
Definition Unit.h:635
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 HandleRemove(AuraEffect const *, AuraEffectHandleModes) const
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void HandleProc(ProcEventInfo const &eventInfo) const
static constexpr uint32 ReactionTrigger
static constexpr uint32 ReactionDead
static constexpr uint32 ReactionCheer
static constexpr uint32 PennyMove
static constexpr uint64 Path4
static constexpr uint64 Path2
static constexpr uint64 Path3
static constexpr uint64 Path1
static constexpr uint32 Prepare
static constexpr uint32 Bouncer
static constexpr uint32 DanielPoole
static constexpr uint32 Penny
static constexpr uint32 SlideDoor
static constexpr uint32 InvisWall
static constexpr uint32 HookPoint
static constexpr uint32 ArenaLowHealthDyingTrigger
static constexpr uint32 KulTirasArenaVOCooldownAura
static constexpr uint32 KulTirasArenaCrowdCheers
static constexpr uint32 KulTirasArenaCrowdBoos
static constexpr uint32 ArenaReactionTrigger
static constexpr std::string_view Bouncer4
static constexpr std::string_view Bouncer2
static constexpr std::string_view Bouncer1
static constexpr std::string_view Bouncer3
static constexpr uint8 ReactionKill
static constexpr uint8 ReactionLowHealth
TriggerCastFlags TriggerFlags
void HandleReactionCheer(Player const *victim) const
void OnPrepareStage1() override
TaskScheduler _scheduler
void HandleKill(Player const *victim) const
void OnCreatureCreate(Creature *creature) override
void OnUpdate(uint32 diff) override
void OnGameObjectCreate(GameObject *gameobject) override
void OnStart() override
arena_hook_point(BattlegroundMap *map)
void OnPlayerJoined(Player *player, bool) override
void DoAction(uint32 actionId, WorldObject *source, WorldObject *target) override
void HandleReactionLowHealth(Player const *victim) const