From 7d670e674ddebab1602392a973757388c807a6be Mon Sep 17 00:00:00 2001 From: nytmyr <53322305+nytmyr@users.noreply.github.com> Date: Sat, 9 Nov 2024 22:00:20 -0600 Subject: [PATCH] add passive stance checks to commands and loading/saving. shouldn't be ` --- zone/bot.cpp | 19 ++++++++++++++++++- zone/bot.h | 3 ++- zone/bot_commands/behind_mob.cpp | 5 +++++ zone/bot_commands/bot.cpp | 10 +--------- zone/bot_commands/cast.cpp | 2 +- zone/bot_commands/click_item.cpp | 6 ++++++ zone/bot_commands/distance_ranged.cpp | 4 ++++ zone/bot_commands/illusion_block.cpp | 5 +++++ zone/bot_commands/max_melee_range.cpp | 5 +++++ zone/bot_commands/sit_hp_percent.cpp | 5 +++++ zone/bot_commands/sit_in_combat.cpp | 5 +++++ zone/bot_commands/sit_mana_percent.cpp | 5 +++++ zone/bot_commands/spell_aggro_checks.cpp | 5 +++++ zone/bot_commands/spell_delays.cpp | 5 +++++ zone/bot_commands/spell_engaged_priority.cpp | 5 +++++ zone/bot_commands/spell_idle_priority.cpp | 5 +++++ zone/bot_commands/spell_max_hp_pct.cpp | 5 +++++ zone/bot_commands/spell_max_mana_pct.cpp | 5 +++++ zone/bot_commands/spell_max_thresholds.cpp | 5 +++++ zone/bot_commands/spell_min_hp_pct.cpp | 5 +++++ zone/bot_commands/spell_min_mana_pct.cpp | 5 +++++ zone/bot_commands/spell_min_thresholds.cpp | 5 +++++ zone/bot_commands/spell_pursue_priority.cpp | 5 +++++ zone/bot_commands/spell_target_count.cpp | 5 +++++ zone/bot_database.cpp | 10 ++++++++++ 25 files changed, 132 insertions(+), 12 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 0e3e2811f..8b997f4bf 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -9833,7 +9833,6 @@ bool Bot::IsMobEngagedByAnyone(Mob* tar) { if (m->GetTarget() == tar) { if ( m->IsBot() && - !m->CastToBot()->GetHoldFlag() && m->IsEngaged() && ( !m->CastToBot()->IsBotNonSpellFighter() || @@ -11421,3 +11420,21 @@ void Bot::ResetBotSpellSettings() AI_AddBotSpells(GetBotSpellID()); SetBotEnforceSpellSetting(false); } + +bool Bot::BotPassiveCheck() { + if (GetBotStance() == Stance::Passive) { + GetOwner()->Message( + Chat::Yellow, + fmt::format( + "{} says, 'I am currently set to stance {} [#{}]. My settings cannot be modified.'", + GetCleanName(), + Stance::GetName(Stance::Passive), + Stance::Passive + ).c_str() + ); + + return true; + } + + return false; +} diff --git a/zone/bot.h b/zone/bot.h index a2e0a8ffb..e0d857880 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -497,7 +497,8 @@ public: void SetSpellTypeMaxHPLimit(uint16 spellType, uint8 hpLimit); inline uint16 GetSpellTypeAEOrGroupTargetCount(uint16 spellType) const { return _spellSettings[spellType].AEOrGroupTargetCount; } void SetSpellTypeAEOrGroupTargetCount(uint16 spellType, uint16 targetCount); - + bool BotPassiveCheck(); + bool GetShowHelm() const { return _showHelm; } void SetShowHelm(bool showHelm) { _showHelm = showHelm; } bool GetBehindMob() const { return _behindMobStatus; } diff --git a/zone/bot_commands/behind_mob.cpp b/zone/bot_commands/behind_mob.cpp index 8e6915860..a7710185f 100644 --- a/zone/bot_commands/behind_mob.cpp +++ b/zone/bot_commands/behind_mob.cpp @@ -130,9 +130,14 @@ void bot_command_behind_mob(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/bot.cpp b/zone/bot_commands/bot.cpp index d867b4e67..ba0ae10dc 100644 --- a/zone/bot_commands/bot.cpp +++ b/zone/bot_commands/bot.cpp @@ -1440,7 +1440,6 @@ void bot_command_stop_melee_level(Client* c, const Seperator* sep) if (helper_is_help_or_usage(sep->arg[1])) { c->Message(Chat::White, "usage: %s [current | reset | sync | value: 0-255] ([actionable: target | byname | ownergroup | ownerraid | targetgroup | namesgroup | mmr | byclass | byrace | spawned] ([actionable_name]))", sep->arg[0]); - c->Message(Chat::White, "note: Only caster or hybrid class bots may be modified"); c->Message(Chat::White, "note: Use [reset] to set stop melee level to server rule"); c->Message(Chat::White, "note: Use [sync] to set stop melee level to current bot level"); return; @@ -1508,14 +1507,7 @@ void bot_command_stop_melee_level(Client* c, const Seperator* sep) int success_count = 0; for (auto my_bot : sbl) { - if (!IsCasterClass(my_bot->GetClass()) && !IsHybridClass(my_bot->GetClass())) { - c->Message( - Chat::White, - fmt::format( - "{} says, 'This command only works on caster or hybrid classes.'", - my_bot->GetCleanName() - ).c_str() - ); + if (my_bot->BotPassiveCheck()) { continue; } diff --git a/zone/bot_commands/cast.cpp b/zone/bot_commands/cast.cpp index 70b6e659c..fd7dc5aa8 100644 --- a/zone/bot_commands/cast.cpp +++ b/zone/bot_commands/cast.cpp @@ -234,7 +234,7 @@ void bot_command_cast(Client* c, const Seperator* sep) NEED TO CHECK: precombat, AE Dispel, AE Lifetap DO I NEED A PBAE CHECK??? */ - if (bot_iter->GetHoldFlag() || bot_iter->GetAppearance() == eaDead || bot_iter->IsFeared() || bot_iter->IsStunned() || bot_iter->IsMezzed() || bot_iter->DivineAura() || bot_iter->GetHP() < 0) { + if (bot_iter->GetBotStance() == Stance::Passive || bot_iter->GetHoldFlag() || bot_iter->GetAppearance() == eaDead || bot_iter->IsFeared() || bot_iter->IsStunned() || bot_iter->IsMezzed() || bot_iter->DivineAura() || bot_iter->GetHP() < 0) { continue; } diff --git a/zone/bot_commands/click_item.cpp b/zone/bot_commands/click_item.cpp index 80375b52c..469750f59 100644 --- a/zone/bot_commands/click_item.cpp +++ b/zone/bot_commands/click_item.cpp @@ -40,12 +40,18 @@ void bot_command_click_item(Client* c, const Seperator* sep) } std::list sbl; + if (ActionableBots::PopulateSBL(c, sep->arg[ab_arg], sbl, ab_mask, !class_race_check ? sep->arg[ab_arg + 1] : nullptr, class_race_check ? atoi(sep->arg[ab_arg + 1]) : 0) == ActionableBots::ABT_None) { return; } + sbl.remove(nullptr); for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (RuleI(Bots, BotsClickItemsMinLvl) > my_bot->GetLevel()) { c->Message(Chat::White, "%s must be level %i to use clickable items.", my_bot->GetCleanName(), RuleI(Bots, BotsClickItemsMinLvl)); continue; diff --git a/zone/bot_commands/distance_ranged.cpp b/zone/bot_commands/distance_ranged.cpp index 70d5e655b..7c7dec82a 100644 --- a/zone/bot_commands/distance_ranged.cpp +++ b/zone/bot_commands/distance_ranged.cpp @@ -57,6 +57,10 @@ void bot_command_distance_ranged(Client* c, const Seperator* sep) int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } diff --git a/zone/bot_commands/illusion_block.cpp b/zone/bot_commands/illusion_block.cpp index e44ddf601..94faafc42 100644 --- a/zone/bot_commands/illusion_block.cpp +++ b/zone/bot_commands/illusion_block.cpp @@ -130,9 +130,14 @@ void bot_command_illusion_block(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/max_melee_range.cpp b/zone/bot_commands/max_melee_range.cpp index e876a9759..c9e32dec1 100644 --- a/zone/bot_commands/max_melee_range.cpp +++ b/zone/bot_commands/max_melee_range.cpp @@ -129,9 +129,14 @@ void bot_command_max_melee_range(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/sit_hp_percent.cpp b/zone/bot_commands/sit_hp_percent.cpp index ac94a13fd..fa4a183bf 100644 --- a/zone/bot_commands/sit_hp_percent.cpp +++ b/zone/bot_commands/sit_hp_percent.cpp @@ -129,9 +129,14 @@ void bot_command_sit_hp_percent(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/sit_in_combat.cpp b/zone/bot_commands/sit_in_combat.cpp index ffcf4d887..210372f56 100644 --- a/zone/bot_commands/sit_in_combat.cpp +++ b/zone/bot_commands/sit_in_combat.cpp @@ -129,9 +129,14 @@ void bot_command_sit_in_combat(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/sit_mana_percent.cpp b/zone/bot_commands/sit_mana_percent.cpp index 85afc8047..a5751f9f4 100644 --- a/zone/bot_commands/sit_mana_percent.cpp +++ b/zone/bot_commands/sit_mana_percent.cpp @@ -129,9 +129,14 @@ void bot_command_sit_mana_percent(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_aggro_checks.cpp b/zone/bot_commands/spell_aggro_checks.cpp index e9ae709ee..2dfeef486 100644 --- a/zone/bot_commands/spell_aggro_checks.cpp +++ b/zone/bot_commands/spell_aggro_checks.cpp @@ -190,9 +190,14 @@ void bot_command_spell_aggro_checks(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_delays.cpp b/zone/bot_commands/spell_delays.cpp index 3c3b153ca..2a5de1017 100644 --- a/zone/bot_commands/spell_delays.cpp +++ b/zone/bot_commands/spell_delays.cpp @@ -196,9 +196,14 @@ void bot_command_spell_delays(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_engaged_priority.cpp b/zone/bot_commands/spell_engaged_priority.cpp index 89d76f2b5..70425ee11 100644 --- a/zone/bot_commands/spell_engaged_priority.cpp +++ b/zone/bot_commands/spell_engaged_priority.cpp @@ -194,9 +194,14 @@ void bot_command_spell_engaged_priority(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_idle_priority.cpp b/zone/bot_commands/spell_idle_priority.cpp index 566a3f46a..d6f0a0c35 100644 --- a/zone/bot_commands/spell_idle_priority.cpp +++ b/zone/bot_commands/spell_idle_priority.cpp @@ -194,9 +194,14 @@ void bot_command_spell_idle_priority(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_max_hp_pct.cpp b/zone/bot_commands/spell_max_hp_pct.cpp index 9d94fd722..7f8cd150b 100644 --- a/zone/bot_commands/spell_max_hp_pct.cpp +++ b/zone/bot_commands/spell_max_hp_pct.cpp @@ -190,9 +190,14 @@ void bot_command_spell_max_hp_pct(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_max_mana_pct.cpp b/zone/bot_commands/spell_max_mana_pct.cpp index 9e22617b0..44cc7e8d5 100644 --- a/zone/bot_commands/spell_max_mana_pct.cpp +++ b/zone/bot_commands/spell_max_mana_pct.cpp @@ -190,9 +190,14 @@ void bot_command_spell_max_mana_pct(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_max_thresholds.cpp b/zone/bot_commands/spell_max_thresholds.cpp index 3b4e0e85f..7ff651514 100644 --- a/zone/bot_commands/spell_max_thresholds.cpp +++ b/zone/bot_commands/spell_max_thresholds.cpp @@ -196,9 +196,14 @@ void bot_command_spell_max_thresholds(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_min_hp_pct.cpp b/zone/bot_commands/spell_min_hp_pct.cpp index 739ab0d1c..371b44820 100644 --- a/zone/bot_commands/spell_min_hp_pct.cpp +++ b/zone/bot_commands/spell_min_hp_pct.cpp @@ -190,9 +190,14 @@ void bot_command_spell_min_hp_pct(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_min_mana_pct.cpp b/zone/bot_commands/spell_min_mana_pct.cpp index e83362f76..b053c462c 100644 --- a/zone/bot_commands/spell_min_mana_pct.cpp +++ b/zone/bot_commands/spell_min_mana_pct.cpp @@ -190,9 +190,14 @@ void bot_command_spell_min_mana_pct(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_min_thresholds.cpp b/zone/bot_commands/spell_min_thresholds.cpp index 6df8fc999..d690dede2 100644 --- a/zone/bot_commands/spell_min_thresholds.cpp +++ b/zone/bot_commands/spell_min_thresholds.cpp @@ -198,9 +198,14 @@ void bot_command_spell_min_thresholds(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_pursue_priority.cpp b/zone/bot_commands/spell_pursue_priority.cpp index 593606437..872444f32 100644 --- a/zone/bot_commands/spell_pursue_priority.cpp +++ b/zone/bot_commands/spell_pursue_priority.cpp @@ -194,9 +194,14 @@ void bot_command_spell_pursue_priority(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_commands/spell_target_count.cpp b/zone/bot_commands/spell_target_count.cpp index f87e232ee..2f78a7468 100644 --- a/zone/bot_commands/spell_target_count.cpp +++ b/zone/bot_commands/spell_target_count.cpp @@ -190,9 +190,14 @@ void bot_command_spell_target_count(Client* c, const Seperator* sep) Bot* first_found = nullptr; int success_count = 0; for (auto my_bot : sbl) { + if (my_bot->BotPassiveCheck()) { + continue; + } + if (!first_found) { first_found = my_bot; } + if (current_check) { c->Message( Chat::Green, diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index e60a17961..3f42d995d 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -2221,6 +2221,11 @@ bool BotDatabase::LoadBotSettings(Mob* m) else { query = fmt::format("`bot_id` = {} AND `stance` = {}", mobID, stanceID); } + + if (stanceID == Stance::Passive) { + LogBotSettings("{} is currently set to {} [#{}]. No saving or loading required.", m->GetCleanName(), Stance::GetName(Stance::Passive), Stance::Passive); + return true; + } const auto& l = BotSettingsRepository::GetWhere(database, query); @@ -2268,6 +2273,11 @@ bool BotDatabase::SaveBotSettings(Mob* m) uint32 charID = (m->IsClient() ? m->CastToClient()->CharacterID() : 0); uint8 stanceID = (m->IsBot() ? m->CastToBot()->GetBotStance() : 0); + if (stanceID == Stance::Passive) { + LogBotSettings("{} is currently set to {} [#{}]. No saving or loading required.", m->GetCleanName(), Stance::GetName(Stance::Passive), Stance::Passive); + return true; + } + std::string query = ""; if (m->IsClient()) {