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

Project1

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

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3171
在线时间
1863 小时
注册时间
2010-6-19
帖子
1205
跳转到指定楼层
1
发表于 2022-9-1 23:24:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Fenlei_Command
  3. #------------------------------------------------------------------------------
  4. # 物品分类
  5. #==============================================================================
  6.  
  7. class Fenlei_Command < Window_Selectable
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化对像
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(22, 276+28, 365, 50)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     @commands = ["", "", "", "",""]
  15. #  @commands = ["平时物品", "战斗物品", "武器装备", "宠物道具","任务道具"]
  16.  
  17.     @item_max = 5
  18.     @column_max = 5
  19.     self.opacity = 0
  20.     self.z = 300
  21.     refresh
  22.     self.index = 0
  23.     # 更改窗口皮肤
  24.     self.windowskin = RPG::Cache.windowskin('物品皮肤/分类')
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 刷新
  28.   #--------------------------------------------------------------------------
  29.   def refresh
  30.     self.contents.clear
  31.     for i in 0...@item_max
  32.       w = contents.text_size(@commands[i]).width
  33.       x = i * 94
  34.       self.contents.font.color = normal_color
  35.       self.contents.draw_text(x, 0, w, 32, @commands[i])
  36.     end
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 項目の描画
  40.   # index : 項目番号
  41.   # color : 文字色
  42.   #--------------------------------------------------------------------------
  43.   def draw_item(index, color)
  44.     self.contents.font.color = color
  45.   # y = index * 32
  46.     self.contents.draw_text(0, y, 128, 32, @commands[index])
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ● 刷新帮助文本
  50.   #--------------------------------------------------------------------------
  51.   def update_help
  52.     @help_window.set_text(@commands[self.index])
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 更新光标举行
  56.   #--------------------------------------------------------------------------
  57.   def update_cursor_rect
  58.     # 光标位置不满 0 的情况下
  59.     if @index < 0
  60.       self.cursor_rect.empty
  61.       return
  62.     end
  63.     # 获取当前的行
  64.     row = @index / @column_max
  65.     # 当前行被显示开头行前面的情况下
  66.     if row < self.top_row
  67.       # 从当前行向开头行滚动
  68.       self.top_row = row
  69.     end
  70.     # 当前行被显示末尾行之后的情况下
  71.     if row > self.top_row + (self.page_row_max - 1)
  72.       # 从当前行向末尾滚动
  73.       self.top_row = row - (self.page_row_max - 1)
  74.     end
  75.     # 计算光标的宽
  76.     cursor_width = self.width / @column_max - 34
  77.     # 计算光标坐标
  78.     x = @index % @column_max * (cursor_width+29)
  79.     # 更新国标矩形
  80.     self.cursor_rect.set(x-3, 0, cursor_width+26, 22)
  81.   end  
  82. end
  83.  
  84. #==============================================================================
  85. # ■ Actor_Item
  86. #------------------------------------------------------------------------------
  87. #  物品画面、战斗画面、显示浏览物品的窗口。
  88. #==============================================================================
  89.  
  90. class Actor_Item < Window_Selectable
  91.   #--------------------------------------------------------------------------
  92.   # ● 初始化对像
  93.   #--------------------------------------------------------------------------
  94.   def initialize(actor)
  95.     super(8, 326, 420, 270)
  96.     @column_max = 6
  97.     self.opacity = 0
  98.     self.z = 300
  99.     @actor = actor
  100.     refresh
  101.     self.index = -1
  102.     # 更改窗口皮肤
  103.     self.windowskin = RPG::Cache.windowskin('物品皮肤/物品')
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 获取物品
  107.   #--------------------------------------------------------------------------
  108.   def item
  109.     return @data[self.index]
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 刷新
  113.   #--------------------------------------------------------------------------
  114.   def refresh
  115.     if self.contents != nil
  116.       self.contents.dispose
  117.       self.contents = nil
  118.     end
  119.     @data = []
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 项目列表设置
  123.   # command : 选中的命令
  124.   #--------------------------------------------------------------------------
  125.   def set_item(command)
  126.     refresh
  127.     case command
  128.     # 平时物品
  129.     when 0
  130.       for i in 1...$data_items.size
  131.         # 选项在0-2时不显示11号属性的物品
  132.         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
  133.           @data.push($data_items[i])
  134.         end
  135.       end
  136.     # 战斗物品  
  137.     when 1
  138.       for i in 1...$data_items.size
  139.         if ($data_items[i].occasion == 1 and $game_party.item_number(i) > 0)
  140.           @data.push($data_items[i])
  141.         end
  142.       end
  143.     # 武器装备  
  144.     when 2
  145.       for i in 1...$data_weapons.size
  146.         if $game_party.weapon_number(i) > 0
  147.           @data.push($data_weapons[i])
  148.         end
  149.       end
  150.       for i in 1...$data_armors.size
  151.         if $game_party.armor_number(i) > 0
  152.           @data.push($data_armors[i])
  153.         end
  154.       end
  155.       @data.push(nil)
  156.     # 宠物道具  
  157.     when 3
  158.       for i in 1...$data_items.size
  159.         # 显示11号和12号属性的物品
  160.         if $data_items[i].element_set.include?(11) or $data_items[i].element_set.include?(12) and $game_party.item_number(i) > 0
  161.           @data.push($data_items[i])
  162.         end
  163.       end
  164.     # 任务道具  
  165.     when 4
  166.       for i in 1...$data_items.size
  167.         if $data_items[i].occasion == 3 and $game_party.item_number(i) > 0
  168.           # 不显示11号和12号属性的物品
  169.           unless $data_items[i].element_set.include?(11) or $data_items[i].element_set.include?(12)
  170.             @data.push($data_items[i])
  171.           end
  172.         end
  173.       end
  174.     end
  175.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  176.     @item_max = @data.size
  177.     if @item_max > 0
  178.       self.contents = Bitmap.new(width - 59.5, row_max * 61)
  179.       self.contents.clear
  180.       for i in 0...@item_max
  181.         draw_item(i)
  182.       end
  183.     end
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● 按类型检索项目数
  187.   #--------------------------------------------------------------------------
  188.   def item_number
  189.     return @item_max
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● 描绘项目
  193.   #     index : 项目编号
  194.   #--------------------------------------------------------------------------
  195.   def draw_item(index)
  196.     item = @data[index]
  197.     return if item.nil?
  198.     case item
  199.     when RPG::Item
  200.       number = $game_party.item_number(item.id)
  201.     when RPG::Weapon
  202.       number = $game_party.weapon_number(item.id)
  203.     when RPG::Armor
  204.       number = $game_party.armor_number(item.id)
  205.     end
  206.     if item.is_a?(RPG::Item) and
  207.       $game_party.item_can_use?(item.id)
  208.       self.contents.font.color = normal_color
  209.     else
  210.       ### 增加能否装备(颜色)判断。######################
  211.       self.contents.font.color = @actor.can_equip?(item) ? normal_color : disabled_color
  212.       ####################################################
  213.     end
  214.     x = index % 6 * 59.5
  215.     y = (index / 6) * 60
  216.     rect = Rect.new(x, y, self.width - 59.5, 60)
  217.     bitmap = RPG::Cache.icon(item.icon_name)
  218.     opacity = 255
  219.     self.contents.blt(x, y , bitmap, Rect.new(0, 0, 59.5, 60), opacity)
  220.     self.contents.font.size = 18
  221.     # 字体加粗
  222.     self.contents.font.bold = true
  223.     self.contents.draw_text(x-4, y-7, 23, 32, number.to_s, 2)
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 刷新帮助文本
  227.   #--------------------------------------------------------------------------
  228.   def update_help  
  229.    # 当没有物品时
  230.    if item == nil
  231.      # 关闭帮助窗口
  232.      @help_window.visible = false
  233.    else
  234.      # 打开帮助窗口
  235.      @help_window.visible = true
  236.      # 显示描述内容
  237.      @help_window.set_text(item)
  238.      #校正帮助窗口位置
  239.      @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  240.    end
  241. end
  242.   #--------------------------------------------------------------------------
  243.   # ● 获取开头行
  244.   #--------------------------------------------------------------------------
  245.   def top_row
  246.     # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
  247.     return self.oy / 60
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 设置开头行
  251.   #     row : 显示开头的行
  252.   #--------------------------------------------------------------------------
  253.   def top_row=(row)
  254.     # row 未满 0 的场合更正为 0
  255.     if row < 0
  256.       row = 0
  257.     end
  258.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  259.     if row > row_max - 1
  260.       row = row_max - 1
  261.     end
  262.     # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
  263.     self.oy = row * 60
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ● 获取 1 页可以显示的行数
  267.   #--------------------------------------------------------------------------
  268.   def page_row_max
  269.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
  270.     return (self.height) / 61
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ● 获取 1 页可以显示的项目数
  274.   #--------------------------------------------------------------------------
  275.   def page_item_max
  276.     # 将行数 page_row_max 乘上列数 @column_max
  277.     return page_row_max * @column_max
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● 更新光标举行
  281.   #--------------------------------------------------------------------------
  282.   def update_cursor_rect
  283.     # 光标位置不满 0 的情况下
  284.     if @index < 0
  285.       self.cursor_rect.empty
  286.       return
  287.     end
  288.     # 获取当前的行
  289.     row = @index / @column_max
  290.     # 当前行被显示开头行前面的情况下
  291.     if row < self.top_row
  292.       # 从当前行向开头行滚动
  293.       self.top_row = row
  294.     end
  295.     # 当前行被显示末尾行之后的情况下
  296.     if row > self.top_row + (self.page_row_max - 1)
  297.       # 从当前行向末尾滚动
  298.       self.top_row = row - (self.page_row_max - 1)
  299.     end
  300.     # 计算光标的宽
  301.     cursor_width = 61
  302.     # 计算光标坐标
  303.     x = @index % @column_max * (cursor_width-1.5)
  304.     y = @index / @column_max * 60 - self.oy
  305.     # 更新国标矩形
  306.     self.cursor_rect.set(x, y, cursor_width, 61)
  307.   end  
  308. end
  309.  
  310. # ■装备判断
  311. #==============================================================================
  312. # ■ Game_Actor
  313. #------------------------------------------------------------------------------
  314. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  315. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  316. #==============================================================================
  317.  
  318. # 判断能否装备。
  319. class Game_Actor < Game_Battler
  320.   def can_equip?(equip)
  321.     if equip.is_a?(RPG::Weapon)
  322.       set = $data_classes[@class_id].weapon_set
  323.     else
  324.       set = $data_classes[@class_id].armor_set
  325.     end
  326.     # 装备为无时返回
  327.     return true if equip.nil?
  328.     # 穿戴装备
  329.     return set.include?(equip.id)
  330.   end
  331. end
  332.  
  333. # 装备等级限制
  334. module RPG
  335.   class Weapon
  336.     def level
  337.      return 1 if @description.split(/★/)[1] == nil
  338.      return @description.split(/★/)[1]
  339.     end
  340.     def description      
  341.       return @description.split(/★/)[0]
  342.     end
  343.   end
  344. class Armor
  345.     def level
  346.      return 1 if @description.split(/★/)[1] == nil
  347.      return @description.split(/★/)[1]
  348.     end
  349.     def description      
  350.       return @description.split(/★/)[0]
  351.     end
  352.   end
  353. end

Lv3.寻梦者

梦石
0
星屑
2821
在线时间
585 小时
注册时间
2022-7-13
帖子
89
2
发表于 2022-9-2 08:57:51 | 只看该作者
本帖最后由 我为鱼肉 于 2022-9-5 21:39 编辑

描绘项目那里,改变颜色那一部分替换为
RUBY 代码复制
  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


RUBY 代码复制
  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区分不能装备和等级不够
RUBY 代码复制
  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

RUBY 代码复制
  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 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3171
在线时间
1863 小时
注册时间
2010-6-19
帖子
1205
3
 楼主| 发表于 2022-9-5 08:55:10 | 只看该作者
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color

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


RUBY 代码复制
  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
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3171
在线时间
1863 小时
注册时间
2010-6-19
帖子
1205
4
 楼主| 发表于 2022-9-5 18:43:28 | 只看该作者
本帖最后由 黑米馒头 于 2022-9-5 18:44 编辑
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color


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




点评

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

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3171
在线时间
1863 小时
注册时间
2010-6-19
帖子
1205
5
 楼主| 发表于 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
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3171
在线时间
1863 小时
注册时间
2010-6-19
帖子
1205
6
 楼主| 发表于 2022-9-5 19:52:49 | 只看该作者
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color

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

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

使用道具 举报

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

本版积分规则

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

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

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

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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