TrinityCore
boss_patchwerk.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 * He should call trash(from the room with Embalming Slime up to frogger(not sure
20 if trash before Embalming Slime too or not)) after aggro
21 */
22
23#include "ScriptMgr.h"
24#include "InstanceScript.h"
25#include "naxxramas.h"
26#include "ScriptedCreature.h"
27
29{
34 EMOTE_FRENZY = 4
35};
36
38{
40 SPELL_FRENZY = 28131,
42 SPELL_SLIME_BOLT = 32309
43};
44
45#define SPELL_HATEFUL_STRIKE RAID_MODE(28308,59192)
46
48{
52};
53
54enum Misc
55{
57};
58
60{
62};
63
64struct boss_patchwerk : public BossAI
65{
66 boss_patchwerk(Creature* creature) : BossAI(creature, BOSS_PATCHWERK), _enraged(false) { }
67
68 void Reset() override
69 {
70 _Reset();
71 _enraged = false;
72 }
73
74 void KilledUnit(Unit* /*Victim*/) override
75 {
76 // 20s cd, not random
77 if (!(rand32() % 5))
79 }
80
81 void JustDied(Unit* /*killer*/) override
82 {
83 _JustDied();
85 }
86
87 void JustEngagedWith(Unit* who) override
88 {
93
95 }
96
97 void UpdateAI(uint32 diff) override
98 {
99 if (!UpdateVictim())
100 return;
101
102 events.Update(diff);
103
104 while (uint32 eventId = events.ExecuteEvent())
105 {
106 switch (eventId)
107 {
108 // Move everything to SPELL_HATEFUL_STRIKE_PRIMER spell script
109 case EVENT_HATEFUL:
110 {
111 // Hateful Strike targets the highest non-MT threat in melee range on 10man
112 // and the higher HP target out of the two highest non-MT threats in melee range on 25man
113 ThreatReference* secondThreat = nullptr;
114 ThreatReference* thirdThreat = nullptr;
115
117 Unit* currentVictim = mgr.GetCurrentVictim();
118 auto list = mgr.GetModifiableThreatList();
119 auto it = list.begin(), end = list.end();
120 if (it == end)
121 {
123 return;
124 }
125
126 if ((*it)->GetVictim() != currentVictim)
127 secondThreat = *it;
128 if ((!secondThreat || Is25ManRaid()) && (++it != end && (*it)->IsAvailable()))
129 {
130 if ((*it)->GetVictim() != currentVictim)
131 (secondThreat ? thirdThreat : secondThreat) = *it;
132 if (!thirdThreat && Is25ManRaid() && (++it != end && (*it)->IsAvailable()))
133 thirdThreat = *it;
134 }
135
136 Unit* pHatefulTarget = nullptr;
137 if (!secondThreat)
138 pHatefulTarget = currentVictim;
139 else if (!thirdThreat)
140 pHatefulTarget = secondThreat->GetVictim();
141 else
142 pHatefulTarget = (secondThreat->GetVictim()->GetHealth() < thirdThreat->GetVictim()->GetHealth()) ? thirdThreat->GetVictim() : secondThreat->GetVictim();
143
144 // add threat to highest threat targets
145 AddThreat(currentVictim, HATEFUL_THREAT_AMT);
146 if (secondThreat)
147 secondThreat->AddThreat(HATEFUL_THREAT_AMT);
148 if (thirdThreat)
149 thirdThreat->AddThreat(HATEFUL_THREAT_AMT);
150
151 DoCast(pHatefulTarget, SPELL_HATEFUL_STRIKE, true);
152
153 events.Repeat(1200ms);
154 break;
155 }
156 case EVENT_BERSERK:
160 break;
161 case EVENT_SLIME:
164 break;
165 }
166 }
167
168 if (!_enraged && !HealthAbovePct(5))
169 {
172 _enraged = true;
173 }
174 }
175
176private:
178};
179
181{
183}
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
uint32 rand32()
Definition: Random.cpp:70
PatchwerkTexts
@ SAY_DEATH
@ SAY_AGGRO
@ EMOTE_FRENZY
@ SAY_SLAY
@ EMOTE_BERSERK
@ ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT
PatchwerkSpells
@ SPELL_SLIME_BOLT
@ SPELL_FRENZY
@ SPELL_BERSERK
@ SPELL_HATEFUL_STRIKE_PRIMER
void AddSC_boss_patchwerk()
PatchwerkEvents
@ EVENT_SLIME
@ EVENT_BERSERK
@ EVENT_HATEFUL
HatefulThreatAmounts
@ HATEFUL_THREAT_AMT
#define SPELL_HATEFUL_STRIKE
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
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
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
void TriggerGameEvent(uint32 gameEventId, WorldObject *source=nullptr, WorldObject *target=nullptr) override
Unit * GetCurrentVictim()
std::vector< ThreatReference * > GetModifiableThreatList()
Unit * GetVictim() const
void AddThreat(float amount)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
ThreatManager & GetThreatManager()
Definition: Unit.h:1063
uint64 GetHealth() const
Definition: Unit.h:776
@ BOSS_PATCHWERK
Definition: naxxramas.h:36
#define RegisterNaxxramasCreatureAI(ai_name)
Definition: naxxramas.h:221
bool HealthAbovePct(uint32 pct) const
bool Is25ManRaid() const
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
boss_patchwerk(Creature *creature)
void JustEngagedWith(Unit *who) override
void KilledUnit(Unit *) override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) override
void Reset() override