diff --git a/zone/command.cpp b/zone/command.cpp index c48bbd685..c973f6cb4 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -6469,21 +6469,27 @@ void command_npcspawn(Client *c, const Seperator *sep) } void command_spawnfix(Client *c, const Seperator *sep) { - Mob *targetMob = c->GetTarget(); - if (!targetMob || !targetMob->IsNPC()) { + Mob *target_mob = c->GetTarget(); + if (!target_mob || !target_mob->IsNPC()) { c->Message(Chat::White, "Error: #spawnfix: Need an NPC target."); return; } - Spawn2* s2 = targetMob->CastToNPC()->respawn2; + Spawn2* s2 = target_mob->CastToNPC()->respawn2; if(!s2) { c->Message(Chat::White, "#spawnfix FAILED -- cannot determine which spawn entry in the database this mob came from."); return; } - std::string query = StringFormat("UPDATE spawn2 SET x = '%f', y = '%f', z = '%f', heading = '%f' WHERE id = '%i'", - c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID()); + std::string query = StringFormat( + "UPDATE spawn2 SET x = '%f', y = '%f', z = '%f', heading = '%f' WHERE id = '%i'", + c->GetX(), + c->GetY(), + target_mob->GetFixedZ(c->GetPosition()), + c->GetHeading(), + s2->GetID() + ); auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); @@ -6492,7 +6498,7 @@ void command_spawnfix(Client *c, const Seperator *sep) { } c->Message(Chat::White, "Updating coordinates successful."); - targetMob->Depop(false); + target_mob->Depop(false); } void command_loc(Client *c, const Seperator *sep)