楼主: 452234679

[已经解决] 逃跑加入战斗菜单的脚本有BUG,请教

[复制链接]
梦石
0
星屑
55
在线时间
105 小时
注册时间
2016-4-3
回帖
50
 楼主| 发表于 2016-7-15 12:01:24 | 显示全部楼层
陈大帅帅帅哥 发表于 2016-7-15 11:19
在*Plugin_BattleCommand的末尾(end之前)添加
#------------------------------------------------------ ...

您好,这样确实可以了,但是当无法逃跑时,如何将逃跑按钮变成灰色呢,谢谢
回复

使用道具 举报

梦石
0
星屑
4657
在线时间
1069 小时
注册时间
2013-3-28
回帖
309

开拓者

发表于 2016-7-15 17:16:08 | 显示全部楼层
452234679 发表于 2016-7-15 12:01
您好,这样确实可以了,但是当无法逃跑时,如何将逃跑按钮变成灰色呢,谢谢  ...

把*Plugin_BattleCommand改成
[pre lang="ruby"]#==============================================================================

class Window_BattleCommand < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 180, 60)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    @commands = ["攻","技","防","物","逃"]
    @item_max = 5
    @column_max = 5
    refresh
    self.active = false
    self.visible = false
    self.index = 0
  end
  #---------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      if i == 5#如果你把"逃"和"撤退"合并了就在后面添一个"-1"
        unless $game_temp.battle_can_escape
          disable_item(i)
        end
      else
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index,color=normal_color)
    x = index % 5 * 30
    y = index / 5 * 30
    self.contents.font.color = color#Color.new(255, 255, 255, 128)#normal_color
    self.contents.draw_text(x, y, 30, 30, @commands[index], 1)
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    x = index % 5 * 30
    y = index / 5 * 30
    self.cursor_rect.set(x, y, 30, 30)
  end
  #--------------------------------------------------------------------------
  # 卐 项目无效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index,disabled_color)
  end
end
#===============================================================================[/pre]
回复

使用道具 举报

梦石
0
星屑
55
在线时间
105 小时
注册时间
2016-4-3
回帖
50
 楼主| 发表于 2016-7-15 23:44:00 | 显示全部楼层
陈大帅帅帅哥 发表于 2016-7-15 17:16
把*Plugin_BattleCommand改成
#===================================================================== ...

您好,我将"逃"和"撤退"合并了,但是如果战斗允许逃跑,这个时候“逃”字不会显示
回复

使用道具 举报

梦石
0
星屑
4657
在线时间
1069 小时
注册时间
2013-3-28
回帖
309

开拓者

发表于 2016-7-16 10:42:49 | 显示全部楼层
452234679 发表于 2016-7-15 23:44
您好,我将"逃"和"撤退"合并了,但是如果战斗允许逃跑,这个时候“逃”字不会显示 ...

找到*Plugin_BattleCommand里的def refresh,下面改成这样
  1. def refresh
  2.     self.contents.clear
  3.     for i in 0...@item_max
  4.       unless $game_temp.battle_can_escape
  5.         if i == 5#如果你把"逃"和"撤退"合并了就在后面添一个"-1"
  6.           disable_item(i)
  7.         end
  8.       else
  9.         draw_item(i)
  10.       end
  11.     end
  12.   end
复制代码
回复

使用道具 举报

梦石
0
星屑
55
在线时间
105 小时
注册时间
2016-4-3
回帖
50
 楼主| 发表于 2016-7-16 13:16:45 | 显示全部楼层
陈大帅帅帅哥 发表于 2016-7-16 10:42
找到*Plugin_BattleCommand里的def refresh,下面改成这样

您好,非常感谢您回答,但是这样改的话,当不允许逃跑时,前面4个选项不会显示
回复

使用道具 举报

梦石
0
星屑
4657
在线时间
1069 小时
注册时间
2013-3-28
回帖
309

开拓者

发表于 2016-7-16 17:27:10 | 显示全部楼层
452234679 发表于 2016-7-16 13:16
您好,非常感谢您回答,但是这样改的话,当不允许逃跑时,前面4个选项不会显示 ...

真不好意思,这回应该没问题了[pre lang="ruby"]def refresh
    self.contents.clear
    for i in 0...@item_max
      if !$game_temp.battle_can_escape and i == 5 #如果你把"逃"和"撤退"合并了就在后面添一个"-1"
        disable_item(i)
      else
        draw_item(i)
      end
    end
  end[/pre]

评分

参与人数 1梦石 +1 收起 理由
RyanBern + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
55
在线时间
105 小时
注册时间
2016-4-3
回帖
50
 楼主| 发表于 2016-7-16 22:03:13 | 显示全部楼层
本帖最后由 452234679 于 2016-7-16 22:09 编辑

您好,非常感谢您回答,经过测试,这个问题彻底解决了,感谢您如此热心,请问可以加您为好友吗,以后如果遇到问题再向您请教。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部