TrinityCore
Loading...
Searching...
No Matches
boss_slad_ran.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 "gundrak.h"
20#include "MotionMaster.h"
21#include "Player.h"
22#include "ScriptedCreature.h"
23#include "SpellAuras.h"
24#include "TemporarySummon.h"
25
34
45
51
53{
55 SPELL_SNAKE_WRAP = 55126, // 55099 -> 55126
57};
58
60{
61 {1783.81f, 646.637f, 133.948f, 3.71755f},
62 {1775.03f, 606.586f, 134.165f, 1.43117f},
63 {1717.39f, 630.041f, 129.282f, 5.96903f},
64 {1765.66f, 646.542f, 134.02f, 5.11381f},
65 {1716.76f, 635.159f, 129.282f, 0.191986f}
66};
67
72
79
81{
82 GROUP_SNAKES = 0
83};
84
85struct boss_slad_ran : public BossAI
86{
88 {
89 Initialize();
90 }
91
93 {
94 _phase = Phase::PHASE_NONE;
95 }
96
97 void Reset() override
98 {
99 _Reset();
100 Initialize();
101 _wrappedPlayers.clear();
102 }
103
104 void JustEngagedWith(Unit* who) override
105 {
108 }
109
110 void ScheduleTasks() override
111 {
113 .Schedule(10s, [this](TaskContext task)
114 {
117 task.Repeat(15s);
118 })
119 .Schedule(3s, [this](TaskContext task)
120 {
122 task.Repeat(10s);
123 })
124 .Schedule(15s, [this](TaskContext task)
125 {
127 task.Repeat(10s);
128 });
129 }
130
131 void UpdateAI(uint32 diff) override
132 {
133 if (!UpdateVictim())
134 return;
135
136 scheduler.Update(diff, [this]
137 {
139 });
140 }
141
142 void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
143 {
144 if (_phase == Phase::PHASE_NONE && HealthBelowPct(30))
145 {
147 _phase = Phase::PHASE_SNAKES;
148
150 {
151 for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
153
154 task.Repeat();
155 });
156 }
157
158 if (_phase == Phase::PHASE_SNAKES && HealthBelowPct(25))
159 {
161 _phase = Phase::PHASE_CONSTRICTORS;
162
164 scheduler.Schedule(5s, [this](TaskContext task)
165 {
166 for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
168
169 task.Repeat();
170 });
171 }
172 }
173
174 void JustDied(Unit* /*killer*/) override
175 {
176 _JustDied();
179 }
180
181 void KilledUnit(Unit* who) override
182 {
183 if (who->GetTypeId() == TYPEID_PLAYER)
184 Talk(SAY_SLAY);
185 }
186
187 void JustSummoned(Creature* summon) override
188 {
190 summons.Summon(summon);
191 }
192
193 void SetGUID(ObjectGuid const& guid, int32 id) override
194 {
196 _wrappedPlayers.insert(guid);
197 }
198
199 bool WasWrapped(ObjectGuid guid) const
200 {
201 return _wrappedPlayers.count(guid) != 0;
202 }
203
204private:
207};
208
210{
212
213 void Reset() override
214 {
216 }
217
218 void JustEngagedWith(Unit* /*who*/) override
219 {
220 _scheduler.Schedule(2s, [this](TaskContext task)
221 {
222 Unit* target = me->GetVictim();
223
225
226 Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
227 if (grip && grip->GetStackAmount() == 5)
228 {
230 target->CastSpell(target, SPELL_SNAKE_WRAP, true);
231
232 if (TempSummon* _me = me->ToTempSummon())
233 if (Unit* summoner = _me->GetSummonerUnit())
234 if (Creature* sladran = summoner->ToCreature())
235 sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
236
238 }
239
240 task.Repeat(3s, 6s);
241 });
242 }
243
244 void UpdateAI(uint32 diff) override
245 {
246 if (!UpdateVictim())
247 return;
248
249 _scheduler.Update(diff);
250 }
251private:
253};
254
256{
257 npc_slad_ran_viper(Creature* creature) : ScriptedAI(creature) { }
258
259 void Reset() override
260 {
262 }
263
264 void JustEngagedWith(Unit* /*who*/) override
265 {
266 _scheduler.Schedule(2s, [this](TaskContext task)
267 {
269 task.Repeat(10s);
270 });
271 }
272
273 void UpdateAI(uint32 diff) override
274 {
275 if (!UpdateVictim())
276 return;
277
278 _scheduler.Update(diff);
279 }
280private:
282};
283
285{
286 public:
287 achievement_snakes_whyd_it_have_to_be_snakes() : AchievementCriteriaScript("achievement_snakes_whyd_it_have_to_be_snakes") { }
288
289 bool OnCheck(Player* player, Unit* target) override
290 {
291 if (!target)
292 return false;
293
294 if (boss_slad_ran* sladRanAI = CAST_AI(boss_slad_ran, target->GetAI()))
295 return !sladRanAI->WasWrapped(player->GetGUID());
296 return false;
297 }
298};
299
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:260
Spells
Definition PlayerAI.cpp:32
#define CAST_AI(a, b)
Definition UnitAI.h:27
DamageEffectType
Definition Unit.h:352
Creatures
@ CREATURE_SNAKE
@ CREATURE_CONSTRICTORS
ConstrictorSpells
@ SPELL_SNAKE_WRAP
@ SPELL_GRIP_OF_SLAD_RAN
@ SPELL_VENOMOUS_BITE
@ DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES
@ SAY_DEATH
@ SAY_SUMMON_SNAKES
@ SAY_SUMMON_CONSTRICTORS
@ SAY_AGGRO
@ EMOTE_NOVA
@ SAY_SLAY
@ EMOTE_ACTIVATE_ALTAR
@ SPELL_SUMMON_SNAKES
@ SPELL_VENOM_BOLT
@ SPELL_POWERFULL_BITE
@ SPELL_POISON_NOVA
@ SPELL_SUMMON_CONSTRICTORS
void AddSC_boss_slad_ran()
static Position SpawnLoc[]
TaskGroup
@ GROUP_SNAKES
@ PHASE_NONE
@ PHASE_SNAKES
@ PHASE_CONSTRICTORS
Yells
uint8 GetStackAmount() const
Definition SpellAuras.h:164
void JustEngagedWith(Unit *who) override
TaskScheduler scheduler
SummonList summons
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void Summon(Creature const *summon)
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
TaskScheduler & CancelGroup(group_t const group)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4439
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
TempSummon * ToTempSummon()
Definition Unit.h:1794
UnitAI * GetAI() const
Definition Unit.h:800
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
Unit * GetVictim() const
Definition Unit.h:859
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
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
bool OnCheck(Player *player, Unit *target) override
#define RegisterGundrakCreatureAI(ai_name)
Definition gundrak.h:101
@ DATA_SLAD_RAN
Definition gundrak.h:31
float GetPositionZ() const
Definition Position.h:81
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80
T const & DUNGEON_MODE(T const &normal5, T const &heroic10) const
bool HealthBelowPct(uint32 pct) const
bool WasWrapped(ObjectGuid guid) const
void KilledUnit(Unit *who) override
void Reset() override
void DamageTaken(Unit *, uint32 &, DamageEffectType, SpellInfo const *) override
void JustSummoned(Creature *summon) override
void JustDied(Unit *) override
GuidSet _wrappedPlayers
void SetGUID(ObjectGuid const &guid, int32 id) override
void ScheduleTasks() override
void UpdateAI(uint32 diff) override
boss_slad_ran(Creature *creature)
void JustEngagedWith(Unit *who) override
npc_slad_ran_constrictor(Creature *creature)
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
void Reset() override
TaskScheduler _scheduler
npc_slad_ran_viper(Creature *creature)