Project1

标题: 关于物品的条件分歧 [打印本页]

作者: LO晓月VE    时间: 2013-2-24 11:08
标题: 关于物品的条件分歧
例如用这个物品换什么什么
20个物品换一个什么
用条件分歧的话,只能是一个物品持有时
然后我2的弄了20个。。
后来我脑子里闪了一下。。。。。
即使弄100你现在不消耗不都是持有吗。我终于聪明了。。。
那怎么才能让这个事件实现呢(我现在怎么这么喜欢吐自己槽。。)
作者: 熊喵酱    时间: 2013-2-24 11:18
1.用合成腳本
  1. #==============================================================================
  2. # ■ RGSS3 アイテム合成 ver 1.02
  3. #------------------------------------------------------------------------------
  4. #  配布元:
  5. #     白の魔 http://izumiwhite.web.fc2.com/
  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.   
  38.    
  39.    
  40.    #-------------------------------------------------------------------------------------
  41.   #武器の合成レシピ
  42.   
  43.   
  44.   #-------------------------------------------------------------------------------------
  45.   #防具の合成レシピ  

  46. end


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

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

  138. end

  139. class Game_Interpreter
  140.   include WD_itemsynthesis
  141. end

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


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

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

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


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

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


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

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


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

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


  783. #==============================================================================
  784. # ■ Window_ItemSynthesisCategory
  785. #------------------------------------------------------------------------------
  786. #  合成画面で、通常アイテムや装備品の分類を選択するウィンドウです。
  787. #==============================================================================

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


  810. #==============================================================================
  811. # ■ Window_ItemSynthesisNumber
  812. #------------------------------------------------------------------------------
  813. #  合成画面で、切替を表示するウィンドウです。
  814. #==============================================================================

  815. class Window_ItemSynthesisChange < Window_Base
  816.   #--------------------------------------------------------------------------
  817.   # ● オブジェクト初期化
  818.   #--------------------------------------------------------------------------
  819.   def initialize(x, y, width, height)
  820.     super(x, y, width, height)
  821.     refresh
  822.   end
  823.   #--------------------------------------------------------------------------
  824.   # ● リフレッシュ
  825.   #--------------------------------------------------------------------------
  826.   def refresh
  827.     contents.clear
  828.     text = "X Y:表示切り替え"
  829.     draw_text(0, 0, contents_width, line_height, text, 1)
  830.   end
  831. end
复制代码
用法選擇要用後問我吧...

2.進入正題

要合成的話需要一個變量

然後那個變量=某物品持有數

npc來了--------------------

如果變量大於20=兌換成功(要減物品) 否則=npc"你沒有什麼怎麼樣的那類"

就這麼簡單....
作者: acn00269    时间: 2013-2-24 11:21
变量操作→数据




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1