Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 03/19/2011
- #==============================================================================#
- # IEO::REGEX::KAPPA
- #==============================================================================#
- module IEO
- module REGEXP
- module KAPPA
- module EVENT
- PAT_RATE = /<(?:PATTERN_RATE|PATTERN RATE|PATTERNRATE):[ ]*(\d+)>/i
- ORIG_PAT = /<(?:DEFAULT_FRAME|DEFAULT FRAME|DEFAULTFRAME):[ ]*(\d+)>/i
- ICON_INDEX = /<(?:ICON_INDEX|ICON INDEX|ICONINDEX):[ ]*(.*)>/i
- PATTERN = /<PATTERN:[ ]*(.*)>/i
- ZOOM = /<ZOOM[ ](.*):[ ]*(.*)>/i
- end
- module GENERAL
- FRAMES = /\#\[(\d+)\]/i
- end
- end
- end
- end
- #==============================================================================#
- # Game_Character
- #==============================================================================#
- class Game_Character
- #--------------------------------------------------------------------------#
- # * Public Instance Variables
- #--------------------------------------------------------------------------#
- attr_accessor :cwidth_div
- attr_accessor :cheight_div
- attr_accessor :icon_index
- # // ------------------------------------------------------ // #
- attr_accessor :zoom_x
- attr_accessor :zoom_y
- #--------------------------------------------------------------------------#
- # * alias method :initialize
- #--------------------------------------------------------------------------#
- alias ieo0aa_initialize initialize unless $@
- def initialize
- @defpattern = [0, 1, 2, 1]
- @patternbld = :bf # :bf (Back-Forth), :ln(Linear), :cus(Custom)
- @patpos = 0 # The internal pattern counter
- @cwidth_div = 3
- @cheight_div= 4
- @icon_index = 0
- @patternrate= 2 # Default pattern rate is 2
- # // ------------------------------------------------------ // #
- @zoom_x = 1.00
- @zoom_y = 1.00
- ieo0aa_initialize
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :update_animation
- #--------------------------------------------------------------------------#
- def update_animation
- speed = @move_speed + (dash? ? 1 : 0)
- if @anime_count > 18 - speed * @patternrate
- if not @step_anime and @stop_count > 0
- @pattern = @original_pattern
- else
- @patpos = (@patpos + 1) % @defpattern.size
- @pattern = @defpattern[@patpos]
- end
- @anime_count = 0
- end
- end
- #--------------------------------------------------------------------------#
- # * alias method :set_graphic
- #--------------------------------------------------------------------------#
- alias ieo0aa_set_graphic set_graphic unless $@
- def set_graphic(character_name, character_index)
- ieo0aa_set_graphic(character_name, character_index)
- setup_defpattern
- end
- #--------------------------------------------------------------------------#
- # * new method :ieo0aa_eventcache
- #--------------------------------------------------------------------------#
- def setup_defpattern
- framecount = 3
- # // ------------------------------------------------------------------ // #
- @character_name.scan(IEO::REGEXP::KAPPA::GENERAL::FRAMES).each { |fr| framecount = fr.to_s.to_i}
- @cwidth_div = framecount
- # // ------------------------------------------------------------------ // #
- case @patternbld
- when :bf # // Back-Forth
- @defpattern = []
- framecount.times { |i| @defpattern << i unless i == framecount }
- af = @defpattern.clone; af.reverse!; af.pop; af.shift; @defpattern += af
- when :ln # // Linear
- @defpattern = []
- framecount.times { |i| @defpattern << i unless i == framecount}
- end
- # // ------------------------------------------------------------------ // #
- end
- end
- #==============================================================================#
- # Game_Event
- #==============================================================================#
- class Game_Event < Game_Character
- #--------------------------------------------------------------------------#
- # * alias method :setup
- #--------------------------------------------------------------------------#
- alias ieo0aa_setup setup unless $@
- def setup(new_page)
- ieo0aa_setup(new_page)
- ieo0aa_eventcache
- end
- #--------------------------------------------------------------------------#
- # * new method :ieo0aa_eventcache
- #--------------------------------------------------------------------------#
- def ieo0aa_eventcache
- return if @list == nil
- for i in 0..@list.size
- next if @list[i] == nil
- if @list[i].code == 108
- @list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
- case line
- when IEO::REGEXP::KAPPA::EVENT::ICON_INDEX
- val = $1
- case val
- when /(?:ITE|I):[ ](\d+)/i
- @icon_index = $data_items[$1.to_i]
- when /(?:WEP|W):[ ](\d+)/i
- @icon_index = $data_weapons[$1.to_i]
- when /(?:ARM|A):[ ](\d+)/i
- @icon_index = $data_armors[$1.to_i]
- when /(?:SKI|S):[ ](\d+)/i
- @icon_index = $data_skills[$1.to_i]
- when /(?:STE|T):[ ](\d+)/i
- @icon_index = $data_states[$1.to_i]
- else
- @icon_index = val.to_i
- end
- when IEO::REGEXP::KAPPA::EVENT::PATTERN
- val = $1
- case val.upcase
- when "LINEAR", "LN"
- @patternbld = :ln
- when "BACKFORTH", "BF"
- @patternbld = :bf
- else
- @patternbld = :cus ; @defpattern = []
- val.scan(/\d+/).each { |n| @defpattern << n.abs }
- end
- when IEO::REGEXP::KAPPA::EVENT::ORIG_PAT
- @original_pattern = $1.to_i
- when IEO::REGEXP::KAPPA::EVENT::PAT_RATE
- @patternrate = $1.to_i
- when IEO::REGEXP::KAPPA::EVENT::ZOOM
- val = $2.to_f * 1.00
- case $1.upcase
- when "X"
- @zoom_x = val
- when "Y"
- @zoom_y = val
- end
- end
- }
- end
- end
- setup_defpattern
- end
- end
- #==============================================================================#
- # Sprite_Character
- #==============================================================================#
- class Sprite_Character < Sprite_Base
- #--------------------------------------------------------------------------#
- # * new method :iconset_bitmap
- #--------------------------------------------------------------------------#
- def iconset_bitmap(iconindex)
- return Cache.system("Iconset")
- end
- #--------------------------------------------------------------------------#
- # * alias method :update
- #--------------------------------------------------------------------------#
- alias ieo0aa_update update unless $@
- def update
- ieo0aa_update
- update_zoom
- end
- #--------------------------------------------------------------------------#
- # * new method :update_zoom
- #--------------------------------------------------------------------------#
- def update_zoom
- unless @character.nil?
- self.zoom_x = @character.zoom_x
- self.zoom_y = @character.zoom_y
- end
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :update_src_rect
- #--------------------------------------------------------------------------#
- def update_src_rect
- if @tile_id == 0 && @icon_index == 0
- index = @character.character_index
- pattern = @character.pattern < @character.cwidth_div ? @character.pattern : 1
- sx = (index % 4 * @character.cwidth_div + pattern) * @cw
- sy = (index / 4 * @character.cheight_div + (@character.direction - 2) / 2) * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
- end
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :update_bitmap
- #--------------------------------------------------------------------------#
- def update_bitmap
- if (@tile_id != @character.tile_id ||
- @icon_index != @character.icon_index ||
- @character_name != @character.character_name ||
- @character_index != @character.character_index)
- # //
- @character.setup_defpattern
- @tile_id = @character.tile_id
- @icon_index = @character.icon_index
- @character_name = @character.character_name
- @character_index = @character.character_index
- if @tile_id > 0
- sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
- sy = @tile_id % 256 / 8 % 16 * 32;
- self.bitmap = tileset_bitmap(@tile_id)
- self.src_rect.set(sx, sy, 32, 32)
- self.ox = 16
- self.oy = 32
- elsif @icon_index > 0
- irect = Rect.new(@icon_index % 16 * 24, @icon_index / 16 * 24, 24, 24)
- self.bitmap = iconset_bitmap(@icon_index)
- self.src_rect.set(irect.x, irect.y, irect.width, irect.height)
- self.ox = irect.width / 2
- self.oy = irect.height + (32 - irect.height) / 2
- else
- self.bitmap = Cache.character(@character_name)
- sign = @character_name[/^[\!\$]./]
- if sign != nil and sign.include?('$')
- @cw = bitmap.width / @character.cwidth_div
- @ch = bitmap.height / @character.cheight_div
- else
- @cw = bitmap.width / (@character.cwidth_div*4)
- @ch = bitmap.height / (@character.cheight_div*2)
- end
- self.ox = @cw / 2
- self.oy = @ch
- end
- end
- end
- end
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment