查看: 1913|回复: 2

[已经解决] 问下在游戏里怎么调用这个脚本?

[复制链接]
梦石
0
星屑
163
在线时间
445 小时
注册时间
2013-7-18
回帖
90
发表于 2013-9-22 07:54:36 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 lottesong 于 2013-9-22 19:39 编辑

答案见1L   >ω<

----------------------------

日文苦手   谢谢

比如想调出来一个物品 注释栏含有<gift>的所有道具窗口  
用如下的脚本
$game_message.item_choice_category = "gift"

为什么不好使啊 啥反应也木有? 其他  用:weapon  用:item也都一样不好使……

orz 都需要什么条件
  里面的PLUS_ID是做什么用的 必须要修改吗才能显示?

原地址
http://cacaosoft.web.fc2.com/tkool/script/rgss3/itemchoice.html

[pre lang="ruby" line="1"]
#******************************************************************************
#
#    * アイテム選択の処理
#
#  --------------------------------------------------------------------------
#    バージョン :  1.2.0
#    対      応 :  RPGツクールVX Ace : RGSS3
#    制  作  者 :  CACAO
#    配  布  元 :  http://cacaosoft.web.fc2.com/
#  --------------------------------------------------------------------------
#   == 概    要 ==
#
#   : キーアイテム以外のものも選べるようにします。
#   : ヘルプウィンドウを表示する機能を追加します。
#
#  --------------------------------------------------------------------------
#   == 注意事項 ==
#
#    ※ 変数には、IDではなくアイテムのデータが代入されます。
#    ※ 選択しなかった場合は 0 が代入されます。
#
#  --------------------------------------------------------------------------
#   == 使用方法 ==
#
#    ★ 選択アイテムの設定する
#     $game_message.item_choice_category にキーワードを代入してください。
#     :all      .. すべての所持品
#     :all_item .. すべてのアイテム
#     :item     .. キーアイテム以外のアイテム
#     :weapon   .. すべての武器
#     :armor    .. すべての防具
#     :equip    .. 武器と防具
#     :sell     .. キーアイテム以外で価格が0でないもの
#     "keyword" .. メモ欄に <keyword> と書かれているもの
#
#    ★ ショップアイテムから選択する
#     $game_message.item_choice_from_goods = true
#     このスクリプトを実行後、ショップの処理でアイテムを設定してください。
#
#    ★ 所持数を非表示にする
#     $game_message.item_choice_hide_number = true
#
#    ★ キャンセルを無効にする
#     $game_message.item_choice_cancel_disabled = true
#
#    ★ 未所持アイテムも表示する
#     $game_message.item_choice_show_nothing = true
#
#    ※ 上記4つの設定は、アイテム選択の処理後に初期化されます。
#
#    ★ アイテム選択ウィンドウの行数を変更する
#     $game_message.item_choice_line = 行数
#
#    ★ ヘルプウィンドウの行数を変更する
#     $game_message.item_choice_help_line = 行数
#     ※ 0 のときは、ヘルプウィンドウが非表示になります。
#
#    ★ カテゴリのアイテム所持数を取得する
#     $game_party.item_count(category)
#     category は、$game_message.item_choice_category と同じものです。
#
#
#******************************************************************************


#==============================================================================
# ◆ 設定項目
#==============================================================================
module CAO
module ItemChoice
  
  #--------------------------------------------------------------------------
  # ◇ 種類によるIDの増加値
  #--------------------------------------------------------------------------
  PLUS_ID = 0
  #--------------------------------------------------------------------------
  # ◇ 行数の設定 (初期値)
  #--------------------------------------------------------------------------
  ITEM_LINE = 4       # アイテム選択ウィンドウ
  HELP_LINE = 0       # ヘルプウィンドウ ( 0 のとき非表示)
  #--------------------------------------------------------------------------
  # ◇ 表示位置の設定
  #--------------------------------------------------------------------------
  POS_TOP = false

end # module ItemChoice
end # module CAO


#/////////////////////////////////////////////////////////////////////////////#
#                                                                             #
#                下記のスクリプトを変更する必要はありません。                 #
#                                                                             #
#/////////////////////////////////////////////////////////////////////////////#


class CAO::Dummy_ItemList < Window_ItemList
  #--------------------------------------------------------------------------
  # ● メソッド定義の取り消し
  #--------------------------------------------------------------------------
  # undef_method *self.superclass.instance_methods(false)
  # def include?(item); super; end
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @category = :none
  end
  #--------------------------------------------------------------------------
  # ● カテゴリのアイテム所持数を取得
  #--------------------------------------------------------------------------
  def count(category)
    @category = category
    return $game_party.all_items.count {|item| include?(item) }
  end
end

class Game_Party
  #--------------------------------------------------------------------------
  # ● カテゴリのアイテム所持数を取得
  #--------------------------------------------------------------------------
  def item_count(category)
    return CAO::Dummy_ItemList.new.count(category)
  end
end

class Game_Message
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :item_choice_category         # アイテム選択 カテゴリ
  attr_accessor :item_choice_from_goods       # アイテム選択 商品から選択
  attr_accessor :item_choice_goods            # アイテム選択 選択アイテム
  attr_accessor :item_choice_hide_number      # アイテム選択 所持数非表示
  attr_accessor :item_choice_cancel_disabled  # アイテム選択 キャンセル無効
  attr_accessor :item_choice_show_nothing     # アイテム選択 未所持でも表示
  attr_accessor :item_choice_line             # アイテム選択 行数
  attr_accessor :item_choice_help_line        # アイテム選択 ヘルプの行数
  #--------------------------------------------------------------------------
  # ●
  #--------------------------------------------------------------------------
  def clear_item_choice
    @item_choice_category = :key_item
    @item_choice_from_goods = false
    @item_choice_goods = []
    @item_choice_hide_number = false
    @item_choice_cancel_disabled = false
    @item_choice_show_nothing = false
  end
end

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ ショップの処理
  #--------------------------------------------------------------------------
  alias _cao_itemchoice_command_302 command_302
  def command_302
    if $game_message.item_choice_from_goods
      goods = [@params]
      while next_event_code == 605
        @Index += 1
        goods.push(@list[@index].parameters)
      end
      $game_message.item_choice_goods = []
      goods.each do |param|
        case param[0]
        when 0; item = $data_items[param[1]]
        when 1; item = $data_weapons[param[1]]
        when 2; item = $data_armors[param[1]]
        end
        $game_message.item_choice_goods.push(item) if item
      end
    else
      _cao_itemchoice_command_302
    end
  end
end
  
class Window_ItemList
  #--------------------------------------------------------------------------
  # ○ アイテムをリストに含めるかどうか
  #--------------------------------------------------------------------------
  alias _cao_itemchoice_include? include?
  def include?(item)
    case @category
    when String
      return item && item.note.include?("<#{@category}>")
    when :all
      return item != nil
    when :all_item
      return item.kind_of?(RPG::Item)
    when :equip
      return item.kind_of?(RPG::Weapon) || item.kind_of?(RPG::Armor)
    when :sell
      return false if item == nil
      return false if item.respond_to?(:key_item?) && item.key_item?
      return false if item.price == 0
      return true
    else
      return _cao_itemchoice_include?(item)
    end
  end
end

class Window_KeyItem
  #--------------------------------------------------------------------------
  # ◎ オブジェクト解放
  #--------------------------------------------------------------------------
  def dispose
    @help_window.dispose if @help_window
    super
  end
  #--------------------------------------------------------------------------
  # ◎ ウィンドウを開く
  #--------------------------------------------------------------------------
  def open
    @help_window.open if @help_window
    super
  end
  #--------------------------------------------------------------------------
  # ◎ ウィンドウを閉じる
  #--------------------------------------------------------------------------
  def close
    @help_window.close if @help_window
    super
  end
  #--------------------------------------------------------------------------
  # ◎ アイテムリストの作成
  #--------------------------------------------------------------------------
  alias _cao_itemchoice_make_item_list make_item_list unless $!
  def make_item_list
    if $game_message.item_choice_show_nothing
      if $game_message.item_choice_from_goods
        @data = $game_message.item_choice_goods
      else
        items = $data_items + $data_weapons + $data_armors
        @data = items.select {|item| include?(item) }
      end
    else
      if $game_message.item_choice_from_goods
        @data = $game_party.all_items & $game_message.item_choice_goods
      else
        # super
        _cao_itemchoice_make_item_list
      end
    end
    create_help_window
  end
  #--------------------------------------------------------------------------
  # ●
  #--------------------------------------------------------------------------
  def create_help_window
    $game_message.item_choice_line ||= CAO::ItemChoice::ITEM_LINE
    $game_message.item_choice_help_line ||= CAO::ItemChoice::HELP_LINE
    @help_window.dispose if @help_window
    if $game_message.item_choice_help_line != 0
      self.help_window = Window_Help.new($game_message.item_choice_help_line)
      @help_window.openness = 0
      @help_window.open
    end
    self.height = fitting_height($game_message.item_choice_line)
    update_placement
  end
  #--------------------------------------------------------------------------
  # ○ アイテムを許可状態で表示するかどうか
  #--------------------------------------------------------------------------
  def enable?(item)
    return true
  end
  #--------------------------------------------------------------------------
  # ●
  #--------------------------------------------------------------------------
  def variable=(value)
    $game_variables[$game_message.item_choice_variable_id] = value
  end
  #--------------------------------------------------------------------------
  # ○ 決定時の処理
  #--------------------------------------------------------------------------
  def on_ok
    if self.item == nil
      self.variable = 0
    elsif CAO::ItemChoice::PLUS_ID > 0
      self.variable = self.item.id
      case self.item
      when RPG::Weapon
        self.variable += CAO::ItemChoice::PLUS_ID
      when RPG::Armor
        self.variable += CAO::ItemChoice::PLUS_ID * 2
      end
    else
      self.variable = self.item
    end
    close
  end
  #--------------------------------------------------------------------------
  # ○ キャンセル処理の有効状態を取得
  #--------------------------------------------------------------------------
  def cancel_enabled?
    return false
  end
  #--------------------------------------------------------------------------
  # ◎ フレーム更新
  #--------------------------------------------------------------------------
  alias _cao_itemchoice_update update unless $!
  def update
    # super
    _cao_itemchoice_update
    @help_window.update if @help_window
    if open? && self.active && Input.trigger?(:B)
      Input.update
      if $game_message.item_choice_cancel_disabled
        Sound.play_buzzer
      else
        Sound.play_cancel
        deactivate
        on_cancel
      end
    end
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ位置の更新
  #--------------------------------------------------------------------------
  def update_placement
    if $game_message.item_choice_help_line == 0
      help_height = 0
    else
      help_height = @help_window.height
    end
    if CAO::ItemChoice::POS_TOP
      if @message_window.close?
        self.y = help_height
      elsif self.height + help_height < @message_window.y
        self.y = help_height
      else
        self.y = @message_window.y + @message_window.height + help_height
      end
    else
      mbh = Graphics.height - (@message_window.y + @message_window.height)
      if @message_window.close?
        self.y = Graphics.height - self.height
      elsif self.height + help_height < mbh
        self.y = Graphics.height - self.height
      else
        self.y = @message_window.y - self.height
      end
    end
    if $game_message.item_choice_help_line != 0
      @help_window.y = self.y - @help_window.height
    end
  end
  #--------------------------------------------------------------------------
  # ○ アイテムの個数を描画
  #--------------------------------------------------------------------------
  alias _cao_itemchoice_draw_item_number draw_item_number
  def draw_item_number(rect, item)
    return if $game_message.item_choice_hide_number
    _cao_itemchoice_draw_item_number(rect, item)
  end
end

class Window_Message
  #--------------------------------------------------------------------------
  # ○ アイテムの選択処理
  #--------------------------------------------------------------------------
  def input_item
    @item_window.start
    @item_window.category = ($game_message.item_choice_category || :key_item)
    Fiber.yield while @item_window.active
    $game_message.clear_item_choice
  end
end
[/pre]

点评

沙发帖子已編輯 請查看  发表于 2013-9-22 10:29

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

发表于 2013-9-22 08:34:56 | 显示全部楼层
本帖最后由 76213585 于 2013-9-21 19:28 编辑

发腳本時用代碼功能匡起來
這樣很難看懂......

============================

試了一下  終於懂了........

首先要先設好這个
  1. $game_message.item_choice_category = x
复制代码
你應該會
然後什么反應都沒有對吧......
原因是使用後必需要再用事件選項(第一頁)中的物品選則才會有反應
他是把可以選則的物品給括展了  並不會把窗口給喚出
所以要使用的事件應該是:
===============================
腳本: $game_message.item_choice_category = "gift"
物品選則處理: [X:變量的名字]
===============================
也就是會把選則的處量ID套入X變量

点评

虽然不知道怎么个原理,瞎定义了个变量,再用使用了物品选择那项,窗口就真的出来了…厉害!!感谢>_<!!!  发表于 2013-9-22 19:36
哦哦已经改了~~发帖的时候没找到发ruby码那项,ಠ_ಠ;【眼神不太好  发表于 2013-9-22 08:56

回复

使用道具 举报

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

发表于 2013-9-22 09:02:20 | 显示全部楼层
TO版主:連帖請原諒.....
其實我沒看到他在指令有定義
  1. :key_item
复制代码
的樣子......

是因為默認的道具選取(事件頁內有)
就是只有貴重物品的
直接使用事件內的選項就行了

点评

谢谢麻烦你了,熬夜所以写错了了,就是用它脚本自定义的那些项都试了…也调不出来窗口来着  发表于 2013-9-22 09:31

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部