Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts/BlackwingLair: fix Nefarian Stage 3 (Bone Construct respawn) #29929

Open
wants to merge 3 commits into
base: 3.3.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ enum BWLGameObjectIds
GO_CHROMAGGUS_LEVER = 179148,
GO_CHROMAGGUS_DOOR = 179116,
GO_PORTCULLIS_NEFARIAN = 176966,
GO_SUPPRESSION_DEVICE = 179784
GO_SUPPRESSION_DEVICE = 179784,
GO_DRAKONID_BONES = 179804
};

enum BWLEvents
Expand All @@ -86,7 +87,10 @@ enum BWLMisc
{
// Razorgore Egg Event
ACTION_PHASE_TWO = 1,
DATA_EGG_EVENT
DATA_EGG_EVENT,

// Nefarian Drakonid Respawn
DATA_DRAKONID_BONES
};

template <class AI, class T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "TemporarySummon.h"
#include "ObjectAccessor.h"

enum Events
{
Expand Down Expand Up @@ -217,12 +218,24 @@ struct boss_victor_nefarius : public BossAI

void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override
{
if (summon->GetEntry() != NPC_NEFARIAN)
if ((summon->GetEntry() != NPC_NEFARIAN) && (summon->GetEntry() != NPC_BONE_CONSTRUCT))
{
summon->UpdateEntry(NPC_BONE_CONSTRUCT);
summon->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
summon->SetReactState(REACT_PASSIVE);
summon->SetStandState(UNIT_STAND_STATE_DEAD);
ObjectGuid summonGUID = summon->GetGUID();
summon->SetHomePosition(summon->GetPosition());
scheduler.Schedule(1500ms, [this, summonGUID](TaskContext /*context*/)
{
if (Creature* creature = ObjectAccessor::GetCreature(*me, summonGUID))
{
SummonDrakonidBones(creature);
creature->SetOriginalEntry(NPC_BONE_CONSTRUCT);
creature->UpdateEntry(NPC_BONE_CONSTRUCT);
creature->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
creature->SetReactState(REACT_PASSIVE);
creature->SetStandState(UNIT_STAND_STATE_DEAD);
creature->SetRespawnCompatibilityMode();
creature->SetVisible(false);
}
});
}
}

Expand Down Expand Up @@ -296,6 +309,7 @@ struct boss_victor_nefarius : public BossAI
if (UpdateVictim() && SpawnedAdds <= 42)
{
events.Update(diff);
scheduler.Update(diff);

if (me->HasUnitState(UNIT_STATE_CASTING))
return;
Expand Down Expand Up @@ -381,6 +395,14 @@ struct boss_victor_nefarius : public BossAI
return false;
}

void SummonDrakonidBones(Creature* creature)
{
float o = creature->GetOrientation();
o += float(M_PI);
QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.0f, 0.0f);
creature->SummonGameObject(GO_DRAKONID_BONES, creature->GetPosition(), rot, 0s, GOSummonType(GO_SUMMON_TIMED_OR_CORPSE_DESPAWN));
}

private:
uint32 SpawnedAdds;
};
Expand Down Expand Up @@ -447,6 +469,30 @@ struct boss_nefarian : public BossAI
}
}

void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
{
// Phase3 begins when health below 20 pct
if (!Phase3 && me->HealthBelowPctDamaged(20, damage))
{
instance->SetData(DATA_DRAKONID_BONES, SPECIAL); //Despawn Drakonids Bones
std::list<Creature*> constructList;
me->GetCreatureListWithEntryInGrid(constructList, NPC_BONE_CONSTRUCT, 500.0f);
for (Creature* const& summon : constructList)
if (summon && !summon->IsAlive())
{
summon->SetVisible(true);
summon->RemoveAllGameObjects();
summon->Respawn();
summon->RemoveUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
summon->SetReactState(REACT_AGGRESSIVE);
summon->SetStandState(UNIT_STAND_STATE_STAND);
DoZoneInCombat(summon);
}
Phase3 = true;
Talk(SAY_RAISE_SKELETONS);
}
}

void UpdateAI(uint32 diff) override
{
if (canDespawn && DespawnTimer <= diff)
Expand Down Expand Up @@ -550,26 +596,6 @@ struct boss_nefarian : public BossAI
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}

// Phase3 begins when health below 20 pct
if (!Phase3 && HealthBelowPct(20))
{
std::list<Creature*> constructList;
me->GetCreatureListWithEntryInGrid(constructList, NPC_BONE_CONSTRUCT, 500.0f);
for (std::list<Creature*>::const_iterator itr = constructList.begin(); itr != constructList.end(); ++itr)
if ((*itr) && !(*itr)->IsAlive())
{
(*itr)->Respawn();
DoZoneInCombat((*itr));
(*itr)->RemoveUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
(*itr)->SetReactState(REACT_AGGRESSIVE);
(*itr)->SetStandState(UNIT_STAND_STATE_STAND);
}

Phase3 = true;
Talk(SAY_RAISE_SKELETONS);
}

DoMeleeAttackIfReady();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class instance_blackwing_lair : public InstanceMapScript
else
EggList.push_back(go->GetGUID());
break;
case GO_DRAKONID_BONES:
DrakonidBonesGUIDs.emplace_back(go->GetGUID());
break;
default:
break;
}
Expand Down Expand Up @@ -233,6 +236,17 @@ class instance_blackwing_lair : public InstanceMapScript
break;
}
}

if (type == DATA_DRAKONID_BONES)
{
if (data == SPECIAL)
{
for (ObjectGuid& guid : DrakonidBonesGUIDs)
if (GameObject* go = instance->GetGameObject(guid))
go->DespawnOrUnsummon();
DrakonidBonesGUIDs.clear();
}
}
}

void OnUnitDeath(Unit* unit) override
Expand Down Expand Up @@ -286,6 +300,9 @@ class instance_blackwing_lair : public InstanceMapScript
uint8 EggCount;
uint32 EggEvent;
GuidList EggList;

// Nefarian
GuidVector DrakonidBonesGUIDs;
};

InstanceScript* GetInstanceScript(InstanceMap* map) const override
Expand Down