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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
809
在线时间
176 小时
注册时间
2017-1-15
帖子
81
跳转到指定楼层
1
发表于 2020-11-23 22:37:22 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
50星屑
我看了下脚本,虽然是日文,但看上去好像没有设置成功率的地方……

RUBY 代码复制
  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.  
  19. i_recipe_switch_off(2)关闭2号物品配方
  20. a_recipe_switch_off(3)关闭3号防具配方
  21. w_recipe_switch_off(4)关闭4号武器配方
  22.  
  23. i_recipe_switch_on?(2)开启了2号物品配方?
  24. a_recipe_switch_on?(3)开启了3号防具配方?
  25. w_recipe_switch_on?(4)开启了4号武器配方?
  26.  
  27. i_recipe_all_switch_on 开启所有物品配方
  28. a_recipe_all_switch_on开启所有防具配方
  29. w_recipe_all_switch_on开启所有武器配方
  30.  
  31.  
  32.  
  33. recipe_all_switch_on开启所有配方
  34. recipe_all_switch_off 关闭所有配方
  35. =end
  36. #--------------------------------------------------------------------------
  37. # ★ 初期設定。
  38. #    合成レシピ等の設定
  39. #--------------------------------------------------------------------------
  40. module WD_itemsynthesis_ini
  41.  
  42.   Cost_view =  true #費用(G)の表示(合成の費用が全て0Gの場合はfalseを推奨)
  43.  
  44.   Category_i = true #カテゴリウィンドウに「アイテム」の項目を表示
  45.   Category_w = true #カテゴリウィンドウに「武器」の項目を表示
  46.   Category_a = true #カテゴリウィンドウに「防具」の項目を表示
  47.   Category_k = true #カテゴリウィンドウに「大事なもの」の項目を表示
  48.  
  49.   I_recipe = [] #この行は削除しないこと
  50.   W_recipe = [] #この行は削除しないこと
  51.   A_recipe = [] #この行は削除しないこと
  52.  
  53.   #以下、合成レシピ。
  54.   #例: I_recipe[3]  = [100, ["I",1,1], ["W",2,1], ["A",2,2], ["A",3,1]]
  55.   #と記載した場合、ID3のアイテムの合成必要は、100G。
  56.   #必要な素材は、ID1のアイテム1個、ID2の武器1個、ID2の防具2個、ID3の防具1個
  57.   #となる。
  58.  
  59.   #アイテムの合成レシピ
  60.   I_recipe[1]  = [300,  ["I",2,1],["I",3,1]]
  61.   I_recipe[20]  = [0,  ["I",19,1],["I",202,1],["I",204,1]]
  62.   #I_recipe[3]  = [100, ["I",1,1], ["I",2,1]]
  63.   #I_recipe[17] = [500, ["I",1,10]]
  64.  
  65.   #武器の合成レシピ
  66.   W_recipe[3]  = [50,   ["W",1,1], ["W",2,1]]
  67.   #W_recipe[6]  = [600,  ["W",3,1], ["I",17,0]]
  68.  
  69.   #防具の合成レシピ  
  70.   A_recipe[2]  = [40,   ["A",1,2]]
  71.   #A_recipe[5]  = [400,  ["A",2,1], ["W",2,2], ["I",17,0]]
  72.  
  73. end
  74.  
  75.  
  76. #==============================================================================
  77. # ■ WD_itemsynthesis
  78. #------------------------------------------------------------------------------
  79. #  アイテム合成用の共通メソッドです。
  80. #==============================================================================
  81.  
  82. module WD_itemsynthesis
  83.   def i_recipe_switch_on(id)
  84.     $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
  85.     $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
  86.     $game_system.i_rcp_sw[id] = true
  87.   end
  88.   def i_recipe_switch_off(id)
  89.     $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
  90.     $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
  91.     $game_system.i_rcp_sw[id] = false
  92.   end
  93.   def i_recipe_switch_on?(id)
  94.     $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
  95.     $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
  96.     return $game_system.i_rcp_sw[id]
  97.   end
  98.   def i_recipe_all_switch_on
  99.     for i in 1..$data_items.size
  100.       i_recipe_switch_on(i)
  101.     end
  102.   end
  103.   def i_recipe_all_switch_off
  104.     for i in 1..$data_items.size
  105.       i_recipe_switch_off(i)
  106.     end
  107.   end
  108.   def w_recipe_switch_on(id)
  109.     $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
  110.     $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
  111.     $game_system.w_rcp_sw[id] = true
  112.   end
  113.   def w_recipe_switch_off(id)
  114.     $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
  115.     $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
  116.     $game_system.w_rcp_sw[id] = false
  117.   end
  118.   def w_recipe_switch_on?(id)
  119.     $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
  120.     $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
  121.     return $game_system.w_rcp_sw[id]
  122.   end
  123.   def w_recipe_all_switch_on
  124.     for i in 1..$data_weapons.size
  125.       w_recipe_switch_on(i)
  126.     end
  127.   end
  128.   def w_recipe_all_switch_off
  129.     for i in 1..$data_weapons.size
  130.       w_recipe_switch_off(i)
  131.     end
  132.   end
  133.   def a_recipe_switch_on(id)
  134.     $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
  135.     $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
  136.     $game_system.a_rcp_sw[id] = true
  137.   end
  138.   def a_recipe_switch_off(id)
  139.     $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
  140.     $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
  141.     $game_system.a_rcp_sw[id] = false
  142.   end
  143.   def a_recipe_switch_on?(id)
  144.     $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
  145.     $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
  146.     return $game_system.a_rcp_sw[id]
  147.   end
  148.   def a_recipe_all_switch_on
  149.     for i in 1..$data_armors.size
  150.       a_recipe_switch_on(i)
  151.     end
  152.   end
  153.   def a_recipe_all_switch_off
  154.     for i in 1..$data_armors.size
  155.       a_recipe_switch_off(i)
  156.     end
  157.   end
  158.   def recipe_all_switch_on
  159.     i_recipe_all_switch_on
  160.     w_recipe_all_switch_on
  161.     a_recipe_all_switch_on
  162.   end
  163.   def recipe_all_switch_off
  164.     i_recipe_all_switch_off
  165.     w_recipe_all_switch_off
  166.     a_recipe_all_switch_off
  167.   end
  168.  
  169. end
  170.  
  171. class Game_Interpreter
  172.   include WD_itemsynthesis
  173. end
  174.  
  175. class Game_System
  176.   #--------------------------------------------------------------------------
  177.   # ● 公開インスタンス変数
  178.   #--------------------------------------------------------------------------
  179.   attr_accessor :i_rcp_sw
  180.   attr_accessor :w_rcp_sw
  181.   attr_accessor :a_rcp_sw
  182.   #--------------------------------------------------------------------------
  183.   # ● オブジェクト初期化
  184.   #--------------------------------------------------------------------------
  185.   alias wd_orig_initialize004 initialize
  186.   def initialize
  187.     wd_orig_initialize004
  188.     @i_rcp_sw = []
  189.     @w_rcp_sw = []
  190.     @a_rcp_sw = []
  191.   end
  192. end
  193.  
  194.  
  195. #==============================================================================
  196. # ■ Scene_ItemSynthesis
  197. #------------------------------------------------------------------------------
  198. #  合成画面の処理を行うクラスです。
  199. #==============================================================================
  200.  
  201. class Scene_ItemSynthesis < Scene_MenuBase
  202.   #--------------------------------------------------------------------------
  203.   # ● 開始処理
  204.   #--------------------------------------------------------------------------
  205.   def start
  206.     super
  207.     create_help_window
  208.     create_dummy_window
  209.     create_number_window
  210.     create_status_window
  211.     create_material_window
  212.     create_list_window
  213.     create_category_window
  214.     create_gold_window
  215.     create_change_window
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● ゴールドウィンドウの作成
  219.   #--------------------------------------------------------------------------
  220.   def create_gold_window
  221.     @gold_window = Window_Gold.new
  222.     @gold_window.viewport = @viewport
  223.     @gold_window.x = Graphics.width - @gold_window.width
  224.     @gold_window.y = @help_window.height
  225.     @gold_window.hide
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ● 切り替え表示ウィンドウの作成
  229.   #--------------------------------------------------------------------------
  230.   def create_change_window
  231.     wx = 0
  232.     wy = @gold_window.y
  233.     ww = Graphics.width - @gold_window.width
  234.     wh = @gold_window.height
  235.     @change_window = Window_ItemSynthesisChange.new(wx, wy, ww, wh)
  236.     @change_window.viewport = @viewport
  237.     @change_window.hide
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ● ダミーウィンドウの作成
  241.   #--------------------------------------------------------------------------
  242.   def create_dummy_window
  243.     wy = @help_window.y + @help_window.height + 48
  244.     wh = Graphics.height - wy
  245.     @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
  246.     @dummy_window.viewport = @viewport
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● 個数入力ウィンドウの作成
  250.   #--------------------------------------------------------------------------
  251.   def create_number_window
  252.     wy = @dummy_window.y
  253.     wh = @dummy_window.height
  254.     @number_window = Window_ItemSynthesisNumber.new(0, wy, wh)
  255.     @number_window.viewport = @viewport
  256.     @number_window.hide
  257.     @number_window.set_handler(:ok,     method(:on_number_ok))
  258.     @number_window.set_handler(:cancel, method(:on_number_cancel))
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ● ステータスウィンドウの作成
  262.   #--------------------------------------------------------------------------
  263.   def create_status_window
  264.     wx = @number_window.width
  265.     wy = @dummy_window.y
  266.     ww = Graphics.width - wx
  267.     wh = @dummy_window.height
  268.     @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
  269.     @status_window.viewport = @viewport
  270.     @status_window.hide
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ● 素材ウィンドウの作成
  274.   #--------------------------------------------------------------------------
  275.   def create_material_window
  276.     wx = @number_window.width
  277.     wy = @dummy_window.y
  278.     ww = Graphics.width - wx
  279.     wh = @dummy_window.height
  280.     @material_window = Window_ItemSynthesisMaterial.new(wx, wy, ww, wh)
  281.     @material_window.viewport = @viewport
  282.     @material_window.hide
  283.     @number_window.material_window = @material_window
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● 合成アイテムリストウィンドウの作成
  287.   #--------------------------------------------------------------------------
  288.   def create_list_window
  289.     wy = @dummy_window.y
  290.     wh = @dummy_window.height
  291.     @list_window = Window_ItemSynthesisList.new(0, wy, wh)
  292.     @list_window.viewport = @viewport
  293.     @list_window.help_window = @help_window
  294.     @list_window.status_window = @status_window
  295.     @list_window.material_window = @material_window
  296.     @list_window.hide
  297.     @list_window.set_handler(:ok,     method(:on_list_ok))
  298.     @list_window.set_handler(:cancel, method(:on_list_cancel))
  299.     @list_window.set_handler(:change_window, method(:on_change_window))   
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● カテゴリウィンドウの作成
  303.   #--------------------------------------------------------------------------
  304.   def create_category_window
  305.     @category_window = Window_ItemSynthesisCategory.new
  306.     @category_window.viewport = @viewport
  307.     @category_window.help_window = @help_window
  308.     @category_window.y = @help_window.height
  309.     @category_window.activate
  310.     @category_window.item_window = @list_window
  311.     @category_window.set_handler(:ok,     method(:on_category_ok))
  312.     @category_window.set_handler(:cancel, method(:return_scene))
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ● 合成アイテムリストウィンドウのアクティブ化
  316.   #--------------------------------------------------------------------------
  317.   def activate_list_window
  318.     @list_window.money = money
  319.     @list_window.show.activate
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● 合成[決定]
  323.   #--------------------------------------------------------------------------
  324.   def on_list_ok
  325.     @item = @list_window.item
  326.     @list_window.hide
  327.     @number_window.set(@item, max_buy, buying_price, currency_unit)
  328.     @number_window.show.activate
  329.   end
  330.   #--------------------------------------------------------------------------
  331.   # ● 合成[キャンセル]
  332.   #--------------------------------------------------------------------------
  333.   def on_list_cancel
  334.     @category_window.activate
  335.     @category_window.show
  336.     @dummy_window.show
  337.     @list_window.hide
  338.     @status_window.hide
  339.     @status_window.item = nil
  340.     @material_window.hide
  341.     @material_window.set(nil, nil)
  342.     @gold_window.hide
  343.     @change_window.hide
  344.     @help_window.clear
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 表示切替
  348.   #--------------------------------------------------------------------------
  349.   def on_change_window
  350.     if @status_window.visible
  351.       @status_window.hide
  352.       @material_window.show
  353.     else
  354.       @status_window.show
  355.       @material_window.hide
  356.     end
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● カテゴリ[決定]
  360.   #--------------------------------------------------------------------------
  361.   def on_category_ok
  362.     activate_list_window
  363.     @gold_window.show
  364.     @change_window.show
  365.     @material_window.show
  366.     @category_window.hide
  367.     @list_window.select(0)
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● 個数入力[決定]
  371.   #--------------------------------------------------------------------------
  372.   def on_number_ok
  373.     Sound.play_shop
  374.     do_syntetic(@number_window.number)
  375.     end_number_input
  376.     @gold_window.refresh
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● 個数入力[キャンセル]
  380.   #--------------------------------------------------------------------------
  381.   def on_number_cancel
  382.     Sound.play_cancel
  383.     end_number_input
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # ● 合成の実行
  387.   #--------------------------------------------------------------------------
  388.   def do_syntetic(number)
  389.     $game_party.lose_gold(number * buying_price)
  390.     $game_party.gain_item(@item, number)
  391.  
  392.       @recipe = @list_window.recipe(@item)
  393.       for i in 1...@recipe.size
  394.         kind = @recipe[i][0]
  395.         id   = @recipe[i][1]
  396.         num  = @recipe[i][2]
  397.         if kind == "I"
  398.           item = $data_items[id]
  399.         elsif kind == "W"
  400.           item = $data_weapons[id]
  401.         elsif kind == "A"
  402.           item = $data_armors[id]
  403.         end
  404.         $game_party.lose_item(item, num*number)
  405.       end
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # ● 個数入力の終了
  409.   #--------------------------------------------------------------------------
  410.   def end_number_input
  411.     @number_window.hide
  412.     activate_list_window
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 最大購入可能個数の取得
  416.   #--------------------------------------------------------------------------
  417.   def max_buy
  418.     max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
  419.  
  420.     @recipe = @list_window.recipe(@item)
  421.       for i in 1...@recipe.size
  422.         kind = @recipe[i][0]
  423.         id   = @recipe[i][1]
  424.         num  = @recipe[i][2]
  425.         if kind == "I"
  426.           item = $data_items[id]
  427.         elsif kind == "W"
  428.           item = $data_weapons[id]
  429.         elsif kind == "A"
  430.           item = $data_armors[id]
  431.         end
  432.         if num > 0
  433.           max_buf = $game_party.item_number(item)/num
  434.         else
  435.           max_buf = 999
  436.         end
  437.         max = [max, max_buf].min
  438.       end
  439.  
  440.     buying_price == 0 ? max : [max, money / buying_price].min
  441.  
  442.   end
  443. #--------------------------------------------------------------------------
  444.   # ● 所持金の取得
  445.   #--------------------------------------------------------------------------
  446.   def money
  447.     @gold_window.value
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● 通貨単位の取得
  451.   #--------------------------------------------------------------------------
  452.   def currency_unit
  453.     @gold_window.currency_unit
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● 合成費用の取得
  457.   #--------------------------------------------------------------------------
  458.   def buying_price
  459.     @list_window.price(@item)
  460.   end
  461. end
  462.  
  463.  
  464. #==============================================================================
  465. # ■ Window_ItemSynthesisList
  466. #------------------------------------------------------------------------------
  467. #  合成画面で、合成可能なアイテムの一覧を表示するウィンドウです。
  468. #==============================================================================
  469.  
  470. class Window_ItemSynthesisList < Window_Selectable
  471.   include WD_itemsynthesis
  472.   #--------------------------------------------------------------------------
  473.   # ● 公開インスタンス変数
  474.   #--------------------------------------------------------------------------
  475.   attr_reader   :status_window            # ステータスウィンドウ
  476.   #--------------------------------------------------------------------------
  477.   # ● オブジェクト初期化
  478.   #--------------------------------------------------------------------------
  479.   def initialize(x, y, height)
  480.     super(x, y, window_width, height)
  481.  
  482.     @shop_goods = []
  483.     @shop_recipes = []
  484.  
  485.     for i in 1..WD_itemsynthesis_ini::I_recipe.size
  486.       recipe = WD_itemsynthesis_ini::I_recipe[i]
  487.       if recipe
  488.         good = [0, i, recipe[0]]
  489.         if i_recipe_switch_on?(i)
  490.           @shop_goods.push(good)
  491.           @shop_recipes.push(recipe)
  492.         end
  493.       end
  494.     end
  495.     for i in 1..WD_itemsynthesis_ini::W_recipe.size
  496.       recipe = WD_itemsynthesis_ini::W_recipe[i]
  497.       if recipe
  498.         good = [1, i, recipe[0]]
  499.         if w_recipe_switch_on?(i)
  500.           @shop_goods.push(good)
  501.           @shop_recipes.push(recipe)
  502.         end
  503.       end
  504.     end
  505.     for i in 1..WD_itemsynthesis_ini::A_recipe.size
  506.       recipe = WD_itemsynthesis_ini::A_recipe[i]
  507.       if recipe
  508.         good = [2, i, recipe[0]]
  509.         if a_recipe_switch_on?(i)
  510.           @shop_goods.push(good)
  511.           @shop_recipes.push(recipe)
  512.         end
  513.       end
  514.     end
  515.  
  516.     @money = 0
  517.     refresh
  518.     select(0)
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ● ウィンドウ幅の取得
  522.   #--------------------------------------------------------------------------
  523.   def window_width
  524.     return 304
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 項目数の取得
  528.   #--------------------------------------------------------------------------
  529.   def item_max
  530.     @data ? @data.size : 1
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ● アイテムの取得
  534.   #--------------------------------------------------------------------------
  535.   def item
  536.     @data[index]
  537.   end
  538.   #--------------------------------------------------------------------------
  539.   # ● 所持金の設定
  540.   #--------------------------------------------------------------------------
  541.   def money=(money)
  542.     @money = money
  543.     refresh
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # ● 選択項目の有効状態を取得
  547.   #--------------------------------------------------------------------------
  548.   def current_item_enabled?
  549.     enable?(@data[index])
  550.   end
  551.   #--------------------------------------------------------------------------
  552.   # ● 合成費用を取得
  553.   #--------------------------------------------------------------------------
  554.   def price(item)
  555.     @price[item]
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # ● 合成可否を取得
  559.   #--------------------------------------------------------------------------
  560.   def enable?(item)
  561.     @makable[item]
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # ● レシピを取得
  565.   #--------------------------------------------------------------------------
  566.   def recipe(item)
  567.     @recipe[item]
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # ● アイテムを許可状態で表示するかどうか
  571.   #--------------------------------------------------------------------------
  572.   def have_mat?(recipe)
  573.     flag = true
  574.     if @money >= recipe[0]
  575.       for i in 1...recipe.size
  576.         kind = recipe[i][0]
  577.         id   = recipe[i][1]
  578.         num  = recipe[i][2]
  579.         if kind == "I"
  580.           item = $data_items[id]
  581.         elsif kind == "W"
  582.           item = $data_weapons[id]
  583.         elsif kind == "A"
  584.           item = $data_armors[id]
  585.         end
  586.         if $game_party.item_number(item) < [num, 1].max
  587.           flag = false
  588.         end
  589.       end
  590.     else
  591.       flag = false
  592.     end
  593.     return flag
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● カテゴリの設定
  597.   #--------------------------------------------------------------------------
  598.   def category=(category)
  599.     return if @category == category
  600.     @category = category
  601.     refresh
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # ● リフレッシュ
  605.   #--------------------------------------------------------------------------
  606.   def refresh
  607.     make_item_list
  608.     create_contents
  609.     draw_all_items
  610.   end
  611.   #--------------------------------------------------------------------------
  612.   # ● アイテムをリストに含めるかどうか
  613.   #--------------------------------------------------------------------------
  614.   def include?(item)
  615.     case @category
  616.     when :item
  617.       item.is_a?(RPG::Item) && !item.key_item?
  618.     when :weapon
  619.       item.is_a?(RPG::Weapon)
  620.     when :armor
  621.       item.is_a?(RPG::Armor)
  622.     when :key_item
  623.       item.is_a?(RPG::Item) && item.key_item?
  624.     else
  625.       false
  626.     end
  627.   end
  628.   #--------------------------------------------------------------------------
  629.   # ● アイテムリストの作成
  630.   #--------------------------------------------------------------------------
  631.   def make_item_list
  632.     @data = []
  633.     @price = {}
  634.     @makable = {}
  635.     @recipe = {}
  636.     for i in 0...@shop_goods.size
  637.       goods = @shop_goods[i]
  638.       recipe = @shop_recipes[i]
  639.       case goods[0]
  640.       when 0;  item = $data_items[goods[1]]
  641.       when 1;  item = $data_weapons[goods[1]]
  642.       when 2;  item = $data_armors[goods[1]]
  643.       end
  644.       if item
  645.         if include?(item)
  646.           @data.push(item)
  647.           @price[item] = goods[2]
  648.           @makable[item] = have_mat?(recipe)
  649.           @recipe[item] = recipe
  650.         end
  651.       end
  652.     end
  653.   end
  654.   #--------------------------------------------------------------------------
  655.   # ● 項目の描画
  656.   #--------------------------------------------------------------------------
  657.   def draw_item(index)
  658.     item = @data[index]
  659.     rect = item_rect(index)
  660.     draw_item_name(item, rect.x, rect.y, enable?(item))
  661.     rect.width -= 4
  662.     draw_text(rect, price(item), 2)  if WD_itemsynthesis_ini::Cost_view
  663.   end
  664.   #--------------------------------------------------------------------------
  665.   # ● ステータスウィンドウの設定
  666.   #--------------------------------------------------------------------------
  667.   def status_window=(status_window)
  668.     @status_window = status_window
  669.     call_update_help
  670.   end
  671.   #--------------------------------------------------------------------------
  672.   # ● 素材ウィンドウの設定
  673.   #--------------------------------------------------------------------------
  674.   def material_window=(material_window)
  675.     @material_window = material_window
  676.     call_update_help
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # ● ヘルプテキスト更新
  680.   #--------------------------------------------------------------------------
  681.   def update_help
  682.     @help_window.set_item(item) if @help_window
  683.     @status_window.item = item if @status_window
  684.     @material_window.set(item, recipe(item)) if @material_window
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # ● ←→ ボタン(表示切替)が押されたときの処理
  688.   #--------------------------------------------------------------------------
  689.   def process_change_window
  690.     Sound.play_cursor
  691.     Input.update
  692.     call_handler(:change_window)
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # ● 決定やキャンセルなどのハンドリング処理
  696.   #--------------------------------------------------------------------------
  697.   def process_handling
  698.     super
  699.     if active
  700.       return process_change_window if handle?(:change_window) && Input.trigger?(:X)
  701.       return process_change_window if handle?(:change_window) && Input.trigger?(:Y)
  702.     end
  703.   end
  704. end
  705.  
  706.  
  707. #==============================================================================
  708. # ■ Window_ItemSynthesisMaterial
  709. #------------------------------------------------------------------------------
  710. #  合成画面で、合成に必要な素材を表示するウィンドウです。
  711. #==============================================================================
  712.  
  713. class Window_ItemSynthesisMaterial < Window_Base
  714.   #--------------------------------------------------------------------------
  715.   # ● オブジェクト初期化
  716.   #--------------------------------------------------------------------------
  717.   def initialize(x, y, width, height)
  718.     super(x, y, width, height)
  719.     @item = nil
  720.     refresh
  721.   end
  722.   #--------------------------------------------------------------------------
  723.   # ● リフレッシュ
  724.   #--------------------------------------------------------------------------
  725.   def refresh
  726.     contents.clear
  727.     draw_possession(4, 0)
  728.     draw_material_info(0, line_height * 2)
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # ● アイテムの設定
  732.   #--------------------------------------------------------------------------
  733.   def set(item, recipe)
  734.     @item = item
  735.     @recipe = recipe
  736.     @make_number = 1
  737.     refresh
  738.   end
  739.   #--------------------------------------------------------------------------
  740.   # ● 作成個数の設定
  741.   #--------------------------------------------------------------------------
  742.   def set_num(make_number)
  743.     @make_number = make_number
  744.     refresh
  745.   end
  746.   #--------------------------------------------------------------------------
  747.   # ● 所持数の描画
  748.   #--------------------------------------------------------------------------
  749.   def draw_possession(x, y)
  750.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  751.     change_color(system_color)
  752.     draw_text(rect, Vocab::Possession)
  753.     change_color(normal_color)
  754.     draw_text(rect, $game_party.item_number(@item), 2)
  755.   end
  756.   #--------------------------------------------------------------------------
  757.   # ● 素材情報の描画
  758.   #--------------------------------------------------------------------------
  759.   def draw_material_info(x, y)
  760.     rect = Rect.new(x, y, contents.width, line_height)
  761.     change_color(system_color)
  762.     contents.font.size = 18
  763.     draw_text(rect, "必要素材", 0)
  764.     if @recipe
  765.       for i in 1...@recipe.size
  766.         kind = @recipe[i][0]
  767.         id   = @recipe[i][1]
  768.         num  = @recipe[i][2]
  769.         if kind == "I"
  770.           item = $data_items[id]
  771.         elsif kind == "W"
  772.           item = $data_weapons[id]
  773.         elsif kind == "A"
  774.           item = $data_armors[id]
  775.         end
  776.         rect = Rect.new(x, y + line_height*i, contents.width, line_height)
  777.         enabled = true
  778.         enabled = false if [num*@make_number, 1].max  > $game_party.item_number(item)
  779.         draw_item_name(item, rect.x, rect.y, enabled)
  780.         change_color(normal_color, enabled)
  781.         if num > 0
  782.           draw_text(rect, "#{num*@make_number}/#{$game_party.item_number(item)}", 2)
  783.         end
  784.       end
  785.     end
  786.     change_color(normal_color)
  787.     contents.font.size = 24
  788.   end
  789. end
  790.  
  791.  
  792. #==============================================================================
  793. # ■ Window_ItemSynthesisNumber
  794. #------------------------------------------------------------------------------
  795. #  合成画面で、合成するアイテムの個数を入力するウィンドウです。
  796. #==============================================================================
  797.  
  798. class Window_ItemSynthesisNumber < Window_ShopNumber
  799.   #--------------------------------------------------------------------------
  800.   # ● リフレッシュ
  801.   #--------------------------------------------------------------------------
  802.   def refresh
  803.     contents.clear
  804.     draw_item_name(@item, 0, item_y)
  805.     draw_number
  806.     draw_total_price if WD_itemsynthesis_ini::Cost_view
  807.   end
  808.   #--------------------------------------------------------------------------
  809.   # ● オブジェクト初期化
  810.   #--------------------------------------------------------------------------
  811.   def material_window=(material_window)
  812.     @material_window = material_window
  813.     call_update_help
  814.   end
  815.   #--------------------------------------------------------------------------
  816.   # ● 作成個数の変更
  817.   #--------------------------------------------------------------------------
  818.   def change_number(amount)
  819.     @number = [[@number + amount, @max].min, 1].max
  820.     call_update_help #追加
  821.   end
  822.   #--------------------------------------------------------------------------
  823.   # ● ヘルプテキスト更新
  824.   #--------------------------------------------------------------------------
  825.   def call_update_help
  826.     @material_window.set_num(@number) if @material_window
  827.   end
  828. end
  829.  
  830.  
  831. #==============================================================================
  832. # ■ Window_ItemSynthesisCategory
  833. #------------------------------------------------------------------------------
  834. #  合成画面で、通常アイテムや装備品の分類を選択するウィンドウです。
  835. #==============================================================================
  836.  
  837. class Window_ItemSynthesisCategory < Window_ItemCategory
  838.   #--------------------------------------------------------------------------
  839.   # ● 桁数の取得
  840.   #--------------------------------------------------------------------------
  841.   def col_max
  842.     i = 0
  843.     i += 1 if WD_itemsynthesis_ini::Category_i
  844.     i += 1 if WD_itemsynthesis_ini::Category_w
  845.     i += 1 if WD_itemsynthesis_ini::Category_a
  846.     i += 1 if WD_itemsynthesis_ini::Category_k
  847.     return i
  848.   end
  849.   #--------------------------------------------------------------------------
  850.   # ● コマンドリストの作成
  851.   #--------------------------------------------------------------------------
  852.   def make_command_list
  853.     add_command(Vocab::item,     :item)     if WD_itemsynthesis_ini::Category_i
  854.     add_command(Vocab::weapon,   :weapon)   if WD_itemsynthesis_ini::Category_w
  855.     add_command(Vocab::armor,    :armor)    if WD_itemsynthesis_ini::Category_a
  856.     add_command(Vocab::key_item, :key_item) if WD_itemsynthesis_ini::Category_k
  857.   end
  858. end
  859.  
  860.  
  861. #==============================================================================
  862. # ■ Window_ItemSynthesisNumber
  863. #------------------------------------------------------------------------------
  864. #  合成画面で、切替を表示するウィンドウです。
  865. #==============================================================================
  866.  
  867. class Window_ItemSynthesisChange < Window_Base
  868.   #--------------------------------------------------------------------------
  869.   # ● オブジェクト初期化
  870.   #--------------------------------------------------------------------------
  871.   def initialize(x, y, width, height)
  872.     super(x, y, width, height)
  873.     refresh
  874.   end
  875.   #--------------------------------------------------------------------------
  876.   # ● リフレッシュ
  877.   #--------------------------------------------------------------------------
  878.   def refresh
  879.     contents.clear
  880.     text = "X Y:表示切换"
  881.     draw_text(0, 0, contents_width, line_height, text, 1)
  882.   end
  883. end

最佳答案

查看完整内容

不可以,除非有好心人/砸RMB找人修改脚本 或许可以考慮換別个脚本,比如Vlue的高级配方合成 https://forums.rpgmakerweb.com/index.php?threads/advanced-recipe-crafting.27108/ #高级配方合成 v1.2 #----------# #功能: 高级配方合成! # #使用方法: 使用脚本 # $crafting_category = :craft - 在呼出场景前使用, :craft 替换为合成类型 # SceneManager.call(Scene_Crafting) - 打开合成菜单 # ...

Lv5.捕梦者

梦石
0
星屑
24252
在线时间
5036 小时
注册时间
2016-3-8
帖子
1618
2
发表于 2020-11-23 22:37:23 | 只看该作者
本帖最后由 alexncf125 于 2020-11-23 23:12 编辑
白の魔的物品合成脚本可以设置成功率吗?

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

或许可以考慮換別个脚本,比如Vlue的高级配方合成
https://forums.rpgmakerweb.com/i ... ipe-crafting.27108/

RUBY 代码复制
  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: [email protected]
  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.  
  22. module ADV_RECIPE
  23. #合成出的武器/护甲是否随机化(需要脚本WA_RANDOMIZATION)
  24.   USE_WA_RANDOMIZATION = false
  25. #合成菜单中合成类型的显示顺序 , 使用:All 代表所有类型
  26.   CATEGORIES = [:炼金,:锻造,:缝纫,:炼甲,:木匠,:建造,:等等]
  27.   DESCRIPTIONS = {
  28.     :炼金 => "可以合成药水!",
  29.     :缝纫 => "可以将多种材料缝合成衣物.",
  30.     :木匠 => "所有东西都可以变成木头."
  31.   }
  32. #合成类型的图标
  33.   CATEGORY_ICONS = [10,199,284,332,0,0,0]
  34. #角色等级图标
  35.   LEVEL_ICON = 117
  36. #合成等级提升需要的经验值, lvl 代表当前等级
  37.   XP_NEEDED_EQUATION = "100 * lvl"
  38. #是否可以合成多个物品
  39.   CRAFT_MULTIPLE = true
  40. #是否在菜单中添加合成指令
  41.   ENABLE_MENU_ACCESS = true
  42. #是否无法在菜单中合成 (只能查看配方,不能合成)
  43.   DISABLE_MENU_CRAFT = false
  44. #详细信息的文字大小, 文字越小,配方显示的越多
  45.   DETAIL_FONT_SIZE = 18
  46.  
  47.  
  48. #以下选项禁用某些功能的显示。然而,就算不在配方中显示,改消耗的仍然会消耗
  49.  
  50. #移除金钱消耗
  51.   DISABLE_GOLD_COST = false
  52. #移除成功率
  53.   DISABLE_SUCCESS = false
  54. #移除角色等级需求
  55.   DISABLE_PLAYER_LEVEL = false
  56. #移除合成等级需求和值槽
  57.   DISABLE_CRAFT_LEVEL = false
  58. #自动学会所有技能 (可以使用 forget_recipe 来在之后遗忘某些配方)
  59.   AUTO_LEARN_RECIPES = true
  60.  
  61.  
  62. #最有趣的 (读作: 最复杂的) 部分!
  63. #配方符号:
  64. #
  65. #产物, 类型 0 = 物品, 1 = 武器, 2 = 护甲
  66. # :result => [类型,id,数量]
  67. #
  68. #需要原料, 格式和产物一样.
  69. # :materials => [ [类型,id,数量,消耗?],[类型,id,数量] ... ],
  70. #
  71. #  以下为可选:
  72. # :gold_cost => 数量          - 消耗金钱, 可以是 0
  73. # :success => 几率           - 成功率
  74. # :success_gain => 几率      - 合成等级每级提升的合成成功率(等级越高,合成成功率越大)
  75. # :level => 数值               - 需要等级
  76. # :craft_level => 数值        - 需要合成等级
  77. # :category => :类型       - 合成类型 (:炼金, :缝纫, etc)
  78. # :multiple => false            - 是否允许多次合成
  79. # :xp => 数量                 - 每次合成获得的合成经验值
  80. # :xp_deprac => 数量          - 每有一个合成等级就减少的经验值
  81. # :pxp => 数量                - 每次合成角色获得经验值
  82.  
  83. # 经验值获得公式最好如下设定:
  84. #  xp gain = xp - (current_level - recipe_level) * xp_deprac
  85.  
  86.   RECIPES = {
  87.   0 => { :result => [0,1,1],
  88.          :materials => [[0,4,2]],
  89.          :gold_cost => 10,
  90.          :success => 95,
  91.          :success_gain => 1,
  92.          :level => 5,
  93.          :craft_level => 1,
  94.          :category => :炼金,
  95.          :xp => 50,
  96.          :xp_deprac => 15,},
  97.  
  98.   1 => { :result => [0,2,1],
  99.          :materials => [[1,4,1],[0,5,2,false]],
  100.          :gold_cost => 50,
  101.          :success => 90,
  102.          :success_gain => 2,
  103.          :level => 15,
  104.          :craft_level => 1,
  105.          :category => :炼金,
  106.          :xp => 150,
  107.          :xp_deprac => 20,},
  108.  
  109.   2 => { :result => [0,3,1],
  110.          :materials => [[0,4,1],[0,5,1],[0,6,2],[0,7,1],[0,8,1],[0,9,2]],
  111.          :gold_cost => 150,
  112.          :success => 85,
  113.          :success_gain => 3,
  114.          :level => 25,
  115.          :craft_level => 1,
  116.          :category => :炼金,
  117.          :xp => 250,
  118.          :xp_deprac => 25,},
  119.  
  120.   }
  121.  
  122. end
  123.  
  124. $crafting_category = :All
  125. class Recipe
  126.   attr_accessor :result
  127.   attr_accessor :materials
  128.   attr_accessor :known
  129.   attr_accessor :id
  130.   attr_accessor :gold_cost
  131.   attr_accessor :level
  132.   attr_accessor :category
  133.   attr_accessor :xp
  134.   def initialize(id,recipe_hash)
  135.     @id = id
  136.     @result = Material.new(recipe_hash[:result])
  137.     @materials = []
  138.     for item in recipe_hash[:materials]
  139.       @materials.push(Material.new(item))
  140.     end
  141.     @known = false
  142.     recipe_hash[:gold_cost] ? @gold_cost = recipe_hash[:gold_cost] : @gold_cost = 0
  143.     recipe_hash[:success] ? @rate = recipe_hash[:success] : @rate = 100
  144.     recipe_hash[:success_gain] ? @rated = recipe_hash[:success_gain] : @rated = 0
  145.     recipe_hash[:level] ? @level = recipe_hash[:level] : @level = 1
  146.     recipe_hash[:category] ? @category = recipe_hash[:category] : @category = CATEGORIES[0]
  147.     recipe_hash[:xp] ? @xp = recipe_hash[:xp] : @xp = 0
  148.     recipe_hash[:xp_deprac] ? @xpd = recipe_hash[:xp_deprac] : @xpd = 0
  149.     recipe_hash[:craft_level] ? @clevel = recipe_hash[:craft_level] : @clevel = 0
  150.     recipe_hash[:pxp] ? @pxp = recipe_hash[:pxp] : @pxp = 0
  151.     !recipe_hash[:multiple].nil? ? @mult = recipe_hash[:multiple] : @mult = true
  152.     @known = ADV_RECIPE::AUTO_LEARN_RECIPES
  153.   end
  154.   def name
  155.     return @result.item.name
  156.   end
  157.   def multiple?
  158.     @mult
  159.   end
  160.   def has_materials?
  161.     for item in @materials
  162.       return false unless $game_party.item_number(item.item) >= item.amount
  163.     end
  164.     return true
  165.   end
  166.   def has_gold?
  167.     $game_party.gold >= @gold_cost
  168.   end
  169.   def has_craft_level?
  170.     craft_level <= $game_party.craft_level_sym(@category)
  171.   end
  172.   def has_level?
  173.     @level <= $game_party.highest_level && has_craft_level?
  174.   end
  175.   def craftable?
  176.     has_gold? && has_materials? && has_level?
  177.   end
  178.   def craft_level
  179.     @clevel
  180.   end
  181.   def amount_craftable?
  182.     mat_amount = []
  183.     for item in @materials
  184.       mat_amount.push($game_party.item_number(item.item) / item.amount)
  185.     end
  186.     if @gold_cost > 0
  187.       return [$game_party.gold / @gold_cost,mat_amount.min].min
  188.     else
  189.       return mat_amount.min
  190.     end
  191.   end
  192.   def craft(fail = 0)
  193.     remove_materials
  194.     if fail < success_rate
  195.       return add_result
  196.     else
  197.       return nil
  198.     end
  199.   end
  200.   def remove_materials
  201.     for item in @materials
  202.       next unless item.consumed?
  203.       $game_party.gain_item(item.item,-item.amount)
  204.     end
  205.     $game_party.gain_gold(-@gold_cost)
  206.   end
  207.   def add_result
  208.     if ADV_RECIPE::USE_WA_RANDOMIZATION
  209.       item = $game_party.add_weapon(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Weapon)
  210.       item = $game_party.add_armor(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Armor)
  211.       item = $game_party.add_item(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Item)
  212.     else
  213.       $game_party.gain_item(@result.item,@result.amount)
  214.       item = @result.item
  215.     end
  216.     $game_party.gain_craft_exp(category_id, xp_gain)
  217.     $game_party.members.each do |actor|
  218.       actor.gain_exp(@pxp)
  219.     end
  220.     item
  221.   end
  222.   def category_id
  223.     ADV_RECIPE::CATEGORIES.index(@category)
  224.   end
  225.   def xp_gain
  226.     level_diff = $game_party.craft_level(category_id) - @clevel
  227.     [@xp - @xpd * level_diff,0].max
  228.   end
  229.   def success_rate
  230.     level_diff = $game_party.craft_level(category_id) - @clevel
  231.     [@rate + @rated * level_diff,100].min
  232.   end
  233. end
  234.  
  235. class Material
  236.   attr_accessor :item
  237.   attr_accessor :amount
  238.   def initialize(mat)
  239.     @item = $data_items[mat[1]] if mat[0] == 0
  240.     @item = $data_weapons[mat[1]] if mat[0] == 1
  241.     @item = $data_armors[mat[1]] if mat[0] == 2
  242.     @amount = mat[2]
  243.     @consumed = mat[3].nil? ? true : mat[3]
  244.   end
  245.   def consumed?
  246.     @consumed
  247.   end
  248. end
  249.  
  250. class Game_Party
  251.   alias recipe_init initialize
  252.   def initialize
  253.     recipe_init
  254.     @crafting_level = [1]*ADV_RECIPE::CATEGORIES.size
  255.     @craft_exp = [0]*ADV_RECIPE::CATEGORIES.size
  256.   end
  257.   def craft_level(id)
  258.     @crafting_level[id]
  259.   end
  260.   def craft_level_sym(sym)
  261.     @crafting_level[ADV_RECIPE::CATEGORIES.index(sym)]
  262.   end
  263.   def craft_exp(id)
  264.     @craft_exp[id]
  265.   end
  266.   def craft_exp_next(id)
  267.     lvl = craft_level(id)
  268.     return eval(ADV_RECIPE::XP_NEEDED_EQUATION)
  269.   end
  270.   def gain_craft_exp(id, val)
  271.     @craft_exp[id] += val
  272.     while craft_exp(id) >= craft_exp_next(id)
  273.       @craft_exp[id] -= craft_exp_next(id)
  274.       @crafting_level[id] += 1
  275.     end
  276.   end
  277. end
  278.  
  279. module DataManager
  280.   class << self
  281.     alias rec_cgo create_game_objects
  282.     alias rec_msc make_save_contents
  283.     alias rec_esc extract_save_contents
  284.   end
  285.   def self.create_game_objects
  286.     rec_cgo
  287.     $game_recipes = create_recipes
  288.   end
  289.   def self.make_save_contents
  290.     contents = rec_msc
  291.     contents[:recipe] = $game_recipes
  292.     contents
  293.   end
  294.   def self.extract_save_contents(contents)
  295.     rec_esc(contents)
  296.     $game_recipes = contents[:recipe]
  297.   end
  298.   def self.create_recipes
  299.     recipes = {}
  300.     ADV_RECIPE::RECIPES.each_pair do |key, val|
  301.       recipes[key] = Recipe.new(key,val)
  302.     end
  303.     recipes
  304.   end
  305. end
  306.  
  307. class Game_Interpreter
  308.   def learn_recipe(id)
  309.     return if $game_recipes[id].nil?
  310.     $game_recipes[id].known = true
  311.   end
  312.   def forget_recipe(id)
  313.     return if $game_recipes[id].nil?
  314.     $game_recipes[id].known = false
  315.   end
  316. end
  317.  
  318. class Window_RecipeList < Window_Selectable
  319.   def initialize(x,y,w,h)
  320.     super
  321.     @data = $game_recipes.values.select {|recipe| include?(recipe)}
  322.     refresh
  323.   end
  324.   def item_max
  325.     @data ? @data.size : 1
  326.   end
  327.   def item
  328.     @data && index >= 0 ? @data[index] : nil
  329.   end
  330.   def current_item_enabled?
  331.     enable?(@data[index])
  332.   end
  333.   def include?(item)
  334.     return false unless item.has_craft_level?
  335.     return false unless item.known
  336.     return true if @category == :All
  337.     return @category == item.category
  338.   end
  339.   def set_category(cat)
  340.     return if cat == @category
  341.     @category = cat
  342.     @data = $game_recipes.values.select {|recipe| include?(recipe)}
  343.     refresh
  344.   end
  345.   def enable?(item)
  346.     return false if item.nil?
  347.     return false if $temp_disable_crafting
  348.     item.craftable?
  349.   end
  350.   def draw_item(index)
  351.     item = @data[index]
  352.     if item
  353.       rect = item_rect(index)
  354.       rect.width -= 4
  355.       enabled = $temp_disable_crafting ? true : enable?(item)
  356.       draw_item_name(item.result.item, rect.x, rect.y, enabled)
  357.       if item.amount_craftable? > 0
  358.         draw_text(rect.x,rect.y,contents.width,24,"x"+item.amount_craftable?.to_s,2)
  359.       end
  360.     end
  361.   end
  362.   def current_item
  363.     index >= 0 ? @data[index] : nil
  364.   end
  365.   def process_ok
  366.     if current_item_enabled?
  367.       Sound.play_ok
  368.       Input.update
  369.       call_ok_handler
  370.     else
  371.       Sound.play_buzzer
  372.     end
  373.   end
  374.   def refresh
  375.     create_contents
  376.     super
  377.   end
  378.   def content_heights
  379.     item_max * 24
  380.   end
  381. end
  382.  
  383. class Window_RecipeDetail < Window_Base
  384.   def initialize(x,y,w,h)
  385.     super
  386.     @recipe = nil
  387.   end
  388.   def set_recipe(recipe)
  389.     @recipe = recipe
  390.     refresh
  391.   end
  392.   def refresh
  393.     contents.clear
  394.     contents.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
  395.     return if @recipe.nil?
  396.     draw_craft_level unless ADV_RECIPE::DISABLE_PLAYER_LEVEL && ADV_RECIPE::DISABLE_CRAFT_LEVEL
  397.     draw_materials
  398.     draw_success_rate unless ADV_RECIPE::DISABLE_SUCCESS
  399.     draw_gold_cost unless ADV_RECIPE::DISABLE_GOLD_COST
  400.   end
  401.   def draw_craft_level
  402.     change_color(system_color, @recipe.has_level?)
  403.     draw_text(0,0,contents.width,contents.font.size,"合成等级:")
  404.     change_color(normal_color, @recipe.has_level?)
  405.     xx = 0
  406.     if !ADV_RECIPE::DISABLE_PLAYER_LEVEL
  407.       draw_text(0,0,contents.width,contents.font.size,@recipe.level,2)
  408.       draw_icon(ADV_RECIPE::LEVEL_ICON,contents.width - 48,0)
  409.       xx += 48
  410.       text = @recipe.craft_level.to_s + "/"
  411.     else
  412.       text = @recipe.craft_level.to_s
  413.     end
  414.     if !ADV_RECIPE::DISABLE_CRAFT_LEVEL
  415.       draw_text(0,0,contents.width - xx,contents.font.size,text,2)
  416.       draw_icon(ADV_RECIPE::CATEGORY_ICONS[ADV_RECIPE::CATEGORIES.index(@recipe.category)],contents.width - 56 - xx,0)
  417.     end
  418.   end
  419.   def draw_materials
  420.     if ADV_RECIPE::DISABLE_CRAFT_LEVEL && ADV_RECIPE::DISABLE_PLAYER_LEVEL
  421.       yy = 0
  422.     else
  423.       yy = contents.font.size
  424.     end
  425.     change_color(system_color, @recipe.craftable?)
  426.     draw_text(0,yy,self.width,contents.font.size,"原料:")
  427.     yy += contents.font.size
  428.     for item in @recipe.materials
  429.       change_color(normal_color, $game_party.item_number(item.item) >= item.amount)
  430.       draw_icon(item.item.icon_index,0,yy)
  431.       draw_text(24,yy,self.width,contents.font.size,item.item.name)
  432.       string = $game_party.item_number(item.item).to_s + "/" + item.amount.to_s
  433.       draw_text(0,yy,self.contents.width,contents.font.size,string,2)
  434.       yy += contents.font.size
  435.     end
  436.   end
  437.   def draw_success_rate
  438.     change_color(system_color, @recipe.craftable?)
  439.     draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,"成功率:")
  440.     change_color(normal_color, @recipe.craftable?)
  441.     draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,@recipe.success_rate.to_s + "%",2)
  442.   end
  443.   def draw_gold_cost
  444.     if @recipe.gold_cost > 0
  445.       change_color(system_color, @recipe.has_gold?)
  446.       draw_text(0,contents.height-contents.font.size*2,contents.width,contents.font.size,"合成成本:")
  447.       change_color(normal_color, @recipe.has_gold?)
  448.       draw_currency_value(@recipe.gold_cost,Vocab::currency_unit,0,contents.height-contents.font.size*2,contents.width)
  449.     end  
  450.   end
  451.   def draw_currency_value(value, unit, x, y, width)
  452.     cx = text_size(unit).width
  453.     change_color(normal_color,$game_party.gold >= value)
  454.     draw_text(x, y, width - cx - 2, contents.font.size, value, 2)
  455.     change_color(system_color)
  456.     draw_text(x, y, width, contents.font.size, unit, 2)
  457.   end
  458. end
  459.  
  460. class Window_RecipeConfirm < Window_Selectable
  461.   attr_accessor :amount
  462.   def initialize(x,y,w,h)
  463.     super
  464.     @amount = 1
  465.     refresh
  466.   end
  467.   def item_max; 1; end;
  468.   def enable?(item); true; end;
  469.   def refresh
  470.     super
  471.     draw_text(0,0,self.contents.width,line_height,"合成",1)
  472.     return unless @recipe && @recipe.craftable?
  473.     draw_text(0,0,contents.width,line_height,"x"+@amount.to_s,2)
  474.   end
  475.   def activate
  476.     super
  477.     select(0)
  478.   end
  479.   def deactivate
  480.     super
  481.     select(-1)
  482.   end
  483.   def set_recipe(rec)
  484.     return if rec == @recipe
  485.     @recipe = rec
  486.     @amount = 1
  487.     refresh
  488.   end
  489.   def cursor_movable?
  490.     active && open? && ADV_RECIPE::CRAFT_MULTIPLE && @recipe.multiple?
  491.   end
  492.   def cursor_down(wrap = false)
  493.     change_amount(-10)
  494.   end
  495.   def cursor_up(wrap = false)
  496.     change_amount(10)
  497.   end
  498.   def cursor_right(wrap = false)
  499.     change_amount(1)
  500.   end
  501.   def cursor_left(wrap = false)
  502.     change_amount(-1)
  503.   end
  504.   def change_amount(val)
  505.     Sound.play_cursor
  506.     @amount += val
  507.     @amount = [[@amount,1].max,@recipe.amount_craftable?].min
  508.     refresh
  509.   end
  510. end
  511.  
  512. class Scene_CraftingAll < Scene_Base
  513.   def start
  514.     super
  515.     @help_window = Window_Help.new
  516.     width = Graphics.width / 2
  517.     height = Graphics.height - @help_window.height - 48
  518.     @list_window = Window_RecipeList.new(0,@help_window.height+48,width,height-48)
  519.     @list_window.set_handler(:ok, method(:list_success))
  520.     @list_window.set_handler(:cancel, method(:cancel))
  521.     @list_window.height += 48 if ADV_RECIPE::DISABLE_CRAFT_LEVEL
  522.     @list_window.create_contents
  523.     @detail_window = Window_RecipeDetail.new(width,@list_window.y,width,height-48*2)
  524.     @detail_window.height += 48 if ADV_RECIPE::DISABLE_GOLD_COST
  525.     @detail_window.create_contents
  526.     height = @detail_window.y + @detail_window.height
  527.     @confirm_window = Window_RecipeConfirm.new(width,height,width,48)
  528.     @confirm_window.set_handler(:ok, method(:craft_success))
  529.     @confirm_window.set_handler(:cancel, method(:confirm_cancel))
  530.     if !ADV_RECIPE::DISABLE_GOLD_COST
  531.       @gold_window = Window_Gold.new
  532.       @gold_window.width = width
  533.       @gold_window.y = Graphics.height - 48
  534.       @gold_window.x = width
  535.     end
  536.     @popup_window = Window_RecPopup.new
  537.     @popup_window.set_handler(:ok, method(:popup_ok))
  538.     @popup_window.set_handler(:cancel, method(:popup_ok))
  539.     @command_window = Window_RecCategory.new
  540.     @command_window.set_handler(:ok, method(:command_ok))
  541.     @command_window.set_handler(:cancel, method(:command_cancel))
  542.     @gauge_window = Window_RecGauge.new unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  543.   end
  544.   def popup_ok
  545.     @popup_window.deactivate
  546.     @popup_window.close
  547.     @list_window.activate
  548.   end
  549.   def update
  550.     super
  551.     @help_window.set_text(@list_window.current_item.result.item.description) if !@list_window.current_item.nil?
  552.     if @command_window.active
  553.       category = ADV_RECIPE::CATEGORIES[@command_window.index]
  554.       @help_window.set_text(ADV_RECIPE::DESCRIPTIONS[category])
  555.     end
  556.     @detail_window.set_recipe(@list_window.current_item)
  557.     @confirm_window.set_recipe(@list_window.current_item)
  558.     @list_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index])
  559.     @gauge_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index]) unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  560.     return unless @list_window.current_item
  561.     if @list_window.current_item.craftable?
  562.       @confirm_window.opacity = 255
  563.       @confirm_window.contents_opacity = 255
  564.     else
  565.       @confirm_window.opacity = 75
  566.       @confirm_window.contents_opacity = 75
  567.     end
  568.   end
  569.   def list_success
  570.     @list_window.deactivate
  571.     @confirm_window.activate
  572.   end
  573.   def craft_success
  574.     amount = 0
  575.     item = nil
  576.     @confirm_window.amount.times do
  577.       item2 = @list_window.current_item.craft(rand(100))
  578.       if item2
  579.         amount += 1
  580.         item = item2
  581.       end
  582.     end
  583.     if item
  584.       @popup_window.set_text(item, amount)
  585.     else
  586.       @popup_window.set_text_fail
  587.     end
  588.     @confirm_window.change_amount(-1000)
  589.     @gold_window.refresh unless ADV_RECIPE::DISABLE_GOLD_COST
  590.     @list_window.refresh
  591.     @gauge_window.refresh unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  592.     @popup_window.activate
  593.   end
  594.   def confirm_cancel
  595.     @confirm_window.deactivate
  596.     @list_window.activate
  597.   end
  598.   def command_cancel
  599.     $temp_disable_crafting = false
  600.     SceneManager.return
  601.   end
  602.   def cancel
  603.     @list_window.select(-1)
  604.     @help_window.set_text("")
  605.     @command_window.activate
  606.   end
  607.   def command_ok
  608.     @list_window.select(0)
  609.     @list_window.activate
  610.   end
  611. end
  612.  
  613. class Scene_Crafting < Scene_CraftingAll
  614.   def start
  615.     super
  616.     @command_window.index = ADV_RECIPE::CATEGORIES.index($crafting_category)
  617.     @command_window.deactivate
  618.     @command_window.visible = false
  619.     @list_window.height += 48
  620.     @list_window.y -= 48
  621.     @detail_window.height += 48
  622.     @detail_window.y -= 48
  623.     @list_window.create_contents
  624.     @detail_window.create_contents
  625.     @list_window.select(0)
  626.     @list_window.activate
  627.   end
  628.   def cancel
  629.     SceneManager.return
  630.   end
  631. end
  632.  
  633. class Window_RecCategory < Window_HorzCommand
  634.   def initialize
  635.     super(0,72)
  636.   end
  637.   def window_width; Graphics.width; end
  638.   def window_height; 48; end
  639.   def make_command_list
  640.     ADV_RECIPE::CATEGORIES.each do |command|
  641.       add_command(command.to_s,command)
  642.     end
  643.   end
  644.   def item_width
  645.     120
  646.   end
  647.   def draw_item(index)
  648.     change_color(normal_color, command_enabled?(index))
  649.     rect = item_rect_for_text(index)
  650.     draw_text(rect, command_name(index))
  651.     draw_icon(ADV_RECIPE::CATEGORY_ICONS[index],rect.x-24,rect.y)
  652.   end
  653.   def item_rect_for_text(index)
  654.     rect = item_rect(index)
  655.     rect.x += 28
  656.     rect.width -= 28
  657.     rect
  658.   end
  659. end
  660.  
  661. class Window_RecPopup < Window_Selectable
  662.   def initialize
  663.     super(Graphics.width/2-window_width/2,Graphics.height/2-window_height/2,120,48)
  664.     self.openness = 0
  665.     deactivate
  666.   end
  667.   def window_width; 120; end
  668.   def window_height; 48; end
  669.   def set_text(item, amount)
  670.     contents.clear
  671.     text = amount.to_s + "x " + item.name + " 已被合成!"
  672.     width = contents.text_size(text).width
  673.     self.width = width + padding*2
  674.     self.x = Graphics.width/2-width/2
  675.     create_contents
  676.     draw_text(24,0,contents.width,line_height,text)
  677.     draw_icon(item.icon_index,0,0)
  678.     open
  679.   end
  680.   def set_text_fail
  681.     contents.clear
  682.     text = "合成失败!"
  683.     width = contents.text_size(text).width
  684.     self.width = width + padding*2
  685.     self.x = Graphics.width/2-width/2
  686.     create_contents
  687.     draw_text(12,0,contents.width,line_height,text)
  688.     open
  689.   end
  690.   def process_ok
  691.     if current_item_enabled?
  692.       Input.update
  693.       deactivate
  694.       call_ok_handler
  695.     else
  696.       Sound.play_buzzer
  697.     end
  698.   end
  699. end
  700.  
  701. class Window_RecGauge < Window_Base
  702.   def initialize
  703.     super(0,Graphics.height-48,Graphics.width/2,48)
  704.     @category = :All
  705.   end
  706.   def refresh
  707.     contents.clear
  708.     return if @category == :All
  709.     draw_icon(ADV_RECIPE::CATEGORY_ICONS[cat_index],0,0)
  710.     draw_text(24,0,contents.width,24,$game_party.craft_level(cat_index))
  711.     rate = $game_party.craft_exp(cat_index).to_f / $game_party.craft_exp_next(cat_index)
  712.     draw_gauge(48, -3, contents.width-48, rate, tp_gauge_color1, tp_gauge_color2)
  713.     if Module.const_defined?(:SPECIAL_GAUGES)
  714.       @gauges[[48,-3]].set_extra("XP",$game_party.craft_exp(cat_index),$game_party.craft_exp_next(cat_index))
  715.     else
  716.       text = $game_party.craft_exp(cat_index).to_s+"/"+$game_party.craft_exp_next(cat_index).to_s
  717.       draw_text(0,0,contents.width,24,text,2)
  718.     end
  719.   end
  720.   def set_category(cat)
  721.     return if cat == @category
  722.     @category = cat
  723.     refresh
  724.   end
  725.   def cat_index
  726.     ADV_RECIPE::CATEGORIES.index(@category)
  727.   end
  728. end
  729.  
  730. class Window_MenuCommand < Window_Command
  731.   alias recipe_aoc add_original_commands
  732.   def add_original_commands
  733.     recipe_aoc
  734.     add_command("合成", :recipe) if ADV_RECIPE::ENABLE_MENU_ACCESS
  735.   end
  736. end
  737.  
  738. class Scene_Menu < Scene_MenuBase
  739.   alias recipe_create_command_window create_command_window
  740.   def create_command_window
  741.     recipe_create_command_window
  742.     @command_window.set_handler(:recipe,   method(:command_recipe))
  743.   end
  744.   def command_recipe
  745.     $temp_disable_crafting = ADV_RECIPE::DISABLE_MENU_CRAFT
  746.     SceneManager.call(Scene_CraftingAll)
  747.   end
  748. end

点评

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

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
37759
在线时间
5385 小时
注册时间
2006-11-10
帖子
6545
3
发表于 2020-11-24 09:49:53 | 只看该作者
在一个随时可以SL的环境里搞几率有啥意义呢?

点评

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 07:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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