Go Back   EQEmulator Home > EQEmulator Forums > Development > Development: Custom Code

Development: Custom Code This is for code thatdoes not emulate live and wont be added to the official code.

Reply
 
Thread Tools Display Modes
  #1  
Old 07-07-2019, 12:37 PM
dclarkpf
Fire Beetle
 
Join Date: Jul 2005
Location: Grants Pass, Or
Posts: 18
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
  #2  
Old 07-07-2019, 02:13 PM
Huppy
Dragon
 
Join Date: Oct 2010
Location: Canada
Posts: 760
Default

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.");
__________________
All our operators are busy.....please hold .....
Reply With Quote
  #3  
Old 07-07-2019, 11:34 PM
dclarkpf
Fire Beetle
 
Join Date: Jul 2005
Location: Grants Pass, Or
Posts: 18
Default

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.
Reply With Quote
  #4  
Old 07-07-2019, 11:44 PM
Huppy
Dragon
 
Join Date: Oct 2010
Location: Canada
Posts: 760
Default

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 View Post
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)
__________________
All our operators are busy.....please hold .....
Reply With Quote
  #5  
Old 07-08-2019, 01:17 AM
dclarkpf
Fire Beetle
 
Join Date: Jul 2005
Location: Grants Pass, Or
Posts: 18
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:22 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3