TrinityCore
Loading...
Searching...
No Matches
zone_the_jade_forest.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 "DB2Stores.h"
19#include "Map.h"
20#include "MotionMaster.h"
21#include "PhasingHandler.h"
22#include "Player.h"
23#include "ScriptMgr.h"
24#include "ScriptedCreature.h"
25#include "Spell.h"
26#include "SpellAuraEffects.h"
27#include "SpellScript.h"
28#include "TemporarySummon.h"
29#include "Unit.h"
30#include "Vehicle.h"
31
33{
34namespace Points
35{
36 static constexpr uint32 RappellingRopeDestination = 1;
37}
38
39namespace Positions
40{
41 static constexpr std::array<Position, 3> RappellingRopeSpawns =
42 {{
43 { 3133.9192f, -750.8542f, 298.9847f },
44 { 3156.4932f, -742.7101f, 297.54916f },
45 { 3169.0479f, -737.92017f, 298.42493f }
46 }};
47
48 static constexpr std::array<Position, 3> RappellingRopeDestinations =
49 {{
50 { 3133.9475f, -749.46844f, 240.00467f },
51 { 3156.2786f, -742.8666f, 239.32095f },
52 { 3168.5525f, -738.01764f, 240.19081f }
53 }};
54}
55
56namespace Quests
57{
58 static constexpr uint32 PaintItRed = 31765;
59}
60
61namespace Spells
62{
63 // Into the Mists & The Mission
64 static constexpr uint32 CancelBlackout = 130812;
65 static constexpr uint32 CutToBlack = 122343;
66
67 // Into the Mists
68 static constexpr uint32 TeleportPrepHorde = 130810;
69 static constexpr uint32 TeleportPlayerToCrashSite = 102930;
70 static constexpr uint32 WakeUpDead = 122344;
71
72 // The Mission
73 static constexpr uint32 TeleportPrepAlliance = 130832;
74 static constexpr uint32 TheMissionTeleportPlayer = 130321;
75 static constexpr uint32 TheMissionSceneJF = 131057;
76
77 // Paint it Red!
78 static constexpr uint32 AbandonVehicle = 92678;
79 static constexpr uint32 CannonExplosionTrigger = 130234;
80 static constexpr uint32 BarrelExplosionTrigger = 130247;
81
82 // Touching Ground
83 static constexpr uint32 ReverseCastRideSeat1 = 85299;
84 static constexpr uint32 RappellingRope = 130960;
85}
86
87// 121545 - Into the Mists Scene - JF
89{
90 bool Validate(SpellInfo const* /*spellInfo*/) override
91 {
92 return ValidateSpellInfo({
94 });
95 }
96
97 void HandleHitTarget(SpellEffIndex /*effIndex*/) const
98 {
99 Unit* hitUnit = GetHitUnit();
100
101 hitUnit->CancelMountAura();
104 .TriggeringSpell = GetSpell()
105 });
106 }
107
112};
113
114// 130723 - Into the Mists Scene End
116{
117 bool Validate(SpellInfo const* /*spellInfo*/) override
118 {
119 return ValidateSpellInfo({
123 });
124 }
125
126 void HandleHitTarget(SpellEffIndex /*effIndex*/) const
127 {
128 Unit* hitUnit = GetHitUnit();
129
130 CastSpellExtraArgs const& castSpellExtraArgs = CastSpellExtraArgsInit{
132 .TriggeringSpell = GetSpell()
133 };
134 hitUnit->CastSpell(nullptr, Spells::TeleportPlayerToCrashSite, castSpellExtraArgs);
135 hitUnit->CastSpell(nullptr, Spells::CutToBlack, castSpellExtraArgs);
136 hitUnit->CastSpell(nullptr, Spells::WakeUpDead, castSpellExtraArgs);
137 }
138
143};
144
145// 131057 - The Mission Scene - JF
147{
148 bool Validate(SpellInfo const* /*spellInfo*/) override
149 {
150 return ValidateSpellInfo({
152 });
153 }
154
155 void HandleHitTarget(SpellEffIndex /*effIndex*/) const
156 {
157 Unit* hitUnit = GetHitUnit();
158
159 hitUnit->CancelMountAura();
162 .TriggeringSpell = GetSpell()
163 });
164 }
165
170};
171
172// 131059 - The Mission Scene End
174{
175 bool Validate(SpellInfo const* /*spellInfo*/) override
176 {
177 return ValidateSpellInfo({
181 });
182 }
183
184 void HandleHitTarget(SpellEffIndex /*effIndex*/) const
185 {
186 Unit* hitUnit = GetHitUnit();
187
188 // EFFECT_0 is incorrectly removing Horde aura
190
191 CastSpellExtraArgs const& castSpellExtraArgs = CastSpellExtraArgsInit{
193 .TriggeringSpell = GetSpell()
194 };
195 hitUnit->CastSpell(nullptr, Spells::TheMissionTeleportPlayer, castSpellExtraArgs);
196 hitUnit->CastSpell(nullptr, Spells::CutToBlack, castSpellExtraArgs);
197 }
198
203};
204
205// 130812 - Cancel Blackout
227
228// 130996 - Summon Gunship Turret, Left
229// 130997 - Summon Gunship Turret, Middle
230// 130998 - Summon Gunship Turret, Right
232{
233 bool Validate(SpellInfo const* /*spellInfo*/) override
234 {
235 return ValidateSpellInfo({
237 });
238 }
239
240 void OnPeriodic(AuraEffect const* /*aurEff*/) const
241 {
242 if (Player* playerTarget = GetTarget()->ToPlayer())
243 if (playerTarget->GetQuestStatus(Quests::PaintItRed) == QUEST_STATUS_COMPLETE)
244 playerTarget->CastSpell(nullptr, Spells::AbandonVehicle, CastSpellExtraArgsInit{
246 });
247 }
248
249 void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) const
250 {
252 }
253
259};
260
261// 130233 - Cannon Explosion Reversecast
283
284// 130246 - Barrel Explosion Reversecast
306
307// 66640 - Rappelling Rope
309{
310 npc_rappelling_rope(Creature* creature) : ScriptedAI(creature) {}
311
312 void PassengerBoarded(Unit* passenger, int8 /*seatId*/, bool apply) override
313 {
314 if (apply)
315 {
316 passenger->SetDisableGravity(true);
317 _scheduler.Schedule(1500ms, [this](TaskContext const& /*context*/)
318 {
319 auto closestPosition = std::ranges::min_element(Positions::RappellingRopeDestinations, std::ranges::less(),
320 [this](Position const& pos) { return me->GetDistance(pos); });
321
323 });
324 }
325 else
326 passenger->SetDisableGravity(false);
327 }
328
329 void MovementInform(uint32 type, uint32 id) override
330 {
332 {
333 if (Vehicle* vehicle = me->GetVehicleKit())
334 vehicle->RemoveAllPassengers();
335
337 }
338 }
339
340 void UpdateAI(uint32 diff) override
341 {
342 _scheduler.Update(diff);
343 }
344
345private:
347};
348
349// 130960 - Rappelling Rope
351{
352 bool Validate(SpellInfo const* /*spellInfo*/) override
353 {
354 return ValidateSpellInfo({
356 });
357 }
358
360 {
361 PreventHitDefaultEffect(effIndex);
362
363 Unit* caster = GetCaster();
364 uint32 creatureId = uint32(GetEffectInfo().MiscValue);
365 SummonPropertiesEntry const* summonProperties = sSummonPropertiesStore.LookupEntry(uint32(GetEffectInfo().MiscValueB));
366 Milliseconds duration = Milliseconds(GetSpellInfo()->CalcDuration(caster));
367 auto closestPosition = std::ranges::min_element(Positions::RappellingRopeSpawns, std::ranges::less(),
368 [caster](Position const& pos) { return caster->GetDistance(pos); });
369
370 if (Creature* rappellingRope = caster->GetMap()->SummonCreature(creatureId, *closestPosition, summonProperties, duration, caster, GetSpellInfo()->Id))
371 {
372 if (TempSummon* summon = rappellingRope->ToTempSummon())
373 summon->SetCanFollowOwner(false);
374
375 rappellingRope->CastSpell(caster, Spells::ReverseCastRideSeat1, CastSpellExtraArgsInit{
377 .TriggeringSpell = GetSpell()
378 });
379 }
380 }
381
386};
387
388// 130970 - Rappelling Rope Aura
408}
409
DB2Storage< SummonPropertiesEntry > sSummonPropertiesStore("SummonProperties.db2", &SummonPropertiesLoadInfo::Instance)
int8_t int8
Definition Define.h:152
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ POINT_MOTION_TYPE
Spells
Definition PlayerAI.cpp:32
@ QUEST_STATUS_COMPLETE
Definition QuestDef.h:148
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_3
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_SUMMON
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ 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 SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
Creature *const me
Definition CreatureAI.h:63
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, Milliseconds duration=0ms, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
Definition Object.cpp:1186
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
static bool OnConditionChange(WorldObject *object, bool updateVisibility=true)
void HandleAfterEffectRemove(AuraEffect const *, AuraEffectHandleModes) const
void HandleAfterEffectRemove(AuraEffect const *, AuraEffectHandleModes) const
void AfterApply(AuraEffect const *, AuraEffectHandleModes) const
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
Spell * GetSpell() const
HookList< EffectHandler > OnEffectLaunch
SpellInfo const * GetSpellInfo() const
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
Definition Unit.h:635
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
TempSummon * ToTempSummon()
Definition Unit.h:1828
bool SetDisableGravity(bool disable, bool updateAnimTier=true)
Definition Unit.cpp:13361
void CancelMountAura(bool force=false)
Definition Unit.cpp:8350
Vehicle * GetVehicleKit() const
Definition Unit.h:1782
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
Map * GetMap() const
Definition Object.h:411
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:432
static constexpr std::array< Position, 3 > RappellingRopeSpawns
static constexpr std::array< Position, 3 > RappellingRopeDestinations
TriggerCastFlags TriggerFlags
void PassengerBoarded(Unit *passenger, int8, bool apply) override
== Fields =======================================
void AddSC_zone_the_jade_forest()