TrinityCore
Loading...
Searching...
No Matches
boss_astromancer.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/*
19 * Combat timers requires to be revisited
20 * Everything related to split requires sniff verification, maybe something is missing or implemented wrongly
21 * Solarian should have big aggro radius
22 * Can transition start while in split phase? What should happen? Currently prevented
23 * Boss does arcane melee damage, is this correct?
24 */
25
26#include "ScriptMgr.h"
27#include "Containers.h"
28#include "InstanceScript.h"
29#include "ObjectAccessor.h"
30#include "ScriptedCreature.h"
31#include "SpellAuras.h"
32#include "SpellInfo.h"
33#include "SpellScript.h"
34#include "the_eye.h"
35
45
81
105
107{
109 VOIDWALKER_ARMOR = 31000
111
119
127
135
142
143// 18805 - High Astromancer Solarian
145{
147 _defaultArmor(creature->GetArmor()), _isSecondPhaseStarted(false), _isSplitInProgress(false) { }
148
149 void Reset() override
150 {
151 _Reset();
152
154 me->SetVisible(true);
156
159 me->SetRegenerateHealth(false);
160 me->SetFullHealth();
161
162 _spotlightsGuidVector.clear();
163 _isSecondPhaseStarted = false;
164 _isSplitInProgress = false;
165 }
166
180
181 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
182 {
184 {
187
192 }
193 }
194
195 void JustSummoned(Creature* summon) override
196 {
197 // Do not engage summons
198 summons.Summon(summon);
199
200 if (summon->GetEntry() == NPC_SPOTLIGHT)
201 _spotlightsGuidVector.push_back(summon->GetGUID());
202 }
203
204 void KilledUnit(Unit* /*victim*/) override
205 {
206 Talk(SAY_SLAY);
207 }
208
209 void JustDied(Unit* /*killer*/) override
210 {
212 _JustDied();
213
215 }
216
217 void UpdateAI(uint32 diff) override
218 {
219 if (!UpdateVictim())
220 return;
221
222 events.Update(diff);
223
225 return;
226
227 while (uint32 eventId = events.ExecuteEvent())
228 {
229 switch (eventId)
230 {
231 // Phase 1 (Looks like combat timers keep tick while in split phase, boss just doesn't cast spells)
236 events.Repeat(3600ms);
237 break;
241 events.Repeat(30s);
242 break;
245 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
247 events.Repeat(10s, 20s);
248 break;
249
250 // Split
251 case EVENT_SPLIT_1:
252 _isSplitInProgress = true;
256 break;
257 case EVENT_SPLIT_2:
258 _spotlightsGuidVector.clear();
263 break;
264 case EVENT_SPLIT_3:
267 break;
268 case EVENT_SPLIT_4:
269 me->SetVisible(false);
271 break;
272 case EVENT_SPLIT_5:
274 if (Creature* spotlight = ObjectAccessor::GetCreature(*me, guid))
275 spotlight->CastSpell(spotlight, SPELL_SUMMON_ASTROMANCER_ADDS);
277 break;
278 case EVENT_SPLIT_6:
279 {
280 // We become visible here because otherwise spell below will not hit Solarian
281 me->SetVisible(true);
282
284
285 for (std::size_t i = 0; i < _spotlightsGuidVector.size() && i < SpotlightSummonSpells.size(); ++i)
287 spotlight->CastSpell(spotlight, SpotlightSummonSpells[i]);
288
290
291 _isSplitInProgress = false;
292
294 break;
295 }
296 // Transition
303 break;
309 break;
310
311 // Phase 2
314 events.Repeat(15s, 25s);
315 break;
316 case EVENT_VOID_BOLT:
318 events.Repeat(8s, 12s);
319 break;
320 default:
321 break;
322 }
323
325 return;
326 }
327 }
328
329private:
334};
335
336// 18806 - Solarium Priest
338{
339 npc_solarium_priest(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
340
341 void InitializeAI() override
342 {
343 me->SetCorpseDelay(1, true);
345 }
346
347 void JustAppeared() override
348 {
350
352 AddThreat(target, 100000.0f);
353
355 solarian->AI()->JustSummoned(me);
356 }
357
358 void Reset() override
359 {
361 }
362
363 void AttackStart(Unit* who) override
364 {
366 }
367
368 void JustEngagedWith(Unit* /*who*/) override
369 {
371 .SetValidator([this]
372 {
374 })
375 .Schedule(0s, [this](TaskContext& task)
376 {
378 task.Repeat(3s, 5s);
379 })
380 .Schedule(10s, 15s, [this](TaskContext& task)
381 {
382 if (Unit* target = DoSelectLowestHpFriendly(100.0f))
383 DoCast(target, SPELL_GREAT_HEAL);
384 task.Repeat(10s, 15s);
385 })
386 .Schedule(10s, 20s, [this](TaskContext& task)
387 {
389 task.Repeat(10s, 20s);
390 });
391 }
392
393 void UpdateAI(uint32 diff) override
394 {
395 if (!UpdateVictim())
396 return;
397
398 _scheduler.Update(diff);
399 }
400
401private:
404};
405
406// 18925 - Solarium Agent
408{
409 npc_solarium_agent(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
410
411 void InitializeAI() override
412 {
413 me->SetCorpseDelay(1, true);
415 }
416
417 void JustAppeared() override
418 {
420
422 AddThreat(target, 100000.0f);
423
425 solarian->AI()->JustSummoned(me);
426 }
427
428private:
430};
431
432// 42783 - Wrath of the Astromancer
434{
435 bool Validate(SpellInfo const* spellInfo) override
436 {
437 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt()) });
438 }
439
440 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
441 {
442 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
443 return;
444
445 GetTarget()->CastSpell(GetTarget(), uint32(GetEffectInfo(EFFECT_1).CalcValueAsInt()), true);
446 }
447
452};
453
uint32_t uint32
Definition Define.h:154
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:434
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_1
@ EFFECT_0
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_EXPIRE
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
static constexpr std::array< uint32, 4 > SplitLargeRadiusSpells2
void AddSC_boss_high_astromancer_solarian()
@ NPC_SPOTLIGHT
@ VOIDWALKER_ARMOR
SolarianTexts
@ SAY_DEATH
@ SAY_VOID_1
@ SAY_AGGRO
@ SAY_SLAY
@ SAY_SUMMON
@ SAY_VOID_2
SolarianEvents
@ EVENT_WRATH_OF_THE_ASTROMANCER
@ EVENT_ARCANE_MISSILES
@ EVENT_SPLIT_4
@ EVENT_PSYCHIC_SCREAM
@ EVENT_SPLIT_2
@ EVENT_VOID_BOLT
@ EVENT_SPLIT_1
@ EVENT_TRANSITION_1
@ EVENT_TRANSITION_2
@ EVENT_SPLIT_3
@ EVENT_BLINDING_LIGHT
@ EVENT_SPLIT_5
@ EVENT_SPLIT_6
static constexpr std::array< uint32, 4 > SplitLargeRadiusSpells1
SolarianSpells
@ SPELL_ASTROMANCER_SPLIT_LARGE_5
@ SPELL_BLINDING_LIGHT
@ SPELL_ARCANE_TORRENT
@ SPELL_ASTROMANCER_SPLIT_LARGE_4
@ SPELL_ASTROMANCER_SPLIT_SMALL_2
@ SPELL_SOLARIAN_TRANSFORM
@ SPELL_ASTROMANCER_SPLIT_LARGE_8
@ SPELL_ASTROMANCER_SPLIT_LARGE_6
@ SPELL_VOID_BOLT
@ SPELL_HOLY_SMITE
@ SPELL_ASTROMANCER_SPLIT_LARGE_1
@ SPELL_SUMMON_ASTROMANCER_SOLARIAN
@ SPELL_ASTROMANCER_SPLIT_LARGE_3
@ SPELL_ASTROMANCER_SPLIT_SMALL_4
@ SPELL_SUMMON_ASTROMANCER_PRIEST
@ SPELL_SUMMON_ASTROMANCER_ADDS
@ SPELL_ASTROMANCER_SPLIT_SMALL_3
@ SPELL_GREAT_HEAL
@ SPELL_ASTROMANCER_SPLIT_SMALL_1
@ SPELL_PSYCHIC_SCREAM
@ SPELL_WRATH_OF_THE_ASTROMANCER
@ SPELL_ASTROMANCER_SPLIT_LARGE_2
@ SPELL_ARCANE_MISSILES
@ SPELL_ASTROMANCER_SPLIT_LARGE_7
static constexpr std::array< uint32, 4 > SplitSmallRadiusSpells
static constexpr std::array< uint32, 3 > SpotlightSummonSpells
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
SpellEffectInfo const & GetEffectInfo(SpellEffIndex effIndex) const
Unit * GetTarget() const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void CallForHelp(float fRadius)
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:396
void SetReactState(ReactStates st)
Definition Creature.h:180
void SetRegenerateHealth(bool value)
Definition Creature.h:381
ReactStates GetReactState() const
Definition Creature.h:181
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:118
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void CancelEvent(EventId eventId)
Definition EventMap.cpp:156
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
Creature * GetCreature(uint32 type)
uint32 GetEntry() const
Definition Object.h:89
int32 CalcValueAsInt(WorldObject const *caster=nullptr, SpellEffectValue const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
uint32 const Id
Definition SpellInfo.h:328
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:590
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
void Summon(Creature const *summon)
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
TaskScheduler & Update()
Update the scheduler to the current time.
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:47
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void InitializeAI()
Definition UnitAI.cpp:35
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
void SetVisible(bool x)
Definition Unit.cpp:8787
void SetFullHealth()
Definition Unit.h:814
void SetArmor(int32 val, int32 bonusVal)
Definition Unit.h:787
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
void NearTeleportTo(TeleportLocation const &target, bool casting=false)
Definition Unit.cpp:13054
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3992
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
bool Validate(SpellInfo const *spellInfo) override
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void RandomShuffle(Iterator begin, Iterator end)
Reorder the elements of the iterator range randomly.
Definition Containers.h:171
auto SelectRandomContainerElement(C const &container) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
Definition Containers.h:110
Unit * DoSelectLowestHpFriendly(float range, uint32 minHPDiff=1)
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 diff) override
boss_high_astromancer_solarian(Creature *creature)
void JustEngagedWith(Unit *who) override
void JustSummoned(Creature *summon) override
InstanceScript * _instance
void InitializeAI() override
npc_solarium_agent(Creature *creature)
void JustAppeared() override
void UpdateAI(uint32 diff) override
InstanceScript * _instance
void InitializeAI() override
npc_solarium_priest(Creature *creature)
void JustEngagedWith(Unit *) override
void AttackStart(Unit *who) override
== Triggered Actions Requested ==================
void JustAppeared() override
#define RegisterTheEyeCreatureAI(ai_name)
Definition the_eye.h:74
@ DATA_SOLARIAN
Definition the_eye.h:33