查看: 1403|回复: 2

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

[复制链接]

梦石
0
星屑
782
在线时间
3431 小时
注册时间
2011-6-10
回帖
6325
发表于 2013-10-28 08:54:59 | 显示全部楼层 |阅读模式

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

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

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

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


  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. module CAO
  46. module Conflate
  47.   #--------------------------------------------------------------------------
  48.   # ◇ 値引率
  49.   #--------------------------------------------------------------------------
  50.   CUT_RATE = 0.3
  51.   
  52.   #--------------------------------------------------------------------------
  53.   # ◇ ショップステータスを表示する
  54.   #--------------------------------------------------------------------------
  55.   USE_SHOP_STATUS = true
  56.   
  57.   #--------------------------------------------------------------------------
  58.   # ◇ 背景画像
  59.   #--------------------------------------------------------------------------
  60.   #     ファイル名を設定します。使用しない場合は nil としてください。
  61.   #--------------------------------------------------------------------------
  62.   FILE_SCENEBACK  = nil#"BackConflate"
  63.   FILE_STATUSBACK = "成品"
  64.   
  65.   #--------------------------------------------------------------------------
  66.   # ◇ 用語設定
  67.   #--------------------------------------------------------------------------
  68.   VOCAB = {}    # <= 変更しないでください。
  69.   VOCAB[:gold]     = ""
  70.   VOCAB[:material] = ""
  71.   VOCAB[:have]     = "                                                                件"
  72.   VOCAB[:have_u]   = ""
  73.   VOCAB[:cost]     = ""
  74. end
  75. end


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


  81. module CAO::Conflate
  82.   REGEXP_GOLD = /^@CONFLATE\[(\d+)(?:,|\])/i
  83.   REGEXP_KEYS = /^@CONFLATE\[(.+?)\]/i
  84.   REGEXP_GOODS = /([IWA])(\d+):(\d+)/i
  85. end

  86. class RPG::BaseItem
  87.   #--------------------------------------------------------------------------
  88.   # ● 合成費用の取得
  89.   #--------------------------------------------------------------------------
  90.   def conflate_price
  91.     return self.note.gsub(" ", "")[CAO::Conflate::REGEXP_GOLD, 1]
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 合成に必要なアイテムの取得
  95.   #--------------------------------------------------------------------------
  96.   def conflate_items
  97.     self.note.gsub(" ", "").scan(CAO::Conflate::REGEXP_KEYS).flatten.
  98.     join(",").scan(CAO::Conflate::REGEXP_GOODS).map do |key|
  99.       case key.first.upcase
  100.       when "I"; [$data_items[key[1].to_i], key[2].to_i]
  101.       when "W"; [$data_weapons[key[1].to_i], key[2].to_i]
  102.       when "A"; [$data_armors[key[1].to_i], key[2].to_i]
  103.       end
  104.     end
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 合成に必要なアイテムが揃っているか判定
  108.   #--------------------------------------------------------------------------
  109.   def enough_material?
  110.     return self.conflate_items.all? {|o,n| n <= $game_party.item_number(o) }
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 合成可能か判定
  114.   #--------------------------------------------------------------------------
  115.   def can_make?
  116.     return false if $game_party.gold < self.conflate_price
  117.     return false unless $game_party.item_number(self) < 99
  118.     return false unless self.enough_material?
  119.     return true
  120.   end
  121. end

  122. class RPG::Item
  123.   #--------------------------------------------------------------------------
  124.   # ○ 合成費用の取得
  125.   #--------------------------------------------------------------------------
  126.   def conflate_price
  127.     return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  128.   end
  129. end
  130. class RPG::Weapon
  131.   #--------------------------------------------------------------------------
  132.   # ○ 合成費用の取得
  133.   #--------------------------------------------------------------------------
  134.   def conflate_price
  135.     return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  136.   end
  137. end
  138. class RPG::Armor
  139.   #--------------------------------------------------------------------------
  140.   # ○ 合成費用の取得
  141.   #--------------------------------------------------------------------------
  142.   def conflate_price
  143.     return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  144.   end
  145. end

  146. class Game_Temp
  147.   #--------------------------------------------------------------------------
  148.   # ● 公開インスタンス変数
  149.   #--------------------------------------------------------------------------
  150.   attr_accessor :conflate_setting         # 合成 準備中フラグ
  151.   attr_accessor :conflate_immediate       # 合成 即時実行フラグ
  152.   attr_accessor :conflate_goods           # 合成 商品リスト
  153.   #--------------------------------------------------------------------------
  154.   # ● オブジェクト初期化
  155.   #--------------------------------------------------------------------------
  156.   alias _cao_conflate_initialize initialize
  157.   def initialize
  158.     _cao_conflate_initialize
  159.     @conflate_goods = []      # 合成アイテムID
  160.   end
  161. end

  162. class Game_Interpreter
  163.   #--------------------------------------------------------------------------
  164.   # ○ ラベル
  165.   #--------------------------------------------------------------------------
  166.   alias _cao_conflate_command_118 command_118
  167.   def command_118
  168.     case @params[0]
  169.     when /^<物品合成>/
  170.       $game_temp.conflate_goods = []
  171.       $game_temp.conflate_setting = true
  172.       $game_temp.conflate_immediate = true
  173.     when /^<合成准备>/
  174.       $game_temp.conflate_goods = []
  175.       $game_temp.conflate_setting = true
  176.       $game_temp.conflate_immediate = false
  177.     when /^<合成开始>/
  178.       $game_temp.next_scene = "conflate"
  179.       $game_temp.conflate_setting = false
  180.       $game_temp.conflate_immediate = false
  181.     when /^<合成完毕>/
  182.       $game_temp.conflate_goods = []
  183.       $game_temp.conflate_setting = false
  184.       $game_temp.conflate_immediate = false
  185.     end
  186.     _cao_conflate_command_118
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ○ ショップの処理
  190.   #--------------------------------------------------------------------------
  191.   alias _cao_conflate_command_302 command_302
  192.   def command_302
  193.     if $game_temp.conflate_setting
  194.       items = [$data_items, $data_weapons, $data_armors]
  195.       while [302, 605].include?(@list[@index].code)
  196.         kind = @list[@index].parameters[0]
  197.         id = @list[@index].parameters[1]
  198.         $game_temp.conflate_goods.push(items[kind][id]) if items[kind][id]
  199.         [url=home.php?mod=space&uid=370741]@Index[/url] += 1
  200.       end
  201.       if $game_temp.conflate_immediate
  202.         $game_temp.next_scene = "conflate"
  203.         $game_temp.conflate_setting = false
  204.         $game_temp.conflate_immediate = false
  205.       end
  206.       return false
  207.     end
  208.     _cao_conflate_command_302
  209.   end
  210. end

  211. class Scene_Map
  212.   #--------------------------------------------------------------------------
  213.   # ○ 画面切り替えの実行
  214.   #--------------------------------------------------------------------------
  215.   alias _cao_conflate_update_scene_change update_scene_change
  216.   def update_scene_change
  217.     return if $game_player.moving?    # プレイヤーの移動中?
  218.     if $game_temp.next_scene == "conflate"
  219.       $game_temp.next_scene = nil
  220.       $scene = Scene_Conflate.new
  221.     else
  222.       _cao_conflate_update_scene_change
  223.     end
  224.   end
  225. end

  226. class Window_Conflate < Window_Selectable
  227.   #--------------------------------------------------------------------------
  228.   # ● オブジェクト初期化
  229.   #     x : ウィンドウの X 座標
  230.   #     y : ウィンドウの Y 座標
  231.   #--------------------------------------------------------------------------
  232.   def initialize(x, y)
  233.     super(x+0, y+140, 240,360+105)
  234.     self.index = 0
  235.     refresh
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● アイテムの取得
  239.   #--------------------------------------------------------------------------
  240.   def item
  241.     return @data[self.index]
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● リフレッシュ
  245.   #--------------------------------------------------------------------------
  246.   def refresh
  247.     @data = []
  248.     $game_temp.conflate_goods.each {|item| @data.push(item) }
  249.     @item_max = @data.size
  250.     create_contents
  251.     for i in 0...@item_max
  252.       draw_item(i)
  253.     end
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # ● 項目の描画
  257.   #     index : 項目番号
  258.   #--------------------------------------------------------------------------
  259.   def draw_item(index)
  260.     item = @data[index]
  261.     rect = item_rect(index)
  262.     self.contents.clear_rect(rect)
  263.     draw_item_name(item, rect.x, rect.y, item.can_make?)
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ● ヘルプテキスト更新
  267.   #--------------------------------------------------------------------------
  268.   def update_help
  269.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  270.   end
  271. end

  272. class Window_ConflateGold < Window_Base
  273.   include CAO::Conflate
  274.   #--------------------------------------------------------------------------
  275.   # ● オブジェクト初期化
  276.   #     x : ウィンドウの X 座標
  277.   #     y : ウィンドウの Y 座標
  278.   #--------------------------------------------------------------------------
  279.   def initialize(x, y)
  280.     super(x+0, y+112+12+105, 304, 56)
  281.     refresh
  282.   end
  283.   #--------------------------------------------------------------------------
  284.   # ● リフレッシュ
  285.   #--------------------------------------------------------------------------
  286.   def refresh
  287.     self.contents.clear
  288.     self.contents.font.color = system_color
  289.     self.contents.draw_text(0, 0, self.contents.width, WLH, VOCAB[:gold])
  290.     draw_currency_value($game_party.gold, 0, 0, self.width - 32)
  291.   end
  292. end

  293. class Window_ConflateStatus < Window_Base
  294.   include CAO::Conflate
  295.   #--------------------------------------------------------------------------
  296.   # ● オブジェクト初期化
  297.   #     x : ウィンドウの X 座標
  298.   #     y : ウィンドウの Y 座標
  299.   #--------------------------------------------------------------------------
  300.   def initialize(x, y)
  301.     super(x+0, y+120, 304, 224)
  302.     @item = nil
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● リフレッシュ
  306.   #--------------------------------------------------------------------------
  307.   def refresh
  308.     self.contents.clear
  309.     return if @item == nil
  310.     self.contents.font.color = system_color
  311.     self.contents.draw_text(0, 0, self.contents.width, WLH, VOCAB[:material])
  312.     @item.conflate_items.each_with_index do |(item,num), i|
  313.       y = i * WLH + WLH
  314.       draw_item_name(item, 8, y, num <= $game_party.item_number(item))
  315.       self.contents.draw_text(8, y, self.contents.width-52, WLH, num, 2)
  316.       text = sprintf("(%02d)", $game_party.item_number(item))
  317.       self.contents.draw_text(8, y, self.contents.width-8, WLH, text, 2)
  318.     end
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● アイテムの設定
  322.   #     item : 新しいアイテム
  323.   #--------------------------------------------------------------------------
  324.   def item=(item)
  325.     if @item != item
  326.       @item = item
  327.       refresh
  328.     end
  329.   end
  330. end

  331. class Window_ConflateInfo < Window_Base
  332.   include CAO::Conflate
  333.   #--------------------------------------------------------------------------
  334.   # ● オブジェクト初期化
  335.   #     x : ウィンドウの X 座標
  336.   #     y : ウィンドウの Y 座標
  337.   #--------------------------------------------------------------------------
  338.   def initialize(x, y)
  339.     super(x+0, y+112, 304, 80)
  340.     @item = nil
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● リフレッシュ
  344.   #--------------------------------------------------------------------------
  345.   def refresh
  346.     self.contents.clear
  347.     return if @item == nil
  348.     width = self.contents.width
  349.     self.contents.font.color = system_color
  350.     self.contents.draw_text(0, 0, width, WLH, VOCAB[:have])
  351.     self.contents.draw_text(0, 0, width, WLH, VOCAB[:have_u], 2)
  352.     self.contents.draw_text(0, WLH, width, WLH, VOCAB[:cost])
  353.     self.contents.draw_text(0, WLH, width, WLH, Vocab::gold, 2)
  354.     self.contents.font.color = normal_color
  355.     width -= contents.text_size(Vocab::gold).width + 2
  356.     self.contents.draw_text(0, 0, width, WLH, $game_party.item_number(@item), 2)
  357.     self.contents.draw_text(0, WLH, width, WLH, @item.conflate_price, 2)
  358.   end
  359.   #--------------------------------------------------------------------------
  360.   # ● アイテムの設定
  361.   #     item : 新しいアイテム
  362.   #--------------------------------------------------------------------------
  363.   def item=(item)
  364.     if @item != item
  365.       @item = item
  366.       refresh
  367.     end
  368.   end
  369. end

  370. class Scene_Conflate < Scene_Base
  371.   #--------------------------------------------------------------------------
  372.   # ● 開始処理
  373.   #--------------------------------------------------------------------------
  374.   def start
  375.     super
  376.     @viewport = Viewport.new(8,-56, 800, 700)
  377.     @viewport.z = 100
  378.     create_menu_background
  379.     @help_window = Window_Help4.new
  380.     @gold_window = Window_ConflateGold.new(240, 304)
  381.     @gold_window.viewport = @viewport
  382.     @conflate_window = Window_Conflate.new(0, 0)
  383.     @conflate_window.viewport = @viewport
  384.     @conflate_window.help_window = @help_window
  385.     @info_window = Window_ConflateInfo.new(240, 0)
  386.     @info_window.viewport = @viewport
  387.     @material_window = Window_ConflateStatus.new(240, 80)
  388.     @material_window.viewport = @viewport
  389.     create_status_window
  390.    
  391.     if CAO::Conflate::FILE_SCENEBACK || CAO::Conflate::FILE_STATUSBACK
  392.       @help_window.opacity = 0
  393.       @gold_window.opacity = 0
  394.       @conflate_window.opacity = 0
  395.       @info_window.opacity = 0
  396.       @material_window.opacity = 0
  397.       @status_window.opacity = 0
  398.     end
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ● 終了処理
  402.   #--------------------------------------------------------------------------
  403.   def terminate
  404.     super
  405.     dispose_menu_background
  406.     @viewport.dispose
  407.     @help_window.dispose
  408.     @gold_window.dispose
  409.     @conflate_window.dispose
  410.     @info_window.dispose
  411.     @material_window.dispose
  412.     @status_window.dispose
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● メニュー画面系の背景作成
  416.   #--------------------------------------------------------------------------
  417.   def create_menu_background
  418.     if CAO::Conflate::FILE_SCENEBACK
  419.       @menuback_sprite = Sprite.new
  420.       @menuback_sprite.bitmap = Cache.system(CAO::Conflate::FILE_SCENEBACK)
  421.     else
  422.       super
  423.     end
  424.     if CAO::Conflate::FILE_STATUSBACK
  425.       @statusback_sprite = Sprite.new(@viewport)
  426.       @statusback_sprite.bitmap = Cache.system(CAO::Conflate::FILE_STATUSBACK)
  427.     end
  428.     update_menu_background
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   # ● メニュー画面系の背景解放
  432.   #--------------------------------------------------------------------------
  433.   def dispose_menu_background
  434.     super
  435.     @statusback_sprite.dispose if CAO::Conflate::FILE_STATUSBACK
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● ショップステータスウィンドウの生成
  439.   #--------------------------------------------------------------------------
  440.   def create_status_window
  441.     @status_window = Window_ShopStatus.new(544, 0)
  442.     @status_window.x = 544
  443.     @status_window.y = 120
  444.     @status_window.height = 360+105
  445.     @status_window.viewport = @viewport
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ● 元の画面へ戻る
  449.   #--------------------------------------------------------------------------
  450.   def return_scene
  451.     $scene = Scene_Map.new
  452.   end
  453.   #--------------------------------------------------------------------------
  454.   # ● フレーム更新
  455.   #--------------------------------------------------------------------------
  456.   def update
  457.     super
  458.     update_menu_background
  459.     @viewport.update
  460.     @help_window.update
  461.     @gold_window.update
  462.     @conflate_window.update
  463.     @info_window.update
  464.     @material_window.update
  465.     @status_window.update
  466.    
  467.     @info_window.item = @conflate_window.item
  468.     @material_window.item = @conflate_window.item
  469.     @status_window.item = @conflate_window.item
  470.    
  471.     update_conflate_input
  472. #    update_status_input
  473.    
  474.     if @open_status
  475.       @viewport.ox += 16
  476.       if @viewport.ox > @status_window.width
  477.         @viewport.ox = @status_window.width
  478.         @open_status = false
  479.       end
  480.     elsif @close_status
  481.       @viewport.ox -= 16
  482.       if @viewport.ox < 0
  483.         @viewport.ox = 0
  484.         @close_status = false
  485.       end
  486.     end
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # ● 合成アイテムの入力更新
  490.   #--------------------------------------------------------------------------
  491.   def update_conflate_input
  492.     if Input.trigger?(Input::B)
  493.       Sound.play_cancel
  494.       return_scene
  495.     elsif Input.trigger?(Input::C)
  496.       if @conflate_window.item.can_make?
  497.         Sound.play_shop
  498.         $game_party.lose_gold(@conflate_window.item.conflate_price)
  499.         for item,n in @conflate_window.item.conflate_items
  500.           $game_party.lose_item(item, n)
  501.         end
  502.         $game_party.gain_item(@conflate_window.item, 1)
  503.         @gold_window.refresh
  504.         @conflate_window.refresh
  505.         @info_window.refresh
  506.         @material_window.refresh
  507.         @status_window.refresh
  508.       else
  509.         Sound.play_buzzer
  510.       end
  511.     end
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ● ショップステータスの入力更新
  515.   #--------------------------------------------------------------------------
  516. #  def update_status_input
  517. #   return unless CAO::Conflate::USE_SHOP_STATUS
  518.   #  if Input.trigger?(Input::LEFT)
  519.    #   @open_status = false
  520.     #  @close_status = true
  521.     #elsif Input.trigger?(Input::RIGHT)
  522.      # @open_status = true
  523.       #@close_status = false
  524.     #end
  525.   #end
  526. end
复制代码

点评

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

永无止境的旅程<

梦石
0
星屑
537
在线时间
1554 小时
注册时间
2012-6-19
回帖
1162

开拓者贵宾

发表于 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]
回复

使用道具 举报

狂気の月兔

梦石
0
星屑
421
在线时间
1245 小时
注册时间
2009-4-7
回帖
866

贵宾

发表于 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 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部