TrinityCore
boss_general_husam.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 "Containers.h"
20#include "InstanceScript.h"
22#include "MoveSplineInit.h"
23#include "MotionMaster.h"
24#include "PassiveAI.h"
25#include "ScriptedCreature.h"
26#include "SpellInfo.h"
27#include "SpellScript.h"
28#include "TemporarySummon.h"
29#include "Vehicle.h"
30
32{
33 // General Husam
45 SPELL_HURL = 83236,
47
48 // Shockwave Stalker
51
52 // Shockwave Visual
54
55 // Tol'Vir Land Mine
61
62 // Bad Intentions Target
65};
66
68{
69 // General Husam
76
77 // Tol'Vir Land Mine
81};
82
84{
85 // General Husam
87
88 // Tol'vir Land Mine
91};
92
94{
95 // General Husam
101 SAY_DEATH = 5
103
105{
106 SEAT_PLAYER = 0
108
110{
112
113 void JustEngagedWith(Unit* who) override
114 {
118
123 if (IsHeroic() || IsTimewalking())
125 }
126
127 void KilledUnit(Unit* victim) override
128 {
129 if (victim->IsPlayer())
130 Talk(SAY_SLAY);
131 }
132
133 void JustDied(Unit* /*killer*/) override
134 {
135 _JustDied();
139 }
140
141 void EnterEvadeMode(EvadeReason /*why*/) override
142 {
147 }
148
149 void JustSummoned(Creature* summon) override
150 {
151 summons.Summon(summon);
152
153 switch (summon->GetEntry())
154 {
156 {
158 float orientation = summon->GetAbsoluteAngle(me) + float(M_PI);
159 Position dest = summon->GetPosition();
160 dest.m_positionX += std::cos(orientation) * 40.f;
161 dest.m_positionY += std::sin(orientation) * 40.f;
162
163 std::function<void(Movement::MoveSplineInit&)> initializer = [dest](Movement::MoveSplineInit& init)
164 {
165 init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false);
166 init.SetVelocity(8.f);
167 };
168 summon->GetMotionMaster()->LaunchMoveSpline(std::move(initializer));
170
171 if (_shockwaveStalkerCount == 4)
172 {
175 }
176 break;
177 }
178 default:
179 break;
180 }
181 }
182
183 void PassengerBoarded(Unit* /*passenger*/, int8 /*seatId*/, bool apply) override
184 {
185 if (apply)
187 }
188
189 void DoAction(int32 action) override
190 {
191 if (action == ACTION_SAY_DETONATE_TRAPS)
193 }
194
195 void UpdateAI(uint32 diff) override
196 {
197 if (!UpdateVictim())
198 return;
199
200 events.Update(diff);
201
203 return;
204
205 while (uint32 eventId = events.ExecuteEvent())
206 {
207 switch (eventId)
208 {
211 events.Repeat(21s);
212 break;
215 events.Repeat(11s, 12s);
216 break;
220 break;
221 case EVENT_SHOCKWAVE:
228
232 events.Repeat(39s);
233 break;
237 events.Repeat(32s);
238 break;
243 break;
244 default:
245 break;
246 }
247 }
248 }
249
250private:
252};
253
255{
256 npc_husam_tolvir_land_mine(Creature* creature) : NullCreatureAI(creature), _instance(nullptr) { }
257
258 void InitializeAI() override
259 {
261 }
262
263 void JustAppeared() override
264 {
265 if (!_instance)
266 return;
267
268 switch (me->GetEntry())
269 {
272 husam->CastSpell(me, SPELL_THROW_LAND_MINES);
274 break;
277 {
278 if (CreatureAI* ai = husam->AI())
279 {
280 ai->JustSummoned(me);
282 ai->JustSummoned(landMine);
283 }
284 }
285 break;
287 if (me->IsSummon())
288 if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
289 me->EnterVehicle(summoner);
291 break;
292 default:
293 break;
294 }
295 }
296
297 void PassengerBoarded(Unit* /*passenger*/, int8 /*seatId*/, bool apply) override
298 {
299 // If our casting land mine has despawned, we also despawn alongside it.
302 }
303
304 void DoAction(int32 action) override
305 {
306 switch (action)
307 {
310 break;
311 case ACTION_DETONATE:
312 _events.Reset();
318 break;
319 default:
320 break;
321 }
322 }
323
324 void UpdateAI(uint32 diff) override
325 {
326 _events.Update(diff);
327
328 while (uint32 eventId = _events.ExecuteEvent())
329 {
330 switch (eventId)
331 {
332 case EVENT_READY_MINE:
336 break;
340 break;
345 break;
346 default:
347 break;
348 }
349 }
350 }
351
352private:
355};
356
358{
360
361 void PassengerBoarded(Unit* passenger, int8 /*seatId*/, bool apply) override
362 {
363 if (apply)
364 {
365 me->m_Events.AddEventAtOffset([&, passenger]()
366 {
367 if (passenger)
368 {
369 DoCast(passenger, SPELL_HARD_IMPACT);
371 }
372 }, 400ms);
373 }
374 }
375};
376
378{
380
381 void JustAppeared() override
382 {
384 me->m_Events.AddEventAtOffset([&]() { me->RemoveAllAuras(); }, 7s);
385 me->DespawnOrUnsummon(12s);
386 }
387};
388
390{
391 bool Validate(SpellInfo const* spellInfo) override
392 {
393 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
394 }
395
396 void HandleTick(AuraEffect const* /*aurEff*/)
397 {
399 GetTarget()->CastSpell(GetCaster()->GetVictim(), GetSpellInfo()->GetEffect(EFFECT_0).TriggerSpell, true);
400 }
401
402 void Register() override
403 {
405 }
406};
407
409{
410 bool Validate(SpellInfo const* /*spellInfo*/) override
411 {
413 }
414
416 {
418 }
419
420 void Register() override
421 {
423 }
424};
425
427{
428 bool Validate(SpellInfo const* /*spellInfo*/) override
429 {
431 }
432
433 void FilterTargets(std::list<WorldObject*>& targets)
434 {
435 if (targets.empty())
437 }
438
439 void Register() override
440 {
442 }
443};
444
446{
448 {
449 if (Creature* caster = GetCaster()->ToCreature())
450 if (CreatureAI* ai = caster->AI())
451 ai->DoAction(ACTION_SAY_DETONATE_TRAPS);
452 }
453
455 {
456 if (Creature* target = GetHitCreature())
457 if (CreatureAI* ai = target->AI())
458 ai->DoAction(ACTION_INITIATE_COUNTDOWN);
459 }
460
461 void Register() override
462 {
465 }
466};
467
469{
470 bool Validate(SpellInfo const* spellInfo) override
471 {
472 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }) && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_1).BasePoints) });
473 }
474
476 {
477 if (Unit* caster = GetCaster())
478 {
479 Unit* target = GetHitUnit();
480 target->CastStop();
481 target->CastSpell(caster, static_cast<uint32>(GetSpellInfo()->GetEffect(EFFECT_1).BasePoints), true);
482 }
483 }
484
485 void Register() override
486 {
488 }
489};
490
492{
493 bool Validate(SpellInfo const* spellInfo) override
494 {
495 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).BasePoints) });
496 }
497
499 {
500 if (Vehicle* vehicle = GetCaster()->GetVehicleKit())
501 {
502 if (Unit* passenger = vehicle->GetPassenger(SEAT_PLAYER))
503 {
504 if (Creature* intentionsTarget = GetCaster()->FindNearestCreature(NPC_BAD_INTENTIONS_TARGET, 100.0f))
505 passenger->CastSpell(intentionsTarget, static_cast<uint32>(GetSpellInfo()->GetEffect(EFFECT_0).BasePoints), true);
506 else
507 passenger->ExitVehicle(); // Safety case to avoid players getting stuck in Husam's hand
508 }
509 }
510 }
511
512 void Register() override
513 {
515 }
516};
517
519{
521 {
522 if (Unit* caster = GetCaster())
523 if (Creature* creature = caster->ToCreature())
524 if (creature->IsAIEnabled())
525 creature->AI()->DoAction(ACTION_DETONATE);
526 }
527
528 void Register() override
529 {
531 }
532};
533
535{
547}
#define M_PI
Definition: Common.h:115
uint8_t uint8
Definition: Define.h:144
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ TEMPSUMMON_MANUAL_DESPAWN
Definition: ObjectDefines.h:70
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENTRY
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ 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 SpellCastFn(F)
Definition: SpellScript.h:825
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ SEAT_PLAYER
@ ACTION_SAY_DETONATE_TRAPS
@ ACTION_DETONATE
@ ACTION_INITIATE_COUNTDOWN
@ EVENT_HAMMER_FIST
@ EVENT_DETONATE_TRAPS
@ EVENT_READY_MINE
@ EVENT_THROW_PLAYER
@ EVENT_BAD_INTENTIONS
@ EVENT_START_COUNTDOWN
@ EVENT_SHOCKWAVE
@ EVENT_CLEAR_AURAS
@ EVENT_MYSTIC_TRAP
@ SAY_DETONATE_MINES
@ SAY_AGGRO
@ SAY_SHOCKWAVE
@ SAY_SLAY
@ SAY_ANNOUNCE_SHOCKWAVE
void AddSC_boss_general_husam()
@ SPELL_SUMMON_SHOCKWAVE_TARGET_S
@ SPELL_LAND_MINE_PLAYER_SEARCH_EFFECT
@ SPELL_LAND_MINE_PLAYER_SEARCH_TRIGGER
@ SPELL_SHOCKWAVE_VISUAL
@ SPELL_DETONATE_TRAPS
@ SPELL_LAND_MINE_PERIODIC
@ SPELL_HARD_IMPACT
@ SPELL_SHOCKWAVE_SUMMON_EFFECT
@ SPELL_SUMMON_SHOCKWAVE_TARGET_N
@ SPELL_HAMMER_FIST
@ SPELL_SHOCKWAVE_VISUAL_PERIODIC_SUMMON_TRIGGER
@ SPELL_TOLVIR_LAND_MINE_VISUAL
@ SPELL_BAD_INTENTIONS
@ SPELL_SUMMON_SHOCKWAVE_TARGET_W
@ SPELL_THROW_LAND_MINES
@ SPELL_SHOCKWAVE
@ SPELL_THROW_VISUAL
@ SPELL_HURL
@ SPELL_EJECT_ALL_PASSENGERS
@ SPELL_SHOCKWAVE_DAMAGE
@ SPELL_MYSTIC_TRAP_DAMAGE
@ SPELL_SUMMON_SHOCKWAVE_TARGET_E
@ SPELL_MYSTIC_TRAP
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
SpellInfo const * GetSpellInfo() const
Unit * GetCaster() const
AuraEffect * GetEffect(uint8 effIndex) const
Unit * GetTarget() const
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:299
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
Definition: CreatureAI.cpp:464
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 Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void DelayEvents(Milliseconds delay)
Definition: EventMap.cpp:96
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:52
void Reset()
Definition: EventMap.cpp:21
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
Creature * GetCreature(uint32 type)
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
void LaunchMoveSpline(std::function< void(Movement::MoveSplineInit &init)> &&initializer, uint32 id=0, MovementGeneratorPriority priority=MOTION_PRIORITY_NORMAL, MovementGeneratorType type=EFFECT_MOTION_TYPE)
static Creature * ToCreature(Object *o)
Definition: Object.h:219
bool IsPlayer() const
Definition: Object.h:212
uint32 GetEntry() const
Definition: Object.h:161
uint32 const Id
Definition: SpellInfo.h:325
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
Definition: SpellScript.h:173
HookList< CastHandler > AfterCast
Definition: SpellScript.h:824
Creature * GetHitCreature() const
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
SpellInfo const * GetSpellInfo() const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
void Summon(Creature const *summon)
Unit * GetSummonerUnit() const
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
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 EnterVehicle(Unit *base, int8 seatId=-1)
Definition: Unit.cpp:12118
void CastStop(uint32 except_spellid=0)
Definition: Unit.cpp:1135
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
TempSummon * ToTempSummon()
Definition: Unit.h:1756
bool IsSummon() const
Definition: Unit.h:738
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
void RemoveAllAuras()
Definition: Unit.cpp:4242
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
EventProcessor m_Events
Definition: Object.h:777
void HandleScriptEffect(SpellEffIndex)
bool Validate(SpellInfo const *spellInfo) override
void HandleScriptEffect(SpellEffIndex)
bool Validate(SpellInfo const *spellInfo) override
void HandleTick(AuraEffect const *)
void Register() override
bool Validate(SpellInfo const *spellInfo) override
void HandleScriptEffect(SpellEffIndex)
void FilterTargets(std::list< WorldObject * > &targets)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void EffectScriptEffect(SpellEffIndex)
@ NPC_TOLVIR_LAND_MINE_TARGET
@ NPC_TOLVIR_LAND_MINE_CASTER
@ NPC_BAD_INTENTIONS_TARGET
@ NPC_TOLVIR_LAND_MINE_VEHICLE
@ NPC_SHOCKWAVE_STALKER
@ BOSS_GENERAL_HUSAM
#define RegisterLostCityOfTheTolvirAI(ai_name)
void apply(T *val)
Definition: ByteConverter.h:41
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
float m_positionX
Definition: Position.h:53
float m_positionY
Definition: Position.h:54
float GetAbsoluteAngle(float x, float y) const
Definition: Position.h:125
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
constexpr float GetPositionZ() const
Definition: Position.h:78
bool IsHeroic() const
bool IsTimewalking() const
void DoAction(int32 action) override
void EnterEvadeMode(EvadeReason) override
void UpdateAI(uint32 diff) override
void KilledUnit(Unit *victim) override
boss_general_husam(Creature *creature)
void JustDied(Unit *) override
void PassengerBoarded(Unit *, int8, bool apply) override
== Fields =======================================
void JustEngagedWith(Unit *who) override
void JustSummoned(Creature *summon) override
npc_husam_bad_intentions_target(Creature *creature)
void PassengerBoarded(Unit *passenger, int8, bool apply) override
== Fields =======================================
npc_husam_shockwave_visual(Creature *creature)
void DoAction(int32 action) override
void PassengerBoarded(Unit *, int8, bool apply) override
== Fields =======================================
void UpdateAI(uint32 diff) override
npc_husam_tolvir_land_mine(Creature *creature)