Manage NPC Server Side?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

RuggeriExtreme
Posts: 63
Joined: 04 Aug 2013, 13:02
Location: Italy
Contact:

Manage NPC Server Side?

Postby RuggeriExtreme » 30 Mar 2014, 01:11

Hi everybody,
i need a solution to manage the NPC in the server side.. First i need that NPC has the same position and rotation in all clients..
The methods that i thought are two:

1) Select the first client that comes close to animal as 'manager of the animal', after this, the client calculates with pathfinding the path of the animal and it updates periodically the position of the animal across server-all clients; Problem: if a client lag, the position-rotation of the animal is not updated and other clients display the animal arrest and no-fluid. Another problem is that the client can cheats in any way.

2) Select the first client that comes close to animal, in the server side, as the 'chased player', then the server updates all client with this information, after this, all clients calculates with pathfinding the path to chase the selected player and move the animal. Problem: the position and rotation of the animal in the client are not synchronized with other clients, another problem is that the server has not a position-rotation of the animal, then he can't check if any bullet/arrow hits him.

Complicated solution that i search:
-1 Recreate a pathfinding system likewise to NavMesh of unity in the server side, then, the server with pathfinding system calculates the path for reach a target position and periodically it updates all clients with updated informations.

Do you have any solution? Thanks in advance!
Zanpher
Posts: 96
Joined: 05 Oct 2009, 23:15

Re: Manage NPC Server Side?

Postby Zanpher » 01 Apr 2014, 20:20

You could have a "NPCManager" class that gets executed say ... every 100ms by the scheduler. Let it handle all the npcs in the game, or have one per room. Let it determine how npcs should move, act and react. There are some source codes around showing how to do that in other languages and games (Mirage Online comes to mind). It sounds like you are trying to figure out a solution to the NPC tax / license. That is the way I went though.
RuggeriExtreme
Posts: 63
Joined: 04 Aug 2013, 13:02
Location: Italy
Contact:

Re: Manage NPC Server Side?

Postby RuggeriExtreme » 03 Apr 2014, 22:54

Zanpher wrote:You could have a "NPCManager" class that gets executed say ... every 100ms by the scheduler. Let it handle all the npcs in the game, or have one per room. Let it determine how npcs should move, act and react. There are some source codes around showing how to do that in other languages and games (Mirage Online comes to mind). It sounds like you are trying to figure out a solution to the NPC tax / license. That is the way I went though.


hi, thanks for the reply, in this case the problem is not where to manage the npc in the server, instead the problem is how calculate a new position for the npc by the server with a pathfinding system in the server..
Can you link me some examples?
Thanks in advance.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 106 guests