查看: 2229|回复: 1

[已经解决] 如何在战斗指令中添加当前角色的名字[用来区分角色]

[复制链接]
梦石
0
星屑
1556
在线时间
626 小时
注册时间
2010-8-5
回帖
317
发表于 2015-8-20 22:26:44 | 显示全部楼层 |阅读模式

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

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

×
战斗中,能否在指令上面描绘当然角色的名字。我把指令的窗口固定了。希望通过这种方法来辨别角色的指令{:2_285:}

梦石
0
星屑
9716
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2015-8-20 23:09:49 | 显示全部楼层

()

默认的是直接用【Window_Command】,为了避免其他冲突,另写了一个独立战斗角色命令窗口(Main前Insert):
点击展开/收起
  1. #==============================================================================
  2. # ■ Window_Command
  3. #------------------------------------------------------------------------------
  4. #  一般的命令选择行窗口。
  5. #==============================================================================

  6. class Window_Battler_Command < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     width    : 窗口的宽
  10.   #     commands : 命令字符串序列
  11.   #--------------------------------------------------------------------------
  12.   def initialize(width, commands)
  13.     # 由命令的个数计算出窗口的高
  14.     super(0, 0, width, (commands.size + 1) * 32 + 32)
  15.     @item_max = commands.size
  16.     @commands = commands
  17.     @actor = nil
  18.     self.contents = Bitmap.new(width - 32, (@item_max + 1) * 32)
  19.     refresh
  20.     self.index = 0
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 刷新
  24.   #--------------------------------------------------------------------------
  25.   def refresh(actor = @actor)
  26.     self.contents.clear
  27.     @actor = actor
  28.     self.contents.draw_text(0, 0, self.contents.width, 32, @actor.name) if @actor
  29.     for i in 0...@item_max
  30.       draw_item(i, normal_color)
  31.     end
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 描绘项目
  35.   #     index : 项目编号
  36.   #     color : 文字色
  37.   #--------------------------------------------------------------------------
  38.   def draw_item(index, color)
  39.     self.contents.font.color = color
  40.     rect = Rect.new(4, 32 * (index + 1), self.contents.width - 8, 32)
  41.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  42.     self.contents.draw_text(rect, @commands[index])
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 项目无效化
  46.   #     index : 项目编号
  47.   #--------------------------------------------------------------------------
  48.   def disable_item(index)
  49.     draw_item(index, disabled_color)
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 更新光标矩形
  53.   #--------------------------------------------------------------------------
  54.   def update_cursor_rect
  55.     # 光标位置不满 0 的情况下
  56.     if @index < 0
  57.       self.cursor_rect.empty
  58.       return
  59.     end
  60.     # 获取当前的行
  61.     row = @index / @column_max
  62.     # 当前行被显示开头行前面的情况下
  63.     if row < self.top_row
  64.       # 从当前行向开头行滚动
  65.       self.top_row = row
  66.     end
  67.     # 当前行被显示末尾行之后的情况下
  68.     if row > self.top_row + (self.page_row_max - 1)
  69.       # 从当前行向末尾滚动
  70.       self.top_row = row - (self.page_row_max - 1)
  71.     end
  72.     # 计算光标的宽度
  73.     cursor_width = self.width / @column_max - 32
  74.     # 计算光标坐标
  75.     x = @index % @column_max * (cursor_width + 32)
  76.     y = (@index + 1) / @column_max * 32 - self.oy
  77.     # 更新光标矩形
  78.     self.cursor_rect.set(x, y, cursor_width, 32)
  79.   end
  80. end
复制代码

用法是在【Scene_Battle 1】里面一开始建立命令窗口的那里,把
  1. @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
复制代码
改成
  1. @actor_command_window = Window_Battler_Command.new(160, [s1, s2, s3, s4])
复制代码
然后在(默认的)【Scene_Battle 3】里面的【def phase3_setup_command_window】这段里面,
在最后面加上一句
  1. @actor_command_window.refresh(@active_battler)
复制代码
PS:如果用了别的战斗系统,试着搜索【def phase3_setup_command_window】,然后在对应位置加上。
PS2:临时写的东西,不能保证是不是会出错……(雾

评分

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

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部