TrinityCore
Loading...
Searching...
No Matches
boss_sporecaller_zancha.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 "AreaTriggerAI.h"
20#include "CellImpl.h"
21#include "Containers.h"
22#include "Conversation.h"
23#include "Creature.h"
24#include "GridNotifiersImpl.h"
25#include "InstanceScript.h"
26#include "ObjectAccessor.h"
27#include "PathGenerator.h"
28#include "ScriptMgr.h"
29#include "ScriptedCreature.h"
30#include "SpellAuraEffects.h"
31#include "SpellAuras.h"
32#include "SpellMgr.h"
33#include "SpellScript.h"
34#include "underrot.h"
35
63
75
88
95
100
105
110
111// 131383 - Sporecaller Zancha
113{
115
122
123 void KilledUnit(Unit* victim) override
124 {
125 if (!victim->IsPlayer())
126 return;
127
128 Talk(SAY_KILL);
129 }
130
131 void JustDied(Unit* /*killer*/) override
132 {
133 _JustDied();
135
137 }
138
139 void Reset() override
140 {
141 _Reset();
142
143 _shockwaveCount = 1;
144 _upheavalCount = 1;
146 }
147
157
181
182 void DoAction(int32 action) override
183 {
184 if (action != ACTION_INTRO)
185 return;
186
187 for (ObjectGuid summonGUID : summons)
188 {
189 if (Creature* defiler = ObjectAccessor::GetCreature(*me, summonGUID))
190 {
191 defiler->KillSelf();
192 defiler->DespawnOrUnsummon(20s);
193 }
194 }
196 }
197
198 void UpdateAI(uint32 diff) override
199 {
200 if (!UpdateVictim())
201 return;
202
203 events.Update(diff);
204
206 return;
207
208 switch (events.ExecuteEvent())
209 {
211 {
212 if (me->GetPower(POWER_ENERGY) >= 100)
213 {
218 }
219 events.Repeat(500ms);
220 break;
221 }
222 case EVENT_SHOCKWAVE:
223 {
227 {
228 if (_shockwaveCount == 2)
229 events.Repeat(14600ms);
230 else if (_shockwaveCount == 3)
231 events.Repeat(45100ms);
232 else if (_shockwaveCount % 2 == 0)
233 events.Repeat(20700ms);
234 else
235 events.Repeat(30400ms);
236 }
237 else
238 {
239 if (_shockwaveCount == 2)
240 events.Repeat(14600ms);
241 else if (_shockwaveCount == 4)
242 events.Repeat(30400ms);
243 else if (_shockwaveCount % 2 == 0)
244 events.Repeat(40100ms);
245 else
246 events.Repeat(15800ms);
247 }
248 break;
249 }
250 case EVENT_UPHEAVAL:
251 {
255 {
256 if (_upheavalCount == 3)
257 events.Repeat(24300ms);
258 else if (_upheavalCount % 2 == 0)
259 events.Repeat(20700ms);
260 else
261 events.Repeat(30400ms);
262 }
263 else
264 {
265 if (_upheavalCount == 3)
266 events.Repeat(30400ms);
267 else if (_upheavalCount % 3 == 0)
268 events.Repeat(24300ms);
269 else
270 events.Repeat(15800ms);
271 }
272 break;
273 }
275 {
278 if (_volatilePodsCount == 4)
279 events.Repeat(27900ms);
280 else
281 events.Repeat(25500ms);
282 break;
283 }
285 {
287 break;
288 }
289 default:
290 break;
291 }
292 }
293
294private:
298};
299
300// 138740 - Musashitake
302{
304
305 void JustAppeared() override
306 {
308 }
309
325
326 void UpdateAI(uint32 diff) override
327 {
328 if (!UpdateVictim())
329 return;
330
331 _events.Update(diff);
332
334 return;
335
336 switch (_events.ExecuteEvent())
337 {
338 case EVENT_TELEPORT:
339 {
342 _events.Repeat(20s);
343 break;
344 }
345 default:
346 break;
347 }
348 }
349
350private:
352};
353
354// 259717 - Upheaval
356{
357 bool Validate(SpellInfo const* /*spellInfo*/) override
358 {
360 }
361
362 void HandleHitTarget(SpellEffIndex /*effIndex*/) const
363 {
364 if (Creature* creatureCaster = GetCaster()->ToCreature())
365 {
366 creatureCaster->CastSpell(GetHitUnit(), SPELL_UPHEAVAL_AURA, CastSpellExtraArgsInit{
368 .TriggeringSpell = GetSpell()
369 });
370 creatureCaster->AI()->Talk(SAY_UPHEAVAL, GetHitUnit());
371 }
372 }
373
378};
379
380// 259718 - Upheaval
382{
383 bool Validate(SpellInfo const* /*spellInfo*/) override
384 {
386 }
387
388 void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) const
389 {
390 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
391 return;
392
393 Unit* target = GetTarget();
396 .TriggeringAura = aurEff
397 });
398 }
399
404};
405
406// 272511 - Upheaval
424
425// 259888 - Festering Harvest
427{
428 static constexpr std::array<uint8, 5> SporecallerEnergizeCycle = { 2, 2, 2, 2, 3 };
429
430 void PeriodicTick(AuraEffect const* aurEff) const
431 {
432 uint8 cycleIdx = aurEff->GetTickNumber() % SporecallerEnergizeCycle.size();
434 }
435
440};
441
442// 259732 - Festering Harvest
444{
445 bool Validate(SpellInfo const* /*spellInfo*/) override
446 {
448 }
449
450 void OnPrecast() override
451 {
452 std::list<Creature*> sporePods;
455 Cell::VisitAllObjects(GetCaster(), searcher, 200.0f);
456
457 if (sporePods.empty())
458 return;
459
460 for (Creature* spore : sporePods)
461 {
462 spore->CastSpell(spore, SPELL_SPORE_POD_BEAM, CastSpellExtraArgsInit{
464 .TriggeringSpell = GetSpell()
465 });
466 }
467 }
468
469 void Register() override { }
470};
471
472// 259845 - Boundless Rot
474{
475 static constexpr Position CenterPosition = { 1032.9444f, 1058.2899f, 33.330894f };
476
477 static void SetDest(SpellScript const&, SpellDestination& dest)
478 {
480 }
481
486};
487
488// 273271 - Volatile Pods
490{
491 void HandleHitTarget(SpellEffIndex /*effIndex*/) const
492 {
493 if (Creature* creatureCaster = GetCaster()->ToCreature())
494 creatureCaster->SummonCreatureGroup(SUMMON_GROUP_VOLATILE_PODS);
495 }
496
501};
502
503// 273285 - Volatile Pods
505{
506 static constexpr uint8 MAX_VOLATILE_PODS = 6;
507
508 void HandleHitTarget(SpellEffIndex /*effIndex*/) const
509 {
510 Unit* target = GetHitUnit();
511
512 for (uint8 i = 0; i < MAX_VOLATILE_PODS; ++i)
513 {
514 float angle = target->GetOrientation() + float(M_PI) / 6.0f + i * float(M_PI) / 3.0f;
515 Position dest(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), angle);
518 .TriggeringSpell = GetSpell()
519 });
520 }
521 }
522
527};
528
529// 272786 - Teleport Behind You
550
551// 272787 - Teleport
572
573// 259727 - Boundless Rot
574// ID - 12266
576{
578
579 void OnUnitEnter(Unit* unit) override
580 {
581 Player* player = unit->ToPlayer();
582 if (!player || player->IsGameMaster())
583 return;
584
585 Unit* caster = at->GetCaster();
586 if (!caster)
587 return;
588
590
591 if (Creature* creatureCaster = caster->ToCreature())
592 creatureCaster->DespawnOrUnsummon();
593 }
594};
595
596// 273300 - Volatile Pods
597// ID - 13726
599{
601
602 void OnInitialize() override
603 {
604 Position destPos = at->GetPosition();
605 at->MovePositionToFirstCollision(destPos, 200.0f, 0.0f);
606
607 PathGenerator path(at);
608 path.CalculatePath(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ(), true);
609
610 at->InitSplines(path.GetPath());
611 }
612
613 void OnDestinationReached() override
614 {
615 at->Remove();
616 }
617
618 void OnUnitEnter(Unit* unit) override
619 {
620 if (!unit->IsPlayer())
621 return;
622
623 Unit* caster = at->GetCaster();
624 if (!caster)
625 return;
626
628 }
629};
630
631// Id 100 - Areatrigger
633{
635
636 void OnCreate(Spell const* /*creatingSpell*/) override
637 {
638 InstanceScript* instance = at->GetInstanceScript();
639 if (!instance)
640 return;
641
642 if (Creature* zancha = instance->GetCreature(DATA_SPORECALLER_ZANCHA))
643 {
644 if (zancha->IsAlive())
645 zancha->SummonCreatureGroup(SUMMON_GROUP_ZANCHA_INTRO);
646 }
647 }
648
649 void OnUnitEnter(Unit* unit) override
650 {
651 Player* player = unit->ToPlayer();
652 if (!player || player->IsGameMaster())
653 return;
654
655 InstanceScript* instance = at->GetInstanceScript();
656 if (!instance)
657 return;
658
659 Creature* zancha = instance->GetCreature(DATA_SPORECALLER_ZANCHA);
660 if (!zancha || !zancha->IsAlive())
661 return;
662
663 zancha->AI()->DoAction(ACTION_INTRO);
664 zancha->CastSpell(unit, SPELL_BOSS_3_INTRO);
665
666 at->Remove();
667 }
668};
669
#define M_PI
Definition Common.h:118
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ TARGET_DEST_DEST
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_TELEPORT_UNITS
@ POWER_ENERGY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_EXPIRE
@ 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.
@ TRIGGERED_IGNORE_CAST_TIME
Will always be instantly cast.
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellDestinationTargetSelectFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ UNIT_FLAG2_UNTARGETABLE_BY_CLIENT
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ SAY_FESTERING_HARVEST
@ SPELL_FESTERING_HARVEST_DAMAGE
@ SPELL_UPHEAVAL_SCRIPT_EFFECT
@ SPELL_UPHEAVAL_SELECTOR
@ SPELL_THOUSAND_FOLD_BLADE
@ SPELL_DECAYING_SPORES
@ SPELL_UPHEAVAL_MISSILE
@ SPELL_VOLATILE_PODS_AREATRIGGER
@ SPELL_VOLATILE_PODS_VISUAL
@ SPELL_TELEPORT_BEHIND_YOU_SELECTOR
@ SPELL_ACHIEVEMENT_VISUAL
@ SPELL_FESTERING_HARVEST
@ SPELL_UPHEAVAL_DAMAGE
void AddSC_boss_sporecaller_zancha()
SporecallerZanchaSummonGroups
@ SUMMON_GROUP_VOLATILE_PODS
@ SUMMON_GROUP_MUSASHITAKE
@ SUMMON_GROUP_ZANCHA_INTRO
AreaTrigger *const at
AreaTriggerAI(AreaTrigger *a, uint32 scriptId={}) noexcept
void InitSplines(std::vector< G3D::Vector3 > const &splinePoints, Optional< float > overrideSpeed={}, Optional< bool > speedIsTimeInSeconds={})
Unit * GetCaster() const
uint32 GetTickNumber() const
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
bool IsPlayer() const
Definition BaseEntity.h:173
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
static Conversation * CreateConversation(uint32 conversationEntry, Unit *creator, Position const &pos, ObjectGuid privateObjectOwner, SpellInfo const *spellInfo=nullptr, bool autoStart=true)
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
bool HasReactState(ReactStates state) const
Definition Creature.h:176
void SetReactState(ReactStates st)
Definition Creature.h:174
CreatureAI * AI() const
Definition Creature.h:228
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:56
Creature * GetCreature(uint32 type)
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
static ObjectGuid const Empty
Definition ObjectGuid.h:314
Player * ToPlayer()
Definition Object.h:126
Creature * ToCreature()
Definition Object.h:121
Movement::PointsArray const & GetPath() const
bool CalculatePath(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, bool forceDest=false)
bool IsGameMaster() const
Definition Player.h:1309
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Spell * GetSpell() const
Definition Spell.h:277
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void DoAction(int32 param)
Definition UnitAI.h:73
Definition Unit.h:635
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:8697
void SetPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:10046
bool IsAlive() const
Definition Unit.h:1185
void SetUninteractible(bool apply)
Definition Unit.cpp:8564
void RemoveUnitFlag2(UnitFlags2 flags)
Definition Unit.h:852
int32 GetPower(Powers power) const
Definition Unit.cpp:10028
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
void SetPowerType(Powers power, bool sendUpdate=true, bool onInit=false)
Definition Unit.cpp:5697
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
void MovePositionToFirstCollision(Position &pos, float dist, float angle) const
Definition Object.cpp:2828
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:1507
static void SetDest(SpellScript const &, SpellDestination &dest)
void PeriodicTick(AuraEffect const *aurEff) const
static constexpr std::array< uint8, 5 > SporecallerEnergizeCycle
void OnRemove(AuraEffect const *aurEff, AuraEffectHandleModes) const
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
TriggerCastFlags TriggerFlags
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:203
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
constexpr float GetOrientation() const
Definition Position.h:90
constexpr float GetPositionZ() const
Definition Position.h:89
bool IsMythicPlus() const
bool IsHeroicOrHigher() const
void Relocate(Position const &pos)
Definition Spell.cpp:82
void OnCreate(Spell const *) override
void OnUnitEnter(Unit *unit) override
boss_sporecaller_zancha(Creature *creature)
void JustEngagedWith(Unit *who) override
void EnterEvadeMode(EvadeReason) override
void DoAction(int32 action) override
void KilledUnit(Unit *victim) override
void UpdateAI(uint32 diff) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
@ DATA_SPORECALLER_ZANCHA
Definition underrot.h:32
#define RegisterUnderrotCreatureAI(ai_name)
Definition underrot.h:60