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 * Verify Enrage spell, most likely current ID is not correct
22 * Damage of pets requires adjustments (seems too low) (DB issue)
23 * Bestial Wrath cannot be applied on Fathom Lurker and only applies on Fathom Sporebat. The reason is Creature Type Mask = 0x00000001 (BEAST).
24 It is unclear if this is an issue or not
25 * Sharkkis should be able to summon multiple pets, at this moment he can have only one summoned pet per time
26 * Totems and Cyclone probably should despawn in case of wipe. At this moment it is NYI
27 * Transform spells (handled in SAI for each totem) for totems cannot be casted by totems because of Totem::IsImmunedToSpellEffect (SPELL_AURA_TRANSFORM)
28 */
29
30#include "ScriptMgr.h"
31#include "InstanceScript.h"
32#include "MotionMaster.h"
33#include "ObjectAccessor.h"
34#include "ScriptedCreature.h"
35#include "SpellInfo.h"
36#include "SpellScript.h"
37#include "serpent_shrine.h"
38
47
92
118
123
124// 21214 - Fathom-Lord Karathress
126{
128
129 void Reset() override
130 {
131 _blessingOfTides = false;
132
136
137 // Respawn advisors
138 for (uint8 i = 0; i < MAX_ADVISORS; ++i)
139 if (!_advisors[i].IsEmpty())
140 {
142 if (advisor && !advisor->IsAlive())
143 advisor->Respawn();
144 }
145
146 _Reset();
147 }
148
149 void JustEngagedWith(Unit* who) override
150 {
153
157 }
158
159 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
160 {
161 if (spellInfo->Id == SPELL_POWER_OF_SHARKKIS || spellInfo->Id == SPELL_POWER_OF_TIDALVESS || spellInfo->Id == SPELL_POWER_OF_CARIBDIS)
163 }
164
165 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
166 {
167 if (!_blessingOfTides && me->HealthBelowPctDamaged(75, damage))
168 {
169 // It is important to get them again because if we respawned advisors previously,
170 // they were created with new guids, so below will not work second time
171 // We do it here and not in Reset() because Reset() is called before respawn
175
176 _blessingOfTides = true;
177 bool canPerformEmote = true;
178 for (ObjectGuid advisorGuid : _advisors)
179 {
180 Creature* advisor = ObjectAccessor::GetCreature(*me, advisorGuid);
181 if (advisor && advisor->IsAlive())
182 {
183 advisor->CastSpell(advisor, SPELL_BLESSING_OF_THE_TIDES, true);
184
185 if (canPerformEmote)
186 {
188 canPerformEmote = false;
189 }
190 }
191 }
192 }
193 }
194
195 void KilledUnit(Unit* /*victim*/) override
196 {
197 Talk(SAY_SLAY);
198 }
199
200 void JustDied(Unit* /*killer*/) override
201 {
202 _JustDied();
204 }
205
206 void UpdateAI(uint32 diff) override
207 {
208 if (!UpdateVictim())
209 return;
210
211 events.Update(diff);
212
214 return;
215
216 while (uint32 eventId = events.ExecuteEvent())
217 {
218 switch (eventId)
219 {
221 {
222 // Select a random unit other than the main tank
224
225 // If there aren't other units, cast on the tank
226 if (!target)
227 target = me->GetVictim();
228
229 if (target)
231
232 events.Repeat(6s, 12s);
233 break;
234 }
235 case EVENT_SEAR_NOVA:
237 events.Repeat(30s, 40s);
238 break;
239 case EVENT_ENRAGE:
241 events.Repeat(90s);
242 break;
243 default:
244 break;
245 }
246
248 return;
249 }
250
252 }
253
254private:
257};
258
259// 21966 - Fathom-Guard Sharkkis
261{
263
264 void Reset() override
265 {
266 _events.Reset();
267 }
268
276
277 void JustDied(Unit* /*killer*/) override
278 {
280 }
281
282 void UpdateAI(uint32 diff) override
283 {
284 if (!UpdateVictim())
285 return;
286
287 _events.Update(diff);
288
290 return;
291
292 while (uint32 eventId = _events.ExecuteEvent())
293 {
294 switch (eventId)
295 {
299 _events.Repeat(5s, 10s);
300 break;
303 _events.Repeat(30s, 40s);
304 break;
305 case EVENT_MULTI_TOSS:
307 DoCast(target, SPELL_MULTI_TOSS);
308 _events.Repeat(20s, 30s);
309 break;
312 _events.Repeat(30s);
313 break;
314 default:
315 break;
316 }
317
319 return;
320 }
321
323 }
324
325private:
327};
328
329// 21965 - Fathom-Guard Tidalvess
331{
333
334 void Reset() override
335 {
336 _events.Reset();
338 }
339
347
348 void JustDied(Unit* /*killer*/) override
349 {
351 }
352
353 void UpdateAI(uint32 diff) override
354 {
355 if (!UpdateVictim())
356 return;
357
358 _events.Update(diff);
359
361 return;
362
363 while (uint32 eventId = _events.ExecuteEvent())
364 {
365 switch (eventId)
366 {
369 _events.Repeat(10s, 15s);
370 break;
373 _events.Repeat(40s, 60s);
374 break;
377 _events.Repeat(40s, 60s);
378 break;
381 _events.Repeat(30s, 50s);
382 break;
383 default:
384 break;
385 }
386
388 return;
389 }
390
392 }
393
394private:
396};
397
398// 21964 - Fathom-Guard Caribdis
400{
402
403 void Reset() override
404 {
405 _events.Reset();
406 }
407
415
416 void JustDied(Unit* /*killer*/) override
417 {
419 }
420
421 void UpdateAI(uint32 diff) override
422 {
423 if (!UpdateVictim())
424 return;
425
426 _events.Update(diff);
427
429 return;
430
431 while (uint32 eventId = _events.ExecuteEvent())
432 {
433 switch (eventId)
434 {
437 _events.Repeat(10s, 30s);
438 break;
441 _events.Repeat(15s, 25s);
442 break;
446 _events.Repeat(40s, 50s);
447 break;
449 if (Unit* target = DoSelectLowestHpFriendly(250.0f))
450 DoCast(target, SPELL_HEALING_WAVE);
451 _events.Repeat(15s, 20s);
452 break;
453 default:
454 break;
455 }
456
458 return;
459 }
460
462 }
463
464private:
466};
467
468// 22104 - Cyclone (Karathress)
470{
472
473 void Reset() override
474 {
476 }
477
478 void JustAppeared() override
479 {
485 // DoCastSelf(SPELL_CYCLONE_KNOCK_BACK_2);
487
489 _scheduler.Schedule(10s, [this](TaskContext task)
490 {
492
493 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
494 {
496 AddThreat(target, 1000000.0f);
498 me->GetMotionMaster()->MoveChase(target);
499 }
500 task.Repeat(10s);
501 });
502 }
503
504 void UpdateAI(uint32 diff) override
505 {
506 UpdateVictim();
507
508 _scheduler.Update(diff);
509 }
510
511private:
513};
514
515// 38358 - Tidal Surge
535
536// 38373 - The Beast Within
556
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:135
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:235
DamageEffectType
Definition Unit.h:352
@ SPELL_SUMMON_FATHOM_SPOREBAT
@ SPELL_BLESSING_OF_THE_TIDES
@ SPELL_POISON_CLEANSING_TOTEM
@ SPELL_CYCLONE_WATER_VISUAL_2
void AddSC_boss_fathomlord_karathress()
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Respawn(bool force=false)
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
void Reset()
Definition EventMap.cpp:21
virtual ObjectGuid GetGuidData(uint32 type) const override
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< CastHandler > OnCast
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)
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:769
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool IsAlive() const
Definition Unit.h:1234
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_fathomlord_karathress_the_beast_within)
PrepareSpellScript(spell_fathomlord_karathress_tidal_surge)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ DATA_CARIBDIS
@ DATA_TIDALVESS
@ DATA_SHARKKIS
@ BOSS_FATHOM_LORD_KARATHRESS
#define RegisterSerpentshrineCavernCreatureAI(ai_name)
Unit * DoSelectLowestHpFriendly(float range, uint32 minHPDiff=1)
void ResetThreatList(Unit *who=nullptr)
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void UpdateAI(uint32 diff) override
void UpdateAI(uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override