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

Project1

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

[讨论] 求助VX队员跟随主角的代码!!找到一个用不了希望大家提供!

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
39 小时
注册时间
2010-9-22
帖子
13
跳转到指定楼层
1
发表于 2011-6-24 22:24:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RT,求大家!

Lv1.梦旅人

梦石
0
星屑
48
在线时间
678 小时
注册时间
2010-8-11
帖子
1533
2
发表于 2011-6-24 23:43:52 | 只看该作者
制作事件……跟随主角……移动4……这样不就OK了么……(+地图位置变量)
小艾工作室开张= =
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
618
在线时间
2656 小时
注册时间
2010-6-28
帖子
1361

开拓者

3
发表于 2011-6-25 00:45:29 | 只看该作者
我只有脚本= =
  1. #==============================================================================
  2. # ■ Train_Actor::Config
  3. #------------------------------------------------------------------------------
  4. # マップ上でアクターを隊列移動させる
  5. #==============================================================================

  6. module Train_Actor

  7.   # ●后面跟随的人看不见时的开关状态
  8.   # true 的时候就是看不见后面的人
  9.   #TRANSPARENT_SWITCH = true
  10.   TRANSPARENT_SWITCH = true

  11.   # ●让后面的人看不见的开关
  12. # TRANSPARENT_SWITCH为true时后面的人看不见
  13.   TRANSPARENT_SWITCHES_INDEX = 96

  14.   # 角色死亡时的行走图名称
  15.   #DEAD_CHARACTER_NAME = "Coffin"
  16.   #角色序列
  17. #DEAD_CHARACTER_INDEX = 0
  18.   DEAD_CHARACTER_NAME = ""
  19.   DEAD_CHARACTER_INDEX = 0

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

  27. end
  28.          
  29. # Train_Actor::Game_Event_Module
  30. # マップ上でアクターを隊列移動させる
  31. # Author:: fukuyama
  32. # Date:: 2007/12/31
  33. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  34. module Train_Actor

  35.   module Game_Event_Module

  36.     # 通行可能判定
  37.     # x:: X 座標
  38.     # y:: Y 座標
  39.     # return:: 通行不可 false 可能 true
  40.     def passable?(x, y)
  41.       result = super(x, y)
  42.       return result if @through
  43.       if result
  44.         # 新しい座標を求める

  45.         new_x = x
  46.         new_y = y
  47.         # トレインアクターのループ

  48.         for actor in $game_party.characters
  49.           # 表示されている場合

  50.           if (not actor.character_name.empty?) and (not actor.transparent)
  51.             # アクターの座標が移動先と一致した場合

  52.             if actor.x == new_x and actor.y == new_y
  53.               # 自分がイベントの場合

  54.               if self != $game_player
  55.                 # 通行不可
  56.                 return false
  57.               end
  58.             end
  59.           end
  60.         end
  61.       end
  62.       return result
  63.     end
  64.   end

  65. end

  66. class Game_Event
  67.   include Train_Actor::Game_Event_Module
  68. end

  69. # Train_Actor::Game_Party_Module
  70. # Game_Party用隊列歩行モジュール
  71. # Author:: fukuyama
  72. # Date:: 2007/12/31
  73. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  74. module Train_Actor

  75.   module Game_Party_Module
  76.     attr_reader :characters

  77.     def initialize
  78.       super
  79.       if @characters.nil?
  80.         @characters = []
  81.         for i in 1 ... Game_Party::MAX_MEMBERS
  82.           @characters.push(Game_Party_Actor.new(i - 1))
  83.         end
  84.       end
  85.     end

  86.     def empty?
  87.       return @actors.empty?
  88.     end

  89.     def dead_actor_include?
  90.       for actor in members
  91.         if actor.dead?
  92.           return true
  93.         end
  94.       end
  95.       return false
  96.     end
  97.     def get_active_party_order
  98.       if not dead_actor_include?
  99.         return members
  100.       end
  101.       alive_actors = []
  102.       dead_actors = []
  103.       for actor in members
  104.         if actor.dead?
  105.           dead_actors.push actor
  106.         else
  107.           alive_actors.push actor
  108.         end
  109.       end
  110.       return alive_actors + dead_actors
  111.     end
  112.     def setup_actor_character_sprites
  113.       setup_actors = get_active_party_order
  114.       for i in 1 ... Game_Party::MAX_MEMBERS
  115.         @characters[i - 1].setup(setup_actors[i])
  116.       end
  117.     end
  118.     def transparent_switch
  119.       if TRANSPARENT_SWITCH
  120.         unless $game_player.transparent
  121.           return $game_switches[TRANSPARENT_SWITCHES_INDEX]
  122.         end
  123.       end
  124.       return $game_player.transparent
  125.     end
  126.     def update_party_actors
  127.       setup_actor_character_sprites
  128.       transparent = transparent_switch
  129.       for character in @characters
  130.         character.transparent = transparent
  131.         character.update
  132.         if $game_player.vehicle_type >= 0 # 乗り物に乗ってる時は同期
  133.           character.sync_with_player
  134.         end
  135.       end
  136.     end
  137.     def moveto_party_actors( x, y )
  138.       setup_actor_character_sprites
  139.       for character in @characters
  140.         character.moveto( x, y )
  141.       end
  142.       @move_list = []
  143.       move_list_setup
  144.     end
  145.     def move_party_actors
  146.       if @move_list == nil
  147.         @move_list = []
  148.         move_list_setup
  149.       end
  150.       @move_list.each_index do |i|
  151.         if not @characters[i].nil?
  152.           @characters[i].add_move_list_element(@move_list[i])
  153.         end
  154.       end
  155.     end
  156.     class Move_List_Element
  157.       def initialize(type,args)
  158.         @type = type
  159.         @args = args
  160.       end
  161.       def type() return @type end
  162.       def args() return @args end
  163.     end
  164.     def move_list_setup
  165.       for i in 0 .. Game_Party::MAX_MEMBERS
  166.         @move_list[i] = nil
  167.       end
  168.     end
  169.     def add_move_list(type,*args)
  170.       if $game_player.vehicle_type >= 0 # 乗り物に乗ってる時は同期
  171.         move_list_setup
  172.         return
  173.       end
  174.       @move_list.unshift(Move_List_Element.new(type,args)).pop
  175.     end
  176.     def move_down_party_actors(turn_enabled = true)
  177.       move_party_actors
  178.       add_move_list(Input::DOWN,turn_enabled)
  179.     end
  180.     def move_left_party_actors(turn_enabled = true)
  181.       move_party_actors
  182.       add_move_list(Input::LEFT,turn_enabled)
  183.     end
  184.     def move_right_party_actors(turn_enabled = true)
  185.       move_party_actors
  186.       add_move_list(Input::RIGHT,turn_enabled)
  187.     end
  188.     def move_up_party_actors(turn_enabled = true)
  189.       move_party_actors
  190.       add_move_list(Input::UP,turn_enabled)
  191.     end
  192.     def move_lower_left_party_actors
  193.       move_party_actors
  194.       add_move_list(DOWN_LEFT)
  195.     end
  196.     def move_lower_right_party_actors
  197.       move_party_actors
  198.       add_move_list(DOWN_RIGHT)
  199.     end
  200.     def move_upper_left_party_actors
  201.       move_party_actors
  202.       add_move_list(UP_LEFT)
  203.     end
  204.     def move_upper_right_party_actors
  205.       move_party_actors
  206.       add_move_list(UP_RIGHT)
  207.     end
  208.     def jump_party_actors(x_plus, y_plus)
  209.       move_party_actors
  210.       add_move_list(JUMP,x_plus, y_plus)
  211.       move_stop_party_actors
  212.     end
  213.     def move_stop_party_actors
  214.       self.members.each do |a|
  215.         move_party_actors
  216.         add_move_list(STOP)
  217.       end
  218.     end
  219.   end

  220. end

  221. class Game_Party
  222.   include Train_Actor::Game_Party_Module
  223. end

  224. # Train_Actor::Game_Player_Module
  225. # Game_Player用隊列歩行モジュール
  226. # Author:: fukuyama
  227. # Date:: 2007/12/31
  228. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  229. module Train_Actor

  230.   module Game_Player_Module
  231.     attr_reader :move_speed
  232.     attr_reader :step_anime
  233.     attr_reader :direction_fix

  234.     def update_party_actors
  235.       if $game_party.empty?
  236.         return
  237.       end
  238.       $game_party.update_party_actors
  239.       actors = $game_party.members
  240.       actor = actors[0]
  241.       if not actor.dead?
  242.         if not @prev_dead.nil?
  243.           @character_name = actor.character_name
  244.           @character_index = actor.character_index
  245.           @prev_dead = nil
  246.         end
  247.         return
  248.       end
  249.       @prev_dead = true
  250.       actors.each do |actor|
  251.         if not actor.dead?
  252.           @character_name = actor.character_name
  253.           @character_index = actor.character_index
  254.           break
  255.         end
  256.       end
  257.     end
  258.     def update
  259.       update_party_actors
  260.       super
  261.     end
  262.     def moveto( x, y )
  263.       $game_party.moveto_party_actors( x, y )
  264.       super( x, y )
  265.     end
  266.     def move_down(turn_enabled = true)
  267.       if passable?(@x, @y + 1)
  268.         $game_party.move_down_party_actors(turn_enabled)
  269.       end
  270.       super(turn_enabled)
  271.     end
  272.     def move_left(turn_enabled = true)
  273.       if passable?(@x - 1, @y)
  274.         $game_party.move_left_party_actors(turn_enabled)
  275.       end
  276.       super(turn_enabled)
  277.     end
  278.     def move_right(turn_enabled = true)
  279.       if passable?(@x + 1, @y)
  280.         $game_party.move_right_party_actors(turn_enabled)
  281.       end
  282.       super(turn_enabled)
  283.     end
  284.     def move_up(turn_enabled = true)
  285.       if passable?(@x, @y - 1)
  286.         $game_party.move_up_party_actors(turn_enabled)
  287.       end
  288.       super(turn_enabled)
  289.     end
  290.     def move_lower_left
  291.       # 下→左、左→下 のどちらかのコースが通行可能な場合
  292.       if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
  293.        (passable?(@x-1, @y) and passable?(@x-1, @y+1))
  294.         $game_party.move_lower_left_party_actors
  295.       end
  296.       super
  297.     end
  298.     def move_lower_right
  299.       # 下→右、右→下 のどちらかのコースが通行可能な場合
  300.       if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
  301.        (passable?(@x+1, @y) and passable?(@x+1, @y+1))
  302.         $game_party.move_lower_right_party_actors
  303.       end
  304.       super
  305.     end
  306.     def move_upper_left
  307.       # 上→左、左→上 のどちらかのコースが通行可能な場合
  308.       if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
  309.        (passable?(@x-1, @y) and passable?(@x-1, @y-1))
  310.         $game_party.move_upper_left_party_actors
  311.       end
  312.       super
  313.     end
  314.     def move_upper_right
  315.       # 上→右、右→上 のどちらかのコースが通行可能な場合
  316.       if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
  317.        (passable?(@x+1, @y) and passable?(@x+1, @y-1))
  318.         $game_party.move_upper_right_party_actors
  319.       end
  320.       super
  321.     end
  322.     def jump(x_plus, y_plus)
  323.       # 新しい座標を計算
  324.       new_x = @x + x_plus
  325.       new_y = @y + y_plus
  326.       # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  327.       if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y)
  328.         $game_party.jump_party_actors(x_plus, y_plus)
  329.       end
  330.       super(x_plus, y_plus)
  331.     end
  332.   end

  333. end

  334. class Game_Player
  335.   include Train_Actor::Game_Player_Module
  336. end

  337. # Train_Actor::Spriteset_Map_Module
  338. # Spriteset_Map用隊列歩行モジュール
  339. # Author:: fukuyama
  340. # Date:: 2007/12/31
  341. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  342. module Train_Actor
  343.   module Spriteset_Map_Module
  344.     def setup_actor_character_sprites
  345.       for character in $game_party.characters.reverse
  346.         @character_sprites.unshift(Sprite_Character.new(@viewport1, character))
  347.       end
  348.     end
  349.   end
  350. end

  351. class Spriteset_Map
  352.   include Train_Actor::Spriteset_Map_Module
  353.   alias train_actor_create_characters create_characters
  354.   def create_characters
  355.     train_actor_create_characters
  356.     setup_actor_character_sprites
  357.   end
  358. end

  359. # Train_Actor::Game_Party_Actor
  360. # マップ上のパーティ用キャラクター
  361. # Author:: fukuyama
  362. # Date:: 2007/12/31
  363. # Copyright:: Copyright (C) 2005-2007 rgss-lib

  364. module Train_Actor

  365.   class Game_Party_Actor < Game_Character
  366.     def initialize(train_index)
  367.       super()
  368.       @train_index = train_index
  369.       @character_wait = 0
  370.       @through = true
  371.       # 不透明度と合成方法を初期化
  372.       @opacity = 255
  373.       @blend_type = 0
  374.       @move_list = []
  375.     end
  376.     def setup(actor)
  377.       # キャラクターのファイル名と色相を設定
  378.       if actor.nil?
  379.         @character_name = ""
  380.       elsif not actor.dead? # 死んでる場合とりあえず、消しとこ…
  381.         @character_name = actor.character_name
  382.         @character_index = actor.character_index
  383.       else
  384.         @character_name = DEAD_CHARACTER_NAME
  385.         @character_index = DEAD_CHARACTER_INDEX
  386.       end
  387.     end
  388.     def dash?
  389.       return false if $game_map.disable_dash?
  390.       #      return false if $game_player.move_route_forcing
  391.       return Input.press?(Input::A)
  392.     end
  393.     def update
  394.       @move_speed = $game_player.move_speed
  395.       @step_anime = $game_player.step_anime
  396.       @opacity = $game_player.opacity
  397.       @blend_type = $game_player.blend_type
  398.       @direction_fix = $game_player.direction_fix
  399.       if @direction_fix
  400.         @direction = $game_player.direction
  401.       end
  402.       update_move_list()
  403.       super
  404.     end
  405.     def screen_z(height = 0)
  406.       if $game_player.x == @x and $game_player.y == @y
  407.         super() - 1
  408.       else
  409.         super()
  410.       end
  411.     end
  412.     def add_move_list_element(element)
  413.       @move_list.push(element)
  414.       if @move_list.size == 1
  415.         update_move_list()
  416.       end
  417.     end
  418.     def move_list_size
  419.       return @move_list.size
  420.     end
  421.     def update_move_list()
  422.       return if moving?
  423.       return if @move_list.empty?
  424.       if @move_list[0].type == STOP
  425.         if @train_index != 0
  426.           character = $game_party.characters[@train_index - 1]
  427.           if character.x == @x and character.y == @y and character.direction == @direction
  428.             distance = (2 ** @move_speed)
  429.             distance *= 2 if dash?
  430.             @character_wait = 256 / distance + 1
  431.             while character.move_list_size < @move_list.size and @move_list[0].type == STOP
  432.               @move_list.shift
  433.             end
  434.           end
  435.         end
  436.       else
  437.         @character_wait = 0
  438.       end
  439.       if @character_wait > 0
  440.         if dash?
  441.           @character_wait -= 2
  442.         else
  443.           @character_wait -= 1
  444.         end
  445.         return
  446.       end
  447.       element = @move_list.shift
  448.       case element.type
  449.       when Input::DOWN
  450.         move_down(element.args[0])
  451.       when Input::LEFT
  452.         move_left(element.args[0])
  453.       when Input::RIGHT
  454.         move_right(element.args[0])
  455.       when Input::UP
  456.         move_up(element.args[0])
  457.       when DOWN_LEFT
  458.         move_lower_left
  459.       when DOWN_RIGHT
  460.         move_lower_right
  461.       when UP_LEFT
  462.         move_upper_left
  463.       when UP_RIGHT
  464.         move_upper_right
  465.       when JUMP
  466.         jump(element.args[0],element.args[1])
  467.       when STOP
  468.         update_move_list()
  469.       end
  470.     end
  471.     def moveto( x, y )
  472.       @move_list.clear
  473.       super(x, y)
  474.     end
  475.     #--------------------------------------------------------------------------
  476.     # ● 下に移動
  477.     #     turn_enabled : その場での向き変更を許可するフラグ
  478.     #--------------------------------------------------------------------------
  479.     def move_down(turn_enabled = true)
  480.       # 下を向く
  481.       if turn_enabled
  482.         turn_down
  483.       end
  484.       # 通行可能な場合
  485.       if passable?(@x, @y + 1)
  486.         # 下を向く
  487.         turn_down
  488.         # 座標を更新
  489.         @y += 1
  490.       end
  491.     end
  492.     #--------------------------------------------------------------------------
  493.     # ● 左に移動
  494.     #     turn_enabled : その場での向き変更を許可するフラグ
  495.     #--------------------------------------------------------------------------
  496.     def move_left(turn_enabled = true)
  497.       # 左を向く

  498.       if turn_enabled
  499.         turn_left
  500.       end
  501.       # 通行可能な場合

  502.       if passable?(@x - 1, @y)
  503.         # 左を向く

  504.         turn_left
  505.         # 座標を更新
  506.         @x -= 1
  507.       end
  508.     end
  509.     #--------------------------------------------------------------------------
  510.     # ● 右に移動
  511.     #     turn_enabled : その場での向き変更を許可するフラグ
  512.     #--------------------------------------------------------------------------
  513.     def move_right(turn_enabled = true)
  514.       # 右を向く

  515.       if turn_enabled
  516.         turn_right
  517.       end
  518.       # 通行可能な場合

  519.       if passable?(@x + 1, @y)
  520.         # 右を向く

  521.         turn_right
  522.         # 座標を更新
  523.         @x += 1
  524.       end
  525.     end
  526.     #--------------------------------------------------------------------------
  527.     # ● 上に移動
  528.     #     turn_enabled : その場での向き変更を許可するフラグ
  529.     #--------------------------------------------------------------------------
  530.     def move_up(turn_enabled = true)
  531.       # 上を向く
  532.       if turn_enabled
  533.         turn_up
  534.       end
  535.       # 通行可能な場合

  536.       if passable?(@x, @y - 1)
  537.         # 上を向く
  538.         turn_up
  539.         # 座標を更新
  540.         @y -= 1
  541.       end
  542.     end
  543.     #--------------------------------------------------------------------------
  544.     # ● 左下に移動
  545.     #--------------------------------------------------------------------------
  546.     def move_lower_left
  547.       # 向き固定でない場合
  548.       unless @direction_fix
  549.         # 右向きだった場合は左を、上向きだった場合は下を向く
  550.         @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  551.       end
  552.       # 下→左、左→下 のどちらかのコースが通行可能な場合
  553.       if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
  554.        (passable?(@x-1, @y) and passable?(@x-1, @y+1))
  555.         # 座標を更新
  556.         @x -= 1
  557.         @y += 1
  558.       end
  559.     end
  560.     #--------------------------------------------------------------------------
  561.     # ● 右下に移動
  562.     #--------------------------------------------------------------------------
  563.     def move_lower_right
  564.       # 向き固定でない場合

  565.       unless @direction_fix
  566.         # 左向きだった場合は右を、上向きだった場合は下を向く
  567.         @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  568.       end
  569.       # 下→右、右→下 のどちらかのコースが通行可能な場合

  570.       if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
  571.        (passable?(@x+1, @y) and passable?(@x+1, @y+1))
  572.         # 座標を更新
  573.         @x += 1
  574.         @y += 1
  575.       end
  576.     end
  577.     #--------------------------------------------------------------------------
  578.     # ● 左上に移動
  579.     #--------------------------------------------------------------------------
  580.     def move_upper_left
  581.       # 向き固定でない場合
  582.       unless @direction_fix
  583.         # 右向きだった場合は左を、下向きだった場合は上を向く
  584.         @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  585.       end
  586.       # 上→左、左→上 のどちらかのコースが通行可能な場合
  587.       if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
  588.        (passable?(@x-1, @y) and passable?(@x-1, @y-1))
  589.         # 座標を更新
  590.         @x -= 1
  591.         @y -= 1
  592.       end
  593.     end
  594.     #--------------------------------------------------------------------------
  595.     # ● 右上に移動
  596.     #--------------------------------------------------------------------------
  597.     def move_upper_right
  598.       # 向き固定でない場合
  599.       unless @direction_fix
  600.         # 左向きだった場合は右を、下向きだった場合は上を向く
  601.         @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  602.       end
  603.       # 上→右、右→上 のどちらかのコースが通行可能な場合
  604.       if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
  605.        (passable?(@x+1, @y) and passable?(@x+1, @y-1))
  606.         # 座標を更新
  607.         @x += 1
  608.         @y -= 1
  609.       end
  610.     end

  611.     def sync_with_player
  612.       @x = $game_player.x
  613.       @y = $game_player.y
  614.       @real_x = $game_player.real_x
  615.       @real_y = $game_player.real_y
  616.       @direction = $game_player.direction
  617.       update_bush_depth
  618.     end

  619.   end

  620. end
复制代码

                 无从有中来,有从无中生。
回复 支持 反对

使用道具 举报

Lv2.观梦者

花开堪折直须折

梦石
0
星屑
621
在线时间
943 小时
注册时间
2010-7-17
帖子
4963

贵宾

4
发表于 2011-6-25 18:40:40 | 只看该作者
请楼主修改标签为“有事请教”或者“已经解决”
大家好,我叫节操,有一天,我被吃了。
http://forever-dream.5d6d.com
永恒の梦制作组论坛

129993099
永恒の梦制作组QQ群
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 05:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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