TrinityCore
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
80{
91};
92
94{
98 float fX, fY, fZ;
99};
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
157 void JustEngagedWith(Unit* who) override
158 {
166 }
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
489{
491}
#define M_PI
Definition: Common.h:115
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ FAIL
@ POINT_MOTION_TYPE
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: ObjectDefines.h:67
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
@ MOVE_FLIGHT
Definition: UnitDefines.h:123
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ SAY_AGGRO
Definition: boss_onyxia.cpp:41
@ SAY_PHASE_2_TRANS
Definition: boss_onyxia.cpp:43
@ EMOTE_BREATH
Definition: boss_onyxia.cpp:46
@ SAY_KILL
Definition: boss_onyxia.cpp:42
@ SAY_PHASE_3_TRANS
Definition: boss_onyxia.cpp:44
Position const Phase2Floating
@ SPELL_CLEAVE
Definition: boss_onyxia.cpp:54
@ SPELL_BREATH_NE_TO_SW
Definition: boss_onyxia.cpp:71
@ SPELL_WING_BUFFET
Definition: boss_onyxia.cpp:52
@ SPELL_BELLOWING_ROAR
Definition: boss_onyxia.cpp:76
@ SPELL_BREATH_SE_TO_NW
Definition: boss_onyxia.cpp:68
@ SPELL_FLAME_BREATH
Definition: boss_onyxia.cpp:53
@ SPELL_BREATH_SOUTH_TO_NORTH
Definition: boss_onyxia.cpp:63
@ SPELL_BREATH_NORTH_TO_SOUTH
Definition: boss_onyxia.cpp:62
@ SPELL_FIREBALL
Definition: boss_onyxia.cpp:59
@ SPELL_DEEP_BREATH
Definition: boss_onyxia.cpp:58
@ SPELL_BREATH_WEST_TO_EAST
Definition: boss_onyxia.cpp:66
@ SPELL_BREATH_SW_TO_NE
Definition: boss_onyxia.cpp:70
@ SPELL_BREATH_EAST_TO_WEST
Definition: boss_onyxia.cpp:65
@ SPELL_BREATH_NW_TO_SE
Definition: boss_onyxia.cpp:69
@ SPELL_TAIL_SWEEP
Definition: boss_onyxia.cpp:55
static OnyxMove MoveData[8]
Position const MiddleRoomLocation
Position const Phase2Location
Position const SpawnLocations[3]
void AddSC_boss_onyxia()
@ EVENT_FLAME_BREATH
Definition: boss_onyxia.cpp:82
@ EVENT_TAIL_SWEEP
Definition: boss_onyxia.cpp:83
@ EVENT_MOVEMENT
Definition: boss_onyxia.cpp:87
@ EVENT_FIREBALL
Definition: boss_onyxia.cpp:88
@ EVENT_WING_BUFFET
Definition: boss_onyxia.cpp:85
@ EVENT_LAIR_GUARD
Definition: boss_onyxia.cpp:89
@ EVENT_DEEP_BREATH
Definition: boss_onyxia.cpp:86
@ EVENT_BELLOWING_ROAR
Definition: boss_onyxia.cpp:81
@ EVENT_WHELP_SPAWN
Definition: boss_onyxia.cpp:90
@ EVENT_CLEAVE
Definition: boss_onyxia.cpp:84
Yells
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void DoZoneInCombat()
Definition: CreatureAI.h:161
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
Definition: Creature.cpp:2822
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:373
void SetReactState(ReactStates st)
Definition: Creature.h:160
CreatureAI * AI() const
Definition: Creature.h:214
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void TriggerGameEvent(uint32 gameEventId, WorldObject *source=nullptr, WorldObject *target=nullptr) override
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
void MoveTakeoff(uint32 id, Position const &pos, Optional< int32 > tierTransitionId={}, Optional< float > velocity={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void Clear()
Definition: ObjectGuid.h:286
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
uint32 const Id
Definition: SpellInfo.h:325
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:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:3059
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition: Unit.cpp:12671
bool SetDisableGravity(bool disable, bool updateAnimTier=true)
Definition: Unit.cpp:12725
bool SetCanFly(bool enable)
Definition: Unit.cpp:12820
bool isMoving() const
Definition: Unit.h:1732
Unit * GetVictim() const
Definition: Unit.h:715
void SetSpeedRate(UnitMoveType mtype, float rate)
Definition: Unit.cpp:8525
void SetFacingTo(float const ori, bool force=true)
Definition: Unit.cpp:12653
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool AttackStop()
Definition: Unit.cpp:5781
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition: Unit.cpp:10591
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:2025
void setActive(bool isActiveObject)
Definition: Object.cpp:922
void SetFarVisible(bool on)
Definition: Object.cpp:973
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
virtual void SetGuidData(uint32, ObjectGuid)
Definition: ZoneScript.h:84
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
Definition: onyxias_lair.h:36
@ DATA_ONYXIA_PHASE
Definition: onyxias_lair.h:35
@ PHASE_BREATH
Definition: onyxias_lair.h:49
@ PHASE_START
Definition: onyxias_lair.h:48
@ PHASE_END
Definition: onyxias_lair.h:50
#define RegisterOnyxiasLairCreatureAI(ai_name)
Definition: onyxias_lair.h:82
@ NPC_WHELP
Definition: onyxias_lair.h:55
@ NPC_LAIRGUARD
Definition: onyxias_lair.h:56
@ NPC_TRIGGER
Definition: onyxias_lair.h:58
@ DATA_FLOOR_ERUPTION_GUID
Definition: onyxias_lair.h:43
@ DATA_ONYXIA
Definition: onyxias_lair.h:30
@ ACHIEV_TIMED_START_EVENT
Definition: onyxias_lair.h:73
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
uint8 LocIdEnd
Definition: boss_onyxia.cpp:96
uint8 LocId
Definition: boss_onyxia.cpp:95
float fY
Definition: boss_onyxia.cpp:98
uint32 SpellId
Definition: boss_onyxia.cpp:97
float fZ
Definition: boss_onyxia.cpp:98
float fX
Definition: boss_onyxia.cpp:98
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetOrientation() const
Definition: Position.h:79
constexpr float GetPositionZ() const
Definition: Position.h:78
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