Jump to content
  • Advertisement
Sign in to follow this  
Malba Tahan

Best multiplayer code for co-operative FPS

This topic is 3790 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm planning to create a co-operative only multiplayer First Person Shooter in C++. I'm not planning to add deathmatch, ctf, or anything like that: there are enough deathmatch shooters out there. But I found it very difficult to code the best multiplayer protocol. Some ideas I've come up with: 1) Since it will be cooperative play only, I have no interest in preventing cheats over the net. 2) Monster AI should be simulated on the clients, as I see no reason to send tons of entity state changes over the network each frame update. Until now, I have analyzed the following multiplayer protocol: a) The Duke Nukem 3D multiplayer code: It's peer-to-peer, lockstep, the whole simulation is done in each machine. Uses dead reckoning to hide lag. b) Age of Empires (I and II), although it's not a FPS, seems to use something like Duke3d code. But it's too laggy for a FPS. c) The Cube Engine multiplayer code. Each client dictates its own position, so there's absolutely no lag for their own input. No problem, since I don't care about cheats. But the code lacks support for entities like monsters. d) The Quake 2 multiplayer code: Client/server mode, transmits only entity changes at each frame. Tons of enemies at the same time could ruin the gameplay because it would occupy all bandwidth. e) Serious Sam multiplayer engine: Seems to be the obvious choice, because it supports cooperative play, huge amounts of monsters at the same time, and I've noticed absolutely NO LAG!! Does anyone have any idea how do they do it?? Which multiplayer algorithm should I implement? It should use UDP for better performance, of course! Please, someone help me, I'd like some advice before I start coding my game. Google was not my friend this time. Thanks in advance, Malba Tahan

Share this post


Link to post
Share on other sites
Advertisement
You can use either the lock-step method, with forward extrapolation, or you have to live with the fact that the clients will not be in sync, and client-side AI will diverge.
You can have the owner of AI send out a "plan" for what it will do for the next few seconds, so that you don't use too much bandwidth. That'll save a bunch compared to sending entity states every tick for each AI entity.

Share this post


Link to post
Share on other sites
I will be forced to program such a protocol soon, too.

When i read the posts of this thread, my first idea was:
Why don't you share your AI over the network.
There could be a list of entities, each one has its own id, and before starting the game/map, it could be handled out with the coop-clients, who will control a part of the ids.
-> This could increase ai-performance (less objects to simulate).

you would only need to update the position and direction, maybe sometimes an animation change or something.

The idea is, that you could precompute the position/action of the enemy in the next second or 2 seconds and send this to other clients, while receiving there precomputations.

Or you cold completely control the entities by each client.

id of entity = 4bytes (should be enough)
position -> 3 double's for x,y,z = 3x8bytes = 24bytes
rotation -> 2 floats for horizontal/vertical values = 2x4bytes = 8bytes

total = 36bytes

Now with 2.000 monsters (hopefully your engine will work with this amount of monsters! ;) ) it would be 72kb/sec.

Well i think it is too much, maybe it is possible to collect the new positions, compress them, and then send them. This for each client, this would mean, if there are 2 players:
one client has to calculate only 1000 entities, and send/receive 36kb/36kb per second (uncompressed).

hmmm, this is just an idea.

Maybe someone knows a better solution

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!