Jump to content
Zen Blood

Changing Step Animation With Script Calls

Recommended Posts

Good evening!


I have a script I'm creating so that the player can have multiple outfits and change to the correct outfit when they're performing an animated action. 

For instance, if the player collides with an event that causes them to trip, I want the player's graphic to change to the appropriate "tripping" sprite set for the outfit they currently have equipped, and then play out the tripping animation in a specific way.


The script is actually working pretty well so far, except for one little detail. For the "tripping" animation, I want to change the player's sprite so that the sprite is at a specific point in its step animation and to stay there until I command the sprite to be reset.


Currently, this is how I have the sprite setup: 

The leftmost sprite is the player standing vertically.

The middle sprite is the player mid-fall.

The rightmost sprite is the player horizontally on the floor.


I know how to do this within an event. In a move route command, you would select 'script' and write in:

@pattern = #insert 0 - 2 here
# 0 = right leg out (leftmost sprite)
# 1 = resting
# 2 = left leg out (rightmost sprite)

Which would cause the target to temporarily jump to that sprite in its stepping animation. For some reason, it resets back to the "resting" sprite, but at least it's doing something right.


Calling @pattern = 2 in my custom class doesn't do anything, even though calling $game_player.jump(1, 0) forces the player to jump like it's supposed to do.

If I can't use a script call to simply do this, I'm thinking I could probably use the script call for 'Set Move Route' and ask it to call @pattern = 2 there.

I've been looking up ways to script a move route, but so far they've only left me confused. 😓

Here's my notes on an example:



move_route = RPG::MoveRoute.new 
# 'move_route' is just a name, right? I can call it anything, like 'sprite_trip'.

move_route.repeat = false           
# Doesn't need explaining.

move_route.skippable = true         
# Doesn't need explaining.

m = RPG::MoveCommand.new            
# This calls a new instance of class MoveCommand, correct?

m.code = 45                         
# 'code' is the action that is going to take place, and 45 is the number of that action, right? 45 (in this case) means that a script action will take place.

m.parameters = ["script call here"] 
# Original note: This is if you use #45 in M.code
# Seems self explanatory, but I'm not sure if I would include or remove the quotation marks.
#This executes the move route.






I tried using this, and while the game doesn't crash, nothing happens either. As a test, I tried replacing "45" with "13" (stepping backwards) and had the same result. So it must not be executing at all. 


I realize I could achieve what I want to do easily via Galv's Move Route Extras (which I do actually have implemented), but just in case I decide to remove that script or use my script for another game, I do not want it depending on someone else's script to work. As a last resort, I may use it anyway.



I am now seeing if I can manipulate instance variables from another class.

class Game_Character < Game_CharacterBase
     attr_accessor   :step_anime 
     attr_accessor   :pattern

Now from my custom class I can call $game_player.step_anime = 2 and $game_player.step_anime = false in an attempt to set the player's sprite and pause their stepping animation once its set.

I actually works to a degree! But after the player sprite goes to the last frame it will immediately pop back to the middle frame.


I'd still like to learn how to make this work exactly how I want it to, but I can use this as-is if I'm willing to compromise on the time it takes for the player to "get up" (which would be making it shorter so that there's no time for the animation to reset back to the middle frame).


Thank you very much for your time.

Edited by Zen Blood
Adding new knowledge.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.