From 348b3744876f42a98f26b8f0a27c4c2ed98fc3da Mon Sep 17 00:00:00 2001
From: UltraNix <80540499+UltraNix@users.noreply.github.com>
Date: Thu, 10 Mar 2022 13:56:02 +0100
Subject: [PATCH] fix(Scripts/AlteracValley): Mini bosses should evade with
boss (#10544)
Fixed #10460
---
.../game/Battlegrounds/Zones/BattlegroundAV.h | 5 +-
.../AlteracValley/alterac_valley.cpp | 46 +++++++++++++++++
.../AlteracValley/boss_drekthar.cpp | 49 ++++++++++++++++++-
.../AlteracValley/boss_vanndar.cpp | 49 ++++++++++++++++++-
4 files changed, 146 insertions(+), 3 deletions(-)
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
index b04cc83011ca0..faef4717528bb 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
@@ -662,7 +662,10 @@ enum BG_AV_CreaturePlace
AV_CPLACE_TRIGGER18 = 319,
AV_CPLACE_TRIGGER19 = 320,
- AV_CPLACE_MAX = 321
+ AV_CPLACE_MAX = 321,
+
+ AV_CPLACE_A_BOSS = 381,
+ AV_CPLACE_H_BOSS = 445
};
//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 ee428aeab99a3..566467618ac1e 100644
--- a/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp
+++ b/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp
@@ -15,6 +15,7 @@
* with this program. If not, see .
*/
+#include "BattlegroundAV.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
@@ -58,6 +59,11 @@ enum Events
EVENT_CHECK_RESET = 6
};
+enum Factions
+{
+ FACTION_AV_ALLIANCE = 1534
+};
+
struct SpellPair
{
uint32 npcEntry;
@@ -104,6 +110,46 @@ class npc_av_marshal_or_warmaster : public CreatureScript
Reset();
}
+ void AttackStart(Unit* victim) override
+ {
+ ScriptedAI::AttackStart(victim);
+
+ // Boss should attack as well
+ if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap())
+ {
+ if (Battleground* bg = bgMap->GetBG())
+ {
+ if (Creature* mainBoss = bg->GetBGCreature((me->GetFaction() == FACTION_AV_ALLIANCE ? AV_CPLACE_A_BOSS : AV_CPLACE_H_BOSS)))
+ {
+ if (mainBoss->IsAIEnabled && !mainBoss->IsInCombat())
+ {
+ mainBoss->AI()->AttackStart(victim);
+ }
+ }
+ }
+ }
+ }
+
+ void EnterEvadeMode() override
+ {
+ ScriptedAI::EnterEvadeMode();
+
+ // Evade boss
+ if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap())
+ {
+ if (Battleground* bg = bgMap->GetBG())
+ {
+ if (Creature* mainBoss = bg->GetBGCreature((me->GetFaction() == FACTION_AV_ALLIANCE ? AV_CPLACE_A_BOSS : AV_CPLACE_H_BOSS)))
+ {
+ if (mainBoss->IsAIEnabled && !mainBoss->IsInEvadeMode())
+ {
+ mainBoss->AI()->EnterEvadeMode();
+ }
+ }
+ }
+ }
+ }
+
void UpdateAI(uint32 diff) override
{
// I have a feeling this isn't blizzlike, but owell, I'm only passing by and cleaning up.
diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp
index f9a1019a391ad..2ca4a38d3a314 100644
--- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp
+++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp
@@ -15,6 +15,7 @@
* with this program. If not, see .
*/
+#include "BattlegroundAV.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
@@ -64,7 +65,7 @@ class boss_drekthar : public CreatureScript
YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); //20 to 30 seconds
}
- void EnterCombat(Unit* /*who*/) override
+ void EnterCombat(Unit* /*victim*/) override
{
Talk(YELL_AGGRO);
}
@@ -75,6 +76,52 @@ class boss_drekthar : public CreatureScript
Talk(YELL_RESPAWN);
}
+ void AttackStart(Unit* victim) override
+ {
+ ScriptedAI::AttackStart(victim);
+
+ // Mini bosses should attack as well
+ if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap())
+ {
+ if (Battleground* bg = bgMap->GetBG())
+ {
+ for (uint8 i = AV_CPLACE_H_MARSHAL_ICE; i <= AV_CPLACE_H_MARSHAL_WTOWER; ++i)
+ {
+ if (Creature* marshall = bg->GetBGCreature(i))
+ {
+ if (marshall->IsAIEnabled && !marshall->IsInCombat())
+ {
+ marshall->AI()->AttackStart(victim);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ void EnterEvadeMode() override
+ {
+ ScriptedAI::EnterEvadeMode();
+
+ // Evade mini bosses
+ if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap())
+ {
+ if (Battleground* bg = bgMap->GetBG())
+ {
+ for (uint8 i = AV_CPLACE_H_MARSHAL_ICE; i <= AV_CPLACE_H_MARSHAL_WTOWER; ++i)
+ {
+ if (Creature* marshall = bg->GetBGCreature(i))
+ {
+ if (marshall->IsAIEnabled && !marshall->IsInEvadeMode())
+ {
+ marshall->AI()->EnterEvadeMode();
+ }
+ }
+ }
+ }
+ }
+ }
+
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp
index f28d7d20259b8..eb1f0a435217b 100644
--- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp
+++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp
@@ -15,6 +15,7 @@
* with this program. If not, see .
*/
+#include "BattlegroundAV.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
@@ -59,11 +60,57 @@ class boss_vanndar : public CreatureScript
YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS);
}
- void EnterCombat(Unit* /*who*/) override
+ void EnterCombat(Unit* /*victim*/) override
{
Talk(YELL_AGGRO);
}
+ void AttackStart(Unit* victim) override
+ {
+ ScriptedAI::AttackStart(victim);
+
+ // Mini bosses should attack as well
+ if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap())
+ {
+ if (Battleground* bg = bgMap->GetBG())
+ {
+ for (uint8 i = AV_CPLACE_A_MARSHAL_SOUTH; i <= AV_CPLACE_A_MARSHAL_STONE; ++i)
+ {
+ if (Creature* marshall = bg->GetBGCreature(i))
+ {
+ if (marshall->IsAIEnabled && !marshall->IsInCombat())
+ {
+ marshall->AI()->AttackStart(victim);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ void EnterEvadeMode() override
+ {
+ ScriptedAI::EnterEvadeMode();
+
+ // Evade mini bosses
+ if (BattlegroundMap* bgMap = me->GetMap()->ToBattlegroundMap())
+ {
+ if (Battleground* bg = bgMap->GetBG())
+ {
+ for (uint8 i = AV_CPLACE_A_MARSHAL_SOUTH; i <= AV_CPLACE_A_MARSHAL_STONE; ++i)
+ {
+ if (Creature* marshall = bg->GetBGCreature(i))
+ {
+ if (marshall->IsAIEnabled && !marshall->IsInEvadeMode())
+ {
+ marshall->AI()->EnterEvadeMode();
+ }
+ }
+ }
+ }
+ }
+ }
+
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())