设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1046|回复: 2
打印 上一主题 下一主题

[已经解决] 帮忙看看这个合成脚本如何使用

[复制链接]

Lv2.观梦者

会吐槽的画师

梦石
0
星屑
782
在线时间
3431 小时
注册时间
2011-6-10
帖子
6535
跳转到指定楼层
1
发表于 2013-10-28 08:54:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 铃仙·优昙华院·因幡 于 2013-10-28 10:00 编辑

写是写了使用方法,但是实验了几次完全用不来……帮忙看看是如何 调出窗口,设置素材的

RUBY 代码复制
  1. #******************************************************************************
  2. #
  3. #    * アイテム合成
  4. #
  5. #  --------------------------------------------------------------------------
  6. #    バージョン :  2.0.1
  7. #     対    応  :  RPGツクールVX : RGSS2
  8. #     制 作 者  :  CACAO
  9. #     配 布 元  :  [url]http://cacaosoft.web.fc2.com/[/url]
  10. #  --------------------------------------------------------------------------
  11. #   == 概    要 ==
  12. #
  13. #    : アイテムの合成機能を追加します。
  14. #
  15. #  --------------------------------------------------------------------------
  16. #   == 使用方法 ==
  17. #
  18. #    ★ 合成画面を表示する (簡易)
  19. #     イベントコマンド「ラベル」に <アイテム合成> と記入し、
  20. #     イベントコマンド「ショップの処理」でアイテムを設定する。
  21. #
  22. #    ★ 合成画面を表示する (分割)
  23. #     イベントコマンド「ラベル」に <合成準備> と記入し、
  24. #     イベントコマンド「ショップの処理」で、アイテムを設定し、
  25. #     イベントコマンド「ラベル」に <合成開始> と記入し合成画面を開く。
  26. #     イベントコマンド「ラベル」に <合成中止> と記入すれば、準備が中止される。
  27. #    ※ アイテムの設定は、複数に分けても構わない。
  28. #
  29. #    ★ 合成素材の設定
  30. #     アイテムのメモ欄に @CONFLATE[種類ID:個数] と記入してください。
  31. #      種類 .. I:アイテム, W:武器, A:防具
  32. #      ID .. データベース上でのアイテムの番号
  33. #      個数 .. 左辺のアイテムの必要な数
  34. #     [...] には、, で区切ることで複数の設定ができます。
  35. #     最初の要素に数値のみの設定を行うと、合成に必要な費用を設定できます。
  36. #     費用の設定を省略した場合、価格に CUT_RATE をかけた値が使用されます。
  37. #    例) @CONFLATE[100, I1:3, I13:1, A17:1]
  38. #    ※ @CONFLATE は、複数に分けて設定することも可能です。
  39. #
  40. #
  41. #******************************************************************************
  42.  
  43.  
  44. #==============================================================================
  45. # ◆ 設定項目
  46. #==============================================================================
  47. module CAO
  48. module Conflate
  49.   #--------------------------------------------------------------------------
  50.   # ◇ 値引率
  51.   #--------------------------------------------------------------------------
  52.   CUT_RATE = 0.3
  53.  
  54.   #--------------------------------------------------------------------------
  55.   # ◇ ショップステータスを表示する
  56.   #--------------------------------------------------------------------------
  57.   USE_SHOP_STATUS = true
  58.  
  59.   #--------------------------------------------------------------------------
  60.   # ◇ 背景画像
  61.   #--------------------------------------------------------------------------
  62.   #     ファイル名を設定します。使用しない場合は nil としてください。
  63.   #--------------------------------------------------------------------------
  64.   FILE_SCENEBACK  = nil#"BackConflate"
  65.   FILE_STATUSBACK = "成品"
  66.  
  67.   #--------------------------------------------------------------------------
  68.   # ◇ 用語設定
  69.   #--------------------------------------------------------------------------
  70.   VOCAB = {}    # <= 変更しないでください。
  71.   VOCAB[:gold]     = ""
  72.   VOCAB[:material] = ""
  73.   VOCAB[:have]     = "                                                                件"
  74.   VOCAB[:have_u]   = ""
  75.   VOCAB[:cost]     = ""
  76. end
  77. end
  78.  
  79.  
  80. #/////////////////////////////////////////////////////////////////////////////#
  81. #                                                                             #
  82. #                下記のスクリプトを変更する必要はありません。                 #
  83. #                                                                             #
  84. #/////////////////////////////////////////////////////////////////////////////#
  85.  
  86.  
  87. module CAO::Conflate
  88.   REGEXP_GOLD = /^@CONFLATE\[(\d+)(?:,|\])/i
  89.   REGEXP_KEYS = /^@CONFLATE\[(.+?)\]/i
  90.   REGEXP_GOODS = /([IWA])(\d+):(\d+)/i
  91. end
  92.  
  93. class RPG::BaseItem
  94.   #--------------------------------------------------------------------------
  95.   # ● 合成費用の取得
  96.   #--------------------------------------------------------------------------
  97.   def conflate_price
  98.     return self.note.gsub(" ", "")[CAO::Conflate::REGEXP_GOLD, 1]
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 合成に必要なアイテムの取得
  102.   #--------------------------------------------------------------------------
  103.   def conflate_items
  104.     self.note.gsub(" ", "").scan(CAO::Conflate::REGEXP_KEYS).flatten.
  105.     join(",").scan(CAO::Conflate::REGEXP_GOODS).map do |key|
  106.       case key.first.upcase
  107.       when "I"; [$data_items[key[1].to_i], key[2].to_i]
  108.       when "W"; [$data_weapons[key[1].to_i], key[2].to_i]
  109.       when "A"; [$data_armors[key[1].to_i], key[2].to_i]
  110.       end
  111.     end
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 合成に必要なアイテムが揃っているか判定
  115.   #--------------------------------------------------------------------------
  116.   def enough_material?
  117.     return self.conflate_items.all? {|o,n| n <= $game_party.item_number(o) }
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 合成可能か判定
  121.   #--------------------------------------------------------------------------
  122.   def can_make?
  123.     return false if $game_party.gold < self.conflate_price
  124.     return false unless $game_party.item_number(self) < 99
  125.     return false unless self.enough_material?
  126.     return true
  127.   end
  128. end
  129.  
  130. class RPG::Item
  131.   #--------------------------------------------------------------------------
  132.   # ○ 合成費用の取得
  133.   #--------------------------------------------------------------------------
  134.   def conflate_price
  135.     return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  136.   end
  137. end
  138. class RPG::Weapon
  139.   #--------------------------------------------------------------------------
  140.   # ○ 合成費用の取得
  141.   #--------------------------------------------------------------------------
  142.   def conflate_price
  143.     return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  144.   end
  145. end
  146. class RPG::Armor
  147.   #--------------------------------------------------------------------------
  148.   # ○ 合成費用の取得
  149.   #--------------------------------------------------------------------------
  150.   def conflate_price
  151.     return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  152.   end
  153. end
  154.  
  155. class Game_Temp
  156.   #--------------------------------------------------------------------------
  157.   # ● 公開インスタンス変数
  158.   #--------------------------------------------------------------------------
  159.   attr_accessor :conflate_setting         # 合成 準備中フラグ
  160.   attr_accessor :conflate_immediate       # 合成 即時実行フラグ
  161.   attr_accessor :conflate_goods           # 合成 商品リスト
  162.   #--------------------------------------------------------------------------
  163.   # ● オブジェクト初期化
  164.   #--------------------------------------------------------------------------
  165.   alias _cao_conflate_initialize initialize
  166.   def initialize
  167.     _cao_conflate_initialize
  168.     @conflate_goods = []      # 合成アイテムID
  169.   end
  170. end
  171.  
  172. class Game_Interpreter
  173.   #--------------------------------------------------------------------------
  174.   # ○ ラベル
  175.   #--------------------------------------------------------------------------
  176.   alias _cao_conflate_command_118 command_118
  177.   def command_118
  178.     case @params[0]
  179.     when /^<物品合成>/
  180.       $game_temp.conflate_goods = []
  181.       $game_temp.conflate_setting = true
  182.       $game_temp.conflate_immediate = true
  183.     when /^<合成准备>/
  184.       $game_temp.conflate_goods = []
  185.       $game_temp.conflate_setting = true
  186.       $game_temp.conflate_immediate = false
  187.     when /^<合成开始>/
  188.       $game_temp.next_scene = "conflate"
  189.       $game_temp.conflate_setting = false
  190.       $game_temp.conflate_immediate = false
  191.     when /^<合成完毕>/
  192.       $game_temp.conflate_goods = []
  193.       $game_temp.conflate_setting = false
  194.       $game_temp.conflate_immediate = false
  195.     end
  196.     _cao_conflate_command_118
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ○ ショップの処理
  200.   #--------------------------------------------------------------------------
  201.   alias _cao_conflate_command_302 command_302
  202.   def command_302
  203.     if $game_temp.conflate_setting
  204.       items = [$data_items, $data_weapons, $data_armors]
  205.       while [302, 605].include?(@list[@index].code)
  206.         kind = @list[@index].parameters[0]
  207.         id = @list[@index].parameters[1]
  208.         $game_temp.conflate_goods.push(items[kind][id]) if items[kind][id]
  209.         [url=home.php?mod=space&uid=370741]@Index[/url] += 1
  210.       end
  211.       if $game_temp.conflate_immediate
  212.         $game_temp.next_scene = "conflate"
  213.         $game_temp.conflate_setting = false
  214.         $game_temp.conflate_immediate = false
  215.       end
  216.       return false
  217.     end
  218.     _cao_conflate_command_302
  219.   end
  220. end
  221.  
  222. class Scene_Map
  223.   #--------------------------------------------------------------------------
  224.   # ○ 画面切り替えの実行
  225.   #--------------------------------------------------------------------------
  226.   alias _cao_conflate_update_scene_change update_scene_change
  227.   def update_scene_change
  228.     return if $game_player.moving?    # プレイヤーの移動中?
  229.     if $game_temp.next_scene == "conflate"
  230.       $game_temp.next_scene = nil
  231.       $scene = Scene_Conflate.new
  232.     else
  233.       _cao_conflate_update_scene_change
  234.     end
  235.   end
  236. end
  237.  
  238. class Window_Conflate < Window_Selectable
  239.   #--------------------------------------------------------------------------
  240.   # ● オブジェクト初期化
  241.   #     x : ウィンドウの X 座標
  242.   #     y : ウィンドウの Y 座標
  243.   #--------------------------------------------------------------------------
  244.   def initialize(x, y)
  245.     super(x+0, y+140, 240,360+105)
  246.     self.index = 0
  247.     refresh
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● アイテムの取得
  251.   #--------------------------------------------------------------------------
  252.   def item
  253.     return @data[self.index]
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # ● リフレッシュ
  257.   #--------------------------------------------------------------------------
  258.   def refresh
  259.     @data = []
  260.     $game_temp.conflate_goods.each {|item| @data.push(item) }
  261.     @item_max = @data.size
  262.     create_contents
  263.     for i in 0...@item_max
  264.       draw_item(i)
  265.     end
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # ● 項目の描画
  269.   #     index : 項目番号
  270.   #--------------------------------------------------------------------------
  271.   def draw_item(index)
  272.     item = @data[index]
  273.     rect = item_rect(index)
  274.     self.contents.clear_rect(rect)
  275.     draw_item_name(item, rect.x, rect.y, item.can_make?)
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # ● ヘルプテキスト更新
  279.   #--------------------------------------------------------------------------
  280.   def update_help
  281.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  282.   end
  283. end
  284.  
  285. class Window_ConflateGold < Window_Base
  286.   include CAO::Conflate
  287.   #--------------------------------------------------------------------------
  288.   # ● オブジェクト初期化
  289.   #     x : ウィンドウの X 座標
  290.   #     y : ウィンドウの Y 座標
  291.   #--------------------------------------------------------------------------
  292.   def initialize(x, y)
  293.     super(x+0, y+112+12+105, 304, 56)
  294.     refresh
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● リフレッシュ
  298.   #--------------------------------------------------------------------------
  299.   def refresh
  300.     self.contents.clear
  301.     self.contents.font.color = system_color
  302.     self.contents.draw_text(0, 0, self.contents.width, WLH, VOCAB[:gold])
  303.     draw_currency_value($game_party.gold, 0, 0, self.width - 32)
  304.   end
  305. end
  306.  
  307. class Window_ConflateStatus < Window_Base
  308.   include CAO::Conflate
  309.   #--------------------------------------------------------------------------
  310.   # ● オブジェクト初期化
  311.   #     x : ウィンドウの X 座標
  312.   #     y : ウィンドウの Y 座標
  313.   #--------------------------------------------------------------------------
  314.   def initialize(x, y)
  315.     super(x+0, y+120, 304, 224)
  316.     @item = nil
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # ● リフレッシュ
  320.   #--------------------------------------------------------------------------
  321.   def refresh
  322.     self.contents.clear
  323.     return if @item == nil
  324.     self.contents.font.color = system_color
  325.     self.contents.draw_text(0, 0, self.contents.width, WLH, VOCAB[:material])
  326.     @item.conflate_items.each_with_index do |(item,num), i|
  327.       y = i * WLH + WLH
  328.       draw_item_name(item, 8, y, num <= $game_party.item_number(item))
  329.       self.contents.draw_text(8, y, self.contents.width-52, WLH, num, 2)
  330.       text = sprintf("(%02d)", $game_party.item_number(item))
  331.       self.contents.draw_text(8, y, self.contents.width-8, WLH, text, 2)
  332.     end
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ● アイテムの設定
  336.   #     item : 新しいアイテム
  337.   #--------------------------------------------------------------------------
  338.   def item=(item)
  339.     if @item != item
  340.       @item = item
  341.       refresh
  342.     end
  343.   end
  344. end
  345.  
  346. class Window_ConflateInfo < Window_Base
  347.   include CAO::Conflate
  348.   #--------------------------------------------------------------------------
  349.   # ● オブジェクト初期化
  350.   #     x : ウィンドウの X 座標
  351.   #     y : ウィンドウの Y 座標
  352.   #--------------------------------------------------------------------------
  353.   def initialize(x, y)
  354.     super(x+0, y+112, 304, 80)
  355.     @item = nil
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● リフレッシュ
  359.   #--------------------------------------------------------------------------
  360.   def refresh
  361.     self.contents.clear
  362.     return if @item == nil
  363.     width = self.contents.width
  364.     self.contents.font.color = system_color
  365.     self.contents.draw_text(0, 0, width, WLH, VOCAB[:have])
  366.     self.contents.draw_text(0, 0, width, WLH, VOCAB[:have_u], 2)
  367.     self.contents.draw_text(0, WLH, width, WLH, VOCAB[:cost])
  368.     self.contents.draw_text(0, WLH, width, WLH, Vocab::gold, 2)
  369.     self.contents.font.color = normal_color
  370.     width -= contents.text_size(Vocab::gold).width + 2
  371.     self.contents.draw_text(0, 0, width, WLH, $game_party.item_number(@item), 2)
  372.     self.contents.draw_text(0, WLH, width, WLH, @item.conflate_price, 2)
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ● アイテムの設定
  376.   #     item : 新しいアイテム
  377.   #--------------------------------------------------------------------------
  378.   def item=(item)
  379.     if @item != item
  380.       @item = item
  381.       refresh
  382.     end
  383.   end
  384. end
  385.  
  386. class Scene_Conflate < Scene_Base
  387.   #--------------------------------------------------------------------------
  388.   # ● 開始処理
  389.   #--------------------------------------------------------------------------
  390.   def start
  391.     super
  392.     @viewport = Viewport.new(8,-56, 800, 700)
  393.     @viewport.z = 100
  394.     create_menu_background
  395.     @help_window = Window_Help4.new
  396.     @gold_window = Window_ConflateGold.new(240, 304)
  397.     @gold_window.viewport = @viewport
  398.     @conflate_window = Window_Conflate.new(0, 0)
  399.     @conflate_window.viewport = @viewport
  400.     @conflate_window.help_window = @help_window
  401.     @info_window = Window_ConflateInfo.new(240, 0)
  402.     @info_window.viewport = @viewport
  403.     @material_window = Window_ConflateStatus.new(240, 80)
  404.     @material_window.viewport = @viewport
  405.     create_status_window
  406.  
  407.     if CAO::Conflate::FILE_SCENEBACK || CAO::Conflate::FILE_STATUSBACK
  408.       @help_window.opacity = 0
  409.       @gold_window.opacity = 0
  410.       @conflate_window.opacity = 0
  411.       @info_window.opacity = 0
  412.       @material_window.opacity = 0
  413.       @status_window.opacity = 0
  414.     end
  415.   end
  416.   #--------------------------------------------------------------------------
  417.   # ● 終了処理
  418.   #--------------------------------------------------------------------------
  419.   def terminate
  420.     super
  421.     dispose_menu_background
  422.     @viewport.dispose
  423.     @help_window.dispose
  424.     @gold_window.dispose
  425.     @conflate_window.dispose
  426.     @info_window.dispose
  427.     @material_window.dispose
  428.     @status_window.dispose
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   # ● メニュー画面系の背景作成
  432.   #--------------------------------------------------------------------------
  433.   def create_menu_background
  434.     if CAO::Conflate::FILE_SCENEBACK
  435.       @menuback_sprite = Sprite.new
  436.       @menuback_sprite.bitmap = Cache.system(CAO::Conflate::FILE_SCENEBACK)
  437.     else
  438.       super
  439.     end
  440.     if CAO::Conflate::FILE_STATUSBACK
  441.       @statusback_sprite = Sprite.new(@viewport)
  442.       @statusback_sprite.bitmap = Cache.system(CAO::Conflate::FILE_STATUSBACK)
  443.     end
  444.     update_menu_background
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # ● メニュー画面系の背景解放
  448.   #--------------------------------------------------------------------------
  449.   def dispose_menu_background
  450.     super
  451.     @statusback_sprite.dispose if CAO::Conflate::FILE_STATUSBACK
  452.   end
  453.   #--------------------------------------------------------------------------
  454.   # ● ショップステータスウィンドウの生成
  455.   #--------------------------------------------------------------------------
  456.   def create_status_window
  457.     @status_window = Window_ShopStatus.new(544, 0)
  458.     @status_window.x = 544
  459.     @status_window.y = 120
  460.     @status_window.height = 360+105
  461.     @status_window.viewport = @viewport
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 元の画面へ戻る
  465.   #--------------------------------------------------------------------------
  466.   def return_scene
  467.     $scene = Scene_Map.new
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # ● フレーム更新
  471.   #--------------------------------------------------------------------------
  472.   def update
  473.     super
  474.     update_menu_background
  475.     @viewport.update
  476.     @help_window.update
  477.     @gold_window.update
  478.     @conflate_window.update
  479.     @info_window.update
  480.     @material_window.update
  481.     @status_window.update
  482.  
  483.     @info_window.item = @conflate_window.item
  484.     @material_window.item = @conflate_window.item
  485.     @status_window.item = @conflate_window.item
  486.  
  487.     update_conflate_input
  488. #    update_status_input
  489.  
  490.     if @open_status
  491.       @viewport.ox += 16
  492.       if @viewport.ox > @status_window.width
  493.         @viewport.ox = @status_window.width
  494.         @open_status = false
  495.       end
  496.     elsif @close_status
  497.       @viewport.ox -= 16
  498.       if @viewport.ox < 0
  499.         @viewport.ox = 0
  500.         @close_status = false
  501.       end
  502.     end
  503.   end
  504.   #--------------------------------------------------------------------------
  505.   # ● 合成アイテムの入力更新
  506.   #--------------------------------------------------------------------------
  507.   def update_conflate_input
  508.     if Input.trigger?(Input::B)
  509.       Sound.play_cancel
  510.       return_scene
  511.     elsif Input.trigger?(Input::C)
  512.       if @conflate_window.item.can_make?
  513.         Sound.play_shop
  514.         $game_party.lose_gold(@conflate_window.item.conflate_price)
  515.         for item,n in @conflate_window.item.conflate_items
  516.           $game_party.lose_item(item, n)
  517.         end
  518.         $game_party.gain_item(@conflate_window.item, 1)
  519.         @gold_window.refresh
  520.         @conflate_window.refresh
  521.         @info_window.refresh
  522.         @material_window.refresh
  523.         @status_window.refresh
  524.       else
  525.         Sound.play_buzzer
  526.       end
  527.     end
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # ● ショップステータスの入力更新
  531.   #--------------------------------------------------------------------------
  532. #  def update_status_input
  533. #   return unless CAO::Conflate::USE_SHOP_STATUS
  534.   #  if Input.trigger?(Input::LEFT)
  535.    #   @open_status = false
  536.     #  @close_status = true
  537.     #elsif Input.trigger?(Input::RIGHT)
  538.      # @open_status = true
  539.       #@close_status = false
  540.     #end
  541.   #end
  542. end

点评

↓哪里多了!哪里多了!→_→  发表于 2013-10-28 09:47
用这么多的外来脚本,你不怕游戏崩溃?  发表于 2013-10-28 09:20
长名公主玩家群:372588926 攻略娱乐应有尽有
了解更多新RM游戏,游戏制作请加入RPGmaker支援群:113622890

Lv2.观梦者

永无止境的旅程

梦石
0
星屑
503
在线时间
1552 小时
注册时间
2012-6-19
帖子
1226

开拓者贵宾

2
发表于 2013-10-28 12:31:11 | 只看该作者
应该是 $scene = Scene_Conflate.new

评分

参与人数 1星屑 +80 收起 理由
Luciffer + 80 塞糖

查看全部评分

[url=https://rpg.blue/thread-389697-1-1.html]https://rpg.blue/https://rpg.blue/data/attachment/forum/201602/26/220128cfbxxs47xth4xkz4.jpg[/url]
&lt;font size=&quot;5&quot;&gt;[color=Green][url=https://rpg.blue/forum.php?mod=viewthread&amp;tid=396208&amp;extra=page%3D1][color=DeepSkyBlue]全新配套ACT系统,每周末一大更新,尽请期待。[/color][/url][/color]
回复 支持 反对

使用道具 举报

Lv1.梦旅人

狂気の月兔

梦石
0
星屑
231
在线时间
1245 小时
注册时间
2009-4-7
帖子
879

贵宾

3
发表于 2013-10-28 16:56:49 | 只看该作者
在需要合成的物品道具防具的备注里面写上

  1. @CONFLATE[100, W1:2, I13:1, A17:1]
复制代码
这里面的 100 表示合成费用为 100金币.
W1:2  表示 武器里 ID 为1 的物品在合成的时候需要 2 把. 同理的还有 I 表示物品, A 表示防具

评分

参与人数 1星屑 +100 收起 理由
Luciffer + 100 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-30 00:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表