查看: 1887|回复: 0

[已经过期] 人物跟隨腳本,優先度問題請求修正~

[复制链接]
梦石
0
星屑
50
在线时间
448 小时
注册时间
2011-10-9
回帖
138
发表于 2014-7-5 21:53:56 | 显示全部楼层 |阅读模式

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

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

×
問題陳述:

在此腳本中,跟隨者的優先度是在「與角色相等」的事件之下
也就是說,跟隨者會被物件給遮蓋
例如路邊的水花、車輛還是怪物等,非常的奇怪
優先度:主角=事件>跟隨者

但當把跟隨者的Z值+1時
又變成會把主角擋住的情形,例如過地圖後
優先度:主角=事件<跟隨者

有無方法讓跟隨者的優先度,在普通級別的事件之上、又在主角之下?
變成:主角>跟隨者>事件    這樣?


謝謝,腳本如下:


  1. if true
  2. #==============================================================================
  3.     # ■ 人物跟隨
  4.     #------------------------------------------------------------------------------
  5.     #
  6.     #   本腳本來自[url]www.66RPG.com[/url],使用和轉載請保留此信息
  7.     #
  8.     #   作者:fukuyama   
  9.     #
  10.     #   移植:ONEWateR
  11.     #
  12.     #==============================================================================
  13.     module Train_Actor

  14.     #是否使用停止跟隨的方法,也就是說,這裡false改為true的時候,如果TRANSPARENT_SWITCHES_INDEX
  15.     #開關打開,跟隨的人物就消失了(其實只是變成透明而已)

  16.     TRANSPARENT_SWITCH = true
  17.     TRANSPARENT_SWITCHES_INDEX = 7 #顯示跟隨人物開關編號
  18.     #舉例:第一個為true,第二個為20,則打開20號開關,後面的人都沒了。

  19.     #跟隨人數的最大數目,可以更改為2、3什麼的。
  20.     TRAIN_ACTOR_SIZE_MAX = 4

  21.     # 定數
  22.     DOWN_LEFT = 1
  23.     DOWN_RIGHT = 3
  24.     UP_LEFT = 7
  25.     UP_RIGHT = 9
  26.     JUMP = 5

  27.     class Game_Party_Actor < Game_Character
  28.     def initialize
  29.     super()
  30.     @through = true
  31.     end
  32.     def setup(actor)
  33.     if actor != nil
  34.     @character_index = actor.character_index
  35.     @character_name = actor.character_name
  36.     @priority_type = 1
  37.     else
  38.     @character_name = ""
  39.     @character_index = 0
  40.     @priority_type = 1
  41.     end
  42.     # 不透明度と合成方法を初期化
  43.     @opacity = 255
  44.     @blend_type = 0
  45.    
  46.    
  47.    
  48.    
  49.    
  50. #-----------------------------------------------------------------------------------   
  51.     def screen_z
  52.     if @priority_type == 2
  53.       result = 200
  54.     elsif @priority_type == 0
  55.       result = 60
  56.     elsif @tile_id > 0
  57.       pass = $game_map.passages[@tile_id]
  58.       if pass & 0x10 == 0x10    # [☆]
  59.         result = 160
  60.       else
  61.         result = 40
  62.       end
  63.     else
  64.       result = 100
  65.     end
  66.     return result - 1
  67.   end   
  68. #-----------------------------------------------------------------------------------  
  69.    
  70.    
  71.    
  72.    
  73.    
  74.    
  75.     end
  76.     #--------------------------------------------------------------------------
  77.     # ● 下に移動
  78.     # turn_enabled : その場での向き変更を許可するフラグ
  79.     #--------------------------------------------------------------------------
  80.     def move_down(turn_enabled = true)
  81.     # 下を向く
  82.     if turn_enabled
  83.     turn_down
  84.     end
  85.     # 通行可能な場合
  86.     if new_passable?(@x, @y, Input::DOWN)
  87.     # 下を向く
  88.     turn_down
  89.     # 座標を更新
  90.     @y += 1
  91.     end
  92.     end
  93.     #--------------------------------------------------------------------------
  94.     # ● 左に移動
  95.     # turn_enabled : その場での向き変更を許可するフラグ
  96.     #--------------------------------------------------------------------------
  97.     def move_left(turn_enabled = true)
  98.     # 左を向く
  99.     if turn_enabled
  100.     turn_left
  101.     end
  102.     # 通行可能な場合
  103.     if new_passable?(@x, @y, Input::LEFT)
  104.     # 左を向く
  105.     turn_left
  106.     # 座標を更新
  107.     @x -= 1
  108.     end
  109.     end
  110.     #--------------------------------------------------------------------------
  111.     # ● 右に移動
  112.     # turn_enabled : その場での向き変更を許可するフラグ
  113.     #--------------------------------------------------------------------------
  114.     def move_right(turn_enabled = true)
  115.     # 右を向く
  116.     if turn_enabled
  117.     turn_right
  118.     end
  119.     # 通行可能な場合
  120.     if new_passable?(@x, @y, Input::RIGHT)
  121.     # 右を向く
  122.     turn_right
  123.     # 座標を更新
  124.     @x += 1
  125.     end
  126.     end
  127.     #--------------------------------------------------------------------------
  128.     # ● 上に移動
  129.     # turn_enabled : その場での向き変更を許可するフラグ
  130.     #--------------------------------------------------------------------------
  131.     def move_up(turn_enabled = true)
  132.     # 上を向く
  133.     if turn_enabled
  134.     turn_up
  135.     end
  136.     # 通行可能な場合
  137.     if new_passable?(@x, @y, Input::UP)
  138.     # 上を向く
  139.     turn_up
  140.     # 座標を更新
  141.     @y -= 1
  142.     end
  143.     end
  144.     #--------------------------------------------------------------------------
  145.     # ● 左下に移動
  146.     #--------------------------------------------------------------------------
  147.     def move_lower_left
  148.     # 向き固定でない場合
  149.     unless @direction_fix
  150.     # 右向きだった場合は左を、上向きだった場合は下を向く
  151.     @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  152.     end
  153.     # 下→左、左→下 のどちらかのコースが通行可能な場合
  154.     if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
  155.     (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
  156.     # 座標を更新
  157.     @x -= 1
  158.     @y += 1
  159.     end
  160.     end
  161.     #--------------------------------------------------------------------------
  162.     # ● 右下に移動
  163.     #--------------------------------------------------------------------------
  164.     def move_lower_right
  165.     # 向き固定でない場合
  166.     unless @direction_fix
  167.     # 左向きだった場合は右を、上向きだった場合は下を向く
  168.     @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  169.     end
  170.     # 下→右、右→下 のどちらかのコースが通行可能な場合
  171.     if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
  172.     (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
  173.     # 座標を更新
  174.     @x += 1
  175.     @y += 1
  176.     end
  177.     end
  178.     #--------------------------------------------------------------------------
  179.     # ● 左上に移動
  180.     #--------------------------------------------------------------------------
  181.     def move_upper_left
  182.     # 向き固定でない場合
  183.     unless @direction_fix
  184.     # 右向きだった場合は左を、下向きだった場合は上を向く
  185.     @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  186.     end
  187.     # 上→左、左→上 のどちらかのコースが通行可能な場合
  188.     if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
  189.     (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
  190.     # 座標を更新
  191.     @x -= 1
  192.     @y -= 1
  193.     end
  194.     end
  195.     #--------------------------------------------------------------------------
  196.     # ● 右上に移動
  197.     #--------------------------------------------------------------------------
  198.     def move_upper_right
  199.     # 向き固定でない場合
  200.     unless @direction_fix
  201.     # 左向きだった場合は右を、下向きだった場合は上を向く
  202.     @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  203.     end
  204.     # 上→右、右→上 のどちらかのコースが通行可能な場合
  205.     if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
  206.     (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
  207.     # 座標を更新
  208.     @x += 1
  209.     @y -= 1
  210.     end
  211.     end
  212.     attr_writer :move_speed
  213.     attr_writer :step_anime
  214.     end
  215.     module Spriteset_Map_Module
  216.     def setup_actor_character_sprites?
  217.     return @setup_actor_character_sprites_flag != nil
  218.     end
  219.     def setup_actor_character_sprites(characters)
  220.     if !setup_actor_character_sprites?
  221.     index_game_player = 0
  222.     @character_sprites.each_index do |i|
  223.     if @character_sprites[i].character.instance_of?(Game_Player)
  224.     index_game_player = i
  225.     break
  226.     end
  227.     end
  228.     for character in characters.reverse
  229.     @character_sprites.unshift(
  230.     Sprite_Character.new(@viewport1, character)
  231.     )
  232.     end
  233.     @setup_actor_character_sprites_flag = true
  234.     end
  235.     end
  236.     end
  237.     module Scene_Map_Module
  238.     def setup_actor_character_sprites(characters)
  239.     @spriteset.setup_actor_character_sprites(characters)
  240.     end
  241.     end
  242.     module Game_Party_Module
  243.     def set_transparent_actors(transparent)
  244.     @transparent = transparent
  245.     end
  246.     def setup_actor_character_sprites
  247.     if @characters == nil
  248.     @characters = []

  249.     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  250.     @characters.push(Game_Party_Actor.new)
  251.     end
  252.     end
  253.     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  254.     @characters[i - 1].setup($game_party.members[i])
  255.     end

  256.     if $scene.class.method_defined?('setup_actor_character_sprites')
  257.     $scene.setup_actor_character_sprites(@characters)
  258.     end
  259.     end
  260.     def update_party_actors
  261.     setup_actor_character_sprites
  262.     transparent = $game_player.transparent
  263.     if transparent == false
  264.     if TRANSPARENT_SWITCH
  265.     transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  266.     end
  267.     end
  268.     for character in @characters
  269.     character.transparent = transparent
  270.     if $game_player.dash?
  271.     character.move_speed = $game_player.move_speed*1.1#1.25
  272.     else
  273.     character.move_speed = $game_player.move_speed
  274.     end
  275.     character.step_anime = $game_player.step_anime
  276.     character.update
  277.     end
  278.     end
  279.     def moveto_party_actors( x, y )
  280.     setup_actor_character_sprites
  281.     for character in @characters
  282.     character.moveto( x, y )
  283.     end
  284.     if @move_list == nil
  285.     @move_list = []
  286.     end
  287.     move_list_setup
  288.     end
  289.     def move_party_actors
  290.     if @move_list == nil
  291.     @move_list = []
  292.     move_list_setup
  293.     end
  294.     @move_list.each_index do |i|
  295.     if @characters[i] != nil
  296.     case @move_list[i].type
  297.     when Input::DOWN
  298.     @characters[i].move_down(@move_list[i].args[0])
  299.     when Input::LEFT
  300.     @characters[i].move_left(@move_list[i].args[0])
  301.     when Input::RIGHT
  302.     @characters[i].move_right(@move_list[i].args[0])
  303.     when Input::UP
  304.     @characters[i].move_up(@move_list[i].args[0])
  305.     when DOWN_LEFT
  306.     @characters[i].move_lower_left
  307.     when DOWN_RIGHT
  308.     @characters[i].move_lower_right
  309.     when UP_LEFT
  310.     @characters[i].move_upper_left
  311.     when UP_RIGHT
  312.     @characters[i].move_upper_right
  313.     when JUMP
  314.     @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  315.     end
  316.     end
  317.     end
  318.     end
  319.     class Move_List_Element
  320.     def initialize(type,args)
  321.     @type = type
  322.     @args = args
  323.     end
  324.     def type() return @type end
  325.     def args() return @args end
  326.     end
  327.     def move_list_setup
  328.     for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  329.     @move_list[i] = nil
  330.     end
  331.     end
  332.     def add_move_list(type,*args)
  333.     @move_list.unshift(Move_List_Element.new(type,args)).pop
  334.     end
  335.     def move_down_party_actors(turn_enabled = true)
  336.     move_party_actors
  337.     add_move_list(Input::DOWN,turn_enabled)
  338.     end
  339.     def move_left_party_actors(turn_enabled = true)
  340.     move_party_actors
  341.     add_move_list(Input::LEFT,turn_enabled)
  342.     end
  343.     def move_right_party_actors(turn_enabled = true)
  344.     move_party_actors
  345.     add_move_list(Input::RIGHT,turn_enabled)
  346.     end
  347.     def move_up_party_actors(turn_enabled = true)
  348.     move_party_actors
  349.     add_move_list(Input::UP,turn_enabled)
  350.     end
  351.     def move_lower_left_party_actors
  352.     move_party_actors
  353.     add_move_list(DOWN_LEFT)
  354.     end
  355.     def move_lower_right_party_actors
  356.     move_party_actors
  357.     add_move_list(DOWN_RIGHT)
  358.     end
  359.     def move_upper_left_party_actors
  360.     move_party_actors
  361.     add_move_list(UP_LEFT)
  362.     end
  363.     def move_upper_right_party_actors
  364.     move_party_actors
  365.     add_move_list(UP_RIGHT)
  366.     end
  367.     def jump_party_actors(x_plus, y_plus)
  368.     move_party_actors
  369.     add_move_list(JUMP,x_plus, y_plus)
  370.     end
  371.     end
  372.     module Game_Player_Module
  373.     def update
  374.     $game_party.update_party_actors
  375.     super
  376.     end
  377.     def moveto( x, y )
  378.     $game_party.moveto_party_actors( x, y )
  379.     super( x, y )
  380.     end
  381.     def move_down(turn_enabled = true)
  382.     if new_passable?(@x, @y, Input::DOWN)
  383.     $game_party.move_down_party_actors(turn_enabled)
  384.     end
  385.     super(turn_enabled)
  386.     end
  387.     def move_left(turn_enabled = true)
  388.     if new_passable?(@x, @y, Input::LEFT)
  389.     $game_party.move_left_party_actors(turn_enabled)
  390.     end
  391.     super(turn_enabled)
  392.     end
  393.     def move_right(turn_enabled = true)
  394.     if new_passable?(@x, @y, Input::RIGHT)
  395.     $game_party.move_right_party_actors(turn_enabled)
  396.     end
  397.     super(turn_enabled)
  398.     end
  399.     def move_up(turn_enabled = true)
  400.     if new_passable?(@x, @y, Input::UP)
  401.     $game_party.move_up_party_actors(turn_enabled)
  402.     end
  403.     super(turn_enabled)
  404.     end
  405.     def move_lower_left
  406.     # 下→左、左→下 のどちらかのコースが通行可能な場合
  407.     if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
  408.     (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
  409.     $game_party.move_lower_left_party_actors
  410.     end
  411.     super
  412.     end
  413.     def move_lower_right
  414.     # 下→右、右→下 のどちらかのコースが通行可能な場合
  415.     if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
  416.     (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
  417.     $game_party.move_lower_right_party_actors
  418.     end
  419.     super
  420.     end
  421.     def move_upper_left
  422.     # 上→左、左→上 のどちらかのコースが通行可能な場合
  423.     if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
  424.     (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
  425.     $game_party.move_upper_left_party_actors
  426.     end
  427.     super
  428.     end
  429.     def move_upper_right
  430.     # 上→右、右→上 のどちらかのコースが通行可能な場合
  431.     if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
  432.     (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
  433.     $game_party.move_upper_right_party_actors
  434.     end
  435.     super
  436.     end
  437.     def jump(x_plus, y_plus)
  438.     # 新しい座標を計算
  439.     new_x = @x + x_plus
  440.     new_y = @y + y_plus
  441.     # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  442.     if (x_plus == 0 and y_plus == 0) or new_passable?(new_x, new_y, 0)
  443.     $game_party.jump_party_actors(x_plus, y_plus)
  444.     end
  445.     super(x_plus, y_plus)
  446.     end
  447.     attr_accessor :move_speed
  448.     attr_accessor :step_anime
  449.     end
  450.     end # module Train_Actor
  451.     class Game_Party
  452.     include Train_Actor::Game_Party_Module
  453.     end
  454.     class Game_Player
  455.     include Train_Actor::Game_Player_Module
  456.     end
  457.     class Spriteset_Map
  458.     include Train_Actor::Spriteset_Map_Module
  459.     end
  460.     class Scene_Map
  461.     include Train_Actor::Scene_Map_Module
  462.     end
  463.     class Game_Character
  464.     def new_passable?(x, y, d)
  465.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  466.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  467.     unless $game_map.valid?(new_x, new_y)
  468.     return false
  469.     end
  470.     x = $game_map.round_x(x)                        # 橫方向循環修正
  471.     y = $game_map.round_y(y)                        # 縱方向循環修正
  472.     return false unless $game_map.valid?(x, y)      # 地圖外?
  473.     return true if @through or debug_through?       # 穿越 ON?
  474.     return false unless map_passable?(new_x, new_y)         # 地圖不能通行?
  475.     return false if collide_with_characters?(new_x, new_y)  # 與角色衝突?
  476.     return true                                     # 可以通行
  477.     end
  478.   end
  479.   end
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部