RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Pokemon 2 frames, trying to modify this script to make a correct movement

0 Members and 1 Guest are viewing this topic.

*
Rep: +0/-0Level 72
RMRK Junior
I'm trying to understand how could i modify this script to make characters move in the right way...
the characters (that i renamed "$001-01%(2)" for the script") look like this one

so the movement is:
UP       LEFT
UP       LEFT
DOWN RIGHT
DOWN RIGHT
But with this script i should edit all the pictures to make them look like this one

with this movement:
DOWN DOWN
LEFT    LEFT
RIGHT RIGHT
UP      UP
And it is a pretty hard work...
Spoiler for:
Code: [Select]
#==============================================================================
# Extra Movement Frames
# Version: 1.0.1
# Author: modern algebra (rmrk.net)
# Date: 26 September 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
# This script allows you to import character sprites with more than 3 frames
#  for movement animation. In other words, it allows you to animate sprites a
#  little more smoothly. One use for it is it allows RMXP format characters to
#  be imported directly into a VXA game without editing (although you will need
#  to rename the file).
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
# Paste this script into its own slot in the Script Editor, above Main but
#   below Materials. If you are using my Composite Graphics script, then this
#   script must be placed in a slot below Composite Graphics.
#
# To create a sprite with extra movement frames, all you need to do is
#   rename the character graphic to something of the form:
#
#   Regular_Name%(x)
# where:
#   x is the number of frames in each character sprite

#  EXAMPLES:
#
# $001-Fighter01%(4)
#   This graphic is a single character with four frames of animation. [XP]
# 022-Actors12%(6)
#   This graphic would be interpreted as a character sheet of 8 characters,
#   each having six frames of animation.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Additionally, this script also allows you to specify the "idle" frame (the
#   frame where the sprite is not moving), and also the pattern if wish to so
#   specify. In essence, all you need to do is add those integers after the
#   number of frames:
#
#   Regular_Name%(x y1 y2 y3 ... yx)
# where:
#   x is the number of frames in each character sprite
#   y1 is the idle frame (the frame shown when sprite is not moving)
#   y2 ... yx are the pattern.
#
#   Keep in mind that the first frame in a sprite is index 0, the second frame
#   is index 1, etc.
#
# Where y1 is excluded, it is assumed to be 0. Where y2 ... yx are excluded,
#   the pattern is assumed to simply cycle through the frames one by one until
#   it repeats.
#
#  EXAMPLES:
#
# $003-Fighter03%(4 2)
#   This graphic is a single character with four frames of animation. The
#   idle frame is 2 (the third one over). The pattern when moving would be
#   2 3 0 1, 2 3 0 1, etc.
# 032-People05%(4 0 1 0 3 2 1)
#   This graphic would be interpreted as a character sheet of 8 characters,
#   each having four frames of animation. The idle frame is 0 (the first
#   in the sheet), and the pattern is 0 1 0 3 2 1, 0 1 0 3 2 1, etc.
#==============================================================================

$imported = {} unless $imported
$imported[:MA_ExtraMovementFrames] = true

#==============================================================================
# *** MA_ExtraMovementFrames
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This module holds a method for calculating width and height of an emf
# character frame
#==============================================================================

module MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check if Character has extra movement frames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_char_is_emf_sprite?(character_name)
character_name && !character_name[/\%[\(\[].+?[\)\]]/].nil?
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Derive Frames Array
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_get_frames(character_name)
character_name = "" unless character_name
frames = !character_name[/\%[\(\[](.+?)[\)\]]/] ? [] :
  $1.scan(/\d+/).collect { |s| s.to_i }
frames[0] = 3 unless frames[0] # If empty, then set to default 3
frames.push(1, 2, 1, 0) if frames[0] == 3 && frames.size < 2
frames[1] = 0 unless frames[1] # Set idle frame
if frames.size < 3
  # Create pattern
  (frames[0] - 1).times {|i| frames.push((frames[1] + i + 1) % frames[0]) }
end
return frames
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Calculate Frame Size
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_calc_frame_size(character_name, bitmap, frames = [])
character_name = "" unless character_name
frames = maemf_get_frames(character_name) if frames.empty?
cw = bitmap.width / (frames[0] ? frames[0] : 3)
ch = bitmap.height / 4
sign = character_name[/^[\!\$]./]
if !sign || !sign.include?('$')
  cw /= 4
  ch /= 2
end
return cw, ch
  end
end

# Compatibility with Composite Graphics
if $imported[:MA_CompositeGraphics]
  #============================================================================
  # *** Cache
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  # aliased method - macgve_make_unique_name
  #============================================================================
  class << Cache
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Make Unique Name
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias macgemf_uniqname_3tc8 macgve_make_unique_name
def macgve_make_unique_name(cg_array = [], *args)
  result = macgemf_uniqname_3tc8(cg_array, *args) # Call Original Method
  # Add %(x) code to name if the first graphic in the array contains it.
  result += $1 if cg_array[0] && cg_array[0].filename[/(\%[\(\[].+?[\)\]])/]
  result
end
  end
end

#==============================================================================
# ** Game_CharacterBase
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
# aliased method - straighten; update_anime_pattern; initialize;
#   set_graphic; character_name=
# new methods - maemf_init_char_frames
#==============================================================================

class Game_CharacterBase
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Straighten
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_straghtn_5sb3 straighten
  def straighten(*args, &block)
maemf_straghtn_5sb3(*args, &block) # Run original method
@pattern = @original_pattern if @walk_anime || @step_anime
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Anime Pattern
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_updanim_ptrn_2yv5 update_anime_pattern
  def update_anime_pattern(*args)
if @ma_char_is_emf_sprite # If an emf sprite
  if !@step_anime && @stop_count > 0 # Reset to stationary
@maemf_frame_index = 0
@pattern = @original_pattern
  else
# Next Pattern
@maemf_frame_index = (@maemf_frame_index + 1) % @maemf_character_pattern.size
@pattern = @maemf_character_pattern[@maemf_frame_index]
  end
else
  maemf_updanim_ptrn_2yv5(*args) # Call original method
end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Character Frames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_init_char_frames
@maemf_frame_index = 0 # Initialize Index
# Save this value for faster reference
@ma_char_is_emf_sprite = ma_char_is_emf_sprite?(character_name)
if @ma_char_is_emf_sprite
  # Get pattern
  @maemf_character_pattern = maemf_get_frames(character_name)
  @maemf_character_pattern.shift # Remove frame number
  @original_pattern = @maemf_character_pattern[0]
else
  @maemf_character_pattern = []
end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Character Frames Proc
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def self.maemf_init_char_frames_proc
Proc.new { |method_name|
  alias_method(:"maemf_#{method_name}_2ev9", method_name) # Alias
  define_method(method_name) do |*args| # Define method
send(:"maemf_#{method_name}_2ev9", *args) # Call original method
maemf_init_char_frames
  end
}
  end
  proc = maemf_init_char_frames_proc
  [:initialize, :set_graphic].each { |name| proc.call(name) }
end

#==============================================================================
# ** Game_Player/Follower/Vehicle/Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This aliases methods in these classes that change @character_name in order
# to call maemf_init_char_frames
#==============================================================================

class Game_Player
  # Refresh
  maemf_init_char_frames_proc.call(:refresh)
end

class Game_Follower
  # Refresh
  maemf_init_char_frames_proc.call(:refresh)
end

class Game_Vehicle
  # Load System Settings
  maemf_init_char_frames_proc.call(:load_system_settings)
end

class Game_Event 
  proc = maemf_init_char_frames_proc
  # Clear Page Settings & Setup Page Settings
  [:clear_page_settings, :setup_page_settings].each { |name| proc.call(name) }
end

#==============================================================================
# ** Sprite_Character
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
# aliased methods - set_character_bitmap; update_src_rect
# new methods - ma_set_emf_character_bitmap; ma_update_emf_src_rect
#==============================================================================

class Sprite_Character
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Character Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_setcharbmp_4rm6 set_character_bitmap
  def set_character_bitmap(*args)
@emf_char = ma_char_is_emf_sprite?(@character_name)
@emf_char ? ma_set_emf_character_bitmap : maemf_setcharbmp_4rm6(*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Transfer Origin Rectangle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_updtsrcrect_2kq5 update_src_rect
  def update_src_rect(*args)
@emf_char ? ma_update_emf_src_rect : maemf_updtsrcrect_2kq5(*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Character Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_set_emf_character_bitmap
self.bitmap = Cache.character(@character_name)
@emf_char_frames = maemf_get_frames(@character_name)
@cw, @ch = maemf_calc_frame_size(@character_name, bitmap, @emf_char_frames)
self.ox = @cw / 2
self.oy = @ch
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Transfer Origin Rectangle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_update_emf_src_rect
if @tile_id == 0
  index = @character.character_index
  pattern = @character.pattern < @emf_char_frames[0] ? @character.pattern : @emf_char_frames[1]
  sx = (index % 4 * @emf_char_frames[0] + pattern) * @cw
  sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  self.src_rect.set(sx, sy, @cw, @ch)
end
  end
end

#==============================================================================
# ** Window_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
# aliased method - draw_character
# new method - ma_draw_emf_character
#==============================================================================

class Window_Base
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Character Graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_drawcharct_3kq6 draw_character
  def draw_character(character_name, *args)
character_name[/\%[\(\[].+?[\)\]]/] ? ma_draw_emf_character(character_name, *args) :
  maemf_drawcharct_3kq6(character_name, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Extra Movement Frames Character Graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_draw_emf_character(character_name, character_index, x, y)
return unless character_name
if !ma_char_is_emf_sprite?(character_name)
  # Draw regular if there is no frame specification in the name
  maemf_drawcharct_3kq6(character_name, *args)
else
  bitmap = Cache.character(character_name)
  frames = maemf_get_frames(character_name)
  cw, ch = maemf_calc_frame_size(character_name, bitmap, frames)
  n = character_index
  src_rect = Rect.new((n%4*frames[0]+frames[1])*cw, (n/4*4)*ch, cw, ch)
  contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
  end
end
Could someone help me?

*
A-pow 2015
Rep:
Level 81
2014 Best RPG Maker User - GraphicsFor frequently finding and reporting spam and spam bots2013 Most Unsung MemberSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.How can I help you? :Da^2 + b^2 = c^2Secret Santa 2012 ParticipantSilver - GIAW 10Silver - GIAW 9Bronze - GIAW HalloweenGold - Game In A Week VII
I'm sorry, I don't understand what you're asking for. Do you want a script just so you don't have to edit the layout of your sprites?
Moving sprites around in a template is like the easiest thing you could possibly do graphics-wise.

***
Rep:
Level 39
RMRK Junior
lol I thought the script wouldn't work for the two row sheets and you were asking for a fix for that...

If you really are asking for something just so you don't have to edit sprite sheets, I doubt anyone will code something like that just so you can be lazy and not have to edit the sheets...
My Website:

:tinysmile:

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Well, it is the type of thing that really is better done by something automated, so here: Sprite Converter

All you have to do is import all of the sprites that you want converted into the Characters folder in Graphics in this project. Then run the project, and it will come up with a message box before exiting. Once it exits, just go into the Converted Characters folder in Graphics and all of your characters should be converted.

If you haven't already done it, then it will rename the file to include the $ and the %(2).

I did it really quick and messy, so don't look at the code if you value your eyes. All credit goes to 66rpg.com, which is where I got the png Saver script. I don't know if it does the conversion well, but I figure this is something you will only need to use once or twice.


Just to be clear, this is meant to be used in the Sprite Converter project only. Do not save the script into your actual project.


EDIT::

Sorry, I didn't realize this post was so old. I guess you've probably already converted all the sprites manually by now. Sorry.
« Last Edit: August 23, 2014, 10:06:41 PM by modern algebra »

***
Rep:
Level 39
RMRK Junior
You actually made a script that re-formats sprite sheets?! That's awesome, and now I must eat my words for saying no one would do it. You are a far more generous person than I am xD

Now that I think about it, it was a little rude to tell him he was lazy, because if he's got every single pokemon in a sheet re-formatting them all would take a lifetime.
My Website:

:tinysmile: