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

Project1

 找回密码
 注册会员
搜索

關於"道具合成"腳本,能否把分類都統一在一欄內?

查看数: 1621 | 评论数: 2 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2013-9-21 08:56

正文摘要:

先附上腳本原網址 :) http://izumiwhite.web.fc2.com/rgss3/rgss3_004_main_ver103.txt "RGSS3 アイテム合成 ver 1.03"- BY 白の魔 在這個腳本中它會自動先進入四個分類(道具、武器、裝備、重要物品)選項讓玩家選擇 ...

回复

chd114 发表于 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的...

查看全部评分

345912390 发表于 2013-9-21 09:14:01
可是可以不过很麻烦。
提供你一个思路: 在设置合成的数组里加上,一个ID位和一个Type(用来分辨物品武器)。再修改一下列表生成和合成部分就可以了。
自己动手,丰衣足食。*^_^*

点评

如果要創新一個ID跟TYPE 是要先在物品設定那裡增加嗎?  发表于 2013-9-22 00:20
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2025-2-4 03:42

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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