TrinityCore
boss_noth.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#include "ScriptMgr.h"
19#include "MotionMaster.h"
20#include "naxxramas.h"
21#include "ScriptedCreature.h"
22
24{
28};
29
31{
32 EVENT_CURSE = 1, // curse of the plaguebringer
33 EVENT_BLINK, // blink (25m only)
34 EVENT_WARRIOR, // summon warriors during ground phase
35 EVENT_BALCONY, // become untargetable and begin balcony phase
36 EVENT_BALCONY_TELEPORT, // actually teleport to balcony, this is slightly delayed
37 EVENT_WAVE, // spawn wave during balcony phase
38 EVENT_GROUND, // end balcony phase and teleport to ground
39 EVENT_GROUND_ATTACKABLE // become attackable and aggressive again at start of ground phase, once again slightly delayed to prevent motionmaster weirdness
40};
41
42enum Talk
43{
48
49 EMOTE_SUMMON = 4, // ground phase
50 EMOTE_SUMMON_WAVE = 5, // balcony phase
51 EMOTE_TELEPORT_1 = 6, // ground to balcony
52 EMOTE_TELEPORT_2 = 7 // balcony to ground
53};
54
56{
57 SPELL_CURSE = 29213,
61
62 SPELL_TELEPORT = 29216, // ground to balcony
63 SPELL_TELEPORT_BACK = 29231 // balcony to ground
64};
65
66enum Adds
67{
71};
72const uint32 SummonWarriorSpells[N_WARRIOR_SPELLS] = { 29247, 29248, 29249 };
73const uint32 SummonChampionSpells[N_CHAMPION_SPELLS] = { 29238, 29255, 29257, 29258, 29262, 29267 };
74const uint32 SummonGuardianSpells[N_GUARDIAN_SPELLS] = { 29239, 29256, 29268 };
75
76#define SPELL_BLINK RAND(29208, 29209, 29210, 29211)
77
78struct boss_noth : public BossAI
79{
80 boss_noth(Creature* creature) : BossAI(creature, BOSS_NOTH), balconyCount(0), justBlinked(false)
81 {
85
87 }
88
89 void EnterEvadeMode(EvadeReason why) override
90 {
91 // in case we reset during balcony phase
95 }
96
97 void Reset() override
98 {
99 _Reset();
100
102 me->SetUninteractible(false);
103
104 balconyCount = 0;
106 justBlinked = false;
107 }
108
109 void JustEngagedWith(Unit* who) override
110 {
114 }
115
117 {
119
121
122 if (!me->IsThreatened())
124 else
125 {
126 uint8 timeGround;
127 switch (balconyCount)
128 {
129 case 0:
130 timeGround = 90;
131 break;
132 case 1:
133 timeGround = 110;
134 break;
135 case 2:
136 default:
137 timeGround = 180;
138 }
145 }
146 }
147
148 void KilledUnit(Unit* victim) override
149 {
150 if (victim->GetTypeId() == TYPEID_PLAYER)
151 Talk(SAY_SLAY);
152 }
153
154 void JustSummoned(Creature* summon) override
155 {
156 summons.Summon(summon);
157 summon->setActive(true);
158 summon->SetFarVisible(true);
159 summon->AI()->DoZoneInCombat();
160 }
161
162 void JustDied(Unit* /*killer*/) override
163 {
164 _JustDied();
166 }
167
168 void DamageTaken(Unit* /*who*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override // prevent noth from somehow dying in the balcony phase
169 {
171 return;
172 if (damage < me->GetHealth())
173 return;
174
175 me->SetHealth(1u);
176 damage = 0u;
177 }
178
179 void HandleSummon(uint32* spellsList, const uint8 nSpells, uint8 num)
180 { // this ensures we do not spawn two mobs using the same spell (<=> in the same position) if we can help it
181 while (num)
182 for (uint8 it = 0; it < nSpells && num; ++it)
183 {
184 num--;
185 uint8 selected = urand(it, nSpells - 1);
186 DoCastAOE(spellsList[selected]);
187 if (selected != it) // shuffle the selected into the part of the array that is no longer being searched
188 std::swap(spellsList[selected], spellsList[it]);
189 }
190 }
191
192 void CastSummon(uint8 nWarrior, uint8 nChampion, uint8 nGuardian)
193 {
197 }
198
199 void UpdateAI(uint32 diff) override
200 {
201 if (!UpdateVictim())
202 return;
203
204 events.Update(diff);
205
207 return;
208
209 while (uint32 eventId = events.ExecuteEvent())
210 {
211 switch (eventId)
212 {
213 case EVENT_CURSE:
214 {
217 break;
218 }
219 case EVENT_WARRIOR:
222
223 CastSummon(RAID_MODE(2, 3), 0, 0);
224
225 events.Repeat(Seconds(40));
226 break;
227 case EVENT_BLINK:
231 justBlinked = true;
232
233 events.Repeat(Seconds(40));
234 break;
235 case EVENT_BALCONY:
238 me->SetUninteractible(true);
239 me->AttackStop();
240 me->StopMoving();
242
245
246 uint8 timeBalcony;
247 switch (balconyCount)
248 {
249 case 0:
250 timeBalcony = 70;
251 break;
252 case 1:
253 timeBalcony = 97;
254 break;
255 case 2:
256 default:
257 timeBalcony = 120;
258 break;
259 }
261 break;
265 break;
266 case EVENT_WAVE:
268 switch (balconyCount)
269 {
270 case 0:
271 CastSummon(0, RAID_MODE(2, 4), 0);
272 break;
273 case 1:
274 CastSummon(0, RAID_MODE(1, 2), RAID_MODE(1, 2));
275 break;
276 case 2:
277 CastSummon(0, 0, RAID_MODE(2, 4));
278 break;
279 default:
280 CastSummon(0, RAID_MODE(5, 10), RAID_MODE(5, 10));
281 break;
282 }
284 break;
285 case EVENT_GROUND:
286 ++balconyCount;
287
290
292 break;
294 me->SetUninteractible(false);
296 break;
297 }
298
300 return;
301 }
302
304 {
305 /* workaround for movechase breaking after blinking
306 without this noth would just stand there unless his current target moves */
308 {
311 justBlinked = false;
312 }
313 }
314 }
315
316 private:
318
320
324};
325
327{
329}
@ DIFFICULTY_25_N
Definition: DBCEnums.h:878
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition: Random.cpp:62
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
const uint32 SummonWarriorSpells[N_WARRIOR_SPELLS]
Definition: boss_noth.cpp:72
@ N_CHAMPION_SPELLS
Definition: boss_noth.cpp:69
@ N_WARRIOR_SPELLS
Definition: boss_noth.cpp:68
@ N_GUARDIAN_SPELLS
Definition: boss_noth.cpp:70
@ SPELL_TELEPORT_BACK
Definition: boss_noth.cpp:63
@ SPELL_CRIPPLE
Definition: boss_noth.cpp:58
@ SPELL_TELEPORT
Definition: boss_noth.cpp:62
@ SPELL_CRIPPLE_25
Definition: boss_noth.cpp:60
@ SPELL_CURSE_25
Definition: boss_noth.cpp:59
@ SPELL_CURSE
Definition: boss_noth.cpp:57
@ PHASE_NONE
Definition: boss_noth.cpp:25
@ PHASE_GROUND
Definition: boss_noth.cpp:26
@ PHASE_BALCONY
Definition: boss_noth.cpp:27
@ SAY_DEATH
Definition: boss_noth.cpp:47
@ SAY_AGGRO
Definition: boss_noth.cpp:44
@ EMOTE_SUMMON
Definition: boss_noth.cpp:49
@ SAY_SLAY
Definition: boss_noth.cpp:46
@ EMOTE_TELEPORT_1
Definition: boss_noth.cpp:51
@ SAY_SUMMON
Definition: boss_noth.cpp:45
@ EMOTE_SUMMON_WAVE
Definition: boss_noth.cpp:50
@ EMOTE_TELEPORT_2
Definition: boss_noth.cpp:52
#define SPELL_BLINK
Definition: boss_noth.cpp:76
const uint32 SummonChampionSpells[N_CHAMPION_SPELLS]
Definition: boss_noth.cpp:73
void AddSC_boss_noth()
Definition: boss_noth.cpp:326
@ EVENT_CURSE
Definition: boss_noth.cpp:32
@ EVENT_BLINK
Definition: boss_noth.cpp:33
@ EVENT_GROUND
Definition: boss_noth.cpp:38
@ EVENT_GROUND_ATTACKABLE
Definition: boss_noth.cpp:39
@ EVENT_WAVE
Definition: boss_noth.cpp:37
@ EVENT_BALCONY
Definition: boss_noth.cpp:35
@ EVENT_WARRIOR
Definition: boss_noth.cpp:34
@ EVENT_BALCONY_TELEPORT
Definition: boss_noth.cpp:36
const uint32 SummonGuardianSpells[N_GUARDIAN_SPELLS]
Definition: boss_noth.cpp:74
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void _JustDied()
void DoZoneInCombat()
Definition: CreatureAI.h:161
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
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 Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
TypeID GetTypeId() const
Definition: Object.h:173
void Summon(Creature const *summon)
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
Definition: Unit.h:627
bool IsWithinMeleeRange(Unit const *obj) const
Definition: Unit.h:699
void SetHealth(uint64 val)
Definition: Unit.cpp:9346
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void StopMoving()
Definition: Unit.cpp:10049
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
Unit * EnsureVictim() const
Definition: Unit.h:717
bool IsThreatened() const
Definition: Unit.cpp:8163
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
void RemoveAllAuras()
Definition: Unit.cpp:4242
bool AttackStop()
Definition: Unit.cpp:5781
void setActive(bool isActiveObject)
Definition: Object.cpp:922
void SetFarVisible(bool on)
Definition: Object.cpp:973
@ BOSS_NOTH
Definition: naxxramas.h:33
#define RegisterNaxxramasCreatureAI(ai_name)
Definition: naxxramas.h:221
T const & RAID_MODE(T const &normal10, T const &normal25) const
Difficulty GetDifficulty() const
void ResetThreatList(Unit *who=nullptr)
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
Definition: boss_noth.cpp:168
uint32 _SummonGuardianSpells[N_GUARDIAN_SPELLS]
Definition: boss_noth.cpp:323
void Reset() override
Definition: boss_noth.cpp:97
uint32 balconyCount
Definition: boss_noth.cpp:317
void EnterEvadeMode(EvadeReason why) override
Definition: boss_noth.cpp:89
uint32 _SummonWarriorSpells[N_WARRIOR_SPELLS]
Definition: boss_noth.cpp:321
void JustSummoned(Creature *summon) override
Definition: boss_noth.cpp:154
void EnterPhaseGround()
Definition: boss_noth.cpp:116
void JustDied(Unit *) override
Definition: boss_noth.cpp:162
void JustEngagedWith(Unit *who) override
Definition: boss_noth.cpp:109
boss_noth(Creature *creature)
Definition: boss_noth.cpp:80
bool justBlinked
Definition: boss_noth.cpp:319
uint32 _SummonChampionSpells[N_CHAMPION_SPELLS]
Definition: boss_noth.cpp:322
void KilledUnit(Unit *victim) override
Definition: boss_noth.cpp:148
void CastSummon(uint8 nWarrior, uint8 nChampion, uint8 nGuardian)
Definition: boss_noth.cpp:192
void UpdateAI(uint32 diff) override
Definition: boss_noth.cpp:199
void HandleSummon(uint32 *spellsList, const uint8 nSpells, uint8 num)
Definition: boss_noth.cpp:179