Thanks.
@ fastlane69,
Very good question indeed!
Chapter 12: Attaching and Picking Up Items
Some problems that were created by this chapter that need fixed:
1) The profession selection code after game start has create 2 problems that I didn't have time to work on that need to be fixed. (Or I think so).
A) The Host shouldn't have to select his profession before others can join and choose theirs. This may not be so simple. It has to do with how I wrote the code with host is always player_number 1. This needs to be fixed. so the host doesn't necessary have to choose profession before any clients do.
B) A related problem, that I believe will happen and is not serious for this tutorial, but would possibly be for a real game. If a client joins and does not select profession, and another clients joins game after him but selects profession before him, the player's entity.player_number will not equal his player_number(a variable) that is being displayed on the screen. The entity.player_number will be set to the in the order of entity creation, while the player's variable player_number is set by the order in which he joined game. So basically, until fixed, an entity that was created out of order of the join sequence, could not tell if this player owned him by
if(my.player_number == player_number) // Does this player own me?
(Maybe get rid of variable player_number and just use player.player_number for everything?)
I wrote the start-up code in a certain way after some of the earlier server test. I did not want to actually assign a player_number until after a a player actually created an entity because, what would happen was, If a player quit before his entity was created, I was using in player action:
Code:
my.ENABLE_DISCONNECT = ON; // player can disconnect from session
and in player event:
function player_events()
{
// client disconnected
if (EVENT_TYPE == EVENT_DISCONNECT)
{
number_of_players -= 1; // decrement number of players
player_number_quit = my.player_number; // set player quit to me since I quit
// Go through all entities, any player# that was above mine, decrement his player number
you = ent_next(NULL);
while(you != NULL)
{
if(you.player_number > player_number_quit)
{
you.player_number -= 1;
send_skill(you.player_number, SEND_ALL); // send new player#
}
you =ent_next(you);
}
send_var(player_number_quit); // let everyone know player that quit
send_var(number_of_players); // let everyone know new number of players
ent_remove(me); // remove ent of player that quit
}
}
So if the player didn't actually have and entity and got disconnected, the whole player number system would get off. So basically, the player_number code needs revamped now, possibly using
Code:
if (event_type == event_leave)
in server_called instead of event_disconnect in player_events? So the connection code and player_number code needs revised. This may or May Not be a simple task. I have alot of variables being passed in different locations setting up player number data. But hey, it's atleast well docemented what I was doing before Chapter 12 changes.
2) Need to add all the ammo packs for each profession (NPC's too) and randomly create them and place them into level. When picked up need to add to my.ammunition_remaining for that player and display it. I was thinking random(10) rounds of ammo per pack.
3) Need to create Lunar Candy power-ups, which heals all professions and needs randomly created and placed in level. When picked I was thinking of adding 10%-15% of max_health to player or NPC.
Chapter 13 : Using Items and Attacking.
1) Need to create profession(weapon actually) specific attack code. Bullets, radition beams, etc themselves would be global. Their effects and sounds would be local. Decreasing ammunition_remaining upon attack and doing correct damage. Key input for attacking. Weapon range as per game description.
2) Local animation code for attacks would need to be added to animate() function.
3) Death code, go back to choose profession panels I suppose.
4) Lunar Pychosis Rating (score) code need to be written and displayed.
Chapter 14 : Managing the Amount of data sent.
Alot of this covered in earlier chapters. Any other techniques for lessening network traffic should be here with an example of it used in game. Maybe some new A6.30 commands like SEND_UNRELIABLE mode if possible, although most of what I have written needs to be reliable.
Chapter 15 : NPC's and Multiplayer AI.
Simple example of AI for the 2 bot types. Entity_scan() or whatever with cave_man pathfinding or however detailed one wants to get. If attacked, will probably attack that player back. May attack player randomly if he is within a certain range. Goes and picks up his ammo packs if within a certain range and ammunition not full. May run if hurt bad.
Chapter 16 : Putting the Pieces Together to Make The Game .
Finishing touches to make the BioSphereIV: Lunar Mania game decription an actual working multiplayer game. Maybe add names above player's entities, possibly a health bar too. Some way to tell players's scores. Make sure when a player first joins, he has a few seconds or so (grace period) before anyone can hit him, so he doesn't die each time during connection. Possible better models that more reflect game description if they are accessable. Players and bots should start with some ammo. Bot's should randomly be re-created after death in a random amount of time. Max number of bot's, ammo_packs, and lunar_candy in level at one time should be set. Stamina or endurance code. When running or attacking it goes down. If stamina is 100%, gradually add health (resting).
Documentation would have to be rechecked, making sure any changes made are added to it.
1) I already have made some slight changes to get the code working with A6.30 public beta I don't think I have changed yet in documentation and any changes in connection/player_number assignment code would require changing the chapter that covers that.
2) Also, internet testing and whatever needed changes to improve code for internet play would probably be a good idea.
That's about it! Hey, you asked! Then truly, it would be the Ultimate 3DGS Tutorial ever hands down!
If anyone does complete it, you can change the name from Locoweed's Multiplayer Tutorial, to whatever, just listing under title or in contributions all who contributed.
If you are interested, I have the document in Word that I can get you, also, I have alot of Chapter 12 documention done up to where I had to do the major restructuring of code to get weapons to attach to local animation instead of to the server's animation.
Let me know,
I will help as much as I can,
Especially, getting started,
Loco