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

Project1

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

[RMVX发布] 2012/10/24更新BUG!!!!简单的【物品合成】脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
46 小时
注册时间
2011-9-13
帖子
55
跳转到指定楼层
1
发表于 2012-10-20 01:04:37 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 最后的信徒 于 2012-10-24 16:47 编辑

Project1.zip (257.68 KB, 下载次数: 254)

本脚本可以和【怪物图鉴+掉宝扩张】同用






关于自由合成的失败惩罚(没有相应的配方时):在1007行设置
  1. #============================================================================
  2. #   物品合成                    
  3. #============================================================================
  4. #                 作者:最后的信徒
  5. #                 时间:2012/10/24
  6. #============================================================================
  7. #使用方法:呼出合成菜单,在事件脚本中输入(6个中文):呼出合成菜单
  8. #          增加配方,在事件脚本中输入:增加配方(序号)
  9. #
  10. #配方的设置:请修改下面星星之间的的 配方
  11. #        如:$配方[序号] = [1,          #类型(1为物品,2为武器,3为防具)
  12. #                           1,          #成品的id
  13. #                           [1,1,1],    #材料1的类型、id和数量
  14. #                           [2,2,1],    #材料2的类型、id和数量
  15. #                           [3,3,1],    #材料3的类型、id和数量
  16. #                           [3,4,1],    #材料4的类型、id和数量
  17. #                           100]        #成功率
  18. #
  19. #规格说明:序号最好由0开始,填大于或等于0的整数;
  20. #          $配方[0]第1个元素为所合成的物品的类型;
  21. #                  第2个元素为所合成的物品的id;
  22. #                  第3至倒数第2个是材料,是一个数组,数组有3个元素,
  23. #                  数组的第1个元素是材料的类型,第2个是材料的id,
  24. #                  第3个是需要的数量;注意材料不要重复,种类最多可以设10个
  25. #                  最后一个元素是成功率
  26. #
  27. #      全局变量 $拥有的配方 中的元素为 配方的 序号
  28. #      请按需设置
  29. #
  30. #============================================================================
  31. #============================================================================
  32.     $拥有的配方 = []
  33.     $配方 = []
  34. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
  35. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
  36.     $配方[0] = [1,                       #类型(1为物品,2为武器,3为防具)
  37.                 3,                       #成品的id
  38.                 [1,1,1],                 #材料1的类型、id和数量
  39.                 100]                     #成功率
  40.                
  41.      
  42. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
  43. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
  44. #==============================================================================
  45. #------------------------------------------------------------------------------
  46. #  拥有光标的移动以及滚动功能的命令窗口类。
  47. #==============================================================================

  48. class Window_滚动命令1 < Window_Base
  49.   #--------------------------------------------------------------------------
  50.   # ● 定义实例变量
  51.   #--------------------------------------------------------------------------
  52.   attr_accessor   :item_max                 # 选项数
  53.   attr_accessor   :column_max               # 行数
  54.   attr_accessor   :index                    # 光标位置
  55.   attr_accessor   :命令组
  56.   #--------------------------------------------------------------------------
  57.   # ● 初始化对像
  58.   #     x      : 窗口 X 座标
  59.   #     y      : 窗口 Y 座标
  60.   #     width  : 窗口宽度
  61.   #     height : 窗口高度
  62.   #     命令组 :按钮数组
  63.   #     spacing : 横向排列时栏间空格
  64.   #--------------------------------------------------------------------------
  65.   def initialize(x, y, width, height, 命令组, spacing = 32)
  66.     @item_max = 命令组.size
  67.     @column_max = 1
  68.     @index = 0
  69.     @spacing = spacing
  70.     @命令组 = 命令组
  71.     super(x, y, width, height)
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ● 生成窗口内容
  75.   #--------------------------------------------------------------------------
  76.   def create_contents
  77.     self.contents.dispose
  78.     self.contents = Bitmap.new(width - 32, [height - 32, row_max * WLH].max)
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 设置光标位置
  82.   #     index : 新光标位置
  83.   #--------------------------------------------------------------------------
  84.   def index=(index)
  85.     @index = index
  86.     update_cursor
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● 计算行数
  90.   #--------------------------------------------------------------------------
  91.   def row_max
  92.     return (@item_max + @column_max - 1) / @column_max
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● 获取首行
  96.   #--------------------------------------------------------------------------
  97.   def top_row
  98.     return self.oy / WLH
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 设置首行
  102.   #     row : 显示在最上的行
  103.   #--------------------------------------------------------------------------
  104.   def top_row=(row)
  105.     row = 0 if row < 0
  106.     row = row_max - 1 if row > row_max - 1
  107.     self.oy = row * WLH
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # ● 获取一页能显示的行数
  111.   #--------------------------------------------------------------------------
  112.   def page_row_max
  113.     return (self.height - 32) / WLH
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 获取一页能显示的选项
  117.   #--------------------------------------------------------------------------
  118.   def page_item_max
  119.     return page_row_max * @column_max
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 获取末行
  123.   #--------------------------------------------------------------------------
  124.   def bottom_row
  125.     return top_row + page_row_max - 1
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● 设置末行
  129.   #     row : 显示在最底的行
  130.   #--------------------------------------------------------------------------
  131.   def bottom_row=(row)
  132.     self.top_row = row - (page_row_max - 1)
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 设置选项矩形
  136.   #     index : 项目编号
  137.   #--------------------------------------------------------------------------
  138.   def item_rect(index)
  139.     rect = Rect.new(0, 0, 0, 0)
  140.     rect.width = (contents.width + @spacing) / @column_max - @spacing
  141.     rect.height = WLH
  142.     rect.x = index % @column_max * (rect.width + @spacing)
  143.     rect.y = index / @column_max * WLH
  144.     return rect
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ● 判断光标是否能够移动
  148.   #--------------------------------------------------------------------------
  149.   def cursor_movable?
  150.     return false if (not visible or not active)
  151.     return false if (index < 0 or index > @item_max or @item_max == 0)
  152.     return false if (@opening or @closing)
  153.     return true
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 光标下移
  157.   #     wrap : 允许循环
  158.   #--------------------------------------------------------------------------
  159.   def cursor_down(wrap = false)
  160.     if (@index < @item_max - @column_max) or (wrap and @column_max == 1)
  161.       @index = (@index + @column_max) % @item_max
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 光标上移
  166.   #     wrap : 允许循环
  167.   #--------------------------------------------------------------------------
  168.   def cursor_up(wrap = false)
  169.     if (@index >= @column_max) or (wrap and @column_max == 1)
  170.       @index = (@index - @column_max + @item_max) % @item_max
  171.     end
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ● 光标右移
  175.   #     wrap : 允许循环
  176.   #--------------------------------------------------------------------------
  177.   def cursor_right(wrap = false)
  178.     if (@column_max >= 2) and
  179.        (@index < @item_max - 1 or (wrap and page_row_max == 1))
  180.       @index = (@index + 1) % @item_max
  181.     end
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 光标左移
  185.   #     wrap : 允许循环
  186.   #--------------------------------------------------------------------------
  187.   def cursor_left(wrap = false)
  188.     if (@column_max >= 2) and
  189.        (@index > 0 or (wrap and page_row_max == 1))
  190.       @index = (@index - 1 + @item_max) % @item_max
  191.     end
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 光标移至下一页
  195.   #--------------------------------------------------------------------------
  196.   def cursor_pagedown
  197.     if top_row + page_row_max < row_max
  198.       @index = [@index + page_item_max, @item_max - 1].min
  199.       self.top_row += page_row_max
  200.     end
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 光标移至上一页
  204.   #--------------------------------------------------------------------------
  205.   def cursor_pageup
  206.     if top_row > 0
  207.       @index = [@index - page_item_max, 0].max
  208.       self.top_row -= page_row_max
  209.     end
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 更新画面
  213.   #--------------------------------------------------------------------------
  214.   def update
  215.     super
  216.     if cursor_movable?
  217.       last_index = @index
  218.       if Input.repeat?(Input::DOWN)
  219.         cursor_down(Input.trigger?(Input::DOWN))
  220.       end
  221.       if Input.repeat?(Input::UP)
  222.         cursor_up(Input.trigger?(Input::UP))
  223.       end
  224.       if Input.repeat?(Input::RIGHT)
  225.         cursor_right(Input.trigger?(Input::RIGHT))
  226.       end
  227.       if Input.repeat?(Input::LEFT)
  228.         cursor_left(Input.trigger?(Input::LEFT))
  229.       end
  230.       if Input.repeat?(Input::R)
  231.         cursor_pagedown
  232.       end
  233.       if Input.repeat?(Input::L)
  234.         cursor_pageup
  235.       end
  236.       if @index != last_index
  237.         Sound.play_cursor
  238.       end
  239.     end
  240.     update_cursor
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 刷新
  244.   #--------------------------------------------------------------------------
  245.   def refresh
  246.     self.contents.clear
  247.     if @column_max == 1
  248.       for i in top_row..bottom_row
  249.         draw_item(i)
  250.       end
  251.     else
  252.       for i in 0..@item_max-1
  253.         draw_item(i)
  254.       end
  255.     end
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 绘制项目
  259.   #     index   : 项目位置
  260.   #     
  261.   #--------------------------------------------------------------------------
  262.   def draw_item(index)
  263.     rect = item_rect(index)
  264.     rect.x += 4
  265.     rect.width -= 8
  266.     self.contents.clear_rect(rect)
  267.     self.contents.font.color = normal_color
  268.     if @column_max == 1
  269.       self.contents.draw_text(rect, @命令组[index])
  270.     else
  271.       self.contents.draw_text(rect, @命令组[index],1)
  272.     end
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ● 更新光标
  276.   #--------------------------------------------------------------------------
  277.   def update_cursor
  278.     if @index < 0                   # 当光标位置小于0
  279.       self.cursor_rect.empty        # 隐藏光标
  280.     else                            # 当光标位置为0或大于
  281.       row = @index / @column_max    # 获取当前行
  282.       if row < top_row              # 若先于首行
  283.         self.top_row = row          # 向上滚动
  284.       end
  285.       if row > bottom_row           # 若後于末行
  286.         self.bottom_row = row       # 向下滚动
  287.       end
  288.       rect = item_rect(@index)      # 获取所选项目矩形
  289.       rect.y -= self.oy             # 设矩形为滚动位置
  290.       self.cursor_rect = rect       # 更新光标矩形
  291.     end
  292.     refresh
  293.   end
  294. end


  295. class Window_合成物品 < Window_Base
  296.   attr_accessor   :左边的物品       #数组,物品类型、id和持有数量
  297.   attr_accessor   :右边的物品       #数组,物品类型、id和数量
  298.   #==========================================================================
  299.   # ● 初始化对象
  300.   #==========================================================================
  301.   def initialize(x,y,n,m)
  302.     super(x, y, n, m)
  303.     @左边的物品 = []
  304.     @右边的物品 = []
  305.   end
  306.   
  307.   def 清除配方信息
  308.     self.contents.clear
  309.   end
  310.   
  311.   def 显示加入的材料
  312.     self.contents.clear
  313.     self.contents.font.color = Color.new(255, 0, 0, 255)
  314.     self.contents.font.size = 25
  315.     self.contents.draw_text(0,0,240,25, "按左、右键增减材料", 1)
  316.     #====================================================================
  317.     # ● 材料
  318.     #====================================================================
  319.     y = 0
  320.     材料=[]
  321.     self.contents.font.size = 15
  322.     self.contents.font.color = Color.new(255, 255, 0, 255)
  323.     self.contents.draw_text(0,50,240,15, "加入的材料", 0)
  324.     self.contents.draw_text(0,50,240,15, "数量", 2)
  325.     self.contents.font.color = Color.new(0, 255, 0, 255)
  326.     if @右边的物品.size > 0
  327.       for i in 0..@右边的物品.size-1
  328.         if @右边的物品[i] != nil
  329.           材料=@右边的物品[i]
  330.           case 材料[0]
  331.           when 1
  332.             text = $data_items[材料[1]].name.to_s
  333.             self.contents.draw_text(0,70+y*20,240,15, text, 0)
  334.             self.contents.draw_text(0,70+y*20,240,15, 材料[2].to_s, 2)
  335.           when 2
  336.             text = $data_weapons[材料[1]].name.to_s
  337.             self.contents.draw_text(0,70+y*20,240,15, text, 0)
  338.             self.contents.draw_text(0,70+y*20,240,15, 材料[2].to_s, 2)
  339.           when 3
  340.             text = $data_armors[材料[1]].name.to_s
  341.             self.contents.draw_text(0,70+y*20,240,15, text, 0)
  342.             self.contents.draw_text(0,70+y*20,240,15, 材料[2].to_s, 2)
  343.           end
  344.           y += 1
  345.         end
  346.       end
  347.     end
  348.   end
  349.   
  350.   
  351.   def 显示配方信息 (id)
  352.     if id >= 0
  353.       临时配方 = []
  354.       临时配方 = $配方[$拥有的配方[id]]
  355.       self.contents.clear
  356.       #====================================================================
  357.       # ● 配方名称
  358.       #====================================================================
  359.       case 临时配方[0]
  360.       when 1          #物品
  361.         text = $data_items[临时配方[1]].name.to_s
  362.         self.contents.font.color = Color.new(255, 0, 0, 255)
  363.         self.contents.font.size = 25
  364.         self.contents.draw_text(0,0,240,25, text, 1)
  365.       when 2          #武器
  366.         text = $data_weapons[临时配方[1]].name.to_s
  367.         self.contents.font.color = Color.new(255, 0, 0, 255)
  368.         self.contents.font.size = 25
  369.         self.contents.draw_text(0,0,240,25, text, 1)
  370.       when 3          #防具
  371.         text = $data_armors[临时配方[1]].name.to_s
  372.         self.contents.font.color = Color.new(255, 0, 0, 255)
  373.         self.contents.font.size = 25
  374.         self.contents.draw_text(0,0,240,25, text, 1)
  375.       end
  376.       #====================================================================
  377.       # ● 材料
  378.       #====================================================================
  379.       y = 0
  380.       材料=[]
  381.       self.contents.font.size = 15
  382.       self.contents.font.color = Color.new(255, 255, 0, 255)
  383.       self.contents.draw_text(0,50,240,15, "所需材料", 0)
  384.       self.contents.draw_text(0,50,240,15, "数量", 2)
  385.       for i in 2..临时配方.size-2
  386.         材料=临时配方[i]
  387.         case 材料[0]
  388.         when 1
  389.           if $game_party.item_number($data_items[材料[1]]) < 材料[2]
  390.             self.contents.font.color = Color.new(128, 128, 128, 255)
  391.           else
  392.             self.contents.font.color = Color.new(0, 255, 0, 255)
  393.           end
  394.           text = $data_items[材料[1]].name.to_s
  395.           self.contents.draw_text(0,70+y*20,240,15, text, 0)
  396.           text=$game_party.item_number($data_items[材料[1]]).to_s+"/"+材料[2].to_s
  397.           self.contents.draw_text(0,70+y*20,240,15, text, 2)
  398.         when 2
  399.           if $game_party.item_number($data_weapons[材料[1]]) < 材料[2]
  400.             self.contents.font.color = Color.new(128, 128, 128, 255)
  401.           else
  402.             self.contents.font.color = Color.new(0, 255, 0, 255)
  403.           end
  404.           text = $data_weapons[材料[1]].name.to_s
  405.           self.contents.draw_text(0,70+y*20,240,15, text, 0)
  406.           text=$game_party.item_number($data_weapons[材料[1]]).to_s+"/"+材料[2].to_s
  407.           self.contents.draw_text(0,70+y*20,240,15, text, 2)
  408.         when 3
  409.           if $game_party.item_number($data_armors[材料[1]]) < 材料[2]
  410.             self.contents.font.color = Color.new(128, 128, 128, 255)
  411.           else
  412.             self.contents.font.color = Color.new(0, 255, 0, 255)
  413.           end
  414.           text = $data_armors[材料[1]].name.to_s
  415.           self.contents.draw_text(0,70+y*20,240,15, text, 0)
  416.           text=$game_party.item_number($data_armors[材料[1]]).to_s+"/"+材料[2].to_s
  417.           self.contents.draw_text(0,70+y*20,240,15, text, 2)
  418.         end
  419.         y += 1
  420.       end
  421.       #====================================================================
  422.       # ● 成功率
  423.       #====================================================================
  424.       text = "成功率:"+临时配方[临时配方.size-1].to_s+"%"
  425.       self.contents.font.color = Color.new(255, 255, 0, 255)
  426.       self.contents.font.size = 15
  427.       self.contents.draw_text(0,30,240,15, text, 2)
  428.     end
  429.   end
  430. end

  431. #============================================================================
  432. class Game_Interpreter
  433.   #--------------------------------------------------------------------------
  434.   # ● 呼出合成菜单
  435.   #--------------------------------------------------------------------------
  436.   def 呼出合成菜单
  437.     return if $game_temp.in_battle           #判断是否战斗中
  438.     return if $game_map.interpreter.running? # 判断是否有事件正在执行
  439.     return if $game_player.moving?           # 判断主角是否移动中
  440.     $scene = Scene_合成物品.new
  441.   end
  442.   
  443.   def 增加配方(配方的序号)
  444.     #--------------------------------------------------------------------
  445.     #  增加配方
  446.     #--------------------------------------------------------------------
  447.     n = 0
  448.     for i in $拥有的配方
  449.       n += 1
  450.       if i == 结果[1]
  451.         n = false
  452.         break
  453.       else
  454.         if n == $拥有的配方.size
  455.           n = true
  456.         end
  457.       end
  458.     end
  459.     if n
  460.       $拥有的配方.push(结果[1])
  461.       临时配方=[]
  462.       临时配方=$配方[结果[1]]
  463.       临时=[]
  464.       临时=临时配方[0]
  465.       case 临时
  466.       when 1
  467.         临时=临时配方[1]
  468.         text = "发现 " + $data_items[临时].name + "配方"
  469.       when 2
  470.         text = "发现 " + $data_weapons[临时].name + "配方"
  471.       when 3
  472.         text = "发现 " + $data_armors[临时].name + "配方"
  473.       end
  474.       $game_message.texts.push(text)
  475.     end
  476.   end
  477. end

  478. #============================================================================
  479. # ● 处理
  480. #============================================================================
  481. class Scene_合成物品 < Scene_Base
  482.   #--------------------------------------------------------------------------
  483.   # ● 开始处理
  484.   #--------------------------------------------------------------------------
  485.   def start
  486.     super
  487.     生成顶部窗口
  488.     @无用窗口_window = Window_合成物品.new(0, 56, 272, 360)
  489.     @右边窗口_window = Window_合成物品.new (272, 56, 272, 360-56)
  490.     生成确认窗口
  491.     @左边窗口激活 = false
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 结束处理
  495.   #--------------------------------------------------------------------------
  496.   def terminate
  497.     super
  498.     @顶部窗口_window.dispose
  499.     @右边窗口_window.dispose
  500.     @无用窗口_window.dispose           
  501.     @确认窗口_window.dispose
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # ● 更新画面
  505.   #--------------------------------------------------------------------------
  506.   def update
  507.     super
  508.     @顶部窗口_window.update
  509.     @左边窗口_window.update if @左边窗口激活
  510.     @确认窗口_window.update
  511.    
  512.    
  513.     if @确认窗口_window.active
  514.       更新确认窗口
  515.       
  516.     elsif @左边窗口激活
  517.       更新左边窗口 if @左边窗口_window.active
  518.       
  519.     elsif @顶部窗口_window.active
  520.       更新顶部窗口
  521.       
  522.     end
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ● 生成顶部窗口
  526.   #--------------------------------------------------------------------------
  527.   def 生成顶部窗口
  528.     @顶部窗口_window = Window_滚动命令1.new(0, 0, 544, 56,["自由合成","配方合成"])
  529.     @顶部窗口_window.index = 0
  530.     @顶部窗口_window.column_max = 2
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ● 更新顶部窗口
  534.   #--------------------------------------------------------------------------
  535.   def 更新顶部窗口
  536.     if Input.trigger?(Input::B)
  537.       Sound.play_cancel
  538.       $scene = Scene_Map.new
  539.     elsif Input.trigger?(Input::C)
  540.       Sound.play_decision
  541.       
  542.       if @顶部窗口_window.index == 1
  543.         配方列表 = []
  544.         临时配方 = []
  545.         for i in $拥有的配方
  546.           临时配方 = $配方[i]
  547.           case 临时配方[0]
  548.           when 1
  549.             配方列表.push($data_items[临时配方[1]].name.to_s)
  550.           when 2
  551.             配方列表.push($data_weapons[临时配方[1]].name.to_s)
  552.           when 3
  553.             配方列表.push($data_armors[临时配方[1]].name.to_s)
  554.           end
  555.         end
  556.         if 配方列表.size > 0
  557.           @顶部窗口_window.active = false
  558.           生成左边窗口(配方列表)
  559.           @右边窗口_window.显示配方信息 (@左边窗口_window.index)
  560.           @右边窗口_window.update
  561.         end
  562.       else
  563.         #--------------------------------------------------------------------
  564.         #  获取物品资料
  565.         #--------------------------------------------------------------------
  566.         命令组=获取物品资料
  567.         #--------------------------------------------------------------------
  568.         #  将物品在左边窗口显示
  569.         #--------------------------------------------------------------------
  570.         if 命令组.size > 0
  571.          
  572.           @顶部窗口_window.active = false
  573.           生成左边窗口(命令组)
  574.           @右边窗口_window.右边的物品 = []
  575.           @右边窗口_window.显示加入的材料
  576.           @右边窗口_window.update
  577.         end
  578.          
  579.         
  580.         
  581.       end
  582.     elsif Input.trigger?(Input::DOWN) or Input.trigger?(Input::UP)
  583.       
  584.     end
  585.   end
  586.   #--------------------------------------------------------------------------
  587.   # ● 生成左边窗口
  588.   #--------------------------------------------------------------------------
  589.   def 生成左边窗口(命令组)
  590.     @左边窗口_window = Window_滚动命令1.new(0, 56, 272, 360,命令组)
  591.     @左边窗口_window.index = 0
  592.     @左边窗口_window.active = true
  593.     @左边窗口激活 = true
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● 释放左边窗口
  597.   #--------------------------------------------------------------------------
  598.   def 释放左边窗口
  599.     @左边窗口激活 = false
  600.     @左边窗口_window.dispose
  601.   end
  602.   #--------------------------------------------------------------------------
  603.   # ● shuaxin
  604.   #--------------------------------------------------------------------------
  605.   def shuaxin
  606.     @左边窗口_window.row_max
  607.     @左边窗口_window.top_row
  608.     @左边窗口_window.bottom_row
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ● 更新左边窗口
  612.   #--------------------------------------------------------------------------
  613.   def 更新左边窗口
  614.     if Input.trigger?(Input::B)
  615.       Sound.play_cancel
  616.       @右边窗口_window.清除配方信息
  617.       @右边窗口_window.update
  618.       @顶部窗口_window.active = true
  619.       释放左边窗口
  620.       @右边窗口_window.左边的物品 = []
  621.       @右边窗口_window.右边的物品 = []
  622.     elsif Input.trigger?(Input::C)
  623.       Sound.play_decision
  624.       @确认窗口_window.active = true
  625.       @左边窗口_window.active = false
  626.       @确认窗口_window.index = 0
  627.     elsif Input.trigger?(Input::DOWN) or Input.trigger?(Input::UP)
  628.       if @顶部窗口_window.index == 1
  629.         @右边窗口_window.显示配方信息 (@左边窗口_window.index)
  630.         @右边窗口_window.update
  631.       end
  632.     elsif Input.trigger?(Input::RIGHT) and @顶部窗口_window.index == 0
  633.       #--------------------------------------------------------------------
  634.       #  加入材料
  635.       #--------------------------------------------------------------------
  636.       临时1 = []
  637.       临时2 = []
  638.       临时1 = @右边窗口_window.左边的物品[@左边窗口_window.index]
  639.       for i in 0..9
  640.         if @右边窗口_window.右边的物品[i]!=nil
  641.           临时2 = @右边窗口_window.右边的物品[i]
  642.           if 临时1[0] == 临时2[0] and 临时1[1] == 临时2[1]
  643.             if 临时1[2]>临时2[2]
  644.               临时2[2] += 1
  645.               @右边窗口_window.右边的物品[i] = 临时2
  646.             end
  647.             break
  648.           elsif i == 9
  649.             for i in 0..9
  650.               if @右边窗口_window.右边的物品[i]==nil
  651.                 @右边窗口_window.右边的物品[i]=[临时1[0],临时1[1],1]
  652.                 break
  653.               end
  654.             end
  655.           end
  656.         elsif i == 9
  657.           for i in 0..9
  658.             if @右边窗口_window.右边的物品[i]==nil
  659.               @右边窗口_window.右边的物品[i]=[临时1[0],临时1[1],1]
  660.               break
  661.             end
  662.           end
  663.         end
  664.       end
  665.       @右边窗口_window.显示加入的材料
  666.       @右边窗口_window.update
  667.     elsif Input.trigger?(Input::LEFT) and @顶部窗口_window.index == 0
  668.       #--------------------------------------------------------------------
  669.       #  减少材料
  670.       #--------------------------------------------------------------------
  671.       临时1 = []
  672.       临时2 = []
  673.       临时1 = @右边窗口_window.左边的物品[@左边窗口_window.index]
  674.       for i in 0..@右边窗口_window.右边的物品.size-1
  675.         if @右边窗口_window.右边的物品[i]!=nil
  676.           临时2 = @右边窗口_window.右边的物品[i]
  677.           if 临时1[0]==临时2[0] and 临时1[1]==临时2[1] and 0<临时2[2]
  678.             临时2[2] -= 1
  679.             if 临时2[2]==0
  680.               @右边窗口_window.右边的物品[i] = nil
  681.             else
  682.               @右边窗口_window.右边的物品[i] = 临时2
  683.             end
  684.             break
  685.           end
  686.         end
  687.       end
  688.       @右边窗口_window.显示加入的材料
  689.       @右边窗口_window.update
  690.     end
  691.   end
  692.   
  693.   #--------------------------------------------------------------------
  694.   #  获取物品资料
  695.   #--------------------------------------------------------------------
  696.   def 获取物品资料
  697.     临时 = []
  698.     命令组 = []
  699.     for i in 1..$data_items.size-1
  700.       if $game_party.item_number($data_items[i]) > 0
  701.         临时[0] = 1
  702.         临时[1] = i
  703.         临时[2] = $game_party.item_number($data_items[i])
  704.         @右边窗口_window.左边的物品.push([临时[0],临时[1],临时[2]])
  705.         命令组.push($data_items[i].name.to_s+" X "+临时[2].to_s)
  706.       end
  707.     end
  708.     for i in 1..$data_weapons.size-1
  709.       if $game_party.item_number($data_weapons[i]) > 0
  710.         临时[0] = 2
  711.         临时[1] = i
  712.         临时[2] = $game_party.item_number($data_weapons[i])
  713.         @右边窗口_window.左边的物品.push([临时[0],临时[1],临时[2]])
  714.         命令组.push($data_weapons[i].name.to_s+" X "+临时[2].to_s)
  715.       end
  716.     end
  717.     for i in 1..$data_armors.size-1
  718.       if $game_party.item_number($data_armors[i]) > 0
  719.         临时[0] = 3
  720.         临时[1] = i
  721.         临时[2] = $game_party.item_number($data_armors[i])
  722.         @右边窗口_window.左边的物品.push([临时[0],临时[1],临时[2]])
  723.         命令组.push($data_armors[i].name.to_s+" X "+临时[2].to_s)
  724.       end
  725.     end
  726.     return 命令组
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ● 生成确认窗口
  730.   #--------------------------------------------------------------------------
  731.   def 生成确认窗口
  732.     @确认窗口_window = Window_滚动命令1.new(272,360,272,56,["确认合成","取消"])
  733.     @确认窗口_window.index = -1
  734.     @确认窗口_window.column_max = 2
  735.     @确认窗口_window.active = false
  736.   end
  737.   #--------------------------------------------------------------------------
  738.   # ● 更新确认窗口
  739.   #--------------------------------------------------------------------------
  740.   def 更新确认窗口
  741.     if Input.trigger?(Input::B)
  742.       Sound.play_cancel
  743.       @左边窗口_window.active = true
  744.       @确认窗口_window.active = false
  745.       @确认窗口_window.index = -1
  746.     elsif Input.trigger?(Input::C)
  747.       Sound.play_decision
  748.       if @确认窗口_window.index == 0
  749.         if @顶部窗口_window.index == 1
  750.           释放左边窗口
  751.           $scene = Scene_Map.new
  752.           if 判断合成条件(@左边窗口_window.index) == false
  753.             $game_message.texts.push("         材料不足")
  754.           else
  755.             $game_message.texts.push(执行配方合成(@左边窗口_window.index).to_s)
  756.           end
  757.         else
  758.           for i in 0..@右边窗口_window.右边的物品.size-1
  759.             @右边窗口_window.右边的物品.delete_at(i) if @右边窗口_window.右边的物品[i]==nil
  760.           end
  761.           if @右边窗口_window.右边的物品.size>0
  762.             释放左边窗口
  763.             $scene = Scene_Map.new
  764.             $game_message.texts.push(执行自由合成(自由合成判断).to_s)
  765.           end
  766.         end
  767.       else
  768.         @确认窗口_window.active = false
  769.         @左边窗口_window.active = true
  770.         @确认窗口_window.index = -1
  771.       end
  772.     end
  773.   end
  774.   #--------------------------------------------------------------------------
  775.   # ● 判断合成条件
  776.   #--------------------------------------------------------------------------
  777.   def 判断合成条件(id)
  778.     临时配方 = []
  779.     临时配方 = $配方[$拥有的配方[id]]
  780.     材料 = []
  781.     for i in 2..临时配方.size-2
  782.       材料=临时配方[i]
  783.       case 材料[0]
  784.       when 1
  785.         if $game_party.item_number($data_items[材料[1]])<材料[2]
  786.           return false
  787.           break
  788.         elsif i == 临时配方.size-2
  789.           return true
  790.         end
  791.       when 2
  792.         if $game_party.item_number($data_weapons[材料[1]])<材料[2]
  793.           return false
  794.           break
  795.         elsif i == 临时配方.size-2
  796.           return true
  797.         end
  798.       when 3
  799.         if $game_party.item_number($data_armors[材料[1]])<材料[2]
  800.           return false
  801.           break
  802.         elsif i == 临时配方.size-2
  803.           return true
  804.         end
  805.       end
  806.     end
  807.   end
  808.   #--------------------------------------------------------------------------
  809.   # ● 执行配方合成
  810.   #--------------------------------------------------------------------------
  811.   def 执行配方合成(id)
  812.     临时配方 = []
  813.     临时配方 = $配方[$拥有的配方[id]]
  814.     材料 = []
  815.     for i in 2..临时配方.size-2
  816.       材料=临时配方[i]
  817.       case 材料[0]
  818.       when 1
  819.         $game_party.gain_item($data_items[材料[1]],-材料[2])
  820.         $game_message.texts.push("失去 "+$data_items[材料[1]].name.to_s+" X "+材料[2].to_s)
  821.       when 2
  822.         $game_party.gain_item($data_weapons[材料[1]],-材料[2])
  823.         $game_message.texts.push("失去 "+$data_weapons[材料[1]].name.to_s+" X "+材料[2].to_s)
  824.       when 3
  825.         $game_party.gain_item($data_armors[材料[1]],-材料[2])
  826.         $game_message.texts.push("失去 "+$data_armors[材料[1]].name.to_s+" X "+材料[2].to_s)
  827.       end
  828.     end
  829.     if rand(100)+1<临时配方[临时配方.size-1]
  830.       case 临时配方[0]
  831.       when 1
  832.         $game_party.gain_item($data_items[临时配方[1]],1)
  833.         $game_message.texts.push("获得 "+$data_items[临时配方[1]].name.to_s+" X 1")
  834.       when 2
  835.         $game_party.gain_item($data_weapons[临时配方[1]],1)
  836.         $game_message.texts.push("获得 "+$data_weapons[临时配方[1]].name.to_s+" X 1")
  837.       when 3
  838.         $game_party.gain_item($data_armors[临时配方[1]],1)
  839.         $game_message.texts.push("获得 "+$data_armors[临时配方[1]].name.to_s+" X 1")
  840.       end
  841.       return "       !!!合成成功!!!"
  842.     else
  843.       return "       !!!失败!!!"
  844.     end
  845.   end
  846.   #--------------------------------------------------------------------------
  847.   # ● 自由合成判断
  848.   #--------------------------------------------------------------------------
  849.   def 自由合成判断
  850.     临时配方=[]
  851.     材料=[]
  852.     结果=[]
  853.     结果[0]=false
  854.     结果[1]= -1
  855.     for i in 0..$配方.size-1
  856.       循环判断 = true
  857.       临时配方=$配方[i]
  858.       if 临时配方.size-3 == @右边窗口_window.右边的物品.size
  859.         for a in 2..临时配方.size-2
  860.           材料=临时配方[a]
  861.           for b in 0..@右边窗口_window.右边的物品.size-1
  862.             if 材料==@右边窗口_window.右边的物品[b]
  863.               break
  864.             else
  865.               循环判断 = false if b == @右边窗口_window.右边的物品.size-1
  866.               break
  867.             end
  868.           end
  869.           break if 循环判断 == false
  870.           if a == 临时配方.size-2 and 循环判断 == true
  871.             结果[0]=true
  872.             结果[1]=i
  873.           end
  874.         end
  875.       else
  876.         循环判断 = false
  877.         break
  878.       end
  879.       if 结果[1] != -1
  880.         结果[0]=true
  881.         break
  882.       end
  883.       if i == $配方.size-1 and 结果[1] == -1
  884.         结果[0]=false
  885.       end
  886.     end
  887.     return 结果
  888.   end
  889.   #--------------------------------------------------------------------------
  890.   # ● 执行自由合成
  891.   #--------------------------------------------------------------------------
  892.   def 执行自由合成(结果)
  893.     if 结果[0] == true
  894.       临时配方=[]
  895.       材料=[]
  896.       临时配方=@右边窗口_window.右边的物品
  897.       for i in 0..临时配方.size-1
  898.         材料=临时配方[i]
  899.         case 材料[0]
  900.         when 1
  901.           $game_party.gain_item($data_items[材料[1]],-材料[2])
  902.           $game_message.texts.push("失去 "+$data_items[材料[1]].name.to_s+" X "+材料[2].to_s)
  903.         when 2
  904.           $game_party.gain_item($data_weapons[材料[1]],-材料[2])
  905.           $game_message.texts.push("失去 "+$data_weapons[材料[1]].name.to_s+" X "+材料[2].to_s)
  906.         when 3
  907.           $game_party.gain_item($data_armors[材料[1]],-材料[2])
  908.           $game_message.texts.push("失去 "+$data_armors[材料[1]].name.to_s+" X "+材料[2].to_s)
  909.         end
  910.       end
  911.       临时配方=[]
  912.       临时配方=$配方[结果[1]]
  913.       if rand(100)+1<临时配方[临时配方.size-1]
  914.         case 临时配方[0]
  915.         when 1
  916.           $game_party.gain_item($data_items[临时配方[1]],1)
  917.           $game_message.texts.push("获得 "+$data_items[临时配方[1]].name.to_s+" X 1")
  918.         when 2
  919.           $game_party.gain_item($data_weapons[临时配方[1]],1)
  920.           $game_message.texts.push("获得 "+$data_weapons[临时配方[1]].name.to_s+" X 1")
  921.         when 3
  922.           $game_party.gain_item($data_armors[临时配方[1]],1)
  923.           $game_message.texts.push("获得 "+$data_armors[临时配方[1]].name.to_s+" X 1")
  924.         end
  925.         #--------------------------------------------------------------------
  926.         #  增加配方
  927.         #--------------------------------------------------------------------
  928.         n = 0
  929.         for i in $拥有的配方
  930.           n += 1
  931.           if i == 结果[1]
  932.             n = false
  933.             break
  934.           else
  935.             if n == $拥有的配方.size
  936.               n = true
  937.             end
  938.           end
  939.         end
  940.         if n
  941.           $拥有的配方.push(结果[1])
  942.           临时配方=[]
  943.           临时配方=$配方[结果[1]]
  944.           临时=[]
  945.           临时=临时配方[0]
  946.           case 临时
  947.           when 1
  948.             临时=临时配方[1]
  949.             text = "发现 " + $data_items[临时].name + "配方"
  950.           when 2
  951.             text = "发现 " + $data_weapons[临时].name + "配方"
  952.           when 3
  953.             text = "发现 " + $data_armors[临时].name + "配方"
  954.           end
  955.           $game_message.texts.push(text)
  956.         end
  957.         return "       !!!合成成功!!!"
  958.       else
  959.         #--------------------------------------------------------------------
  960.         #  增加配方
  961.         #--------------------------------------------------------------------
  962.         n = 0
  963.         for i in $拥有的配方
  964.           n += 1
  965.           if i == 结果[1]
  966.             n = false
  967.             break
  968.           else
  969.             if n == $拥有的配方.size
  970.               n = true
  971.             end
  972.           end
  973.         end
  974.         if n
  975.           $拥有的配方.push(结果[1])
  976.           临时配方=[]
  977.           临时配方=$配方[结果[1]]
  978.           临时=[]
  979.           临时=临时配方[0]
  980.           case 临时
  981.           when 1
  982.             临时=临时配方[1]
  983.             text = "发现 " + $data_items[临时].name + "配方"
  984.           when 2
  985.             text = "发现 " + $data_weapons[临时].name + "配方"
  986.           when 3
  987.             text = "发现 " + $data_armors[临时].name + "配方"
  988.           end
  989.           $game_message.texts.push(text)
  990.         end
  991.         return "       !!!失败!!!"
  992.       end
  993.     else
  994.       合成失败惩罚(@右边窗口_window.右边的物品)
  995.       return "       !!!失败!!!"
  996.     end
  997.   end
  998.   #--------------------------------------------------------------------------
  999.   # ● 合成失败惩罚
  1000.   #--------------------------------------------------------------------------
  1001.   def 合成失败惩罚(材料)
  1002.     惩罚系数=1                    # 最多损失多少种材料,0为不损失,填0~10
  1003.     if 惩罚系数 > 0
  1004.       材料组=材料
  1005.       损失=[]
  1006.       临时=[]
  1007.       for i in 1..惩罚系数
  1008.         for i in 0..9
  1009.           if 材料组[i] != nil
  1010.             临时.push(i)
  1011.           end
  1012.         end
  1013.         临时=临时[rand(临时.size-1)]
  1014.         损失=材料组.delete_at(临时)
  1015.         case 损失[0]
  1016.         when 1
  1017.           $game_party.gain_item($data_items[损失[1]],-损失[2])
  1018.           $game_message.texts.push("失去 "+$data_items[损失[1]].name.to_s+" X"+损失[2].to_s)
  1019.         when 2
  1020.           $game_party.gain_item($data_weapons[损失[1]],-损失[2])
  1021.           $game_message.texts.push("失去 "+$data_weapons[损失[1]].name.to_s+" X"+损失[2].to_s)
  1022.         when 3
  1023.           $game_party.gain_item($data_armors[损失[1]],-损失[2])
  1024.           $game_message.texts.push("失去 "+$data_armors[损失[1]].name.to_s+" X"+损失[2].to_s)
  1025.         end
  1026.         break if 材料组.size == 0
  1027.       end
  1028.     end
  1029.   end
  1030.   
  1031. end
复制代码

点评

但是左边不减少会感觉很诡异···不合理啊  发表于 2012-10-24 12:29

Lv2.观梦者

梦石
0
星屑
519
在线时间
664 小时
注册时间
2010-6-30
帖子
223
2
发表于 2012-10-20 11:09:51 | 只看该作者
使用方法:呼出合成菜单,在事件脚本中输入(4个中文):呼出合成菜单  {:2_270:} 我进来就看见不尽人意的地方...


{:2_275:}4个字...  呼出合成菜单..

点评

被你发现了.......  发表于 2012-10-20 11:51
回复 支持 反对

使用道具 举报

Lv4.逐梦者

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

开拓者

3
发表于 2012-10-20 12:10:21 | 只看该作者
虽然不想打击,但是这个脚本很常见···你应该玩玩开罗游戏的吃货大食堂,那种合成不会告诉你配方成品什么的,材料是自己选,满足某个配方就得到提示:可以制作XX了,如果是没学会的配方就会说:客人应该也会喜欢、这组合不太好、最近市面上很流行之类的话

点评

吃货大食堂这种游戏太复杂了= =开罗的游戏到现在我也只理解了游戏发展国的操作,其他的都看不懂啊泥煤的  发表于 2012-10-20 16:55
! 有考虑过.....不过我还是新人,将就下吧。。。  发表于 2012-10-20 13:03
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
191
在线时间
835 小时
注册时间
2012-9-16
帖子
1811
4
发表于 2012-10-20 13:17:39 | 只看该作者
什么叫:四个字:呼出菜单???

——旧坑欢迎戳
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
86 小时
注册时间
2011-2-2
帖子
55
5
发表于 2012-10-20 14:44:06 | 只看该作者
本帖最后由 chg1998 于 2012-10-20 15:01 编辑

图片顶上,只不过图片作者做的不错。关键是应该附上附件!!!!!!!

目测脚本里可以有汉字么?

点评

范例么?随便新建个游戏加脚本进去就好了啊。。。  发表于 2012-10-20 17:39
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
71
在线时间
288 小时
注册时间
2011-9-22
帖子
226
6
发表于 2012-10-21 20:59:01 | 只看该作者
呼不出来啊撸主!!太坑了啊!

点评

表示很悲哀........  发表于 2012-10-22 21:17
真的呼不出来,在新建的工程里试也不行。。  发表于 2012-10-21 21:32
真的呼不出来,在新建的工程里试也不行。。  发表于 2012-10-21 21:32
事件脚本写:呼出合成菜单 另:此脚本正在更新中  发表于 2012-10-21 21:17
http://img165.poco.cn/mypoco/myphoto/20110922/20/6420219220110922203357086.jpg
永不停歇的追尋者。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
46 小时
注册时间
2011-9-13
帖子
55
7
 楼主| 发表于 2012-10-22 21:16:19 | 只看该作者

点评

谢谢给你添麻烦了,现在没事了能打开了= =  发表于 2012-10-24 20:29
绝对没按错,但就是怎么都打不开合成菜单。。  发表于 2012-10-24 20:22
范例那里,你确定按的是A(Z)?  发表于 2012-10-24 11:03
[url=home.php?mod=space&username=Password]@Password[/url] bug还好说,这个我真的不知道怎么弄  发表于 2012-10-23 17:40
[url=home.php?mod=space&username=羁绊の终]@羁绊の终[/url] 表示无能为力.....  发表于 2012-10-23 17:34
回复 支持 反对

使用道具 举报

Lv2.观梦者 (版主)

HATSUNE★MIKU
KAGAMINE★LEN
KAGAMINE★RIN
MEGURINE★LUKA

梦石
0
星屑
849
在线时间
1172 小时
注册时间
2012-4-2
帖子
5035

开拓者

8
发表于 2012-10-22 22:03:19 | 只看该作者
好多啊
感觉不是“简单”啊

点评

代码嘛....是可以优化的......我说的简单主要是画面啊,排版啊之类的.........太罗嗦噜~~~~  发表于 2012-10-22 22:06
回复 支持 反对

使用道具 举报

Lv4.逐梦者

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

开拓者

9
发表于 2012-10-23 00:29:21 | 只看该作者
本帖最后由 chd114 于 2012-10-23 00:40 编辑

比上次的有进步···不过把自由合成中的左侧物品已经放到右边了,左边的却没减少岂不是不正常?



‘‘──chd114于2012-10-23 00:31补充以下内容:

大概应该是这样···另外楼主如果可以成功做出VX版本的可以尝试XP和AV的,最后你可以考虑做成一个通用的(RMAVXP都可以直接用的那种)
’’











http://tieba.baidu.com/p/1938320701我还是给你参考图地址吧···6R的图片上传又抽风···

点评

左边的材料是没有减少,但是右边的材料绝对不会比左边的多  发表于 2012-10-24 11:06
目前不打算更新了...  发表于 2012-10-24 11:04
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
268
在线时间
160 小时
注册时间
2014-9-17
帖子
67
10
发表于 2015-2-12 23:43:45 | 只看该作者
怎么呼出啊,脚本里的呼出方法不行啊!
c
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-28 13:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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