Page 1 of 1

LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 5:57 am
by ResourceDragon
Hello, it's me again. I've been working on a multiplayer game over a LAN (That works through our household's HomeGroup), And i've hit my last roadblock. If I can get this to work, all the technical coding and such will be done.

Now, the problem i've come across, is I have an actor that randomly spawns an enemy and a random time. The actors it spawns are the same actor. (So they are clones)

How would I go about saving the x, y, animpos, hp, speed, etc. Of all the clones, and loading all of these into the other game?(Preferably without lag)

One way i've found would work would be requiring making another variable for EVERY actor.variable, but this would take hundreds of variables, and a crap load of time I don't have. The end result would be extreme lag, and how would you know how many clones and when to spawn them into the other game?

Another way i've thought about doing it, would be that one computer has the whole game with three canvas' that draw from the three corresponding players, save the drawing and load it into other games the other three players have. The problems with this would be that I don't know how the canvas' work, or how to save and load the drawn items, and how the other three players would be able to control there players with keys, let alone moving each players cursor to aim their weapon.

Figuring out how to do this would up the games fun value immensely.(It's already fun, but it would be awesome to get a LAN Setup up and running.)

I have the non-random variables I need working(i.e. Player1's x and y, Player2's x and y) But it's just these enemy clones that I need help with.

Please help..

Re: LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 6:05 am
by Hblade
Code: Select all
int XSAV[20000], YSAV[20000], APSAV[20000], HPSAV[20000], SPSAV[20000], ETC[20000];

After creating those arrays, you can store 20,000 actor's data in them. (Prefered you create the arrays normally through the variable creation)
Code: Select all
Array[cloneindex]=value;

Replace Array with the array name, XSAV for example, and replace value; with the value, x or y for example, or animpos.

Example:
Code: Select all
XSAV[cloneindex]=x;


When loaded:
Code: Select all
x=XSAV[cloneindex];


:)

Re: LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 4:57 pm
by ResourceDragon
Hm, I thought arrays would be an answer too the problem...but i've never used them before.


Ohhh... I see. This just might work, you've given light to some new ideas for me. Thanks! I'll be back with my findings.

Re: LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 5:36 pm
by DST
That's too much data to send over a network. The lag will be absolutely horrible.

Consider instead, making a pregenerated list of random numbers, and sending that list to all clients at the start of the game. Then all of them will spawn the same enemies. Then you pass the actions of the players, and if player 2 kills something in his version of the game, his identical position and action will kill that enemy in the other players' versions of the game.

Re: LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 5:56 pm
by ResourceDragon
I thought about that too, but then you would have the same enemy in two different locations... It would be nice for the enemies to keep their x, y, and animpos the same in all the clients... :/ And I just realized i've got to be able to tell the other clients the said enemy died, as well. Hmmm..

The pregenerated list of numbers fixes problem 1 of 3 though. thanks.

Re: LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 6:15 pm
by Hblade
Then you could set it up where you have an array of 64 instead, and it only captures the loneindex of actors that are on the screen of either 2 (meaning, a total of 32 enemies max on screen per player)

Re: LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 6:46 pm
by ResourceDragon
That might work too, but i've noticed even trying to SAVE any variables, let alone load them, causes GE games to lag..

Re: LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 7:49 pm
by Hblade
oh DX

try FILE *file = fopen or w/e :D

Re: LAN Saving and loading randomly spawning actors

PostPosted: Sun Apr 01, 2012 11:28 pm
by ResourceDragon
uh...

Can you put an example for the FILE* code?

Re: LAN Saving and loading randomly spawning actors

PostPosted: Mon Apr 02, 2012 12:57 am
by Hblade

Re: LAN Saving and loading randomly spawning actors

PostPosted: Mon Apr 02, 2012 4:25 am
by ResourceDragon
....

I'm sorry... DX But that just confuses me more... :cry:

Re: LAN Saving and loading randomly spawning actors

PostPosted: Mon Apr 02, 2012 5:12 am
by skydereign
Well the point is there actually are a lot of FILE* explanations on these forums. In fact if you search my posts, I've explained how FILE*s a number of times. That actually goes about almost any questions people have. But, here's hopefully a more informative link.
http://game-editor.com/forum/viewtopic.php?f=2&t=11396&p=80049&#p80049

Re: LAN Saving and loading randomly spawning actors

PostPosted: Mon Apr 02, 2012 4:30 pm
by Hblade
Thats the post I was looking for ^^ I fail at reserach :oops: sorry hehe.

Sky's explanation will so.ve your confusion :D