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

Project1

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

[已经解决] 主站的这个合成脚本能不能使不参加合成的物品不显示

[复制链接]

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

跳转到指定楼层
1
发表于 2014-11-24 20:06:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 yang1zhi 于 2014-11-24 20:20 编辑

比如一些任务物品,不想让他们参加合成。
然后一些剧情物品,不想让他们参加合成。
这个合成脚本有合成失败后物品会消失的功能。假设任务物品合成后消失了挺麻烦的。而且任务物品剧情物品种类也比较多,翻页也麻烦。
能不能不显示出来。
比如@formulas[0] = [1,2,3,4,5,6] 这样物品栏的123456ID的物品都不显示出来
@formulas[1] = [1,2,3] 这样武器栏的123ID的武器都不显示出来
@formulas[2] = [1,2,3]这样防具栏的123ID的防具都不显示出来。
我只是举个例子,我不知道怎么改好。

或者有没有方式读取物品备注,判断后面有没有@特殊物品,有的话就不显示

RUBY 代码复制
  1. #==============================================================================
  2. # ★ Item_Transmute
  3. #------------------------------------------------------------------------------
  4. #  配方不公开的物品合成 
  5. #  By Summoner
  6. #==============================================================================
  7. #
  8. # 本脚本以 知识共享署名-非商业性使用 3.0 Unported 许可协议进行许可。
  9. # 详见 [url]http://creativecommons.org/licenses/by-nc/3.0/[/url]
  10. #
  11. #==============================================================================
  12. #  
  13. # 这是一个配方不公开的物品合成,也就是说什么材料可以合成什么物品玩家在
  14. # 游戏中的合成界面是不能直接看到的。由于物品的合成配方不是公开的,所以
  15. # 玩家需要通过自己探索或从NPC处得到合成配方(当然看攻略也是一种可能)
  16. #  
  17. # 例如M&M中的配药水,Diablo II的盒子,NWV中的铁匠铺、Wizard Lab……
  18. #  
  19. # 冲突可能性:基本上是添加新的内容,冲突可能性较小
  20. #
  21. # 可扩展性:可以加强、扩展的东西应该很多。
  22. #   例如:合成需要花费GP、SP甚至XP,合成需要特定器具,合成失败受到伤害,
  23. #   某些物品的几率合成、物品图鉴等等。
  24. #
  25. #   有的东西已经注释清楚了,搞懂原理的话,根据自己需要改起来也不会很麻烦。
  26. #
  27. #   个人一下子没时间实现这些,欢迎大家多多修改分享。
  28. #
  29. # 使用方法:在事件中使用脚本$scene = Scene_Compose.new,然后等待2帧
  30. #
  31. #
  32. #==============================================================================
  33.  
  34. # 若合成失败(无匹配的配方)物品是否失去
  35. $Ingredient_Lost_When_Fail = true
  36.  
  37. # 合成成功/失败SE  
  38. # 若不使用SE请设置为“""”(不含外引号)
  39. $SE_Compose_Successful = "Audio/SE/109-Heal05"  
  40. $SE_Compose_Failed = "Audio/SE/117-Fire01"
  41.  
  42. #=============================================================================
  43. # ■ 配方及补充的定义
  44. #-----------------------------------------------------------------------------
  45. # Game_System
  46. #=============================================================================
  47. class Game_System
  48.   attr_accessor :formulas
  49.   attr_accessor :products
  50.   alias formulas_initialize initialize  
  51.   def initialize  
  52.     formulas_initialize
  53.     @formulas = []  
  54.     @products = []
  55. #############################################################################
  56. #  
  57. #===========================配方表===========================================   
  58. #
  59. #  配方格式
  60. #
  61. #  @formulas[i] = [[材料种类,材料编号,数量],[材料种类,材料编号,数量]……]                  
  62. #  @products[i] = [[成品种类,成品编号,数量],[成品种类,成品编号,数量]……]
  63. #   
  64. #  种类:物品 0 武器 1 防具 2
  65. #
  66. #  1.如果有两个配方材料相同,理论上会按编号较小的处理
  67. #  2.配方材料的顺序与合成是无关的(当然如果你想改成有关肯定也不会太麻烦)
  68. #  3.允许某个材料拆成多件成品(可能就不叫物品合成,应该叫物品分解了)
  69. #  4.暂时不支持多步合并为一步的合成  
  70. #       例如 A + B = C,C + D = E,如果不存在A + B + D = E的配方
  71. #       A + B + D无法合成 E  
  72. #
  73. #############################################################################
  74.     @formulas[0] = []
  75.     @products[0] = []
  76.     # 样例1: 回复剂x3 = 超回复剂x1
  77.     @formulas[1] = [[1,1,1],[0,202,1]]         
  78.     @products[1] = [[1,38,1]]
  79.     @formulas[2] = [[0,2,3]]
  80.     @products[2] = [[0,3,1]]
  81.     @formulas[3] = [[0,4,3]]
  82.     @products[3] = [[0,5,1]]
  83.     @formulas[4] = [[0,5,3]]
  84.     @products[4] = [[0,6,1]]
  85.     # 样例2: 完全恢复剂x1 + 超级香水x1 = 圣灵药x1
  86.     @formulas[5] = [[0,3,1],[0,6,1]]
  87.     @products[5] = [[0,7,1]]
  88.     # 样例3: 完全恢复剂x1 + 超级香水x1 = 完全圣灵药x1
  89.     # 被样例2 被覆盖
  90.     @formulas[6] = [[0,3,1],[0,6,1]]
  91.     @products[6] = [[0,8,1]]
  92.     # 圣灵药x1 = 完全恢复剂x1 + 超级香水x1 (Item_Decompose...)
  93.     @formulas[7] = [[0,7,1]]
  94.     @products[7] = [[0,3,1],[0,6,1]]
  95.     # 样例5: 铜剑x1 + 回复剂x1 + 铜铠x1 = 密斯利尔剑x1
  96.     @formulas[8] = [[1,1,1],[0,1,1],[2,1,1]]  
  97.     @products[8] = [[1,4,1]]
  98.   end  
  99. end
  100.  
  101. class Game_Temp  
  102.   attr_accessor :forge
  103.   alias forge_item_initialize initialize  
  104.   def initialize  
  105.     forge_item_initialize
  106.     # 定义合成窗口中的物品储存区
  107.     [url=home.php?mod=space&uid=14254]@Forge[/url] = []  
  108.   end  
  109. end
  110.  
  111. #==============================================================================
  112. # ■ Window_ForgeCommand
  113. #------------------------------------------------------------------------------
  114. #  合成画面、选择要做的事的窗口
  115. #==============================================================================
  116.  
  117. class Window_ComposeCommand < Window_Selectable
  118.   #--------------------------------------------------------------------------
  119.   # ● 初始化对像
  120.   #--------------------------------------------------------------------------
  121.   def initialize
  122.     super(0, 64, 640, 64)
  123.     self.contents = Bitmap.new(width - 32, height - 32)
  124.     @item_max = 4
  125.     @column_max = 4
  126.     @commands = ["选择材料", "加工", "放弃加工", "离开"]
  127.     refresh
  128.     self.index = 0
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 刷新
  132.   #--------------------------------------------------------------------------
  133.   def refresh
  134.     self.contents.clear
  135.     for i in 0...@item_max
  136.       draw_item(i)
  137.     end
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● 描绘项目
  141.   #     index : 项目编号
  142.   #--------------------------------------------------------------------------
  143.   def draw_item(index)
  144.     x = 4 + index * 160
  145.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  146.   end
  147. end
  148.  
  149. #==============================================================================
  150. # ■ Window_ForgeLeft
  151. #------------------------------------------------------------------------------
  152. #  合成画面中显示拥有的物品的窗口
  153. #==============================================================================
  154.  
  155. class Window_ComposeLeft < Window_Selectable
  156.   #--------------------------------------------------------------------------
  157.   # ● 初始化对像
  158.   #--------------------------------------------------------------------------
  159.   def initialize
  160.     super(0, 128, 320, 352)
  161.     @column_max = 1
  162.     refresh
  163.     self.index = 0
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 获取物品
  167.   #--------------------------------------------------------------------------
  168.   def item
  169.     return @data[self.index]
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 刷新
  173.   #--------------------------------------------------------------------------
  174.   def refresh
  175.     if self.contents != nil
  176.       self.contents.dispose
  177.       self.contents = nil
  178.     end
  179.     self.update_cursor_rect
  180.     @data = []
  181.     for i in 1...$data_items.size
  182.       if $game_party.item_number(i) > 0
  183.         @data.push($data_items[i])
  184.       end
  185.     end
  186.     for i in 1...$data_weapons.size
  187.       if $game_party.weapon_number(i) > 0
  188.         @data.push($data_weapons[i])
  189.       end
  190.     end
  191.     for i in 1...$data_armors.size
  192.       if $game_party.armor_number(i) > 0
  193.         @data.push($data_armors[i])
  194.       end
  195.     end
  196.     # 如果项目数不是 0 就生成位图、描绘全部项目
  197.     @item_max = @data.size
  198.     if @item_max > 0
  199.       self.contents = Bitmap.new(width - 32, row_max * 32)
  200.       for i in 0...@item_max
  201.         draw_item(i)
  202.       end
  203.     end
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ● 描绘项目
  207.   #     index : 项目标号
  208.   #--------------------------------------------------------------------------
  209.   def draw_item(index)
  210.     item = @data[index]
  211.     case item
  212.     when RPG::Item
  213.       number = $game_party.item_number(item.id)
  214.     when RPG::Weapon
  215.       number = $game_party.weapon_number(item.id)
  216.     when RPG::Armor
  217.       number = $game_party.armor_number(item.id)
  218.     end
  219.     self.contents.font.color = normal_color
  220.     x = 4
  221.     y = index * 32
  222.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  223.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  224.     bitmap = RPG::Cache.icon(item.icon_name)
  225.     opacity = self.contents.font.color == normal_color ? 255 : 128
  226.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  227.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  228.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  229.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ● 刷新帮助文本
  233.   #--------------------------------------------------------------------------
  234.   def update_help
  235.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  236.   end
  237. end
  238.  
  239. #==============================================================================
  240. # ■ Window_ForgeRight
  241. #------------------------------------------------------------------------------
  242. #  合成画面中的合成区窗口
  243. #==============================================================================
  244.  
  245. class Window_ComposeRight < Window_Selectable
  246.   attr_accessor :forge_item
  247.   #--------------------------------------------------------------------------
  248.   # ● 初始化对像
  249.   #--------------------------------------------------------------------------
  250.   def initialize(forge_item)
  251.     super(320, 128, 320, 352)
  252.     @column_max = 1
  253.     @forge_item = []
  254.     refresh
  255.     self.index = 0
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 获取物品
  259.   #--------------------------------------------------------------------------
  260.   def item
  261.     return @data[self.index]
  262.   end
  263.   #--------------------------------------------------------------------------  
  264.   # ● 获取物品  
  265.   #--------------------------------------------------------------------------  
  266.   def item_number  
  267.     return @data_number[self.index]  
  268.   end  
  269.   #--------------------------------------------------------------------------
  270.   # ● 刷新
  271.   #--------------------------------------------------------------------------
  272.   def refresh
  273.     if self.contents != nil
  274.       self.contents.dispose
  275.       self.contents = nil
  276.     end
  277.     @data = []
  278.     @data_number = []  
  279.     @forge_item = $game_temp.forge
  280.     for item_forge in @forge_item
  281.       case item_forge[0]
  282.       when 0
  283.         item = $data_items[item_forge[1]]
  284.       when 1
  285.         item = $data_weapons[item_forge[1]]
  286.       when 2
  287.         item = $data_armors[item_forge[1]]
  288.       end
  289.       if (item != nil) and (item_forge[2] != 0)  
  290.         @data.push(item)  
  291.         @data_number.push(item_forge[2])  
  292.       else  
  293.         @data.delete(item)  
  294.       end  
  295.     end
  296.     # 如果项目数不是 0 就生成位图、描绘全部项目
  297.     @item_max = @data.size
  298.     if @item_max > 0
  299.       self.contents = Bitmap.new(width - 32, row_max * 32)
  300.       for i in 0...@item_max
  301.         draw_item(i)
  302.       end
  303.     end
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 描绘项目
  307.   #     index : 项目标号
  308.   #--------------------------------------------------------------------------
  309.   def draw_item(index)
  310.     item = @data[index]
  311.     case item
  312.     when RPG::Item
  313.       number = $game_temp.forge[index][2]
  314.     when RPG::Weapon
  315.       number = $game_temp.forge[index][2]
  316.     when RPG::Armor
  317.       number = $game_temp.forge[index][2]
  318.     end
  319.     self.contents.font.color = normal_color
  320.     x = 4
  321.     y = index * 32
  322.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  323.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  324.     bitmap = RPG::Cache.icon(item.icon_name)
  325.     opacity = self.contents.font.color == normal_color ? 255 : 128
  326.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  327.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  328.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  329.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● 刷新帮助文本
  333.   #--------------------------------------------------------------------------
  334.   def update_help
  335.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  336.   end
  337. end
  338.  
  339. #==============================================================================
  340. # ■ Scene_Compose
  341. #------------------------------------------------------------------------------
  342. #  处理物品合成画面的类
  343. #==============================================================================
  344.  
  345. class Scene_Compose
  346. #--------------------------------------------------------------------------
  347. # ● 初始化
  348. #--------------------------------------------------------------------------
  349. def initialize
  350.    # 生成帮助窗口
  351.    @help_window = Window_Help.new
  352.    # 生成命令窗口
  353.    @command_window = Window_ComposeCommand.new
  354.    @command_window.active = false
  355.    # 生成左方窗口
  356.    @item_window = Window_ComposeLeft.new
  357.    @item_window.active = true
  358.    @item_window.help_window = @help_window
  359.    # 生成右方窗口
  360.    @forge_window = Window_ComposeRight.new([])
  361.    @forge_window.active = false
  362.    @forge_window.help_window = @help_window
  363.    # 初始化配方与合成区
  364.    @formulas = $game_system.formulas
  365.    @products = $game_system.products
  366.    [url=home.php?mod=space&uid=14254]@Forge[/url] = []
  367.    @products_temp = []      
  368. end
  369.   #--------------------------------------------------------------------------
  370.   # ● 主处理
  371.   #--------------------------------------------------------------------------
  372. def main
  373.    # 执行过渡
  374.    Graphics.transition
  375.    # 主循环
  376.    loop do
  377.      # 刷新游戏画面
  378.      Graphics.update
  379.      # 刷新输入情报
  380.      Input.update
  381.      # 刷新画面
  382.      update
  383.      # 如果画面被切换的话就中断循环
  384.      if $scene != self
  385.        break
  386.      end
  387.    end
  388.    # 准备过渡
  389.    Graphics.freeze
  390.    # 释放窗口
  391.    @help_window.dispose
  392.    @command_window.dispose
  393.    @item_window.dispose
  394.    @forge_window.dispose
  395. end
  396.   #--------------------------------------------------------------------------
  397.   # ● 刷新画面
  398.   #--------------------------------------------------------------------------  
  399. def update
  400.    @help_window.update
  401.    @command_window.update
  402.    @item_window.update
  403.    @forge_window.update
  404.    if @command_window.active
  405.      update_command
  406.      return
  407.    end
  408.    if @item_window.active
  409.      update_item
  410.      return
  411.    end
  412.    if @forge_window.active
  413.      update_forge
  414.      return
  415.    end
  416.     return
  417. end
  418.   #--------------------------------------------------------------------------
  419.   # ● 刷新画面(指令窗口激活的情况下)
  420.   #--------------------------------------------------------------------------
  421.   def update_command
  422.     # 按下 B 键的情况下
  423.     if Input.trigger?(Input::B)
  424.       # 演奏取消 SE
  425.       $game_system.se_play($data_system.cancel_se)
  426.       abort
  427.       # 切换到地图画面
  428.       $scene = Scene_Map.new
  429.       return
  430.     end
  431.      # 按下 C 键的情况下
  432.     if Input.trigger?(Input::C)
  433.       # 命令窗口光标位置分支
  434.       case @command_window.index
  435.       when 0  # 更改材料
  436.         # 演奏确定 SE
  437.         $game_system.se_play($data_system.decision_se)
  438.         # 窗口状态转向物品窗口
  439.         @command_window.active = false
  440.         @item_window.active = true
  441.         @forge_window.active = false
  442.       when 1  # 合成
  443.         # 演奏确定 SE
  444.         $game_system.se_play($data_system.decision_se)
  445.         # 执行合成命令
  446.         if $game_temp.forge != []
  447.           compose
  448.         end
  449.       when 2  # 放弃合成
  450.         # 演奏确定 SE
  451.         $game_system.se_play($data_system.decision_se)
  452.         # 放弃合成
  453.         abort
  454.       when 3  # 离开
  455.         # 演奏确定 SE
  456.         $game_system.se_play($data_system.decision_se)
  457.         # 放弃合成
  458.         abort
  459.         # 切换到地图画面
  460.         $scene = Scene_Map.new
  461.       end
  462.       return
  463.     end
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ● 刷新画面(物品窗口激活的情况下)
  467.   #--------------------------------------------------------------------------
  468.   def update_item
  469.      # 按下 B 键的情况下
  470.     if Input.trigger?(Input::B)
  471.       # 演奏取消 SE
  472.       $game_system.se_play($data_system.cancel_se)
  473.       # 切换到指令窗口
  474.       @item_window.active = false
  475.       @command_window.active = true
  476.       @help_window.set_text("")
  477.       return
  478.     end
  479.      # 按下 C 键的情况
  480.     if Input.trigger?(Input::C)
  481.       # 演奏确定 SE
  482.       $game_system.se_play($data_system.decision_se)
  483.       # 获取物品
  484.       @item = @item_window.item
  485.       # 获取物品的所持数
  486.       case @item
  487.       when RPG::Item
  488.         number = $game_party.item_number(@item.id)
  489.         typetemp = 0
  490.       when RPG::Weapon
  491.         number = $game_party.weapon_number(@item.id)
  492.         typetemp = 1
  493.       when RPG::Armor
  494.         number = $game_party.armor_number(@item.id)
  495.         typetemp = 2
  496.       end
  497.       if number != nil
  498.         # 更改合成窗口的物品
  499.         case @item
  500.         when RPG::Item
  501.           $game_party.lose_item(@item.id, 1)
  502.         when RPG::Weapon
  503.           $game_party.lose_weapon(@item.id, 1)
  504.         when RPG::Armor
  505.           $game_party.lose_armor(@item.id, 1)
  506.         end
  507.         forge_change(typetemp, @item.id, 1)
  508.         # 刷新各窗口
  509.         @item_window.update
  510.         @help_window.update
  511.         @forge_window.update
  512.         @item_window.refresh
  513.         @forge_window.refresh
  514.       end
  515.     end
  516.      # 按下 右方向键 的情况
  517.     if Input.trigger?(Input::RIGHT)
  518.       # 切换到合成窗口
  519.       @item_window.active = false
  520.       @forge_window.active = true
  521.     end
  522.   end
  523.   #--------------------------------------------------------------------------
  524.   # ● 刷新画面(合成窗口激活的情况下)
  525.   #--------------------------------------------------------------------------
  526.   def update_forge
  527.      # 按下 B 键的情况下
  528.     if Input.trigger?(Input::B)
  529.       # 演奏取消 SE
  530.       $game_system.se_play($data_system.cancel_se)
  531.       # 切换到指令窗口
  532.       @forge_window.active = false
  533.       @command_window.active = true
  534.       @help_window.set_text("")
  535.       return
  536.     end
  537.      # 按下 C 键的情况
  538.     if Input.trigger?(Input::C)
  539.      # 演奏确定 SE
  540.      $game_system.se_play($data_system.decision_se)
  541.      # 获取物品
  542.       @item = @forge_window.item
  543.       # 获取物品的所持数
  544.       case @item
  545.       when RPG::Item
  546.         number = @forge_window.item_number
  547.         typetemp = 0
  548.       when RPG::Weapon
  549.         number = @forge_window.item_number
  550.         typetemp = 1
  551.       when RPG::Armor
  552.         number = @forge_window.item_number
  553.         typetemp = 2
  554.       end
  555.      if number != nil
  556.        # 更改合成窗口的物品
  557.        case @item
  558.        when RPG::Item
  559.          $game_party.gain_item(@item.id, 1)
  560.        when RPG::Weapon
  561.          $game_party.gain_weapon(@item.id, 1)
  562.        when RPG::Armor
  563.          $game_party.gain_armor(@item.id, 1)
  564.        end
  565.        #p number
  566.        forge_change(typetemp, @item.id, -1)
  567.        # 刷新各窗口
  568.        @item_window.refresh
  569.        @forge_window.refresh
  570.        @help_window.update
  571.        @item_window.update
  572.        @forge_window.update
  573.       end
  574.     end
  575.        # 按下 左方向键 的情况下
  576.     if Input.trigger?(Input::LEFT)
  577.       # 切换到合成窗口
  578.       @forge_window.active = false
  579.       @item_window.active = true
  580.     end
  581.   end
  582.   #--------------------------------------------------------------------------
  583.   # ● 更改合成窗口物品
  584.   #--------------------------------------------------------------------------
  585.   def forge_change(type,id,number)  
  586.      quantity = number  
  587.      for item in $game_temp.forge
  588.        if (item[0]==type) and (item[1]==id)  
  589.          item[2] = [item[2] += quantity,99].min  
  590.          if item[2] == 0  
  591.            $game_temp.forge.delete(item)  
  592.          end
  593.          return  
  594.        end  
  595.      end  
  596.      $game_temp.forge.push([type,id,number])  
  597.   end  
  598.   #--------------------------------------------------------------------------
  599.   # ● 放弃合成
  600.   #--------------------------------------------------------------------------  
  601.   def abort
  602.     # 将合成窗口中的物品转移至物品窗口中
  603.     for item in $game_temp.forge
  604.       # 判断物品类型并归还
  605.       case item[0]
  606.       when 0
  607.         $game_party.gain_item(item[1], item[2])
  608.       when 1
  609.         $game_party.gain_weapon(item[1], item[2])
  610.       when 2
  611.         $game_party.gain_armor(item[1], item[2])
  612.       end
  613.     end
  614.     $game_temp.forge = []
  615.     # 刷新各窗口
  616.     @item_window.refresh
  617.     @forge_window.refresh
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 检测是否有符合的配方
  621.   #--------------------------------------------------------------------------
  622. def match
  623.    match_one = false
  624.    match_this = false
  625.     # 检测每一个配方
  626.    for i in [email]0...@formulas.size[/email]
  627.      # 将合成窗口中的物品复制到合成缓存区
  628.      # 注意: 直接使用"="将传引用 导致检测配方是否匹配时合成窗口中物品被删除
  629.      @forge = $game_temp.forge.dup
  630.      # 检测这个配方中每一项材料
  631.      for ingredient in @formulas[i]
  632.        match_this = true
  633.        # 合成区中没有此项材料的情况
  634.        unless @forge.include?(ingredient)
  635.          match_this = false
  636.          break
  637.        end
  638.        # 从合成区中暂时删除这项材料
  639.        @forge.delete(ingredient)
  640.      end
  641.      if match_this == false
  642.        next
  643.      end
  644.      # 检测合成区中是否还有配方外的材料剩余
  645.      unless @forge == []
  646.        match_this = false
  647.      end
  648.      # 满足这一个配方的情况
  649.      if match_this == true
  650.        match_one = true
  651.        # 获取配方的成品
  652.        @products_temp = @products[i]
  653.        break
  654.      end
  655.    end
  656.    return match_one
  657. end
  658.   #--------------------------------------------------------------------------
  659.   # ● 合成
  660.   #--------------------------------------------------------------------------
  661. def compose
  662.    #判断合成消耗物品是否携带
  663.    if $game_party.item_number(10) >= 1
  664.      #合成消耗物品减少
  665.      $game_party.gain_item(10,-1)
  666.    # 如果有符合的配方
  667.    if match
  668.      # 将合成窗口中的材料改变为成品
  669.      $game_temp.forge = []
  670.      for i in [email]0...@products_temp.size[/email]
  671.       forge_change(@products_temp[i][0], @products_temp[i][1], @products_temp[i][2])
  672.     end
  673.      if $SE_Compose_Successful != ""
  674.        Audio.se_play($SE_Compose_Successful)
  675.      end
  676.    # 合成失败的情况
  677.    else  
  678.      if $SE_Compose_Failed != ""
  679.        Audio.se_play($SE_Compose_Failed)
  680.      end
  681.      if $Ingredient_Lost_When_Fail
  682.        $game_temp.forge = []
  683.      end
  684.    end
  685.    end
  686.     # 刷新各窗口
  687.    @item_window.refresh
  688.    @forge_window.refresh
  689. end
  690. end
  

Lv5.捕梦者

梦石
0
星屑
33077
在线时间
5104 小时
注册时间
2012-11-19
帖子
4878

开拓者

2
发表于 2014-11-24 22:22:19 | 只看该作者
稍微修改了下,没有加入材料配方的物品都不显示。
  1. #==============================================================================
  2. # ★ Item_Transmute
  3. #------------------------------------------------------------------------------
  4. #  配方不公开的物品合成 
  5. #  By Summoner
  6. #==============================================================================
  7. #
  8. # 本脚本以 知识共享署名-非商业性使用 3.0 Unported 许可协议进行许可。
  9. # 详见 [url]http://creativecommons.org/licenses/by-nc/3.0/[/url]
  10. #
  11. #==============================================================================
  12. #  
  13. # 这是一个配方不公开的物品合成,也就是说什么材料可以合成什么物品玩家在
  14. # 游戏中的合成界面是不能直接看到的。由于物品的合成配方不是公开的,所以
  15. # 玩家需要通过自己探索或从NPC处得到合成配方(当然看攻略也是一种可能)
  16. #  
  17. # 例如M&M中的配药水,Diablo II的盒子,NWV中的铁匠铺、Wizard Lab……
  18. #  
  19. # 冲突可能性:基本上是添加新的内容,冲突可能性较小
  20. #
  21. # 可扩展性:可以加强、扩展的东西应该很多。
  22. #   例如:合成需要花费GP、SP甚至XP,合成需要特定器具,合成失败受到伤害,
  23. #   某些物品的几率合成、物品图鉴等等。
  24. #
  25. #   有的东西已经注释清楚了,搞懂原理的话,根据自己需要改起来也不会很麻烦。
  26. #
  27. #   个人一下子没时间实现这些,欢迎大家多多修改分享。
  28. #
  29. # 使用方法:在事件中使用脚本$scene = Scene_Compose.new,然后等待2帧
  30. #
  31. #
  32. #==============================================================================

  33. # 若合成失败(无匹配的配方)物品是否失去
  34. $Ingredient_Lost_When_Fail = true

  35. # 合成成功/失败SE  
  36. # 若不使用SE请设置为“""”(不含外引号)
  37. $SE_Compose_Successful = "Audio/SE/109-Heal05"  
  38. $SE_Compose_Failed = "Audio/SE/117-Fire01"

  39. #=============================================================================
  40. # ■ 配方及补充的定义
  41. #-----------------------------------------------------------------------------
  42. # Game_System
  43. #=============================================================================
  44. class Game_System
  45.   attr_accessor :formulas
  46.   attr_accessor :products
  47.   alias formulas_initialize initialize  
  48.   def initialize  
  49.     formulas_initialize
  50.     @formulas = []  
  51.     @products = []
  52. #############################################################################
  53. #  
  54. #===========================配方表===========================================   
  55. #
  56. #  配方格式
  57. #
  58. #  @formulas[i] = [[材料种类,材料编号,数量],[材料种类,材料编号,数量]……]                  
  59. #  @products[i] = [[成品种类,成品编号,数量],[成品种类,成品编号,数量]……]
  60. #   
  61. #  种类:物品 0 武器 1 防具 2
  62. #
  63. #  1.如果有两个配方材料相同,理论上会按编号较小的处理
  64. #  2.配方材料的顺序与合成是无关的(当然如果你想改成有关肯定也不会太麻烦)
  65. #  3.允许某个材料拆成多件成品(可能就不叫物品合成,应该叫物品分解了)
  66. #  4.暂时不支持多步合并为一步的合成  
  67. #       例如 A + B = C,C + D = E,如果不存在A + B + D = E的配方
  68. #       A + B + D无法合成 E  
  69. #
  70. #############################################################################
  71.     @formulas[0] = []
  72.     @products[0] = []
  73.     # 样例1: 回复剂x3 = 超回复剂x1
  74.     @formulas[1] = [[1,1,1],[0,202,1]]         
  75.     @products[1] = [[1,38,1]]
  76.     @formulas[2] = [[0,2,3]]
  77.     @products[2] = [[0,3,1]]
  78.     @formulas[3] = [[0,4,3]]
  79.     @products[3] = [[0,5,1]]
  80.     @formulas[4] = [[0,5,3]]
  81.     @products[4] = [[0,6,1]]
  82.     # 样例2: 完全恢复剂x1 + 超级香水x1 = 圣灵药x1
  83.     @formulas[5] = [[0,3,1],[0,6,1]]
  84.     @products[5] = [[0,7,1]]
  85.     # 样例3: 完全恢复剂x1 + 超级香水x1 = 完全圣灵药x1
  86.     # 被样例2 被覆盖
  87.     @formulas[6] = [[0,3,1],[0,6,1]]
  88.     @products[6] = [[0,8,1]]
  89.     # 圣灵药x1 = 完全恢复剂x1 + 超级香水x1 (Item_Decompose...)
  90.     @formulas[7] = [[0,7,1]]
  91.     @products[7] = [[0,3,1],[0,6,1]]
  92.     # 样例5: 铜剑x1 + 回复剂x1 + 铜铠x1 = 密斯利尔剑x1
  93.     @formulas[8] = [[1,1,1],[0,1,1],[2,1,1]]  
  94.     @products[8] = [[1,4,1]]
  95.   end  
  96.   
  97.   #-------------------------------------------------------------------------
  98.   # ● 判断物品是否是材料。#X☆R
  99.   #    kind :种类(物品 0 武器 1 防具 2) 。
  100.   #    id   :物品ID。
  101.   #-------------------------------------------------------------------------
  102.   def is_material?(kind, id)
  103.     @formulas.each do |a|
  104.       b = a.select{|i| i[0] == kind && i[1] == id}
  105.       return true unless b.empty?
  106.     end
  107.     return false
  108.   end
  109.   #-------------------------------------------------------------------------
  110.   
  111. end

  112. class Game_Temp  
  113.   attr_accessor :forge
  114.   alias forge_item_initialize initialize  
  115.   def initialize  
  116.     forge_item_initialize
  117.     # 定义合成窗口中的物品储存区
  118.     [url=home.php?mod=space&uid=14254]@Forge[/url] = []  
  119.   end
  120. end

  121. #==============================================================================
  122. # ■ Window_ForgeCommand
  123. #------------------------------------------------------------------------------
  124. #  合成画面、选择要做的事的窗口
  125. #==============================================================================

  126. class Window_ComposeCommand < Window_Selectable
  127.   #--------------------------------------------------------------------------
  128.   # ● 初始化对像
  129.   #--------------------------------------------------------------------------
  130.   def initialize
  131.     super(0, 64, 640, 64)
  132.     self.contents = Bitmap.new(width - 32, height - 32)
  133.     @item_max = 4
  134.     @column_max = 4
  135.     @commands = ["选择材料", "加工", "放弃加工", "离开"]
  136.     refresh
  137.     self.index = 0
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● 刷新
  141.   #--------------------------------------------------------------------------
  142.   def refresh
  143.     self.contents.clear
  144.     for i in 0...@item_max
  145.       draw_item(i)
  146.     end
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 描绘项目
  150.   #     index : 项目编号
  151.   #--------------------------------------------------------------------------
  152.   def draw_item(index)
  153.     x = 4 + index * 160
  154.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  155.   end
  156. end

  157. #==============================================================================
  158. # ■ Window_ForgeLeft
  159. #------------------------------------------------------------------------------
  160. #  合成画面中显示拥有的物品的窗口
  161. #==============================================================================

  162. class Window_ComposeLeft < Window_Selectable
  163.   #--------------------------------------------------------------------------
  164.   # ● 初始化对像
  165.   #--------------------------------------------------------------------------
  166.   def initialize
  167.     super(0, 128, 320, 352)
  168.     @column_max = 1
  169.     refresh
  170.     self.index = 0
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ● 获取物品
  174.   #--------------------------------------------------------------------------
  175.   def item
  176.     return @data[self.index]
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 刷新
  180.   #--------------------------------------------------------------------------
  181.   def refresh
  182.     if self.contents != nil
  183.       self.contents.dispose
  184.       self.contents = nil
  185.     end
  186.     self.update_cursor_rect
  187.     @data = []
  188.     for i in 1...$data_items.size
  189.       if $game_party.item_number(i) > 0
  190.         @data.push($data_items[i]) if $game_system.is_material?(0, i) #X☆R
  191.       end
  192.     end
  193.     for i in 1...$data_weapons.size
  194.       if $game_party.weapon_number(i) > 0
  195.         @data.push($data_weapons[i]) if $game_system.is_material?(1, i) #X☆R
  196.       end
  197.     end
  198.     for i in 1...$data_armors.size
  199.       if $game_party.armor_number(i) > 0
  200.         @data.push($data_armors[i]) if $game_system.is_material?(2, i) #X☆R
  201.       end
  202.     end
  203.     # 如果项目数不是 0 就生成位图、描绘全部项目
  204.     @item_max = @data.size
  205.     if @item_max > 0
  206.       self.contents = Bitmap.new(width - 32, row_max * 32)
  207.       for i in 0...@item_max
  208.         draw_item(i)
  209.       end
  210.     end
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 描绘项目
  214.   #     index : 项目标号
  215.   #--------------------------------------------------------------------------
  216.   def draw_item(index)
  217.     item = @data[index]
  218.     case item
  219.     when RPG::Item
  220.       number = $game_party.item_number(item.id)
  221.     when RPG::Weapon
  222.       number = $game_party.weapon_number(item.id)
  223.     when RPG::Armor
  224.       number = $game_party.armor_number(item.id)
  225.     end
  226.     self.contents.font.color = normal_color
  227.     x = 4
  228.     y = index * 32
  229.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  230.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  231.     bitmap = RPG::Cache.icon(item.icon_name)
  232.     opacity = self.contents.font.color == normal_color ? 255 : 128
  233.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  234.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  235.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  236.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 刷新帮助文本
  240.   #--------------------------------------------------------------------------
  241.   def update_help
  242.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  243.   end
  244. end

  245. #==============================================================================
  246. # ■ Window_ForgeRight
  247. #------------------------------------------------------------------------------
  248. #  合成画面中的合成区窗口
  249. #==============================================================================

  250. class Window_ComposeRight < Window_Selectable
  251.   attr_accessor :forge_item
  252.   #--------------------------------------------------------------------------
  253.   # ● 初始化对像
  254.   #--------------------------------------------------------------------------
  255.   def initialize(forge_item)
  256.     super(320, 128, 320, 352)
  257.     @column_max = 1
  258.     @forge_item = []
  259.     refresh
  260.     self.index = 0
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● 获取物品
  264.   #--------------------------------------------------------------------------
  265.   def item
  266.     return @data[self.index]
  267.   end
  268.   #--------------------------------------------------------------------------  
  269.   # ● 获取物品  
  270.   #--------------------------------------------------------------------------  
  271.   def item_number  
  272.     return @data_number[self.index]  
  273.   end  
  274.   #--------------------------------------------------------------------------
  275.   # ● 刷新
  276.   #--------------------------------------------------------------------------
  277.   def refresh
  278.     if self.contents != nil
  279.       self.contents.dispose
  280.       self.contents = nil
  281.     end
  282.     @data = []
  283.     @data_number = []  
  284.     @forge_item = $game_temp.forge
  285.     for item_forge in @forge_item
  286.       case item_forge[0]
  287.       when 0
  288.         item = $data_items[item_forge[1]]
  289.       when 1
  290.         item = $data_weapons[item_forge[1]]
  291.       when 2
  292.         item = $data_armors[item_forge[1]]
  293.       end
  294.       if (item != nil) and (item_forge[2] != 0)  
  295.         @data.push(item)  
  296.         @data_number.push(item_forge[2])  
  297.       else  
  298.         @data.delete(item)  
  299.       end  
  300.     end
  301.     # 如果项目数不是 0 就生成位图、描绘全部项目
  302.     @item_max = @data.size
  303.     if @item_max > 0
  304.       self.contents = Bitmap.new(width - 32, row_max * 32)
  305.       for i in 0...@item_max
  306.         draw_item(i)
  307.       end
  308.     end
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● 描绘项目
  312.   #     index : 项目标号
  313.   #--------------------------------------------------------------------------
  314.   def draw_item(index)
  315.     item = @data[index]
  316.     case item
  317.     when RPG::Item
  318.       number = $game_temp.forge[index][2]
  319.     when RPG::Weapon
  320.       number = $game_temp.forge[index][2]
  321.     when RPG::Armor
  322.       number = $game_temp.forge[index][2]
  323.     end
  324.     self.contents.font.color = normal_color
  325.     x = 4
  326.     y = index * 32
  327.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  328.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  329.     bitmap = RPG::Cache.icon(item.icon_name)
  330.     opacity = self.contents.font.color == normal_color ? 255 : 128
  331.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  332.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  333.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  334.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 刷新帮助文本
  338.   #--------------------------------------------------------------------------
  339.   def update_help
  340.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  341.   end
  342. end

  343. #==============================================================================
  344. # ■ Scene_Compose
  345. #------------------------------------------------------------------------------
  346. #  处理物品合成画面的类
  347. #==============================================================================

  348. class Scene_Compose
  349. #--------------------------------------------------------------------------
  350. # ● 初始化
  351. #--------------------------------------------------------------------------
  352. def initialize
  353.    # 生成帮助窗口
  354.    @help_window = Window_Help.new
  355.    # 生成命令窗口
  356.    @command_window = Window_ComposeCommand.new
  357.    @command_window.active = false
  358.    # 生成左方窗口
  359.    @item_window = Window_ComposeLeft.new
  360.    @item_window.active = true
  361.    @item_window.help_window = @help_window
  362.    # 生成右方窗口
  363.    @forge_window = Window_ComposeRight.new([])
  364.    @forge_window.active = false
  365.    @forge_window.help_window = @help_window
  366.    # 初始化配方与合成区
  367.    @formulas = $game_system.formulas
  368.    @products = $game_system.products
  369.    @Forge = []
  370.    @products_temp = []      
  371. end
  372.   #--------------------------------------------------------------------------
  373.   # ● 主处理
  374.   #--------------------------------------------------------------------------
  375. def main
  376.    # 执行过渡
  377.    Graphics.transition
  378.    # 主循环
  379.    loop do
  380.      # 刷新游戏画面
  381.      Graphics.update
  382.      # 刷新输入情报
  383.      Input.update
  384.      # 刷新画面
  385.      update
  386.      # 如果画面被切换的话就中断循环
  387.      if $scene != self
  388.        break
  389.      end
  390.    end
  391.    # 准备过渡
  392.    Graphics.freeze
  393.    # 释放窗口
  394.    @help_window.dispose
  395.    @command_window.dispose
  396.    @item_window.dispose
  397.    @forge_window.dispose
  398. end
  399.   #--------------------------------------------------------------------------
  400.   # ● 刷新画面
  401.   #--------------------------------------------------------------------------  
  402. def update
  403.    @help_window.update
  404.    @command_window.update
  405.    @item_window.update
  406.    @forge_window.update
  407.    if @command_window.active
  408.      update_command
  409.      return
  410.    end
  411.    if @item_window.active
  412.      update_item
  413.      return
  414.    end
  415.    if @forge_window.active
  416.      update_forge
  417.      return
  418.    end
  419.     return
  420. end
  421.   #--------------------------------------------------------------------------
  422.   # ● 刷新画面(指令窗口激活的情况下)
  423.   #--------------------------------------------------------------------------
  424.   def update_command
  425.     # 按下 B 键的情况下
  426.     if Input.trigger?(Input::B)
  427.       # 演奏取消 SE
  428.       $game_system.se_play($data_system.cancel_se)
  429.       abort
  430.       # 切换到地图画面
  431.       $scene = Scene_Map.new
  432.       return
  433.     end
  434.      # 按下 C 键的情况下
  435.     if Input.trigger?(Input::C)
  436.       # 命令窗口光标位置分支
  437.       case @command_window.index
  438.       when 0  # 更改材料
  439.         # 演奏确定 SE
  440.         $game_system.se_play($data_system.decision_se)
  441.         # 窗口状态转向物品窗口
  442.         @command_window.active = false
  443.         @item_window.active = true
  444.         @forge_window.active = false
  445.       when 1  # 合成
  446.         # 演奏确定 SE
  447.         $game_system.se_play($data_system.decision_se)
  448.         # 执行合成命令
  449.         if $game_temp.forge != []
  450.           compose
  451.         end
  452.       when 2  # 放弃合成
  453.         # 演奏确定 SE
  454.         $game_system.se_play($data_system.decision_se)
  455.         # 放弃合成
  456.         abort
  457.       when 3  # 离开
  458.         # 演奏确定 SE
  459.         $game_system.se_play($data_system.decision_se)
  460.         # 放弃合成
  461.         abort
  462.         # 切换到地图画面
  463.         $scene = Scene_Map.new
  464.       end
  465.       return
  466.     end
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # ● 刷新画面(物品窗口激活的情况下)
  470.   #--------------------------------------------------------------------------
  471.   def update_item
  472.      # 按下 B 键的情况下
  473.     if Input.trigger?(Input::B)
  474.       # 演奏取消 SE
  475.       $game_system.se_play($data_system.cancel_se)
  476.       # 切换到指令窗口
  477.       @item_window.active = false
  478.       @command_window.active = true
  479.       @help_window.set_text("")
  480.       return
  481.     end
  482.      # 按下 C 键的情况
  483.     if Input.trigger?(Input::C)
  484.       # 演奏确定 SE
  485.       $game_system.se_play($data_system.decision_se)
  486.       # 获取物品
  487.       @item = @item_window.item
  488.       # 获取物品的所持数
  489.       case @item
  490.       when RPG::Item
  491.         number = $game_party.item_number(@item.id)
  492.         typetemp = 0
  493.       when RPG::Weapon
  494.         number = $game_party.weapon_number(@item.id)
  495.         typetemp = 1
  496.       when RPG::Armor
  497.         number = $game_party.armor_number(@item.id)
  498.         typetemp = 2
  499.       end
  500.       if number != nil
  501.         # 更改合成窗口的物品
  502.         case @item
  503.         when RPG::Item
  504.           $game_party.lose_item(@item.id, 1)
  505.         when RPG::Weapon
  506.           $game_party.lose_weapon(@item.id, 1)
  507.         when RPG::Armor
  508.           $game_party.lose_armor(@item.id, 1)
  509.         end
  510.         forge_change(typetemp, @item.id, 1)
  511.         # 刷新各窗口
  512.         @item_window.update
  513.         @help_window.update
  514.         @forge_window.update
  515.         @item_window.refresh
  516.         @forge_window.refresh
  517.       end
  518.     end
  519.      # 按下 右方向键 的情况
  520.     if Input.trigger?(Input::RIGHT)
  521.       # 切换到合成窗口
  522.       @item_window.active = false
  523.       @forge_window.active = true
  524.     end
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 刷新画面(合成窗口激活的情况下)
  528.   #--------------------------------------------------------------------------
  529.   def update_forge
  530.      # 按下 B 键的情况下
  531.     if Input.trigger?(Input::B)
  532.       # 演奏取消 SE
  533.       $game_system.se_play($data_system.cancel_se)
  534.       # 切换到指令窗口
  535.       @forge_window.active = false
  536.       @command_window.active = true
  537.       @help_window.set_text("")
  538.       return
  539.     end
  540.      # 按下 C 键的情况
  541.     if Input.trigger?(Input::C)
  542.      # 演奏确定 SE
  543.      $game_system.se_play($data_system.decision_se)
  544.      # 获取物品
  545.       @item = @forge_window.item
  546.       # 获取物品的所持数
  547.       case @item
  548.       when RPG::Item
  549.         number = @forge_window.item_number
  550.         typetemp = 0
  551.       when RPG::Weapon
  552.         number = @forge_window.item_number
  553.         typetemp = 1
  554.       when RPG::Armor
  555.         number = @forge_window.item_number
  556.         typetemp = 2
  557.       end
  558.      if number != nil
  559.        # 更改合成窗口的物品
  560.        case @item
  561.        when RPG::Item
  562.          $game_party.gain_item(@item.id, 1)
  563.        when RPG::Weapon
  564.          $game_party.gain_weapon(@item.id, 1)
  565.        when RPG::Armor
  566.          $game_party.gain_armor(@item.id, 1)
  567.        end
  568.        #p number
  569.        forge_change(typetemp, @item.id, -1)
  570.        # 刷新各窗口
  571.        @item_window.refresh
  572.        @forge_window.refresh
  573.        @help_window.update
  574.        @item_window.update
  575.        @forge_window.update
  576.       end
  577.     end
  578.        # 按下 左方向键 的情况下
  579.     if Input.trigger?(Input::LEFT)
  580.       # 切换到合成窗口
  581.       @forge_window.active = false
  582.       @item_window.active = true
  583.     end
  584.   end
  585.   #--------------------------------------------------------------------------
  586.   # ● 更改合成窗口物品
  587.   #--------------------------------------------------------------------------
  588.   def forge_change(type,id,number)  
  589.      quantity = number  
  590.      for item in $game_temp.forge
  591.        if (item[0]==type) and (item[1]==id)  
  592.          item[2] = [item[2] += quantity,99].min  
  593.          if item[2] == 0  
  594.            $game_temp.forge.delete(item)  
  595.          end
  596.          return  
  597.        end  
  598.      end  
  599.      $game_temp.forge.push([type,id,number])  
  600.   end  
  601.   #--------------------------------------------------------------------------
  602.   # ● 放弃合成
  603.   #--------------------------------------------------------------------------  
  604.   def abort
  605.     # 将合成窗口中的物品转移至物品窗口中
  606.     for item in $game_temp.forge
  607.       # 判断物品类型并归还
  608.       case item[0]
  609.       when 0
  610.         $game_party.gain_item(item[1], item[2])
  611.       when 1
  612.         $game_party.gain_weapon(item[1], item[2])
  613.       when 2
  614.         $game_party.gain_armor(item[1], item[2])
  615.       end
  616.     end
  617.     $game_temp.forge = []
  618.     # 刷新各窗口
  619.     @item_window.refresh
  620.     @forge_window.refresh
  621.   end
  622.   #--------------------------------------------------------------------------
  623.   # ● 检测是否有符合的配方
  624.   #--------------------------------------------------------------------------
  625. def match
  626.    match_one = false
  627.    match_this = false
  628.     # 检测每一个配方
  629.    for i in [email protected]
  630.      # 将合成窗口中的物品复制到合成缓存区
  631.      # 注意: 直接使用"="将传引用 导致检测配方是否匹配时合成窗口中物品被删除
  632.      @forge = $game_temp.forge.dup
  633.      # 检测这个配方中每一项材料
  634.      for ingredient in @formulas[i]
  635.        match_this = true
  636.        # 合成区中没有此项材料的情况
  637.        unless @forge.include?(ingredient)
  638.          match_this = false
  639.          break
  640.        end
  641.        # 从合成区中暂时删除这项材料
  642.        @forge.delete(ingredient)
  643.      end
  644.      if match_this == false
  645.        next
  646.      end
  647.      # 检测合成区中是否还有配方外的材料剩余
  648.      unless @forge == []
  649.        match_this = false
  650.      end
  651.      # 满足这一个配方的情况
  652.      if match_this == true
  653.        match_one = true
  654.        # 获取配方的成品
  655.        @products_temp = @products[i]
  656.        break
  657.      end
  658.    end
  659.    return match_one
  660. end
  661.   #--------------------------------------------------------------------------
  662.   # ● 合成
  663.   #--------------------------------------------------------------------------
  664. def compose
  665.    #判断合成消耗物品是否携带
  666.    if $game_party.item_number(10) >= 1
  667.      #合成消耗物品减少
  668.      $game_party.gain_item(10,-1)
  669.    # 如果有符合的配方
  670.    if match
  671.      # 将合成窗口中的材料改变为成品
  672.      $game_temp.forge = []
  673.      for i in 0...@products_temp.size
  674.       forge_change(@products_temp[i][0], @products_temp[i][1], @products_temp[i][2])
  675.     end
  676.      if $SE_Compose_Successful != ""
  677.        Audio.se_play($SE_Compose_Successful)
  678.      end
  679.    # 合成失败的情况
  680.    else  
  681.      if $SE_Compose_Failed != ""
  682.        Audio.se_play($SE_Compose_Failed)
  683.      end
  684.      if $Ingredient_Lost_When_Fail
  685.        $game_temp.forge = []
  686.      end
  687.    end
  688.    end
  689.     # 刷新各窗口
  690.    @item_window.refresh
  691.    @forge_window.refresh
  692. end
  693. end
复制代码

点评

原来删掉[URL]就可以了。太感谢了。能继续做游戏了  发表于 2014-11-24 22:58
大神太感谢了。[url=home.php?mod=space&uid=14254]@Forge[/url] = [] 是什么  发表于 2014-11-24 22:50

评分

参与人数 2星屑 +350 收起 理由
RyanBern + 200 认可答案
美丽晨露 + 150 我很赞同

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 13:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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