add passive stance checks to commands and loading/saving. shouldn't be `

This commit is contained in:
nytmyr
2024-11-09 22:00:20 -06:00
parent aa29f6e001
commit 7d670e674d
25 changed files with 132 additions and 12 deletions
+18 -1
View File
@@ -9833,7 +9833,6 @@ bool Bot::IsMobEngagedByAnyone(Mob* tar) {
if (m->GetTarget() == tar) { if (m->GetTarget() == tar) {
if ( if (
m->IsBot() && m->IsBot() &&
!m->CastToBot()->GetHoldFlag() &&
m->IsEngaged() && m->IsEngaged() &&
( (
!m->CastToBot()->IsBotNonSpellFighter() || !m->CastToBot()->IsBotNonSpellFighter() ||
@@ -11421,3 +11420,21 @@ void Bot::ResetBotSpellSettings()
AI_AddBotSpells(GetBotSpellID()); AI_AddBotSpells(GetBotSpellID());
SetBotEnforceSpellSetting(false); 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;
}
+1
View File
@@ -497,6 +497,7 @@ public:
void SetSpellTypeMaxHPLimit(uint16 spellType, uint8 hpLimit); void SetSpellTypeMaxHPLimit(uint16 spellType, uint8 hpLimit);
inline uint16 GetSpellTypeAEOrGroupTargetCount(uint16 spellType) const { return _spellSettings[spellType].AEOrGroupTargetCount; } inline uint16 GetSpellTypeAEOrGroupTargetCount(uint16 spellType) const { return _spellSettings[spellType].AEOrGroupTargetCount; }
void SetSpellTypeAEOrGroupTargetCount(uint16 spellType, uint16 targetCount); void SetSpellTypeAEOrGroupTargetCount(uint16 spellType, uint16 targetCount);
bool BotPassiveCheck();
bool GetShowHelm() const { return _showHelm; } bool GetShowHelm() const { return _showHelm; }
void SetShowHelm(bool showHelm) { _showHelm = showHelm; } void SetShowHelm(bool showHelm) { _showHelm = showHelm; }
+5
View File
@@ -130,9 +130,14 @@ void bot_command_behind_mob(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+1 -9
View File
@@ -1440,7 +1440,6 @@ void bot_command_stop_melee_level(Client* c, const Seperator* sep)
if (helper_is_help_or_usage(sep->arg[1])) { 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, "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 [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"); c->Message(Chat::White, "note: Use [sync] to set stop melee level to current bot level");
return; return;
@@ -1508,14 +1507,7 @@ void bot_command_stop_melee_level(Client* c, const Seperator* sep)
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (!IsCasterClass(my_bot->GetClass()) && !IsHybridClass(my_bot->GetClass())) { if (my_bot->BotPassiveCheck()) {
c->Message(
Chat::White,
fmt::format(
"{} says, 'This command only works on caster or hybrid classes.'",
my_bot->GetCleanName()
).c_str()
);
continue; continue;
} }
+1 -1
View File
@@ -234,7 +234,7 @@ void bot_command_cast(Client* c, const Seperator* sep)
NEED TO CHECK: precombat, AE Dispel, AE Lifetap NEED TO CHECK: precombat, AE Dispel, AE Lifetap
DO I NEED A PBAE CHECK??? 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; continue;
} }
+6
View File
@@ -40,12 +40,18 @@ void bot_command_click_item(Client* c, const Seperator* sep)
} }
std::list<Bot*> sbl; std::list<Bot*> 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) { 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; return;
} }
sbl.remove(nullptr); sbl.remove(nullptr);
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (RuleI(Bots, BotsClickItemsMinLvl) > my_bot->GetLevel()) { 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)); c->Message(Chat::White, "%s must be level %i to use clickable items.", my_bot->GetCleanName(), RuleI(Bots, BotsClickItemsMinLvl));
continue; continue;
+4
View File
@@ -57,6 +57,10 @@ void bot_command_distance_ranged(Client* c, const Seperator* sep)
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
+5
View File
@@ -130,9 +130,14 @@ void bot_command_illusion_block(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -129,9 +129,14 @@ void bot_command_max_melee_range(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -129,9 +129,14 @@ void bot_command_sit_hp_percent(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -129,9 +129,14 @@ void bot_command_sit_in_combat(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -129,9 +129,14 @@ void bot_command_sit_mana_percent(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -190,9 +190,14 @@ void bot_command_spell_aggro_checks(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -196,9 +196,14 @@ void bot_command_spell_delays(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
@@ -194,9 +194,14 @@ void bot_command_spell_engaged_priority(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
@@ -194,9 +194,14 @@ void bot_command_spell_idle_priority(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -190,9 +190,14 @@ void bot_command_spell_max_hp_pct(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -190,9 +190,14 @@ void bot_command_spell_max_mana_pct(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
@@ -196,9 +196,14 @@ void bot_command_spell_max_thresholds(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -190,9 +190,14 @@ void bot_command_spell_min_hp_pct(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -190,9 +190,14 @@ void bot_command_spell_min_mana_pct(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
@@ -198,9 +198,14 @@ void bot_command_spell_min_thresholds(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
@@ -194,9 +194,14 @@ void bot_command_spell_pursue_priority(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+5
View File
@@ -190,9 +190,14 @@ void bot_command_spell_target_count(Client* c, const Seperator* sep)
Bot* first_found = nullptr; Bot* first_found = nullptr;
int success_count = 0; int success_count = 0;
for (auto my_bot : sbl) { for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) { if (!first_found) {
first_found = my_bot; first_found = my_bot;
} }
if (current_check) { if (current_check) {
c->Message( c->Message(
Chat::Green, Chat::Green,
+10
View File
@@ -2222,6 +2222,11 @@ bool BotDatabase::LoadBotSettings(Mob* m)
query = fmt::format("`bot_id` = {} AND `stance` = {}", mobID, stanceID); 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); const auto& l = BotSettingsRepository::GetWhere(database, query);
if (l.empty()) { if (l.empty()) {
@@ -2268,6 +2273,11 @@ bool BotDatabase::SaveBotSettings(Mob* m)
uint32 charID = (m->IsClient() ? m->CastToClient()->CharacterID() : 0); uint32 charID = (m->IsClient() ? m->CastToClient()->CharacterID() : 0);
uint8 stanceID = (m->IsBot() ? m->CastToBot()->GetBotStance() : 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 = ""; std::string query = "";
if (m->IsClient()) { if (m->IsClient()) {