2 Player System in rm2k(3)
 | submitted by Seraph on Mon Nov 28, 2005 3:34 pm This tutorial shows you how to make a 2 player system in rm2k(3) that actually works! |
This Tutorial is designed to let you know how to make a game that features 2 players in rpg maker 2003.
For this Tutorial, you may need:
- - Some Knowledge of Switches
- - Some Knowledge of Variables
- - Some Knowledge of Fork Conditions
- - Some Knowledge of Move Events
- - Some Knowledge of Loops or Parrallel Process Events
This tutorial will just tell you how to make a 2Player system on one map only. From here you should be able to pick up everything that's been done (it's all explained) and transfer the system onto any map that you want.
Okay, the first thing we need to do is make our blank map. Make it the default 20x15 tiles in size. The chipset isnt important - just make a blank grassy map and add a couple of walls/obstacles.
Now you make the player 2 character. For this tutorial make an event called "chara2" on your map, and set its graphic to the character set of your player 2 character. It can be anything, a village man will do. For the events conditions, set it to Action Key, Same Layer As Hero.
Next, we need to set up the controls. Rm2k3 uses the arrow keys as the default movement buttons for the hero, and there's no way of changing this. Player 1 is going to be the hero anyway, so we don't want to change it. For player 2 it would be good in theory to use the arrows on the numpad, but we can't since these arrows are also used to control the hero (player 1). Instead we will use the set of keys in the upper-right corner of the numpad:
/ * - 9.
- / = Move Left
- * = Move Up
- - = Move Right
- 9 = Move Down
To go about setting up the controls, make a common event in the database and call it something along the lines of "P2 Controls". It needs to be a parrallel process event, and there is just one command in this event - an Enter Password command. In the possible ticked boxes you should tick the number 0-9 keys and the symbol keys at the bottom, but make sure that the other options are all left unchecked. At the top where it says "change received keycode" (or some other rough translation) select a new variable, and call this variable "P2 Buttons".
You can also make use of the wait 0.0 seconds trick in this event if you wish, but I personally don't. This trick is great, however, if your 2-Player system is lagging at all. All you have to do is put a wait command in the event:
[Code]:
wait (0.0secs)
You have just created the first common event, which is used to collect your instructions. All this event does is watch out for any key presses and, when it notices that a key has been pressed, changes the value of our "P2 Buttons" variable. Next we need to make an event to read this variable and act on its value.
Okay, now, make a new common event and, again, set it to a parrallel process. Call this event "P2 Movement". This event is going to use quite a few forks, so get ready for it. Here's the hard part.
First of all is put a wait 0.0 second command in there. The purpose of this is to prevent lag, as mentioned earlier in the tutorial.
Now put in a Fork Condition to check the value of the "P2 Buttons" variable. First lets check if it's value is 19, and be sure to include an
case. If it is 19, the player must have pressed 9 on the numpad, hence want to move down. So as the instructions in the fork put Move Event, and move the event "chara2" down one square. When putting in the command for the character movement, be sure to tick the box that says "Ignore Impossible Moves", this is to prevent player 2 from walking through walls and such things. And that's the principal! Repeat the fork for the different directions, taking into account that the value of "P2 Control" has to be different. Also, put a wait 0.1seconds command after each move event.

Notes: Since these events are common events, you have to keep some constants. If you want this 2 player system to work on more than one map, you'll have to ensure that "chara2" has the same event ID on every single map or else you will get unwanted movement from other events. I hope this tutorial helps!