Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[CONTRIBUTION] Quake-style multiplayer code download! #318216
04/06/10 03:14
04/06/10 03:14
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline OP
Serious User
Redeemer  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Hello fellow forumites!

It is time to unveil my first real contribution: some quake-style multiplayer code written in C-Script! The code is a little long but pretty well commented. With a little effort, someone can easily port it to Lite-C.

The server handles 90% of the game; the only thing the clients handle is input. This means for every client added, there is very little bandwidth usage. It is also very difficult for clients to cheat, and if the server changes something in the world (ie gravity) then all the clients are affected!

Other features:
-cooperative/deathmatch game modes
-6 different AI types included for cooperative mode
-2 different player weapons (more can be added easily)
-some silly test assets I made! tongue

known issues:
-players are invincible; I didn't take the time to include dying/respawning routines.
-if a client joins the game before the server starts a map, then all the players will spawn at the same location

You can download the whole package at my personal homepage, under the "Projects" section:
http://redeemer812.110mb.com/

I'd give you a direct link to the package, but my host doesn't want me using my account like it's a file server. I don't want to push them.

Anyway, enjoy the code, and remember to read the "readme" file included in the archive! Questions and comments are welcome. laugh


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: Redeemer] #318219
04/06/10 04:24
04/06/10 04:24
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
just a few questions? am already doing an MP but am sure this code will help others, so...

does your AI do anything? what do you have pertaining to AI code? path finding?

why is it hard to cheat? server checks? such as what? speed checks? wall checks? what?

Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: darkinferno] #318244
04/06/10 11:54
04/06/10 11:54
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Well, thank u for that contribution; I guess it was much work to code all that, and its very kind to make it public.
However, with the engine version 7.82 I get an error right at the beginning, when testing the rumble_main.c:

Dangerous instruction in event event_wait;
result = c_trace(my.x,you.x,ignore_me+ignore_passable+ignore_sprites);

I guess that is due to the engine version; will probably test your code with another engine version later.

Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: the_clown] #318247
04/06/10 12:02
04/06/10 12:02
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
I dont have comm version but I'm downloading this anyway. I think I can use the AI, thanks laugh

Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: bart_the_13th] #318269
04/06/10 14:50
04/06/10 14:50
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline OP
Serious User
Redeemer  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Thank you for the feedback. This isn't a very large contribution, but if it helps you learn how to make a simple quake-style shooter, then I've done my job. laugh

Now your questions:

@darkinferno:
Quote:
does your AI do anything? what do you have pertaining to AI code? path finding?


The AI is a simple state machine involving waiting, hunting, attacking, and dying states. Here's a simple AI map:

WAIT:
-if health is to low, go to DIE state.
-stand still, look for player.
-if player is detected, go to the HUNT state.
-else: repeat

HUNT:
-if health is to low, go to DIE state.
-look for player.
-if player is visible, remember his location and move toward him.
-if player isn't visible, move toward to his last seen location.
-if the player is within a certain range and he is visible, go to ATTACK.
-else: repeat.

ATTACK:
-fire a bullet
-go to HUNT

DIE:
-play death animation, remove senses, etc.

It's not complex by any means, but it works well enough.

Quote:
why is it hard to cheat? server checks? such as what? speed checks? wall checks? what?

It's difficult to cheat using my system primarily because the ONLY thing the client does is send input values to the server. The server handles all movement, collision, attacking, monsters, etc.

Essentially if the client wants to move forward, the server will determine how fast it moves and where it ends up. I imagine there are still ways to cheat here, but it's much more reliable than using a client-based movement system.

@the_clown:
Quote:
with the engine version 7.82 I get an error right at the beginning, when testing the rumble_main.c:

Dangerous instruction in event event_wait;
result = c_trace(my.x,you.x,ignore_me+ignore_passable+ignore_sprites);

I guess that is due to the engine version; will probably test your code with another engine version later.

You can fix this by placing a "wait(1);" instruction before the c_trace() instruction. I would've done this myself, but in my version of Gamestudio I don't get this error message, so I didn't think about it.

Once again, thanks for the feedback.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: Redeemer] #318280
04/06/10 16:41
04/06/10 16:41
Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
Roel Offline
Senior Member
Roel  Offline
Senior Member

Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
Neat work!
I have a little question:

some time ago I tried to write a multiplayer system for games,
but I ran into a little problem...

I used the same thing you use:
clients do input, server does movement

everything runs fine, but when the server runs at a different frame rate than the
client, the game shocks.
Now, I was wondering how you worked around this.

again, it is a very good contribution.
the fact that it is in C-script shouldn't be a real problem.
Thank you!


Check out the throwing game here: The throwing game
Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: Roel] #318285
04/06/10 17:03
04/06/10 17:03
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline OP
Serious User
Redeemer  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Quote:
everything runs fine, but when the server runs at a different frame rate than the client, the game shocks.Now, I was wondering how you worked around this.


I used to have this problem. To fix it, you have to set the "dplay_smooth" variable to 0 so the client doesn't try to smooth any delayed movements.

An alternative solution is to write code that allows the client to see immediate feedback from a key press, by having the client move himself. The server then moves the client itself and "corrects" the client, so you get immediate feedback but the server ultimately has control. This method is more complicated, however, and I never used it.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: Redeemer] #318306
04/06/10 22:18
04/06/10 22:18
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
so the server does all movement? doesnt that feel laggy to the clients at times? does it just interpolate between the positions on the client? or you have some algorithm to blend between player and updates? i only asked because i switched my movement to client side only, 16 players server side becomes a lagfest in most cases i've seen

Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: darkinferno] #318319
04/07/10 03:12
04/07/10 03:12
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline OP
Serious User
Redeemer  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Quote:
so the server does all movement? doesnt that feel laggy to the clients at times?

Under a LAN, no. But if the ping times between the client and server are great enough, it can cause a problem.

I'd like to point out that the goal of this contribution was to show how a simple multiplayer FPS might be done for LANs. It's definitely not a good example of a high quality multiplayer system, but it helps show you where to get startede. The users are encouraged to use this system as a base for larger, better projects, or just for learning purposes.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: [CONTRIBUTION] Quake-style multiplayer code download! [Re: Redeemer] #318321
04/07/10 04:31
04/07/10 04:31
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
ahh now i understand your aim, well you did great, it'd be good to see this ported to liteC, my game is pretty much too complex so releasing the source code isnt a plan of mine.. but i really like what you did, tho i never played it.. you however need to handle your GUNplay different in your future projects tho.. meaning, make shooting feel more believable.. anyways, great contribution. laterS


Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1