Moving an NPC to a different map

05/31/2023 08:44 KingGannon#1
I'm trying to make a NPC that moves to a different map from the Player Client every time you talk to the NPC.
Yes, it sound familiar to the BlueMouse NPC.
No, it has nothing to do with the BlueMouse and nothing to do with Richard the Thief NPC.
I had made at the other post where you talk to that NPC and it moves around the map or to a different map. To which I had succeeded in making the NPC move around to a different part of the map as long as the NPC is in the same as the map as the Player.

This time I want to make make this NPC move to another map. I'm getting this NPC to move into a map that has no NPC, Spawns, Portals etc. no objects. The Player has to change maps in order to find this NPC. Unlike the BlueMouse, there is no chance this NPC will spawn in the same map as the Player.

Any help would be appreciated.
05/31/2023 18:11 Spirited#2
I don't think it needs to be super complicated. If you don't want the NPC location to persist across server restarts, then you can just update it in memory. Aka. remove it from the current map and (if successful then) add it to the new map. That's assuming your map system / screen system both handle adding and removing NPCs in real-time.

If you want those locations to persist, then maybe you could have the NPC dialog script write to the database. Expose a new "UpdateSpawn" function or something. That way, you avoid having to make new tables and such for dynamic spawn locations.
06/01/2023 02:03 KingGannon#3
All right then keeping it simple
I do the same thing as I did to move the dynamic location NPC around. The only difference this time is in order to spawn the NPC to the new map I can either use the Map Insert function by searching up the Unique MapID then NPC ID and then use the NPC ID as the object to Insert into the new map.

Otherwise, I can create a new function which I prefer to avoid doing for the whole Map class editing.
And I don't need to rewrite the database either.

Am I on the right track?
06/01/2023 02:22 Spirited#4
Quote:
Originally Posted by KingGannon View Post
All right then keeping it simple
I do the same thing as I did to move the dynamic location NPC around. The only difference this time is in order to spawn the NPC to the new map I can either use the Map Insert function by searching up the Unique MapID then NPC ID and then use the NPC ID as the object to Insert into the new map.

Otherwise, I can create a new function which I prefer to avoid doing for the whole Map class editing.
And I don't need to rewrite the database either.

Am I on the right track?
Adding methods is a best practice. If you have a method that's longer than 25 lines, then generally you want to split that up. If you already have a method for adding an NPC to a map using the Map class, then for sure use that. If you don't though, then this could be a good opportunity to create a method like that. Totally up to you, though - I'm not familiar with what source you're using.
06/01/2023 02:37 KingGannon#5
This is for Redux source and the client v5065.

Since I had written a long line of code for more than 2 NPCs by now.
I figured as much that you will tell me to create a method so I can call up that method the next time I decided to create a similar NPC.

Many thanks by the way.
If it weren't for your help I'd probably be complicating this far more than it needs to be.