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

Project1

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

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

[复制链接]

Lv3.寻梦者 (版主)

梦石
0
星屑
1852
在线时间
2678 小时
注册时间
2010-6-26
帖子
3197

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

跳转到指定楼层
1
发表于 2016-2-2 15:04:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

RUBY 代码复制
  1. ###########################################################################################################################
  2. # 脚本功能:八方向走与多帧移动之图片修正 + 人物跟随。
  3.  
  4. $c3_每一步的帧数 = 4
  5. $c3_总共可用的方向数 = 8 #——建议不要修改这个。如果要伪8方向的,就用伪的好了。
  6.  
  7.  
  8. # 作者:carol3
  9. ###########################################################################################################################
  10. ###########################################################################################################################
  11.  
  12. class Game_Player < Game_Character
  13. if $c3_总共可用的方向数 == 8
  14.    def update
  15.      last_moving = moving?
  16.      unless moving? or $game_system.map_interpreter.running? or
  17.             @move_route_forcing or $game_temp.message_window_showing
  18. =begin
  19.      if Input.press?(Input::SHIFT)
  20.        if @move_speed != 5
  21.         @move_speed = 5
  22.        end
  23.       else
  24.        if @move_speed != 4
  25.         @move_speed = 4
  26.        end
  27.      end
  28. =end
  29.        # 用井号后面的东西替代前面的,就可以实现斜4方向走
  30.        case Input.dir8
  31.        when 2
  32.          move_down #move_lower_left
  33.        when 4
  34.          move_left #move_upper_left
  35.        when 6
  36.          move_right #move_lower_right
  37.        when 8
  38.          move_up #move_upper_right
  39.        when 1
  40.          move_lower_left
  41.        when 3
  42.          move_lower_right
  43.        when 7
  44.          move_upper_left
  45.        when 9
  46.          move_upper_right
  47.        end
  48.      end
  49.      # 本地变量记忆坐标
  50.      last_real_x = @real_x
  51.      last_real_y = @real_y
  52.      super
  53.      # 角色向下移动、画面上的位置在中央下方的情况下
  54.      if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  55.        # 画面向下卷动
  56.        $game_map.scroll_down(@real_y - last_real_y)
  57.      end
  58.      # 角色向左移动、画面上的位置在中央左方的情况下
  59.      if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  60.        # 画面向左卷动
  61.        $game_map.scroll_left(last_real_x - @real_x)
  62.      end
  63.      # 角色向右移动、画面上的位置在中央右方的情况下
  64.      if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  65.        # 画面向右卷动
  66.        $game_map.scroll_right(@real_x - last_real_x)
  67.      end
  68.      # 角色向上移动、画面上的位置在中央上方的情况下
  69.      if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  70.        # 画面向上卷动
  71.        $game_map.scroll_up(last_real_y - @real_y)
  72.      end
  73.      # 不在移动中的情况下
  74.      unless moving?
  75.        # 上次主角移动中的情况
  76.        if last_moving
  77.          # 与同位置的事件接触就判定为事件启动
  78.          result = check_event_trigger_here([1,2])
  79.          # 没有可以启动的事件的情况下
  80.          if result == false
  81.            # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  82.            unless $DEBUG and Input.press?(Input::CTRL)
  83.              # 遇敌计数下降
  84.              if @encounter_count > 0
  85.                @encounter_count -= 1
  86.              end
  87.            end
  88.          end
  89.        end
  90.        # 按下 C 键的情况下
  91.        if Input.trigger?(Input::C)
  92.          # 判定为同位置以及正面的事件启动
  93.          check_event_trigger_here([0])
  94.          check_event_trigger_there([0,1,2])
  95.        end
  96.      end
  97.    end
  98.    #--------------------------------------------------------------------------
  99.    # ● 正面事件的启动判定
  100.    #--------------------------------------------------------------------------
  101.    def check_event_trigger_there(triggers)
  102.      result = false
  103.      # 事件执行中的情况下
  104.      if $game_system.map_interpreter.running?
  105.        return result
  106.      end
  107.      # 计算正面坐标
  108.      new_x = @x
  109.      new_y = @y
  110.      case @direction
  111.      when 1
  112.        new_x -= 1
  113.        new_y += 1
  114.      when 2
  115.        new_y += 1
  116.      when 3
  117.        new_x += 1
  118.        new_y += 1
  119.      when 4
  120.        new_x -= 1
  121.      when 6
  122.        new_x += 1
  123.      when 7
  124.        new_x -= 1
  125.        new_y -= 1
  126.      when 8
  127.        new_y -= 1
  128.      when 9
  129.        new_x += 1
  130.        new_y -= 1
  131.      end
  132.      # 全部事件的循环
  133.      for event in $game_map.events.values
  134.        # 事件坐标与目标一致的情况下
  135.        if event.x == new_x and event.y == new_y and
  136.           triggers.include?(event.trigger)
  137.          # 跳跃中以外的情况下、启动判定是正面的事件
  138.          if not event.jumping? and not event.over_trigger?
  139.            event.start
  140.            result = true
  141.          end
  142.        end
  143.      end
  144.      # 找不到符合条件的事件的情况下
  145.      if result == false
  146.        # 正面的元件是计数器的情况下
  147.        if $game_map.counter?(new_x, new_y)
  148.          # 计算 1 元件里侧的坐标
  149.          new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  150.          new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  151.          # 全事件的循环
  152.          for event in $game_map.events.values
  153.            # 事件坐标与目标一致的情况下
  154.            if event.x == new_x and event.y == new_y and
  155.               triggers.include?(event.trigger)
  156.              # 跳跃中以外的情况下、启动判定是正面的事件
  157.              if not event.jumping? and not event.over_trigger?
  158.                event.start
  159.                result = true
  160.              end
  161.            end
  162.          end
  163.        end
  164.      end
  165.      return result
  166.    end
  167. end
  168. end
  169.  
  170.  
  171. class Sprite_Character < RPG::Sprite
  172. def update
  173.    super
  174.    # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  175.    if @tile_id != @character.tile_id or
  176.       @character_name != @character.character_name or
  177.       @character_hue != @character.character_hue
  178.      # 记忆元件 ID 与文件名、色相
  179.      @tile_id = @character.tile_id
  180.      @character_name = @character.character_name
  181.      @character_hue = @character.character_hue
  182.      # 元件 ID 为有效值的情况下
  183.      if @tile_id >= 384
  184.        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  185.          @tile_id, @character.character_hue)
  186.        self.src_rect.set(0, 0, 32, 32)
  187.        self.ox = 16
  188.        self.oy = 32
  189.      # 元件 ID 为无效值的情况下
  190.      else
  191.        self.bitmap = RPG::Cache.character(@character.character_name,
  192.          @character.character_hue)
  193.        @cw = bitmap.width / $c3_每一步的帧数
  194.        if $c3_总共可用的方向数==4
  195.          @ch = bitmap.height / 4
  196.        else
  197.          @ch = bitmap.height / 8
  198.        end
  199.        self.ox = @cw / 2
  200.        self.oy = @ch
  201.      end
  202.    end
  203.    # 设置可视状态
  204.    self.visible = (not @character.transparent)
  205.    # 图形是角色的情况下
  206.    if @tile_id == 0
  207.      # 设置传送目标的矩形
  208.      sx = @character.pattern * @cw
  209.      if $c3_总共可用的方向数==8
  210.        case @character.direction
  211.        when 2
  212.          sy = 0 * @ch
  213.        when 4
  214.          sy = 1 * @ch
  215.        when 6
  216.          sy = 2 * @ch
  217.        when 8
  218.          sy = 3 * @ch
  219.        when 1
  220.          sy = 4 * @ch
  221.        when 3
  222.          sy = 5 * @ch
  223.        when 7
  224.          sy = 6 * @ch
  225.        when 9
  226.          sy = 7 * @ch
  227.        end
  228.      else
  229.        sy = (@character.direction - 2) / 2 * @ch
  230.      end
  231.      self.src_rect.set(sx, sy, @cw, @ch)
  232.    end
  233.    # 设置脚本的坐标
  234.    self.x = @character.screen_x
  235.    self.y = @character.screen_y
  236.    self.z = @character.screen_z(@ch)
  237.    # 设置不透明度、合成方式、茂密
  238.    self.opacity = @character.opacity
  239.    self.blend_type = @character.blend_type
  240.    self.bush_depth = @character.bush_depth
  241.    # 动画
  242.    if @character.animation_id != 0
  243.      animation = $data_animations[@character.animation_id]
  244.      animation(animation, true)
  245.      @character.animation_id = 0
  246.    end
  247.    #####################################################################
  248.    #id = $game_map.map_id
  249.    #name = $data_mapinfos[id].name
  250.    #if name.include?("★")
  251.    #  rage = name.split(/★/)[1]
  252.    #  min_rate = rage.split(/~/)[0].to_f
  253.    #  max_rate = rage.split(/~/)[1].to_f
  254.    #  rate =  min_rate + (@character.y.to_f / $game_map.height.to_f * (max_rate - min_rate))
  255.    #  if @character.character_name.include?("★★") != true
  256.    #    self.zoom_x = self.zoom_y = rate
  257.    #  end
  258.    #end
  259.    ####################################################################
  260. end
  261. end
  262.  
  263. class Game_Character
  264. def c8
  265.    # 随机 0~5 的分支
  266.    case rand(10)
  267.    when 0..3  # 随机
  268.      move_random
  269.    when 4  # 前进一步
  270.      move_forward
  271.    when 5  # 暂时停止
  272.      @stop_count = 0
  273.    when 6..9  #另外4方向随机
  274.      c4
  275.    end
  276. end
  277. def c4
  278.    case rand(5)
  279.    when 0
  280.      move_upper_left
  281.      @direction = 7
  282.    when 1
  283.      move_upper_right
  284.      @direction = 9
  285.    when 2
  286.      move_lower_left
  287.      @direction = 1
  288.    when 3
  289.      move_lower_right
  290.      @direction = 3
  291.    when 4
  292.      @stop_count = 0
  293.    end
  294. end
  295.  
  296. def update
  297.    # 跳跃中、移动中、停止中的分支
  298.    if jumping?
  299.      update_jump
  300.    elsif moving?
  301.      update_move
  302.    else
  303.      update_stop
  304.    end
  305.    # 动画计数超过最大值的情况下
  306.    # ※最大值等于基本值减去移动速度 * 1 的值
  307.    if @anime_count > 16 * 4/$c3_每一步的帧数 - @move_speed * 2
  308.      # 停止动画为 OFF 并且在停止中的情况下
  309.      if not @step_anime and @stop_count > 0
  310.        # 还原为原来的图形
  311.        @pattern = @original_pattern
  312.      # 停止动画为 ON 并且在移动中的情况下
  313.      else
  314.        # 更新图形
  315.        @pattern = (@pattern + 1) % $c3_每一步的帧数
  316.      end
  317.      # 清除动画计数
  318.      @anime_count = 0
  319.    end
  320.    # 等待中的情况下
  321.    if @wait_count > 0
  322.      # 减少等待计数
  323.      @wait_count -= 1
  324.      return
  325.    end
  326.    # 强制移动路线的场合
  327.    if @move_route_forcing
  328.      # 自定义移动
  329.      move_type_custom
  330.      return
  331.    end
  332.    # 事件执行待机中并且为锁定状态的情况下
  333.    if @starting or lock?
  334.      # 不做规则移动
  335.      return
  336.    end
  337.    # 如果停止计数超过了一定的值(由移动频度算出)
  338.    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  339.      # 移动类型分支
  340.      case @move_type
  341.      when 1  # 随机
  342.        move_type_random
  343.      when 2  # 接近
  344.        move_type_toward_player
  345.      when 3  # 自定义
  346.        move_type_custom
  347.      end
  348.    end
  349. end
  350. end
  351.  
  352. class Window_Base < Window
  353. def draw_actor_graphic(actor, x, y)
  354.    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  355.    cw = bitmap.width / $c3_每一步的帧数
  356.    ch = bitmap.height / $c3_总共可用的方向数
  357.    src_rect = Rect.new(0, 0, cw, ch)
  358.    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  359. end
  360. end
  361.  
  362. class Game_Character
  363. #--------------------------------------------------------------------------
  364. # ● 面向主角的方向
  365. #--------------------------------------------------------------------------
  366. def turn_toward_player
  367.    # 求得与主角的坐标差
  368.    sx = @x - $game_player.x
  369.    sy = @y - $game_player.y
  370.    # 坐标相等的场合下
  371.    if sx == 0 and sy == 0
  372.      return
  373.    end
  374.    # 横侧距离长的情况下
  375.    if sx.abs > sy.abs
  376.      # 将左右方向变更为朝向主角的方向
  377.      sx > 0 ? turn_left : turn_right
  378.    # 竖侧距离长的情况下
  379.    else
  380.      # 将上下方向变更为朝向主角的方向
  381.      sy > 0 ? turn_up : turn_down
  382.    end
  383.   unless @direction_fix
  384.    if sx == -1 and sy == -1
  385.      @direction = 3
  386.      @stop_count = 0
  387.    elsif sx == -1 and sy == 1
  388.      @direction = 9
  389.      @stop_count = 0
  390.    elsif sx == 1 and sy == -1
  391.      @direction = 1
  392.      @stop_count = 0
  393.    elsif sx == 1 and sy == 1
  394.      @direction = 7
  395.      @stop_count = 0
  396.    end
  397.   end
  398. end
  399. end
  400.  
  401. #==============================================================================
  402. #============================================================================== #==============================================================================
  403. #==============================================================================
  404.  
  405.  
  406. # ————————————————————————————————————
  407.  
  408. # ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
  409. #
  410. # Train_Actor
  411. #
  412. #
  413.  
  414. module Train_Actor
  415.  
  416.  
  417.  
  418.  
  419. #是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX
  420. #开关打开,跟随的人物就消失了(其实只是变成透明而已)
  421. TRANSPARENT_SWITCH = true
  422. TRANSPARENT_SWITCHES_INDEX = 32
  423. #举例:第一个为true,第二个为20,则打开20号开关,后面的人都没了。
  424.  
  425.  
  426.  
  427.  
  428.  
  429. #跟随人数的最大数目,可以更改为2、3什么的。
  430. TRAIN_ACTOR_SIZE_MAX = 4
  431.  
  432.  
  433.  
  434.  
  435.  
  436. # 定数
  437. #Input::DOWN = 2
  438. #Input::LEFT = 4
  439. #Input::RIGHT = 6
  440. #Input::UP = 6
  441. DOWN_LEFT = 1
  442. DOWN_RIGHT = 3
  443. UP_LEFT = 7
  444. UP_RIGHT = 9
  445. JUMP = 5
  446.  
  447. class Game_Party_Actor < Game_Character
  448. def initialize
  449. super()
  450. @through = true
  451. end
  452. def setup(actor)
  453. # キャラクターのファイル名と色相を設定
  454. if actor != nil
  455. @character_name = actor.character_name
  456. @character_hue = actor.character_hue
  457. else
  458. @character_name = ""
  459. @character_hue = 0
  460. end
  461. # 不透明度と合成方法を初期化
  462. @opacity = 255
  463. @blend_type = 0
  464. end
  465. def screen_z(height = 0)
  466. if $game_player.x == @x and $game_player.y == @y
  467. return $game_player.screen_z(height) - 1
  468. end
  469. super(height)
  470. end
  471. #--------------------------------------------------------------------------
  472. # ● 下に移動
  473. # turn_enabled : その場での向き変更を許可するフラグ
  474. #--------------------------------------------------------------------------
  475. def move_down(turn_enabled = true)
  476. # 下を向く
  477. if turn_enabled
  478. turn_down
  479. end
  480. # 通行可能な場合
  481. if passable?(@x, @y, Input::DOWN)
  482. # 下を向く
  483. turn_down
  484. # 座標を更新
  485. @y += 1
  486. end
  487. end
  488. #--------------------------------------------------------------------------
  489. # ● 左に移動
  490. # turn_enabled : その場での向き変更を許可するフラグ
  491. #--------------------------------------------------------------------------
  492. def move_left(turn_enabled = true)
  493. # 左を向く
  494. if turn_enabled
  495. turn_left
  496. end
  497. # 通行可能な場合
  498. if passable?(@x, @y, Input::LEFT)
  499. # 左を向く
  500. turn_left
  501. # 座標を更新
  502. @x -= 1
  503. end
  504. end
  505. #--------------------------------------------------------------------------
  506. # ● 右に移動
  507. # turn_enabled : その場での向き変更を許可するフラグ
  508. #--------------------------------------------------------------------------
  509. def move_right(turn_enabled = true)
  510. # 右を向く
  511. if turn_enabled
  512. turn_right
  513. end
  514. # 通行可能な場合
  515. if passable?(@x, @y, Input::RIGHT)
  516. # 右を向く
  517. turn_right
  518. # 座標を更新
  519. @x += 1
  520. end
  521. end
  522. #--------------------------------------------------------------------------
  523. # ● 上に移動
  524. # turn_enabled : その場での向き変更を許可するフラグ
  525. #--------------------------------------------------------------------------
  526. def move_up(turn_enabled = true)
  527. # 上を向く
  528. if turn_enabled
  529. turn_up
  530. end
  531. # 通行可能な場合
  532. if passable?(@x, @y, Input::UP)
  533. # 上を向く
  534. turn_up
  535. # 座標を更新
  536. @y -= 1
  537. end
  538. end
  539. #--------------------------------------------------------------------------
  540. # ● 左下に移動
  541. #--------------------------------------------------------------------------
  542. def move_lower_left
  543. # 向き固定でない場合
  544. unless @direction_fix
  545. # 右向きだった場合は左を、上向きだった場合は下を向く
  546.  
  547. @direction = 1
  548. end
  549. # 下→左、左→下 のどちらかのコースが通行可能な場合
  550. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  551. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  552. # 座標を更新
  553. @x -= 1
  554. @y += 1
  555. end
  556. end
  557. #--------------------------------------------------------------------------
  558. # ● 右下に移動
  559. #--------------------------------------------------------------------------
  560. def move_lower_right
  561. # 向き固定でない場合
  562. unless @direction_fix
  563. # 左向きだった場合は右を、上向きだった場合は下を向く
  564.  
  565. @direction = 3
  566. end
  567. # 下→右、右→下 のどちらかのコースが通行可能な場合
  568. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  569. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  570. # 座標を更新
  571. @x += 1
  572. @y += 1
  573. end
  574. end
  575. #--------------------------------------------------------------------------
  576. # ● 左上に移動
  577. #--------------------------------------------------------------------------
  578. def move_upper_left
  579. # 向き固定でない場合
  580. unless @direction_fix
  581. # 右向きだった場合は左を、下向きだった場合は上を向く
  582.  
  583. @direction = 7
  584. end
  585. # 上→左、左→上 のどちらかのコースが通行可能な場合
  586. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  587. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  588. # 座標を更新
  589. @x -= 1
  590. @y -= 1
  591. end
  592. end
  593. #--------------------------------------------------------------------------
  594. # ● 右上に移動
  595. #--------------------------------------------------------------------------
  596. def move_upper_right
  597.  
  598. # 向き固定でない場合
  599. unless @direction_fix
  600. # 左向きだった場合は右を、下向きだった場合は上を向く
  601.  
  602. @direction = 9
  603. end
  604. # 上→右、右→上 のどちらかのコースが通行可能な場合
  605. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  606. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  607. # 座標を更新
  608. @x += 1
  609. @y -= 1
  610. end
  611. end
  612. attr_writer :move_speed
  613. attr_writer :step_anime
  614. end
  615. module Spriteset_Map_Module
  616. def setup_actor_character_sprites?
  617. return @setup_actor_character_sprites_flag != nil
  618. end
  619. def setup_actor_character_sprites(characters)
  620. if !setup_actor_character_sprites?
  621. index_game_player = 0
  622. @character_sprites.each_index do |i|
  623. if @character_sprites[i].character.instance_of?(Game_Player)
  624. index_game_player = i
  625. break
  626. end
  627. end
  628. for character in characters.reverse
  629. @character_sprites.unshift(
  630. Sprite_Character.new(@viewport1, character)
  631. )
  632. end
  633. @setup_actor_character_sprites_flag = true
  634. end
  635. end
  636. end
  637. module Scene_Map_Module
  638. def setup_actor_character_sprites(characters)
  639. @spriteset.setup_actor_character_sprites(characters)
  640. end
  641. end
  642. module Game_Party_Module
  643. def return_char(i)
  644. return @characters[i]
  645. end
  646. def set_transparent_actors(transparent)
  647. @transparent = transparent
  648. end
  649. def setup_actor_character_sprites
  650. if @characters == nil
  651. @characters = []
  652. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  653. @characters.push(Game_Party_Actor.new)
  654. end
  655. end
  656. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  657. @characters[i - 1].setup(actors[i])
  658. end
  659. if $scene.class.method_defined?('setup_actor_character_sprites')
  660. $scene.setup_actor_character_sprites(@characters)
  661. end
  662. end
  663. def update_party_actors
  664. setup_actor_character_sprites
  665. transparent = $game_player.transparent
  666. if transparent == false
  667. if TRANSPARENT_SWITCH
  668. transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  669. end
  670. end
  671. for character in @characters
  672. character.transparent = transparent
  673. character.move_speed = $game_player.move_speed
  674. character.step_anime = $game_player.step_anime
  675. character.update
  676. end
  677. end
  678. def moveto_party_actors( x, y )
  679. setup_actor_character_sprites
  680. for character in @characters
  681. character.moveto( x, y )
  682. end
  683. if @move_list == nil
  684. @move_list = []
  685. end
  686. move_list_setup
  687. end
  688. def move_party_actors
  689. if @move_list == nil
  690. @move_list = []
  691. move_list_setup
  692. end
  693. @move_list.each_index do |i|
  694. if @characters[i] != nil
  695. case @move_list[i].type
  696. when Input::DOWN
  697. @characters[i].move_down(@move_list[i].args[0])
  698. when Input::LEFT
  699. @characters[i].move_left(@move_list[i].args[0])
  700. when Input::RIGHT
  701. @characters[i].move_right(@move_list[i].args[0])
  702. when Input::UP
  703. @characters[i].move_up(@move_list[i].args[0])
  704. when DOWN_LEFT
  705. @characters[i].move_lower_left
  706. when DOWN_RIGHT
  707. @characters[i].move_lower_right
  708. when UP_LEFT
  709. @characters[i].move_upper_left
  710. when UP_RIGHT
  711. @characters[i].move_upper_right
  712. when JUMP
  713. @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  714. end
  715. end
  716. end
  717. end
  718. class Move_List_Element
  719. def initialize(type,args)
  720. @type = type
  721. @args = args
  722. end
  723. def type() return @type end
  724. def args() return @args end
  725. end
  726. def move_list_setup
  727. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  728. @move_list[i] = nil
  729. end
  730. end
  731. def add_move_list(type,*args)
  732. @move_list.unshift(Move_List_Element.new(type,args)).pop
  733. end
  734. def move_down_party_actors(turn_enabled = true)
  735. move_party_actors
  736. add_move_list(Input::DOWN,turn_enabled)
  737. end
  738. def move_left_party_actors(turn_enabled = true)
  739. move_party_actors
  740. add_move_list(Input::LEFT,turn_enabled)
  741. end
  742. def move_right_party_actors(turn_enabled = true)
  743. move_party_actors
  744. add_move_list(Input::RIGHT,turn_enabled)
  745. end
  746. def move_up_party_actors(turn_enabled = true)
  747. move_party_actors
  748. add_move_list(Input::UP,turn_enabled)
  749. end
  750. def move_lower_left_party_actors
  751. move_party_actors
  752. add_move_list(DOWN_LEFT)
  753. end
  754. def move_lower_right_party_actors
  755. move_party_actors
  756. add_move_list(DOWN_RIGHT)
  757. end
  758. def move_upper_left_party_actors
  759. move_party_actors
  760. add_move_list(UP_LEFT)
  761. end
  762. def move_upper_right_party_actors
  763. move_party_actors
  764. add_move_list(UP_RIGHT)
  765. end
  766. def jump_party_actors(x_plus, y_plus)
  767. move_party_actors
  768. add_move_list(JUMP,x_plus, y_plus)
  769. end
  770. end
  771. module Game_Player_Module
  772. def update
  773. $game_party.update_party_actors
  774. super
  775. end
  776. def moveto( x, y )
  777. $game_party.moveto_party_actors( x, y )
  778. super( x, y )
  779. end
  780. def move_down(turn_enabled = true)
  781. if passable?(@x, @y, Input::DOWN)
  782. $game_party.move_down_party_actors(turn_enabled)
  783. end
  784. super(turn_enabled)
  785. end
  786. def move_left(turn_enabled = true)
  787. if passable?(@x, @y, Input::LEFT)
  788. $game_party.move_left_party_actors(turn_enabled)
  789. end
  790. super(turn_enabled)
  791. end
  792. def move_right(turn_enabled = true)
  793. if passable?(@x, @y, Input::RIGHT)
  794. $game_party.move_right_party_actors(turn_enabled)
  795. end
  796. super(turn_enabled)
  797. end
  798. def move_up(turn_enabled = true)
  799. if passable?(@x, @y, Input::UP)
  800. $game_party.move_up_party_actors(turn_enabled)
  801. end
  802. super(turn_enabled)
  803. end
  804. def move_lower_left
  805. # 下→左、左→下 のどちらかのコースが通行可能な場合
  806. @direction = 1
  807. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  808. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  809. $game_party.move_lower_left_party_actors
  810. end
  811. super
  812. end
  813. def move_lower_right
  814. # 下→右、右→下 のどちらかのコースが通行可能な場合
  815. @direction = 3
  816. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  817. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  818. $game_party.move_lower_right_party_actors
  819. end
  820. super
  821. end
  822. def move_upper_left
  823. # 上→左、左→上 のどちらかのコースが通行可能な場合
  824. @direction = 7
  825. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  826. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  827. $game_party.move_upper_left_party_actors
  828. end
  829. super
  830. end
  831. def move_upper_right
  832. # 上→右、右→上 のどちらかのコースが通行可能な場合
  833. @direction = 9
  834. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  835. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  836. $game_party.move_upper_right_party_actors
  837. end
  838. super
  839. end
  840. def jump(x_plus, y_plus)
  841. # 新しい座標を計算
  842. new_x = @x + x_plus
  843. new_y = @y + y_plus
  844. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  845. if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  846. $game_party.jump_party_actors(x_plus, y_plus)
  847. end
  848. super(x_plus, y_plus)
  849. end
  850. attr_reader :move_speed
  851. attr_reader :step_anime
  852. end
  853. end # module Train_Actor
  854. class Game_Party
  855. include Train_Actor::Game_Party_Module
  856. end
  857. class Game_Player
  858. include Train_Actor::Game_Player_Module
  859. end
  860. class Spriteset_Map
  861. include Train_Actor::Spriteset_Map_Module
  862. end
  863. class Scene_Map
  864. include Train_Actor::Scene_Map_Module
  865. end
  866.  
  867. #==============================================================================
  868. #==============================================================================

评分

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

查看全部评分


      情人怨遥夜,竟夕起相思

Lv1.梦旅人 (暗夜天使)

梦石
0
星屑
60
在线时间
936 小时
注册时间
2008-2-14
帖子
973

开拓者

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

评分

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

查看全部评分

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 19:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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