[Bots] Remove Alt Combat Functionality (#4067)

* [Bots] Remove Alt Combat Functionality

# Notes
- This functionality needlessly complicates bot targeting logic and causes crashes and unintended behavior for players when accidentally enabled or enabled by default.

* Cleanup
This commit is contained in:
Alex King 2024-02-12 04:00:11 -05:00 committed by GitHub
parent e920e35a5c
commit 0adca46a73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 40 additions and 213 deletions

View File

@ -694,7 +694,6 @@ RULE_BOOL(Bots, BotGroupXP, false, "Determines whether client gets experience fo
RULE_BOOL(Bots, BotLevelsWithOwner, false, "Auto-updates spawned bots as owner levels/de-levels (false is original behavior)")
RULE_INT(Bots, BotCharacterLevel, 0, "If level is greater that value player can spawn bots if BotCharacterLevelEnabled is true")
RULE_INT(Bots, CasterStopMeleeLevel, 13, "Level at which caster bots stop melee attacks")
RULE_BOOL(Bots, AllowOwnerOptionAltCombat, true, "When option is enabled, bots will use an auto-/shared-aggro combat model")
RULE_BOOL(Bots, AllowOwnerOptionAutoDefend, true, "When option is enabled, bots will defend their owner on enemy aggro")
RULE_REAL(Bots, LeashDistance, 562500.0f, "Distance a bot is allowed to travel from leash owner before being pulled back (squared value)")
RULE_BOOL(Bots, AllowApplyPoisonCommand, true, "Allows the use of the bot command 'applypoison'")

View File

@ -85,7 +85,6 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm
SetShowHelm(true);
SetPauseAI(false);
m_alt_combat_hate_timer.Start(250);
m_auto_defend_timer.Disable();
SetGuardFlag(false);
SetHoldFlag(false);
@ -205,7 +204,6 @@ Bot::Bot(
SetTaunting((GetClass() == Class::Warrior || GetClass() == Class::Paladin || GetClass() == Class::ShadowKnight) && (GetBotStance() == EQ::constants::stanceAggressive));
SetPauseAI(false);
m_alt_combat_hate_timer.Start(250);
m_auto_defend_timer.Disable();
SetGuardFlag(false);
SetHoldFlag(false);
@ -1958,8 +1956,6 @@ void Bot::AI_Process()
HealRotationChecks();
bool bo_alt_combat = (RuleB(Bots, AllowOwnerOptionAltCombat) && bot_owner->GetBotOption(Client::booAltCombat));
if (GetAttackFlag()) { // Push owner's target onto our hate list
SetOwnerTarget(bot_owner);
}
@ -1969,8 +1965,6 @@ void Bot::AI_Process()
//ALT COMBAT (ACQUIRE HATE)
SetBotTarget(bot_owner, raid, bot_group, leash_owner, lo_distance, leash_distance, bo_alt_combat);
glm::vec3 Goal(0, 0, 0);
// We have aggro to choose from
@ -1996,12 +1990,6 @@ void Bot::AI_Process()
}
}
// ALT COMBAT (ACQUIRE TARGET)
else if (bo_alt_combat && m_alt_combat_hate_timer.Check()) { // Find a mob from hate list to target
AcquireBotTarget(bot_group, nullptr, leash_owner, leash_distance);
}
// DEFAULT (ACQUIRE TARGET)
// VERIFY TARGET AND STANCE
@ -2021,7 +2009,7 @@ void Bot::AI_Process()
// TARGET VALIDATION
if (!IsValidTarget(bot_owner, leash_owner, lo_distance, leash_distance, bo_alt_combat, tar, tar_distance)) {
if (!IsValidTarget(bot_owner, leash_owner, lo_distance, leash_distance, tar, tar_distance)) {
return;
}
@ -2683,17 +2671,29 @@ void Bot::CalcMeleeDistances(const Mob* tar, const EQ::ItemInstance* const& p_it
}
}
bool Bot::IsValidTarget(Client* bot_owner, Client* leash_owner, float lo_distance, float leash_distance, bool bo_alt_combat, Mob* tar, float tar_distance) {
bool Bot::IsValidTarget(
Client* bot_owner,
Client* leash_owner,
float lo_distance,
float leash_distance,
Mob* tar,
float tar_distance
)
{
if (!tar || !bot_owner || !leash_owner) {
return false;
}
bool valid_target_state = HOLDING || !tar->IsNPC() || tar->IsMezzed() || lo_distance > leash_distance || tar_distance > leash_distance;
bool valid_target = !GetAttackingFlag() && !CheckLosFN(tar) && !leash_owner->CheckLosFN(tar);
bool valid_bo_target = !GetAttackingFlag() && NOT_PULLING_BOT && !leash_owner->AutoAttackEnabled() && !tar->GetHateAmount(this) && !tar->GetHateAmount(leash_owner);
const bool valid_target_state = (
HOLDING ||
!tar->IsNPC() ||
tar->IsMezzed() ||
lo_distance > leash_distance ||
tar_distance > leash_distance
);
const bool valid_target = !GetAttackingFlag() && !CheckLosFN(tar) && !leash_owner->CheckLosFN(tar);
if (valid_target_state || valid_target || !IsAttackAllowed(tar) || (bo_alt_combat && valid_bo_target)) {
if (valid_target_state || valid_target || !IsAttackAllowed(tar)) {
// Normally, we wouldn't want to do this without class checks..but, too many issues can arise if we let enchanter animation pets run rampant
if (HasPet()) {
GetPet()->RemoveFromHateList(tar);
@ -2712,6 +2712,7 @@ bool Bot::IsValidTarget(Client* bot_owner, Client* leash_owner, float lo_distanc
SetPullingFlag(false);
SetReturningFlag(false);
bot_owner->SetBotPulling(false);
if (GetPet()) {
GetPet()->SetPetOrder(m_previous_pet_order);
}
@ -2723,13 +2724,15 @@ bool Bot::IsValidTarget(Client* bot_owner, Client* leash_owner, float lo_distanc
return false;
}
return true;
}
Mob* Bot::GetBotTarget(Client* bot_owner) {
Mob* Bot::GetBotTarget(Client* bot_owner)
{
Mob* t = GetTarget();
Mob* tar = GetTarget();
if (!tar || PASSIVE) {
if (!t || PASSIVE) {
if (GetTarget()) {
SetTarget(nullptr);
}
@ -2737,12 +2740,13 @@ Mob* Bot::GetBotTarget(Client* bot_owner) {
WipeHateList();
SetAttackFlag(false);
SetAttackingFlag(false);
if (PULLING_BOT) {
if (PULLING_BOT) {
// 'Flags' should only be set on the bot that is pulling
SetPullingFlag(false);
SetReturningFlag(false);
bot_owner->SetBotPulling(false);
if (GetPet()) {
GetPet()->SetPetOrder(m_previous_pet_order);
}
@ -2752,84 +2756,8 @@ Mob* Bot::GetBotTarget(Client* bot_owner) {
BotMeditate(true);
}
}
return tar;
}
void Bot::AcquireBotTarget(Group* bot_group, Raid* raid, Client* leash_owner, float leash_distance) {// Group roles can be expounded upon in the future
Mob* assist_mob = nullptr;
bool find_target = true;
if (raid) {
assist_mob = raid->GetRaidMainAssistOne();
}
else if (bot_group) {
assist_mob = entity_list.GetMob(bot_group->GetMainAssistName());
}
if (assist_mob) {
if (assist_mob->GetTarget()) {
if (assist_mob != this) {
if (GetTarget() != assist_mob->GetTarget()) {
SetTarget(assist_mob->GetTarget());
}
if (
HasPet() &&
(
GetClass() != Class::Enchanter ||
GetPet()->GetPetType() != petAnimation ||
GetAA(aaAnimationEmpathy) >= 2
)
) {
// This artificially inflates pet's target aggro..but, less expensive than checking hate each AI process
GetPet()->AddToHateList(assist_mob->GetTarget(), 1);
GetPet()->SetTarget(assist_mob->GetTarget());
}
}
find_target = false;
} else if (assist_mob != this) {
if (GetTarget()) {
SetTarget(nullptr);
}
if (
HasPet() &&
(
GetClass() != Class::Enchanter ||
GetPet()->GetPetType() != petAnimation ||
GetAA(aaAnimationEmpathy) >= 1
)
) {
GetPet()->WipeHateList();
GetPet()->SetTarget(nullptr);
}
find_target = false;
}
}
if (find_target) {
if (IsRooted()) {
auto closest = hate_list.GetClosestEntOnHateList(this, true);
if (closest) {
SetTarget(closest);
}
} else {
// This will keep bots on target for now..but, future updates will allow for rooting/stunning
if (auto escaping = hate_list.GetEscapingMobOnHateList(leash_owner, leash_distance)) {
SetTarget(escaping);
}
if (!GetTarget()) {
auto most_hate = hate_list.GetMobWithMostHateOnList(this, nullptr, true);
if (most_hate) {
SetTarget(most_hate);
}
}
}
}
return t;
}
bool Bot::ReturningFlagChecks(Client* bot_owner, float fm_distance) {// Need to make it back to group before clearing return flag
@ -2893,42 +2821,6 @@ bool Bot::PullingFlagChecks(Client* bot_owner) {
return true;
}
void Bot::SetBotTarget(Client* bot_owner, Raid* raid, Group* bot_group, Client* leash_owner, float lo_distance, float leash_distance, bool bo_alt_combat) {
if (bo_alt_combat && m_alt_combat_hate_timer.Check(false)) {
// Empty hate list - let's find some aggro
if (bot_owner->IsEngaged() && !IsEngaged() && NOT_HOLDING && NOT_PASSIVE && (!bot_owner->GetBotPulling() || NOT_PULLING_BOT)) {
SetLeashOwnerTarget(leash_owner, bot_owner, lo_distance, leash_distance);
}
else if (!IsEngaged() && raid) {
for (const auto& raid_member : raid->members) {
if (!raid_member.member) {
continue;
}
auto rm_target = raid_member.member->GetTarget();
if (!rm_target || !rm_target->IsNPC()) {
continue;
}
SetBotGroupTarget(bot_owner, leash_owner, lo_distance, leash_distance, raid_member.member, rm_target);
}
}
else if (!IsEngaged() && bot_group) {
for (const auto& bg_member: bot_group->members) {
if (!bg_member) {
continue;
}
auto bgm_target = bg_member->GetTarget();
if (!bgm_target || !bgm_target->IsNPC()) {
continue;
}
SetBotGroupTarget(bot_owner, leash_owner, lo_distance, leash_distance, bg_member, bgm_target);
}
}
}
}
void Bot::HealRotationChecks() {
if (IsMyHealRotationSet()) {
@ -3063,26 +2955,6 @@ Client* Bot::SetLeashOwner(Client* bot_owner, Group* bot_group, Raid* raid, uint
return leash_owner;
}
void Bot::SetLeashOwnerTarget(Client* leash_owner, Client* bot_owner, float lo_distance, float leash_distance) {
Mob* lo_target = leash_owner->GetTarget();
if (lo_target &&
lo_target->IsNPC() &&
!lo_target->IsMezzed() &&
((bot_owner->GetBotOption(Client::booAutoDefend) && lo_target->GetHateAmount(leash_owner)) || leash_owner->AutoAttackEnabled()) &&
lo_distance <= leash_distance &&
DistanceSquared(m_Position, lo_target->GetPosition()) <= leash_distance &&
(CheckLosFN(lo_target) || leash_owner->CheckLosFN(lo_target)) &&
IsAttackAllowed(lo_target))
{
AddToHateList(lo_target, 1);
if (HasPet() && (GetClass() != Class::Enchanter || GetPet()->GetPetType() != petAnimation || GetAA(aaAnimationEmpathy) >= 2)) {
GetPet()->AddToHateList(lo_target, 1);
GetPet()->SetTarget(lo_target);
}
}
}
void Bot::SetOwnerTarget(Client* bot_owner) {
if (GetPet() && PULLING_BOT) {
GetPet()->SetPetOrder(m_previous_pet_order);
@ -3155,22 +3027,6 @@ void Bot::BotPullerProcess(Client* bot_owner, Raid* raid) {
}
}
void Bot::SetBotGroupTarget(const Client* bot_owner, Client* leash_owner, float lo_distance, float leash_distance, Mob* const& bg_member, Mob* bgm_target) {
if (!bgm_target->IsMezzed() &&
((bot_owner->GetBotOption(Client::booAutoDefend) && bgm_target->GetHateAmount(bg_member)) || leash_owner->AutoAttackEnabled()) &&
lo_distance <= leash_distance &&
DistanceSquared(m_Position, bgm_target->GetPosition()) <= leash_distance &&
(CheckLosFN(bgm_target) || leash_owner->CheckLosFN(bgm_target)) &&
IsAttackAllowed(bgm_target))
{
AddToHateList(bgm_target, 1);
if (HasPet() && (GetClass() != Class::Enchanter || GetPet()->GetPetType() != petAnimation || GetAA(aaAnimationEmpathy) >= 2)) {
GetPet()->AddToHateList(bgm_target, 1);
GetPet()->SetTarget(bgm_target);
}
}
}
void Bot::Depop() {
WipeHateList();
entity_list.RemoveFromHateLists(this);

View File

@ -781,12 +781,15 @@ public:
Mob* SetFollowMob(Client* leash_owner);
Mob* GetBotTarget(Client* bot_owner);
void AcquireBotTarget(Group* bot_group, Raid* raid, Client* leash_owner, float leash_distance);
void SetBotTarget(Client* bot_owner, Raid* raid, Group* bot_group, Client* leash_owner, float lo_distance, float leash_distance, bool bo_alt_combat);
void SetLeashOwnerTarget(Client* leash_owner, Client* bot_owner, float lo_distance, float leash_distance);
void SetOwnerTarget(Client* bot_owner);
void SetBotGroupTarget(const Client* bot_owner, Client* leash_owner, float lo_distance, float leash_distance, Mob* const& bg_member, Mob* bgm_target);
bool IsValidTarget(Client* bot_owner, Client* leash_owner, float lo_distance, float leash_distance, bool bo_alt_combat, Mob* tar, float tar_distance);
bool IsValidTarget(
Client* bot_owner,
Client* leash_owner,
float lo_distance,
float leash_distance,
Mob* tar,
float tar_distance
);
bool PullingFlagChecks(Client* bot_owner);
bool ReturningFlagChecks(Client* bot_owner, float fm_distance);
@ -879,7 +882,6 @@ private:
int32 end_regen;
Timer m_evade_timer; // can be moved to pTimers at some point
Timer m_alt_combat_hate_timer;
Timer m_auto_defend_timer;
Timer auto_save_timer;
bool m_dirtyautohaters;

View File

@ -45,11 +45,6 @@ void bot_command_owner_option(Client *c, const Seperator *sep)
"<td><c \"#888888\">spawn with class-based message</td>"
"</tr>"
"<tr>"
"<td><c \"#CCCCCC\">altcombat</td>"
"<td><c \"#00CC00\">enable <c \"#CCCCCC\">| <c \"#00CC00\">disable</td>"
"<td><c \"#888888\">use alternate ai combat behavior</td>"
"</tr>"
"<tr>"
"<td></td>"
"<td><c \"#00CCCC\">null</td>"
"<td><c \"#888888\">(toggles)</td>"
@ -199,28 +194,6 @@ void bot_command_owner_option(Client *c, const Seperator *sep)
c->Message(Chat::White, "Bot 'spawn message' is now %s.", argument.c_str());
}
else if (!owner_option.compare("altcombat")) {
if (RuleB(Bots, AllowOwnerOptionAltCombat)) {
if (!argument.compare("enable")) {
c->SetBotOption(Client::booAltCombat, true);
}
else if (!argument.compare("disable")) {
c->SetBotOption(Client::booAltCombat, false);
}
else {
c->SetBotOption(Client::booAltCombat, !c->GetBotOption(Client::booAltCombat));
}
database.botdb.SaveOwnerOption(c->CharacterID(), Client::booAltCombat, c->GetBotOption(Client::booAltCombat));
c->Message(Chat::White, "Bot 'alt combat' is now %s.", (c->GetBotOption(Client::booAltCombat) ? "enabled" : "disabled"));
}
else {
c->Message(Chat::White, "Bot owner option 'altcombat' is not allowed on this server.");
}
}
else if (!owner_option.compare("autodefend")) {
if (RuleB(Bots, AllowOwnerOptionAutoDefend)) {
@ -292,7 +265,6 @@ void bot_command_owner_option(Client *c, const Seperator *sep)
"<tr>" "<td><c \"#CCCCCC\">statsupdate</td>" "<td><c \"#00CC00\">{}</td>" "</tr>"
"<tr>" "<td><c \"#CCCCCC\">spawnmessage</td>" "<td><c \"#00CC00\">{}</td>" "</tr>"
"<tr>" "<td><c \"#CCCCCC\">spawnmessage</td>" "<td><c \"#00CC00\">{}</td>" "</tr>"
"<tr>" "<td><c \"#CCCCCC\">altcombat</td>" "<td><c \"#00CC00\">{}</td>" "</tr>"
"<tr>" "<td><c \"#CCCCCC\">autodefend</td>" "<td><c \"#00CC00\">{}</td>" "</tr>"
"<tr>" "<td><c \"#CCCCCC\">buffcounter</td>" "<td><c \"#00CC00\">{}</td>" "</tr>"
"<tr>" "<td><c \"#CCCCCC\">monkwumessage</td>" "<td><c \"#00CC00\">{}</td>" "</tr>"
@ -301,7 +273,6 @@ void bot_command_owner_option(Client *c, const Seperator *sep)
(c->GetBotOption(Client::booStatsUpdate) ? "enabled" : "disabled"),
(c->GetBotOption(Client::booSpawnMessageSay) ? "say" : (c->GetBotOption(Client::booSpawnMessageTell) ? "tell" : "silent")),
(c->GetBotOption(Client::booSpawnMessageClassSpecific) ? "class" : "default"),
(RuleB(Bots, AllowOwnerOptionAltCombat) ? (c->GetBotOption(Client::booAltCombat) ? "enabled" : "disabled") : "restricted"),
(RuleB(Bots, AllowOwnerOptionAutoDefend) ? (c->GetBotOption(Client::booAutoDefend) ? "enabled" : "disabled") : "restricted"),
(c->GetBotOption(Client::booBuffCounter) ? "enabled" : "disabled"),
(c->GetBotOption(Client::booMonkWuMessage) ? "enabled" : "disabled")

View File

@ -1842,7 +1842,7 @@ bool BotDatabase::SaveOwnerOption(const uint32 owner_id, size_t type, const bool
Client::booDeathMarquee,
Client::booStatsUpdate,
Client::booSpawnMessageClassSpecific,
Client::booAltCombat,
Client::booUnused,
Client::booAutoDefend,
Client::booBuffCounter,
Client::booMonkWuMessage

View File

@ -370,7 +370,6 @@ Client::Client(EQStreamInterface *ieqs) : Mob(
bot_owner_options[booSpawnMessageSay] = false;
bot_owner_options[booSpawnMessageTell] = true;
bot_owner_options[booSpawnMessageClassSpecific] = true;
bot_owner_options[booAltCombat] = RuleB(Bots, AllowOwnerOptionAltCombat);
bot_owner_options[booAutoDefend] = RuleB(Bots, AllowOwnerOptionAutoDefend);
bot_owner_options[booBuffCounter] = false;
bot_owner_options[booMonkWuMessage] = false;
@ -537,7 +536,7 @@ void Client::SendZoneInPackets()
safe_delete(outapp);
if (IsInAGuild()) {
guild_mgr.UpdateDbMemberOnline(CharacterID(), true);
guild_mgr.UpdateDbMemberOnline(CharacterID(), true);
//SendGuildMembers();
SendGuildURL();
SendGuildChannel();
@ -747,7 +746,7 @@ bool Client::Save(uint8 iCommitNow) {
SetNextInvSnapshot(RuleI(Character, InvSnapshotMinRetryM));
}
}
database.SaveCharacterData(this, &m_pp, &m_epp); /* Save Character Data */
database.SaveCharacterEXPModifier(this);

View File

@ -2076,7 +2076,7 @@ public:
booSpawnMessageSay,
booSpawnMessageTell,
booSpawnMessageClassSpecific,
booAltCombat,
booUnused,
booAutoDefend,
booBuffCounter,
booMonkWuMessage,