TrinityCore
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
61{
62 // General Bjarngrim
72
73 // Stormforged Lieutenant
76};
77
79{
83};
84
86{
88};
89
91{
93};
94
96{
97 // General Bjarngrim
106 SAY_DEATH = 8
108
110{
111 ITEM_ID_AXE = 43625,
113 ITEM_ID_GREATAXE = 43623
115
117{
121
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
152static std::array<StanceInfo, MAX_STANCE> const StanceData =
153{
157};
158
160{
162
163 void JustAppeared() override
164 {
167 }
168
169 void JustEngagedWith(Unit* who) override
170 {
172 Talk(SAY_AGGRO, who);
173 events.Reset();
175 }
176
177 void EnterEvadeMode(EvadeReason /*why*/) override
178 {
181 }
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
326 void JustEngagedWith(Unit* /*who*/) override
327 {
330 }
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
382 bool Validate(SpellInfo const* /*spellInfo*/) override
383 {
385 }
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
441 void Register() override
442 {
445 }
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
464 void Register() override
465 {
467 }
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
484 void Register() override
485 {
487 }
488};
489
491{
494 RegisterSpellScriptWithArgs(spell_bjarngrim_stance_dummy, "spell_bjarngrim_defensive_stance_dummy", STANCE_DEFENSIVE);
495 RegisterSpellScriptWithArgs(spell_bjarngrim_stance_dummy, "spell_bjarngrim_battle_stance_dummy", STANCE_BATTLE);
496 RegisterSpellScriptWithArgs(spell_bjarngrim_stance_dummy, "spell_bjarngrim_berserker_stance_dummy", STANCE_BERSERKER);
499}
Texts
Actions
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ WAYPOINT_MOTION_TYPE
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition: ScriptMgr.h:1368
@ EFFECT_0
Definition: SharedDefines.h:30
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define sSpellMgr
Definition: SpellMgr.h:849
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:2029
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
EvadeReason
Definition: UnitAICommon.h:30
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ 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_BATTLE_AURA
@ SPELL_TEMPOARY_ELECTRICAL_CHARGE
@ SPELL_RENEW_STEEL
@ SPELL_MORTAL_STRIKE
@ SPELL_DEFENSIVE_AURA
@ SPELL_ARC_WELD_DAMAGE
@ SPELL_KNOCK_AWAY
@ 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
@ SAY_DEFENSIVE_STANCE
@ SAY_BERSERKER_STANCE
static std::array< uint8, 2 > const ClearTempoaryChargeWaypointIds
@ EVENT_SPELL_REFLECTION
@ EVENT_KNOCK_AWAY
@ EVENT_CHECK_BJARNGRIMS_HEALTH
@ EVENT_CHECK_STANCE_COOLDOWN
@ EVENT_MORTAL_STRIKE
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
Unit * GetTarget() const
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)
Definition: CreatureAI.cpp:219
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 SetCanDualWield(bool value) override
Definition: Creature.cpp:1940
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void CancelEventGroup(uint32 group)
Definition: EventMap.cpp:153
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
void Reset()
Definition: EventMap.cpp:21
Creature * GetCreature(uint32 type)
InstanceMap * instance
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition: Map.cpp:2348
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
Definition: Map.cpp:2437
static Creature * ToCreature(Object *o)
Definition: Object.h:219
bool IsPlayer() const
Definition: Object.h:212
Duration GetRemainingCooldown(SpellInfo const *spellInfo) const
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
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
void SetVirtualItem(uint32 slot, uint32 itemId, uint16 appearanceModId=0, uint16 itemVisual=0)
Definition: Unit.cpp:13604
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
SpellHistory * GetSpellHistory()
Definition: Unit.h:1457
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
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