Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bot Commands] Separate Bot Commands into Individual Files #4035

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,830 changes: 569 additions & 9,261 deletions zone/bot_command.cpp

Large diffs are not rendered by default.

1,343 changes: 1,215 additions & 128 deletions zone/bot_command.h

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions zone/bot_commands/actionable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "../bot_command.h"

void bot_command_actionable(Client* c, const Seperator* sep)
{
if (helper_command_alias_fail(c, "bot_command_actionable", sep->arg[0], "actionable")) {
return;
}

c->Message(Chat::White, "Actionable command arguments:");
c->Message(Chat::White, "target - selects target as single bot .. use ^command [target] or imply by empty actionable argument");
c->Message(Chat::White, "byname [name] - selects single bot by name");
c->Message(Chat::White, "ownergroup - selects all bots in the owner's group");
c->Message(Chat::White, "ownerraid - selects all bots in the owner's raid");
c->Message(Chat::White, "targetgroup - selects all bots in target's group");
c->Message(Chat::White, "namesgroup [name] - selects all bots in name's group");
c->Message(Chat::White, "healrotation [name] - selects all member and target bots of a heal rotation where name is a member");
c->Message(Chat::White, "healrotationmembers [name] - selects all member bots of a heal rotation where name is a member");
c->Message(Chat::White, "healrotationtargets [name] - selects all target bots of a heal rotation where name is a member");
c->Message(Chat::White, "byclass - selects all bots of the chosen class");
c->Message(Chat::White, "byrace - selects all bots of the chosen rsce");
c->Message(Chat::White, "spawned - selects all spawned bots");
c->Message(Chat::White, "all - selects all spawned bots .. argument use indicates en masse database updating");
c->Message(Chat::White, "You may only select your bots as actionable");
}
91 changes: 91 additions & 0 deletions zone/bot_commands/aggressive.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include "../bot_command.h"

void bot_command_aggressive(Client* c, const Seperator* sep)
{
bcst_list* local_list = &bot_command_spells[BCEnum::SpT_Stance];
if (helper_spell_list_fail(c, local_list, BCEnum::SpT_Stance) ||
helper_command_alias_fail(c, "bot_command_aggressive", sep->arg[0], "aggressive")) {
return;
}
if (helper_is_help_or_usage(sep->arg[1])) {
c->Message(
Chat::White,
"usage: %s ([actionable: target | byname | ownergroup | ownerraid | targetgroup | namesgroup | healrotationtargets | byclass | byrace | spawned] ([actionable_name]))",
sep->arg[0]
);
helper_send_usage_required_bots(c, BCEnum::SpT_Stance);
return;
}
const int ab_mask = ActionableBots::ABM_Type1;

std::string class_race_arg = sep->arg[1];
bool class_race_check = false;
if (!class_race_arg.compare("byclass") || !class_race_arg.compare("byrace")) {
class_race_check = true;
}

std::list<Bot*> sbl;
if (ActionableBots::PopulateSBL(
c,
sep->arg[1],
sbl,
ab_mask,
!class_race_check ? sep->arg[2] : nullptr,
class_race_check ? atoi(sep->arg[2]) : 0
) == ActionableBots::ABT_None) {
return;
}

sbl.remove(nullptr);

int success_count = 0;
int candidate_count = sbl.size();
for (auto list_iter: *local_list) {
if (sbl.empty()) {
break;
}

auto local_entry = list_iter->SafeCastToStance();
if (helper_spell_check_fail(local_entry)) {
continue;
}
if (local_entry->stance_type != BCEnum::StT_Aggressive) {
continue;
}

for (auto bot_iter = sbl.begin(); bot_iter != sbl.end();) {
Bot* my_bot = *bot_iter;
if (local_entry->caster_class != my_bot->GetClass()) {
++bot_iter;
continue;
}
if (local_entry->spell_level > my_bot->GetLevel()) {
++bot_iter;
continue;
}

my_bot->InterruptSpell();
if (candidate_count == 1) {
Bot::BotGroupSay(
my_bot,
fmt::format(
"Using {}.",
spells[local_entry->spell_id].name
).c_str()
);
}

my_bot->UseDiscipline(local_entry->spell_id, my_bot->GetID());
++success_count;

bot_iter = sbl.erase(bot_iter);
}
}

c->Message(
Chat::White,
"%i of %i bots have attempted to use aggressive disciplines",
success_count,
candidate_count
);
}
Loading