View Single Post
  #1  
Old 07-07-2019, 12:37 PM
dclarkpf
Fire Beetle
 
Join Date: Jul 2005
Location: Grants Pass, Or
Posts: 20
Default Quickly add missing spawns.

I'm probably missing something.. but I just wanted to throw this up here, in case someone else finds it useful...

This code allows you, as a gm, to target a mob and the created a new spawn location for that spawn group exactly where you are standing.
I uses #spawnadd after targeting a mob. It will make the targeting mob disappear.
Then #repop and you should see both the mob you targeted and the new spawn location populate with mobs. (of course the whole zone repops because of this)

To make this code work.. First make a back up of your code, so you can always revert to the original. Insert the following code in to the correct files, recompile, and restart your server.

Insert this in command.h
Line 290
Code:
void command_spawnadd(Client *c, const Seperator *sep);
Insert this in command.cpp
Line 383
Code:
command_add("spawnadd", "- Add a new spawn point for spawngroup at your location/heading.", 170, command_spawnadd) ||
Insert this in command.cpp
Line 5435
Code:
void command_spawnadd(Client *c, const Seperator *sep) {
    Mob *targetMob = c->GetTarget();
    if (!targetMob || !targetMob->IsNPC()) {
        c->Message(0, "Error: #spawnfix: Need an NPC target.");
        return;
    }

    Spawn2* s2 = targetMob->CastToNPC()->respawn2;

    std::string query = StringFormat("SELECT spawngroupID, zone, version, respawntime, variance, pathgrid, _condition, enabled, animation from spawn2 where id='%i'", s2->GetID());
    auto results = database.QueryDatabase(query);
    if (!results.Success()) {
        c->Message(0, "We couldn't find the targeted mob in the spawn2 table.");
        return;
    }

    auto res = results.begin();
    query = StringFormat(
        "insert into spawn2 (spawngroupID, zone, version, x, y, z, heading, respawntime, variance, pathgrid, _condition, enabled, animation) values (%s,'%s',%s,%f,%f,%f,%f,%s,%s,%s,%s,%s,%s);",
        res[0], res[1], res[2], c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(), res[3], res[4], res[5], res[6], res[7], res[8]);

    results = database.QueryDatabase(query);
    if (!results.Success()) {
        c->Message(13, "Update failed! MySQL gave the following error:");
        c->Message(13, results.ErrorMessage().c_str());
        return;
    }

    c->Message(0, "Adding new spawn successful. targetMob->GetID=%i", targetMob->GetID());
    targetMob->Depop(false);
}
Reply With Quote