From 0c9c78fbab55463b5c61d02ab182ec3a48c7002c Mon Sep 17 00:00:00 2001 From: Aeadoin <109764533+Aeadoin@users.noreply.github.com> Date: Fri, 30 Dec 2022 17:18:05 -0500 Subject: [PATCH] [Bot Commands] Toggle Enforce Spell Settings (#2682) * [Bot Commands] Toggle enforcespellsettings * Cleanup * Update bot_command.cpp Co-authored-by: Alex King <89047260+Kinglykrab@users.noreply.github.com> --- zone/bot.h | 1 + zone/bot_command.cpp | 13 ++++--------- zone/bot_structs.h | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/zone/bot.h b/zone/bot.h index e76dbe1c1..0865b26fa 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -638,6 +638,7 @@ public: void LoadBotSpellSettings(); bool UpdateBotSpellSetting(uint16 spell_id, BotSpellSetting* bs); void SetBotEnforceSpellSetting(bool enforcespellsettings, bool save = false); + bool GetBotEnforceSpellSetting() const { return m_enforce_spell_settings; } static void SpawnBotGroupByName(Client* c, std::string botgroup_name, uint32 leader_id); diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 331deaecd..2338e3de5 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -10782,7 +10782,7 @@ void bot_command_enforce_spell_list(Client* c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Usage: {} [True/False]", + "Usage: {} [True|False] (Blank to toggle]", sep->arg[0] ).c_str() ); @@ -10795,20 +10795,15 @@ void bot_command_enforce_spell_list(Client* c, const Seperator *sep) return; } - bool toggle = ( - sep->IsNumber(1) ? - (std::stoi(sep->arg[1]) ? true : false) : - atobool(sep->arg[1]) - ); - - my_bot->SetBotEnforceSpellSetting(toggle, true); + bool enforce_state = (sep->argnum > 0) ? Strings::ToBool(sep->arg[1]) : !my_bot->GetBotEnforceSpellSetting(); + my_bot->SetBotEnforceSpellSetting(enforce_state, true); c->Message( Chat::White, fmt::format( "{}'s Spell Settings List entries are now {}.", my_bot->GetCleanName(), - toggle ? "enforced" : "optional" + my_bot->GetBotEnforceSpellSetting() ? "enforced" : "optional" ).c_str() ); } diff --git a/zone/bot_structs.h b/zone/bot_structs.h index 15c135a17..f0943df70 100644 --- a/zone/bot_structs.h +++ b/zone/bot_structs.h @@ -85,7 +85,7 @@ struct BotSpellSetting { uint8 max_level; int8 min_hp; int8 max_hp; - bool is_enabled; + bool is_enabled = true; }; struct BotSpells_Struct {