TrinityCore
Loading...
Searching...
No Matches
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
36
45
52
57
62
63struct boss_patchwerk : public BossAI
64{
65 boss_patchwerk(Creature* creature) : BossAI(creature, BOSS_PATCHWERK), _enraged(false) { }
66
74
75 void KilledUnit(Unit* /*Victim*/) override
76 {
77 // 20s cd, not random
78 if (!(rand32() % 5))
80 }
81
82 void JustDied(Unit* /*killer*/) override
83 {
84 _JustDied();
86 }
87
97
98 void UpdateAI(uint32 diff) override
99 {
100 if (!UpdateVictim())
101 return;
102
103 events.Update(diff);
104
105 while (uint32 eventId = events.ExecuteEvent())
106 {
107 switch (eventId)
108 {
109 // Move everything to SPELL_HATEFUL_STRIKE_PRIMER spell script
110 case EVENT_HATEFUL:
111 {
112 // Hateful Strike targets the highest non-MT threat in melee range on 10man
113 // and the higher HP target out of the two highest non-MT threats in melee range on 25man
114 ThreatReference* secondThreat = nullptr;
115 ThreatReference* thirdThreat = nullptr;
116
118 Unit* currentVictim = mgr.GetCurrentVictim();
119 auto list = mgr.GetModifiableThreatList();
120 auto it = list.begin(), end = list.end();
121 if (it == end)
122 {
124 return;
125 }
126
127 if ((*it)->GetVictim() != currentVictim)
128 secondThreat = *it;
129 if ((!secondThreat || Is25ManRaid()) && (++it != end && (*it)->IsAvailable()))
130 {
131 if ((*it)->GetVictim() != currentVictim)
132 (secondThreat ? thirdThreat : secondThreat) = *it;
133 if (!thirdThreat && Is25ManRaid() && (++it != end && (*it)->IsAvailable()))
134 thirdThreat = *it;
135 }
136
137 Unit* pHatefulTarget = nullptr;
138 if (!secondThreat)
139 pHatefulTarget = currentVictim;
140 else if (!thirdThreat)
141 pHatefulTarget = secondThreat->GetVictim();
142 else
143 pHatefulTarget = (secondThreat->GetVictim()->GetHealth() < thirdThreat->GetVictim()->GetHealth()) ? thirdThreat->GetVictim() : secondThreat->GetVictim();
144
145 // add threat to highest threat targets
146 AddThreat(currentVictim, HATEFUL_THREAT_AMT);
147 if (secondThreat)
148 secondThreat->AddThreat(HATEFUL_THREAT_AMT);
149 if (thirdThreat)
150 thirdThreat->AddThreat(HATEFUL_THREAT_AMT);
151
152 DoCast(pHatefulTarget, SPELL_HATEFUL_STRIKE, true);
153
154 events.Repeat(1200ms);
155 break;
156 }
157 case EVENT_BERSERK:
161 break;
162 case EVENT_SLIME:
165 break;
166 }
167 }
168
169 if (!_enraged && !HealthAbovePct(5))
170 {
173 _enraged = true;
174 }
175
177 }
178
179private:
181};
182
@ ACHIEVEMENT_TIMED_TYPE_EVENT
Definition DBCEnums.h:122
uint32_t uint32
Definition Define.h:133
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:27
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_HATEFUL_STRIKE
@ SPELL_BERSERK
@ SPELL_HATEFUL_STRIKE_PRIMER
void AddSC_boss_patchwerk()
PatchwerkEvents
@ EVENT_SLIME
@ EVENT_BERSERK
@ EVENT_HATEFUL
HatefulThreatAmounts
@ HATEFUL_THREAT_AMT
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
@ EVADE_REASON_NO_HOSTILES
Definition CreatureAI.h:94
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
void DoStopTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
Unit * GetCurrentVictim()
std::vector< ThreatReference * > GetModifiableThreatList()
Unit * GetVictim() const
void AddThreat(float amount)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
ThreatManager & GetThreatManager()
Definition Unit.h:1155
uint32 GetHealth() const
Definition Unit.h:913
@ 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