EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development: Custom Code (https://www.eqemulator.org/forums/forumdisplay.php?f=665)
-   -   Quickly add missing spawns. (https://www.eqemulator.org/forums/showthread.php?t=42521)

dclarkpf 07-07-2019 12:37 PM

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);
}


Huppy 07-07-2019 02:13 PM

Using #spawnfix isn't enough ? (it's already in the commands) I noticed this in your posted code though:
Code:

c->Message(0, "Error: #spawnfix: Need an NPC target.");

dclarkpf 07-07-2019 11:34 PM

Thanks.. I figured that I was missing something. Based on what I read I thought spawnfix was for moving an existing spawn point, not creating a new one. I'll give it a whirl. I guess i'm just too quick to code.

Huppy 07-07-2019 11:44 PM

Sorry, I was going by this (that you posted), which #spawnfix does the same thing. You can use '#repop close' instead of repopping the whole zone.

Quote:

Originally Posted by dclarkpf (Post 262975)
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)


dclarkpf 07-08-2019 01:17 AM

No worries. I really try to look and see what is going on in the code, before I tweak something. But, there is just so much in there. I feel like I'm missing half of what the emu does.

Thanks for the #repop close. I'll definitely be using that from now on.


All times are GMT -4. The time now is 03:23 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.