TrinityCore
Loading...
Searching...
No Matches
boss_swamplord_muselek.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 * Timers requires to be revisited
20 * What does SPELL_NOTIFY_OF_DEATH is unknown
21 * What does Script Effect of spell SPELL_HUNTERS_MARK is unknown
22 */
23
24#include "ScriptMgr.h"
25#include "ScriptedCreature.h"
26#include "SpellScript.h"
27#include "SpellInfo.h"
28#include "MotionMaster.h"
29#include "Player.h"
30#include "the_underbog.h"
31
39
41{
42 // Musel'ek - Combat - Ranged
43 SPELL_SHOOT = 22907,
45
46 // Musel'ek - Combat - Melee
51
52 // Musel'ek - Combat - Sequence
59
60 // Musel'ek - Combat - Death
62
63 // Claw
65 SPELL_MAUL = 34298,
66 SPELL_FRENZY = 34971,
67 SPELL_FERAL_CHARGE = 39435
68};
69
96
106
113
115{
116 { 290.53226f, -125.35236f, 29.697079f, 0.0f },
117 { 295.05692f, -123.32802f, 29.659490f, 0.0f }
118};
119
120// 17826 - Swamplord Musel'ek
122{
124
125 void Reset() override
126 {
127 _Reset();
130 }
131
145
146 void AttackStart(Unit* who) override
147 {
149 }
150
151 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
152 {
153 if (_phase < PHASE_HEALTH_70 && me->HealthBelowPctDamaged(70, damage))
154 {
155 _phase++;
157 }
158
159 if (_phase < PHASE_HEALTH_30 && me->HealthBelowPctDamaged(30, damage))
160 {
161 _phase++;
163 }
164 }
165
166 void OnSpellCast(SpellInfo const* spellInfo) override
167 {
168 if (spellInfo->Id == SPELL_BEAR_COMMAND)
170 }
171
172 void MovementInform(uint32 type, uint32 pointId) override
173 {
174 if (type != POINT_MOTION_TYPE)
175 return;
176
177 if (pointId == POINT_MOVE_AWAY)
179 }
180
181 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
182 {
183 if (spellInfo->Id == SPELL_FACE_HIGHEST_THREAT)
185 me->SetFacingToObject(target);
186 }
187
188 void KilledUnit(Unit* /*victim*/) override
189 {
190 Talk(SAY_SLAY);
191 }
192
193 void JustDied(Unit* /*killer*/) override
194 {
195 _JustDied();
197
198 if (Creature* claw = me->FindNearestCreature(NPC_CLAW, 100.0f))
200 }
201
202 void UpdateAI(uint32 diff) override
203 {
204 if (!UpdateVictim())
205 return;
206
207 events.Update(diff);
208
210 return;
211
212 while (uint32 eventId = events.ExecuteEvent())
213 {
214 switch (eventId)
215 {
216 // Ranged
217 case EVENT_SHOOT:
219 events.Repeat(2s, 4s);
220 break;
221 case EVENT_MULTI_SHOT:
223 events.Repeat(25s, 35s);
224 break;
225
226 // Melee
227 case EVENT_KNOCK_AWAY:
229 events.Repeat(30s, 40s);
230 break;
233 events.Repeat(25s);
234 break;
237 events.Repeat(10s, 20s);
238 break;
239
240 // Sequence
243
246
249 break;
253
254 // Not always? Or wrong place? This is based only on one cast in sniff, need more info
255 if (roll_chance(50))
257 break;
262
264 DoCast(target, SPELL_AIMED_SHOT);
265 break;
266 default:
267 break;
268 }
269
271 return;
272 }
273 }
274
275private:
277};
278
279// 17827 - Claw
280struct npc_claw : public ScriptedAI
281{
283
284 void Reset() override
285 {
286 _events.Reset();
287 _chargeCounter = 0;
289 }
290
291 void JustEngagedWith(Unit* /*who*/) override
292 {
295 }
296
297 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
298 {
299 if (spellInfo->Id == SPELL_BEAR_COMMAND)
301 }
302
303 bool OnGossipHello(Player* player) override
304 {
306 return false;
307 }
308
309 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
310 {
311 // This CAN occur even if Musel'ek is NOT yet dead
312 if (!_canPerformOutro && me->HealthBelowPctDamaged(20, damage))
313 {
314 _canPerformOutro = true;
316 me->SetImmuneToAll(true);
318 }
319 }
320
327
328 void MovementInform(uint32 type, uint32 pointId) override
329 {
330 if (type != POINT_MOTION_TYPE)
331 return;
332
333 switch (pointId)
334 {
335 case POINT_OUTRO_1:
337 break;
338 case POINT_OUTRO_2:
340 break;
341 }
342 }
343
344 void UpdateAI(uint32 diff) override
345 {
346 if (!UpdateVictim())
347 {
349 {
350 _events.Update(diff);
351
352 while (uint32 eventId = _events.ExecuteEvent())
353 {
354 switch (eventId)
355 {
356 case EVENT_OUTRO_1:
357 me->SetWalk(true);
363 me->SetImmuneToAll(true);
364 break;
365 case EVENT_OUTRO_2:
367 break;
368 case EVENT_OUTRO_3:
369 me->SetFacingTo(3.420845270156860351f);
371 break;
372 default:
373 break;
374 }
375 }
376 }
377
378 return;
379 }
380
381 _events.Update(diff);
382
384 return;
385
386 while (uint32 eventId = _events.ExecuteEvent())
387 {
388 switch (eventId)
389 {
392 _events.Repeat(10s, 20s);
393 break;
394 case EVENT_MAUL:
396 _events.Repeat(10s, 15s);
397 break;
400 // 0 seems to be valid value. He doesn't obey always, perhaps. Or something is more tricky than it seems
401 _chargeCounter = RAND(0, 1, 2, 3, 4);
404 break;
407 {
409 DoCast(target, SPELL_FERAL_CHARGE);
410
412 _events.Repeat(2s, 5s);
413 }
414 break;
415 default:
416 break;
417 }
418
420 return;
421 }
422 }
423
424private:
429};
430
431// 31564 - Move Away Primer
433{
434 void HandleDummy(SpellEffIndex /*effIndex*/)
435 {
436 GetCaster()->GetMotionMaster()->MovePoint(POINT_MOVE_AWAY, GetCaster()->GetNearPosition(frand(15.0f, 35.0f), frand(0.0f, 2.0f * float(M_PI))));
437 }
438
443};
444
#define M_PI
Definition Common.h:118
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
float frand(float min, float max)
Definition Random.cpp:56
bool roll_chance(float chance, PseudoRandomDistributionState &state)
Definition Random.cpp:131
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
#define SpellEffectFn(F, I, N)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STAND_STATE_SIT
Definition UnitDefines.h:43
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
void AddSC_boss_swamplord_muselek()
@ EVENT_COMBAT_SEQUENCE_1
@ EVENT_RAPTOR_STRIKE
@ EVENT_COMBAT_SEQUENCE_3
@ EVENT_COMBAT_SEQUENCE_2
@ EVENT_COMMAND_RESPONSE
Position const OutroPos[2]
@ FACTION_CENARION_EXP
@ SPELL_NOTIFY_OF_DEATH
@ SPELL_FREEZING_TRAP
@ SPELL_RAPTOR_STRIKE
@ SPELL_MOVE_AWAY_PRIMER
@ SPELL_FACE_HIGHEST_THREAT
void JustEngagedWith(Unit *who) override
EventMap events
virtual void JustReachedHome()
Definition CreatureAI.h:167
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:180
bool UpdateEntry(uint32 entry, CreatureData const *data=nullptr, bool updateLevel=true)
Definition Creature.cpp:591
void SetImmuneToAll(bool apply) override
Definition Creature.h:187
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
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={})
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition Player.cpp:16646
uint32 const Id
Definition SpellInfo.h:328
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:47
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
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 SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition Unit.cpp:10804
void SetFaction(uint32 faction) override
Definition Unit.h:887
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
void SetFacingToObject(WorldObject const *object, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13394
bool SetWalk(bool enable)
Definition Unit.cpp:13422
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
void SetFacingTo(float ori, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13385
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3992
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1522
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void JustEngagedWith(Unit *who) override
void AttackStart(Unit *who) override
void UpdateAI(uint32 diff) override
boss_swamplord_muselek(Creature *creature)
void KilledUnit(Unit *) override
void OnSpellCast(SpellInfo const *spellInfo) override
void MovementInform(uint32 type, uint32 pointId) override
void JustReachedHome() override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
bool OnGossipHello(Player *player) override
void MovementInform(uint32 type, uint32 pointId) override
void UpdateAI(uint32 diff) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void JustEngagedWith(Unit *) override
void Reset() override
npc_claw(Creature *creature)
#define RegisterTheUnderbogCreatureAI(ai_name)
@ DATA_SWAMPLORD_MUSELEK