Help - Search - Members - Calendar
Full Version: RMVX Caterpillar Script
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS2
Pages: 1, 2, 3, 4, 5
Diedrupo
This is a quick modification of Trickster's caterpillar script to make it work in RMVX. Just copy and paste and add somewhere above Main.
UPDATE: I have updated the script to fix the dash problem.

CODE

class Game_Player
#--------------------------------------------------------------------------
# * Move Down
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
super(turn_enabled)
end
#--------------------------------------------------------------------------
# * Move Left
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
super(turn_enabled)
end
#--------------------------------------------------------------------------
# * Move Right
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
super(turn_enabled)
end
#--------------------------------------------------------------------------
# * Move up
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
super(turn_enabled)
end
#--------------------------------------------------------------------------
# * Move Lower Left
#--------------------------------------------------------------------------
def move_lower_left
super
end
#--------------------------------------------------------------------------
# * Move Lower Right
#--------------------------------------------------------------------------
def move_lower_right
super
end
#--------------------------------------------------------------------------
# * Move Upper Left
#--------------------------------------------------------------------------
def move_upper_left
super
end
#--------------------------------------------------------------------------
# * Move Upper Right
#--------------------------------------------------------------------------
def move_upper_right
super
end
end

class Game_Follower < Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :actor
attr_accessor :move_speed
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
super()
@through = true
@actor = actor
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
@actor = actor
setup
end
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup
if @actor != nil
@character_name = $game_actors[@actor].character_name
@character_index = $game_actors[@actor].character_index
else
@character_name = ""
@character_index = 0
end
@opacity = 255
@blend_type = 0
@priority_type = 0
end

#--------------------------------------------------------------------------
# * Screen Z
#--------------------------------------------------------------------------
def screen_z
if $game_player.x == @x and $game_player.y == @y
return $game_player.screen_z - 1
end
super
end
#--------------------------------------------------------------------------
# * Same Position Starting Determinant (Disabled)
#--------------------------------------------------------------------------
def check_event_trigger_here(triggers)
result = false
return result
end
#--------------------------------------------------------------------------
# * Front Envent Starting Determinant (Disabled)
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
result = false
return result
end
#--------------------------------------------------------------------------
# * Touch Event Starting Determinant (Disabled)
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
result = false
return result
end
end

class Spriteset_Map
alias_method :spriteset_map_create_characters, :create_characters
def create_characters
spriteset_map_create_characters
$game_party.followers.each do |char|
@character_sprites << Sprite_Character.new(@viewport1, char)
end
end
end

class Game_Party
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_SIZE = 8
CATERPILLAR = 2
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :followers
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_party_initialize, :initialize
def initialize
trick_caterpillar_party_initialize
@followers = Array.new(MAX_SIZE - 1) {Game_Follower.new(nil)}
@move_list = []
end
#--------------------------------------------------------------------------
# * Update Followers
#--------------------------------------------------------------------------
def update_followers
flag = $game_player.transparent || $game_switches[CATERPILLAR]
@followers.each_with_index do |char, i|
char.actor = @actors[i + 1]
char.move_speed = $game_player.move_speed
if $game_player.dash?
char.move_speed += 1
end
char.update
char.transparent = flag
end
end
#--------------------------------------------------------------------------
# * Move To Party
#--------------------------------------------------------------------------
def moveto_party(x, y)
@followers.each {|char| char.moveto(x, y)}
@move_list.clear
end
#--------------------------------------------------------------------------
# * Move Party
#--------------------------------------------------------------------------
def move_party
@move_list.each_index do |i|
if @followers[i] == nil
@move_list[i...@move_list.size] = nil
next
end
case @move_list[i].type
when 2
@followers[i].move_down(*@move_list[i].args)
when 4
@followers[i].move_left(*@move_list[i].args)
when 6
@followers[i].move_right(*@move_list[i].args)
when 8
@followers[i].move_up(*@move_list[i].args)
when 1
@followers[i].move_lower_left
when 3
@followers[i].move_lower_right
when 7
@followers[i].move_upper_left
when 9
@followers[i].move_upper_right
when 5
@followers[i].jump(*@move_list[i].args)
end
end
end
#--------------------------------------------------------------------------
# * Add Move List
#--------------------------------------------------------------------------
def update_move(type, *args)
move_party
@move_list.unshift(Game_MoveListElement.new(type, args))
end
end

class Game_MoveListElement
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(type, args)
@type = type
@args = args
end
#--------------------------------------------------------------------------
# * Type
#--------------------------------------------------------------------------
def type
return @type
end
#--------------------------------------------------------------------------
# * Args
#--------------------------------------------------------------------------
def args
return @args
end
end

class Game_Player
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :move_speed

#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_update, :update
def update
$game_party.update_followers
trick_caterpillar_player_update
end
#--------------------------------------------------------------------------
# * 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
#--------------------------------------------------------------------------
# * Move Down
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_move_down, :move_down
def move_down(turn_enabled = true)
if passable?(@x, @y+1)
$game_party.update_move(2, turn_enabled)
end
trick_caterpillar_player_move_down(turn_enabled)
end
#--------------------------------------------------------------------------
# * Move Left
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_move_left, :move_left
def move_left(turn_enabled = true)
if passable?(@x-1, @y)
$game_party.update_move(4, turn_enabled)
end
trick_caterpillar_player_move_left(turn_enabled)
end
#--------------------------------------------------------------------------
# * Move Right
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_move_right, :move_right
def move_right(turn_enabled = true)
if passable?(@x+1, @y)
$game_party.update_move(6, turn_enabled)
end
trick_caterpillar_player_move_right(turn_enabled)
end
#--------------------------------------------------------------------------
# * Move Up
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_move_up, :move_up
def move_up(turn_enabled = true)
if passable?(@x, @y-1)
$game_party.update_move(8, turn_enabled)
end
trick_caterpillar_player_move_up(turn_enabled)
end
#--------------------------------------------------------------------------
# * Move Lower Left
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_move_lower_left, :move_lower_left
def move_lower_left
if passable?(@x - 1, @y) and passable?(@x, @y + 1)
$game_party.update_move(1)
end
trick_caterpillar_player_move_lower_left
end
#--------------------------------------------------------------------------
# * Move Lower Right
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_move_lower_right, :move_lower_right
def move_lower_right
if passable?(@x + 1, @y) and passable?(@x, @y + 1)
$game_party.update_move(3)
end
trick_caterpillar_player_move_lower_right
end
#--------------------------------------------------------------------------
# * Move Upper Left
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_move_upper_left, :move_upper_left
def move_upper_left
if passable?(@x - 1, @y) and passable?(@x, @y - 1)
$game_party.update_move(7)
end
trick_caterpillar_player_move_upper_left
end
#--------------------------------------------------------------------------
# * Move Upper Right
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_move_upper_right, :move_upper_right
def move_upper_right
if passable?(@x + 1, @y) and passable?(@x, @y - 1)
$game_party.update_move(9)
end
trick_caterpillar_player_move_upper_right
end
#--------------------------------------------------------------------------
# * Jump
#--------------------------------------------------------------------------
alias_method :trick_caterpillar_player_jump, :jump
def jump(x_plus, y_plus)
new_x = @x + x_plus
new_y = @y + y_plus
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y)
$game_party.update_move(5, x_plus, y_plus)
end
trick_caterpillar_player_jump(x_plus, y_plus)
end
end###########
###########
###########


Posted with Trickster's permission. Please give him credit if you use this script (even though I made the RMVX modifications, it is still his work).

Screenshot of it in action:


NOTE: I noticed that the CODEBOX tag messed the formatting of the script up, so I uploaded a text file attachment with the script as well.
jasonicus
Nice upload, man. I was hoping to see one of these as the first scripts.
KaneBlueriver
This may be a little silly question here but when I change the opacity (not the script) for certain events and such. The main character would disappear and the party wouldn't. My question is, am I doing something wrong here?
Diedrupo
QUOTE (KaneBlueriver @ Jan 20 2008, 02:03 PM) *
This may be a little silly question here but when I change the opacity (not the script) for certain events and such. The main character would disappear and the party wouldn't. My question is, am I doing something wrong here?


That's pretty odd, I will try it and see if I can fix it.

As a temporary workaround, if you want to turn on/off the catepillar, you can do it with a switch.
The script right now defaults to switch#2, if you want to change that, look for:

CATERPILLAR = 2

in the code, and change the 2 to whatever switch you want. the switch needs to be on for the followers to disappear.
Be sure to add a call script right after you toggle the switch with:

$game_map.need_refresh = true
SeeYouAlways
Looks great, thank you for the script! I will make good use for this because the train of chibi characters is so cute, compared to RPG Maker XP's RTP. pinch.gif
jasonicus
I thought the same thing, but I noticed that when you dash the party members don't and it looks kind of odd.
Diedrupo
QUOTE (jasonicus @ Jan 21 2008, 01:04 AM) *
I thought the same thing, but I noticed that when you dash the party members don't and it looks kind of odd.


Yeah, I am going to fix that, don't worry.
jasonicus
Oh, cool.
Diedrupo
Here's the fix for followers not dashing when you do:

CODE

#--------------------------------------------------------------------------
# * Update Followers
#--------------------------------------------------------------------------
def update_followers
flag = $game_player.transparent || $game_switches[CATERPILLAR]
@followers.each_with_index do |char, i|
char.actor = @actors[i + 1]
char.move_speed = $game_player.move_speed
if $game_player.dash?
char.move_speed += 1
end
char.update
char.transparent = flag
end
end


Replace def update_followers in class Game_Party with the one above. I will update the first post accordingly as well.
X-Snake-X
Very nice Script^^
I might use it wink.gif
jasonicus
Update works great! Thanks!
X-Auron
I copied the script and "glue" in the Editor of Scripts, but an error ocurred: He appears everything in one line
Diedrupo
QUOTE (X-Auron @ Jan 23 2008, 12:57 AM) *
I copied the script and "glue" in the Editor of Scripts, but an error ocurred: He appears everything in one line



Did you place it directly above Main?
ss3dj
cool script
Wimpy
I love me some caterpillary goodness! happy.gif It works smoothly, and it's SO cute when the characters run around...kinda like a choo-choo train, haha.
X-Snake-X
Hey I have some problems...
Everytime I add a Third Chara all the Charas are disappearing?
e.g when i have a map with three charas with an add to team thing...
The first chara appears.. But when i recruit another one they all
disappear^^"
Diedrupo
QUOTE (X-Snake-X @ Jan 28 2008, 09:54 AM) *
Hey I have some problems...
Everytime I add a Third Chara all the Charas are disappearing?
e.g when i have a map with three charas with an add to team thing...
The first chara appears.. But when i recruit another one they all
disappear^^"


That doesn't happen to me. Are you using other scripts? Make sure Caterpillar goes below them.
X-Snake-X
QUOTE (Diedrupo @ Jan 28 2008, 06:04 PM) *
QUOTE (X-Snake-X @ Jan 28 2008, 09:54 AM) *
Hey I have some problems...
Everytime I add a Third Chara all the Charas are disappearing?
e.g when i have a map with three charas with an add to team thing...
The first chara appears.. But when i recruit another one they all
disappear^^"


That doesn't happen to me. Are you using other scripts? Make sure Caterpillar goes below them.


But this will even happen when i only have you script in my game.
Diedrupo
QUOTE (X-Snake-X @ Jan 28 2008, 01:14 PM) *
QUOTE (Diedrupo @ Jan 28 2008, 06:04 PM) *
QUOTE (X-Snake-X @ Jan 28 2008, 09:54 AM) *
Hey I have some problems...
Everytime I add a Third Chara all the Charas are disappearing?
e.g when i have a map with three charas with an add to team thing...
The first chara appears.. But when i recruit another one they all
disappear^^"


That doesn't happen to me. Are you using other scripts? Make sure Caterpillar goes below them.


But this will even happen when i only have you script in my game.


Can you upload your project somewhere?
X-Snake-X
QUOTE (Diedrupo @ Jan 28 2008, 09:52 PM) *
QUOTE (X-Snake-X @ Jan 28 2008, 01:14 PM) *
QUOTE (Diedrupo @ Jan 28 2008, 06:04 PM) *
QUOTE (X-Snake-X @ Jan 28 2008, 09:54 AM) *
Hey I have some problems...
Everytime I add a Third Chara all the Charas are disappearing?
e.g when i have a map with three charas with an add to team thing...
The first chara appears.. But when i recruit another one they all
disappear^^"


That doesn't happen to me. Are you using other scripts? Make sure Caterpillar goes below them.


But this will even happen when i only have you script in my game.


Can you upload your project somewhere?


Yeah:
http://rapidshare.com/files/87414492/Project3.rar.html
I hope rapidshare is okay.
Diedrupo
QUOTE (X-Snake-X @ Jan 28 2008, 05:21 PM) *
QUOTE (Diedrupo @ Jan 28 2008, 09:52 PM) *
QUOTE (X-Snake-X @ Jan 28 2008, 01:14 PM) *
QUOTE (Diedrupo @ Jan 28 2008, 06:04 PM) *
QUOTE (X-Snake-X @ Jan 28 2008, 09:54 AM) *
Hey I have some problems...
Everytime I add a Third Chara all the Charas are disappearing?
e.g when i have a map with three charas with an add to team thing...
The first chara appears.. But when i recruit another one they all
disappear^^"


That doesn't happen to me. Are you using other scripts? Make sure Caterpillar goes below them.


But this will even happen when i only have you script in my game.


Can you upload your project somewhere?


Yeah:
http://rapidshare.com/files/87414492/Project3.rar.html
I hope rapidshare is okay.


Ah ok, I see what's going on.

The script uses Switch 2 by default to turn the followers on/off. look for the CATERPILLAR = 2 line and change it to a different switch. The problem in your project is that you are using switch 2 to hide the 2nd event. You should use a self switch instead.
X-Snake-X
Ah i see xD
So you use the Switch 2 xD
Okay I'll try it^^
(maybe because of that it works in my other sample game^^)
THX!
BurnZer0
Is there anyway to increase the distance between the sprites, just slightly?I am using some XP sprites, and only my lead character, of the caterpillar is walking on the head of the 2nd character.The rest of them are fine, as they overlap the feet of the character in front of them.

EDIT: Nvm, i decided to use the default sprites, i will just render them in different color.So i should not have any problems with this script now.
X-Snake-X
Hey Dann...
A friend of mine is complaining about a thing...
He said that he gets an error by letting the hero jump.
Maybe you check that^^

EDIT:
Ahhh xD Never mind. I found the problem
Check line 195.
when f
it should be when 1.
revenantwings57
it doesn't work. it says there is an error in line 137.
X-Snake-X
QUOTE (revenantwings57 @ Feb 4 2008, 12:29 AM) *
it doesn't work. it says there is an error in line 137.


Then i would say you made a mistake^^"
Line 137 is
"#--------------------------------------------------------------------------"
So there can't be an error xD
maybe you should delete you current script and make a new
one with the script in the first post.
Guilmon Burst Mode
Can someone explain how they move? XD
Diedrupo
QUOTE (X-Snake-X @ Feb 3 2008, 09:34 AM) *
Hey Dann...
A friend of mine is complaining about a thing...
He said that he gets an error by letting the hero jump.
Maybe you check that^^

EDIT:
Ahhh xD Never mind. I found the problem
Check line 195.
when f
it should be when 1.


You mean the when 5? Should be 1 instead? Cool, i'll check that after work.
shaman666
a little bug is, the chars following you are always in a layer behind events (even events "below hero")
joshoga
Whenever I use the "Jump" command, the game errors...


---------------------------
Project4
---------------------------
????? 'Catterpillar' ? 198 ??? NameError ????????

undefined local variable or method `j' for #<Game_Party:0x2b813c0>
---------------------------
OK
---------------------------



#======Edit===================
Ah, nevermind figured it out, line 198, instead of "when j" should be "when 1"
Guilmon Burst Mode
QUOTE (shaman666 @ Feb 5 2008, 05:49 PM) *
a little bug is, the chars following you are always in a layer behind events (even events "below hero")


Try changing this line in Game_Follower.
CODE
@priority_type = 0

to:
CODE
@priority_type = $game_player.priority_type


Then add this to the bottom of the script.
CODE
class Game_Character
attr_accessor :priority_type
end


Not sure if it'll work though...
Astel
QUOTE (X-Snake-X @ Feb 3 2008, 03:34 PM) *
QUOTE (revenantwings57 @ Feb 4 2008, 12:29 AM) *
it doesn't work. it says there is an error in line 137.


Then i would say you made a mistake^^"
Line 137 is
"#--------------------------------------------------------------------------"
So there can't be an error xD
maybe you should delete you current script and make a new
one with the script in the first post.

Actually lines 137 is this one:

$game_party.followers.each do |char|

And it also gives this error. When used a saved file
?????''?137 ???NoMethodError ????????
undefined method 'each' for nil:NilClass

When using the New Game, shows a japanese message and the test game closes.
X-Snake-X
QUOTE (Astel @ Feb 11 2008, 05:36 PM) *
QUOTE (X-Snake-X @ Feb 3 2008, 03:34 PM) *
QUOTE (revenantwings57 @ Feb 4 2008, 12:29 AM) *
it doesn't work. it says there is an error in line 137.


Then i would say you made a mistake^^"
Line 137 is
"#--------------------------------------------------------------------------"
So there can't be an error xD
maybe you should delete you current script and make a new
one with the script in the first post.

Actually lines 137 is this one:

$game_party.followers.each do |char|

And it also gives this error. When used a saved file
?????''?137 ???NoMethodError ????????
undefined method 'each' for nil:NilClass

When using the New Game, shows a japanese message and the test game closes.


Hmm... THAT's weird^^"

thats MY line 137^^
Maybe your script is really corrupt? DId you replace it with the one
in the first post?
Astel
I'm using the one from the text file on the bottom of the post.

I get it to work, but only works with a new game (the other error was my mistake, i forgot that i was playing around with my maps and deleted the start point) else it keeps showing the same error when loading a older game file.
oozoom
I've found a glitch.

If you lose a battle, the caterpillar still stays, but if you win a battle, I lose my second character.

Any ideas?
Diedrupo
QUOTE (oozoom @ Feb 14 2008, 09:21 AM) *
I've found a glitch.

If you lose a battle, the caterpillar still stays, but if you win a battle, I lose my second character.

Any ideas?


That doesn't happen to me. Did anyone die during the battle?

If possible, upload your project somewhere and I can take a look at it. That's usually the best way for me to fix these things.

For the jumping issue, I think changing the 1 to 5 will fix it, but sorry have not gotten a chance to look.
crowgamer
umm cool but how do I make it work with my characters? every time I try to test play or the full game it keeps saying error creat characters sprite map set >.> I know nothing of skripts so can any one tell me what to do in a simple way?
Yuu-Mon Musuedo
I have a small problem. I keep getting a error in line 198 whenever I tell my character to move to the left without no other party members following him. Think you can help me on this?

I had my character moving in 1/2 speed if that might help.
Diedrupo
I need both of you to upload your projects somewhere so I can take a look at it.
Yuu-Mon Musuedo
QUOTE (Diedrupo @ Feb 21 2008, 09:23 AM) *
I need both of you to upload your projects somewhere so I can take a look at it.

Here's mine, hope it helps. It's zipped by the way.

http://rapidshare.com/files/93987189/Yuu-M...roject.rar.html
Yuu-Mon Musuedo
Sorry for double post, sorry, sorry, sorry!

But I checked up and tried to use my newbie skills to find out why I kept only getting a error on "line 198" and I found this.

CODE
@followers[i].move_up(*@move_list[i].args)
when j
@followers[i].move_lower_left
when 3


At "when j", I found it a little odd being there since it wasn't highlighted red like the others. So I removed it. After that, I stopped getting that error. Now, I don't know if that was the right thing to do or if I may made another error that might come up later. But I just post this to make sure if this was right or not. So far, nothing is wrong.
shaman666
yeah, the code is wrong, and that was said all along the topic...

change the j to 1 and it'll work
Diedrupo
Oh yeah sorry about that, hm i should edit the first post to make sure it's correct..
nathmatt
were did u upload the text file ?
nathmatt
nvm i got it but is there any way for it to work with the foot step script
Diedrupo
QUOTE (nathmatt @ Feb 24 2008, 05:00 PM) *
nvm i got it but is there any way for it to work with the foot step script


Does it work if you put the footstep script below it?
Someonation
I can't copy the script.......
I mean i copy the script....but when i paste it on the sprit list above main, all the script comes in 1 line.....please help
Thanks in advance
Eyal
Mech-Ah
I seem to have the same problem, with the script pasting. It's annoying.
nico_14_ian
Question. I added the script to a location above Main but it copied it all onto 1 line. Now I'm getting errors.com
Can anyone help me out? wink.gif
Diedrupo
That sounds very weird, I don't get that problem.

Try using the text file?

If that still does not work, I will upload a demo with the script so you can just copy and paste that.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.