TrinityCore
boss_ormorok.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 "GameObject.h"
20#include "Map.h"
21#include "nexus.h"
22#include "ScriptedCreature.h"
23#include "SpellScript.h"
24
26{
29 SPELL_FRENZY = 48017,
32
37
42};
43
45{
51 SAY_FRENZY = 6
52};
53
55{
60};
61
63{
64 public:
65 OrmorokTanglerPredicate(Unit* unit) : me(unit) { }
66
67 bool operator() (WorldObject* object) const
68 {
69 return object->GetDistance2d(me) >= 5.0f;
70 }
71
72 private:
74};
75
76struct boss_ormorok : public BossAI
77{
78 boss_ormorok(Creature* creature) : BossAI(creature, DATA_ORMOROK)
79 {
80 Initialize();
81 }
82
84 {
85 frenzy = false;
86 }
87
88 void Reset() override
89 {
91 Initialize();
92 }
93
94 void JustEngagedWith(Unit* who) override
95 {
97
101 if (IsHeroic())
103
105 }
106
107 void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
108 {
109 if (!frenzy && HealthBelowPct(25))
110 {
113 frenzy = true;
114 }
115 }
116
117 void JustDied(Unit* /*killer*/) override
118 {
119 _JustDied();
121 }
122
123 void KilledUnit(Unit* who) override
124 {
125 if (who->GetTypeId() == TYPEID_PLAYER)
126 Talk(SAY_KILL);
127 }
128
129 void UpdateAI(uint32 diff) override
130 {
131 if (!UpdateVictim())
132 return;
133
134 events.Update(diff);
135
137 return;
138
139 while (uint32 eventId = events.ExecuteEvent())
140 {
141 switch (eventId)
142 {
143 case EVENT_TRAMPLE:
146 break;
151 break;
156 break;
161 break;
162 default:
163 break;
164 }
165
167 return;
168 }
169 }
170
171private:
172 bool frenzy;
173
174};
175
177{
180
183
186
188};
189
191{
192 47936,
193 47942,
194 47943
195};
196
198{
200 {
201 _count = 0;
202 _despawntimer = 0;
203 }
204
205 void IsSummonedBy(WorldObject* owner) override
206 {
207 switch (me->GetEntry())
208 {
210 _count = 0;
211 me->SetFacingToObject(owner);
213 break;
216 if (Creature* trigger = owner->ToCreature())
217 _count = trigger->AI()->GetData(DATA_COUNT) + 1;
218 break;
219 default:
221 break;
222 }
223
226 trap->Use(me);
227
228 _despawntimer = 2000;
229 }
230
231 uint32 GetData(uint32 type) const override
232 {
233 return type == DATA_COUNT ? _count : 0;
234 }
235
236 void UpdateAI(uint32 diff) override
237 {
238 if (_despawntimer <= diff)
239 {
242 trap->Delete();
243
245 }
246 else
247 _despawntimer -= diff;
248 }
249
250private:
253
254};
255
256std::array<uint32, 4> const SummonSpells =
257{
259};
260
261std::array<uint32, 4> const SummonSpellsHeroic =
262{
264};
265
266// 47958, 57082 - Crystal Spikes
268{
269 bool Validate(SpellInfo const* /*spellInfo*/) override
270 {
272 }
273
274 void HandleScript(SpellEffIndex /*effIndex*/)
275 {
276 Unit* caster = GetCaster();
277 for (uint32 spells : (caster->GetMap()->IsHeroic() ? SummonSpellsHeroic : SummonSpells))
278 caster->CastSpell(caster, spells);
279 }
280
281 void Register() override
282 {
284 }
285};
286
287// 47941 - Crystal Spike
289{
290 void HandlePeriodic(AuraEffect const* /*aurEff*/)
291 {
292 Unit* target = GetTarget();
294 if (Creature* trigger = target->ToCreature())
295 {
297 if (trigger->AI()->GetData(DATA_COUNT) < MAX_COUNT)
298 trigger->CastSpell(trigger, spell, true);
299 }
300 }
301
302 void Register() override
303 {
305 }
306};
307
309{
314}
uint32_t uint32
Definition: Define.h:142
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_AURA_PERIODIC_DUMMY
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ SAY_DEATH
@ SAY_CRYSTAL_SPIKES
@ SAY_REFLECT
@ SAY_AGGRO
@ SAY_KILL
@ SAY_FRENZY
@ SPELL_TRAMPLE
@ SPELL_CRYSTAL_SPIKES
@ SPELL_SUMMON_CRYSTAL_SPIKE_2_H
@ SPELL_SUMMON_CRYSTAL_SPIKE_1_H
@ SPELL_SUMMON_CRYSTAL_SPIKE_2
@ SPELL_SUMMON_CRYSTAL_SPIKE_3
@ SPELL_SUMMON_CRYSTAL_SPIKE_1
@ SPELL_SUMMON_CRYSTAL_SPIKE_4
@ SPELL_SUMMON_CRYSTAL_SPIKE_3_H
@ SPELL_FRENZY
@ SPELL_SUMMON_CRYSTAL_SPIKE_4_H
@ SPELL_SPELL_REFLECTION
@ SPELL_SUMMON_CRYSTALLINE_TANGLER
std::array< uint32, 4 > const SummonSpells
void AddSC_boss_ormorok()
uint32 const crystalSpikeSummon[3]
CrystalSpikes
@ NPC_CRYSTAL_SPIKE_INITIAL
@ SPELL_CRYSTAL_SPIKE_AURA
@ NPC_CRYSTAL_SPIKE_TRIGGER
@ GO_CRYSTAL_SPIKE_TRAP
@ DATA_COUNT
@ MAX_COUNT
@ SPELL_CRYSTAL_SPIKE_DAMAGE
@ EVENT_CRYSTALLINE_TANGLER
@ EVENT_SPELL_REFLECTION
@ EVENT_CRYSTAL_SPIKES
@ EVENT_TRAMPLE
std::array< uint32, 4 > const SummonSpellsHeroic
Yells
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
void Reset() override
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool IsHeroic() const
Definition: Map.cpp:3282
static Creature * ToCreature(Object *o)
Definition: Object.h:219
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
bool operator()(WorldObject *object) const
OrmorokTanglerPredicate(Unit *unit)
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:839
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
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition: Unit.cpp:12671
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition: Object.cpp:2170
Map * GetMap() const
Definition: Object.h:624
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
void HandlePeriodic(AuraEffect const *)
bool Validate(SpellInfo const *) override
@ DATA_ORMOROK
Definition: nexus.h:33
#define RegisterNexusCreatureAI(ai_name)
Definition: nexus.h:74
bool IsHeroic() const
bool HealthBelowPct(uint32 pct) const
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void KilledUnit(Unit *who) override
void Reset() override
boss_ormorok(Creature *creature)
void DamageTaken(Unit *, uint32 &, DamageEffectType, SpellInfo const *) override
void Initialize()
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
uint32 GetData(uint32 type) const override
npc_crystal_spike_trigger(Creature *creature)
void IsSummonedBy(WorldObject *owner) override