查看: 2452|回复: 1

[已经解决] 真八方向+队友跟随,请问要如何才能控制能显示跟随的角色

[复制链接]
梦石
0
星屑
1857
在线时间
2678 小时
注册时间
2010-6-26
回帖
3008

开拓者整合系统大赛RMVX达人剧作品鉴家

发表于 2016-2-2 15:04:49 | 显示全部楼层 |阅读模式

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

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

×
我想请问下如何控制可以跟随的角色?比如我限定 资料库里面 3、4号角色在队伍里的时候可以跟随在后面,但是我没有设定的5、6角色即使在队伍里也不会跟随,请问这个效果要如何做到呢?

脚本如下,希望各位脚本大大能帮忙想想办法OAO

  1. ###########################################################################################################################
  2. # 脚本功能:八方向走与多帧移动之图片修正 + 人物跟随。

  3. $c3_每一步的帧数 = 4
  4. $c3_总共可用的方向数 = 8 #——建议不要修改这个。如果要伪8方向的,就用伪的好了。


  5. # 作者:carol3
  6. ###########################################################################################################################
  7. ###########################################################################################################################

  8. class Game_Player < Game_Character
  9. if $c3_总共可用的方向数 == 8
  10.    def update
  11.      last_moving = moving?
  12.      unless moving? or $game_system.map_interpreter.running? or
  13.             @move_route_forcing or $game_temp.message_window_showing
  14. =begin
  15.      if Input.press?(Input::SHIFT)
  16.        if @move_speed != 5
  17.         @move_speed = 5
  18.        end
  19.       else
  20.        if @move_speed != 4
  21.         @move_speed = 4
  22.        end
  23.      end
  24. =end
  25.        # 用井号后面的东西替代前面的,就可以实现斜4方向走
  26.        case Input.dir8
  27.        when 2
  28.          move_down #move_lower_left
  29.        when 4
  30.          move_left #move_upper_left
  31.        when 6
  32.          move_right #move_lower_right
  33.        when 8
  34.          move_up #move_upper_right
  35.        when 1
  36.          move_lower_left
  37.        when 3
  38.          move_lower_right
  39.        when 7
  40.          move_upper_left
  41.        when 9
  42.          move_upper_right
  43.        end
  44.      end
  45.      # 本地变量记忆坐标
  46.      last_real_x = @real_x
  47.      last_real_y = @real_y
  48.      super
  49.      # 角色向下移动、画面上的位置在中央下方的情况下
  50.      if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  51.        # 画面向下卷动
  52.        $game_map.scroll_down(@real_y - last_real_y)
  53.      end
  54.      # 角色向左移动、画面上的位置在中央左方的情况下
  55.      if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  56.        # 画面向左卷动
  57.        $game_map.scroll_left(last_real_x - @real_x)
  58.      end
  59.      # 角色向右移动、画面上的位置在中央右方的情况下
  60.      if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  61.        # 画面向右卷动
  62.        $game_map.scroll_right(@real_x - last_real_x)
  63.      end
  64.      # 角色向上移动、画面上的位置在中央上方的情况下
  65.      if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  66.        # 画面向上卷动
  67.        $game_map.scroll_up(last_real_y - @real_y)
  68.      end
  69.      # 不在移动中的情况下
  70.      unless moving?
  71.        # 上次主角移动中的情况
  72.        if last_moving
  73.          # 与同位置的事件接触就判定为事件启动
  74.          result = check_event_trigger_here([1,2])
  75.          # 没有可以启动的事件的情况下
  76.          if result == false
  77.            # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  78.            unless $DEBUG and Input.press?(Input::CTRL)
  79.              # 遇敌计数下降
  80.              if @encounter_count > 0
  81.                @encounter_count -= 1
  82.              end
  83.            end
  84.          end
  85.        end
  86.        # 按下 C 键的情况下
  87.        if Input.trigger?(Input::C)
  88.          # 判定为同位置以及正面的事件启动
  89.          check_event_trigger_here([0])
  90.          check_event_trigger_there([0,1,2])
  91.        end
  92.      end
  93.    end
  94.    #--------------------------------------------------------------------------
  95.    # ● 正面事件的启动判定
  96.    #--------------------------------------------------------------------------
  97.    def check_event_trigger_there(triggers)
  98.      result = false
  99.      # 事件执行中的情况下
  100.      if $game_system.map_interpreter.running?
  101.        return result
  102.      end
  103.      # 计算正面坐标
  104.      new_x = @x
  105.      new_y = @y
  106.      case @direction
  107.      when 1
  108.        new_x -= 1
  109.        new_y += 1
  110.      when 2
  111.        new_y += 1
  112.      when 3
  113.        new_x += 1
  114.        new_y += 1
  115.      when 4
  116.        new_x -= 1
  117.      when 6
  118.        new_x += 1
  119.      when 7
  120.        new_x -= 1
  121.        new_y -= 1
  122.      when 8
  123.        new_y -= 1
  124.      when 9
  125.        new_x += 1
  126.        new_y -= 1
  127.      end
  128.      # 全部事件的循环
  129.      for event in $game_map.events.values
  130.        # 事件坐标与目标一致的情况下
  131.        if event.x == new_x and event.y == new_y and
  132.           triggers.include?(event.trigger)
  133.          # 跳跃中以外的情况下、启动判定是正面的事件
  134.          if not event.jumping? and not event.over_trigger?
  135.            event.start
  136.            result = true
  137.          end
  138.        end
  139.      end
  140.      # 找不到符合条件的事件的情况下
  141.      if result == false
  142.        # 正面的元件是计数器的情况下
  143.        if $game_map.counter?(new_x, new_y)
  144.          # 计算 1 元件里侧的坐标
  145.          new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  146.          new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  147.          # 全事件的循环
  148.          for event in $game_map.events.values
  149.            # 事件坐标与目标一致的情况下
  150.            if event.x == new_x and event.y == new_y and
  151.               triggers.include?(event.trigger)
  152.              # 跳跃中以外的情况下、启动判定是正面的事件
  153.              if not event.jumping? and not event.over_trigger?
  154.                event.start
  155.                result = true
  156.              end
  157.            end
  158.          end
  159.        end
  160.      end
  161.      return result
  162.    end
  163. end
  164. end


  165. class Sprite_Character < RPG::Sprite
  166. def update
  167.    super
  168.    # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  169.    if @tile_id != @character.tile_id or
  170.       @character_name != @character.character_name or
  171.       @character_hue != @character.character_hue
  172.      # 记忆元件 ID 与文件名、色相
  173.      @tile_id = @character.tile_id
  174.      @character_name = @character.character_name
  175.      @character_hue = @character.character_hue
  176.      # 元件 ID 为有效值的情况下
  177.      if @tile_id >= 384
  178.        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  179.          @tile_id, @character.character_hue)
  180.        self.src_rect.set(0, 0, 32, 32)
  181.        self.ox = 16
  182.        self.oy = 32
  183.      # 元件 ID 为无效值的情况下
  184.      else
  185.        self.bitmap = RPG::Cache.character(@character.character_name,
  186.          @character.character_hue)
  187.        @cw = bitmap.width / $c3_每一步的帧数
  188.        if $c3_总共可用的方向数==4
  189.          @ch = bitmap.height / 4
  190.        else
  191.          @ch = bitmap.height / 8
  192.        end
  193.        self.ox = @cw / 2
  194.        self.oy = @ch
  195.      end
  196.    end
  197.    # 设置可视状态
  198.    self.visible = (not @character.transparent)
  199.    # 图形是角色的情况下
  200.    if @tile_id == 0
  201.      # 设置传送目标的矩形
  202.      sx = @character.pattern * @cw
  203.      if $c3_总共可用的方向数==8
  204.        case @character.direction
  205.        when 2
  206.          sy = 0 * @ch
  207.        when 4
  208.          sy = 1 * @ch
  209.        when 6
  210.          sy = 2 * @ch
  211.        when 8
  212.          sy = 3 * @ch
  213.        when 1
  214.          sy = 4 * @ch
  215.        when 3
  216.          sy = 5 * @ch
  217.        when 7
  218.          sy = 6 * @ch
  219.        when 9
  220.          sy = 7 * @ch
  221.        end
  222.      else
  223.        sy = (@character.direction - 2) / 2 * @ch
  224.      end
  225.      self.src_rect.set(sx, sy, @cw, @ch)
  226.    end
  227.    # 设置脚本的坐标
  228.    self.x = @character.screen_x
  229.    self.y = @character.screen_y
  230.    self.z = @character.screen_z(@ch)
  231.    # 设置不透明度、合成方式、茂密
  232.    self.opacity = @character.opacity
  233.    self.blend_type = @character.blend_type
  234.    self.bush_depth = @character.bush_depth
  235.    # 动画
  236.    if @character.animation_id != 0
  237.      animation = $data_animations[@character.animation_id]
  238.      animation(animation, true)
  239.      @character.animation_id = 0
  240.    end
  241.    #####################################################################
  242.    #id = $game_map.map_id
  243.    #name = $data_mapinfos[id].name
  244.    #if name.include?("★")
  245.    #  rage = name.split(/★/)[1]
  246.    #  min_rate = rage.split(/~/)[0].to_f
  247.    #  max_rate = rage.split(/~/)[1].to_f
  248.    #  rate =  min_rate + (@character.y.to_f / $game_map.height.to_f * (max_rate - min_rate))
  249.    #  if @character.character_name.include?("★★") != true
  250.    #    self.zoom_x = self.zoom_y = rate
  251.    #  end
  252.    #end
  253.    ####################################################################
  254. end
  255. end

  256. class Game_Character
  257. def c8
  258.    # 随机 0~5 的分支
  259.    case rand(10)
  260.    when 0..3  # 随机
  261.      move_random
  262.    when 4  # 前进一步
  263.      move_forward
  264.    when 5  # 暂时停止
  265.      @stop_count = 0
  266.    when 6..9  #另外4方向随机
  267.      c4
  268.    end
  269. end
  270. def c4
  271.    case rand(5)
  272.    when 0
  273.      move_upper_left
  274.      @direction = 7
  275.    when 1
  276.      move_upper_right
  277.      @direction = 9
  278.    when 2
  279.      move_lower_left
  280.      @direction = 1
  281.    when 3
  282.      move_lower_right
  283.      @direction = 3
  284.    when 4
  285.      @stop_count = 0
  286.    end
  287. end
  288.      
  289. def update
  290.    # 跳跃中、移动中、停止中的分支
  291.    if jumping?
  292.      update_jump
  293.    elsif moving?
  294.      update_move
  295.    else
  296.      update_stop
  297.    end
  298.    # 动画计数超过最大值的情况下
  299.    # ※最大值等于基本值减去移动速度 * 1 的值
  300.    if @anime_count > 16 * 4/$c3_每一步的帧数 - @move_speed * 2
  301.      # 停止动画为 OFF 并且在停止中的情况下
  302.      if not @step_anime and @stop_count > 0
  303.        # 还原为原来的图形
  304.        @pattern = @original_pattern
  305.      # 停止动画为 ON 并且在移动中的情况下
  306.      else
  307.        # 更新图形
  308.        @pattern = (@pattern + 1) % $c3_每一步的帧数
  309.      end
  310.      # 清除动画计数
  311.      @anime_count = 0
  312.    end
  313.    # 等待中的情况下
  314.    if @wait_count > 0
  315.      # 减少等待计数
  316.      @wait_count -= 1
  317.      return
  318.    end
  319.    # 强制移动路线的场合
  320.    if @move_route_forcing
  321.      # 自定义移动
  322.      move_type_custom
  323.      return
  324.    end
  325.    # 事件执行待机中并且为锁定状态的情况下
  326.    if @starting or lock?
  327.      # 不做规则移动
  328.      return
  329.    end
  330.    # 如果停止计数超过了一定的值(由移动频度算出)
  331.    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  332.      # 移动类型分支
  333.      case @move_type
  334.      when 1  # 随机
  335.        move_type_random
  336.      when 2  # 接近
  337.        move_type_toward_player
  338.      when 3  # 自定义
  339.        move_type_custom
  340.      end
  341.    end
  342. end
  343. end

  344. class Window_Base < Window
  345. def draw_actor_graphic(actor, x, y)
  346.    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  347.    cw = bitmap.width / $c3_每一步的帧数
  348.    ch = bitmap.height / $c3_总共可用的方向数
  349.    src_rect = Rect.new(0, 0, cw, ch)
  350.    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  351. end
  352. end

  353. class Game_Character
  354. #--------------------------------------------------------------------------
  355. # ● 面向主角的方向
  356. #--------------------------------------------------------------------------
  357. def turn_toward_player
  358.    # 求得与主角的坐标差
  359.    sx = @x - $game_player.x
  360.    sy = @y - $game_player.y
  361.    # 坐标相等的场合下
  362.    if sx == 0 and sy == 0
  363.      return
  364.    end
  365.    # 横侧距离长的情况下
  366.    if sx.abs > sy.abs
  367.      # 将左右方向变更为朝向主角的方向
  368.      sx > 0 ? turn_left : turn_right
  369.    # 竖侧距离长的情况下
  370.    else
  371.      # 将上下方向变更为朝向主角的方向
  372.      sy > 0 ? turn_up : turn_down
  373.    end
  374.   unless @direction_fix
  375.    if sx == -1 and sy == -1
  376.      @direction = 3
  377.      @stop_count = 0
  378.    elsif sx == -1 and sy == 1
  379.      @direction = 9
  380.      @stop_count = 0
  381.    elsif sx == 1 and sy == -1
  382.      @direction = 1
  383.      @stop_count = 0
  384.    elsif sx == 1 and sy == 1
  385.      @direction = 7
  386.      @stop_count = 0
  387.    end
  388.   end
  389. end
  390. end

  391. #==============================================================================
  392. #============================================================================== #==============================================================================
  393. #==============================================================================


  394. # ————————————————————————————————————

  395. # ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
  396. #
  397. # Train_Actor
  398. #
  399. #

  400. module Train_Actor




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





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





  408. # 定数
  409. #Input::DOWN = 2
  410. #Input::LEFT = 4
  411. #Input::RIGHT = 6
  412. #Input::UP = 6
  413. DOWN_LEFT = 1
  414. DOWN_RIGHT = 3
  415. UP_LEFT = 7
  416. UP_RIGHT = 9
  417. JUMP = 5

  418. class Game_Party_Actor < Game_Character
  419. def initialize
  420. super()
  421. @through = true
  422. end
  423. def setup(actor)
  424. # キャラクターのファイル名と色相を設定
  425. if actor != nil
  426. @character_name = actor.character_name
  427. @character_hue = actor.character_hue
  428. else
  429. @character_name = ""
  430. @character_hue = 0
  431. end
  432. # 不透明度と合成方法を初期化
  433. @opacity = 255
  434. @blend_type = 0
  435. end
  436. def screen_z(height = 0)
  437. if $game_player.x == @x and $game_player.y == @y
  438. return $game_player.screen_z(height) - 1
  439. end
  440. super(height)
  441. end
  442. #--------------------------------------------------------------------------
  443. # ● 下に移動
  444. # turn_enabled : その場での向き変更を許可するフラグ
  445. #--------------------------------------------------------------------------
  446. def move_down(turn_enabled = true)
  447. # 下を向く
  448. if turn_enabled
  449. turn_down
  450. end
  451. # 通行可能な場合
  452. if passable?(@x, @y, Input::DOWN)
  453. # 下を向く
  454. turn_down
  455. # 座標を更新
  456. @y += 1
  457. end
  458. end
  459. #--------------------------------------------------------------------------
  460. # ● 左に移動
  461. # turn_enabled : その場での向き変更を許可するフラグ
  462. #--------------------------------------------------------------------------
  463. def move_left(turn_enabled = true)
  464. # 左を向く
  465. if turn_enabled
  466. turn_left
  467. end
  468. # 通行可能な場合
  469. if passable?(@x, @y, Input::LEFT)
  470. # 左を向く
  471. turn_left
  472. # 座標を更新
  473. @x -= 1
  474. end
  475. end
  476. #--------------------------------------------------------------------------
  477. # ● 右に移動
  478. # turn_enabled : その場での向き変更を許可するフラグ
  479. #--------------------------------------------------------------------------
  480. def move_right(turn_enabled = true)
  481. # 右を向く
  482. if turn_enabled
  483. turn_right
  484. end
  485. # 通行可能な場合
  486. if passable?(@x, @y, Input::RIGHT)
  487. # 右を向く
  488. turn_right
  489. # 座標を更新
  490. @x += 1
  491. end
  492. end
  493. #--------------------------------------------------------------------------
  494. # ● 上に移動
  495. # turn_enabled : その場での向き変更を許可するフラグ
  496. #--------------------------------------------------------------------------
  497. def move_up(turn_enabled = true)
  498. # 上を向く
  499. if turn_enabled
  500. turn_up
  501. end
  502. # 通行可能な場合
  503. if passable?(@x, @y, Input::UP)
  504. # 上を向く
  505. turn_up
  506. # 座標を更新
  507. @y -= 1
  508. end
  509. end
  510. #--------------------------------------------------------------------------
  511. # ● 左下に移動
  512. #--------------------------------------------------------------------------
  513. def move_lower_left
  514. # 向き固定でない場合
  515. unless @direction_fix
  516. # 右向きだった場合は左を、上向きだった場合は下を向く

  517. @direction = 1
  518. end
  519. # 下→左、左→下 のどちらかのコースが通行可能な場合
  520. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  521. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  522. # 座標を更新
  523. @x -= 1
  524. @y += 1
  525. end
  526. end
  527. #--------------------------------------------------------------------------
  528. # ● 右下に移動
  529. #--------------------------------------------------------------------------
  530. def move_lower_right
  531. # 向き固定でない場合
  532. unless @direction_fix
  533. # 左向きだった場合は右を、上向きだった場合は下を向く

  534. @direction = 3
  535. end
  536. # 下→右、右→下 のどちらかのコースが通行可能な場合
  537. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  538. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  539. # 座標を更新
  540. @x += 1
  541. @y += 1
  542. end
  543. end
  544. #--------------------------------------------------------------------------
  545. # ● 左上に移動
  546. #--------------------------------------------------------------------------
  547. def move_upper_left
  548. # 向き固定でない場合
  549. unless @direction_fix
  550. # 右向きだった場合は左を、下向きだった場合は上を向く

  551. @direction = 7
  552. end
  553. # 上→左、左→上 のどちらかのコースが通行可能な場合
  554. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  555. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  556. # 座標を更新
  557. @x -= 1
  558. @y -= 1
  559. end
  560. end
  561. #--------------------------------------------------------------------------
  562. # ● 右上に移動
  563. #--------------------------------------------------------------------------
  564. def move_upper_right

  565. # 向き固定でない場合
  566. unless @direction_fix
  567. # 左向きだった場合は右を、下向きだった場合は上を向く

  568. @direction = 9
  569. end
  570. # 上→右、右→上 のどちらかのコースが通行可能な場合
  571. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  572. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  573. # 座標を更新
  574. @x += 1
  575. @y -= 1
  576. end
  577. end
  578. attr_writer :move_speed
  579. attr_writer :step_anime
  580. end
  581. module Spriteset_Map_Module
  582. def setup_actor_character_sprites?
  583. return @setup_actor_character_sprites_flag != nil
  584. end
  585. def setup_actor_character_sprites(characters)
  586. if !setup_actor_character_sprites?
  587. index_game_player = 0
  588. @character_sprites.each_index do |i|
  589. if @character_sprites[i].character.instance_of?(Game_Player)
  590. index_game_player = i
  591. break
  592. end
  593. end
  594. for character in characters.reverse
  595. @character_sprites.unshift(
  596. Sprite_Character.new(@viewport1, character)
  597. )
  598. end
  599. @setup_actor_character_sprites_flag = true
  600. end
  601. end
  602. end
  603. module Scene_Map_Module
  604. def setup_actor_character_sprites(characters)
  605. @spriteset.setup_actor_character_sprites(characters)
  606. end
  607. end
  608. module Game_Party_Module
  609. def return_char(i)
  610. return @characters[i]
  611. end
  612. def set_transparent_actors(transparent)
  613. @transparent = transparent
  614. end
  615. def setup_actor_character_sprites
  616. if @characters == nil
  617. @characters = []
  618. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  619. @characters.push(Game_Party_Actor.new)
  620. end
  621. end
  622. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  623. @characters[i - 1].setup(actors[i])
  624. end
  625. if $scene.class.method_defined?('setup_actor_character_sprites')
  626. $scene.setup_actor_character_sprites(@characters)
  627. end
  628. end
  629. def update_party_actors
  630. setup_actor_character_sprites
  631. transparent = $game_player.transparent
  632. if transparent == false
  633. if TRANSPARENT_SWITCH
  634. transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  635. end
  636. end
  637. for character in @characters
  638. character.transparent = transparent
  639. character.move_speed = $game_player.move_speed
  640. character.step_anime = $game_player.step_anime
  641. character.update
  642. end
  643. end
  644. def moveto_party_actors( x, y )
  645. setup_actor_character_sprites
  646. for character in @characters
  647. character.moveto( x, y )
  648. end
  649. if @move_list == nil
  650. @move_list = []
  651. end
  652. move_list_setup
  653. end
  654. def move_party_actors
  655. if @move_list == nil
  656. @move_list = []
  657. move_list_setup
  658. end
  659. @move_list.each_index do |i|
  660. if @characters[i] != nil
  661. case @move_list[i].type
  662. when Input::DOWN
  663. @characters[i].move_down(@move_list[i].args[0])
  664. when Input::LEFT
  665. @characters[i].move_left(@move_list[i].args[0])
  666. when Input::RIGHT
  667. @characters[i].move_right(@move_list[i].args[0])
  668. when Input::UP
  669. @characters[i].move_up(@move_list[i].args[0])
  670. when DOWN_LEFT
  671. @characters[i].move_lower_left
  672. when DOWN_RIGHT
  673. @characters[i].move_lower_right
  674. when UP_LEFT
  675. @characters[i].move_upper_left
  676. when UP_RIGHT
  677. @characters[i].move_upper_right
  678. when JUMP
  679. @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  680. end
  681. end
  682. end
  683. end
  684. class Move_List_Element
  685. def initialize(type,args)
  686. @type = type
  687. @args = args
  688. end
  689. def type() return @type end
  690. def args() return @args end
  691. end
  692. def move_list_setup
  693. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  694. @move_list[i] = nil
  695. end
  696. end
  697. def add_move_list(type,*args)
  698. @move_list.unshift(Move_List_Element.new(type,args)).pop
  699. end
  700. def move_down_party_actors(turn_enabled = true)
  701. move_party_actors
  702. add_move_list(Input::DOWN,turn_enabled)
  703. end
  704. def move_left_party_actors(turn_enabled = true)
  705. move_party_actors
  706. add_move_list(Input::LEFT,turn_enabled)
  707. end
  708. def move_right_party_actors(turn_enabled = true)
  709. move_party_actors
  710. add_move_list(Input::RIGHT,turn_enabled)
  711. end
  712. def move_up_party_actors(turn_enabled = true)
  713. move_party_actors
  714. add_move_list(Input::UP,turn_enabled)
  715. end
  716. def move_lower_left_party_actors
  717. move_party_actors
  718. add_move_list(DOWN_LEFT)
  719. end
  720. def move_lower_right_party_actors
  721. move_party_actors
  722. add_move_list(DOWN_RIGHT)
  723. end
  724. def move_upper_left_party_actors
  725. move_party_actors
  726. add_move_list(UP_LEFT)
  727. end
  728. def move_upper_right_party_actors
  729. move_party_actors
  730. add_move_list(UP_RIGHT)
  731. end
  732. def jump_party_actors(x_plus, y_plus)
  733. move_party_actors
  734. add_move_list(JUMP,x_plus, y_plus)
  735. end
  736. end
  737. module Game_Player_Module
  738. def update
  739. $game_party.update_party_actors
  740. super
  741. end
  742. def moveto( x, y )
  743. $game_party.moveto_party_actors( x, y )
  744. super( x, y )
  745. end
  746. def move_down(turn_enabled = true)
  747. if passable?(@x, @y, Input::DOWN)
  748. $game_party.move_down_party_actors(turn_enabled)
  749. end
  750. super(turn_enabled)
  751. end
  752. def move_left(turn_enabled = true)
  753. if passable?(@x, @y, Input::LEFT)
  754. $game_party.move_left_party_actors(turn_enabled)
  755. end
  756. super(turn_enabled)
  757. end
  758. def move_right(turn_enabled = true)
  759. if passable?(@x, @y, Input::RIGHT)
  760. $game_party.move_right_party_actors(turn_enabled)
  761. end
  762. super(turn_enabled)
  763. end
  764. def move_up(turn_enabled = true)
  765. if passable?(@x, @y, Input::UP)
  766. $game_party.move_up_party_actors(turn_enabled)
  767. end
  768. super(turn_enabled)
  769. end
  770. def move_lower_left
  771. # 下→左、左→下 のどちらかのコースが通行可能な場合
  772. @direction = 1
  773. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  774. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  775. $game_party.move_lower_left_party_actors
  776. end
  777. super
  778. end
  779. def move_lower_right
  780. # 下→右、右→下 のどちらかのコースが通行可能な場合
  781. @direction = 3
  782. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  783. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  784. $game_party.move_lower_right_party_actors
  785. end
  786. super
  787. end
  788. def move_upper_left
  789. # 上→左、左→上 のどちらかのコースが通行可能な場合
  790. @direction = 7
  791. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  792. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  793. $game_party.move_upper_left_party_actors
  794. end
  795. super
  796. end
  797. def move_upper_right
  798. # 上→右、右→上 のどちらかのコースが通行可能な場合
  799. @direction = 9
  800. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  801. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  802. $game_party.move_upper_right_party_actors
  803. end
  804. super
  805. end
  806. def jump(x_plus, y_plus)
  807. # 新しい座標を計算
  808. new_x = @x + x_plus
  809. new_y = @y + y_plus
  810. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  811. if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  812. $game_party.jump_party_actors(x_plus, y_plus)
  813. end
  814. super(x_plus, y_plus)
  815. end
  816. attr_reader :move_speed
  817. attr_reader :step_anime
  818. end
  819. end # module Train_Actor
  820. class Game_Party
  821. include Train_Actor::Game_Party_Module
  822. end
  823. class Game_Player
  824. include Train_Actor::Game_Player_Module
  825. end
  826. class Spriteset_Map
  827. include Train_Actor::Spriteset_Map_Module
  828. end
  829. class Scene_Map
  830. include Train_Actor::Scene_Map_Module
  831. end

  832. #==============================================================================
  833. #==============================================================================
复制代码

评分

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

查看全部评分


      情人怨遥夜,竟夕起相思
梦石
0
星屑
60
在线时间
936 小时
注册时间
2008-2-14
回帖
930

开拓者

发表于 2016-2-2 16:43:17 | 显示全部楼层
显示角色可控的八方向跟随.zip (5.85 KB, 下载次数: 94)
脚本内搜索“显示的角色”更改需要显示出来的角色的ID

评分

参与人数 2星屑 +180 梦石 +1 收起 理由
RyanBern + 1 认可答案
月下耶鲁夫 + 180 谢谢断电姐姐帮忙!

查看全部评分

接稿,UI(已接)/立绘(已接)
无偿/有偿皆可,有偿速度会更快^q^
作品请见相册,有意请发私信:)
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部