查看: 3588|回复: 9

[已经解决] RM怎么实现背包物品有限功能

[复制链接]
梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

发表于 2017-2-19 10:50:04 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 guoxiaomi 于 2017-3-11 21:51 编辑

为什么没有背包格子有限这种东西,满了就装不下,而且没有丢弃功能
梦石
1
星屑
24088
在线时间
3339 小时
注册时间
2011-7-8
回帖
3862

开拓者

发表于 2017-2-19 11:04:28 | 显示全部楼层
上网搜,负重脚本,有真相
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复

使用道具 举报

梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

 楼主| 发表于 2017-2-19 11:49:55 | 显示全部楼层
guoxiaomi 发表于 2017-2-19 11:04
上网搜,负重脚本,有真相

我试试,研究下这脚本

点评

其实是想让你在本站搜“负重 脚本”注意加空格或者就搜“负重”  发表于 2017-2-19 12:26
回复

使用道具 举报

梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
回帖
135
发表于 2017-2-19 11:57:42 | 显示全部楼层
单人负重系统。

负重范例.zip

2.64 MB, 下载次数: 130

Vanyogin
回复

使用道具 举报

梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

 楼主| 发表于 2017-2-19 12:19:14 | 显示全部楼层
戴迪 发表于 2017-2-19 11:49
我试试,研究下这脚本

在外站的负重脚本运行出错
回复

使用道具 举报

梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

 楼主| 发表于 2017-2-19 12:43:56 | 显示全部楼层

倒腾倒腾
回复

使用道具 举报

梦石
0
星屑
60
在线时间
52 小时
注册时间
2017-1-12
回帖
183
发表于 2017-2-19 12:59:10 | 显示全部楼层
请善用搜索....
负重脚本如下
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. # 欢迎访问[url]www.66RPG.com[/url]
  4. # 梦想世界,在你手中
  5. #==============================================================================  
  6. #
  7. # Sample master list for crafting script (物品分类增强版)
  8. # written by Deke
  9. # 增强:叶子
  10. # 增强版编写日期:12-30-2005
  11. #============================================================================================
  12. # 简介:
  13. # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
  14. # 物品方法。
  15. # ------
  16. # 增强版补充说明:
  17. # 在这个增强版中,可以对成品进行手动分类。
  18. # 成品增加了一个分类属性。
  19. # 这个分类纯粹是按自己的意愿,没有规定第几类必须是什么。
  20. # 召唤特定分类的界面,就只会看到特定分类的成品。
  21. #
  22. # 例如:
  23. # 使用脚本$scene = Scene_Craft.new(1),
  24. # 出来的界面就只会显示成品分类为1的东西
  25. # 同样道理,使用脚本$scene = Scene_Craft.new(2),
  26. # 出来的界面就只会显示成品分类为2的东西
  27. #
  28. # 如果使用脚本$scene = Scene_Craft.new或$scene = Scene_Craft.new(0)来召唤界面
  29. # 就可以看到所有成品。
  30. #
  31. # 注意:不要弄混淆“成品种类”和“成品分类”
  32. # 成品种类是指成品是普通物品(0),防具(1)或武器(2)
  33. # 成品分类是指此物品的自定义分类
  34. #
  35. #
  36. # 使用方法:
  37. # 1、召唤界面:使用脚本$scene = Scene_Craft.new(分类的数字)
  38. # 例如:使用脚本$scene = Scene_Craft.new(1),出来分类1的界面
  39. #
  40. # 2、学习合成:$game_party.learn_recipe(合成项目)
  41. #
  42. #  2.1、其实这个脚本可以使同一成品有不同配方
  43. #
  44. #    就这样说可能解释得不清楚,先来解释一下脚本学习配方的原理:
  45. #    $game_party.learn_recipe(合成项目)的处理过程并不是直接学习这个配方,
  46. #    而是在配方库中找到和合成项目成品相同的配方。
  47. #
  48. #    如果配方库中有两个配方成品相同的话,配方版本就变得重要。
  49. #    $game_party.learn_recipe(合成项目,配方版本)
  50. #    配方版本为1的话,学到的配方就是@recipe_list[xx]中与合成项目成品相同且数字最小的配方
  51. #    配方版本为2的话,学到的配方就是数字第二小的配方
  52. #    在上面这个脚本语句中,不填配方版本的话就默认为1
  53. #
  54. #  2.2、忘记配方:$game_party.forget_recipe(合成项目)
  55. #   2.21、同样道理,这个语句也可以写配方版本
  56. #    $game_party.forget_recipe(合成项目,配方版本)
  57. #    配方版本定义见2.1
  58. #
  59. #  2.3、配方版本不能乱填!例如游戏中某一个配方的成品是唯一的,与所有其它配方的成品都不相同
  60. #   那么学习的时候就不用填配方版本。
  61. #   如果这时在配方版本填了2的话,就有可能学不到或者忘不了(-_-||)
  62. #   
  63. #
  64. # 3、合成定义:
  65. # 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
  66. # 直接写在这里就可以,另一种是在学习之前现场定义。
  67. #
  68. # 4、举例
  69. #  4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[1])
  70. #       注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
  71. #
  72. #  4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,   
  73. #  脚本:
  74. #    材料 = [$game_variables[1],$game_variables[2]]  #——材料编号是变量1、2的编号
  75. #    材料种类 = [0,0]                                #——材料是物品
  76. #    材料数量 = [$game_variables[3],$game_variables[4]]  #——需要材料数量是变量3、4的编号
  77. #    成品 = $game_variables[5]                       #——获得结果编号是5
  78. #    成品种类 = 1                                    #——成品是防具类
  79. #    成品分类 = 1                                    #——这一项不写的话默认为0
  80. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类,成品分类))
  81. #    上面这条语句的成品分类这一项不写也行,这样它就默认为0了。
  82. #    (也就是此物品没有分类,不会在分类菜单中出现)
  83. #    省略成品分类的脚本语句可以像下面这样写:
  84. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类))
  85. #
  86. #===========================================================================================
  87. $VAR_NUMBER = 65

  88. class Game_Temp
  89. attr_reader :recipe_list  
  90. alias crafting_temp_initialize initialize
  91. def initialize
  92.    crafting_temp_initialize
  93.    @recipe_list=[]
  94.    get_recipe_list
  95. end

  96.   def get_recipe_list   

  97.    材料 = [12]             # 需要材料的数据库编号
  98.    材料种类 = [0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  99.    材料数量 = [1]         # 需要材料的数量
  100.    成品 = 4                  # 获得物品编号
  101.    获得数 = 8
  102.    成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  103.    成品分类 = 0              # 获得成品分类
  104.    @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)

  105. end # of get_recipe_list method
  106. end # of updates to Game_Temp Class


  107. #================================
  108. # CRAFTING PROGRAM
  109. #----------------------------------------------------------------
  110. #-written by Deke
  111. #-yes_no window code created by Phsylomortis
  112. #----------------------------------------------------------------
  113. #================================

  114. #updates to Game_Party class
  115. =begin

  116.   负重系统v0.1

  117.   作者:秀秀
  118.   
  119.   功能:物品 武器 防具都多了重量属性
  120.          
  121.         增加了背包负重 超过负重最大值 则不能获得
  122.   
  123.   使用方法:在(物品,武器,防具)数据库中设置名称
  124.   
  125.             方式为:名称+n+重量
  126.             
  127.             比如 铜剑n1.5  表示铜剑重量为1.5
  128.                  回复剂n0.5 表示回复剂重量为0.5
  129.            
  130.             设置背包重量:默认为变量1,一定要在游戏开始设置好     
  131.                           搜索 VAR_NUMBER 可以改变存放背包负重的变量
  132.                           当然也可以随时改变这个数值

  133.             获取背包最大负重:
  134.                           $game_variables[VAR_NUMBER]
  135.             获取背包当前负重:
  136.                           $gane_party.weight
  137.             获取物品重量:
  138.                           $data_items[id].weight
  139.             获取武器重量:
  140.                           $data_weapons[id].weight     
  141.             获取防具重量:
  142.                           $data_armors[id].weight

  143. =end                     


  144. module RPG
  145.   class Item
  146.     def name
  147.       return @name.split(/,/)[0] # w 代表重量
  148.     end
  149.     def weight
  150.       return @name.split(/,/)[3].to_i # w 代表重量
  151.     end  
  152.    end

  153.   class Weapon
  154.     def name
  155.       return @name.split(/,/)[0] # w 代表重量
  156.     end
  157.     def weight
  158.       return @name.split(/,/)[3].to_i # w 代表重量
  159.     end  
  160.    end

  161.   class Armor
  162.     def name
  163.       return @name.split(/,/)[0] # w 代表重量
  164.     end
  165.     def weight
  166.       return @name.split(/,/)[3].to_i # w 代表重量
  167.     end  
  168.   end
  169. end

  170. class Game_Party

  171.   #--------------------------------------------------------------------------
  172.   # ● 定义实例变量
  173.   #--------------------------------------------------------------------------
  174.   attr_accessor :weight
  175.   #--------------------------------------------------------------------------
  176.   # ● 初始化对像
  177.   #--------------------------------------------------------------------------
  178.   alias wt_initialize initialize
  179.   def initialize
  180.     wt_initialize
  181.     @weight = 0
  182.   end


  183.   #--------------------------------------------------------------------------
  184.   # ● 增加物品 (减少)
  185.   #     item_id : 物品 ID
  186.   #     n       : 个数
  187.   #--------------------------------------------------------------------------
  188.   def gain_item(item_id, n)
  189.     # 更新 hash 的个数数据
  190.     if item_id > 0

  191.       temp = @weight + $data_items[item_id].weight * n

  192.       return if (n < 0 and @items[item_id] == nil)

  193.       if temp > max_weight
  194.         return
  195.       end
  196.       if temp < 0
  197.         a = @weight
  198.         for i in 1..n.abs
  199.           a -= $data_items[item_id].weight
  200.           if a < 0
  201.             return
  202.           else
  203.             # 数量-1
  204.             @items[item_id] = [[item_number(item_id) - i, 0].max, 99].min
  205.             # 负重-1
  206.             @weight -= $data_items[item_id].weight
  207.             # p @weight
  208.           end  
  209.         end
  210.         # p @weight
  211.         return
  212.       end  

  213.       if @items[item_id] != nil
  214.         b = @items[item_id] - n.abs
  215.         if b < 0 and n < 0
  216.           c = @items[item_id]
  217.           @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  218.           @weight -= $data_items[item_id].weight * c
  219.           # p @weight
  220.           return
  221.         end
  222.       end  

  223.       @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  224.       @weight = temp
  225.       # p @weight
  226.     end
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # ● 增加武器 (减少)
  230.   #     weapon_id : 武器 ID
  231.   #     n         : 个数
  232.   #--------------------------------------------------------------------------
  233.   def gain_weapon(weapon_id, n)
  234.     # 更新 hash 的个数数据
  235.     if weapon_id > 0
  236.       temp = @weight + $data_weapons[weapon_id].weight * n

  237.       return if (n < 0 and @weapons[weapon_id] == nil)

  238.       if temp > max_weight
  239.         return
  240.       end
  241.       if temp < 0
  242.         a = @weight
  243.         for i in 1..n.abs
  244.           a -= $data_weapons[weapon_id].weight
  245.           if a < 0
  246.             return
  247.           else
  248.             # 数量-1
  249.             @weapons[weapon_id] = [[weapon_number(weapon_id) - i, 0].max, 99].min
  250.             # 负重-1
  251.             @weight -= $data_weapons[weapon_id].weight
  252.            # p @weight
  253.           end  
  254.         end
  255.        # p @weight
  256.         return
  257.       end  

  258.       if @weapons[weapon_id] != nil
  259.         b = @weapons[weapon_id] - n.abs
  260.         if b < 0 and n < 0
  261.           c = @weapons[weapon_id]
  262.           @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  263.           @weight -= $data_weapons[weapon_id].weight * c
  264.         #  p @weight
  265.           return
  266.         end
  267.       end

  268.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  269.       @weight = temp
  270.      # p @weight
  271.     end
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   # ● 增加防具 (减少)
  275.   #     armor_id : 防具 ID
  276.   #     n        : 个数
  277.   #--------------------------------------------------------------------------
  278.   def gain_armor(armor_id, n)
  279.     # 更新 hash 的个数数据
  280.     if armor_id > 0
  281.       temp = @weight + $data_armors[armor_id].weight * n

  282.       return if (n < 0 and @armors[armor_id] == nil)

  283.       if temp > max_weight
  284.         return
  285.       end
  286.       if temp < 0
  287.         a = @weight
  288.         for i in 1..n.abs
  289.           a -= $data_armors[armor_id].weight
  290.           if a < 0
  291.             return
  292.           else
  293.             # 数量-1
  294.             @armors[armor_id] = [[armor_number(armor_id) - i, 0].max, 99].min
  295.             # 负重-1
  296.             @weight -= $data_armors[armor_id].weight
  297.             # p @weight
  298.           end  
  299.         end
  300.         # p @weight
  301.         return
  302.       end  

  303.       if @armors[armor_id] != nil
  304.         b = @armors[armor_id] - n.abs
  305.         if b < 0 and n < 0
  306.           c = @armors[armor_id]
  307.           @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  308.           @weight -= $data_armors[armor_id].weight * c
  309.           # p @weight
  310.           return
  311.         end
  312.       end

  313.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  314.       @weight = temp
  315.       # p @weight
  316.     end
  317.   end

  318.   def max_weight
  319.     return $game_variables[1]
  320.   end

  321.   def check_weight

  322.   end

  323. end  


  324. #================================================================================

  325. #==============================================================================
  326. # ■ Scene_Item
  327. #------------------------------------------------------------------------------
  328. #  处理物品画面的类。
  329. #==============================================================================

  330. class Scene_Item
  331.   alias ori_main main
  332.   def main
  333.     @weight_window = Window_Weight.new
  334.     @weight_window.x = 0
  335.     @weight_window.y = 416
  336.     @weight_window.z = 9999
  337.     ori_main
  338.     @weight_window.dispose
  339.   end  
  340.   alias ori_update update
  341.   def update
  342.        case @item_window.item
  343.        when RPG::Item
  344.          @weight_window.refresh($data_items[@item_window.item.id].weight)
  345.        when RPG::Weapon
  346.          @weight_window.refresh($data_weapons[@item_window.item.id].weight)
  347.        when RPG::Armor  
  348.          @weight_window.refresh($data_armors[@item_window.item.id].weight)
  349.        end
  350.     ori_update
  351.   end
  352. end

  353. class Window_Item < Window_Selectable
  354.   #--------------------------------------------------------------------------
  355.   # ● 初始化对像
  356.   #--------------------------------------------------------------------------
  357.   def initialize
  358.     super(0, 64, 640, 352)
  359.     @column_max = 2
  360.     refresh
  361.     self.index = 0
  362.     # 战斗中的情况下将窗口移至中央并将其半透明化
  363.     if $game_temp.in_battle
  364.       self.y = 64
  365.       self.height = 256
  366.       self.back_opacity = 160
  367.     end
  368.   end
  369. end  

  370. class Window_Weight < Window_Base
  371.   def initialize
  372.     super(0,0,640,64)
  373.     self.opacity = 128
  374.     self.contents = Bitmap.new(width-32,height-32)
  375.     refresh(nil)
  376.   end  
  377.   def refresh(weight)
  378.     self.contents.clear
  379.     if weight != nil
  380.       self.contents.draw_text(0,0,256,32,"物品重量:#{weight}")
  381.     end
  382.     self.contents.draw_text(256,0,320,32,"背包重量:"+$game_party.weight.to_s + "/" + $game_variables[1].to_s , 0)
  383.   end
  384. end  

  385. class Game_Party

  386. attr_accessor       :recipes

  387. alias crafting_party_initialize initialize

  388. def initialize
  389.    crafting_party_initialize
  390.    @recipes=[]
  391. end

  392. #----------------------------------------------------------------------
  393. def know?(recipe, version = 1)
  394.    unless recipe.is_a?(Game_Recipe)
  395.      recipe = get_recipe_from_master_list(recipe, version)
  396.    end
  397.    return $game_party.recipes.include?(recipe)
  398. end

  399. #----------------------------------------------------------------------
  400. def learn_recipe(recipe, version = 1)
  401.    unless recipe.is_a?(Game_Recipe)
  402.      recipe = get_recipe_from_master_list(recipe, version)
  403.    end
  404.    if recipe.is_a?(Game_Recipe)
  405.      unless know?(recipe)
  406.        @recipes.push(recipe)
  407.      end
  408.    end
  409. end

  410. #----------------------------------------------------------------------
  411. def forget_recipe(recipe , version = 1)
  412.    if !recipe.is_a?(Game_Recipe)
  413.      recipe = get_recipe_from_master_list(recipe, version)
  414.    end
  415.    if recipe.is_a?(Game_Recipe)
  416.      for i in [email]0...@recipes.size[/email]
  417.        if recipe == @recipes[i]
  418.          index = i
  419.          break
  420.        end
  421.      end
  422.      if index != nil
  423.        @recipes.delete(@recipes[index])
  424.      end
  425.    end
  426. end

  427. #----------------------------------------------------------------------
  428. def get_recipe_from_master_list(item, version)
  429.    index = nil
  430.    for i in 0...$game_temp.recipe_list.size#1=0
  431.      #print $game_temp.recipe_list.size
  432.      if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  433.        version -= 1
  434.        if version == 0
  435.          index = i
  436.          break
  437.        end
  438.      end
  439.    end
  440.    if index.is_a?(Integer)
  441.      return ($game_temp.recipe_list[index])
  442.    else
  443.      return false
  444.    end
  445. end

  446. end # of Game_Party updates

  447. #================================
  448. class Game_Recipe

  449. attr_reader :ingredients
  450. attr_reader :quantities
  451. attr_reader :result
  452. attr_reader :result_num
  453. attr_reader :result_type
  454. attr_reader :ingredient_types
  455. attr_reader :craft_type  #物品分类

  456. #----------------------------------------------------------------------
  457. def initialize( ingredients, ingredient_types, quantities, result, result_num,result_type, craft_type=0)
  458.    @ingredients = ingredients
  459.    @ingredient_types = ingredient_types
  460.    @quantities = quantities
  461.    @result = result
  462.    @result_num = result_num
  463.    $rrresultnum = result_num
  464.    @result_type = result_type
  465.    @craft_type = craft_type
  466. end

  467. #----------------------------------------------------------------------
  468. def name
  469.    case @result_type
  470.      when 0
  471.        name = $data_items[@result].name
  472.      when 1
  473.        name = $data_armors[@result].name
  474.      when 2
  475.        name = $data_weapons[@result].name
  476.    end
  477.    return name
  478. end

  479. #----------------------------------------------------------------------
  480. def have
  481.    have_all = true
  482.    for i in [email]0...@ingredients.size[/email]
  483.      case @ingredient_types[i]
  484.        when 0
  485.          if $game_party.item_number(@ingredients[i]) < @quantities[i]
  486.            have_all=false
  487.          end
  488.        when 1
  489.          if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  490.            have_all=false
  491.          end
  492.        when 2
  493.          if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  494.            have_all=false
  495.          end
  496.      end
  497.    end
  498.    return have_all
  499. end

  500. #----------------------------------------------------------------------
  501. def decrement
  502.    for i in [email]0...@ingredients.size[/email]
  503.      case @ingredient_types[i]
  504.      when 0
  505.        $game_party.lose_item(@ingredients[i], @quantities[i])
  506.      when 1
  507.        $game_party.lose_armor(@ingredients[i], @quantities[i])
  508.      when 2
  509.        $game_party.lose_weapon(@ingredients[i], @quantities[i])
  510.      end
  511.    end
  512. end

  513. #----------------------------------------------------------------------
  514. def make
  515.    if have
  516.      decrement
  517.      case @result_type
  518.      when 0
  519.        $game_party.gain_item(@result, @result_num)
  520.      when 1
  521.        $game_party.gain_armor(@result, @result_num)
  522.      when 2
  523.        $game_party.gain_weapon(@result, @result_num)
  524.      end
  525.    end
  526. end

  527. #----------------------------------------------------------------------
  528. def == (recipe)
  529.    if recipe.is_a?(Game_Recipe)
  530.      equal = true
  531.      if recipe.ingredients != self.ingredients
  532.        equal = false
  533.      end
  534.      if recipe.ingredient_types != self.ingredient_types
  535.        equal = false
  536.      end
  537.      if recipe.quantities != self.quantities
  538.        equal = false
  539.      end
  540.      if recipe.result != self.result
  541.        equal=false
  542.      end
  543.      if recipe.result_type != self.result_type
  544.        equal = false
  545.      end
  546.    else
  547.      equal = false
  548.    end
  549.    return equal
  550. end

  551. end # of Game_Recipe class

  552. #===================================

  553. class Window_Craft < Window_Selectable
  554. attr_reader :data #声明数据
  555. #--------------------------------------------------------------------------
  556. def initialize(craft_type=0)
  557.    @craft_type = craft_type
  558.    super(0, 64, 240, 416)
  559.    @column_max = 1
  560.    refresh
  561.    self.index = 0
  562. end

  563. #--------------------------------------------------------------------------
  564. def recipe
  565.    return @data[self.index]
  566. end

  567. #--------------------------------------------------------------------------
  568. def refresh
  569.    if self.contents != nil
  570.      self.contents.dispose
  571.      self.contents = nil
  572.    end
  573.    @data = []
  574.    for i in 0...$game_party.recipes.size
  575.       #@craft_type为0时就显示全部物品
  576.       #不为0时就显示对应物品
  577.      @data.push($game_party.recipes[i])
  578.      #if @craft_type == 0
  579.      #  @data.push($game_party.recipes[i])
  580.      #elsif $game_party.recipes[i].craft_type == @craft_type
  581.      #  @data.push($game_party.recipes[i])
  582.      #end
  583.    end
  584.    @item_max = @data.size
  585.    if @item_max > 0
  586.      self.contents = Bitmap.new(width - 32, row_max * 32)
  587.      self.contents.font.name = "迷你简隶变" # = "迷你简隶变"
  588.      self.contents.font.size = 18 # = 18
  589.      for i in 0...@item_max
  590.        draw_item(i)
  591.      end
  592.    end
  593. end

  594. #--------------------------------------------------------------------------
  595. def draw_item(index)
  596.    recipe = @data[index]
  597.    self.contents.font.color = recipe.have ? normal_color : disabled_color
  598.    x = 16
  599.    y = index * 32
  600.    self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  601. end

  602. #--------------------------------------------------------------------------
  603. def update_help
  604.    current_recipe = recipe
  605.    if current_recipe.is_a?(Game_Recipe)
  606.    case current_recipe.result_type
  607.      when 0
  608.        description = $data_items[current_recipe.result].description
  609.      when 1
  610.        description = $data_armors[current_recipe.result].description
  611.      when 2
  612.        description = $data_weapons[current_recipe.result].description
  613.      end
  614.    else
  615.      description = ""
  616.    end
  617.    @help_window.set_text(description)
  618.    @help_window.update
  619. end

  620. end # of Window_Craft

  621. #=======================================
  622. class Window_CraftResult < Window_Base

  623. #--------------------------------------------------------------------------
  624. def initialize
  625.    super(240, 64, 400, 184)
  626.    self.contents = Bitmap.new(width - 32, height - 32)
  627.    self.contents.font.name = "迷你简隶变" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  628.    self.contents.font.size = 18 # = 20
  629.    @result = nil
  630.    @type = nil
  631. end

  632. #--------------------------------------------------------------------------
  633. def refresh
  634.    self.contents.clear
  635.    case @type
  636.      when 0
  637.        item = $data_items[@result]
  638.        ssstats=$game_party.item_number(@result)               
  639.        @bitmap = RPG::Cache.icon(item.icon_name)
  640.      when 1
  641.        item = $data_armors[@result]
  642.        @strings = ["", "", "", "", "",
  643.                       "", ""]
  644.        @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  645.                    item.agi_plus, item.int_plus, $rrresultnum]
  646.        ssstats=$game_party.armor_number(@result)            
  647.        @bitmap = RPG::Cache.icon(item.icon_name)
  648.      when 2
  649.        item = $data_weapons[@result]
  650.        @strings =["", "", "", "", "",
  651.                    "", ""]
  652.        @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  653.                    item.agi_plus, item.int_plus, $rrresultnum]
  654.        ssstats=$game_party.weapon_number(@result)            
  655.        @bitmap = RPG::Cache.icon(item.icon_name)
  656.    end
  657.    #——for i in [email]0...@strings.size[/email]
  658.      #——x = i%2 * 184
  659.      #——y = i /2 *28 +32
  660.      #——self.contents.font.color = normal_color
  661.      #——self.contents.draw_text(x,y,100, 28,@strings[i])
  662.      #——self.contents.font.color = system_color
  663.      #——self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  664.    #——end
  665.    self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  666.    self.contents.font.color= normal_color
  667.    self.contents.draw_text(40, 0, 300, 28, "待制作物品的现有数量:")
  668.    self.contents.font.color = system_color
  669.    count = ssstats.to_s
  670.    self.contents.draw_text(294, 0, 45, 28, count)
  671. end

  672. #----------------------------------------------------------------------
  673. def set_result(result , type)
  674.    @result = result
  675.    @type = type
  676.    refresh
  677. end

  678. end #of Window_CraftResult

  679. #=======================================
  680. class Window_CraftIngredients < Window_Base

  681. #--------------------------------------------------------------------------
  682. def initialize
  683.    super(240, 248, 400, 232)
  684.    self.contents = Bitmap.new(width - 32, height - 32)
  685.    self.contents.font.name = "迷你简隶变" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  686.    self.contents.font.size = 18 # = 20
  687.    @ingredients = []
  688.    @types = []
  689.    @quantities = []
  690.    @item = nil
  691.    @count = 0
  692. end

  693. #--------------------------------------------------------------------------
  694. def refresh
  695.    self.contents.clear
  696.    for i in [email]0...@ingredients.size[/email]
  697.      case @types[i]
  698.      when 0
  699.        @item = $data_items[@ingredients[i]]
  700.        @count = $game_party.item_number(@ingredients[i])
  701.      when 1
  702.        @item = $data_armors[@ingredients[i]]
  703.        @count = $game_party.armor_number(@ingredients[i])
  704.      when 2
  705.        @item = $data_weapons[@ingredients[i]]
  706.        @count = $game_party.weapon_number(@ingredients[i])
  707.      end
  708.      y = i *26
  709.      self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  710.      self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  711.      self.contents.draw_text(30, y, 280, 28, @item.name)
  712.      self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  713.      self.contents.font.color = system_color
  714.      self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  715.    end
  716. end

  717. #--------------------------------------------------------------------------
  718. def set_ingredients(ingredients , types, quantities)
  719.    @ingredients = ingredients
  720.    @types = types
  721.    @quantities = quantities
  722.    refresh
  723. end

  724. end # of Window_CraftIngredients

  725. #======================================
  726. class Scene_Craft

  727. #--------------------------------------------------------------------------
  728. # @craft_type:物品种类,0就是全部
  729. def initialize(craft_type=0,craft_index=0)
  730.    @craft_index=craft_index
  731.    @craft_type = craft_type
  732. end

  733. #--------------------------------------------------------------------------
  734. def main
  735.    @craft_window = Window_Craft.new(@craft_type)
  736.    @craft_window.index=@craft_index
  737.    @confirm_window = Window_Base.new(120, 188, 400, 64)
  738.    @confirm_window.contents = Bitmap.new(368, 32)
  739.    @confirm_window.contents.font.name = "迷你简隶变"
  740.    @confirm_window.contents.font.size = 20
  741.    @help_window = Window_Help.new
  742.    @craft_window.help_window = @help_window
  743.    @result_window=Window_CraftResult.new
  744.    @ingredients_window=Window_CraftIngredients.new
  745.    @yes_no_window = Window_Command.new(100, ["确定", "取消"])
  746.    @confirm_window.visible = false
  747.    @confirm_window.z = 1500
  748.    @yes_no_window.visible = false
  749.    @yes_no_window.active = false
  750.    @yes_no_window.index = 0
  751.    @yes_no_window.x = 270
  752.    @yes_no_window.y = 252
  753.    @yes_no_window.z = 1500
  754.    @label_window = Window_Base.new(450,200,190,52)
  755.    @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  756.    @label_window.contents.font.size=20
  757.    @label_window.contents.font.color = @label_window.normal_color
  758.    @label_window.contents.font.name = "迷你简隶变"
  759.    @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "   现有     需要")
  760.    Graphics.transition
  761.    loop do
  762.      Graphics.update
  763.      Input.update
  764.      update
  765.      if $scene != self
  766.        break
  767.      end
  768.    end
  769.    Graphics.freeze
  770.    @help_window.dispose
  771.    @craft_window.dispose
  772.    @result_window.dispose
  773.    @ingredients_window.dispose
  774.    @confirm_window.dispose
  775.    @yes_no_window.dispose
  776.    @label_window.dispose
  777. end

  778. #--------------------------------------------------------------------------
  779. def update
  780.    @craft_window.update
  781.    @ingredients_window.update
  782.    if @craft_window.data.size > 0 #本类窗口物品大于0的话
  783.      @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  784.      @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  785.                                                           @craft_window.recipe.ingredient_types,
  786.                                                           @craft_window.recipe.quantities)
  787.    end
  788.    if @craft_window.active
  789.      update_craft
  790.      return
  791.    end
  792.    if @yes_no_window.active
  793.      confirm_update
  794.      return
  795.    end
  796. end

  797. #--------------------------------------------------------------------------
  798. def update_craft
  799.    if Input.trigger?(Input::B)
  800.      $game_system.se_play($data_system.cancel_se)
  801.      $scene = Scene_Menu.new(1)
  802.      return
  803.    end
  804.    if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  805.      @recipe = @craft_window.recipe
  806.      if @recipe != nil
  807.        if @recipe.have
  808.          @yes_no_window.active = true
  809.          @craft_window.active = false
  810.        else
  811.          $game_system.se_play($data_system.buzzer_se)
  812.          return
  813.        end
  814.      else
  815.        $game_system.se_play($data_system.buzzer_se)
  816.        return
  817.      end
  818.    end
  819. end

  820. #--------------------------------------------------------------------------
  821. def confirm_update
  822.    @craft_index = @craft_window.index
  823.    @confirm_window.visible = true
  824.    @confirm_window.z = 1500
  825.    @yes_no_window.visible = true
  826.    @yes_no_window.active = true
  827.    @yes_no_window.z = 1500
  828.    @yes_no_window.update
  829.    string = "制作" + @recipe.name + "?"
  830.    cw = @confirm_window.contents.text_size(string).width
  831.    center = @confirm_window.contents.width/2 - cw /2
  832.    unless @drawn
  833.      @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  834.      @drawn = true
  835.    end
  836.    if Input.trigger?(Input::C)
  837.      if @yes_no_window.index == 0
  838.        $game_system.se_play($data_system.decision_se)
  839.        @recipe.make
  840.        $game_system.se_play($data_system.save_se)
  841.        $scene=Scene_Craft.new(@craft_index)
  842.      else
  843.        $game_system.se_play($data_system.cancel_se)
  844.        $scene=Scene_Craft.new(@craft_index)
  845.      end
  846.    end
  847.    if Input.trigger?(Input::B)
  848.      $game_system.se_play($data_system.cancel_se)
  849.      $scene=Scene_Craft.new(@craft_index)
  850.    end
  851. end

  852. end # of Scene_Craft

  853. #==============================================================================
  854. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  855. # 欢迎访问[url]www.66RPG.com[/url]
  856. # 梦想世界,在你手中
  857. #==============================================================================
复制代码

评分

参与人数 1星屑 +100 收起 理由
guoxiaomi + 100 觉得这个脚本怪怪的

查看全部评分

别问我是谁! 我只是一个不为人知的小白而已..
回复 1 0

使用道具 举报

梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

 楼主| 发表于 2017-2-19 13:13:30 | 显示全部楼层
axicc 发表于 2017-2-19 12:59
请善用搜索....
负重脚本如下
#======================================================================= ...


我是不知道这个功能的脚本名字应该叫什么,所以不知道搜索什么内容。在站内找了下后,发现物品上限和种类上限刚好都是我需要的,等有时间去试验下

点评

直接搜负重 很多的 (当然很多都是提问...)  发表于 2017-2-19 13:16
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部