XP 스크립트



출처 : http://f44.aaa.livedoor.jp/~ytomy/tkool/rpgtech/frame.html



┌───── 여기 밑부터 ───┐

#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆2ペイン式セーブ - KGC_2PaneSave◆
#_/----------------------------------------------------------------------------
#_/  2ペイン式のセーブ画面を作成します。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ カスタマイズ項目 ★
#==============================================================================

module KGC
  # ◆ページ数
  #  1 ページにつきセーブファイル 4 個。
  #  多すぎるとセーブ/ロード画面の表示が遅くなります。
  #  ※必ず 1 以上を指定してください。
  TPS_PAGE_NUMBER = 4
  # ◆ファイル番号書式
  #  【{i}..ファイル番号】
  TPS_FILE_INDEX_FORMAT = "FILE {i}"

  # ◆メンバーリストの列数(1~4)
  #  5 以上にすると表示が被ります。
  TPS_MEMBER_COLS = 3
  # ◆控えメンバーも描画
  #  ≪多人数パーティ≫導入時のみ有効。
  TPS_DRAW_ALL_MEMBER = true
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["2PaneSave"] = true

#==============================================================================
# ■ Window_SaveFile
#==============================================================================

class Window_SaveFile < Window_Base
  attr_accessor :destination
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #    file_index : セーブファイルのインデックス
  #    filename  : ファイル名
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(file_index * 160, 64, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    @file_index = file_index
    @filename = "Save#{@file_index + 1}.rxdata"
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "r")
      @time_stamp = file.mtime
      @frame_count = Marshal.load(file)
      unless @frame_count.is_a?(Integer)
        @frame_count = Marshal.load(file)
      end
      9.times { |i|  # 不要な箇所を読み飛ばす
        Marshal.load(file)
      }
      @total_sec = @frame_count / Graphics.frame_rate
      file.close
    end
    refresh
    @destination = self.x
    @selected = false
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    # MapInfo.rxdata をロード
    mapinfo = load_data("Data/MapInfos.rxdata")
    self.contents.clear
    # ファイル番号を描画
    self.contents.font.color = system_color
    name = KGC::TPS_FILE_INDEX_FORMAT.dup
    name.gsub!(/{i}/) { "#{@file_index + 1}" }
    self.contents.draw_text(4, 0, 120, 32, name)
    @name_width = contents.text_size(name).width
    # セーブファイルが存在する場合
    if @file_exist
      # プレイ時間を描画
      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, 32, 120, 32, time_string)
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    # ウィンドウ移動
    if self.x != @destination
      if (self.x - @destination).abs < 12
        self.x = @destination
      else
        dist = (@destination - self.x) / 8
        if dist < 0
          dist = [dist, -12].min
        else
          dist = [dist, 12].max
        end
        self.x += dist
      end
    end
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_SaveFileInfo
#------------------------------------------------------------------------------
#  ファイルの情報を表示するウィンドウです。
#==============================================================================

class Window_SaveFileInfo < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 160, 640, 320)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 20
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #    file_index : セーブファイルのインデックス
  #--------------------------------------------------------------------------
  def refresh(file_index)
    if @file_index == file_index
      return
    end
    self.contents.clear
    @file_index = file_index
    filename = "Save#{file_index + 1}.rxdata"
    if FileTest.exist?(filename)
      self.contents.font.color = normal_color
      self.contents.font.name = Font.default_name
      self.contents.font.size = 20
      self.contents.font.bold = Font.default_bold
      draw_file_info(filename)
    else
      self.contents.font.color = disabled_color
      self.contents.font.name = "Times New Roman"
      self.contents.font.size = 32
      self.contents.font.bold = true
      self.contents.draw_text(0, 112, 640, 64, "- NO DATA -", 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● ファイル情報描画
  #    filename : 対象ファイル名
  #--------------------------------------------------------------------------
  def draw_file_info(filename)
    file = File.open(filename, "r")
    time_stamp = file.mtime
    frame_count = Marshal.load(file)
    unless frame_count.is_a?(Integer)
      frame_count = Marshal.load(file)
    end
    game_system = Marshal.load(file)
    game_switches = Marshal.load(file)
    game_variables = Marshal.load(file)
    game_self_switches = Marshal.load(file)
    game_screen = Marshal.load(file)
    game_actors = Marshal.load(file)
    game_party = Marshal.load(file)
    game_troop = Marshal.load(file)
    game_map = Marshal.load(file)
    total_sec = frame_count / Graphics.frame_rate
    file.close
    # キャラクターを描画
    actors = game_party.actors
    if $imported["LargeParty"] && !KGC::TPS_DRAW_ALL_MEMBER
      actors = game_party.battle_actors
    end
    actors.each_with_index { |actor, i|
      x = i / 5 * (608 / KGC::TPS_MEMBER_COLS)
      y = i % 5 * 48
      out = dead = false
      if $imported["LargeParty"] && !game_party.battle_actors.include?(actor)
        out = true
      elsif actor.dead?
        dead = true
      end
      image = RPG::Cache.character(actor.character_name, actor.character_hue)
      rect = Rect.new(0, 0, image.width >> 2, image.height >> 2)
      self.contents.blt(x, y, image, rect, out ? 128 : 255)
      self.contents.font.color = dead ? knockout_color : normal_color
      self.contents.draw_text(x + 40, y, 108, 24, actor.name)
      self.contents.font.color = system_color
      self.contents.draw_text(x + 40, y + 24, 32, 24, "Lv")
      self.contents.font.color = normal_color
      self.contents.draw_text(x + 72, y + 24, 64, 24, actor.level.to_s)
    }
    # プレイ時間を描画
    hour = total_sec / 3600
    min = total_sec / 60 % 60
    sec = total_sec % 60
    time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
    self.contents.font.color = system_color
    self.contents.draw_text(480, 240, 48, 24, "TIME")
    self.contents.font.color = normal_color
    self.contents.draw_text(528, 240, 80, 24, time_string, 2)
    # タイムスタンプを描画
    time_string = time_stamp.strftime("%Y/%m/%d %H:%M")
    self.contents.draw_text(448, 264, 160, 24, time_string, 2)
    # セーブ場所・任務を描画
    if $imported["PlaceMission"]
      mapinfo = load_data("Data/MapInfos.rxdata")
      place = ""
      # マップ名が無い場合
      if game_system.place == nil || game_system.place == ""
        # マップ名を取得
        place = mapinfo[game_map.map_id].name
      else
        place = game_system.place
      end
      self.contents.font.color = system_color
      cx = self.contents.text_size("セーブ場所").width
      self.contents.draw_text(4, 240, cx, 24, "セーブ場所")
      self.contents.font.color = normal_color
      self.contents.draw_text(8 + cx, 240, 596 - cx, 24, place)
      self.contents.font.color = system_color
      cx = self.contents.text_size("任務").width
      self.contents.draw_text(4, 264, cx, 24, "任務")
      self.contents.font.color = normal_color
      self.contents.draw_text(8 + cx, 264, 596 - cx, 24, game_system.mission)
    end
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Title
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_KGC_2PaneSave update
  def update
    # コンティニュー判定
    unless @continue_checked
      found = false
      (KGC::TPS_PAGE_NUMBER * 4).times { |i|
        if FileTest.exist?("Save#{i+1}.rxdata")
          found = true
          break
        end
      }
      # セーブファイルが見付かった場合
      if found
        # カーソルをコンティニューに合わせる
        @command_window.index = 1
      end
      @continue_checked = true
    end

    update_KGC_2PaneSave
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_File
#==============================================================================

class Scene_File
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  def main
    @file_number = KGC::TPS_PAGE_NUMBER * 4
    create_sprites
    # 最後に操作したファイルを選択
    @file_index = $game_temp.last_file_index
    @savefile_windows[@file_index].selected = true
    @index_x = @file_index % 4
    @top_position = 0
    (@file_index / 4).times { |i|
      @top_position -= 160 * 4
    }
    @scroll = 0
    # ウィンドウ移動
    move_window(true)
    @info_window.refresh(@file_index)
    # トランジション実行
    Graphics.transition
    # メインループ
    loop {
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    }
    # トランジション準備
    Graphics.freeze
    dispose_sprites
  end
  #--------------------------------------------------------------------------
  # ● スプライト生成
  #--------------------------------------------------------------------------
  def create_sprites
    # ヘルプウィンドウ作成
    @help_window = Window_Help.new
    @help_window.set_text(@help_text)
    # セーブファイルウィンドウ作成
    @savefile_windows = []
    @file_number.times { |i|
      @savefile_windows << Window_SaveFile.new(i, make_filename(i))
    }
    # 情報ウィンドウ作成
    @info_window = Window_SaveFileInfo.new
    # ナビゲートウィンドウ作成
    if KGC::TPS_PAGE_NUMBER > 1
      @navi_window = []
      @navi_sprite = []
      2.times { |i|
        @navi_window[i] = Window_Base.new(0, 140, 80, 36)
        @navi_window[i].back_opacity = 160
        @navi_window[i].z = 1000
        @navi_sprite[i] = Sprite.new
        @navi_sprite[i].bitmap = Bitmap.new(64, 24)
        @navi_sprite[i].bitmap.font.size = 20
        @navi_sprite[i].y = 144
        @navi_sprite[i].z = 1001
      }
      @navi_sprite[0].bitmap.draw_text(0, 0, 64, 24, "← Prev", 1)
      @navi_sprite[0].x = 8
      @navi_sprite[1].bitmap.draw_text(0, 0, 64, 24, "Next →", 1)
      @navi_window[1].x = 560
      @navi_sprite[1].x = 568
    end
    # ウィンドウ半透明化
    window_alpha if $imported["MenuAlter"] && KGC::MA_MENU_TRANSPARENT
  end
  #--------------------------------------------------------------------------
  # ● スプライト破棄
  #--------------------------------------------------------------------------
  def dispose_sprites
    # ナビゲートウィンドウ破棄
    if KGC::TPS_PAGE_NUMBER > 1
      2.times { |i|
        @navi_window[i].dispose
        @navi_sprite[i].bitmap.dispose
        @navi_sprite[i].bitmap = nil
        @navi_sprite[i].dispose
        @navi_window[i] = @navi_sprite[i] = nil
      }
    end
    # ウィンドウ破棄
    @help_window.dispose
    @help_window = nil
    @savefile_windows.each_index { |i|
      @savefile_windows[i].dispose
      @savefile_windows[i] = nil
    }
    @info_window.dispose
    @info_window = nil
    # スプライトセット破棄
    if @spriteset != nil
      @spriteset.dispose
      @spriteset = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    # ウィンドウを更新
    @help_window.update
    @savefile_windows.each { |w|
      w.update
    }
    # C ボタン
    if Input.trigger?(Input::C)
      on_decision(make_filename(@file_index))
      $game_temp.last_file_index = @file_index
      return
    # B ボタン
    elsif Input.trigger?(Input::B)
      on_cancel
      return
    # →
    elsif Input.repeat?(Input::RIGHT)
      # →の押下状態がリピートでない場合か、
      # またはカーソル位置がファイル個数より前の場合
      if Input.trigger?(Input::RIGHT) || @file_index < @file_number - 1
        # カーソル SE を演奏
        $game_system.se_play($data_system.cursor_se)
        # カーソルを右に移動
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % @file_number
        @savefile_windows[@file_index].selected = true
        @index_x += 1
        self.move_window
        return
      end
    # ←
    elsif Input.repeat?(Input::LEFT)
      # ←の押下状態がリピートでない場合か、
      # またはカーソル位置が 0 より後ろの場合
      if Input.trigger?(Input::LEFT) || @file_index > 0
        # カーソル SE を演奏
        $game_system.se_play($data_system.cursor_se)
        # カーソルを左に移動
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + @file_number - 1) % @file_number
        @savefile_windows[@file_index].selected = true
        @index_x -= 1
        self.move_window
        return
      end
    # ↓またはR
    elsif Input.repeat?(Input::DOWN) || Input.repeat?(Input::R)
      # ↓,R の押下状態がリピートでない場合
      if Input.trigger?(Input::DOWN) || Input.trigger?(Input::R)
        # カーソル SE を演奏
        $game_system.se_play($data_system.cursor_se)
        # カーソルを右に移動
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 4) % @file_number
        @savefile_windows[@file_index].selected = true
        @scroll = 1
        self.move_window
        return
      end
    # ↑またはL
    elsif Input.repeat?(Input::UP) || Input.repeat?(Input::L)
      # ↑,L の押下状態がリピートでない場合
      if Input.trigger?(Input::UP) || Input.trigger?(Input::L)
        # カーソル SE を演奏
        $game_system.se_play($data_system.cursor_se)
        # カーソルを左に移動
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + @file_number - 4) % @file_number
        @savefile_windows[@file_index].selected = true
        @scroll = -1
        self.move_window
        return
      end
    end
    @info_window.refresh(@file_index)
  end
  #--------------------------------------------------------------------------
  # ● セーブウィンドウの移動
  #    force : 強制移動
  #--------------------------------------------------------------------------
  def move_window(force = false)
    if !force
      # 普通にカーソル移動した場合
      if @scroll == 0 && @index_x >= 0 && @index_x <= 3
        return
      end
      if @index_x == 4 || @scroll == 1  # 右にスクロール
        if @file_index <= 3  # 左端に移動
          @top_position = 0
        else  # ページ移動
          @top_position -= 160 * 4
        end
        @index_x = 0 if @scroll == 0
      elsif @index_x == -1 || @scroll == -1  # 左にスクロール
        if @file_index >= @file_number - 4  # 右端に移動
          @top_position = (@file_number - 4) * -160
        else  # 通常移動
          @top_position += 160 * 4
        end
        @index_x = 3 if @scroll == 0
      end
      @scroll = 0
      @file_number.times { |i|
        @savefile_windows[i].destination = @top_position + 160 * i
      }
    else
      @file_number.times { |i|
        @savefile_windows[i].x = @savefile_windows[i].destination =
          @top_position + 160 * i
      }
    end
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ半透明化
  #--------------------------------------------------------------------------
  def window_alpha
    # [Scene_Save]で再定義
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Save
#==============================================================================

class Scene_Save < Scene_File
  #--------------------------------------------------------------------------
  # ● ウィンドウ半透明化
  #--------------------------------------------------------------------------
  def window_alpha
    # スプライトセット作成
    @spriteset = Spriteset_Map.new
    # 各ウィンドウを半透明化
    @help_window.back_opacity = 160
    @savefile_windows.each { |w|
      w.back_opacity = 160
    }
    @info_window.back_opacity = 160
  end
  #--------------------------------------------------------------------------
  # ● セーブデータの書き込み
  #    file : 書き込み用ファイルオブジェクト (オープン済み)
  #--------------------------------------------------------------------------
  def write_save_data(file)
    # セーブファイル描画用のキャラクターデータを作成
    characters = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.battler_name, actor.battler_hue])
    end
    # セーブファイル描画用のキャラクターデータを書き込む
    Marshal.dump(characters, file)
    # プレイ時間計測用のフレームカウントを書き込む
    Marshal.dump(Graphics.frame_count, file)
    # セーブ回数を 1 増やす
    $game_system.save_count += 1
    # マジックナンバーを保存する
    # (エディタで保存するたびにランダムな値に書き換えられる)
    $game_system.magic_number = $data_system.magic_number
    # 各種ゲームオブジェクトを書き込む
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, file)
    Marshal.dump($game_actors, file)
    Marshal.dump($game_party, file)
    Marshal.dump($game_troop, file)
    Marshal.dump($game_map, file)
    Marshal.dump($game_player, file)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Load
#==============================================================================

class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    # テンポラリオブジェクトを再作成
    $game_temp = Game_Temp.new
    # タイムスタンプが最新のファイルを選択
    $game_temp.last_file_index = 0
    latest_time = Time.at(0)
    (KGC::TPS_PAGE_NUMBER * 4).times { |i|
      filename = make_filename(i)
      if FileTest.exist?(filename)
        file = File.open(filename, "r")
        if file.mtime > latest_time
          latest_time = file.mtime
          $game_temp.last_file_index = i
        end
        file.close
      end
    }
    super("どのファイルをロードしますか?")
  end
end


└─────여기까지 ┘


이거 쓰면 이렇게 되나요?

Who's 백호

?

이상혁입니다.

http://elab.kr

Atachment
첨부 '1'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6202
1021 키입력 한글입력스크립트 16 file 아방스 2007.11.09 11828
1020 온라인 채팅 가능 온라인 스크립트 배포 107 file 아방스 2009.01.03 10685
1019 온라인 RPG 만들기 xp 온라인 스크립트 33 아방스 2007.11.09 9601
1018 맵/타일 [유니크급] RPG XP 게임을 3D화로 보자! Neo Mode7 script / 52 file 쉴더 2009.02.28 9447
1017 온라인 온라인 스크립트 Unis Net RMXP 공식 배포! 25 file 뮤바보 2011.12.25 9403
1016 온라인 광넷[ 광땡 온라인 + 넷플레이 ] 62 - 하늘 - 2009.08.02 9003
1015 전투 [액알]neo_a-rpg_module_1[1][1].2 스크립트 83 file 은빛바람 2009.10.03 8307
1014 이름입력 대화창에 얼굴, 이름 띄우기 37 킬라롯 2008.11.09 7497
1013 온라인 넷플레이1.7.0+abs5.5+한챗 49 쀍뛝쒧 2009.01.24 7289
1012 메뉴 메이플스토리처럼 메뉴를^^ 57 file 딸기님 2010.07.13 7145
1011 메시지 대화창에 얼굴 그래픽 띠우기 73 아방스 2007.11.09 7119
1010 스킬 ABP액알 v1.2 스킬추가, 버그수정판 36 file 백호 2009.02.22 6920
1009 전투 [신기술 체험] 강회된 횡스크롤 액알 13 file 백호 2009.02.22 6841
1008 메뉴 온라인메뉴처럼!! 메이플 메뉴처럼!! 변신~스크립트 33 WMN 2008.03.17 6824
1007 그래픽 화면을 부드럽게 해주는스크립트[ 아주 유용] 56 file - 하늘 - 2009.08.05 6566
1006 온라인 Mr.Metring NPE 1.0 [RPG XP 온라인 스크립트] 35 아방스 2009.01.07 6535
1005 이름입력 케릭터 위에 또는 NPC 위에 이름 뛰우기 [헬악이님 제공] 49 file 아방스 2007.11.09 6414
1004 액터 시트르산의 XP용 감정 말풍선 표시 스크립트 37 file 시트르산 2011.01.25 6114
1003 HUD 주인공,NPC이름 머리 나타내기 49 file 송긔 2010.11.28 6067
1002 전투 액알 스크립트 24 백호 2009.02.22 6017
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52