查看: 2072|回复: 3

[已经解决] 关于人物跟随脚本的实体问题

[复制链接]
梦石
0
星屑
50
在线时间
62 小时
注册时间
2011-10-2
回帖
18
发表于 2015-5-24 20:49:02 | 显示全部楼层 |阅读模式

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

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

×
在制作游戏的时候用了下面的这个人物跟随脚本
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载自www.phylomortis.com,转载请保留此信息
  3. # ————————————————————————————————————

  4. # ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
  5. # by fukuyama

  6. #
  7. # Train_Actor
  8. #
  9. # fukuyama@alles.or.jp
  10. # http://www4.big.or.jp/~fukuyama/rgss/Train_Actor.txt
  11. #

  12. module Train_Actor




  13. #是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX
  14. #开关打开,跟随的人物就消失了(其实只是变成透明而已)
  15. TRANSPARENT_SWITCH = true
  16. TRANSPARENT_SWITCHES_INDEX = 8
  17. #举例:第一个为true,第二个为20,则打开20号开关,后面的人都没了。





  18. #跟随人数的最大数目,可以更改为2、3什么的。
  19. TRAIN_ACTOR_SIZE_MAX = 5





  20. # 定数
  21. #Input::DOWN = 2
  22. #Input::LEFT = 4
  23. #Input::RIGHT = 6
  24. #Input::UP = 6
  25. DOWN_LEFT = 1
  26. DOWN_RIGHT = 3
  27. UP_LEFT = 7
  28. UP_RIGHT = 9
  29. JUMP = 5

  30. class Game_Party_Actor < Game_Character
  31.   def initialize
  32.     super()
  33.     @through = true
  34.   end
  35.   def setup(actor)
  36. # キャラクターのファイル名と色相を設定
  37.     if actor != nil
  38.       @character_name = actor.character_name
  39.       @character_hue = actor.character_hue
  40.     else
  41.       @character_name = ""
  42.       @character_hue = 0
  43.     end
  44. # 不透明度と合成方法を初期化
  45.     @opacity = 255
  46.     @blend_type = 0
  47.   end
  48.   
  49.   def screen_z(height = 0)
  50.     if $game_player.x == @x and $game_player.y == @y
  51.   
  52.     return $game_player.screen_z(height) - 1
  53.   end
  54.   

  55.   super(height)
  56. end
  57. #--------------------------------------------------------------------------
  58. # ● 下に移動
  59. # turn_enabled : その場での向き変更を許可するフラグ
  60. #--------------------------------------------------------------------------
  61. def move_down(turn_enabled = true)
  62.   if turn_enabled
  63.     turn_down
  64.   end
  65.   
  66.   if passable?(@x, @y, Input::DOWN)
  67.     turn_down
  68.     @y += 1
  69.   end
  70.   

  71. end

  72. #--------------------------------------------------------------------------
  73. # ● 左に移動
  74. # turn_enabled : その場での向き変更を許可するフラグ
  75. #--------------------------------------------------------------------------
  76.   def move_left(turn_enabled = true)
  77. # 左を向く
  78.     if turn_enabled
  79.       turn_left
  80.     end
  81. # 通行可能な場合
  82.    if passable?(@x, @y, Input::LEFT)
  83.   # 左を向く
  84.     turn_left
  85.     @x -= 1
  86.    end
  87. end

  88. #--------------------------------------------------------------------------
  89. # ● 右に移動
  90. # turn_enabled : その場での向き変更を許可するフラグ
  91. #--------------------------------------------------------------------------
  92.   def move_right(turn_enabled = true)
  93. # 右を向く
  94.     if turn_enabled
  95.       turn_right
  96.     end
  97.    
  98. # 通行可能な場合
  99.     if passable?(@x, @y, Input::RIGHT)
  100. # 右を向く
  101.       turn_right
  102. # 座標を更新
  103.       @x += 1
  104.     end
  105.   end
  106.   
  107. #--------------------------------------------------------------------------
  108. # ● 上に移動
  109. # turn_enabled : その場での向き変更を許可するフラグ
  110. #--------------------------------------------------------------------------
  111.   def move_up(turn_enabled = true)
  112. # 上を向く
  113.     if turn_enabled
  114.       turn_up
  115.     end
  116. # 通行可能な場合
  117.     if passable?(@x, @y, Input::UP)
  118. # 上を向く
  119.       turn_up
  120. # 座標を更新
  121.       @y -= 1
  122.     end
  123.    
  124.   end
  125.   
  126. #--------------------------------------------------------------------------
  127. # ● 左下に移動
  128. #--------------------------------------------------------------------------
  129.   def move_lower_left
  130. # 向き固定でない場合
  131.     unless @direction_fix
  132. # 右向きだった場合は左を、上向きだった場合は下を向く
  133.       @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  134.     end
  135.    
  136. # 下→左、左→下 のどちらかのコースが通行可能な場合
  137.   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  138.   (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  139. # 座標を更新
  140.     @x -= 1
  141.     @y += 1
  142.   end
  143.   
  144. end

  145. #--------------------------------------------------------------------------
  146. # ● 右下に移動
  147. #--------------------------------------------------------------------------
  148.   def move_lower_right
  149. # 向き固定でない場合
  150.     unless @direction_fix
  151. # 左向きだった場合は右を、上向きだった場合は下を向く
  152.       @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  153.     end
  154.    
  155. # 下→右、右→下 のどちらかのコースが通行可能な場合
  156.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  157.     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  158. # 座標を更新
  159.       @x += 1
  160.       @y += 1
  161.     end
  162.   end
  163.   
  164. #--------------------------------------------------------------------------
  165. # ● 左上に移動
  166. #--------------------------------------------------------------------------
  167.   def move_upper_left
  168. # 向き固定でない場合
  169.     unless @direction_fix
  170. # 右向きだった場合は左を、下向きだった場合は上を向く
  171.       @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  172.     end
  173.    
  174. # 上→左、左→上 のどちらかのコースが通行可能な場合
  175.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  176.     (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  177. # 座標を更新
  178.       @x -= 1
  179.       @y -= 1
  180.     end
  181.    
  182.   end
  183.   
  184. #--------------------------------------------------------------------------
  185. # ● 右上に移動
  186. #--------------------------------------------------------------------------
  187.   def move_upper_right
  188. # 向き固定でない場合
  189.     unless @direction_fix
  190. # 左向きだった場合は右を、下向きだった場合は上を向く
  191.       @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  192.     end
  193.    
  194. # 上→右、右→上 のどちらかのコースが通行可能な場合
  195.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  196.     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  197. # 座標を更新
  198.        @x += 1
  199.        @y -= 1
  200.      end     
  201.    end   
  202.   attr_writer :move_speed
  203.   attr_writer :step_anime
  204. end
  205. module Spriteset_Map_Module
  206.   def setup_actor_character_sprites?
  207.     return @setup_actor_character_sprites_flag != nil
  208.   end  
  209.   def setup_actor_character_sprites(characters)
  210.     if !setup_actor_character_sprites?
  211.       index_game_player = 0
  212.       @character_sprites.each_index do |i|
  213.         if @character_sprites[i].character.instance_of?(Game_Player)
  214.           index_game_player = i
  215.           break
  216.         end        
  217.       end
  218.       for character in characters.reverse
  219.         @character_sprites.unshift(Sprite_Character.new(@viewport1, character))
  220.       end
  221.      @setup_actor_character_sprites_flag = true
  222.    end
  223. end
  224. end
  225. module Scene_Map_Module
  226.   def setup_actor_character_sprites(characters)
  227.     @spriteset.setup_actor_character_sprites(characters)
  228.   end  
  229. end
  230. module Game_Party_Module
  231.   def set_transparent_actors(transparent)
  232.     @transparent = transparent
  233.   end
  234.   def setup_actor_character_sprites
  235.     if @characters == nil
  236.       @characters = []
  237.       for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  238.         @characters.push(Game_Party_Actor.new)
  239.       end
  240.     end
  241.     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  242.       @characters[i - 1].setup(actors[i])
  243.     end
  244.     if $scene.class.method_defined?('setup_actor_character_sprites')
  245.       $scene.setup_actor_character_sprites(@characters)
  246.     end   
  247.   end
  248.   def update_party_actors
  249.     setup_actor_character_sprites
  250.     transparent = $game_player.transparent
  251.     if transparent == false
  252.       if TRANSPARENT_SWITCH
  253.         transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  254.       end
  255.     end
  256.     for character in @characters
  257.       character.transparent = transparent
  258.       character.move_speed = $game_player.move_speed
  259.       character.step_anime = $game_player.step_anime
  260.       character.update
  261.     end
  262.   end  
  263.   def moveto_party_actors( x, y )
  264.     setup_actor_character_sprites
  265.     for character in @characters
  266.       character.moveto( x, y )
  267.     end
  268.     if @move_list == nil
  269.       @move_list = []
  270.     end
  271.     move_list_setup
  272.   end
  273.   def move_party_actors
  274.     if @move_list == nil
  275.       @move_list = []
  276.       move_list_setup
  277.     end
  278.     @move_list.each_index do |i|
  279.     if @characters[i] != nil
  280.       case @move_list[i].type
  281.       when Input::DOWN
  282.         @characters[i].move_down(@move_list[i].args[0])
  283.       when Input::LEFT
  284.         @characters[i].move_left(@move_list[i].args[0])
  285.       when Input::RIGHT
  286.         @characters[i].move_right(@move_list[i].args[0])
  287.       when Input::UP
  288.         @characters[i].move_up(@move_list[i].args[0])
  289.       when DOWN_LEFT
  290.         @characters[i].move_lower_left
  291.       when DOWN_RIGHT
  292.         @characters[i].move_lower_right
  293.       when UP_LEFT
  294.         @characters[i].move_upper_left
  295.       when UP_RIGHT
  296.         @characters[i].move_upper_right
  297.       when JUMP
  298.         @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  299.       end
  300.     end   
  301.   end
  302. end

  303. class Move_List_Element
  304.   def initialize(type,args)
  305.     @type = type
  306.     @args = args
  307.   end
  308.   def type() return @type end
  309.     def args() return @args end
  310.   end
  311.   def move_list_setup
  312.     for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  313.       @move_list[i] = nil
  314.     end   
  315.   end  
  316.   def add_move_list(type,*args)
  317.     @move_list.unshift(Move_List_Element.new(type,args)).pop
  318.   end
  319.   def move_down_party_actors(turn_enabled = true)
  320.     move_party_actors
  321.     add_move_list(Input::DOWN,turn_enabled)
  322.   end
  323.   
  324.   def move_left_party_actors(turn_enabled = true)
  325.     move_party_actors
  326.     add_move_list(Input::LEFT,turn_enabled)
  327.   end
  328.   def move_right_party_actors(turn_enabled = true)
  329.     move_party_actors
  330.     add_move_list(Input::RIGHT,turn_enabled)
  331.   end
  332.   def move_up_party_actors(turn_enabled = true)
  333.     move_party_actors
  334.     add_move_list(Input::UP,turn_enabled)
  335.   end
  336.   def move_lower_left_party_actors
  337.     move_party_actors
  338.     add_move_list(DOWN_LEFT)
  339.   end
  340.   def move_lower_right_party_actors
  341.     move_party_actors
  342.     add_move_list(DOWN_RIGHT)
  343.   end
  344.   def move_upper_left_party_actors
  345.     move_party_actors
  346.     add_move_list(UP_LEFT)
  347.   end
  348.   def move_upper_right_party_actors
  349.     move_party_actors
  350.     add_move_list(UP_RIGHT)
  351.   end
  352.   def jump_party_actors(x_plus, y_plus)
  353.     move_party_actors
  354.     add_move_list(JUMP,x_plus, y_plus)
  355.   end  
  356. end

  357. module Game_Player_Module
  358.   def update
  359.     $game_party.update_party_actors
  360.     super
  361.   end
  362.   def moveto( x, y )
  363.     $game_party.moveto_party_actors( x, y )
  364.     super( x, y )
  365.   end
  366.   def move_down(turn_enabled = true)
  367.     if passable?(@x, @y, Input::DOWN)
  368.       $game_party.move_down_party_actors(turn_enabled)
  369.     end
  370.     super(turn_enabled)
  371.   end
  372.   def move_left(turn_enabled = true)
  373.     if passable?(@x, @y, Input::LEFT)
  374.       $game_party.move_left_party_actors(turn_enabled)
  375.     end
  376.     super(turn_enabled)
  377.   end
  378.   def move_right(turn_enabled = true)
  379.     if passable?(@x, @y, Input::RIGHT)
  380.       $game_party.move_right_party_actors(turn_enabled)
  381.     end
  382.     super(turn_enabled)
  383.   end
  384.   def move_up(turn_enabled = true)
  385.     if passable?(@x, @y, Input::UP)
  386.       $game_party.move_up_party_actors(turn_enabled)
  387.     end
  388.     super(turn_enabled)
  389.   end
  390.   def move_lower_left
  391.     # 下→左、左→下 のどちらかのコースが通行可能な場合
  392.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  393.       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  394.       $game_party.move_lower_left_party_actors
  395.     end
  396.     super
  397.   end
  398.   def move_lower_right
  399.     # 下→右、右→下 のどちらかのコースが通行可能な場合
  400.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  401.       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  402.       $game_party.move_lower_right_party_actors
  403.     end
  404.     super
  405.   end
  406.   def move_upper_left
  407.     # 上→左、左→上 のどちらかのコースが通行可能な場合
  408.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  409.       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  410.       $game_party.move_upper_left_party_actors
  411.     end
  412.     super
  413.   end
  414.   def move_upper_right
  415.     # 上→右、右→上 のどちらかのコースが通行可能な場合
  416.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  417.       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  418.       $game_party.move_upper_right_party_actors
  419.     end
  420.     super
  421.   end
  422.   def jump(x_plus, y_plus)
  423.     # 新しい座標を計算
  424.     new_x = @x + x_plus
  425.     new_y = @y + y_plus
  426.     # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  427.     if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  428.       $game_party.jump_party_actors(x_plus, y_plus)
  429.     end
  430.     super(x_plus, y_plus)
  431.   end
  432.   
  433.   attr_reader :move_speed
  434.   attr_reader :step_anime
  435. end

  436. end # module Train_Actor
  437. class Game_Party
  438.   include Train_Actor::Game_Party_Module
  439. end
  440. class Game_Player
  441.   include Train_Actor::Game_Player_Module
  442. end
  443. class Spriteset_Map
  444.   include Train_Actor::Spriteset_Map_Module
  445. end
  446. class Scene_Map
  447.   include Train_Actor::Scene_Map_Module
  448. end
  449. class Scene_Menu
  450. include Train_Actor::Scene_Map_Module
  451. end
  452. class Scene_Item
  453. include Train_Actor::Scene_Map_Module
  454. end
  455. class Scene_Skill
  456. include Train_Actor::Scene_Map_Module
  457. end
  458. class Scene_State
  459. include Train_Actor::Scene_Map_Module
  460. end
  461. class Scene_Save
  462. include Train_Actor::Scene_Map_Module
  463. end
  464. class Scene_End
  465. include Train_Actor::Scene_Map_Module
  466. end
复制代码
遇到的一个问题是   后面跟随的几个角色是没有实体的可能跟图片一样
地图上NPC自由移动会出现跟后面角色重叠的情况 看起来很诡异
有没有什么办法来让它们也占用地图上的空间?

点评

建议在进入城市、城镇等环境的时候,把功能关闭。在野外的时候再打开。这样会比较方便。  发表于 2015-5-24 20:56
这个脚本所能做到的效果本来就很诡异。个人不建议使用  发表于 2015-5-24 20:54

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

梦石
0
星屑
50
在线时间
62 小时
注册时间
2011-10-2
回帖
18
 楼主| 发表于 2015-5-24 21:17:19 | 显示全部楼层
问题是野外我也设置的有触发式的敌人NPC……  这才是重合的最主要问题……
有没有效果更好的脚本呢……  

点评

Orz貌似不能点评一楼…… 所以才跟帖的 不好意思  发表于 2015-5-25 23:19
请善用点评,不要总回帖。跟随系统目前没有更好脚本。有人提出用事件来制作,但是工程巨大,每个地图都得有事件,还要判断队友是否在对内。  发表于 2015-5-24 23:23
回复

使用道具 举报

梦石
0
星屑
68
在线时间
436 小时
注册时间
2010-7-19
回帖
384
发表于 2015-5-25 11:56:43 | 显示全部楼层
本帖最后由 zhouzhuofan1 于 2015-5-25 12:03 编辑

= =如果跟随的“队友”为不可通行,
那么你想想,万一主角走到了哪个角落或较窄的地方,被“队友”卡住怎么办?
如果要解决你的问题,那么我这个问题肯定也是要解决的,
那么这样就更复杂了,对于其它事件来说,“队友”要是不可通行的,而对于主角来说要是可通行的,会要麻烦很多


而你做的游戏应该是回合制RPG吧?这样改“队友”是为了增加躲避明雷的难度?

点评

看来没办法解决了orz 就这样好了  发表于 2015-5-26 14:32
=-=没事,你就当做他们抱在一起过地图的  发表于 2015-5-26 12:06
是啊 也考虑过 刚进地图所有单位在一个格子里的情况 所以有点儿蛋疼啊orz 这样主要是想解决NPC跟跟随队友重叠的美观问题……  发表于 2015-5-25 23:19

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2015-5-25 12:55:23 | 显示全部楼层
本帖最后由 汪汪 于 2015-5-27 14:05 编辑

额从理论上说,可以实现这些效果,
但是,涉及判断太多,比如,xxx碰到队友会不会触发事件等等....
如果这样的话,那么地图上的每一个事件都应该有智能的ai了.


暂时只能做到这一步

[pre lang="ruby"]module Tongban
  @visible = true  #显示?
  @renshu = 3 #跟随人数
        def self.setup(x,y)
                $game_party.move = []       
                if @visible == false
                        for i in 1..@renshu
                                $game_map.events.delete(-i)
                        end
                else
      for i in 1..@renshu
                         actors = $game_party.actors
       if actors.is_a?(Game_Actor)
          ev = RPG::Event.new(x, y)
          ev.id = - i
          ev.pages[0].move_speed = $game_player.move_speed
          ev.pages[0].graphic.character_name = actors.character_name           # 角色 文件名
          ev.pages[0].graphic.character_hue = actors.character_hue
          $game_map.events[-i] = Game_Event.new(@map_id, ev)
        else
          $game_map.events.delete(-i)
        end
                        end
                end
                if $scene.is_a?(Scene_Map)
                        $scene.refresh_spriteset
                end
        end
       
        def self.play_move(lx=0,x=0,y =0 )
                $game_party.move.unshift([lx , x, y])
                for i in 1..@renshu
                        if $game_party.move != nil
                                elx = $game_party.move[0]
                                ex = $game_party.move[1]
                                ey= $game_party.move[2]
                                tongban_move(-i,elx,ex,ey)       
                        end
                end
                $game_party.move.delete_at(10)
        end
  
  
        def self.tongban_move(id,elx,ex,ey)
                ev = $game_map.events[id]
                if ev.is_a?(Game_Event)
                        case elx
                        when 2  # 下
                                ev.move_down(ex)       
                        when 4  # 左       
                                ev.move_left(ex)                       
                        when 6  # 右
                                ev.move_right(ex)
                        when 8  # 上
                                ev.move_up(ex)
                        when 1
                                ev.move_lower_left
                        when 3                       
                                ev.move_lower_right
                        when 7       
                                ev.move_upper_left
                        when 9
                                ev.move_upper_right
                        when 11
                                ev.jump(ex,ey)
                        when 12
                                ev.moveto(ex,ey)
                        end
                end
        end
       
        def self.passable?(x,y)               
    if @visible == true
      actors_x = $game_player.x
      actors_y = $game_player.y
      return true if actors_x == x and actors_y == y        
      actors_number = 0
      for i in 1..@renshu

        if $game_map.events[-i].is_a?(Game_Event)
          actors_x = $game_map.events[-i].x
          actors_y = $game_map.events[-i].y
          return true if actors_x == x and actors_y == y                
        end
        actors_number += 1
      end
    end
                return false
        end
  
        def self.visible(i)
                i = true if i != false
                if @visible != i
                        @visible = i
                        setup($game_player.x,$game_player.y)
                end
        end
  def self.transfer_player
    return @transfer_player
  end
        def self.transfer_player=( i=false )
                return @transfer_player = i
        end       
end



class Game_Character
        attr_accessor :move_speed
        # 判断通行
        def passable?(x, y, d)
                # 求得新的坐标
                new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
                new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
                # 坐标在地图以外的情况
                unless $game_map.valid?(new_x, new_y)
                        # 不能通行
                        return false
                end
                return true if (self == $game_player or self.id < 0 and Tongban.passable?(new_x,new_y))
                # 穿透是 ON 的情况下
                if @through
                        # 可以通行
                        return true
                end
                # 移动者的元件无法来到指定方向的情况下
                unless $game_map.passable?(x, y, d, self)
                        # 通行不可
                        return false
                end
                # 从指定方向不能进入到移动处的元件的情况下
                unless $game_map.passable?(new_x, new_y, 10 - d)
                        # 不能通行
                        return false
                end
                # 循环全部事件
                for event in $game_map.events.values
                        # 事件坐标于移动目标坐标一致的情况下
                        if event.x == new_x and event.y == new_y
                                # 穿透为 ON
                                unless event.through
                                        # 自己就是事件的情况下
                                        if self != $game_player
                                                # 不能通行
                                                return false
                                        end
                                        # 自己是主角、对方的图形是角色的情况下
                                        if event.character_name != ""
                                                # 不能通行
                                                return false
                                        end
                                end
                        end
                end
                # 主角的坐标与移动目标坐标一致的情况下
                if $game_player.x == new_x and $game_player.y == new_y
                        # 穿透为 ON
                        unless $game_player.through
                                # 自己的图形是角色的情况下
                                if @character_name != ""
                                        # 不能通行
                                        return false
                                end
                        end
                end
                # 可以通行
                return true
        end
  def moveto(x, y)
    if self.is_a?(Game_Player)
      if Tongban.transfer_player == true
        Tongban.setup(x,y)
        Tongban.transfer_player = false
      else
        Tongban.play_move(12,x,y)
      end
    end
    @x = x % $game_map.width
    @y = y % $game_map.height
    @real_x = @x * 128
    @real_y = @y * 128
    @prelock_direction = 0
  end
        #--------------------------------------------------------------------------
        # ● 向下移动
        #     turn_enabled : 本场地位置更改许可标志
        #--------------------------------------------------------------------------
        def move_down(turn_enabled = true)
                # 面向下
                if turn_enabled
                        turn_down
                end
                # 可以通行的场合
                if passable?(@x, @y, 2)                       
                        Tongban.play_move(2,turn_enabled)  if self == $game_player
                        # 面向下
                        turn_down
                        # 更新坐标
                        @y += 1
                        # 增加步数
                        increase_steps
                       
                        # 不能通行的情况下
                else
                        # 接触事件的启动判定
                        check_event_trigger_touch(@x, @y+1)
                end
        end
        #--------------------------------------------------------------------------
        # ● 向左移动
        #     turn_enabled : 本场地位置更改许可标志
        #--------------------------------------------------------------------------
        def move_left(turn_enabled = true)
                # 面向左
                if turn_enabled
                        turn_left
                end
                # 可以通行的情况下
                if passable?(@x, @y, 4)               
                        Tongban.play_move(4,turn_enabled)  if self == $game_player
                        # 面向左
                        turn_left
                        # 更新坐标
                        @x -= 1
                        # 增加步数
                        increase_steps
                       
                        # 不能通行的情况下
                else
                        # 接触事件的启动判定
                        check_event_trigger_touch(@x-1, @y)
                end
        end
        #--------------------------------------------------------------------------
        # ● 向右移动
        #     turn_enabled : 本场地位置更改许可标志
        #--------------------------------------------------------------------------
        def move_right(turn_enabled = true)
                # 面向右
                if turn_enabled
                        turn_right
                end
                # 可以通行的场合
                if passable?(@x, @y, 6)       
                        Tongban.play_move(6,turn_enabled)   if self == $game_player
                        # 面向右
                        turn_right
                        # 更新坐标
                        @x += 1
                        # 增加步数
                        increase_steps
                       
                        # 不能通行的情况下
                else
                        # 接触事件的启动判定
                        check_event_trigger_touch(@x+1, @y)
                end
        end
        #--------------------------------------------------------------------------
        # ● 向上移动
        #     turn_enabled : 本场地位置更改许可标志
        #--------------------------------------------------------------------------
        def move_up(turn_enabled = true)
                # 面向上
                if turn_enabled
                        turn_up
                end
                # 可以通行的情况下
                if passable?(@x, @y, 8)       
                        Tongban.play_move(8,turn_enabled)   if self == $game_player
                        # 面向上
                        turn_up
                        # 更新坐标
                        @y -= 1
                        # 歩数増加
                        increase_steps
                       
                        # 不能通行的情况下
                else
                        # 接触事件的启动判定
                        check_event_trigger_touch(@x, @y-1)
                end
        end
        #--------------------------------------------------------------------------
        # ● 向左下移动
        #--------------------------------------------------------------------------
        def move_lower_left
                # 没有固定面向的场合
                unless @direction_fix
                        # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
                        @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
                end
                # 下→左、左→下 的通道可以通行的情况下
                if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
                        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
                        Tongban.play_move(1)   if self == $game_player
                        # 更新坐标
                        @x -= 1
                        @y += 1
                        # 增加步数
                        increase_steps
                       
                end
        end
        #--------------------------------------------------------------------------
        # ● 向右下移动
        #--------------------------------------------------------------------------
        def move_lower_right
                # 没有固定面向的场合
                unless @direction_fix
                        # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
                        @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
                end
                # 下→右、右→下 的通道可以通行的情况下
                if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
                        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
                        Tongban.play_move(3)   if self == $game_player
                        # 更新坐标
                        @x += 1
                        @y += 1
                        # 增加步数
                        increase_steps
                       
                end
        end
        #--------------------------------------------------------------------------
        # ● 向左上移动
        #--------------------------------------------------------------------------
        def move_upper_left
                unless @direction_fix
                        @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
                end
                # 上→左、左→上 的通道可以通行的情况下
                if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
                        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
                        Tongban.play_move(7)   if self == $game_player
                        # 更新坐标
                        @x -= 1
                        @y -= 1
                        # 增加步数
                        increase_steps
                end
        end
        #--------------------------------------------------------------------------
        # ● 向右上移动
        #--------------------------------------------------------------------------
        def move_upper_right
                unless @direction_fix
                        @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
                end
                if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
                        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
                        Tongban.play_move(9)   if self == $game_player
                        @x += 1
                        @y -= 1
                        increase_steps
                end
        end
end

class Game_Map
        attr_accessor  :events
        def setup(map_id)
                # 地图 ID 记录到 @map_id
                @map_id = map_id
                # 地图文件装载后、设置到 @map
                @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
                # 定义实例变量设置地图元件信息
                tileset = $data_tilesets[@map.tileset_id]
                @tileset_name = tileset.tileset_name
                @autotile_names = tileset.autotile_names
                @panorama_name = tileset.panorama_name
                @panorama_hue = tileset.panorama_hue
                @fog_name = tileset.fog_name
                @fog_hue = tileset.fog_hue
                @fog_opacity = tileset.fog_opacity
                @fog_blend_type = tileset.fog_blend_type
                @fog_zoom = tileset.fog_zoom
                @fog_sx = tileset.fog_sx
                @fog_sy = tileset.fog_sy
                @battleback_name = tileset.battleback_name
                @passages = tileset.passages
                @priorities = tileset.priorities
                @terrain_tags = tileset.terrain_tags
                # 初始化显示坐标
                @display_x = 0
                @display_y = 0
                # 清除刷新要求标志
                @need_refresh = false
                # 设置地图事件数据
                @events = {}
                for i in @map.events.keys
                        @events = Game_Event.new(@map_id, @map.events)
                end
                # 设置公共事件数据
                @common_events = {}
                for i in 1...$data_common_events.size
                        @common_events = Game_CommonEvent.new(i)
                end
                # 初始化雾的各种信息
                @fog_ox = 0
                @fog_oy = 0
                @fog_tone = Tone.new(0, 0, 0, 0)
                @fog_tone_target = Tone.new(0, 0, 0, 0)
                @fog_tone_duration = 0
                @fog_opacity_duration = 0
                @fog_opacity_target = 0
                # 初始化滚动信息
                @scroll_direction = 2
                @scroll_rest = 0
                @scroll_speed = 4
                Tongban.transfer_player = true
        end
       
end
class Scene_Map
        #--------------------------------------------------------------------------
        # ● 重新描绘地图
        #--------------------------------------------------------------------------
        def refresh_spriteset
                @spriteset.dispose
                @spriteset = Spriteset_Map.new
        end
end

class Game_Party
  attr_accessor  :move
  def refresh
    # 游戏数据载入后角色对像直接从 $game_actors
    # 分离。
    # 回避由于载入造成的角色再设置的问题。
    new_actors = []
    for i in 0...@actors.size
      if $data_actors[@actors.id] != nil
        new_actors.push($game_actors[@actors.id])
      end
    end
    @actors = new_actors
                setup($game_player.x,$game_player.y)
  end
end

[/pre]

点评

增减队员时的处理没做……应该比较简单  发表于 2015-5-27 00:01
额,用事件代替了图片,对于其他事件来说不能通行,对于自己和伙伴事件来说可以通行..有可能出现未知错误.....  发表于 2015-5-26 22:40
给你一个修改方法,让事件跟随移动这个效果大概可以实现,你可以对Game_Player里的通行判定进行修改,让角色遇到队友时可以通行.  发表于 2015-5-26 17:35
怪物碰到跟随人物不会触发 主要是怪物会跟人物重合 很不美观的问题……  发表于 2015-5-25 23:18
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部