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

Project1

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

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

[复制链接]

Lv3.寻梦者

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

开拓者

跳转到指定楼层
1
发表于 2017-2-19 10:50:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

为什么没有背包格子有限这种东西,满了就装不下,而且没有丢弃功能

Lv5.捕梦者 (版主)

梦石
1
星屑
23984
在线时间
3339 小时
注册时间
2011-7-8
帖子
3926

开拓者

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

使用道具 举报

Lv3.寻梦者

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

开拓者

3
 楼主| 发表于 2017-2-19 11:49:55 | 只看该作者
guoxiaomi 发表于 2017-2-19 11:04
上网搜,负重脚本,有真相

我试试,研究下这脚本

点评

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
帖子
151
4
发表于 2017-2-19 11:57:42 | 只看该作者
单人负重系统。

负重范例.zip

2.64 MB, 下载次数: 129

Vanyogin
回复 支持 反对

使用道具 举报

Lv3.寻梦者

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

开拓者

5
 楼主| 发表于 2017-2-19 12:19:14 | 只看该作者
戴迪 发表于 2017-2-19 11:49
我试试,研究下这脚本

在外站的负重脚本运行出错
回复 支持 反对

使用道具 举报

Lv3.寻梦者

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

开拓者

6
 楼主| 发表于 2017-2-19 12:43:56 | 只看该作者

倒腾倒腾
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
52 小时
注册时间
2017-1-12
帖子
192
7
发表于 2017-2-19 12:59:10 | 只看该作者
请善用搜索....
负重脚本如下
RUBY 代码复制
  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.  
  89. class Game_Temp
  90. attr_reader :recipe_list  
  91. alias crafting_temp_initialize initialize
  92. def initialize
  93.    crafting_temp_initialize
  94.    @recipe_list=[]
  95.    get_recipe_list
  96. end
  97.  
  98.   def get_recipe_list   
  99.  
  100.    材料 = [12]             # 需要材料的数据库编号
  101.    材料种类 = [0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  102.    材料数量 = [1]         # 需要材料的数量
  103.    成品 = 4                  # 获得物品编号
  104.    获得数 = 8
  105.    成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  106.    成品分类 = 0              # 获得成品分类
  107.    @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
  108.  
  109. end # of get_recipe_list method
  110. end # of updates to Game_Temp Class
  111.  
  112.  
  113. #================================
  114. # CRAFTING PROGRAM
  115. #----------------------------------------------------------------
  116. #-written by Deke
  117. #-yes_no window code created by Phsylomortis
  118. #----------------------------------------------------------------
  119. #================================
  120.  
  121. #updates to Game_Party class
  122. =begin
  123.  
  124.   负重系统v0.1
  125.  
  126.   作者:秀秀
  127.  
  128.   功能:物品 武器 防具都多了重量属性
  129.          
  130.         增加了背包负重 超过负重最大值 则不能获得
  131.  
  132.   使用方法:在(物品,武器,防具)数据库中设置名称
  133.  
  134.             方式为:名称+n+重量
  135.             
  136.             比如 铜剑n1.5  表示铜剑重量为1.5
  137.                  回复剂n0.5 表示回复剂重量为0.5
  138.           
  139.             设置背包重量:默认为变量1,一定要在游戏开始设置好     
  140.                           搜索 VAR_NUMBER 可以改变存放背包负重的变量
  141.                           当然也可以随时改变这个数值
  142.  
  143.             获取背包最大负重:
  144.                           $game_variables[VAR_NUMBER]
  145.             获取背包当前负重:
  146.                           $gane_party.weight
  147.             获取物品重量:
  148.                           $data_items[id].weight
  149.             获取武器重量:
  150.                           $data_weapons[id].weight     
  151.             获取防具重量:
  152.                           $data_armors[id].weight
  153.  
  154. =end                     
  155.  
  156.  
  157. module RPG
  158.   class Item
  159.     def name
  160.       return @name.split(/,/)[0] # w 代表重量
  161.     end
  162.     def weight
  163.       return @name.split(/,/)[3].to_i # w 代表重量
  164.     end  
  165.    end
  166.  
  167.   class Weapon
  168.     def name
  169.       return @name.split(/,/)[0] # w 代表重量
  170.     end
  171.     def weight
  172.       return @name.split(/,/)[3].to_i # w 代表重量
  173.     end  
  174.    end
  175.  
  176.   class Armor
  177.     def name
  178.       return @name.split(/,/)[0] # w 代表重量
  179.     end
  180.     def weight
  181.       return @name.split(/,/)[3].to_i # w 代表重量
  182.     end  
  183.   end
  184. end
  185.  
  186. class Game_Party
  187.  
  188.   #--------------------------------------------------------------------------
  189.   # ● 定义实例变量
  190.   #--------------------------------------------------------------------------
  191.   attr_accessor :weight
  192.   #--------------------------------------------------------------------------
  193.   # ● 初始化对像
  194.   #--------------------------------------------------------------------------
  195.   alias wt_initialize initialize
  196.   def initialize
  197.     wt_initialize
  198.     @weight = 0
  199.   end
  200.  
  201.  
  202.   #--------------------------------------------------------------------------
  203.   # ● 增加物品 (减少)
  204.   #     item_id : 物品 ID
  205.   #     n       : 个数
  206.   #--------------------------------------------------------------------------
  207.   def gain_item(item_id, n)
  208.     # 更新 hash 的个数数据
  209.     if item_id > 0
  210.  
  211.       temp = @weight + $data_items[item_id].weight * n
  212.  
  213.       return if (n < 0 and @items[item_id] == nil)
  214.  
  215.       if temp > max_weight
  216.         return
  217.       end
  218.       if temp < 0
  219.         a = @weight
  220.         for i in 1..n.abs
  221.           a -= $data_items[item_id].weight
  222.           if a < 0
  223.             return
  224.           else
  225.             # 数量-1
  226.             @items[item_id] = [[item_number(item_id) - i, 0].max, 99].min
  227.             # 负重-1
  228.             @weight -= $data_items[item_id].weight
  229.             # p @weight
  230.           end  
  231.         end
  232.         # p @weight
  233.         return
  234.       end  
  235.  
  236.       if @items[item_id] != nil
  237.         b = @items[item_id] - n.abs
  238.         if b < 0 and n < 0
  239.           c = @items[item_id]
  240.           @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  241.           @weight -= $data_items[item_id].weight * c
  242.           # p @weight
  243.           return
  244.         end
  245.       end  
  246.  
  247.       @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  248.       @weight = temp
  249.       # p @weight
  250.     end
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # ● 增加武器 (减少)
  254.   #     weapon_id : 武器 ID
  255.   #     n         : 个数
  256.   #--------------------------------------------------------------------------
  257.   def gain_weapon(weapon_id, n)
  258.     # 更新 hash 的个数数据
  259.     if weapon_id > 0
  260.       temp = @weight + $data_weapons[weapon_id].weight * n
  261.  
  262.       return if (n < 0 and @weapons[weapon_id] == nil)
  263.  
  264.       if temp > max_weight
  265.         return
  266.       end
  267.       if temp < 0
  268.         a = @weight
  269.         for i in 1..n.abs
  270.           a -= $data_weapons[weapon_id].weight
  271.           if a < 0
  272.             return
  273.           else
  274.             # 数量-1
  275.             @weapons[weapon_id] = [[weapon_number(weapon_id) - i, 0].max, 99].min
  276.             # 负重-1
  277.             @weight -= $data_weapons[weapon_id].weight
  278.            # p @weight
  279.           end  
  280.         end
  281.        # p @weight
  282.         return
  283.       end  
  284.  
  285.       if @weapons[weapon_id] != nil
  286.         b = @weapons[weapon_id] - n.abs
  287.         if b < 0 and n < 0
  288.           c = @weapons[weapon_id]
  289.           @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  290.           @weight -= $data_weapons[weapon_id].weight * c
  291.         #  p @weight
  292.           return
  293.         end
  294.       end
  295.  
  296.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  297.       @weight = temp
  298.      # p @weight
  299.     end
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● 增加防具 (减少)
  303.   #     armor_id : 防具 ID
  304.   #     n        : 个数
  305.   #--------------------------------------------------------------------------
  306.   def gain_armor(armor_id, n)
  307.     # 更新 hash 的个数数据
  308.     if armor_id > 0
  309.       temp = @weight + $data_armors[armor_id].weight * n
  310.  
  311.       return if (n < 0 and @armors[armor_id] == nil)
  312.  
  313.       if temp > max_weight
  314.         return
  315.       end
  316.       if temp < 0
  317.         a = @weight
  318.         for i in 1..n.abs
  319.           a -= $data_armors[armor_id].weight
  320.           if a < 0
  321.             return
  322.           else
  323.             # 数量-1
  324.             @armors[armor_id] = [[armor_number(armor_id) - i, 0].max, 99].min
  325.             # 负重-1
  326.             @weight -= $data_armors[armor_id].weight
  327.             # p @weight
  328.           end  
  329.         end
  330.         # p @weight
  331.         return
  332.       end  
  333.  
  334.       if @armors[armor_id] != nil
  335.         b = @armors[armor_id] - n.abs
  336.         if b < 0 and n < 0
  337.           c = @armors[armor_id]
  338.           @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  339.           @weight -= $data_armors[armor_id].weight * c
  340.           # p @weight
  341.           return
  342.         end
  343.       end
  344.  
  345.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  346.       @weight = temp
  347.       # p @weight
  348.     end
  349.   end
  350.  
  351.   def max_weight
  352.     return $game_variables[1]
  353.   end
  354.  
  355.   def check_weight
  356.  
  357.   end
  358.  
  359. end  
  360.  
  361.  
  362. #================================================================================
  363.  
  364. #==============================================================================
  365. # ■ Scene_Item
  366. #------------------------------------------------------------------------------
  367. #  处理物品画面的类。
  368. #==============================================================================
  369.  
  370. class Scene_Item
  371.   alias ori_main main
  372.   def main
  373.     @weight_window = Window_Weight.new
  374.     @weight_window.x = 0
  375.     @weight_window.y = 416
  376.     @weight_window.z = 9999
  377.     ori_main
  378.     @weight_window.dispose
  379.   end  
  380.   alias ori_update update
  381.   def update
  382.        case @item_window.item
  383.        when RPG::Item
  384.          @weight_window.refresh($data_items[@item_window.item.id].weight)
  385.        when RPG::Weapon
  386.          @weight_window.refresh($data_weapons[@item_window.item.id].weight)
  387.        when RPG::Armor  
  388.          @weight_window.refresh($data_armors[@item_window.item.id].weight)
  389.        end
  390.     ori_update
  391.   end
  392. end
  393.  
  394. class Window_Item < Window_Selectable
  395.   #--------------------------------------------------------------------------
  396.   # ● 初始化对像
  397.   #--------------------------------------------------------------------------
  398.   def initialize
  399.     super(0, 64, 640, 352)
  400.     @column_max = 2
  401.     refresh
  402.     self.index = 0
  403.     # 战斗中的情况下将窗口移至中央并将其半透明化
  404.     if $game_temp.in_battle
  405.       self.y = 64
  406.       self.height = 256
  407.       self.back_opacity = 160
  408.     end
  409.   end
  410. end  
  411.  
  412. class Window_Weight < Window_Base
  413.   def initialize
  414.     super(0,0,640,64)
  415.     self.opacity = 128
  416.     self.contents = Bitmap.new(width-32,height-32)
  417.     refresh(nil)
  418.   end  
  419.   def refresh(weight)
  420.     self.contents.clear
  421.     if weight != nil
  422.       self.contents.draw_text(0,0,256,32,"物品重量:#{weight}")
  423.     end
  424.     self.contents.draw_text(256,0,320,32,"背包重量:"+$game_party.weight.to_s + "/" + $game_variables[1].to_s , 0)
  425.   end
  426. end  
  427.  
  428. class Game_Party
  429.  
  430. attr_accessor       :recipes
  431.  
  432. alias crafting_party_initialize initialize
  433.  
  434. def initialize
  435.    crafting_party_initialize
  436.    @recipes=[]
  437. end
  438.  
  439. #----------------------------------------------------------------------
  440. def know?(recipe, version = 1)
  441.    unless recipe.is_a?(Game_Recipe)
  442.      recipe = get_recipe_from_master_list(recipe, version)
  443.    end
  444.    return $game_party.recipes.include?(recipe)
  445. end
  446.  
  447. #----------------------------------------------------------------------
  448. def learn_recipe(recipe, version = 1)
  449.    unless recipe.is_a?(Game_Recipe)
  450.      recipe = get_recipe_from_master_list(recipe, version)
  451.    end
  452.    if recipe.is_a?(Game_Recipe)
  453.      unless know?(recipe)
  454.        @recipes.push(recipe)
  455.      end
  456.    end
  457. end
  458.  
  459. #----------------------------------------------------------------------
  460. def forget_recipe(recipe , version = 1)
  461.    if !recipe.is_a?(Game_Recipe)
  462.      recipe = get_recipe_from_master_list(recipe, version)
  463.    end
  464.    if recipe.is_a?(Game_Recipe)
  465.      for i in [email]0...@recipes.size[/email]
  466.        if recipe == @recipes[i]
  467.          index = i
  468.          break
  469.        end
  470.      end
  471.      if index != nil
  472.        @recipes.delete(@recipes[index])
  473.      end
  474.    end
  475. end
  476.  
  477. #----------------------------------------------------------------------
  478. def get_recipe_from_master_list(item, version)
  479.    index = nil
  480.    for i in 0...$game_temp.recipe_list.size#1=0
  481.      #print $game_temp.recipe_list.size
  482.      if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  483.        version -= 1
  484.        if version == 0
  485.          index = i
  486.          break
  487.        end
  488.      end
  489.    end
  490.    if index.is_a?(Integer)
  491.      return ($game_temp.recipe_list[index])
  492.    else
  493.      return false
  494.    end
  495. end
  496.  
  497. end # of Game_Party updates
  498.  
  499. #================================
  500. class Game_Recipe
  501.  
  502. attr_reader :ingredients
  503. attr_reader :quantities
  504. attr_reader :result
  505. attr_reader :result_num
  506. attr_reader :result_type
  507. attr_reader :ingredient_types
  508. attr_reader :craft_type  #物品分类
  509.  
  510. #----------------------------------------------------------------------
  511. def initialize( ingredients, ingredient_types, quantities, result, result_num,result_type, craft_type=0)
  512.    @ingredients = ingredients
  513.    @ingredient_types = ingredient_types
  514.    @quantities = quantities
  515.    @result = result
  516.    @result_num = result_num
  517.    $rrresultnum = result_num
  518.    @result_type = result_type
  519.    @craft_type = craft_type
  520. end
  521.  
  522. #----------------------------------------------------------------------
  523. def name
  524.    case @result_type
  525.      when 0
  526.        name = $data_items[@result].name
  527.      when 1
  528.        name = $data_armors[@result].name
  529.      when 2
  530.        name = $data_weapons[@result].name
  531.    end
  532.    return name
  533. end
  534.  
  535. #----------------------------------------------------------------------
  536. def have
  537.    have_all = true
  538.    for i in [email]0...@ingredients.size[/email]
  539.      case @ingredient_types[i]
  540.        when 0
  541.          if $game_party.item_number(@ingredients[i]) < @quantities[i]
  542.            have_all=false
  543.          end
  544.        when 1
  545.          if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  546.            have_all=false
  547.          end
  548.        when 2
  549.          if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  550.            have_all=false
  551.          end
  552.      end
  553.    end
  554.    return have_all
  555. end
  556.  
  557. #----------------------------------------------------------------------
  558. def decrement
  559.    for i in [email]0...@ingredients.size[/email]
  560.      case @ingredient_types[i]
  561.      when 0
  562.        $game_party.lose_item(@ingredients[i], @quantities[i])
  563.      when 1
  564.        $game_party.lose_armor(@ingredients[i], @quantities[i])
  565.      when 2
  566.        $game_party.lose_weapon(@ingredients[i], @quantities[i])
  567.      end
  568.    end
  569. end
  570.  
  571. #----------------------------------------------------------------------
  572. def make
  573.    if have
  574.      decrement
  575.      case @result_type
  576.      when 0
  577.        $game_party.gain_item(@result, @result_num)
  578.      when 1
  579.        $game_party.gain_armor(@result, @result_num)
  580.      when 2
  581.        $game_party.gain_weapon(@result, @result_num)
  582.      end
  583.    end
  584. end
  585.  
  586. #----------------------------------------------------------------------
  587. def == (recipe)
  588.    if recipe.is_a?(Game_Recipe)
  589.      equal = true
  590.      if recipe.ingredients != self.ingredients
  591.        equal = false
  592.      end
  593.      if recipe.ingredient_types != self.ingredient_types
  594.        equal = false
  595.      end
  596.      if recipe.quantities != self.quantities
  597.        equal = false
  598.      end
  599.      if recipe.result != self.result
  600.        equal=false
  601.      end
  602.      if recipe.result_type != self.result_type
  603.        equal = false
  604.      end
  605.    else
  606.      equal = false
  607.    end
  608.    return equal
  609. end
  610.  
  611. end # of Game_Recipe class
  612.  
  613. #===================================
  614.  
  615. class Window_Craft < Window_Selectable
  616. attr_reader :data #声明数据
  617. #--------------------------------------------------------------------------
  618. def initialize(craft_type=0)
  619.    @craft_type = craft_type
  620.    super(0, 64, 240, 416)
  621.    @column_max = 1
  622.    refresh
  623.    self.index = 0
  624. end
  625.  
  626. #--------------------------------------------------------------------------
  627. def recipe
  628.    return @data[self.index]
  629. end
  630.  
  631. #--------------------------------------------------------------------------
  632. def refresh
  633.    if self.contents != nil
  634.      self.contents.dispose
  635.      self.contents = nil
  636.    end
  637.    @data = []
  638.    for i in 0...$game_party.recipes.size
  639.       #@craft_type为0时就显示全部物品
  640.       #不为0时就显示对应物品
  641.      @data.push($game_party.recipes[i])
  642.      #if @craft_type == 0
  643.      #  @data.push($game_party.recipes[i])
  644.      #elsif $game_party.recipes[i].craft_type == @craft_type
  645.      #  @data.push($game_party.recipes[i])
  646.      #end
  647.    end
  648.    @item_max = @data.size
  649.    if @item_max > 0
  650.      self.contents = Bitmap.new(width - 32, row_max * 32)
  651.      self.contents.font.name = "迷你简隶变" # = "迷你简隶变"
  652.      self.contents.font.size = 18 # = 18
  653.      for i in 0...@item_max
  654.        draw_item(i)
  655.      end
  656.    end
  657. end
  658.  
  659. #--------------------------------------------------------------------------
  660. def draw_item(index)
  661.    recipe = @data[index]
  662.    self.contents.font.color = recipe.have ? normal_color : disabled_color
  663.    x = 16
  664.    y = index * 32
  665.    self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  666. end
  667.  
  668. #--------------------------------------------------------------------------
  669. def update_help
  670.    current_recipe = recipe
  671.    if current_recipe.is_a?(Game_Recipe)
  672.    case current_recipe.result_type
  673.      when 0
  674.        description = $data_items[current_recipe.result].description
  675.      when 1
  676.        description = $data_armors[current_recipe.result].description
  677.      when 2
  678.        description = $data_weapons[current_recipe.result].description
  679.      end
  680.    else
  681.      description = ""
  682.    end
  683.    @help_window.set_text(description)
  684.    @help_window.update
  685. end
  686.  
  687. end # of Window_Craft
  688.  
  689. #=======================================
  690. class Window_CraftResult < Window_Base
  691.  
  692. #--------------------------------------------------------------------------
  693. def initialize
  694.    super(240, 64, 400, 184)
  695.    self.contents = Bitmap.new(width - 32, height - 32)
  696.    self.contents.font.name = "迷你简隶变" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  697.    self.contents.font.size = 18 # = 20
  698.    @result = nil
  699.    @type = nil
  700. end
  701.  
  702. #--------------------------------------------------------------------------
  703. def refresh
  704.    self.contents.clear
  705.    case @type
  706.      when 0
  707.        item = $data_items[@result]
  708.        ssstats=$game_party.item_number(@result)               
  709.        @bitmap = RPG::Cache.icon(item.icon_name)
  710.      when 1
  711.        item = $data_armors[@result]
  712.        @strings = ["", "", "", "", "",
  713.                       "", ""]
  714.        @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  715.                    item.agi_plus, item.int_plus, $rrresultnum]
  716.        ssstats=$game_party.armor_number(@result)            
  717.        @bitmap = RPG::Cache.icon(item.icon_name)
  718.      when 2
  719.        item = $data_weapons[@result]
  720.        @strings =["", "", "", "", "",
  721.                    "", ""]
  722.        @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  723.                    item.agi_plus, item.int_plus, $rrresultnum]
  724.        ssstats=$game_party.weapon_number(@result)            
  725.        @bitmap = RPG::Cache.icon(item.icon_name)
  726.    end
  727.    #——for i in [email][email protected][/email]
  728.      #——x = i%2 * 184
  729.      #——y = i /2 *28 +32
  730.      #——self.contents.font.color = normal_color
  731.      #——self.contents.draw_text(x,y,100, 28,@strings[i])
  732.      #——self.contents.font.color = system_color
  733.      #——self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  734.    #——end
  735.    self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  736.    self.contents.font.color= normal_color
  737.    self.contents.draw_text(40, 0, 300, 28, "待制作物品的现有数量:")
  738.    self.contents.font.color = system_color
  739.    count = ssstats.to_s
  740.    self.contents.draw_text(294, 0, 45, 28, count)
  741. end
  742.  
  743. #----------------------------------------------------------------------
  744. def set_result(result , type)
  745.    @result = result
  746.    @type = type
  747.    refresh
  748. end
  749.  
  750. end #of Window_CraftResult
  751.  
  752. #=======================================
  753. class Window_CraftIngredients < Window_Base
  754.  
  755. #--------------------------------------------------------------------------
  756. def initialize
  757.    super(240, 248, 400, 232)
  758.    self.contents = Bitmap.new(width - 32, height - 32)
  759.    self.contents.font.name = "迷你简隶变" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  760.    self.contents.font.size = 18 # = 20
  761.    @ingredients = []
  762.    @types = []
  763.    @quantities = []
  764.    @item = nil
  765.    @count = 0
  766. end
  767.  
  768. #--------------------------------------------------------------------------
  769. def refresh
  770.    self.contents.clear
  771.    for i in [email]0...@ingredients.size[/email]
  772.      case @types[i]
  773.      when 0
  774.        @item = $data_items[@ingredients[i]]
  775.        @count = $game_party.item_number(@ingredients[i])
  776.      when 1
  777.        @item = $data_armors[@ingredients[i]]
  778.        @count = $game_party.armor_number(@ingredients[i])
  779.      when 2
  780.        @item = $data_weapons[@ingredients[i]]
  781.        @count = $game_party.weapon_number(@ingredients[i])
  782.      end
  783.      y = i *26
  784.      self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  785.      self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  786.      self.contents.draw_text(30, y, 280, 28, @item.name)
  787.      self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  788.      self.contents.font.color = system_color
  789.      self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  790.    end
  791. end
  792.  
  793. #--------------------------------------------------------------------------
  794. def set_ingredients(ingredients , types, quantities)
  795.    @ingredients = ingredients
  796.    @types = types
  797.    @quantities = quantities
  798.    refresh
  799. end
  800.  
  801. end # of Window_CraftIngredients
  802.  
  803. #======================================
  804. class Scene_Craft
  805.  
  806. #--------------------------------------------------------------------------
  807. # @craft_type:物品种类,0就是全部
  808. def initialize(craft_type=0,craft_index=0)
  809.    @craft_index=craft_index
  810.    @craft_type = craft_type
  811. end
  812.  
  813. #--------------------------------------------------------------------------
  814. def main
  815.    @craft_window = Window_Craft.new(@craft_type)
  816.    @craft_window.index=@craft_index
  817.    @confirm_window = Window_Base.new(120, 188, 400, 64)
  818.    @confirm_window.contents = Bitmap.new(368, 32)
  819.    @confirm_window.contents.font.name = "迷你简隶变"
  820.    @confirm_window.contents.font.size = 20
  821.    @help_window = Window_Help.new
  822.    @craft_window.help_window = @help_window
  823.    @result_window=Window_CraftResult.new
  824.    @ingredients_window=Window_CraftIngredients.new
  825.    @yes_no_window = Window_Command.new(100, ["确定", "取消"])
  826.    @confirm_window.visible = false
  827.    @confirm_window.z = 1500
  828.    @yes_no_window.visible = false
  829.    @yes_no_window.active = false
  830.    @yes_no_window.index = 0
  831.    @yes_no_window.x = 270
  832.    @yes_no_window.y = 252
  833.    @yes_no_window.z = 1500
  834.    @label_window = Window_Base.new(450,200,190,52)
  835.    @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  836.    @label_window.contents.font.size=20
  837.    @label_window.contents.font.color = @label_window.normal_color
  838.    @label_window.contents.font.name = "迷你简隶变"
  839.    @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "   现有     需要")
  840.    Graphics.transition
  841.    loop do
  842.      Graphics.update
  843.      Input.update
  844.      update
  845.      if $scene != self
  846.        break
  847.      end
  848.    end
  849.    Graphics.freeze
  850.    @help_window.dispose
  851.    @craft_window.dispose
  852.    @result_window.dispose
  853.    @ingredients_window.dispose
  854.    @confirm_window.dispose
  855.    @yes_no_window.dispose
  856.    @label_window.dispose
  857. end
  858.  
  859. #--------------------------------------------------------------------------
  860. def update
  861.    @craft_window.update
  862.    @ingredients_window.update
  863.    if @craft_window.data.size > 0 #本类窗口物品大于0的话
  864.      @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  865.      @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  866.                                                           @craft_window.recipe.ingredient_types,
  867.                                                           @craft_window.recipe.quantities)
  868.    end
  869.    if @craft_window.active
  870.      update_craft
  871.      return
  872.    end
  873.    if @yes_no_window.active
  874.      confirm_update
  875.      return
  876.    end
  877. end
  878.  
  879. #--------------------------------------------------------------------------
  880. def update_craft
  881.    if Input.trigger?(Input::B)
  882.      $game_system.se_play($data_system.cancel_se)
  883.      $scene = Scene_Menu.new(1)
  884.      return
  885.    end
  886.    if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  887.      @recipe = @craft_window.recipe
  888.      if @recipe != nil
  889.        if @recipe.have
  890.          @yes_no_window.active = true
  891.          @craft_window.active = false
  892.        else
  893.          $game_system.se_play($data_system.buzzer_se)
  894.          return
  895.        end
  896.      else
  897.        $game_system.se_play($data_system.buzzer_se)
  898.        return
  899.      end
  900.    end
  901. end
  902.  
  903. #--------------------------------------------------------------------------
  904. def confirm_update
  905.    @craft_index = @craft_window.index
  906.    @confirm_window.visible = true
  907.    @confirm_window.z = 1500
  908.    @yes_no_window.visible = true
  909.    @yes_no_window.active = true
  910.    @yes_no_window.z = 1500
  911.    @yes_no_window.update
  912.    string = "制作" + @recipe.name + "?"
  913.    cw = @confirm_window.contents.text_size(string).width
  914.    center = @confirm_window.contents.width/2 - cw /2
  915.    unless @drawn
  916.      @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  917.      @drawn = true
  918.    end
  919.    if Input.trigger?(Input::C)
  920.      if @yes_no_window.index == 0
  921.        $game_system.se_play($data_system.decision_se)
  922.        @recipe.make
  923.        $game_system.se_play($data_system.save_se)
  924.        $scene=Scene_Craft.new(@craft_index)
  925.      else
  926.        $game_system.se_play($data_system.cancel_se)
  927.        $scene=Scene_Craft.new(@craft_index)
  928.      end
  929.    end
  930.    if Input.trigger?(Input::B)
  931.      $game_system.se_play($data_system.cancel_se)
  932.      $scene=Scene_Craft.new(@craft_index)
  933.    end
  934. end
  935.  
  936. end # of Scene_Craft
  937.  
  938. #==============================================================================
  939. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  940. # 欢迎访问[url]www.66RPG.com[/url]
  941. # 梦想世界,在你手中
  942. #==============================================================================

评分

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

查看全部评分

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

使用道具 举报

Lv3.寻梦者

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

开拓者

8
 楼主| 发表于 2017-2-19 13:13:30 | 只看该作者
axicc 发表于 2017-2-19 12:59
请善用搜索....
负重脚本如下
#======================================================================= ...


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

点评

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-21 22:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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