PDA

View Full Version : #spawnfix command


Wolfman
06-15-2003, 01:42 PM
Here's a quick command I put together to fix spawngroups' coordinates and headings on the fly. Just target a mob and it automatically updates coords and heading, to the character you're currently using coords and headings, in the db. Use #repop for effects to instantly show up. Here's the diff file for it.



--- client.cpp 2003-06-15 21:25:24.000000000 -0400
+++ client.cpp 2003-06-15 21:08:29.000000000 -0400
@@ -4104,6 +4104,38 @@
else if (strcasecmp(sep->arg[0], "#npcspawn") == 0) {
NPCSpawn(sep);
}
+ else if (strcasecmp(sep->arg[0], "#spawnfix") == 0) {
+ if (target==0) {
+ Message(0, "Error: #spawnfix: No Target.");
+ }
+ else {
+ int32 tmp = 0;
+ char errbuf[MYSQL_ERRMSG_SIZE];
+ char *query = 0;
+ MYSQL_RES *result;
+ MYSQL_ROW row;
+
+ if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT id from spawn2 where zone='%s' AND x='%f' AND y='%f' AND heading='%f'", zone->GetShortName(), target->GetX(), target->GetY(), target->GetHeading()), errbuf, &result)) {
+ row = mysql_fetch_row(result);
+
+ if (row[0])
+ tmp = atoi(row[0]);
+
+ query = 0;
+ if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE spawn2 SET x='%f', y='%f', z='%f', heading='%f' WHERE id='%i'",this->GetX(), this->GetY(), this->GetZ(), this->GetHeading(),tmp), errbuf, 0))
+ Message(0, "Updating coordinates successful!");
+
+ delete[] query;
+ mysql_free_result(result);
+
+ }
+ else {
+ mysql_free_result(result);
+ Message(0, "Upating coordinates failed!");
+ }
+ }
+ }
+
else
return false;
return true;
@@ -4523,6 +4555,7 @@
Message(0, " #zsave [file name] - Save the current zone header to ./cfg/<filename>.cfg");
Message(0, " #dbspawn2 [spawngroup] [respawn] [variance]");
Message(0, " #npcspawn [create|add|update|remove|delete]");
+ Message(0, " #spawnfix - Fixes coordinates and heading for spawn groups");
Message(0, " #fixmob [nextrace|prevrace|gender|nexttexture|prevtexture|n exthelm|prevhelm]");
}
if ((strcasecmp(sep->arg[1], "debug") == 0 || strcasecmp(sep->arg[1], "all") == 0) && admin >= 201)



I've done some minor testing and didn't run into any troubles using it.

Trumpcard
06-15-2003, 02:23 PM
Thats really handy! I'm throwing this into CVS now.. I'm sure the database developers will really appreciate this one.


Just tested it out... Thats going to make modifying spawn placement so much nicer.. Once all the mobs are dumped into the zone, it'll be a cinch to place them using this.

Great update Wolf, thanks!

killspree
06-15-2003, 11:22 PM
Very nice, look forward to playing with this command. :)

used_pawn
06-16-2003, 11:42 AM
yay! :D
i kludge something similar into my own code, but i like yours better, hehe