查看: 12328|回复: 4

[已经解决] 战斗中查看状态

[复制链接]
梦石
0
星屑
365
在线时间
212 小时
注册时间
2011-5-31
回帖
17
发表于 2021-6-20 21:22:47 | 显示全部楼层 |阅读模式
悬赏50星屑已解决
请问各位大神们,如何达到战斗中查看状态的效果?
由于小弟有使用图标状态,想要案一个件显示目前角色的状态,
有找到一篇 https://rpg.blue/thread-477464-1-1.html
这是小弟想达到的效果,
但这是使用RTAB战斗系统,小弟钻研了一下还是没办法使用,
还请大神们指引一条明路。

最佳答案

查看完整内容

看了下楼主发的工程的效果,大概写了下。 说明:Scene_Battle的phase3阶段皆可以查看状态(敌我) G键开启,G键结束 不包含图标状态,状态介绍文字直接使用的楼主工程中的 [pre lang="ruby"]class Window_State < Window_Selectable def initialize(battler) super(240, 240, 200, 160) @column_max = 1 self.z = 1000 @help_window_active = false @name = Window_Base.new(self.x, self ...
梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
回帖
205
发表于 2021-6-20 21:22:48 | 显示全部楼层
看了下楼主发的工程的效果,大概写了下。

说明:Scene_Battle的phase3阶段皆可以查看状态(敌我)
         G键开启,G键结束
         不包含图标状态,状态介绍文字直接使用的楼主工程中的

[pre lang="ruby"]class Window_State < Window_Selectable
  def initialize(battler)
    super(240, 240, 200, 160)
    @column_max = 1
    self.z = 1000
    @help_window_active = false
    @name = Window_Base.new(self.x, self.y - 64, self.width, 64)
    @name.z = 1000
    @name.contents = Bitmap.new(@name.width - 32, @name.height - 32)
    self.refresh(battler)
    @last_state_id = 0
  end
  
  def refresh(battler)
    @battler = battler
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @name.contents.clear
    return if @battler == nil
    @name.contents.font.color.set(0, 250, 0)
    @name.contents.draw_text(0, 0, @name.width - 32, 32, @battler.name, 1)
    @item_max = @battler.states.size
    w = self.width - 32
    self.contents = Bitmap.new(w, self.row_max * 32 + 32)
    self.oy = 0
    if @item_max == 0
      self.contents.draw_text(0, 0, w, 32, "没有状态", 1)
      @index = -1
      @help_window.set_text("") if @help_window != nil
      @help_window_active = false
      return
    end
    @battler.states.each_with_index do |state_id, i|
      state = $data_states[state_id]
      if state != nil
        turn = @battler.states_turn[state_id]
        turn_text = (turn == -1 ? "∞" : turn.to_s) + "回合"
        self.contents.draw_text(0, 32 * i, w, 32, state.name, 0)
        self.contents.draw_text(0, 32 * i, w, 32, turn_text, 2)
      end
    end
    @index = 0
    @help_window_active = true
  end
  
  def dispose
    super
    @name.dispose
  end
  
  def set_help
    state_id = @battler.states[@index]  
    state = $data_states[state_id]
    info = $状态介绍[state_id] == nil ? "" :
      ("【#{state.name}】:" + $状态介绍[state_id])
    @help_window.set_text(state == nil ? "" : info)
  end
  
  def update_help
    return unless @help_window_active == true
    if @last_state_id != @battler.states[@index]
      self.set_help
      @last_state_id = @battler.states[@index]
    end
  end
  
  def update
    super
    @name.visible = self.visible
  end
end

class Window_StateHelp < Window_Base
  def initialize
    super(0, 0, 640, 64)
    self.z = 1000
  end
  
  def set_text(text)
    temp = Bitmap.new(1, 1)
    rect = temp.text_size(text)
    max = (rect.width * 1.0 / (self.width - 32)).ceil
    max = 1 if max < 1
    temp.dispose
    temp = nil
    text2 = text.clone
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    self.height = max * 32 + 32
    self.contents = Bitmap.new(self.width - 32, max * 32)
    self.contents.font.color = normal_color
    if max == 1
      align = rect.width < (self.width - 32) / 2 ? 1 : 0
      self.contents.draw_text(0, 0, self.width - 32, 32, text2, align)
      return
    end
    sx, sy = 0, 0
    while ((c = text2.slice!(/./m)) != nil)
      if c == "\n"
        sy += 1
        sx = 0
        next
      end
      rect = self.contents.text_size(c)
      if sx + rect.width > self.width - 32
        sx = 0
        sy += 1
      end
      self.contents.draw_text(sx, sy * 32, rect.width, 32, c, 0)
      sx += rect.width        
    end
    self.visible = true
  end
end

class Key
  GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'I', 'I')
  G = 71
  def self.trigger?(nVK)
    value = GetAsyncKeyState.call(nVK)
    return (value & 0x8000 != 0) && (value & 1 == 1)
  end
end

class Game_Battler
  def states_turn
    return @states_turn
  end
end

class Scene_Battle
=begin
  def main
    …………
    # 准备过渡
    Graphics.freeze
    # 释放窗口
    self.end_state    #自行添加
    …………
  end
=end
  def update_state
    @state_window.update
    if Input.trigger?(Input::R)
      @state_index = (@state_index + 1) % @all_battlers.size
      @state_window.refresh(@all_battlers[@state_index])
      return
    end
    if Input.trigger?(Input::L)
      @state_index = (@state_index - 1) % @all_battlers.size
      @state_window.refresh(@all_battlers[@state_index])
      return
    end
  end
  
  def start_state
    @state_window = Window_State.new(@active_battler)
    @state_help_window = Window_StateHelp.new
    @state_window.help_window = @state_help_window
    # 根据需要,自行修改查看的目标范围。比如battler.exist?
    @all_battlers = $game_party.actors + $game_troop.enemies
    @state_index = @all_battlers.index(@active_battler) || 0
  end
  
  def end_state
    if @state_window != nil
      @state_window.dispose
      @state_window = nil
    end
    if @state_help_window != nil
      @state_help_window.dispose
      @state_help_window = nil
    end
    @all_battlers = nil
    @state_index = nil
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (角色命令回合)
  #--------------------------------------------------------------------------
  alias ori_update_phase3 update_phase3
  def update_phase3
    if Key.trigger?(Key::G)
      if @state_window == nil
        self.start_state
        bool = false
      else
        self.end_state
        bool = true        
      end
      if @enemy_arrow != nil
        @enemy_arrow.visible = bool
      elsif @actor_arrow != nil
        @actor_arrow.visible = bool
      elsif @skill_window != nil
        @skill_window.visible = bool
      elsif @item_window != nil
        @item_window.visible = bool
      elsif @actor_command_window.active
        @actor_command_window.visible = bool
      end
    end
    if @state_window != nil
      self.update_state
      return
    end

    ori_update_phase3
  end
end[/pre]

回复

使用道具 举报

梦石
0
星屑
3080
在线时间
492 小时
注册时间
2016-10-1
回帖
30
发表于 2021-6-23 02:09:46 | 显示全部楼层
本帖最后由 mmm999xp 于 2021-6-23 02:11 编辑

请仔细描述你遇到的问题,不然没人知道你在哪个地方出问题,脚本弹窗错误?或是显示特别怪,还是其他问题?
如果不是脚本盲,首先你需要一个按一个键或是战斗指令(例如状态)来打开状态窗口,全局搜索Input的用法,如果是指令,这个指令必须添加到你的战斗命令里(如攻击、特技、防御、道具、状态等)
另外,这个显示是跟战斗系统比较没关联的,但RTAB似乎把战斗选单重定义了,所以必须到RTAB主脚本中找找
回复

使用道具 举报

梦石
0
星屑
365
在线时间
212 小时
注册时间
2011-5-31
回帖
17
 楼主| 发表于 2021-6-27 11:44:56 | 显示全部楼层
mmm999xp 发表于 2021-6-23 02:09
请仔细描述你遇到的问题,不然没人知道你在哪个地方出问题,脚本弹窗错误?或是显示特别怪,还是其他问题?
...

这样说好了,我不要用RTAB,
我只要他的战斗中按下G可以查看状态选单的功能,
是不是只能从RTAB中拆解?
我是个脚本盲,但我在努力了...
回复

使用道具 举报

梦石
0
星屑
365
在线时间
212 小时
注册时间
2011-5-31
回帖
17
 楼主| 发表于 2021-7-3 13:33:20 | 显示全部楼层
RPGzh500223 发表于 2021-6-30 19:32
看了下楼主发的工程的效果,大概写了下。

说明:Scene_Battle的phase3阶段皆可以查看状态(敌我)

感謝大神的支援...
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部