Small cleanup in boss Ouro script.
[scriptdev2-git.git] / scripts / kalimdor / temple_of_ahnqiraj / boss_ouro.cpp
bloba4ac81597b5d1e2cde1d0c4a5f03524289f6198f
1 /* Copyright (C) 2006 - 2010 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 /* ScriptData
18 SDName: Boss_Ouro
19 SD%Complete: 50
20 SDComment: script needs to be reworked
21 SDCategory: Temple of Ahn'Qiraj
22 EndScriptData */
24 #include "precompiled.h"
25 #include "temple_of_ahnqiraj.h"
27 enum
29 SPELL_SWEEP = 26103,
30 SPELL_SANDBLAST = 26102,
31 SPELL_GROUND_RUPTURE = 26100,
32 SPELL_BIRTH = 26262, //The Birth Animation
33 SPELL_BOULDER = 26616,
34 SPELL_BERSERK = 26615,
36 SPELL_SUMMON_SCARABS = 26060,
37 SPELL_SUMMON_OURO_MOUND = 26058,
38 SPELL_SUMMON_OURO = 26642,
40 SPELL_DIRTMOUND_PASSIVE = 26092,
41 SPELL_SUBMERGE_VISUAL = 26063,
43 NPC_OURO_SCARAB = 15718,
44 NPC_OURO_SPAWNER = 15957,
45 NPC_OURO_TRIGGER = 15717
48 struct MANGOS_DLL_DECL boss_ouroAI : public ScriptedAI
50 boss_ouroAI(Creature* pCreature) : ScriptedAI(pCreature) {Reset();}
52 uint32 m_uiSweepTimer;
53 uint32 m_uiSandBlastTimer;
54 uint32 m_uiSubmergeTimer;
55 uint32 m_uiBackTimer;
56 uint32 m_uiChangeTargetTimer;
57 uint32 m_uiSpawnTimer;
59 bool m_bEnraged;
60 bool m_bSubmerged;
62 void Reset()
64 m_uiSweepTimer = urand(5000, 10000);
65 m_uiSandBlastTimer = urand(20000, 35000);
66 m_uiSubmergeTimer = urand(90000, 150000);
67 m_uiBackTimer = urand(30000, 45000);
68 m_uiChangeTargetTimer = urand(5000, 8000);
69 m_uiSpawnTimer = urand(10000, 20000);
71 m_bEnraged = false;
72 m_bSubmerged = false;
75 void Aggro(Unit* pWho)
77 DoCastSpellIfCan(m_creature, SPELL_BIRTH);
80 void UpdateAI(const uint32 uiDiff)
82 // Return since we have no pTarget
83 if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
84 return;
86 if (!m_bSubmerged)
88 // Sweep
89 if (m_uiSweepTimer < uiDiff)
91 DoCastSpellIfCan(m_creature->getVictim(), SPELL_SWEEP);
92 m_uiSweepTimer = urand(15000, 30000);
94 else
95 m_uiSweepTimer -= uiDiff;
97 // Sand Blast
98 if (m_uiSandBlastTimer < uiDiff)
100 DoCastSpellIfCan(m_creature->getVictim(), SPELL_SANDBLAST);
101 m_uiSandBlastTimer = urand(20000, 35000);
103 else
104 m_uiSandBlastTimer -= uiDiff;
106 if (!m_bEnraged)
108 if (m_creature->GetHealthPercent() < 20.0f)
110 DoCastSpellIfCan(m_creature, SPELL_BERSERK);
111 m_bEnraged = true;
112 return;
115 // Submerge
116 if (m_uiSubmergeTimer < uiDiff)
118 //Cast
119 m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE);
120 m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
121 m_creature->setFaction(35);
122 DoCastSpellIfCan(m_creature, SPELL_DIRTMOUND_PASSIVE);
124 m_bSubmerged = true;
125 m_uiBackTimer = urand(30000, 45000);
127 else
128 m_uiSubmergeTimer -= uiDiff;
131 DoMeleeAttackIfReady();
133 else
135 // Change Target
136 if (m_uiChangeTargetTimer < uiDiff)
138 if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
140 m_creature->GetMap()->CreatureRelocation(m_creature, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0.0f);
141 m_creature->SendMonsterMove(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), SPLINETYPE_NORMAL, SPLINEFLAG_WALKMODE, 1);
144 m_uiChangeTargetTimer = urand(10000, 20000);
146 else
147 m_uiChangeTargetTimer -= uiDiff;
149 // Back
150 if (m_uiBackTimer < uiDiff)
152 m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
153 m_creature->setFaction(14);
155 DoCastSpellIfCan(m_creature->getVictim(), SPELL_GROUND_RUPTURE);
157 m_bSubmerged = false;
158 m_uiSubmergeTimer = urand(60000, 120000);
160 else
161 m_uiBackTimer -= uiDiff;
166 CreatureAI* GetAI_boss_ouro(Creature* pCreature)
168 return new boss_ouroAI(pCreature);
171 void AddSC_boss_ouro()
173 Script* newscript;
174 newscript = new Script;
175 newscript->Name = "boss_ouro";
176 newscript->GetAI = &GetAI_boss_ouro;
177 newscript->RegisterSelf();