查看: 1865|回复: 0

[已经过期] 角色跟随和呼出对话框的问题

[复制链接]
梦石
0
星屑
995
在线时间
180 小时
注册时间
2013-2-16
回帖
146
发表于 2013-2-23 21:44:40 | 显示全部楼层 |阅读模式

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

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

×
大家都知道,呼出对话框可以直观的显示是哪个人说的话。
但是,如果加了角色跟随,如果把呼出的名字设为队员的名字,
但是还是队长说话......头像是队员的.......
如果用事件代替队员的话很麻烦.......如何解决??

我曾经找到过可以解决这个问题的角色跟随系统,不过这是从别人的游戏里挖出来的。放到工程里会报错.......
希望能够解决冲突
脚本如下:
[pre lang="ruby" line="1"]# rgss-lib
=begin

a
=end
         
# dq
         
# train_actor
         
# Config.rb
#==============================================================================
# ■ Train_Actor::Config
#------------------------------------------------------------------------------
# マップ上でアクターを隊列移動させる
#==============================================================================

module Train_Actor

  # ●透明状態用スイッチ設定
  # true だとスイッチ制御を行う
  #TRANSPARENT_SWITCH = true
  TRANSPARENT_SWITCH = false

  # ●透明状態用スイッチ番号
  # TRANSPARENT_SWITCH が true で、この番号のスイッチがONだと透明になる
  TRANSPARENT_SWITCHES_INDEX = 20

  # ●アクターの最大数
  # 将来的に多人数パーティが出来るようになったら…
  TRAIN_ACTOR_SIZE_MAX = 6

  # 死亡時のキャラクターグラフィック名
  #DEAD_CHARACTER_NAME = "Coffin"
  DEAD_CHARACTER_NAME = ""

  # 定数
  DOWN_LEFT  = 1
  DOWN_RIGHT = 3
  UP_LEFT    = 7
  UP_RIGHT   = 9
  JUMP       = 5
  STOP       = 0

end
       
# rgss
         
# Game_Event_Module.rb
# Game_Event_Module
# マップ上でアクターを隊列移動させる
# Author:: fukuyama
# Date:: 2006/03/05
# Copyright:: Copyright (C) 2005 fukuyama

module Train_Actor

  module Game_Event_Module
    # 通行可能判定
    # x:: X 座標
    # y:: Y 座標
    # d:: 方向 (0,2,4,6,8)  ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用)
    # return:: 通行不可 false 可能 true
    def passable?(x, y, d)
      result = super(x, y, d)
      return result if @through
      if result
        # 新しい座標を求める
        new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
        new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
        # トレインアクターのループ
        for actor in $game_party.characters
          # 表示されている場合
          if (not actor.character_name.empty?) and (not actor.transparent)
            # アクターの座標が移動先と一致した場合
            if actor.x == new_x and actor.y == new_y
              # 自分がイベントの場合
              if self != $game_player
                # 通行不可
                return false
              end
            end
          end
        end
      end
      return result
    end
  end

end

class Game_Event
  include Train_Actor::Game_Event_Module
end

# Game_Party_Module.rb
# Train_Actor::Game_Party_Module
# Game_Party用隊列歩行モジュール
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib

module Train_Actor

  module Game_Party_Module
    attr_reader :characters
    def dead_actor_include?
      for actor in actors
        if actor.dead?
          return true
        end
      end
      return false
    end
   
    def get_active_party_order
      if not dead_actor_include?
        return actors
      end
      alive_actors = []
      dead_actors = []
      for actor in actors
        if actor.dead?
          dead_actors.push actor
        else
          alive_actors.push actor
        end
      end
      return alive_actors + dead_actors
    end
   
    def setup_actor_character_sprites
      if @characters.nil?
        @characters = []
        for i in 1 ... TRAIN_ACTOR_SIZE_MAX
          @characters.push(Game_Party_Actor.new(i - 1))
        end
      end
      
      if @characters.size < TRAIN_ACTOR_SIZE_MAX
        for i in @characters.size + 1 ... TRAIN_ACTOR_SIZE_MAX
          @characters.push(Game_Party_Actor.new(i - 1))
        end
      end
      
      setup_actors = get_active_party_order
      for i in 1 .. @characters.size
        @characters[i - 1].setup(setup_actors)
      end
      if $scene.class.method_defined?('setup_actor_character_sprites')
        $scene.setup_actor_character_sprites
      end
    end
   
    def transparent_switch
      if TRANSPARENT_SWITCH
        unless $game_player.transparent
          return $game_switches[TRANSPARENT_SWITCHES_INDEX]
        end
      end
      return $game_player.transparent
    end
   
    def update_party_actors
      setup_actor_character_sprites
      transparent = transparent_switch
      for character in @characters
        character.transparent = transparent
        character.update
      end
    end
   
    #cob
    def moveto_party_actors(x, y)
      setup_actor_character_sprites
      @move_list = []
      move_list_setup      
      follow = true
      for character in @characters
        character.stop_anime_when_transferring
        if follow
          if $game_player.passable?(x, y, 10 - $game_player.direction)
            case $game_player.direction
            when 2
              y -= 1
              add_move_list(Input::DOWN)
            when 4
              x += 1
              add_move_list(Input::LEFT)
            when 6
              x -= 1
              add_move_list(Input::RIGHT)
            when 8
              y += 1
              add_move_list(Input::UP)
            end            
          else
            follow = false
          end
        end
        character.direction = $game_player.direction
        character.moveto(x, y)
      end
      
      if $game_temp.player_close_door
        if $game_party.actors.size > 1
          @characters[$game_party.actors.size - 2].direction = 10 - $game_player.direction
          $game_player.direction_fix = true
        else
          $game_player.direction = 10 - $game_player.direction
        end        
        $game_temp.player_close_door = false
      end        
    end
   
    def move_party_actors
      if @move_list == nil
        @move_list = []
        move_list_setup
      end
      @move_list.each_index do |i|
        if not @characters.nil?
          @characters.add_move_list_element(@move_list)
        end
      end
    end
   
    #cob
    def turn_left_party_actors
      for character in @characters
        character.turn_left
      end      
    end
   
    #cob
    def initialize_location
      for character in @characters
        character.moveto($game_player.x, $game_player.y)
      end      
    end
   
    class Move_List_Element
      def initialize(type,args)
        @type = type
        @args = args
      end
      def type() return @type end
      def args() return @args end
    end
    def move_list_setup
      for i in 0 .. TRAIN_ACTOR_SIZE_MAX
        @move_list = nil
      end
    end
    def add_move_list(type,*args)
      @move_list.unshift(Move_List_Element.new(type,args)).pop
    end
    def move_down_party_actors(turn_enabled = true)
      move_party_actors
      add_move_list(Input::DOWN,turn_enabled)
    end
    def move_left_party_actors(turn_enabled = true)
      move_party_actors
      add_move_list(Input::LEFT,turn_enabled)
    end
    def move_right_party_actors(turn_enabled = true)
      move_party_actors
      add_move_list(Input::RIGHT,turn_enabled)
    end
    def move_up_party_actors(turn_enabled = true)
      move_party_actors
      add_move_list(Input::UP,turn_enabled)
    end
    def move_lower_left_party_actors
      move_party_actors
      add_move_list(DOWN_LEFT)
    end
    def move_lower_right_party_actors
      move_party_actors
      add_move_list(DOWN_RIGHT)
    end
    def move_upper_left_party_actors
      move_party_actors
      add_move_list(UP_LEFT)
    end
    def move_upper_right_party_actors
      move_party_actors
      add_move_list(UP_RIGHT)
    end
    def jump_party_actors(x_plus, y_plus)
      move_party_actors
      add_move_list(JUMP,x_plus, y_plus)
      move_stop_party_actors
    end
    def move_stop_party_actors
      actors.each do |a|
        move_party_actors
        add_move_list(STOP)
      end
    end
  end

end

class Game_Party
  include Train_Actor::Game_Party_Module

  # アクターを加える
  # actor_id:: アクター ID
  def add_actor(actor_id)
    # アクターを取得
    actor = $game_actors[actor_id]
    # パーティ人数が 4 人未満で、このアクターがパーティにいない場合
    if @actors.size < Train_Actor::TRAIN_ACTOR_SIZE_MAX and not @actors.include?(actor)
      # アクターを追加
      @actors.push(actor)
      # プレイヤーをリフレッシュ
      $game_player.refresh
    end
  end
end

# Game_Player_Module.rb
# Train_Actor::Game_Player_Module
# Game_Player用隊列歩行モジュール
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib

module Train_Actor

  module Game_Player_Module
    attr_reader :move_speed
    attr_reader :step_anime


    def update_party_actors
      if $game_party.actors.empty?
        return
      end
      $game_party.update_party_actors
      
      actor = $game_party.actors[0]
      if not actor.dead?
        if not @prev_dead.nil?
          @character_name = actor.character_name
          @character_hue = actor.character_hue
          @prev_dead = nil
        end
        return
      end
      @prev_dead = true
      $game_party.actors.each do |actor|
        if not actor.dead?
          @character_name = actor.character_name
          @character_hue = actor.character_hue
          break
        end
      end
    end
    def update
      update_party_actors
      super
    end
   
    #cob
    def moveto(x, y)
      old_x = @x
      old_y = @y
      super(x, y) #before move party or xy may be unpassable by player      
      if $game_temp.move_party
        $game_party.moveto_party_actors(x, y)
        stop_anime_when_transferring
      else
        for event in $game_party.characters
          event.moveto(event.x + x - old_x, event.y + y - old_y)
        end        
        $game_temp.move_party = true
      end
    end
   
    #cob
    def turn_toward_player
      @direction_fix = true
      for event in $game_party.characters
        event.turn_toward_player        
      end
    end      
   
    def move_down(turn_enabled = true)
      if passable?(@x, @y, Input::DOWN)
        $game_party.move_down_party_actors(turn_enabled)
      end
      super(turn_enabled)
    end
    def move_left(turn_enabled = true)
      if passable?(@x, @y, Input::LEFT)
        $game_party.move_left_party_actors(turn_enabled)
      end
      super(turn_enabled)
    end
    def move_right(turn_enabled = true)
      if passable?(@x, @y, Input::RIGHT)
        $game_party.move_right_party_actors(turn_enabled)
      end
      super(turn_enabled)
    end
    def move_up(turn_enabled = true)
      if passable?(@x, @y, Input::UP)
        $game_party.move_up_party_actors(turn_enabled)
      end
      super(turn_enabled)
    end
    def move_lower_left
      # 下→左、左→下 のどちらかのコースが通行可能な場合
      if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
        $game_party.move_lower_left_party_actors
      end
      super
    end
    def move_lower_right
      # 下→右、右→下 のどちらかのコースが通行可能な場合
      if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
        $game_party.move_lower_right_party_actors
      end
      super
    end
    def move_upper_left
      # 上→左、左→上 のどちらかのコースが通行可能な場合
      if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
        $game_party.move_upper_left_party_actors
      end
      super
    end
    def move_upper_right
      # 上→右、右→上 のどちらかのコースが通行可能な場合
      if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
        $game_party.move_upper_right_party_actors
      end
      super
    end
    def jump(x_plus, y_plus)
      # 新しい座標を計算
      new_x = @x + x_plus
      new_y = @y + y_plus
      # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
      if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
        $game_party.jump_party_actors(x_plus, y_plus)
      end
      super(x_plus, y_plus)
    end
  end

end

class Game_Player
  include Train_Actor::Game_Player_Module
end

# Scene_Map_Module.rb
# Train_Actor::Scene_Map_Module
# Scene_Map用隊列歩行モジュール
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib

module Train_Actor

  module Scene_Map_Module
    def setup_actor_character_sprites
      @spriteset.setup_actor_character_sprites
    end
  end

end

class Scene_Map
  include Train_Actor::Scene_Map_Module
end

# Spriteset_Map_Module.rb
# Train_Actor::Spriteset_Map_Module
# Spriteset_Map用隊列歩行モジュール
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib

module Train_Actor

  module Spriteset_Map_Module
    def setup_actor_character_sprites?
      return @setup_actor_character_sprites_flag != nil
    end
   
    def setup_actor_character_sprites
      return unless $game_party.characters
      if not setup_actor_character_sprites?
        for character in $game_party.characters.reverse
          @character_sprites.unshift(Sprite_Character.new(@viewport1, character))
        end
        @setup_actor_character_sprites_flag = true
      end
    end
  end

end

class Spriteset_Map
  include Train_Actor::Spriteset_Map_Module
end
  
# Game_Party_Actor.rb
# Train_Actor::Game_Party_Actor
# マップ上のパーティ用キャラクター
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib

module Train_Actor

  class Game_Party_Actor < Game_Character
    def initialize(character_index)
      super()
      @character_index = character_index
      @character_wait = 0
      @through = true
      # 不透明度と合成方法を初期化
      @opacity = 255
      @blend_type = 0
      @move_list = []
    end
   
    def setup(actor)
      # キャラクターのファイル名と色相を設定
      if actor.nil?
        @character_name = ""
        @character_hue = 0
      elsif not actor.dead? # 死んでる場合とりあえず、消しとこ…
        @character_name = actor.character_name
        @character_hue = actor.character_hue
      else
        @character_name = DEAD_CHARACTER_NAME
        @character_hue = 0
      end
    end
   
    def update
      @move_speed = $game_player.move_speed
      @step_anime = $game_player.step_anime
      @opacity = $game_player.opacity
      @blend_type = $game_player.blend_type
      @direction_fix = $game_player.direction_fix
      #if @direction_fix
      #  @direction = $game_player.direction
      #end
      update_move_list()
      super
    end
   
    def screen_z(height = 0)
      if $game_player.screen_z(height) == 999
        return 998
      end
      if $game_player.x == @x and $game_player.y == @y
        super(height) - 1
      else
        super(height)
      end
    end
   
    def add_move_list_element(element)
      @move_list.push(element)
      if @move_list.size == 1
        update_move_list()
      end
    end
   
    def move_list_size
      return @move_list.size
    end
   
    def update_move_list()
      return if moving?
      
      if @move_list.empty?
        @direction = $game_player.direction unless @direction_fix
        return
      end
      
      if @move_list[0].type == STOP
        if @character_index != 0
          character = $game_party.characters[@character_index - 1]
          if character.x == @x and character.y == @y and character.direction == @direction
            @character_wait = 128 / (2 ** @move_speed) + 1
            while character.move_list_size < @move_list.size and @move_list[0].type == STOP
              @move_list.shift
            end
          end
        end
      else
        @character_wait = 0
      end
      
      if @character_wait > 0
        @character_wait -= 1
        return
      end
      
      element = @move_list.shift
      while element.type == STOP
        element = @move_list.shift
      end
      
      case element.type
      when Input::DOWN
        move_down(element.args[0])
      when Input::LEFT
        move_left(element.args[0])
      when Input::RIGHT
        move_right(element.args[0])
      when Input::UP
        move_up(element.args[0])
      when DOWN_LEFT
        move_lower_left
      when DOWN_RIGHT
        move_lower_right
      when UP_LEFT
        move_upper_left
      when UP_RIGHT
        move_upper_right
      when JUMP
        jump(element.args[0],element.args[1])
      end
    end
   
    def moveto( x, y )
      @move_list.clear
      super(x, y)
    end
    #--------------------------------------------------------------------------
    # ● 下に移動
    #     turn_enabled : その場での向き変更を許可するフラグ
    #--------------------------------------------------------------------------
    def move_down(turn_enabled = true)
      # 下を向く
      if turn_enabled
        turn_down
      end
      # 通行可能な場合
      if passable?(@x, @y, Input::DOWN)
        # 下を向く
        turn_down
        # 座標を更新
        @y = (@y + 1 + $game_map.height) % ($game_map.height)
        @real_y = (@y - 1) * 128
      end
    end
    #--------------------------------------------------------------------------
    # ● 左に移動
    #     turn_enabled : その場での向き変更を許可するフラグ
    #--------------------------------------------------------------------------
    def move_left(turn_enabled = true)
      # 左を向く
      if turn_enabled
        turn_left
      end
      # 通行可能な場合
      if passable?(@x, @y, Input::LEFT)
        # 左を向く
        turn_left
        # 座標を更新
        @x = (@x - 1 + $game_map.width) % ($game_map.width)
        @real_x = (@x + 1) * 128
      end
    end
    #--------------------------------------------------------------------------
    # ● 右に移動
    #     turn_enabled : その場での向き変更を許可するフラグ
    #--------------------------------------------------------------------------
    def move_right(turn_enabled = true)
      # 右を向く
      if turn_enabled
        turn_right
      end
      # 通行可能な場合
      if passable?(@x, @y, Input::RIGHT)
        # 右を向く
        turn_right
        # 座標を更新
        @x = (@x + 1 + $game_map.width) % ($game_map.width)
        @real_x = (@x - 1) * 128
      end
    end
    #--------------------------------------------------------------------------
    # ● 上に移動
    #     turn_enabled : その場での向き変更を許可するフラグ
    #--------------------------------------------------------------------------
    def move_up(turn_enabled = true)
      # 上を向く
      if turn_enabled
        turn_up
      end
      # 通行可能な場合
      if passable?(@x, @y, Input::UP)
        # 上を向く
        turn_up
        # 座標を更新
        @y = (@y - 1 + $game_map.height) % ($game_map.height)
        @real_y = (@y + 1) * 128
      end
    end
  end

end
   
[/pre]

请任意解决其中一个,谢谢{:2_275:}
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部