@@ -55,139 +55,127 @@ enum HatefulThreatAmounts
5555 HATEFUL_THREAT_AMT =1000 ,
5656};
5757
58- class boss_patchwerk :public CreatureScript
58+ struct boss_patchwerk :public BossAI
5959{
60- public:
61- boss_patchwerk () : CreatureScript(" boss_patchwerk" ) { }
62-
63- CreatureAI*GetAI (Creature* creature)const override
60+ boss_patchwerk (Creature* creature) : BossAI(creature, BOSS_PATCHWERK)
6461 {
65- return GetNaxxramasAI<boss_patchwerkAI>(creature) ;
62+ Enraged = false ;
6663 }
6764
68- struct boss_patchwerkAI :public BossAI
65+ bool Enraged;
66+
67+ void Reset ()override
6968 {
70- boss_patchwerkAI (Creature* creature) : BossAI(creature, BOSS_PATCHWERK)
71- {
72- Enraged =false ;
73- }
69+ _Reset ();
7470
75- bool Enraged;
71+ instance->DoStopTimedAchievement (ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
72+ }
7673
77- void Reset ()override
78- {
79- _Reset ();
74+ void KilledUnit (Unit*/* Victim*/ )override
75+ {
76+ if (!(rand32 () %5 ))
77+ Talk (SAY_SLAY);
78+ }
8079
81- instance->DoStopTimedAchievement (ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
82- }
80+ void JustDied (Unit*/* killer*/ )override
81+ {
82+ _JustDied ();
83+ Talk (SAY_DEATH);
84+ }
8385
84- void KilledUnit (Unit*/* Victim*/ )override
85- {
86- if (!(rand32 () %5 ))
87- Talk (SAY_SLAY);
88- }
86+ void JustEngagedWith (Unit* who)override
87+ {
88+ BossAI::JustEngagedWith (who);
89+ Enraged =false ;
90+ Talk (SAY_AGGRO);
91+ events.ScheduleEvent (EVENT_HATEFUL, 1s);
92+ events.ScheduleEvent (EVENT_BERSERK, 6min);
8993
90- void JustDied (Unit*/* killer*/ )override
91- {
92- _JustDied ();
93- Talk (SAY_DEATH);
94- }
94+ instance->DoStartTimedAchievement (ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
95+ }
9596
96- void JustEngagedWith (Unit* who)override
97- {
98- BossAI::JustEngagedWith (who);
99- Enraged =false ;
100- Talk (SAY_AGGRO);
101- events.ScheduleEvent (EVENT_HATEFUL, 1s);
102- events.ScheduleEvent (EVENT_BERSERK, 6min);
97+ void UpdateAI (uint32 diff)override
98+ {
99+ if (!UpdateVictim ())
100+ return ;
103101
104- instance->DoStartTimedAchievement (ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
105- }
102+ events.Update (diff);
106103
107- void UpdateAI (uint32diff) override
104+ while (uint32eventId = events. ExecuteEvent ())
108105 {
109- if (!UpdateVictim ())
110- return ;
111-
112- events.Update (diff);
113-
114- while (uint32 eventId = events.ExecuteEvent ())
106+ switch (eventId)
115107 {
116- switch (eventId)
108+ case EVENT_HATEFUL:
117109 {
118- case EVENT_HATEFUL:
110+ // Hateful Strike targets the highest non-MT threat in melee range on 10man
111+ // and the higher HP target out of the two highest non-MT threats in melee range on 25man
112+ ThreatReference* secondThreat =nullptr ;
113+ ThreatReference* thirdThreat =nullptr ;
114+
115+ ThreatManager& mgr = me->GetThreatManager ();
116+ Unit* currentVictim = mgr.GetCurrentVictim ();
117+ auto list = mgr.GetModifiableThreatList ();
118+ auto it = list.begin (), end = list.end ();
119+ if (it == end)
119120 {
120- // Hateful Strike targets the highest non-MT threat in melee range on 10man
121- // and the higher HP target out of the two highest non-MT threats in melee range on 25man
122- ThreatReference* secondThreat =nullptr ;
123- ThreatReference* thirdThreat =nullptr ;
124-
125- ThreatManager& mgr = me->GetThreatManager ();
126- Unit* currentVictim = mgr.GetCurrentVictim ();
127- auto list = mgr.GetModifiableThreatList ();
128- auto it = list.begin (), end = list.end ();
129- if (it == end)
130- {
131- EnterEvadeMode (EVADE_REASON_NO_HOSTILES);
132- return ;
133- }
121+ EnterEvadeMode (EVADE_REASON_NO_HOSTILES);
122+ return ;
123+ }
134124
125+ if ((*it)->GetVictim () != currentVictim)
126+ secondThreat = *it;
127+ if ((!secondThreat ||Is25ManRaid ()) && (++it != end && (*it)->IsAvailable ()))
128+ {
135129if ((*it)->GetVictim () != currentVictim)
136- secondThreat = *it;
137- if ((!secondThreat ||Is25ManRaid ()) && (++it != end && (*it)->IsAvailable ()))
138- {
139- if ((*it)->GetVictim () != currentVictim)
140- (secondThreat ? thirdThreat : secondThreat) = *it;
141- if (!thirdThreat &&Is25ManRaid () && (++it != end && (*it)->IsAvailable ()))
142- thirdThreat = *it;
143- }
144-
145- Unit* pHatefulTarget =nullptr ;
146- if (!secondThreat)
147- pHatefulTarget = currentVictim;
148- else if (!thirdThreat)
149- pHatefulTarget = secondThreat->GetVictim ();
150- else
151- pHatefulTarget = (secondThreat->GetVictim ()->GetHealth () < thirdThreat->GetVictim ()->GetHealth ()) ? thirdThreat->GetVictim () : secondThreat->GetVictim ();
152-
153- // add threat to highest threat targets
154- AddThreat (currentVictim, HATEFUL_THREAT_AMT);
155- if (secondThreat)
156- secondThreat->AddThreat (HATEFUL_THREAT_AMT);
157- if (thirdThreat)
158- thirdThreat->AddThreat (HATEFUL_THREAT_AMT);
159-
160- DoCast (pHatefulTarget, SPELL_HATEFUL_STRIKE,true );
161-
162- events.Repeat (Seconds (1 ));
163- break ;
130+ (secondThreat ? thirdThreat : secondThreat) = *it;
131+ if (!thirdThreat &&Is25ManRaid () && (++it != end && (*it)->IsAvailable ()))
132+ thirdThreat = *it;
164133 }
165- case EVENT_BERSERK:
166- DoCast (me, SPELL_BERSERK,true );
167- Talk (EMOTE_BERSERK);
168- events.ScheduleEvent (EVENT_SLIME, 2s);
169- break ;
170- case EVENT_SLIME:
171- DoCastAOE (SPELL_SLIME_BOLT,true );
172- events.Repeat (Seconds (2 ));
173- break ;
174- }
175- }
176134
177- if (!Enraged &&HealthBelowPct (5 ))
178- {
179- DoCast (me, SPELL_FRENZY,true );
180- Talk (EMOTE_FRENZY);
181- Enraged =true ;
135+ Unit* pHatefulTarget =nullptr ;
136+ if (!secondThreat)
137+ pHatefulTarget = currentVictim;
138+ else if (!thirdThreat)
139+ pHatefulTarget = secondThreat->GetVictim ();
140+ else
141+ pHatefulTarget = (secondThreat->GetVictim ()->GetHealth () < thirdThreat->GetVictim ()->GetHealth ()) ? thirdThreat->GetVictim () : secondThreat->GetVictim ();
142+
143+ // add threat to highest threat targets
144+ AddThreat (currentVictim, HATEFUL_THREAT_AMT);
145+ if (secondThreat)
146+ secondThreat->AddThreat (HATEFUL_THREAT_AMT);
147+ if (thirdThreat)
148+ thirdThreat->AddThreat (HATEFUL_THREAT_AMT);
149+
150+ DoCast (pHatefulTarget, SPELL_HATEFUL_STRIKE,true );
151+
152+ events.Repeat (Seconds (1 ));
153+ break ;
154+ }
155+ case EVENT_BERSERK:
156+ DoCast (me, SPELL_BERSERK,true );
157+ Talk (EMOTE_BERSERK);
158+ events.ScheduleEvent (EVENT_SLIME, 2s);
159+ break ;
160+ case EVENT_SLIME:
161+ DoCastAOE (SPELL_SLIME_BOLT,true );
162+ events.Repeat (Seconds (2 ));
163+ break ;
182164 }
165+ }
183166
184- DoMeleeAttackIfReady ();
167+ if (!Enraged &&HealthBelowPct (5 ))
168+ {
169+ DoCast (me, SPELL_FRENZY,true );
170+ Talk (EMOTE_FRENZY);
171+ Enraged =true ;
185172 }
186- };
187173
174+ DoMeleeAttackIfReady ();
175+ }
188176};
189177
190178void AddSC_boss_patchwerk ()
191179{
192- new boss_patchwerk ( );
180+ RegisterNaxxramasCreatureAI (boss_patchwerk );
193181}