CREATING A SIMPLE STEP COUNTING SYSTEM

How to create a simple step counting system in RPG Maker 2000/2003

PROGRAMMING AN EASY STEP COUNTER

INTRODUCTION
Hey folks! Fresh guy to the forums Digital Koifish back with another tutorial. I know that there are already tutorials about this all over but I came up with another way to create a step counter that I believe might be a lot more simple and customizable to fit people's needs.


TUTORIAL
This tutorial will cover how to create a simple system to count the hero's steps in your RPG. The practical applications for this kinda thing are very open in RPG Maker.


WHAT YOU WILL NEED TO KNOW
-Variables
-Fork/Branch Conditions


PROGRAMMING
The set up is very simple. First you'll want to set up two common events. The first will be a common event set to parallel process that will set two variables to the hero's x and y axis positions on a map. So set up an event and call it something like hero.pos (for position, not piece of--). Then go to variable operations and set a variable called hero.xpos (or whatever else you want) to store hero's x position. You can do this by dropping the 'Sprite' option box down to hero and then setting the drop box next to it all the way down to hero's x position. Do the same for a hero.ypos variable and set it to store hero's y position.

Next you will need to create a common event set to parallel process that will do the actual step counting. So create an event and call it something like system.step. Now in this event, you'll want to choose to 'Memorize Position on Map'. This will ask you to store the map id, the x-position, and the y-position. Create whatever variables you want, I used pos.map, pos.x, and pos.y as my variables. The purpose of doing this is to have a reference to check the hero's position to.

Now set a wait period of as small an increment as possible, I think RPG Maker 2003's smallest wait time is 0.1 seconds. Do this by going to Wait in the events editor and setting it to 1 (tenths of a second). This will make the system check the hero's position every 0.1 seconds.

Now comes the 'Fork/Branch Conditions' events. Set a Branch Condition to actvate if the variable pos.x is equal to the variable hero.xpos. Nothing will happen here since this will check if the hero has moved at all on the x-axis. In the else case however, set a Variable Operation to add (1) to a variable called step.counter. In effect, this event will check to see if the hero has moved on the x-axis and do nothing if there is no movement but add to the step counter if there is.

Do the same for the pos.y variable by creating a Branch Conditions set to activate if it is equal to the variable hero.ypos. Again nothing happens except for in the else case where it will add (1) to the step.counter variable.

And there you have it! To test this, just create an event that displays Message: \v and it will tell you how many steps you've taken since the system has started counting.


FINAL PROGRAMMING LOOK
Common Event: hero.pos
Variable Oper: (0001: hero.xpos) Set, Hero Xpos
Variable Oper: (0002: hero.ypos) Set, Hero Ypos

Common Event: system.step
Memorize Location: (0003), (0004), (0005)
Wait: 0.1 Sec
Branch if Var hero.xpos is V(0004) Equal
:Else Handler
Variable Oper: (0005: step.counter) + , 1

:End

Branch if Var hero.ypos is V(0005) Equal

:Else Handler
Variable Oper: (0005: step.counter) +, 1

:End


VARIATIONS
This set up can be used to set up CBS (Custom Battle Systems) so that a player will enter battle if the reach a certain step number. Just set up another variable to random between two numbers that will be the number of steps a hero has to take and then set it so that when your step counter reaches that number, it will reset and then bring you into battle.

The programming for that in itself will depend on the CBS so I won't tutorial it here.


NOTICEABLE FLAWS
There are just a few flaws I've found with this set up. First is that if the character moves too fast for the 0.1 second wait period that it will not count properly, counting two steps as one because it only checks to see if there is a position change within that 0.1 second time period. So setting the hero's default pace to a slow, countable pace will help. Check out my Creating A Run/Sprint Key tutorial to learn how to do that.

Another flaw I found is that if have a cinematic event where the hero's sprite is moving throughout it, the system will still count the steps even though the player him/herself did not do any actual movement. Also if you have a CMS (custom menu system) or CBS and use a separate map here the hero sprite is not restricted in movement, actions with the arrow keys in those maps will count toward the step counter, so restrict your hero movement in those maps.

And finally, if you have an ABS (action battle system), the step counter will count arbitrary x/y position changes that may arise if the player moves forward a little to attack the enemy at button press.


THANKS FOR READING!

Posts

Pages: 1
You can fix the cinematic event problem by making the entire process linked in a parallel process Input Key variable. If the variable is greater than 0 (a.k.a. player is pushing any directional key) THEN the system checks for a location change. That's what I did for mine.

And for the multiple step counting, I just made it count every 0.2 seconds and it works fine.
Ah yes. Useful information indeed Drakonais. Thanks.
Pages: 1