메뉴

스테이터스 화면 from Harts Horn

by 백호 posted Feb 22, 2009
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
아래의 스크립트를 에러없이 사용하려면 게이지 그림파일이 필요합니다.  그림파일은 http://hartshorn-id.hp.infoseek.co.jp/material/status.html 에서 찾아 보세요(파일명은 bar.png).


#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。再定義
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 次のレベルまでの EXP の割合取得
  #--------------------------------------------------------------------------
  def exp_rate
    return @exp_list[@level+1] > 0 ? (@exp - @exp_list[@level]) * 100 / (@exp_list[@level+1] - @exp_list[@level]) : 100
  end
end

#==============================================================================
# ■ Harts_Window_StatusTitle
#------------------------------------------------------------------------------
#  アイテム画面で、タイトルを表示するウィンドウ。
#==============================================================================

class Harts_Window_StatusTitle < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, "ステータス", 1)
  end
end

#==============================================================================
# ■ Harts_Window_StatusName
#------------------------------------------------------------------------------
#  ステータス画面で表示する、名前ウィンドウです。
#==============================================================================

class Harts_Window_StatusName < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #    actor : アクター
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_name(@actor, 4, 0)
  end
end

#==============================================================================
# ■ Window_Status
#------------------------------------------------------------------------------
#  ステータス画面で表示する、ステータスウィンドウです。
#==============================================================================

class Harts_Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #    actor : アクター
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 640, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # バトラーグラフィックロード
    bitmap = RPG::Cache.battler(@actor.battler_name, @actor.battler_hue)
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(16, 0, bitmap, src_rect)
    # バーグラフィックロード
    bar = Bitmap.new("./Graphics/Pictures/bar.png")
    draw_actor_class(@actor, 4 + 144, 0)
    draw_actor_level(@actor, 4 + 144, 32)
    draw_actor_state(@actor, 4 + 144, 64)
   
    hpbar = @actor.hp * 100 / @actor.maxhp
    spbar = @actor.sp * 100 / @actor.maxsp
    self.contents.blt(390, 107, bar, Rect.new(0, 0, 102, 6))
    self.contents.blt(390, 139, bar, Rect.new(0, 0, 102, 6))
    if hpbar < 25
      self.contents.blt(391, 108, bar, Rect.new(0, 20, hpbar, 4))
    elsif hpbar < 50
      self.contents.blt(391, 108, bar, Rect.new(0, 16, hpbar, 4))
    else
      self.contents.blt(391, 108, bar, Rect.new(0, 12, hpbar, 4))
    end
    if spbar < 25
      self.contents.blt(391, 140, bar, Rect.new(0, 20, spbar, 4))
    elsif spbar < 50
      self.contents.blt(391, 140, bar, Rect.new(0, 16, spbar, 4))
    else
      self.contents.blt(391, 140, bar, Rect.new(0, 12, spbar, 4))
    end
    draw_actor_hp(@actor, 320, 80, 172)
    draw_actor_sp(@actor, 320, 112, 172)
   
    strbar = @actor.str * 100 / 999
    dexbar = @actor.dex * 100 / 999
    agibar = @actor.agi * 100 / 999
    intbar = @actor.int * 100 / 999
    self.contents.blt(480, 176, bar, Rect.new(0, 0, 102, 6))
    self.contents.blt(480, 208, bar, Rect.new(0, 0, 102, 6))
    self.contents.blt(480, 240, bar, Rect.new(0, 0, 102, 6))
    self.contents.blt(480, 272, bar, Rect.new(0, 0, 102, 6))
    self.contents.blt(481, 177, bar, Rect.new(0, 24, strbar, 4))
    self.contents.blt(481, 209, bar, Rect.new(0, 24, dexbar, 4))
    self.contents.blt(481, 241, bar, Rect.new(0, 24, agibar, 4))
    self.contents.blt(481, 273, bar, Rect.new(0, 24, intbar, 4))
    draw_actor_parameter(@actor, 320, 288, 0)
    draw_actor_parameter(@actor, 320, 320, 1)
    draw_actor_parameter(@actor, 320, 352, 2)
    draw_actor_parameter(@actor, 320, 160, 3)
    draw_actor_parameter(@actor, 320, 192, 4)
    draw_actor_parameter(@actor, 320, 224, 5)
    draw_actor_parameter(@actor, 320, 256, 6)
   
    self.contents.blt(320, 59, bar, Rect.new(0, 6, 202, 6))
    self.contents.blt(321, 60, bar, Rect.new(0, 24, @actor.exp_rate * 2, 4))
    self.contents.font.color = system_color
    self.contents.draw_text(320, 0, 80, 32, "EXP")
    self.contents.draw_text(320, 32, 80, 32, "NEXT")
    self.contents.font.color = normal_color
    self.contents.draw_text(320 + 80, 0, 84, 32, @actor.exp_s, 2)
    self.contents.draw_text(320 + 80, 32, 84, 32, @actor.next_rest_exp_s, 2)
   
    self.contents.font.color = system_color
    self.contents.draw_text(4, 192, 96, 32, "装備")
    draw_item_name($data_weapons[@actor.weapon_id], 16, 224)
    draw_item_name($data_armors[@actor.armor1_id], 16, 256)
    draw_item_name($data_armors[@actor.armor2_id], 16, 288)
    draw_item_name($data_armors[@actor.armor3_id], 16, 320)
    draw_item_name($data_armors[@actor.armor4_id], 16, 352)
  end
end

#==============================================================================
# ■ Harts_Scene_Status
#------------------------------------------------------------------------------
#  ステータス画面の処理を行うクラスです。再定義
#==============================================================================

class Scene_Status
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #    actor_index : アクターインデックス
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  def main
    # アクターを取得
    @actor = $game_party.actors[@actor_index]
    # タイトルウィンドウを作成
    @title_window = Harts_Window_StatusTitle.new
    # 名前ウィンドウを作成
    @name_window = Harts_Window_StatusName.new(@actor)
    @name_window.x = 160
    # ステータスウィンドウを作成
    @status_window = Harts_Window_Status.new(@actor)
    @status_window.y = 64
    # トランジション実行
    Graphics.transition
    # メインループ
    loop do
      # ゲーム画面を更新
      Graphics.update
      # 入力情報を更新
      Input.update
      # フレーム更新
      update
      # 画面が切り替わったらループを中断
      if $scene != self
        break
      end
    end
    # トランジション準備
    Graphics.freeze
    # ウィンドウを解放
    @title_window.dispose
    @name_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # メニュー画面に切り替え
      $scene = Scene_Menu.new(3)
      return
    end
    # R ボタンが押された場合
    if Input.trigger?(Input::R)
      # カーソル SE を演奏
      $game_system.se_play($data_system.cursor_se)
      # 次のアクターへ
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # 別のステータス画面に切り替え
      $scene = Scene_Status.new(@actor_index)
      return
    end
    # L ボタンが押された場合
    if Input.trigger?(Input::L)
      # カーソル SE を演奏
      $game_system.se_play($data_system.cursor_se)
      # 前のアクターへ
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # 別のステータス画面に切り替え
      $scene = Scene_Status.new(@actor_index)
      return
    end
  end
end