mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
### Summary This PR restores the Naxxramas raid strategies that were removed in commit 686fe513b25bbb20ccfcc89f08ee8c4b498a263e . The reintroduced logic is core‑friendly (no AzerothCore script headers or internal boss AI/EventMap dependencies), and the Naxxramas actions have been refactored into per‑boss files for better maintainability. ### Motivation The previous removal was meant to avoid core modifications and unblock upstreaming. This PR brings the strategies back while adhering to that requirement, using only observable state and mod‑playerbots helpers. ### What’s included - Re‑enabled the Naxxramas strategies previously removed. - Replaced core script header dependencies with observable checks (auras, casts, unit flags, flight state, etc.). - Split the Naxxramas action logic into per‑boss source files to avoid a “god file” and ease future maintenance. - Minor, non‑intrusive behavior improvements aligned with existing helpers. ### Future work Some strategies may still require refinement or more advanced handling later. This PR focuses on restoring the baseline logic without core dependencies, while keeping changes minimal and safe. **Any contributions are welcome to further improve and fine‑tune the Naxxramas strategies.** ### Testing Tested in some Naxx boxx. No server crash and boss killed :D Note: I'll make another PR with revised scripts when this one are merged --------- Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com> Co-authored-by: bash <hermensb@gmail.com> Co-authored-by: Revision <tkn963@gmail.com> Co-authored-by: kadeshar <kadeshar@gmail.com>
178 lines
6.9 KiB
C++
178 lines
6.9 KiB
C++
#include "RaidNaxxActions.h"
|
|
|
|
#include "PlayerbotAIConfig.h"
|
|
#include "Playerbots.h"
|
|
|
|
bool KelthuzadChooseTargetAction::Execute(Event /*event*/)
|
|
{
|
|
if (!helper.UpdateBossAI())
|
|
return false;
|
|
|
|
GuidVector attackers = context->GetValue<GuidVector>("attackers")->Get();
|
|
Unit* target = nullptr;
|
|
Unit *target_soldier = nullptr, *target_weaver = nullptr, *target_abomination = nullptr, *target_kelthuzad = nullptr,
|
|
*target_guardian = nullptr;
|
|
for (auto i = attackers.begin(); i != attackers.end(); ++i)
|
|
{
|
|
Unit* unit = botAI->GetUnit(*i);
|
|
if (!unit)
|
|
continue;
|
|
|
|
if (botAI->EqualLowercaseName(unit->GetName(), "guardian of icecrown"))
|
|
{
|
|
if (!target_guardian)
|
|
target_guardian = unit;
|
|
else if (unit->GetVictim() && target_guardian->GetVictim() && unit->GetVictim()->ToPlayer() &&
|
|
target_guardian->GetVictim()->ToPlayer() && !botAI->IsAssistTank(unit->GetVictim()->ToPlayer()) &&
|
|
botAI->IsAssistTank(target_guardian->GetVictim()->ToPlayer()))
|
|
{
|
|
target_guardian = unit;
|
|
}
|
|
else if (unit->GetVictim() && target_guardian->GetVictim() && unit->GetVictim()->ToPlayer() &&
|
|
target_guardian->GetVictim()->ToPlayer() && !botAI->IsAssistTank(unit->GetVictim()->ToPlayer()) &&
|
|
!botAI->IsAssistTank(target_guardian->GetVictim()->ToPlayer()) &&
|
|
target_guardian->GetDistance2d(helper.center.first, helper.center.second) >
|
|
bot->GetDistance2d(unit))
|
|
{
|
|
target_guardian = unit;
|
|
}
|
|
}
|
|
|
|
if (unit->GetDistance2d(helper.center.first, helper.center.second) > 30.0f)
|
|
continue;
|
|
|
|
if (bot->GetDistance2d(unit) > sPlayerbotAIConfig.spellDistance)
|
|
continue;
|
|
|
|
if (botAI->EqualLowercaseName(unit->GetName(), "unstoppable abomination"))
|
|
{
|
|
if (target_abomination == nullptr ||
|
|
target_abomination->GetDistance2d(helper.center.first, helper.center.second) >
|
|
unit->GetDistance2d(helper.center.first, helper.center.second))
|
|
{
|
|
target_abomination = unit;
|
|
}
|
|
}
|
|
if (botAI->EqualLowercaseName(unit->GetName(), "soldier of the frozen wastes"))
|
|
{
|
|
if (target_soldier == nullptr ||
|
|
target_soldier->GetDistance2d(helper.center.first, helper.center.second) >
|
|
unit->GetDistance2d(helper.center.first, helper.center.second))
|
|
{
|
|
target_soldier = unit;
|
|
}
|
|
}
|
|
if (botAI->EqualLowercaseName(unit->GetName(), "soul weaver"))
|
|
{
|
|
if (target_weaver == nullptr || target_weaver->GetDistance2d(helper.center.first, helper.center.second) >
|
|
unit->GetDistance2d(helper.center.first, helper.center.second))
|
|
target_weaver = unit;
|
|
}
|
|
|
|
if (botAI->EqualLowercaseName(unit->GetName(), "kel'thuzad"))
|
|
target_kelthuzad = unit;
|
|
}
|
|
std::vector<Unit*> targets;
|
|
if (botAI->IsRanged(bot))
|
|
{
|
|
if (botAI->GetRangedDpsIndex(bot) <= 1)
|
|
targets = {target_soldier, target_weaver, target_abomination, target_kelthuzad};
|
|
else
|
|
targets = {target_weaver, target_soldier, target_abomination, target_kelthuzad};
|
|
}
|
|
else if (botAI->IsAssistTank(bot))
|
|
targets = {target_abomination, target_guardian, target_kelthuzad};
|
|
else
|
|
targets = {target_abomination, target_kelthuzad};
|
|
|
|
for (Unit* t : targets)
|
|
{
|
|
if (t)
|
|
{
|
|
target = t;
|
|
break;
|
|
}
|
|
}
|
|
if (context->GetValue<Unit*>("current target")->Get() == target)
|
|
return false;
|
|
|
|
if (target_kelthuzad && target == target_kelthuzad)
|
|
return Attack(target, true);
|
|
|
|
return Attack(target, false);
|
|
}
|
|
|
|
bool KelthuzadPositionAction::Execute(Event /*event*/)
|
|
{
|
|
if (!helper.UpdateBossAI())
|
|
return false;
|
|
|
|
if (helper.IsPhaseOne())
|
|
{
|
|
if (AI_VALUE(Unit*, "current target") == nullptr)
|
|
return MoveInside(NAXX_MAP_ID, helper.center.first, helper.center.second, bot->GetPositionZ(), 3.0f,
|
|
MovementPriority::MOVEMENT_COMBAT);
|
|
}
|
|
else if (helper.IsPhaseTwo())
|
|
{
|
|
Unit* shadow_fissure = helper.GetAnyShadowFissure();
|
|
if (!shadow_fissure || !bot->IsWithinDistInMap(shadow_fissure, 10.0f))
|
|
{
|
|
float distance, angle;
|
|
if (botAI->IsMainTank(bot))
|
|
{
|
|
if (AI_VALUE2(bool, "has aggro", "current target"))
|
|
return MoveTo(NAXX_MAP_ID, helper.tank_pos.first, helper.tank_pos.second, bot->GetPositionZ(), false, false, false,
|
|
false, MovementPriority::MOVEMENT_COMBAT);
|
|
else
|
|
return false;
|
|
}
|
|
else if (botAI->IsRanged(bot))
|
|
{
|
|
uint32 index = botAI->GetRangedIndex(bot);
|
|
if (index < 8)
|
|
{
|
|
distance = 20.0f;
|
|
angle = index * M_PI / 4;
|
|
}
|
|
else
|
|
{
|
|
distance = 32.0f;
|
|
angle = (index - 8) * M_PI / 4;
|
|
}
|
|
float dx, dy;
|
|
dx = helper.center.first + cos(angle) * distance;
|
|
dy = helper.center.second + sin(angle) * distance;
|
|
return MoveTo(NAXX_MAP_ID, dx, dy, bot->GetPositionZ(), false, false, false, false, MovementPriority::MOVEMENT_COMBAT);
|
|
}
|
|
else if (botAI->IsTank(bot))
|
|
{
|
|
Unit* cur_tar = AI_VALUE(Unit*, "current target");
|
|
if (cur_tar && cur_tar->GetVictim() && cur_tar->GetVictim()->ToPlayer() &&
|
|
botAI->EqualLowercaseName(cur_tar->GetName(), "guardian of icecrown") &&
|
|
botAI->IsAssistTank(cur_tar->GetVictim()->ToPlayer()))
|
|
{
|
|
return MoveTo(NAXX_MAP_ID, helper.assist_tank_pos.first, helper.assist_tank_pos.second, bot->GetPositionZ(),
|
|
false, false, false, false, MovementPriority::MOVEMENT_COMBAT);
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
float dx, dy;
|
|
float angle;
|
|
if (!botAI->IsRanged(bot))
|
|
angle = shadow_fissure->GetAngle(helper.center.first, helper.center.second);
|
|
else
|
|
angle = bot->GetAngle(shadow_fissure) + M_PI;
|
|
|
|
dx = shadow_fissure->GetPositionX() + cos(angle) * 10.0f;
|
|
dy = shadow_fissure->GetPositionY() + sin(angle) * 10.0f;
|
|
return MoveTo(NAXX_MAP_ID, dx, dy, bot->GetPositionZ(), false, false, false, false, MovementPriority::MOVEMENT_COMBAT);
|
|
}
|
|
}
|
|
return false;
|
|
}
|