TrinityCore
Loading...
Searching...
No Matches
boss_omor_the_unscarred.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/*
19 * Combat timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "Containers.h"
24#include "hellfire_ramparts.h"
25#include "Player.h"
26#include "ScriptedCreature.h"
27#include "SpellAuraEffects.h"
28#include "SpellInfo.h"
29#include "SpellScript.h"
30
40
54
63
64// 17308 - Omor the Unscarred
66{
68
69 void Reset() override
70 {
71 _Reset();
72
73 _demonicShieldUsed = false;
74 }
75
87
88 void AttackStart(Unit* who) override
89 {
91 }
92
93 void OnSpellCast(SpellInfo const* spellInfo) override
94 {
95 switch (spellInfo->Id)
96 {
98 if (roll_chance_i(30))
100 break;
103 break;
104 default:
105 break;
106 }
107 }
108
109 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
110 {
111 if (!_demonicShieldUsed && me->HealthBelowPctDamaged(20, damage))
112 {
113 _demonicShieldUsed = true;
115 }
116 }
117
118 void JustSummoned(Creature* summoned) override
119 {
120 // Engage but don't despawn hounds
121 if (me->IsEngaged())
122 DoZoneInCombat(summoned);
123 }
124
125 void KilledUnit(Unit* /*victim*/) override
126 {
127 Talk(SAY_SLAY);
128 }
129
130 void JustDied(Unit* /*killer*/) override
131 {
132 _JustDied();
134 }
135
136 void UpdateAI(uint32 diff) override
137 {
138 if (!UpdateVictim())
139 return;
140
141 events.Update(diff);
142
144 return;
145
146 while (uint32 eventId = events.ExecuteEvent())
147 {
148 switch (eventId)
149 {
153 events.Repeat(6s, 10s);
154 else
155 events.Repeat(3s, 4s);
156 break;
160 events.Repeat(30s, 40s);
161 break;
164 events.Repeat(20s, 26s);
165 break;
168 events.Repeat(23s, 30s);
169 break;
172 break;
173 default:
174 break;
175 }
176
178 return;
179 }
180
182 }
183
184private:
186};
187
188// 35642 - Orbital Strike Target
190{
192
193 bool Validate(SpellInfo const* /*spellInfo*/) override
194 {
196 }
197
198 void FilterTargets(std::list<WorldObject*>& targets)
199 {
200 if (targets.size() <= 1)
201 return;
202
203 Unit* caster = GetCaster();
204 targets.remove_if([caster](WorldObject const* target)
205 {
206 return caster->GetExactDist2d(target) > 20.0f;
207 });
208
210 _canContinue = true;
211 }
212
213 void HandleDummy(SpellEffIndex /*effIndex*/)
214 {
215 if (!_canContinue)
216 return;
217
218 Unit* caster = GetCaster();
219 Unit* target = GetHitUnit();
220
221 caster->CastSpell(caster, SPELL_ORBITAL_STRIKE_WHIP, true);
222 caster->CastSpell(target, SPELL_ORBITAL_STRIKE_KNOCK, true);
223
224 if (Creature* creature = caster->ToCreature())
225 creature->AI()->Talk(SAY_KNOCK, target);
226
227 if (caster->CanHaveThreatList())
228 caster->GetThreatManager().ModifyThreatByPercent(target, -100);
229 }
230
236
237private:
238 bool _canContinue = false;
239};
240
241// 32185 - Orbital Strike
243{
245
246 bool Validate(SpellInfo const* spellInfo) override
247 {
248 return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
249 }
250
251 void OnPeriodic(AuraEffect const* aurEff)
252 {
254
255 if (Creature* creature = GetTarget()->ToCreature())
256 {
257 for (ThreatReference const* ref : creature->GetThreatManager().GetUnsortedThreatList())
258 {
259 Unit* victim = ref->GetVictim();
260 if (victim->IsPlayer() && victim->IsFalling())
261 creature->CastSpell(victim, aurEff->GetSpellEffectInfo().TriggerSpell, aurEff);
262 }
263 }
264 }
265
270};
271
uint32_t uint32
Definition Define.h:133
bool roll_chance_i(int chance)
Definition Random.h:59
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ TARGET_UNIT_SRC_AREA_ENEMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
void AddSC_boss_omor_the_unscarred()
@ EVENT_SUMMON_FIENDISH_HOUND
@ EVENT_ORBITAL_STRIKE_TARGET
@ EVENT_TREACHEROUS_AURA
@ SPELL_ORBITAL_STRIKE_KNOCK
@ SPELL_ORBITAL_STRIKE_TARGET
@ SPELL_TREACHEROUS_AURA
@ SPELL_SUMMON_FIENDISH_HOUND
@ SPELL_ORBITAL_STRIKE_WHIP
SpellEffectInfo const & GetSpellEffectInfo() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
bool IsEngaged() const override
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
static Creature * ToCreature(Object *o)
Definition Object.h:186
bool IsPlayer() const
Definition Object.h:179
uint32 TriggerSpell
Definition SpellInfo.h:228
uint32 Id
Definition SpellInfo.h:289
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:483
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void ModifyThreatByPercent(Unit *target, int32 percent)
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:48
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:844
bool CanHaveThreatList() const
====================== THREAT & COMBAT ====================
Definition Unit.h:1122
ThreatManager & GetThreatManager()
Definition Unit.h:1155
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
bool IsFalling() const
Definition Unit.cpp:12813
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_omor_the_unscarred_orbital_strike_target)
void FilterTargets(std::list< WorldObject * > &targets)
PrepareAuraScript(spell_omor_the_unscarred_orbital_strike_whip)
bool Validate(SpellInfo const *spellInfo) override
@ DATA_OMOR_THE_UNSCARRED
#define RegisterHellfireRampartsCreatureAI(ai_name)
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:66
float GetExactDist2d(const float x, const float y) const
Definition Position.h:109
void JustEngagedWith(Unit *who) override
void JustSummoned(Creature *summoned) override
void AttackStart(Unit *who) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void OnSpellCast(SpellInfo const *spellInfo) override
void UpdateAI(uint32 diff) override
boss_omor_the_unscarred(Creature *creature)