I'm glad you like it, if I created a cloased game mode I'll upload a demo of it.
It won't be compressed so everyone who wants to can take a look into the code.
@Damocles
I'm using ONLY Skills for the communication.
Arrays just don't work for mp games, or you'd have to have an array for each player... *urgs*
Otherwise the data destroys itself and messes everything up.
Only for a few global things I'm using vars like for server logout or current level ID.
Skills are the key for mp programming, they give you the dynamic freedom you MUST have.
@msl_manni
Sure, I hope I can tell you clearly.
The main control skills I use:
1. _ActReq_ID - Clients send Requests to the server, those numbers stand for actions like move, attack, cast a spell ect., the server can create this IDs, too.
2. _ActReq_handle - A handle to an entity (if necessary) for example the actor I want to attack.
3. _Action_ID - The Server waits until an actor has finished his action, takes the _ActReq_ID, stores it into _Action_ID and sends it to everyone.
4. _Action_handle - The server takes or generates this handle (if necessary, depenting on the _Action_ID) and sends it to the clients together with the _Action_ID
5. _Action_target_X, _Action_target_Y, _Action_target_Z - This vector (if needed) can be created by the server (when attacking the server calculates where the actor has to move to, to attack) or the client (if he wants to move to a certain position), it is only send when needed and only used when the _Action_ID is an ID that needs it.
Now you know all skills that are necessary to control the game.
The _ActReq_ID and _ActReq_handle are only send to the server if a client makes a input (every 3 to 5 seconds or something like that.
So in normal case only the _Action_ID is send to the clients, sometimes the _Action_handle, too, and some cases the _Action_target_X skill-vector, too.
Movement target for attacks are being calculated by the server, the clients only tell they want to attack and which actor they want to attack.
Thus everyone recieves the movement-target position that is being calculated by the server and moves to this position.
- This is the key, why I do not need position updates! -
The server starts a function with proc_local() for each actor (player or enemy do not make any difference, everyone uses the same function), this function recognizes when _Action_ID is set and acts depending on the ID, from this point on, there is no multiplayer stuff needed any more, everything is done locally.
The function can turn the actor, calculate his speed, do his animation, start spell effects and all the other nice stuff.
Only the server calculates damage, evasion rate, critical hits and stuff and sends the damage numbers or text-IDs for text like "Miss!" or "Counter!", but this is only for visual purpose and has nothing to do with controling the game.
The big key that I found while creating this game is, that even in a multiplayer game, you do not have to do much multiplayer stuff.
-> You still can do most/ nearly everything locally! (and it works even better and is easier to program than sharing every single detail)
So let me tell you the data flow in simple steps:
- Clients send action requests to the server, or the server creates them by himself.
- The Server sends the action ID (which is equal to the action request value) to the clients.
- The clients act depending on the action IDs through a function started with proc_local().
Note: Every actor on each client does this, not only the player's actor!
Every enemy, every actor of other players and the own player actor, all use the same system.