Rewrite ^followd command and remove squared values from command

This commit is contained in:
nytmyr
2024-11-01 14:58:37 -05:00
parent 088f13130a
commit 0f16601e5d
5 changed files with 185 additions and 38 deletions
@@ -189,7 +189,7 @@ WHERE rv.rule_name LIKE 'Bots:BotExpansionSettings'
AND bd.expansion_bitmask != rv.rule_value;
INSERT INTO bot_settings SELECT NULL, 0, `bot_id`, 1, 0, `show_helm`, 'BaseSetting', 'ShowHelm' FROM bot_data WHERE `show_helm` != 1;
INSERT INTO bot_settings SELECT NULL, 0, `bot_id`, 2, 0, `follow_distance`, 'BaseSetting', 'FollowDistance' FROM bot_data WHERE `follow_distance` != 184;
INSERT INTO bot_settings SELECT NULL, 0, `bot_id`, 2, 0, sqrt(`follow_distance`), 'BaseSetting', 'FollowDistance' FROM bot_data WHERE `follow_distance` != 184;
INSERT INTO bot_settings
SELECT NULL, 0, `bot_id`, 3, 0, `stop_melee_level`, 'BaseSetting', 'StopMeleeLevel'
@@ -238,6 +238,7 @@ ALTER TABLE `bot_data`
UPDATE `bot_command_settings` SET `aliases`= 'bh' WHERE `bot_command`='behindmob';
UPDATE `bot_command_settings` SET `aliases`= 'bs|settings' WHERE `bot_command`='botsettings';
UPDATE `bot_command_settings` SET `aliases`= CASE WHEN LENGTH(`aliases`) > 0 THEN CONCAT(`aliases`, '|followdistance') ELSE 'followd||followdistance' END WHERE `bot_command`='botfollowdistance' AND `aliases` NOT LIKE '%followdistance%';
UPDATE `bot_command_settings` SET `aliases`= CASE WHEN LENGTH(`aliases`) > 0 THEN CONCAT(`aliases`, '|ranged|toggleranged|btr') ELSE 'ranged|toggleranged|btr' END WHERE `bot_command`='bottoggleranged' AND `aliases` NOT LIKE '%ranged|toggleranged|btr%';
UPDATE `bot_command_settings` SET `aliases`= CASE WHEN LENGTH(`aliases`) > 0 THEN CONCAT(`aliases`, '|cr') ELSE 'cr' END WHERE `bot_command`='casterrange' AND `aliases` NOT LIKE '%cr%';
UPDATE `bot_command_settings` SET `aliases`= 'copy' WHERE `bot_command`='copysettings';
+2
View File
@@ -873,6 +873,8 @@ RULE_INT(Bots, StatusCreateLimit, 120, "Minimum status to bypass spawn limit. De
RULE_BOOL(Bots, BardsAnnounceCasts, false, "This determines whether or not Bard bots will announce that they're casting songs (Buffs, Heals, Nukes, Slows, etc.) they will always announce Mez.")
RULE_BOOL(Bots, EnableBotTGB, true, "If enabled bots will cast group buffs as TGB.")
RULE_BOOL(Bots, DoResponseAnimations, true, "If enabled bots will do animations to certain responses or commands.")
RULE_INT(Bots, DefaultFollowDistance, 20, "Default 20. Distance a bot will follow behind.")
RULE_INT(Bots, MaxFollowDistance, 300, "Default 300. Max distance a bot can be set to follow behind.")
RULE_CATEGORY_END()
RULE_CATEGORY(Chat)
+4 -4
View File
@@ -9894,7 +9894,7 @@ void Bot::SetBotBaseSetting(uint16 botSetting, int settingValue) {
SetShowHelm(settingValue);
break;
case BotBaseSettings::FollowDistance:
SetFollowDistance(EQ::Clamp(static_cast<uint32>(settingValue), static_cast<uint32>(1), BOT_FOLLOW_DISTANCE_DEFAULT_MAX));
SetFollowDistance(EQ::Clamp(static_cast<uint32>(settingValue * settingValue), static_cast<uint32>(1), static_cast<uint32>((RuleI(Bots, MaxFollowDistance) * RuleI(Bots, MaxFollowDistance)))));
break;
case BotBaseSettings::StopMeleeLevel:
SetStopMeleeLevel(settingValue);
@@ -9943,8 +9943,8 @@ int Bot::GetBotBaseSetting(uint16 botSetting) {
//LogBotSettingsDetail("Returning current GetShowHelm of [{}] for [{}]", GetShowHelm(), GetCleanName()); //deleteme
return GetShowHelm();
case BotBaseSettings::FollowDistance:
//LogBotSettingsDetail("Returning current GetFollowDistance of [{}] for [{}]", GetFollowDistance(), GetCleanName()); //deleteme
return GetFollowDistance();
//LogBotSettingsDetail("Returning current GetFollowDistance of [{}] for [{}]", sqrt(GetFollowDistance()), GetCleanName()); //deleteme
return sqrt(GetFollowDistance());
case BotBaseSettings::StopMeleeLevel:
//LogBotSettingsDetail("Returning current GetStopMeleeLevel of [{}] for [{}]", GetStopMeleeLevel(), GetCleanName()); //deleteme
return GetStopMeleeLevel();
@@ -9992,7 +9992,7 @@ int Bot::GetDefaultBotBaseSetting(uint16 botSetting) {
case BotBaseSettings::ShowHelm:
return true;
case BotBaseSettings::FollowDistance:
return BOT_FOLLOW_DISTANCE_DEFAULT;
return (RuleI(Bots, DefaultFollowDistance) * RuleI(Bots, DefaultFollowDistance));
case BotBaseSettings::StopMeleeLevel:
if (IsCasterClass(GetClass())) {
return RuleI(Bots, CasterStopMeleeLevel);
-3
View File
@@ -37,9 +37,6 @@
#include <sstream>
constexpr uint32 BOT_FOLLOW_DISTANCE_DEFAULT = 184; // as DSq value (~13.565 units)
constexpr uint32 BOT_FOLLOW_DISTANCE_DEFAULT_MAX = 2500; // as DSq value (50 units)
constexpr uint32 BOT_KEEP_ALIVE_INTERVAL = 5000; // 5 seconds
constexpr uint32 BOT_COMBAT_JITTER_INTERVAL_MIN = 1500; // 1.5 seconds
+177 -30
View File
@@ -466,58 +466,205 @@ void bot_command_delete(Client *c, const Seperator *sep)
void bot_command_follow_distance(Client *c, const Seperator *sep)
{
if (helper_command_alias_fail(c, "bot_command_follow_distance", sep->arg[0], "botfollowdistance"))
return;
if (helper_is_help_or_usage(sep->arg[1])) {
c->Message(Chat::White, "usage: %s [set [1 to %i]] [distance] ([actionable: target | byname | ownergroup | ownerraid | targetgroup | namesgroup | healrotationmembers | healrotationtargets | mmr | byclass | byrace | spawned] ([actionable_name]))", sep->arg[0], BOT_FOLLOW_DISTANCE_DEFAULT_MAX);
c->Message(Chat::White, "usage: %s [clear] ([actionable: target | byname | ownergroup | ownerraid | targetgroup | namesgroup | healrotationmembers | healrotationtargets | mmr | byclass | byrace | spawned] ([actionable_name]))", sep->arg[0]);
if (helper_command_alias_fail(c, "bot_command_follow_distance", sep->arg[0], "botfollowdistance")) {
return;
}
const int ab_mask = ActionableBots::ABM_NoFilter;
uint32 bfd = BOT_FOLLOW_DISTANCE_DEFAULT;
if (helper_is_help_or_usage(sep->arg[1])) {
std::vector<std::string> description =
{
"Sets or resets the follow distance of the selected bots."
};
std::vector<std::string> notes =
{
fmt::format(
"[Default]: {}",
RuleI(Bots, MaxFollowDistance)
),
fmt::format(
"- You must use a value between 1 and {}.",
RuleI(Bots, MaxFollowDistance)
)
};
std::vector<std::string> example_format =
{
fmt::format(
"{} [reset]/[set [value]] [actionable]"
, sep->arg[0]
)
};
std::vector<std::string> examples_one =
{
"To set all bots to follow at a distance of 25:",
fmt::format(
"{} set 25 spawned",
sep->arg[0]
)
};
std::vector<std::string> examples_two =
{
"To check the curret following distance of all bots:",
fmt::format(
"{} current spawned",
sep->arg[0]
)
};
std::vector<std::string> examples_three =
{
"To reset the following distance of all Wizards:",
fmt::format(
"{} reset byclass {}",
sep->arg[0],
Class::Wizard
)
};
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());
return;
}
const int ab_mask = ActionableBots::ABM_Type2;
uint32 bfd = RuleI(Bots, DefaultFollowDistance);
bool set_flag = false;
bool currentCheck = false;
int ab_arg = 2;
if (!strcasecmp(sep->arg[1], "set")) {
std::string arg1 = sep->arg[1];
if (!arg1.compare("set")) {
if (!sep->IsNumber(2)) {
c->Message(Chat::White, "A numeric [distance] is required to use this command. [1 to %i]", BOT_FOLLOW_DISTANCE_DEFAULT_MAX);
c->Message(Chat::Yellow, "You must enter a value between 1 and %i.", RuleI(Bots, MaxFollowDistance));
return;
}
bfd = Strings::ToInt(sep->arg[2]);
if (bfd < 1)
bfd = 1;
if (bfd > BOT_FOLLOW_DISTANCE_DEFAULT_MAX)
bfd = BOT_FOLLOW_DISTANCE_DEFAULT_MAX;
if (bfd < 1) {
c->Message(Chat::Yellow, "You must enter a value between 1 and %i.", RuleI(Bots, MaxFollowDistance));
return;
}
if (bfd > RuleI(Bots, MaxFollowDistance)) {
c->Message(Chat::Yellow, "You must enter a value between 1 and %i.", RuleI(Bots, MaxFollowDistance));
return;
}
set_flag = true;
ab_arg = 3;
++ab_arg;
}
else if (strcasecmp(sep->arg[1], "clear")) {
c->Message(Chat::White, "This command requires a [set | clear] argument");
else if (!arg1.compare("current")) {
currentCheck = true;
}
else if (arg1.compare("reset")) {
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;
}
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::list<Bot*> sbl;
auto ab_type = ActionableBots::PopulateSBL(c, sep->arg[ab_arg], sbl, ab_mask, sep->arg[(ab_arg + 1)]);
if (ab_type == ActionableBots::ABT_None)
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;
int bot_count = 0;
for (auto bot_iter : sbl) {
if (!bot_iter)
continue;
bot_iter->SetFollowDistance(bfd);
++bot_count;
}
if (ab_type == ActionableBots::ABT_All) {
c->Message(Chat::White, "%s all of your bot follow distances to %i", set_flag ? "Set" : "Cleared", bfd);
sbl.remove(nullptr);
int botCount = 0;
for (auto bot_iter : sbl) {
if (!bot_iter) {
continue;
}
if (currentCheck) {
Mob* follow_mob = entity_list.GetMob(bot_iter->GetFollowID());
c->Message(
Chat::Green,
fmt::format(
"{} says, 'I am currently following {} at a distance of {}.'",
bot_iter->GetCleanName(),
follow_mob ? follow_mob->GetCleanName() : "no one",
sqrt(bot_iter->GetFollowDistance())
).c_str()
);
}
else {
bot_iter->SetFollowDistance(bfd * bfd);
++botCount;
}
}
if (currentCheck) {
return;
}
if (botCount == 1) {
Mob* follow_mob = entity_list.GetMob(sbl.front()->GetFollowID());
c->Message(
Chat::Green,
fmt::format(
"{} says, 'Following {} at a distance of {}.'",
sbl.front()->GetCleanName(),
follow_mob ? follow_mob->GetCleanName() : "you",
bfd
).c_str()
);
}
else {
c->Message(Chat::White, "%s %i of your spawned bot follow distances to %i", (set_flag ? "Set" : "Cleared"), bot_count, bfd);
c->Message(
Chat::Green,
fmt::format(
"{} of your bots are now following at a distance of {}.",
botCount,
bfd
).c_str()
);
}
}