Moved yells to database

This commit is contained in:
crow
2025-09-27 23:03:15 -05:00
parent bdfd45c9a0
commit 59555b2248
4 changed files with 179 additions and 114 deletions

View File

@@ -0,0 +1,29 @@
DELETE FROM ai_playerbot_texts WHERE name IN (
'netherspite_beam_blocking_red',
'netherspite_beam_blocking_blue',
'netherspite_beam_blocking_green',
'netherspite_beam_leaving_blue',
'netherspite_beam_leaving_green'
);
DELETE FROM ai_playerbot_texts_chance WHERE name IN (
'netherspite_beam_blocking_red',
'netherspite_beam_blocking_blue',
'netherspite_beam_blocking_green',
'netherspite_beam_leaving_blue',
'netherspite_beam_leaving_green'
);
INSERT INTO ai_playerbot_texts (name, text, say_type, reply_type, text_loc1, text_loc2, text_loc3, text_loc4, text_loc5, text_loc6, text_loc7, text_loc8) VALUES
('netherspite_beam_blocking_red', '%player is moving to block the red beam!', 0, 0, '', '', '', '', '', '', '', ''),
('netherspite_beam_blocking_blue', '%player is moving to block the blue beam!', 0, 0, '', '', '', '', '', '', '', ''),
('netherspite_beam_blocking_green', '%player is moving to block the green beam!', 0, 0, '', '', '', '', '', '', '', ''),
('netherspite_beam_leaving_blue', '%player is leaving the blue beam--next blocker up!', 0, 0, '', '', '', '', '', '', '', ''),
('netherspite_beam_leaving_green', '%player is leaving the green beam--next blocker up!', 0, 0, '', '', '', '', '', '', '', '');
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES
('netherspite_beam_blocking_red', 100),
('netherspite_beam_blocking_blue', 100),
('netherspite_beam_blocking_green', 100),
('netherspite_beam_leaving_blue', 100),
('netherspite_beam_leaving_green', 100);

View File

@@ -101,6 +101,7 @@ bool KarazhanMaidenOfVirtuePositionBossAction::Execute(Event event)
bot->GetPositionZ(), false, false, false, false, MovementPriority::MOVEMENT_COMBAT, true, false); bot->GetPositionZ(), false, false, false, false, MovementPriority::MOVEMENT_COMBAT, true, false);
} }
} }
return false; return false;
} }
@@ -146,6 +147,7 @@ bool KarazhanMaidenOfVirtuePositionRangedAction::Execute(Event event)
KARAZHAN_MAIDEN_OF_VIRTUE_RANGED_POSITION[index].GetPositionY(), bot->GetPositionZ(), false, KARAZHAN_MAIDEN_OF_VIRTUE_RANGED_POSITION[index].GetPositionY(), bot->GetPositionZ(), false,
false, false, false, MovementPriority::MOVEMENT_COMBAT, true, false); false, false, false, MovementPriority::MOVEMENT_COMBAT, true, false);
} }
return false; return false;
} }
@@ -176,9 +178,11 @@ bool KarazhanBigBadWolfPositionBossAction::Execute(Event event)
{ {
return false; return false;
} }
return MoveTo(bot->GetMapId(), mX, mY, bot->GetPositionZ(), false, false, false, false, return MoveTo(bot->GetMapId(), mX, mY, bot->GetPositionZ(), false, false, false, false,
MovementPriority::MOVEMENT_COMBAT, true, false); MovementPriority::MOVEMENT_COMBAT, true, false);
} }
return false; return false;
} }
@@ -193,7 +197,6 @@ bool KarazhanBigBadWolfPositionBossAction::isUseful()
bool KarazhanBigBadWolfRunAwayAction::Execute(Event event) bool KarazhanBigBadWolfRunAwayAction::Execute(Event event)
{ {
constexpr float threshold = 1.0f; constexpr float threshold = 1.0f;
Position target = KARAZHAN_BIG_BAD_WOLF_RUN_POSITION[currentIndex]; Position target = KARAZHAN_BIG_BAD_WOLF_RUN_POSITION[currentIndex];
while (bot->GetExactDist2d(target.GetPositionX(), target.GetPositionY()) < threshold) while (bot->GetExactDist2d(target.GetPositionX(), target.GetPositionY()) < threshold)
@@ -201,6 +204,7 @@ bool KarazhanBigBadWolfRunAwayAction::Execute(Event event)
currentIndex = (currentIndex + 1) % 4; currentIndex = (currentIndex + 1) % 4;
target = KARAZHAN_BIG_BAD_WOLF_RUN_POSITION[currentIndex]; target = KARAZHAN_BIG_BAD_WOLF_RUN_POSITION[currentIndex];
} }
return MoveTo(bot->GetMapId(), target.GetPositionX(), target.GetPositionY(), target.GetPositionZ(), return MoveTo(bot->GetMapId(), target.GetPositionX(), target.GetPositionY(), target.GetPositionZ(),
false, false, false, true, MovementPriority::MOVEMENT_FORCED); false, false, false, true, MovementPriority::MOVEMENT_FORCED);
} }
@@ -257,13 +261,8 @@ bool KarazhanWizardOfOzMarkTargetAction::Execute(Event event)
bool KarazhanWizardOfOzScorchStrawmanAction::Execute(Event event) bool KarazhanWizardOfOzScorchStrawmanAction::Execute(Event event)
{ {
Unit* strawman = AI_VALUE2(Unit*, "find target", "strawman"); Unit* strawman = AI_VALUE2(Unit*, "find target", "strawman");
if (!strawman || !strawman->IsAlive())
{
return false;
}
Group* group = bot->GetGroup(); Group* group = bot->GetGroup();
if (!group) if (!strawman || !strawman->IsAlive() || !group)
{ {
return false; return false;
} }
@@ -271,18 +270,9 @@ bool KarazhanWizardOfOzScorchStrawmanAction::Execute(Event event)
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next()) for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{ {
Player* member = itr->GetSource(); Player* member = itr->GetSource();
if (!member || !member->IsAlive())
{
continue;
}
if (member->getClass() != CLASS_MAGE)
{
continue;
}
PlayerbotAI* mageAI = sPlayerbotsMgr->GetPlayerbotAI(member); PlayerbotAI* mageAI = sPlayerbotsMgr->GetPlayerbotAI(member);
if (!mageAI) if (!member || !member->IsAlive() || member->getClass() != CLASS_MAGE || !mageAI)
{ {
continue; continue;
} }
if (mageAI->CanCastSpell("scorch", strawman)) if (mageAI->CanCastSpell("scorch", strawman))
@@ -290,6 +280,7 @@ bool KarazhanWizardOfOzScorchStrawmanAction::Execute(Event event)
mageAI->CastSpell("scorch", strawman); mageAI->CastSpell("scorch", strawman);
} }
} }
return false; return false;
} }
@@ -325,6 +316,7 @@ bool KarazhanTheCuratorPositionBossAction::Execute(Event event)
false); false);
} }
} }
return false; return false;
} }
@@ -345,6 +337,7 @@ bool KarazhanTheCuratorSpreadRangedAction::Execute(Event event)
{ {
return FleePosition(nearestPlayer->GetPosition(), minDistance); return FleePosition(nearestPlayer->GetPosition(), minDistance);
} }
return false; return false;
} }
@@ -391,6 +384,7 @@ bool KarazhanShadeOfAranArcaneExplosionRunAwayAction::Execute(Event event)
{ {
return MoveAway(boss, safeDistance - distance); return MoveAway(boss, safeDistance - distance);
} }
return false; return false;
} }
@@ -415,6 +409,7 @@ bool KarazhanShadeOfAranFlameWreathStopMovementAction::Execute(Event event)
} }
return true; return true;
} }
return false; return false;
} }
@@ -422,15 +417,14 @@ bool KarazhanShadeOfAranMarkConjuredElementalAction::Execute(Event event)
{ {
RaidKarazhanHelpers karazhanHelper(botAI); RaidKarazhanHelpers karazhanHelper(botAI);
Unit* boss = AI_VALUE2(Unit*, "find target", "shade of aran"); Unit* boss = AI_VALUE2(Unit*, "find target", "shade of aran");
if (!boss || !boss->IsAlive())
{
return false;
}
Unit* target = karazhanHelper.GetFirstAliveUnitByEntry(NPC_CONJURED_ELEMENTAL); Unit* target = karazhanHelper.GetFirstAliveUnitByEntry(NPC_CONJURED_ELEMENTAL);
if (!target || !target->IsAlive() || target->HasAura(SPELL_WARLOCK_BANISH))
if (!boss || !boss->IsAlive() ||
!target || !target->IsAlive() || target->HasAura(SPELL_WARLOCK_BANISH))
{ {
return false; return false;
} }
karazhanHelper.MarkTargetWithSkull(target); karazhanHelper.MarkTargetWithSkull(target);
return false; return false;
@@ -464,21 +458,17 @@ bool KarazhanShadeOfAranSpreadRangedAction::Execute(Event event)
{ {
return FleePosition(nearestPlayer->GetPosition(), minDistance); return FleePosition(nearestPlayer->GetPosition(), minDistance);
} }
return false; return false;
} }
bool KarazhanShadeOfAranSpreadRangedAction::isUseful() bool KarazhanShadeOfAranSpreadRangedAction::isUseful()
{ {
Unit* boss = AI_VALUE2(Unit*, "find target", "shade of aran"); Unit* boss = AI_VALUE2(Unit*, "find target", "shade of aran");
if (!boss || !boss->IsAlive())
{
return false;
}
RaidKarazhanHelpers karazhanHelper(botAI); RaidKarazhanHelpers karazhanHelper(botAI);
return botAI->IsRanged(bot) && !karazhanHelper.IsFlameWreathActive() && !(boss->HasUnitState(UNIT_STATE_CASTING) return boss && boss->IsAlive() && botAI->IsRanged(bot) && !karazhanHelper.IsFlameWreathActive() &&
&& boss->FindCurrentSpellBySpellId(SPELL_ARCANE_EXPLOSION)); !(boss->HasUnitState(UNIT_STATE_CASTING) && boss->FindCurrentSpellBySpellId(SPELL_ARCANE_EXPLOSION));
} }
// One tank per phase will dance in and out of the red beam (5 seconds in, 5 seconds out) // One tank per phase will dance in and out of the red beam (5 seconds in, 5 seconds out)
@@ -498,29 +488,33 @@ bool KarazhanNetherspiteBlockRedBeamAction::Execute(Event event)
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next()) for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{ {
Player* member = itr->GetSource(); Player* member = itr->GetSource();
if (!member || !member->IsAlive())
{
continue;
}
PlayerbotAI* memberAI = sPlayerbotsMgr->GetPlayerbotAI(member); PlayerbotAI* memberAI = sPlayerbotsMgr->GetPlayerbotAI(member);
if (!memberAI || !memberAI->IsTank(member)) if (!member || !member->IsAlive() || !memberAI || !memberAI->IsTank(member) ||
{ member->HasAura(SPELL_NETHER_EXHAUSTION_RED))
continue;
}
if (member->HasAura(SPELL_NETHER_EXHAUSTION_RED))
{ {
continue; continue;
} }
eligibleTank = member; eligibleTank = member;
break; break;
} }
RaidKarazhanHelpers karazhanHelper(botAI); RaidKarazhanHelpers karazhanHelper(botAI);
Position beamPos = karazhanHelper.GetPositionOnBeam(boss, redPortal, 18.0f); Position beamPos = karazhanHelper.GetPositionOnBeam(boss, redPortal, 18.0f);
if (bot == eligibleTank) if (bot == eligibleTank)
{ {
bot->Yell("I'm moving to block the red beam!", LANG_UNIVERSAL); std::string msg;
std::map<std::string, std::string> ph;
ph["%player"] = bot->GetName();
bool got = sPlayerbotTextMgr->GetBotText("netherspite_beam_blocking_red", msg, ph);
if (got && !msg.empty())
{
bot->Yell(msg, LANG_UNIVERSAL);
}
else
{
bot->Yell(bot->GetName() + " is moving to block the red beam!", LANG_UNIVERSAL);
}
ObjectGuid botGuid = bot->GetGUID(); ObjectGuid botGuid = bot->GetGUID();
uint32 intervalSecs = 5; uint32 intervalSecs = 5;
@@ -539,6 +533,7 @@ bool KarazhanNetherspiteBlockRedBeamAction::Execute(Event event)
return MoveTo(bot->GetMapId(), beamPos.GetPositionX(), beamPos.GetPositionY(), beamPos.GetPositionZ(), return MoveTo(bot->GetMapId(), beamPos.GetPositionX(), beamPos.GetPositionY(), beamPos.GetPositionZ(),
false, false, false, true, MovementPriority::MOVEMENT_FORCED); false, false, false, true, MovementPriority::MOVEMENT_FORCED);
} }
else else
{ {
float bx = boss->GetPositionX(); float bx = boss->GetPositionX();
@@ -552,6 +547,7 @@ bool KarazhanNetherspiteBlockRedBeamAction::Execute(Event event)
{ {
return false; return false;
} }
dx /= length; dx /= length;
dy /= length; dy /= length;
float perpDx = -dy; float perpDx = -dy;
@@ -564,6 +560,7 @@ bool KarazhanNetherspiteBlockRedBeamAction::Execute(Event event)
MovementPriority::MOVEMENT_FORCED); MovementPriority::MOVEMENT_FORCED);
} }
} }
return false; return false;
} }
@@ -576,23 +573,21 @@ bool KarazhanNetherspiteBlockRedBeamAction::isUseful()
static std::map<ObjectGuid, bool> lastBossBanishState; static std::map<ObjectGuid, bool> lastBossBanishState;
bool bossIsBanished = boss && boss->HasAura(SPELL_NETHERSPITE_BANISHED); bool bossIsBanished = boss && boss->HasAura(SPELL_NETHERSPITE_BANISHED);
if (!boss || !redPortal) if (!boss || !redPortal || bossIsBanished)
{ {
return false; return false;
} }
if (lastBossBanishState[botGuid] != bossIsBanished)
if (lastBossBanishState[botGuid] != bossIsBanished)
{ {
if (!bossIsBanished) if (!bossIsBanished)
{ {
beamMoveTimes[botGuid] = 0; beamMoveTimes[botGuid] = 0;
lastBeamMoveSideways[botGuid] = false; lastBeamMoveSideways[botGuid] = false;
} }
lastBossBanishState[botGuid] = bossIsBanished; lastBossBanishState[botGuid] = bossIsBanished;
} }
if (bossIsBanished)
{
return false;
}
return true; return true;
} }
@@ -613,18 +608,42 @@ bool KarazhanNetherspiteBlockBlueBeamAction::Execute(Event event)
if (wasBlocking && !isBlockingNow) if (wasBlocking && !isBlockingNow)
{ {
bot->Yell("I'm leaving the blue beam--next blocker up!", LANG_UNIVERSAL); std::string msg;
std::map<std::string, std::string> ph;
ph["%player"] = bot->GetName();
bool got = sPlayerbotTextMgr->GetBotText("netherspite_beam_leaving_blue", msg, ph);
if (got && !msg.empty())
{
bot->Yell(msg, LANG_UNIVERSAL);
}
else
{
bot->Yell(bot->GetName() + " is leaving the blue beam--next blocker up!", LANG_UNIVERSAL);
}
wasBlockingBlueBeam[botGuid] = false; wasBlockingBlueBeam[botGuid] = false;
return false;
} }
else if (isBlockingNow)
{
wasBlockingBlueBeam[botGuid] = true;
}
if (isBlockingNow) if (isBlockingNow)
{ {
if (!wasBlocking) if (!wasBlocking)
bot->Yell("I'm moving to block the blue beam!", LANG_UNIVERSAL); {
std::string msg;
std::map<std::string, std::string> ph;
ph["%player"] = bot->GetName();
bool got = sPlayerbotTextMgr->GetBotText("netherspite_beam_blocking_blue", msg, ph);
if (got && !msg.empty())
{
bot->Yell(msg, LANG_UNIVERSAL);
}
else
{
bot->Yell(bot->GetName() + " is moving to block the blue beam!", LANG_UNIVERSAL);
}
}
wasBlockingBlueBeam[botGuid] = true; wasBlockingBlueBeam[botGuid] = true;
std::vector<Unit*> voidZones = karazhanHelper.GetAllVoidZones(); std::vector<Unit*> voidZones = karazhanHelper.GetAllVoidZones();
float bx = boss->GetPositionX(); float bx = boss->GetPositionX();
float by = boss->GetPositionY(); float by = boss->GetPositionY();
@@ -677,12 +696,11 @@ bool KarazhanNetherspiteBlockBlueBeamAction::Execute(Event event)
return MoveTo(bot->GetMapId(), bestPos.GetPositionX(), bestPos.GetPositionY(), bestPos.GetPositionZ(), return MoveTo(bot->GetMapId(), bestPos.GetPositionX(), bestPos.GetPositionY(), bestPos.GetPositionZ(),
false, false, false, true, MovementPriority::MOVEMENT_FORCED); false, false, false, true, MovementPriority::MOVEMENT_FORCED);
} }
return false; return false;
} }
else if (wasBlocking)
{ wasBlockingBlueBeam[botGuid] = false;
wasBlockingBlueBeam[botGuid] = false;
}
return false; return false;
} }
@@ -712,14 +730,42 @@ bool KarazhanNetherspiteBlockGreenBeamAction::Execute(Event event)
if (wasBlocking && !isBlockingNow) if (wasBlocking && !isBlockingNow)
{ {
bot->Yell("I'm leaving the green beam--next blocker up!", LANG_UNIVERSAL); std::string msg;
std::map<std::string, std::string> ph;
ph["%player"] = bot->GetName();
bool got = sPlayerbotTextMgr->GetBotText("netherspite_beam_leaving_green", msg, ph);
if (got && !msg.empty())
{
bot->Yell(msg, LANG_UNIVERSAL);
}
else
{
bot->Yell(bot->GetName() + " TESTRUN is leaving the green beam--next blocker up!", LANG_UNIVERSAL);
}
wasBlockingGreenBeam[botGuid] = false; wasBlockingGreenBeam[botGuid] = false;
return false;
} }
else if (isBlockingNow)
if (isBlockingNow)
{ {
if (!wasBlocking) if (!wasBlocking)
bot->Yell("I'm moving to block the green beam!", LANG_UNIVERSAL); {
std::string msg;
std::map<std::string, std::string> ph;
ph["%player"] = bot->GetName();
bool got = sPlayerbotTextMgr->GetBotText("netherspite_beam_blocking_green", msg, ph);
if (got && !msg.empty())
{
bot->Yell(msg, LANG_UNIVERSAL);
}
else
{
bot->Yell(bot->GetName() + " TESTRUN is moving to block the green beam!", LANG_UNIVERSAL);
}
}
wasBlockingGreenBeam[botGuid] = true; wasBlockingGreenBeam[botGuid] = true;
std::vector<Unit*> voidZones = karazhanHelper.GetAllVoidZones(); std::vector<Unit*> voidZones = karazhanHelper.GetAllVoidZones();
float bx = boss->GetPositionX(); float bx = boss->GetPositionX();
float by = boss->GetPositionY(); float by = boss->GetPositionY();
@@ -733,6 +779,7 @@ bool KarazhanNetherspiteBlockGreenBeamAction::Execute(Event event)
{ {
return false; return false;
} }
dx /= length; dx /= length;
dy /= length; dy /= length;
float bestDist = 150.0f; float bestDist = 150.0f;
@@ -747,7 +794,7 @@ bool KarazhanNetherspiteBlockGreenBeamAction::Execute(Event event)
for (Unit* voidZone : voidZones) for (Unit* voidZone : voidZones)
{ {
float voidZoneDist = sqrt(pow(candidateX - voidZone->GetPositionX(), 2) + float voidZoneDist = sqrt(pow(candidateX - voidZone->GetPositionX(), 2) +
pow(candidateY - voidZone->GetPositionY(), 2)); pow(candidateY - voidZone->GetPositionY(), 2));
if (voidZoneDist < 4.0f) if (voidZoneDist < 4.0f)
{ {
outsideAllVoidZones = false; outsideAllVoidZones = false;
@@ -771,12 +818,11 @@ bool KarazhanNetherspiteBlockGreenBeamAction::Execute(Event event)
return MoveTo(bot->GetMapId(), bestPos.GetPositionX(), bestPos.GetPositionY(), bestPos.GetPositionZ(), return MoveTo(bot->GetMapId(), bestPos.GetPositionX(), bestPos.GetPositionY(), bestPos.GetPositionZ(),
false, false, false, true, MovementPriority::MOVEMENT_FORCED); false, false, false, true, MovementPriority::MOVEMENT_FORCED);
} }
return false; return false;
} }
else if (wasBlocking)
{ wasBlockingGreenBeam[botGuid] = false;
wasBlockingGreenBeam[botGuid] = false;
}
return false; return false;
} }
@@ -835,7 +881,6 @@ bool KarazhanNetherspiteAvoidBeamAndVoidZoneAction::Execute(Event event)
float length = sqrt(dx*dx + dy*dy); float length = sqrt(dx*dx + dy*dy);
beams.push_back({greenPortal, 0.0f, length}); beams.push_back({greenPortal, 0.0f, length});
} }
bool nearBeam = false; bool nearBeam = false;
for (const auto& beam : beams) for (const auto& beam : beams)
{ {
@@ -844,7 +889,7 @@ bool KarazhanNetherspiteAvoidBeamAndVoidZoneAction::Execute(Event event)
float dx = px - bx, dy = py - by; float dx = px - bx, dy = py - by;
float length = sqrt(dx*dx + dy*dy); float length = sqrt(dx*dx + dy*dy);
if (length == 0.0f) if (length == 0.0f)
{continue; {
continue; continue;
} }
dx /= length; dy /= length; dx /= length; dy /= length;
@@ -858,7 +903,6 @@ bool KarazhanNetherspiteAvoidBeamAndVoidZoneAction::Execute(Event event)
break; break;
} }
} }
if (!nearVoidZone && !nearBeam) if (!nearVoidZone && !nearBeam)
{ {
return false; return false;
@@ -936,12 +980,14 @@ bool KarazhanNetherspiteAvoidBeamAndVoidZoneAction::isUseful()
{ {
return false; return false;
} }
RaidKarazhanHelpers karazhanHelper(botAI); RaidKarazhanHelpers karazhanHelper(botAI);
auto [redBlocker, greenBlocker, blueBlocker] = karazhanHelper.GetCurrentBeamBlockers(); auto [redBlocker, greenBlocker, blueBlocker] = karazhanHelper.GetCurrentBeamBlockers();
if (bot == redBlocker || bot == blueBlocker || bot == greenBlocker) if (bot == redBlocker || bot == blueBlocker || bot == greenBlocker)
{ {
return false; return false;
} }
return true; return true;
} }
@@ -957,6 +1003,7 @@ bool KarazhanNetherspiteBanishPhaseAvoidVoidZoneAction::Execute(Event event)
return FleePosition(vz->GetPosition(), 4.0f); return FleePosition(vz->GetPosition(), 4.0f);
} }
} }
return false; return false;
} }
@@ -967,6 +1014,7 @@ bool KarazhanNetherspiteBanishPhaseAvoidVoidZoneAction::isUseful()
{ {
return false; return false;
} }
RaidKarazhanHelpers karazhanHelper(botAI); RaidKarazhanHelpers karazhanHelper(botAI);
std::vector<Unit*> voidZones = karazhanHelper.GetAllVoidZones(); std::vector<Unit*> voidZones = karazhanHelper.GetAllVoidZones();
for (Unit* vz : voidZones) for (Unit* vz : voidZones)
@@ -976,6 +1024,7 @@ bool KarazhanNetherspiteBanishPhaseAvoidVoidZoneAction::isUseful()
return true; return true;
} }
} }
return false; return false;
} }
@@ -1037,6 +1086,7 @@ bool KarazhanPrinceMalchezaarNonTankAvoidHazardAction::Execute(Event event)
return MoveTo(bot->GetMapId(), bestDestX, bestDestY, bestDestZ, false, false, false, true, return MoveTo(bot->GetMapId(), bestDestX, bestDestY, bestDestZ, false, false, false, true,
MovementPriority::MOVEMENT_FORCED); MovementPriority::MOVEMENT_FORCED);
} }
return false; return false;
} }
@@ -1127,6 +1177,7 @@ bool KarazhanPrinceMalchezaarNonTankAvoidHazardAction::Execute(Event event)
} }
} }
} }
return false; return false;
} }
@@ -1165,6 +1216,7 @@ bool KarazhanPrinceMalchezaarTankAvoidHazardAction::Execute(Event event)
break; break;
} }
} }
if (nearInfernal) if (nearInfernal)
{ {
for (int i = 0; i < numAngles; ++i) for (int i = 0; i < numAngles; ++i)
@@ -1238,6 +1290,7 @@ bool KarazhanPrinceMalchezaarTankAvoidHazardAction::Execute(Event event)
MovementPriority::MOVEMENT_COMBAT); MovementPriority::MOVEMENT_COMBAT);
} }
} }
return false; return false;
} }

View File

@@ -100,18 +100,14 @@ Unit* RaidKarazhanHelpers::GetNearestPlayerInRadius(float radius)
} }
} }
} }
return nullptr; return nullptr;
} }
bool RaidKarazhanHelpers::IsFlameWreathActive() bool RaidKarazhanHelpers::IsFlameWreathActive()
{ {
Unit* boss = AI_VALUE2(Unit*, "find target", "shade of aran"); Unit* boss = AI_VALUE2(Unit*, "find target", "shade of aran");
if (!boss) Spell* currentSpell = boss ? boss->GetCurrentSpell(CURRENT_GENERIC_SPELL) : nullptr;
{
return false;
}
Spell* currentSpell = boss->GetCurrentSpell(CURRENT_GENERIC_SPELL);
if (currentSpell && currentSpell->m_spellInfo && currentSpell->m_spellInfo->Id == SPELL_FLAME_WREATH) if (currentSpell && currentSpell->m_spellInfo && currentSpell->m_spellInfo->Id == SPELL_FLAME_WREATH)
{ {
return true; return true;
@@ -132,6 +128,7 @@ bool RaidKarazhanHelpers::IsFlameWreathActive()
} }
} }
} }
return false; return false;
} }
@@ -148,20 +145,19 @@ std::vector<Player*> RaidKarazhanHelpers::GetBlueBlockers()
{ {
continue; continue;
} }
bool isDps = botAI->IsDps(member); bool isDps = botAI->IsDps(member);
bool isWarrior = member->getClass() == CLASS_WARRIOR; bool isWarrior = member->getClass() == CLASS_WARRIOR;
bool isRogue = member->getClass() == CLASS_ROGUE; bool isRogue = member->getClass() == CLASS_ROGUE;
bool hasExhaustion = member->HasAura(SPELL_NETHER_EXHAUSTION_BLUE); bool hasExhaustion = member->HasAura(SPELL_NETHER_EXHAUSTION_BLUE);
Aura* blueBuff = member->GetAura(SPELL_BLUE_BEAM_DEBUFF); Aura* blueBuff = member->GetAura(SPELL_BLUE_BEAM_DEBUFF);
bool overStack = blueBuff && blueBuff->GetStackAmount() >= 25; bool overStack = blueBuff && blueBuff->GetStackAmount() >= 25;
if (isDps && !isWarrior && !isRogue && !hasExhaustion && !overStack) if (isDps && !isWarrior && !isRogue && !hasExhaustion && !overStack)
{ {
blueBlockers.push_back(member); blueBlockers.push_back(member);
} }
} }
} }
return blueBlockers; return blueBlockers;
} }
@@ -180,7 +176,6 @@ std::vector<Player*> RaidKarazhanHelpers::GetGreenBlockers()
{ {
continue; continue;
} }
bool hasExhaustion = member->HasAura(SPELL_NETHER_EXHAUSTION_GREEN); bool hasExhaustion = member->HasAura(SPELL_NETHER_EXHAUSTION_GREEN);
Aura* greenBuff = member->GetAura(SPELL_GREEN_BEAM_DEBUFF); Aura* greenBuff = member->GetAura(SPELL_GREEN_BEAM_DEBUFF);
bool overStack = greenBuff && greenBuff->GetStackAmount() >= 25; bool overStack = greenBuff && greenBuff->GetStackAmount() >= 25;
@@ -189,13 +184,13 @@ std::vector<Player*> RaidKarazhanHelpers::GetGreenBlockers()
bool eligibleRogueWarrior = (isRogue || isDpsWarrior) && !hasExhaustion; bool eligibleRogueWarrior = (isRogue || isDpsWarrior) && !hasExhaustion;
bool isHealer = botAI->IsHeal(member); bool isHealer = botAI->IsHeal(member);
bool eligibleHealer = isHealer && !hasExhaustion && !overStack; bool eligibleHealer = isHealer && !hasExhaustion && !overStack;
if (eligibleRogueWarrior || eligibleHealer) if (eligibleRogueWarrior || eligibleHealer)
{ {
greenBlockers.push_back(member); greenBlockers.push_back(member);
} }
} }
} }
return greenBlockers; return greenBlockers;
} }
@@ -210,7 +205,6 @@ Position RaidKarazhanHelpers::GetPositionOnBeam(Unit* boss, Unit* portal, float
float dx = px - bx; float dx = px - bx;
float dy = py - by; float dy = py - by;
float length = sqrt(dx*dx + dy*dy); float length = sqrt(dx*dx + dy*dy);
if (length == 0.0f) if (length == 0.0f)
{ {
return Position(bx, by, bz); return Position(bx, by, bz);
@@ -218,7 +212,6 @@ Position RaidKarazhanHelpers::GetPositionOnBeam(Unit* boss, Unit* portal, float
dx /= length; dx /= length;
dy /= length; dy /= length;
float targetX = bx + dx * distanceFromBoss; float targetX = bx + dx * distanceFromBoss;
float targetY = by + dy * distanceFromBoss; float targetY = by + dy * distanceFromBoss;
float targetZ = bz; float targetZ = bz;
@@ -233,38 +226,29 @@ std::tuple<Player*, Player*, Player*> RaidKarazhanHelpers::GetCurrentBeamBlocker
Player* blueBlocker = nullptr; Player* blueBlocker = nullptr;
std::vector<Player*> redBlockers; std::vector<Player*> redBlockers;
if (Group* group = bot->GetGroup()) if (Group* group = bot->GetGroup())
{
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{ {
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next()) Player* member = itr->GetSource();
PlayerbotAI* memberAI = sPlayerbotsMgr->GetPlayerbotAI(member);
if (!member || !member->IsAlive() || !memberAI || !memberAI->IsTank(member) ||
member->HasAura(SPELL_NETHER_EXHAUSTION_RED))
{ {
Player* member = itr->GetSource(); continue;
if (!member || !member->IsAlive())
{
continue;
}
if (!botAI->IsTank(member))
{
continue;
}
if (member->HasAura(SPELL_NETHER_EXHAUSTION_RED))
{
continue;
}
redBlockers.push_back(member);
} }
redBlockers.push_back(member);
} }
}
if (!redBlockers.empty()) if (!redBlockers.empty())
{ {
redBlocker = redBlockers.front(); redBlocker = redBlockers.front();
} }
std::vector<Player*> greenBlockers = GetGreenBlockers(); std::vector<Player*> greenBlockers = GetGreenBlockers();
if (!greenBlockers.empty()) if (!greenBlockers.empty())
{ {
greenBlocker = greenBlockers.front(); greenBlocker = greenBlockers.front();
} }
std::vector<Player*> blueBlockers = GetBlueBlockers(); std::vector<Player*> blueBlockers = GetBlueBlockers();
if (!blueBlockers.empty()) if (!blueBlockers.empty())
{ {
@@ -286,13 +270,13 @@ std::vector<Unit*> RaidKarazhanHelpers::GetAllVoidZones()
{ {
continue; continue;
} }
float dist = bot->GetExactDist2d(unit); float dist = bot->GetExactDist2d(unit);
if (dist < radius) if (dist < radius)
{ {
voidZones.push_back(unit); voidZones.push_back(unit);
} }
} }
return voidZones; return voidZones;
} }
@@ -302,12 +286,12 @@ bool RaidKarazhanHelpers::IsSafePosition(float x, float y, float z,
for (Unit* hazard : hazards) for (Unit* hazard : hazards)
{ {
float dist = std::sqrt(std::pow(x - hazard->GetPositionX(), 2) + std::pow(y - hazard->GetPositionY(), 2)); float dist = std::sqrt(std::pow(x - hazard->GetPositionX(), 2) + std::pow(y - hazard->GetPositionY(), 2));
if (dist < hazardRadius) if (dist < hazardRadius)
{ {
return false; return false;
} }
} }
return true; return true;
} }
@@ -315,16 +299,15 @@ std::vector<Unit*> RaidKarazhanHelpers::GetSpawnedInfernals() const
{ {
std::vector<Unit*> infernals; std::vector<Unit*> infernals;
const GuidVector npcs = botAI->GetAiObjectContext()->GetValue<GuidVector>("nearest hostile npcs")->Get(); const GuidVector npcs = botAI->GetAiObjectContext()->GetValue<GuidVector>("nearest hostile npcs")->Get();
for (const auto& npcGuid : npcs) for (const auto& npcGuid : npcs)
{ {
Unit* unit = botAI->GetUnit(npcGuid); Unit* unit = botAI->GetUnit(npcGuid);
if (unit && unit->GetEntry() == NPC_NETHERSPITE_INFERNAL) if (unit && unit->GetEntry() == NPC_NETHERSPITE_INFERNAL)
{ {
infernals.push_back(unit); infernals.push_back(unit);
} }
} }
return infernals; return infernals;
} }
@@ -341,7 +324,7 @@ bool RaidKarazhanHelpers::IsStraightPathSafe(const Position& start, const Positi
{ {
return true; return true;
} }
for (float checkDist = 0.0f; checkDist <= totalDist; checkDist += stepSize) for (float checkDist = 0.0f; checkDist <= totalDist; checkDist += stepSize)
{ {
float t = checkDist / totalDist; float t = checkDist / totalDist;
@@ -357,7 +340,7 @@ bool RaidKarazhanHelpers::IsStraightPathSafe(const Position& start, const Positi
} }
} }
} }
return true; return true;
} }
@@ -384,7 +367,6 @@ Position RaidKarazhanHelpers::CalculateArcPoint(const Position& current, const P
float dotProduct = currentX * targetX + currentY * targetY; float dotProduct = currentX * targetX + currentY * targetY;
dotProduct = std::max(-1.0f, std::min(1.0f, dotProduct)); dotProduct = std::max(-1.0f, std::min(1.0f, dotProduct));
float angle = std::acos(dotProduct); float angle = std::acos(dotProduct);
float crossProduct = currentX * targetY - currentY * targetX; float crossProduct = currentX * targetY - currentY * targetX;
float stepAngle = angle * arcFraction; float stepAngle = angle * arcFraction;
if (crossProduct < 0) if (crossProduct < 0)
@@ -394,10 +376,8 @@ Position RaidKarazhanHelpers::CalculateArcPoint(const Position& current, const P
float cos_a = std::cos(stepAngle); float cos_a = std::cos(stepAngle);
float sin_a = std::sin(stepAngle); float sin_a = std::sin(stepAngle);
float rotatedX = currentX * cos_a - currentY * sin_a; float rotatedX = currentX * cos_a - currentY * sin_a;
float rotatedY = currentX * sin_a + currentY * cos_a; float rotatedY = currentX * sin_a + currentY * cos_a;
float desiredDist = currentDist * 0.9f + targetDist * 0.1f; float desiredDist = currentDist * 0.9f + targetDist * 0.1f;
return Position(center.GetPositionX() + rotatedX * desiredDist, return Position(center.GetPositionX() + rotatedX * desiredDist,

View File

@@ -31,6 +31,7 @@ float KarazhanBigBadWolfMultiplier::GetValue(Action* action)
return 0.0f; return 0.0f;
} }
} }
return 1.0f; return 1.0f;
} }
@@ -81,6 +82,7 @@ float KarazhanShadeOfAranMultiplier::GetValue(Action* action)
return 0.0f; return 0.0f;
} }
} }
return 1.0f; return 1.0f;
} }
@@ -125,6 +127,7 @@ float KarazhanNetherspiteBlueAndGreenBeamMultiplier::GetValue(Action* action)
break; break;
} }
} }
if (inBeam) if (inBeam)
{ {
std::vector<Unit*> voidZones = karazhanHelper.GetAllVoidZones(); std::vector<Unit*> voidZones = karazhanHelper.GetAllVoidZones();
@@ -145,6 +148,7 @@ float KarazhanNetherspiteBlueAndGreenBeamMultiplier::GetValue(Action* action)
} }
} }
} }
return 1.0f; return 1.0f;
} }
@@ -208,6 +212,7 @@ float KarazhanNetherspiteRedBeamMultiplier::GetValue(Action* action)
} }
} }
} }
return 1.0f; return 1.0f;
} }
@@ -215,13 +220,11 @@ float KarazhanPrinceMalchezaarMultiplier::GetValue(Action* action)
{ {
Unit* boss = AI_VALUE2(Unit*, "find target", "prince malchezaar"); Unit* boss = AI_VALUE2(Unit*, "find target", "prince malchezaar");
if (boss && botAI->IsMelee(bot) && bot->HasAura(SPELL_ENFEEBLE)) if (boss && botAI->IsMelee(bot) && bot->HasAura(SPELL_ENFEEBLE) &&
!dynamic_cast<KarazhanPrinceMalchezaarNonTankAvoidHazardAction*>(action))
{ {
if (dynamic_cast<KarazhanPrinceMalchezaarNonTankAvoidHazardAction*>(action))
{
return 1.0f;
}
return 0.0f; return 0.0f;
} }
return 1.0f; return 1.0f;
} }