mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Commands] Modify #grid and #wp. (#1399)
- #grid add will no longer let you put in a duplicate grid. - Grid nodes now spawn with invul/immune to damage. - Grid nodes now set an entity variable "grid_id" on spawn. - This allows grid nodes to be specifically despawned by "grid_id" entity variable, meaning you can view multiple grids at once and not despawn them all accidentally. - #grid hide will despawn your targeted NPC's Grid nodes. - #grid add, #grid show, #grid delete, and #grid hide send messages to let GM know what's going on. - #wp add and #wp delete now send messages to let the GM know what's going on. - #wpadd now send messages to let the GM know what's going on.
This commit is contained in:
+150
-82
@@ -439,8 +439,8 @@ int command_init(void)
|
||||
command_add("weather", "[0/1/2/3] (Off/Rain/Snow/Manual) - Change the weather", 80, command_weather) ||
|
||||
command_add("who", "[search]", 20, command_who) ||
|
||||
command_add("worldshutdown", "- Shut down world and all zones", 200, command_worldshutdown) ||
|
||||
command_add("wp", "[add/delete] [grid_num] [pause] [wp_num] [-h] - Add/delete a waypoint to/from a wandering grid", 170, command_wp) ||
|
||||
command_add("wpadd", "[pause] [-h] - Add your current location as a waypoint to your NPC target's AI path", 170, command_wpadd) ||
|
||||
command_add("wp", "[add|delete] [grid_id] [pause] [waypoint_id] [-h] - Add or delete a waypoint by grid ID. (-h to use current heading)", 170, command_wp) ||
|
||||
command_add("wpadd", "[pause] [-h] - Add your current location as a waypoint to your NPC target's AI path. (-h to use current heading)", 170, command_wpadd) ||
|
||||
command_add("wpinfo", "- Show waypoint info about your NPC target", 170, command_wpinfo) ||
|
||||
command_add("worldwide", "Performs world-wide GM functions such as cast (can be extended for other commands). Use caution", 250, command_worldwide) ||
|
||||
command_add("xtargets", "Show your targets Extended Targets and optionally set how many xtargets they can have.", 250, command_xtargets) ||
|
||||
@@ -2470,28 +2470,58 @@ void command_setlsinfo(Client *c, const Seperator *sep)
|
||||
|
||||
void command_grid(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (strcasecmp("max", sep->arg[1]) == 0) {
|
||||
c->Message(Chat::White, "Highest grid ID in this zone: %d", content_db.GetHighestGrid(zone->GetZoneID()));
|
||||
}
|
||||
else if (strcasecmp("add", sep->arg[1]) == 0) {
|
||||
content_db.ModifyGrid(c, false, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]), zone->GetZoneID());
|
||||
}
|
||||
else if (strcasecmp("show", sep->arg[1]) == 0) {
|
||||
|
||||
Mob *target = c->GetTarget();
|
||||
|
||||
if (!target || !target->IsNPC()) {
|
||||
c->Message(Chat::White, "You need a NPC target!");
|
||||
auto command_type = sep->arg[1];
|
||||
auto zone_id = zone->GetZoneID();
|
||||
if (strcasecmp("max", command_type) == 0) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Highest grid ID in this zone is {}.",
|
||||
content_db.GetHighestGrid(zone_id)
|
||||
).c_str()
|
||||
);
|
||||
} else if (strcasecmp("add", command_type) == 0) {
|
||||
auto grid_id = atoi(sep->arg[2]);
|
||||
auto wander_type = atoi(sep->arg[3]);
|
||||
auto pause_type = atoi(sep->arg[4]);
|
||||
if (!content_db.GridExistsInZone(zone_id, grid_id)) {
|
||||
content_db.ModifyGrid(c, false, grid_id, wander_type, pause_type, zone_id);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Grid {} added to zone ID {} with wander type {} and pause type {}.",
|
||||
grid_id,
|
||||
zone_id,
|
||||
wander_type,
|
||||
pause_type
|
||||
).c_str()
|
||||
);
|
||||
} else {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Grid {} already exists in zone ID {}.",
|
||||
grid_id,
|
||||
zone_id
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string query = StringFormat(
|
||||
} else if (strcasecmp("show", command_type) == 0) {
|
||||
Mob *target = c->GetTarget();
|
||||
if (!target || !target->IsNPC()) {
|
||||
c->Message(Chat::White, "You need to target an NPC!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto grid_id = target->CastToNPC()->GetGrid();
|
||||
std::string query = fmt::format(
|
||||
"SELECT `x`, `y`, `z`, `heading`, `number` "
|
||||
"FROM `grid_entries` "
|
||||
"WHERE `zoneid` = %u and `gridid` = %i "
|
||||
"WHERE `zoneid` = {} AND `gridid` = {} "
|
||||
"ORDER BY `number`",
|
||||
zone->GetZoneID(),
|
||||
target->CastToNPC()->GetGrid()
|
||||
zone_id,
|
||||
grid_id
|
||||
);
|
||||
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
@@ -2501,33 +2531,21 @@ void command_grid(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
c->Message(Chat::White, "No grid found");
|
||||
c->Message(Chat::White, "No grid found.");
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Depop any node npc's already spawned
|
||||
*/
|
||||
auto &mob_list = entity_list.GetMobList();
|
||||
for (auto itr = mob_list.begin(); itr != mob_list.end(); ++itr) {
|
||||
Mob *mob = itr->second;
|
||||
if (mob->IsNPC() && mob->GetRace() == 2254) {
|
||||
mob->Depop();
|
||||
}
|
||||
}
|
||||
// Depop any node npc's already spawned
|
||||
entity_list.DespawnGridNodes(grid_id);
|
||||
|
||||
/**
|
||||
* Spawn grid nodes
|
||||
*/
|
||||
// Spawn grid nodes
|
||||
std::map<std::vector<float>, int32> zoffset;
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
for (auto row : results) {
|
||||
glm::vec4 node_position = glm::vec4(atof(row[0]), atof(row[1]), atof(row[2]), atof(row[3]));
|
||||
|
||||
std::vector<float> node_loc {
|
||||
node_position.x,
|
||||
node_position.y,
|
||||
node_position.z
|
||||
node_position.x,
|
||||
node_position.y,
|
||||
node_position.z
|
||||
};
|
||||
|
||||
// If we already have a node at this location, set the z offset
|
||||
@@ -2536,46 +2554,98 @@ void command_grid(Client *c, const Seperator *sep)
|
||||
auto search = zoffset.find(node_loc);
|
||||
if (search != zoffset.end()) {
|
||||
search->second = search->second + 3;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
zoffset[node_loc] = 0.0;
|
||||
}
|
||||
|
||||
node_position.z += zoffset[node_loc];
|
||||
|
||||
NPC::SpawnGridNodeNPC(node_position,atoi(row[4]),zoffset[node_loc]);
|
||||
NPC::SpawnGridNodeNPC(node_position, grid_id, atoi(row[4]), zoffset[node_loc]);
|
||||
}
|
||||
}
|
||||
else if (strcasecmp("delete", sep->arg[1]) == 0) {
|
||||
content_db.ModifyGrid(c, true, atoi(sep->arg[2]), 0, 0, zone->GetZoneID());
|
||||
}
|
||||
else {
|
||||
c->Message(Chat::White, "Usage: #grid add/delete grid_num wandertype pausetype");
|
||||
c->Message(Chat::White, "Usage: #grid max - displays the highest grid ID used in this zone (for add)");
|
||||
c->Message(Chat::White, "Usage: #grid show - displays wp nodes as boxes");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Spawning nodes for grid {}.",
|
||||
grid_id
|
||||
).c_str()
|
||||
);
|
||||
} else if (strcasecmp("hide", command_type) == 0) {
|
||||
Mob* target = c->GetTarget();
|
||||
if (!target || !target->IsNPC()) {
|
||||
c->Message(Chat::White, "You need to target an NPC!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto grid_id = target->CastToNPC()->GetGrid();
|
||||
entity_list.DespawnGridNodes(grid_id);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Depawning nodes for grid {}.",
|
||||
grid_id
|
||||
).c_str()
|
||||
);
|
||||
} else if (strcasecmp("delete", command_type) == 0) {
|
||||
auto grid_id = atoi(sep->arg[2]);
|
||||
content_db.ModifyGrid(c, true, grid_id, 0, 0, zone_id);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Grid {} deleted from zone ID {}.",
|
||||
grid_id,
|
||||
zone_id
|
||||
).c_str()
|
||||
);
|
||||
} else {
|
||||
c->Message(Chat::White, "Usage: #grid [add|delete] [grid_id] [wander_type] [pause_type]");
|
||||
c->Message(Chat::White, "Usage: #grid [max] - displays the highest grid ID used in this zone (for add)");
|
||||
c->Message(Chat::White, "Usage: #grid [show] - displays wp nodes as boxes");
|
||||
}
|
||||
}
|
||||
|
||||
void command_wp(Client *c, const Seperator *sep)
|
||||
{
|
||||
int wp = atoi(sep->arg[4]);
|
||||
auto command_type = sep->arg[1];
|
||||
auto grid_id = atoi(sep->arg[2]);
|
||||
if (grid_id != 0) {
|
||||
auto pause = atoi(sep->arg[3]);
|
||||
auto waypoint = atoi(sep->arg[4]);
|
||||
auto zone_id = zone->GetZoneID();
|
||||
if (strcasecmp("add", command_type) == 0) {
|
||||
if (waypoint == 0) { // Default to highest if it's left blank, or we enter 0
|
||||
waypoint = (content_db.GetHighestWaypoint(zone_id, grid_id) + 1);
|
||||
}
|
||||
|
||||
if (strcasecmp("add", sep->arg[1]) == 0) {
|
||||
if (wp == 0) //default to highest if it's left blank, or we enter 0
|
||||
wp = content_db.GetHighestWaypoint(zone->GetZoneID(), atoi(sep->arg[2])) + 1;
|
||||
if (strcasecmp("-h", sep->arg[5]) == 0) {
|
||||
content_db.AddWP(c, atoi(sep->arg[2]),wp, c->GetPosition(), atoi(sep->arg[3]),zone->GetZoneID());
|
||||
}
|
||||
else {
|
||||
auto position = c->GetPosition();
|
||||
position.w = -1;
|
||||
content_db.AddWP(c, atoi(sep->arg[2]),wp, position, atoi(sep->arg[3]),zone->GetZoneID());
|
||||
if (strcasecmp("-h", sep->arg[5]) == 0) {
|
||||
content_db.AddWP(c, grid_id, waypoint, c->GetPosition(), pause, zone_id);
|
||||
} else {
|
||||
auto position = c->GetPosition();
|
||||
position.w = -1;
|
||||
content_db.AddWP(c, grid_id, waypoint, position, pause, zone_id);
|
||||
}
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Waypoint {} added to grid {} with a pause of {} {}.",
|
||||
waypoint,
|
||||
grid_id,
|
||||
pause,
|
||||
(pause == 1 ? "second" : "seconds")
|
||||
).c_str()
|
||||
);
|
||||
} else if (strcasecmp("delete", command_type) == 0) {
|
||||
content_db.DeleteWaypoint(c, grid_id, waypoint, zone_id);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Waypoint {} deleted from grid {}.",
|
||||
waypoint,
|
||||
grid_id
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
c->Message(Chat::White,"Usage: #wp [add|delete] [grid_id] [pause] [waypoint_id] [-h]");
|
||||
}
|
||||
else if (strcasecmp("delete", sep->arg[1]) == 0)
|
||||
content_db.DeleteWaypoint(c, atoi(sep->arg[2]),wp,zone->GetZoneID());
|
||||
else
|
||||
c->Message(Chat::White,"Usage: #wp add/delete grid_num pause wp_num [-h]");
|
||||
}
|
||||
|
||||
void command_iplookup(Client *c, const Seperator *sep)
|
||||
@@ -7843,20 +7913,14 @@ void command_wpinfo(Client *c, const Seperator *sep)
|
||||
|
||||
void command_wpadd(Client *c, const Seperator *sep)
|
||||
{
|
||||
int type1 = 0,
|
||||
type2 = 0,
|
||||
pause = 0; // Defaults for a new grid
|
||||
|
||||
int type1 = 0, type2 = 0, pause = 0; // Defaults for a new grid
|
||||
Mob *target = c->GetTarget();
|
||||
if (target && target->IsNPC()) {
|
||||
Spawn2 *s2info = target->CastToNPC()->respawn2;
|
||||
|
||||
if (s2info ==
|
||||
nullptr) // Can't figure out where this mob's spawn came from... maybe a dynamic mob created by #spawn
|
||||
{
|
||||
if (s2info == nullptr) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
"#wpadd FAILED -- Can't determine which spawn record in the database this mob came from!"
|
||||
"#wpadd Failed, you must target a valid spawn."
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -7864,8 +7928,7 @@ void command_wpadd(Client *c, const Seperator *sep)
|
||||
if (sep->arg[1][0]) {
|
||||
if (atoi(sep->arg[1]) >= 0) {
|
||||
pause = atoi(sep->arg[1]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
c->Message(Chat::White, "Usage: #wpadd [pause] [-h]");
|
||||
return;
|
||||
}
|
||||
@@ -7875,18 +7938,23 @@ void command_wpadd(Client *c, const Seperator *sep)
|
||||
position.w = -1;
|
||||
}
|
||||
|
||||
uint32 tmp_grid = content_db.AddWPForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone->GetZoneID());
|
||||
auto zone_id = zone->GetZoneID();
|
||||
uint32 tmp_grid = content_db.AddWPForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone_id);
|
||||
if (tmp_grid) {
|
||||
target->CastToNPC()->SetGrid(tmp_grid);
|
||||
}
|
||||
|
||||
target->CastToNPC()->AssignWaypoints(target->CastToNPC()->GetGrid());
|
||||
auto grid_id = target->CastToNPC()->GetGrid();
|
||||
target->CastToNPC()->AssignWaypoints(grid_id);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
"Waypoint added. Use #wpinfo to see waypoints for this NPC (may need to #repop first)."
|
||||
fmt::format(
|
||||
"Waypoint added to grid {} in zone ID {}. Use #wpinfo to see waypoints for this NPC (may need to #repop first).",
|
||||
grid_id,
|
||||
zone_id
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
c->Message(Chat::White, "You must target an NPC to use this.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user