VX 스크립트

#    Animated Sprites instead of Faces in scenes.
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: February 19, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to draw an actor's sprite in any scene that already
#   draws the actor's face. You can either use it to supplement the face
#   graphic or replace the face graphic altogether. For each scene where you
#   choose to use this feature, you can configure a number of options, such as
#   where the sprite will show up (in relation to the face graphic), whether or
#   not the face will also be drawn, what pose the sprite will start in,
#   whether it will be animated, whether it will change directions (and if so,
#   over what time interval), and if subsequently drawn sprites should be drawn
#   in a different pose.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script in its own slot below Materials and above Main in the
#   Script Editor (F11).
#
#    To add a scene and configure how the sprites will show up in it, read the
#   instructions in the EDITABLE REGION at line 30 very carefully.
#==============================================================================

ASF_CONFIGURATION = {
#\\\\\\\\\\\\\\\\\\\
#  EDITABLE REGION
#````````````````````````````````````````````````````````````````````````````
#  For each scene that you want the faces to be replaced (or supplemented) by
# sprites, set up an entry as follows (values are default), omitting any that
# you want to be default (pay attention to commas and curly brackets):
#
#    Scene_X => {
#      :x_offset => 0,
#      :y_offset => 0,
#      :remove_face => false,
#      :default_start_pose => 0,
#      :alternate_start_pose => false,
#      :change_directions => false,
#      :direction_frames => 120,
#      :animate_sprites => false,
#      :move_speed => 4
#    }
#
#  where:
#    Scene_X ~ the name of the scene. eg Scene_Menu; Scene_Battle; Scene_Name
#    :x_offset ~ an integer, representing how many pixels left or right it
#      should be moved from the center of where the face would be drawn.
#      Positive numbers will be drawn right of that, and negative numbers drawn
#      left of that. If excluded, it defaults to 0.
#    :y_offset ~ an integer, representing how many pixels up or down it should
#      be moved from the bottom of where the face would be drawn. If negative,
#      it will be drawn higher and if positive, it will be drawn lower. If
#      excluded, it defaults to 0.
#    :remove_face ~ a boolean. If true, the face won't be drawn. If false, the
#      face will be drawn along with the sprite. Defaults to false.
#    :default_start_pose ~ an integer, 0-3. This is the starting pose of the
#      first drawn sprite. 0 => Down; 1 => Right; 2 => Up; 3 => Left. If
#      excluded, defaults to 0.
#    :alternate_start_pose ~ a boolean. If true, then each time a new sprite
#      is drawn, its start position will differ. So, if you have three actor
#      sprites are being drawn, and the default start pose is 0 (Down), then
#      the first sprite would start facing down, the second sprite would
#      start facing Right, and the third sprite would start facing Up. If
#      excluded, defaults to false
#    :change_directions ~ a boolean. If true, the sprites would change
#      over the time interval set in :direction_frames. If false, the sprites
#      will only face one direction for the duration of the scene. If excluded,
#      defaults to false
#    :direction_frames ~ an integer. If :change_directions is true, this
#      integer will determine the number of frames before the sprite changes
#      direction. 60 frames = 1 second. If excluded, defaults to 120.
#    :animate_sprites ~ a boolean. If true, the sprites will be shown walking.
#      If false, they will remain stationary. If excluded, defaults to false.
#    :move_speed ~ an integer, 1-6. If :animate_sprites is true, this is
#      the speed that the sprite will be animating. 1 is the slowest and 6 is
#      the fastest. Defaults to 4
#
#    If you get a syntax error when test playing your game, you most likely
#   forgot to put a comma or curly bracket in. If you set up entries for more
#   than one scene, you need to put a comma after each } except for the last
#   entry. For all of the attributes you specify in each scene entry, you need
#   a comma after the value except for the last entry.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  Scene_Menu => {
    :x_offset => -32,
    :y_offset => 0,
    :remove_face => false,
    :default_start_pose => 0,
    :alternate_start_pose => true,
    :animate_sprites => true,
    :move_speed => 1,
    :change_directions => true,
    :direction_frames => 120
  },
  Scene_Status => {                   #혹 스테이터스를 메뉴에서 빼실꺼면 이부분을 빼세요.
    :x_offset => 0,                       #~ 
    :y_offset => -32,                   #~
    :remove_face => true,            #~
    :default_start_pose => 0,      #~
    :animate_sprites => true       #~
  }                                              #여기까지.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#  END EDITABLE REGION
#////////////////////////////////////////////////////////////////////////////
}

#==============================================================================
# ** Bitmap
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new attr_accessor - asf_just_cleared
#    aliased method - clear
#==============================================================================

class Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variable
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :asf_just_cleared
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Clear
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mala_wlksprtmnu_clr_2gc1 clear unless self.method_defined? (:mala_wlksprtmnu_clr_2gc1)
  def clear (*args)
    mala_wlksprtmnu_clr_2gc1 (*args) # Run Original Method
    @asf_just_cleared = true
  end
end

#==============================================================================
# ** Game_Character
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Compatibility patch for Composite Characters
#==============================================================================

class Game_Character
  attr_writer :composite_character if self.method_defined? (:composite_character)
end

#==============================================================================
# ** Sprite_MenuActor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This window displays the walking sprite of an actor.
#==============================================================================

class Sprite_MenuActor < Sprite_Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (actor_id, x, y, dir, config, viewport = nil)
    @frame_count = 0
    @change_direction, @asf_animation = config[:change_directions], config[:animate_sprites]
    @direction_frames = config[:direction_frames].is_a? (Integer) ? config[:direction_frames] : 120
    actor = $game_actors[actor_id]
    character = Game_Character.new
    # Set to composite character if that script exists.
    if character.methods.include? ("composite_character")
      character.composite_character = actor.composite_character
    else
      character.set_graphic (actor.character_name, actor.character_index)
    end
    super (viewport, character)
    self.x, self.y = x, y
    case dir
    when 1 then @character.turn_right
    when 2 then @character.turn_up
    when 3 then @character.turn_left
    end
    # Change Speed and Frequency of the Sprite
    freq = config[:move_speed] ? config[:move_speed] : 4
    move_route = RPG::MoveRoute.new
    move_route.list.unshift (RPG::MoveCommand.new (29, [freq]))
    @character.force_move_route (move_route)
    update_bitmap
    update
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update
    # Turn at user-specified intervals
    if @change_direction
      if @frame_count >= @direction_frames
        @character.turn_right_90
        @frame_count = 0
      end
      @frame_count += 1
    end
    if @asf_animation
      @character.update_move
      @character.update_animation
    end
    update_src_rect
  end
end

#==============================================================================
# ** Window_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - initialize, update, dispose, draw_actor_face
#    new methods - dispose_walking_sprites
#==============================================================================

class Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_asf_init_wlkng_7jk2 initialize
  def initialize (*args)
    @ma_walking_sprites = []
    ma_asf_init_wlkng_7jk2 (*args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Dispose
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malgba_wlksprts_disps_5yu2 dispose
  def dispose (*args)
    @ma_walking_sprites.each { |sprite| sprite.dispose }
    @ma_walking_sprites.clear
    malgba_wlksprts_disps_5yu2 (*args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mrnalb_sprtwlk_updt_7uj2 update
  def update (*args)
    # Dispose all sprites if bitmap recently cleared and new faces not drawn
    if self.contents.asf_just_cleared
      @ma_walking_sprites.each { |sprite| sprite.dispose }
      @ma_walking_sprites.clear
      self.contents.asf_just_cleared = false
    end
    # Check if contents have scrolled
    x_plus, y_plus = 0, 0
    if @asf_scroll_x != self.ox
      @asf_scroll_x = 0 unless @asf_scroll_x
      x_plus += (@asf_scroll_x - self.ox)
      @asf_scroll_x = self.ox
    end
    if @asf_scroll_y != self.oy
      @asf_scroll_y = 0 unless @asf_scroll_y
      y_plus += (@asf_scroll_y - self.oy)
      @asf_scroll_y = self.oy
    end
    @ma_walking_sprites.each { |sprite|
      sprite.update
      # Scroll if contents have scrolled.
      sprite.x += x_plus
      sprite.y += y_plus
      }
    mrnalb_sprtwlk_updt_7uj2 (*args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Actor Face Graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_drwactrface_spritereplce_6uj2 draw_actor_face
  def draw_actor_face(actor, x, y, size = 96, *args)
    # If scene is specified to replace the face graphic
    if ASF_CONFIGURATION.keys.include? ($scene.class)
      # Dispose all sprites if bitmap recently cleared
      if self.contents.asf_just_cleared
        @ma_walking_sprites.each { |sprite| sprite.dispose }
        @ma_walking_sprites.clear
        self.contents.asf_just_cleared = false
      end
      config = ASF_CONFIGURATION[$scene.class]
      malg_drwactrface_spritereplce_6uj2 (actor, x, y, size, *args) unless config[:remove_face]
      # Get offset
      x_off = config[:x_offset] ? config[:x_offset] : 0
      y_off = config[:y_offset] ? config[:y_offset] : 0
      sx = x + (size / 2) + x_off
      sy = y + size + y_off
      pose = config[:default_start_pose] ? config[:default_start_pose] : 0
      dir = config[:alternate_start_pose] ? @ma_walking_sprites.size % 4 : pose
      # Create Sprite
      viewport = Viewport.new (self.x + 16, self.y + 16, contents.width, contents.height)
      viewport.z = self.z + 50
      viewport.z += self.viewport.z if self.viewport
      sprite = Sprite_MenuActor.new (actor.id, sx, sy, dir, config, viewport)
      @ma_walking_sprites.push (sprite)
    else
      # Draw face if scene not affected
      malg_drwactrface_spritereplce_6uj2 (actor, x, y, size, *args)
    end
  end
end
출처:rmrk
Comment '12'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
377 아이템 드롭 아이템 확장 6 신규회원 2012.02.24 2977
376 기타 KGC 리버스 데미지! 28 루시페르 2009.04.13 2979
375 아이템 아이템 무게, 아이템별 소지수 적용 16 file 허걱 2010.11.11 2981
374 파티 5인 파티 프로젝트 V1.1 4 file 지나가는떡꼬치 2012.06.30 2988
373 액터 동료가 따라다니게 하는 스크립트 (Woratana's Caterpillar System) 5 MinaAubert 2012.09.13 3012
372 기타 땅파기 18 file 비극ㆍ 2010.04.19 3013
371 상태/속성 YERD - Custom Status Properties 7 훈덕 2009.11.08 3021
» 기타 메뉴에서 애니매이션 사용! 12 비극ㆍ 2010.04.19 3022
369 기타 카지노 슬롯머신 15 file 아방스가 짱 2010.02.28 3023
368 맵/타일 맵상 캐릭터 그래픽 확대 / 축소 이벤트 스크립트 6 시트르산 2010.09.10 3023
367 장비 아이템 장비시 스킬습득, 'SW_EquipFinisher' by Siot Warrior 19 file 시옷전사 2010.08.31 3029
366 스킬 체스트 팝업 3.0 9 file 파이어 2010.12.05 3037
365 메뉴 윈도우창 크기 조절 스크립트 0.3 5 아방스 2008.01.30 3038
364 이동 및 탈것 Wachunga님의 XP용 MapLink VX용으로 개조 6 file 허걱 2009.02.13 3039
363 장비 장비에 레벨제한 스크립트!! 21 ijsh515 2010.09.19 3040
362 기타 화면 확대 스크립트 12 file 에돌이 2011.07.22 3061
361 기타 Base Project 15 아방스 2009.02.05 3063
360 타이틀/게임오버 메인 화면을 건너뛰고 시작하는 스크립트 14 아방스 2008.02.01 3064
359 전투 Actor Battler Graphics 13 아방스 2008.03.07 3065
358 장비 남성 / 여성전용 장비 스크립트 (수정 v1.1) 16 Evangelista 2009.11.15 3070
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ... 32 Next
/ 32