KENTONA'S COOLER CATERPILLAR SYSTEM

A Caterpillar System for RM2K3 but requires more code

  • kentona
  • 03/10/2010 05:41 PM
  • 41911 views
After reading Calunio's Caterpillar System I implemented it into my game, but noticed a few quirks. For example, when the Hero is up against an obstacle and faces down without moving down (or any direction), the behavior of the followers is not ideal. They will position themselves behind the Hero regardless of passibility and the fact that the hero hasn't actually moved. Plus, I expanded it to include 3 followers behind the Hero and included the auto-start positioning logic for when you enter a new map.

I have also made a template project!

DOWNLOAD TEMPLATE PROJECT
http://rpgmaker.net/users/kentona/locker/Caterpillar.rar

Update (Jan/23)
Converted to the current official version of RM2k3, but lazily just dumped the old RTP into the resources of this project:
https://rpgmaker.net/users/kentona/locker/Caterpillar2.zip

VARIABLES, SWITCHES AND EVENTS
You will need 18 variables and 3 switches and 4 events on every map to make this tutorial work.

Event ID:0001: Positioning
Event ID:0002: Follower
Event ID:0003: Third
Event ID:0004: Rearguard

[0101:HeroX]
[0102:HeroY]
[0103:SecondX]
[0104:SecondY]
[0105:FollowerX]
[0106:FollowerY]
[0107:ThirdX]
[0108:ThirdY]
[0109:NextX]
[0110:NextY]
[0111:FourthX]
[0112:FourthY]
[0113:PreviousHeroX]
[0114:PreviousHeroY]
[0115:PreviousSecondX]
[0116:PreviousSecondY]
[0117:PreviousThirdX]
[0118:PreviousThirdY]

[0098:ThirdMoved]
[0099:SecondMoved]
[0100:HeroMoved]


The gist of this caterpillar system is that the Follower follows the Hero, the Third follows the Follower, and the Rearguard follows the Third. The followers (Follower, Third and Rearguard) are all parallel processes, same layer as Hero, with Phasing ON. They will only move if the person they are following change position on the map. (Thus they won't move if the person they are following simply changes facing direction without actually moving). Being in phased mode means that you can freely walk through them so you won't get stuck in narrow areas.


Now, on to the events...

Event ID:0001: Positioning

The auto-start Positioning event moves all the followers to the same location as the hero, just to start things off.

By erasing the event it ensures that this event is only run once BUT will re-run if the player leaves the map and then returns later. It saves having to track variables and whatnot.

The Positioning event also initiallizes a few positional tracking variables for use in the followers events.

Event Graphic: invisible
Trigger: Auto-Start
Event Layer: Below Hero


<> Variable Oper: [0101:HeroX] Set, Hero X Coord
<> Variable Oper: [0102:HeroY] Set, Hero Y Coord
<> Variable Oper: [0113:PreviousHeroX] Set, Hero X Coord
<> Variable Oper: [0114:PreviousHeroY] Set, Hero Y Coord
<> Variable Oper: [0115:PreviousSecondX] Set, Hero X Coord
<> Variable Oper: [0116:PreviousSecondY] Set, Hero Y Coord
<> Variable Oper: [0117:PreviousThirdX] Set, Hero X Coord
<> Variable Oper: [0118:PreviousThirdY] Set, Hero Y Coord
<> Change Event Location: Follower (V[0101], V[0102])
<> Change Event Location: Follower (V[0101], V[0102])
<> Change Event Location: Follower (V[0101], V[0102])
<> Erase Event



Event ID:0002: Follower

This event is the dude immediately after the hero.

The logic is straigtforward: track the location of the Hero, test to see if the Hero has changed position, and if he has move This Event accordingly.

Event Graphic: charset of the second playable character
Trigger: Parallel Process
Event Layer: Same layer as Hero


<> Comment ---------------------- INITIALIZE VARIABLES
<> Move Event: This Event, Phasing Mode ON
<> Variable Oper: [0101:HeroX] Set, Hero X Coord
<> Variable Oper: [0102:HeroY] Set, Hero Y Coord
<> Variable Oper: [0103:SecondX] Set, This Event X Coord
<> Variable Oper: [0104:SecondY] Set, This Event Y Coord
<> Comment ---------------------- TEST TO SEE IF HERO MOVED
<> Branch if Var [0113:PreviousHeroX] is V[0101:HeroX] Not
<> Switch: [0100:HeroMoved] ON
<> End if
<> Branch if Var [0114:PreviousHeroY] is V[0102:HeroY] Not
<> Switch: [0100:HeroMoved] ON
<> End if
<> Comment ---------------------- IF HERO MOVED, MOVE FOLLOWER
<> Branch if Switch: [0100:HeroMoved] is ON
<> Switch: [0100:HeroMoved] OFF
<> Variable Oper: [0113:PreviousHeroX] Set, V[0101:HeroX] Value
<> Variable Oper: [0114:PreviousHeroY] Set, V[0102:HeroY] Value
<> Branch if Hero Up Facing
<> Variable Oper: [0102:HeroY] + 1
<> End if
<> Branch if Hero Down Facing
<> Variable Oper: [0102:HeroY] - 1
<> End if
<> Branch if Hero Left Facing
<> Variable Oper: [0101:HeroX] + 1
<> End if
<> Branch if Hero Right Facing
<> Variable Oper: [0101:HeroX] - 1
<> End if
<> Comment ---------------------- MOVE FOLLOWER
<> Branch if Var [0103:SecondX] is V[0101:HeroX] Less
<> Move Event: This Event, Move Right
<> End if
<> Branch if Var [0103:SecondX] is V[0101:HeroX] Greater
<> Move Event: This Event, Move Left
<> End if
<> Branch if Var [0104:SecondY] is V[0102:HeroY] Less
<> Move Event: This Event, Move Down
<> End if
<> Branch if Var [0104:SecondY] is V[0102:HeroY] Greater
<> Move Event: This Event, Move Up
<> End if
<> End if



Event ID:0003: Third

This event is the dude third in line in the caterpillar, following the Follower event.

It is very similar to the Follower event, except that the Third tracks the position of the Follower event rather than the Hero.

Event Graphic: charset of the third playable character
Trigger: Parallel Process
Event Layer: Same layer as Hero


<> Comment ---------------------- INITIALIZE VARIABLES
<> Move Event: This Event, Phasing Mode ON
<> Variable Oper: [0105:FollowerX] Set, Follower X Coord
<> Variable Oper: [0106:FollowerY] Set, Follower Y Coord
<> Variable Oper: [0107:ThirdX] Set, This Event X Coord
<> Variable Oper: [0108:ThirdY] Set, This Event Y Coord
<> Comment ---------------------- TEST TO SEE IF FOLLOWER MOVED
<> Branch if Var [0113:PreviousHeroX] is V[0105:FollowerX] Not
<> Switch: [0099:SecondMoved] ON
<> End if
<> Branch if Var [0114:PreviousHeroY] is V[0106:FollowerY] Not
<> Switch: [0099:SecondMoved] ON
<> End if
<> Comment ---------------------- IF FOLLOWER MOVED, MOVE THIRD
<> Branch if Switch: [0099:SecondMoved] is ON
<> Switch: [0099:SecondMoved] OFF
<> Variable Oper: [0115:PreviousFollowerX] Set, V[0105:FollowerX] Value
<> Variable Oper: [0116:PreviousFollowerY] Set, V[0106:FollowerY] Value
<> Branch if Follower Up Facing
<> Variable Oper: [0106:FollowerY] + 1
<> End if
<> Branch if Follower Down Facing
<> Variable Oper: [0106:FollowerY] - 1
<> End if
<> Branch if Follower Left Facing
<> Variable Oper: [0105:FollowerX] + 1
<> End if
<> Branch if Follower Right Facing
<> Variable Oper: [0105:FollowerX] - 1
<> End if
<> Comment ---------------------- MOVE THIRD
<> Branch if Var [0107:ThirdX] is V[0105:FollowerX] Less
<> Move Event: This Event, Move Right
<> End if
<> Branch if Var [0107:ThirdX] is V[0105:FollowerX] Greater
<> Move Event: This Event, Move Left
<> End if
<> Branch if Var [0108:ThirdY] is V[0106:FollowerY] Less
<> Move Event: This Event, Move Down
<> End if
<> Branch if Var [0108:ThirdY] is V[0106:FollowerY] Greater
<> Move Event: This Event, Move Up
<> End if
<> End if



Event ID:0004: Rearguard

This event is the dude last in line in the caterpillar, following the Third event.

Same as the Third event, except tracking the Third's position (obviously).

Event Graphic: charset of the fourth playable character
Trigger: Parallel Process
Event Layer: Same layer as Hero


<> Comment ---------------------- INITIALIZE VARIABLES
<> Move Event: This Event, Phasing Mode ON
<> Variable Oper: [0109:NextX] Set, Third X Coord
<> Variable Oper: [0110:NextY] Set, Third Y Coord
<> Variable Oper: [0111:FourthX] Set, This Event X Coord
<> Variable Oper: [0112:FourthY] Set, This Event Y Coord
<> Comment ---------------------- TEST TO SEE IF THIRD MOVED
<> Branch if Var [0113:PreviousThirdX] is V[0109:NextX] Not
<> Switch: [0098:ThirdMoved] ON
<> End if
<> Branch if Var [0114:PreviousThirdY] is V[0110:NextY] Not
<> Switch: [0098:ThirdMoved] ON
<> End if
<> Comment ---------------------- IF THIRD MOVED, MOVE REARGUARD
<> Branch if Switch: [0098:ThirdMoved] is ON
<> Switch: [0098:ThirdMoved] OFF
<> Variable Oper: [0117:PreviousThirdX] Set, V[0109:NextX] Value
<> Variable Oper: [0118:PreviousThirdY] Set, V[0110:NextY] Value
<> Branch if Third Up Facing
<> Variable Oper: [0110:NextY] + 1
<> End if
<> Branch if Third Down Facing
<> Variable Oper: [0110:NextY] - 1
<> End if
<> Branch if Third Left Facing
<> Variable Oper: [0109:NextX] + 1
<> End if
<> Branch if Third Right Facing
<> Variable Oper: [0109:NextX] - 1
<> End if
<> Comment ---------------------- MOVE REARGUARD
<> Branch if Var [0111:FourthX] is V[0109:NextX] Less
<> Move Event: This Event, Move Right
<> End if
<> Branch if Var [0111:FourthX] is V[0109:NextX] Greater
<> Move Event: This Event, Move Left
<> End if
<> Branch if Var [0112:FourthY] is V[0110:NextY] Less
<> Move Event: This Event, Move Down
<> End if
<> Branch if Var [0112:FourthY] is V[0110:NextY] Greater
<> Move Event: This Event, Move Up
<> End if
<> End if



...and there it is!


NOTES
-You cannot allow the player to change the order of the party (unless you somehow track the order manually and change charsets and event graphics accordingly)
-This caterpillar assumes that you have only 4 playable characters (if you have more, you will have to add logic for event graphics)
-The leader of the caterpillar will be the Hero, ie- whoever happens to be first in the party order.
-Since Phasing Mode is ON for the followers, other events can walk over them (Unfortunately, Forbid Event Overlap doesn't work on Phased events)
-It is critical that the event IDs are consistent! RM2k3 references other events by their Event ID, so if you don't have these events as 0001, 0002, 0003, and 0004 make sure to edit the follower events accordingly to reference the correct events. Honestly, it is easiest just to create a template map with these four events ready to go to use for every time you want to make a new map in your game. Copy the template map, paste it to where you want it and then add mapping and other events after. That way the event IDs are always 0001~0004 and you don't have to muck around with anything.
-In the Template project I also added special world map logic for riding in vehicles like boats and airships.

Posts

Pages: first 1234 next last
Looks like Calunio has been out Caterpillar'd
Max McGee
with sorrow down past the fence
9159
VARIABLES, SWITCHES AND EVENTS
You will need 18 variables and 3 switches and 4 events on every map to make this tutorial work.


God I love RPG Maker VX.
Your title is mean.
But my intention was "A simple Caterpillar System for RM2K3 with very little code", so your is cooler, mine is simpler. :D
Anyways, good job. There's an easy way to fix this "You cannot allow the player to change the order of the party" though. That's the beauty of RM2K3... you can do almost anything if you use variables enough.
Craze
why would i heal when i could equip a morningstar
15170
See: Max's statement.
I'm working on one for RMVX myself, it's a tad bit complicated but I'll post it as soon as I work everything out.

Step1. Purchase RpgmakerVX

Step2. Find Caterpillar script.

Step3. Copy and Paste script into game.

Step4. ???

Step5. Profit

If your computer can't run RMVX then get a new computer. If you can't afford a computer that's able to play RMVX then you probably should spent your time elsewhere. If your parents aren't willing to get a non-crappy computer, get new parents.

Okay that's a very nice tut....well I didn't read it but I'm sure it's nice.
Okay honest I went over it this time XD!

I remember around 4 years back when I was still working with 2k3. I must have spent forever on at least every single map in the game making sure the caterpillar system I set up for it worked. In the end it did function very well but there isn't a single part of me that thinks the prize is worth the effort(even a tiny bit). But to anyone who feels it in their soul to do this...I won't stop ya.
Still prefer Rusty's caterpillar system though. You could potentially have hundreds of followers behind you with little work.
Still prefer Rusty's caterpillar system though. You could potentially have hundreds of followers behind you with little work.
Damn internal server error
Alright, next time I'll keep my work to myself. Jerks.
Okay, so I looked up a caterpillar script for RMVX and I have no idea why you guys are complaining. It's 384 lines of code (vs. about 45 lines per follower in this tutorial) and it looks a lot like this:

  #--------------------------------------------------------------------------

# * Moveto
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_moveto, :moveto
def moveto(x, y)
$game_party.moveto_party(x, y)
trick_caterpillar_player_moveto(x, y)
end


What the fuck guys? Why do you feel the need to shit on anything RM2k3 related? Does it give you the jollies? Or are you just cruel and petty? I'm getting really tired of this bullshit.
Yes indeed. This bashing seem very useless to me. ESPECIALLY since it seems like you're also too lazy to write your own code instead just copy it into your game and say "yeah this is so much simpler". Copy-pasting code like that is just ilke taking a sample game in rm2k3 with a working caterpillar system and make your game with that.

Write your own goddamn scripts. *hytter argt med näven*
hey hey hey! I'm using rm2k3 as well in case you didn't notice! I'm not bashing anything! (In case it was aimed at me)
No, it wasn't directed at you Aten. I was just miffed that this tutorial was ripped apart for nothing more than the fact that it wasn't some RMVX script that you could blindly copy and paste into your game and then feel good about yourself.
Exactly why I never use xp or vx. Its the maker of choice for lazy developers, so to speak.
Well it's not like there's anything premade about using a maker in the first place. It's not like were all using company made systems in which we're plugging and playing premade functions or events. Luckily everyone else here is using is C++ or C# or Java to make most of their game from scratch...Using somebody else's already made work for game making is lazy and shameful...

And I'm not crapping on the tutorial, it's well written and easy to learn and applicable to pretty much every other rpg maker as well. I just come from someone who used rm2k3 for 5+ years and made the move to the newer programs....so yes I feel it in my bones to kinda chuckle looking back on the stuff I put myself though just to get little tiny visual additions such as a caterpillar system. Sorry >.>



Yeah, I have no problem with VX but I do have a problem with people ragging on me just because this tutorial isn't about VX.

My next project will probably be in VX (or XNA Game Studio/C#).
I agree kentona, the way some people act about any kind of 2k3 based help material (whether it be asking for help or giving it) is just simply unreasonable, unhelpful, and ignorant. No, using VX is not how you do something in 2k3, and just because something is easier in VX doesn't mean the person reading/posting wants to use that program.

That said, this could be a very helpful tut for me, since I'm making a NES style game in my spare time! :]
Max McGee
with sorrow down past the fence
9159
I didn't mean to be mean, Kentona. My point was only that this could be accomplished in about two clicks in VX (CTRL + C, CTRL + V) as opposed to 18 switches, 3 variables, and 4 events on every map. Far be it from me to hate on 2k3. I released some of my most beloved projects in it. And there are still some great games made in it.
Max McGee
with sorrow down past the fence
9159
And I'm not crapping on the tutorial, it's well written and easy to learn and applicable to pretty much every other rpg maker as well. I just come from someone who used rm2k3 for 5+ years and made the move to the newer programs....so yes I feel it in my bones to kinda chuckle looking back on the stuff I put myself though just to get little tiny visual additions such as a caterpillar system. Sorry >.>


Basically this. It was things like eventing a CBS in rm2k3 that made me appreciate the poop out of the ability to copy paste a script for something like a caterpillar system.
Pages: first 1234 next last