TrinityCore
Loading...
Searching...
No Matches
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
66
82
84{
85 // General Husam
87
88 // Tol'vir Land Mine
91};
92
103
105{
106 SEAT_PLAYER = 0
108
110{
112
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
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.
300 if (me->GetEntry() == NPC_TOLVIR_LAND_MINE_VEHICLE && !apply)
302 }
303
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
406};
407
409{
410 bool Validate(SpellInfo const* /*spellInfo*/) override
411 {
413 }
414
419
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
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
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
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
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
532};
533
#define M_PI
Definition Common.h:118
uint8_t uint8
Definition Define.h:156
int8_t int8
Definition Define.h:152
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ TEMPSUMMON_MANUAL_DESPAWN
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ TARGET_UNIT_SRC_AREA_ENTRY
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ SPELLVALUE_MAX_TARGETS
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellCastFn(F)
EvadeReason
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ 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_SHOCKWAVE
@ 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_EJECT_ALL_PASSENGERS
@ SPELL_SHOCKWAVE_DAMAGE
@ SPELL_MYSTIC_TRAP_DAMAGE
@ SPELL_SUMMON_SHOCKWAVE_TARGET_E
@ SPELL_MYSTIC_TRAP
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
SpellInfo const * GetSpellInfo() const
Unit * GetCaster() const
AuraEffect * GetEffect(uint8 effIndex) const
Unit * GetTarget() const
bool IsPlayer() const
Definition BaseEntity.h:173
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
void SetReactState(ReactStates st)
Definition Creature.h:174
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void DelayEvents(Milliseconds delay)
Definition EventMap.cpp:100
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:56
void Reset()
Definition EventMap.cpp:25
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, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 GetEntry() const
Definition Object.h:89
Creature * ToCreature()
Definition Object.h:121
uint32 const Id
Definition SpellInfo.h:328
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:588
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
HookList< CastHandler > AfterCast
Creature * GetHitCreature() const
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
SpellInfo const * GetSpellInfo() const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void Summon(Creature const *summon)
Unit * GetSummonerUnit() const
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
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 EnterVehicle(Unit *base, int8 seatId=-1)
Definition Unit.cpp:12749
void CastStop(uint32 except_spellid=0)
Definition Unit.cpp:1186
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
TempSummon * ToTempSummon()
Definition Unit.h:1828
bool IsSummon() const
Definition Unit.h:749
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void RemoveAllAuras()
Definition Unit.cpp:4382
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
EventProcessor m_Events
Definition Object.h:561
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)
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
float m_positionX
Definition Position.h:64
float m_positionY
Definition Position.h:65
float GetAbsoluteAngle(float x, float y) const
Definition Position.h:136
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
constexpr float GetPositionZ() const
Definition Position.h:89
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)