Gw Temp

Menu

Tutorial - 'New Multiplayer System for RM2K3' by Axel

An item about RPGMaker 2000 posted on

Blurb

An awesome tutorial that shows you how to use key processing to create a 4-player game in RM2K3.

Body

And a new tutorial from me! I suppose this is the last time I will update my multiplayer system, because after this update, I can’t think of another update.
This time, in the multiplayer system, you can play with up to 4 players. Every player can walk in every direction, and has an action button to start events. The players can’t walk out of the screen, and player 1 can’t walk in a direction if that means an-other player would get out of the screen.
This tutorial is written in the concepts from Advocate’s version 1.08. A conditional branch is called a fork conditioning sometimes, and a key input processing is some-times called input key. The rest isn’t that much different, so if you have another ver-sion, I suppose you can follow the “programming language”.

You need:
• rm2k(3)
• an event for player 2, an event for player 3 and an event for player 4 in every map
• 2 variables and for every player 5 more
• … to know how variables, input key, fork conditionings and coordinates work
• … much experience with rm2k(3), especially with coordinates and variables

Index
• Variables Prospect at all used variables
• Step 1 Explanations how we’re going to make this
• Step 2 Let’s start with the event commands
• Step 3 Second event commands with explaining
• Step 4 Complete first common event
• Step 5 Action button
• Step 6 Explaining other common events except for one
• Step 7 Explaining the last common event
• Step 8 Create the last common event
• Step 9 Last event commands and finish this tutorial

Variables Prospect at all used variables
Under this, all variables are viewable. This will help you in step 6!
Note: You can change numbers of variables, but make sure you don’t make a fault then.
• Variable [0001: X position hero]
• Variable [0002: Y position hero]
• Variable [0003: X position player 2]
• Variable [0004: Y position player 2]
• Variable [0005: Player 2 buttons]
• Variable [0006: X hero + – X player 2]
• Variable [0007: Y hero + – Y player 2]
• Variable [0008: X position player 3]
• Variable [0009: Y position player 3]
• Variable [0010: Player 3 buttons]
• Variable [0011: X hero + – X player 3]
• Variable [0012: Y hero + – Y player 3]
• Variable [0013: X position player 4]
• Variable [0014: Y position player 4]
• Variable [0015: Player 4 buttons]
• Variable [0016: X hero + – X player 4]
• Variable [0017: Y hero + – Y player 4]
• Variable [0018: Typed in a button]
Step 1 Explanations how we’re going to make this
In this tutorial, we will create a common event for every player in which we will make the player can walk. In common events, we can only let events walk if they’ve got the same ID. So, in every map EV0001 has to be an event with the graphic for player 2, in every map EV0002 has to be an event with the graphic for player 3, in every map EV0003 has to be an event with the graphic for player 4, even in maps where these players don’t participate! In maps where these players don’t par-ticipate, create events without graphics for them and put them at a place where they can’t do anything, like in the corner in the bottom at the right.
Now the explanations about the event commands. We will check with Key Input Processings and fork conditionings which button has been pressed. Then, we will check if that player is allowed to move in that direction or not, with coordinates and fork conditionings. If so, the player will move. So we will need one common event for each player. Further, in any case 2 variables and for each player 5 more.
Please do not do this tutorial if you do not know enough about all those concepts. Otherwise, the tutorial will probably be too hard for you to follow.

Step 2 Let’s start with the event commands
First, create event 0001 in the first map. Second, create the common event for player 2. Parallel process, no start condition switch.
As you already read we will use coordinates for checking if the players don’t walk out of the screen. So first, let’s store the heroes coordinates in V[0001: X position hero] and V[0002: Y position hero], and the coordinates of player 2 (so that’s the coordi-nates of EV0001) in V[0003: X position player 2] and V[0004: Y position player 2].
So now we will make an input key. First, think of which button you want player 2 to use to walk. In this tutorial, player 2 can walk to the left with 1, down with 2, up with 3 and right with 4 and the action button is 5.
Put the input key. Store it in V[0005: Player 2 buttons]. Wait for the key stroke and just check the buttons you want player 2 to use (so in this tutorial the numbers).
Then check if that button is the button you want player 2 to use to walk to the left. So in this tutorial we will check now if we pressed button number 1. We must check then if that variable is 11 (the number + 10). And then… the more difficulty part starts.

The event commands till now:
<>Variable Oper: V[0001: X position hero] Set, Hero X coord.
<>Variable Oper: V[0002: Y position hero] Set, Hero Y coord.
<>Variable Oper: V[0003: X position player 2] Set, Player 2 X coord.
<>Variable Oper: V[0004: Y position player 2] Set, Player 2 Y coord.
<>Key Input Proc: V[0005: Player 2 buttons]
<>Branch if Var [0005: Player 2 buttons] is 11

Step 3 Second event commands with explaining
Okay, so now we have checked the coordinates, and we checked if player 2 has pressed the button for walking to the left.
We know, if you walk to the left, your X–coordinate changes. It decreases with 1. So for checking if player 2 doesn’t walk so far to the left that he walks out of the screen, we must check if the X–coordinate of player 2 isn’t that much different from the X–coordinate from the hero. He can walk 9 squares from the hero to the left at highest.
But how do we check that? We will need an extra variable for that: V[0006: X hero + – X player2]. First we must set it to the X–coordinate of the hero. We must check if the X–coordinates aren’t higher than 8. 8, not 9, because if it is 8 and you walk to the left it is 9. If it is 9 and you walk to the left you walk out of the screen. Because your X–coordinates decreases with 1 when you walk to the left, we must decrease vari-able 0006 with 8. If you can’t follow this, read this again. It’s very important for you to understand this, otherwise you can’t complete this tutorial!
Now we have the X–coordinate of player 2 and this new variable, which is the maxi-mum player 2 can walk in X–coordinates. So player 2 can’t walk to the left if the dif-ference between his X–coordinate and the heroes X–coordinate is too big. That means: Player 2 can only walk to the left if that new variable (variable 6) is less than the X–coordinate of player 2 (variable 3). If variable 6 is not less than variable 3, player 2 can’t walk to the left, so we should let him face to the left.

The event commands till now:
<>Variable Oper: V[0001: X position hero] Set, Hero X coord.
<>Variable Oper: V[0002: Y position hero] Set, Hero Y coord.
<>Variable Oper: V[0003: X position player 2] Set, Player 2 X coord.
<>Variable Oper: V[0004: Y position player 2] Set, Player 2 Y coord.
<>Key Input Proc: V[0005: Player 2 buttons]
<>Branch if Var [0005: Player 2 buttons] is 11
…<>Variable Oper: V[0006: X hero + – X player2] Set Hero, X coord.
…<>Variable Oper: V[0006: X hero + – X player2] –, 8
…<>Branch if Var [0006: X hero + – X player2] is V[0003] Less/Equal
……<>Move event: Player 2, Move left
……<>
…:Else Handler
……<>Move event: Player 2, Face left
……<>
…:End
…
:Else Handler

Step 4 Complete first common event
So, now we made player 2 can walk to the left. But of course player 2 can walk in other directions too. Now, we will make that player 2 can walk down. So we first should check if that variable V[0005: player 2 buttons] is 12 (or if you use another key, check if it is another number). If you walk down, your Y position will slightly in-crease with 1. So we should create a new variable, for checking if the Y–coordinate of player 2 isn’t that much different from the heroes. We should create V[0007: Y hero + – Y player2]. First, we set it to the Y–position of the hero. Player 2 can’t walk more than 6 squares down compared with the heroes Y–position. When you walk down your Y position increases so we should variable 7 count up with 6. If that new variable is more than the variable of the Y position of player 2, player 2 can walk down. If not, player 2 should face down.
Player 2 can also walk up. So we should check if V[0005: player 2 buttons] is 13 (or another key). When you walk up your Y position decreases. Set V[0007: Y hero + – Y player2] to the heroes Y position. Now first think. Do you want that player 2 can walk so that’s he completely in sight, or walk till the upper square, so that you can only see him half? Decrease the variable with 5 for completely in sight, decrease the variable with 6 for the upper square. Player 2 can only walk up if variable 7 is less than his Y position. If not he faces up.
Player 2 can walk right. Check is variable 5 is 14. When you walk right your X posi-tion increases. Set variable 6 to the heroes X position. Count up with 9. If variable 6 is more than the X position of player 2, player 2 buttons to the right. If not, he faces right.
At last, player 2 has an action button. Do not place anything for this in this common event.

The event commands till now:
<>Variable Oper: V[0001: X position hero] Set, Hero X coord.
<>Variable Oper: V[0002: Y position hero] Set, Hero Y coord.
<>Variable Oper: V[0003: X position player 2] Set, Player 2 X coord.
<>Variable Oper: V[0004: Y position player 2] Set, Player 2 Y coord.
<>Key Input Proc: V[0005: Player 2 buttons]
<>Branch if Var [0005: Player 2 buttons] is 11
…<>Variable Oper: V[0006: X hero + – X player2] Set Hero, X coord.
…<>Variable Oper: V[0006: X hero + – X player2] –, 8
…<>Branch if Var [0006: X hero + – X player2] is V[0003] Less/Equal
……<>Move event: Player 2, Move left
……<>
…:Else Handler
……<>Move event: Player 2, Face left
……<>
…:End
…
:Else Handler
…<>Branch if Var [0005: player 2 buttons] is 12
……<>Variable Oper: V[0007: Y hero + – Y player2] Set, Hero Y coord.
……<>Variable Oper: V[0007: Y hero + – Y player2] +, 6
……<>Branch if Var [0007: Y hero + – Y player2] is V[0004] or more
………<>Move event: Player 2, Move down
………<>
……:Else Handler
………<>Move event: Player 2, Face down
………<>
……:End
……<>
…:Else Handler
……<>Branch if Var [0005: Player 2 buttons] is 13
………<>Variable Oper: V[0007: Y hero + – Y player2] Set, Hero Y coord.
………<>Variable Oper: V[0007: Y hero + – Y player2] –, 6
………<>Branch if Var [0007: Y hero + – Y player2] is V[0004], Less/Equal
…………<>Move event: Player 2, Move up
…………<>
………:Else Handler
…………<>Move event: Player 2, Face up
…………<>
………:End
………<>
……:Else Handler
………Branch if Var [0005: Player 2 buttons] is 14
…………<>Variable Oper: V[0006: X hero + – X player2] Set, Hero X coord.
…………<>Variable Oper: V[0006: X hero + – X player2] +, 9
…………<>Branch if Var [0006: X hero + – X player2] is V[0003] or more
……………<>Move event: Player 2, Move right
……………<>
…………:Else Handler
……………<>Move event: Player 2, Face right
……………<>
…………:End
End of branches, till the end of the event commands

Step 5 Action button
This is very simple. If you want an event player 2 can “open”, just set it to “action key” and “below hero”. In the event commands, you just do:

<>Key Input Proc: V[0005: Player 2 buttons]
<>Branch if Var [0005: Player 2 buttons] is 15

And after this you place what should happen. In this way, only player 2 can open this event. Under this you can see the event commands of an event every player can open.
5 is Enter or Z, 15 is number 5, 10 is number 0 and 24 is the dot in the bottom at the right of your keyboard.

Action key, below hero Action key is sometimes called “on key press”.

<>Key Input Proc: V[0018: Typed in a button]
<>Branch if Var [0018: Typed in a button] is 5
Let it happen
:Else Handler
<>Branch if Var [0018: Typed in a button] is 15
Let it happen
:Else Handler
<>Branch if Var [0018: Typed in a button] is 10
Let it happen
:Else Handler
<>Branch if Var [0018: Typed in a button] is 24
Let it happen

Please notice the difference between those 2 event commands. The first event can only be opened by player 2, the second event can be opened by every player.

Step 6 Explaining other common events except for one
You just make the same common event for player 3. You just have to change:
 the variables. Create new variables for player 3. For a list of variables, please see the chapter “variables”, which is placed before step 1.
 the input keys. Just give him the keys 6, 7, 8, 9, and 0 for example.
 the move event. Do not let player 2 walk, but player 3.
And do the very same for player 4. After that, continue with the step which is almost the last one… step 7.

Step 7 Explaining the last common event
In this step, we will complete this tutorial! Just one more common event to go!
In this common event, we will let player 1 move. But now you’re thinking, why should we create a common event for that, because player 1 can move automatically. Unfor-tunately, player 1 can. Still we should make this common event, otherwise, for exam-ple, player 1 can walk down, but that would mean player 2, 3 or 4 could get out of the screen. So, let’s fix that problem.
Unfortunately, there’s a little problem with fixing that problem. We can make this in 2 ways:
• Either we solve the first problem, but if player 1 wants to walk down (so that player 2, 3, or 4 gets out of the screen), player 1 will walk up instead. This does not look great in your game, but it works. The common event can be a parallel process in this case.
• Or we solve the first problem, and when player 1 wants to walk down (so that player 2, 3, or 4 gets out of the screen), player 1 will just face down instead of walking. This looks perfectly in your game, but this will only work if the com-mon event is autostart. That means that other events like parallel processes, will never work in your game. It means as well that player 1 has to walk just like any other player: by pressing the arrow again for every step.
Unfortunately, this is unsolvable. Choose one of the options which you want to make. Both aren’t great, but you should choose one.

Note: Now it’s going to be a bit confusing.
• If you’ve chosen to do option 1, do NOT create the underlined things which are described after this but DO create the italicized things.
• If you’ve chosen to do option 2, do NOT create the italicized things which are described after this but DO create the underlined things.
Please do not ignore this note, otherwise, you’ll ruin your multiplayer system.

Another note: If you’ve chosen option 2 at first, but when you’ve finished your game for 50% and think “I should have chosen option 1”, you can still change it. This works vice versa too: you can change option 1 to option 2 after a while.

Last note: If you chose option 1, the common event will be parallel process. This means that player 1 can just walk like he always does: Press and hold an arrow but-ton. But, if the arrow button is held down while walking over the square where you should have stopped (because of the position of player 2, 3 or 4), the hero will just walk on, because he did not press the button again. This is, unfortunately, unsolvable as well. If you chose option 2, the common event will be autostart. You won’t have that problem, described above this, but player 2 will have to walk just like any other player; by pressing the arrow again and again for every step.

So now, continue to the step, last but one: step 8.

Step 8 Create the last common event
After this step, you will only have one final step and after that, you will have a multi-player system in your game, with all updates I could think of.
So, let’s create the last common event. Make it parallel process or autostart (remem-ber, step 7? Option 1, do NOT create underlined things. Option 2, do NOT create italicized things). Do not use a trigger switch (sometimes called a “start conditioning switch). Put a key input processing in variable [0018: Typed in a button]. Check if the hero is walking down (so if there’s stored 1 in variable 18). If so, put the Y coordi-nates of player 2, 3 and 4 in the variables we’ve created for them (variable 0004, 0009 and 0014). Set variable [0007: Y hero + – Y player 2] to the heroes Y position. Subtract the Y position from player 2 from this variable. Check if the variable is now 7 or more (7, because if players are 7 squares above player 1, they are still in screen). If NOT, let the hero move up or let the hero face down. If SO, set variable [0012: Y hero + – Y player 3] to the heroes Y position, Subtract the Y position from player 3 from this variable and check if the variable is now 7. If NOT, let the hero move up or let the hero face down. If SO, do the same for checking player 4. After the last branch, in the else handler, let the hero finally move down.

Did you follow this? If so, you can check what you’ve made by looking under this. If not, you can just copy the commands by looking under this.

Please pay close attention whether you have to create the italicized and under-lined commands or not!

<>Key Input Proc: [0018: Typed in a button]
<>Branch if Var [0018: Typed in a button] is 1
…<>Variable Oper: [0004: Y position player 2] Set, Player 2 Y coord.
…<>Variable Oper: [0009: Y position player 3] Set, Player 3 Y coord.
…<>Variable Oper: [0014: Y position player 4] Set, Player 4 Y coord.
…<>Variable Oper: [0007: Y hero + – Y player 2] Set, Hero Y coord.
…<>Variable Oper: [0007: Y hero + – Y player 2] –, Player 2 Y coord.
…<>Branch if Var [0007: Y hero + – Y player 2] is 7 or more
……<>Move event: Hero, Move up Watch out!
……<>Move event: Hero, Face Down Watch out!
……<>
…:Else Handler
……<>Variable Oper: [0012: Y hero + – Y player 3] Set, Hero Y coord.
……<>Variable Oper: [0012: Y hero + – Y player 3] –, Player 3 Y coord.
……<>Branch if Var [0012: Y hero + – Y player 3] is 7 or more
………<>Move event: Hero, Move up Watch out!
………<>Move event: Hero, Face Down Watch out!
………<>
……:Else Handler
………<>Variable Oper: [0017: Y hero + – Y player 4] Set, Hero Y coord.
………<>Variable Oper: [0017: Y hero + – Y player 4] –, Player 4 Y coord.
………<>Branch if Var [0017: Y hero + – Y player 4] is 7 or more
…………<>Move event: Hero, Move up Watch out!
…………<>Move event: Hero, Face Down Watch out!
…………<>
………:Else Handler
…………<>Move event: Hero, Move down
…………<>
………:End
………<>
……:End
……<>
…:End
…<>
:Else
…<> place step 9 here
:End
<>

Time for the last step!

Step 9 Last event commands and finish this tutorial

Are you ready for the last step?
In step 8, you made the commands for checking whether the hero should be allowed to walk down or not. In this step, we will check if the hero can walk in other directions too. I will type explanations about this, I won’t type all commands, because those are almost the same as the commands in step 8.
• If walking to the left: Check if variable 18 is 2. Set variable 6 to the X position of player 2 and subtract the heroes X coord. Check if it’s 10 or more now. If so, move to the right or face to the left. If not, set variable 11 to the X position of player 3 and subtract the heroes X coord. Check if it’s 10 or more now. If so, move to the right or face to the left. If not, set variable 16 to the X position of player 4 and subtract the heroes X coord. Check if it’s 10 or more now. If so, move to the right or face to the left. If not, move to the left.
• If walking to the right: Check if variable 18 is 3. Set variable 6 to the heroes X position and subtract the X coord of player 2. Check if it’s 9 or more now. If so, move to the left or face to the right. If not, set variable 11 to the heroes X posi-tion and subtract the X coord of player 3. Check if it’s 9 or more now. If so, move to the left or face to the right. If not, set variable 16 to the heroes X posi-tion and subtract the X coord of player 4. Check if it’s 9 or more now. If so, move to the left or face to the right. If not, move to the right.
• If walking up: Check if variable 18 is 4. Set variable 7 to the Y position of player 2 and subtract the heroes Y coord. Check if it’s 7 or more now. If so, move down or face up. If not, set variable 12 to the Y position of player 3 and subtract the heroes Y coord. Check if it’s 7 or more now. If so, move down or face up. If not, set variable 17 to the Y position of player 4 and subtract the he-roes Y coord. Check if it’s 7 or more now. If so, move down or face up. If not, move up.

And you’ve finished this tutorial! Just do not forget the following 2 things:
• In every map in your game, EV0001 has to be player 2, EV0002 has to be player 3 and EV0003 has to be player 4. In maps where those player don’t play, place invisible events for them.
• View step 5 (at page 5) to see how to create events which can only be opened by player 2, only by player 3, or only by player 4, and how to create events which can be opened by every player. Of course, you can also create events which can only be opened by 2 players.

What to do if something doesn’t work
• If player 1 can’t walk far enough or can walk too far, review step 8 and 9 and check if everything is correct. And make sure that you did what you should have done (italicized and underlined things)
• If player 2, 3 or 3 can’t walk, can’t walk far enough, can walk too far or walk in the wrong direction, review the common events from the player and check if everything is correct.




If you’ve understood all this you can also create objects you can control. Just do not use a common event but a normal event.

This new multiplayer system has been written by Axel. If you have any critic, sugges-tions or found any bugs, let me know somehow (for example by mailing me at my ad-dress Axeltjuh_101@hotmail.com).
I hope this has helped you… Now on to the next tutorial!

Axel