TrinityCore
Loading...
Searching...
No Matches
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 "ObjectAccessor.h"
22#include "ScriptedCreature.h"
23#include "SpellInfo.h"
24#include "temple_of_ahnqiraj.h"
25#include "TemporarySummon.h"
26
28{
31 SPELL_TOXIN = 26575,
38 SPELL_VISCIDUS_SHRINKS = 25893, // Removed from client, in world.spell_dbc
39
40 SPELL_MEMBRANE_VISCIDUS = 25994, // damage reduction spell - removed from DBC
41 SPELL_VISCIDUS_WEAKNESS = 25926, // aura which procs at damage - should trigger the slow spells - removed from DBC
42 SPELL_VISCIDUS_GROWS = 25897, // removed from DBC
43 SPELL_SUMMON_GLOBS = 25885, // summons npc 15667 using spells from 25865 to 25884; All spells have target coords - removed from DBC
44 SPELL_VISCIDUS_TELEPORT = 25904, // removed from DBC
45};
46
53
60
71
82
84{
85 ROOM_CENTER = 1
86};
87
88Position const ViscidusCoord = { -7992.36f, 908.19f, -52.62f, 1.68f };
89float const RoomRadius = 40.0f;
90
92{
93 public:
94 boss_viscidus() : CreatureScript("boss_viscidus") { }
95
96 struct boss_viscidusAI : public BossAI
97 {
99 {
100 Initialize();
101 }
102
104 {
105 _hitcounter = 0;
107 }
108
109 void Reset() override
110 {
111 _Reset();
112 Initialize();
113 }
114
115 void DamageTaken(Unit* attacker, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
116 {
117 if (_phase != PHASE_MELEE)
118 return;
119
120 ++_hitcounter;
121
123 {
125 events.Reset();
128 me->SetVisible(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
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 }
228
229 events.Update(diff);
230
231 while (uint32 eventId = events.ExecuteEvent())
232 {
233 switch (eventId)
234 {
238 break;
242 break;
244 _hitcounter = 0;
246 break;
247 default:
248 break;
249 }
250 }
251
252 if (_phase != PHASE_GLOB)
254 }
255
256 private:
259 };
260
261 CreatureAI* GetAI(Creature* creature) const override
262 {
263 return GetAQ40AI<boss_viscidusAI>(creature);
264 }
265};
266
268{
269 public:
270 npc_glob_of_viscidus() : CreatureScript("boss_glob_of_viscidus") { }
271
273 {
274 npc_glob_of_viscidusAI(Creature* creature) : ScriptedAI(creature) { }
275
276 void JustDied(Unit* /*killer*/) override
277 {
278 InstanceScript* instance = me->GetInstanceScript();
279
280 if (Creature* Viscidus = instance->GetCreature(DATA_VISCIDUS))
281 {
282 if (BossAI* ViscidusAI = dynamic_cast<BossAI*>(Viscidus->GetAI()))
283 ViscidusAI->SummonedCreatureDespawn(me);
284
285 if (Viscidus->IsAlive() && Viscidus->GetHealthPct() < 5.0f)
286 {
287 Viscidus->SetVisible(true);
288 if (Viscidus->GetVictim())
289 Unit::Kill(Viscidus->EnsureVictim(), Viscidus);
290 }
291 else
292 {
293 Viscidus->SetHealth(Viscidus->GetHealth() - Viscidus->GetMaxHealth() / 20);
294 Viscidus->CastSpell(Viscidus, SPELL_VISCIDUS_SHRINKS);
295 }
296 }
297 }
298
299 void MovementInform(uint32 /*type*/, uint32 id) override
300 {
301 if (id == ROOM_CENTER)
302 {
304 if (TempSummon* summon = me->ToTempSummon())
305 summon->UnSummon();
306 }
307 }
308 };
309
310 CreatureAI* GetAI(Creature* creature) const override
311 {
312 return GetAQ40AI<npc_glob_of_viscidusAI>(creature);
313 }
314};
315
317{
318 new boss_viscidus();
320}
#define M_PI
Definition Common.h:72
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
Spells
Definition PlayerAI.cpp:32
@ SPELL_SCHOOL_MASK_FROST
@ UNIT_STATE_MELEE_ATTACKING
Definition Unit.h:221
DamageEffectType
Definition Unit.h:352
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
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
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
Creature * GetCreature(uint32 type)
SpellSchoolMask GetSchoolMask() const
bool empty() const
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void SetVisible(bool x)
Definition Unit.cpp:8513
float GetHealthPct() const
Definition Unit.h:921
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3638
TempSummon * ToTempSummon()
Definition Unit.h:1794
void NearTeleportTo(Position const &pos, bool casting=false)
Definition Unit.cpp:12832
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true)
Definition Unit.cpp:10930
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
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:1992
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
float GetPositionZ() const
Definition Position.h:81
float GetOrientation() const
Definition Position.h:82
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80
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