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

Project1

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

[已经过期] 跪求人物跟随系统(我在华为网盘上下不了)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
390
在线时间
2 小时
注册时间
2014-1-10
帖子
1
跳转到指定楼层
1
发表于 2014-1-27 16:56:26 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
我是新手,我在华为网盘上下载不了人物跟随系统教程,请大家帮帮忙

Lv1.梦旅人

梦石
0
星屑
68
在线时间
208 小时
注册时间
2013-8-8
帖子
1296
3
发表于 2014-1-29 10:20:24 | 只看该作者
  1. # rgss-lib
  2. =begin

  3. DQシステムスクリプト Train_Actor
  4. Author:: yf30 at users.sourceforge.jp (http://sourceforge.jp/users/yf30/)
  5. Date:: 2009/02/26
  6. Copyright:: Copyright (C) 2004-2009 rgss-lib
  7. URL:: http://sourceforge.jp/projects/rgss-lib/

  8. #    modified by 熊的选民 chosen of bear

  9. =end
  10.          
  11. # dq
  12.          
  13. # train_actor
  14.          
  15. # Config.rb
  16. #==============================================================================
  17. # ■ Train_Actor::Config
  18. #------------------------------------------------------------------------------
  19. # マップ上でアクターを隊列移動させる
  20. #==============================================================================

  21. module Train_Actor

  22.   # ●透明状態用スイッチ設定
  23.   # true だとスイッチ制御を行う
  24.    #TRANSPARENT_SWITCH = true
  25.   TRANSPARENT_SWITCH = false

  26.   # ●透明状態用スイッチ番号
  27.   # TRANSPARENT_SWITCH が true で、この番号のスイッチがONだと透明になる
  28.   TRANSPARENT_SWITCHES_INDEX = 19

  29.   # ●アクターの最大数
  30.   # 将来的に多人数パーティが出来るようになったら…
  31.   TRAIN_ACTOR_SIZE_MAX = 6

  32.   # 死亡時のキャラクターグラフィック名
  33.   #DEAD_CHARACTER_NAME = "Coffin"
  34.   DEAD_CHARACTER_NAME = ""

  35.   # 定数
  36.   DOWN_LEFT  = 1
  37.   DOWN_RIGHT = 3
  38.   UP_LEFT    = 7
  39.   UP_RIGHT   = 9
  40.   JUMP       = 5
  41.   STOP       = 0

  42. end
  43.        
  44. # rgss
  45.          
  46. # Game_Event_Module.rb
  47. # Game_Event_Module
  48. # マップ上でアクターを隊列移動させる
  49. # Author:: fukuyama
  50. # Date:: 2006/03/05
  51. # Copyright:: Copyright (C) 2005 fukuyama

  52. module Train_Actor

  53.   module Game_Event_Module
  54.     # 通行可能判定
  55.     # x:: X 座標
  56.     # y:: Y 座標
  57.     # d:: 方向 (0,2,4,6,8)  ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用)
  58.     # return:: 通行不可 false 可能 true
  59.     def passable?(x, y, d)
  60.       result = super(x, y, d)
  61.       return result if @through
  62.       if result
  63.         # 新しい座標を求める
  64.         new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  65.         new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  66.         # トレインアクターのループ
  67.         for actor in $game_party.characters
  68.           # 表示されている場合
  69.           if (not actor.character_name.empty?) and (not actor.transparent)
  70.             # アクターの座標が移動先と一致した場合
  71.             if actor.x == new_x and actor.y == new_y
  72.               # 自分がイベントの場合
  73.               if self != $game_player
  74.                 # 通行不可
  75.                 return false
  76.               end
  77.             end
  78.           end
  79.         end
  80.       end
  81.       return result
  82.     end
  83.   end

  84. end

  85. class Game_Event
  86.   include Train_Actor::Game_Event_Module
  87. end

  88. # Game_Party_Module.rb
  89. # Train_Actor::Game_Party_Module
  90. # Game_Party用隊列歩行モジュール
  91. # Author:: fukuyama
  92. # Date:: 2007/12/31
  93. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  94. module Train_Actor

  95.   module Game_Party_Module
  96.     attr_reader :characters
  97.     def dead_actor_include?
  98.       for actor in actors
  99.         if actor.dead?
  100.           return true
  101.         end
  102.       end
  103.       return false
  104.     end
  105.    
  106.     def get_active_party_order
  107.       if not dead_actor_include?
  108.         return actors
  109.       end
  110.       alive_actors = []
  111.       dead_actors = []
  112.       for actor in actors
  113.         if actor.dead?
  114.           dead_actors.push actor
  115.         else
  116.           alive_actors.push actor
  117.         end
  118.       end
  119.       return alive_actors + dead_actors
  120.     end
  121.    
  122.     def setup_actor_character_sprites
  123.       if @characters.nil?
  124.         @characters = []
  125.         for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  126.           @characters.push(Game_Party_Actor.new(i - 1))
  127.         end
  128.       end
  129.       
  130.       if @characters.size < TRAIN_ACTOR_SIZE_MAX
  131.         for i in @characters.size + 1 ... TRAIN_ACTOR_SIZE_MAX
  132.           @characters.push(Game_Party_Actor.new(i - 1))
  133.         end
  134.       end
  135.       
  136.       setup_actors = get_active_party_order
  137.       for i in 1 .. @characters.size
  138.         @characters[i - 1].setup(setup_actors[i])
  139.       end
  140.       if $scene.class.method_defined?('setup_actor_character_sprites')
  141.         $scene.setup_actor_character_sprites
  142.       end
  143.     end
  144.    
  145.     def transparent_switch
  146.       if TRANSPARENT_SWITCH
  147.         unless $game_player.transparent
  148.           return $game_switches[TRANSPARENT_SWITCHES_INDEX]
  149.         end
  150.       end
  151.       return $game_player.transparent
  152.     end
  153.    
  154.     def update_party_actors
  155.       setup_actor_character_sprites
  156.       transparent = transparent_switch
  157.       for character in @characters
  158.         character.transparent = transparent
  159.         character.update
  160.       end
  161.     end
  162.    
  163.     #cob
  164.     def moveto_party_actors(x, y)
  165.       setup_actor_character_sprites
  166.       @move_list = []
  167.       move_list_setup      
  168.       follow = true
  169.       for character in @characters
  170.         #character.stop_anime_when_transferring
  171.         if follow
  172.           if $game_player.passable?(x, y, 10 - $game_player.direction)
  173.             case $game_player.direction
  174.             when 2
  175.               y -= 1
  176.               add_move_list(Input::DOWN)
  177.             when 4
  178.               x += 1
  179.               add_move_list(Input::LEFT)
  180.             when 6
  181.               x -= 1
  182.               add_move_list(Input::RIGHT)
  183.             when 8
  184.               y += 1
  185.               add_move_list(Input::UP)
  186.             end            
  187.           else
  188.             follow = false
  189.           end
  190.         end
  191.         #character.direction = $game_player.direction
  192.         character.moveto(x, y)
  193.       end
  194.       
  195.       #if $game_temp.player_close_door
  196.       #  if $game_party.actors.size > 1
  197.       #    @characters[$game_party.actors.size - 2].direction = 10 - $game_player.direction
  198.       #    $game_player.direction_fix = true
  199.       #  else
  200.       #    $game_player.direction = 10 - $game_player.direction
  201.       #  end        
  202.       #  $game_temp.player_close_door = false
  203.       #end        
  204.     end
  205.    
  206.     def move_party_actors
  207.       if @move_list == nil
  208.         @move_list = []
  209.         move_list_setup
  210.       end
  211.       @move_list.each_index do |i|
  212.         if not @characters[i].nil?
  213.           @characters[i].add_move_list_element(@move_list[i])
  214.         end
  215.       end
  216.     end
  217.    
  218.     #cob
  219.     def turn_left_party_actors
  220.       for character in @characters
  221.         character.turn_left
  222.       end      
  223.     end
  224.    
  225.     #cob
  226.     def initialize_location
  227.       for character in @characters
  228.         character.moveto($game_player.x, $game_player.y)
  229.       end      
  230.     end
  231.    
  232.     class Move_List_Element
  233.       def initialize(type,args)
  234.         @type = type
  235.         @args = args
  236.       end
  237.       def type() return @type end
  238.       def args() return @args end
  239.     end
  240.     def move_list_setup
  241.       for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  242.         @move_list[i] = nil
  243.       end
  244.     end
  245.     def add_move_list(type,*args)
  246.       @move_list.unshift(Move_List_Element.new(type,args)).pop
  247.     end
  248.     def move_down_party_actors(turn_enabled = true)
  249.       move_party_actors
  250.       add_move_list(Input::DOWN,turn_enabled)
  251.     end
  252.     def move_left_party_actors(turn_enabled = true)
  253.       move_party_actors
  254.       add_move_list(Input::LEFT,turn_enabled)
  255.     end
  256.     def move_right_party_actors(turn_enabled = true)
  257.       move_party_actors
  258.       add_move_list(Input::RIGHT,turn_enabled)
  259.     end
  260.     def move_up_party_actors(turn_enabled = true)
  261.       move_party_actors
  262.       add_move_list(Input::UP,turn_enabled)
  263.     end
  264.     def move_lower_left_party_actors
  265.       move_party_actors
  266.       add_move_list(DOWN_LEFT)
  267.     end
  268.     def move_lower_right_party_actors
  269.       move_party_actors
  270.       add_move_list(DOWN_RIGHT)
  271.     end
  272.     def move_upper_left_party_actors
  273.       move_party_actors
  274.       add_move_list(UP_LEFT)
  275.     end
  276.     def move_upper_right_party_actors
  277.       move_party_actors
  278.       add_move_list(UP_RIGHT)
  279.     end
  280.     def jump_party_actors(x_plus, y_plus)
  281.       move_party_actors
  282.       add_move_list(JUMP,x_plus, y_plus)
  283.       move_stop_party_actors
  284.     end
  285.     def move_stop_party_actors
  286.       actors.each do |a|
  287.         move_party_actors
  288.         add_move_list(STOP)
  289.       end
  290.     end
  291.   end

  292. end

  293. class Game_Party
  294.   include Train_Actor::Game_Party_Module

  295.   # アクターを加える
  296.   # actor_id:: アクター ID
  297.   def add_actor(actor_id)
  298.     # アクターを取得
  299.     actor = $game_actors[actor_id]
  300.     # パーティ人数が 4 人未満で、このアクターがパーティにいない場合
  301.     if @actors.size < Train_Actor::TRAIN_ACTOR_SIZE_MAX and not @actors.include?(actor)
  302.       # アクターを追加
  303.       @actors.push(actor)
  304.       # プレイヤーをリフレッシュ
  305.       $game_player.refresh
  306.     end
  307.   end
  308. end

  309. # Game_Player_Module.rb
  310. # Train_Actor::Game_Player_Module
  311. # Game_Player用隊列歩行モジュール
  312. # Author:: fukuyama
  313. # Date:: 2007/12/31
  314. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  315. module Train_Actor

  316.   module Game_Player_Module
  317.     attr_reader :move_speed
  318.     attr_reader :step_anime
  319.     attr_accessor :direction_fix

  320.     def update_party_actors
  321.       if $game_party.actors.empty?
  322.         return
  323.       end
  324.       $game_party.update_party_actors
  325.       
  326.       actor = $game_party.actors[0]
  327.       if not actor.dead?
  328.         if not @prev_dead.nil?
  329.           @character_name = actor.character_name
  330.           @character_hue = actor.character_hue
  331.           @prev_dead = nil
  332.         end
  333.         return
  334.       end
  335.       @prev_dead = true
  336.       $game_party.actors.each do |actor|
  337.         if not actor.dead?
  338.           @character_name = actor.character_name
  339.           @character_hue = actor.character_hue
  340.           break
  341.         end
  342.       end
  343.     end
  344.     def update
  345.       update_party_actors
  346.       super
  347.     end
  348.    
  349.     #cob
  350.     def moveto(x, y)
  351.       #if $game_temp.move_party
  352.         $game_party.moveto_party_actors(x, y)
  353.         #stop_anime_when_transferring
  354.       #else
  355.       #  $game_temp.move_party = true
  356.       #end
  357.       super(x, y)      
  358.     end
  359.    
  360.     #cob
  361.     def turn_toward_player
  362.       @direction_fix = true
  363.       for event in $game_party.characters
  364.         event.turn_toward_player        
  365.       end
  366.     end      
  367.    
  368.     def move_down(turn_enabled = true)
  369.       if passable?(@x, @y, Input::DOWN)
  370.         $game_party.move_down_party_actors(turn_enabled)
  371.       end
  372.       super(turn_enabled)
  373.     end
  374.     def move_left(turn_enabled = true)
  375.       if passable?(@x, @y, Input::LEFT)
  376.         $game_party.move_left_party_actors(turn_enabled)
  377.       end
  378.       super(turn_enabled)
  379.     end
  380.     def move_right(turn_enabled = true)
  381.       if passable?(@x, @y, Input::RIGHT)
  382.         $game_party.move_right_party_actors(turn_enabled)
  383.       end
  384.       super(turn_enabled)
  385.     end
  386.     def move_up(turn_enabled = true)
  387.       if passable?(@x, @y, Input::UP)
  388.         $game_party.move_up_party_actors(turn_enabled)
  389.       end
  390.       super(turn_enabled)
  391.     end
  392.     def move_lower_left
  393.       # 下→左、左→下 のどちらかのコースが通行可能な場合
  394.       if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  395.        (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  396.         $game_party.move_lower_left_party_actors
  397.       end
  398.       super
  399.     end
  400.     def move_lower_right
  401.       # 下→右、右→下 のどちらかのコースが通行可能な場合
  402.       if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  403.        (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  404.         $game_party.move_lower_right_party_actors
  405.       end
  406.       super
  407.     end
  408.     def move_upper_left
  409.       # 上→左、左→上 のどちらかのコースが通行可能な場合
  410.       if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  411.        (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  412.         $game_party.move_upper_left_party_actors
  413.       end
  414.       super
  415.     end
  416.     def move_upper_right
  417.       # 上→右、右→上 のどちらかのコースが通行可能な場合
  418.       if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  419.        (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  420.         $game_party.move_upper_right_party_actors
  421.       end
  422.       super
  423.     end
  424.     def jump(x_plus, y_plus)
  425.       # 新しい座標を計算
  426.       new_x = @x + x_plus
  427.       new_y = @y + y_plus
  428.       # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  429.       if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  430.         $game_party.jump_party_actors(x_plus, y_plus)
  431.       end
  432.       super(x_plus, y_plus)
  433.     end
  434.   end

  435. end

  436. class Game_Player
  437.   include Train_Actor::Game_Player_Module
  438. end

  439. # Scene_Map_Module.rb
  440. # Train_Actor::Scene_Map_Module
  441. # Scene_Map用隊列歩行モジュール
  442. # Author:: fukuyama
  443. # Date:: 2007/12/31
  444. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  445. module Train_Actor

  446.   module Scene_Map_Module
  447.     def setup_actor_character_sprites
  448.       @spriteset.setup_actor_character_sprites
  449.     end
  450.   end

  451. end

  452. class Scene_Map
  453.   include Train_Actor::Scene_Map_Module
  454. end

  455. # Spriteset_Map_Module.rb
  456. # Train_Actor::Spriteset_Map_Module
  457. # Spriteset_Map用隊列歩行モジュール
  458. # Author:: fukuyama
  459. # Date:: 2007/12/31
  460. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  461. module Train_Actor

  462.   module Spriteset_Map_Module
  463.     def setup_actor_character_sprites?
  464.       return @setup_actor_character_sprites_flag != nil
  465.     end
  466.    
  467.     def setup_actor_character_sprites
  468.       return unless $game_party.characters
  469.       if not setup_actor_character_sprites?
  470.         for character in $game_party.characters.reverse
  471.           @character_sprites.unshift(Sprite_Character.new(@viewport1, character))
  472.         end
  473.         @setup_actor_character_sprites_flag = true
  474.       end
  475.     end
  476.   end

  477. end

  478. class Spriteset_Map
  479.   include Train_Actor::Spriteset_Map_Module
  480. end
  481.   
  482. # Game_Party_Actor.rb
  483. # Train_Actor::Game_Party_Actor
  484. # マップ上のパーティ用キャラクター
  485. # Author:: fukuyama
  486. # Date:: 2007/12/31
  487. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  488. module Train_Actor

  489.   class Game_Party_Actor < Game_Character
  490.     def initialize(character_index)
  491.       super()
  492.       @character_index = character_index
  493.       @character_wait = 0
  494.       @through = true
  495.       # 不透明度と合成方法を初期化
  496.       [url=home.php?mod=space&uid=316553]@opacity[/url] = 255
  497.       @blend_type = 0
  498.       @move_list = []
  499.     end
  500.    
  501.     def setup(actor)
  502.       # キャラクターのファイル名と色相を設定
  503.       if actor.nil?
  504.         @character_name = ""
  505.         @character_hue = 0
  506.       elsif not actor.dead? # 死んでる場合とりあえず、消しとこ…
  507.         @character_name = actor.character_name
  508.         @character_hue = actor.character_hue
  509.       else
  510.         @character_name = DEAD_CHARACTER_NAME
  511.         @character_hue = 0
  512.       end
  513.     end
  514.    
  515.     def update
  516.       @move_speed = $game_player.move_speed
  517.       @step_anime = $game_player.step_anime
  518.       @opacity = $game_player.opacity
  519.       @blend_type = $game_player.blend_type
  520.       @direction_fix = $game_player.direction_fix
  521.       #if @direction_fix
  522.       #  @direction = $game_player.direction
  523.       #end
  524.       update_move_list()
  525.       super
  526.     end
  527.    
  528.     def screen_z(height = 0)
  529.       if $game_player.screen_z(height) == 999
  530.         return 998
  531.       end
  532.       if $game_player.x == @x and $game_player.y == @y
  533.         super(height) - 1
  534.       else
  535.         super(height)
  536.       end
  537.     end
  538.    
  539.     def add_move_list_element(element)
  540.       @move_list.push(element)
  541.       if @move_list.size == 1
  542.         update_move_list()
  543.       end
  544.     end
  545.    
  546.     def move_list_size
  547.       return @move_list.size
  548.     end
  549.    
  550.     def update_move_list()
  551.       return if moving?
  552.       
  553.       if @move_list.empty?
  554.         @direction = $game_player.direction unless @direction_fix
  555.         return
  556.       end
  557.       
  558.       if @move_list[0].type == STOP
  559.         if @character_index != 0
  560.           character = $game_party.characters[@character_index - 1]
  561.           if character.x == @x and character.y == @y and character.direction == @direction
  562.             @character_wait = 128 / (2 ** @move_speed) + 1
  563.             while character.move_list_size < @move_list.size and @move_list[0].type == STOP
  564.               @move_list.shift
  565.             end
  566.           end
  567.         end
  568.       else
  569.         @character_wait = 0
  570.       end
  571.       
  572.       if @character_wait > 0
  573.         @character_wait -= 1
  574.         return
  575.       end
  576.       
  577.       element = @move_list.shift
  578.       while element.type == STOP
  579.         element = @move_list.shift
  580.       end
  581.       
  582.       case element.type
  583.       when Input::DOWN
  584.         move_down(element.args[0])
  585.       when Input::LEFT
  586.         move_left(element.args[0])
  587.       when Input::RIGHT
  588.         move_right(element.args[0])
  589.       when Input::UP
  590.         move_up(element.args[0])
  591.       when DOWN_LEFT
  592.         move_lower_left
  593.       when DOWN_RIGHT
  594.         move_lower_right
  595.       when UP_LEFT
  596.         move_upper_left
  597.       when UP_RIGHT
  598.         move_upper_right
  599.       when JUMP
  600.         jump(element.args[0],element.args[1])
  601.       end
  602.     end
  603.    
  604.     def moveto( x, y )
  605.       @move_list.clear
  606.       super(x, y)
  607.     end
  608.     #--------------------------------------------------------------------------
  609.     # ● 下に移動
  610.     #     turn_enabled : その場での向き変更を許可するフラグ
  611.     #--------------------------------------------------------------------------
  612.     def move_down(turn_enabled = true)
  613.       # 下を向く
  614.       if turn_enabled
  615.         turn_down
  616.       end
  617.       # 通行可能な場合
  618.       if passable?(@x, @y, Input::DOWN)
  619.         # 下を向く
  620.         turn_down
  621.         # 座標を更新
  622.         @y = (@y + 1 + $game_map.height) % ($game_map.height)
  623.         @real_y = (@y - 1) * 128
  624.       end
  625.     end
  626.     #--------------------------------------------------------------------------
  627.     # ● 左に移動
  628.     #     turn_enabled : その場での向き変更を許可するフラグ
  629.     #--------------------------------------------------------------------------
  630.     def move_left(turn_enabled = true)
  631.       # 左を向く
  632.       if turn_enabled
  633.         turn_left
  634.       end
  635.       # 通行可能な場合
  636.       if passable?(@x, @y, Input::LEFT)
  637.         # 左を向く
  638.         turn_left
  639.         # 座標を更新
  640.         @x = (@x - 1 + $game_map.width) % ($game_map.width)
  641.         @real_x = (@x + 1) * 128
  642.       end
  643.     end
  644.     #--------------------------------------------------------------------------
  645.     # ● 右に移動
  646.     #     turn_enabled : その場での向き変更を許可するフラグ
  647.     #--------------------------------------------------------------------------
  648.     def move_right(turn_enabled = true)
  649.       # 右を向く
  650.       if turn_enabled
  651.         turn_right
  652.       end
  653.       # 通行可能な場合
  654.       if passable?(@x, @y, Input::RIGHT)
  655.         # 右を向く
  656.         turn_right
  657.         # 座標を更新
  658.         @x = (@x + 1 + $game_map.width) % ($game_map.width)
  659.         @real_x = (@x - 1) * 128
  660.       end
  661.     end
  662.     #--------------------------------------------------------------------------
  663.     # ● 上に移動
  664.     #     turn_enabled : その場での向き変更を許可するフラグ
  665.     #--------------------------------------------------------------------------
  666.     def move_up(turn_enabled = true)
  667.       # 上を向く
  668.       if turn_enabled
  669.         turn_up
  670.       end
  671.       # 通行可能な場合
  672.       if passable?(@x, @y, Input::UP)
  673.         # 上を向く
  674.         turn_up
  675.         # 座標を更新
  676.         @y = (@y - 1 + $game_map.height) % ($game_map.height)
  677.         @real_y = (@y + 1) * 128
  678.       end
  679.     end
  680.   end

  681. end
  682.    
复制代码

评分

参与人数 1星屑 +90 收起 理由
myownroc + 90 塞糖

查看全部评分

我已经没有兴趣认真做游戏了……只能胡扯
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
865 小时
注册时间
2010-6-27
帖子
131
2
发表于 2014-1-27 17:29:04 | 只看该作者
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

# ————————————————————————————————————

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

#
# Train_Actor
#
# [email protected]
# http://www4.big.or.jp/~fukuyama/rgss/Train_Actor.txt
#

module Train_Actor




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





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





# 定数
#Input::DOWN = 2
#Input::LEFT = 4
#Input::RIGHT = 6
#Input::UP = 6
DOWN_LEFT = 1
DOWN_RIGHT = 3
UP_LEFT = 7
UP_RIGHT = 9
JUMP = 5

class Game_Party_Actor < Game_Character
def initialize
super()
@through = true
end
def setup(actor)
# キャラクターのファイル名と色相を設定
if actor != nil
@character_name = actor.character_name
@character_hue = actor.character_hue
else
@character_name = ""
@character_hue = 0
end
# 不透明度と合成方法を初期化
@opacity = 255
@blend_type = 0
end
def screen_z(height = 0)
if $game_player.x == @x and $game_player.y == @y
return $game_player.screen_z(height) - 1
end
super(height)
end
#--------------------------------------------------------------------------
# ● 下に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# 下を向く
if turn_enabled
turn_down
end
# 通行可能な場合
if passable?(@x, @y, Input::DOWN)
# 下を向く
turn_down
# 座標を更新
@y += 1
end
end
#--------------------------------------------------------------------------
# ● 左に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# 左を向く
if turn_enabled
turn_left
end
# 通行可能な場合
if passable?(@x, @y, Input::LEFT)
# 左を向く
turn_left
# 座標を更新
@x -= 1
end
end
#--------------------------------------------------------------------------
# ● 右に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# 右を向く
if turn_enabled
turn_right
end
# 通行可能な場合
if passable?(@x, @y, Input::RIGHT)
# 右を向く
turn_right
# 座標を更新
@x += 1
end
end
#--------------------------------------------------------------------------
# ● 上に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# 上を向く
if turn_enabled
turn_up
end
# 通行可能な場合
if passable?(@x, @y, Input::UP)
# 上を向く
turn_up
# 座標を更新
@y -= 1
end
end
#--------------------------------------------------------------------------
# ● 左下に移動
#--------------------------------------------------------------------------
def move_lower_left
# 向き固定でない場合
unless @direction_fix
# 右向きだった場合は左を、上向きだった場合は下を向く
@direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
end
# 下→左、左→下 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
# 座標を更新
@x -= 1
@y += 1
end
end
#--------------------------------------------------------------------------
# ● 右下に移動
#--------------------------------------------------------------------------
def move_lower_right
# 向き固定でない場合
unless @direction_fix
# 左向きだった場合は右を、上向きだった場合は下を向く
@direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
end
# 下→右、右→下 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
# 座標を更新
@x += 1
@y += 1
end
end
#--------------------------------------------------------------------------
# ● 左上に移動
#--------------------------------------------------------------------------
def move_upper_left
# 向き固定でない場合
unless @direction_fix
# 右向きだった場合は左を、下向きだった場合は上を向く
@direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
end
# 上→左、左→上 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
# 座標を更新
@x -= 1
@y -= 1
end
end
#--------------------------------------------------------------------------
# ● 右上に移動
#--------------------------------------------------------------------------
def move_upper_right
# 向き固定でない場合
unless @direction_fix
# 左向きだった場合は右を、下向きだった場合は上を向く
@direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
end
# 上→右、右→上 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
# 座標を更新
@x += 1
@y -= 1
end
end
attr_writer :move_speed
attr_writer :step_anime
end
module Spriteset_Map_Module
def setup_actor_character_sprites?
return @setup_actor_character_sprites_flag != nil
end
def setup_actor_character_sprites(characters)
if !setup_actor_character_sprites?
index_game_player = 0
@character_sprites.each_index do |i|
if @character_sprites.character.instance_of?(Game_Player)
index_game_player = i
break
end
end
for character in characters.reverse
@character_sprites.unshift(
Sprite_Character.new(@viewport1, character)
)
end
@setup_actor_character_sprites_flag = true
end
end
end
module Scene_Map_Module
def setup_actor_character_sprites(characters)
@spriteset.setup_actor_character_sprites(characters)
end
end
module Game_Party_Module
def set_transparent_actors(transparent)
@transparent = transparent
end
def setup_actor_character_sprites
if @characters == nil
@characters = []
for i in 1 ... TRAIN_ACTOR_SIZE_MAX
@characters.push(Game_Party_Actor.new)
end
end
for i in 1 ... TRAIN_ACTOR_SIZE_MAX
next if @characters[i-1].nil?
@characters[i - 1].setup(actors)
end
if $scene.class.method_defined?('setup_actor_character_sprites')
$scene.setup_actor_character_sprites(@characters)
end
end
def update_party_actors
setup_actor_character_sprites
transparent = $game_player.transparent
if transparent == false
if TRANSPARENT_SWITCH
transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
end
end
for character in @characters
character.transparent = transparent
character.move_speed = $game_player.move_speed
character.step_anime = $game_player.step_anime
character.update
end
end
def moveto_party_actors( x, y )
setup_actor_character_sprites
for character in @characters
character.moveto( x, y )
end
if @move_list == nil
@move_list = []
end
move_list_setup
end
def move_party_actors
if @move_list == nil
@move_list = []
move_list_setup
end
@move_list.each_index do |i|
if @characters != nil
case @move_list.type
when Input::DOWN
@characters.move_down(@move_list.args[0])
when Input::LEFT
@characters.move_left(@move_list.args[0])
when Input::RIGHT
@characters.move_right(@move_list.args[0])
when Input::UP
@characters.move_up(@move_list.args[0])
when DOWN_LEFT
@characters.move_lower_left
when DOWN_RIGHT
@characters.move_lower_right
when UP_LEFT
@characters.move_upper_left
when UP_RIGHT
@characters.move_upper_right
when JUMP
@characters.jump(@move_list.args[0],@move_list.args[1])
end
end
end
end
class Move_List_Element
def initialize(type,args)
@type = type
@args = args
end
def type() return @type end
def args() return @args end
end
def move_list_setup
for i in 0 .. TRAIN_ACTOR_SIZE_MAX
@move_list = nil
end
end
def add_move_list(type,*args)
@move_list.unshift(Move_List_Element.new(type,args)).pop
end
def move_down_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::DOWN,turn_enabled)
end
def move_left_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::LEFT,turn_enabled)
end
def move_right_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::RIGHT,turn_enabled)
end
def move_up_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::UP,turn_enabled)
end
def move_lower_left_party_actors
move_party_actors
add_move_list(DOWN_LEFT)
end
def move_lower_right_party_actors
move_party_actors
add_move_list(DOWN_RIGHT)
end
def move_upper_left_party_actors
move_party_actors
add_move_list(UP_LEFT)
end
def move_upper_right_party_actors
move_party_actors
add_move_list(UP_RIGHT)
end
def jump_party_actors(x_plus, y_plus)
move_party_actors
add_move_list(JUMP,x_plus, y_plus)
end
end
module Game_Player_Module
def update
$game_party.update_party_actors
super
end
def moveto( x, y )
$game_party.moveto_party_actors( x, y )
super( x, y )
end
def move_down(turn_enabled = true)
if passable?(@x, @y, Input::DOWN)
$game_party.move_down_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_left(turn_enabled = true)
if passable?(@x, @y, Input::LEFT)
$game_party.move_left_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_right(turn_enabled = true)
if passable?(@x, @y, Input::RIGHT)
$game_party.move_right_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_up(turn_enabled = true)
if passable?(@x, @y, Input::UP)
$game_party.move_up_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_lower_left
# 下→左、左→下 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
$game_party.move_lower_left_party_actors
end
super
end
def move_lower_right
# 下→右、右→下 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
$game_party.move_lower_right_party_actors
end
super
end
def move_upper_left
# 上→左、左→上 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
$game_party.move_upper_left_party_actors
end
super
end
def move_upper_right
# 上→右、右→上 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
$game_party.move_upper_right_party_actors
end
super
end
def jump(x_plus, y_plus)
# 新しい座標を計算
new_x = @x + x_plus
new_y = @y + y_plus
# 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
$game_party.jump_party_actors(x_plus, y_plus)
end
super(x_plus, y_plus)
end
attr_reader :move_speed
attr_reader :step_anime
end
end # module Train_Actor
class Game_Party
include Train_Actor::Game_Party_Module
end
class Game_Player
include Train_Actor::Game_Player_Module
end
class Spriteset_Map
include Train_Actor::Spriteset_Map_Module
end
class Scene_Map
include Train_Actor::Scene_Map_Module
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

评分

参与人数 1星屑 +90 收起 理由
myownroc + 90 塞糖

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 05:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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