查看: 2466|回复: 28

[已经解决] 装备等级判定

[复制链接]
梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
发表于 2022-9-1 23:24:21 | 显示全部楼层 |阅读模式

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

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

×
下面这个脚本已经添加了装备等级显示,如何给装备添加上等级限制。

  1. #==============================================================================
  2. # ■ Fenlei_Command
  3. #------------------------------------------------------------------------------
  4. # 物品分类
  5. #==============================================================================

  6. class Fenlei_Command < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(22, 276+28, 365, 50)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     @commands = ["", "", "", "",""]
  14. #  @commands = ["平时物品", "战斗物品", "武器装备", "宠物道具","任务道具"]

  15.     @item_max = 5
  16.     @column_max = 5
  17.     self.opacity = 0
  18.     self.z = 300
  19.     refresh
  20.     self.index = 0
  21.     # 更改窗口皮肤
  22.     self.windowskin = RPG::Cache.windowskin('物品皮肤/分类')
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 刷新
  26.   #--------------------------------------------------------------------------
  27.   def refresh
  28.     self.contents.clear
  29.     for i in 0...@item_max
  30.       w = contents.text_size(@commands[i]).width
  31.       x = i * 94
  32.       self.contents.font.color = normal_color
  33.       self.contents.draw_text(x, 0, w, 32, @commands[i])
  34.     end
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 項目の描画
  38.   # index : 項目番号
  39.   # color : 文字色
  40.   #--------------------------------------------------------------------------
  41.   def draw_item(index, color)
  42.     self.contents.font.color = color
  43.   # y = index * 32
  44.     self.contents.draw_text(0, y, 128, 32, @commands[index])
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● 刷新帮助文本
  48.   #--------------------------------------------------------------------------
  49.   def update_help
  50.     @help_window.set_text(@commands[self.index])
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 更新光标举行
  54.   #--------------------------------------------------------------------------
  55.   def update_cursor_rect
  56.     # 光标位置不满 0 的情况下
  57.     if @index < 0
  58.       self.cursor_rect.empty
  59.       return
  60.     end
  61.     # 获取当前的行
  62.     row = @index / @column_max
  63.     # 当前行被显示开头行前面的情况下
  64.     if row < self.top_row
  65.       # 从当前行向开头行滚动
  66.       self.top_row = row
  67.     end
  68.     # 当前行被显示末尾行之后的情况下
  69.     if row > self.top_row + (self.page_row_max - 1)
  70.       # 从当前行向末尾滚动
  71.       self.top_row = row - (self.page_row_max - 1)
  72.     end
  73.     # 计算光标的宽
  74.     cursor_width = self.width / @column_max - 34
  75.     # 计算光标坐标
  76.     x = @index % @column_max * (cursor_width+29)
  77.     # 更新国标矩形
  78.     self.cursor_rect.set(x-3, 0, cursor_width+26, 22)
  79.   end  
  80. end

  81. #==============================================================================
  82. # ■ Actor_Item
  83. #------------------------------------------------------------------------------
  84. #  物品画面、战斗画面、显示浏览物品的窗口。
  85. #==============================================================================

  86. class Actor_Item < Window_Selectable
  87.   #--------------------------------------------------------------------------
  88.   # ● 初始化对像
  89.   #--------------------------------------------------------------------------
  90.   def initialize(actor)
  91.     super(8, 326, 420, 270)
  92.     @column_max = 6
  93.     self.opacity = 0
  94.     self.z = 300
  95.     @actor = actor
  96.     refresh
  97.     self.index = -1
  98.     # 更改窗口皮肤
  99.     self.windowskin = RPG::Cache.windowskin('物品皮肤/物品')
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● 获取物品
  103.   #--------------------------------------------------------------------------
  104.   def item
  105.     return @data[self.index]
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 刷新
  109.   #--------------------------------------------------------------------------
  110.   def refresh
  111.     if self.contents != nil
  112.       self.contents.dispose
  113.       self.contents = nil
  114.     end
  115.     @data = []
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 项目列表设置
  119.   # command : 选中的命令
  120.   #--------------------------------------------------------------------------
  121.   def set_item(command)
  122.     refresh
  123.     case command
  124.     # 平时物品
  125.     when 0
  126.       for i in 1...$data_items.size
  127.         # 选项在0-2时不显示11号属性的物品
  128.         if ($data_items[i].occasion == 0 or $data_items[i].occasion == 2) and $game_party.item_number(i) > 0 and $data_items[i].element_set.include?(11) == false
  129.           @data.push($data_items[i])
  130.         end
  131.       end
  132.     # 战斗物品  
  133.     when 1
  134.       for i in 1...$data_items.size
  135.         if ($data_items[i].occasion == 1 and $game_party.item_number(i) > 0)
  136.           @data.push($data_items[i])
  137.         end
  138.       end
  139.     # 武器装备  
  140.     when 2
  141.       for i in 1...$data_weapons.size
  142.         if $game_party.weapon_number(i) > 0
  143.           @data.push($data_weapons[i])
  144.         end
  145.       end
  146.       for i in 1...$data_armors.size
  147.         if $game_party.armor_number(i) > 0
  148.           @data.push($data_armors[i])
  149.         end
  150.       end
  151.       @data.push(nil)
  152.     # 宠物道具  
  153.     when 3
  154.       for i in 1...$data_items.size
  155.         # 显示11号和12号属性的物品
  156.         if $data_items[i].element_set.include?(11) or $data_items[i].element_set.include?(12) and $game_party.item_number(i) > 0
  157.           @data.push($data_items[i])
  158.         end
  159.       end
  160.     # 任务道具  
  161.     when 4
  162.       for i in 1...$data_items.size
  163.         if $data_items[i].occasion == 3 and $game_party.item_number(i) > 0
  164.           # 不显示11号和12号属性的物品
  165.           unless $data_items[i].element_set.include?(11) or $data_items[i].element_set.include?(12)
  166.             @data.push($data_items[i])
  167.           end
  168.         end
  169.       end
  170.     end
  171.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  172.     @item_max = @data.size
  173.     if @item_max > 0
  174.       self.contents = Bitmap.new(width - 59.5, row_max * 61)
  175.       self.contents.clear
  176.       for i in 0...@item_max
  177.         draw_item(i)
  178.       end
  179.     end
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 按类型检索项目数
  183.   #--------------------------------------------------------------------------
  184.   def item_number
  185.     return @item_max
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● 描绘项目
  189.   #     index : 项目编号
  190.   #--------------------------------------------------------------------------
  191.   def draw_item(index)
  192.     item = @data[index]
  193.     return if item.nil?
  194.     case item
  195.     when RPG::Item
  196.       number = $game_party.item_number(item.id)
  197.     when RPG::Weapon
  198.       number = $game_party.weapon_number(item.id)
  199.     when RPG::Armor
  200.       number = $game_party.armor_number(item.id)
  201.     end
  202.     if item.is_a?(RPG::Item) and
  203.       $game_party.item_can_use?(item.id)
  204.       self.contents.font.color = normal_color
  205.     else
  206.       ### 增加能否装备(颜色)判断。######################
  207.       self.contents.font.color = @actor.can_equip?(item) ? normal_color : disabled_color
  208.       ####################################################
  209.     end
  210.     x = index % 6 * 59.5
  211.     y = (index / 6) * 60
  212.     rect = Rect.new(x, y, self.width - 59.5, 60)
  213.     bitmap = RPG::Cache.icon(item.icon_name)
  214.     opacity = 255
  215.     self.contents.blt(x, y , bitmap, Rect.new(0, 0, 59.5, 60), opacity)
  216.     self.contents.font.size = 18
  217.     # 字体加粗
  218.     self.contents.font.bold = true
  219.     self.contents.draw_text(x-4, y-7, 23, 32, number.to_s, 2)
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 刷新帮助文本
  223.   #--------------------------------------------------------------------------
  224.   def update_help  
  225.    # 当没有物品时
  226.    if item == nil
  227.      # 关闭帮助窗口
  228.      @help_window.visible = false
  229.    else
  230.      # 打开帮助窗口
  231.      @help_window.visible = true
  232.      # 显示描述内容
  233.      @help_window.set_text(item)
  234.      #校正帮助窗口位置
  235.      @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  236.    end
  237. end
  238.   #--------------------------------------------------------------------------
  239.   # ● 获取开头行
  240.   #--------------------------------------------------------------------------
  241.   def top_row
  242.     # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
  243.     return self.oy / 60
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ● 设置开头行
  247.   #     row : 显示开头的行
  248.   #--------------------------------------------------------------------------
  249.   def top_row=(row)
  250.     # row 未满 0 的场合更正为 0
  251.     if row < 0
  252.       row = 0
  253.     end
  254.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  255.     if row > row_max - 1
  256.       row = row_max - 1
  257.     end
  258.     # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
  259.     self.oy = row * 60
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # ● 获取 1 页可以显示的行数
  263.   #--------------------------------------------------------------------------
  264.   def page_row_max
  265.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
  266.     return (self.height) / 61
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 获取 1 页可以显示的项目数
  270.   #--------------------------------------------------------------------------
  271.   def page_item_max
  272.     # 将行数 page_row_max 乘上列数 @column_max
  273.     return page_row_max * @column_max
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 更新光标举行
  277.   #--------------------------------------------------------------------------
  278.   def update_cursor_rect
  279.     # 光标位置不满 0 的情况下
  280.     if @index < 0
  281.       self.cursor_rect.empty
  282.       return
  283.     end
  284.     # 获取当前的行
  285.     row = @index / @column_max
  286.     # 当前行被显示开头行前面的情况下
  287.     if row < self.top_row
  288.       # 从当前行向开头行滚动
  289.       self.top_row = row
  290.     end
  291.     # 当前行被显示末尾行之后的情况下
  292.     if row > self.top_row + (self.page_row_max - 1)
  293.       # 从当前行向末尾滚动
  294.       self.top_row = row - (self.page_row_max - 1)
  295.     end
  296.     # 计算光标的宽
  297.     cursor_width = 61
  298.     # 计算光标坐标
  299.     x = @index % @column_max * (cursor_width-1.5)
  300.     y = @index / @column_max * 60 - self.oy
  301.     # 更新国标矩形
  302.     self.cursor_rect.set(x, y, cursor_width, 61)
  303.   end  
  304. end

  305. # ■装备判断
  306. #==============================================================================
  307. # ■ Game_Actor
  308. #------------------------------------------------------------------------------
  309. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  310. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  311. #==============================================================================

  312. # 判断能否装备。
  313. class Game_Actor < Game_Battler
  314.   def can_equip?(equip)
  315.     if equip.is_a?(RPG::Weapon)
  316.       set = $data_classes[@class_id].weapon_set
  317.     else
  318.       set = $data_classes[@class_id].armor_set
  319.     end
  320.     # 装备为无时返回
  321.     return true if equip.nil?
  322.     # 穿戴装备
  323.     return set.include?(equip.id)
  324.   end
  325. end

  326. # 装备等级限制
  327. module RPG
  328.   class Weapon
  329.     def level
  330.      return 1 if @description.split(/★/)[1] == nil
  331.      return @description.split(/★/)[1]
  332.     end
  333.     def description      
  334.       return @description.split(/★/)[0]
  335.     end
  336.   end
  337. class Armor
  338.     def level
  339.      return 1 if @description.split(/★/)[1] == nil
  340.      return @description.split(/★/)[1]
  341.     end
  342.     def description      
  343.       return @description.split(/★/)[0]
  344.     end
  345.   end
  346. end
复制代码
梦石
0
星屑
2821
在线时间
585 小时
注册时间
2022-7-13
回帖
81
发表于 2022-9-2 08:57:51 | 显示全部楼层
本帖最后由 我为鱼肉 于 2022-9-5 21:39 编辑

描绘项目那里,改变颜色那一部分替换为

  1.   self.contents.font.color = disabled_color
  2.   if (item.is_a?(RPG::Item) and
  3.       $game_party.item_can_use?(item.id)) or
  4.      ((item.is_a?(RPG::Weapon) or item.is_a?(
  5. RPG::Armor)) and @actor.can_equip?(item))
  6.       self.contents.font.color = normal_color
  7.   end
复制代码

  1. # 判断能否装备。
  2. class Game_Actor < Game_Battler
  3.   def can_equip?(equip)
  4.     return true if equip.nil?
  5.     list = equip.is_a?(RPG::Weapon) ?
  6. $data_classes[@class_id].weapon_set : $data_classes[@class_id].armor_set
  7.     # 装备为无时返回
  8.     return false if not list.include?(equip.id) or equip.level > self.level
  9.     # 允许穿戴装备
  10.     return true
  11.   end
  12. end
复制代码


判定能否装备的方法可以改一下,用false和nil区分不能装备和等级不够
  1. # 判断能否装备。
  2. class Game_Actor < Game_Battler
  3.   def can_equip?(equip)
  4.     return true if equip.nil?
  5.     list = equip.is_a?(RPG::Weapon) ?
  6. $data_classes[@class_id].weapon_set : $data_classes[@class_id].armor_set
  7.     #用false和nil做一个区分,用来判定为什么不能装备
  8.     # 不能装备
  9.     if not list.include?(equip.id)
  10.       return false
  11.     end
  12.     # 等级不够
  13.     if equip.level > self.level
  14.       return nil
  15.     end
  16.     # 允许穿戴装备
  17.     return true
  18.   end
  19. end
复制代码
  1. #--------------------------------------------------------------------------
  2.   # ● 刷新画面 (目标窗口被激活的情况下)
  3.   #--------------------------------------------------------------------------
  4.   def update_itemlist
  5.     # 按下 B 键的情况下
  6.     if Input.trigger?(Input::B)
  7.       # 演奏取消 SE
  8.       $game_system.se_play($data_system.cancel_se)
  9.       # 打开物品分类
  10.       @itemcommand_window.active = true
  11.       # 关闭物品栏窗口
  12.       @itemlist_window.active = false
  13.       # 隐藏物品栏索引
  14.       @itemlist_window.index = -1
  15.       # 隐藏帮助窗口
  16.       @help_window.visible = false
  17.       @itemcommand_window.index = @command_index
  18.       # 索引返回到0,在回到-1达到隐藏效果
  19.       0.downto(-1) { |x|  @itemlist_window.index = x }
  20.       return
  21.     end
  22.     # 按下 C 键的情况下
  23.     if Input.trigger?(Input::C)
  24.       # 获取项目窗口中当前选定的数据
  25.       @item = @itemlist_window.item
  26.       # 非使用项目时
  27.       unless @item.is_a?(RPG::Item)
  28.         if @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
  29.           case @actor.can_equip?(@item)
  30.           when false
  31.             tip_str = "你不能装备!"
  32.           when nil
  33.             tip_str = "等级过低无法穿戴!"
  34.           else
  35.             tip_str = false
  36.           end
  37.           if tip_str
  38.             $game_system.se_play($data_system.buzzer_se)
  39.             @tip.tip(tip_str)
  40.             return
  41.           end
  42.         end
  43.         # 激活装备界面
  44.         $game_system.se_play($data_system.decision_se)
  45.         if @item.nil?
  46.           @type = nil
  47.         else
  48.           @type = @item.is_a?(RPG::Weapon) ? 0 : @item.kind + 1
  49.         end
  50.         if @item != nil
  51.           @item1 == @itemlist_window.item
  52.         end
  53.         # 关闭物品栏窗口
  54.         @itemlist_window.active = false
  55.         @right_window.index = @type.nil? ? 0 : @type
  56.         # 打开装备栏窗口
  57.         @right_window.active = true
  58.         return
  59.       end
  60.       # 不可用时
  61.       unless $game_party.item_can_use?(@item.id)
  62.        # 演奏冻结 SE
  63.         $game_system.se_play($data_system.buzzer_se)
  64.         @tip.tip("你不能使用该物品!")
  65.         return
  66.       end
  67.       # 演奏确定 SE
  68.       $game_system.se_play($data_system.decision_se)
  69.       # 效果范围是我方的情况下
  70.       if @item.scope >= 3
  71.         # 激活目标窗口
  72.         @itemlist_window.active = false
  73.          # 调整物品画面使用对像角色选择的窗口位置
  74.         @target_window.visible = true
  75.         @target_window.active = true
  76.          # 设置效果范围 (单体/全体) 的对应光标位置
  77.         if @item.scope == 4 || @item.scope == 6
  78.           @target_window.index = -1
  79.         else
  80.           @target_window.index = 0
  81.         end
  82.       # 效果在我方以外的情况下
  83.       else
  84.         # 公共事件 ID 有效的情况下
  85.         if @item.common_event_id > 0
  86.           # 预约调用公共事件
  87.           $game_temp.common_event_id = @item.common_event_id
  88.           # 演奏物品使用时的 SE
  89.           $game_system.se_play(@item.menu_se)
  90.           # 消耗品的情况下
  91.             if @item.consumable
  92.            # 使用的物品数减 1
  93.               $game_party.lose_item(@item.id, 1)
  94.              # 再描绘物品窗口的项目
  95.               @itemlist_window.draw_item(@itemlist_window.index)
  96.             end
  97.           # 切换到地图画面
  98.           $scene = Scene_Map.new
  99.           return
  100.         end
  101.       end
  102.       return
  103.     end
  104.   end
复制代码

点评

可以,太牛了!  发表于 2022-9-5 21:54
现在再试试看吧  发表于 2022-9-5 21:40
我知道问题了,因为判断能否装备的方法本身就判断了等级。所以如果等级不够只会提示无法装备  发表于 2022-9-5 21:34
p出来是武器,论坛又出问题了,发不了图片...,算了放弃吧,还是很感谢  发表于 2022-9-5 21:31
我已经晕了。。。  发表于 2022-9-5 21:26

评分

参与人数 1星屑 +100 赞 +1 收起 理由
RyanBern + 100 + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-9-5 08:55:10 | 显示全部楼层
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color

下面这个说明能不能帮忙添加1个等级限制显示,等级不够时显示,“等级不够无法穿戴!”


  1.     # 按下 C 键的情况下
  2.     if Input.trigger?(Input::C)
  3.       # 获取项目窗口中当前选定的数据
  4.       @item = @itemlist_window.item
  5.       # 非使用项目时
  6.       unless @item.is_a?(RPG::Item)
  7.         # 不能装备演奏冻结SE。
  8.         unless @actor.can_equip?(@item)
  9.           # 演奏冻结 SE
  10.           $game_system.se_play($data_system.buzzer_se)
  11.           @tip.tip("你不能装备!")
  12.           return
  13.         end
  14.         # 激活装备界面
  15.         $game_system.se_play($data_system.decision_se)
  16.         if @item.nil?
  17.           @type = nil
  18.         else
  19.           @type = @item.is_a?(RPG::Weapon) ? 0 : @item.kind + 1
  20.         end
  21.         if @item != nil
  22.           @item1 == @itemlist_window.item
  23.         end
  24.         # 关闭物品栏窗口
  25.         @itemlist_window.active = false
  26.         @right_window.index = @type.nil? ? 0 : @type
  27.         # 打开装备栏窗口
  28.         @right_window.active = true
  29.         return
  30.       end
复制代码

点评

好了  发表于 2022-9-5 09:44
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-9-5 18:43:28 | 显示全部楼层
本帖最后由 黑米馒头 于 2022-9-5 18:44 编辑
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color


我意思是,现在这样和原来的效果一样。。人物等级比武器等级低的时候,也只显示"不能装备",是不是哪里没修改好。。
还有我在空白处点装备的时候,直接弹脚本错误。

1.jpg


2.png

点评

现在应该可以了。把>=改为<就行了  发表于 2022-9-5 18:51
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-9-5 19:23:43 | 显示全部楼层
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color

还是不行,
        p"111"
        tip_str = "等级过低无法穿戴!" if @actor.level < @item.level
我这P,都P不出这个描述。。

还有应该是前面加了这句,return if @item.nil?导致无法拆卸装备了

点评

现在应该不会报错了。还有就是检查一下此@actor,判断我没找到问题  发表于 2022-9-5 19:41
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-9-5 19:52:49 | 显示全部楼层
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color

非常感谢,不过还是不行,不知道啥情况。。。。我把全部脚本贴出来吧,实在不行就不改了,挺不好意思的

  1. #==============================================================================
  2. # ■ Scene_Item
  3. #------------------------------------------------------------------------------
  4. #  处理物品画面的类。
  5. #==============================================================================

  6. class Scene_Item
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像■■■■■■■■■■■■■■■■■■■■■■
  9.   #     actor_index : 角色索引
  10.   #--------------------------------------------------------------------------
  11.   def initialize(actor_index = 0, equip_index = 0)
  12.     @actor_index = actor_index # 返回菜单用
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 主处理
  16.   #--------------------------------------------------------------------------
  17.   def main

  18.     # 获取角色
  19.     @actor = $game_party.actors[@actor_index]
  20.    
  21.     # 获取角色现在装备的物品
  22.     @right_window = Window_Eq.new(@actor)
  23.     # 隐藏装备栏索引
  24.     @right_window.index = -1
  25.     # 隐藏装备栏窗口
  26.     @right_window.active = false
  27.    
  28.     # 生成装备帮助窗口
  29.     @help1_window = Shop_Help.new
  30.     # 关联装备帮助窗口
  31.     @right_window.help_window = @help1_window
  32.     @right_window.help_window.z = 2000
  33.    
  34.     # 提示窗口
  35.     @tip = Window_Tip_Item.new
  36.    
  37.     # 显示人物动态图窗口
  38.     @dongtaitu_window = Window_dtt.new(@actor)
  39.    
  40.     # 生成物品分类窗口
  41.     @itemcommand_window = Fenlei_Command.new
  42.     @command_index = @itemcommand_window.index
  43.    
  44.     # 生成物品窗口
  45.     @itemlist_window = Actor_Item.new(@actor)
  46.     @itemlist_window.active = false
  47.    
  48.     # 生成物品帮助窗口
  49.     @help_window = Shop_Help.new
  50.    
  51.     # 关联物品帮助窗口
  52.     @itemlist_window.help_window = @help_window
  53.    
  54.     # 生成目标窗口 (设置为不可见・不活动)
  55.     @target_window = Window_Target_zl.new
  56.     @target_window.visible = false
  57.     @target_window.active = false
  58.    
  59.     # 生成头像框
  60.     @sthero_window = Window_Sthero.new
  61.    
  62.     # 显示游戏界面1图片
  63.     @jiemian = Sprite.new
  64.     @jiemian.bitmap = Bitmap.new("Graphics/Pictures/Ui/主界面/游戏界面1")
  65.     @jiemian.z = 200   
  66.     # 显示游戏界面2图片
  67.     @jiemian1 = Sprite.new
  68.     @jiemian1.bitmap = Bitmap.new("Graphics/Pictures/Ui/主界面/游戏界面2")
  69.     @jiemian1.y = 715
  70.     @jiemian1.z = 200
  71.    
  72.     # 生成背景图窗口
  73.     @back = Sprite.new
  74.     @back.bitmap = Bitmap.new("Graphics/Pictures/Ui/物品界面/物品背景")  
  75.     @back.y = (768-555)/2-53/2
  76.     @back.z = 200
  77.    
  78.     # 生成现实时间窗口
  79.     @realtime_window = Window_RealTime.new
  80.     # 生成游戏时间窗口
  81.     @playtime_window = Window_PlayTime.new
  82.    
  83.     # 显示队伍头像
  84.     @dtx = Window_DuiTouxiang.new
  85.    
  86.     # 生成金钱窗口
  87.     @gold_window = Window_Gold.new
  88.     @gold_window.x = 58+2
  89.     @gold_window.y = 571
  90.     @gold_window.opacity = 0
  91.    
  92.     # 生成队标窗口
  93.     @db = Window_db.new
  94.     # 队伍人数大于1
  95.     if $game_party.actors.size <= 1
  96.       # 隐藏队标窗口
  97.       @db.visible = false
  98.     else
  99.       # 显示队标窗口
  100.       @db.visible = true
  101.     end
  102.    
  103.     # 物品窗口索引
  104.     @itemlist_window.set_item(@command_index)
  105.     # 执行过度
  106.     Graphics.transition
  107.     # 主循环
  108.     loop do
  109.       # 刷新游戏画面
  110.       Graphics.update
  111.       # 刷新输入信息
  112.       Input.update
  113.       # 刷新画面
  114.       update
  115.       # 如果画面切换就中断循环
  116.       if $scene != self
  117.         break
  118.       end
  119.     end
  120.     # 装备过渡
  121.     Graphics.freeze
  122.     # 释放物品分类窗口
  123.     @itemcommand_window.dispose
  124.     # 释放物品栏窗口
  125.     @itemlist_window.dispose
  126.     # 释放目标被激活的窗口
  127.     @target_window.dispose
  128.     # 释放提示窗口
  129.     @tip.dispose
  130.     # 释放装备窗口
  131.     @right_window.dispose
  132.     # 释放物品帮助窗口
  133.     @help_window.dispose
  134.     # 释放装备帮助窗口
  135.     @help1_window.dispose
  136.     # 释放人物动态图窗口
  137.     @dongtaitu_window.dispose
  138.     # 释放头像框
  139.     @sthero_window.dispose
  140.     # 释放现实时间窗口
  141.     @realtime_window.dispose
  142.     # 释放游戏时间窗口
  143.     @playtime_window.dispose
  144.     # 释放队伍头像
  145.     @dtx.dispose
  146.     # 释放界面图片
  147.     @jiemian.dispose
  148.     @jiemian.bitmap.dispose
  149.     @jiemian1.dispose
  150.     @jiemian1.bitmap.dispose
  151.     # 释放背景图窗口
  152.     @back.dispose
  153.     # 释放背景图图片
  154.     @back.bitmap.dispose
  155.     # 释放金钱窗口
  156.     @gold_window.dispose
  157.     # 释放队标窗口
  158.     @db.dispose
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 刷新画面
  162.   #--------------------------------------------------------------------------
  163.   def update
  164.     #【仿网游动态地图界面】
  165.     $spriteset.update
  166.     # 刷新队伍头像
  167.     @dtx.update
  168.     # 刷新游戏时间窗口
  169.     @playtime_window.update   
  170.     # 刷新显示时间窗口
  171.     @realtime_window.update
  172.     # 刷新装备窗口   
  173.     @right_window.update
  174.     # 物品提示窗口
  175.     @tip.update
  176.     # 刷新物品分类
  177.     @itemcommand_window.update
  178.     # 刷新物品栏窗口
  179.     @itemlist_window.update
  180.     # 刷新人物动态图窗口
  181.     @dongtaitu_window.update
  182.     # 刷新物品帮助窗口
  183.     @help_window.update
  184.     # 刷新装备帮助窗口
  185.     @help1_window.update
  186.     # 刷新头像框
  187.     @sthero_window.update
  188.     # 刷新界面图片
  189.     @jiemian.update
  190.     @jiemian1.update
  191.     # 刷新背景图窗口
  192.     @back.update
  193.     # 刷新金钱窗口
  194.     @gold_window.update
  195.    
  196.     # 队伍人数大于1
  197.     if $game_party.actors.size <= 1
  198.       # 隐藏队标窗口
  199.       @db.visible = false
  200.       # 刷新队标窗口
  201.       @db.update
  202.     else
  203.       # 显示队标窗口
  204.       @db.visible = true
  205.       # 刷新队标窗口
  206.       @db.update
  207.     end
  208.    
  209.     # 调整装备栏光标距离
  210.     irect = @right_window.cursor_rect
  211.       w = @help1_window
  212.     w.x = @right_window.x + irect.x + irect.width + 13
  213.     w.y = @right_window.y + irect.y + irect.height + 13
  214.     if w.x + w.width > 1024
  215.       w.x = 1024 - w.width
  216.     end
  217.     if w.y + w.height > 400#768
  218.       w.y = 400 - w.height
  219.     end   
  220.    
  221.     # 按下 ALT 的情况
  222.     if Kboard.keyboard(226)
  223.       # 按下 ALT + E 关闭物品画面  
  224.       if Kboard.key(8,1)      
  225.         # 演奏取消 SE
  226.         $game_system.se_play($data_system.cancel_se)
  227.         # 回到带头角色头像框
  228.         $temp_mapface_id = $game_party.actors[0].id
  229.         # 切换到地图画面
  230.         $scene = Scene_Map.new
  231.         return
  232.       end
  233.     end  
  234.   # 队伍人数大于1时
  235.   if $game_party.actors.size > 1   
  236.     # 按下 W 键的情况下
  237.     if Kboard.key(26,1)
  238.       # 演奏光标 SE
  239.       $game_system.se_play($data_system.cursor_se)
  240.       # 移至下一位角色
  241.       @actor_index += 1
  242.       @actor_index %= $game_party.actors.size
  243.       # 角色头像对应角色索引
  244.       $temp_mapface_id = $game_party.actors[@actor_index].id
  245.       # 回到物品栏索引
  246.       $scene = Scene_Item.new(@actor_index)
  247.       return
  248.     end
  249.     # 按下 Q 键的情况下
  250.     if Kboard.key(20,1)
  251.       # 演奏光标 SE
  252.       $game_system.se_play($data_system.cursor_se)
  253.       # 移至上一位角色
  254.       @actor_index += $game_party.actors.size - 1
  255.       @actor_index %= $game_party.actors.size
  256.       # 角色头像对应角色索引
  257.       $temp_mapface_id = $game_party.actors[@actor_index].id
  258.       # 回到物品栏索引
  259.       $scene = Scene_Item.new(@actor_index)
  260.       return
  261.     end      
  262.   end
  263.   
  264.     # 刷新目标被激活的窗口
  265.     @target_window.update
  266.     if @command_index != @itemcommand_window.index
  267.       @command_index = @itemcommand_window.index
  268.       @itemlist_window.set_item(@command_index)
  269.     end
  270.     # 物品分类被激活的情况下: 调用 update_itemcommand
  271.     if @itemcommand_window.active
  272.       update_itemcommand
  273.       return
  274.     end
  275.     # 物品窗口被激活的情况下: 调用 update_itemlist
  276.     if @itemlist_window.active
  277.       update_itemlist
  278.       return
  279.     end
  280.     # 目标窗口被激活的情况下: 调用 update_target
  281.     if @target_window.active
  282.       update_target
  283.       return
  284.     end
  285.     # 角色装备栏被激活的情况下:调用 update_equip
  286.     if @right_window.active
  287.       update_equip
  288.       return
  289.     end
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ● 刷新画面 (物品分类窗口被激活的情况下)
  293.   #--------------------------------------------------------------------------
  294.   def update_itemcommand
  295.     # 按下 B 键的情况下 主窗口 B 键 退出
  296.     if Input.trigger?(Input::B)
  297.       # 演奏取消 SE
  298.       $game_system.se_play($data_system.cancel_se)
  299.       # 回到带头角色头像框
  300.       $temp_mapface_id = $game_party.actors[0].id
  301.       # 切换到地图画面
  302.       $scene = Scene_Map.new
  303.       return
  304.     end   
  305.     # 按下 C 键的情况下
  306.     if Input.trigger?(Input::C)
  307.       # 如果没有选定命令项
  308.       if @itemlist_window.item_number == 0
  309.         # 演奏冻结 SE
  310.         $game_system.se_play($data_system.buzzer_se)
  311.         return
  312.       end
  313.       # 演奏确定 SE
  314.       $game_system.se_play($data_system.decision_se)
  315.       # 激活物品分类窗口--关闭
  316.       @itemcommand_window.active = false
  317.       # 显示帮助窗口
  318.       @help_window.visible = true
  319.       # 激活物品栏窗口--打开
  320.       @itemlist_window.active = true
  321.       # 激活物品栏索引为第一个
  322.       @itemlist_window.index = 0
  323.       return
  324.     end
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● 刷新画面 (目标窗口被激活的情况下)
  328.   #--------------------------------------------------------------------------
  329.   def update_itemlist
  330.     # 按下 B 键的情况下
  331.     if Input.trigger?(Input::B)
  332.       # 演奏取消 SE
  333.       $game_system.se_play($data_system.cancel_se)
  334.       # 打开物品分类
  335.       @itemcommand_window.active = true
  336.       # 关闭物品栏窗口
  337.       @itemlist_window.active = false
  338.       # 隐藏物品栏索引
  339.       @itemlist_window.index = -1
  340.       # 隐藏帮助窗口
  341.       @help_window.visible = false
  342.       @itemcommand_window.index = @command_index
  343.       # 索引返回到0,在回到-1达到隐藏效果
  344.       0.downto(-1) { |x|  @itemlist_window.index = x }
  345.       return
  346.     end
  347.     # 按下 C 键的情况下
  348.     if Input.trigger?(Input::C)
  349.       # 获取项目窗口中当前选定的数据
  350.       @item = @itemlist_window.item
  351.       # 非使用项目时
  352.       unless @item.is_a?(RPG::Item)
  353.         # 不能装备演奏冻结SE。
  354.         unless @actor.can_equip?(@item)
  355.           # 演奏冻结 SE
  356.           $game_system.se_play($data_system.buzzer_se)
  357.          
  358.           @tip.tip("你不能装备!")
  359.          
  360.           return
  361.         end
  362.         # 激活装备界面
  363.         $game_system.se_play($data_system.decision_se)
  364.         if @item.nil?
  365.           @type = nil
  366.         else
  367.           @type = @item.is_a?(RPG::Weapon) ? 0 : @item.kind + 1
  368.         end
  369.         
  370.         if @item != nil
  371.           @item1 == @itemlist_window.item
  372.         end
  373.         
  374.         # 关闭物品栏窗口
  375.         @itemlist_window.active = false
  376.         @right_window.index = @type.nil? ? 0 : @type
  377.         # 打开装备栏窗口
  378.         @right_window.active = true
  379.         
  380.         return
  381.       end
  382.       # 不可用时
  383.       unless $game_party.item_can_use?(@item.id)
  384.        # 演奏冻结 SE
  385.         $game_system.se_play($data_system.buzzer_se)
  386.         
  387.         @tip.tip("你不能使用该物品!")
  388.         
  389.         return
  390.       end
  391.       # 演奏确定 SE
  392.       $game_system.se_play($data_system.decision_se)
  393.       # 效果范围是我方的情况下
  394.       if @item.scope >= 3
  395.         # 激活目标窗口
  396.         @itemlist_window.active = false
  397.          # 调整物品画面使用对像角色选择的窗口位置
  398.         @target_window.visible = true
  399.         @target_window.active = true
  400.          # 设置效果范围 (单体/全体) 的对应光标位置
  401.         if @item.scope == 4 || @item.scope == 6
  402.           @target_window.index = -1
  403.         else
  404.           @target_window.index = 0
  405.         end
  406.       # 效果在我方以外的情况下
  407.       else
  408.         # 公共事件 ID 有效的情况下
  409.         if @item.common_event_id > 0
  410.           # 预约调用公共事件
  411.           $game_temp.common_event_id = @item.common_event_id
  412.           # 演奏物品使用时的 SE
  413.           $game_system.se_play(@item.menu_se)
  414.           # 消耗品的情况下
  415.             if @item.consumable
  416.            # 使用的物品数减 1
  417.               $game_party.lose_item(@item.id, 1)
  418.              # 再描绘物品窗口的项目
  419.               @itemlist_window.draw_item(@itemlist_window.index)
  420.             end
  421.           # 切换到地图画面
  422.           $scene = Scene_Map.new
  423.           return
  424.         end
  425.       end
  426.       return
  427.     end
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 刷新画面 (目标窗口被激活的情况下)
  431.   #--------------------------------------------------------------------------
  432.   def update_target
  433.     # 按下 B 键的情况下
  434.     if Input.trigger?(Input::B)
  435.        # 演奏取消 SE
  436.       $game_system.se_play($data_system.cancel_se)
  437.      # 由于物品用完而不能使用的场合
  438.       unless $game_party.item_can_use?(@item.id)
  439.         # 再次生成物品窗口的内容
  440.         @itemlist_window.refresh
  441.       end
  442.       # 删除目标窗口
  443.       @itemlist_window.active = true
  444.       @target_window.visible = false
  445.       @target_window.active = false
  446.       @itemlist_window.set_item(@command_index)
  447.       return
  448.     end
  449.     # 按下 C 键的情况下
  450.     if Input.trigger?(Input::C)
  451.       # 如果物品用完的情况下
  452.       if $game_party.item_number(@item.id) == 0
  453.         # 演奏冻结 SE
  454.         $game_system.se_play($data_system.buzzer_se)
  455.         # 物品提示
  456.         @tip.tip("物品已用完!")
  457.         return
  458.       end
  459.       # 目标是全体的情况下
  460.       if @target_window.index == -1
  461.          # 对同伴全体应用物品使用效果
  462.         used = false
  463.         for i in $game_party.actors
  464.           used |= i.item_effect(@item)
  465.         end
  466.       end
  467.       # 目标是单体的情况下
  468.       if @target_window.index >= 0
  469.         # 对目标角色应用物品的使用效果
  470.         target = $game_party.actors[@target_window.index]
  471.         used = target.item_effect(@item)
  472.       end
  473.       # 使用物品的情况下
  474.       if used
  475.         # 演奏物品使用时的 SE
  476.         $game_system.se_play(@item.menu_se)
  477.         # 消耗品的情况下
  478.         if @item.consumable
  479.           # 使用的物品数减 1
  480.           $game_party.lose_item(@item.id, 1)
  481.           # 再描绘物品窗口的项目
  482.           @itemlist_window.draw_item(@itemlist_window.index)
  483.           @itemlist_window.set_item(@command_index)
  484.                
  485.           #如果使用后物品归零,则关闭Help_Window
  486.           if $game_party.item_number(@item.id) == 0

  487.             # 隐藏帮助窗口
  488.             @help_window.visible = false
  489.             # 删除目标窗口
  490.             @target_window.visible = false
  491.             @target_window.active  = false
  492.             # 物品提示
  493.             @tip.tip("物品已用完!")
  494.             
  495.             #这是为了让光标不要停留在空白处
  496.             if @itemlist_window.index > 0
  497.               @itemlist_window.index -= 1
  498.             end

  499.             # 激活物品窗口状态
  500.             @itemlist_window.active = true
  501.           end
  502.          
  503.         end
  504.          # 再生成目标窗口的内容
  505.         @target_window.refresh
  506.         # 全灭的情况下
  507.         if $game_party.all_dead?
  508.         # 切换到游戏结束画面
  509.           $scene = Scene_Gameover.new
  510.           return
  511.         end
  512.         # 公共事件 ID 有效的情况下
  513.         if @item.common_event_id > 0
  514.          # 预约调用公共事件
  515.           $game_temp.common_event_id = @item.common_event_id
  516.            # 切换到地图画面
  517.           $scene = Scene_Map.new
  518.           return
  519.         end
  520.       end
  521.       # 无法使用物品的情况下
  522.       unless used
  523.        # 演奏冻结 SE
  524.         $game_system.se_play($data_system.buzzer_se)
  525.         # 物品提示
  526.         @tip.tip("你不能使用该物品!")
  527.       end
  528.     return
  529.     end
  530.   end
  531.   # 刷新(角色装备)。
  532.   def update_equip
  533.     # 按下 B 键的情况下
  534.     if Input.trigger?(Input::B)
  535.       # 演奏取消 SE
  536.       $game_system.se_play($data_system.cancel_se)
  537.       # #隐藏物品分类
  538.       @itemlist_window.active = true
  539.       # 隐藏装备栏窗口
  540.       @right_window.active = false
  541.       # 隐藏装备帮助窗口
  542.       @help1_window.visible = false
  543.       # 隐藏装备索引
  544.       @right_window.index = -1
  545.       return
  546.     end
  547.     # 按下 C 键的情况下
  548.     if Input.trigger?(Input::C)
  549.       if @type != nil and @right_window.index != @type
  550.         # 演奏冻结 SE
  551.         $game_system.se_play($data_system.buzzer_se)
  552.         # 物品提示
  553.         @tip.tip("不能装备在这儿!")
  554.         return
  555.       end
  556.       # 演奏装备 SE
  557.       $game_system.se_play($data_system.equip_se)
  558.       # 变更装备
  559.       @actor.equip(@right_window.index, @item == nil ? 0 : @item.id)
  560.    
  561. =begin   
  562.       # 如果穿着后,装备归零,则关闭Help_Window
  563.       if $game_party.item_number(@item1.id) == 0
  564.         @help_window.visible = false
  565.         # 物品窗口索引判定(这是为了让光标不要停留在空白处)
  566.         if @itemlist_window.index > 0
  567.         #  @itemlist_window.index -= 1
  568.         end
  569.         @item1 = nil
  570.       end
  571. =end

  572.       # 索引=物品分类
  573.       @itemlist_window.set_item(@command_index)
  574.       # 刷新装备窗口
  575.       @right_window.refresh
  576.       # 关闭物品窗口激活状态
  577.       @itemlist_window.active = true
  578.       # 隐藏装备栏窗口
  579.       @right_window.active = false
  580.       # 隐藏装备帮助窗口
  581.       @help1_window.visible = false
  582.       # 隐藏装备索引
  583.       @right_window.index = -1
  584.     end
  585.   end
  586. end
复制代码
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部