Jump to content
  • .npc move Command does not work


    guisadop
    • Status: Not a bug
      Main Category: Core / Mangos Daemon
      Sub-Category: Game Master
      Version: 21.14 (Master Branch) Milestone: Unset Priority: New
      Related to:
      Implemented Version: Unset

    The ".npc move" command does not work. This has been the case for a few years already.

    What happens: the NPC just respawns at its original location.

    What should happen: the NPC should respawn exactly where the player is.

    How to reproduce: target any NPC and type .npc move as a GM character.

     

    UPDATE: upon further testing, I realized that the NPC is moved after the database is reloaded, which means the problem is with the respawn code, as DB-wise it works as it should. I will continue to investigate.


    User Feedback

    Recommended Comments

    SOLVED!

    I don't know what was wrong with the old code. My guess is that the NPC respawn code uses NPC location data loaded at initialization, so the NPC was respawning at the same location even though its location in the database was being changed correctly.

    What I did was: I replaced the code for the HandleNpcMoveCommand on CreatureCommand.cpp with one call for HandleNpcAddCommand and one call for HandleNpcDeleteCommand. I also modified HandleNpcAddCommand to add a copy of the NPC you're targeting in case you don't provide an input argument. This way a copy of the NPC gets added, then the old NPC gets deleted. It's not as clean OR as efficient, but since you're not going to be using this command a lot it really just works :) 

    This is my code:

    https://pastebin.com/ZHAw128S

    Just realized there's still some debug lines there :P anyway, I hope this helps anyone who's having a problem with this command as I was having. EasyBuild really makes it easy to test stuff like this.

    Link to comment
    Share on other sites

    Unfortunately, the proposed way is incorrect. Every NPC is identified by a `guid` field in the DB (GUID = Global Unique ID), renamed to the SpawnId in the current TC. This "DB GUID" may be used in several other DB tables, for example, game_event_creature or creature_linking. Your approach will surely change the NPC DB GUID; even if you delete it first and add it second, you won't get the old DB GUID for it back. Also, NPC removal doesn't care for cleaning up any reference to the NPC in the other tables.

    In other words, you destroy much more than you gain.

    The `creature` table is not reloadable as well. You have to restart the whole server. It's due to a reason, again. A proper way might be changing the in-memory (i.e. loaded) image of the table along with the respective DB content. It's not so simple because you have to show the change to the every client connected that knows of the changed NPC.

    Link to comment
    Share on other sites


    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use