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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
552
在线时间
464 小时
注册时间
2009-10-11
帖子
407
跳转到指定楼层
1
发表于 2013-9-21 08:56:53 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

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

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

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

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

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

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

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

BS00361.png (377.51 KB, 下载次数: 25)

BS00361.png

BS00362.png (379.67 KB, 下载次数: 26)

BS00362.png
因为现实太残酷、所以我们都在打造虚幻的天堂。如果现实不再残酷,也是因为有这快乐的天堂。

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

3
发表于 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 [email protected]
  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
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
465
在线时间
915 小时
注册时间
2011-5-11
帖子
438
2
发表于 2013-9-21 09:14:01 手机端发表。 | 只看该作者
可是可以不过很麻烦。
提供你一个思路: 在设置合成的数组里加上,一个ID位和一个Type(用来分辨物品武器)。再修改一下列表生成和合成部分就可以了。
自己动手,丰衣足食。*^_^*

点评

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-2-4 04:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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