KENTONA'S COOLER CATERPILLAR SYSTEM

A Caterpillar System for RM2K3 but requires more code

  • kentona
  • 03/10/2010 05:41 PM
  • 42027 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 prev 1234 last
I added 8way Movement for the hero and it broke this system. So I came up with a way to incorporate 8way movement for the follower with just a minor addition. I'm only doing this for one follower so I don't know what would happen if you had more.

For each branch that compares coordiantes and ultimately moves the follower, you add 3 branches that compare the other coordinate.



Do this x4 for each direction.

For whatever reason it needs an end event processing, otherwise it moves in a different direction. And it needs a wait here or the follower moves slower, don't ask me to explain that one. But now my follower sticks to me like glue no matter what direction I travel in.
AtiyaTheSeeker
In all fairness, bird shrapnel isn't as deadly as wood shrapnel
5424
Ooh, this looks like it'll come in handy. Hoping this works for RM2k as well as 2003; can't imagine there'd be a hiccup, but you never know. Either way, thank you for this, Kentona. :D
No problem! I imagine it should work for 2k, but I honestly didn't try.
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

I opened this in the Steam version of RM2k3, converted the project, then just copied the files from the old RM2tsukukuru2003 RTP right into the project's resources wholesale. But it works now, for those of you who use the official Steam version and want to check it out.
Pages: first prev 1234 last