Gw Temp

Menu

Tutorial - 'Lufia Fight System' by Axel

An item about RPGMaker 2000 posted on

Blurb

How to create a system like the Lufia Fight! Well written tutorial!

Body

It’s been a long time since I wrote my last tutorial. Now I’ll write this tutorial… A Lufia Fight System.
With a Lufia Fight System, I mean a system to start battles like in Lufia II: when you stand next to a monster. And monsters only move when you move, and you can adjust the speed.
The tutorial is written with the event command names like in Advocate’s version 1.08.
If you use another version, I think you’ll understand them as well; just one note: A conditional branch is sometimes called a fork conditioning.

You need:
• rm2k or rm2k3
• … to know how variables, coordinates, input key processing’s, labels, loops and conditional branches work
• 1 common event and for every monster you use per map 3 normal events
• in any case 5 variables and for every monster you use per map 5 more.

Note: this tutorial is made so that you don’t have to use more things for every single monster in your whole game. You need extra things for every monster per map. So if you have 139 monsters in your whole game, 21 monsters in one map at highest, then you’ll need 21 more things instead of 139.

Index
• Variables View all used variables
• Step 1 Basic information and explanations about common event
• Step 2 Explain and put in the common event
• Step 3 All explanations for the first normal event
• Step 4 Making the first normal event
• Step 5 Start the battle in the second normal event
• Step 6 Create the battle and end

Variables View all used variables
Beneath this, all used variables are viewable. This comes in handy when you are creating event commands.
Note: You can use other variable numbers of course, but make sure you don’t make mistakes then!
• Variable [0001: Hero X coord]
• Variable [0002: Hero Y coord]
• Variable [0003: Hero X coord 2]
• Variable [0004: Hero Y coord 2]
• Variable [0005: Which battle?]
• Variable [0006: Monster 1 counts your walking]
• Variable [0007: Will monster 1 move?]
• Variable [0008: Monster 1 – hero walks again]
• Variable [0009: Monster 1 – X coord]
• Variable [0010: Monster 1 – Y coord]
• Variable [0011: Monster 2 counts your walking]
• Variable [0012: Will monster 2 move?]
• Variable [0013: Monster 2 – hero walks again]
• Variable [0014: Monster 2 – X coord]
• Variable [0015: Monster 2 – Y coord]
• Variable [0016: Monster 3 counts your walking]
• Variable [0017: Will monster 3 move?]
• Variable [0018: Monster 3 – hero walks again]
• Variable [0019: Monster 3 – X coord]
• Variable [0020: Monster 3 – Y coord]
• Go on like this for every monster per map.

Step 1 Basic information and explanations about common event
First we’ll make that monsters only move when you move. We’ll use a common event to check if you’ve walked, and a normal event for every monster to make them walk as fast as you want them to walk. Second, we’ll create that you’ll fight against the monster by standing 1 square above, beneath, at the right or at the left from the monster.
Note: it is quite handy if you use the same event ID for monster 1 in every map, the same event ID for monster 2 in every map et cetera. Why this comes in handy is explained by creating the first normal event.
Now the explanations about the common event. The common event will check if you walk. You might think this is easy made, by checking whether the arrow keys are pushed and then count up a variable by one. Unfortunately it isn’t that easy. In that way, you can walk 10 squares to the right (without stopping pressing the button) and that would still count as 1.
So we’re going to make this by putting the heroes X and Y coordinates in variables, waiting 0.1 second and then put in again in different variables. Then check if they’re the same. If they’re not, you must have walked 1 square. If they are, then the variable won’t count of course. This must be made in a loop.

Step 2 Explain and put in the common event
At first, create the loop. Then he’ll constantly check if you’re walking. Which means the common event is perallel process and not using a trigger switch.
Secondly, set the heroes X coordinate in a variable. In this tutorial we will use
V[0001: Hero X coord]
Thirdly, set the heroes Y coordinate in a variable. In this tutorial we will use
V[0002: Hero Y coord]
Then we should wait 0.1 second. You may have walked in that time. So then, put the heroes X and Y coordinates in different variables. In this tutorial we will use
V[0003: Hero X coord 2] and V[0004: Hero Y coord 2]
Then check if the first X coordinate and the second X coordinate are the same. If they’re not, count up the variable by 1. Then do the same with the Y coordinates.
But it’s not that easy. If you use the same variable for every monster, you can only create that monster walk all at the same speed (why this is like this, will be explained when creating the monster movement). So, count up all variables you use for every single monster per map. Remember that example? So count up 21 variables with 1 there. For those variables we will use in this tutorial:
V[0006]: Monster 1 counts your walking
V[0010]: Monster 2 counts your walking
V[0016]: Monster 3 counts your walking
5 more again (because every monster per map uses 5 variables).
Because we’ll have to count up for both X and Y coordinates changes, I’ll use a label.
The event commands for the common event are:

<>Loop
<>Variable Oper: [0001: Hero X coord] Set, Hero X coord
<>Variable Oper: [0002: Hero Y coord] Set, Hero Y coord
<>Wait: 0.1 Sec
<>Variable Oper: [0003: Hero X coord 2] Set, Hero X coord
<>Variable Oper: [0004: Hero Y coord 2] Set, Hero Y coord
<>Branch if Var [0001: Hero X coord] is V[0003] not equal
<>Jump to label: 1
<>
: End
<>Branch if Var [0002: Hero X coord] is V[0004] not equal
<>Label: 1
<>Variable Oper: [0006: Monster 1 counts your walking] +, 1
<>Variable Oper: [0011: Monster 2 counts your walking] +, 1
<>Variable Oper: [0016: Monster 3 counts your walking] +, 1
Go on like this till you’ve had every monster per map.
: End
<>
: End loop
<>

Step 3 All explanations for the first normal event
In this step, I’ll explain the needed extra explanations for the first normal event. The “normal” explanations and the event commands for this event is written in step 4.

In this event, we will make a red jelly which walks 1 step once you walked 3 steps. A random variable is used for making the jelly walks sometimes after 4 or more steps. This looks better than a monster walking always when you walk 3 steps. The following variable is used for that random variable:
V[0007: Will monster 1 move?]
Note that this variable changes for every monster. If we create monster 2, this would be Variable[0012: Will monster 2 move?].

If the monster wouldn’t move after the 3 steps, it’ll have to wait till the hero walked another square and then go back to the random variable again. This is made with an input key processing. The used variable is:
V[0008: Monster 1 - Hero walks again]
At the input key processing for this variable, check only the arrow keys and wait until this key is pressed.

Because we use a random variable, we will use a label as well. If the monster doesn’t move after 3 steps, we have to go back to the random variable, which can be perfectly made using a label.

Now the explanation why it’s handy to use the same ID for every monster 1 in every map: We move the monster in this event. If you use the same ID for every monster 1 in every map, you don’t have to change that when you copy this to another map with another monster 1.

Got all this? Then move to step 4, for creating the event.


Step 4 Making the first normal event
So now, let’s make the monsters move! In this tutorial we will completely work out 1 monster: a red jelly like in Lufia II. A red jelly moves 1 step when you have made 3 steps (sometimes 4 or 5). So let’s make that!
First check if the hero has moves 3 steps (or more or less, which is different per monster). Note that you have to check a different variable for each monster when you check that (remember, the common event, where we had to count up 21 variables? Every monster in a map uses another variable than another monster).
If the hero has moved 3 steps, we should make the monster move.
In this tutorial we’ll set a variable randomly to 1 or 2 and then check if it’s 1. If it is, let the monster move randomly. If it isn’t, wait till the hero has walked 1 square and then try again. Don’t forget to wait for the key pressed at the input key processing. Of course, you can make this at any way you want.
So the event commands of the first normal event for a monster like this are:

<>Branch if Var[0006: Monster 1 counts your walking] is 3 or more
<>Label: 1
<>Variable Oper: [0007: Will monster 1 move?] Set, Rnd [1-2]
<>Branch if Var[0007: Will monster 1 move?] is 1
<>Move event: Red jelly, Move Randomly
<>Variable Oper: [0006: Monster 1 counts your walking] Set, 0
<>
: Else Handler
<>Key Input Proc: [0008: Monster 1 - Hero walks again]
<>Jump to Label: 1
<>
: End
<>
: End
<>

Step 5 Start the battle in the second normal event
And now, we’ll create the event that makes the battle start when you are 1 square above, beneath, at the right or at the left of the monster. I wrote a tutorial about this some months ago, the touch system. This works exactly the same.
First, put the coordinates of the hero and the monster in variables. Then check if the hero is 1 square above the monster (so check if the heroes Y coordinate is 1 less than the monster Y coordinate and the X coordinates are the same). If so, start battle. If not, check if the hero’s 1 square beneath the monster (so if the Y coordinate is 1 more and the X coordinates are the same). If so, start battle. If not, check if the X coordinate is 1 more or 1 less than the monster and the Y coordinates are the same. If so, start battle. If not, don’t start the battle.
When starting the battle, first wait 0.2 seconds. That’s because when the hero moves 1 square, the battle would start immediately without that wait – so when the hero isn’t completely at the right square. If you wait 0.2 seconds, that’ll be fixed. It’s difficult to explain, but when you forget the wait, you’ll know what I’m trying to say.
This means the following variable are used for this step in this tutorial:
V[0001: Hero X coord] V[0002: Hero Y coord]
V[0009: Monster 1 - X coord]: V[0010: Monster 1 - Y coord]
Because we constantly have to check whether a battle should start, this event is a perallel process.
We’ll make the battle start by calling to the monster on the map (so in this case the red jelly itself), because that way we don’t have to place it four times, and it is handier when you copy the events to other maps; this way you’ll only have to change 1 thing instead of 4.
When you take a look at the event commands beneath this text, you’ll see that after the first “else handler”, the Y coordinate of the hero is count up by 2, instead of 1 what you would think. That’s because it’s already been subtracted by 1 (for checking whether the hero’s 1 square above the monster), so now we have to count up by 2 instead of 1.
So the event commands for the normal event, which makes the battle start when you are 1 square above, beneath, at the right or at the left of monster 1, are:

<>Variable Oper: [0001: Hero X coord] Set, Hero X coord
<>Variable Oper: [0002: Hero Y coord] Set, Hero Y coord
<>Variable Oper: [0009: Monster 1 – X coord] Set, Red Jelly X coord
<>Variable Oper: [0010: Monster 1 – Y coord] Set, Red Jelly Y coord
<>Branch if Var[0001: Hero X coord] is V[0009] equal to
<>Variable Oper: [0002: Hero Y coord] -, 1
<>Branch if Var[0002: Hero Y coord] is V[0010] equal to
<>Wait: 0.2 sec
<>Call Event: Red Jelly [1]
<>
: Else Handler
<>Variable Oper: [0002: Hero Y coord] +, 2
<>Branch if Var[0002: Hero Y coord] is V[0010] equal to
<>Wait: 0.2 sec
<>Call Event: Red Jelly [1]
<>
: End
<>
: End
<>
: Else handler
<>Branch if Var[0002: Hero Y coord] is V[0010] equal to
<>Variable Oper: [0001: Hero X coord] -, 1
<>Branch if Var[0001: Hero X coord] is V[0009] equal to
<>Wait: 0.2 sec
<>Call Event: Red Jelly [1]
<>
: Else handler
<>Variable Oper: [0001: Hero X coord] +, 2
<>Branch if Var[0001: Hero X coord] is V[0010] equal to
<>Wait: 0.2 sec
<>Call Event: Red Jelly [1]
End of branches till the end of the event commands

Step 6 Create the battle and end
The last step!
We called to the monster itself to start the battle. So, we should create event commands in the monster event as well.
The monster must be set to stationary. He may not walk, unless that variable is enough to make the monster move.
The monster must be set to “same layer as hero”, and the start condition as “collision with hero”.
This can be done in one single command, just an enemy encounter. I made it a little bit more complicated, but it looks better I suppose.
I use a variable and store that randomly in the numbers, which fit the number of monster groups; with one of those monster groups, I want to start a battle. So this means that you don’t always fight the exact same monster group in a battle with that monster. This makes rpgmaker choose randomly one of the battles you want rpgmaker to choose from.
I added a victory and defeat handler as well. This makes you able to do different things when you whether win from the monster or are defeated by it.
How is that made?
First, I set the variable randomly to 1 or 2. The used variable is in this tutorial
V[0005: Which battle?]
Randomly to 1 or 2, because monster group 1 is one red jelly and monster group 2 are two red jelly’s and I want rpgmaker to choose one of those battles randomly.
Then I created an enemy encounter (sometimes called a “start battle” in other versions). The hero fights with the monster group which ID’s stored in variable 0005. The escape handler is set to “execute custom handler”.
In the victory handler I made the monster flash and disappear.
In the escape handler, I just set the variable which counts your steps to 0, so the monster won’t walk immediately.
The defeat handler is set to “execute custom handler”.
In the defeat handler I made a stop BGM, tint screen and game over.
This can of course be made in many ways. You are able to not using a random battle, or a victory and defeat handler. You can make an ABS or CBS or whatever.
The battle version of this tutorial looks like this:

<>Variable Oper: V[0005: Which battle] Set, Rnd [1-2]
<>Enemy encounter: Normal, V[0005], Lufia 2 cave
: Victory Handler
<>Flash Sprite: This Event, 1.0 sec (Wait)
<>Change event location: This Event, (000,000)
<>
: Escape Handler
<>Variable Oper: [0006: Monster 1 counts your walking] Set, 0
<>
: Defeat Handler
<>Play BGM: Luf2intro
<>Tint Screen: (R200 G000 B000 S000), 2.0 sec (Wait)
<>Tint Screen: (R200 G200 B200 S200), 2.0 sec (Wait)
<>Tint Screen: (R000 G000 B000 S000), 1.0 sec (Wait)
<>Game Over

<>
: End
<>

And that’s it! You made the following:
• Monsters only move when you move, and you can adjust speed
• You start battles when you’re 1 square above, beneath, at the right or at the left of a monster
• Fight random battles
• You had to use new variables for every monster per map. If you have 139 monsters in your whole game, and at highest 21 at one map, then you have to create 21 times new things, instead of 139.

I hope this tutorial has helped you. Other tutorials I wrote:
• Arrow system You can shoot arrows anywhere (like in Lufia II as well),
except at places you don’t want. You can hit switches and if you’re handy with coordinates, hit monsters too.
• Code system Create closed doors which only open with a code, or
create instruments like the ocarina in Zelda, The Ocarina of time!
• Ice system You shouldn’t stand too long on ice or you will break
through. Slippery ice guaranteed!
• Multiplayer system 3 Play with up to 4 players at the same time. 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 another player would get out of the screen.
• Rock paper scissors Play the game rock paper scissors.
• 4 small tutorials – Create puzzles with stones and switches
– Make the hero jump in 2 versions
– Let the hero play piano
– Let the hero check how long he’s played the game
• Spot system Create guards, which can walk randomly if you want.
The hero had better not come too close or he’ll get in
jail, because the guards spotted him.
• Time and weather Count seconds, minutes, hours, days or even more.
Make the weather change randomly after a random
while, or choose yourself what weather it’ll be.
• Touch system Check whether the hero’s 1 square above, beneath, at
the right or at the left from a monster, and allow him to
fight in custom battles.

All tutorials are downloadable at my site, www.rpgdomain.tk, some are downloadable at THE site for games: www.gamingw.net.

This lufia fight system has been written by Axel. If you have any critic, suggestions or found any bugs, let me know somehow (for example by mailing me at my address Axeltjuh_101@hotmail.com or Axeltjuh.101@gmail.com).
I hope this tutorial has helped you!

Axel