Dungeon code cleanup

Consistent code, easier to read logic flow and some missing nullptr checks
This commit is contained in:
Bobblybook
2024-10-20 15:49:10 +11:00
parent a430786133
commit d0a9e98801
16 changed files with 106 additions and 151 deletions

View File

@@ -7,6 +7,8 @@ bool AttackErekemAction::Execute(Event event)
{
// Focus boss first, adds after
Unit* boss = AI_VALUE2(Unit*, "find target", "erekem");
if (!boss) { return false; }
if (AI_VALUE(Unit*, "current target") != boss)
{
return Attack(boss);
@@ -19,6 +21,8 @@ bool AttackIchorGlobuleAction::Execute(Event event)
Unit* boss = AI_VALUE2(Unit*, "find target", "ichoron");
if (!boss) { return false; }
Unit* currentTarget = AI_VALUE(Unit*, "current target");
// Tank prioritise boss if it's up
if (botAI->IsTank(bot) && !boss->HasAura(SPELL_DRAINED))
{
@@ -38,7 +42,6 @@ bool AttackIchorGlobuleAction::Execute(Event event)
Unit* unit = botAI->GetUnit(*i);
if (unit && unit->GetEntry() == NPC_ICHOR_GLOBULE)
{
Unit* currentTarget = AI_VALUE(Unit*, "current target");
// Check IDs here, NOT Unit* pointers:
// Don't keep swapping between sentries.
// If we're already attacking one, don't retarget another
@@ -50,7 +53,7 @@ bool AttackIchorGlobuleAction::Execute(Event event)
}
}
// No ichor globules left alive, fall back to targeting boss
if (AI_VALUE(Unit*, "current target") != boss)
if (currentTarget != boss)
{
return Attack(boss);
}
@@ -62,6 +65,8 @@ bool AttackVoidSentryAction::Execute(Event event)
{
Unit* boss = AI_VALUE2(Unit*, "find target", "zuramat the obliterator");
if (!boss) { return false; }
Unit* currentTarget = AI_VALUE(Unit*, "current target");
// Target is not findable from threat table using AI_VALUE2(),
// therefore need to search manually for the unit name
@@ -73,7 +78,6 @@ bool AttackVoidSentryAction::Execute(Event event)
Unit* unit = botAI->GetUnit(*i);
if (unit && unit->GetEntry() == NPC_VOID_SENTRY)
{
Unit* currentTarget = AI_VALUE(Unit*, "current target");
// Check IDs here, NOT Unit* pointers:
// Don't keep swapping between sentries.
// If we're already attacking one, don't retarget another
@@ -85,7 +89,7 @@ bool AttackVoidSentryAction::Execute(Event event)
}
}
// No void sentries left alive, fall back to targeting boss
if (AI_VALUE(Unit*, "current target") != boss)
if (currentTarget != boss)
{
return Attack(boss);
}

View File

@@ -8,8 +8,6 @@
#include "Playerbots.h"
#include "VioletHoldTriggers.h"
// const Position NOVOS_PARTY_POSITION = Position(-378.852f, -760.349f, 28.587f);
class AttackErekemAction : public AttackAction
{
public:

View File

@@ -6,30 +6,42 @@
bool ErekemTargetTrigger::IsActive()
{
return AI_VALUE2(Unit*, "find target", "erekem") && botAI->IsDps(bot);
Unit* boss = AI_VALUE2(Unit*, "find target", "erekem");
if (!boss) { return false; }
return botAI->IsDps(bot);
}
bool IchoronTargetTrigger::IsActive()
{
return AI_VALUE2(Unit*, "find target", "ichoron") && !botAI->IsHeal(bot);
Unit* boss = AI_VALUE2(Unit*, "find target", "ichoron");
if (!boss) { return false; }
return !botAI->IsHeal(bot);
}
bool VoidShiftTrigger::IsActive()
{
Unit* boss = AI_VALUE2(Unit*, "find target", "zuramat the obliterator");
return boss && bot->HasAura(SPELL_VOID_SHIFTED) && !botAI->IsHeal(bot);
if (!boss) { return false; }
return bot->HasAura(SPELL_VOID_SHIFTED) && !botAI->IsHeal(bot);
}
bool ShroudOfDarknessTrigger::IsActive()
{
Unit* boss = AI_VALUE2(Unit*, "find target", "zuramat the obliterator");
return boss && boss->HasAura(SPELL_SHROUD_OF_DARKNESS);
if (!boss) { return false; }
return boss->HasAura(SPELL_SHROUD_OF_DARKNESS);
}
bool CyanigosaPositioningTrigger::IsActive()
{
Unit* boss = AI_VALUE2(Unit*, "find target", "cyanigosa");
if (!boss) { return false; }
// Include healers here for now, otherwise they stand in things
return boss && !botAI->IsTank(bot) && !botAI->IsRangedDps(bot);
// return boss && botAI->IsMelee(bot) && !botAI->IsTank(bot);
return !botAI->IsTank(bot) && !botAI->IsRangedDps(bot);
// return botAI->IsMelee(bot) && !botAI->IsTank(bot);
}