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);
137 }
138
139 void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
140 {
141 if (_phase == Phase::PHASE_NONE && HealthBelowPct(30))
142 {
144 _phase = Phase::PHASE_SNAKES;
145
146 scheduler.Schedule(5s, GROUP_SNAKES, [this](TaskContext& task)
147 {
148 for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
150
151 task.Repeat();
152 });
153 }
154
155 if (_phase == Phase::PHASE_SNAKES && HealthBelowPct(25))
156 {
158 _phase = Phase::PHASE_CONSTRICTORS;
159
161 scheduler.Schedule(5s, [this](TaskContext& task)
162 {
163 for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
165
166 task.Repeat();
167 });
168 }
169 }
170
171 void JustDied(Unit* /*killer*/) override
172 {
173 _JustDied();
176 }
177
178 void KilledUnit(Unit* who) override
179 {
180 if (who->GetTypeId() == TYPEID_PLAYER)
181 Talk(SAY_SLAY);
182 }
183
184 void JustSummoned(Creature* summon) override
185 {
187 summons.Summon(summon);
188 }
189
190 void SetGUID(ObjectGuid const& guid, int32 id) override
191 {
193 _wrappedPlayers.insert(guid);
194 }
195
196 bool WasWrapped(ObjectGuid guid) const
197 {
198 return _wrappedPlayers.count(guid) != 0;
199 }
200
201private:
204};
205
207{
209
210 void Reset() override
211 {
213 }
214
215 void JustEngagedWith(Unit* /*who*/) override
216 {
217 _scheduler.Schedule(2s, [this](TaskContext& task)
218 {
219 Unit* target = me->GetVictim();
220
222
223 Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
224 if (grip && grip->GetStackAmount() == 5)
225 {
227 target->CastSpell(target, SPELL_SNAKE_WRAP, true);
228
229 if (TempSummon* _me = me->ToTempSummon())
230 if (Unit* summoner = _me->GetSummonerUnit())
231 if (Creature* sladran = summoner->ToCreature())
232 sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
233
235 }
236
237 task.Repeat(3s, 6s);
238 });
239 }
240
241 void UpdateAI(uint32 diff) override
242 {
243 if (!UpdateVictim())
244 return;
245
246 _scheduler.Update(diff);
247 }
248private:
250};
251
253{
254 npc_slad_ran_viper(Creature* creature) : ScriptedAI(creature) { }
255
256 void Reset() override
257 {
259 }
260
261 void JustEngagedWith(Unit* /*who*/) override
262 {
263 _scheduler.Schedule(2s, [this](TaskContext& task)
264 {
266 task.Repeat(10s);
267 });
268 }
269
270 void UpdateAI(uint32 diff) override
271 {
272 if (!UpdateVictim())
273 return;
274
275 _scheduler.Update(diff);
276 }
277private:
279};
280
282{
283 public:
284 achievement_snakes_whyd_it_have_to_be_snakes() : AchievementCriteriaScript("achievement_snakes_whyd_it_have_to_be_snakes") { }
285
286 bool OnCheck(Player* player, Unit* target) override
287 {
288 if (!target)
289 return false;
290
291 if (boss_slad_ran* sladRanAI = CAST_AI(boss_slad_ran, target->GetAI()))
292 return !sladRanAI->WasWrapped(player->GetGUID());
293 return false;
294 }
295};
296
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:432
Spells
Definition PlayerAI.cpp:32
#define CAST_AI(a, b)
Definition UnitAI.h:29
DamageEffectType
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:238
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
void JustEngagedWith(Unit *who) override
TaskScheduler scheduler
SummonList summons
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
Creature * ToCreature()
Definition Object.h:121
void Summon(Creature const *summon)
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelGroup(group_t group)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
TempSummon * ToTempSummon()
Definition Unit.h:1828
UnitAI * GetAI() const
Definition Unit.h:668
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4700
Unit * GetVictim() const
Definition Unit.h:726
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
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:1398
bool OnCheck(Player *player, Unit *target) override
#define RegisterGundrakCreatureAI(ai_name)
Definition gundrak.h:99
@ DATA_SLAD_RAN
Definition gundrak.h:31
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr float GetPositionZ() const
Definition Position.h:89
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)