Implement ^spellannouncecasts to toggle announcing casts of spell types

This commit is contained in:
nytmyr
2025-01-31 14:31:48 -06:00
parent bf8a576003
commit bd97453852
12 changed files with 461 additions and 116 deletions
+3 -1
View File
@@ -19,7 +19,8 @@ void bot_command_bot_settings(Client* c, const Seperator* sep)
"sithppercent",
"sitincombat",
"sitmanapercent",
"spellaggrocheck",
"spellaggrochecks",
"spellannouncecasts",
"spelldelays",
"spellengagedpriority",
"spellholds",
@@ -31,6 +32,7 @@ void bot_command_bot_settings(Client* c, const Seperator* sep)
"spellminmanapct",
"spellminthresholds",
"spellpursuepriority",
"spellresistlimits",
"spelltargetcount",
"spelllist",
"stance",
+13 -4
View File
@@ -52,7 +52,7 @@ void bot_command_copy_settings(Client* c, const Seperator* sep)
),
};
p.actionables = { "target, byname, ownergroup, ownerraid, targetgroup, namesgroup, healrotationtargets, mmr, byclass, byrace, spawned" };
p.options = { "all, misc, spellsettings, spelltypesettings, spellholds, spelldelays, spellminthresholds, spellmaxthresholds, spellminmanapct, spellmaxmanapct, spellminhppct, spellmaxhppct, spellidlepriority, spellengagedpriority, spellpursuepriority, spellaggrochecks, spelltargetcounts, spellresistlimits, blockedbuffs, blockedpetbuffs" };
p.options = { "all, misc, spellsettings, spelltypesettings, spellholds, spelldelays, spellminthresholds, spellmaxthresholds, spellminmanapct, spellmaxmanapct, spellminhppct, spellmaxhppct, spellidlepriority, spellengagedpriority, spellpursuepriority, spellaggrochecks, spelltargetcounts, spellresistlimits, spellannouncecasts, blockedbuffs, blockedpetbuffs" };
p.options_one =
{
"[spellsettings] will copy ^spellsettings options",
@@ -111,6 +111,7 @@ void bot_command_copy_settings(Client* c, const Seperator* sep)
"spellaggrochecks",
"spelltargetcounts",
"spellresistlimits",
"spellannouncecasts",
"blockedbuffs",
"blockedpetbuffs"
};
@@ -255,14 +256,16 @@ void bot_command_copy_settings(Client* c, const Seperator* sep)
from->CopySettings(to, BotSettingCategories::SpellMinThreshold, spell_type);
from->CopySettings(to, BotSettingCategories::SpellMaxThreshold, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeAggroCheck, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeResistLimit, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeMinManaPct, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeMaxManaPct, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeMinHPPct, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeMaxHPPct, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeIdlePriority, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeEngagedPriority, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypePursuePriority, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypePursuePriority, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeAEOrGroupTargetCount, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeAnnounceCast, spell_type);
}
else {
for (uint16 i = BotSpellTypes::START; i <= BotSpellTypes::END; ++i) {
@@ -271,14 +274,16 @@ void bot_command_copy_settings(Client* c, const Seperator* sep)
from->CopySettings(to, BotSettingCategories::SpellMinThreshold, i);
from->CopySettings(to, BotSettingCategories::SpellMaxThreshold, i);
from->CopySettings(to, BotSettingCategories::SpellTypeAggroCheck, i);
from->CopySettings(to, BotSettingCategories::SpellTypeResistLimit, i);
from->CopySettings(to, BotSettingCategories::SpellTypeMinManaPct, i);
from->CopySettings(to, BotSettingCategories::SpellTypeMaxManaPct, i);
from->CopySettings(to, BotSettingCategories::SpellTypeMinHPPct, i);
from->CopySettings(to, BotSettingCategories::SpellTypeMaxHPPct, i);
from->CopySettings(to, BotSettingCategories::SpellTypeIdlePriority, i);
from->CopySettings(to, BotSettingCategories::SpellTypeEngagedPriority, i);
from->CopySettings(to, BotSettingCategories::SpellTypePursuePriority, i);
from->CopySettings(to, BotSettingCategories::SpellTypePursuePriority, i);
from->CopySettings(to, BotSettingCategories::SpellTypeAEOrGroupTargetCount, i);
from->CopySettings(to, BotSettingCategories::SpellTypeAnnounceCast, i);
}
}
@@ -299,14 +304,16 @@ void bot_command_copy_settings(Client* c, const Seperator* sep)
from->CopySettings(to, BotSettingCategories::SpellMinThreshold, spell_type);
from->CopySettings(to, BotSettingCategories::SpellMaxThreshold, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeAggroCheck, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeResistLimit, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeMinManaPct, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeMaxManaPct, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeMinHPPct, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeMaxHPPct, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeIdlePriority, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeEngagedPriority, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypePursuePriority, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypePursuePriority, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeAEOrGroupTargetCount, spell_type);
from->CopySettings(to, BotSettingCategories::SpellTypeAnnounceCast, spell_type);
}
else {
for (uint16 i = BotSpellTypes::START; i <= BotSpellTypes::END; ++i) {
@@ -315,6 +322,7 @@ void bot_command_copy_settings(Client* c, const Seperator* sep)
from->CopySettings(to, BotSettingCategories::SpellMinThreshold, i);
from->CopySettings(to, BotSettingCategories::SpellMaxThreshold, i);
from->CopySettings(to, BotSettingCategories::SpellTypeAggroCheck, i);
from->CopySettings(to, BotSettingCategories::SpellTypeResistLimit, i);
from->CopySettings(to, BotSettingCategories::SpellTypeMinManaPct, i);
from->CopySettings(to, BotSettingCategories::SpellTypeMaxManaPct, i);
from->CopySettings(to, BotSettingCategories::SpellTypeMinHPPct, i);
@@ -323,6 +331,7 @@ void bot_command_copy_settings(Client* c, const Seperator* sep)
from->CopySettings(to, BotSettingCategories::SpellTypeEngagedPriority, i);
from->CopySettings(to, BotSettingCategories::SpellTypePursuePriority, i);
from->CopySettings(to, BotSettingCategories::SpellTypeAEOrGroupTargetCount, i);
from->CopySettings(to, BotSettingCategories::SpellTypeAnnounceCast, i);
}
}
+33 -2
View File
@@ -38,7 +38,7 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
)
};
p.actionables = { "target, byname, ownergroup, ownerraid, targetgroup, namesgroup, healrotationtargets, mmr, byclass, byrace, spawned" };
p.options = { "all, misc, spellsettings, spelltypesettings, spellholds, spelldelays, spellminthresholds, spellmaxthresholds, spellminmanapct, spellmaxmanapct, spellminhppct, spellmaxhppct, spellidlepriority, spellengagedpriority, spellpursuepriority, spellaggrocheck, spelltargetcounts, spellresistlimits" };
p.options = { "all, misc, spellsettings, spelltypesettings, spellholds, spelldelays, spellminthresholds, spellmaxthresholds, spellminmanapct, spellmaxmanapct, spellminhppct, spellmaxhppct, spellidlepriority, spellengagedpriority, spellpursuepriority, spellaggrocheck, spelltargetcounts, spellresistlimits, spellannouncecasts" };
p.options_one =
{
"[spellsettings] will restore ^spellsettings options",
@@ -100,7 +100,8 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
"spellpursuepriority",
"spellaggrochecks",
"spelltargetcounts",
"spellresistlimits"
"spellresistlimits",
"spellannouncecasts"
};
if (sep->IsNumber(spell_type_arg_int)) {
@@ -223,6 +224,7 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
my_bot->SetSpellMinThreshold(spell_type, my_bot->GetDefaultSpellMinThreshold(spell_type, bot_stance));
my_bot->SetSpellMaxThreshold(spell_type, my_bot->GetDefaultSpellMaxThreshold(spell_type, bot_stance));
my_bot->SetSpellTypeAggroCheck(spell_type, my_bot->GetDefaultSpellTypeAggroCheck(spell_type, bot_stance));
my_bot->SetSpellTypeResistLimit(spell_type, my_bot->GetDefaultSpellTypeResistLimit(spell_type, bot_stance));
my_bot->SetSpellTypeMinManaLimit(spell_type, my_bot->GetDefaultSpellTypeMinManaLimit(spell_type, bot_stance));
my_bot->SetSpellTypeMaxManaLimit(spell_type, my_bot->GetDefaultSpellTypeMaxManaLimit(spell_type, bot_stance));
my_bot->SetSpellTypeMinHPLimit(spell_type, my_bot->GetDefaultSpellTypeMinHPLimit(spell_type, bot_stance));
@@ -231,6 +233,7 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
my_bot->SetSpellTypePriority(spell_type, BotPriorityCategories::Engaged, my_bot->GetDefaultSpellTypePriority(spell_type, BotPriorityCategories::Engaged, my_bot->GetClass(), bot_stance));
my_bot->SetSpellTypePriority(spell_type, BotPriorityCategories::Pursue, my_bot->GetDefaultSpellTypePriority(spell_type, BotPriorityCategories::Pursue, my_bot->GetClass(), bot_stance));
my_bot->SetSpellTypeAEOrGroupTargetCount(spell_type, my_bot->GetDefaultSpellTypeAEOrGroupTargetCount(spell_type, bot_stance));
my_bot->SetSpellTypeAnnounceCast(spell_type, my_bot->GetDefaultSpellTypeAnnounceCast(spell_type, bot_stance));
}
else {
for (uint16 i = BotSpellTypes::START; i <= BotSpellTypes::END; ++i) {
@@ -239,6 +242,7 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
my_bot->SetSpellMinThreshold(i, my_bot->GetDefaultSpellMinThreshold(i, bot_stance));
my_bot->SetSpellMaxThreshold(i, my_bot->GetDefaultSpellMaxThreshold(i, bot_stance));
my_bot->SetSpellTypeAggroCheck(i, my_bot->GetDefaultSpellTypeAggroCheck(i, bot_stance));
my_bot->SetSpellTypeResistLimit(i, my_bot->GetDefaultSpellTypeResistLimit(i, bot_stance));
my_bot->SetSpellTypeMinManaLimit(i, my_bot->GetDefaultSpellTypeMinManaLimit(i, bot_stance));
my_bot->SetSpellTypeMaxManaLimit(i, my_bot->GetDefaultSpellTypeMaxManaLimit(i, bot_stance));
my_bot->SetSpellTypeMinHPLimit(i, my_bot->GetDefaultSpellTypeMinHPLimit(i, bot_stance));
@@ -247,6 +251,7 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
my_bot->SetSpellTypePriority(i, BotPriorityCategories::Engaged, my_bot->GetDefaultSpellTypePriority(i, BotPriorityCategories::Engaged, my_bot->GetClass(), bot_stance));
my_bot->SetSpellTypePriority(i, BotPriorityCategories::Pursue, my_bot->GetDefaultSpellTypePriority(i, BotPriorityCategories::Pursue, my_bot->GetClass(), bot_stance));
my_bot->SetSpellTypeAEOrGroupTargetCount(i, my_bot->GetDefaultSpellTypeAEOrGroupTargetCount(i, bot_stance));
my_bot->SetSpellTypeAnnounceCast(i, my_bot->GetDefaultSpellTypeAnnounceCast(i, bot_stance));
}
}
@@ -263,6 +268,7 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
my_bot->SetSpellMinThreshold(i, my_bot->GetDefaultSpellMinThreshold(i, bot_stance));
my_bot->SetSpellMaxThreshold(i, my_bot->GetDefaultSpellMaxThreshold(i, bot_stance));
my_bot->SetSpellTypeAggroCheck(i, my_bot->GetDefaultSpellTypeAggroCheck(i, bot_stance));
my_bot->SetSpellTypeResistLimit(i, my_bot->GetDefaultSpellTypeResistLimit(i, bot_stance));
my_bot->SetSpellTypeMinManaLimit(i, my_bot->GetDefaultSpellTypeMinManaLimit(i, bot_stance));
my_bot->SetSpellTypeMaxManaLimit(i, my_bot->GetDefaultSpellTypeMaxManaLimit(i, bot_stance));
my_bot->SetSpellTypeMinHPLimit(i, my_bot->GetDefaultSpellTypeMinHPLimit(i, bot_stance));
@@ -271,6 +277,7 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
my_bot->SetSpellTypePriority(i, BotPriorityCategories::Engaged, my_bot->GetDefaultSpellTypePriority(i, BotPriorityCategories::Engaged, my_bot->GetClass(), bot_stance));
my_bot->SetSpellTypePriority(i, BotPriorityCategories::Pursue, my_bot->GetDefaultSpellTypePriority(i, BotPriorityCategories::Pursue, my_bot->GetClass(), bot_stance));
my_bot->SetSpellTypeAEOrGroupTargetCount(i, my_bot->GetDefaultSpellTypeAEOrGroupTargetCount(i, bot_stance));
my_bot->SetSpellTypeAnnounceCast(i, my_bot->GetDefaultSpellTypeAnnounceCast(i, bot_stance));
};
my_bot->ResetBotSpellSettings();
@@ -339,6 +346,18 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
output = "aggro check settings";
}
else if (!strcasecmp(sep->arg[1], "resist limit")) {
if (spell_type != UINT16_MAX) {
my_bot->SetSpellTypeAEOrGroupTargetCount(spell_type, my_bot->GetDefaultSpellTypeAEOrGroupTargetCount(spell_type, bot_stance));
}
else {
for (uint16 i = BotSpellTypes::START; i <= BotSpellTypes::END; ++i) {
my_bot->SetSpellTypeAEOrGroupTargetCount(i, my_bot->GetDefaultSpellTypeAEOrGroupTargetCount(i, bot_stance));
}
}
output = "resist limit settings";
}
else if (!strcasecmp(sep->arg[1], "minmanapct")) {
if (spell_type != UINT16_MAX) {
my_bot->SetSpellTypeMinManaLimit(spell_type, my_bot->GetDefaultSpellTypeMinManaLimit(spell_type, bot_stance));
@@ -435,6 +454,18 @@ void bot_command_default_settings(Client* c, const Seperator* sep)
output = "target count settings";
}
else if (!strcasecmp(sep->arg[1], "announcecast")) {
if (spell_type != UINT16_MAX) {
my_bot->SetSpellTypeAEOrGroupTargetCount(spell_type, my_bot->GetDefaultSpellTypeAEOrGroupTargetCount(spell_type, bot_stance));
}
else {
for (uint16 i = BotSpellTypes::START; i <= BotSpellTypes::END; ++i) {
my_bot->SetSpellTypeAEOrGroupTargetCount(i, my_bot->GetDefaultSpellTypeAEOrGroupTargetCount(i, bot_stance));
}
}
output = "announce cast settings";
}
my_bot->Save();
++success_count;
+9 -11
View File
@@ -233,17 +233,15 @@ void bot_command_depart(Client* c, const Seperator* sep)
bot_iter->SetCastedSpellType(BotSpellTypes::Teleport);
}
if (bot_iter->GetClass() != Class::Bard || RuleB(Bots, BardsAnnounceCasts)) {
Bot::RaidGroupSay(
bot_iter,
fmt::format(
"Casting {} [{}] on {}.",
GetSpellName(itr->SpellId),
bot_iter->GetSpellTypeNameByID(BotSpellTypes::Teleport),
(tar == bot_iter ? "myself" : tar->GetCleanName())
).c_str()
);
}
Bot::RaidGroupSay(
bot_iter,
fmt::format(
"Casting {} [{}] on {}.",
GetSpellName(itr->SpellId),
bot_iter->GetSpellTypeNameByID(BotSpellTypes::Teleport),
(tar == bot_iter ? "myself" : tar->GetCleanName())
).c_str()
);
is_success = true;
}
+214
View File
@@ -0,0 +1,214 @@
#include "../bot_command.h"
void bot_command_spell_announce_cast(Client* c, const Seperator* sep) {
if (helper_command_alias_fail(c, "bot_command_spell_announce_cast", sep->arg[0], "spellannouncecasts")) {
c->Message(Chat::White, "note: Allows you to enable or disable cast announcements for bots by spell type.");
return;
}
if (helper_is_help_or_usage(sep->arg[1])) {
BotCommandHelpParams p;
p.description = { "Allows you to enable or disable cast announcements for bots by spell type." };
p.example_format =
{
fmt::format("{} [Type Shortname] [value] [actionable]", sep->arg[0]),
fmt::format("{} [Type ID] [value] [actionable]", sep->arg[0])
};
p.examples_one =
{
"To set all bots to stop announcing dispels:",
fmt::format(
"{} {} 0 spawned",
sep->arg[0],
Bot::GetSpellTypeShortNameByID(BotSpellTypes::Dispel)
),
fmt::format(
"{} {} 0 spawned",
sep->arg[0],
BotSpellTypes::Dispel
)
};
p.examples_two =
{
"To set Wizards to not announce nukes:",
fmt::format(
"{} {} 0 byclass {}",
sep->arg[0],
Bot::GetSpellTypeShortNameByID(BotSpellTypes::Nuke),
Class::Wizard
),
fmt::format(
"{} {} 0 byclass {}",
sep->arg[0],
BotSpellTypes::Nuke,
Class::Wizard
)
};
p.examples_three =
{
"To check the current announcement setting for debuffs:",
fmt::format(
"{} {} current spawned",
sep->arg[0],
Bot::GetSpellTypeShortNameByID(BotSpellTypes::Debuff)
),
fmt::format(
"{} {} current spawned",
sep->arg[0],
BotSpellTypes::Debuff
)
};
p.actionables = { "target, byname, ownergroup, ownerraid, targetgroup, namesgroup, healrotationtargets, mmr, byclass, byrace, spawned" };
std::string popup_text = c->SendBotCommandHelpWindow(p);
popup_text = DialogueWindow::Table(popup_text);
c->SendPopupToClient(sep->arg[0], popup_text.c_str());
c->SendSpellTypePrompts();
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];
int ab_arg = 2;
bool current_check = false;
uint16 spell_type = 0;
uint32 type_value = 0;
// String/Int type checks
if (sep->IsNumber(1)) {
spell_type = atoi(sep->arg[1]);
if (!EQ::ValueWithin(spell_type, BotSpellTypes::START, BotSpellTypes::END)) {
c->Message(Chat::Yellow, "You must choose a valid spell type. Spell types range from %i to %i", BotSpellTypes::START, BotSpellTypes::END);
return;
}
}
else {
if (Bot::GetSpellTypeIDByShortName(arg1) != UINT16_MAX) {
spell_type = Bot::GetSpellTypeIDByShortName(arg1);
}
else {
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;
}
}
if (sep->IsNumber(2)) {
type_value = atoi(sep->arg[2]);
++ab_arg;
if (type_value != 0 && type_value != 1) {
c->Message(Chat::Yellow, "You must enter either 0 for [Disabled] or 1 for [Enabled].");
return;
}
}
else if (!arg2.compare("current")) {
++ab_arg;
current_check = true;
}
else {
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;
}
const int ab_mask = ActionableBots::ABM_Type1;
std::string class_race_arg = sep->arg[ab_arg];
bool class_race_check = false;
if (!class_race_arg.compare("byclass") || !class_race_arg.compare("byrace")) {
class_race_check = true;
}
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) {
return;
}
sbl.erase(std::remove(sbl.begin(), sbl.end(), nullptr), sbl.end());
Bot* first_found = nullptr;
int success_count = 0;
for (auto my_bot : sbl) {
if (my_bot->BotPassiveCheck()) {
continue;
}
if (!first_found) {
first_found = my_bot;
}
if (current_check) {
c->Message(
Chat::Green,
fmt::format(
"{} says, 'I currently {} announce [{}] casts.'",
my_bot->GetCleanName(),
(my_bot->GetSpellTypeAnnounceCast(spell_type) ? "do" : "do not"),
Bot::GetSpellTypeNameByID(spell_type)
).c_str()
);
}
else {
my_bot->SetSpellTypeAnnounceCast(spell_type, type_value);
++success_count;
}
}
if (!current_check) {
if (success_count == 1 && first_found) {
c->Message(
Chat::Green,
fmt::format(
"{} says, 'I will {} announce [{}] casts.'",
first_found->GetCleanName(),
(first_found->GetSpellTypeAnnounceCast(spell_type) ? "now" : "no longer"),
Bot::GetSpellTypeNameByID(spell_type)
).c_str()
);
}
else {
c->Message(
Chat::Green,
fmt::format(
"{} of your bots will {} announce [{}] casts.",
success_count,
(type_value ? "now" : "no longer"),
Bot::GetSpellTypeNameByID(spell_type)
).c_str()
);
}
}
}