-
I think storing them in an INI would be good though, in case the server crashes or something else happens to it. The server would just store the data in temp variables and then send that data to the players. When an item is dropped or picked up, it would store/remove the data from the INI as well, so the server would have a temporary and a more permanent value storage for the items. Unless you don't need the server keeping track of items like that... then you'd just store it in temp variables on the server.
I would still suggest using an array or maybe the named variable object to keep track of what variables should be saved to what channel. (this would be on the server side)
-
OK thanks so much Konidias and LB you guys always help me! Next I'm wondering how i would do monsters and enemies... Would the server keep track of what channels have monsters and send data to clients when they enter the map? And then when clients attack they would send that data only to other clients. When a monster is killed the data will be sent to the server so that it knows another one will need to be spawned. IS this correct?
-
Monsters would be done just like items... except you'd probably want to constantly send out their data since they are most likely going to be moving around and attacking and taking damage and stuff.
When a player attacks a monster, the attack request is sent to the server, the server does the damage calculations and then sends out to the channel that the monster was hit... then all of the clients receive that message and display the hit animation/damage display or whatever.
The server would know when a monster is killed because while it's calculating the damage it would determine the monster has no more health or whatever, and then it would just send out a killed message to the channel instead of a damage message. It could respawn whenever you wanted it to, after the monster is killed.
Basically with a client-server game you only have to think about it like this:
The server is playing the game, and the clients are just receiving info from the server and displaying it. The client merely acts as a remote control. It sends movement/control requests to the server. Clients shouldn't be sending info to other clients.
Think about kind of how the OnLive game system works. It's literally just video being streamed to your TV while your controls are sending button pressing data to the actual game.
-
Thanks again. I understand the concept now. But I'm a little confused as to how I'm going to be doing this. I've finally conquered saving data (huge accomplishment for me!) by having clients send strings to the server which will be delimited and saved in a generated INI (you, Konidias, actually helped me with that too!). I completely understand the concept but how would i go about sending this specific data to the server to be saved? For example we have a monster Troll.
The first step is to tell the server what to send out and when. So when the user enters a certain area, send message to server letting it know that the player is in a monster zone. Depending on the message, the server will send:
1. Channel (map)
2. Spawn Coords
3. Health
4. Items that the monster drops
5. ? anything else? Where does this information come from? and Ini? an array?
I'm pretty sure i have to identify the monsters with an ID of some sort. How do i do that? How do i limit the number of trolls so they dont spawn like crazy?
And how would the server continually update the correct monster's ID with health, position, etc WHILE it is being killed by anywhere from one to a few dozen players?
6. My idea is that the server would constantly be sending this data and the players would update the server which would in turn update the players.
I know this a hard task and I dont want you to walk me through every single step. But I'd like a few pointers on my ideas and which objects to use and maybe a small explanation so I can see exactly how it is done. I understand the idea but im stuttering on my execution of it!
Again, you guys are such a great help. And Konidias, i wish you luck on your game! I looked at the videos and it looks really nice so far! I wish i could show you my game but its embarrassing ATM haha ;)
-
Well the way I would do it (and this is just one way, not the only way), would be to store monsters using an array. It could be set up so that:
X = channel number
Y = monster id
Z = attribute to store for that monster
So say you have 5 channels, each with 3 monsters on them. If you wanted to deal with say... monster #2's hitpoints on channel 4, you'd access the array at:
x4,y2,z1
Where 4 = channel, 2 = monster number, 1 = what I designate as the HP value.
Then you could change that array value to whatever the hitpoints need to be.
You would store all the values using that Z position... so 0 could be monster's level, 1 = hp, 2 = attack power, 3 = x position, 4 = y position, etc... whatever you want to do.
This way the server is using this "monster array" to store all monster's values on all channels... all in a single array on the server.
You aren't generating a unique monster for each client... It's the same monster being displayed based on it's array values on the server. So you could have 5 players fighting the same monster, and each player's attack request gets sent to the server, the server calculates the damage and updates, and then sends the players the results.
The monster doesn't physically "exist" anywhere. It's just data in an array. In order for players to "hit" the monster, the server calculates positions and directions instead of "overlapping objects" or anything like that. So for example, if a player swings a sword at a monster, the client sends the attack request to the server, along with the player's location of attack. The server then takes that location of attack info, and checks to see if it's within range of the monster's x/y and it's size (width/height) so basically if the players attack location falls into the range of the monster's "body area", then it was a successful hit. The monster's HP is lowered, the server then sends the new HP to the clients. That's all it needs to send. From this, the client receives the new monster HP and processes this as:
"monster's HP is lower than before, so display damage numbers popping up from monster, play monster hurting animation, etc"
Each time the monster loses HP from a hit, all players will see it. Even if two players hit the monster at nearly the same time, the server will still receive both hit requests and process both individually.
So I hope that answers the question as to how the server would continually update the monster's info. Hope this makes sense!
-
Forgive me but this question is based on my lack of knowledge of arrays:
So I can set one value to X, one value to Y, and multiple values to Z that will all be sent as one bit of data for the players to interpret?
-
You wouldn't be sending the player all the array numbers... Just specific values from the array. To send the monster health, you'd do something like:
Blast number ValueAtXYZ( "Array", 4, 2, 1) to channel 0 on subchannel 0
So if the value in the array at position 4,2,1 = 100, then it would send the number 100. Hope this makes sense.