Hey! For those of you who want to eliminate that random encounter
system that RM2k(3) uses, then this tutorial is for you. It will teach
you how to create an encounter system in where you can see the monster
on the screen before you engage in battle with it.
Things you need to know about;
- Switches
Variables
Fork Conditions
Proper Use of Enemy Encounter
Your imagination!
Step 1: Getting Started
Let's get started.
First off, since this is a visible encounter system, we won't need to
use the options for the random encounter system. So first thing you
should do is to go to your map and right click on Map Properties.
Make sure that no monster groups are in the enemy encounters box.
You also don't need to worry about the battle background box, as we
will choose them for each and every event. Now make your monster
event. We need two pages for this.
Page 1
Set this page to the following;
Trigger Condition: Parallel Process
Event Layer: Same Layer as Hero
Animation Type: Continuous
Movement Frequency: 2: (1/4 Normal)
Movement Type: Random
Speed: 5
Event Graphic: Set it to a monster graphic, like Monster1 from the
RTP or whatever you desire.
What this setting does is make it so that your monster moves about the
map randomly, not too fast so that it would be impossible to avoid,
and not too slow that you could avoid it easily. Now the coding. This
part requires you to make 7 different variables. I'll explain each.
In this tutorial, we'll use variables 0001 - 0007; of course, you
can use any seven variables you wish to suit your game's needs, as
long as there is seven. Now go to Variable Operations and set the
first one to Single Variable (we'll use 0001 for this tutorial as
an example). Name this first one, "Hero X Pos" For the operation, set
it to Set "Equal". For the operand, set it to Sprite. "Choose Hero", and
change the second drop-down box to "X Coordinate" Then click OK. Still
with me? Here's what it should look like if you hit OK;
<>Variable Oper: [0001:Hero X pos] Set, Hero X Coord.Now under that, create another variable. For this tut's purpose, we'll
use 0002. Do the exact same thing for this one as you did for the
first one, except change it's name to Hero Y pos, and set it to Y
coordinate. Here's what it should look like;
<>Variable Oper: [0002:Hero Y pos] Set, Hero Y Coord.Ok. Now you have X/Y coordinates for your hero. But we also need X/Y
coordinates for the monster. So, make two more variables (0003 and
0004 for this tut), and place them under 0001 and 0002. Same thing
here; name 0003 Monster X pos, and 0004 Monster Y pos. Set 0003 to
'This Event' and choose X coordinate. Set 0004 to 'This Event' and
choose Y coordinate. Then hit OK. Afterwards, it should look like the
below;
<>Variable Oper: [0003:Monster X pos] Set, This Event X Coord.
<>Variable Oper: [0004:Monster Y pos] Set, This Event Y Coord.Now, we don't want the monster to just walk around. Let's give him
some AI. When the hero strays too close, the monster will start to
chase him down. If they meet, then a battle starts. That's common
sense. So, the next two variables need to determine how close the
hero has to be in order for the monster to begin to chase him.
Set Variable 0005 to the value of Variable 0001, and Variable 0006 to
be the value of Variable 0002. These two will always check the X/Y
coordinates of the hero. Under that, set Variable 0005 to subtract
the value of Variable 0003, and Variable 0006 to subtract the value
of Variable 0004. Confused? Here's how it should look:
<>Variable Oper: [0005: X distance] Set, Var [0001]'s Value
<>Variable Oper: [0006: Y distance] Set, Var [0002]'s Value
<>Variable Oper: [0005: X distance] - , Var [0003]'s Value
<>Variable Oper: [0006: X distance] - , Var [0004]'s ValueWhen you set your variables, use the 'Value of Variable' operand
to set it up. Like when you set up Variable 0005, choose 'Value of
Variable' then choose 0001. Do the same for 0006, and set that to
'Value of Variable' 0002. This, as I said earlier, constantly checks
the hero's position. For the next two, choose Variable 0005, and
select the Subtract operation, then choose 'Value of Variable' and
choose 0003. Then select 0006, select Subtract, then choose 'Value
of Variable' 0004. This subtracts the difference of the monster's
position to the hero's. Now under all this, make a fork condition
with NO ELSE CASE. Choose Variable, and select Variable 0005.
Choose Number, and set it to -4. In the drop down box below, choose
Greater Than or Equal To. Then under that, make another fork.
Choose 0005 again (remember that 0005 should be your X variable) and
then make the number 4, and have it say Less Than or Equal To.
Under that, make another fork. Choose 0006 this time (this should be
your Y variable) and have it set to -4, then choose Greater Than or
Equal To. Under that, make one last fork. Choose 0006 again and
then make that number 4, and make it say Less Than or Equal To.
Then under those four forks, make a switch turn on. In this tut,
I'll use Switch 0001. Call this switch 'Follow'. Here's the coding:
<>Branch if Var [0005: X distance] is -4 or more
<>Branch if Var [0005: X distance] is 4 Less/Equal
<>Branch if Var [0006: Y distance] is -4 or more
<>Branch if Var [0006: Y distance] is 4 Less/Equal
<>Switch Operation: [0001:Follow] ON
<>
: End
<>
: End
<>
: End
<>
: End
<>Explanation: If the hero's X/Y position and the monster's X/Yposition are within a range between 4 and -4, the monster will start
chasing the hero. If the hero is outside of this range, the monster
will not chase him.
Alright. The First Page is done. On to the second page.
Page 2
Set this page to the following;
-Preconditions: Switch 0001 is ON. Check this to make sure this is on.
-Trigger Condition: Collision with Hero
-Event Layer: Same Layer as Hero (Forbid Event Overlap should not be
checked)
-Animation Type: Continuous
-Movement Frequency: 6: (4x Normal)
Movement Type: Toward Hero
Speed: 5 (Again, this is neither too slow, nor too fast)What happens? When your hero comes within the -4 to 4 range of the
monster, this page triggers and thus the monster starts to chase you.
Now comes the fun part: Making your monster battles. First thing
you should do is to set your seventh and final Variable. We'll use
0007 in this case as an example. This variable determines how many
monster groups the hero can fight, and which ones appear in a fight
randomly. In my game, I typically used 5 different groups, but you can have less or more. Use your
imagination. You can have as little as two, or as many as 50, but
keep in mind that the more your value, the more monster groups
you'll have to make, and that means more coding. So, let's stick with
5 groups for this tutorial's purpose.
Ok. Setting the seventh variable. Set 0007 to Set Equal and under
Operand, choose 'Random number Between'. Make the first number 1
and the second number 5. It should look like this:
<>Variable Oper: [0007:Random Monster] Set, Rnd [1-5]What happens is that when the monster comes into contact with the
hero, this variable randomly picks a number between 1 and 5, and
selects the monster group under that number, which we'll set now.
Make a fork for each possible monster encounter. In this case,
since I used 5 possibilities, that means we'll need 5 fork conditions.
Each fork needs to have an ELSE CASE checked, except for the final
fork.
For this next part, I'm gonna use monsters from my game for an
example. I'll use Puffballs, Ice Gargoyles, Ice Manglers, and Wing
Cannons. Let's set a fork for the first option.
If the game picks 1 from the variable 0007, then the hero will
fight a party of two Puffballs and an Ice Gargoyle (again, using my
game as an example here). Before you move on, check to see if your
monster groups are there and they're set up to how you want them
set up. Ok, so go to Fork Conditions, and choose Variable. Select
0007 as the variable, and make the number 1. Check the box for
else case. After that, go to Enemy Encounter (page 2). Select
'No Special Conditions' (unless you want something specific to happen
here, but it just wouldn't look right if the heroes get first
strike or a back attack every single time they run into this
monster event). Select your monster group next, in this case it would
be Puffballx2, Ice Gargoyle. Next, select your battle background.
Since the monsters in this example are from a snow area in my game,
we'll use Snowy Forest (or whatever background you want). Make
sure you select 'Use Background Associated'. Your Escape Handler
should be set to 'End Event Processing', and your Defeat Handler needs
to be set to 'Execute Custom Handler'. Click OK. Check below to see
if you're doing this right:
<>Enemy Encounter: Normal, Puffballx2,Ice Garg-, Snowy ForestThis causes two options to show up: Victory Handler and Defeat
Handler. Under Defeat Handler, you can either put a Game Over
command, or have something happen - depending on your game. Under
Victory handler, put this code:
: Victory Handler
<>Play Sound: Monster2
<>Wait: 0.5 Sec
<>Flash Sprite: This Event, 0.2 Sec (Wait)
<>Switch Operation: [0001: Follow] OFF
<>Erase Event
*You may also put anything you wish to add, as well, as long as it
doesn't screw up the process.What happens here is when the heroes defeat the monster, the monster
makes a screeching noise, flashes, and disappears. Erase Event makes
sure that the monster doesn't come back until the hero leaves the
map. If the hero returns to the map, the monster will return, so
that opens up an opportunity to level up your heroes by exiting
and re-entering the map. Under the Else Case, set up the second
fork condition, with the same properties, only thing different here
is your monster groups. Your code for each one should look like this:
<>Variable Oper: [0007:Random monster] Set [1-5]
<>Branch if Var [0007:Random monster] is 1
<>Enemy Encounter: Normal, (Insert monster group, backgrounds here)
: Victory Handler
<>Play Sound: Monster2
<>Wait 0.5 Sec
<>Flash Spriter: This Event, 0.2 Sec (Wait)
<>Switch Operation: [0001:Follow] OFF
<>Erase Event
<>
: Defeat Handler
<>Game Over (or whatever else you want here)
<>
: End
<>
: Else Handler
<>Branch if Var [0007:Random monster] is 2
<>Enemy Encounter: Normal, (Insert monster group, backgrounds here)
: Victory Handler
<>Play Sound: Monster2
<>Wait 0.5 Sec
<>Flash Spriter: This Event, 0.2 Sec (Wait)
<>Switch Operation: [0001:Follow] OFF
<>Erase Event
<>
: Defeat Handler
<>Game Over (or whatever else you want here)
<>
: End
<>
: Else Handler
<>Branch if Var [0007:Random monster] is 3
<>Enemy Encounter: Normal, (Insert monster group, backgrounds here)
: Victory Handler
<>Play Sound: Monster2
<>Wait 0.5 Sec
<>Flash Spriter: This Event, 0.2 Sec (Wait)
<>Switch Operation: [0001:Follow] OFF
<>Erase Event
<>
: Defeat Handler
<>Game Over (or whatever else you want here)
<>
: End
<>
: Else Handler
<>Branch if Var [0007:Random monster] is 4
<>Enemy Encounter: Normal, (Insert monster group, backgrounds here)
: Victory Handler
<>Play Sound: Monster2
<>Wait 0.5 Sec
<>Flash Spriter: This Event, 0.2 Sec (Wait)
<>Switch Operation: [0001:Follow] OFF
<>Erase Event
<>
: Defeat Handler
<>Game Over (or whatever else you want here)
<>
: End
<>
: Else Handler
<>Branch if Var [0007:Random monster] is 5
<>Enemy Encounter: Normal, (Insert monster group, backgrounds here)
: Victory Handler
<>Play Sound: Monster2
<>Wait 0.5 Sec
<>Flash Spriter: This Event, 0.2 Sec (Wait)
<>Switch Operation: [0001:Follow] OFF
<>Erase Event
<>
: Defeat Handler
<>Game Over (or whatever else you want here)
<>
: End
<>
: Else Handler
<>So, after you set all your monster groups, all you have to do is
copy and paste your monster event as many times as you want. Just
make sure your monsters correspond with the area your hero is in.
If you want to have different monsters in a different area, you
have to change the monsters to suit your needs. If the game starts to
lag due to having many monster events on your map, you can insert a
wait command at the very beginning of the coding on page one. A wait
command of 0.4 seconds should do the trick. This also works for those
of you who have slower computers, and your game is lagging; inputting
this wait command should get rid of at least some of the lag, if not
most or all of it.
NOTE: When the hero comes within the -4 to 4 range, the monster will start
to chase him as usual. This will also cause every monster on the map to
run to your hero. So, it's a good idea to make your maps carefully in order
to avoid some situation in your game where five or six monsters are lined
up right behind each other waiting to battle your characters. Make walls,
water, lava or any other unpassable features to force the monster to try
to walk around it. Bottom line: Focus on you going to the monster; not
the monster going to you.
Congradulaitons, You get a Cookie!