Networked Multiplayer Deathmatch Template [2 or more players] WIP

Hi there,
This is another template for network multiplayer. This is like a deathmatch (actually not a FPS, sorry)
I made a lot of improvements over the first version.

  • Server and client are in a single file (but in different scenes)
  • This version uses only non-blocking sockets. So, it does not freeze blender and don’t need multithreading
  • Interface to choose run server, or type server IP address and run client
  • Real multiplayer. 1, 2 3,…, 20, 400 players can join the game. It is limited only by server memory and network lag. You can use this in your MMORPG ( it’s a joke !!! Check posts below)
  • On screen message log

What is missing:

  • Detect clients disconnection to remove avatars from game. (I already did it, but the script simply disapeared :()
  • Detect when client fall from arena and send a “frag” message (and count “frags”)
  • Some UV scroll on tank movement

How to test (in one single machine):

  • Open multiple Blender instances with the tank.blend file and position windows side-by-side (you can see 4 blender instances in the pic below)
  • Run (“P”) the game engine in all Blender’s
  • Choose one Blender to run server (click “Run as Server”)
  • Choose the remaining Blenders to run client (click “Run as Client”)
  • Use WSAD in a client to move the tank. Arrows to aim the turret. Space to shot
  • See action sychronized in all blender’s

How to test (in a network):

  • Chose someone to be the server (everybody must know the IP addres of the server machine)
  • Run Blender (tank.blend) on server machine and click on “Run as server”
  • Run Blenders (tank.blend) on other machines. Type the server IP address and click “Run as client”
  • Try a deathmatch (and tell me if it works :o)

I tried to put a lot of comments in the network code to help people understand it. But what people must be aware is that the network code is not the hard part. The most complex task in any networked multiplayer game is to define and control the communication protocol and synchronization messages and procedures.
I wil try make this a complete game

There it is:
http://www.4shared.com/file/82320784/232ff1b3/tank.html

PS: Linux users. Plz, tell me if it works in your linux box

Attachments



awesome!

we really need more multiplayer games :slight_smile:

me and p00f want to make a chess like game to play online.

thank you :slight_smile:

ooh this looks effin sweet, I’m downloading it in a sec…

Hello
not working on my Debian/GNU Linux

Here’s the messages:
PYTHON SCRIPT ERROR:

Traceback (most recent call last):
File “NWC_ReceiveState”, line 9, in ?
File “/usr/lib/python2.4/threading.py”, line 13, in ?
from collections import deque
ImportError: /usr/lib/python2.4/lib-dynload/collections.so: undefined symbol: _PyArg_NoKeywords
Compiled with Python version 2.4.1.
Checking for installed Python… got it!

Bye and thank you

Thanks OTO.
It looks something wrong with your threading module. Well, i am not actually using it (but i forgot to remove the import command from the scripts). I posted a version without this imports. If you can test it again …

http://uploaded.to/?id=6ymlk9

Wow, this is awesome, I just hope those people who are looking to make MMORPG’s don’t become harder to persuade :wink:

:yes:Wow, really nice.

Heh, wasn’t able to test it out on my old labtop, but will try it out with my desktop later on. Is this only for network or does it work over the internet too? Haven’t tried that yet either.

Morgade, if it’s not too much of a hassle, would you be able to explain what parts of the code would be hackable to be customized for different multiplayer games.

In particular…

  • which places send/receive message pertaining to the player
  • how that information is used, etc.

Jason Lin

Very cool!

Maybe some more mmorpgs aren’t too far into the horizon as some of us thought? :slight_smile:

Thanks Morgade!

lol an mmorpg would be fun to do. it sounds like a great community project…

Hello again

now, it seems to work!!
I could connect Player 1 and there’s no error messages.
Nice work!
Bye

for me it’s working on ubuntu (6.10 and 7.04) with network on LAN …but it’s not “fast” … the animation drops at 15/20 fps with lag with “outside” and “services” using the CPU almost at 100% together … with only 2 clients …
I think that from this, we are long time ago in a galaxie far, far away from having a MMORPG structure …

but it’s a good start … ! :slight_smile:

Also, the disconnecting feature is VERY important … the whole system is pointless if it’s not able to wipe out disconnected player, at least after some time of idle…

mm… A lot of things can be happening. Coding a network game server requires a lot of hacking. It’s needed to optimize sockets buffering use, message sending interval, position interpolation in clients, delay workarounds, etc… The CPU charge could be saved if you use a lower buffer size in the recv operations (try changing it to 512 instead of 4096 in the ReceiveState and ReceiveInput scripts). The lag could be caused by network problems, or lower operation system UDP datagrams queues (causing message dropping). Or even you are noticing the LogicTicRate set to 30 (state being synchronized only 30 times per second to avoid network flooding). Finally, check if some unexpected error are being printed every frame in the console, making everything slower.

The MMORPG thing in my post was just a joke. A MMORPG server is a real complex system. You can create a MMORPG client with Blender, but i doubt someone can create a robust server. The server could be more easily created in something like Java or C++ (and it sill can use Bullet physics).

I will try to add this soon. It’s just an Always sensor pulsing every 3 seconds to a python script that checks the state of all TCP client connections, and remove objects related to clients with invalid TCP state.

  1. is it open source, or do you want royalties to further development? (beer? pizza? cake?) :eyebrowlift2:

  2. going to check thouroughly when I get home from work, but eh, do you mind if I cannibalise the code and game mechanics for another project? (off course I’ll make any cough improvements cough on the network engine available).

  3. yes, I know, I’m sucha a lazy programmer I don’t even take the time to code it myself. :o

(the coughing is mostly due to me not being a good programmer, and that I suppose I won’t be able to do anything but bog the network code down, but at the very least, I’ll give it a try).

The MMORPG thing in my post was just a joke. A MMORPG server is a real complex system. You can create a MMORPG client with Blender, but i doubt someone can create a robust server. The server could be more easily created in something like Java or C++ (and it sill can use Bullet physics).

well … I understood that =^^= …

From my point of view, a MMORPG is not only a problem of network coding, but also a content production question… it needed millions of bucks to blizzard to build WoW, so of course, we’re not playing in the same court…

For the multiplayer server part, I think it could be done in python also, and maybe the BZoo project could give some ideas. (don’t know if it’s still alive …)

Here, I tried to reduce the buffer but it didn’t change anything… and no error in the console…

I understand this is some hard work, it’s why I did reply with what I found on my systems (and the fact that it works with lan on linux)… I’ll look further to see if another machine has the same problem as server, as I tested this on an AMD64 build that I don’t trust completely.

keep up the good work !!

Just poking my head in to tell people that it seems to be working, for me, running 6 clients on the same computer gets a little laggy and weird but it passed the crucial test: it didn’t crash my old’n buggy computer :smiley:

Open Source. You can send me some bucks if your game become the next WoW

Go ahead.

I know ! I emphasized the joke because suddenly i realized that most people reading the post could take it serious ! :o

Mmm… I know it’s like to argue about religion, but actually I’m not a Python fan. I think that static typed languages (like C# or Java) are better than dinamically typed (like Python) to implement big projects like a game server.

aw man morgrade this is awsome :). Your going in my credits list whether you like it or not, lol.
Thanks for this, Chuzzy

i keep getting ‘import error: no module named socket’

can someone help

simply, fast and works fine
excellent work
in the future
it wanted to play fps with some of this page .

You need Python installed in your computer to run it
Probably you don’t have it installed, or your Python installation is broken