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

Project1

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

[已经过期] 角色独立背包

[复制链接]

Lv2.观梦者

梦石
0
星屑
375
在线时间
602 小时
注册时间
2014-5-8
帖子
699
跳转到指定楼层
1
发表于 2014-9-5 19:32:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这个脚本是在百变宝典里找到的,很乱,我改了好半天才改进了一点
怎么把那个装备所占空间大小给取消?
怎么在选择角色的时候如果该角色的物品为零,那么就提示该角色没有物品?
如果背包空间不够了,在得到物品的时候就提示该角色背包装不下了,怎么弄?
RUBY 代码复制
  1. #单人负重系统 V 1.10 BY SLICK
  2.  
  3. module RPG
  4.   class Item
  5.     attr_accessor :weight
  6.     def name
  7.       return @name.split(/,/)[0]
  8.     end
  9.     def weight
  10.       rpgwt = @name.split(/,/)[1].to_i
  11.       return rpgwt = nil ? 0 : rpgwt
  12.     end
  13.     def description
  14.       return @description.split(/@/)[0]
  15.     end
  16.     def inc_weight
  17.       rpgwt = @description.split(/@/)[1].to_i
  18.       return rpgwt = nil ? 0 : rpgwt
  19.     end
  20.   end
  21.  
  22.   class Weapon
  23.     attr_accessor :weight
  24.     def name
  25.       return @name.split(/,/)[0]
  26.     end
  27.     def weight
  28.       rpgwt = @name.split(/,/)[1].to_i
  29.       return rpgwt = nil ? 0 : rpgwt
  30.     end  
  31.    end
  32.  
  33.   class Armor
  34.     attr_accessor :weight
  35.     def name
  36.       return @name.split(/,/)[0]
  37.     end
  38.     def weight
  39.       rpgwt = @name.split(/,/)[1].to_i
  40.       return rpgwt = nil ? 0 : rpgwt
  41.     end  
  42.   end
  43. end
  44.  
  45. class Game_Actor < Game_Battler
  46.   attr_accessor :weight # 单个人物目前所带负载
  47.   attr_accessor :indi_capacity
  48.   attr_accessor :items
  49.   attr_accessor :weapons
  50.   attr_accessor :armors
  51.   alias original_setup setup
  52.   def setup(actor_id)
  53.     original_setup(actor_id)
  54.     @weight=0
  55.     @items = {}
  56.     @weapons = {}
  57.     @armors = {}
  58.     case actor_id
  59.       when 1 # SLICK
  60.         @indi_capacity = 50000
  61.       when 2 # 玛塔赫
  62.         @indi_capacity = 18000
  63.       when 3 # 塞拉斯
  64.         @indi_capacity = 40000
  65.       when 4 # 特萝西
  66.         @indi_capacity = 14000
  67.       when 5 # 艾斯迪儿
  68.         @indi_capacity = 36000
  69.       when 6 # 菲力克斯
  70.         @indi_capacity = 25000      
  71.       when 7 # 克萝莉亚
  72.         @indi_capacity = 14000
  73.       when 8 # 西露达
  74.         @indi_capacity = 10000
  75.     end
  76.   end
  77.  
  78.   def total_weight
  79.     totalwt = self.weight
  80.     if self.weapon_id != 0
  81.       totalwt += $data_weapons[self.weapon_id].weight
  82.     end
  83.     if self.armor1_id != 0
  84.       totalwt += $data_armors[self.armor1_id].weight
  85.     end
  86.     if self.armor2_id != 0
  87.       totalwt += $data_armors[self.armor2_id].weight
  88.     end
  89.     if self.armor3_id != 0
  90.       totalwt += $data_armors[self.armor3_id].weight
  91.     end
  92.     if self.armor4_id != 0
  93.       totalwt += $data_armors[self.armor4_id].weight
  94.     end
  95.     return totalwt
  96.   end  
  97.  
  98.   def item_number(item_id)
  99.     # 如果 hash 个数数值不存在就返回 0
  100.     return @items.include?(item_id) ? @items[item_id] : 0
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 获取武器所持数
  104.   #     weapon_id : 武器 ID
  105.   #--------------------------------------------------------------------------
  106.   def weapon_number(weapon_id)
  107.     # 如果 hash 个数数值不存在就返回 0
  108.     return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 获取防具所持数
  112.   #     armor_id : 防具 ID
  113.   #--------------------------------------------------------------------------
  114.   def armor_number(armor_id)
  115.     # 如果 hash 个数数值不存在就返回 0
  116.     return @armors.include?(armor_id) ? @armors[armor_id] : 0
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 增加物品 (减少)
  120.   #     item_id : 物品 ID
  121.   #     n       : 个数
  122.   #--------------------------------------------------------------------------
  123.   def gain_item(item_id, n)
  124.     # 更新 hash 的个数数据
  125.     if item_id > 0
  126.  
  127.       temp = @weight + $data_items[item_id].weight * n
  128.  
  129.       return if (n < 0 and @items[item_id] == nil)
  130.  
  131.       if temp > max_weight
  132.         return
  133.       end
  134.       if temp < 0
  135.         a = @weight
  136.         for i in 1..n.abs
  137.           a -= $data_items[item_id].weight
  138.           if a < 0
  139.             return
  140.           else
  141.             # 数量-1
  142.             @items[item_id] = [item_number(item_id) - i, 0].max
  143.             # 负重-1
  144.             @weight -= $data_items[item_id].weight
  145.             # p @weight
  146.           end  
  147.         end
  148.         # p @weight
  149.         return
  150.       end  
  151.  
  152.       if @items[item_id] != nil
  153.         b = @items[item_id] - n.abs
  154.         if b < 0 and n < 0
  155.           c = @items[item_id]
  156.           @items[item_id] = [item_number(item_id) + n, 0].max
  157.           @weight -= $data_items[item_id].weight * c
  158.           # p @weight
  159.           return
  160.         end
  161.       end  
  162.  
  163.       @items[item_id] = [item_number(item_id) + n, 0].max
  164.       @weight = temp
  165.       # p @weight
  166.     end
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ● 增加武器 (减少)
  170.   #     weapon_id : 武器 ID
  171.   #     n         : 个数
  172.   #--------------------------------------------------------------------------
  173.   def gain_weapon(weapon_id, n)
  174.     # 更新 hash 的个数数据
  175.     if weapon_id > 0
  176.       temp = @weight + $data_weapons[weapon_id].weight * n
  177.  
  178.       return if (n < 0 and @weapons[weapon_id] == nil)
  179.  
  180.       if temp > max_weight
  181.         return
  182.       end
  183.       if temp < 0
  184.         a = @weight
  185.         for i in 1..n.abs
  186.           a -= $data_weapons[weapon_id].weight
  187.           if a < 0
  188.             return
  189.           else
  190.             # 数量-1
  191.             @weapons[weapon_id] = [weapon_number(weapon_id) - i, 0].max
  192.             # 负重-1
  193.             @weight -= $data_weapons[weapon_id].weight
  194.            # p @weight
  195.           end  
  196.         end
  197.        # p @weight
  198.         return
  199.       end  
  200.  
  201.       if @weapons[weapon_id] != nil
  202.         b = @weapons[weapon_id] - n.abs
  203.         if b < 0 and n < 0
  204.           c = @weapons[weapon_id]
  205.           @weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
  206.           @weight -= $data_weapons[weapon_id].weight * c
  207.         #  p @weight
  208.           return
  209.         end
  210.       end
  211.  
  212.       @weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
  213.       @weight = temp
  214.      # p @weight
  215.     end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● 增加防具 (减少)
  219.   #     armor_id : 防具 ID
  220.   #     n        : 个数
  221.   #--------------------------------------------------------------------------
  222.   def gain_armor(armor_id, n)
  223.     # 更新 hash 的个数数据
  224.     if armor_id > 0
  225.       temp = @weight + $data_armors[armor_id].weight * n
  226.  
  227.       return if (n < 0 and @armors[armor_id] == nil)
  228.  
  229.       if temp > max_weight
  230.         return
  231.       end
  232.       if temp < 0
  233.         a = @weight
  234.         for i in 1..n.abs
  235.           a -= $data_armors[armor_id].weight
  236.           if a < 0
  237.             return
  238.           else
  239.             # 数量-1
  240.             @armors[armor_id] = [armor_number(armor_id) - i, 0].max
  241.             # 负重-1
  242.             @weight -= $data_armors[armor_id].weight
  243.             # p @weight
  244.           end  
  245.         end
  246.         # p @weight
  247.         return
  248.       end  
  249.  
  250.       if @armors[armor_id] != nil
  251.         b = @armors[armor_id] - n.abs
  252.         if b < 0 and n < 0
  253.           c = @armors[armor_id]
  254.           @armors[armor_id] = [armor_number(armor_id) + n, 0].max
  255.           @weight -= $data_armors[armor_id].weight * c
  256.           # p @weight
  257.           return
  258.         end
  259.       end
  260.  
  261.       @armors[armor_id] = [armor_number(armor_id) + n, 0].max
  262.       @weight = temp
  263.       # p @weight
  264.     end
  265.   end
  266.  
  267.   def max_weight
  268.     return @indi_capacity
  269.   end
  270.  
  271.   def check_weight
  272.  
  273.   end
  274.  
  275.   #--------------------------------------------------------------------------
  276.   # ● 减少物品
  277.   #     item_id : 物品 ID
  278.   #     n       : 个数
  279.   #--------------------------------------------------------------------------
  280.   def lose_item(item_id, n)
  281.     # 调用 gain_item 的数值逆转
  282.     gain_item(item_id, -n)
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 减少武器
  286.   #     weapon_id : 武器 ID
  287.   #     n         : 个数
  288.   #--------------------------------------------------------------------------
  289.   def lose_weapon(weapon_id, n)
  290.     # 调用 gain_weapon 的数值逆转
  291.     gain_weapon(weapon_id, -n)
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● 减少防具
  295.   #     armor_id : 防具 ID
  296.   #     n        : 个数
  297.   #--------------------------------------------------------------------------
  298.   def lose_armor(armor_id, n)
  299.     # 调用 gain_armor 的数值逆转
  300.     gain_armor(armor_id, -n)
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● 判断物品可以使用
  304.   #     item_id : 物品 ID
  305.   #--------------------------------------------------------------------------
  306.   def item_can_use?(item_id)
  307.     # 物品个数为 0 的情况
  308.     if item_number(item_id) == 0
  309.       # 不能使用
  310.       return false
  311.     end
  312.     # 获取可以使用的时候
  313.     occasion = $data_items[item_id].occasion
  314.     # 战斗的情况
  315.     if $game_temp.in_battle
  316.       # 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
  317.       return (occasion == 0 or occasion == 1)
  318.     end
  319.     # 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
  320.     return (occasion == 0 or occasion == 2)
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● 变更装备
  324.   #     equip_type : 装备类型
  325.   #     id    : 武器 or 防具 ID  (0 为解除装备)
  326.   #--------------------------------------------------------------------------
  327.   def equip(equip_type, id)
  328.     case equip_type
  329.     when 0  # 武器
  330.       if id == 0 or self.weapon_number(id) > 0
  331.         self.gain_weapon(@weapon_id, 1)
  332.         @weapon_id = id
  333.         self.lose_weapon(id, 1)
  334.       end
  335.     when 1  # 盾
  336.       if id == 0 or self.armor_number(id) > 0
  337.         update_auto_state($data_armors[@armor1_id], $data_armors[id])
  338.         self.gain_armor(@armor1_id, 1)
  339.         @armor1_id = id
  340.         self.lose_armor(id, 1)
  341.       end
  342.     when 2  # 头
  343.       if id == 0 or self.armor_number(id) > 0
  344.         update_auto_state($data_armors[@armor2_id], $data_armors[id])
  345.         self.gain_armor(@armor2_id, 1)
  346.         @armor2_id = id
  347.         self.lose_armor(id, 1)
  348.       end
  349.     when 3  # 身体
  350.       if id == 0 or self.armor_number(id) > 0
  351.         update_auto_state($data_armors[@armor3_id], $data_armors[id])
  352.         self.gain_armor(@armor3_id, 1)
  353.         @armor3_id = id
  354.         self.lose_armor(id, 1)
  355.       end
  356.     when 4  # 装饰品
  357.       if id == 0 or self.armor_number(id) > 0
  358.         update_auto_state($data_armors[@armor4_id], $data_armors[id])
  359.         self.gain_armor(@armor4_id, 1)
  360.         @armor4_id = id
  361.         self.lose_armor(id, 1)
  362.       end
  363.     end
  364.   end
  365. end  
  366. #==============================================================================
  367. # ■ Scene_IndiItem
  368. #------------------------------------------------------------------------------
  369. #  处理单人物品画面的类。
  370. #==============================================================================
  371.  
  372. class Scene_IndiItem
  373.   #--------------------------------------------------------------------------
  374.   # ● 初始化对像
  375.   #     actor_index : 角色索引
  376.   #     equip_index : 装备索引
  377.   #--------------------------------------------------------------------------
  378.   def initialize(actor_index)
  379.     @actor_index = actor_index
  380.     @actor = $game_party.actors[@actor_index]
  381.     $正在丢弃物品 = 0
  382.     $正在交付物品 = 0
  383.     $指定人物=0
  384.     $交付数量=0
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 主处理
  388.   #--------------------------------------------------------------------------
  389.   def main
  390.     # 生成帮助窗口、物品窗口
  391.     @help_window = Window_Help.new
  392.     @help_window.y = 10
  393.     @item_window = Window_IndiItem.new(@actor)
  394.     @item_window.y = 67
  395.     # 关联帮助窗口
  396.     @item_window.help_window = @help_window
  397.     # 生成目标窗口 (设置为不可见・不活动)
  398.     @target_window = Window_Target.new
  399.     @target_window.visible = false
  400.     @target_window.active = false
  401.     @num_window = Window_GiveNum.new(@actor, nil)
  402.     @num_window.visible=false
  403.     @num_window.active=false
  404.     @give_window = Window_Give.new(@actor)
  405.     @give_window.visible=false
  406.     @give_window.active=false
  407.     @dowi_window = Window_Dowi.new
  408.     @dowi_window.visible=false
  409.     @dowi_window.active=false
  410.     # 执行过度
  411.     Graphics.transition
  412.     # 主循环
  413.     loop do
  414.       # 刷新游戏画面
  415.       Graphics.update
  416.       # 刷新输入信息
  417.       Input.update
  418.       # 刷新画面
  419.       update
  420.       # 如果画面切换就中断循环
  421.       if $scene != self
  422.         break
  423.       end
  424.     end
  425.     # 装备过渡
  426.     Graphics.freeze
  427.     # 释放窗口
  428.     @help_window.dispose
  429.     @item_window.dispose
  430.     @target_window.dispose
  431.     @num_window.dispose
  432.     @give_window.dispose
  433.     @dowi_window.dispose
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 刷新画面
  437.   #--------------------------------------------------------------------------
  438.   def update
  439.     # 刷新窗口
  440.     @help_window.update
  441.     @item_window.update
  442.     @target_window.update
  443.     # 物品窗口被激活的情况下: 调用 update_item
  444.     if @item_window.active
  445.       update_item
  446.       return
  447.     end
  448.     # 目标窗口被激活的情况下: 调用 update_target
  449.     if @target_window.active
  450.       update_target
  451.       return
  452.     end
  453.     if @num_window.active
  454.       update_num
  455.       return
  456.     end  
  457.     if @give_window.active
  458.       update_give
  459.       return
  460.     end
  461.     if @dowi_window.active
  462.       update_dowi
  463.       return
  464.     end
  465.   end
  466.   def update_num
  467.     if Input.trigger?(Input::B)
  468.       @num_window.active=false
  469.       @num_window.visible=false
  470.       @give_window.active=false
  471.       @give_window.visible=false
  472.       @item_window.active=true
  473.       $game_system.se_play($data_system.cancel_se)
  474.       return
  475.     end
  476.     if Input.trigger?(Input::C)
  477.       @item = @item_window.item
  478.       wwwt = @item.weight * $交付数量
  479.       if @dowi_window.index == 1
  480.         if wwwt > ($game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight)
  481.           $game_system.se_play($data_system.buzzer_se)
  482.           return
  483.         end
  484.         case @item
  485.         when RPG::Item
  486.           $game_party.actors[$指定人物].gain_item(@item.id,$交付数量)
  487.         when RPG::Weapon
  488.           $game_party.actors[$指定人物].gain_weapon(@item.id,$交付数量)
  489.         when RPG::Armor
  490.           $game_party.actors[$指定人物].gain_armor(@item.id,$交付数量)
  491.         end  
  492.       end  
  493.       case @item
  494.       when RPG::Item
  495.         @actor.lose_item(@item.id,$交付数量)
  496.       when RPG::Weapon
  497.         @actor.lose_weapon(@item.id,$交付数量)
  498.       when RPG::Armor
  499.         @actor.lose_armor(@item.id,$交付数量)
  500.       end  
  501.       @num_window.active=false
  502.       @num_window.visible=false
  503.       @give_window.active=false
  504.       @give_window.visible=false
  505.       @item_window.active=true
  506.       $game_system.se_play($data_system.decision_se)
  507.       @item_window.refresh
  508.       @weight_window.refresh(@item.weight)
  509.       return
  510.     end
  511.     @num_window.update
  512.   end
  513.   def update_give
  514.     if Input.trigger?(Input::B)
  515.       @give_window.active=false
  516.       @give_window.visible=false
  517.       @item_window.active=true
  518.       $game_system.se_play($data_system.cancel_se)
  519.       return
  520.     end
  521.     if Input.trigger?(Input::C)
  522.       @item = @item_window.item
  523.       @give_window.active=false
  524.       @num_window.dispose
  525.       @num_window = Window_GiveNum.new(@actor, @item)
  526.       @num_window.active=true
  527.       @num_window.visible=true
  528.       $game_system.se_play($data_system.decision_se)
  529.       return
  530.     end
  531.     if Input.trigger?(Input::DOWN)
  532.       @give_window.index+=1
  533.       if @give_window.index>=$give_max
  534.         @give_window.index=0
  535.       end  
  536.       $game_system.se_play($data_system.cursor_se)
  537.       return
  538.     end  
  539.     if Input.trigger?(Input::UP)
  540.       @give_window.index-=1
  541.       if @give_window.index<0
  542.         @give_window.index+=$give_max
  543.       end
  544.       $game_system.se_play($data_system.cursor_se)
  545.       return
  546.     end
  547.     @give_window.update
  548.   end
  549.   def update_dowi
  550.     if Input.trigger?(Input::B)
  551.       @dowi_window.active=false
  552.       @dowi_window.visible=false
  553.       @item_window.active=true
  554.       $game_system.se_play($data_system.cancel_se)
  555.       return
  556.     end
  557.     if Input.trigger?(Input::C)
  558.       @item = @item_window.item
  559.       if @dowi_window.index == 0
  560. #==============================================================================        
  561.       # 不使用物品的情况下
  562.       unless @item.is_a?(RPG::Item)
  563.         # 演奏冻结 SE
  564.         $game_system.se_play($data_system.buzzer_se)
  565.         return
  566.       end
  567.       # 不能使用的情况下
  568.       unless @actor.item_can_use?(@item.id)
  569.         # 演奏冻结 SE
  570.         $game_system.se_play($data_system.buzzer_se)
  571.         return
  572.       end
  573.       # 演奏确定 SE
  574.       $game_system.se_play($data_system.decision_se)
  575.       # 效果范围是我方的情况下
  576.       if @item.scope >= 3
  577.         # 激活目标窗口
  578.         @dowi_window.active=false
  579.         @dowi_window.visible=false
  580.         @target_window.x = (@item_window.index + 1) % 2 * 304
  581.         @target_window.visible = true
  582.         @target_window.active = true
  583.         # 设置效果范围 (单体/全体) 的对应光标位置
  584.         if @item.scope == 4 || @item.scope == 6
  585.           @target_window.index = -1
  586.         else
  587.           @target_window.index = 0
  588.         end
  589.       # 效果在我方以外的情况下
  590.       else
  591.         # 公共事件 ID 有效的情况下
  592.         if @item.common_event_id > 0
  593.           # 预约调用公共事件
  594.           $game_temp.common_event_id = @item.common_event_id
  595.           # 演奏物品使用时的 SE
  596.           $game_system.se_play(@item.menu_se)
  597.           # 消耗品的情况下
  598.           if @item.consumable
  599.             # 使用的物品数减 1
  600.             @actor.lose_item(@item.id, 1)
  601.             # 再描绘物品窗口的项目
  602.             @item_window.draw_item(@item_window.index)
  603.           end
  604.           # 切换到地图画面
  605.           $scene = Scene_Map.new
  606.           return
  607.         end
  608.  
  609.       return
  610.       end
  611. #==============================================================================   
  612.       else
  613.         if @dowi_window.index==1
  614.           if $game_party.actors.size<2
  615.             $game_system.se_play($data_system.buzzer_se)
  616.             return
  617.           end  
  618.           $正在交付物品=1
  619.           $正在丢弃物品=0
  620.           @dowi_window.active=false
  621.           @dowi_window.visible=false
  622.           @give_window.dispose
  623.           @give_window=Window_Give.new(@actor)
  624.           @give_window.active=true
  625.           @give_window.visible=true
  626.         else
  627.           $正在交付物品=0
  628.           $正在丢弃物品=1
  629.           @dowi_window.active=false
  630.           @dowi_window.visible=false
  631.           @item = @item_window.item
  632.           @num_window.dispose
  633.           @num_window = Window_GiveNum.new(@actor, @item)
  634.           @num_window.active=true
  635.           @num_window.visible=true
  636.         end  
  637.         $game_system.se_play($data_system.decision_se)
  638.         return
  639.       end  
  640.     end
  641.     if Input.trigger?(Input::DOWN)
  642.       @dowi_window.index+=1
  643.       if @dowi_window.index>2
  644.         @dowi_window.index=0
  645.       end  
  646.       $game_system.se_play($data_system.cursor_se)
  647.       return
  648.     end  
  649.     if Input.trigger?(Input::UP)
  650.       @dowi_window.index-=1
  651.       if @dowi_window.index<0
  652.         @dowi_window.index=2
  653.       end
  654.       $game_system.se_play($data_system.cursor_se)
  655.       return
  656.     end
  657.     @dowi_window.update
  658.   end  
  659.   #--------------------------------------------------------------------------
  660.   # ● 刷新画面 (物品窗口被激活的情况下)
  661.   #--------------------------------------------------------------------------
  662.   def update_item
  663.     # 按下 R 键的情况下
  664.     if Input.trigger?(Input::R)
  665.       # 演奏光标 SE
  666.       $game_system.se_play($data_system.cursor_se)
  667.       # 移至下一位角色
  668.       @actor_index += 1
  669.       @actor_index %= $game_party.actors.size
  670.       # 切换到别的装备画面
  671.       $scene = Scene_IndiItem.new(@actor_index)
  672.       return
  673.     end
  674.     # 按下 L 键的情况下
  675.     if Input.trigger?(Input::L)
  676.       # 演奏光标 SE
  677.       $game_system.se_play($data_system.cursor_se)
  678.       # 移至上一位角色
  679.       @actor_index += $game_party.actors.size - 1
  680.       @actor_index %= $game_party.actors.size
  681.       # 切换到别的装备画面
  682.       $scene = Scene_IndiItem.new(@actor_index)
  683.       return
  684.     end
  685.     # 按下 B 键的情况下
  686.     if Input.trigger?(Input::B)
  687.       # 演奏取消 SE
  688.       $game_system.se_play($data_system.cancel_se)
  689.       # 切换到菜单画面
  690.       $scene = Scene_Menu.new(0)
  691.       return
  692.     end
  693.     # 按下 C 键的情况下
  694.     if Input.trigger?(Input::C)
  695.       # 获取物品窗口当前选中的物品数据
  696.       @item = @item_window.item
  697.       @item_window.active=false
  698.       @dowi_window.dispose
  699.       @dowi_window=Window_Dowi.new(@item)
  700.       @dowi_window.visible=true
  701.       @dowi_window.active=true
  702.       $game_system.se_play($data_system.decision_se)
  703.       return
  704.  
  705.     end
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # ● 刷新画面 (目标窗口被激活的情况下)
  709.   #--------------------------------------------------------------------------
  710.   def update_target
  711.     # 按下 B 键的情况下
  712.     if Input.trigger?(Input::B)
  713.       # 演奏取消 SE
  714.       $game_system.se_play($data_system.cancel_se)
  715.       # 由于物品用完而不能使用的场合
  716.       unless @actor.item_can_use?(@item.id)
  717.         # 再次生成物品窗口的内容
  718.         @item_window.refresh
  719.       end
  720.       # 删除目标窗口
  721.       @item_window.active = true
  722.       @target_window.visible = false
  723.       @target_window.active = false
  724.       return
  725.     end
  726.     # 按下 C 键的情况下
  727.     if Input.trigger?(Input::C)
  728.       # 如果物品用完的情况下
  729.       if @actor.item_number(@item.id) == 0
  730.         # 演奏冻结 SE
  731.         $game_system.se_play($data_system.buzzer_se)
  732.         return
  733.       end
  734.       # 目标是全体的情况下
  735.       if @target_window.index == -1
  736.         # 对同伴全体应用物品使用效果
  737.         used = false
  738.         for i in $game_party.actors
  739.           used |= i.item_effect(@item)
  740.         end
  741.       end
  742.       # 目标是单体的情况下
  743.       if @target_window.index >= 0
  744.         # 对目标角色应用物品的使用效果
  745.         target = $game_party.actors[@target_window.index]
  746.         used = target.item_effect(@item)
  747.       end
  748.       # 使用物品的情况下
  749.       if used
  750.         # 演奏物品使用时的 SE
  751.         $game_system.se_play(@item.menu_se)
  752.         # 消耗品的情况下
  753.         if @item.consumable
  754.           # 使用的物品数减 1
  755.           @actor.lose_item(@item.id, 1)
  756.           # 再描绘物品窗口的项目
  757.           @item_window.draw_item(@item_window.index)
  758.         end
  759.         # 再生成目标窗口的内容
  760.         @target_window.refresh
  761.         # 全灭的情况下
  762.         if $game_party.all_dead?
  763.           # 切换到游戏结束画面
  764.           $scene = Scene_Gameover.new
  765.           return
  766.         end
  767.         # 公共事件 ID 有效的情况下
  768.         if @item.common_event_id > 0
  769.           # 预约调用公共事件
  770.           $game_temp.common_event_id = @item.common_event_id
  771.           # 切换到地图画面
  772.           $scene = Scene_Map.new
  773.           return
  774.         end
  775.       end
  776.       # 无法使用物品的情况下
  777.       unless used
  778.         # 演奏冻结 SE
  779.         $game_system.se_play($data_system.buzzer_se)
  780.       end
  781.       return
  782.     end
  783.   end
  784. end
  785.  
  786. class Scene_Battle
  787.   def start_item_select
  788.     # 生成物品窗口
  789.     @item_window = Window_IndiItem.new(@active_actor)
  790.     # 关联帮助窗口
  791.     @item_window.help_window = @help_window
  792.     # 无效化角色指令窗口
  793.     @actor_command_window.active = false
  794.     @actor_command_window.visible = false
  795.   end
  796.   #--------------------------------------------------------------------------
  797.   # ● 刷新画面 (角色命令回合 : 选择物品)
  798.   #--------------------------------------------------------------------------
  799.   def update_phase3_item_select
  800.     # 设置物品窗口为可视状态
  801.     @item_window.visible = true
  802.     # 刷新物品窗口
  803.     @item_window.update
  804.     # 按下 B 键的情况下
  805.     if Input.trigger?(Input::B)
  806.       # 演奏取消 SE
  807.       $game_system.se_play($data_system.cancel_se)
  808.       # 选择物品结束
  809.       end_item_select
  810.       return
  811.     end
  812.     # 按下 C 键的情况下
  813.     if Input.trigger?(Input::C)
  814.       # 获取物品窗口现在选择的物品资料
  815.       @item = @item_window.item
  816.       # 无法使用的情况下
  817.       unless @active_actor.item_can_use?(@item.id)
  818.         # 演奏冻结 SE
  819.         $game_system.se_play($data_system.buzzer_se)
  820.         return
  821.       end
  822.       # 演奏确定 SE
  823.       $game_system.se_play($data_system.decision_se)
  824.       # 设置行动
  825.       @active_actor.current_action.item_id = @item.id
  826.       # 设置物品窗口为不可见状态
  827.       @item_window.visible = false
  828.       # 效果范围是敌单体的情况下
  829.       if @item.scope == 1
  830.         # 开始选择敌人
  831.         start_enemy_select
  832.       # 效果范围是我方单体的情况下
  833.       elsif @item.scope == 3 or @item.scope == 5
  834.         # 开始选择角色
  835.         start_actor_select
  836.       # 效果范围不是单体的情况下
  837.       else
  838.         # 物品选择结束
  839.         end_item_select
  840.         # 转到下一位角色的指令输入
  841.         phase3_next_actor
  842.       end
  843.       return
  844.     end
  845.   end
  846.  
  847.   def make_item_action_result(battler)
  848.     # アイテムを取得
  849.     @item = $data_items[battler.current_action.item_id]
  850.     # アイテム切れなどで使用できなくなった場合
  851.     unless battler.item_can_use?(@item.id)
  852.       # ステップ 6 に移行
  853.       battler.phase = 6
  854.       return
  855.     end
  856.     # 消耗品の場合
  857.     if @item.consumable
  858.       # 使用したアイテムを 1 減らす
  859.       battler.lose_item(@item.id, 1)
  860.     end
  861.     # アニメーション ID を設定
  862.     battler.anime1 = @item.animation1_id
  863.     battler.anime2 = @item.animation2_id
  864.     # コモンイベント ID を設定
  865.     battler.event = @item.common_event_id
  866.     # 対象を決定
  867.     index = battler.current_action.target_index
  868.     target = $game_party.smooth_target_actor(index)
  869.     # 対象側バトラーを設定
  870.     set_target_battlers(@item.scope, battler)
  871.     # アイテムの効果を適用
  872.     for target in battler.target
  873.       target.item_effect(@item, battler)
  874.     end
  875.   end
  876. end
  877.  
  878. #==============================================================================
  879. # ■ Window_IndiItem
  880. #------------------------------------------------------------------------------
  881. #  物品画面、战斗画面、显示浏览物品的窗口。
  882. #==============================================================================
  883.  
  884. class Window_IndiItem < Window_Selectable
  885.   #--------------------------------------------------------------------------
  886.   # ● 初始化对像
  887.   #--------------------------------------------------------------------------
  888.   def initialize(actor)
  889.     @actor = actor
  890.     super(0, 64, 640, 288)
  891.     @column_max = 2
  892.     refresh
  893.     self.index = 0
  894.     # 战斗中的情况下将窗口移至中央并将其半透明化
  895.     if $game_temp.in_battle
  896.       self.y = 64
  897.       self.height = 256
  898.       self.back_opacity = 160
  899.     end
  900.   end
  901.   #--------------------------------------------------------------------------
  902.   # ● 获取物品
  903.   #--------------------------------------------------------------------------
  904.   def item
  905.     return @data[self.index]
  906.   end
  907.   #--------------------------------------------------------------------------
  908.   # ● 刷新
  909.   #--------------------------------------------------------------------------
  910.   def refresh
  911.     if self.contents != nil
  912.       self.contents.dispose
  913.       self.contents = nil
  914.     end
  915.     @data = []
  916.     # 添加报务
  917.     for i in 1...$data_items.size
  918.       if @actor.item_number(i) > 0
  919.         @data.push($data_items[i])
  920.       end
  921.     end
  922.     # 在战斗中以外添加武器、防具
  923.     unless $game_temp.in_battle
  924.       for i in 1...$data_weapons.size
  925.         if @actor.weapon_number(i) > 0
  926.           @data.push($data_weapons[i])
  927.         end
  928.       end
  929.       for i in 1...$data_armors.size
  930.         if @actor.armor_number(i) > 0
  931.           @data.push($data_armors[i])
  932.         end
  933.       end
  934.     end
  935.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  936.     @item_max = @data.size
  937.     if @item_max > 0
  938.       self.contents = Bitmap.new(width - 32, row_max * 32)
  939.       for i in 0...@item_max
  940.         draw_item(i)
  941.       end
  942.     end
  943.   end
  944.   #--------------------------------------------------------------------------
  945.   # ● 描绘项目
  946.   #     index : 项目编号
  947.   #--------------------------------------------------------------------------
  948.   def draw_item(index)
  949.     item = @data[index]
  950.     case item
  951.     when RPG::Item
  952.       number = @actor.item_number(item.id)
  953.     when RPG::Weapon
  954.       number = @actor.weapon_number(item.id)
  955.     when RPG::Armor
  956.       number = @actor.armor_number(item.id)
  957.     end
  958.     if item.is_a?(RPG::Item) and
  959.        @actor.item_can_use?(item.id)
  960.       self.contents.font.color = normal_color
  961.     else
  962.       self.contents.font.color = disabled_color
  963.     end
  964.     x = 4 + index % 2 * (288 + 32)
  965.     y = index / 2 * 32
  966.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  967.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  968.     bitmap = RPG::Cache.icon(item.icon_name)
  969.     opacity = self.contents.font.color == normal_color ? 255 : 128
  970.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  971.     self.contents.draw_text(x + 28, y, 192, 32, item.name, 0)
  972.     self.contents.draw_text(x + 224, y, 16, 32, ":", 1)
  973.     self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2)
  974.   end
  975.   #--------------------------------------------------------------------------
  976.   # ● 刷新帮助文本
  977.   #--------------------------------------------------------------------------
  978.   def update_help
  979.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  980.   end
  981. end
  982.  
  983. class Scene_IndiItem
  984.   alias ori_main main
  985.   def main
  986.     @weight_window = Window_Weight.new(@actor)
  987.     @weight_window.x = 0
  988.     @weight_window.y = 348
  989.     @weight_window.z = 0
  990.     ori_main
  991.     @weight_window.dispose
  992.   end  
  993.   alias ori_update update
  994.   def update
  995.        case @item_window.item
  996.        when RPG::Item
  997.          @weight_window.refresh($data_items[@item_window.item.id].weight)
  998.        when RPG::Weapon
  999.          @weight_window.refresh($data_weapons[@item_window.item.id].weight)
  1000.        when RPG::Armor  
  1001.          @weight_window.refresh($data_armors[@item_window.item.id].weight)
  1002.        end
  1003.     ori_update
  1004.   end
  1005. end
  1006.  
  1007. class Window_Weight < Window_Base
  1008.   def initialize(actor)
  1009.     @actor=actor
  1010.     super(0,0,640,110)
  1011.     self.opacity = 255
  1012.     self.contents = Bitmap.new(width-32,height-32)
  1013.     refresh(nil)
  1014.   end  
  1015.   def refresh(weight)
  1016.     self.contents.clear
  1017.     self.contents.draw_text(0,0,160,32,@actor.name)
  1018.     if weight != nil
  1019.       self.contents.draw_text(128,0,160,32,"单件重量:#{weight}")
  1020.     end
  1021.     self.contents.draw_text(320,0,320,32,"背包空间:"+@actor.total_weight.to_s + "/" + @actor.indi_capacity.to_s , 0)
  1022.     ssstx=0
  1023.     sssty=32
  1024.     self.contents.draw_text(ssstx,sssty,160,32,"装备物品:")
  1025.     ssstx=128
  1026.     if @actor.weapon_id != 0
  1027.       self.contents.draw_text(ssstx,sssty,160,32,$data_weapons[@actor.weapon_id].name + "(" + $data_weapons[@actor.weapon_id].weight.to_s + ")")
  1028.     end
  1029.     ssstx=288
  1030.     if @actor.armor1_id != 0
  1031.       self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor1_id].name + "(" + $data_armors[@actor.armor1_id].weight.to_s + ")")
  1032.     end
  1033.     ssstx=448
  1034.     if @actor.armor2_id != 0
  1035.       self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor2_id].name + "(" + $data_armors[@actor.armor2_id].weight.to_s + ")")
  1036.     end
  1037.     ssstx=128
  1038.     sssty=64
  1039.     if @actor.armor3_id != 0
  1040.       self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor3_id].name + "(" + $data_armors[@actor.armor3_id].weight.to_s + ")")
  1041.     end
  1042.     ssstx=288
  1043.     if @actor.armor4_id != 0
  1044.       self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor4_id].name + "(" + $data_armors[@actor.armor4_id].weight.to_s + ")")
  1045.     end
  1046.   end
  1047. end  
  1048.  
  1049. class Window_Dowi < Window_Selectable
  1050.   def initialize(item = nil)
  1051.     super(256, 240, 90, 130)
  1052.     @item = item
  1053.     self.opacity = 255
  1054.     self.contents = Bitmap.new(width-32,height-32)
  1055.     self.z=120
  1056.     self.index=0
  1057.     refresh
  1058.   end  
  1059.   def refresh
  1060.     self.contents.draw_text(4, 0, 192, 32, "使用", 0)
  1061.     self.contents.draw_text(4, 32, 192, 32, "交给", 0)
  1062.     self.contents.draw_text(4, 64, 192, 32, "丢弃", 0)
  1063.   end  
  1064. end
  1065.  
  1066. class Window_Give < Window_Selectable
  1067.   def initialize(actor)
  1068.     super(256, 240, 128, 160)
  1069.     @actor = actor
  1070.     @column_max = 1
  1071.     self.active = false
  1072.     self.index = -1
  1073.     self.contents = Bitmap.new(width - 32, height - 32)
  1074.     self.z=120
  1075.     self.index=0
  1076.     $指定人物=0
  1077.     # 添加本人以外的角色
  1078.     @data=[]
  1079.     @data_target=[]
  1080.     for iii in 0...$game_party.actors.size
  1081.       if @actor != $game_party.actors[iii]
  1082.         @data.push($game_party.actors[iii].name)
  1083.         @data_target.push(iii)
  1084.       end  
  1085.     end
  1086.     @item_max=@data.size
  1087.     $give_max=@item_max
  1088.     refresh
  1089.   end
  1090.  
  1091.   def refresh
  1092.     self.contents.clear
  1093.     for i in 0...@item_max
  1094.       draw_item(i)
  1095.     end
  1096.     $指定人物=@data_target[self.index]
  1097.   end  
  1098.  
  1099.   #--------------------------------------------------------------------------
  1100.   # ● 项目的描绘
  1101.   #     index : 项目符号
  1102.   #--------------------------------------------------------------------------
  1103.   def draw_item(index)
  1104.     #print index
  1105.     item = @data[index]
  1106.     #print item
  1107.     x = 4
  1108.     y = index * 32
  1109.     self.contents.font.color = normal_color
  1110.     self.contents.draw_text(x, y, 192, 32, item, 0)
  1111.   end
  1112.  
  1113.   def update
  1114.     refresh
  1115.   end  
  1116. end
  1117.  
  1118. class Window_GiveNum < Window_Base
  1119.   #--------------------------------------------------------------------------
  1120.   # ● 初始化对像
  1121.   #--------------------------------------------------------------------------
  1122.   def initialize(actor, item)
  1123.     super(160, 80, 320, 160)
  1124.     self.contents = Bitmap.new(width - 32, height - 32)
  1125.     @item = item
  1126.     @number = 1
  1127.     if item != nil  
  1128.       @max = actor.item_number(item.id)
  1129.     else
  1130.       @max = 0
  1131.     end  
  1132.     self.z=120
  1133.     refresh
  1134.   end
  1135.   def refresh
  1136.     self.contents.clear
  1137.     self.contents.font.color = normal_color
  1138.     if @item != nil  
  1139.     if $正在丢弃物品 != 0
  1140.       self.contents.draw_text(4, 0, 192, 32, "丢掉几件", 0)
  1141.       self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0)
  1142.       self.contents.draw_text(4, 32, 192, 32, "减轻重量", 0)
  1143.       self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0)
  1144.       self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0)
  1145.       return
  1146.     end  
  1147.     if $正在交付物品 != 1
  1148.       self.contents.draw_text(4, 0, 192, 32, "要交给谁", 0)
  1149.     else
  1150.       self.contents.draw_text(4, 0, 192, 32, "交给几件", 0)
  1151.       self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0)
  1152.       self.contents.draw_text(4, 32, 192, 32, "交换重量", 0)
  1153.       self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0)
  1154.       self.contents.draw_text(4, 64, 240, 32, "接收方剩余负荷", 0)
  1155.       lastweight=$game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight
  1156.       self.contents.draw_text(200, 64, 192, 32, lastweight.to_s, 0)
  1157.     end
  1158.     self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0)
  1159.     end
  1160.   end  
  1161.   #--------------------------------------------------------------------------
  1162.   # ● 刷新画面
  1163.   #--------------------------------------------------------------------------
  1164.   def update
  1165.     super
  1166.     if @item != nil
  1167.     if self.active
  1168.       # 光标右 (+10)
  1169.       if Input.repeat?(Input::RIGHT) and @number < @max
  1170.         $game_system.se_play($data_system.cursor_se)
  1171.         @number = [@number + 10, @max].min
  1172.       end
  1173.       # 光标左 (-10)
  1174.       if Input.repeat?(Input::LEFT) and @number > 1
  1175.         $game_system.se_play($data_system.cursor_se)
  1176.         @number = [@number - 10, 1].max
  1177.       end
  1178.       # 光标上 (-1)
  1179.       if Input.repeat?(Input::UP) and @number > 1
  1180.         $game_system.se_play($data_system.cursor_se)
  1181.         @number -= 1
  1182.       end
  1183.       # 光标下 (+1)
  1184.       if Input.repeat?(Input::DOWN) and @number < @max
  1185.         $game_system.se_play($data_system.cursor_se)
  1186.         @number += 1
  1187.       end
  1188.     end
  1189.     end
  1190.     $交付数量=@number
  1191.     refresh
  1192.   end
  1193. end
  1194.  
  1195. #==============================================================================
  1196. # ■ Window_EquipItem
  1197. #------------------------------------------------------------------------------
  1198. #  装备画面、显示浏览变更装备的候补物品的窗口。
  1199. #==============================================================================
  1200.  
  1201. class Window_EquipItem < Window_Selectable
  1202.   #--------------------------------------------------------------------------
  1203.   # ● 初始化对像
  1204.   #     actor      : 角色
  1205.   #     equip_type : 装备部位 (0~3)
  1206.   #--------------------------------------------------------------------------
  1207.   def initialize(actor, equip_type)
  1208.     super(0, 256, 640, 224)
  1209.     @actor = actor
  1210.     @equip_type = equip_type
  1211.     @column_max = 2
  1212.     refresh
  1213.     self.active = false
  1214.     self.index = -1
  1215.   end
  1216.   #--------------------------------------------------------------------------
  1217.   # ● 获取物品
  1218.   #--------------------------------------------------------------------------
  1219.   def item
  1220.     return @data[self.index]
  1221.   end
  1222.   #--------------------------------------------------------------------------
  1223.   # ● 刷新
  1224.   #--------------------------------------------------------------------------
  1225.   def refresh
  1226.     if self.contents != nil
  1227.       self.contents.dispose
  1228.       self.contents = nil
  1229.     end
  1230.     @data = []
  1231.     # 添加可以装备的武器
  1232.     if @equip_type == 0
  1233.       weapon_set = $data_classes[@actor.class_id].weapon_set
  1234.       for i in 1...$data_weapons.size
  1235.         if @actor.weapon_number(i) > 0 and weapon_set.include?(i)
  1236.           @data.push($data_weapons[i])
  1237.         end
  1238.       end
  1239.     end
  1240.     # 添加可以装备的防具
  1241.     if @equip_type != 0
  1242.       armor_set = $data_classes[@actor.class_id].armor_set
  1243.       for i in 1...$data_armors.size
  1244.         if @actor.armor_number(i) > 0 and armor_set.include?(i)
  1245.           if $data_armors[i].kind == @equip_type-1
  1246.             @data.push($data_armors[i])
  1247.           end
  1248.         end
  1249.       end
  1250.     end
  1251.     # 添加空白
  1252.     @data.push(nil)
  1253.     # 生成位图、描绘全部项目
  1254.     @item_max = @data.size
  1255.     self.contents = Bitmap.new(width - 32, row_max * 32)
  1256.     for i in 0...@item_max-1
  1257.       draw_item(i)
  1258.     end
  1259.   end
  1260.   #--------------------------------------------------------------------------
  1261.   # ● 项目的描绘
  1262.   #     index : 项目符号
  1263.   #--------------------------------------------------------------------------
  1264.   def draw_item(index)
  1265.     item = @data[index]
  1266.     x = 4 + index % 2 * (288 + 32)
  1267.     y = index / 2 * 32
  1268.     case item
  1269.     when RPG::Weapon
  1270.       number = @actor.weapon_number(item.id)
  1271.     when RPG::Armor
  1272.       number = @actor.armor_number(item.id)
  1273.     end
  1274.     bitmap = RPG::Cache.icon(item.icon_name)
  1275.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  1276.     self.contents.font.color = normal_color
  1277.     self.contents.draw_text(x + 28, y, 192, 32, item.name, 0)
  1278.     self.contents.draw_text(x + 224, y, 16, 32, ":", 1)
  1279.     self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2)
  1280.   end
  1281.   #--------------------------------------------------------------------------
  1282.   # ● 刷新帮助文本
  1283.   #--------------------------------------------------------------------------
  1284.   def update_help
  1285.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  1286.   end
  1287. end
  1288.  
  1289. class Game_Party
  1290.   #--------------------------------------------------------------------------
  1291.   # ● 增加物品 (减少)
  1292.   #     item_id : 物品 ID
  1293.   #     n       : 个数
  1294.   #--------------------------------------------------------------------------
  1295.   def gain_item(item_id, n)
  1296.     # 更新 hash 的个数数据
  1297.     if item_id > 0
  1298.       wwwt = $data_items[item_id].weight
  1299.       straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
  1300.       for iii in 0...n #检查物品n次
  1301.         leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
  1302.         while leftwt < wwwt
  1303.           straight += 1
  1304.           if straight>=$game_party.actors.size
  1305.             return
  1306.           end  
  1307.           leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
  1308.         end
  1309.         $game_party.actors[straight].gain_item(item_id, 1)
  1310.       end
  1311.     end
  1312.   end
  1313.   #--------------------------------------------------------------------------
  1314.   # ● 增加武器 (减少)
  1315.   #     weapon_id : 武器 ID
  1316.   #     n         : 个数
  1317.   #--------------------------------------------------------------------------
  1318.   def gain_weapon(weapon_id, n)
  1319.     # 更新 hash 的个数数据
  1320.     if item_id > 0
  1321.       wwwt = $data_weapons[weapon_id].weight
  1322.       straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
  1323.       for iii in 0...n #检查物品n次
  1324.         leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
  1325.         while leftwt < wwwt
  1326.           straight += 1
  1327.           if straight>=$game_party.actors.size
  1328.             return
  1329.           end  
  1330.           leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
  1331.         end
  1332.         $game_party.actors[straight].gain_weapon(weapon_id, 1)
  1333.       end  
  1334.     end
  1335.   end
  1336.   #--------------------------------------------------------------------------
  1337.   # ● 增加防具 (减少)
  1338.   #     armor_id : 防具 ID
  1339.   #     n        : 个数
  1340.   #--------------------------------------------------------------------------
  1341.   def gain_armor(armor_id, n)
  1342.     # 更新 hash 的个数数据
  1343.     if item_id > 0
  1344.       wwwt = $data_armors[armor_id].weight
  1345.       straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
  1346.       for iii in 0...n #检查物品n次
  1347.         leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
  1348.         while leftwt < wwwt
  1349.           straight += 1
  1350.           if straight>=$game_party.actors.size
  1351.             return
  1352.           end  
  1353.           leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
  1354.         end
  1355.         $game_party.actors[straight].gain_armor(armor_id, 1)
  1356.       end  
  1357.     end
  1358.   end
  1359. end

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

本版积分规则

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

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

GMT+8, 2024-4-23 19:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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