查看: 1429|回复: 1

[已经解决] [已解决]战斗换人脚本中,如何使特定角色无法被替换?

[复制链接]
梦石
0
星屑
635
在线时间
39 小时
注册时间
2024-1-28
回帖
2
发表于 2024-5-3 21:17:28 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 海胆泡面 于 2024-5-5 14:44 编辑

使用的战斗换人脚本应该是enghao_lim很久以前制作的战斗换人脚本,可以兼容XRXS26. 人物扩张系统 ver..05使用。
[fold][pre lang="ruby"]#==============================================================================
# ◎ 战斗换人脚本主要部分。
#==============================================================================
# 制作by:enghao_lim
#==============================================================================
# 使用方法:
#
# 必须配合人物扩张脚本使用。
#
# 把此脚本插入到main之前。
#
# 根据范例中scene battle 1 及 scene battle 2 的修改方法修改自己的工程。
#
# 默认战斗最大人数为4,如果想更改,把update_phase3_character_select里所有的4更改即可。
#==============================================================================

class Scene_Battle

  def update_phase3_character_select
   
    @actor_window.visible = true

    @actor_window.update

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      end_character_select
      
      return
      
    end
   
    if Input.trigger?(Input::C)
      
      for i in 0...$game_party.actors.size
        
        if @active_battler.id == $game_party.actors.id
         
          @active_place = i
         
          @blink_character = $game_party.actors.id
      
        end
        
      end
      
      if @start == 0
        
        if @actor_window.index >= 4
         
          @actor1 = $game_party.backword_actors[@actor_window.index-4]
         
          @actor2 = @actor_window.index-4
         
          @start = 1
         
          @choose_backword = 1
         
        else
         
          @actor1 = $game_party.actors[@actor_window.index]
        
          @actor2 = @actor_window.index
        
          @start = 1
         
          @choose_backword = 0
         
        end
        
      else
        
        if @actor_window.index >= 4
         
          if @choose_backword == 1
            
            $game_party.backword_actors[@actor2] = $game_party.backword_actors[@actor_window.index-4]
            
            
            $game_party.backword_actors[@actor_window.index-4] = @actor1
            
          else
            
            if $game_party.actors[@actor2].id == $game_party.actors[@active_place].id and $game_party.backword_actors[@actor_window.index-4].hp == 0
               
              $game_system.se_play($data_system.cancel_se)
               
            else
            
              $game_party.actors[@actor2] = $game_party.backword_actors[@actor_window.index-4]
            
              $game_party.backword_actors[@actor_window.index-4] = @actor1
              
            end
            
          end
         
          @status_window.refresh
        
          @actor_window.refresh
        
          $game_player.refresh
        
          @start = 0
         
          if @active_battler.id != $game_party.actors[@active_place].id
            
            @active_battler = $game_party.actors[@active_place]
            
            $game_actors[@blink_character].blink = false
            
            @active_battler.blink = true
            
          end
         
        else
         
          if @choose_backword == 1
            
            if $game_party.actors[@actor_window.index].id == $game_party.actors[@active_place].id and @actor1.hp == 0
               
              $game_system.se_play($data_system.cancel_se)
   
            else
            
              $game_party.backword_actors[@actor2] = $game_party.actors[@actor_window.index]
            
              $game_party.actors[@actor_window.index] = @actor1
               
            end

          else
            
            if $game_party.actors[@actor2].id == $game_party.actors[@active_place].id and $game_party.actors[@actor_window.index].hp == 0
              
              $game_system.se_play($data_system.cancel_se)
               
            elsif $game_party.actors[@actor_window.index].id == $game_party.actors[@active_place].id and @actor1.hp == 0
               
              $game_system.se_play($data_system.cancel_se)
           
            else
            
              $game_party.actors[@actor2] = $game_party.actors[@actor_window.index]
            
              $game_party.actors[@actor_window.index] = @actor1
            
            end
            
          end
         
          @status_window.refresh
        
          @actor_window.refresh
        
          $game_player.refresh
        
          @start = 0
         
          if @active_battler.id != $game_party.actors[@active_place].id
            
            @active_battler = $game_party.actors[@active_place]
            
            $game_actors[@blink_character].blink = false
            
            @active_battler.blink = true
            
          end
        
        end
        
      end
      
      return
      
    end
   
  end

  def start_character_select
   
    @start = 0
   
    @actor1 = 0
   
    @actor2 = 0
   
    @actor_window = Window_ChangeActor.new
   
    @actor_window.help_window = @help_window
   
    @actor_command_window.active = false
   
    @actor_command_window.visible = false
   
  end
  #--------------------------------------------------------------------------
  # ●
  #--------------------------------------------------------------------------
  def end_character_select
   
    @actor_window.dispose
   
    @actor_window = nil
   
    @help_window.visible = false
   
    @actor_command_window.active = true
   
    @actor_command_window.visible = true
   
  end
  
end

#------------------------------------------------------------------------------

class Window_ChangeActor < Window_Selectable

  #----------------------------------------------------------------------------
  
  def initialize
   
    super(0, 64, 640, 256)
   
    @item_max = $game_party.actors.size + $game_party.backword_actors.size
   
    @column_max = 2
   
    refresh
   
    self.index = 0
   
    self.back_opacity = 160
  
  end

  #----------------------------------------------------------------------------
  
  def item
   
    return @data[self.index]
   
  end
  
  #----------------------------------------------------------------------------

  def refresh
   
    if self.contents != nil
      
      self.contents.dispose
      
      self.contents = nil
      
    end
   
    @data = []
   
    if $game_party.actors.size != 0
      
      for i in 0...$game_party.actors.size
        
        @data.push($game_actors[$game_party.actors.id])
        
      end
      
    end
   
    if $game_party.backword_actors.size != 0
      
      for i in 0...$game_party.backword_actors.size
        
        @data.push($game_actors[$game_party.backword_actors.id])
        
      end
      
    end
        
    self.contents = Bitmap.new(width - 32, row_max * 48)
   
    for i in 0...@item_max
      
      draw_item(i)
      
    end

  end

  #----------------------------------------------------------------------------
  
  def draw_item(index)
   
    actor = @data[index]
   
    x = 4 + index % 2 * (288 + 32)
   
    y = index / 2 * 48
   
    rect = Rect.new(x, y, self.width / @column_max - 32, 48)
   
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   
    draw_actor_graphic(actor,x+15,y+48)
   
    self.contents.font.size = 18
   
    self.contents.font.color = crisis_color
   
    self.contents.draw_text(x+42, y, 212, 24, actor.name, 0)
   
    self.contents.font.color = normal_color
   
    self.contents.draw_text(x+42,y+24,242,24,"HP" +"  "+actor.hp.to_s + "/"+ actor.maxhp.to_s)
   
  end
  
  #----------------------------------------------------------------------------
  
  def update_cursor_rect
   
    x = 4 + index % 2 * (288 + 32)
   
    y = index / 2 * 48
   
    self.cursor_rect.set(x-1, y-1, 216, 50)
   
  end
  
  #----------------------------------------------------------------------------
  
  def update_help
   
    @help_window.set_text(@data[index].name)
   
  end
  
end
[/pre][/fold]

人物扩张脚本里面有一部分是规定特定编号的角色无法被交换的:
[pre lang="ruby" line="31"]class Scene_Menu
  MENU_MEMBER_CHANGE_KEY_GO    = Input::RIGHT # 进入键
  MENU_MEMBER_CHANGE_KEY_END   = Input::LEFT  # 离开键
  MENU_MEMBER_CHANGE_INDEX_MIN = 0            # 可更换角色最小编号
  FORCETOBATTLE_ACTORS         = []           # 不能待机的角色编号
  UMBATTLABLE_ACTORS           = []           # 不能加入战斗的角色编号
  UNMOVABLE_ACTORS             = []           # 不能移动的角色编号
end[/pre]

但是战斗换人脚本里面没找到对应的内容。

希望达成的效果是首位的队员无论在菜单换人还是战斗换人中都能固定在首位而不会被交换掉、或者在战斗结束之后自动返回首位,请问应该如何达成这一效果?




找到解决方案了。
首先在class Scene_Battle这一行后面加入
UNMOVABLE_ACTORS = [] # 禁止移动的角色的编号
然后在if Input.trigger?(Input::C)和for i in 0...$game_party.actors.size这两行代码之间插入这些代码:
[pre lang="ruby"]      if UNMOVABLE_ACTORS.include?($game_party.actors[@actor_window.index].id)#禁止移动开始
        $game_system.se_play($data_system.buzzer_se)
        return
      end# 禁止移动结束[/pre]
就可以了
梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
发表于 2024-5-5 10:18:54 | 显示全部楼层
unless $game_party.actors[0].id 排除首位角色
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部