From 385176f434fe366cc4bc3520af86107d538327c8 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Sat, 23 Apr 2022 16:32:09 +0200 Subject: [PATCH] fix(Core): Crashfix. (#11490) * fix(Core): Crashfix. * Update. --- .../game/Battlegrounds/Zones/BattlegroundAV.h | 2 +- .../AlteracValley/alterac_valley.cpp | 36 ++++++++----- .../AlteracValley/boss_drekthar.cpp | 52 ++++++++++++------- .../AlteracValley/boss_vanndar.cpp | 48 ++++++++++------- 4 files changed, 87 insertions(+), 51 deletions(-) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index 95b3e146a..3768004fe 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -661,7 +661,7 @@ enum BG_AV_CreaturePlace AV_CPLACE_MAX = 321, AV_CPLACE_A_BOSS = 381, - AV_CPLACE_H_BOSS = 445 + AV_CPLACE_H_BOSS = 443 }; //x, y, z, o diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp index 6da704604..7ec5c28e7 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp @@ -103,6 +103,7 @@ public: events.ScheduleEvent(EVENT_CHECK_RESET, 5000); _hasAura = false; + _attacked = false; } void JustRespawned() override @@ -114,16 +115,21 @@ public: { ScriptedAI::AttackStart(victim); - // Boss should attack as well - if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) + if (!_attacked) { - if (Battleground* bg = bgMap->GetBG()) + _attacked = true; + + // Boss should attack as well + if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) { - if (Creature* mainBoss = bg->GetBGCreature((me->GetFaction() == FACTION_AV_ALLIANCE ? AV_CPLACE_A_BOSS : AV_CPLACE_H_BOSS))) + if (Battleground* bg = bgMap->GetBG()) { - if (mainBoss->IsAIEnabled && !mainBoss->GetVictim()) + if (Creature* mainBoss = bg->GetBGCreature((me->GetFaction() == FACTION_AV_ALLIANCE ? AV_CPLACE_A_BOSS : AV_CPLACE_H_BOSS))) { - mainBoss->AI()->AttackStart(victim); + if (mainBoss->IsAIEnabled && !mainBoss->GetVictim()) + { + mainBoss->AI()->AttackStart(victim); + } } } } @@ -134,16 +140,21 @@ public: { ScriptedAI::EnterEvadeMode(why); - // Evade boss - if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) + if (_attacked) { - if (Battleground* bg = bgMap->GetBG()) + _attacked = false; + + // Evade boss + if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) { - if (Creature* mainBoss = bg->GetBGCreature((me->GetFaction() == FACTION_AV_ALLIANCE ? AV_CPLACE_A_BOSS : AV_CPLACE_H_BOSS))) + if (Battleground* bg = bgMap->GetBG()) { - if (mainBoss->IsAIEnabled && !mainBoss->IsInEvadeMode()) + if (Creature* mainBoss = bg->GetBGCreature((me->GetFaction() == FACTION_AV_ALLIANCE ? AV_CPLACE_A_BOSS : AV_CPLACE_H_BOSS))) { - mainBoss->AI()->EnterEvadeMode(); + if (mainBoss->IsAIEnabled && !mainBoss->IsInEvadeMode()) + { + mainBoss->AI()->EnterEvadeMode(); + } } } } @@ -214,6 +225,7 @@ public: private: EventMap events; bool _hasAura; + bool _attacked; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp index 3dc5e9b35..45e5277e8 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp @@ -54,15 +54,17 @@ public: uint32 FrenzyTimer; uint32 YellTimer; uint32 ResetTimer; + bool Attacked; void Reset() override { - WhirlwindTimer = urand(1 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); - Whirlwind2Timer = urand(1 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); - KnockdownTimer = 12 * IN_MILLISECONDS; - FrenzyTimer = 6 * IN_MILLISECONDS; - ResetTimer = 5 * IN_MILLISECONDS; - YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); //20 to 30 seconds + WhirlwindTimer = urand(1 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + Whirlwind2Timer = urand(1 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + KnockdownTimer = 12 * IN_MILLISECONDS; + FrenzyTimer = 6 * IN_MILLISECONDS; + ResetTimer = 5 * IN_MILLISECONDS; + YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); //20 to 30 seconds + Attacked = false; } void EnterCombat(Unit* /*who*/) override @@ -80,18 +82,23 @@ public: { ScriptedAI::AttackStart(victim); - // Mini bosses should attack as well - if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) + if (!Attacked) { - if (Battleground* bg = bgMap->GetBG()) + Attacked = true; + + // Mini bosses should attack as well + if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) { - for (uint8 i = AV_CPLACE_H_MARSHAL_ICE; i <= AV_CPLACE_H_MARSHAL_WTOWER; ++i) + if (Battleground* bg = bgMap->GetBG()) { - if (Creature* marshall = bg->GetBGCreature(i)) + for (uint8 i = AV_CPLACE_H_MARSHAL_ICE; i <= AV_CPLACE_H_MARSHAL_WTOWER; ++i) { - if (marshall->IsAIEnabled && !marshall->GetVictim()) + if (Creature* marshall = bg->GetBGCreature(i)) { - marshall->AI()->AttackStart(victim); + if (marshall->IsAIEnabled && !marshall->GetVictim()) + { + marshall->AI()->AttackStart(victim); + } } } } @@ -103,18 +110,23 @@ public: { ScriptedAI::EnterEvadeMode(why); - // Evade mini bosses - if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) + if (Attacked) { - if (Battleground* bg = bgMap->GetBG()) + Attacked = false; + + // Evade mini bosses + if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) { - for (uint8 i = AV_CPLACE_H_MARSHAL_ICE; i <= AV_CPLACE_H_MARSHAL_WTOWER; ++i) + if (Battleground* bg = bgMap->GetBG()) { - if (Creature* marshall = bg->GetBGCreature(i)) + for (uint8 i = AV_CPLACE_H_MARSHAL_ICE; i <= AV_CPLACE_H_MARSHAL_WTOWER; ++i) { - if (marshall->IsAIEnabled && !marshall->IsInEvadeMode()) + if (Creature* marshall = bg->GetBGCreature(i)) { - marshall->AI()->EnterEvadeMode(); + if (marshall->IsAIEnabled && !marshall->IsInEvadeMode()) + { + marshall->AI()->EnterEvadeMode(); + } } } } diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp index 432241351..4712b7574 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp @@ -50,14 +50,16 @@ public: uint32 StormboltTimer; uint32 ResetTimer; uint32 YellTimer; + bool Attacked; void Reset() override { - AvatarTimer = 3 * IN_MILLISECONDS; - ThunderclapTimer = 4 * IN_MILLISECONDS; - StormboltTimer = 6 * IN_MILLISECONDS; - ResetTimer = 5 * IN_MILLISECONDS; + AvatarTimer = 3 * IN_MILLISECONDS; + ThunderclapTimer = 4 * IN_MILLISECONDS; + StormboltTimer = 6 * IN_MILLISECONDS; + ResetTimer = 5 * IN_MILLISECONDS; YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); + Attacked = false; } void EnterCombat(Unit* /*who*/) override @@ -69,18 +71,23 @@ public: { ScriptedAI::AttackStart(victim); - // Mini bosses should attack as well - if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) + if (!Attacked) { - if (Battleground* bg = bgMap->GetBG()) + Attacked = true; + + // Mini bosses should attack as well + if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) { - for (uint8 i = AV_CPLACE_A_MARSHAL_SOUTH; i <= AV_CPLACE_A_MARSHAL_STONE; ++i) + if (Battleground* bg = bgMap->GetBG()) { - if (Creature* marshall = bg->GetBGCreature(i)) + for (uint8 i = AV_CPLACE_A_MARSHAL_SOUTH; i <= AV_CPLACE_A_MARSHAL_STONE; ++i) { - if (marshall->IsAIEnabled && !marshall->GetVictim()) + if (Creature* marshall = bg->GetBGCreature(i)) { - marshall->AI()->AttackStart(victim); + if (marshall->IsAIEnabled && !marshall->GetVictim()) + { + marshall->AI()->AttackStart(victim); + } } } } @@ -92,18 +99,23 @@ public: { ScriptedAI::EnterEvadeMode(why); - // Evade mini bosses - if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) + if (Attacked) { - if (Battleground* bg = bgMap->GetBG()) + Attacked = false; + + // Evade mini bosses + if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap()) { - for (uint8 i = AV_CPLACE_A_MARSHAL_SOUTH; i <= AV_CPLACE_A_MARSHAL_STONE; ++i) + if (Battleground* bg = bgMap->GetBG()) { - if (Creature* marshall = bg->GetBGCreature(i)) + for (uint8 i = AV_CPLACE_A_MARSHAL_SOUTH; i <= AV_CPLACE_A_MARSHAL_STONE; ++i) { - if (marshall->IsAIEnabled && !marshall->IsInEvadeMode()) + if (Creature* marshall = bg->GetBGCreature(i)) { - marshall->AI()->EnterEvadeMode(); + if (marshall->IsAIEnabled && !marshall->IsInEvadeMode()) + { + marshall->AI()->EnterEvadeMode(); + } } } }