Can you say, "Follow the leader"?
Well, now we're going to discuss the basic element for a catapiller script - A code that makes other events follow the player.. There are more advanced ways to do it, but that's for you to explore.
Q.So why do an event version when I can just use an RGSS script?
A. An eventing version is much more managable for special cutscenes or parts in your game, well, for non-scriptors anyway..
Here's the crackdown, I'll display the script, then explain what each command does, after all, eventing is like a whole 'nother language.
Basic Catapiller Script:
<>Variable: [0001: Player X] = Player X Coords
<>Variable: [0002: Player Y] = Player Y Coords
<>Variable: [0003: Follower 1 X] = This Event X Coords
<>Variable: [0004: Follower 1 Y] = This Event Y Coords
<>Conditional Branch: Variable [0001: Player X] > Variable [0003: Follower 1 X]
<>Move Event:: This Event
: : <>Move Right
<>
End
<>Conditional Branch: Variable [0001: Player X] < Variable [0003: Follower 1 X]
<>Move Event:: This Event
: : <>Move Left
<>
End
<>Conditional Branch: Variable [0001: Player Y] > Variable [0003: Follower 1 Y]
<>Move Event:: This Event
: : <>Move Down
<>
End
<>Conditional Branch: Variable [0001: Player Y] < Variable [0003: Follower 1 Y]
<>Move Event:: This Event
: : <>Move Up
<>
End
I know what your thinking,
"OMG great, sexy, intellectual, cunning, amazing and compassionate teacher Arkbennett, I just don't understand what all those bigs words like 'variable' even mean!"
I know, it's a dreaded fate not to understand, so, let's delve deeper into it, shall we?
First off, typically your going to put this in a reguler event on the map, but you could use it through a common event, but let's not get into that now. Your going to start a new event on the map, name it whatever you want. Your going to set it as a
parallel event, I typically set the speed to
fast and the frequency to
higher. And yes, this coding will go inside the event that you want to follow the player.
Now, you see that I split the code, the first portion is going to be part 1, the second; part 2.
The first part is the variable set up. This is where your going to save both the X and Y of the player and the followers coordinates. You should have some knowledge of variables, so we won't delve to deep in it.
Part 2 is the
Conditional Branch, this determines which way the follower should go.
It's pretty simple, RMXP's coordinate setup is similer to Quandrant IVs in math (0 starts in the top left) and the X increases as you move right, and the Y increases as you move down. So, for the first conditional branch,
<>Conditional Branch: Variable [0001: Player X] > Variable [0003: Follower 1 X]
<>Move Event:: This Event
: : <>Move Right
<>
End
It's saying, if Player's X coordinate is greater than Follower 1's X,
Move Right. Easy peasy, right? Now, if you wanted to add more followers, Make follower 2 follow follower 1, follower 3 follows follower 2, and so on and so forth.
I'd suggest putting follower 2 variables and
Conditional Branchs in the event that will be follower 2. The same with 3 and 4 and so on.
So as an example, follower 2 would look like this..
<>Variable: [0005: Follower 2 X] = This Event X Coords
<>Variable: [0006: Follower 2 Y] = This Event Y Coords
<>Conditional Branch: Variable [0003: Follower 1 X] > Variable [0005: Follower 2 X]
<>Move Event:: This Event
: : <>Move Right
<>
End
<>Conditional Branch: Variable [0003: Follower 1 X] < Variable [0005: Follower 2 X]
<>Move Event:: This Event
: : <>Move Left
<>
End
<>Conditional Branch: Variable [0004: Follower 1 Y] > Variable [0006: Follower 2 Y]
<>Move Event:: This Event
: : <>Move Down
<>
End
<>Conditional Branch: Variable [0004: Follower 1 Y] < Variable [0006: Follower 2 Y]
<>Move Event:: This Event
: : <>Move Up
<>
End
Alrighty, I think I got the basic element down of the catapiller script, so, if you have any questions or are confused in any way, please heistate to ask. Just joking go ahead and ask!