[RMXP] Auto Frame Script Request

Started by Ronivan, August 10, 2013, 02:10:38 pm

Previous topic - Next topic

Ronivan

August 10, 2013, 02:10:38 pm Last Edit: August 10, 2013, 02:29:21 pm by Ronivan
I'm having problem with my game because the Multi Frame Script changes the animation file name, like hero [8]. I've tryed all kinds of Multi frame scripts, all scripts needs a change in the image name to specify the number of frames on it. So I wanted to make a request here for someone to create a very different kind of auto frame script. Maybe it would be possible to create a script where the number of frames of animation would be inserted into it? Like this for sample:

Files inside the "Characters" folder:

name of .png file => number of frames

hero => 8
hero_ACT => 7
hero_HIT => 6
hero_SWD_01 => 6

Note: It's a script for RPG Maker XP.

Thus the file name does not change, and the script will do the organization of animation frames by file names .png written on it. Someone could create something like that?

Zexion

Hmm, that would be a LOT more useful, but I don't know how I would change my script to fit that D:
Why exactly can't you use the tags that most scripts require?

Ronivan

Because I'm using XAS ABS.
XAS needs a command line, like Hero_ACT.  I'm using Ragnarok Online sprites, and they have lots of variations, like the hero_swd_01 has 7 frames, and the hero has 8, if I imput hero [8] and hero [7]_swd_01, XAS will not recognize the hero [7]_swd_01 because the main sprite name is hero [8].
Enemies also have a lot of variations, like poring [6] and poring [3]_hit. I can't change after the command line, like hero_swd_01 [7] because XAS will not recognize the command line specified on the script.
That's my problem.

KK20

Because you don't want the number of frames to be in the name of the file, and because we all know storing integers in a .png is impossible, you would need a Configuration module within the custom-frames script. It would be a generally easy rewrite.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ronivan

Understood, but can anyone do that? As long the image file name does not change, I'll not have problems with XAS.

KK20

Post the custom frames script you are using.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ronivan

August 10, 2013, 03:34:36 pm #6 Last Edit: August 10, 2013, 03:38:55 pm by Ronivan
This one is Cogwheel Multi Frame Script. Its not customized, just the common Cogwheel Mult-Frame. As you can see, its require a [number] tag.



#==============================================================================
# Extra Frames
# por COGHWELL
# http://members.jcom.home.ne.jp/cogwheel/
#==============================================================================
# O script permite que a imagem do character tenha mais que 4 frames.
#
# Para definir a quantidade de frames basta definir o nome adicione [X]
# ao seu nome, onde X é o numero de frames.
#
# Ex.:
# 001-Fighter01[7].png
#
# Isto significa que o 001-Fighter01 terá 7 frames
#==============================================================================

#==============================================================================
# ■ Game_Character
#==============================================================================
class Game_Character
 #--------------------------------------------------------------------------
 def update
   if jumping?
     update_jump
   elsif moving?
     update_move
   else
     update_stop
   end
   if @character_name[/\[(\d+)\]/]
     @anime_count = 20 if @anime_count > 0 and @pattern == @original_pattern
     if @anime_count * ($1.to_i - 1) / 4 > 18 - @move_speed * 3
       if not @step_anime and @stop_count > 0
         @pattern = @original_pattern
       else
         @pattern = @pattern % ($1.to_i - 1) + 1
       end
       @anime_count = 0
     end
   else
     if @anime_count > 18 - @move_speed * 2
       if not @step_anime and @stop_count > 0
         @pattern = @original_pattern
       else
         @pattern = (@pattern + 1) % 4
       end
       @anime_count = 0
     end
   end
   if @wait_count > 0
     @wait_count -= 1
     return
   end
   if @move_route_forcing
     move_type_custom
     return
   end
   if @starting or lock?
     return
   end
   if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
     case @move_type
     when 1
       move_type_random
     when 2
       move_type_toward_player
     when 3
       move_type_custom
     end
   end
 end
end


#================================================= =============================
# ■ Sprite_Character
#================================================= =============================
class Sprite_Character < RPG::Sprite
 #--------------------------------------------------------------------------
 def update
   super
   if @tile_id != @character.tile_id or
      @character_name != @character.character_name or
      @character_hue != @character.character_hue
     @tile_id = @character.tile_id
     @character_name = @character.character_name
     @character_hue = @character.character_hue
     if @tile_id >= 384
       self.bitmap = RPG::Cache.tile($game_map.tileset_name,
       @tile_id, @character.character_hue)
       self.src_rect.set(0, 0, 32, 32)
       self.ox = 16
       self.oy = 32
     else
       self.bitmap = RPG::Cache.character(@character.character_name,
       @character.character_hue)
       if @character.character_name[/\[(\d+)\]/]
         @cw = bitmap.width / $1.to_i
         @ch = bitmap.height / 4
       else
         @cw = bitmap.width / 4
         @ch = bitmap.height / 4
       end
       self.ox = @cw / 2
       self.oy = @ch
     end
   end
   self.visible = (not @character.transparent)
   if @tile_id == 0
     sx = @character.pattern * @cw
     sy = (@character.direction - 2) / 2 * @ch
     self.src_rect.set(sx, sy, @cw, @ch)
   end
   self.x = @character.screen_x
   self.y = @character.screen_y
   self.z = @character.screen_z(@ch)
   self.opacity = @character.opacity
   self.blend_type = @character.blend_type
   self.bush_depth = @character.bush_depth
   if @character.animation_id != 0
     animation = $data_animations[@character.animation_id]
     animation(animation, true)
     @character.animation_id = 0
   end
 end
end

#================================================= =============================
# ■ Window_Base
#================================================= =============================
class Window_Base < Window
 #--------------------------------------------------------------------------
 def draw_actor_graphic(actor, x, y)
   bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
   if actor.character_name[/\[(\d+)\]/]
     cw = bitmap.width / $1.to_i
     ch = bitmap.height / 4
   else
     cw = bitmap.width / 4
     ch = bitmap.height / 4
   end
   src_rect = Rect.new(0, 0, cw, ch)
   self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
 end
end

#================================================= =============================
# ■ Window_SaveFile
#================================================= =============================
class Window_SaveFile < Window_Base
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   self.contents.font.color = normal_color
   name = "File #{@file_index + 1}"
   self.contents.draw_text(4, 0, 600, 32, name)
   @name_width = contents.text_size(name).width
   if @file_exist
     for i in 0...@characters.size
       bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
       if @characters[i][0][/\[(\d+)\]/]
         cw = bitmap.width / $1.to_i
         ch = bitmap.height / 4
       else
       cw = bitmap.width / 4
       ch = bitmap.height / 4
     end
     src_rect = Rect.new(0, 0, cw, ch)
     x = 300 - @characters.size * 32 + i * 64 - cw / 2
     self.contents.blt(x, 68 - ch, bitmap, src_rect)
   end
   hour = @total_sec / 60 / 60
   min = @total_sec / 60 % 60
   sec = @total_sec % 60
   time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 8, 600, 32, time_string, 2)
   self.contents.font.color = normal_color
   time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
   self.contents.draw_text(4, 40, 600, 32, time_string, 2)
   end
 end
end

#================================================= =============================
# ■ Game_Player
#================================================= =============================
class Game_Player < Game_Character
 #--------------------------------------------------------------------------
 def anime_update
   if @character_name[/\[(\d+)\]/]
     @anime_count = 20 if @anime_count > 0 and @pattern == @original_pattern
     if @anime_count * ($1.to_i - 1) / 4 > 18 - @move_speed * 2
       if not @step_anime and @stop_count > 0
         @pattern = @original_pattern
       else
         @pattern = @pattern % ($1.to_i - 1) + 1
       end
       @anime_count = 0
     end
   else
     if @anime_count > 18 - @move_speed * 2
       if not @step_anime and @stop_count > 0
         @pattern = @original_pattern
       else
         @pattern = (@pattern + 1) % 4
       end
       @anime_count = 0
     end
   end
 end
end

KK20

August 10, 2013, 03:56:46 pm #7 Last Edit: August 10, 2013, 04:12:54 pm by KK20
Not tested, but looks logical.

#==============================================================================
# Extra Frames
# por COGHWELL
# Edit by KK20
# http://members.jcom.home.ne.jp/cogwheel/
#==============================================================================
# KK20's Note: The following instructions are no longer relevant to this script.
# The number of frames a character sprite uses is determined by the amount
# configured in the configuration below.
#==============================================================================
# O script permite que a imagem do character tenha mais que 4 frames.
#
# Para definir a quantidade de frames basta definir o nome adicione [X]
# ao seu nome, onde X é o numero de frames.
#
# Ex.:
# 001-Fighter01[7].png
#
# Isto significa que o 001-Fighter01 terá 7 frames
#==============================================================================
module ExtraFramesConfig
 def self.char_frames(name)
   case name
   #--------------------------------------------------------------------------
   # Begin Configuration
   # Format:
   #             when 'filename' then return FRAMES
   #
   # Any names not configured will be assumed to have 4 frames (RMXP default)
   #--------------------------------------------------------------------------
   when 'hero' then return 8
   when 'hero_ACT' then return 7
   when 'hero_HIT' then return 6
   when 'hero_SWD_1' then return 6
   #--------------------------------------------------------------------------
   # End of Configuration
   #--------------------------------------------------------------------------
   else
     return 4
    end
 end
end

#==============================================================================
# ■ Game_Character
#==============================================================================
class Game_Character
 #--------------------------------------------------------------------------
 def update
   if jumping?
     update_jump
   elsif moving?
     update_move
   else
     update_stop
   end
   frames = ExtraFramesConfig.char_frames(@character_name)
   if frames != 4
     @anime_count = 20 if @anime_count > 0 and @pattern == @original_pattern
     if @anime_count * (frames - 1) / 4 > 18 - @move_speed * 3
       if not @step_anime and @stop_count > 0
         @pattern = @original_pattern
       else
         @pattern = @pattern % (frames - 1) + 1
       end
       @anime_count = 0
     end
   else
     if @anime_count > 18 - @move_speed * 2
       if not @step_anime and @stop_count > 0
         @pattern = @original_pattern
       else
         @pattern = (@pattern + 1) % 4
       end
       @anime_count = 0
     end
   end
   if @wait_count > 0
     @wait_count -= 1
     return
   end
   if @move_route_forcing
     move_type_custom
     return
   end
   if @starting or lock?
     return
   end
   if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
     case @move_type
     when 1
       move_type_random
     when 2
       move_type_toward_player
     when 3
       move_type_custom
     end
   end
 end
end


#================================================= =============================
# ■ Sprite_Character
#================================================= =============================
class Sprite_Character < RPG::Sprite
 #--------------------------------------------------------------------------
 def update
   super
   if @tile_id != @character.tile_id or
      @character_name != @character.character_name or
      @character_hue != @character.character_hue
     @tile_id = @character.tile_id
     @character_name = @character.character_name
     @character_hue = @character.character_hue
     if @tile_id >= 384
       self.bitmap = RPG::Cache.tile($game_map.tileset_name,
       @tile_id, @character.character_hue)
       self.src_rect.set(0, 0, 32, 32)
       self.ox = 16
       self.oy = 32
     else
       self.bitmap = RPG::Cache.character(@character.character_name,
       @character.character_hue)
       frames = ExtraFramesConfig.char_frames(@character.character_name)
       if frames != 4
         @cw = bitmap.width / frames
         @ch = bitmap.height / 4
       else
         @cw = bitmap.width / 4
         @ch = bitmap.height / 4
       end
       self.ox = @cw / 2
       self.oy = @ch
     end
   end
   self.visible = (not @character.transparent)
   if @tile_id == 0
     sx = @character.pattern * @cw
     sy = (@character.direction - 2) / 2 * @ch
     self.src_rect.set(sx, sy, @cw, @ch)
   end
   self.x = @character.screen_x
   self.y = @character.screen_y
   self.z = @character.screen_z(@ch)
   self.opacity = @character.opacity
   self.blend_type = @character.blend_type
   self.bush_depth = @character.bush_depth
   if @character.animation_id != 0
     animation = $data_animations[@character.animation_id]
     animation(animation, true)
     @character.animation_id = 0
   end
 end
end

#================================================= =============================
# ■ Window_Base
#================================================= =============================
class Window_Base < Window
 #--------------------------------------------------------------------------
 def draw_actor_graphic(actor, x, y)
   bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
   frames = ExtraFramesConfig.char_frames(actor.character_name)
   if frames != 4
     cw = bitmap.width / frames
     ch = bitmap.height / 4
   else
     cw = bitmap.width / 4
     ch = bitmap.height / 4
   end
   src_rect = Rect.new(0, 0, cw, ch)
   self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
 end
end

#================================================= =============================
# ■ Window_SaveFile
#================================================= =============================
class Window_SaveFile < Window_Base
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   self.contents.font.color = normal_color
   name = "File #{@file_index + 1}"
   self.contents.draw_text(4, 0, 600, 32, name)
   @name_width = contents.text_size(name).width
   if @file_exist
     for i in 0...@characters.size
       bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
       frames = ExtraFramesConfig.char_frames(@characters[i][0])
       if @characters[i][0][/\[(\d+)\]/]
         cw = bitmap.width / frames
         ch = bitmap.height / 4
       else
       cw = bitmap.width / 4
       ch = bitmap.height / 4
     end
     src_rect = Rect.new(0, 0, cw, ch)
     x = 300 - @characters.size * 32 + i * 64 - cw / 2
     self.contents.blt(x, 68 - ch, bitmap, src_rect)
   end
   hour = @total_sec / 60 / 60
   min = @total_sec / 60 % 60
   sec = @total_sec % 60
   time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 8, 600, 32, time_string, 2)
   self.contents.font.color = normal_color
   time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
   self.contents.draw_text(4, 40, 600, 32, time_string, 2)
   end
 end
end

#================================================= =============================
# ■ Game_Player
#================================================= =============================
class Game_Player < Game_Character
 #--------------------------------------------------------------------------
 def anime_update
   frames = ExtraFramesConfig.char_frames(@character_name)
   if frames != 4
     @anime_count = 20 if @anime_count > 0 and @pattern == @original_pattern
     if @anime_count * (frames - 1) / 4 > 18 - @move_speed * 2
       if not @step_anime and @stop_count > 0
         @pattern = @original_pattern
       else
         @pattern = @pattern % ($1.to_i - 1) + 1
       end
       @anime_count = 0
     end
   else
     if @anime_count > 18 - @move_speed * 2
       if not @step_anime and @stop_count > 0
         @pattern = @original_pattern
       else
         @pattern = (@pattern + 1) % 4
       end
       @anime_count = 0
     end
   end
 end
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ronivan

August 10, 2013, 04:02:04 pm #8 Last Edit: August 10, 2013, 04:07:55 pm by Ronivan
Seems nice. But it gave a error at start up.

Error Script COG - Extra Frames, on 243 on line SyntaxError

KK20

Yep, my intuition was right. Forgot to put an 'end' after the 'case' block. Fixed in original post.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ronivan

Ohhhhhhhhhh that's worked just perfect! You can't imagine how long I was searching for this script change.

Just a small question, I may add any lines to that frame configuration right?

when 'hero_ANI' then return 7

Anyway, my deepest thanks for your help.

KK20

Yep, as long as you keep that format and make a new line for each entry, you can have as many as you need. :)

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ronivan