查看: 1811|回复: 4

[已经解决] 白の魔的物品合成脚本可以设置成功率吗?

[复制链接]
梦石
0
星屑
809
在线时间
176 小时
注册时间
2017-1-15
回帖
50
发表于 2020-11-23 22:37:22 | 显示全部楼层 |阅读模式
悬赏50星屑已解决
我看了下脚本,虽然是日文,但看上去好像没有设置成功率的地方……

  1. #==============================================================================
  2. # ■ RGSS3 アイテム合成 ver 1.02
  3. #------------------------------------------------------------------------------
  4. #  配布元:
  5. #     白の魔 [url]http://izumiwhite.web.fc2.com/[/url]
  6. #
  7. #  利用規約:
  8. #     RPGツクールVX Aceの正規の登録者のみご利用になれます。
  9. #     利用報告・著作権表示とかは必要ありません。
  10. #     改造もご自由にどうぞ。
  11. #     何か問題が発生しても責任は持ちません。
  12. #==============================================================================
  13. =begin
  14. i_recipe_switch_on(2) i_中的i可以改成a和w表示防具和武器的开启 2是配方的ID
  15. i_recipe_switch_on(2)开启2号物品配方
  16. a_recipe_switch_on(3)开启3号防具配方
  17. w_recipe_switch_on(4)开启4号武器配方

  18. i_recipe_switch_off(2)关闭2号物品配方
  19. a_recipe_switch_off(3)关闭3号防具配方
  20. w_recipe_switch_off(4)关闭4号武器配方

  21. i_recipe_switch_on?(2)开启了2号物品配方?
  22. a_recipe_switch_on?(3)开启了3号防具配方?
  23. w_recipe_switch_on?(4)开启了4号武器配方?

  24. i_recipe_all_switch_on 开启所有物品配方
  25. a_recipe_all_switch_on开启所有防具配方
  26. w_recipe_all_switch_on开启所有武器配方



  27. recipe_all_switch_on开启所有配方
  28. recipe_all_switch_off 关闭所有配方
  29. =end
  30. #--------------------------------------------------------------------------
  31. # ★ 初期設定。
  32. #    合成レシピ等の設定
  33. #--------------------------------------------------------------------------
  34. module WD_itemsynthesis_ini

  35.   Cost_view =  true #費用(G)の表示(合成の費用が全て0Gの場合はfalseを推奨)

  36.   Category_i = true #カテゴリウィンドウに「アイテム」の項目を表示
  37.   Category_w = true #カテゴリウィンドウに「武器」の項目を表示
  38.   Category_a = true #カテゴリウィンドウに「防具」の項目を表示
  39.   Category_k = true #カテゴリウィンドウに「大事なもの」の項目を表示

  40.   I_recipe = [] #この行は削除しないこと
  41.   W_recipe = [] #この行は削除しないこと
  42.   A_recipe = [] #この行は削除しないこと

  43.   #以下、合成レシピ。
  44.   #例: I_recipe[3]  = [100, ["I",1,1], ["W",2,1], ["A",2,2], ["A",3,1]]
  45.   #と記載した場合、ID3のアイテムの合成必要は、100G。
  46.   #必要な素材は、ID1のアイテム1個、ID2の武器1個、ID2の防具2個、ID3の防具1個
  47.   #となる。

  48.   #アイテムの合成レシピ
  49.   I_recipe[1]  = [300,  ["I",2,1],["I",3,1]]
  50.   I_recipe[20]  = [0,  ["I",19,1],["I",202,1],["I",204,1]]
  51.   #I_recipe[3]  = [100, ["I",1,1], ["I",2,1]]
  52.   #I_recipe[17] = [500, ["I",1,10]]

  53.   #武器の合成レシピ
  54.   W_recipe[3]  = [50,   ["W",1,1], ["W",2,1]]
  55.   #W_recipe[6]  = [600,  ["W",3,1], ["I",17,0]]

  56.   #防具の合成レシピ  
  57.   A_recipe[2]  = [40,   ["A",1,2]]
  58.   #A_recipe[5]  = [400,  ["A",2,1], ["W",2,2], ["I",17,0]]

  59. end


  60. #==============================================================================
  61. # ■ WD_itemsynthesis
  62. #------------------------------------------------------------------------------
  63. #  アイテム合成用の共通メソッドです。
  64. #==============================================================================

  65. module WD_itemsynthesis
  66.   def i_recipe_switch_on(id)
  67.     $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
  68.     $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
  69.     $game_system.i_rcp_sw[id] = true
  70.   end
  71.   def i_recipe_switch_off(id)
  72.     $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
  73.     $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
  74.     $game_system.i_rcp_sw[id] = false
  75.   end
  76.   def i_recipe_switch_on?(id)
  77.     $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
  78.     $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
  79.     return $game_system.i_rcp_sw[id]
  80.   end
  81.   def i_recipe_all_switch_on
  82.     for i in 1..$data_items.size
  83.       i_recipe_switch_on(i)
  84.     end
  85.   end
  86.   def i_recipe_all_switch_off
  87.     for i in 1..$data_items.size
  88.       i_recipe_switch_off(i)
  89.     end
  90.   end
  91.   def w_recipe_switch_on(id)
  92.     $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
  93.     $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
  94.     $game_system.w_rcp_sw[id] = true
  95.   end
  96.   def w_recipe_switch_off(id)
  97.     $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
  98.     $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
  99.     $game_system.w_rcp_sw[id] = false
  100.   end
  101.   def w_recipe_switch_on?(id)
  102.     $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
  103.     $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
  104.     return $game_system.w_rcp_sw[id]
  105.   end
  106.   def w_recipe_all_switch_on
  107.     for i in 1..$data_weapons.size
  108.       w_recipe_switch_on(i)
  109.     end
  110.   end
  111.   def w_recipe_all_switch_off
  112.     for i in 1..$data_weapons.size
  113.       w_recipe_switch_off(i)
  114.     end
  115.   end
  116.   def a_recipe_switch_on(id)
  117.     $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
  118.     $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
  119.     $game_system.a_rcp_sw[id] = true
  120.   end
  121.   def a_recipe_switch_off(id)
  122.     $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
  123.     $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
  124.     $game_system.a_rcp_sw[id] = false
  125.   end
  126.   def a_recipe_switch_on?(id)
  127.     $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
  128.     $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
  129.     return $game_system.a_rcp_sw[id]
  130.   end
  131.   def a_recipe_all_switch_on
  132.     for i in 1..$data_armors.size
  133.       a_recipe_switch_on(i)
  134.     end
  135.   end
  136.   def a_recipe_all_switch_off
  137.     for i in 1..$data_armors.size
  138.       a_recipe_switch_off(i)
  139.     end
  140.   end
  141.   def recipe_all_switch_on
  142.     i_recipe_all_switch_on
  143.     w_recipe_all_switch_on
  144.     a_recipe_all_switch_on
  145.   end
  146.   def recipe_all_switch_off
  147.     i_recipe_all_switch_off
  148.     w_recipe_all_switch_off
  149.     a_recipe_all_switch_off
  150.   end

  151. end

  152. class Game_Interpreter
  153.   include WD_itemsynthesis
  154. end

  155. class Game_System
  156.   #--------------------------------------------------------------------------
  157.   # ● 公開インスタンス変数
  158.   #--------------------------------------------------------------------------
  159.   attr_accessor :i_rcp_sw
  160.   attr_accessor :w_rcp_sw
  161.   attr_accessor :a_rcp_sw
  162.   #--------------------------------------------------------------------------
  163.   # ● オブジェクト初期化
  164.   #--------------------------------------------------------------------------
  165.   alias wd_orig_initialize004 initialize
  166.   def initialize
  167.     wd_orig_initialize004
  168.     @i_rcp_sw = []
  169.     @w_rcp_sw = []
  170.     @a_rcp_sw = []
  171.   end
  172. end


  173. #==============================================================================
  174. # ■ Scene_ItemSynthesis
  175. #------------------------------------------------------------------------------
  176. #  合成画面の処理を行うクラスです。
  177. #==============================================================================

  178. class Scene_ItemSynthesis < Scene_MenuBase
  179.   #--------------------------------------------------------------------------
  180.   # ● 開始処理
  181.   #--------------------------------------------------------------------------
  182.   def start
  183.     super
  184.     create_help_window
  185.     create_dummy_window
  186.     create_number_window
  187.     create_status_window
  188.     create_material_window
  189.     create_list_window
  190.     create_category_window
  191.     create_gold_window
  192.     create_change_window
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● ゴールドウィンドウの作成
  196.   #--------------------------------------------------------------------------
  197.   def create_gold_window
  198.     @gold_window = Window_Gold.new
  199.     @gold_window.viewport = @viewport
  200.     @gold_window.x = Graphics.width - @gold_window.width
  201.     @gold_window.y = @help_window.height
  202.     @gold_window.hide
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● 切り替え表示ウィンドウの作成
  206.   #--------------------------------------------------------------------------
  207.   def create_change_window
  208.     wx = 0
  209.     wy = @gold_window.y
  210.     ww = Graphics.width - @gold_window.width
  211.     wh = @gold_window.height
  212.     @change_window = Window_ItemSynthesisChange.new(wx, wy, ww, wh)
  213.     @change_window.viewport = @viewport
  214.     @change_window.hide
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● ダミーウィンドウの作成
  218.   #--------------------------------------------------------------------------
  219.   def create_dummy_window
  220.     wy = @help_window.y + @help_window.height + 48
  221.     wh = Graphics.height - wy
  222.     @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
  223.     @dummy_window.viewport = @viewport
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 個数入力ウィンドウの作成
  227.   #--------------------------------------------------------------------------
  228.   def create_number_window
  229.     wy = @dummy_window.y
  230.     wh = @dummy_window.height
  231.     @number_window = Window_ItemSynthesisNumber.new(0, wy, wh)
  232.     @number_window.viewport = @viewport
  233.     @number_window.hide
  234.     @number_window.set_handler(:ok,     method(:on_number_ok))
  235.     @number_window.set_handler(:cancel, method(:on_number_cancel))
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● ステータスウィンドウの作成
  239.   #--------------------------------------------------------------------------
  240.   def create_status_window
  241.     wx = @number_window.width
  242.     wy = @dummy_window.y
  243.     ww = Graphics.width - wx
  244.     wh = @dummy_window.height
  245.     @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
  246.     @status_window.viewport = @viewport
  247.     @status_window.hide
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 素材ウィンドウの作成
  251.   #--------------------------------------------------------------------------
  252.   def create_material_window
  253.     wx = @number_window.width
  254.     wy = @dummy_window.y
  255.     ww = Graphics.width - wx
  256.     wh = @dummy_window.height
  257.     @material_window = Window_ItemSynthesisMaterial.new(wx, wy, ww, wh)
  258.     @material_window.viewport = @viewport
  259.     @material_window.hide
  260.     @number_window.material_window = @material_window
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● 合成アイテムリストウィンドウの作成
  264.   #--------------------------------------------------------------------------
  265.   def create_list_window
  266.     wy = @dummy_window.y
  267.     wh = @dummy_window.height
  268.     @list_window = Window_ItemSynthesisList.new(0, wy, wh)
  269.     @list_window.viewport = @viewport
  270.     @list_window.help_window = @help_window
  271.     @list_window.status_window = @status_window
  272.     @list_window.material_window = @material_window
  273.     @list_window.hide
  274.     @list_window.set_handler(:ok,     method(:on_list_ok))
  275.     @list_window.set_handler(:cancel, method(:on_list_cancel))
  276.     @list_window.set_handler(:change_window, method(:on_change_window))   
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● カテゴリウィンドウの作成
  280.   #--------------------------------------------------------------------------
  281.   def create_category_window
  282.     @category_window = Window_ItemSynthesisCategory.new
  283.     @category_window.viewport = @viewport
  284.     @category_window.help_window = @help_window
  285.     @category_window.y = @help_window.height
  286.     @category_window.activate
  287.     @category_window.item_window = @list_window
  288.     @category_window.set_handler(:ok,     method(:on_category_ok))
  289.     @category_window.set_handler(:cancel, method(:return_scene))
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ● 合成アイテムリストウィンドウのアクティブ化
  293.   #--------------------------------------------------------------------------
  294.   def activate_list_window
  295.     @list_window.money = money
  296.     @list_window.show.activate
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 合成[決定]
  300.   #--------------------------------------------------------------------------
  301.   def on_list_ok
  302.     @item = @list_window.item
  303.     @list_window.hide
  304.     @number_window.set(@item, max_buy, buying_price, currency_unit)
  305.     @number_window.show.activate
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ● 合成[キャンセル]
  309.   #--------------------------------------------------------------------------
  310.   def on_list_cancel
  311.     @category_window.activate
  312.     @category_window.show
  313.     @dummy_window.show
  314.     @list_window.hide
  315.     @status_window.hide
  316.     @status_window.item = nil
  317.     @material_window.hide
  318.     @material_window.set(nil, nil)
  319.     @gold_window.hide
  320.     @change_window.hide
  321.     @help_window.clear
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ● 表示切替
  325.   #--------------------------------------------------------------------------
  326.   def on_change_window
  327.     if @status_window.visible
  328.       @status_window.hide
  329.       @material_window.show
  330.     else
  331.       @status_window.show
  332.       @material_window.hide
  333.     end
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ● カテゴリ[決定]
  337.   #--------------------------------------------------------------------------
  338.   def on_category_ok
  339.     activate_list_window
  340.     @gold_window.show
  341.     @change_window.show
  342.     @material_window.show
  343.     @category_window.hide
  344.     @list_window.select(0)
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 個数入力[決定]
  348.   #--------------------------------------------------------------------------
  349.   def on_number_ok
  350.     Sound.play_shop
  351.     do_syntetic(@number_window.number)
  352.     end_number_input
  353.     @gold_window.refresh
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 個数入力[キャンセル]
  357.   #--------------------------------------------------------------------------
  358.   def on_number_cancel
  359.     Sound.play_cancel
  360.     end_number_input
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 合成の実行
  364.   #--------------------------------------------------------------------------
  365.   def do_syntetic(number)
  366.     $game_party.lose_gold(number * buying_price)
  367.     $game_party.gain_item(@item, number)

  368.       @recipe = @list_window.recipe(@item)
  369.       for i in 1...@recipe.size
  370.         kind = @recipe[i][0]
  371.         id   = @recipe[i][1]
  372.         num  = @recipe[i][2]
  373.         if kind == "I"
  374.           item = $data_items[id]
  375.         elsif kind == "W"
  376.           item = $data_weapons[id]
  377.         elsif kind == "A"
  378.           item = $data_armors[id]
  379.         end
  380.         $game_party.lose_item(item, num*number)
  381.       end
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # ● 個数入力の終了
  385.   #--------------------------------------------------------------------------
  386.   def end_number_input
  387.     @number_window.hide
  388.     activate_list_window
  389.   end
  390.   #--------------------------------------------------------------------------
  391.   # ● 最大購入可能個数の取得
  392.   #--------------------------------------------------------------------------
  393.   def max_buy
  394.     max = $game_party.max_item_number(@item) - $game_party.item_number(@item)

  395.     @recipe = @list_window.recipe(@item)
  396.       for i in 1...@recipe.size
  397.         kind = @recipe[i][0]
  398.         id   = @recipe[i][1]
  399.         num  = @recipe[i][2]
  400.         if kind == "I"
  401.           item = $data_items[id]
  402.         elsif kind == "W"
  403.           item = $data_weapons[id]
  404.         elsif kind == "A"
  405.           item = $data_armors[id]
  406.         end
  407.         if num > 0
  408.           max_buf = $game_party.item_number(item)/num
  409.         else
  410.           max_buf = 999
  411.         end
  412.         max = [max, max_buf].min
  413.       end

  414.     buying_price == 0 ? max : [max, money / buying_price].min

  415.   end
  416. #--------------------------------------------------------------------------
  417.   # ● 所持金の取得
  418.   #--------------------------------------------------------------------------
  419.   def money
  420.     @gold_window.value
  421.   end
  422.   #--------------------------------------------------------------------------
  423.   # ● 通貨単位の取得
  424.   #--------------------------------------------------------------------------
  425.   def currency_unit
  426.     @gold_window.currency_unit
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # ● 合成費用の取得
  430.   #--------------------------------------------------------------------------
  431.   def buying_price
  432.     @list_window.price(@item)
  433.   end
  434. end


  435. #==============================================================================
  436. # ■ Window_ItemSynthesisList
  437. #------------------------------------------------------------------------------
  438. #  合成画面で、合成可能なアイテムの一覧を表示するウィンドウです。
  439. #==============================================================================

  440. class Window_ItemSynthesisList < Window_Selectable
  441.   include WD_itemsynthesis
  442.   #--------------------------------------------------------------------------
  443.   # ● 公開インスタンス変数
  444.   #--------------------------------------------------------------------------
  445.   attr_reader   :status_window            # ステータスウィンドウ
  446.   #--------------------------------------------------------------------------
  447.   # ● オブジェクト初期化
  448.   #--------------------------------------------------------------------------
  449.   def initialize(x, y, height)
  450.     super(x, y, window_width, height)

  451.     @shop_goods = []
  452.     @shop_recipes = []

  453.     for i in 1..WD_itemsynthesis_ini::I_recipe.size
  454.       recipe = WD_itemsynthesis_ini::I_recipe[i]
  455.       if recipe
  456.         good = [0, i, recipe[0]]
  457.         if i_recipe_switch_on?(i)
  458.           @shop_goods.push(good)
  459.           @shop_recipes.push(recipe)
  460.         end
  461.       end
  462.     end
  463.     for i in 1..WD_itemsynthesis_ini::W_recipe.size
  464.       recipe = WD_itemsynthesis_ini::W_recipe[i]
  465.       if recipe
  466.         good = [1, i, recipe[0]]
  467.         if w_recipe_switch_on?(i)
  468.           @shop_goods.push(good)
  469.           @shop_recipes.push(recipe)
  470.         end
  471.       end
  472.     end
  473.     for i in 1..WD_itemsynthesis_ini::A_recipe.size
  474.       recipe = WD_itemsynthesis_ini::A_recipe[i]
  475.       if recipe
  476.         good = [2, i, recipe[0]]
  477.         if a_recipe_switch_on?(i)
  478.           @shop_goods.push(good)
  479.           @shop_recipes.push(recipe)
  480.         end
  481.       end
  482.     end

  483.     @money = 0
  484.     refresh
  485.     select(0)
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # ● ウィンドウ幅の取得
  489.   #--------------------------------------------------------------------------
  490.   def window_width
  491.     return 304
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 項目数の取得
  495.   #--------------------------------------------------------------------------
  496.   def item_max
  497.     @data ? @data.size : 1
  498.   end
  499.   #--------------------------------------------------------------------------
  500.   # ● アイテムの取得
  501.   #--------------------------------------------------------------------------
  502.   def item
  503.     @data[index]
  504.   end
  505.   #--------------------------------------------------------------------------
  506.   # ● 所持金の設定
  507.   #--------------------------------------------------------------------------
  508.   def money=(money)
  509.     @money = money
  510.     refresh
  511.   end
  512.   #--------------------------------------------------------------------------
  513.   # ● 選択項目の有効状態を取得
  514.   #--------------------------------------------------------------------------
  515.   def current_item_enabled?
  516.     enable?(@data[index])
  517.   end
  518.   #--------------------------------------------------------------------------
  519.   # ● 合成費用を取得
  520.   #--------------------------------------------------------------------------
  521.   def price(item)
  522.     @price[item]
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ● 合成可否を取得
  526.   #--------------------------------------------------------------------------
  527.   def enable?(item)
  528.     @makable[item]
  529.   end
  530.   #--------------------------------------------------------------------------
  531.   # ● レシピを取得
  532.   #--------------------------------------------------------------------------
  533.   def recipe(item)
  534.     @recipe[item]
  535.   end
  536.   #--------------------------------------------------------------------------
  537.   # ● アイテムを許可状態で表示するかどうか
  538.   #--------------------------------------------------------------------------
  539.   def have_mat?(recipe)
  540.     flag = true
  541.     if @money >= recipe[0]
  542.       for i in 1...recipe.size
  543.         kind = recipe[i][0]
  544.         id   = recipe[i][1]
  545.         num  = recipe[i][2]
  546.         if kind == "I"
  547.           item = $data_items[id]
  548.         elsif kind == "W"
  549.           item = $data_weapons[id]
  550.         elsif kind == "A"
  551.           item = $data_armors[id]
  552.         end
  553.         if $game_party.item_number(item) < [num, 1].max
  554.           flag = false
  555.         end
  556.       end
  557.     else
  558.       flag = false
  559.     end
  560.     return flag
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ● カテゴリの設定
  564.   #--------------------------------------------------------------------------
  565.   def category=(category)
  566.     return if @category == category
  567.     @category = category
  568.     refresh
  569.   end
  570.   #--------------------------------------------------------------------------
  571.   # ● リフレッシュ
  572.   #--------------------------------------------------------------------------
  573.   def refresh
  574.     make_item_list
  575.     create_contents
  576.     draw_all_items
  577.   end
  578.   #--------------------------------------------------------------------------
  579.   # ● アイテムをリストに含めるかどうか
  580.   #--------------------------------------------------------------------------
  581.   def include?(item)
  582.     case @category
  583.     when :item
  584.       item.is_a?(RPG::Item) && !item.key_item?
  585.     when :weapon
  586.       item.is_a?(RPG::Weapon)
  587.     when :armor
  588.       item.is_a?(RPG::Armor)
  589.     when :key_item
  590.       item.is_a?(RPG::Item) && item.key_item?
  591.     else
  592.       false
  593.     end
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● アイテムリストの作成
  597.   #--------------------------------------------------------------------------
  598.   def make_item_list
  599.     @data = []
  600.     @price = {}
  601.     @makable = {}
  602.     @recipe = {}
  603.     for i in 0...@shop_goods.size
  604.       goods = @shop_goods[i]
  605.       recipe = @shop_recipes[i]
  606.       case goods[0]
  607.       when 0;  item = $data_items[goods[1]]
  608.       when 1;  item = $data_weapons[goods[1]]
  609.       when 2;  item = $data_armors[goods[1]]
  610.       end
  611.       if item
  612.         if include?(item)
  613.           @data.push(item)
  614.           @price[item] = goods[2]
  615.           @makable[item] = have_mat?(recipe)
  616.           @recipe[item] = recipe
  617.         end
  618.       end
  619.     end
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # ● 項目の描画
  623.   #--------------------------------------------------------------------------
  624.   def draw_item(index)
  625.     item = @data[index]
  626.     rect = item_rect(index)
  627.     draw_item_name(item, rect.x, rect.y, enable?(item))
  628.     rect.width -= 4
  629.     draw_text(rect, price(item), 2)  if WD_itemsynthesis_ini::Cost_view
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ● ステータスウィンドウの設定
  633.   #--------------------------------------------------------------------------
  634.   def status_window=(status_window)
  635.     @status_window = status_window
  636.     call_update_help
  637.   end
  638.   #--------------------------------------------------------------------------
  639.   # ● 素材ウィンドウの設定
  640.   #--------------------------------------------------------------------------
  641.   def material_window=(material_window)
  642.     @material_window = material_window
  643.     call_update_help
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # ● ヘルプテキスト更新
  647.   #--------------------------------------------------------------------------
  648.   def update_help
  649.     @help_window.set_item(item) if @help_window
  650.     @status_window.item = item if @status_window
  651.     @material_window.set(item, recipe(item)) if @material_window
  652.   end
  653.   #--------------------------------------------------------------------------
  654.   # ● ←→ ボタン(表示切替)が押されたときの処理
  655.   #--------------------------------------------------------------------------
  656.   def process_change_window
  657.     Sound.play_cursor
  658.     Input.update
  659.     call_handler(:change_window)
  660.   end
  661.   #--------------------------------------------------------------------------
  662.   # ● 決定やキャンセルなどのハンドリング処理
  663.   #--------------------------------------------------------------------------
  664.   def process_handling
  665.     super
  666.     if active
  667.       return process_change_window if handle?(:change_window) && Input.trigger?(:X)
  668.       return process_change_window if handle?(:change_window) && Input.trigger?(:Y)
  669.     end
  670.   end
  671. end


  672. #==============================================================================
  673. # ■ Window_ItemSynthesisMaterial
  674. #------------------------------------------------------------------------------
  675. #  合成画面で、合成に必要な素材を表示するウィンドウです。
  676. #==============================================================================

  677. class Window_ItemSynthesisMaterial < Window_Base
  678.   #--------------------------------------------------------------------------
  679.   # ● オブジェクト初期化
  680.   #--------------------------------------------------------------------------
  681.   def initialize(x, y, width, height)
  682.     super(x, y, width, height)
  683.     @item = nil
  684.     refresh
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # ● リフレッシュ
  688.   #--------------------------------------------------------------------------
  689.   def refresh
  690.     contents.clear
  691.     draw_possession(4, 0)
  692.     draw_material_info(0, line_height * 2)
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # ● アイテムの設定
  696.   #--------------------------------------------------------------------------
  697.   def set(item, recipe)
  698.     @item = item
  699.     @recipe = recipe
  700.     @make_number = 1
  701.     refresh
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # ● 作成個数の設定
  705.   #--------------------------------------------------------------------------
  706.   def set_num(make_number)
  707.     @make_number = make_number
  708.     refresh
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # ● 所持数の描画
  712.   #--------------------------------------------------------------------------
  713.   def draw_possession(x, y)
  714.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  715.     change_color(system_color)
  716.     draw_text(rect, Vocab::Possession)
  717.     change_color(normal_color)
  718.     draw_text(rect, $game_party.item_number(@item), 2)
  719.   end
  720.   #--------------------------------------------------------------------------
  721.   # ● 素材情報の描画
  722.   #--------------------------------------------------------------------------
  723.   def draw_material_info(x, y)
  724.     rect = Rect.new(x, y, contents.width, line_height)
  725.     change_color(system_color)
  726.     contents.font.size = 18
  727.     draw_text(rect, "必要素材", 0)
  728.     if @recipe
  729.       for i in 1...@recipe.size
  730.         kind = @recipe[i][0]
  731.         id   = @recipe[i][1]
  732.         num  = @recipe[i][2]
  733.         if kind == "I"
  734.           item = $data_items[id]
  735.         elsif kind == "W"
  736.           item = $data_weapons[id]
  737.         elsif kind == "A"
  738.           item = $data_armors[id]
  739.         end
  740.         rect = Rect.new(x, y + line_height*i, contents.width, line_height)
  741.         enabled = true
  742.         enabled = false if [num*@make_number, 1].max  > $game_party.item_number(item)
  743.         draw_item_name(item, rect.x, rect.y, enabled)
  744.         change_color(normal_color, enabled)
  745.         if num > 0
  746.           draw_text(rect, "#{num*@make_number}/#{$game_party.item_number(item)}", 2)
  747.         end
  748.       end
  749.     end
  750.     change_color(normal_color)
  751.     contents.font.size = 24
  752.   end
  753. end


  754. #==============================================================================
  755. # ■ Window_ItemSynthesisNumber
  756. #------------------------------------------------------------------------------
  757. #  合成画面で、合成するアイテムの個数を入力するウィンドウです。
  758. #==============================================================================

  759. class Window_ItemSynthesisNumber < Window_ShopNumber
  760.   #--------------------------------------------------------------------------
  761.   # ● リフレッシュ
  762.   #--------------------------------------------------------------------------
  763.   def refresh
  764.     contents.clear
  765.     draw_item_name(@item, 0, item_y)
  766.     draw_number
  767.     draw_total_price if WD_itemsynthesis_ini::Cost_view
  768.   end
  769.   #--------------------------------------------------------------------------
  770.   # ● オブジェクト初期化
  771.   #--------------------------------------------------------------------------
  772.   def material_window=(material_window)
  773.     @material_window = material_window
  774.     call_update_help
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # ● 作成個数の変更
  778.   #--------------------------------------------------------------------------
  779.   def change_number(amount)
  780.     @number = [[@number + amount, @max].min, 1].max
  781.     call_update_help #追加
  782.   end
  783.   #--------------------------------------------------------------------------
  784.   # ● ヘルプテキスト更新
  785.   #--------------------------------------------------------------------------
  786.   def call_update_help
  787.     @material_window.set_num(@number) if @material_window
  788.   end
  789. end


  790. #==============================================================================
  791. # ■ Window_ItemSynthesisCategory
  792. #------------------------------------------------------------------------------
  793. #  合成画面で、通常アイテムや装備品の分類を選択するウィンドウです。
  794. #==============================================================================

  795. class Window_ItemSynthesisCategory < Window_ItemCategory
  796.   #--------------------------------------------------------------------------
  797.   # ● 桁数の取得
  798.   #--------------------------------------------------------------------------
  799.   def col_max
  800.     i = 0
  801.     i += 1 if WD_itemsynthesis_ini::Category_i
  802.     i += 1 if WD_itemsynthesis_ini::Category_w
  803.     i += 1 if WD_itemsynthesis_ini::Category_a
  804.     i += 1 if WD_itemsynthesis_ini::Category_k
  805.     return i
  806.   end
  807.   #--------------------------------------------------------------------------
  808.   # ● コマンドリストの作成
  809.   #--------------------------------------------------------------------------
  810.   def make_command_list
  811.     add_command(Vocab::item,     :item)     if WD_itemsynthesis_ini::Category_i
  812.     add_command(Vocab::weapon,   :weapon)   if WD_itemsynthesis_ini::Category_w
  813.     add_command(Vocab::armor,    :armor)    if WD_itemsynthesis_ini::Category_a
  814.     add_command(Vocab::key_item, :key_item) if WD_itemsynthesis_ini::Category_k
  815.   end
  816. end


  817. #==============================================================================
  818. # ■ Window_ItemSynthesisNumber
  819. #------------------------------------------------------------------------------
  820. #  合成画面で、切替を表示するウィンドウです。
  821. #==============================================================================

  822. class Window_ItemSynthesisChange < Window_Base
  823.   #--------------------------------------------------------------------------
  824.   # ● オブジェクト初期化
  825.   #--------------------------------------------------------------------------
  826.   def initialize(x, y, width, height)
  827.     super(x, y, width, height)
  828.     refresh
  829.   end
  830.   #--------------------------------------------------------------------------
  831.   # ● リフレッシュ
  832.   #--------------------------------------------------------------------------
  833.   def refresh
  834.     contents.clear
  835.     text = "X Y:表示切换"
  836.     draw_text(0, 0, contents_width, line_height, text, 1)
  837.   end
  838. end
复制代码

最佳答案

查看完整内容

不可以,除非有好心人/砸RMB找人修改脚本 或许可以考慮換別个脚本,比如Vlue的高级配方合成 https://forums.rpgmakerweb.com/index.php?threads/advanced-recipe-crafting.27108/ [pre lang="ruby"]#高级配方合成 v1.2 #----------# #功能: 高级配方合成! # #使用方法: 使用脚本 # $crafting_category = :craft - 在呼出场景前使用, :craft 替换为合成类型 # SceneManager.call(Scene_Crafting) - 打 ...
梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-11-23 22:37:23 | 显示全部楼层
本帖最后由 alexncf125 于 2020-11-23 23:12 编辑
白の魔的物品合成脚本可以设置成功率吗?

不可以,除非有好心人/砸RMB找人修改脚本

或许可以考慮換別个脚本,比如Vlue的高级配方合成
https://forums.rpgmakerweb.com/i ... ipe-crafting.27108/
A9AfjHN.png
  1. #高级配方合成 v1.2
  2. #----------#
  3. #功能: 高级配方合成!
  4. #
  5. #使用方法:    使用脚本
  6. #       $crafting_category = :craft         - 在呼出场景前使用, :craft 替换为合成类型
  7. #       SceneManager.call(Scene_Crafting)   - 打开合成菜单
  8. #       SceneManager.call(Scene_CraftingAll)- 打开分类合成菜单
  9. #       learn_recipe(id)                    - 学会该配方
  10. #       forget_recipe(id)                   - 遗忘该配方
  11. #
  12. #----------#
  13. #-- Script by: V.M of D.T
  14. #
  15. #- Questions or comments can be:
  16. #    given by email: sumptuaryspade@live.ca
  17. #    provided on facebook: [url]http://www.facebook.com/DaimoniousTailsGames[/url]
  18. #   All my other scripts and projects can be found here: [url]http://daimonioustails.weebly.com/[/url]
  19. #
  20. #- Free to use in any project with credit given, donations always welcome!

  21. module ADV_RECIPE
  22. #合成出的武器/护甲是否随机化(需要脚本WA_RANDOMIZATION)
  23.   USE_WA_RANDOMIZATION = false
  24. #合成菜单中合成类型的显示顺序 , 使用:All 代表所有类型
  25.   CATEGORIES = [:炼金,:锻造,:缝纫,:炼甲,:木匠,:建造,:等等]
  26.   DESCRIPTIONS = {
  27.     :炼金 => "可以合成药水!",
  28.     :缝纫 => "可以将多种材料缝合成衣物.",
  29.     :木匠 => "所有东西都可以变成木头."
  30.   }
  31. #合成类型的图标
  32.   CATEGORY_ICONS = [10,199,284,332,0,0,0]
  33. #角色等级图标
  34.   LEVEL_ICON = 117
  35. #合成等级提升需要的经验值, lvl 代表当前等级
  36.   XP_NEEDED_EQUATION = "100 * lvl"
  37. #是否可以合成多个物品
  38.   CRAFT_MULTIPLE = true
  39. #是否在菜单中添加合成指令
  40.   ENABLE_MENU_ACCESS = true
  41. #是否无法在菜单中合成 (只能查看配方,不能合成)
  42.   DISABLE_MENU_CRAFT = false
  43. #详细信息的文字大小, 文字越小,配方显示的越多
  44.   DETAIL_FONT_SIZE = 18
  45.   

  46. #以下选项禁用某些功能的显示。然而,就算不在配方中显示,改消耗的仍然会消耗

  47. #移除金钱消耗
  48.   DISABLE_GOLD_COST = false
  49. #移除成功率
  50.   DISABLE_SUCCESS = false
  51. #移除角色等级需求
  52.   DISABLE_PLAYER_LEVEL = false
  53. #移除合成等级需求和值槽
  54.   DISABLE_CRAFT_LEVEL = false
  55. #自动学会所有技能 (可以使用 forget_recipe 来在之后遗忘某些配方)
  56.   AUTO_LEARN_RECIPES = true


  57. #最有趣的 (读作: 最复杂的) 部分!
  58. #配方符号:
  59. #
  60. #产物, 类型 0 = 物品, 1 = 武器, 2 = 护甲
  61. # :result => [类型,id,数量]
  62. #
  63. #需要原料, 格式和产物一样.
  64. # :materials => [ [类型,id,数量,消耗?],[类型,id,数量] ... ],
  65. #
  66. #  以下为可选:
  67. # :gold_cost => 数量          - 消耗金钱, 可以是 0
  68. # :success => 几率           - 成功率
  69. # :success_gain => 几率      - 合成等级每级提升的合成成功率(等级越高,合成成功率越大)
  70. # :level => 数值               - 需要等级
  71. # :craft_level => 数值        - 需要合成等级
  72. # :category => :类型       - 合成类型 (:炼金, :缝纫, etc)
  73. # :multiple => false            - 是否允许多次合成
  74. # :xp => 数量                 - 每次合成获得的合成经验值
  75. # :xp_deprac => 数量          - 每有一个合成等级就减少的经验值
  76. # :pxp => 数量                - 每次合成角色获得经验值

  77. # 经验值获得公式最好如下设定:
  78. #  xp gain = xp - (current_level - recipe_level) * xp_deprac

  79.   RECIPES = {
  80.   0 => { :result => [0,1,1],
  81.          :materials => [[0,4,2]],
  82.          :gold_cost => 10,
  83.          :success => 95,
  84.          :success_gain => 1,
  85.          :level => 5,
  86.          :craft_level => 1,
  87.          :category => :炼金,
  88.          :xp => 50,
  89.          :xp_deprac => 15,},
  90.          
  91.   1 => { :result => [0,2,1],
  92.          :materials => [[1,4,1],[0,5,2,false]],
  93.          :gold_cost => 50,
  94.          :success => 90,
  95.          :success_gain => 2,
  96.          :level => 15,
  97.          :craft_level => 1,
  98.          :category => :炼金,
  99.          :xp => 150,
  100.          :xp_deprac => 20,},
  101.          
  102.   2 => { :result => [0,3,1],
  103.          :materials => [[0,4,1],[0,5,1],[0,6,2],[0,7,1],[0,8,1],[0,9,2]],
  104.          :gold_cost => 150,
  105.          :success => 85,
  106.          :success_gain => 3,
  107.          :level => 25,
  108.          :craft_level => 1,
  109.          :category => :炼金,
  110.          :xp => 250,
  111.          :xp_deprac => 25,},
  112.          
  113.   }

  114. end

  115. $crafting_category = :All
  116. class Recipe
  117.   attr_accessor :result
  118.   attr_accessor :materials
  119.   attr_accessor :known
  120.   attr_accessor :id
  121.   attr_accessor :gold_cost
  122.   attr_accessor :level
  123.   attr_accessor :category
  124.   attr_accessor :xp
  125.   def initialize(id,recipe_hash)
  126.     @id = id
  127.     @result = Material.new(recipe_hash[:result])
  128.     @materials = []
  129.     for item in recipe_hash[:materials]
  130.       @materials.push(Material.new(item))
  131.     end
  132.     @known = false
  133.     recipe_hash[:gold_cost] ? @gold_cost = recipe_hash[:gold_cost] : @gold_cost = 0
  134.     recipe_hash[:success] ? @rate = recipe_hash[:success] : @rate = 100
  135.     recipe_hash[:success_gain] ? @rated = recipe_hash[:success_gain] : @rated = 0
  136.     recipe_hash[:level] ? @level = recipe_hash[:level] : @level = 1
  137.     recipe_hash[:category] ? @category = recipe_hash[:category] : @category = CATEGORIES[0]
  138.     recipe_hash[:xp] ? @xp = recipe_hash[:xp] : @xp = 0
  139.     recipe_hash[:xp_deprac] ? @xpd = recipe_hash[:xp_deprac] : @xpd = 0
  140.     recipe_hash[:craft_level] ? @clevel = recipe_hash[:craft_level] : @clevel = 0
  141.     recipe_hash[:pxp] ? @pxp = recipe_hash[:pxp] : @pxp = 0
  142.     !recipe_hash[:multiple].nil? ? @mult = recipe_hash[:multiple] : @mult = true
  143.     @known = ADV_RECIPE::AUTO_LEARN_RECIPES
  144.   end
  145.   def name
  146.     return @result.item.name
  147.   end
  148.   def multiple?
  149.     @mult
  150.   end
  151.   def has_materials?
  152.     for item in @materials
  153.       return false unless $game_party.item_number(item.item) >= item.amount
  154.     end
  155.     return true
  156.   end
  157.   def has_gold?
  158.     $game_party.gold >= @gold_cost
  159.   end
  160.   def has_craft_level?
  161.     craft_level <= $game_party.craft_level_sym(@category)
  162.   end
  163.   def has_level?
  164.     @level <= $game_party.highest_level && has_craft_level?
  165.   end
  166.   def craftable?
  167.     has_gold? && has_materials? && has_level?
  168.   end
  169.   def craft_level
  170.     @clevel
  171.   end
  172.   def amount_craftable?
  173.     mat_amount = []
  174.     for item in @materials
  175.       mat_amount.push($game_party.item_number(item.item) / item.amount)
  176.     end
  177.     if @gold_cost > 0
  178.       return [$game_party.gold / @gold_cost,mat_amount.min].min
  179.     else
  180.       return mat_amount.min
  181.     end
  182.   end
  183.   def craft(fail = 0)
  184.     remove_materials
  185.     if fail < success_rate
  186.       return add_result
  187.     else
  188.       return nil
  189.     end
  190.   end
  191.   def remove_materials
  192.     for item in @materials
  193.       next unless item.consumed?
  194.       $game_party.gain_item(item.item,-item.amount)
  195.     end
  196.     $game_party.gain_gold(-@gold_cost)
  197.   end
  198.   def add_result
  199.     if ADV_RECIPE::USE_WA_RANDOMIZATION
  200.       item = $game_party.add_weapon(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Weapon)
  201.       item = $game_party.add_armor(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Armor)
  202.       item = $game_party.add_item(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Item)
  203.     else
  204.       $game_party.gain_item(@result.item,@result.amount)
  205.       item = @result.item
  206.     end
  207.     $game_party.gain_craft_exp(category_id, xp_gain)
  208.     $game_party.members.each do |actor|
  209.       actor.gain_exp(@pxp)
  210.     end
  211.     item
  212.   end
  213.   def category_id
  214.     ADV_RECIPE::CATEGORIES.index(@category)
  215.   end
  216.   def xp_gain
  217.     level_diff = $game_party.craft_level(category_id) - @clevel
  218.     [@xp - @xpd * level_diff,0].max
  219.   end
  220.   def success_rate
  221.     level_diff = $game_party.craft_level(category_id) - @clevel
  222.     [@rate + @rated * level_diff,100].min
  223.   end
  224. end

  225. class Material
  226.   attr_accessor :item
  227.   attr_accessor :amount
  228.   def initialize(mat)
  229.     @item = $data_items[mat[1]] if mat[0] == 0
  230.     @item = $data_weapons[mat[1]] if mat[0] == 1
  231.     @item = $data_armors[mat[1]] if mat[0] == 2
  232.     @amount = mat[2]
  233.     @consumed = mat[3].nil? ? true : mat[3]
  234.   end
  235.   def consumed?
  236.     @consumed
  237.   end
  238. end

  239. class Game_Party
  240.   alias recipe_init initialize
  241.   def initialize
  242.     recipe_init
  243.     @crafting_level = [1]*ADV_RECIPE::CATEGORIES.size
  244.     @craft_exp = [0]*ADV_RECIPE::CATEGORIES.size
  245.   end
  246.   def craft_level(id)
  247.     @crafting_level[id]
  248.   end
  249.   def craft_level_sym(sym)
  250.     @crafting_level[ADV_RECIPE::CATEGORIES.index(sym)]
  251.   end
  252.   def craft_exp(id)
  253.     @craft_exp[id]
  254.   end
  255.   def craft_exp_next(id)
  256.     lvl = craft_level(id)
  257.     return eval(ADV_RECIPE::XP_NEEDED_EQUATION)
  258.   end
  259.   def gain_craft_exp(id, val)
  260.     @craft_exp[id] += val
  261.     while craft_exp(id) >= craft_exp_next(id)
  262.       @craft_exp[id] -= craft_exp_next(id)
  263.       @crafting_level[id] += 1
  264.     end
  265.   end
  266. end

  267. module DataManager
  268.   class << self
  269.     alias rec_cgo create_game_objects
  270.     alias rec_msc make_save_contents
  271.     alias rec_esc extract_save_contents
  272.   end
  273.   def self.create_game_objects
  274.     rec_cgo
  275.     $game_recipes = create_recipes
  276.   end
  277.   def self.make_save_contents
  278.     contents = rec_msc
  279.     contents[:recipe] = $game_recipes
  280.     contents
  281.   end
  282.   def self.extract_save_contents(contents)
  283.     rec_esc(contents)
  284.     $game_recipes = contents[:recipe]
  285.   end
  286.   def self.create_recipes
  287.     recipes = {}
  288.     ADV_RECIPE::RECIPES.each_pair do |key, val|
  289.       recipes[key] = Recipe.new(key,val)
  290.     end
  291.     recipes
  292.   end
  293. end

  294. class Game_Interpreter
  295.   def learn_recipe(id)
  296.     return if $game_recipes[id].nil?
  297.     $game_recipes[id].known = true
  298.   end
  299.   def forget_recipe(id)
  300.     return if $game_recipes[id].nil?
  301.     $game_recipes[id].known = false
  302.   end
  303. end

  304. class Window_RecipeList < Window_Selectable
  305.   def initialize(x,y,w,h)
  306.     super
  307.     @data = $game_recipes.values.select {|recipe| include?(recipe)}
  308.     refresh
  309.   end
  310.   def item_max
  311.     @data ? @data.size : 1
  312.   end
  313.   def item
  314.     @data && index >= 0 ? @data[index] : nil
  315.   end
  316.   def current_item_enabled?
  317.     enable?(@data[index])
  318.   end
  319.   def include?(item)
  320.     return false unless item.has_craft_level?
  321.     return false unless item.known
  322.     return true if @category == :All
  323.     return @category == item.category
  324.   end
  325.   def set_category(cat)
  326.     return if cat == @category
  327.     @category = cat
  328.     @data = $game_recipes.values.select {|recipe| include?(recipe)}
  329.     refresh
  330.   end
  331.   def enable?(item)
  332.     return false if item.nil?
  333.     return false if $temp_disable_crafting
  334.     item.craftable?
  335.   end
  336.   def draw_item(index)
  337.     item = @data[index]
  338.     if item
  339.       rect = item_rect(index)
  340.       rect.width -= 4
  341.       enabled = $temp_disable_crafting ? true : enable?(item)
  342.       draw_item_name(item.result.item, rect.x, rect.y, enabled)
  343.       if item.amount_craftable? > 0
  344.         draw_text(rect.x,rect.y,contents.width,24,"x"+item.amount_craftable?.to_s,2)
  345.       end
  346.     end
  347.   end
  348.   def current_item
  349.     index >= 0 ? @data[index] : nil
  350.   end
  351.   def process_ok
  352.     if current_item_enabled?
  353.       Sound.play_ok
  354.       Input.update
  355.       call_ok_handler
  356.     else
  357.       Sound.play_buzzer
  358.     end
  359.   end
  360.   def refresh
  361.     create_contents
  362.     super
  363.   end
  364.   def content_heights
  365.     item_max * 24
  366.   end
  367. end

  368. class Window_RecipeDetail < Window_Base
  369.   def initialize(x,y,w,h)
  370.     super
  371.     @recipe = nil
  372.   end
  373.   def set_recipe(recipe)
  374.     @recipe = recipe
  375.     refresh
  376.   end
  377.   def refresh
  378.     contents.clear
  379.     contents.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
  380.     return if @recipe.nil?
  381.     draw_craft_level unless ADV_RECIPE::DISABLE_PLAYER_LEVEL && ADV_RECIPE::DISABLE_CRAFT_LEVEL
  382.     draw_materials
  383.     draw_success_rate unless ADV_RECIPE::DISABLE_SUCCESS
  384.     draw_gold_cost unless ADV_RECIPE::DISABLE_GOLD_COST
  385.   end
  386.   def draw_craft_level
  387.     change_color(system_color, @recipe.has_level?)
  388.     draw_text(0,0,contents.width,contents.font.size,"合成等级:")
  389.     change_color(normal_color, @recipe.has_level?)
  390.     xx = 0
  391.     if !ADV_RECIPE::DISABLE_PLAYER_LEVEL
  392.       draw_text(0,0,contents.width,contents.font.size,@recipe.level,2)
  393.       draw_icon(ADV_RECIPE::LEVEL_ICON,contents.width - 48,0)
  394.       xx += 48
  395.       text = @recipe.craft_level.to_s + "/"
  396.     else
  397.       text = @recipe.craft_level.to_s
  398.     end
  399.     if !ADV_RECIPE::DISABLE_CRAFT_LEVEL
  400.       draw_text(0,0,contents.width - xx,contents.font.size,text,2)
  401.       draw_icon(ADV_RECIPE::CATEGORY_ICONS[ADV_RECIPE::CATEGORIES.index(@recipe.category)],contents.width - 56 - xx,0)
  402.     end
  403.   end
  404.   def draw_materials
  405.     if ADV_RECIPE::DISABLE_CRAFT_LEVEL && ADV_RECIPE::DISABLE_PLAYER_LEVEL
  406.       yy = 0
  407.     else
  408.       yy = contents.font.size
  409.     end
  410.     change_color(system_color, @recipe.craftable?)
  411.     draw_text(0,yy,self.width,contents.font.size,"原料:")
  412.     yy += contents.font.size
  413.     for item in @recipe.materials
  414.       change_color(normal_color, $game_party.item_number(item.item) >= item.amount)
  415.       draw_icon(item.item.icon_index,0,yy)
  416.       draw_text(24,yy,self.width,contents.font.size,item.item.name)
  417.       string = $game_party.item_number(item.item).to_s + "/" + item.amount.to_s
  418.       draw_text(0,yy,self.contents.width,contents.font.size,string,2)
  419.       yy += contents.font.size
  420.     end
  421.   end
  422.   def draw_success_rate
  423.     change_color(system_color, @recipe.craftable?)
  424.     draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,"成功率:")
  425.     change_color(normal_color, @recipe.craftable?)
  426.     draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,@recipe.success_rate.to_s + "%",2)
  427.   end
  428.   def draw_gold_cost
  429.     if @recipe.gold_cost > 0
  430.       change_color(system_color, @recipe.has_gold?)
  431.       draw_text(0,contents.height-contents.font.size*2,contents.width,contents.font.size,"合成成本:")
  432.       change_color(normal_color, @recipe.has_gold?)
  433.       draw_currency_value(@recipe.gold_cost,Vocab::currency_unit,0,contents.height-contents.font.size*2,contents.width)
  434.     end  
  435.   end
  436.   def draw_currency_value(value, unit, x, y, width)
  437.     cx = text_size(unit).width
  438.     change_color(normal_color,$game_party.gold >= value)
  439.     draw_text(x, y, width - cx - 2, contents.font.size, value, 2)
  440.     change_color(system_color)
  441.     draw_text(x, y, width, contents.font.size, unit, 2)
  442.   end
  443. end

  444. class Window_RecipeConfirm < Window_Selectable
  445.   attr_accessor :amount
  446.   def initialize(x,y,w,h)
  447.     super
  448.     @amount = 1
  449.     refresh
  450.   end
  451.   def item_max; 1; end;
  452.   def enable?(item); true; end;
  453.   def refresh
  454.     super
  455.     draw_text(0,0,self.contents.width,line_height,"合成",1)
  456.     return unless @recipe && @recipe.craftable?
  457.     draw_text(0,0,contents.width,line_height,"x"+@amount.to_s,2)
  458.   end
  459.   def activate
  460.     super
  461.     select(0)
  462.   end
  463.   def deactivate
  464.     super
  465.     select(-1)
  466.   end
  467.   def set_recipe(rec)
  468.     return if rec == @recipe
  469.     @recipe = rec
  470.     @amount = 1
  471.     refresh
  472.   end
  473.   def cursor_movable?
  474.     active && open? && ADV_RECIPE::CRAFT_MULTIPLE && @recipe.multiple?
  475.   end
  476.   def cursor_down(wrap = false)
  477.     change_amount(-10)
  478.   end
  479.   def cursor_up(wrap = false)
  480.     change_amount(10)
  481.   end
  482.   def cursor_right(wrap = false)
  483.     change_amount(1)
  484.   end
  485.   def cursor_left(wrap = false)
  486.     change_amount(-1)
  487.   end
  488.   def change_amount(val)
  489.     Sound.play_cursor
  490.     @amount += val
  491.     @amount = [[@amount,1].max,@recipe.amount_craftable?].min
  492.     refresh
  493.   end
  494. end

  495. class Scene_CraftingAll < Scene_Base
  496.   def start
  497.     super
  498.     @help_window = Window_Help.new
  499.     width = Graphics.width / 2
  500.     height = Graphics.height - @help_window.height - 48
  501.     @list_window = Window_RecipeList.new(0,@help_window.height+48,width,height-48)
  502.     @list_window.set_handler(:ok, method(:list_success))
  503.     @list_window.set_handler(:cancel, method(:cancel))
  504.     @list_window.height += 48 if ADV_RECIPE::DISABLE_CRAFT_LEVEL
  505.     @list_window.create_contents
  506.     @detail_window = Window_RecipeDetail.new(width,@list_window.y,width,height-48*2)
  507.     @detail_window.height += 48 if ADV_RECIPE::DISABLE_GOLD_COST
  508.     @detail_window.create_contents
  509.     height = @detail_window.y + @detail_window.height
  510.     @confirm_window = Window_RecipeConfirm.new(width,height,width,48)
  511.     @confirm_window.set_handler(:ok, method(:craft_success))
  512.     @confirm_window.set_handler(:cancel, method(:confirm_cancel))
  513.     if !ADV_RECIPE::DISABLE_GOLD_COST
  514.       @gold_window = Window_Gold.new
  515.       @gold_window.width = width
  516.       @gold_window.y = Graphics.height - 48
  517.       @gold_window.x = width
  518.     end
  519.     @popup_window = Window_RecPopup.new
  520.     @popup_window.set_handler(:ok, method(:popup_ok))
  521.     @popup_window.set_handler(:cancel, method(:popup_ok))
  522.     @command_window = Window_RecCategory.new
  523.     @command_window.set_handler(:ok, method(:command_ok))
  524.     @command_window.set_handler(:cancel, method(:command_cancel))
  525.     @gauge_window = Window_RecGauge.new unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  526.   end
  527.   def popup_ok
  528.     @popup_window.deactivate
  529.     @popup_window.close
  530.     @list_window.activate
  531.   end
  532.   def update
  533.     super
  534.     @help_window.set_text(@list_window.current_item.result.item.description) if !@list_window.current_item.nil?
  535.     if @command_window.active
  536.       category = ADV_RECIPE::CATEGORIES[@command_window.index]
  537.       @help_window.set_text(ADV_RECIPE::DESCRIPTIONS[category])
  538.     end
  539.     @detail_window.set_recipe(@list_window.current_item)
  540.     @confirm_window.set_recipe(@list_window.current_item)
  541.     @list_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index])
  542.     @gauge_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index]) unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  543.     return unless @list_window.current_item
  544.     if @list_window.current_item.craftable?
  545.       @confirm_window.opacity = 255
  546.       @confirm_window.contents_opacity = 255
  547.     else
  548.       @confirm_window.opacity = 75
  549.       @confirm_window.contents_opacity = 75
  550.     end
  551.   end
  552.   def list_success
  553.     @list_window.deactivate
  554.     @confirm_window.activate
  555.   end
  556.   def craft_success
  557.     amount = 0
  558.     item = nil
  559.     @confirm_window.amount.times do
  560.       item2 = @list_window.current_item.craft(rand(100))
  561.       if item2
  562.         amount += 1
  563.         item = item2
  564.       end
  565.     end
  566.     if item
  567.       @popup_window.set_text(item, amount)
  568.     else
  569.       @popup_window.set_text_fail
  570.     end
  571.     @confirm_window.change_amount(-1000)
  572.     @gold_window.refresh unless ADV_RECIPE::DISABLE_GOLD_COST
  573.     @list_window.refresh
  574.     @gauge_window.refresh unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  575.     @popup_window.activate
  576.   end
  577.   def confirm_cancel
  578.     @confirm_window.deactivate
  579.     @list_window.activate
  580.   end
  581.   def command_cancel
  582.     $temp_disable_crafting = false
  583.     SceneManager.return
  584.   end
  585.   def cancel
  586.     @list_window.select(-1)
  587.     @help_window.set_text("")
  588.     @command_window.activate
  589.   end
  590.   def command_ok
  591.     @list_window.select(0)
  592.     @list_window.activate
  593.   end
  594. end

  595. class Scene_Crafting < Scene_CraftingAll
  596.   def start
  597.     super
  598.     @command_window.index = ADV_RECIPE::CATEGORIES.index($crafting_category)
  599.     @command_window.deactivate
  600.     @command_window.visible = false
  601.     @list_window.height += 48
  602.     @list_window.y -= 48
  603.     @detail_window.height += 48
  604.     @detail_window.y -= 48
  605.     @list_window.create_contents
  606.     @detail_window.create_contents
  607.     @list_window.select(0)
  608.     @list_window.activate
  609.   end
  610.   def cancel
  611.     SceneManager.return
  612.   end
  613. end

  614. class Window_RecCategory < Window_HorzCommand
  615.   def initialize
  616.     super(0,72)
  617.   end
  618.   def window_width; Graphics.width; end
  619.   def window_height; 48; end
  620.   def make_command_list
  621.     ADV_RECIPE::CATEGORIES.each do |command|
  622.       add_command(command.to_s,command)
  623.     end
  624.   end
  625.   def item_width
  626.     120
  627.   end
  628.   def draw_item(index)
  629.     change_color(normal_color, command_enabled?(index))
  630.     rect = item_rect_for_text(index)
  631.     draw_text(rect, command_name(index))
  632.     draw_icon(ADV_RECIPE::CATEGORY_ICONS[index],rect.x-24,rect.y)
  633.   end
  634.   def item_rect_for_text(index)
  635.     rect = item_rect(index)
  636.     rect.x += 28
  637.     rect.width -= 28
  638.     rect
  639.   end
  640. end

  641. class Window_RecPopup < Window_Selectable
  642.   def initialize
  643.     super(Graphics.width/2-window_width/2,Graphics.height/2-window_height/2,120,48)
  644.     self.openness = 0
  645.     deactivate
  646.   end
  647.   def window_width; 120; end
  648.   def window_height; 48; end
  649.   def set_text(item, amount)
  650.     contents.clear
  651.     text = amount.to_s + "x " + item.name + " 已被合成!"
  652.     width = contents.text_size(text).width
  653.     self.width = width + padding*2
  654.     self.x = Graphics.width/2-width/2
  655.     create_contents
  656.     draw_text(24,0,contents.width,line_height,text)
  657.     draw_icon(item.icon_index,0,0)
  658.     open
  659.   end
  660.   def set_text_fail
  661.     contents.clear
  662.     text = "合成失败!"
  663.     width = contents.text_size(text).width
  664.     self.width = width + padding*2
  665.     self.x = Graphics.width/2-width/2
  666.     create_contents
  667.     draw_text(12,0,contents.width,line_height,text)
  668.     open
  669.   end
  670.   def process_ok
  671.     if current_item_enabled?
  672.       Input.update
  673.       deactivate
  674.       call_ok_handler
  675.     else
  676.       Sound.play_buzzer
  677.     end
  678.   end
  679. end

  680. class Window_RecGauge < Window_Base
  681.   def initialize
  682.     super(0,Graphics.height-48,Graphics.width/2,48)
  683.     @category = :All
  684.   end
  685.   def refresh
  686.     contents.clear
  687.     return if @category == :All
  688.     draw_icon(ADV_RECIPE::CATEGORY_ICONS[cat_index],0,0)
  689.     draw_text(24,0,contents.width,24,$game_party.craft_level(cat_index))
  690.     rate = $game_party.craft_exp(cat_index).to_f / $game_party.craft_exp_next(cat_index)
  691.     draw_gauge(48, -3, contents.width-48, rate, tp_gauge_color1, tp_gauge_color2)
  692.     if Module.const_defined?(:SPECIAL_GAUGES)
  693.       @gauges[[48,-3]].set_extra("XP",$game_party.craft_exp(cat_index),$game_party.craft_exp_next(cat_index))
  694.     else
  695.       text = $game_party.craft_exp(cat_index).to_s+"/"+$game_party.craft_exp_next(cat_index).to_s
  696.       draw_text(0,0,contents.width,24,text,2)
  697.     end
  698.   end
  699.   def set_category(cat)
  700.     return if cat == @category
  701.     @category = cat
  702.     refresh
  703.   end
  704.   def cat_index
  705.     ADV_RECIPE::CATEGORIES.index(@category)
  706.   end
  707. end

  708. class Window_MenuCommand < Window_Command
  709.   alias recipe_aoc add_original_commands
  710.   def add_original_commands
  711.     recipe_aoc
  712.     add_command("合成", :recipe) if ADV_RECIPE::ENABLE_MENU_ACCESS
  713.   end
  714. end

  715. class Scene_Menu < Scene_MenuBase
  716.   alias recipe_create_command_window create_command_window
  717.   def create_command_window
  718.     recipe_create_command_window
  719.     @command_window.set_handler(:recipe,   method(:command_recipe))
  720.   end
  721.   def command_recipe
  722.     $temp_disable_crafting = ADV_RECIPE::DISABLE_MENU_CRAFT
  723.     SceneManager.call(Scene_CraftingAll)
  724.   end
  725. end
复制代码

点评

好吧,谢谢了 我试试这个  发表于 2020-11-24 18:00
回复

使用道具 举报

梦石
0
星屑
42345
在线时间
6022 小时
注册时间
2006-11-10
回帖
6975
发表于 2020-11-24 09:49:53 | 显示全部楼层
在一个随时可以SL的环境里搞几率有啥意义呢?

点评

除非学DQM强制存档、or 自动存档  发表于 2020-11-25 18:52
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部