[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>
This commit is contained in:
Aeadoin 2022-12-30 17:18:05 -05:00 committed by GitHub
parent 8fc665a3c1
commit 0c9c78fbab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 10 deletions

View File

@ -638,6 +638,7 @@ public:
void LoadBotSpellSettings(); void LoadBotSpellSettings();
bool UpdateBotSpellSetting(uint16 spell_id, BotSpellSetting* bs); bool UpdateBotSpellSetting(uint16 spell_id, BotSpellSetting* bs);
void SetBotEnforceSpellSetting(bool enforcespellsettings, bool save = false); 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); static void SpawnBotGroupByName(Client* c, std::string botgroup_name, uint32 leader_id);

View File

@ -10782,7 +10782,7 @@ void bot_command_enforce_spell_list(Client* c, const Seperator *sep)
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
"Usage: {} [True/False]", "Usage: {} [True|False] (Blank to toggle]",
sep->arg[0] sep->arg[0]
).c_str() ).c_str()
); );
@ -10795,20 +10795,15 @@ void bot_command_enforce_spell_list(Client* c, const Seperator *sep)
return; return;
} }
bool toggle = ( bool enforce_state = (sep->argnum > 0) ? Strings::ToBool(sep->arg[1]) : !my_bot->GetBotEnforceSpellSetting();
sep->IsNumber(1) ? my_bot->SetBotEnforceSpellSetting(enforce_state, true);
(std::stoi(sep->arg[1]) ? true : false) :
atobool(sep->arg[1])
);
my_bot->SetBotEnforceSpellSetting(toggle, true);
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
"{}'s Spell Settings List entries are now {}.", "{}'s Spell Settings List entries are now {}.",
my_bot->GetCleanName(), my_bot->GetCleanName(),
toggle ? "enforced" : "optional" my_bot->GetBotEnforceSpellSetting() ? "enforced" : "optional"
).c_str() ).c_str()
); );
} }

View File

@ -85,7 +85,7 @@ struct BotSpellSetting {
uint8 max_level; uint8 max_level;
int8 min_hp; int8 min_hp;
int8 max_hp; int8 max_hp;
bool is_enabled; bool is_enabled = true;
}; };
struct BotSpells_Struct { struct BotSpells_Struct {