TrinityCore
Loading...
Searching...
No Matches
boss_general_bjarngrim.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 "halls_of_lightning.h"
20#include "SpellScript.h"
21#include "CreatureGroups.h"
22#include "InstanceScript.h"
23#include "Map.h"
24#include "MovementDefines.h"
25#include "ObjectAccessor.h"
26#include "ScriptedCreature.h"
27#include "SpellAuras.h"
28#include "SpellHistory.h"
29#include "SpellMgr.h"
30
32{
33 // General Bjarngrim
45 SPELL_CLEAVE = 15284,
49 SPELL_SLAM = 52026,
50
51 // Stormforged Lieutenant
55
56 // Invisible Stalker
58};
59
77
84
89
94
108
115
124
125// These values must be sync with the data in waypoint_path_node.
126// Each of these points is going to trigger a Charge Up sequence
127static std::array<uint8, 2> const ChargeUpWaypointIds = { 7, 15 };
128// Each of these points is going to remove the Tempoary Electrical Charge buff from General Bjarngrim
129static std::array<uint8, 2> const ClearTempoaryChargeWaypointIds = { 5, 13 };
130
131// This value must be sync with the data in spawngroup_template
133
135{
136 StanceTextInfo(uint32 announceTextId, uint32 sayTextId) :
137 AnnounceTextId(announceTextId), SayTextId(sayTextId) { }
138
141};
142
144{
145 StanceInfo(StanceTextInfo textInfo, uint32 stanceSpellId) :
146 TextInfo(textInfo), StanceSpellId(stanceSpellId) { }
147
150};
151
158
160{
162
168
169 void JustEngagedWith(Unit* who) override
170 {
172 Talk(SAY_AGGRO, who);
173 events.Reset();
175 }
176
182
183 void KilledUnit(Unit* victim) override
184 {
185 if (victim->IsPlayer())
186 Talk(SAY_SLAY, victim);
187 }
188
189 void JustDied(Unit* killer) override
190 {
191 BossAI::JustDied(killer);
192 Talk(SAY_DEATH, killer);
194 }
195
196 void MovementInform(uint32 motionType, uint32 pointId) override
197 {
198 if (motionType != WAYPOINT_MOTION_TYPE)
199 return;
200
201 if (std::find(ChargeUpWaypointIds.begin(), ChargeUpWaypointIds.end(), pointId) != ChargeUpWaypointIds.end())
203 else if (std::find(ClearTempoaryChargeWaypointIds.begin(), ClearTempoaryChargeWaypointIds.end(), pointId) != ClearTempoaryChargeWaypointIds.end())
205 }
206
207 void DoAction(int32 action) override
208 {
209 switch (action)
210 {
212 {
214
215 // @todo: figure out if the stances just cycle or if they are random
217
218 DoCastSelf(StanceData[_currentStanceId].StanceSpellId);
219 Talk(StanceData[_currentStanceId].TextInfo.AnnounceTextId);
220 Talk(StanceData[_currentStanceId].TextInfo.SayTextId);
221
222 switch (_currentStanceId)
223 {
224 case STANCE_DEFENSIVE:
229 break;
230 case STANCE_BERSERKER:
236 break;
237 case STANCE_BATTLE:
242 break;
243 default:
244 break;
245 }
246
247 break;
248 }
249 default:
250 break;
251 }
252 }
253
254 void UpdateAI(uint32 diff) override
255 {
257 return;
258
259 events.Update(diff);
260
262 return;
263
264 while (uint32 eventId = events.ExecuteEvent())
265 {
266 switch (eventId)
267 {
268 case EVENT_CHARGE_UP:
271 stalker->m_Events.AddEventAtOffset([stalker]() { stalker->CastSpell(nullptr, SPELL_CHARGE_UP_DUMMY); }, 4s);
272 break;
274 // General Bjarngrim uses a category cooldown to handle the stance switching, so we do as well.
277 events.Repeat(1s);
278 break;
279 case EVENT_KNOCK_AWAY:
281 events.Repeat(11s);
282 break;
285 events.Repeat(8s + 500ms);
286 break;
287 case EVENT_WHIRLWIND:
289 break;
290 case EVENT_INTERCEPT:
291 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, -8.f, true, true))
292 DoCast(target, SPELL_INTERCEPT);
293 break;
294 case EVENT_CLEAVE:
296 break;
299 break;
300 case EVENT_SLAM:
302 events.Repeat(5s);
303 break;
304 default:
305 break;
306 }
307
309 return;
310 }
311 }
312
313 private:
315};
316
318{
320
321 void InitializeAI() override
322 {
324 }
325
331
332 void EnterEvadeMode(EvadeReason why) override
333 {
335 _events.Reset();
336 }
337
338 void UpdateAI(uint32 diff) override
339 {
340 if (!UpdateVictim())
341 return;
342
343 _events.Update(diff);
344
346 return;
347
348 while (uint32 eventId = _events.ExecuteEvent())
349 {
350 switch (eventId)
351 {
352 case EVENT_ARC_WELD:
353 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.f, true))
354 DoCast(target, SPELL_ARC_WELD);
355 _events.Repeat(22s);
356 break;
359 if (bjarngrim->GetHealthPct() <= 75.f) // @todo: validate
360 DoCast(bjarngrim, SPELL_RENEW_STEEL);
361
362 _events.Repeat(10s, 14s); // @todo: these are just taken from the old code. We know that these heals are pct based so we need the cooldown rather than a timer
363 break;
364 default:
365 break;
366 }
367 }
368 }
369private:
372};
373
374// 53790 - Defensive Stance
375// 53791 - Berserker Stance
376// 53792 - Battle Stance
378{
379public:
381
386
387 void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
388 {
389 Creature* target = GetTarget()->ToCreature();
390 if (!target)
391 return;
392
393 switch (_stanceId)
394 {
395 case STANCE_DEFENSIVE:
396 target->SetVirtualItem(0, ITEM_ID_AXE);
397 target->SetVirtualItem(1, ITEM_ID_SHIELD);
398 target->CastSpell(nullptr, SPELL_DEFENSIVE_AURA);
399 break;
400 case STANCE_BERSERKER:
401 target->SetVirtualItem(0, ITEM_ID_AXE);
402 target->SetVirtualItem(1, ITEM_ID_AXE);
403 target->CastSpell(nullptr, SPELL_BERSERKER_AURA);
404 target->SetCanDualWield(true);
405 break;
406 case STANCE_BATTLE:
408 target->SetVirtualItem(1, 0);
409 target->CastSpell(nullptr, SPELL_BATTLE_AURA);
410 break;
411 default:
412 break;
413 }
414
415 target->CastSpell(nullptr, SPELL_STANCE_COOLDOWN);
416 }
417
418 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
419 {
420 Creature* target = GetTarget()->ToCreature();
421 if (!target)
422 return;
423
424 switch (_stanceId)
425 {
426 case STANCE_DEFENSIVE:
428 break;
429 case STANCE_BERSERKER:
431 target->SetCanDualWield(false);
432 break;
433 case STANCE_BATTLE:
435 break;
436 default:
437 break;
438 }
439 }
440
446private:
448};
449
450// 52098 - Charge Up
452{
453 bool Validate(SpellInfo const* /*spellInfo*/) override
454 {
456 }
457
458 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
459 {
460 if (Creature* target = GetTarget()->ToCreature())
461 target->CastSpell(nullptr, SPELL_TEMPOARY_ELECTRICAL_CHARGE);
462 }
463
468};
469
470// 59085 - Arc Weld
472{
473 bool Validate(SpellInfo const* /*spellInfo*/) override
474 {
476 }
477
478 void HandlePeriodic(AuraEffect const* /*aurEff*/)
479 {
480 if (GetTarget()->isMoving())
481 GetTarget()->CastSpell(nullptr, SPELL_ARC_WELD_DAMAGE, true);
482 }
483
488};
489
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ WAYPOINT_MOTION_TYPE
Spells
Definition PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition ScriptMgr.h:1382
@ EFFECT_0
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define sSpellMgr
Definition SpellMgr.h:812
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ EVENT_GROUP_BERSERKER_STANCE
@ EVENT_GROUP_DEFENSIVE_STANCE
@ EVENT_GROUP_BATTLE_STANCE
@ ACTION_SWITCH_STANCE
static std::array< uint8, 2 > const ChargeUpWaypointIds
static constexpr uint32 SPAWN_GROUP_ID_STORMFORGED_LIEUTENANTS
@ SPELL_BATTLE_STANCE
@ SPELL_DEFENSIVE_STANCE
@ SPELL_TEMPOARY_ELECTRICAL_CHARGE
@ SPELL_MORTAL_STRIKE
@ SPELL_DEFENSIVE_AURA
@ SPELL_ARC_WELD_DAMAGE
@ SPELL_SPELL_REFLECTION
@ SPELL_BERSERKER_AURA
@ SPELL_CHARGE_UP_DUMMY
@ SPELL_STANCE_COOLDOWN
@ SPELL_BERSERKER_STANCE
@ PHASE_OUT_OF_COMBAT
static std::array< StanceInfo, MAX_STANCE > const StanceData
void AddSC_boss_general_bjarngrim()
@ SAY_ANNOUNCE_BATTLE_STANCE
@ SAY_ANNOUNCE_BERSERKER_STANCE
@ SAY_ANNOUNCE_DEFENSIVE_STANCE
static std::array< uint8, 2 > const ClearTempoaryChargeWaypointIds
@ EVENT_SPELL_REFLECTION
@ EVENT_CHECK_BJARNGRIMS_HEALTH
@ EVENT_CHECK_STANCE_COOLDOWN
@ EVENT_MORTAL_STRIKE
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
bool IsPlayer() const
Definition BaseEntity.h:173
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
EventMap events
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetCanDualWield(bool value) override
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void CancelEventGroup(uint32 group)
Definition EventMap.cpp:157
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
bool IsInPhase(uint8 phase) const
Definition EventMap.h:222
void SetPhase(uint8 phase)
Definition EventMap.cpp:32
void Reset()
Definition EventMap.cpp:25
Creature * GetCreature(uint32 type)
InstanceMap * instance
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2350
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
Definition Map.cpp:2439
Creature * ToCreature()
Definition Object.h:121
Duration GetRemainingCooldown(SpellInfo const *spellInfo) const
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
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:162
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetVirtualItem(uint32 slot, uint32 itemId, uint16 appearanceModId=0, uint16 itemVisual=0)
Definition Unit.cpp:14374
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
SpellHistory * GetSpellHistory()
Definition Unit.h:1498
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
bool Validate(SpellInfo const *) override
void HandlePeriodic(AuraEffect const *)
bool Validate(SpellInfo const *) override
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
#define RegisterHallsOfLightningCreatureAI(ai_name)
@ DATA_GENERAL_BJARNGRIM
@ DATA_INVISIBLE_STALKER
Difficulty GetDifficulty() const
StanceInfo(StanceTextInfo textInfo, uint32 stanceSpellId)
StanceTextInfo TextInfo
StanceTextInfo(uint32 announceTextId, uint32 sayTextId)
void EnterEvadeMode(EvadeReason) override
void MovementInform(uint32 motionType, uint32 pointId) override
void UpdateAI(uint32 diff) override
void KilledUnit(Unit *victim) override
void JustDied(Unit *killer) override
void DoAction(int32 action) override
boss_general_bjarngrim(Creature *creature)
void JustEngagedWith(Unit *who) override
void EnterEvadeMode(EvadeReason why) override