XP 스크립트

특정아이템에 갯수를 제한하는 스크립트입니다.
레어템등에 쓰면 좋겠죠? ㅎ
물론 상점에서도 제한양만큼 밖에 못사고요 ㅎ

#시작~~~~~~~~~
module RX_T_LIM
  # 初期設定
  @rx_t_limit_weapon_num = []
  @rx_t_limit_armor_num = []    #건들지마세요
  @rx_t_limit_item_num = []
 
  /-設定例:
  ここではアイテムID:1・ポーションの最大所持数を24個に
      アイテムID:3・フルポーションの最大所持数を48個に
      それぞれ設定しています。
      お好みにより色々設定して下さい。-/
  # -------------★설정하세요★-------------
  @rx_t_limit_item_num[1] = 24                        # ↓ 아이템 입니다
  @rx_t_limit_item_num[2] = 48        # @rx_t_limit_item_num[id] =  갯수
                                                    #만약 @rx_t_limit_weapon_num[id] = 갯수 면무기
                                                    #@rx_t_limit_armor_num[id] = 갯수 면방어구
                                                    #이런식으로 계속 만드실 수 있어요 ㅎ

 # -------------★설정 끝 ㅅㄱ~★-------------
  def RX_T_LIM.weapon(id, num)
    if @rx_t_limit_weapon_num[id] != nil
      if num > @rx_t_limit_weapon_num[id]
        num = @rx_t_limit_weapon_num[id]
      end
    end
  end
  def RX_T_LIM.armor(id, num)
    if @rx_t_limit_armor_num[id] != nil
      if num > @rx_t_limit_armor_num[id]
        num = @rx_t_limit_armor_num[id]
      end
    end
  end
  def RX_T_LIM.item(id, num)
    if @rx_t_limit_item_num[id] != nil
      if num > @rx_t_limit_item_num[id]
        num = @rx_t_limit_item_num[id]
      end
    end
  end
  def RX_T_LIM.d_weapon(id)
    if @rx_t_limit_weapon_num[id] != nil
      num = @rx_t_limit_weapon_num[id]
    end
  end
  def RX_T_LIM.d_armor(id)
    if @rx_t_limit_armor_num[id] != nil
      num = @rx_t_limit_armor_num[id]
    end
  end
  def RX_T_LIM.d_item(id)
    if @rx_t_limit_item_num[id] != nil
      num = @rx_t_limit_item_num[id]
    end
  end
end

#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
#  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
# ラスのインスタンスは $game_party で参照されます。
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # ● アイテムの所持数取得
  #    item_id : アイテム ID
  #--------------------------------------------------------------------------
  alias rx_rg11_item_number item_number
  def item_number(item_id)
    # ★ ハッシュに個数データがあれば所持数制限があるかチェック
    if @items.include?(item_id)
      rx_num = RX_T_LIM.item(item_id, @items[item_id])
      # 所持制限数を超えていたら制限数まで減らす
      if rx_num != nil
        @items[item_id] = rx_num
      end
    end
    rx_rg11_item_number(item_id)
  end
  #--------------------------------------------------------------------------
  # ● 武器の所持数取得
  #    weapon_id : 武器 ID
  #--------------------------------------------------------------------------
  alias rx_rg11_weapon_number weapon_number
  def weapon_number(weapon_id)
    # ★ ハッシュに個数データがあれば所持数制限があるかチェック
    if @weapons.include?(weapon_id)
      rx_num = RX_T_LIM.weapon(weapon_id, @weapons[weapon_id])
      # 所持制限数を超えていたら制限数まで減らす
      if rx_num != nil
        @weapons[weapon_id] = rx_num
      end
    end
    rx_rg11_weapon_number(weapon_id)
  end
  #--------------------------------------------------------------------------
  # ● 防具の所持数取得
  #    armor_id : 防具 ID
  #--------------------------------------------------------------------------
  alias rx_rg11_armor_number armor_number
  def armor_number(armor_id)
    # ★ ハッシュに個数データがあれば所持数制限があるかチェック
    if @weapons.include?(armor_id)
      rx_num = RX_T_LIM.armor(armor_id, @armors[armor_id])
      # 所持制限数を超えていたら制限数まで減らす
      if rx_num != nil
        @armors[armor_id] = rx_num
      end
    end
    rx_rg11_armor_number(armor_id)
  end
end

#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
#  ショップ画面で、購入できる商品の一覧を表示するウィンドウです。
#==============================================================================

class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #    index : 項目番号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    # アイテムの所持数を取得
    case item
    # -------------★改造ここから★-------------
    when RPG::Item
      # ★ 個数制限があるかチェック
      rx_num = RX_T_LIM.d_item(item.id)
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      # ★ 個数制限があるかチェック
      rx_num = RX_T_LIM.d_weapon(item.id)
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      # ★ 個数制限があるかチェック
      rx_num = RX_T_LIM.d_armor(item.id)
      number = $game_party.armor_number(item.id)
    end
    # ★ 個数制限最終判定
    if rx_num == nil
      rx_num = 99
    end
    # ★ 価格が所持金以下、かつ所持数が 99(若しくは制限個数)でなければ通常文字色に、
    # そうでなければ無効文字色に設定
    if item.price <= $game_party.gold and number < rx_num
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    # -------------★改造ここまで★-------------
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 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, 88, 32, item.price.to_s, 2)
  end
end

#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
#  ショップ画面の処理を行うクラスです。
#==============================================================================

class Scene_Shop
  #--------------------------------------------------------------------------
  # ● フレーム更新 (購入ウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_buy
    # ステータスウィンドウのアイテムを設定
    @status_window.item = @buy_window.item
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # ウィンドウの状態を初期モードへ
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      # ヘルプテキストを消去
      @help_window.set_text("")
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # アイテムを取得
      @item = @buy_window.item
      # アイテムが無効の場合、または価格が所持金より上の場合
      if @item == nil or @item.price > $game_party.gold
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # アイテムの所持数を取得
      case @item
      # -------------★改造ここから★-------------
      when RPG::Item
        # ★ 購入数制限があるかチェック
        rx_num = RX_T_LIM.d_item(@item.id)
        number = $game_party.item_number(@item.id)
      when RPG::Weapon
        # ★ 購入数制限があるかチェック
        rx_num = RX_T_LIM.d_weapon(@item.id)
        number = $game_party.weapon_number(@item.id)
      when RPG::Armor
        # ★ 購入数制限があるかチェック
        rx_num = RX_T_LIM.d_armor(@item.id)
        number = $game_party.armor_number(@item.id)
      end
      # ★ 特に購入数制限がなければ購入数を99に。
      if rx_num == nil
        rx_num = 99
      end
      # ★ すでに 99 個(もしくは制限個数分)所持している場合
      if number == rx_num
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # -------------★改造ここまで★-------------
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      # 最大購入可能個数を計算
      max = @item.price == 0 ? 99 : $game_party.gold / @item.price
      max = [max, rx_num - number].min
      # ウィンドウの状態を個数入力モードへ
      @buy_window.active = false
      @buy_window.visible = false
      @number_window.set(@item, max, @item.price)
      @number_window.active = true
      @number_window.visible = true
      end
  end
end
#------------------끝

사용법

우선 스크립트붙이신후 13행에 가보세요
그러면 설정하는곳이 있을겁니다.
그쪽에서 설정하시면 되고요
 @rx_t_limit_item_num[1] = 24 이렇게 되있는것은 1번아이템에 갯수가 24개로 제한되는거에요
  여기서  가운데 영어를 바꾸면 무기 방어구 설정도 가능합니다.
@rx_t_limit_weapon_num[id] = 숫자  ←특정 무기 갯수 제한
@rx_t_limit_armor_num[id] = 숫자 ← 특정방어구 갯수 제한
입니다.

나머지 아이템갯수는 99개로 제한될거에요 아마도;;;;;
이것도 바꿀수는 있는데 왠만하면 비추;; 아이템 소지수 돌파 쓰는분도 비추입니다;;

출처는 type74 입니다

Who's 백호

?

이상혁입니다.

http://elab.kr

Comment '3'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6202
921 기타 Defining Encounter Areas by RPG Advocate (사용법 첨부) file 백호 2009.02.22 1201
920 전투 DerVVulfman's addons for Mr.Mo's ABS file Alkaid 2010.09.10 1645
919 기타 Difficulty Options by SephirothSpawn 백호 2009.02.22 869
918 기타 Drago - Custom Resolution by LiTTleDRAgo Alkaid 2014.02.13 1114
917 그래픽 Drago - Custom Resolution II 1 Alkaid 2014.09.10 1009
916 기타 Dynamic Stores by Astro_mech@rmxp.net 1 file 백호 2009.02.22 878
915 아이템 Easy Item & Gold Gain by SephirothSpawn (SDK호환) 백호 2009.02.22 881
914 기타 Economy System by Nick@Creation Asylum 1 file 백호 2009.02.22 934
913 맵/타일 Editor Tiles by PK8 (XP/VX/VXA) Alkaid 2012.09.11 1868
912 기타 Encounter Control by SephirothSpawn (SDK호환) 4 file 백호 2009.02.22 1159
911 기타 endroll 주석 번역 6 file insertend 2010.05.15 1638
910 스킬 Equipment Skills 2.0 by SephirothSpawn file 백호 2009.02.22 1007
909 장비 Equipment Upgrade System 1.1 by Charlie Fleed Alkaid 2010.11.18 1928
908 기타 Etude87_Bone_Animation_Character ver.1.2 4 습작 2012.07.06 1255
907 전투 Etude87_Custom_Slip_Damage_XP ver.1.0 5 습작 2012.08.26 1857
906 메뉴 Etude87_Horror_Menu_XP ver.1.1 15 file 습작 2012.08.04 2762
905 메시지 Etude87_Item_Choice_XP ver.1.10 13 file 습작 2013.05.19 2187
904 맵/타일 Etude87_Map_Remember_XP ver.1.2 2 습작 2012.07.17 1614
903 변수/스위치 Etude87_Variables_XP 2 습작 2011.12.26 2105
902 메뉴 Event Spawner 1 file 백호 2009.02.22 980
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