查看: 2187|回复: 2

[已经过期] 關於"道具合成"腳本,能否把分類都統一在一欄內?

[复制链接]
梦石
0
星屑
562
在线时间
465 小时
注册时间
2009-10-11
回帖
322
发表于 2013-9-21 08:56:53 | 显示全部楼层 |阅读模式

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

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

×
先附上腳本原網址 :)
http://izumiwhite.web.fc2.com/rgss3/rgss3_004_main_ver103.txt
"RGSS3 アイテム合成 ver 1.03"- BY 白の魔

在這個腳本中它會自動先進入四個分類(道具、武器、裝備、重要物品)選項讓玩家選擇(圖1),

如果我想要不分這四個大類,直接把能合成的物品都丟進同一類就好了,能否實現呢??

也因為不用再取選擇分類,我想更乾脆、當玩家開啟合成選單,就能直接跳到所有物品的合成畫面(圖2)  :)

  1. #==============================================================================
  2. # ■ RGSS3 アイテム合成 ver 1.03
  3. #------------------------------------------------------------------------------
  4. #  配布元:
  5. #     白の魔 [url]http://izumiwhite.web.fc2.com/[/url]
  6. #
  7. #  利用規約:
  8. #     RPGツクールVX Aceの正規の登録者のみご利用になれます。
  9. #     利用報告・著作権表示とかは必要ありません。
  10. #     改造もご自由にどうぞ。
  11. #     何か問題が発生しても責任は持ちません。
  12. #==============================================================================


  13. #--------------------------------------------------------------------------
  14. # ★ 初期設定。
  15. #    合成レシピ等の設定
  16. #--------------------------------------------------------------------------
  17. module WD_itemsynthesis_ini
  18.   
  19.   Cost_view =  true #費用(G)の表示(合成の費用が全て0Gの場合はfalseを推奨)
  20.   
  21.   Category_i = true #カテゴリウィンドウに「アイテム」の項目を表示
  22.   Category_w = true #カテゴリウィンドウに「武器」の項目を表示
  23.   Category_a = true #カテゴリウィンドウに「防具」の項目を表示
  24.   Category_k = true #カテゴリウィンドウに「大事なもの」の項目を表示
  25.   
  26.   I_recipe = [] #この行は削除しないこと
  27.   W_recipe = [] #この行は削除しないこと
  28.   A_recipe = [] #この行は削除しないこと
  29.   
  30.   #以下、合成レシピ。
  31.   #例: I_recipe[3]  = [100, ["I",1,1], ["W",2,1], ["A",2,2], ["A",3,1]]
  32.   #と記載した場合、ID3のアイテムの合成必要は、100G。
  33.   #必要な素材は、ID1のアイテム1個、ID2の武器1個、ID2の防具2個、ID3の防具1個
  34.   #となる。
  35.   
  36.   #アイテムの合成レシピ
  37.   I_recipe[2]  = [10,  ["I",1,2]]
  38.   I_recipe[3]  = [100, ["I",1,1], ["I",2,1]]
  39.   I_recipe[17] = [500, ["I",1,10]]

  40.   #武器の合成レシピ
  41.   W_recipe[3]  = [50,   ["W",1,1], ["W",2,1]]
  42.   W_recipe[6]  = [600,  ["W",3,1], ["I",17,0]]
  43.   
  44.   #防具の合成レシピ  
  45.   A_recipe[2]  = [40,   ["A",1,2]]
  46.   A_recipe[5]  = [400,  ["A",2,1], ["W",2,2], ["I",17,0]]
  47.   
  48. end


  49. #==============================================================================
  50. # ■ WD_itemsynthesis
  51. #------------------------------------------------------------------------------
  52. #  アイテム合成用の共通メソッドです。
  53. #==============================================================================

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

  140. end

  141. class Game_Interpreter
  142.   include WD_itemsynthesis
  143. end

  144. class Game_System
  145.   #--------------------------------------------------------------------------
  146.   # ● 公開インスタンス変数
  147.   #--------------------------------------------------------------------------
  148.   attr_accessor :i_rcp_sw
  149.   attr_accessor :w_rcp_sw
  150.   attr_accessor :a_rcp_sw
  151.   #--------------------------------------------------------------------------
  152.   # ● オブジェクト初期化
  153.   #--------------------------------------------------------------------------
  154.   alias wd_orig_initialize004 initialize
  155.   def initialize
  156.     wd_orig_initialize004
  157.     @i_rcp_sw = []
  158.     @w_rcp_sw = []
  159.     @a_rcp_sw = []
  160.   end
  161. end


  162. #==============================================================================
  163. # ■ Scene_ItemSynthesis
  164. #------------------------------------------------------------------------------
  165. #  合成画面の処理を行うクラスです。
  166. #==============================================================================

  167. class Scene_ItemSynthesis < Scene_MenuBase
  168.   #--------------------------------------------------------------------------
  169.   # ● 開始処理
  170.   #--------------------------------------------------------------------------
  171.   def start
  172.     super
  173.     create_help_window
  174.     create_dummy_window
  175.     create_number_window
  176.     create_status_window
  177.     create_material_window
  178.     create_list_window
  179.     create_category_window
  180.     create_gold_window
  181.     create_change_window
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● ゴールドウィンドウの作成
  185.   #--------------------------------------------------------------------------
  186.   def create_gold_window
  187.     @gold_window = Window_Gold.new
  188.     @gold_window.viewport = @viewport
  189.     @gold_window.x = Graphics.width - @gold_window.width
  190.     @gold_window.y = @help_window.height
  191.     @gold_window.hide
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 切り替え表示ウィンドウの作成
  195.   #--------------------------------------------------------------------------
  196.   def create_change_window
  197.     wx = 0
  198.     wy = @gold_window.y
  199.     ww = Graphics.width - @gold_window.width
  200.     wh = @gold_window.height
  201.     @change_window = Window_ItemSynthesisChange.new(wx, wy, ww, wh)
  202.     @change_window.viewport = @viewport
  203.     @change_window.hide
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ● ダミーウィンドウの作成
  207.   #--------------------------------------------------------------------------
  208.   def create_dummy_window
  209.     wy = @help_window.y + @help_window.height + 48
  210.     wh = Graphics.height - wy
  211.     @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
  212.     @dummy_window.viewport = @viewport
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # ● 個数入力ウィンドウの作成
  216.   #--------------------------------------------------------------------------
  217.   def create_number_window
  218.     wy = @dummy_window.y
  219.     wh = @dummy_window.height
  220.     @number_window = Window_ItemSynthesisNumber.new(0, wy, wh)
  221.     @number_window.viewport = @viewport
  222.     @number_window.hide
  223.     @number_window.set_handler(:ok,     method(:on_number_ok))
  224.     @number_window.set_handler(:cancel, method(:on_number_cancel))
  225.     @number_window.set_handler(:change_window, method(:on_change_window))   
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ● ステータスウィンドウの作成
  229.   #--------------------------------------------------------------------------
  230.   def create_status_window
  231.     wx = @number_window.width
  232.     wy = @dummy_window.y
  233.     ww = Graphics.width - wx
  234.     wh = @dummy_window.height
  235.     @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
  236.     @status_window.viewport = @viewport
  237.     @status_window.hide
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ● 素材ウィンドウの作成
  241.   #--------------------------------------------------------------------------
  242.   def create_material_window
  243.     wx = @number_window.width
  244.     wy = @dummy_window.y
  245.     ww = Graphics.width - wx
  246.     wh = @dummy_window.height
  247.     @material_window = Window_ItemSynthesisMaterial.new(wx, wy, ww, wh)
  248.     @material_window.viewport = @viewport
  249.     @material_window.hide
  250.     @number_window.material_window = @material_window
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # ● 合成アイテムリストウィンドウの作成
  254.   #--------------------------------------------------------------------------
  255.   def create_list_window
  256.     wy = @dummy_window.y
  257.     wh = @dummy_window.height
  258.     @list_window = Window_ItemSynthesisList.new(0, wy, wh)
  259.     @list_window.viewport = @viewport
  260.     @list_window.help_window = @help_window
  261.     @list_window.status_window = @status_window
  262.     @list_window.material_window = @material_window
  263.     @list_window.hide
  264.     @list_window.set_handler(:ok,     method(:on_list_ok))
  265.     @list_window.set_handler(:cancel, method(:on_list_cancel))
  266.     @list_window.set_handler(:change_window, method(:on_change_window))   
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● カテゴリウィンドウの作成
  270.   #--------------------------------------------------------------------------
  271.   def create_category_window
  272.     @category_window = Window_ItemSynthesisCategory.new
  273.     @category_window.viewport = @viewport
  274.     @category_window.help_window = @help_window
  275.     @category_window.y = @help_window.height
  276.     @category_window.activate
  277.     @category_window.item_window = @list_window
  278.     @category_window.set_handler(:ok,     method(:on_category_ok))
  279.     @category_window.set_handler(:cancel, method(:return_scene))
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # ● 合成アイテムリストウィンドウのアクティブ化
  283.   #--------------------------------------------------------------------------
  284.   def activate_list_window
  285.     @list_window.money = money
  286.     @list_window.show.activate
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● 合成[決定]
  290.   #--------------------------------------------------------------------------
  291.   def on_list_ok
  292.     @item = @list_window.item
  293.     @list_window.hide
  294.     @number_window.set(@item, max_buy, buying_price, currency_unit)
  295.     @number_window.show.activate
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ● 合成[キャンセル]
  299.   #--------------------------------------------------------------------------
  300.   def on_list_cancel
  301.     @category_window.activate
  302.     @category_window.show
  303.     @dummy_window.show
  304.     @list_window.hide
  305.     @status_window.hide
  306.     @status_window.item = nil
  307.     @material_window.hide
  308.     @material_window.set(nil, nil)
  309.     @gold_window.hide
  310.     @change_window.hide
  311.     @help_window.clear
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   # ● 表示切替
  315.   #--------------------------------------------------------------------------
  316.   def on_change_window
  317.     if @status_window.visible
  318.       @status_window.hide
  319.       @material_window.show
  320.     else
  321.       @status_window.show
  322.       @material_window.hide
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● カテゴリ[決定]
  327.   #--------------------------------------------------------------------------
  328.   def on_category_ok
  329.     activate_list_window
  330.     @gold_window.show
  331.     @change_window.show
  332.     @material_window.show
  333.     @category_window.hide
  334.     @list_window.select(0)
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 個数入力[決定]
  338.   #--------------------------------------------------------------------------
  339.   def on_number_ok
  340.     Sound.play_shop
  341.     do_syntetic(@number_window.number)
  342.     end_number_input
  343.     @gold_window.refresh
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # ● 個数入力[キャンセル]
  347.   #--------------------------------------------------------------------------
  348.   def on_number_cancel
  349.     Sound.play_cancel
  350.     end_number_input
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # ● 合成の実行
  354.   #--------------------------------------------------------------------------
  355.   def do_syntetic(number)
  356.     $game_party.lose_gold(number * buying_price)
  357.     $game_party.gain_item(@item, number)
  358.    
  359.       @recipe = @list_window.recipe(@item)
  360.       for i in [email]1...@recipe.size[/email]
  361.         kind = @recipe[i][0]
  362.         id   = @recipe[i][1]
  363.         num  = @recipe[i][2]
  364.         if kind == "I"
  365.           item = $data_items[id]
  366.         elsif kind == "W"
  367.           item = $data_weapons[id]
  368.         elsif kind == "A"
  369.           item = $data_armors[id]
  370.         end
  371.         $game_party.lose_item(item, num*number)
  372.       end
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ● 個数入力の終了
  376.   #--------------------------------------------------------------------------
  377.   def end_number_input
  378.     @number_window.hide
  379.     activate_list_window
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 最大購入可能個数の取得
  383.   #--------------------------------------------------------------------------
  384.   def max_buy
  385.     max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
  386.    
  387.     @recipe = @list_window.recipe(@item)
  388.       for i in [email]1...@recipe.size[/email]
  389.         kind = @recipe[i][0]
  390.         id   = @recipe[i][1]
  391.         num  = @recipe[i][2]
  392.         if kind == "I"
  393.           item = $data_items[id]
  394.         elsif kind == "W"
  395.           item = $data_weapons[id]
  396.         elsif kind == "A"
  397.           item = $data_armors[id]
  398.         end
  399.         if num > 0
  400.           max_buf = $game_party.item_number(item)/num
  401.         else
  402.           max_buf = 999
  403.         end
  404.         max = [max, max_buf].min
  405.       end
  406.       
  407.     buying_price == 0 ? max : [max, money / buying_price].min

  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ● 所持金の取得
  411.   #--------------------------------------------------------------------------
  412.   def money
  413.     @gold_window.value
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ● 通貨単位の取得
  417.   #--------------------------------------------------------------------------
  418.   def currency_unit
  419.     @gold_window.currency_unit
  420.   end
  421.   #--------------------------------------------------------------------------
  422.   # ● 合成費用の取得
  423.   #--------------------------------------------------------------------------
  424.   def buying_price
  425.     @list_window.price(@item)
  426.   end
  427. end


  428. #==============================================================================
  429. # ■ Window_ItemSynthesisList
  430. #------------------------------------------------------------------------------
  431. #  合成画面で、合成可能なアイテムの一覧を表示するウィンドウです。
  432. #==============================================================================

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


  668. #==============================================================================
  669. # ■ Window_ItemSynthesisMaterial
  670. #------------------------------------------------------------------------------
  671. #  合成画面で、合成に必要な素材を表示するウィンドウです。
  672. #==============================================================================

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


  750. #==============================================================================
  751. # ■ Window_ItemSynthesisNumber
  752. #------------------------------------------------------------------------------
  753. #  合成画面で、合成するアイテムの個数を入力するウィンドウです。
  754. #==============================================================================

  755. class Window_ItemSynthesisNumber < Window_ShopNumber
  756.   #--------------------------------------------------------------------------
  757.   # ● リフレッシュ
  758.   #--------------------------------------------------------------------------
  759.   def refresh
  760.     contents.clear
  761.     draw_item_name(@item, 0, item_y)
  762.     draw_number
  763.     draw_total_price if WD_itemsynthesis_ini::Cost_view
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● オブジェクト初期化
  767.   #--------------------------------------------------------------------------
  768.   def material_window=(material_window)
  769.     @material_window = material_window
  770.     call_update_help
  771.   end
  772.   #--------------------------------------------------------------------------
  773.   # ● 作成個数の変更
  774.   #--------------------------------------------------------------------------
  775.   def change_number(amount)
  776.     @number = [[@number + amount, @max].min, 1].max
  777.     call_update_help #追加
  778.   end
  779.   #--------------------------------------------------------------------------
  780.   # ● ヘルプテキスト更新
  781.   #--------------------------------------------------------------------------
  782.   def call_update_help
  783.     @material_window.set_num(@number) if @material_window
  784.   end
  785.   #--------------------------------------------------------------------------
  786.   # ● Z ボタン(表示切替)が押されたときの処理
  787.   #--------------------------------------------------------------------------
  788.   def process_change_window
  789.     Sound.play_cursor
  790.     Input.update
  791.     call_handler(:change_window)
  792.   end
  793.   #--------------------------------------------------------------------------
  794.   # ● 決定やキャンセルなどのハンドリング処理
  795.   #--------------------------------------------------------------------------
  796.   def process_handling
  797.     super
  798.     if active
  799.       return process_change_window if handle?(:change_window) && Input.trigger?(:Z)
  800. #      return process_change_window if handle?(:change_window) && Input.trigger?(:Z)
  801.     end
  802.   end
  803. end


  804. #==============================================================================
  805. # ■ Window_ItemSynthesisCategory
  806. #------------------------------------------------------------------------------
  807. #  合成画面で、通常アイテムや装備品の分類を選択するウィンドウです。
  808. #==============================================================================

  809. class Window_ItemSynthesisCategory < Window_ItemCategory
  810.   #--------------------------------------------------------------------------
  811.   # ● 桁数の取得
  812.   #--------------------------------------------------------------------------
  813.   def col_max
  814.     i = 0
  815.     i += 1 if WD_itemsynthesis_ini::Category_i
  816.     i += 1 if WD_itemsynthesis_ini::Category_w
  817.     i += 1 if WD_itemsynthesis_ini::Category_a
  818.     i += 1 if WD_itemsynthesis_ini::Category_k
  819.     return i
  820.   end
  821.   #--------------------------------------------------------------------------
  822.   # ● コマンドリストの作成
  823.   #--------------------------------------------------------------------------
  824.   def make_command_list
  825.     add_command(Vocab::item,     :item)     if WD_itemsynthesis_ini::Category_i
  826.     add_command(Vocab::weapon,   :weapon)   if WD_itemsynthesis_ini::Category_w
  827.     add_command(Vocab::armor,    :armor)    if WD_itemsynthesis_ini::Category_a
  828.     add_command(Vocab::key_item, :key_item) if WD_itemsynthesis_ini::Category_k
  829.   end
  830. end


  831. #==============================================================================
  832. # ■ Window_ItemSynthesisNumber
  833. #------------------------------------------------------------------------------
  834. #  合成画面で、切替を表示するウィンドウです。
  835. #==============================================================================

  836. class Window_ItemSynthesisChange < Window_Base
  837.   #--------------------------------------------------------------------------
  838.   # ● オブジェクト初期化
  839.   #--------------------------------------------------------------------------
  840.   def initialize(x, y, width, height)
  841.     super(x, y, width, height)
  842.     refresh
  843.   end
  844.   #--------------------------------------------------------------------------
  845.   # ● リフレッシュ
  846.   #--------------------------------------------------------------------------
  847.   def refresh
  848.     contents.clear
  849.     text = "Z: 素材 ⇔ ステータス 表示切り替え"
  850.     draw_text(0, 0, contents_width, line_height, text, 1)
  851.   end
  852. end
复制代码
BS00361.png
BS00362.png
因为现实太残酷、所以我们都在打造虚幻的天堂。如果现实不再残酷,也是因为有这快乐的天堂。
梦石
0
星屑
1478
在线时间
993 小时
注册时间
2011-5-11
回帖
418
发表于 2013-9-21 09:14:01 来自手机 | 显示全部楼层
可是可以不过很麻烦。
提供你一个思路: 在设置合成的数组里加上,一个ID位和一个Type(用来分辨物品武器)。再修改一下列表生成和合成部分就可以了。
自己动手,丰衣足食。*^_^*

点评

如果要創新一個ID跟TYPE 是要先在物品設定那裡增加嗎?  发表于 2013-9-22 00:20
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2013-9-21 10:30:53 | 显示全部楼层
用这个吧孩子~

  1. ==============================================================================
  2. ★ Item_Transmute
  3. ------------------------------------------------------------------------------
  4.   配方不公开的物品合成(加强版)
  5.   原作者 Summoner
  6.   By Chd114
  7. ------------------------------------------------------------------------------
  8.   注:该脚本具有至高权威性,可以覆盖任何此脚本的前身脚本!
  9.   注:此脚本无视魔法免疫!
  10.   注:使用此脚本时,处于无敌状态!
  11. ==============================================================================
  12. 本脚本以知识共享署名-非商业性使用 3.0 Unported 许可协议进行许可。
  13. 详见 http://creativecommons.org/licenses/by-nc/3.0/
  14. ==============================================================================
  15. 原作者的话:  
  16. 这是一个配方不公开的物品合成,也就是说什么材料可以合成什么物品玩家在
  17. 游戏中的合成界面是不能直接看到的。由于物品的合成配方不是公开的,所以
  18. 玩家需要通过自己探索或从NPC处得到合成配方(当然看攻略也是一种可能)
  19. 例如M&M中的配药水,Diablo II的盒子,NWV中的铁匠铺、Wizard Lab……
  20. 可扩展性:可以加强、扩展的东西应该很多。
  21. 例如:合成需要花费GP、SP甚至XP,合成需要特定器具,合成失败受到伤害,
  22. 某些物品的几率合成、物品图鉴等等。
  23. 有的东西已经注释清楚了,搞懂原理的话,根据自己需要改起来也不会很麻烦。
  24. 个人一下子没时间实现这些,欢迎大家多多修改分享。

  25. Chd114的话(2013年6月9日 11:45:40):
  26. 其实这个脚本的改进思路早在去年此脚本出来之前就有想法了···只不过那个
  27. 时候本人的技术还差了一点所以就没有盲目去弄今天(2013年6月9日 9:33:40)
  28. 花了2小时左右的时间鼓捣了下最后把大部分东西都弄好了

  29. Chd114的话(2013年6月10日 7:59:49):
  30. 吃饭前来了新的灵感,于是就在吃完饭后鼓捣了下下···现在一个配方里的每一种成
  31. 功额外产物和失败额外产物都可以设定独立的出现概率了,而且还加了新功能,
  32. 可以控制开关与变量!(2013年6月10日 8:28:03)

  33. 此脚本冲突可能性:与装备耐久度、随即装备属性之类会导致装备具有独立性的
  34. 脚本功能冲突,其他脚本基本上不冲突

  35. 使用方法:在事件中使用脚本$scene = Scene_Compose.new,然后等待2帧
  36. ==============================================================================
  37. 若合成失败(无匹配的配方、因合成概率低而失败)物品是否失去
  38. =end
  39. $Ingredient_Lost_When_Fail = true#false
  40. # 合成成功/失败SE  
  41. # 若不使用SE请设置为“""”(不含外引号)
  42. $SE_Compose_Successful = ""  
  43. $SE_Compose_Failed = ""
  44.   
  45. #=============================================================================
  46. # ■ 配方及补充的定义
  47. #-----------------------------------------------------------------------------
  48. # Game_System
  49. #=============================================================================
  50. class Game_System
  51.   attr_accessor :formulas
  52.   attr_accessor :products
  53.   attr_accessor :sproducts
  54.   attr_accessor :fproducts
  55.   attr_accessor :other
  56.   attr_accessor :probability
  57.   alias formulas_initialize initialize  
  58.   def initialize  
  59.     formulas_initialize
  60.     @formulas = []  
  61.     @products = []
  62.     @sproducts = []
  63.     @fproducts = []
  64.     @other = []
  65.     @probability = []
  66. =begin
  67. ===========================配方表===========================================   

  68.   配方格式
  69.   @formulas[i] = [[材料种类,材料编号,数量],[材料种类,材料编号,数量]……]                  
  70.   @products[i] = [[成品种类,成品编号,数量],[成品种类,成品编号,数量]……]
  71.   @sproducts[i] = [[成功额外产物种类,编号,数量,出现概率],[成功额外产物种类,编号,数量,出现概率]]
  72.   @fproducts[i] = [[失败额外产物种类,编号,数量,出现概率],[失败额外产物种类,编号,数量,出现概率]]
  73.   @other[i] = [[开关/变量,开关/变量编号,控制系数],[开关/变量,开关/变量编号,控制系数]]
  74.   @probability[i] = 合成成功率
  75.   种类:物品 0 武器 1 防具 2
  76.   1.如果有两个配方材料相同,理论上会按编号较小的处理
  77.   2.配方材料的顺序与合成是无关的(当然如果你想改成有关肯定也不会太麻烦)
  78.   3.允许某个材料拆成多件成品(可能就不叫物品合成,应该叫物品分解了)
  79.   4.产物数量神马的理论上你可以无限写,只要你不怕麻烦加手抽筋。
  80.   5.暂时不支持多步合并为一步的合成  
  81.     例如 A + B = C,C + D = E,如果不存在A + B + D = E的配方
  82.     A + B + D无法合成 E
  83.   6.暂时不支持将配方逆向使用(本功能会尝试完善)
  84.     例如 A + B = C,C = A + B,如果不存在C = A + B的配方
  85.     C无法拆解成A + B
  86.   7.暂时不支持花费金钱的合成与配方学习(本功能会尝试完善)
  87.     例如A + B = C,作者设定成合成此配方的成品需要花费5000金币之类的
  88.   8.成功额外产物出现的概率与失败额外产物出现的概率会导致所有成功额外
  89.   产物或所有失败额外产物同时出现,比如失败额外产物有大药膏和艾西非远
  90.   古祭祀,则在合成失败后若出现失败的额外产物时同时出现大药膏和艾西非
  91.   远古祭祀。
  92.   9.成功额外产物和失败额外产物的设定和配方材料、配方成品设定格式是一致的。
  93.   10.@other[i]里面控制开关与变量,当[开关/变量,开关/变量编号,控制系数]
  94.   里面的[开关/变量]为0时是改变开关,改变开关的时候若控制系数为0则是关闭,
  95.   1就是打开,当[开关/变量]为1时是改变变量,这个时候控制系数可以添任意正负
  96.   整数。
  97.   11.当你要改变开关状态时控制系数只能是1或0
  98.   12.不需要的功能全部数字写0即可
  99.   13.只有合成/拆分成功时才能改变开关与变量
  100.   14.已经打开的开关依然可以用合成/拆分操作重复打开

  101. =end
  102.     #初始化模板
  103.     @formulas[0] = []
  104.     @products[0] = []
  105.     @sproducts[0] = []
  106.     @fproducts[0] = []
  107.     @other[0] = []
  108.     @probability[0] = []
  109.     #这个才是样例!!!
  110.     @formulas[1] = [[1,1,1]]         
  111.     @products[1] = [[2,29,1]]
  112.     @sproducts[1] = [[1,2,1,50],[1,3,1,100]]
  113.     @fproducts[1] = [[0,2,1,50],[0,3,3,100]]
  114.     @other[1] = [[0,10,1],[1,20,2]]#10号开关打开,20号变量+2
  115.     @probability[1] = 100
  116.   end  
  117. end
  118.   
  119. class Game_Temp  
  120.   attr_accessor :forge
  121.   alias forge_item_initialize initialize  
  122.   def initialize  
  123.     forge_item_initialize
  124.     # 定义合成窗口中的物品储存区
  125.     [url=home.php?mod=space&uid=14254]@Forge[/url] = []  
  126.   end  
  127. end
  128.   
  129. #==============================================================================
  130. # ■ Window_ForgeCommand
  131. #------------------------------------------------------------------------------
  132. #  合成画面、选择要做的事的窗口
  133. #==============================================================================
  134.   
  135. class Window_ComposeCommand < Window_Selectable
  136.   #--------------------------------------------------------------------------
  137.   # ● 初始化对像
  138.   #--------------------------------------------------------------------------
  139.   def initialize
  140.     super(0, 64, 640, 64)
  141.     self.contents = Bitmap.new(width - 32, height - 32)
  142.     @item_max = 4
  143.     @column_max = 4
  144.     @commands = ["更改材料", "合成", "放弃合成", "离开"]
  145.     refresh
  146.     self.index = 0
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 刷新
  150.   #--------------------------------------------------------------------------
  151.   def refresh
  152.     self.contents.clear
  153.     for i in 0...@item_max
  154.       draw_item(i)
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 描绘项目
  159.   #     index : 项目编号
  160.   #--------------------------------------------------------------------------
  161.   def draw_item(index)
  162.     x = 4 + index * 160
  163.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  164.   end
  165. end
  166.   
  167. #==============================================================================
  168. # ■ Window_ForgeLeft
  169. #------------------------------------------------------------------------------
  170. #  合成画面中显示拥有的物品的窗口
  171. #==============================================================================
  172.   
  173. class Window_ComposeLeft < Window_Selectable
  174.   #--------------------------------------------------------------------------
  175.   # ● 初始化对像
  176.   #--------------------------------------------------------------------------
  177.   def initialize
  178.     super(0, 128, 320, 352)
  179.     @column_max = 1
  180.     refresh
  181.     self.index = 0
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 获取物品
  185.   #--------------------------------------------------------------------------
  186.   def item
  187.     return @data[self.index]
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ● 刷新
  191.   #--------------------------------------------------------------------------
  192.   def refresh
  193.     if self.contents != nil
  194.       self.contents.dispose
  195.       self.contents = nil
  196.     end
  197.     self.update_cursor_rect
  198.     @data = []
  199.     for i in 1...$data_items.size
  200.       if $game_party.item_number(i) > 0
  201.         @data.push($data_items[i])
  202.       end
  203.     end
  204.     for i in 1...$data_weapons.size
  205.       if $game_party.weapon_number(i) > 0
  206.         @data.push($data_weapons[i])
  207.       end
  208.     end
  209.     for i in 1...$data_armors.size
  210.       if $game_party.armor_number(i) > 0
  211.         @data.push($data_armors[i])
  212.       end
  213.     end
  214.     # 如果项目数不是 0 就生成位图、描绘全部项目
  215.     @item_max = @data.size
  216.     if @item_max > 0
  217.       self.contents = Bitmap.new(width - 32, row_max * 32)
  218.       for i in 0...@item_max
  219.         draw_item(i)
  220.       end
  221.     end
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # ● 描绘项目
  225.   #     index : 项目标号
  226.   #--------------------------------------------------------------------------
  227.   def draw_item(index)
  228.     item = @data[index]
  229.     case item
  230.     when RPG::Item
  231.       number = $game_party.item_number(item.id)
  232.     when RPG::Weapon
  233.       number = $game_party.weapon_number(item.id)
  234.     when RPG::Armor
  235.       number = $game_party.armor_number(item.id)
  236.     end
  237.     self.contents.font.color = text_color(item.name_color_66RPG)
  238.     x = 4
  239.     y = index * 32
  240.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  241.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  242.     bitmap = RPG::Cache.icon(item.icon_name)
  243.     opacity = self.contents.font.color == text_color(item.name_color_66RPG) ? 255 : 128
  244.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
  245.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  246.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  247.     self.contents.draw_text(x + 256, y, 32, 32, number.to_s, 2)
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 刷新帮助文本
  251.   #--------------------------------------------------------------------------
  252.   def update_help
  253.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  254.   end
  255. end
  256.   
  257. #==============================================================================
  258. # ■ Window_ForgeRight
  259. #------------------------------------------------------------------------------
  260. #  合成画面中的合成区窗口
  261. #==============================================================================
  262.   
  263. class Window_ComposeRight < Window_Selectable
  264.   attr_accessor :forge_item
  265.   #--------------------------------------------------------------------------
  266.   # ● 初始化对像
  267.   #--------------------------------------------------------------------------
  268.   def initialize(forge_item)
  269.     super(320, 128, 320, 352)
  270.     @column_max = 1
  271.     @forge_item = []
  272.     refresh
  273.     self.index = 0
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 获取物品
  277.   #--------------------------------------------------------------------------
  278.   def item
  279.     return @data[self.index]
  280.   end
  281.   #--------------------------------------------------------------------------  
  282.   # ● 获取物品  
  283.   #--------------------------------------------------------------------------  
  284.   def item_number  
  285.     return @data_number[self.index]  
  286.   end  
  287.   #--------------------------------------------------------------------------
  288.   # ● 刷新
  289.   #--------------------------------------------------------------------------
  290.   def refresh
  291.     if self.contents != nil
  292.       self.contents.dispose
  293.       self.contents = nil
  294.     end
  295.     @data = []
  296.     @data_number = []  
  297.     @forge_item = $game_temp.forge
  298.     for item_forge in @forge_item
  299.       case item_forge[0]
  300.       when 0
  301.         item = $data_items[item_forge[1]]
  302.       when 1
  303.         item = $data_weapons[item_forge[1]]
  304.       when 2
  305.         item = $data_armors[item_forge[1]]
  306.       end
  307.       if (item != nil) and (item_forge[2] != 0)  
  308.         @data.push(item)  
  309.         @data_number.push(item_forge[2])  
  310.       else  
  311.         @data.delete(item)  
  312.       end  
  313.     end
  314.     # 如果项目数不是 0 就生成位图、描绘全部项目
  315.     @item_max = @data.size
  316.     if @item_max > 0
  317.       self.contents = Bitmap.new(width - 32, row_max * 32)
  318.       for i in 0...@item_max
  319.         draw_item(i)
  320.       end
  321.     end
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ● 描绘项目
  325.   #     index : 项目标号
  326.   #--------------------------------------------------------------------------
  327.   def draw_item(index)
  328.     item = @data[index]
  329.     case item
  330.     when RPG::Item
  331.       number = $game_temp.forge[index][2]
  332.     when RPG::Weapon
  333.       number = $game_temp.forge[index][2]
  334.     when RPG::Armor
  335.       number = $game_temp.forge[index][2]
  336.     end
  337.     self.contents.font.color = text_color(item.name_color_66RPG)
  338.     x = 4
  339.     y = index * 32
  340.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  341.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  342.     bitmap = RPG::Cache.icon(item.icon_name)
  343.     opacity = self.contents.font.color == text_color(item.name_color_66RPG) ? 255 : 128
  344.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
  345.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  346.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  347.     self.contents.draw_text(x + 256, y, 32, 32, number.to_s, 2)
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # ● 刷新帮助文本
  351.   #--------------------------------------------------------------------------
  352.   def update_help
  353.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  354.   end
  355. end
  356.   
  357. #==============================================================================
  358. # ■ Scene_Compose
  359. #------------------------------------------------------------------------------
  360. #  处理物品合成画面的类
  361. #==============================================================================
  362.   
  363. class Scene_Compose
  364. #--------------------------------------------------------------------------
  365. # ● 初始化
  366. #--------------------------------------------------------------------------
  367. def initialize
  368.    # 生成帮助窗口
  369.    @help_window = Window_Help.new
  370.    # 生成命令窗口
  371.    @command_window = Window_ComposeCommand.new
  372.    @command_window.active = false
  373.    # 生成左方窗口
  374.    @item_window = Window_ComposeLeft.new
  375.    @item_window.active = true
  376.    @item_window.help_window = @help_window
  377.    # 生成右方窗口
  378.    @forge_window = Window_ComposeRight.new([])
  379.    @forge_window.active = false
  380.    @forge_window.help_window = @help_window
  381.    # 初始化配方与合成区
  382.    @formulas = $game_system.formulas
  383.    @products = $game_system.products
  384.    @sproducts = $game_system.sproducts
  385.    @fproducts = $game_system.fproducts
  386.    @other = $game_system.other
  387.    @probability = $game_system.probability
  388.    @forge = []
  389.    @products_temp = []  
  390.    @sproducts_temp = []
  391.    @fproducts_temp = []
  392.    @other_temp = []
  393.    @probability_temp = []
  394. end
  395.   #--------------------------------------------------------------------------
  396.   # ● 主处理
  397.   #--------------------------------------------------------------------------
  398. def main
  399.    # 执行过渡
  400.    Graphics.transition
  401.    # 主循环
  402.    loop do
  403.      # 刷新游戏画面
  404.      Graphics.update
  405.      # 刷新输入情报
  406.      Input.update
  407.      # 刷新画面
  408.      update
  409.      # 如果画面被切换的话就中断循环
  410.      if $scene != self
  411.        break
  412.      end
  413.    end
  414.    # 准备过渡
  415.    Graphics.freeze
  416.    # 释放窗口
  417.    @help_window.dispose
  418.    @command_window.dispose
  419.    @item_window.dispose
  420.    @forge_window.dispose
  421. end
  422.   #--------------------------------------------------------------------------
  423.   # ● 刷新画面
  424.   #--------------------------------------------------------------------------  
  425. def update
  426.    @help_window.update
  427.    @command_window.update
  428.    @item_window.update
  429.    @forge_window.update
  430.    if @command_window.active
  431.      update_command
  432.      return
  433.    end
  434.    if @item_window.active
  435.      update_item
  436.      return
  437.    end
  438.    if @forge_window.active
  439.      update_forge
  440.      return
  441.    end
  442.     return
  443. end
  444.   #--------------------------------------------------------------------------
  445.   # ● 刷新画面(指令窗口激活的情况下)
  446.   #--------------------------------------------------------------------------
  447.   def update_command
  448.     # 按下 B 键的情况下
  449.     if Input.trigger?(Input::B)
  450.       # 演奏取消 SE
  451.       $game_system.se_play($data_system.cancel_se)
  452.       abort
  453.       # 切换到地图画面
  454.       $scene = Scene_Map.new
  455.       return
  456.     end
  457.      # 按下 C 键的情况下
  458.     if Input.trigger?(Input::C)
  459.       # 命令窗口光标位置分支
  460.       case @command_window.index
  461.       when 0  # 更改材料
  462.         # 演奏确定 SE
  463.         $game_system.se_play($data_system.decision_se)
  464.         # 窗口状态转向物品窗口
  465.         @command_window.active = false
  466.         @item_window.active = true
  467.         @forge_window.active = false
  468.       when 1  # 合成
  469.         # 演奏确定 SE
  470.         $game_system.se_play($data_system.decision_se)
  471.         # 执行合成命令
  472.         if $game_temp.forge != []
  473.           compose
  474.         end
  475.       when 2  # 放弃合成
  476.         # 演奏确定 SE
  477.         $game_system.se_play($data_system.decision_se)
  478.         # 放弃合成
  479.         abort
  480.       when 3  # 离开
  481.         # 演奏确定 SE
  482.         $game_system.se_play($data_system.decision_se)
  483.         # 放弃合成
  484.         abort
  485.         # 切换到地图画面
  486.         $scene = Scene_Map.new
  487.       end
  488.       return
  489.     end
  490.   end
  491.   #--------------------------------------------------------------------------
  492.   # ● 刷新画面(物品窗口激活的情况下)
  493.   #--------------------------------------------------------------------------
  494.   def update_item
  495.      # 按下 B 键的情况下
  496.     if Input.trigger?(Input::B)
  497.       # 演奏取消 SE
  498.       $game_system.se_play($data_system.cancel_se)
  499.       # 切换到指令窗口
  500.       @item_window.active = false
  501.       @command_window.active = true
  502.       @help_window.set_text("")
  503.       return
  504.     end
  505.      # 按下 C 键的情况
  506.     if Input.trigger?(Input::C)
  507.       # 演奏确定 SE
  508.       $game_system.se_play($data_system.decision_se)
  509.       # 获取物品
  510.       @item = @item_window.item
  511.       # 获取物品的所持数
  512.       case @item
  513.       when RPG::Item
  514.         number = $game_party.item_number(@item.id)
  515.         typetemp = 0
  516.       when RPG::Weapon
  517.         number = $game_party.weapon_number(@item.id)
  518.         typetemp = 1
  519.       when RPG::Armor
  520.         number = $game_party.armor_number(@item.id)
  521.         typetemp = 2
  522.       end
  523.       if number != nil
  524.         # 更改合成窗口的物品
  525.         case @item
  526.         when RPG::Item
  527.           $game_party.lose_item(@item.id, 1)
  528.         when RPG::Weapon
  529.           $game_party.lose_weapon(@item.id, 1)
  530.         when RPG::Armor
  531.           $game_party.lose_armor(@item.id, 1)
  532.         end
  533.         forge_change(typetemp, @item.id, 1)
  534.         # 刷新各窗口
  535.         @item_window.update
  536.         @help_window.update
  537.         @forge_window.update
  538.         @item_window.refresh
  539.         @forge_window.refresh
  540.       end
  541.     end
  542.      # 按下 右方向键 的情况
  543.     if Input.trigger?(Input::RIGHT)
  544.       # 切换到合成窗口
  545.       @item_window.active = false
  546.       @forge_window.active = true
  547.     end
  548.   end
  549.   #--------------------------------------------------------------------------
  550.   # ● 刷新画面(合成窗口激活的情况下)
  551.   #--------------------------------------------------------------------------
  552.   def update_forge
  553.      # 按下 B 键的情况下
  554.     if Input.trigger?(Input::B)
  555.       # 演奏取消 SE
  556.       $game_system.se_play($data_system.cancel_se)
  557.       # 切换到指令窗口
  558.       @forge_window.active = false
  559.       @command_window.active = true
  560.       @help_window.set_text("")
  561.       return
  562.     end
  563.      # 按下 C 键的情况
  564.     if Input.trigger?(Input::C)
  565.      # 演奏确定 SE
  566.      $game_system.se_play($data_system.decision_se)
  567.      # 获取物品
  568.       @item = @forge_window.item
  569.       # 获取物品的所持数
  570.       case @item
  571.       when RPG::Item
  572.         number = @forge_window.item_number
  573.         typetemp = 0
  574.       when RPG::Weapon
  575.         number = @forge_window.item_number
  576.         typetemp = 1
  577.       when RPG::Armor
  578.         number = @forge_window.item_number
  579.         typetemp = 2
  580.       end
  581.      if number != nil
  582.        # 更改合成窗口的物品
  583.        case @item
  584.        when RPG::Item
  585.          $game_party.gain_item(@item.id, 1)
  586.        when RPG::Weapon
  587.          $game_party.gain_weapon(@item.id, 1)
  588.        when RPG::Armor
  589.          $game_party.gain_armor(@item.id, 1)
  590.        end
  591.        #p number
  592.        forge_change(typetemp, @item.id, -1)
  593.        # 刷新各窗口
  594.        @item_window.refresh
  595.        @forge_window.refresh
  596.        @help_window.update
  597.        @item_window.update
  598.        @forge_window.update
  599.       end
  600.     end
  601.        # 按下 左方向键 的情况下
  602.     if Input.trigger?(Input::LEFT)
  603.       # 切换到合成窗口
  604.       @forge_window.active = false
  605.       @item_window.active = true
  606.     end
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ● 更改合成窗口物品
  610.   #--------------------------------------------------------------------------
  611.   def forge_change(type,id,number)  
  612.      quantity = number  
  613.      for item in $game_temp.forge
  614.        if (item[0]==type) and (item[1]==id)  
  615.          item[2] = [item[2] += quantity,99].min  
  616.          if item[2] == 0  
  617.            $game_temp.forge.delete(item)  
  618.          end
  619.          return  
  620.        end  
  621.      end  
  622.      $game_temp.forge.push([type,id,number])  
  623.   end  
  624.   #--------------------------------------------------------------------------
  625.   # ● 放弃合成
  626.   #--------------------------------------------------------------------------  
  627.   def abort
  628.     # 将合成窗口中的物品转移至物品窗口中
  629.     for item in $game_temp.forge
  630.       # 判断物品类型并归还
  631.       case item[0]
  632.       when 0
  633.         $game_party.gain_item(item[1], item[2])
  634.       when 1
  635.         $game_party.gain_weapon(item[1], item[2])
  636.       when 2
  637.         $game_party.gain_armor(item[1], item[2])
  638.       end
  639.     end
  640.     $game_temp.forge = []
  641.     # 刷新各窗口
  642.     @item_window.refresh
  643.     @forge_window.refresh
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # ● 检测是否有符合的配方
  647.   #--------------------------------------------------------------------------
  648. def match
  649.    match_one = false
  650.    match_this = false
  651.     # 检测每一个配方
  652.    for i in 0...@formulas.size
  653.      # 将合成窗口中的物品复制到合成缓存区
  654.      # 注意: 直接使用"="将传引用 导致检测配方是否匹配时合成窗口中物品被删除
  655.      @forge = $game_temp.forge.dup
  656.      # 检测这个配方中每一项材料
  657.      for ingredient in @formulas[i]
  658.        match_this = true
  659.        # 合成区中没有此项材料的情况
  660.        unless @forge.include?(ingredient)
  661.          match_this = false
  662.          break
  663.        end
  664.        # 从合成区中暂时删除这项材料
  665.        @forge.delete(ingredient)
  666.      end
  667.      if match_this == false
  668.        next
  669.      end
  670.      # 检测合成区中是否还有配方外的材料剩余
  671.      unless @forge == []
  672.        match_this = false
  673.      end
  674.      # 满足这一个配方的情况
  675.      if match_this == true
  676.        match_one = true
  677.        # 获取配方的成品、成功额外产物、失败额外产物、合成各种概率
  678.        @products_temp = @products[i]
  679.        @sproducts_temp = @sproducts[i]
  680.        @fproducts_temp = @fproducts[i]
  681.        @other_temp = @other[i]
  682.        @probability_temp = @probability[i]
  683.        $g=i
  684.        break
  685.      end
  686.    end
  687.    return match_one
  688. end
  689.   #--------------------------------------------------------------------------
  690.   # ● 合成
  691.   #--------------------------------------------------------------------------
  692. def compose
  693.    # 如果有符合的配方
  694.    if match
  695.      # 将合成窗口中的材料改变为成品
  696.      $game_temp.forge = []
  697.      if @probability_temp==100
  698.        @pro1=0#当成功率为100%时随机概率是0
  699.      else
  700.        @pro1=rand(99)#当成功率不为100%时随即概率为0-99
  701.      end
  702.      if @pro1<@probability_temp
  703.        for i in 0...@other_temp.size
  704.          if @other_temp[i][1]!=0
  705.            if @other_temp[i][0]==0
  706.              $game_switches[@other_temp[i][1]]=@other_temp[i][2]#控制开关
  707.            else
  708.              $game_variables[@other_temp[i][1]]+=@other_temp[i][2]#控制变量
  709.            end
  710.          end
  711.          $game_map.need_refresh = true#强制刷新地图
  712.        end
  713.        for i in 0...@products_temp.size
  714.          forge_change(@products_temp[i][0], @products_temp[i][1], @products_temp[i][2])
  715.        end
  716.        for i in 0...@sproducts_temp.size
  717.          if @sproducts_temp[i][3]==100
  718.            @pro2=0#成功额外产率为100%时随即概率为0
  719.          elsif @sproducts_temp[i][3]<100
  720.            @pro2=rand(99)#成功额外产率为0-99%时随即概率为0-99%
  721.          else
  722.            @pro2=0#成功额外产率为0%时没有成功额外产物
  723.          end
  724.          if @pro2<@sproducts_temp[i][3]
  725.            forge_change(@sproducts_temp[i][0], @sproducts_temp[i][1], @sproducts_temp[i][2])
  726.          end
  727.        end  
  728.      else
  729.        for i in 0...@fproducts_temp.size
  730.          if @fproducts_temp[i][3]==100
  731.            @pro3=0#成功额外产率为100%时随即概率为0
  732.          elsif @fproducts_temp[i][3]<100
  733.            @pro3=rand(99)#成功额外产率为0-99%时随即概率为0-99%
  734.          else
  735.            @pro3=0#成功额外产率为0%时没有成功额外产物
  736.          end
  737.          if @pro3<@fproducts_temp[i][3]
  738.            forge_change(@fproducts_temp[i][0], @fproducts_temp[i][1], @fproducts_temp[i][2])
  739.          end
  740.        end
  741.      end
  742.      if $SE_Compose_Successful != ""
  743.        Audio.se_play($SE_Compose_Successful)
  744.      end
  745.    # 合成失败的情况
  746.    else  
  747.      if $SE_Compose_Failed != ""
  748.        Audio.se_play($SE_Compose_Failed)
  749.      end
  750.      if $Ingredient_Lost_When_Fail
  751.        $game_temp.forge = []
  752.      end
  753.    end
  754.     # 刷新各窗口
  755.    @item_window.refresh
  756.    @forge_window.refresh
  757. end
  758. end
复制代码

评分

参与人数 1星屑 +30 收起 理由
熊喵酱 + 30 感謝幫忙 可是看起來是VX的...

查看全部评分

[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部