Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 2 of 7 1 2 3 4 5 6 7
Re: multiplayer game development blog [Re: ulf] #72127
05/02/06 20:26
05/02/06 20:26
Joined: Aug 2005
Posts: 1,012
germany, dresden
ulf Offline OP
Serious User
ulf  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,012
germany, dresden
02.05. okay just a quick update today, i managed to implent faction as well. so now if a player writes /f text only his faction sees the text. the faction is determined by a -d statement when starting the engine. players can chose their faction within our external starter program.

i also added some small information when a client joins or leaves the game.

right now iam working on a playerlist with display of playername, faction, race.
this gives me some trouble since i cant access the string in player.string1 with the str_ function in the latest public beta.
maybe its just a fault of me, but it maybe a bug too. anyways if i dont find a solution to access this strings ill have to find a workaround.

my plan for the playerlist is to get the name of a joined player when he triggers event_join and add his chosen race after the race selection screen to the list. then i only have to manage to display it on all players...

Last edited by ulf; 05/02/06 20:27.
Re: multiplayer game development blog [Re: ulf] #72128
05/03/06 00:24
05/03/06 00:24
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
Nice blog ulf,

Should help alot of people out.

To answer your question here.
"after some testing i realised that i have to put a sleep(1) bevore the level load, so that the on_server command is properly triggered when the client joins the game. iam wondering why nobody else or locoweed had this problem yet?"

I also had that problem at one point or another. I think it has been varying somewhat depending on the GStudio version. I am surprised it wasn't still in there ( a sleep() before level_load() ), but it probably started working in version A6.30 without so I took it out. I usually leave those lines in, but commented out with a warning. Either that or it was always working until after A6.30 and I asked Conetic about it then, but I have ran into that problem at sometime. It doesn't hurt to have it there anyway, so it might as well be there no matter what the version.

Also, I like how you are explaining how you are adding whisper, etc. Very good stuff.

Nice blog, keep it up,
Loco

And feel free to use/change anything from the original tutorial to use to help the community, like your own expanded tutorial on what you are doing. I have no problem with that if you want to do something like that.

Last edited by Locoweed; 05/03/06 00:51.

Professional A8.30
Spoils of War - East Coast Games
Re: multiplayer game development blog [Re: Locoweed] #72129
05/04/06 21:07
05/04/06 21:07
Joined: Aug 2005
Posts: 1,012
germany, dresden
ulf Offline OP
Serious User
ulf  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,012
germany, dresden
thanks locoweed unfortunately i have no time writing a tutorial like yours because iam working every minute i find on the project. however because i think its a shame that the mulitplayer forum is deserted i post here and write what iam experiencing.
i dont think iam a good coder good enough to write a tutorial like yours, iam only a average guy with a dreamgame in mind and a little team to help me
iam at the very start of finding out how things work, i wont say ill never write a tutorial but until i do i will need more knowledge.

04.05.06 today i finally got the movement working, iam using a modified version of georges stratego2 movement.

because my camera was facing down 60 degree tilt, i had to calculate the point the mouse is clicking for the unit to move to. georges code is with the camera facing down directly at the map.

i did it with a code snipped i found on the forum. here is it:

Code:

vec_set(temp.x, vector(mouse_pos.x, mouse_pos.y,2000))
vec_for_screen (temp.x, camera);
vec_sub(temp.x, camera.x);
temp.x/=temp.z;
temp.y/=temp.z;
temp.x=camera.x+(temp.x*-1)*camera.z;
temp.y=camera.y+(temp.y*-1)*camera.z;
temp.z=0;



this takes the mouse position and gets the right vector position where the mouse clicks. if you want to use this for terrain you have to trace afterwards because .z of temp is set to zero.

it works quite well except that if you click at a hill, its not 100% correct because it takes the z. coordinate at zero and traces upwards the hill. i havent found a solution for that yet.

then i was able to create the movement, after this i switched my.nosend=on; for the players entities. then i create at every client a local entity for the host player with ent_createlocal. when the host player moves i sent 4 times a second his coordinates to all the clients. with this code:

Code:

// send pos to fake every 4 sec
timer += 16 * time;
if(timer >= 64)
{
vec_set(hostplayerposition, my.x);
send_var(hostplayerposition);
timer = 0;
}



then i directly set this coordinates in the entities action. and it works! it lags like hell but i think i can smooth it out with vec_lerp to interpolate between the last received position and the actual position.
i also have to send updates when the entity stops moving so movement ends for all at the same point.

right now it only works for the host player but with 2 clients connected it consumes an average bps of 40! without nosend and 2 clients updating the host on the clients consumes 400. so sending manually is 10 times better. without other stuff like animation changes and so on. right now it only moves the host.

i guess it will take me some time to smooth this movement on the clients. i also have to find out an effiecient way to create a fake entity at all the clients for each other player, get input from this fake entities and move the real entities on the host pc and send upates to the fakes.
i dont have an idea how this system should be set up. i guess it can be done with lots of entity pointers and updating them when a client leaves or joins. i thought about haveing 10 each on the host and client corresponding to the my.player_number. but iam not shure yet.

i hope you could follow iam a bit confused right now as the code is getting bigger and bigger 2500 lines now. and i have to reorganize it and comment it soon again so that i dont lose the overview.

ill keep you updated what i find out. maybe some of you has an idea about how to efficient create fake entities on the clients and keep them updated?

Re: multiplayer game development blog [Re: ulf] #72130
05/05/06 19:11
05/05/06 19:11
Joined: Aug 2005
Posts: 1,012
germany, dresden
ulf Offline OP
Serious User
ulf  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,012
germany, dresden
05.05.06 today i made a big step i think i now have a simple movement code for the server player. his positions are sent to all clients 4 times a second . now i have a very simple movement for the clients. they just use c_move to move to every new received position.

this works quite well only sometimes there are little jerks in the movement. i think i know the cause but havent found a good solution yet. the statemachine of the client switches to mode_stand when the last received position is reached with c_move. now if this position is reach bevore the client receives a new position the player stands still for a very little time. and starts moving then again. this is where the jerk comes from.

i made a little sketch to show you how i do movement.



i sent the new position first when the client joins so he knows where the server stands at. and when the server player stops his movement so both end at almost the same position.

i will now think about a way to prevent the problem that the player stops at the client because he reached the last received position faster than he got a new one.

iam pretty happy already because we tested this over the internet and it works with 30-40 bps average!

nice weekend all of you, ill update the blog once i find out new things. if you have any suggestions for me you are very welcome!

Last edited by ulf; 05/05/06 19:17.
Re: multiplayer game development blog [Re: ulf] #72131
05/06/06 20:29
05/06/06 20:29
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
Hi ulf,

When I first started trying to get multiplayer to work with 3DGS long ago, I was doing things similar to what you are trying. I still believe client-side movement is the most effiecent and best way to go. The concept you are using is pretty much the same, the technique was a bit different though. I sent force-over-time and updated actual position every once and a while, while you are sending points to go to, and sending position updates sometimes. With a point-and-click movement game, sending points to go to might actually be more efficient, although with a FPS or real time movement game where the player can change his direction at any time, I think the force-over-time method would have to be used.

Anyway, nice work. Good reading.

Later,
Loco


Professional A8.30
Spoils of War - East Coast Games
Re: multiplayer game development blog [Re: Locoweed] #72132
05/06/06 22:04
05/06/06 22:04
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
Hi again,

I was thinking on your "player moves to next received position and then stops and waits for next received position" concept. I think if you managed it right, the client entity would never have to actually stop and wait for next position update. Just giving you something to think about. How could you use some dplay variables such as dplay_latency and fps on the client to predict better when that client should arrive at next waypoint on his computer, minimizing any noticable wait time?

Loco


Professional A8.30
Spoils of War - East Coast Games
Re: multiplayer game development blog [Re: Locoweed] #72133
05/07/06 09:08
05/07/06 09:08
Joined: Aug 2005
Posts: 1,012
germany, dresden
ulf Offline OP
Serious User
ulf  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,012
germany, dresden
hey again loco,

i just typed a 1000words reply and it got lost due to a "invalid form" and me not saving it bevore posting... so ill sum up what i wrote.

in my movement code, the server sents every 4 positions the position of the hostplayer to the client and once a client joins his actual position. this goes like this:

x--y1----y2----y3----y4...

as you can see when the client at x reached position y1 it receives. it has to wait 1/4 second till the position y2 is incoming. so it will just stand there waiting. i cannot change the first initial sent update i think because a client could join at any time thus receiving a position from the host wich is like 1mm next to the starting position.

i was however able to get the animations correctly i used the .z coordinate of the hostplayerposition vector to set it to 1 to indicate when the state switches to mode_stand at the host so the clients do this too after they are very close to the last received position.

now you pointed me in the direction of dplay_latency... i can only guess that you mean i move the clients host entity very very slow to the first received position so that it reaches this position not until it gets the second one and so on...
but i doubt this will solve the problem. imagine the client receives starting position of the host at 0,0 then the next position is 0,0.003 due to the send algorithm i use. so the client will move to 0,0.003 and wait there till the next position comes in. moving such a short distance is probably bad. i think i try to let the client only move when the first position is var away from the actual position... lets see how this works.

this is the update code i use to send positions, its placed in the hosts movement of his entity in the while(1) loop at the state MODE_WALK

Code:

vec_set(hostplayerposition, my.x);

// send pos to fake every 4 sec
timer += 16 * time;
if(timer >= 64)
{


hostplayerposition.z = 0;
send_var(hostplayerposition);
timer = 0;
}



so if iam completely wrong please point me to the right direction master

thanks again!

Re: multiplayer game development blog [Re: ulf] #72134
05/07/06 11:09
05/07/06 11:09
Joined: May 2002
Posts: 611
Germany => Bavaria => Unterfra...
LordRathan Offline
User
LordRathan  Offline
User

Joined: May 2002
Posts: 611
Germany => Bavaria => Unterfra...
Sorry for hijacking this thread, but maybe both of you, ulf and locoweed, should have a look at this thread in Morbius. Maybe it is interesting for you.

Sorry again. ulf, keep up this amazing thread. It is very helpfull.

Re: multiplayer game development blog [Re: LordRathan] #72135
05/07/06 21:34
05/07/06 21:34
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
@ LordRathan,
Get back to you on that.

@ ulf,

"imagine the client receives starting position of the host at 0,0 then the next position is 0,0.003 due to the send algorithm i use. so the client will move to 0,0.003 and wait there till the next position comes in."

How do the enitities move on the client from 0,0 to 0,0.0003? With ent_move() (or c_move()), or do you just place it the directly my.X, my.PAN, etc?

Loco


Professional A8.30
Spoils of War - East Coast Games
Re: multiplayer game development blog [Re: Locoweed] #72136
05/08/06 06:21
05/08/06 06:21
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline
Expert
William  Offline
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
Using c_move() isn't a good idea due to collision problems and overshooting because of it. For my game I send the positions using send_rate and then interpolated the positions. The only problem with this is the entities appear a bit behind each other on the clients, but on the server they are all in their right posiitons. This poses a problem in a racing game where on your comp it shows the vehicle behind you, but in reality(on the server) it's a little ahead of you. Mabye this doesn't matter much in other genres as much... I'm thinking of something to tackle this, in the meantime you can change this code to still keep them quite close... on lan you dont notice this(since you update every frame).

Code:
 
function movement_smooth() //collision box
{my.invisible = on; //ent_morph(my, "kart2.mdl");
var rotate[3]; var s_angle[3]; var old_angle[3]; var new_angle[3]; var angle_direct; var oangle_direct; var pan_factor;
var calc_angle[3]; var move[3]; var move_old[3]; var xdirect; var move_factor; var zspeed; var length;

while(1)
{
if(my != decoy_1)&&(!lan)
{
my.passable = on;

vec_set(s_angle.pan, my.server_angle);
rotate.pan = ang(s_angle.pan - my.pan); my.pan += rotate.pan * 0.4 * time;
rotate.tilt = ang(s_angle.tilt - my.tilt); my.tilt += rotate.tilt * 0.4 * time;
rotate.roll = ang(s_angle.roll - my.roll); my.roll += rotate.roll * 0.4 * time;
vec_set(old_angle.pan, my.server_angle);

vec_set(move.x, my.server_origin);
if(move_old.x != move.x){vec_set(length.x, move.x); vec_sub(length.x, my.x); vec_set(temp.x, move.x); vec_sub(temp.x, my.x); vec_to_angle(calc_angle.pan, temp.x);}
my.x += length.x * 0.6 * time;
my.y += length.y * 0.6 * time;
my.z += length.z * 0.6 * time;

if(key_v){vec_set(my.x, my.server_origin);}
if(my.fspeed < 5){vec_set(my.x, my.server_origin);}

vec_set(temp.x, nullvector);
if(my.server_origin != move_old.x){my.fspeed = vec_dist(my.server_origin, move_old.x); my.fspeed /= 2.74; zspeed = move.z - move_old.z; zspeed /= 2.74;}
if(my.tracekart){you = ptr_for_handle(my.tracekart); vec_set(you.x, my.x); if(you.spin == 0){vec_set(you.pan, my.pan);} you.z -= 27;}

vec_set(move_old.x, my.server_origin);
}
if(my != decoy_1)&&(lan)
{
my.passable = on;
vec_set(s_angle.pan, my.server_angle);
rotate.pan = ang(s_angle.pan - my.pan); my.pan += rotate.pan * 0.4 * time;
rotate.tilt = ang(s_angle.tilt - my.tilt); my.tilt += rotate.tilt * 0.4 * time;
rotate.roll = ang(s_angle.roll - my.roll); my.roll += rotate.roll * 0.4 * time;
vec_set(old_angle.pan, my.server_angle);

vec_set(move.x, my.server_origin);
if(move_old.x != move.x){vec_set(length.x, move.x); vec_sub(length.x, my.x); vec_set(temp.x, move.x); vec_sub(temp.x, my.x); vec_to_angle(calc_angle.pan, temp.x);}
my.x += length.x * 0.6 * time;
my.y += length.y * 0.6 * time;
my.z += length.z * 0.6 * time;

if(my.server_origin != move_old.x){my.fspeed = vec_dist(my.server_origin, move_old.x); my.fspeed /= 2.74; zspeed = move.z - move_old.z; zspeed /= 2.74;}
if(my.tracekart){you = ptr_for_handle(my.tracekart); vec_set(you.x, my.x); if(you.spin == 0){vec_set(you.pan, my.pan);} you.z -= 27;}

vec_set(move_old.x, my.server_origin);
}

wait(1);
}
}




Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/
Page 2 of 7 1 2 3 4 5 6 7

Moderated by  HeelX, Spirit 

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