Extra Movement Frames
Version: 1.0
Author: modern algebra
Date: January 20, 2008
Description
This script allows you to import characters with more than 3 movement frames. In other words, It allows you to make movement animation a little bit smoother, if that is what is desired. One use for it is it allows RMXP format characters to be imported into a VX game without editing (you'll need to rename the file though)
Features
- Unlimited number of movement frames
- Works on a character to character basis
- Very easy to use
Screenshots
N/A for this kind of script
Instructions
Insert this script above main in the database. To add a character with extra movement frames, simply rename the character graphic to something of the form:
!$%[<number of movement frames>]<Regular name>
Example: !$%[4]001-Fighter01
That would make the graphic 001-Fighter01 be interpreted as having 4 frames
Script
#==============================================================================
# Extra Movement Frames v. 1.0
# Author: modern algebra (rmrk.net)
# Date: January 20, 2008
#------------------------------------------------------------------------------
# Instructions:
# Insert this script above main in the database. To add a character with
# extra movement frames, simply rename the character graphic to something
# of the form:
# !$%[<number of movement frames>]<Regular name>
#
# Example: !$%[4]001-Fighter01
# That would make the graphic 001-Fighter01 be interpreted as having 4 frames
#------------------------------------------------------------------------------
# ** Game_Character
#------------------------------------------------------------------------------
# Summary of changes:
# aliased methods - update_animation
# new class variables - height divisor, width divisor
# new methods - calculate_divisors
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :height_divisor # The height of a single frame
attr_reader :width_divisor # number of frames in the x direction
attr_reader :char_frames
#--------------------------------------------------------------------------
# * Calculate Divisors
#--------------------------------------------------------------------------
# Sets up the instance variables required
#--------------------------------------------------------------------------
def calculate_divisors
return unless @previous_character.nil? || @previous_character != @character_name
bitmap = Cache.character (@character_name)
sign = @character_name[/^[\!\$].[\%]\[\d*\]/]
if !sign.nil? && sign.size > 5
@original_pattern = 0
@width_divisor = sign[4, sign.size - 5].to_i
@height_divisor = 4
@char_frames = @width_divisor
elsif !sign.nil? && sign.include? ('$')
@width_divisor = 3
@height_divisor = 4
@char_frames = 3
else
@width_divisor = 12
@height_divisor = 8
@char_frames = 3
end
@previous_character = @character_name
end
#--------------------------------------------------------------------------
# * Update Animation
#--------------------------------------------------------------------------
# Change the hard coded values to ones dependent on character graphic format
#--------------------------------------------------------------------------
alias ma_extra_movement_frames_anim_upd update_animation
def update_animation
if @width_divisor == 12 || @width_divisor == 3
ma_extra_movement_frames_anim_upd
return
end
saved_anime_count = @anime_count
pattern_original = @pattern
speed = @move_speed + (dash? ? 1 : 0)
ma_extra_movement_frames_anim_upd
if (saved_anime_count > (18 - speed * 2)) && (@step_anime || (@stop_count <= 0))
@pattern = (pattern_original + 1) % @char_frames
end
end
end
#==============================================================================
# * Sprite Character
#------------------------------------------------------------------------------
# Summary of changes:
# aliased methods - update_src_rect, update_bitmap
#==============================================================================
class Sprite_Character
#--------------------------------------------------------------------------
# * Update Src Rect
#--------------------------------------------------------------------------
# Interpret multiple movement frames: Changed pattern
#--------------------------------------------------------------------------
alias ma_extra_movement_frames_src_rect_upd update_src_rect
def update_src_rect
if @tile_id == 0
ma_extra_movement_frames_src_rect_upd
index = @character.character_index
pattern = @character.pattern < @character.char_frames ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
#--------------------------------------------------------------------------
# * Update Bitmap
#--------------------------------------------------------------------------
# Change hard coded values to ones dependent on character graphic
#--------------------------------------------------------------------------
alias ma_extra_movement_frames_bmp_upd update_bitmap
def update_bitmap
@character.calculate_divisors
saved_tile_id = @tile_id
saved_character_name = @character_name
saved_character_index = @character_index
ma_extra_movement_frames_bmp_upd
if saved_tile_id != @character.tile_id or
saved_character_name != @character.character_name or
saved_character_index != @character.character_index
unless @tile_id > 0
@cw = bitmap.width / @character.width_divisor
@ch = bitmap.height / @character.height_divisor
self.ox = @cw / 2
self.oy = @ch
end
end
end
end
#==============================================================================
# ** Window Base
#------------------------------------------------------------------------------
# Summary of changes:
# overwritten methods - draw_character
#==============================================================================
class Window_Base
#--------------------------------------------------------------------------
# * Draw Charater (overwritten for extra movement frames)
# character_name : the name of the character file
# character_index : the index of the character in the file
# x : the x position to draw
# y : the y position to draw
#--------------------------------------------------------------------------
def draw_character(character_name, character_index, x, y)
return if character_name == nil
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$].[\%]\[\d*\]/]
if !sign.nil? && sign.size > 5
cw = bitmap.width / sign[4, sign.size - 5].to_i
ch = bitmap.height / 4
elsif sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
Credit
Support
Just post here at rmrk if you have problems.
Known Compatibility Issues
Sorry, I overwrote a method (draw_character in Window_Base). Because of that, there might be some major compatibility issues. If I write a next version, my one goal will be to avoid overwriting that method, but it made things easier this time around.
Author's Notes
I wrote this a while ago, but with Synthesize posting VX scripts, I don't want to fall behind :P
Sounds badass.
QuoteWell, I would like to use it... BUT:
Known Compatibility Issues
Sorry, I overwrote a method (draw_character in Window_Base). Because of that, there might be some major compatibility issues. If I write a next version, my one goal will be to avoid overwriting that method, but it made things easier this time around.
Author's Notes
I wrote this a while ago, but with Synthesize posting VX scripts, I don't want to fall behind
Did you fixed it allready ???
I really need that script.
Question:!$%[
8]001-Fighter01 <- Now Fighter01 should have
8 movement frames, right ?
But how should the Charset look like ?
Like this 8 x 4 (just an example):
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.pic-upload.de%2F07.05.08%2F3gpw8x.PNG&hash=40fbe4ca89dca71320500e254f88fc1e3119d32f) (http://www.pic-upload.de/view-620754/PNG_PCITURE.PNG.html)
Could you please make an example Charset for a Char with 6-8 movement frames ?Im a bit confused ???
Thnx.
The one you posted is the correct format.
As for the compatibility thing - it will only be a problem is somebody else overwrites the draw_character method. I have yet to encounter another VX script that does, so you should be safe for now. If you do come across one. Post a link to it here and I will see if I can make them compatible.
Quote from: modern algebra on May 28, 2008, 09:06:41 PM
The one you posted is the correct format.
As for the compatibility thing - it will only be a problem is somebody else overwrites the draw_character method. I have yet to encounter another VX script that does, so you should be safe for now. If you do come across one. Post a link to it here and I will see if I can make them compatible.
Just let me know if i understood u right.
So ur saying that the script is ok as long as not another script make use of that "draw_character"...
right or wrong ?
???
sry im pretty new to that "script" stuff :dog:
BtW:
Is this ur forum ?
I see millions of ur scripts on other forums.
Looks like ur one of those smart brains ^^
I cant handle scripts but i can work pretty fine with common events... the old school ya know ^^
Thanks for all ur scripts your really a enrichment for the VX.
No, other scripts can make use of that method too, they just can't overwrite it. If it's overwritten by another script, you'll have a problem in the menu and stuff where you expect to see your sprite drawn. Just don't worry about it though - I don't think it is that likely that another script will do that, so you'll probably not encounter any problems whatsoever.
And as to your question, this is the forum I am most active on yes, but I do not own the forum. That would be Roph, who is currently masquerading as Roach.
Aha, cool ;D
Well I actually just need your Extra Picture & Extra Sprites Script for my game coz everything is basecly build with common events.
So i wont get any trouble with yours & other scripts.
Thanks for your Scripts MA.
Cya :huge:
Nice script. I've been waiting for something like this.
Hmhmhm.
I may need to use this.
Great job, MA. ;8
hello modern algebra, i was wondering , is there any way to change this script to work well with a normal sprite sheet? [without the $ sign]
or to change kylock's 8 direction movement+sprite support to work with this script? because i have tryed any possible way to make them work well together,and well... they work, but it does not show any of the diagonal movement frames, so i was wondering if it is possible to edit this script or kylock's script to use a sprite sheet like: "!$%[6]Actor6" and that it will use 8 rows instead of 4 [for going up/down/left/right/lower right/upper right/lower left/upper left].
so 1st row will be used to walk up, 2nd row will be used to go left, 3rd will be used to go right, 4th will be used to go down, 5th will be used to go lower right, 6th to go to lower left, 7th will be used to go to upper left, and 8th will be used to go to upper right.
here's an example of a picture i intend to use:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi537.photobucket.com%2Falbums%2Fff339%2Flomastulx%2F6Actor_5.png&hash=936b62eca4decff74c3cfa723cf2d3168ffc36fb)
and here is kylock's 8 direction movement + sprite support:
[spoiler]
[sub]#==============================================================================
# 8 Way Directional Movement
#------------------------------------------------------------------------------
# Kylock
# 21.3.2008
# Version 1.1
#==============================================================================
# Special thanks to Arrow-1 for the script request and supplying sprites for
# testing purposes.
#==============================================================================
# Instructions:
# Add this script towards the top, since methods are rewritten and not
# aliased. Once you add it and run your game, the script will
# automagically enable 8-way directional movement for your hero.
# Features:
# * Added movement functionality to allow your hero to move in diagonal
# directions
# * Corrects directional issues resulting from trying to activate events
# while facing a diaganol direction. (could be better implemented,
# but does work as it is)
#==============================================================================
# Changelog
# 1.0 Initial Release
# 1.1 Added support for no custom sprites and added compatibility with
# Anaryu's Anti-Lag script (must be loaded above the anti-lag script)
#==============================================================================
#==============================================================================
# ** Script Configuration
#==============================================================================
module KMDM
DIRSPRITE = true # set to true if you are using a custom
# character sprite for diagonal movement
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# rewrote def move_by-input to enable extra directions
#==============================================================================
class Game_Player < Game_Character
def move_by_input
return unless movable?
return if $game_map.interpreter.running?
case Input.dir8
when 1; move_lower_left
when 2; move_down
when 3; move_lower_right
when 4; move_left
when 7; move_upper_left
when 6; move_right
when 8; move_up
when 9; move_upper_right
end
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# Corrects direction so events will respond when hero is facing diagonal.
# Modifies: def move_lower_left, def move_lower_right, def move_upper_left,
# and def move_upper_right
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Move Lower Left
#--------------------------------------------------------------------------
def move_lower_left(turn_ok = true)
set_direction(5)
if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y+1))
@x -= 1
@y += 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# * Move Lower Right
#--------------------------------------------------------------------------
def move_lower_right(turn_ok = true)
set_direction(3)
if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y+1))
@x += 1
@y += 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# * Move Upper Left
#--------------------------------------------------------------------------
def move_upper_left(turn_ok = true)
if KMDM::DIRSPRITE == true
set_direction(7)
else
set_direction(8)
end
if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y-1))
@x -= 1
@y -= 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# * Move Upper Right
#--------------------------------------------------------------------------
def move_upper_right(turn_ok = true)
set_direction(9)
if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y-1))
@x += 1
@y -= 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# Adds functionality for diagonal character sprites.
# Modifies: def update_src_rect
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# * Update Transfer Origin Rectangle
#--------------------------------------------------------------------------
def update_src_rect
if @tile_id == 0
index = @character.character_index
#if the character is facing diagonally, use the second spriteset
if @character.direction % 2 != 0 && KMDM::DIRSPRITE == true
index = @character.character_index + 1
end
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
end[/spoiler]
p.s will it work also with your running script? [with 6 frames aswell].
ill be waiting for your response.
--LoMastul
Quote from: lomastul on November 10, 2008, 02:33:58 PM
hello modern algebra, i was wondering , is there any way to change this script to work well with a normal sprite sheet? [without the $ sign]
or to change kylock's 8 direction movement+sprite support to work with this script? because i have tryed any possible way to make them work well together,and well... they work, but it does not show any of the diagonal movement frames, so i was wondering if it is possible to edit this script or kylock's script to use a sprite sheet like: "!$%[6]Actor6" and that it will use 8 rows instead of 4 [for going up/down/left/right/lower right/upper right/lower left/upper left].
so 1st row will be used to walk up, 2nd row will be used to go left, 3rd will be used to go right, 4th will be used to go down, 5th will be used to go lower right, 6th to go to lower left, 7th will be used to go to upper left, and 8th will be used to go to upper right.
here's an example of a picture i intend to use:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi537.photobucket.com%2Falbums%2Fff339%2Flomastulx%2F6Actor_5.png&hash=936b62eca4decff74c3cfa723cf2d3168ffc36fb)
and here is kylock's 8 direction movement + sprite support:
[spoiler]
[sub]#==============================================================================
# 8 Way Directional Movement
#------------------------------------------------------------------------------
# Kylock
# 21.3.2008
# Version 1.1
#==============================================================================
# Special thanks to Arrow-1 for the script request and supplying sprites for
# testing purposes.
#==============================================================================
# Instructions:
# Add this script towards the top, since methods are rewritten and not
# aliased. Once you add it and run your game, the script will
# automagically enable 8-way directional movement for your hero.
# Features:
# * Added movement functionality to allow your hero to move in diagonal
# directions
# * Corrects directional issues resulting from trying to activate events
# while facing a diaganol direction. (could be better implemented,
# but does work as it is)
#==============================================================================
# Changelog
# 1.0 Initial Release
# 1.1 Added support for no custom sprites and added compatibility with
# Anaryu's Anti-Lag script (must be loaded above the anti-lag script)
#==============================================================================
#==============================================================================
# ** Script Configuration
#==============================================================================
module KMDM
DIRSPRITE = true # set to true if you are using a custom
# character sprite for diagonal movement
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# rewrote def move_by-input to enable extra directions
#==============================================================================
class Game_Player < Game_Character
def move_by_input
return unless movable?
return if $game_map.interpreter.running?
case Input.dir8
when 1; move_lower_left
when 2; move_down
when 3; move_lower_right
when 4; move_left
when 7; move_upper_left
when 6; move_right
when 8; move_up
when 9; move_upper_right
end
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# Corrects direction so events will respond when hero is facing diagonal.
# Modifies: def move_lower_left, def move_lower_right, def move_upper_left,
# and def move_upper_right
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Move Lower Left
#--------------------------------------------------------------------------
def move_lower_left(turn_ok = true)
set_direction(5)
if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y+1))
@x -= 1
@y += 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# * Move Lower Right
#--------------------------------------------------------------------------
def move_lower_right(turn_ok = true)
set_direction(3)
if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y+1))
@x += 1
@y += 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# * Move Upper Left
#--------------------------------------------------------------------------
def move_upper_left(turn_ok = true)
if KMDM::DIRSPRITE == true
set_direction(7)
else
set_direction(8)
end
if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y-1))
@x -= 1
@y -= 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# * Move Upper Right
#--------------------------------------------------------------------------
def move_upper_right(turn_ok = true)
set_direction(9)
if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y-1))
@x += 1
@y -= 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# Adds functionality for diagonal character sprites.
# Modifies: def update_src_rect
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# * Update Transfer Origin Rectangle
#--------------------------------------------------------------------------
def update_src_rect
if @tile_id == 0
index = @character.character_index
#if the character is facing diagonally, use the second spriteset
if @character.direction % 2 != 0 && KMDM::DIRSPRITE == true
index = @character.character_index + 1
end
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
end[/spoiler]
p.s will it work also with your running script? [with 6 frames aswell].
ill be waiting for your response.
--LoMastul
I need exactly the same :D could you do it?
I'd also like your personal opinion about how many frames would be enough to make a character walk naturally, but without forcing the sistem too much...
I'll look into it, but I have quite a bit to do now, so don't expect anything for a while.
Ok, here it is.
#==============================================================================
# 8 Way Directional Movement and Extra Movement Frames Compatibility Script
#------------------------------------------------------------------------------
# Kylock
# 9.1.2009
# Version 1.0
# Extra Movement Frames by modern algebra (rmrk.net)
#==============================================================================
# Requested by Lomastul
#==============================================================================
# Instructions:
# Add this script BELOW the other two scripts. The other scripts shoud work
# in any order. Ensure DIRSPRITE = true in the 8-way movement script.
#------------------------------------------------------------------------------
# ORIGINAL SCRIPTS:
# 8 Way Directional Movement by Kylock:
# http://www.rpgrevolution.com/forums/index.php?showtopic=13487
# Extra Movement Frames by modern algebra:
# http://rmrk.net/index.php/topic,24191.0.html
#==============================================================================
#==============================================================================
# * Sprite Character
#------------------------------------------------------------------------------
# Summary of changes:
# aliased methods - update_src_rect, update_bitmap
#==============================================================================
class Sprite_Character
#--------------------------------------------------------------------------
# * Update Src Rect
#--------------------------------------------------------------------------
# Interpret multiple movement frames: Changed pattern
#--------------------------------------------------------------------------
alias ma_extra_movement_frames_src_rect_upd2 update_src_rect
def update_src_rect
if @tile_id == 0
ma_extra_movement_frames_src_rect_upd2
index = @character.character_index
#if the character is facing diagonally, use the second spriteset
if @character.direction % 2 != 0 && KMDM::DIRSPRITE == true
index = @character.character_index + 1
end
pattern = @character.pattern < @character.char_frames ? @character.pattern : 1
sx = (index % 4 * @character.char_frames + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
#--------------------------------------------------------------------------
# * Update Bitmap
#--------------------------------------------------------------------------
# Change hard coded values to ones dependent on character graphic
#--------------------------------------------------------------------------
alias ma_extra_movement_frames_bmp_upd2 update_bitmap
def update_bitmap
@character.calculate_divisors
saved_tile_id = @tile_id
saved_character_name = @character_name
saved_character_index = @character_index
ma_extra_movement_frames_bmp_upd2
if saved_tile_id != @character.tile_id or
saved_character_name != @character.character_name or
saved_character_index != @character.character_index
unless @tile_id > 0
if KMDM::DIRSPRITE
@cw = bitmap.width / @character.width_divisor / 2
else
@ch = bitmap.height / @character.height_divisor
end
self.ox = @cw / 2
self.oy = @ch
end
end
end
end
I had to reformat your sprite for functionality.
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi218.photobucket.com%2Falbums%2Fcc308%2Fkylock1%2F6Actor_5.png&hash=9d2fb789a99169fcf5460483cd95ddd6435fc40d)
Enjoy,
Kylock
Oh, cool. Thanks for doing all the work ;D
I had forgotten all about this request.
I see... so it's YOUR fault that Lomastul is buggin me on MSN =p
Very good script Modern Algebra ^ ^
I am amazed to see how you mastered the RGSS, a question you program in other languages?
Parabens by the script, he is very good
Well, thanks, though I would not consider myself a master of RGSS. This script is actually pretty old and there are a few things I'd do differently if I were to write the script today. And no, I don't program in other languages.
And yeah, sorry about that Kylock :P
Dear Sir,
I registered to this site for 1 reason, and 1 reason only- To thank you for your skill and hard work and for sharing this with us so we can create great games without an understanding of "programming".
You Sir, have allowed me to do things with my game far beyond the scope of my knowledge and limits and for this I thank you immensely.
Well, you're welcome.
I enjoy writing them when I can, and thanks for taking the effort to post that ~ it means a lot :lol:
I wish I could understand how this script worked... I feel like a complete moron. I don't know how I'm ever going to learn how to script that well.
Been studying this script more closely the past few days... I can just about understand what's going on, except for one thing... I'll try to explain, here...
It seems to me that @character_pattern (or pattern, or whatever--it's called different things all over the place) represents the "frame" of animation. By default that would be 0 for the left frame, 1 for the middle (the standing-still-with-arms-at-both-sides frame) and 2 for the right frame.
What I can't figure out amongst all the junk going on is where what frame to be displayed is determined. "1" should be default in a normal 3/4 character sheet. The sequence in a default game seems to be "1, 2, 1, 0... 1, 2, 1, 0..." If you have more than 3 frames in a sequence, not only should the default "stand-still" position be changed to a different number (in this case, it appears to be the variable @original_pattern, which is set to 0 for some reason)... and this scripts seems to play the sequence from 0 to the highest, then wrap around again...
If you had a character sheet 5 frames wide with the stand-still frame in the center (2), the sequence should play out (2, 3, 4, 3, 2, 1, 0, 1... 2, 3, 4, 3, 2, 1, 0, 1...)...
But I've looked all over in this script and the original and can't seem to figure out how the game determines which frame is played next... just can't figure it out.
In the update_animation method of Game_Character:
#--------------------------------------------------------------------------
# * Update Animation
#--------------------------------------------------------------------------
# Change the hard coded values to ones dependent on character graphic format
#--------------------------------------------------------------------------
alias ma_extra_movement_frames_anim_upd update_animation
def update_animation
if @width_divisor == 12 || @width_divisor == 3
ma_extra_movement_frames_anim_upd
return
end
saved_anime_count = @anime_count
pattern_original = @pattern
speed = @move_speed + (dash? ? 1 : 0)
ma_extra_movement_frames_anim_upd
if (saved_anime_count > (18 - speed * 2)) && (@step_anime || (@stop_count <= 0))
@pattern = (pattern_original + 1) % @char_frames
end
end
Most specifically:
if (saved_anime_count > (18 - speed * 2)) && (@step_anime || (@stop_count <= 0))
@pattern = (pattern_original + 1) % @char_frames
end
pattern_original is basically just @pattern, preserved from before it is modified in the original method. So what that code does is add 1, and then use modular division. Modular division is basically it takes the remainder of the division. So, for instance,
5 % 3 = 2, since 5 = 1*(3) + 2. Or 34 % 6 = 4 because 34 = 5*(6) + 4. In general, x % y = x - (x / y), where division rounds down.
So:
@pattern = (pattern_original + 1) % @char_frames
adds 1, mods by the number of char_frames already determined. So, if @char_frames = 5, then we could run through each instance of the pattern. It starts at 1, since that is something I did not change:
1, then that code adds 1 and mods by 5, so 2, 3, 4, 0 (5 % 5 = 0). and then it goes back to 1.
I know what you mean, but it still doesn't make sense...
Take, for instance, the original script... don't even worry about the extra movement frames add-on, but take a look here at the original...
under Sprite_Character
#--------------------------------------------------------------------------
# * Update Transfer Origin Rectangle
#--------------------------------------------------------------------------
def update_src_rect
if @tile_id == 0
index = @character.character_index
pattern = @character.pattern < 3 ? @character.pattern : 1 # <-- Huh?
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
Not sure what's going on in the 4th line. If I had to guess, pattern = character.pattern 1 (what is the : for?) unless character.pattern is less than 3... yeah I'm not complete in my search for ruby knowledge. I've seen ? before, sort of like an "if" on the fly... but ":" escapes me at the moment... could this be the answer, I wonder..
(edit:) Hm actually... it seems this means: pattern = @character.pattern if @character.pattern is less than 3, otherwise pattern = 1. I am more confused than before, now.
Anyway...
Under Game_Character...
#--------------------------------------------------------------------------
# * Update Animation Count
#--------------------------------------------------------------------------
def update_animation
speed = @move_speed + (dash? ? 1 : 0)
if @anime_count > 18 - speed * 2
if not @step_anime and @stop_count > 0
@pattern = @original_pattern
else
@pattern = (@pattern + 1) % 4
end
@anime_count = 0
end
end
Follows the same formula, but modulus 4... and since @original_pattern = 1...
pattern = (pattern + 1) % 4
2
pattern = (pattern + 1) % 4
3
pattern = (pattern + 1) % 4
0
pattern = (pattern + 1) % 4
1
So... there are actually 4 patterns, even though in a character file you only have 3 frames horizontally... this tells me patterns are stored in a sequence somewhere. And the game seems to play them in the order of 1, 2, 1, 0, repeat... because 1, 2, 0, 1 ... would look ridiculous... hope I'm making sense there...
The question is, where is this sequence being stored, and how is the 1 2 1 0... order determined? This turned out more complicated than it seemed, I think....
Hm... maybe this is it, then...
okay, say @original_pattern = 1, which it is by default (the "standing" frame, the one in the middle... the one on the left is 0, and the one on the right is 2)...
the modulus division keeps the pattern incrementing by 1... BUT... this line here...
pattern = @character.pattern < 3 ? @character.pattern : 1
This means that if the current pattern is 3 or more, then use pattern 1...
So, with that...
1..2..NOT 3, BUT 1, since 3 is NOT less than 3...0...1
So the pattern is 1 2 1 0... repeat...
Now, this works fine with default character sets... and I could be wrong here, but what do you think? Am I onto something?
OK, well you're right about the ? : thingy, basically:
pattern = @character.pattern < 3 ? @character.pattern : 1
is the same as:
if @character.pattern < 3
pattern = @character.pattern
else
pattern = 1
end
As for the other part, yes it is sequenced in the way you describe, but the sequence is calculated in the expression you are having trouble with. Consider the sequence as you describe it. 1 => 2 => 1 => 0.
Now put it through that conditional.
Let's do it on a case by case basis. Obviously the potential values for @character.pattern are 0, 1, 2, and 3, as you say.
So:
pattern = @character.pattern < 3 ? @character.pattern : 1
when @character.pattern = 0, it is less than 3, so pattern = @character.pattern = 0.
when @character.pattern = 1, it is less than 3, so pattern = @character.pattern = 1.
when @character.pattern = 2, it is less than 3, so pattern = @character.pattern = 2.
when @character.pattern = 3, it is not less than 3, so pattern = 1.
Thus, that forms the 1 => 2 => 1 => 0 sequence you have noted.
Cool... well then... knowing that, one can come up with a formula to deal with just about any size of character file.
Gow would you do that...make the character set bigger I mean. How big can you go? For example, I have a friend that is custom making sprites for me, and we want them to look really awesome, but we don't like the quishy look of the VX RTP characters, so we're making them bigger, so how big can the character set be?
As big as you want, but you don't need this script to do that.
Just put $ before the character file name, and it will treat it as a single character sheet, so it can be any size.
Hello there! I've been working with your script but I ran into few problems. They're pretty minor, but I just want to throw them at your direction so you know them.
Issue #1
By default, RPPVX process the walking pattern like this: 1,2,3,2,1,2,3 - repeat. It cycles, from 1 to 3, to 1, etc.
But your script changed that so it goes 1,2,3,4, 1,2,3,4, 1,2,3,4. It doesn't cycle backwards. I can probably dive in the script and try to change the pattern settings.
Issue #2
When I start the game with my main character using your extended pattern script. It goes to 3rd pattern, but immediately switches to 1st pattern. It's minor but you can see character change its pattern when you're not doing anything at first - (game start, teleport wrap, etc.) It's kind of big issue for me. They aren't supposed to do that in my opinion so it irks me.
Issue #3
The script doesn't affect any filename that doesn't have $ in front. So that's fine... until I used my custom sprite that only has 3 frames, named $raven, but in the game, it acts like he has extended patterns so it only shows partial raven sprite. I can avoid this issue by setting it to %[3], though.
I believe issue # 1 is actually because this is (presumably) intended to make it possible to use RMXP characters. RMXP goes 1-2-3-4-1-2-3-4... instead.
~Miget man12
Is this script compatible with Tankentai SBS(v3.3), ATB (v1.1) and the Animated Enemies Add-on?
Because I'm having a problem, or I'm just doing it wrong... I dunno.
Well I placed the script above MAIN, I already added a character with name !$%[6]lawrence but in game I just can see parts of the sprites, sliced. :-\ In battle it goes okay.
Am I doing something wrong or it's incompatible? ??? Thanks ^-^
Very nice script, but is it customizable enough to just use animations like this?
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi47.tinypic.com%2Fdetxg0.png&hash=06bb0420a244edd694458a7fae6895c004d435d0)
Hi modern algebra, thanks for letting me use your EMF Script.
Its very usefull but I need your advice for some things about it.
This is a sample Sprite I made (only for the Down Button) to test your script:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.pic-upload.de%2Fview-5659782%2F----7-aaa.png.html&hash=f8666202b12710c1ee5312c9391631c5c4c151a2)
http://www.pic-upload.de/view-5659782/----7-aaa.png.html
What do I have to edit in your script to make it walk like this:
1-3-4-5-6-7-(repeat)
Currently your script envolves the "Stand Sprite" (2) into the walking animation, making it look "bad".
And also I've found a little issue in your script:
When I start the game with my main character. It goes to 2nd pattern, but immediately switches to 1st pattern. You can see character change its pattern when you're not doing anything at first - (game start, teleport wrap, etc.).
How do I also change this ?
I hope you can help me as fast as possible.
Thank you.
-HEast
Wait, so I have to rename my actual .png file for this to work? Lame... I spent all night downloading Sithjester's sprites so I could use them with RMVX.
It takes about 1 second to rename a file
I have a lot of files :)
If you're seriously that fucking lazy, get photoshop and make a batch command to save-as documents to whatever you want. Use google on how to batch command actions in photoshop if you have it, because I'm not going to explain something like this to an idiot.
Wow, you're a dumbass. I already did it, so get the fuck off my case.
Huh, well it mustn't have taken you too long then. Also, dumbass would be the incorrect insult. I haven't done anything dumb at all. Asshole would have been more suitable, I think. I'm not particularly on your case. You just seem to post stupid shit all the time, and I'm there to tell you that they're stupid. To be honest, it's really nothing personal, lol. I just think a lot of your posts are dumb, dumbass . ;D
No, you're pretty much on my case. You call me fucking lazy, call me an idiot, and then try to make it seem like you did nothing wrong. And yeah, you are a dumbass. I post stupid shit all the time? I'm new to forums, and I've barely been here for two days. Try to show a little consideration next time.
Hey, lets pick a fight with a mod. Why don't you calm down, and keep this off the script. Take it to a PM or something. I don't think MA likes spam in his topics for the scripts that he worked so hard on.
Anyway, I just noticed this, and I rather like it. Nice job :)
Technically, I think grafikal picked a fight with him, not the other way around :P
Anyway, I agree with redyugi; talk about it elsewhere.
Hello, im incredibly new to scripting but i learn fast. i was very excited to find this script because i can do better movement detail due to extending frame movements. but im having so much trouble understanding how to really install it correctly. i keep running into "syntax errors" and the sort. i know everyone is prolly screaming out newb right now lol and i dont blame you haha. but im just completely lost. if possible, could anyone spare the time to explain how to make this work correctly? like a step by step process? it would mean so much.
Quote from: DemonOfVenus on October 24, 2010, 11:26:51 PM
Hello, im incredibly new to scripting but i learn fast. i was very excited to find this script because i can do better movement detail due to extending frame movements. but im having so much trouble understanding how to really install it correctly. i keep running into "syntax errors" and the sort. i know everyone is prolly screaming out newb right now *snicker* and i dont blame you haha. but im just completely lost. if possible, could anyone spare the time to explain how to make this work correctly? like a step by step process? it would mean so much.
ok this is the actual error """"Script line 60: name error occurred. Undefined method `update_animation' for class `game_character'
Well, update_animation is a default method of Game_Character, so ...
my best guess is that you're using RMXP. This script is for RMVX and it will not work in XP. Sorry.
If you are using VX, then you must have screwed around with the default scripts or erased Game_Character accidentally.
well crap lol, i did however start a new project and try inserting the script but i still received that error, but maybe i did mess something else up.....anyways thanx for replying!
Hmm, OK. Well where are you putting the script? Because this script has to be put below Materials and above Main. You would get that error if you put it anywhere above the Game_Character slot.
ooooooohhhhhhh....now i see what i did, yeah you were totally right! im used to working with XP and the original rpg maker translated by don miguel or something like that. if only i had scrolled down a bit i would have answered my own question! haha thanx again for the help. and i will make great use of the script
This seems nice, though when I installed it to try it out, one of my butterflies (the ones that came with rmvx) turned into a sheep when it went diagonally to the left. OAO;;
Just posting to let you know that this is incompatible with GTBS. When I enter battle, I get an error on line 71.
QuoteScript 'Extra Movement Frames' line 71: TypeError occured.
nil can't be coerced into Fixnum
Here is line 71
@pattern = (pattern_original + 1) % @char_frames
Can you help me because in my database where i put the troops, the monster are invisible so i must predict monsters location by trying battle test :'(
and the worst, in battle my monster are look like this
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi46.tinypic.com%2F16j58wh.png&hash=923258f8cbd1277321a2cf10dbf9c11b299169d0)
can someone help me? i have already followed using !$%[number of frame]<name> :(
What is that script you are using? Also, I think I need to see the battlers. Could you possibly recreate the error in a new project and upload that for me to take a look?
Quote from: modern algebra on October 20, 2012, 01:55:05 PM
What is that script you are using? Also, I think I need to see the battlers. Could you possibly recreate the error in a new project and upload that for me to take a look?
here's the link : http://www.mediafire.com/?4gtg4dwv4gz96cv (http://www.mediafire.com/?4gtg4dwv4gz96cv)
Well, the problem is that the script is not designed to work with battlers, only with character sheets. I had thought that maybe that script used Sprite_Characters in battle, but it doesn't, so this script will not work on them.
I am sorry that I could not be of more assistance, but I have no plans to make this script work on battlers.
is kaduki can't using a bigger animated battlers unless the small one? because i'm newbie here i can only use small one with the same size with character :/
Whether the size of the sprites are small or large, this script doesn't work with that battle system and cannot be used to extend the movement frames of the battlers.
Now, there might be a way internal to that battle system that allows you to do it. Of that, however, I am unaware since I am unfamiliar with that script.
I'm not sure if you go through rmrk anymore, but I just want to ask you this:
Is this script compatible with your dash animation script and kylock's '8 dir movement + sprite support'?