TrinityCore
Loading...
Searching...
No Matches
boss_onyxia.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/* ScriptData
19SDName: Boss_Onyxia
20SD%Complete: 95
21SDComment: <Known bugs>
22 Ground visual for Deep Breath effect;
23 Not summoning whelps on phase 3 (lacks info)
24 </Known bugs>
25SDCategory: Onyxia's Lair
26EndScriptData */
27
28#include "ScriptMgr.h"
29#include "CellImpl.h"
30#include "GridNotifiersImpl.h"
31#include "InstanceScript.h"
32#include "MotionMaster.h"
33#include "ObjectAccessor.h"
34#include "onyxias_lair.h"
35#include "ScriptedCreature.h"
36#include "TemporarySummon.h"
37
39{
40 // Say
45 // Emote
46 EMOTE_BREATH = 4
47};
48
50{
51 // Phase 1 spells
54 SPELL_CLEAVE = 68868,
56
57 // Phase 2 spells
60
61 //Not much choise about these. We have to make own defintion on the direction/start-end point
62 SPELL_BREATH_NORTH_TO_SOUTH = 17086, // 20x in "array"
63 SPELL_BREATH_SOUTH_TO_NORTH = 18351, // 11x in "array"
64
65 SPELL_BREATH_EAST_TO_WEST = 18576, // 7x in "array"
66 SPELL_BREATH_WEST_TO_EAST = 18609, // 7x in "array"
67
68 SPELL_BREATH_SE_TO_NW = 18564, // 12x in "array"
69 SPELL_BREATH_NW_TO_SE = 18584, // 12x in "array"
70 SPELL_BREATH_SW_TO_NE = 18596, // 12x in "array"
71 SPELL_BREATH_NE_TO_SW = 18617, // 12x in "array"
72
73 //SPELL_BREATH = 21131, // 8x in "array", different initial cast than the other arrays
74
75 // Phase 3 spells
77};
78
92
100
102{
103 {0, 1, SPELL_BREATH_WEST_TO_EAST, -33.5561f, -182.682f, -56.9457f}, //west
104 {1, 0, SPELL_BREATH_EAST_TO_WEST, -31.4963f, -250.123f, -55.1278f}, //east
105 {2, 4, SPELL_BREATH_NW_TO_SE, 6.8951f, -180.246f, -55.896f}, //north-west
106 {3, 5, SPELL_BREATH_NE_TO_SW, 10.2191f, -247.912f, -55.896f}, //north-east
107 {4, 2, SPELL_BREATH_SE_TO_NW, -63.5156f, -240.096f, -55.477f}, //south-east
108 {5, 3, SPELL_BREATH_SW_TO_NE, -58.2509f, -189.020f, -55.790f}, //south-west
109 {6, 7, SPELL_BREATH_SOUTH_TO_NORTH, -65.8444f, -213.809f, -55.2985f}, //south
110 {7, 6, SPELL_BREATH_NORTH_TO_SOUTH, 22.8763f, -217.152f, -55.0548f}, //north
111};
112
113Position const MiddleRoomLocation = {-23.6155f, -215.357f, -55.7344f, 0.0f};
114
115Position const Phase2Location = {-80.924f, -214.299f, -82.942f, 0.0f};
116Position const Phase2Floating = { -80.924f, -214.299f, -57.942f, 0.0f };
117
119{
120 //Whelps
121 {-30.127f, -254.463f, -89.440f, 0.0f},
122 {-30.817f, -177.106f, -89.258f, 0.0f},
123 //Lair Guard
124 {-145.950f, -212.831f, -68.659f, 0.0f}
125};
126
127struct boss_onyxia : public BossAI
128{
129 boss_onyxia(Creature* creature) : BossAI(creature, DATA_ONYXIA)
130 {
131 Initialize();
132 }
133
135 {
137 MovePoint = urand(0, 5);
141 tankGUID.Clear();
142 IsMoving = false;
143 }
144
145 void Reset() override
146 {
147 Initialize();
148
149 SetCombatMovement(true);
150 me->SetCanMelee(true);
151
152 _Reset();
155 }
156
167
168 void JustSummoned(Creature* summoned) override
169 {
170 DoZoneInCombat(summoned);
172 summoned->AI()->AttackStart(target);
173
174 switch (summoned->GetEntry())
175 {
176 case NPC_WHELP:
178 break;
179 case NPC_LAIRGUARD:
180 summoned->setActive(true);
181 summoned->SetFarVisible(true);
182 break;
183 }
184 summons.Summon(summoned);
185 }
186
187 void KilledUnit(Unit* /*victim*/) override
188 {
189 Talk(SAY_KILL);
190 }
191
192 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
193 {
194 if (spellInfo->Id == SPELL_BREATH_EAST_TO_WEST ||
195 spellInfo->Id == SPELL_BREATH_WEST_TO_EAST ||
196 spellInfo->Id == SPELL_BREATH_SE_TO_NW ||
197 spellInfo->Id == SPELL_BREATH_NW_TO_SE ||
198 spellInfo->Id == SPELL_BREATH_SW_TO_NE ||
199 spellInfo->Id == SPELL_BREATH_NE_TO_SW)
200 {
203
206 }
207 }
208
209 void MovementInform(uint32 type, uint32 id) override
210 {
211 if (type == POINT_MOTION_TYPE)
212 {
213 switch (id)
214 {
215 case 8:
217 if (PointData)
218 {
221 }
222 break;
223 case 9:
224 me->SetCanFly(false);
225 me->SetDisableGravity(false);
227 Unit::Kill(me, trigger);
229 // tank selection based on phase one. If tank is not there i take nearest one
231 me->GetMotionMaster()->MoveChase(tank);
232 else if (Unit* newtarget = SelectTarget(SelectTargetMethod::MinDistance, 0))
233 me->GetMotionMaster()->MoveChase(newtarget);
239 break;
240 case 10:
241 me->SetCanFly(true);
242 me->SetDisableGravity(true);
243 me->SetFacingTo(me->GetOrientation() + float(M_PI));
245 triggerGUID = trigger->GetGUID();
255 break;
256 case 11:
257 if (PointData)
260 break;
261 default:
262 IsMoving = false;
263 break;
264 }
265 }
266 }
267
268 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
269 {
270 //Workaround - Couldn't find a way to group this spells (All Eruption)
271 if (((spellInfo->Id >= 17086 && spellInfo->Id <= 17095) ||
272 (spellInfo->Id == 17097) ||
273 (spellInfo->Id >= 18351 && spellInfo->Id <= 18361) ||
274 (spellInfo->Id >= 18564 && spellInfo->Id <= 18576) ||
275 (spellInfo->Id >= 18578 && spellInfo->Id <= 18607) ||
276 (spellInfo->Id == 18609) ||
277 (spellInfo->Id >= 18611 && spellInfo->Id <= 18628) ||
278 (spellInfo->Id >= 21132 && spellInfo->Id <= 21133) ||
279 (spellInfo->Id >= 21135 && spellInfo->Id <= 21139) ||
280 (spellInfo->Id >= 22191 && spellInfo->Id <= 22202) ||
281 (spellInfo->Id >= 22267 && spellInfo->Id <= 22268)) &&
282 (target->GetTypeId() == TYPEID_PLAYER))
283 {
285 }
286 }
287
289 {
290 uint8 MaxCount = sizeof(MoveData) / sizeof(OnyxMove);
291
292 for (uint8 i = 0; i < MaxCount; ++i)
293 {
294 if (MoveData[i].LocId == MovePoint)
295 return &MoveData[i];
296 }
297
298 return nullptr;
299 }
300
302 {
303 uint8 MaxCount = sizeof(MoveData) / sizeof(OnyxMove);
304
305 uint8 iTemp = urand(0, MaxCount - 1);
306
307 if (iTemp >= MovePoint)
308 ++iTemp;
309
310 MovePoint = iTemp;
311 }
312
313 void UpdateAI(uint32 diff) override
314 {
315 if (!UpdateVictim())
316 return;
317
318 //Common to PHASE_START && PHASE_END
319 if (Phase == PHASE_START || Phase == PHASE_END)
320 {
321 //Specific to PHASE_START || PHASE_END
322 if (Phase == PHASE_START)
323 {
324 if (HealthBelowPct(65))
325 {
326 if (Unit* target = me->GetVictim())
327 tankGUID = target->GetGUID();
328 SetCombatMovement(false);
331 me->AttackStop();
332 me->SetCanMelee(false);
334 return;
335 }
336 }
337
338 events.Update(diff);
339
341 return;
342
343 while (uint32 eventId = events.ExecuteEvent())
344 {
345 switch (eventId)
346 {
347 case EVENT_BELLOWING_ROAR: // Phase PHASE_END
348 {
350 // Eruption
351 GameObject* Floor = nullptr;
354 Cell::VisitGridObjects(me, searcher, 30.0f);
355 if (Floor)
358 break;
359 }
360 case EVENT_FLAME_BREATH: // Phase PHASE_START and PHASE_END
363 break;
364 case EVENT_TAIL_SWEEP: // Phase PHASE_START and PHASE_END
367 break;
368 case EVENT_CLEAVE: // Phase PHASE_START and PHASE_END
371 break;
372 case EVENT_WING_BUFFET: // Phase PHASE_START and PHASE_END
375 break;
376 default:
377 break;
378 }
379
381 return;
382 }
383 }
384 else
385 {
386 if (HealthBelowPct(40))
387 {
391 SetCombatMovement(true);
392 IsMoving = false;
393 me->SetCanMelee(true);
394 Position const pos = me->GetHomePosition();
395 me->GetMotionMaster()->MovePoint(9, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + 12.0f);
397 return;
398 }
399
400 if (!me->isMoving())
402 me->SetFacingToObject(trigger);
403
404 events.Update(diff);
405
407 return;
408
409 while (uint32 eventId = events.ExecuteEvent())
410 {
411 switch (eventId)
412 {
413 case EVENT_DEEP_BREATH: // Phase PHASE_BREATH
414 if (!IsMoving)
415 {
416 if (me->IsNonMeleeSpellCast(false))
418
420 if (PointData)
423 }
424 else
426 break;
427 case EVENT_MOVEMENT: // Phase PHASE_BREATH
429 {
432
433 if (!PointData)
434 return;
435
437 IsMoving = true;
439 }
440 else
442 break;
443 case EVENT_FIREBALL: // Phase PHASE_BREATH
444 if (!IsMoving)
445 {
447 DoCast(target, SPELL_FIREBALL);
449 }
450 else
452 break;
453 case EVENT_LAIR_GUARD: // Phase PHASE_BREATH
456 break;
457 case EVENT_WHELP_SPAWN: // Phase PHASE_BREATH
460 if (SummonWhelpCount >= RAID_MODE(20, 40))
461 {
464 }
465 else
467 break;
468 default:
469 break;
470 }
471
473 return;
474 }
475 }
476 }
477
478 private:
486};
487
#define M_PI
Definition Common.h:118
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ FAIL
@ POINT_MOTION_TYPE
@ TEMPSUMMON_CORPSE_DESPAWN
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
Spells
Definition PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
@ MOVE_FLIGHT
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ SAY_AGGRO
@ SAY_PHASE_2_TRANS
@ EMOTE_BREATH
@ SAY_KILL
@ SAY_PHASE_3_TRANS
Position const Phase2Floating
@ SPELL_CLEAVE
@ SPELL_BREATH_NE_TO_SW
@ SPELL_WING_BUFFET
@ SPELL_BELLOWING_ROAR
@ SPELL_BREATH_SE_TO_NW
@ SPELL_FLAME_BREATH
@ SPELL_BREATH_SOUTH_TO_NORTH
@ SPELL_BREATH_NORTH_TO_SOUTH
@ SPELL_FIREBALL
@ SPELL_DEEP_BREATH
@ SPELL_BREATH_WEST_TO_EAST
@ SPELL_BREATH_SW_TO_NE
@ SPELL_BREATH_EAST_TO_WEST
@ SPELL_BREATH_NW_TO_SE
@ SPELL_TAIL_SWEEP
static OnyxMove MoveData[8]
Position const MiddleRoomLocation
Position const Phase2Location
Position const SpawnLocations[3]
void AddSC_boss_onyxia()
@ EVENT_FLAME_BREATH
@ EVENT_TAIL_SWEEP
@ EVENT_MOVEMENT
@ EVENT_FIREBALL
@ EVENT_WING_BUFFET
@ EVENT_LAIR_GUARD
@ EVENT_DEEP_BREATH
@ EVENT_BELLOWING_ROAR
@ EVENT_WHELP_SPAWN
@ EVENT_CLEAVE
Yells
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
bool UpdateVictim()
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Creature *const me
Definition CreatureAI.h:63
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:388
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 ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void TriggerGameEvent(uint32 gameEventId, WorldObject *source=nullptr, WorldObject *target=nullptr) override
void MoveTakeoff(uint32 id, Position const &pos, Optional< int32 > tierTransitionId={}, Optional< float > velocity={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
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 Clear()
Definition ObjectGuid.h:329
uint32 GetEntry() const
Definition Object.h:89
uint32 const Id
Definition SpellInfo.h:328
void Summon(Creature const *summon)
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:79
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:162
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3231
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:3201
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition Unit.cpp:13307
bool SetDisableGravity(bool disable, bool updateAnimTier=true)
Definition Unit.cpp:13361
bool SetCanFly(bool enable)
Definition Unit.cpp:13459
bool isMoving() const
Definition Unit.h:1804
Unit * GetVictim() const
Definition Unit.h:726
void SetSpeedRate(UnitMoveType mtype, float rate)
Definition Unit.cpp:8942
void SetFacingTo(float const ori, bool force=true)
Definition Unit.cpp:13289
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool AttackStop()
Definition Unit.cpp:5965
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition Unit.cpp:11225
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1398
void setActive(bool isActiveObject)
Definition Object.cpp:276
void SetFarVisible(bool on)
Definition Object.cpp:327
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:100
virtual void SetGuidData(uint32, ObjectGuid)
Definition ZoneScript.h:92
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ DATA_SHE_DEEP_BREATH_MORE
@ DATA_ONYXIA_PHASE
@ PHASE_BREATH
@ PHASE_START
@ PHASE_END
#define RegisterOnyxiasLairCreatureAI(ai_name)
@ NPC_WHELP
@ NPC_LAIRGUARD
@ NPC_TRIGGER
@ DATA_FLOOR_ERUPTION_GUID
@ DATA_ONYXIA
@ ACHIEV_TIMED_START_EVENT
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:179
uint8 LocIdEnd
uint8 LocId
uint32 SpellId
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr float GetOrientation() const
Definition Position.h:90
constexpr float GetPositionZ() const
Definition Position.h:89
void SetCombatMovement(bool allowMovement)
T const & RAID_MODE(T const &normal10, T const &normal25) const
bool HealthBelowPct(uint32 pct) const
void MovementInform(uint32 type, uint32 id) override
void JustEngagedWith(Unit *who) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
boss_onyxia(Creature *creature)
OnyxMove * GetMoveData()
void Reset() override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
uint8 SummonWhelpCount
ObjectGuid tankGUID
void SetNextRandomPoint()
void KilledUnit(Unit *) override
ObjectGuid triggerGUID
void UpdateAI(uint32 diff) override
void JustSummoned(Creature *summoned) override
void Initialize()
OnyxMove * PointData