Okay, now I come to deal with enemies in the game, and got some questions about how to handle them. Do you have enemies, and "players" in the same list or in separate lists? or an separate server( Npc server )? and how do you update themselves, and what kind of information containing your updates? I've made it so updated only enemies that are in range from the player and contains position, velocity, animation, type, etc. And deal with them in the same list of players they are but of another type "OBJ_ENEMY" And every object that has this type will run a "AI_Update procedure" As contains a simple AI such as check on a player is inrange, if it is the send packet to move this player etc, but the question is how you would handle your way to manage enemies in an online game.
My questions are :
1) Server have to manage player, but most generally the world too. I wonder if the best way to do, it is to have two servers : one for player management, and to distribute informations, and another to gouvern the world?
2) I wonder how NPCs are managed by the server, and more precisely collision management? Must I write same code engine as the client ( with newton for example), to be sure that the mesh collision are right? Or must I dedicated this job to the client, which informs the server if there is a default in the path way provided?
3) Lot of information must be provided to players, I don't know rythm to refresh information to player.
I know of some MMORPG's, like The Saga of Ryzom, they have dedicated server binaries for all kinds of subtasks, like NPCs, weather, etc. That way, a crash of a server won't bring down your whole shard.
Ohter question I have is, Is it smart to use like newton physics on the server part? To handle the collisions and updates for the clients( correct positions ) etc or how will you manage it? and can be stripped to determine collision detection etc. The trouble with these libraries is they tend to be client-focussed, which can make them unwieldy when developing a server, both in terms of the size of the DLL / SO they produce and their demand for processor time. And I dont use the same meshes on the server as the client. Server meshes can just be bounding boxes for most objects etc.
Also frequency of updates to the client should be kept to a minimum (is here,starts walking in direction from point, stops walking, is here) rather than being updated of everything is here, is here, is here, is here, is here blabla...
WoW and/or Lineage2. Characters even don't get checked for collisions between themselves. May be I'm wrong, but as it seems to me, both of these games servers are based on a conception that "up is always up", that means, everything is going on a 2d map that can be represented by cells, Dont get me wrong here, Im not plan to make a game like this^^ Just want to know how it works.
Thank you very much!
Handle enemies in online games.
-
- Posts: 368
- Joined: Tue Aug 21, 2007 1:43 am
- Location: The Middle of Nowhere
Here is a simple rule you want to follow with your server: Never ever, under any circumstances, trust the client.
If you have the client sending you position or collision information, then you want to double check it, but it would be better to do the collision on the server and tell the client where it is.
It's boils down to this. Servers should be telling the client what to do and the client should be politely asking the server for things.
I've seen AI handled many ways. Planeshift uses a separate client for all it's NPC's that moves them around and handles interaction. I've also seen the main server handle it all. I've also seen AI handled as both separate entities or the same as any other player as far as the game is concerned. Really, it's up to you.
One thing you may want to check out is Protocol Buffers (http://code.google.com/p/protobuf/). It's a free SDK from google using the Apache license that they use to serialize data on most of their servers and applications. It should be useful when sending packets of information that contain variable amounts of data and it supports changing the data structure of the buffer without having to recompile older applications to support it. Unknown data is simply ignored.
Also, one more thing. You will have to tell every client where they are once in a while. Clients get out of step, either due to differing lag, computer freezes, or whatever. They will need a position to sync back to if they get out of step and they won't be able to tell the server that they are off because they can't detect that without server position information.
If you have the client sending you position or collision information, then you want to double check it, but it would be better to do the collision on the server and tell the client where it is.
It's boils down to this. Servers should be telling the client what to do and the client should be politely asking the server for things.
I've seen AI handled many ways. Planeshift uses a separate client for all it's NPC's that moves them around and handles interaction. I've also seen the main server handle it all. I've also seen AI handled as both separate entities or the same as any other player as far as the game is concerned. Really, it's up to you.
One thing you may want to check out is Protocol Buffers (http://code.google.com/p/protobuf/). It's a free SDK from google using the Apache license that they use to serialize data on most of their servers and applications. It should be useful when sending packets of information that contain variable amounts of data and it supports changing the data structure of the buffer without having to recompile older applications to support it. Unknown data is simply ignored.
Also, one more thing. You will have to tell every client where they are once in a while. Clients get out of step, either due to differing lag, computer freezes, or whatever. They will need a position to sync back to if they get out of step and they won't be able to tell the server that they are off because they can't detect that without server position information.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
-
- Posts: 368
- Joined: Tue Aug 21, 2007 1:43 am
- Location: The Middle of Nowhere
Those questions boil down to a matter of experience. I've seen them done many different ways with similar results.
For the MMO I'm working on, I treat AI as "players" in the server. They drive around the characters using the same commands as the player clients send to the server. They see and detect things by doing various tests from the position of the character entity they are controlling.
I'm also using PhysX for the server side physics, but that again is a matter of taste. From my experience with Newton, I don't see why it wouldn't work.
I store characters in an std::vector (although there may be more efficient ways). I then have multiple functions to search, add and remove items from this list. In fact, it's the way I store all game objects, each type of object gets it's own list and the programmer can search based on the type of entity they want.
For the MMO I'm working on, I treat AI as "players" in the server. They drive around the characters using the same commands as the player clients send to the server. They see and detect things by doing various tests from the position of the character entity they are controlling.
I'm also using PhysX for the server side physics, but that again is a matter of taste. From my experience with Newton, I don't see why it wouldn't work.
I store characters in an std::vector (although there may be more efficient ways). I then have multiple functions to search, add and remove items from this list. In fact, it's the way I store all game objects, each type of object gets it's own list and the programmer can search based on the type of entity they want.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.