Add pet option to ^taunt

No longer has toggle, required on/off option and an optional "pet" option to control pets' taunting state
This commit is contained in:
nytmyr
2024-12-24 08:07:13 -06:00
parent 5a000f1259
commit 8b7ffd7117
+158 -67
View File
@@ -1,32 +1,134 @@
#include "../bot_command.h" #include "../bot_command.h"
void bot_command_taunt(Client *c, const Seperator *sep) void bot_command_taunt(Client* c, const Seperator* sep)
{ {
if (helper_command_alias_fail(c, "bot_command_taunt", sep->arg[0], "taunt")) { if (helper_command_alias_fail(c, "bot_command_taunt", sep->arg[0], "taunt")) {
return; return;
} }
if (helper_is_help_or_usage(sep->arg[1])) { if (helper_is_help_or_usage(sep->arg[1])) {
c->Message(Chat::White, "usage: %s ([option: on | off]) ([actionable: target | byname | ownergroup | ownerraid | targetgroup | namesgroup | healrotationtargets | mmr | byclass | byrace | spawned] ([actionable_name]))", sep->arg[0]); std::vector<std::string> description =
{
"Allows you to turn on/off the taunting state of your bots and/or their pets"
};
std::vector<std::string> notes = { };
std::vector<std::string> example_format =
{
fmt::format(
"{} [on / off / pet] [optional: pet] [actionable, default: target]"
, sep->arg[0]
)
};
std::vector<std::string> examples_one =
{
"To turn off taunt on all bots:",
fmt::format(
"{} off spawned",
sep->arg[0]
)
};
std::vector<std::string> examples_two =
{
"To turn on taunt on all bots' pets:",
fmt::format(
"{} on pet spawned",
sep->arg[0]
)
};
std::vector<std::string> examples_three =
{
"To turn on taunt for all ShadowKnights:",
fmt::format(
"{} on byclass {}",
sep->arg[0],
Class::ShadowKnight
)
};
std::vector<std::string> actionables =
{
"target, byname, ownergroup, ownerraid, targetgroup, namesgroup, healrotationtargets, mmr, byclass, byrace, spawned"
};
std::vector<std::string> options = { };
std::vector<std::string> options_one = { };
std::vector<std::string> options_two = { };
std::vector<std::string> options_three = { };
std::string popup_text = c->SendCommandHelpWindow(
c,
description,
notes,
example_format,
examples_one, examples_two, examples_three,
actionables,
options,
options_one, options_two, options_three
);
popup_text = DialogueWindow::Table(popup_text);
c->SendPopupToClient(sep->arg[0], popup_text.c_str());
if (RuleB(Bots, SendClassRaceOnHelp)) {
c->Message(
Chat::Yellow,
fmt::format(
"Use {} for information about race/class IDs.",
Saylink::Silent("^classracelist")
).c_str()
);
}
return;
}
std::string arg1 = sep->arg[1];
std::string arg2 = sep->arg[2];
bool tauntState = false;
bool petTaunt = false;
bool validOption = false;
int ab_arg = 1;
if (!arg1.compare("on")) {
tauntState = true;
validOption = true;
++ab_arg;
}
else if (!arg1.compare("off")) {
validOption = true;
++ab_arg;
}
if (!arg2.compare("pet")) {
petTaunt = true;
validOption = true;
++ab_arg;
}
if (!validOption) {
c->Message(
Chat::Yellow,
fmt::format(
"Incorrect argument, use {} for information regarding this command.",
Saylink::Silent(
fmt::format("{} help", sep->arg[0])
)
).c_str()
);
return; return;
} }
const int ab_mask = ActionableBots::ABM_Type1; const int ab_mask = ActionableBots::ABM_Type1;
std::string actionableArg = sep->arg[ab_arg];
std::string arg1 = sep->arg[1]; if (actionableArg.empty()) {
actionableArg = "target";
bool taunt_state = false;
bool toggle_taunt = true;
int ab_arg = 1;
if (!arg1.compare("on")) {
taunt_state = true;
toggle_taunt = false;
++ab_arg;
}
else if (!arg1.compare("off")) {
toggle_taunt = false;
++ab_arg;
} }
std::string class_race_arg = sep->arg[ab_arg]; std::string class_race_arg = sep->arg[ab_arg];
@@ -38,25 +140,23 @@ void bot_command_taunt(Client *c, const Seperator *sep)
std::vector<Bot*> sbl; std::vector<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, actionableArg, 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.erase(std::remove(sbl.begin(), sbl.end(), nullptr), sbl.end()); sbl.erase(std::remove(sbl.begin(), sbl.end(), nullptr), sbl.end());
int taunting_count = 0; int botTauntingCount = 0;
for (auto bot_iter : sbl) { int petTauntingCount = 0;
if (!bot_iter->GetSkill(EQ::skills::SkillTaunt)) {
continue;
}
if (toggle_taunt) { if (!petTaunt) {
bot_iter->SetTaunting(!bot_iter->IsTaunting()); for (auto bot_iter : sbl) {
} else { if (!bot_iter->GetSkill(EQ::skills::SkillTaunt)) {
bot_iter->SetTaunting(taunt_state); continue;
} }
bot_iter->SetTaunting(tauntState);
if (sbl.size() == 1) {
Bot::BotGroupSay( Bot::BotGroupSay(
bot_iter, bot_iter,
fmt::format( fmt::format(
@@ -64,27 +164,23 @@ void bot_command_taunt(Client *c, const Seperator *sep)
bot_iter->IsTaunting() ? "now" : "no longer" bot_iter->IsTaunting() ? "now" : "no longer"
).c_str() ).c_str()
); );
}
++taunting_count; ++botTauntingCount;
}
} }
for (auto bot_iter : sbl) { if (petTaunt) {
if (!bot_iter->HasPet()) { for (auto bot_iter : sbl) {
continue; if (!bot_iter->HasPet()) {
} continue;
}
if (!bot_iter->GetPet()->GetSkill(EQ::skills::SkillTaunt)) { if (!bot_iter->GetPet()->GetSkill(EQ::skills::SkillTaunt)) {
continue; continue;
} }
if (toggle_taunt) { bot_iter->GetPet()->CastToNPC()->SetTaunting(tauntState);
bot_iter->GetPet()->CastToNPC()->SetTaunting(!bot_iter->GetPet()->CastToNPC()->IsTaunting());
} else {
bot_iter->GetPet()->CastToNPC()->SetTaunting(taunt_state);
}
if (sbl.size() == 1) {
Bot::BotGroupSay( Bot::BotGroupSay(
bot_iter, bot_iter,
fmt::format( fmt::format(
@@ -92,34 +188,29 @@ void bot_command_taunt(Client *c, const Seperator *sep)
bot_iter->GetPet()->CastToNPC()->IsTaunting() ? "now" : "no longer" bot_iter->GetPet()->CastToNPC()->IsTaunting() ? "now" : "no longer"
).c_str() ).c_str()
); );
}
++taunting_count; ++petTauntingCount;
}
} }
if (taunting_count) { if (botTauntingCount || petTauntingCount) {
if (toggle_taunt) { c->Message(
c->Message( Chat::Green,
Chat::White, fmt::format(
fmt::format( "{} of your {} are {} taunting.",
"{} of your bots and their pets {} toggled their taunting state", (botTauntingCount ? botTauntingCount : petTauntingCount),
taunting_count, (botTauntingCount ? "bots" : "bots' pets"),
taunting_count != 1 ? "have" : "has" tauntState ? "now" : "no longer"
).c_str() ).c_str()
); );
} else {
c->Message(
Chat::White,
fmt::format(
"{} of your bots and their pets {} {} taunting.",
taunting_count,
taunting_count != 1 ? "have" : "has",
taunt_state ? "started" : "stopped"
).c_str()
);
}
} }
else { else {
c->Message(Chat::White, "None of your bots are capable of taunting"); c->Message(
Chat::Yellow,
fmt::format(
"None of your {} are capable of taunting.",
!petTaunt ? "bots" : "bots' pets"
).c_str()
);
} }
} }