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

Project1

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

[已经解决] 求大神整合一下这两个脚本。

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
125 小时
注册时间
2006-7-19
帖子
336
跳转到指定楼层
1
发表于 2016-1-17 20:44:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
第一个是 @韩云溪  大大的 任务系统 ,由@zyyczp   工藤由纪  进行过改进。
脚本代码如下:
RUBY 代码复制
  1. =begin
  2. 领取任务:$game_party.get_task(任意数字,任务名称,任务描述)
  3. 完成任务:$game_party.finish_task(领取任务时设定的数字)
  4. 对已有任务追加说明:$game_party.add_task(任务编号,任务追加描述)
  5.  
  6. 如:
  7. 前面有事件$game_party.get_task(1,"测试","只是测试")
  8.  
  9. 此时任务1的说明为
  10.  
  11. >只是测试
  12.  
  13. 后面完成任务的脚本就是$game_party.finish_task(1)
  14.  
  15. 追加说明$game_party.add_task(1,"真的只是测试哦")
  16.  
  17. 此时任务1的说明为:
  18. >只是测试
  19. >真的只是测试哦
  20.  
  21. 召唤任务界面:SceneManager.call(Scene_Task)
  22.  
  23. 该脚本来自66rpg,发布者:韩云溪
  24. 改进:工藤由纪(论坛ID:zyyczp)
  25. =end
  26.  
  27. #===========================================================
  28. #●任务系统
  29. #===========================================================
  30. class Task
  31.   attr_reader :desc
  32.   attr_reader :finished
  33.   def initialize(origin_name,desc)
  34.     @origin_name = origin_name
  35.     @desc = desc
  36.     @finished = false
  37.   end
  38.   def name
  39.     if @finished
  40.       return @origin_name + "(完成)"
  41.     else
  42.       return @origin_name
  43.     end
  44.   end
  45.   def desc=(desc)
  46.     @desc = desc
  47.   end
  48.  
  49.   def finish
  50.     @finished = true
  51.   end
  52.  
  53. end
  54.  
  55. class Game_Party < Game_Unit
  56.   alias old_init initialize
  57.   def initialize
  58.     old_init
  59.     @tasks = {}
  60.   end
  61.   def add_task(i,desc)
  62.     @tasks[i].desc = @tasks[i].desc + "\n" + desc
  63.   end
  64.   def get_task(i,name,desc)
  65.     @tasks[i]=Task.new(name,desc)
  66.   end
  67.   def have_task?(i)
  68.     @tasks[i] != nil
  69.   end
  70.   def finish_task(i)
  71.     @tasks[i].finish if have_task?(i)
  72.   end
  73.   def unfinished_tasks
  74.     n = []
  75.     for i in @tasks.values
  76.       next if i.finished
  77.       n.push(i)
  78.     end
  79.     return n
  80.   end
  81.   def finished_tasks
  82.     n = []
  83.     for i in @tasks.values
  84.       next unless i.finished
  85.       n.push(i)
  86.     end
  87.     return n
  88.   end
  89. end
  90.  
  91. class Window_Task_Type < Window_HorzCommand
  92.   #--------------------------------------------------------------------------
  93.   # ● オブジェクト初期化
  94.   #--------------------------------------------------------------------------
  95.   def initialize
  96.     super(0, 0)
  97.     activate
  98.   end
  99.   def window_width
  100.     return Graphics.width
  101.   end
  102.   def col_max
  103.     return 3
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● コマンドリストの作成
  107.   #--------------------------------------------------------------------------
  108.   def make_command_list
  109.     add_command("未完成任务",  :unfinished_task)
  110.     add_command("已完成任务", :finished_task)
  111.     add_command("取消", :cancel)
  112.   end
  113. end
  114.  
  115. class Window_TaskLeft < Window_Selectable
  116.   attr_reader :finished
  117.   def initialize
  118.     super(0,48,160,Graphics.height - 48)
  119.     create_contents
  120.     @finished = false
  121.     @index = 0
  122.     refresh
  123.     deactivate
  124.   end
  125.   def set_finish(finish)
  126.     @finished = finish
  127.     set_item_max
  128.   end
  129.   def item_max
  130.     return @item_max != nil ? @item_max : 0
  131.   end
  132.   def set_item_max
  133.     if @finished
  134.       @item_max = $game_party.finished_tasks.size
  135.     else
  136.       @item_max = $game_party.unfinished_tasks.size
  137.     end
  138.   end
  139.  
  140.   def refresh
  141.     set_item_max
  142.     super
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 項目の描画
  146.   #--------------------------------------------------------------------------
  147.   def draw_item(index)
  148.     text = ""
  149.     unless @finished
  150.       if $game_party.unfinished_tasks[index] != nil
  151.         text = $game_party.unfinished_tasks[index].name
  152.       end
  153.     else
  154.       if $game_party.finished_tasks[index] != nil
  155.         text = $game_party.finished_tasks[index].name  
  156.       end
  157.     end
  158.     draw_text(item_rect_for_text(index), text)
  159.   end
  160.  
  161. end
  162.  
  163. class Window_TaskRight < Window_Base
  164.   attr_reader :left_index
  165.   def initialize
  166.     super(160,48,Graphics.width - 160,Graphics.height - 48)
  167.     create_contents
  168.     @left_index = 0
  169.     @finished = false
  170.     refresh
  171.   end
  172.   def set_index(i)
  173.     @left_index = i
  174.     refresh
  175.   end
  176.   def set_finish(i)
  177.     @finished = i
  178.   end
  179.  
  180.   def refresh
  181.     contents.clear
  182.     draw_desc
  183.   end
  184.   def draw_desc
  185.     if @finished
  186.       if $game_party.finished_tasks[@left_index] != nil
  187.         draw_text_ex(0,0,$game_party.finished_tasks[@left_index].desc)
  188.       end
  189.     else
  190.       if $game_party.unfinished_tasks[@left_index] != nil
  191.         draw_text_ex(0,0,$game_party.unfinished_tasks[@left_index].desc)
  192.       end
  193.     end
  194.   end
  195.  
  196. end
  197.  
  198. class Scene_Task < Scene_Base
  199.   def start
  200.     super
  201.     create_task_type_window
  202.     create_left_window
  203.     create_right_window
  204.   end
  205.   def update
  206.     super
  207.     if @left_window.active
  208.       if Input.trigger?(:B)
  209.         @left_window.deactivate
  210.         @task_type_window.activate
  211.       end
  212.       if Input.trigger?(:UP) || Input.trigger?(:DOWN)
  213.         @right_window.set_finish(@left_window.finished)
  214.         @right_window.set_index(@left_window.index)
  215.       end
  216.     end
  217.   end
  218.  
  219.   def terminate
  220.     super
  221.   end
  222.   def create_task_type_window
  223.     @task_type_window = Window_Task_Type.new
  224.     @task_type_window.set_handler(:unfinished_task,method(:view_unfinished_task))
  225.     @task_type_window.set_handler(:finished_task,method(:view_finished_task))
  226.     @task_type_window.set_handler(:cancel,method(:return_scene))
  227.   end
  228.   def create_left_window
  229.     @left_window = Window_TaskLeft.new
  230.     @left_window.set_finish(false)
  231.     @left_window.refresh
  232.   end
  233.   def create_right_window
  234.     @right_window = Window_TaskRight.new
  235.     @right_window.refresh
  236.   end
  237.   def view_unfinished_task
  238.     @left_window.set_finish(false)
  239.     @left_window.refresh
  240.     @left_window.activate
  241.     @task_type_window.deactivate
  242.     @right_window.set_finish(false)
  243.     @right_window.set_index(@left_window.index)
  244.   end
  245.   def view_finished_task
  246.     @left_window.set_finish(true)
  247.     @left_window.refresh
  248.     @left_window.activate
  249.     @task_type_window.deactivate
  250.     @right_window.set_finish(true)
  251.     @right_window.set_index(@left_window.index)
  252.   end
  253.  
  254. end


第二个是由 @utf-8  译成的, 物品制造的 脚本,就是可以将一种或者多种 物品 合成另一种物品。
脚本代码如下:
RUBY 代码复制
  1. #encoding:utf-8
  2. #==============================================================================
  3. # 本腳本來自[url]www.66RPG.com[/url],使用和轉載請保留此信息
  4. #==============================================================================
  5. #==============================================================================
  6. #
  7. #每添加一个制造的类型,最上面的类别菜单就会多一项。
  8. #
  9. #添加类型的方法是:
  10. #$game_party.add_cook_type(类别名称,类别介绍, 类别状态-默认false)
  11. #
  12. #举例:
  13. #$game_party.add_cook_type("制药","调配药品", true)
  14. #
  15. #添加配方的方法:
  16. #$game_party.add_cookbook(配方名称, 配方介绍, 配方类别名称,材料的二维数组,产出物的二维数组,配方状态)
  17. #
  18. #举例:
  19. #$game_party.add_cookbook("初级补血药水", "制作初级补血药水", "制药",[[18,2]],[[1,1]],true)
  20. #
  21. #调用窗口的方法:SceneManager.call(Scene_Cook)
  22. #
  23. #
  24. #==============================================================================
  25.  
  26. #==============================================================================
  27. # ■ Cookbook_Type
  28. #------------------------------------------------------------------------------
  29. #  食谱类型类。
  30. #==============================================================================
  31.  
  32. class Cookbook_Type
  33.   attr_reader :index
  34.   attr_reader :name
  35.   attr_reader :description
  36.   attr_reader :enabled
  37.   #--------------------------------------------------------------------------
  38.   # ● 初始化对象
  39.   #--------------------------------------------------------------------------
  40.   def initialize(index, name, description, enabled = false)
  41.     @index = index
  42.     @name = name
  43.     @description = description
  44.     @enabled = enabled
  45.   end
  46.  
  47.   def enable(en)
  48.     @enabled = en
  49.   end
  50. end
  51.  
  52. #==============================================================================
  53. # ■ Cookbook
  54. #------------------------------------------------------------------------------
  55. #  食谱类。本类在 Game_Task 类的内部使用。
  56. #   食谱属性:食谱序号,食谱名称,食谱类型,食谱介绍,原料,成品
  57. #==============================================================================
  58.  
  59. class Cookbook
  60.   attr_reader :index
  61.   attr_reader :name
  62.   attr_reader :description
  63.   attr_reader :type
  64.   attr_reader :input
  65.   attr_reader :output
  66.   attr_reader :enabled
  67.   #--------------------------------------------------------------------------
  68.   # ● 初始化对象
  69.   #--------------------------------------------------------------------------
  70.   def initialize(index, name, description, type, input, output, enabled = true)
  71.     @index = index
  72.     @name = name
  73.     @description = description
  74.     @type = type
  75.     @input = input
  76.     @output = output
  77.     @enabled = enabled
  78.   end
  79.  
  80.   def enable(en)
  81.     @enabled = en
  82.   end
  83.  
  84.   #--------------------------------------------------------------------------
  85.   # ● 查询列表中的物品
  86.   #--------------------------------------------------------------------------
  87.   def in_list?(item, list)
  88.     list.each do |arr|
  89.       return true if arr[0] == item.id
  90.     end
  91.     return false
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 查询是否是材料列表中的物品
  95.   #--------------------------------------------------------------------------
  96.   def resource?(item)
  97.     in_list?(item, @input)
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 查询是否是产出列表中的物品
  101.   #--------------------------------------------------------------------------
  102.   def output?(item)
  103.     in_list?(item, @output)
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 查询材料需求量
  107.   #--------------------------------------------------------------------------
  108.   def amount(item, i)
  109.     if i == 0
  110.       @input.each do |arr|
  111.         return arr[1] if arr[0] == item.id
  112.       end
  113.     else
  114.       @output.each do |arr|
  115.         return arr[1] if arr[0] == item.id
  116.       end
  117.     end
  118.     return 0
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 查询材料是否足够
  122.   #--------------------------------------------------------------------------
  123.   def enough?
  124.     input.each do |arr|
  125.       return false if $data_items[arr[0]] && arr[1] > $game_party.item_number($data_items[arr[0]])
  126.     end
  127.     return true
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 查询某件材料是否足够
  131.   #--------------------------------------------------------------------------
  132.   def item_enough?(item)
  133.     input.each do |arr|
  134.       return false if arr[0] == item.id && arr[1] > $game_party.item_number(item)
  135.     end
  136.     return true
  137.   end
  138. end
  139.  
  140. #==============================================================================
  141. # ■ Game_Party
  142. #==============================================================================
  143.  
  144. class Game_Party < Game_Unit
  145.   #--------------------------------------------------------------------------
  146.   # ● 初始化对象
  147.   #--------------------------------------------------------------------------
  148.   alias old_init initialize
  149.   def initialize
  150.     old_init
  151.     @cook_types = []
  152.     @cookbooks = []
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 添加新的制造类型
  156.   #--------------------------------------------------------------------------
  157.   def add_cook_type(n, d, en)
  158.     @cook_types.push(Cookbook_Type.new(@cook_types.size, n, d, en)) if !have_cook_type?(n)
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 添加新的食谱
  162.   #--------------------------------------------------------------------------
  163.   def add_cookbook(n, d, type, input, output, en)
  164.     if !have_cookbook?(n) && have_cook_type?(type)
  165.       @cookbooks.push(Cookbook.new(@cookbooks.size, n, d, type, input, output, en))
  166.     end
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ● 判断名称为n的制造类型是否存在
  170.   #--------------------------------------------------------------------------
  171.   def have_cook_type?(n)
  172.     @cook_types.each do |x|
  173.       return true if x.name == n
  174.     end
  175.     return false
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 判断名称为n的食谱是否存在
  179.   #--------------------------------------------------------------------------
  180.   def have_cookbook?(n)
  181.     @cookbooks.each do |x|
  182.       return true if x.name == n
  183.     end
  184.     return false
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 返回制造类型列表
  188.   #--------------------------------------------------------------------------
  189.   def cook_types
  190.     return @cook_types
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● 返回食谱列表
  194.   #--------------------------------------------------------------------------
  195.   def cookbooks(type = nil)
  196.     return @cookbooks if type == nil
  197.     arr = []
  198.     @cookbooks.each do |x|
  199.       arr.push(x) if x.type == type
  200.     end
  201.     return arr
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● 更改序号为i的制造类型的使用状态
  205.   #--------------------------------------------------------------------------
  206.   def set_cook_type(i, en)
  207.     @cook_types[i].enable(en)
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 更改序号为i的食谱的使用状态
  211.   #--------------------------------------------------------------------------
  212.   def set_cookbook(i, en)
  213.     @cookbooks[i].enable(en)
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● 返回制造类型数目
  217.   #--------------------------------------------------------------------------
  218.   def cook_types_size
  219.     return @cook_types.size
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 查询名称为n的制造类型的描述
  223.   #--------------------------------------------------------------------------
  224.   def cook_type_description(n)
  225.     @cook_types.each do |x|
  226.       return x.description if x.name == n
  227.     end
  228.     return ""
  229.   end
  230. end
  231.  
  232. #==============================================================================
  233. # ■ Scene_Cook
  234. #------------------------------------------------------------------------------
  235. #  制造画面
  236. #==============================================================================
  237.  
  238. class Scene_Cook < Scene_ItemBase
  239.   #--------------------------------------------------------------------------
  240.   # ● 开始处理
  241.   #--------------------------------------------------------------------------
  242.   def start
  243.     super
  244.     create_category_window
  245.     create_cookbook_window
  246.     create_description_window
  247.     create_needs_window
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 生成分类窗口
  251.   #--------------------------------------------------------------------------
  252.   def create_category_window
  253.     @category_window = Window_CookCategory.new
  254.     @category_window.viewport = @viewport
  255.     @category_window.y = 0
  256.     @category_window.set_handler(:ok,     method(:on_category_ok))
  257.     @category_window.set_handler(:cancel, method(:return_scene))
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● 生成食谱窗口
  261.   #--------------------------------------------------------------------------
  262.   def create_cookbook_window
  263.     wy = @category_window.height
  264.     wh = Graphics.height - wy
  265.     @item_window = Window_CookList.new(0, wy, Graphics.width*0.5 , wh)
  266.     @item_window.viewport = @viewport
  267.     @item_window.set_handler(:ok,     method(:on_item_ok))
  268.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  269.     @category_window.item_window = @item_window
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 生成描述窗口
  273.   #--------------------------------------------------------------------------
  274.   def create_description_window
  275.     wy = @category_window.height
  276.     @help_window = Window_Description.new(Graphics.width*0.5, wy)
  277.     @help_window.viewport = @viewport
  278.     @item_window.help_window = @help_window
  279.     @category_window.help_window = @help_window
  280.   end
  281.     #--------------------------------------------------------------------------
  282.   # ● 生成材料窗口
  283.   #--------------------------------------------------------------------------
  284.   def create_needs_window
  285.     wy = @category_window.height + @help_window.height
  286.     wh = Graphics.height - wy
  287.     @needs_window = Window_NeedsList.new(Graphics.width*0.5, wy, Graphics.width*0.5 , wh)
  288.     #@item_window.viewport = @viewport
  289.     @item_window.needs_window = @needs_window
  290.  
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # ● 分类“确定”
  294.   #--------------------------------------------------------------------------
  295.   def on_category_ok
  296.     @item_window.activate
  297.     @item_window.select_last
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● 食谱“确定”
  301.   #--------------------------------------------------------------------------
  302.   def on_item_ok
  303.     #$game_party.last_item.object = item
  304.     cook
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # ● 食谱“取消”
  308.   #--------------------------------------------------------------------------
  309.   def on_item_cancel
  310.     @item_window.unselect
  311.     @category_window.activate
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   # ● 制造
  315.   #--------------------------------------------------------------------------
  316.   def cook
  317.     if item.enough?
  318.       play_se_for_item
  319.       use_item
  320.       @needs_window.refresh
  321.       @item_window.refresh
  322.       activate_item_window
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 播放制作声效
  327.   #--------------------------------------------------------------------------
  328.   def play_se_for_item
  329.     Sound.play_recovery
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● 使用食谱
  333.   #--------------------------------------------------------------------------
  334.   def use_item
  335.     #super
  336.     #@item_window.redraw_current_item
  337.     $data_items.each do |it|
  338.       if it && !it.name.empty?
  339.         $game_party.gain_item(it,-item.amount(it,0)) if item.resource?(it)
  340.         $game_party.gain_item(it,item.amount(it,1)) if item.output?(it)
  341.       end
  342.     end
  343.   end
  344. end
  345.  
  346.  
  347. #==============================================================================
  348. # ■ Window_CookCategory
  349. #------------------------------------------------------------------------------
  350. #  制造画面中,显示制造类型的窗口。
  351. #==============================================================================
  352.  
  353. class Window_CookCategory < Window_HorzCommand
  354.   #--------------------------------------------------------------------------
  355.   # ● 定义实例变量
  356.   #--------------------------------------------------------------------------
  357.   attr_reader   :item_window
  358.   #--------------------------------------------------------------------------
  359.   # ● 初始化对象
  360.   #--------------------------------------------------------------------------
  361.   def initialize
  362.     super(0, 0)
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 获取窗口的宽度
  366.   #--------------------------------------------------------------------------
  367.   def window_width
  368.     Graphics.width
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ● 获取列数
  372.   #--------------------------------------------------------------------------
  373.   def col_max
  374.     return $game_party.cook_types_size
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 更新画面
  378.   #--------------------------------------------------------------------------
  379.   def update
  380.     super
  381.     #@item_window.category = current_symbol if @item_window
  382.     @item_window.category = current_data[:name] if @item_window
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # ● 生成制造列表
  386.   #--------------------------------------------------------------------------
  387.   def make_command_list
  388.     $game_party.cook_types.each do |t|
  389.       add_command(t.name, t.index, t.enabled)
  390.     end
  391.   end
  392.   #--------------------------------------------------------------------------
  393.   # ● 设置制造列表窗口
  394.   #--------------------------------------------------------------------------
  395.   def item_window=(item_window)
  396.     @item_window = item_window
  397.     update
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # ● 更新帮助内容
  401.   #--------------------------------------------------------------------------
  402.   def update_help
  403.     @help_window.set_text($game_party.cook_type_description(current_data[:name]))
  404.   end
  405. end
  406.  
  407. #==============================================================================
  408. # ■ Window_CookList
  409. #------------------------------------------------------------------------------
  410. #  任务画面中,显示已获得任务的窗口。
  411. #==============================================================================
  412.  
  413. class Window_CookList < Window_Selectable
  414.   #--------------------------------------------------------------------------
  415.   # ● 定义实例变量
  416.   #--------------------------------------------------------------------------
  417.   attr_reader   :needs_window
  418.   #--------------------------------------------------------------------------
  419.   # ● 初始化对象
  420.   #--------------------------------------------------------------------------
  421.   def initialize(x, y, width, height)
  422.     super
  423.     @data = []
  424.     @category = $game_party.cook_types_size > 0 ? $game_party.cook_types[0].name : nil
  425.     refresh
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ● 设置分类
  429.   #--------------------------------------------------------------------------
  430.   def category=(category)
  431.     return if @category == category
  432.     @category = category
  433.     refresh
  434.     self.oy = 0
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # ● 设置材料窗口
  438.   #--------------------------------------------------------------------------
  439.   def needs_window=(needs_window)
  440.     @needs_window = needs_window
  441.     update
  442.   end
  443.   #--------------------------------------------------------------------------
  444.   # ● 获取列数
  445.   #--------------------------------------------------------------------------
  446.   def col_max
  447.     return 1
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● 获取项目数
  451.   #--------------------------------------------------------------------------
  452.   def item_max
  453.     @data ? @data.size : 1
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● 获取食谱
  457.   #--------------------------------------------------------------------------
  458.   def item
  459.     @data && index >= 0 ? @data[index] : nil
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ● 获取选择食谱的有效状态
  463.   #--------------------------------------------------------------------------
  464.   def current_item_enabled?
  465.     enable?(@data[index])
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # ● 查询此食谱是否可用
  469.   #--------------------------------------------------------------------------
  470.   def enable?(item)
  471.     item.enabled && item.enough?
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ● 生成食谱列表
  475.   #--------------------------------------------------------------------------
  476.   def make_item_list
  477.     @data = $game_party.cookbooks(@category)
  478.   end
  479.   #--------------------------------------------------------------------------
  480.   # ● 返回上一个选择的位置
  481.   #--------------------------------------------------------------------------
  482.   def select_last
  483.     select(0)
  484.   end
  485.   #--------------------------------------------------------------------------
  486.   # ● 绘制项目
  487.   #--------------------------------------------------------------------------
  488.   def draw_item(index)
  489.     item = @data[index]
  490.     if item
  491.       rect = item_rect(index)
  492.       rect.width -= 4
  493.       draw_item_name(item, rect.x, rect.y, enable?(item))
  494.     end
  495.   end
  496.   #--------------------------------------------------------------------------
  497.   # ● 绘制名称
  498.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  499.   #--------------------------------------------------------------------------
  500.   def draw_item_name(item, x, y, enabled = true, width = 300)
  501.     return unless item
  502.     text = item.name
  503.     text += "[材料不足]" if !item.enough?
  504.     change_color(normal_color, enabled)
  505.     draw_text(x, y, width, line_height, text)
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ● 更新帮助内容
  509.   #--------------------------------------------------------------------------
  510.   def update_help
  511.     @help_window.set_item(item)
  512.   end
  513.    #--------------------------------------------------------------------------
  514.   # ● 更新食谱清单
  515.   #--------------------------------------------------------------------------
  516.   def update_needslist
  517.     @needs_window.set_item(item)
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # ● 调用帮助窗口的更新方法
  521.   #--------------------------------------------------------------------------
  522.   def call_update_help
  523.     update_help if @help_window
  524.     update_needslist if @needs_window
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 刷新
  528.   #--------------------------------------------------------------------------
  529.   def refresh
  530.     make_item_list
  531.     create_contents
  532.     draw_all_items
  533.   end
  534. end
  535. #==============================================================================
  536. # ■ Window_Description
  537. #------------------------------------------------------------------------------
  538. #  显示食谱的说明的窗口
  539. #==============================================================================
  540.  
  541. class Window_Description < Window_Base
  542.   #--------------------------------------------------------------------------
  543.   # ● 初始化对象
  544.   #--------------------------------------------------------------------------
  545.   def initialize(x, y)
  546.     super(x, y, Graphics.width*0.5, fitting_height(4))
  547.   end
  548.   #--------------------------------------------------------------------------
  549.   # ● 设置内容
  550.   #--------------------------------------------------------------------------
  551.   def set_text(text)
  552.     if text != @text
  553.       @text = text
  554.       refresh
  555.     end
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # ● 清除
  559.   #--------------------------------------------------------------------------
  560.   def clear
  561.     set_text("")
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # ● 设置食谱的介绍
  565.   #--------------------------------------------------------------------------
  566.   def set_item(item)
  567.     set_text(item ? item.description : "")
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # ● 刷新
  571.   #--------------------------------------------------------------------------
  572.   def refresh
  573.     contents.clear
  574.     draw_text_ex(4, 0, @text)
  575.   end
  576. end
  577.  
  578. #==============================================================================
  579. # ■ Window_NeedsList
  580. #------------------------------------------------------------------------------
  581. #  制造画面中,显示食谱所需材料的窗口。
  582. #==============================================================================
  583.  
  584. class Window_NeedsList < Window_Selectable
  585.   #--------------------------------------------------------------------------
  586.   # ● 初始化对象
  587.   #--------------------------------------------------------------------------
  588.   def initialize(x, y, width, height)
  589.     super
  590.     @category = :item
  591.     @cookbook = nil
  592.     @data = []
  593.     refresh
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● 获取列数
  597.   #--------------------------------------------------------------------------
  598.   def col_max
  599.     return 1
  600.   end
  601.   #--------------------------------------------------------------------------
  602.   # ● 获取项目数
  603.   #--------------------------------------------------------------------------
  604.   def item_max
  605.     @data ? @data.size : 1
  606.   end
  607.   #--------------------------------------------------------------------------
  608.   # ● 获取物品
  609.   #--------------------------------------------------------------------------
  610.   def item
  611.     @data && index >= 0 ? @data[index] : nil
  612.   end
  613.   #--------------------------------------------------------------------------
  614.   # ● 查询列表中是否含有此物品
  615.   #--------------------------------------------------------------------------
  616.   def include?(item)
  617.     item.is_a?(RPG::Item) && !item.key_item?
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 获取选择食谱的有效状态
  621.   #--------------------------------------------------------------------------
  622.   def current_item_enabled?
  623.     enable?(@data[index])
  624.   end
  625.   #--------------------------------------------------------------------------
  626.   # ● 查询此食谱是否可用
  627.   #--------------------------------------------------------------------------
  628.   def enable?(item)
  629.     $game_party.usable?(item) && @cookbook.item_enough?(item)
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ● 生成物品列表
  633.   #--------------------------------------------------------------------------
  634.   def make_item_list
  635.     @data = []
  636.     return if @cookbook== nil
  637.     tmp1 = []
  638.     tmp2 = []
  639.     $data_items.each do |item|
  640.       tmp1.push([item, 0]) if item && !item.name.empty? && @cookbook.resource?(item)
  641.       tmp2.push([item, 1]) if item && !item.name.empty? && @cookbook.output?(item)
  642.     end
  643.     if tmp1.size > 0 && tmp2.size > 0
  644.       @data.push(["需要材料:",0])
  645.       @data += tmp1
  646.       @data.push(["可以获得:",1])
  647.       @data += tmp2
  648.     end
  649.   end
  650.   #--------------------------------------------------------------------------
  651.   # ● 返回上一个选择的位置
  652.   #--------------------------------------------------------------------------
  653.   def select_last
  654.     select(0)
  655.   end
  656.   #--------------------------------------------------------------------------
  657.   # ● 绘制项目
  658.   #--------------------------------------------------------------------------
  659.   def draw_item(index)
  660.     item = @data[index]
  661.     if item
  662.       rect = item_rect(index)
  663.       rect.width -= 4
  664.       if item[0].is_a?(RPG::Item)
  665.         draw_item_name(item, rect.x, rect.y, enable?(item[0]))
  666.         draw_item_number(rect, item[0])
  667.       else
  668.         draw_input_output(item, rect.x, rect.y)
  669.       end
  670.     end
  671.   end
  672.   #--------------------------------------------------------------------------
  673.   # ● 绘制物品名称
  674.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  675.   #--------------------------------------------------------------------------
  676.   def draw_item_name(item, x, y, enabled = true, width = 172)
  677.     return unless item
  678.     text = item[0].name + "*" + String(@cookbook.amount(item[0], item[1]))
  679.     draw_icon(item[0].icon_index, x, y, enabled)
  680.     change_color(normal_color, enable?(item[0]))
  681.     draw_text(x + 24, y, width, line_height, text)
  682.   end
  683.   #--------------------------------------------------------------------------
  684.   # ● 绘制输入和产出
  685.   #--------------------------------------------------------------------------
  686.   def draw_input_output(item, x, y, enabled = false, width = 172)
  687.     return unless item
  688.     if item[1] == 0
  689.       text = "[需要]"
  690.     else
  691.       text = "[可以获得]"
  692.     end
  693.     change_color(normal_color, @cookbook.enough?)
  694.     draw_text(x , y, width, line_height, text)
  695.   end
  696.   #--------------------------------------------------------------------------
  697.   # ● 绘制物品个数
  698.   #--------------------------------------------------------------------------
  699.   def draw_item_number(rect, item)
  700.     draw_text(rect, sprintf("现有%2d", $game_party.item_number(item)), 2)
  701.   end
  702.   #--------------------------------------------------------------------------
  703.   # ● 刷新
  704.   #--------------------------------------------------------------------------
  705.   def refresh
  706.     make_item_list
  707.     create_contents
  708.     draw_all_items
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # ● 设置食谱的材料
  712.   #--------------------------------------------------------------------------
  713.   def set_item(item)
  714.     @cookbook = item
  715.     refresh
  716.   end
  717. end
  718.  
  719. #==============================================================================
  720. # 本腳本來自[url]www.66RPG.com[/url],使用和轉載請保留此信息
  721. #==============================================================================
  722.  
  723.  
  724. # add by Sion 2013.12.17
  725. # 作者修改了原范例的菜单,但是在原系统脚本里改的。
  726. # 整理出来写在这里, 不需要改菜单的同学把这些删掉就可以。
  727. class Scene_Menu
  728.   def command_cook
  729.     SceneManager.call(Scene_Cook)
  730.   end
  731.   alias_method :s20131217_create_command_window, :create_command_window
  732.   def create_command_window
  733.     s20131217_create_command_window
  734.     @command_window.set_handler(:cook, method(:command_cook))
  735.   end
  736. end
  737. class Window_MenuCommand
  738.   alias_method :s20131217_add_main_commands, :add_main_commands
  739.   def add_main_commands
  740.     s20131217_add_main_commands
  741.     add_command("制造",   :cook,   main_commands_enabled)
  742.   end
  743. end




通过我的寻找,发现两套脚本应该是运用了 同一个“add”之类的函数,才造成的,但本人脚本功底实在渣的没办法。即便找到问题所在,也无法解决。烦请大大们整合一下。(我尝试过搜索另一套VA任务系统来使用,发现另一套直接诸多报错,漏洞百出。而又找不到第三套任务系统,所以只能来麻烦各位了。)

Lv4.逐梦者 (版主)

无限の剣制

梦石
0
星屑
10074
在线时间
5020 小时
注册时间
2013-2-28
帖子
5030

开拓者贵宾

2
发表于 2016-1-18 11:50:19 | 只看该作者
这两个脚本个人感觉就是【糟糕】。有不少新人玩VA的时候被他们坑过
  1. #encoding:utf-8
  2. #==============================================================================
  3. # 本腳本來自[url]www.66RPG.com[/url],使用和轉載請保留此信息
  4. #==============================================================================
  5. #==============================================================================
  6. #
  7. #每添加一个制造的类型,最上面的类别菜单就会多一项。
  8. #
  9. #添加类型的方法是:
  10. #$game_party.add_cook_type(类别名称,类别介绍, 类别状态-默认false)
  11. #
  12. #举例:
  13. #$game_party.add_cook_type("制药","调配药品", true)
  14. #
  15. #添加配方的方法:
  16. #$game_party.add_cookbook(配方名称, 配方介绍, 配方类别名称,材料的二维数组,产出物的二维数组,配方状态)
  17. #
  18. #举例:
  19. #$game_party.add_cookbook("初级补血药水", "制作初级补血药水", "制药",[[18,2]],[[1,1]],true)
  20. #
  21. #调用窗口的方法:SceneManager.call(Scene_Cook)
  22. #
  23. #
  24. #==============================================================================

  25. #==============================================================================
  26. # ■ Cookbook_Type
  27. #------------------------------------------------------------------------------
  28. #  食谱类型类。
  29. #==============================================================================

  30. class Cookbook_Type
  31.   attr_reader :index
  32.   attr_reader :name
  33.   attr_reader :description
  34.   attr_reader :enabled
  35.   #--------------------------------------------------------------------------
  36.   # ● 初始化对象
  37.   #--------------------------------------------------------------------------
  38.   def initialize(index, name, description, enabled = false)
  39.     @index = index
  40.     @name = name
  41.     @description = description
  42.     @enabled = enabled
  43.   end

  44.   def enable(en)
  45.     @enabled = en
  46.   end
  47. end

  48. #==============================================================================
  49. # ■ Cookbook
  50. #------------------------------------------------------------------------------
  51. #  食谱类。本类在 Game_Task 类的内部使用。
  52. #   食谱属性:食谱序号,食谱名称,食谱类型,食谱介绍,原料,成品
  53. #==============================================================================

  54. class Cookbook
  55.   attr_reader :index
  56.   attr_reader :name
  57.   attr_reader :description
  58.   attr_reader :type
  59.   attr_reader :input
  60.   attr_reader :output
  61.   attr_reader :enabled
  62.   #--------------------------------------------------------------------------
  63.   # ● 初始化对象
  64.   #--------------------------------------------------------------------------
  65.   def initialize(index, name, description, type, input, output, enabled = true)
  66.     @index = index
  67.     @name = name
  68.     @description = description
  69.     @type = type
  70.     @input = input
  71.     @output = output
  72.     @enabled = enabled
  73.   end

  74.   def enable(en)
  75.     @enabled = en
  76.   end

  77.   #--------------------------------------------------------------------------
  78.   # ● 查询列表中的物品
  79.   #--------------------------------------------------------------------------
  80.   def in_list?(item, list)
  81.     list.each do |arr|
  82.       return true if arr[0] == item.id
  83.     end
  84.     return false
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 查询是否是材料列表中的物品
  88.   #--------------------------------------------------------------------------
  89.   def resource?(item)
  90.     in_list?(item, @input)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 查询是否是产出列表中的物品
  94.   #--------------------------------------------------------------------------
  95.   def output?(item)
  96.     in_list?(item, @output)
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # ● 查询材料需求量
  100.   #--------------------------------------------------------------------------
  101.   def amount(item, i)
  102.     if i == 0
  103.       @input.each do |arr|
  104.         return arr[1] if arr[0] == item.id
  105.       end
  106.     else
  107.       @output.each do |arr|
  108.         return arr[1] if arr[0] == item.id
  109.       end
  110.     end
  111.     return 0
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 查询材料是否足够
  115.   #--------------------------------------------------------------------------
  116.   def enough?
  117.     input.each do |arr|
  118.       return false if $data_items[arr[0]] && arr[1] > $game_party.item_number($data_items[arr[0]])
  119.     end
  120.     return true
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 查询某件材料是否足够
  124.   #--------------------------------------------------------------------------
  125.   def item_enough?(item)
  126.     input.each do |arr|
  127.       return false if arr[0] == item.id && arr[1] > $game_party.item_number(item)
  128.     end
  129.     return true
  130.   end
  131. end

  132. #==============================================================================
  133. # ■ Game_Party
  134. #==============================================================================

  135. class Game_Party < Game_Unit
  136.   #--------------------------------------------------------------------------
  137.   # ● 初始化对象
  138.   #--------------------------------------------------------------------------
  139.   alias old_cook_init initialize
  140.   def initialize
  141.     old_cook_init
  142.     @cook_types = []
  143.     @cookbooks = []
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ● 添加新的制造类型
  147.   #--------------------------------------------------------------------------
  148.   def add_cook_type(n, d, en)
  149.     @cook_types.push(Cookbook_Type.new(@cook_types.size, n, d, en)) if !have_cook_type?(n)
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 添加新的食谱
  153.   #--------------------------------------------------------------------------
  154.   def add_cookbook(n, d, type, input, output, en)
  155.     if !have_cookbook?(n) && have_cook_type?(type)
  156.       @cookbooks.push(Cookbook.new(@cookbooks.size, n, d, type, input, output, en))
  157.     end
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● 判断名称为n的制造类型是否存在
  161.   #--------------------------------------------------------------------------
  162.   def have_cook_type?(n)
  163.     @cook_types.each do |x|
  164.       return true if x.name == n
  165.     end
  166.     return false
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ● 判断名称为n的食谱是否存在
  170.   #--------------------------------------------------------------------------
  171.   def have_cookbook?(n)
  172.     @cookbooks.each do |x|
  173.       return true if x.name == n
  174.     end
  175.     return false
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 返回制造类型列表
  179.   #--------------------------------------------------------------------------
  180.   def cook_types
  181.     return @cook_types
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 返回食谱列表
  185.   #--------------------------------------------------------------------------
  186.   def cookbooks(type = nil)
  187.     return @cookbooks if type == nil
  188.     arr = []
  189.     @cookbooks.each do |x|
  190.       arr.push(x) if x.type == type
  191.     end
  192.     return arr
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● 更改序号为i的制造类型的使用状态
  196.   #--------------------------------------------------------------------------
  197.   def set_cook_type(i, en)
  198.     @cook_types[i].enable(en)
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 更改序号为i的食谱的使用状态
  202.   #--------------------------------------------------------------------------
  203.   def set_cookbook(i, en)
  204.     @cookbooks[i].enable(en)
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # ● 返回制造类型数目
  208.   #--------------------------------------------------------------------------
  209.   def cook_types_size
  210.     return @cook_types.size
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 查询名称为n的制造类型的描述
  214.   #--------------------------------------------------------------------------
  215.   def cook_type_description(n)
  216.     @cook_types.each do |x|
  217.       return x.description if x.name == n
  218.     end
  219.     return ""
  220.   end
  221. end

  222. #==============================================================================
  223. # ■ Scene_Cook
  224. #------------------------------------------------------------------------------
  225. #  制造画面
  226. #==============================================================================

  227. class Scene_Cook < Scene_ItemBase
  228.   #--------------------------------------------------------------------------
  229.   # ● 开始处理
  230.   #--------------------------------------------------------------------------
  231.   def start
  232.     super
  233.     create_category_window
  234.     create_cookbook_window
  235.     create_description_window
  236.     create_needs_window
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 生成分类窗口
  240.   #--------------------------------------------------------------------------
  241.   def create_category_window
  242.     @category_window = Window_CookCategory.new
  243.     @category_window.viewport = @viewport
  244.     @category_window.y = 0
  245.     @category_window.set_handler(:ok,     method(:on_category_ok))
  246.     @category_window.set_handler(:cancel, method(:return_scene))
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● 生成食谱窗口
  250.   #--------------------------------------------------------------------------
  251.   def create_cookbook_window
  252.     wy = @category_window.height
  253.     wh = Graphics.height - wy
  254.     @item_window = Window_CookList.new(0, wy, Graphics.width*0.5 , wh)
  255.     @item_window.viewport = @viewport
  256.     @item_window.set_handler(:ok,     method(:on_item_ok))
  257.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  258.     @category_window.item_window = @item_window
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ● 生成描述窗口
  262.   #--------------------------------------------------------------------------
  263.   def create_description_window
  264.     wy = @category_window.height
  265.     @help_window = Window_Description.new(Graphics.width*0.5, wy)
  266.     @help_window.viewport = @viewport
  267.     @item_window.help_window = @help_window
  268.     @category_window.help_window = @help_window
  269.   end
  270.     #--------------------------------------------------------------------------
  271.   # ● 生成材料窗口
  272.   #--------------------------------------------------------------------------
  273.   def create_needs_window
  274.     wy = @category_window.height + @help_window.height
  275.     wh = Graphics.height - wy
  276.     @needs_window = Window_NeedsList.new(Graphics.width*0.5, wy, Graphics.width*0.5 , wh)
  277.     #@item_window.viewport = @viewport
  278.     @item_window.needs_window = @needs_window

  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 分类“确定”
  282.   #--------------------------------------------------------------------------
  283.   def on_category_ok
  284.     @item_window.activate
  285.     @item_window.select_last
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 食谱“确定”
  289.   #--------------------------------------------------------------------------
  290.   def on_item_ok
  291.     #$game_party.last_item.object = item
  292.     cook
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # ● 食谱“取消”
  296.   #--------------------------------------------------------------------------
  297.   def on_item_cancel
  298.     @item_window.unselect
  299.     @category_window.activate
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● 制造
  303.   #--------------------------------------------------------------------------
  304.   def cook
  305.     if item.enough?
  306.       play_se_for_item
  307.       use_item
  308.       @needs_window.refresh
  309.       @item_window.refresh
  310.       activate_item_window
  311.     end
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   # ● 播放制作声效
  315.   #--------------------------------------------------------------------------
  316.   def play_se_for_item
  317.     Sound.play_recovery
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● 使用食谱
  321.   #--------------------------------------------------------------------------
  322.   def use_item
  323.     #super
  324.     #@item_window.redraw_current_item
  325.     $data_items.each do |it|
  326.       if it && !it.name.empty?
  327.         $game_party.gain_item(it,-item.amount(it,0)) if item.resource?(it)
  328.         $game_party.gain_item(it,item.amount(it,1)) if item.output?(it)
  329.       end
  330.     end
  331.   end
  332. end


  333. #==============================================================================
  334. # ■ Window_CookCategory
  335. #------------------------------------------------------------------------------
  336. #  制造画面中,显示制造类型的窗口。
  337. #==============================================================================

  338. class Window_CookCategory < Window_HorzCommand
  339.   #--------------------------------------------------------------------------
  340.   # ● 定义实例变量
  341.   #--------------------------------------------------------------------------
  342.   attr_reader   :item_window
  343.   #--------------------------------------------------------------------------
  344.   # ● 初始化对象
  345.   #--------------------------------------------------------------------------
  346.   def initialize
  347.     super(0, 0)
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # ● 获取窗口的宽度
  351.   #--------------------------------------------------------------------------
  352.   def window_width
  353.     Graphics.width
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 获取列数
  357.   #--------------------------------------------------------------------------
  358.   def col_max
  359.     return $game_party.cook_types_size
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # ● 更新画面
  363.   #--------------------------------------------------------------------------
  364.   def update
  365.     super
  366.     #@item_window.category = current_symbol if @item_window
  367.     @item_window.category = current_data[:name] if @item_window
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● 生成制造列表
  371.   #--------------------------------------------------------------------------
  372.   def make_command_list
  373.     $game_party.cook_types.each do |t|
  374.       add_command(t.name, t.index, t.enabled)
  375.     end
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # ● 设置制造列表窗口
  379.   #--------------------------------------------------------------------------
  380.   def item_window=(item_window)
  381.     @item_window = item_window
  382.     update
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # ● 更新帮助内容
  386.   #--------------------------------------------------------------------------
  387.   def update_help
  388.     @help_window.set_text($game_party.cook_type_description(current_data[:name]))
  389.   end
  390. end

  391. #==============================================================================
  392. # ■ Window_CookList
  393. #------------------------------------------------------------------------------
  394. #  任务画面中,显示已获得任务的窗口。
  395. #==============================================================================

  396. class Window_CookList < Window_Selectable
  397.   #--------------------------------------------------------------------------
  398.   # ● 定义实例变量
  399.   #--------------------------------------------------------------------------
  400.   attr_reader   :needs_window
  401.   #--------------------------------------------------------------------------
  402.   # ● 初始化对象
  403.   #--------------------------------------------------------------------------
  404.   def initialize(x, y, width, height)
  405.     super
  406.     @data = []
  407.     @category = $game_party.cook_types_size > 0 ? $game_party.cook_types[0].name : nil
  408.     refresh
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # ● 设置分类
  412.   #--------------------------------------------------------------------------
  413.   def category=(category)
  414.     return if @category == category
  415.     @category = category
  416.     refresh
  417.     self.oy = 0
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 设置材料窗口
  421.   #--------------------------------------------------------------------------
  422.   def needs_window=(needs_window)
  423.     @needs_window = needs_window
  424.     update
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # ● 获取列数
  428.   #--------------------------------------------------------------------------
  429.   def col_max
  430.     return 1
  431.   end
  432.   #--------------------------------------------------------------------------
  433.   # ● 获取项目数
  434.   #--------------------------------------------------------------------------
  435.   def item_max
  436.     @data ? @data.size : 1
  437.   end
  438.   #--------------------------------------------------------------------------
  439.   # ● 获取食谱
  440.   #--------------------------------------------------------------------------
  441.   def item
  442.     @data && index >= 0 ? @data[index] : nil
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # ● 获取选择食谱的有效状态
  446.   #--------------------------------------------------------------------------
  447.   def current_item_enabled?
  448.     enable?(@data[index])
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # ● 查询此食谱是否可用
  452.   #--------------------------------------------------------------------------
  453.   def enable?(item)
  454.     item.enabled && item.enough?
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # ● 生成食谱列表
  458.   #--------------------------------------------------------------------------
  459.   def make_item_list
  460.     @data = $game_party.cookbooks(@category)
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● 返回上一个选择的位置
  464.   #--------------------------------------------------------------------------
  465.   def select_last
  466.     select(0)
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # ● 绘制项目
  470.   #--------------------------------------------------------------------------
  471.   def draw_item(index)
  472.     item = @data[index]
  473.     if item
  474.       rect = item_rect(index)
  475.       rect.width -= 4
  476.       draw_item_name(item, rect.x, rect.y, enable?(item))
  477.     end
  478.   end
  479.   #--------------------------------------------------------------------------
  480.   # ● 绘制名称
  481.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  482.   #--------------------------------------------------------------------------
  483.   def draw_item_name(item, x, y, enabled = true, width = 300)
  484.     return unless item
  485.     text = item.name
  486.     text += "[材料不足]" if !item.enough?
  487.     change_color(normal_color, enabled)
  488.     draw_text(x, y, width, line_height, text)
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # ● 更新帮助内容
  492.   #--------------------------------------------------------------------------
  493.   def update_help
  494.     @help_window.set_item(item)
  495.   end
  496.    #--------------------------------------------------------------------------
  497.   # ● 更新食谱清单
  498.   #--------------------------------------------------------------------------
  499.   def update_needslist
  500.     @needs_window.set_item(item)
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # ● 调用帮助窗口的更新方法
  504.   #--------------------------------------------------------------------------
  505.   def call_update_help
  506.     update_help if @help_window
  507.     update_needslist if @needs_window
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # ● 刷新
  511.   #--------------------------------------------------------------------------
  512.   def refresh
  513.     make_item_list
  514.     create_contents
  515.     draw_all_items
  516.   end
  517. end
  518. #==============================================================================
  519. # ■ Window_Description
  520. #------------------------------------------------------------------------------
  521. #  显示食谱的说明的窗口
  522. #==============================================================================

  523. class Window_Description < Window_Base
  524.   #--------------------------------------------------------------------------
  525.   # ● 初始化对象
  526.   #--------------------------------------------------------------------------
  527.   def initialize(x, y)
  528.     super(x, y, Graphics.width*0.5, fitting_height(4))
  529.   end
  530.   #--------------------------------------------------------------------------
  531.   # ● 设置内容
  532.   #--------------------------------------------------------------------------
  533.   def set_text(text)
  534.     if text != @text
  535.       @text = text
  536.       refresh
  537.     end
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ● 清除
  541.   #--------------------------------------------------------------------------
  542.   def clear
  543.     set_text("")
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # ● 设置食谱的介绍
  547.   #--------------------------------------------------------------------------
  548.   def set_item(item)
  549.     set_text(item ? item.description : "")
  550.   end
  551.   #--------------------------------------------------------------------------
  552.   # ● 刷新
  553.   #--------------------------------------------------------------------------
  554.   def refresh
  555.     contents.clear
  556.     draw_text_ex(4, 0, @text)
  557.   end
  558. end

  559. #==============================================================================
  560. # ■ Window_NeedsList
  561. #------------------------------------------------------------------------------
  562. #  制造画面中,显示食谱所需材料的窗口。
  563. #==============================================================================

  564. class Window_NeedsList < Window_Selectable
  565.   #--------------------------------------------------------------------------
  566.   # ● 初始化对象
  567.   #--------------------------------------------------------------------------
  568.   def initialize(x, y, width, height)
  569.     super
  570.     @category = :item
  571.     @cookbook = nil
  572.     @data = []
  573.     refresh
  574.   end
  575.   #--------------------------------------------------------------------------
  576.   # ● 获取列数
  577.   #--------------------------------------------------------------------------
  578.   def col_max
  579.     return 1
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # ● 获取项目数
  583.   #--------------------------------------------------------------------------
  584.   def item_max
  585.     @data ? @data.size : 1
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # ● 获取物品
  589.   #--------------------------------------------------------------------------
  590.   def item
  591.     @data && index >= 0 ? @data[index] : nil
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # ● 查询列表中是否含有此物品
  595.   #--------------------------------------------------------------------------
  596.   def include?(item)
  597.     item.is_a?(RPG::Item) && !item.key_item?
  598.   end
  599.   #--------------------------------------------------------------------------
  600.   # ● 获取选择食谱的有效状态
  601.   #--------------------------------------------------------------------------
  602.   def current_item_enabled?
  603.     enable?(@data[index])
  604.   end
  605.   #--------------------------------------------------------------------------
  606.   # ● 查询此食谱是否可用
  607.   #--------------------------------------------------------------------------
  608.   def enable?(item)
  609.     $game_party.usable?(item) && @cookbook.item_enough?(item)
  610.   end
  611.   #--------------------------------------------------------------------------
  612.   # ● 生成物品列表
  613.   #--------------------------------------------------------------------------
  614.   def make_item_list
  615.     @data = []
  616.     return if @cookbook== nil
  617.     tmp1 = []
  618.     tmp2 = []
  619.     $data_items.each do |item|
  620.       tmp1.push([item, 0]) if item && !item.name.empty? && @cookbook.resource?(item)
  621.       tmp2.push([item, 1]) if item && !item.name.empty? && @cookbook.output?(item)
  622.     end
  623.     if tmp1.size > 0 && tmp2.size > 0
  624.       @data.push(["需要材料:",0])
  625.       @data += tmp1
  626.       @data.push(["可以获得:",1])
  627.       @data += tmp2
  628.     end
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ● 返回上一个选择的位置
  632.   #--------------------------------------------------------------------------
  633.   def select_last
  634.     select(0)
  635.   end
  636.   #--------------------------------------------------------------------------
  637.   # ● 绘制项目
  638.   #--------------------------------------------------------------------------
  639.   def draw_item(index)
  640.     item = @data[index]
  641.     if item
  642.       rect = item_rect(index)
  643.       rect.width -= 4
  644.       if item[0].is_a?(RPG::Item)
  645.         draw_item_name(item, rect.x, rect.y, enable?(item[0]))
  646.         draw_item_number(rect, item[0])
  647.       else
  648.         draw_input_output(item, rect.x, rect.y)
  649.       end
  650.     end
  651.   end
  652.   #--------------------------------------------------------------------------
  653.   # ● 绘制物品名称
  654.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  655.   #--------------------------------------------------------------------------
  656.   def draw_item_name(item, x, y, enabled = true, width = 172)
  657.     return unless item
  658.     text = item[0].name + "*" + String(@cookbook.amount(item[0], item[1]))
  659.     draw_icon(item[0].icon_index, x, y, enabled)
  660.     change_color(normal_color, enable?(item[0]))
  661.     draw_text(x + 24, y, width, line_height, text)
  662.   end
  663.   #--------------------------------------------------------------------------
  664.   # ● 绘制输入和产出
  665.   #--------------------------------------------------------------------------
  666.   def draw_input_output(item, x, y, enabled = false, width = 172)
  667.     return unless item
  668.     if item[1] == 0
  669.       text = "[需要]"
  670.     else
  671.       text = "[可以获得]"
  672.     end
  673.     change_color(normal_color, @cookbook.enough?)
  674.     draw_text(x , y, width, line_height, text)
  675.   end
  676.   #--------------------------------------------------------------------------
  677.   # ● 绘制物品个数
  678.   #--------------------------------------------------------------------------
  679.   def draw_item_number(rect, item)
  680.     draw_text(rect, sprintf("现有%2d", $game_party.item_number(item)), 2)
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ● 刷新
  684.   #--------------------------------------------------------------------------
  685.   def refresh
  686.     make_item_list
  687.     create_contents
  688.     draw_all_items
  689.   end
  690.   #--------------------------------------------------------------------------
  691.   # ● 设置食谱的材料
  692.   #--------------------------------------------------------------------------
  693.   def set_item(item)
  694.     @cookbook = item
  695.     refresh
  696.   end
  697. end

  698. #==============================================================================
  699. # 本腳本來自[url]www.66RPG.com[/url],使用和轉載請保留此信息
  700. #==============================================================================


  701. # add by Sion 2013.12.17
  702. # 作者修改了原范例的菜单,但是在原系统脚本里改的。
  703. # 整理出来写在这里, 不需要改菜单的同学把这些删掉就可以。
  704. class Scene_Menu
  705.   def command_cook
  706.     SceneManager.call(Scene_Cook)
  707.   end
  708.   alias_method :s20131217_create_command_window, :create_command_window
  709.   def create_command_window
  710.     s20131217_create_command_window
  711.     @command_window.set_handler(:cook, method(:command_cook))
  712.   end
  713. end
  714. class Window_MenuCommand
  715.   alias_method :s20131217_add_main_commands, :add_main_commands
  716.   def add_main_commands
  717.     s20131217_add_main_commands
  718.     add_command("制造",   :cook,   main_commands_enabled)
  719.   end
  720. end
复制代码
下面那个换成这样的,未测试

点评

简单测试了下,完全能用。 多谢啦!  发表于 2016-1-18 21:22

评分

参与人数 1星屑 +10 收起 理由
天涯孤客 + 10 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
26 小时
注册时间
2008-7-6
帖子
24
3
发表于 2016-3-28 14:45:51 | 只看该作者
挖个坟 0。0 这个已经不知道是多少年前自己整合的东西来着~
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-16 07:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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