TrinityCore
boss_viscidus.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#include "ScriptMgr.h"
19#include "InstanceScript.h"
20#include "MotionMaster.h"
21#include "ScriptedCreature.h"
22#include "SpellInfo.h"
23#include "temple_of_ahnqiraj.h"
24#include "TemporarySummon.h"
25
27{
30 SPELL_TOXIN = 26575,
37 SPELL_VISCIDUS_SHRINKS = 25893, // Removed from client, in world.spell_dbc
38
39 SPELL_MEMBRANE_VISCIDUS = 25994, // damage reduction spell - removed from DBC
40 SPELL_VISCIDUS_WEAKNESS = 25926, // aura which procs at damage - should trigger the slow spells - removed from DBC
41 SPELL_VISCIDUS_GROWS = 25897, // removed from DBC
42 SPELL_SUMMON_GLOBS = 25885, // summons npc 15667 using spells from 25865 to 25884; All spells have target coords - removed from DBC
43 SPELL_VISCIDUS_TELEPORT = 25904, // removed from DBC
44};
45
47{
51};
52
54{
57 PHASE_GLOB = 3
58};
59
61{
65
69};
70
72{
76
80};
81
83{
84 ROOM_CENTER = 1
85};
86
87Position const ViscidusCoord = { -7992.36f, 908.19f, -52.62f, 1.68f };
88float const RoomRadius = 40.0f;
89
91{
92 public:
93 boss_viscidus() : CreatureScript("boss_viscidus") { }
94
95 struct boss_viscidusAI : public BossAI
96 {
98 {
99 Initialize();
100 }
101
103 {
104 _hitcounter = 0;
106 }
107
108 void Reset() override
109 {
110 _Reset();
111 Initialize();
112 }
113
114 void DamageTaken(Unit* attacker, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
115 {
116 if (_phase != PHASE_MELEE)
117 return;
118
119 ++_hitcounter;
120
122 {
124 events.Reset();
127 me->SetVisible(false);
128 me->SetCanMelee(false);
131
132 uint8 NumGlobes = me->GetHealthPct() / 5.0f;
133 for (uint8 i = 0; i < NumGlobes; ++i)
134 {
135 float Angle = i * 2 * float(M_PI) / NumGlobes;
136 float X = ViscidusCoord.GetPositionX() + std::cos(Angle) * RoomRadius;
137 float Y = ViscidusCoord.GetPositionY() + std::sin(Angle) * RoomRadius;
138 float Z = -35.0f;
139
140 if (TempSummon* Glob = me->SummonCreature(NPC_GLOB_OF_VISCIDUS, X, Y, Z))
141 {
142 Glob->UpdateAllowedPositionZ(X, Y, Z);
143 Glob->NearTeleportTo(X, Y, Z, 0.0f);
144 Glob->GetMotionMaster()->MovePoint(ROOM_CENTER, ViscidusCoord);
145 }
146 }
147 }
150 else if (_hitcounter == HITCOUNTER_CRACK)
152 }
153
154 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
155 {
156 if ((spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST) && _phase == PHASE_FROST && me->GetHealthPct() > 5.0f)
157 {
158 ++_hitcounter;
159
161 {
162 _hitcounter = 0;
168 }
170 {
174 }
175 else if (_hitcounter >= HITCOUNTER_SLOW)
176 {
179 }
180 }
181 }
182
183 void JustEngagedWith(Unit* who) override
184 {
186 events.Reset();
187 InitSpells();
188 }
189
191 {
195 }
196
197 void EnterEvadeMode(EvadeReason why) override
198 {
201 }
202
203 void JustDied(Unit* /*killer*/) override
204 {
207 _JustDied();
208 }
209
210 void UpdateAI(uint32 diff) override
211 {
212 if (!UpdateVictim())
213 return;
214
215 if (_phase == PHASE_GLOB && summons.empty())
216 {
222
223 _hitcounter = 0;
225 InitSpells();
226 me->SetVisible(true);
227 me->SetCanMelee(true);
228 }
229
230 events.Update(diff);
231
232 while (uint32 eventId = events.ExecuteEvent())
233 {
234 switch (eventId)
235 {
239 break;
243 break;
245 _hitcounter = 0;
247 break;
248 default:
249 break;
250 }
251 }
252 }
253
254 private:
257 };
258
259 CreatureAI* GetAI(Creature* creature) const override
260 {
261 return GetAQ40AI<boss_viscidusAI>(creature);
262 }
263};
264
266{
267 public:
268 npc_glob_of_viscidus() : CreatureScript("boss_glob_of_viscidus") { }
269
271 {
272 npc_glob_of_viscidusAI(Creature* creature) : ScriptedAI(creature) { }
273
274 void JustDied(Unit* /*killer*/) override
275 {
276 InstanceScript* instance = me->GetInstanceScript();
277
278 if (Creature* Viscidus = instance->GetCreature(DATA_VISCIDUS))
279 {
280 Viscidus->AI()->SummonedCreatureDespawn(me);
281
282 if (Viscidus->IsAlive() && Viscidus->GetHealthPct() < 5.0f)
283 {
284 Viscidus->SetVisible(true);
285 if (Viscidus->GetVictim())
286 Unit::Kill(Viscidus->EnsureVictim(), Viscidus);
287 }
288 else
289 {
290 Viscidus->SetHealth(Viscidus->GetHealth() - Viscidus->GetMaxHealth() / 20);
291 Viscidus->CastSpell(Viscidus, SPELL_VISCIDUS_SHRINKS);
292 }
293 }
294 }
295
296 void MovementInform(uint32 /*type*/, uint32 id) override
297 {
298 if (id == ROOM_CENTER)
299 {
301 if (TempSummon* summon = me->ToTempSummon())
302 summon->UnSummon();
303 }
304 }
305 };
306
307 CreatureAI* GetAI(Creature* creature) const override
308 {
309 return GetAQ40AI<npc_glob_of_viscidusAI>(creature);
310 }
311};
312
314{
315 new boss_viscidus();
317}
#define M_PI
Definition: Common.h:115
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
Spells
Definition: PlayerAI.cpp:32
@ SPELL_SCHOOL_MASK_FROST
EvadeReason
Definition: UnitAICommon.h:30
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_MELEE_ATTACKING
Definition: Unit.h:256
void AddSC_boss_viscidus()
@ EMOTE_SLOW
@ EMOTE_CRACK
@ EMOTE_FREEZE
@ EMOTE_FROZEN
@ EMOTE_EXPLODE
@ EMOTE_SHATTER
Position const ViscidusCoord
@ SPELL_POISON_SHOCK
@ SPELL_VISCIDUS_TELEPORT
@ SPELL_VISCIDUS_SLOWED_MORE
@ SPELL_POISONBOLT_VOLLEY
@ SPELL_VISCIDUS_GROWS
@ SPELL_VISCIDUS_SHRINKS
@ SPELL_VISCIDUS_FREEZE
@ SPELL_TOXIN
@ SPELL_VISCIDUS_SUICIDE
@ SPELL_VISCIDUS_WEAKNESS
@ SPELL_VISCIDUS_SLOWED
@ SPELL_MEMBRANE_VISCIDUS
@ SPELL_REJOIN_VISCIDUS
@ SPELL_VISCIDUS_EXPLODE
@ SPELL_SUMMON_GLOBS
@ PHASE_GLOB
@ PHASE_MELEE
@ PHASE_FROST
float const RoomRadius
MovePoints
@ ROOM_CENTER
HitCounter
@ HITCOUNTER_CRACK
@ HITCOUNTER_SLOW
@ HITCOUNTER_EXPLODE
@ HITCOUNTER_SLOW_MORE
@ HITCOUNTER_SHATTER
@ HITCOUNTER_FREEZE
@ EVENT_POISONBOLT_VOLLEY
@ EVENT_POISON_SHOCK
@ EVENT_RESET_PHASE
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void _JustDied()
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
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 SetCanMelee(bool canMelee, bool fleeFromMelee=false)
Definition: Creature.cpp:2822
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
Creature * GetCreature(uint32 type)
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2465
bool empty() const
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void SetVisible(bool x)
Definition: Unit.cpp:8351
float GetHealthPct() const
Definition: Unit.h:784
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3685
TempSummon * ToTempSummon()
Definition: Unit.h:1756
void NearTeleportTo(Position const &pos, bool casting=false)
Definition: Unit.cpp:12327
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition: Unit.cpp:10591
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
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
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetOrientation() const
Definition: Position.h:79
constexpr float GetPositionZ() const
Definition: Position.h:78
void ResetThreatList(Unit *who=nullptr)
void DamageTaken(Unit *attacker, uint32 &, DamageEffectType, SpellInfo const *) override
void EnterEvadeMode(EvadeReason why) override
boss_viscidusAI(Creature *creature)
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
void MovementInform(uint32, uint32 id) override
@ NPC_GLOB_OF_VISCIDUS
@ DATA_VISCIDUS