fix(Core): Crashfix. (#11490)

* fix(Core): Crashfix.

* Update.
This commit is contained in:
UltraNix
2022-04-23 16:32:09 +02:00
committed by GitHub
parent d0a4df2869
commit 385176f434
4 changed files with 87 additions and 51 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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();
}
}
}
}

View File

@@ -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();
}
}
}
}