From 451750eb04ad1252085edc7101c700a2f533b01b Mon Sep 17 00:00:00 2001 From: Exitare Date: Mon, 10 Mar 2025 14:10:43 -0700 Subject: [PATCH] fix(Scripts/Hyjal): Fix hyjal trash (#21194) Co-authored-by: Exitare Co-authored-by: Ludwig --- .../BattleForMountHyjal/instance_hyjal.cpp | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp index 2c6a3d06b..51b66ae14 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp @@ -92,8 +92,9 @@ public: { _bossWave = TO_BE_DECIDED; _retreat = 0; - trash = 0; + _trash = 0; _currentWave = 0; + _initialWaves = false; _encounterNPCs.clear(); _summonedNPCs.clear(); _baseAlliance.clear(); @@ -190,9 +191,9 @@ public: if (creature->IsSummon() && _bossWave != TO_BE_DECIDED) { - if (_currentWave == 0) + if (_currentWave == 0 && _initialWaves) creature->SetReputationRewardDisabled(true); - DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, ++trash); // Update the instance wave count on new trash spawn + DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, ++_trash); // Update the instance wave count on new trash spawn _encounterNPCs.insert(creature->GetGUID()); // Used for despawning on wipe } break; @@ -230,10 +231,10 @@ public: { if (_bossWave != TO_BE_DECIDED) { - DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, --trash); // Update the instance wave count on new trash death + DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, --_trash); // Update the instance wave count on new trash death _encounterNPCs.erase(creature->GetGUID()); // Used for despawning on wipe - if (trash == 0) // It can reach negatives if trash spawned after a retreat are killed, it shouldn't affect anything. Also happens on retail + if (_trash == 0) // It can reach negatives if trash spawned after a retreat are killed, it shouldn't affect anything. Also happens on retail SetData(DATA_SPAWN_WAVES, 1); } } @@ -245,14 +246,12 @@ public: _summonedNPCs.erase(creature->GetGUID()); break; case NPC_WINTERCHILL: + _initialWaves = false; + [[fallthrough]]; case NPC_ANETHERON: case NPC_KAZROGAL: case NPC_AZGALOR: - if (Creature* jaina = GetCreature(DATA_JAINA)) - jaina->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP); - if (Creature* thrall = GetCreature(DATA_THRALL)) - thrall->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP); - SetData(DATA_RESET_WAVES, 1); + ResetWaves(); break; } } @@ -364,6 +363,7 @@ public: _retreat = 0; if (GetBossState(DATA_WINTERCHILL) != DONE) { + _initialWaves = true; if (_bossWave == TO_BE_DECIDED) for (ObjectGuid const& guid : _baseAlliance) if (Creature* creature = instance->GetCreature(guid)) @@ -481,16 +481,19 @@ public: SetData(DATA_RESET_WAVES, 0); break; case DATA_RESET_WAVES: + if (GetBossState(DATA_WINTERCHILL) != DONE) + _initialWaves = true; + scheduler.CancelGroup(CONTEXT_GROUP_WAVES); _encounterNPCs.clear(); _summonedNPCs.clear(); _currentWave = 0; - trash = 0; + _trash = 0; _bossWave = TO_BE_DECIDED; _retreat = 0; DoUpdateWorldState(WORLD_STATE_WAVES, _currentWave); - DoUpdateWorldState(WORLD_STATE_ENEMY, trash); - DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, trash); + DoUpdateWorldState(WORLD_STATE_ENEMY, _trash); + DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, _trash); break; } @@ -517,7 +520,7 @@ public: { // No overlapping! scheduler.CancelGroup(CONTEXT_GROUP_WAVES); - trash = 0; // Reset counter here to avoid resetting the counter from scheduled waves. Required because creatures killed for RP events counts towards the kill counter as well, confirmed in Retail. + _trash = 0; // Reset counter here to avoid resetting the counter from scheduled waves. Required because creatures killed for RP events counts towards the kill counter as well, confirmed in Retail. scheduler.Schedule(1ms, [this, startWaves, maxWaves, timerptr](TaskContext context) { @@ -566,8 +569,8 @@ public: } } - protected: - int32 trash; + private: + int32 _trash; uint8 _currentWave; uint8 _bossWave; uint8 _retreat; @@ -581,6 +584,16 @@ public: GuidSet _ancientGemHorde; GuidSet _roaringFlameAlliance; GuidSet _roaringFlameHorde; + bool _initialWaves; + + void ResetWaves() + { + if (Creature* jaina = GetCreature(DATA_JAINA)) + jaina->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP); + if (Creature* thrall = GetCreature(DATA_THRALL)) + thrall->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP); + SetData(DATA_RESET_WAVES, 1); + } }; };