XP 스크립트

제가 쓰려고 간단히 만들어 본 겁니다.

단순히 아이템을 선택해서 아이템의 ID를 변수에 대입하는 기능입니다.
대입된 변수를 통해 여러가지 이벤트를 만들 수 있겠죠 ...

# ★ 아이템 선택 시스템 ★ 2009.1.29
# 제작자 : lepin@naver.com

# 호출 스크립트 : $scene = Scene_Item_Select.new

# 아이템일 경우 : 변수 값 = 아이템의 ID
# 무기일 경우 : 변수 값 = 무기의 ID + 1000
# 방어구일 경우 : 변수 값 = 방어구의 ID + 2000
# 선택하지 않을 경우 : 변수 값 = 0

# 커스터마이즈
module LEPIN
  # 아이템의 ID를 취득하는 변수의 ID
  ITEM_VARIABLE = 9
  # 선택할 수 있는 아이템에 넣는 속성의 이름 (따움표를 지우지 말것)
  ITEM_ELEMENT = "item_select"
  # 선택된 아이템을 소비한다 (true, false)
  ITEM_LOSE = false
end
# 커스터마이즈 끝

#==============================================================================
# ■ Window_Item_Select
#------------------------------------------------------------------------------
#   아이템 선택용 윈도우
#==============================================================================

class Window_Item_Select < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 오브젝트 초기화
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # ● 아이템의 취득
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 리프레쉬
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # 아이템을 추가
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        if $data_items[i].element_set.include?($data_system.elements.index(LEPIN::ITEM_ELEMENT))
          @data.push($data_items[i])
        end
      end
    end
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0
        if $data_weapons[i].element_set.include?($data_system.elements.index(LEPIN::ITEM_ELEMENT))
          @data.push($data_weapons[i])
        end
      end
    end
    for i in 1...$data_armors.size
      if $game_party.armor_number(i) > 0
        if $data_armors[i].guard_element_set.include?($data_system.elements.index(LEPIN::ITEM_ELEMENT))
          @data.push($data_armors[i])
        end
      end
    end
    # 항목수가 0 이 아니면 비트 맵을 작성해, 전항목을 묘화
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
   #--------------------------------------------------------------------------
  # ● 항목의 묘화
  #     index : 항목 번호
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    self.contents.font.color = normal_color
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # ● 헬프 텍스트 갱신
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#==============================================================================
# ■ Scene_Item_Select
#------------------------------------------------------------------------------
#  아이템 아이템 화면의 처리를 실시하는 클래스입니다.
#==============================================================================

class Scene_Item_Select
  #--------------------------------------------------------------------------
  # ● 메인 처리
  #--------------------------------------------------------------------------
  def main
    # 헬프 윈도우, 아이템 윈도우를 작성
    @help_window = Window_Help.new
    @item_window = Window_Item_Select.new
    # 헬프 윈도우를 관련지어
    @item_window.help_window = @help_window
    # 커맨드 윈도우를 작성 (불가시·비액티브하게 설정)
    s1 = "선택한다"
    s2 = "그만둔다"
    @command_window = Window_Command.new(192, [s1, s2])   
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 240 - @command_window.height / 2
    @command_window.visible = false
    @command_window.active = false
    # 트란지션 실행
    Graphics.transition
    # 메인 루프
    loop do
      # 게임 화면을 갱신
      Graphics.update
      # 입력 정보를 갱신
      Input.update
      # 프레임 갱신
      update
      # 화면이 바뀌면 루프를 중단
      if $scene != self
        break
      end
    end
    # 트란지션 준비
    Graphics.freeze
    # 윈도우를 해방
    @help_window.dispose
    @item_window.dispose
    @command_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신
  #--------------------------------------------------------------------------
  def update
    # 윈도우를 갱신
    @help_window.update
    @item_window.update
    @command_window.update
    # 아이템 윈도우가 액티브의 경우: update_item 를 부른다
    if @item_window.active
      update_item
      return
    end
    # 커맨드 윈도우가 액티브의 경우: update_command 를 부른다
    if @command_window.active
      update_command
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신 (아이템 윈도우가 액티브의 경우)
  #--------------------------------------------------------------------------
  def update_item
    # B 버튼이 밀렸을 경우
    if Input.trigger?(Input::B)
      # 캔슬 SE 를 연주
      $game_system.se_play($data_system.cancel_se)
      # 변수 값 = 0
      $game_variables[LEPIN::ITEM_VARIABLE] = 0
      # 메뉴 화면으로 전환해
      $scene = Scene_Map.new     
      return
    end
    # C 버튼이 밀렸을 경우
    if Input.trigger?(Input::C)
      # 아이템 윈도우로 현재 선택되고 있는 데이터를 취득
      @item = @item_window.item
      # 아이템이 없는 경우
      unless @item.is_a?(RPG::Item) or @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
        # 버저 SE 를 연주
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 결정 SE 를 연주
      $game_system.se_play($data_system.decision_se)
      # 커맨드 윈도우를 액티브화
      @item_window.active = false
      @command_window.index = 0
      @command_window.visible = true
      @command_window.active = true
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신 (커맨드 윈도우)
  #--------------------------------------------------------------------------
  def update_command
    # 커멘드 윈도우를 갱신
    @command_window.update
    # B 버튼이 밀렸을 경우
    if Input.trigger?(Input::B)
      # 캔슬 SE 를 연주
      $game_system.se_play($data_system.cancel_se)
      # 커맨드 윈도우를 액티브화
      @item_window.active = true
      @command_window.visible = false
      @command_window.active = false
      return
    end
    # C 버튼이 밀렸을 경우
    if Input.trigger?(Input::C)
      # 커멘드 윈도우의 커서 위치에서 분기
      case @command_window.index
      when 0  # 선택한다
        # 결정 SE 를 연주
        $game_system.se_play($data_system.decision_se)
        # 아이템/무기/방어구 별로 분류
        case @item
        when RPG::Item
          value = 0
          if LEPIN::ITEM_LOSE == true
          $game_party.lose_item(@item.id, 1)
          end
        when RPG::Weapon         
          value = 1000
          if LEPIN::ITEM_LOSE == true
          $game_party.lose_weapon(@item.id, 1)
          end
        when RPG::Armor
          value = 2000
          if LEPIN::ITEM_LOSE == true
          $game_party.lose_armor(@item.id, 1)
          end
        end
        # 변수를 취득
        $game_variables[LEPIN::ITEM_VARIABLE] = @item.id + value
        # 맵 화면으로 전환
        $scene = Scene_Map.new
      when 1  # 그만둔다
        # 결정 SE 를 연주
        $game_system.se_play($data_system.decision_se)
        # 아이템 윈도우를 액티브화
        @item_window.active = true
        @command_window.visible = false
        @command_window.active = false
      end
      return
    end
    if Input.trigger?(Input::UP) or Input.trigger?(Input::L)
      @command_window.index = 0
    end
    if Input.trigger?(Input::DOWN) or Input.trigger?(Input::R)
      @command_window.index = 1
    end
  end
end


 

Comment '5'
  • ?
    백년술사 2009.01.29 15:59
    어떻게 하는거죠?
    근데 제가 방금 보고 온 아이템 선택하기 같은데...<제목만>
    게임 공작소 치거면 출처를..
  • ?
    백년술사 2009.01.29 16:02
    그리고 이거 어떻게 사용?
  • ?
    레핀 2009.01.29 18:13

    게임공작소에 올린 사람이랑 동일인물이고요 ;
    수정했으니 다시 받아주세요 .....
    이벤트 커맨드 -> 스크립에 $scene = Scene_Item_Select.new 라고 입력해주시면 됩니다.

     
  • ?
    RMdude 2009.02.13 12:05
    이거 오류뜨는 데요
    74 행에 Undefined method 'size' for nil:NilClass 라고
  • ?
    내로미 2010.05.19 21:56

    그런건 어떤 스크립트와 충돌이 일어나서 생긴 문제인데요.

    그건 스크립트의 위치를 바꾸면 될것같습니다.


List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6173
1021 메시지 Taylor's Simple Message System 2000 Alkaid 2020.07.05 243
1020 제작도구 [XP/VX/VXA] Doodad's Editor by newold Alkaid 2020.07.12 387
1019 이름입력 한글조합입력기(영어가능) file 조규진1 2019.11.10 503
1018 전투 전투중에 장비들 교체하기 file 레이스89 2017.08.19 596
1017 기타 [All RGSS] FileTest (Unicode) file Cheapmunk 2014.12.29 612
1016 맵/타일 맵연결 스크립트 (데모첨부) file 게임애호가 2018.06.15 690
1015 기타 에어리어 설정 by RPG Advocate 백호 2009.02.22 709
1014 기타 Boat Script 백호 2009.02.21 729
1013 기타 Localization by ForeverZer0, KK20 습작 2013.04.26 738
1012 기타 Materia System file 백호 2009.02.21 749
1011 기타 Real-Time Day Night 3 백호 2009.02.22 751
1010 스킬 SG_Escape Only Skills by sandgolem (SDK호환) 백호 2009.02.22 752
1009 기타 killer님 요청하신 스크립트 두번째입니다. 나뚜루 2009.02.21 759
1008 기타 Letter by Letter Message Window by slipknot@rmxp.org (SDK호환) 1 file 백호 2009.02.22 760
1007 기타 Advanced Gold display by Dubealex 1 백호 2009.02.22 761
1006 스킬 Skill Requirements by SephirothSpawn (SDK호환) file 백호 2009.02.22 763
1005 기타 Sphere Grid System file 백호 2009.02.21 765
1004 기타 AMS-Advanced Message Script Edited by Dubleax 3 file 백호 2009.02.21 765
1003 스킬 SG_Skill Break by sandgolem (SDK호환) 백호 2009.02.22 772
1002 기타 Activation_system file 백호 2009.02.22 775
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