TrinityCore
boss_moragg.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 "ScriptedCreature.h"
21#include "SpellAuraEffects.h"
22#include "SpellScript.h"
23#include "violet_hold.h"
24
26{
29
30 // Visual
34};
35
36#define SPELL_RAY_OF_PAIN DUNGEON_MODE(54438,59523)
37#define SPELL_RAY_OF_SUFFERING DUNGEON_MODE(54442,59524)
38
39struct boss_moragg : public BossAI
40{
41 boss_moragg(Creature* creature) : BossAI(creature, DATA_MORAGG) { }
42
43 void Reset() override
44 {
46 }
47
48 void JustEngagedWith(Unit* who) override
49 {
51 }
52
53 void JustReachedHome() override
54 {
57 }
58
59 void UpdateAI(uint32 diff) override
60 {
61 if (!UpdateVictim())
62 return;
63
64 scheduler.Update(diff);
65 }
66
67 void ScheduleTasks() override
68 {
69 scheduler.Async([this]
70 {
73 });
74
75 scheduler.Schedule(Seconds(15), [this](TaskContext task)
76 {
77 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 50.0f, true))
78 DoCast(target, SPELL_OPTIC_LINK);
79 task.Repeat(Seconds(25));
80 });
81
82 scheduler.Schedule(Seconds(5), [this](TaskContext task)
83 {
85 task.Repeat(Seconds(10));
86 });
87 }
88};
89
90// 54438, 59523 - Ray of Pain
91// 54442, 59524 - Ray of Suffering
93{
94 void OnPeriodic(AuraEffect const* aurEff)
95 {
97
98 if (UnitAI* AI = GetTarget()->GetAI())
99 if (Unit* target = AI->SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true))
100 {
101 uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
102 GetTarget()->CastSpell(target, triggerSpell, aurEff);
103 }
104 }
105
106 void Register() override
107 {
109 }
110};
111
112// 54396 - Optic Link
114{
115 bool Validate(SpellInfo const* /*spellInfo*/) override
116 {
117 return ValidateSpellInfo(
118 {
122 });
123 }
124
125 void OnPeriodic(AuraEffect const* aurEff)
126 {
127 if (Unit* caster = GetCaster())
128 {
129 if (aurEff->GetTickNumber() >= 8)
130 caster->CastSpell(GetTarget(), SPELL_OPTIC_LINK_LEVEL_3, aurEff);
131
132 if (aurEff->GetTickNumber() >= 4)
133 caster->CastSpell(GetTarget(), SPELL_OPTIC_LINK_LEVEL_2, aurEff);
134
135 caster->CastSpell(GetTarget(), SPELL_OPTIC_LINK_LEVEL_1, aurEff);
136 }
137 }
138
139 void OnUpdate(AuraEffect* aurEff)
140 {
141 switch (aurEff->GetTickNumber())
142 {
143 case 1:
144 aurEff->SetAmount(aurEff->GetAmount() + 250); // base amount is 500
145 break;
146 case 4:
147 aurEff->SetAmount(aurEff->GetAmount() * 2); // goes to 1500
148 break;
149 case 8:
150 aurEff->SetAmount(aurEff->GetAmount() * 2); // goes to 3000
151 break;
152 default:
153 break;
154 }
155 }
156
157 void Register() override
158 {
161 }
162};
163
165{
169}
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectUpdatePeriodicFn(F, I, N)
Definition: SpellScript.h:2052
@ SPELL_OPTIC_LINK
Definition: boss_moragg.cpp:28
@ SPELL_OPTIC_LINK_LEVEL_3
Definition: boss_moragg.cpp:33
@ SPELL_CORROSIVE_SALIVA
Definition: boss_moragg.cpp:27
@ SPELL_OPTIC_LINK_LEVEL_1
Definition: boss_moragg.cpp:31
@ SPELL_OPTIC_LINK_LEVEL_2
Definition: boss_moragg.cpp:32
#define SPELL_RAY_OF_SUFFERING
Definition: boss_moragg.cpp:37
void AddSC_boss_moragg()
#define SPELL_RAY_OF_PAIN
Definition: boss_moragg.cpp:36
uint32 GetTickNumber() const
SpellEffectInfo const & GetSpellEffectInfo() const
void SetAmount(int32 amount)
int32 GetAmount() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetCaster() const
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
Definition: SpellScript.h:2051
Unit * GetTarget() const
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
TaskScheduler scheduler
void JustReachedHome() override
void Reset() override
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
uint32 TriggerSpell
Definition: SpellInfo.h:237
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Async(std::function< void()> callable)
TaskScheduler & Update(success_t const &callback=nullptr)
Definition: UnitAI.h:50
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:627
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
void OnPeriodic(AuraEffect const *aurEff)
Definition: boss_moragg.cpp:94
void Register() override
void JustEngagedWith(Unit *who) override
Definition: boss_moragg.cpp:48
boss_moragg(Creature *creature)
Definition: boss_moragg.cpp:41
void JustReachedHome() override
Definition: boss_moragg.cpp:53
void UpdateAI(uint32 diff) override
Definition: boss_moragg.cpp:59
void Reset() override
Definition: boss_moragg.cpp:43
void ScheduleTasks() override
Definition: boss_moragg.cpp:67
@ DATA_HANDLE_CELLS
Definition: violet_hold.h:87
@ DATA_MORAGG
Definition: violet_hold.h:54
#define RegisterVioletHoldCreatureAI(ai_name)
Definition: violet_hold.h:164