TrinityCore
Loading...
Searching...
No Matches
boss_fathomlord_karathress.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 * Greater Poison Cleansing Totem has no passive spell (nothing found in sniffs). What spell should it use?
20 * Seer Olum's event is NYI (should be handled in DB)
21 * Damage of fathom pets is too low, core issue (if creature is summoned by spell, damage is quite low)
22 * Bestial Wrath cannot be applied on Fathom Lurker and only applies on Fathom Sporebat. The reason is Creature Type Mask = 0x00000001 (BEAST).
23 It is unclear if this is an issue or not
24 * Sharkkis should be able to summon multiple pets, at this moment he can have only one summoned pet per time
25 * Transform spells (handled in SAI for each totem) for totems cannot be casted by totems because of Totem::IsImmunedToSpellEffect (SPELL_AURA_TRANSFORM)
26 * Timers requires to be revisited
27 */
28
29#include "ScriptMgr.h"
30#include "InstanceScript.h"
31#include "Map.h"
32#include "ScriptedCreature.h"
33#include "SpellInfo.h"
34#include "SpellScript.h"
35#include "serpent_shrine.h"
36
45
90
116
124
125static constexpr std::array<uint32, 3> FathomGuardSpawnGroupsData =
126{
130};
131
132// 21214 - Fathom-Lord Karathress
134{
137
138 void JustAppeared() override
139 {
141 me->GetMap()->SpawnGroupSpawn(group, true);
142 }
143
144 void JustEngagedWith(Unit* who) override
145 {
147
149
153 }
154
155 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
156 {
157 switch (spellInfo->Id)
158 {
163 break;
165 if (!_performedEmote)
166 {
168 _performedEmote = true;
169 }
170 break;
171 default:
172 break;
173 }
174 }
175
176 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
177 {
178 if (!_blessingOfTides && me->HealthBelowPctDamaged(75, damage))
179 {
180 _blessingOfTides = true;
181
183 if (Creature* guard = instance->GetCreature(data))
184 if (guard->IsAlive())
185 guard->AI()->DoAction(ACTION_GIVE_BLESSING);
186 }
187 }
188
189 void JustSummoned(Creature* summon) override
190 {
191 summons.Summon(summon);
192 }
193
194 void EnterEvadeMode(EvadeReason /*why*/) override
195 {
197 me->GetMap()->SpawnGroupDespawn(group);
198
201 }
202
203 void KilledUnit(Unit* /*victim*/) override
204 {
205 Talk(SAY_SLAY);
206 }
207
208 void JustDied(Unit* /*killer*/) override
209 {
210 _JustDied();
212 }
213
214 void UpdateAI(uint32 diff) override
215 {
216 if (!UpdateVictim())
217 return;
218
219 events.Update(diff);
220
222 return;
223
224 while (uint32 eventId = events.ExecuteEvent())
225 {
226 switch (eventId)
227 {
230 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 80.0f, true))
232 events.Repeat(6s, 12s);
233 break;
234 case EVENT_SEAR_NOVA:
236 events.Repeat(30s, 40s);
237 break;
238 case EVENT_BERSERK:
240 break;
241 default:
242 break;
243 }
244
246 return;
247 }
248
250 }
251
252private:
255};
256
258{
259 FathomGuardBaseAI(Creature* creature) : ScriptedAI(creature), Instance(creature->GetInstanceScript()) { }
260
261 void Reset() override
262 {
263 Events.Reset();
264 }
265
266 void DoAction(int32 action) override
267 {
268 if (action == ACTION_GIVE_BLESSING)
270 }
271
272 void JustSummoned(Creature* summon) override
273 {
275 karathress->AI()->JustSummoned(summon);
276 }
277
278 virtual void ExecuteEvent(uint32 const eventId) = 0;
279
280 void UpdateAI(uint32 diff) override
281 {
282 if (!UpdateVictim())
283 return;
284
285 Events.Update(diff);
286
288 return;
289
290 while (uint32 eventId = Events.ExecuteEvent())
291 {
292 ExecuteEvent(eventId);
293
295 return;
296 }
297
299 }
300
301protected:
304};
305
306// 21966 - Fathom-Guard Sharkkis
308{
310
311 void JustEngagedWith(Unit* /*who*/) override
312 {
313 Events.ScheduleEvent(EVENT_LEECHING_THROW, 5s, 10s);
314 Events.ScheduleEvent(EVENT_THE_BEAST_WITHIN, 30s, 40s);
315 Events.ScheduleEvent(EVENT_MULTI_TOSS, 20s, 30s);
316 Events.ScheduleEvent(EVENT_SUMMON_FATHOM_PET, 10s);
317 }
318
319 void JustDied(Unit* /*killer*/) override
320 {
322 }
323
324 void ExecuteEvent(uint32 eventId) override
325 {
326 switch (eventId)
327 {
331 Events.Repeat(5s, 10s);
332 break;
335 Events.Repeat(30s, 40s);
336 break;
337 case EVENT_MULTI_TOSS:
339 DoCast(target, SPELL_MULTI_TOSS);
340 Events.Repeat(20s, 30s);
341 break;
344 Events.Repeat(30s);
345 break;
346 default:
347 break;
348 }
349 }
350};
351
352// 21965 - Fathom-Guard Tidalvess
354{
356
357 void JustAppeared() override
358 {
360 }
361
362 void JustEngagedWith(Unit* /*who*/) override
363 {
364 Events.ScheduleEvent(EVENT_FROST_SHOCK, 10s, 15s);
365 Events.ScheduleEvent(EVENT_SPITFIRE_TOTEM, 10s, 15s);
366 Events.ScheduleEvent(EVENT_EARTHBIND_TOTEM, 15s, 25s);
367 Events.ScheduleEvent(EVENT_POISON_CLEANSING_TOTEM, 20s, 30s);
368 }
369
370 void JustDied(Unit* /*killer*/) override
371 {
373 }
374
375 void ExecuteEvent(uint32 eventId) override
376 {
377 switch (eventId)
378 {
381 Events.Repeat(10s, 15s);
382 break;
385 Events.Repeat(40s, 60s);
386 break;
389 Events.Repeat(40s, 60s);
390 break;
393 Events.Repeat(30s, 50s);
394 break;
395 default:
396 break;
397 }
398 }
399};
400
401// 21964 - Fathom-Guard Caribdis
403{
405
406 void JustEngagedWith(Unit* /*who*/) override
407 {
408 Events.ScheduleEvent(EVENT_WATER_BOLT_VOLLEY, 15s, 25s);
409 Events.ScheduleEvent(EVENT_TIDAL_SURGE, 15s, 20s);
410 Events.ScheduleEvent(EVENT_SUMMON_CYCLONE, 10s, 25s);
411 Events.ScheduleEvent(EVENT_HEALING_WAVE, 15s, 25s);
412 }
413
414 void JustDied(Unit* /*killer*/) override
415 {
417 }
418
419 void ExecuteEvent(uint32 eventId) override
420 {
421 switch (eventId)
422 {
425 Events.Repeat(10s, 30s);
426 break;
429 Events.Repeat(15s, 25s);
430 break;
434 Events.Repeat(40s, 50s);
435 break;
437 if (Unit* target = DoSelectLowestHpFriendly(250.0f))
438 DoCast(target, SPELL_HEALING_WAVE);
439 Events.Repeat(15s, 20s);
440 break;
441 default:
442 break;
443 }
444 }
445};
446
447// 22104 - Cyclone (Karathress)
449{
451
452 void Reset() override
453 {
455 }
456
457 void JustAppeared() override
458 {
467
468 _scheduler.Schedule(10s, [this](TaskContext task)
469 {
471
472 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
473 {
475 AddThreat(target, 1000000.0f);
476 AttackStart(target);
477 }
478 task.Repeat(10s);
479 });
480 }
481
482 void UpdateAI(uint32 diff) override
483 {
484 UpdateVictim();
485
486 _scheduler.Update(diff);
487 }
488
489private:
491};
492
493// 38358 - Tidal Surge
513
514// 38373 - The Beast Within
534
First const & RAND(First const &first, Second const &second, Rest const &... rest)
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_1
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
#define SpellCastFn(F)
@ UNIT_STATE_CASTING
Definition Unit.h:249
DamageEffectType
Definition Unit.h:366
@ SPELL_SUMMON_FATHOM_SPOREBAT
@ SPELL_BLESSING_OF_THE_TIDES
@ SPELL_POISON_CLEANSING_TOTEM
@ SPELL_CYCLONE_WATER_VISUAL_2
static constexpr std::array< uint32, 3 > FathomGuardSpawnGroupsData
void AddSC_boss_fathomlord_karathress()
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
Creature * GetCreature(uint32 type)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:3382
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
Definition Map.cpp:3458
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< CastHandler > OnCast
void Summon(Creature const *summon)
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
uint32 GetThreatListPlayerCount(bool includeOffline=false) const
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:783
ThreatManager & GetThreatManager()
Definition Unit.h:1169
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:932
Map * GetMap() const
Definition Object.h:451
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_fathomlord_karathress_the_beast_within)
PrepareSpellScript(spell_fathomlord_karathress_tidal_surge)
@ DATA_CARIBDIS
@ DATA_TIDALVESS
@ DATA_SHARKKIS
@ BOSS_FATHOM_LORD_KARATHRESS
#define RegisterSerpentshrineCavernCreatureAI(ai_name)
void UpdateAI(uint32 diff) override
virtual void ExecuteEvent(uint32 const eventId)=0
void JustSummoned(Creature *summon) override
FathomGuardBaseAI(Creature *creature)
void DoAction(int32 action) override
void AttackStart(Unit *) override
Unit * DoSelectLowestHpFriendly(float range, uint32 minHPDiff=1)
ScriptedAI(Creature *creature)
void ResetThreatList(Unit *who=nullptr)
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void ExecuteEvent(uint32 eventId) override
void ExecuteEvent(uint32 eventId) override
void ExecuteEvent(uint32 eventId) override
void JustSummoned(Creature *summon) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void EnterEvadeMode(EvadeReason) override