Gw Temp

Menu

Tutorial - 'Catterpillar systems' by Nicky9Door

An item about RPGMaker 2000 posted on

Blurb

How to create a caterpillar system where the characters visually walk behind the protagonist

Body

Hello, Nicky9Door here, giving you a very detailed tutorial on how to make a Caterpillar system. Let’s begin.

What it does

The advanced Caterpillar will make all your characters in your party visually walk behind your hero when you walk and when the hero stops, it will make the hero and all party members stand on one "square" to alleviate clutter on the map/screen. When walking, 4 tiles will be used, when standing, 1 tile will be used. The procedure below can be used for up to 4 characters and hints in the "Advanced users" section will explain how to do exceed the 4 character limit.

Requirements

Hero Chipsets with fully functional walking, pre-assembled map that you'd like the caterpillar to be tested on, understanding Local events, basic understanding of the X and Y planes, 4 Variables for each character being a part of the caterpillar, knowledge of RPG Maker or coding, maximum of 3 playable characters (again, only for testing purposes, with some advanced coding you can use this code without editing it by much to do 1,000 characters or more) and patience.

Procedure

Step 1-Local Event Creation-
Go into "event mode" and right click on a cell (square) that you know you have no intentions on making an event be triggered there for an example I used a wall or a far corner. The placement of this event is irrelevant since it's not going to visually do anything and we are just using it for code. Once you've decided a home for the code, create 3 more... We should now have a total of 4 events that do NOT have any code in them and are placed on a location where they won't be in the way of other events. This completes Step 1.

Step 2-Making the Heroes-
Now that we have our 4 events, let's set the Graphics of 3 of them (see left side of event editor when you opened the event). The graphics you're going to set them are the other 3 playable characters (see requirements for more). As for the code, we aren't going to play with it just yet. What we will make sure of is that all of the 3 events are set to "Parallel Process", Same Level As Hero, Check "Hero (whoever corresponds with the graphics) must be in party", and x4 normal. Name each event according to that person’s position in the caterpillar, for an example; the 2nd person in the line could be called 2nd_person and so on and so forth. Now click New Page and change the graphics to a blank "pink" tile from your *chipset as well as uncheck "Hero must be in party" and change the event to a "push button" event (You will want to change this to Parallel only on maps that you will be getting or losing a character). That completes step 3.

Step 3-Coding-Assigning Variables
Now that we have our 3 characters; let's go back to the event blank event. This event is going to be set to "Parallel Process" and is NOT going to have any graphics. Now in the code portion we are going to start it with a move event. In the move event you're going to move 2nd_person and have it "StartSlipThrough" and that will be it. Do the same with 3rd_person and 4th_person. Immediately after the 3 move events we are going to assign our variables. We need 4 variables right off of the bat. The first one we'll call Hero X and assign that to equal Hero X Position. The 2nd one we'll call Hero Y and assign that to equal Hero Y Position. The 3rd one we'll call Hero Last X and assign that to equal Hero X. The last one will be called Hero Last Y and equal to Hero Y. So what that should look like is this (I do not have Rpg Maker 2000 open this is off the top of my head) :
<>Move Event 4th_person-StartSlipThrough
<>Change Var: Hero X = Hero's X Pos.
<>Change Var: Hero Y = Hero's Y Pos.
<>Change Var: Hero Last X = Hero X
<>Change Var: Hero Last Y = Hero Y
Alright awesome. Now let's create underneath that a Teleport Command. Have 2nd_person teleport to the variables Hero X and Hero Y. Have the same happen for 3rd_person and 4th as well. Now that all 4 heroes share the same X and Y we need to set the other variables. We still need both the current X and Y and the Last X and Y. For an example. The first one would be 2nd_person X = 2nd_person X Pos. and then do the Y and then have 2nd_person_LastX equal 2nd_person X and then do the same with the Y and then on to 3rd_person. When you're finished, you should have a total of 16 variables the next line we're going to put a label command in of Label 1 so that way we don't have the variables reassigned again and we can loop it from this point on. Now we are going to assign Hero X to equal Hero X position again after the Label as well as Hero Y to equal the Hero Y position, this will be explained later, to make things easier you can copy the line from above and paste it here. Let's do a wait command of 0.0 seconds after the Label 1#. Alright now you thought that was complicating, let's do the function statements.

Step 4-Coding-Functions and Comparisons-
Now that all of our characters are all standing at one cell we are going to make them move together. Instead of explaining it then showing it to you in an example we're going to do reverse on this one and then I'm going to analyze it for you. So here is the first function (I will later refer to it as If Then)
<>If Hero Last X > Hero X
<>Wait: 0.1 sec
<>Move Event: 2nd_person left
<>Change Hero Last X to equal Hero X
<>Change Hero Last Y to equal Hero Y
<>Goto Label 1#
<>
:End Case
Now to analyze that for you what we just did was check to see if the hero moved in the left direction. The way to know if they did, we compared what the X was before they moved to what it was when they did and if the top part of that was true then they would've moved -1 on the X plane (Left). Think of it this way. We are going to treat the variables Hero Last X and Hero Last Y as the vertex (0,0), in this case the Hero X and Hero Y should be thought of as (-1,0). If you didn't get that, that's fine, shake your head and take a sip of your favorite beverage that's close by and read on otherwise if you did get it I'm sure you know where this is headed and you can skip to the next Step. Now after the ":End Case" in the code we are going to do another IF statement that will look like this:
<>If Hero Last X < Hero X
<>Wait: 0.1 sec
<>Move Event: 2nd_person right
<>Change Hero Last X to equal Hero X
<>Change Hero Last Y to equal Hero Y
<>Goto Label 1#
<>
:End Case
Again, we checked to see if he moved on the X plane at all. This time the result would be +1 (right). Now onto the Y's
<>If Hero Last Y < Hero Y
<>Wait: 0.1 sec
<>Move Event: 2nd_person down
<>Change Hero Last X to equal Hero X
<>Change Hero Last Y to equal Hero Y
<>Goto Label 1#
<>
:End Case
To analyze we compared the Y's this time and it came out to be -1 if this statement was true. So we moved 2nd_person down too.
<>If Hero Last Y > Hero Y
<>Wait: 0.1 sec
<>Move Event: 2nd_person up
<>Change Hero Last X to equal Hero X
<>Change Hero Last Y to equal Hero Y
<>Goto Label 1#
<>
:End Case
Obviously we are going to move 2nd_person up here because if this statement is true then it would come out to be +1. The next part is going to be if the player just didn't move at all and stayed still. The code would look something like this:
<>If Hero Last X = Hero X
<>If Hero Last Y = Hero Y
<>Goto Label 1#
<>
:End Case
<>
:End Case
Obviously we don't need to reassign the variables because they already equal what we would've changed them too! So this completes this Step!!!

Step 5-Making 3rd_person follow 2nd_person and 4th_person follow 3rd_person-
Wouldn't it be awesome if there was just an easy way to make the 3rd person follow 2nd person??? Well fat chance... We will have to do the same thing with 2nd person that we did with Hero. I have no intent to type out the code because a smart person would copy the code from the blank event's code portion and change it to work with 3rd person's on the 3rd person's code portion. It is annoying but if you want a fully functional caterpillar this is the best way to do it without having broken code. Now you'll have to do the same for 4th_person. That's it, you have completed your Caterpillar and you are ready to test out your map with them. Now the down fall is that you will have to move the 4 events to every map that you plan on having caterpillars on. There is no simple way to make this work globally since the 2nd_person and others would still have to be on each map and they would have to remain the same name (not to mention I'd have to introduce Switches and for those who don't understand the way boolean works or how True/False works and I wouldn't like to waste my time with that). The last thing we need to do is test it.

Step 6-Testing
Make sure that when you do your "Test Play" that you have have set the correct "playable characters" in the database to start with you. I would test all four at once if I were you then cut down to one to make sure that the blank events (see Step 2) are working right when they really aren't in the party. That's it. If it works cool, if not then you messed up (see below for potential problems).

Advanced users only

There is a way to make this this caterpillar work with parties that have different characters in them as well as exceed the maximum of 3 extra characters. This would involve taking the code out of the 3rd_person and 4th_person and putting them in their own events on the map first of all. Now that the code does not rely on the 3 graphics events all you have to do is make more pages. Have page 1 be for your 2nd character that can be replaced with another character that would be presented on page 2. Remember to turn "Hero if (enter name here) is in party" on for each page though so that way they don't show up if they really aren't in the party. Ideally, if the code was tweaked enough you could have someone who was the page 1 on 3rd_person be shown as a 2nd_person (as page 3 or something like that) and NOT shown as 3rd_person as well. This would involve making sure you have a page on 3rd_person that has no "event conditions" as described in Step 2 with a blank graphic and have a switch called "(Name) is in party" be turned ON. Also to exceed the 3 characters in the caterpillar, you will have to make a switch for each person that will be "in the party" and have them turned on when they enter the party and turned off when they leave. This method is preferred over the RPG Maker 2000's way of adding and removing character's for this exact reason; exceeding the 4 party limit. These switches would replace the "is in party" part of the event conditions for each #_person event. I will not type up the actual tweak for my caterpillar code, you will have to play with the code and find out for yourself (a true coder would be able to figure it out, it's not hard).

Potential Personal Errors

Characters don't move in the proper direction because you didn't compare the Last X and Current X properly. See my code Sniplets again and find the mistake.
Characters are being shown when they aren't in party because you did not set the "new page" as no graphics or because you did not uncheck "Hero (name) must be in party".
Characters aren't keeping up with your Hero because you have sped up the hero's speed frequency and not the other 3 events or because you did not enter the proper wait command for the run time to catch up.
Characters don't stand on the same square as the hero because you either moved him too many spaces when you moved him in the caterpillar or because you did not teleport him to the correct spot when you started your code.
Characters show the wrong graphics because you put the wrong graphics in Step 2 or you tried to do the Advanced Users Only and you didn't know what you were doing.
There are many other possibilities of how this code could get garbled by you when you transition it from my words to the program. If all else falls, read this tutorial again and compare it to what you have.

That’s it, thanks for reading it and I hoped it helped you!