TrinityCore
boss_morogrim_tidewalker.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/* ScriptData
19SDName: Boss_Morogrim_Tidewalker
20SD%Complete: 90
21SDComment: Water globules don't explode properly, remove hacks
22SDCategory: Coilfang Resevoir, Serpent Shrine Cavern
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "InstanceScript.h"
27#include "Map.h"
28#include "ScriptedCreature.h"
29#include "serpent_shrine.h"
30#include "TemporarySummon.h"
31
33{
34 // Yell
40 // Emotes
44};
45
47{
52
57
62
63 // Water Globule
65};
66
68{
69 // Creatures
72};
73
74float MurlocCords[10][4] =
75{
76 {424.36f, -715.4f, -7.14f, 0.124f},
77 {425.13f, -719.3f, -7.14f, 0.124f},
78 {425.05f, -724.23f, -7.14f, 0.124f},
79 {424.91f, -728.68f, -7.14f, 0.124f},
80 {424.84f, -732.18f, -7.14f, 0.124f},
81 {321.05f, -734.2f, -13.15f, 0.124f},
82 {321.05f, -729.4f, -13.15f, 0.124f},
83 {321.05f, -724.03f, -13.15f, 0.124f},
84 {321.05f, -718.73f, -13.15f, 0.124f},
85 {321.05f, -714.24f, -13.15f, 0.124f}
86};
87
88//Morogrim Tidewalker AI
90{
92 {
93 Initialize();
94 Playercount = 0;
95 counter = 0;
96 }
97
99 {
100 TidalWave_Timer = 10000;
101 WateryGrave_Timer = 30000;
102 Earthquake_Timer = 40000;
108
109 Earthquake = false;
110 Phase2 = false;
111 }
112
120
122 bool Phase2;
123
124 void Reset() override
125 {
126 Initialize();
127
128 _Reset();
129 }
130
131 void KilledUnit(Unit* /*victim*/) override
132 {
133 Talk(SAY_SLAY);
134 }
135
136 void JustDied(Unit* /*killer*/) override
137 {
139
140 _JustDied();
141 }
142
143 void JustEngagedWith(Unit* who) override
144 {
147 _JustEngagedWith(who);
148 }
149
150 void ApplyWateryGrave(Unit* player, uint8 i)
151 {
152 switch (i)
153 {
154 case 0: player->CastSpell(player, SPELL_WATERY_GRAVE_1, true); break;
155 case 1: player->CastSpell(player, SPELL_WATERY_GRAVE_2, true); break;
156 case 2: player->CastSpell(player, SPELL_WATERY_GRAVE_3, true); break;
157 case 3: player->CastSpell(player, SPELL_WATERY_GRAVE_4, true); break;
158 }
159 }
160
161 void UpdateAI(uint32 diff) override
162 {
163 //Return since we have no target
164 if (!UpdateVictim())
165 return;
166
167 //Earthquake_Timer
168 if (Earthquake_Timer <= diff)
169 {
170 if (!Earthquake)
171 {
173 Earthquake = true;
174 Earthquake_Timer = 10000;
175 }
176 else
177 {
179
180 for (uint8 i = 0; i < 10; ++i)
181 {
184 Murloc->AI()->AttackStart(target);
185 }
187 Earthquake = false;
188 Earthquake_Timer = 40000 + rand32() % 5000;
189 }
190 } else Earthquake_Timer -= diff;
191
192 //TidalWave_Timer
193 if (TidalWave_Timer <= diff)
194 {
196 TidalWave_Timer = 20000;
197 } else TidalWave_Timer -= diff;
198
199 if (!Phase2)
200 {
201 //WateryGrave_Timer
202 if (WateryGrave_Timer <= diff)
203 {
204 //Teleport 4 players under the waterfalls
205 GuidSet targets;
206 GuidSet::const_iterator itr = targets.begin();
207 for (uint8 i = 0; i < 4; ++i)
208 {
209 counter = 0;
210 Unit* target;
211 do
212 {
213 target = SelectTarget(SelectTargetMethod::Random, 1, 50, true); //target players only
214 if (counter < Playercount)
215 break;
216 if (target)
217 itr = targets.find(target->GetGUID());
218 ++counter;
219 } while (itr != targets.end());
220
221 if (target)
222 {
223 targets.insert(target->GetGUID());
224 ApplyWateryGrave(target, i);
225 }
226 }
227
229
231 WateryGrave_Timer = 30000;
232 } else WateryGrave_Timer -= diff;
233
234 //Start Phase2
235 if (HealthBelowPct(25))
236 Phase2 = true;
237 }
238 else
239 {
240 //WateryGlobules_Timer
241 if (WateryGlobules_Timer <= diff)
242 {
243 GuidSet globules;
244 GuidSet::const_iterator itr = globules.begin();
245 for (uint8 g = 0; g < 4; g++) //one unit can't cast more than one spell per update, so some players have to cast for us XD
246 {
247 counter = 0;
248 Unit* pGlobuleTarget;
249 do
250 {
251 pGlobuleTarget = SelectTarget(SelectTargetMethod::Random, 0, 50, true);
252 if (pGlobuleTarget)
253 itr = globules.find(pGlobuleTarget->GetGUID());
254 if (counter > Playercount)
255 break;
256 ++counter;
257 } while (itr != globules.end());
258
259 if (pGlobuleTarget)
260 {
261 globules.insert(pGlobuleTarget->GetGUID());
262 pGlobuleTarget->CastSpell(pGlobuleTarget, globulespell[g], true);
263 }
264 }
266 WateryGlobules_Timer = 25000;
267 } else WateryGlobules_Timer -= diff;
268 }
269 }
270};
271
273{
274 npc_water_globule(Creature* creature) : ScriptedAI(creature)
275 {
276 Initialize();
277 }
278
280 {
281 Check_Timer = 1000;
282 }
283
285
286 void Reset() override
287 {
288 Initialize();
289
291 }
292
293 void JustEngagedWith(Unit* /*who*/) override { }
294
295 void MoveInLineOfSight(Unit* who) override
296
297 {
298 if (!who || me->GetVictim())
299 return;
300
301 if (me->CanCreatureAttack(who))
302 {
303 //no attack radius check - it attacks the first target that moves in his los
304 //who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
305 AttackStart(who);
306 }
307 }
308
309 void UpdateAI(uint32 diff) override
310 {
311 //Return since we have no target
312 if (!UpdateVictim())
313 return;
314
315 if (Check_Timer <= diff)
316 {
317 if (me->IsWithinDistInMap(me->GetVictim(), 5))
318 {
320
321 //despawn
323 return;
324 }
325 Check_Timer = 500;
326 } else Check_Timer -= diff;
327
328 //do NOT deal any melee damage to the target.
329 }
330};
331
333{
336}
uint8_t uint8
Definition: Define.h:144
int8_t int8
Definition: Define.h:140
uint32_t uint32
Definition: Define.h:142
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition: ObjectDefines.h:66
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:393
Spells
Definition: PlayerAI.cpp:32
uint32 rand32()
Definition: Random.cpp:70
@ FACTION_MONSTER
@ NPC_TIDEWALKER_LURKER
@ EMOTE_WATERY_GLOBULES
@ SPELL_SUMMON_WATER_GLOBULE_3
@ SPELL_WATERY_GRAVE_4
@ SPELL_WATERY_GRAVE_EXPLOSION
@ SPELL_SUMMON_WATER_GLOBULE_2
@ SPELL_SUMMON_WATER_GLOBULE_4
@ SPELL_WATERY_GRAVE_3
@ SPELL_SUMMON_WATER_GLOBULE_1
@ SPELL_WATERY_GRAVE_1
@ SPELL_GLOBULE_EXPLOSION
@ SPELL_WATERY_GRAVE_2
float MurlocCords[10][4]
void AddSC_boss_morogrim_tidewalker()
Yells
void _JustEngagedWith(Unit *who)
void _JustDied()
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
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
bool CanCreatureAttack(Unit const *victim, bool force=true) const
Definition: Creature.cpp:2686
uint32 getSize() const
Definition: LinkedList.h:128
PlayerList const & GetPlayers() const
Definition: Map.h:367
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
Definition: Unit.h:627
void SetFaction(uint32 faction) override
Definition: Unit.h:859
Unit * GetVictim() const
Definition: Unit.h:715
Map * GetMap() const
Definition: Object.h:624
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1147
@ BOSS_MOROGRIM_TIDEWALKER
#define RegisterSerpentshrineCavernCreatureAI(ai_name)
void AttackStart(Unit *) override
== Triggered Actions Requested ==================
bool HealthBelowPct(uint32 pct) const
boss_morogrim_tidewalker(Creature *creature)
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void ApplyWateryGrave(Unit *player, uint8 i)
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
npc_water_globule(Creature *creature)
void MoveInLineOfSight(Unit *who) override