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

Project1

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

[已经过期] 队伍变换的脚本不知道哪有错

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
336 小时
注册时间
2010-8-26
帖子
428
跳转到指定楼层
1
发表于 2010-8-27 00:09:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这脚本感觉不对啊,队伍变换的时候,如果第2个人走掉了,那第3个人替上来,但换的时候还是显示第2个人的状态,哪位哥哥姐姐帮帮忙,我脚本很菜
#==============================================================================
# ** 队员改变系统
#------------------------------------------------------------------------------
#  编写:Dargor©
#  时间:2008.08.03
#  汉化:DeathKing
#  时间:2009.06.17
#  更新:DeathKing
#  时间:2009.06.17
#  版本:1.1
#------------------------------------------------------------------------------
#  更新历史:
#   - 1.0 (2008.08.03), 发布初始版本
#   - 1.1 (2009.06.17), DeathKing更新版本,修正了与国内RMVX脚本
#                       不兼容问题。(找不到Game_Party的max_members方法)
#------------------------------------------------------------------------------
#  备注:
#  一些无关紧要的就不翻译了!
#==============================================================================

# 词汇定义
Vocab::PartyAccept       = '确认'         # 确认排序
Vocab::PartyArrange      = '调整'         # 调整顺序
Vocab::PartyReset        = '重置'         # 重新设定
Vocab::PartyAcceptTxt    = '确认排列'     # 用于下方的详细说明
Vocab::PartyArrangeTxt   = '调整顺序'     # 同上
Vocab::PartyResetTxt     = '重置队列'     # 同上


#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  所有窗口的超级类。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Remake Window Contents
  #--------------------------------------------------------------------------
  def remake_contents(width, height)
    self.width = width
    self.height = height
    create_contents
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Walking Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y, opacity = 255)
    draw_character(actor.character_name, actor.character_index, x, y, opacity)
  end
  #--------------------------------------------------------------------------
  # * Draw Character Graphic
  #     character_name  : Character graphic filename
  #     character_index : Character graphic index
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_character(character_name, character_index, x, y, opacity = 255)
    return if character_name == nil
    bitmap = Cache.character(character_name)
    sign = character_name[/^[\!\$]./]
    if sign != nil and sign.include?('$')
      cw = bitmap.width / 3
      ch = bitmap.height / 4
    else
      cw = bitmap.width / 12
      ch = bitmap.height / 8
    end
    n = character_index
    src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :actors
  attr_accessor :reserve_actors
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_party_changer_party_initialize initialize
  alias dargor_party_add_actor add_actor
  alias dargor_party_remove_actor remove_actor
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    dargor_party_changer_party_initialize
    @reserve_actors = []
  end
  #--------------------------------------------------------------------------
  # * Get Reserve Members
  #--------------------------------------------------------------------------
  def reserve_members
    result = []
    for i in @reserve_actors
      result.push($game_actors)
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Get All Members
  #--------------------------------------------------------------------------
  def all_members
    all_actors = (@actors + @reserve_actors).sort
    array = []
    for i in all_actors
      array << $game_actors
    end
    return array.uniq
  end
  #--------------------------------------------------------------------------
  # * Add an Actor
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def add_actor(actor_id)
    dargor_party_add_actor(actor_id)
    add_reserve_actor(actor_id)
  end
  #--------------------------------------------------------------------------
  # * Remove Actor
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def remove_actor(actor_id)
    dargor_party_remove_actor(actor_id)
    remove_reserve_actor(actor_id)
  end
  #--------------------------------------------------------------------------
  # * Add an Actor from the Reserve
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def add_reserve_actor(actor_id, force=false)
    if force
      @reserve_actors.push(actor_id)
      $game_player.refresh
      return
    end
    if @actors.size == MAX_MEMBERS and not @reserve_actors.include?(actor_id)
      @reserve_actors.push(actor_id)
      $game_player.refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Remove Actor from the Reserve
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def remove_reserve_actor(actor_id)
    @reserve_actors.delete(actor_id)
    $game_player.refresh
  end
  #--------------------------------------------------------------------------
  # ● 获取最大同伴数
  #--------------------------------------------------------------------------
  def max_members
    return MAX_MEMBERS
  end
end

#==============================================================================
# ** Window_Party
#------------------------------------------------------------------------------
#  This window displays party member status on the party changer screen.
#==============================================================================

class Window_PartyMembers < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :members
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 272, 416)
    @members = []
    @selection_rect = false
    @selection_y = 0
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = @members.size
    if @selection_rect
      color = Color.new(0,0,0,160)
      self.contents.fill_rect(2, @selection_y, contents.width-4, 92, color)
    end
    i = 0
    for actor in @members
      x = 104
      y = i * 96 + WLH / 2 + 10
      draw_actor_face(actor, 2, i * 96 + 2, 92)
      draw_actor_name(actor, x, y - WLH)
      draw_actor_level(actor, x, y)
      draw_actor_hp(actor, x, y + WLH * 1)
      draw_actor_mp(actor, x, y + WLH * 2)
      i += 1
    end
  end
  #--------------------------------------------------------------------------
  # * Add Member
  #--------------------------------------------------------------------------
  def add_member(id)
    return if @members.include?($game_party.all_members[id])
    @members.push($game_party.all_members[id])
    w = self.width
    h = self.height = 416 + (96 * (@members.size-4))
    remake_contents(w, h)
    self.height = 416
    refresh
  end
  #--------------------------------------------------------------------------
  # * Remove Member
  #--------------------------------------------------------------------------
  def remove_member(id)
    @members.delete($game_party.all_members[id])
    w = self.width
    h = self.height = 416 + (96 * (@members.size-4))
    remake_contents(w, h)
    self.height = 416
    refresh
  end
  #--------------------------------------------------------------------------
  # * Clear Members
  #--------------------------------------------------------------------------
  def clear_members
    @members = []
    w = self.width
    h = self.height = 416 + (96 * (@members.size-4))
    remake_contents(w, h)
    self.height = 416
    refresh
  end
  #--------------------------------------------------------------------------
  # * Set Selection Rect
  #--------------------------------------------------------------------------
  def set_selection_rect(index)
    @selection_rect = true
    @selection_y = index * 96 - WLH / 2 + 14
    refresh
  end
  #--------------------------------------------------------------------------
  # * Clear Selection Rect
  #--------------------------------------------------------------------------
  def clear_selection_rect
    @selection_rect = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Update cursor
  #--------------------------------------------------------------------------
  def update_cursor
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # Get top row
    row = @index  / @column_max
    if row < self.top_row
      self.top_row = row
    end
    # Reset Top Row if at bottom of list
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    y = @index / @column_max * 96 - self.oy
    # Draw the cursor
    self.cursor_rect.set(0, y, contents.width, 96)
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------  
  def top_row
    return self.oy / 96
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #     row : row shown on top
  #--------------------------------------------------------------------------  
  def top_row=(row)
    if row < 0
      row = 0
    end
    if row > row_max - 1
      row = row_max - 1
    end
    self.oy = row * 96
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------  
  def page_row_max
    return 4
  end
end

#==============================================================================
# ** Window_ReserveMembers
#------------------------------------------------------------------------------
#  This window displays reserve members on the party changer screen.
#==============================================================================

class Window_ReserveMembers < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :members
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize
    @members = $game_party.all_members.dup
    height =  58 * (@members.size.to_f / 4).ceil
    super(272, 128, 272, height)
    @item_max = @members.size
    @column_max = 4
    @row_max = (@members.size.to_f / 4).ceil
    refresh
    self.height = 128
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    i = 0
    for actor in @members
      opacity = 255
      if actor.nil?
        actor = $game_party.all_members
        opacity = 160
      end
      x = 24 + i % 4 * 60
      y = 40 + i / 4 * 48
      draw_actor_graphic(actor,x,y,opacity)
      i += 1
    end
  end
  #--------------------------------------------------------------------------
  # * Set Member
  #--------------------------------------------------------------------------
  def set_member(index, member_id)
    @members[index] = member_id
    refresh
  end
  #--------------------------------------------------------------------------
  # * Reset Members
  #--------------------------------------------------------------------------
  def reset_members
    @members = $game_party.all_members.dup
    refresh
  end
  #--------------------------------------------------------------------------
  # * Update cursor
  #--------------------------------------------------------------------------
  def update_cursor
    x = @index % 4 * 60
    y = @index / 4 * 48
    y -= self.oy
    if @index < 0               # No cursor
      self.cursor_rect.empty
    elsif @index < @item_max    # Normal
      self.cursor_rect.set(x, y, 48, 48)
    end
    # Get top row
    row = @index  / @column_max
    if row < self.top_row
      self.top_row = row
    end
    # Reset Top Row if at bottom of list
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------  
  def top_row
    return self.oy / 48
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #     row : row shown on top
  #--------------------------------------------------------------------------  
  def top_row=(row)
    if row < 0
      row = 0
    end
    if row > row_max - 1
      row = row_max - 1
    end
    self.oy = row * 48
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------  
  def page_row_max
    return 2
  end
end

#==============================================================================
# ** Window_MemberStatus
#------------------------------------------------------------------------------
#  This window displays a member's status on the party changer screen.
#==============================================================================

class Window_MemberStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize
    super(272, 0, 272, 128)
    @member = nil
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    return if @member.nil?
    actor = @member
    x = 104
    draw_actor_face(actor, 2, 2, 92)
    draw_actor_name(actor, x, 0)
    draw_actor_level(actor, x, WLH)
    draw_actor_hp(actor, x, WLH * 2)
    draw_actor_mp(actor, x, WLH * 3)
  end
  #--------------------------------------------------------------------------
  # * Set Member
  #--------------------------------------------------------------------------
  def set_member(member)
    @member = $game_actors[member]
    refresh
  end
end

#==============================================================================
# ** Scene_PartyChanger
#------------------------------------------------------------------------------
#  This class performs the Party Changer screen processing.
#==============================================================================

class Scene_PartyChanger < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    create_command_window
    create_help_window
    @party_window = Window_PartyMembers.new
    @reserve_window = Window_ReserveMembers.new
    @status_window = Window_MemberStatus.new
    @status_window.set_member(@reserve_window.index)
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @party_window.dispose
    @reserve_window.dispose
    @command_window.dispose
    @status_window.dispose
    @help_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Create Help Window
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_Help.new
    @help_window.x = 272
    @help_window.y = 416 - 56
    @help_window.width = 272
    @help_window.create_contents
    @help_window.set_text('从你的同伴')
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    s1 = Vocab::PartyAccept
    s2 = Vocab::PartyArrange
    s3 = Vocab::PartyReset
    @command_window = Window_Command.new(160, [s1, s2, s3])
    @command_window.index = 0
    @command_window.x = 272
    @command_window.y = 256
    @command_window.width = 272
    @command_window.active = false
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @old_index = @reserve_window.index
    super
    update_menu_background
    update_help
    @command_window.update
    @party_window.update
    @reserve_window.update
    @status_window.update
    @help_window.update
    if can_display_status?
      @status_window.set_member(@reserve_window.index+1)
    end
    if @command_window.active
      update_command_selection
      return
    end
    if @party_window.active
      update_party_selection
      return
    end
    if @reserve_window.active
      update_reserve_selection
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Can Display Status?
  #--------------------------------------------------------------------------
  def can_display_status?
    return @reserve_window.index != @old_index
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Help Window
  #--------------------------------------------------------------------------
  def update_help
    if @party_window.active
      @help_window.set_text('调整队列')
    end
    if @reserve_window.active
      @help_window.set_text('从你的同伴')
    end
    if @command_window.active
      case @command_window.index
      when 0
        @help_window.set_text(Vocab::PartyAcceptTxt)
      when 1
        @help_window.set_text(Vocab::PartyArrangeTxt )
      when 2
        @help_window.set_text(Vocab::PartyResetTxt)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Party Window
  #--------------------------------------------------------------------------
  def update_party_selection
    # 跳转至命令窗口
    if Input.trigger?(Input::B)
      @party_window.active = false
      @party_window.index = -1
      @command_window.active = true
      @party_window.clear_selection_rect
      @member1 = nil
      @member2 = nil
      return
    end
    # 调整队列
    if Input.trigger?(Input::C)
      # 创建第一同伴变量
      if @member1.nil?
        @member1 = @party_window.members[@party_window.index]
        @member1_index = @party_window.index
        @party_window.set_selection_rect(@member1_index)
        return
      end
      # 创建第二同伴变量
      if @member2.nil?
        @member2 = @party_window.members[@party_window.index]
        @member2_index = @party_window.index
        # 如果不是同一人就交换他们的位置
        if @member1 != @member2
          @party_window.members[@member1_index] = @member2
          @party_window.members[@member2_index] = @member1
        end
        @party_window.clear_selection_rect
        @member1 = nil
        @member2 = nil
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Reserve Window
  #--------------------------------------------------------------------------
  def update_reserve_selection
    # 如果同伴少于一人则调回选择角色的窗口。
    if Input.trigger?(Input::B) and @party_window.members.size > 0
      @reserve_window.active = false
      @command_window.active = true
      return
    end
    # 将角色加入同伴
    if Input.trigger?(Input::C)
      @party_window.add_member(@reserve_window.index)
      @reserve_window.set_member(@reserve_window.index, nil)
    end
    # 如果同伴已满就跳转至另一窗口
    if @party_window.members.size == $game_party.max_members
      @command_window.active = true
      @reserve_window.active = false
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Command Window
  #--------------------------------------------------------------------------
  def update_command_selection
    if Input.trigger?(Input::C)
      case @command_window.index
      # 重置队列
      when 0
        $game_party.actors.clear
        for member in @party_window.members + @reserve_window.members
          if @party_window.members.include?(member)
            $game_party.add_actor(member.id)
          end
          $game_party.add_reserve_actor(member.id, true)
        end
        $game_player.refresh
        $scene = Scene_Map.new
      # 调整队列
      when 1
        @party_window.index = 0
        @party_window.active = true
        @command_window.active = false
      # 重置队列
      when 2
        @party_window.clear_members
        @party_window.clear_selection_rect
        @reserve_window.reset_members
        @reserve_window.active
        @reserve_window.active = true
        @command_window.active = false
      end
    end
  end
end

点评

话说这个脚本如何使用啊?  发表于 2010-10-20 14:43
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-5 11:38

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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