Skip to content

Commit

Permalink
fix(Scripts/Naxxramas): fixed invalid horseman state on instance init (
Browse files Browse the repository at this point in the history
  • Loading branch information
Razor2142 authored Jan 19, 2025
1 parent 759c912 commit 20ad1c6
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "ScriptedCreature.h"
#include "naxxramas.h"

static constexpr uint8 HorsemanCount = 4;

const float HeiganPos[2] = {2796, -3707};
const float HeiganEruptionSlope[3] =
{
Expand Down Expand Up @@ -94,13 +96,12 @@ class instance_naxxramas : public InstanceMapScript
PatchwerkRoomTrash.clear();

// Controls
_horsemanKilled = 0;
_speakTimer = 0;
_horsemanTimer = 0;
_screamTimer = 2 * MINUTE * IN_MILLISECONDS;
_hadThaddiusGreet = false;
_currentWingTaunt = SAY_FIRST_WING_TAUNT;
_horsemanLoadDoneState = false;
_horsemanLoaded = 0;

// Achievements
abominationsKilled = 0;
Expand Down Expand Up @@ -167,14 +168,13 @@ class instance_naxxramas : public InstanceMapScript
ObjectGuid _lichkingGUID;

// Controls
uint8 _horsemanKilled;
uint32 _speakTimer;
uint32 _horsemanTimer;
uint32 _screamTimer;
bool _hadThaddiusGreet;
EventMap events;
uint8 _currentWingTaunt;
bool _horsemanLoadDoneState;
uint8 _horsemanLoaded;

// Achievements
uint8 abominationsKilled;
Expand Down Expand Up @@ -251,15 +251,19 @@ class instance_naxxramas : public InstanceMapScript
return;
case NPC_LADY_BLAUMEUX:
_blaumeuxGUID = creature->GetGUID();
++_horsemanLoaded;
return;
case NPC_SIR_ZELIEK:
_zeliekGUID = creature->GetGUID();
++_horsemanLoaded;
return;
case NPC_BARON_RIVENDARE:
_rivendareGUID = creature->GetGUID();
++_horsemanLoaded;
return;
case NPC_THANE_KORTHAZZ:
_korthazzGUID = creature->GetGUID();
++_horsemanLoaded;
return;
case NPC_SAPPHIRON:
_sapphironGUID = creature->GetGUID();
Expand All @@ -272,6 +276,9 @@ class instance_naxxramas : public InstanceMapScript
return;
}

if (_horsemanLoaded == HorsemanCount)
SetBossState(BOSS_HORSEMAN, GetBossState(BOSS_HORSEMAN));

InstanceScript::OnCreatureCreate(creature);
}

Expand Down Expand Up @@ -681,13 +688,25 @@ class instance_naxxramas : public InstanceMapScript
}

// Horseman handling
if (bossId == BOSS_HORSEMAN && !_horsemanLoadDoneState)
if (bossId == BOSS_HORSEMAN && _horsemanLoaded == HorsemanCount)
{
uint8 horsemanKilled {};
if (Creature* cr = instance->GetCreature(_blaumeuxGUID))
horsemanKilled += !cr->IsAlive();

if (Creature* cr = instance->GetCreature(_rivendareGUID))
horsemanKilled += !cr->IsAlive();

if (Creature* cr = instance->GetCreature(_zeliekGUID))
horsemanKilled += !cr->IsAlive();

if (Creature* cr = instance->GetCreature(_korthazzGUID))
horsemanKilled += !cr->IsAlive();

if (state == DONE)
{
_horsemanTimer++;
_horsemanKilled++;
if (_horsemanKilled < 4)
if (horsemanKilled < HorsemanCount)
{
return false;
}
Expand All @@ -699,10 +718,9 @@ class instance_naxxramas : public InstanceMapScript
}

// respawn
else if (state == NOT_STARTED && _horsemanKilled > 0)
else if (state == NOT_STARTED && horsemanKilled > 0)
{
Creature* cr;
_horsemanKilled = 0;
if ((cr = instance->GetCreature(_blaumeuxGUID)))
{
if (!cr->IsAlive())
Expand Down

0 comments on commit 20ad1c6

Please sign in to comment.