Quote:1. Do most of you broadcast NPC position from server to clients or do you sent the destination from the server to clients and let clients *move* the npc instead?
Client moves them.
Quote:1a. If your sending the destination from server to client and allowing client to *move* the NPC, how are you maintaining client/server synchronization regarding position, angle, fov etc... ?
The server, a server has NPC's just like a normal client, however this server does all the pathfinding.
Pathfinding is a set of linear interpolations, call them points. the server calculates arrival time for when each point, also take rotation into consideration as some NPCs might have different rotation speeds.
pseudo : timeOfArrival = unitDist / unitPerSecond + rotation / rotationspeed
Send this information off to the client and let the client move its units according the the pre-calculated points and it's arrival time-stamp.
Each other frame or so, check if it has yet arrived at the first point and check if the time-stamp has been passed, if so then you can either speed it up alot till it gets there or simply place it there manually. Keep in mind that if it has slowed down too much and haven't reached the point and it's 2 seconds passed the server time keep that number and place it on the linear interpolation between the next points according to arrival time / distance roughly.
Also each time an Attack or new Movement is sent you could send current position as-well and if they are different make the client set it to that position instantly.
Server sends both spawn and deletion when it comes to FoV. Also anytime you receive that a player has targeted and wants to attack or so, do check on the server to see that the distance between the player and npc is valid for the action.
*There's tons more of thoughts but it's too much to keep ontop of your head.
Quote:1b. If your broadcasting NPC position from server to clients, do you find it consumes excessive bandwidth in large npc population areas? How do you throttle it down?
Spatial Partitioning : Divide your whole world into sub areas (Already done by EE but might have to do it on your own if you do not want to load some specific world data onto a Server, this also applies to Pathfinding) <- There are solutions for these and I could provide with few solution ideas.
Only do some updates to NPC if there are any "Neighbor" objects in sight, meaning that do not update its position etc if there's no players in it's FoV, etc.
Spatial Partitioning means that you can divide it into X amount of sub areas which means that instead of looping through 100's of players you might be dealing with a loop of 5.
watch out for O(n^2). A Spatial Partitioning system should reduce the amount of them.
Quote:2. Do you create an external process which connects to server on a socket just to handle all NPC processing? or do you process everything from a single server application?
For now it's a standalone code meaning that nothing is seriously bound to another part of the Server, but yet only one server developed.
What this means is that when the day comes that the server is actually turning out being slow I could simply pass it onto a second server without massive amount of development time.
Keep performance killers on a separate thread if you can, see it as if you were to create an IOCP Server. Worker thread and so on. <-- Be careful about this so you do not slow it down instead of giving it speed.