This repository has been archived by the owner on Jan 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboss_patchwerk.cpp
167 lines (145 loc) · 5.32 KB
/
boss_patchwerk.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: Boss_Patchwerk
SD%Complete: 99
SDComment:
SDCategory: Naxxramas
EndScriptData */
#include "precompiled.h"
#include "def_naxxramas.h"
#define SAY_AGGRO1 -1533017
#define SAY_AGGRO2 -1533018
#define SAY_SLAY -1533019
#define SAY_DEATH -1533020
#define EMOTE_BERSERK -1533021
#define EMOTE_ENRAGE -1533022
#define SPELL_HATEFULSTRIKE 28308
#define H_SPELL_HATEFULSTRIKE 59192
#define SPELL_ENRAGE 28131
#define SPELL_BERSERK 26662
#define SPELL_SLIMEBOLT 32309
struct MANGOS_DLL_DECL boss_patchwerkAI : public ScriptedAI
{
boss_patchwerkAI(Creature* pCreature) : ScriptedAI(pCreature)
{
pInstance = (ScriptedInstance*)pCreature->GetInstanceData();
IsHeroicMode = pCreature->GetMap()->IsHeroic();
Reset();
}
ScriptedInstance* pInstance;
bool IsHeroicMode;
uint32 HatefullStrike_Timer;
uint32 Enrage_Timer;
uint32 Slimebolt_Timer;
uint32 hatefull_tar;
bool Enraged;
void Reset()
{
HatefullStrike_Timer = 1200; //1.2 seconds
Enrage_Timer = 420000; //7 minutes 420,000
Slimebolt_Timer = 450000; //7.5 minutes 450,000
hatefull_tar = IsHeroicMode ? 3 : 2;
Enraged = false;
if(GameObject* pDoor = pInstance->instance->GetGameObject(pInstance->GetData64(GO_CONS_PATH_EXIT_DOOR)))
pDoor->SetGoState(GO_STATE_READY);
pInstance->SetData(DATA_PATCHWERK_EVENT,NOT_STARTED);
}
void KilledUnit(Unit* Victim)
{
DoScriptText(SAY_SLAY, m_creature);
}
void JustDied(Unit* Killer)
{
DoScriptText(SAY_DEATH, m_creature);
pInstance->SetData(DATA_PATCHWERK_EVENT,DONE);
if(GameObject* pDoor = pInstance->instance->GetGameObject(pInstance->GetData64(GO_CONS_PATH_EXIT_DOOR)))
pDoor->SetGoState(GO_STATE_ACTIVE);
}
void Aggro(Unit *who)
{
if (rand()%2)
DoScriptText(SAY_AGGRO1, m_creature);
else
DoScriptText(SAY_AGGRO2, m_creature);
pInstance->SetData(DATA_PATCHWERK_EVENT,IN_PROGRESS);
}
void UpdateAI(const uint32 diff)
{
if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
return;
//HatefullStrike_Timer
if (HatefullStrike_Timer < diff)
{
//Cast Hateful strike on the player with the highest
//amount of HP within melee distance
uint32 MostHP = 0;
Unit* pMostHPTarget = NULL;
Unit* pTemp = NULL;
std::list<HostilReference*>::iterator i = m_creature->getThreatManager().getThreatList().begin();
for (i = m_creature->getThreatManager().getThreatList().begin(); i!=m_creature->getThreatManager().getThreatList().end(); ++i)
{
pTemp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid());
if (pTemp && pTemp->isAlive() && pTemp->GetHealth() > MostHP && m_creature->IsWithinDist(pTemp, 5.0f, false))
{
MostHP = pTemp->GetHealth();
pMostHPTarget = pTemp;
}
}
if (pMostHPTarget)
DoCast(pMostHPTarget,IsHeroicMode ? H_SPELL_HATEFULSTRIKE : SPELL_HATEFULSTRIKE,true);
for(uint32 i = 0;i<hatefull_tar;i++)
{
Unit* Tar = SelectUnit(SELECT_TARGET_TOPAGGRO,i);
m_creature->AddThreat(Tar,5000.0f); //wrong +threat
}
HatefullStrike_Timer = 1200;
}else HatefullStrike_Timer -= diff;
//Enrage_Timer
if (Enrage_Timer < diff)
{
DoCast(m_creature, SPELL_BERSERK);
DoScriptText(EMOTE_BERSERK, m_creature);
Enrage_Timer = 300000;
}else Enrage_Timer -= diff;
//Slimebolt_Timer
if (Slimebolt_Timer < diff)
{
DoCast(m_creature->getVictim(),SPELL_SLIMEBOLT);
Slimebolt_Timer = 5000;
}else Slimebolt_Timer -= diff;
//Enrage if not already enraged and below 5%
if (!Enraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 5)
{
DoCast(m_creature,SPELL_ENRAGE);
DoScriptText(EMOTE_ENRAGE,NULL);
Enraged = true;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_boss_patchwerk(Creature* pCreature)
{
return new boss_patchwerkAI(pCreature);
}
void AddSC_boss_patchwerk()
{
Script *newscript;
newscript = new Script;
newscript->Name = "boss_patchwerk";
newscript->GetAI = &GetAI_boss_patchwerk;
newscript->RegisterSelf();
}