CATERPILLAR SYSTEM

A simple Caterpillar System for RM2K3 with very little code

  • calunio
  • 02/10/2010 01:01 PM
  • 23056 views
This is a code for a simple caterpillar system (event following hero) for RM2K3.

You need 4 variables:
Hero-X
Hero-Y
Event-X
Event-Y

Also, the event must be a Parallel Process.

Here is the code as it should appear on the Parallel Process page of the event:

<>Comment: First, set the position of the Hero and of the Event using your 4 variables.
<>Variable Oper: [0001:Hero-X] Set, Hero X Coord.
<>Variable Oper: [0002:Hero-Y] Set, Hero Y Coord.
<>Variable Oper: [0003:Event-X] Set, This Event X Coord.
<>Variable Oper: [0004:Event-Y] Set, This Event Y Coord.
<>Comment: Second, add this piece of code because you want the Event to be BEHIND the Hero, not in the same place.
<>Branch if Hero Up Facing
<>Variable Oper: [0002:Hero-Y] + , 1
<>
: End
<>Branch if Hero Down Facing
<>Variable Oper: [0002:Hero-Y] - , 1
<>
: End
<>Branch if Hero Left Facing
<>Variable Oper: [0002:Hero-X] + , 1
<>
: End
<>Branch if Hero Right Facing
<>Variable Oper: [0002:Hero-X] - , 1
<>
: End
<>Comment: Now, make the Event move comparing the position of the Hero and the position of the Event.
<>Comment: I also added Phasing to the event, so it won't get stuck anywhere trying to follow the hero.
<>Branch if Var [0003:Event-X] is V[0001] Less
<>Move Event: This Event, Phasing Mode ON, Move Right, Phasing Mode OFF
<>
: End
<>Branch if Var [0003:Event-X] is V[0001] Greater
<>Move Event: This Event, Phasing Mode ON, Move Left, Phasing Mode OFF
<>
: End
<>Branch if Var [0004:Event-Y] is V[0002] Less
<>Move Event: This Event, Phasing Mode ON, Move Down, Phasing Mode OFF
<>
: End
<>Branch if Var [0004:Event-Y] is V[0002] Greater
<>Move Event: This Event, Phasing Mode ON, Move Up, Phasing Mode OFF
<>
: End
<>

That's it! Pretty easy.

Also...
If you want a second event to follow the line, you can use the same code, but the second event must follow the first event, not the hero.
If you want to be able to interact with the event (like talking), use a separate parallel event to make the event move, using the code above.

Posts

Pages: first 12 next last
author=kentona
Yes, make an autostart event that moves the follower(s) to the location of the hero, and then at the end of the autostart event use the Erase Event command.

So it would be like:

<> Set Var0001 = Hero X
<> Set Var0002 = Hero Y
<> Change Event Location: Follower (var0001, var0002)
<> Erase Event


Caterpillar events are cool, but unfortunately, (1) there's the whole making offsets thing, and inevitably if you walk fast you can leave the character in the dust, (2) or they can get tangled up by obstacles, (3) or you can turn around suddenly and get stuck by the person following you, there's the whole making the character above or below you but this looks bad. (4) Lastly, the entire idea of having to import a parallel process event plus a series of other local events isn't very user friendly. (5) Awhile back, I latched on to the idea of just teleporting your follower to your position as ThisEvent: Phasing, move through you, face, then end phasing. But it just looked really terrible. So, how to get the caterpillar to only do something when you move.

And of course, we want it all on one page.

You'll need 6 variables. Basically CurrentX, CurrentY, CurrentFacing (this is important), and NewX, NewY, NewFacing. And the event in question is Same Layer and Parallel Process, and has the If Hero is in Party checked.

1)Set CurrentX, CurrentY, CurrentFacing (if you dunno how to use facing, 2=down, 4=left, 6=right,8=up)
2)Condition: If CurrentX is equal to NewX, CurrentY is equal to NewY, CurrentFacing is equal to NewFacing. Make these all nested inside each other. End Event Processing
3) Now put everything else past this. This is your "else"
4) Change Event Location, This Event (CurrentX, CurrentY). Basically, if the hero has moved or changed facing direction, teleport the follower to where you are. Because you added facing, it you turn around, you're able to walk through the follower.
5) Use Condition: Facing is the numbers listed above. Make a move event, where ThisEvent does the following: Move(the opposite direction you're facing), Face Hero and set to Ignore Impossible Moves. I originally thought you needed Phasing On and Off, but you don't, and actually shouldn't (when you turn towards your follower while facing a wall, if Phasing is On, the follower will step into the wall due to them coming out of you, without Phasing this doesn't happen).
6) Set NewX, NewY, and NewFacing then End Event Processing

Like this.



That's it. If you stop, the follower stops updating position. If you turn around, it doesn't matter that they're same layer, they move behind you. If you're near a wall, no big deal. And no getting caught or left behind.

The thing with most caterpillar things is they assume a single teleport. This always runs into problems, as you can wind up outrunning your follower, or trapping them behind obstacles.

Note: Known glitches. I haven't gotten this to work with secondary followers. The process of getting characters behind you and to reface means the second follower will constantly move. But in terms of having one companion, this is better since it constantly updates.
I tried using this on common events and tested it out but the other characters wouldn't spawn and follow the hero, whats up with that?
Maybe it's set to below hero. Set it to same level as hero.
The character following me is an event with a grphic, it is a parallel process with no preconditions and no custom movement type. I used the code above and thats it. When i go to test it doesnt move and i can walk right through it.

p.s. on a related note, my help file doesn't work so all my informatiom is off the web. Whats up with that?

AND THANK YOU
I APPRECIATE ALL THE HELP
Well, hard to say. Would you describe exactly what you did?

Btw, tip: if you're very new to RM2k3, try not to do complicated stuff for now.
I just started playing RM2K3(i kno im late) and i have a basic understanding of how it works. My problem is eventing. For example im trying to do a caterpillar system i got off this website from you but it doesnt work. I feel like something is missing or im doing something wrong. Besides what you have in this tutorial is there anything else i should be aware of?
You don't need the move event to increase his move speed. Take it out.
I put his frequency to normal:4 like you said, and put a move event that said to increase his move speed. He is still way too fast. Now he stays behind the hero, but it looks like he is continuously teleporting behind the hero

EDIT: I looked at your tutorial too, but I decided that since I only need this catepillar system for a few maps and with one follower that I would use this one.
Movement: Frequency should be set to 4:Normal.

Also, try this: http://rpgmaker.net/tutorials/256/
Would this be "Frequency up" or "movespeed up" because when I use movespeed up just once, he's way too fast. Frequency doesn't seem to have an effect.
Increase the event movement speed to be the same as the hero's (Normal by default).
When I use this system the follower character is too slow compared to the hero. This leads to the follower character taking routes through objects and such. This also leads to the follower lagging behind the hero. How do I fix this?
Now, would that be a CE, or another event on every map?
Oops, I missed something. (Curse you lack of Edit button!!) Right after the If Hero Moved ON branch, add a line to turn it off:


<> Branch if Switch [0001:Hero Moved] is ON
<> Switch Operation: [0001:Hero Moved] OFF
<> Var [0005:Previous_Hero_X] Set, Var[0001:Hero_X] Value
<> Var [0006:Previous_Hero_Y] Set, Var[0002:Hero_Y] Value
...etc...
I figured out how to prevent that quirky movement AND prevent you from getting blocked in a narrow path AND still have the follower(s) be 1/2 or 1/3rd transparent when walking through certain tiles (such as one the worldmap forest).

Leave the followers as Same Layer As Hero but at the start of the parallel event have a <> Move Event: This Event, Phasing Mode ON and never turn it off (remove the Phasing Mode OFF lines from the original move events). This will prevent the blocking and allow for 1/2 or 1/3 transparencies.

For the quirky movement, for the first follower you need to add a simple check to determine if the hero has changed position and only do the follower movement logic if it has.

In the autostart event I described before, add two new variables Previous_Hero_X and Previous_Hero_Y and set them to the current hero's X and Y positions.

In the follower's parallel process, add this right after the <>Variable Oper: Set, This Event Y Coord.:


<> Branch if Var [0005:Previous_Hero_X] is V[0001:Hero_X] Not
<> Switch Operation: [0001:Hero Moved] ON
<> End
<> Branch if Var [0006:Previous_Hero_Y] is V[0002:Hero_Y] Not
<> Switch Operation: [0001:Hero Moved] ON
<> End
<> Branch if Switch [0001:Hero Moved] is ON
<> Var [0005:Previous_Hero_X] Set, Var[0001:Hero_X] Value
<> Var [0006:Previous_Hero_Y] Set, Var[0002:Hero_Y] Value
...insert movement code here with all the If Left Facing, Right facing, If Var [0003:Event-X] is V[0001] Less, etc...
<> End


With that in place, the first follower will only use his move logic if the hero has actually changed position, and since the second follower follows the first and the third follower follows the second, they won't move either unless the hero does.


Yes, make an autostart event that moves the follower(s) to the location of the hero, and then at the end of the autostart event use the Erase Event command.

So it would be like:

<> Set Var0001 = Hero X
<> Set Var0002 = Hero Y
<> Change Event Location: Follower (var0001, var0002)
<> Erase Event
One more thing. I got it working. My only problem is that the event has to run over to the hero from where they are in the map. Is there a way to fix that?
Now, you have to make this event on every map, right?
Pages: first 12 next last