From ca95a986ba0c6cbc250e78b590a169b8ac98747a Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:36:04 -0300 Subject: [PATCH] fix(Scripts/BlackwingLair): Improve Nefarian's add animations (#11414) --- .../BlackwingLair/boss_nefarian.cpp | 40 ++++++++++++++++++- .../BlackwingLair/instance_blackwing_lair.cpp | 37 +++++------------ 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp index c908c4456..7bf5d1e48 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp @@ -931,13 +931,15 @@ struct npc_drakonid_spawner : public ScriptedAI } } - void IsSummonedBy(Unit* /*summoner*/) override + void IsSummonedBy(Unit* summoner) override { DoCastSelf(SPELL_SPAWN_DRAKONID_GEN); _scheduler.Schedule(10s, 60s, [this](TaskContext /*context*/) { DoCastSelf(SPELL_SPAWN_CHROMATIC_DRAKONID); }); + + _owner = summoner->GetGUID(); } void UpdateAI(uint32 diff) override @@ -945,8 +947,44 @@ struct npc_drakonid_spawner : public ScriptedAI _scheduler.Update(diff); } + void SummonedCreatureDies(Creature* summon, Unit* /*unit*/) override + { + if (summon->GetEntry() != NPC_BONE_CONSTRUCT) + { + if (Creature* victor = ObjectAccessor::GetCreature(*me, _owner)) + { + victor->AI()->DoAction(ACTION_NEFARIUS_ADD_KILLED); + } + + ObjectGuid summonGuid = summon->GetGUID(); + + summon->SetCorpseDelay(DAY * IN_MILLISECONDS); + summon->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); + summon->SetHomePosition(summon->GetPosition()); + + _scheduler.Schedule(1s, [this, summonGuid](TaskContext /*context*/) + { + if (Creature* construct = ObjectAccessor::GetCreature(*me, summonGuid)) + { + construct->SetVisible(false); + } + }).Schedule(2s, [this, summonGuid](TaskContext /*context*/) + { + if (Creature* construct = ObjectAccessor::GetCreature(*me, summonGuid)) + { + construct->UpdateEntry(NPC_BONE_CONSTRUCT); + construct->SetReactState(REACT_PASSIVE); + construct->SetStandState(UNIT_STAND_STATE_DEAD); + construct->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); + construct->SetVisible(true); + } + }); + } + } + protected: TaskScheduler _scheduler; + ObjectGuid _owner; }; std::unordered_map const classCallSpells = diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp index d6fa9715f..75e0210cc 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp @@ -91,6 +91,12 @@ public: void OnCreatureCreate(Creature* creature) override { + // This is required because the tempspawn at Vael overwrites his GUID. + if (creature->GetEntry() == NPC_VICTOR_NEFARIUS && creature->ToTempSummon()) + { + return; + } + InstanceScript::OnCreatureCreate(creature); switch (creature->GetEntry()) @@ -275,14 +281,13 @@ public: case DATA_NEFARIAN: switch (state) { + case FAIL: + _events.ScheduleEvent(EVENT_RESPAWN_NEFARIUS, 15 * 60 * IN_MILLISECONDS); //15min + [[fallthrough]]; case NOT_STARTED: if (Creature* nefarian = instance->GetCreature(nefarianGUID)) nefarian->DespawnOrUnsummon(); break; - case FAIL: - _events.ScheduleEvent(EVENT_RESPAWN_NEFARIUS, 15 * 60 * IN_MILLISECONDS); //15min - SetBossState(DATA_NEFARIAN, NOT_STARTED); - break; default: break; } @@ -378,30 +383,6 @@ public: { switch (unit->GetEntry()) { - case NPC_BLACK_DRAKONID: - case NPC_BLUE_DRAKONID: - case NPC_BRONZE_DRAKONID: - case NPC_CHROMATIC_DRAKONID: - case NPC_GREEN_DRAKONID: - case NPC_RED_DRAKONID: - if (Creature* summon = unit->ToTempSummon()) - { - summon->SetCorpseDelay(DAY * IN_MILLISECONDS); - summon->UpdateEntry(NPC_BONE_CONSTRUCT); - summon->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - summon->SetReactState(REACT_PASSIVE); - summon->SetStandState(UNIT_STAND_STATE_DEAD); - summon->SetHomePosition(summon->GetPosition()); - - if (Creature* nefarius = GetCreature(DATA_LORD_VICTOR_NEFARIUS)) - { - if (nefarius->AI()) - { - nefarius->AI()->DoAction(ACTION_NEFARIUS_ADD_KILLED); - } - } - } - break; case NPC_BLACKWING_DRAGON: --addsCount[0]; if (EggEvent != DONE && _events.GetTimeUntilEvent(EVENT_RAZOR_SPAWN) == Milliseconds::max())