TrinityCore
boss_bronjahm.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 "forge_of_souls.h"
20#include "InstanceScript.h"
21#include "Map.h"
22#include "MotionMaster.h"
23#include "ObjectAccessor.h"
24#include "ScriptedCreature.h"
25#include "SpellAuraEffects.h"
26#include "SpellScript.h"
27
29{
35};
36
38{
44 SPELL_FEAR = 68950,
46 SPELL_SOULSTORM_CHANNEL = 69008, // Pre-fight
47 SPELL_SOULSTORM_VISUAL = 68870, // Pre-cast Soulstorm
48 SPELL_PURPLE_BANISH_VISUAL = 68862 // Used by Soul Fragment (Aura)
49};
50
52{
57 EVENT_FEAR = 5
58};
59
61{
63 PHASE_2 = 2
64};
65
66enum Misc
67{
69};
70
71struct boss_bronjahm : public BossAI
72{
74 {
76 }
77
78 void Reset() override
79 {
80 _Reset();
85 me->SetCanMelee(true);
86 }
87
88 void JustReachedHome() override
89 {
92 }
93
94 void JustEngagedWith(Unit* who) override
95 {
99 }
100
101 void JustDied(Unit* /*killer*/) override
102 {
103 _JustDied();
105 }
106
107 void KilledUnit(Unit* who) override
108 {
109 if (who->GetTypeId() == TYPEID_PLAYER)
110 Talk(SAY_SLAY);
111 }
112
113 void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
114 {
116 {
119 events.ScheduleEvent(EVENT_FEAR, 12s, 16s, 0, PHASE_2);
121 me->SetCanMelee(false);
122 }
123 }
124
125 void JustSummoned(Creature* summon) override
126 {
127 if (summon->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT)
128 {
129 summons.Summon(summon);
131 summon->GetMotionMaster()->MoveFollow(me, me->GetCombatReach(), 0.0f);
132 summon->CastSpell(summon, SPELL_PURPLE_BANISH_VISUAL, true);
133 }
134 }
135
136 uint32 GetData(uint32 type) const override
137 {
138 if (type == DATA_SOUL_POWER)
139 {
140 uint32 count = 0;
141 for (ObjectGuid const& guid : summons)
142 {
143 if (Creature* summon = ObjectAccessor::GetCreature(*me, guid))
144 if (summon->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT && summon->IsAlive())
145 ++count;
146 }
147 return count;
148 }
149
150 return 0;
151 }
152
153 void UpdateAI(uint32 diff) override
154 {
155 if (!UpdateVictim())
156 return;
157
158 events.Update(diff);
159
161 return;
162
163 while (uint32 eventId = events.ExecuteEvent())
164 {
165 switch (eventId)
166 {
167 case EVENT_MAGIC_BANE:
170 break;
173 {
176 }
177 else
178 {
182 }
183 break;
185 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
186 {
188 DoCast(target, SPELL_CORRUPT_SOUL);
189 }
191 break;
192 case EVENT_SOULSTORM:
195 me->CastSpell(me, SPELL_SOULSTORM, false);
196 break;
197 case EVENT_FEAR:
200 break;
201 default:
202 break;
203 }
204
206 return;
207 }
208 }
209};
210
212{
214 {
216 }
217
218 void IsSummonedBy(WorldObject* /*summoner*/) override
219 {
221 bronjahm->AI()->JustSummoned(me);
222 }
223
224 void MovementInform(uint32 type, uint32 id) override
225 {
226 if (type != FOLLOW_MOTION_TYPE)
227 return;
228
230 return;
231
232 me->CastSpell(nullptr, SPELL_CONSUME_SOUL, true);
234 }
235
236private:
238};
239
240// 68793, 69050 - Magic's Bane
242{
243 void CalculateDamage(Unit const* victim, int32& damage, int32& /*flatMod*/, float& /*pctMod*/) const
244 {
245 if (victim->GetPowerType() != POWER_MANA)
246 return;
247
248 int32 const maxDamage = GetCaster()->GetMap()->IsHeroic() ? 15000 : 10000;
249 int32 newDamage = damage + (victim->GetMaxPower(POWER_MANA) / 2);
250 damage = std::min(maxDamage, newDamage);
251 }
252
253 void Register() override
254 {
256 }
257};
258
259// 68861 - Consume Soul
261{
263 {
264 PreventHitDefaultEffect(effIndex);
266 }
267
268 void Register() override
269 {
271 }
272};
273
275{
276 68904,
277 68886,
278 68905,
279 68896,
280 68906,
281 68897,
282 68907,
283 68898
284};
285
287{
288 void HandlePeriodicTick(AuraEffect const* aurEff)
289 {
292 }
293
294 void Register() override
295 {
297 }
298};
299
300// 68921, 69049 - Soulstorm
302{
303 void FilterTargets(std::list<WorldObject*>& targets)
304 {
305 Unit* caster = GetCaster();
306 targets.remove_if([caster](WorldObject* target)
307 {
308 return caster->GetExactDist2d(target) <= 10.0f;
309 });
310 }
311
312 void Register() override
313 {
315 }
316};
317
319{
320 public:
321 achievement_bronjahm_soul_power() : AchievementCriteriaScript("achievement_bronjahm_soul_power") { }
322
323 bool OnCheck(Player* /*source*/, Unit* target) override
324 {
325 return target && target->GetAI()->GetData(DATA_SOUL_POWER) >= 4;
326 }
327};
328
330{
335 RegisterSpellScriptWithArgs(spell_bronjahm_soulstorm_visual, "spell_bronjahm_soulstorm_channel");
336 RegisterSpellScriptWithArgs(spell_bronjahm_soulstorm_visual, "spell_bronjahm_soulstorm_visual");
339}
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ FOLLOW_MOTION_TYPE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition: ScriptMgr.h:1368
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_DEST_AREA_ENEMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ POWER_MANA
#define EFFECT_ALL
Definition: SharedDefines.h:72
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELLVALUE_MAX_TARGETS
Definition: SpellDefines.h:230
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define SpellCalcDamageFn(F)
Definition: SpellScript.h:879
@ REACT_PASSIVE
Definition: UnitDefines.h:506
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
static uint32 const SoulstormVisualSpells[]
@ DATA_SOUL_POWER
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_SLAY
@ SAY_CORRUPT_SOUL
@ SAY_SOUL_STORM
void AddSC_boss_bronjahm()
@ SPELL_CONSUME_SOUL
@ SPELL_PURPLE_BANISH_VISUAL
@ SPELL_FEAR
@ SPELL_SOULSTORM_CHANNEL
@ SPELL_TELEPORT
@ SPELL_SHADOW_BOLT
@ SPELL_MAGIC_S_BANE
@ SPELL_SOULSTORM
@ SPELL_SOULSTORM_VISUAL
@ SPELL_CORRUPT_SOUL
CombatPhases
@ PHASE_2
@ PHASE_1
@ EVENT_CORRUPT_SOUL
@ EVENT_FEAR
@ EVENT_MAGIC_BANE
@ EVENT_SOULSTORM
@ EVENT_SHADOW_BOLT
Yells
uint32 GetTickNumber() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetTarget() const
void _JustReachedHome()
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
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 SetCanMelee(bool canMelee, bool fleeFromMelee=false)
Definition: Creature.cpp:2822
void SetReactState(ReactStates st)
Definition: Creature.h:160
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 IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
virtual ObjectGuid GetGuidData(uint32 type) const override
bool IsHeroic() const
Definition: Map.cpp:3282
void MoveFollow(Unit *target, float dist, ChaseAngle angle, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_ACTIVE)
LowType GetCounter() const
Definition: ObjectGuid.h:293
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
HookList< DamageAndHealingCalcHandler > CalcDamage
Definition: SpellScript.h:878
Unit * GetCaster() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
void Summon(Creature const *summon)
virtual uint32 GetData(uint32) const
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
bool IsWithinMeleeRange(Unit const *obj) const
Definition: Unit.h:699
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
Powers GetPowerType() const
Definition: Unit.h:799
float GetCombatReach() const override
Definition: Unit.h:694
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:9410
UnitAI * GetAI() const
Definition: Unit.h:660
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
Map * GetMap() const
Definition: Object.h:624
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
bool OnCheck(Player *, Unit *target) override
void HandleScript(SpellEffIndex effIndex)
void CalculateDamage(Unit const *victim, int32 &damage, int32 &, float &) const
void FilterTargets(std::list< WorldObject * > &targets)
void HandlePeriodicTick(AuraEffect const *aurEff)
@ DATA_BRONJAHM
@ NPC_CORRUPTED_SOUL_FRAGMENT
#define RegisterForgeOfSoulsCreatureAI(ai_name)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:106
bool HealthAbovePct(uint32 pct) const
void Reset() override
boss_bronjahm(Creature *creature)
void JustSummoned(Creature *summon) override
uint32 GetData(uint32 type) const override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void KilledUnit(Unit *who) override
void DamageTaken(Unit *, uint32 &, DamageEffectType, SpellInfo const *) override
void JustReachedHome() override
void JustDied(Unit *) override
void IsSummonedBy(WorldObject *) override
npc_corrupted_soul_fragment(Creature *creature)
void MovementInform(uint32 type, uint32 id) override