find command uses new pathing system now which loads .nav files saved by map_edit, still in initial stages of testing. Fixed a bug where find might cause a desync in some cases as well.

This commit is contained in:
KimLS
2016-01-12 18:33:00 -08:00
parent c6e9fbc878
commit e61e2e7f02
57 changed files with 25463 additions and 653 deletions
-311
View File
@@ -290,7 +290,6 @@ int command_init(void)
command_add("packetprofile", "- Dump packet profile for target or self.", 250, command_packetprofile) ||
#endif
command_add("path", "- view and edit pathing", 200, command_path) ||
command_add("peekinv", "[worn/inv/cursor/trib/bank/trade/world/all] - Print out contents of your player target's inventory", 100, command_peekinv) ||
command_add("peqzone", "[zonename] - Go to specified zone, if you have > 75% health", 0, command_peqzone) ||
command_add("permaclass", "[classnum] - Change your or your player target's class (target is disconnected)", 80, command_permaclass) ||
@@ -6777,316 +6776,6 @@ void command_qglobal(Client *c, const Seperator *sep) {
c->Message(15, "Invalid action specified.");
}
void command_path(Client *c, const Seperator *sep)
{
if(sep->arg[1][0] == '\0' || !strcasecmp(sep->arg[1], "help"))
{
c->Message(0, "Syntax: #path shownodes: Spawns a npc to represent every npc node.");
c->Message(0, "#path info node_id: Gives information about node info (requires shownode target).");
c->Message(0, "#path dump file_name: Dumps the current zone->pathing to a file of your naming.");
c->Message(0, "#path add [requested_id]: Adds a node at your current location will try to take the requested id if possible.");
c->Message(0, "#path connect connect_to_id [is_teleport] [door_id]: Connects the currently targeted node to connect_to_id's node and connects that node back (requires shownode target).");
c->Message(0, "#path sconnect connect_to_id [is_teleport] [door_id]: Connects the currently targeted node to connect_to_id's node (requires shownode target).");
c->Message(0, "#path qconnect [set]: short cut connect, connects the targeted node to the node you set with #path qconnect set (requires shownode target).");
c->Message(0, "#path disconnect [all]/disconnect_from_id: Disconnects the currently targeted node to disconnect from disconnect from id's node (requires shownode target), if passed all as the second argument it will disconnect this node from every other node.");
c->Message(0, "#path move: Moves your targeted node to your current position");
c->Message(0, "#path process file_name: processes the map file and tries to automatically generate a rudimentary path setup and then dumps the current zone->pathing to a file of your naming.");
c->Message(0, "#path resort [nodes]: resorts the connections/nodes after you've manually altered them so they'll work.");
return;
}
if(!strcasecmp(sep->arg[1], "shownodes"))
{
if(zone->pathing)
zone->pathing->SpawnPathNodes();
return;
}
if(!strcasecmp(sep->arg[1], "info"))
{
if(zone->pathing)
{
zone->pathing->NodeInfo(c);
}
return;
}
if(!strcasecmp(sep->arg[1], "dump"))
{
if(zone->pathing)
{
if(sep->arg[2][0] == '\0')
return;
zone->pathing->DumpPath(sep->arg[2]);
}
return;
}
if(!strcasecmp(sep->arg[1], "add"))
{
if(zone->pathing)
{
float px = c->GetX();
float py = c->GetY();
float pz = c->GetZ();
float best_z;
if(zone->zonemap)
{
glm::vec3 loc(px, py, pz);
best_z = zone->zonemap->FindBestZ(loc, nullptr);
}
else
{
best_z = pz;
}
int32 res = zone->pathing->AddNode(px, py, pz, best_z, atoi(sep->arg[2]));
if(res >= 0)
{
c->Message(0, "Added Path Node: %i", res);
}
else
{
c->Message(0, "Failed to add Path Node");
}
}
else
{
zone->pathing = new PathManager();
float px = c->GetX();
float py = c->GetY();
float pz = c->GetZ();
float best_z;
if(zone->zonemap)
{
glm::vec3 loc(px, py, pz);
best_z = zone->zonemap->FindBestZ(loc, nullptr);
}
else
{
best_z = pz;
}
int32 res = zone->pathing->AddNode(px, py, pz, best_z, atoi(sep->arg[2]));
if(res >= 0)
{
c->Message(0, "Added Path Node: %i", res);
}
else
{
c->Message(0, "Failed to add Path Node");
}
}
return;
}
if(!strcasecmp(sep->arg[1], "remove"))
{
if(zone->pathing)
{
if(zone->pathing->DeleteNode(c))
{
c->Message(0, "Removed Node.");
}
else
{
c->Message(0, "Unable to Remove Node.");
}
}
return;
}
if(!strcasecmp(sep->arg[1], "connect"))
{
if(zone->pathing)
{
zone->pathing->ConnectNodeToNode(c, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]));
}
return;
}
if(!strcasecmp(sep->arg[1], "sconnect"))
{
if(zone->pathing)
{
zone->pathing->ConnectNode(c, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]));
}
return;
}
if(!strcasecmp(sep->arg[1], "qconnect"))
{
if(zone->pathing)
{
if(!strcasecmp(sep->arg[2], "set"))
{
zone->pathing->QuickConnect(c, true);
}
else
{
zone->pathing->QuickConnect(c, false);
}
}
return;
}
if(!strcasecmp(sep->arg[1], "disconnect"))
{
if(zone->pathing)
{
if(!strcasecmp(sep->arg[2], "all"))
{
zone->pathing->DisconnectAll(c);
}
else
{
zone->pathing->DisconnectNodeToNode(c, atoi(sep->arg[2]));
}
}
return;
}
if(!strcasecmp(sep->arg[1], "move"))
{
if(zone->pathing)
{
zone->pathing->MoveNode(c);
}
return;
}
if(!strcasecmp(sep->arg[1], "process"))
{
if(zone->pathing)
{
if(sep->arg[2][0] == '\0')
return;
zone->pathing->ProcessNodesAndSave(sep->arg[2]);
c->Message(0, "Path processed...");
}
return;
}
if(!strcasecmp(sep->arg[1], "resort"))
{
if(zone->pathing)
{
if(!strcasecmp(sep->arg[2], "nodes"))
{
zone->pathing->SortNodes();
c->Message(0, "Nodes resorted...");
}
else
{
zone->pathing->ResortConnections();
c->Message(0, "Connections resorted...");
}
}
return;
}
if(!strcasecmp(sep->arg[1], "hazard"))
{
if(zone->pathing)
{
if(c && c->GetTarget())
{
if (zone->pathing->NoHazardsAccurate(glm::vec3(c->GetX(), c->GetY(), c->GetZ()),
glm::vec3(c->GetTarget()->GetX(), c->GetTarget()->GetY(), c->GetTarget()->GetZ())))
{
c->Message(0, "No hazards.");
}
else
{
c->Message(0, "Hazard Detected...");
}
}
}
return;
}
if(!strcasecmp(sep->arg[1], "print"))
{
if(zone->pathing)
{
zone->pathing->PrintPathing();
}
return;
}
if(!strcasecmp(sep->arg[1], "showneighbours") || !strcasecmp(sep->arg[1], "showneighbors"))
{
if(!c->GetTarget())
{
c->Message(0, "First #path shownodes to spawn the pathnodes, and then target one of them.");
return;
}
if(zone->pathing)
{
zone->pathing->ShowPathNodeNeighbours(c);
return;
}
}
if(!strcasecmp(sep->arg[1], "meshtest"))
{
if(zone->pathing)
{
if(!strcasecmp(sep->arg[2], "simple"))
{
c->Message(0, "You may go linkdead. Results will be in the log file.");
zone->pathing->SimpleMeshTest();
return;
}
else
{
c->Message(0, "You may go linkdead. Results will be in the log file.");
zone->pathing->MeshTest();
return;
}
}
}
if(!strcasecmp(sep->arg[1], "allspawns"))
{
if(zone->pathing)
{
c->Message(0, "You may go linkdead. Results will be in the log file.");
entity_list.FindPathsToAllNPCs();
return;
}
}
if(!strcasecmp(sep->arg[1], "nearest"))
{
if(!c->GetTarget() || !c->GetTarget()->IsMob())
{
c->Message(0, "You must target something.");
return;
}
if(zone->pathing)
{
Mob *m = c->GetTarget();
glm::vec3 Position(m->GetX(), m->GetY(), m->GetZ());
int Node = zone->pathing->FindNearestPathNode(Position);
if(Node == -1)
c->Message(0, "Unable to locate a path node within range.");
else
c->Message(0, "Nearest path node is %i", Node);
return;
}
}
c->Message(0, "Unknown path command.");
}
void Client::Undye() {
for (int cur_slot = EmuConstants::MATERIAL_BEGIN; cur_slot <= EmuConstants::MATERIAL_END; cur_slot++ ) {
uint8 slot2=SlotConvert(cur_slot);