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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
448 小时
注册时间
2011-10-9
帖子
184
跳转到指定楼层
1
发表于 2014-7-5 21:53:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
問題陳述:

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

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

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


謝謝,腳本如下:


RUBY 代码复制
  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.  
  15.     #是否使用停止跟隨的方法,也就是說,這裡false改為true的時候,如果TRANSPARENT_SWITCHES_INDEX
  16.     #開關打開,跟隨的人物就消失了(其實只是變成透明而已)
  17.  
  18.     TRANSPARENT_SWITCH = true
  19.     TRANSPARENT_SWITCHES_INDEX = 7 #顯示跟隨人物開關編號
  20.     #舉例:第一個為true,第二個為20,則打開20號開關,後面的人都沒了。
  21.  
  22.     #跟隨人數的最大數目,可以更改為2、3什麼的。
  23.     TRAIN_ACTOR_SIZE_MAX = 4
  24.  
  25.     # 定數
  26.     DOWN_LEFT = 1
  27.     DOWN_RIGHT = 3
  28.     UP_LEFT = 7
  29.     UP_RIGHT = 9
  30.     JUMP = 5
  31.  
  32.     class Game_Party_Actor < Game_Character
  33.     def initialize
  34.     super()
  35.     @through = true
  36.     end
  37.     def setup(actor)
  38.     if actor != nil
  39.     @character_index = actor.character_index
  40.     @character_name = actor.character_name
  41.     @priority_type = 1
  42.     else
  43.     @character_name = ""
  44.     @character_index = 0
  45.     @priority_type = 1
  46.     end
  47.     # 不透明度と合成方法を初期化
  48.     @opacity = 255
  49.     @blend_type = 0
  50.  
  51.  
  52.  
  53.  
  54.  
  55. #-----------------------------------------------------------------------------------   
  56.     def screen_z
  57.     if @priority_type == 2
  58.       result = 200
  59.     elsif @priority_type == 0
  60.       result = 60
  61.     elsif @tile_id > 0
  62.       pass = $game_map.passages[@tile_id]
  63.       if pass & 0x10 == 0x10    # [☆]
  64.         result = 160
  65.       else
  66.         result = 40
  67.       end
  68.     else
  69.       result = 100
  70.     end
  71.     return result - 1
  72.   end   
  73. #-----------------------------------------------------------------------------------  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.     end
  81.     #--------------------------------------------------------------------------
  82.     # ● 下に移動
  83.     # turn_enabled : その場での向き変更を許可するフラグ
  84.     #--------------------------------------------------------------------------
  85.     def move_down(turn_enabled = true)
  86.     # 下を向く
  87.     if turn_enabled
  88.     turn_down
  89.     end
  90.     # 通行可能な場合
  91.     if new_passable?(@x, @y, Input::DOWN)
  92.     # 下を向く
  93.     turn_down
  94.     # 座標を更新
  95.     @y += 1
  96.     end
  97.     end
  98.     #--------------------------------------------------------------------------
  99.     # ● 左に移動
  100.     # turn_enabled : その場での向き変更を許可するフラグ
  101.     #--------------------------------------------------------------------------
  102.     def move_left(turn_enabled = true)
  103.     # 左を向く
  104.     if turn_enabled
  105.     turn_left
  106.     end
  107.     # 通行可能な場合
  108.     if new_passable?(@x, @y, Input::LEFT)
  109.     # 左を向く
  110.     turn_left
  111.     # 座標を更新
  112.     @x -= 1
  113.     end
  114.     end
  115.     #--------------------------------------------------------------------------
  116.     # ● 右に移動
  117.     # turn_enabled : その場での向き変更を許可するフラグ
  118.     #--------------------------------------------------------------------------
  119.     def move_right(turn_enabled = true)
  120.     # 右を向く
  121.     if turn_enabled
  122.     turn_right
  123.     end
  124.     # 通行可能な場合
  125.     if new_passable?(@x, @y, Input::RIGHT)
  126.     # 右を向く
  127.     turn_right
  128.     # 座標を更新
  129.     @x += 1
  130.     end
  131.     end
  132.     #--------------------------------------------------------------------------
  133.     # ● 上に移動
  134.     # turn_enabled : その場での向き変更を許可するフラグ
  135.     #--------------------------------------------------------------------------
  136.     def move_up(turn_enabled = true)
  137.     # 上を向く
  138.     if turn_enabled
  139.     turn_up
  140.     end
  141.     # 通行可能な場合
  142.     if new_passable?(@x, @y, Input::UP)
  143.     # 上を向く
  144.     turn_up
  145.     # 座標を更新
  146.     @y -= 1
  147.     end
  148.     end
  149.     #--------------------------------------------------------------------------
  150.     # ● 左下に移動
  151.     #--------------------------------------------------------------------------
  152.     def move_lower_left
  153.     # 向き固定でない場合
  154.     unless @direction_fix
  155.     # 右向きだった場合は左を、上向きだった場合は下を向く
  156.     @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  157.     end
  158.     # 下→左、左→下 のどちらかのコースが通行可能な場合
  159.     if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
  160.     (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
  161.     # 座標を更新
  162.     @x -= 1
  163.     @y += 1
  164.     end
  165.     end
  166.     #--------------------------------------------------------------------------
  167.     # ● 右下に移動
  168.     #--------------------------------------------------------------------------
  169.     def move_lower_right
  170.     # 向き固定でない場合
  171.     unless @direction_fix
  172.     # 左向きだった場合は右を、上向きだった場合は下を向く
  173.     @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  174.     end
  175.     # 下→右、右→下 のどちらかのコースが通行可能な場合
  176.     if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
  177.     (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
  178.     # 座標を更新
  179.     @x += 1
  180.     @y += 1
  181.     end
  182.     end
  183.     #--------------------------------------------------------------------------
  184.     # ● 左上に移動
  185.     #--------------------------------------------------------------------------
  186.     def move_upper_left
  187.     # 向き固定でない場合
  188.     unless @direction_fix
  189.     # 右向きだった場合は左を、下向きだった場合は上を向く
  190.     @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  191.     end
  192.     # 上→左、左→上 のどちらかのコースが通行可能な場合
  193.     if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
  194.     (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
  195.     # 座標を更新
  196.     @x -= 1
  197.     @y -= 1
  198.     end
  199.     end
  200.     #--------------------------------------------------------------------------
  201.     # ● 右上に移動
  202.     #--------------------------------------------------------------------------
  203.     def move_upper_right
  204.     # 向き固定でない場合
  205.     unless @direction_fix
  206.     # 左向きだった場合は右を、下向きだった場合は上を向く
  207.     @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  208.     end
  209.     # 上→右、右→上 のどちらかのコースが通行可能な場合
  210.     if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
  211.     (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
  212.     # 座標を更新
  213.     @x += 1
  214.     @y -= 1
  215.     end
  216.     end
  217.     attr_writer :move_speed
  218.     attr_writer :step_anime
  219.     end
  220.     module Spriteset_Map_Module
  221.     def setup_actor_character_sprites?
  222.     return @setup_actor_character_sprites_flag != nil
  223.     end
  224.     def setup_actor_character_sprites(characters)
  225.     if !setup_actor_character_sprites?
  226.     index_game_player = 0
  227.     @character_sprites.each_index do |i|
  228.     if @character_sprites[i].character.instance_of?(Game_Player)
  229.     index_game_player = i
  230.     break
  231.     end
  232.     end
  233.     for character in characters.reverse
  234.     @character_sprites.unshift(
  235.     Sprite_Character.new(@viewport1, character)
  236.     )
  237.     end
  238.     @setup_actor_character_sprites_flag = true
  239.     end
  240.     end
  241.     end
  242.     module Scene_Map_Module
  243.     def setup_actor_character_sprites(characters)
  244.     @spriteset.setup_actor_character_sprites(characters)
  245.     end
  246.     end
  247.     module Game_Party_Module
  248.     def set_transparent_actors(transparent)
  249.     @transparent = transparent
  250.     end
  251.     def setup_actor_character_sprites
  252.     if @characters == nil
  253.     @characters = []
  254.  
  255.     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  256.     @characters.push(Game_Party_Actor.new)
  257.     end
  258.     end
  259.     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  260.     @characters[i - 1].setup($game_party.members[i])
  261.     end
  262.  
  263.     if $scene.class.method_defined?('setup_actor_character_sprites')
  264.     $scene.setup_actor_character_sprites(@characters)
  265.     end
  266.     end
  267.     def update_party_actors
  268.     setup_actor_character_sprites
  269.     transparent = $game_player.transparent
  270.     if transparent == false
  271.     if TRANSPARENT_SWITCH
  272.     transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  273.     end
  274.     end
  275.     for character in @characters
  276.     character.transparent = transparent
  277.     if $game_player.dash?
  278.     character.move_speed = $game_player.move_speed*1.1#1.25
  279.     else
  280.     character.move_speed = $game_player.move_speed
  281.     end
  282.     character.step_anime = $game_player.step_anime
  283.     character.update
  284.     end
  285.     end
  286.     def moveto_party_actors( x, y )
  287.     setup_actor_character_sprites
  288.     for character in @characters
  289.     character.moveto( x, y )
  290.     end
  291.     if @move_list == nil
  292.     @move_list = []
  293.     end
  294.     move_list_setup
  295.     end
  296.     def move_party_actors
  297.     if @move_list == nil
  298.     @move_list = []
  299.     move_list_setup
  300.     end
  301.     @move_list.each_index do |i|
  302.     if @characters[i] != nil
  303.     case @move_list[i].type
  304.     when Input::DOWN
  305.     @characters[i].move_down(@move_list[i].args[0])
  306.     when Input::LEFT
  307.     @characters[i].move_left(@move_list[i].args[0])
  308.     when Input::RIGHT
  309.     @characters[i].move_right(@move_list[i].args[0])
  310.     when Input::UP
  311.     @characters[i].move_up(@move_list[i].args[0])
  312.     when DOWN_LEFT
  313.     @characters[i].move_lower_left
  314.     when DOWN_RIGHT
  315.     @characters[i].move_lower_right
  316.     when UP_LEFT
  317.     @characters[i].move_upper_left
  318.     when UP_RIGHT
  319.     @characters[i].move_upper_right
  320.     when JUMP
  321.     @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  322.     end
  323.     end
  324.     end
  325.     end
  326.     class Move_List_Element
  327.     def initialize(type,args)
  328.     @type = type
  329.     @args = args
  330.     end
  331.     def type() return @type end
  332.     def args() return @args end
  333.     end
  334.     def move_list_setup
  335.     for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  336.     @move_list[i] = nil
  337.     end
  338.     end
  339.     def add_move_list(type,*args)
  340.     @move_list.unshift(Move_List_Element.new(type,args)).pop
  341.     end
  342.     def move_down_party_actors(turn_enabled = true)
  343.     move_party_actors
  344.     add_move_list(Input::DOWN,turn_enabled)
  345.     end
  346.     def move_left_party_actors(turn_enabled = true)
  347.     move_party_actors
  348.     add_move_list(Input::LEFT,turn_enabled)
  349.     end
  350.     def move_right_party_actors(turn_enabled = true)
  351.     move_party_actors
  352.     add_move_list(Input::RIGHT,turn_enabled)
  353.     end
  354.     def move_up_party_actors(turn_enabled = true)
  355.     move_party_actors
  356.     add_move_list(Input::UP,turn_enabled)
  357.     end
  358.     def move_lower_left_party_actors
  359.     move_party_actors
  360.     add_move_list(DOWN_LEFT)
  361.     end
  362.     def move_lower_right_party_actors
  363.     move_party_actors
  364.     add_move_list(DOWN_RIGHT)
  365.     end
  366.     def move_upper_left_party_actors
  367.     move_party_actors
  368.     add_move_list(UP_LEFT)
  369.     end
  370.     def move_upper_right_party_actors
  371.     move_party_actors
  372.     add_move_list(UP_RIGHT)
  373.     end
  374.     def jump_party_actors(x_plus, y_plus)
  375.     move_party_actors
  376.     add_move_list(JUMP,x_plus, y_plus)
  377.     end
  378.     end
  379.     module Game_Player_Module
  380.     def update
  381.     $game_party.update_party_actors
  382.     super
  383.     end
  384.     def moveto( x, y )
  385.     $game_party.moveto_party_actors( x, y )
  386.     super( x, y )
  387.     end
  388.     def move_down(turn_enabled = true)
  389.     if new_passable?(@x, @y, Input::DOWN)
  390.     $game_party.move_down_party_actors(turn_enabled)
  391.     end
  392.     super(turn_enabled)
  393.     end
  394.     def move_left(turn_enabled = true)
  395.     if new_passable?(@x, @y, Input::LEFT)
  396.     $game_party.move_left_party_actors(turn_enabled)
  397.     end
  398.     super(turn_enabled)
  399.     end
  400.     def move_right(turn_enabled = true)
  401.     if new_passable?(@x, @y, Input::RIGHT)
  402.     $game_party.move_right_party_actors(turn_enabled)
  403.     end
  404.     super(turn_enabled)
  405.     end
  406.     def move_up(turn_enabled = true)
  407.     if new_passable?(@x, @y, Input::UP)
  408.     $game_party.move_up_party_actors(turn_enabled)
  409.     end
  410.     super(turn_enabled)
  411.     end
  412.     def move_lower_left
  413.     # 下→左、左→下 のどちらかのコースが通行可能な場合
  414.     if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
  415.     (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
  416.     $game_party.move_lower_left_party_actors
  417.     end
  418.     super
  419.     end
  420.     def move_lower_right
  421.     # 下→右、右→下 のどちらかのコースが通行可能な場合
  422.     if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
  423.     (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
  424.     $game_party.move_lower_right_party_actors
  425.     end
  426.     super
  427.     end
  428.     def move_upper_left
  429.     # 上→左、左→上 のどちらかのコースが通行可能な場合
  430.     if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
  431.     (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
  432.     $game_party.move_upper_left_party_actors
  433.     end
  434.     super
  435.     end
  436.     def move_upper_right
  437.     # 上→右、右→上 のどちらかのコースが通行可能な場合
  438.     if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
  439.     (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
  440.     $game_party.move_upper_right_party_actors
  441.     end
  442.     super
  443.     end
  444.     def jump(x_plus, y_plus)
  445.     # 新しい座標を計算
  446.     new_x = @x + x_plus
  447.     new_y = @y + y_plus
  448.     # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  449.     if (x_plus == 0 and y_plus == 0) or new_passable?(new_x, new_y, 0)
  450.     $game_party.jump_party_actors(x_plus, y_plus)
  451.     end
  452.     super(x_plus, y_plus)
  453.     end
  454.     attr_accessor :move_speed
  455.     attr_accessor :step_anime
  456.     end
  457.     end # module Train_Actor
  458.     class Game_Party
  459.     include Train_Actor::Game_Party_Module
  460.     end
  461.     class Game_Player
  462.     include Train_Actor::Game_Player_Module
  463.     end
  464.     class Spriteset_Map
  465.     include Train_Actor::Spriteset_Map_Module
  466.     end
  467.     class Scene_Map
  468.     include Train_Actor::Scene_Map_Module
  469.     end
  470.     class Game_Character
  471.     def new_passable?(x, y, d)
  472.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  473.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  474.     unless $game_map.valid?(new_x, new_y)
  475.     return false
  476.     end
  477.     x = $game_map.round_x(x)                        # 橫方向循環修正
  478.     y = $game_map.round_y(y)                        # 縱方向循環修正
  479.     return false unless $game_map.valid?(x, y)      # 地圖外?
  480.     return true if @through or debug_through?       # 穿越 ON?
  481.     return false unless map_passable?(new_x, new_y)         # 地圖不能通行?
  482.     return false if collide_with_characters?(new_x, new_y)  # 與角色衝突?
  483.     return true                                     # 可以通行
  484.     end
  485.   end
  486.   end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-5-9 01:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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