TrinityCore
Loading...
Searching...
No Matches
boss_golden_serpent.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 "AreaTrigger.h"
19#include "AreaTriggerAI.h"
20#include "CreatureAI.h"
21#include "CreatureAIImpl.h"
22#include "InstanceScript.h"
23#include "Map.h"
24#include "MotionMaster.h"
25#include "ObjectAccessor.h"
26#include "ScriptMgr.h"
27#include "ScriptedCreature.h"
28#include "SpellAuraEffects.h"
29#include "SpellScript.h"
30#include "SpellAuras.h"
31#include "SharedDefines.h"
32#include "TemporarySummon.h"
33#include "kings_rest.h"
34
47
55
60
65
70
75
82
83constexpr Position GoldenSerpentRespawnPos = { -1058.8403f, 2615.1667f, 810.1519f, 5.113396f };
84
85// 135322 - The Golden Serpent
87{
89
103
109
110 void JustDied(Unit* /*killer*/) override
111 {
112 _JustDied();
114 }
115
124
125 void Reset() override
126 {
127 _announcedLuster = false;
128 }
129
139
140 void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
141 {
142 if (pathId == PATH_GOLDEN_SERPENT_SUBMERGE)
143 {
146 }
147 else if (pathId == PATH_GOLDEN_SERPENT_FLYING)
149 else if (pathId == PATH_GOLDEN_SERPENT_LANDING)
150 {
152 me->SetPlayHoverAnim(false);
154 me->SetUninteractible(false);
155 me->SetDisableGravity(false);
156 }
157 }
158
159 void DoAction(int32 action) override
160 {
162 {
163 if (!_announcedLuster)
164 {
166 _announcedLuster = true;
167 }
168 }
169 }
170
171 void UpdateAI(uint32 diff) override
172 {
173 scheduler.Update(diff);
174
175 if (!UpdateVictim())
176 return;
177
178 events.Update(diff);
179
181 return;
182
183 while (uint32 eventId = events.ExecuteEvent())
184 {
185 switch (eventId)
186 {
187 case EVENT_SPIT_GOLD:
188 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 300.0f, true))
189 DoCast(target, SPELL_SPIT_GOLD);
191 break;
195 break;
196 case EVENT_TAIL_TRASH:
199 break;
202 _announcedLuster = false;
204 break;
205 default:
206 break;
207 }
208
210 return;
211 }
212 }
213private:
215};
216
217// 135406 - Animated Gold
219{
220 npc_animated_gold(Creature* creature) : ScriptedAI(creature), _isMoltenGoldCast(false) { }
221
227
228 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
229 {
230 if (spellInfo->Id == SPELL_LUCRES_CALL)
231 {
232 _scheduler.Schedule(3s, [this](TaskContext const&)
233 {
235 {
236 Creature* goldenSerpent = me->GetInstanceScript()->GetCreature(DATA_GOLDEN_SERPENT);
237 if (!goldenSerpent)
238 return;
239
240 me->GetMotionMaster()->Clear();
241 me->SetWalk(true);
242 me->GetMotionMaster()->MoveFollow(goldenSerpent, 2.0f, {}, {}, true);
243 _isMoltenGoldCast = false;
244 }
245 });
246 }
247 }
248
249 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
250 {
251 if (me->GetHealth() <= damage)
252 {
253 damage = me->GetHealth() - 1;
254
255 if (!_isMoltenGoldCast)
256 {
257 me->CastSpell(nullptr, SPELL_MOLTEN_GOLD_AURA, false);
258 me->GetMotionMaster()->Clear();
259 me->StopMoving();
260 _isMoltenGoldCast = true;
261 }
262 }
263 }
264
265 void MovementInform(uint32 type, uint32 /*pointId*/) override
266 {
267 if (type == FOLLOW_MOTION_TYPE)
268 {
270 if (!goldenSerpent)
271 return;
272
273 if (!goldenSerpent->IsAIEnabled())
274 return;
275
276 me->DespawnOrUnsummon(4s);
277 me->GetMotionMaster()->Clear();
278 me->StopMoving();
279 me->CastSpell(nullptr, SPELL_LUSTER, true);
281 me->SetDisplayId(DISPLAY_INVISIBLE);
282 me->SetUninteractible(true);
283 }
284 }
285
286 void UpdateAI(uint32 diff) override
287 {
288 _scheduler.Update(diff);
289 }
290
291private:
294};
295
296// 17570 - Molten Gold - Areatrigger
298{
299 at_kings_rest_molten_gold(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { }
300
301 void OnUnitEnter(Unit* unit) override
302 {
303 if (!unit->IsPlayer())
304 return;
305
306 unit->CastSpell(nullptr, SPELL_MOLTEN_GOLD_DAMAGE, false);
307 }
308
309 void OnUnitExit(Unit* unit, AreaTriggerExitReason /*reason*/) override
310 {
312 }
313};
314
315// 265773 - Spit Gold
317{
318 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
319 {
320 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEATH && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
321 return;
322
323 if (Unit* caster = GetCaster())
324 caster->SummonCreature(NPC_ANIMATED_GOLD, GetTarget()->GetPosition());
325 }
326
331};
332
333// 265915 - Molten Gold
354
AreaTriggerExitReason
Definition AreaTrigger.h:69
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ NOT_STARTED
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ FOLLOW_MOTION_TYPE
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_1
@ EFFECT_0
@ FACTION_MONSTER_2
@ FACTION_FRIENDLY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_DEATH
@ AURA_REMOVE_BY_EXPIRE
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_TRANSFORM
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ REACT_PASSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
GoldenSerpentActions
@ ACTION_ANNOUNCE_ABSORB_ANIMATED_GOLD
@ SAY_ANNOUNCE_ABSORB_ANIMATED_GOLD
void AddSC_boss_golden_serpent()
@ PATH_GOLDEN_SERPENT_SUBMERGE
@ PATH_GOLDEN_SERPENT_FLYING
@ PATH_GOLDEN_SERPENT_LANDING
@ DISPLAY_INVISIBLE
@ NPC_ANIMATED_GOLD
GoldenSerpentEvents
@ EVENT_SPIT_GOLD
@ EVENT_LUCRES_CALL
@ EVENT_TAIL_TRASH
@ EVENT_SERPENTINE_GUST
constexpr Position GoldenSerpentRespawnPos
GoldenSerpentSpells
@ SPELL_GOLDEN_SERPENT_EMERGE_STATE
@ SPELL_LUCRES_CALL
@ SPELL_BREAK_PLAYER_TARGETTING
@ SPELL_MOLTEN_GOLD_DAMAGE
@ SPELL_TAIL_TRASH
@ SPELL_MOLTEN_GOLD_AURA
@ SPELL_SERPENTINE_GUST
@ SPELL_SPIT_GOLD
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
Unit * GetTarget() const
bool IsPlayer() const
Definition BaseEntity.h:173
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
TaskScheduler scheduler
SummonList summons
EventMap events
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:174
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
CreatureAI * AI() const
Definition Creature.h:228
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
Creature * GetCreature(uint32 type)
EncounterState GetBossState(uint32 id) const
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 const Id
Definition SpellInfo.h:328
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void DoAction(int32 param)
Definition UnitAI.h:73
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
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetImmuneToPC(bool apply, bool keepCombat)
Definition Unit.cpp:8518
void SetPlayHoverAnim(bool enable, bool sendUpdate=true)
Definition Unit.cpp:14175
void SetFaction(uint32 faction) override
Definition Unit.h:872
void SetAnimTier(AnimTier animTier, bool notifyClient=true)
Definition Unit.cpp:10745
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool SetDisableGravity(bool disable, bool updateAnimTier=true)
Definition Unit.cpp:13361
void SetUninteractible(bool apply)
Definition Unit.cpp:8564
bool IsAIEnabled() const
Definition Unit.h:666
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
void OnApply(AuraEffect const *, AuraEffectHandleModes)
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
#define RegisterKingsRestCreatureAI(ai_name)
Definition kings_rest.h:76
@ DATA_GOLDEN_SERPENT
Definition kings_rest.h:31
constexpr void Relocate(float x, float y)
Definition Position.h:74
void OnUnitEnter(Unit *unit) override
at_kings_rest_molten_gold(AreaTrigger *areatrigger)
void OnUnitExit(Unit *unit, AreaTriggerExitReason) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void DoAction(int32 action) override
boss_the_golden_serpent(Creature *creature)
void JustDied(Unit *) override
void EnterEvadeMode(EvadeReason) override
void WaypointPathEnded(uint32, uint32 pathId) override
void MovementInform(uint32 type, uint32) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void JustAppeared() override
void UpdateAI(uint32 diff) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
npc_animated_gold(Creature *creature)