mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-19 16:31:29 +00:00
[Commands] Cleanup #roambox Command. (#2135)
- Cleanup messages and logic.
This commit is contained in:
parent
bf7c1252f8
commit
55629ce396
@ -307,7 +307,7 @@ int command_init(void)
|
|||||||
command_add("resetaa_timer", "Command to reset AA cooldown timers.", AccountStatus::GMMgmt, command_resetaa_timer) ||
|
command_add("resetaa_timer", "Command to reset AA cooldown timers.", AccountStatus::GMMgmt, command_resetaa_timer) ||
|
||||||
command_add("resetdisc_timer", "Command to reset all discipline cooldown timers.", AccountStatus::GMMgmt, command_resetdisc_timer) ||
|
command_add("resetdisc_timer", "Command to reset all discipline cooldown timers.", AccountStatus::GMMgmt, command_resetdisc_timer) ||
|
||||||
command_add("revoke", "[charname] [1/0] - Makes charname unable to talk on OOC", AccountStatus::GMMgmt, command_revoke) ||
|
command_add("revoke", "[charname] [1/0] - Makes charname unable to talk on OOC", AccountStatus::GMMgmt, command_revoke) ||
|
||||||
command_add("roambox", "Manages roambox settings for an NPC", AccountStatus::GMMgmt, command_roambox) ||
|
command_add("roambox", "[Remove|Set] [Box Size] [Delay (Milliseconds)] - Remove or set an NPC's roambox size and delay", AccountStatus::GMMgmt, command_roambox) ||
|
||||||
command_add("rules", "(subcommand) - Manage server rules", AccountStatus::GMImpossible, command_rules) ||
|
command_add("rules", "(subcommand) - Manage server rules", AccountStatus::GMImpossible, command_rules) ||
|
||||||
command_add("save", "- Force your player or player corpse target to be saved to the database", AccountStatus::Guide, command_save) ||
|
command_add("save", "- Force your player or player corpse target to be saved to the database", AccountStatus::Guide, command_save) ||
|
||||||
command_add("scale", "- Handles npc scaling", AccountStatus::GMLeadAdmin, command_scale) ||
|
command_add("scale", "- Handles npc scaling", AccountStatus::GMLeadAdmin, command_scale) ||
|
||||||
|
|||||||
@ -3,91 +3,103 @@
|
|||||||
|
|
||||||
void command_roambox(Client *c, const Seperator *sep)
|
void command_roambox(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
std::string arg1 = sep->arg[1];
|
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
|
||||||
|
c->Message(Chat::White, "You need a valid NPC target for this command");
|
||||||
Mob *target = c->GetTarget();
|
|
||||||
if (!target || !target->IsNPC()) {
|
|
||||||
c->Message(Chat::Red, "You need a valid NPC target for this command");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NPC *npc = dynamic_cast<NPC *>(target);
|
int arguments = sep->argnum;
|
||||||
int spawn_group_id = npc->GetSpawnGroupId();
|
if (!arguments) {
|
||||||
|
c->Message(Chat::White, "#roambox remove - Remove a roambox from an NPC");
|
||||||
|
c->Message(Chat::White, "#roambox set [Box Size] [Delay] - Set a roambox for an NPC");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto target = c->GetTarget()->CastToNPC();
|
||||||
|
int spawn_group_id = target->GetSpawnGroupId();
|
||||||
if (spawn_group_id <= 0) {
|
if (spawn_group_id <= 0) {
|
||||||
c->Message(Chat::Red, "NPC needs a valid SpawnGroup!");
|
c->Message(Chat::Red, "NPC needs a valid SpawnGroup!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg1 == "set") {
|
bool is_remove = !strcasecmp(sep->arg[1], "remove");
|
||||||
int box_size = (sep->arg[2] ? atoi(sep->arg[2]) : 0);
|
bool is_set = !strcasecmp(sep->arg[1], "set");
|
||||||
int delay = (sep->arg[3] ? atoi(sep->arg[3]) : 15000);
|
if (!is_remove && !is_set) {
|
||||||
if (box_size > 0) {
|
c->Message(Chat::White, "#roambox remove - Remove a roambox from an NPC");
|
||||||
std::string query = fmt::format(
|
c->Message(Chat::White, "#roambox set [Box Size] [Delay] - Set a roambox for an NPC");
|
||||||
SQL(
|
return;
|
||||||
UPDATE spawngroup SET
|
}
|
||||||
dist = {},
|
|
||||||
min_x = {},
|
if (is_remove) {
|
||||||
max_x = {},
|
auto query = fmt::format(
|
||||||
min_y = {},
|
"UPDATE spawngroup SET dist = 0, min_x = 0, max_x = 0, min_y = 0, max_y = 0, delay = 0 WHERE id = {}",
|
||||||
max_y = {},
|
spawn_group_id
|
||||||
delay = {}
|
);
|
||||||
WHERE id = {}
|
|
||||||
),
|
database.QueryDatabase(query);
|
||||||
(box_size / 2),
|
|
||||||
npc->GetX() - (box_size / 2),
|
c->Message(
|
||||||
npc->GetX() + (box_size / 2),
|
Chat::White,
|
||||||
npc->GetY() - (box_size / 2),
|
fmt::format(
|
||||||
npc->GetY() + (box_size / 2),
|
"Roambox has been removed from {} ({}) on spawn group ID {}.",
|
||||||
|
target->GetCleanName(),
|
||||||
|
target->GetID(),
|
||||||
|
spawn_group_id
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
} else if (is_set) {
|
||||||
|
float box_size = 0.0f;
|
||||||
|
int delay = 15000;
|
||||||
|
|
||||||
|
if (arguments >= 2) {
|
||||||
|
box_size = std::stof(sep->arg[2]);
|
||||||
|
|
||||||
|
if (arguments == 3) {
|
||||||
|
delay = std::stoi(sep->arg[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (box_size) {
|
||||||
|
auto query = fmt::format(
|
||||||
|
"UPDATE spawngroup SET dist = {:2f}, min_x = {:2f}, max_x = {:.2f}, min_y = {:2f}, max_y = {:2f}, delay = {} WHERE id = {}",
|
||||||
|
(box_size / 2.0f),
|
||||||
|
(target->GetX() - (box_size / 2.0f)),
|
||||||
|
(target->GetX() + (box_size / 2.0f)),
|
||||||
|
(target->GetY() - (box_size / 2.0f)),
|
||||||
|
(target->GetY() + (box_size / 2.0f)),
|
||||||
delay,
|
delay,
|
||||||
spawn_group_id
|
spawn_group_id
|
||||||
);
|
);
|
||||||
|
|
||||||
database.QueryDatabase(query);
|
auto results = database.QueryDatabase(query);
|
||||||
|
|
||||||
|
if (!results.RowsAffected()) {
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Failed to set roambox for {} ({}).",
|
||||||
|
target->GetCleanName(),
|
||||||
|
target->GetID()
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::Yellow,
|
Chat::White,
|
||||||
"NPC (%s) Roam Box set to box size of [%i] SpawnGroupId [%i] delay [%i]",
|
fmt::format(
|
||||||
npc->GetCleanName(),
|
"Roambox set to box size of {} for {} ({}) on spawn group ID {} with a delay of {} ({}).",
|
||||||
box_size,
|
box_size,
|
||||||
|
target->GetCleanName(),
|
||||||
|
target->GetID(),
|
||||||
spawn_group_id,
|
spawn_group_id,
|
||||||
|
ConvertMillisecondsToTime(delay),
|
||||||
delay
|
delay
|
||||||
|
).c_str()
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
return;
|
c->Message(Chat::White, "Box size must be greater than 0.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
c->Message(Chat::Red, "Box size must be set!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg1 == "remove") {
|
|
||||||
std::string query = fmt::format(
|
|
||||||
SQL(
|
|
||||||
UPDATE spawngroup SET
|
|
||||||
dist = 0,
|
|
||||||
min_x = 0,
|
|
||||||
max_x = 0,
|
|
||||||
min_y = 0,
|
|
||||||
max_y = 0,
|
|
||||||
delay = 0
|
|
||||||
WHERE id = {}
|
|
||||||
),
|
|
||||||
spawn_group_id
|
|
||||||
);
|
|
||||||
|
|
||||||
database.QueryDatabase(query);
|
|
||||||
|
|
||||||
c->Message(
|
|
||||||
Chat::Yellow,
|
|
||||||
"NPC (%s) Roam Box has been removed from SpawnGroupID [%i]",
|
|
||||||
npc->GetCleanName(),
|
|
||||||
spawn_group_id
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
c->Message(Chat::Yellow, "> Command Usage");
|
|
||||||
c->Message(Chat::Yellow, "#roambox set box_size [delay = 0]");
|
|
||||||
c->Message(Chat::Yellow, "#roambox remove");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user