Project1

标题: 关于VX整队的问题 [打印本页]

作者: 轩辕大将军    时间: 2013-6-12 11:12
标题: 关于VX整队的问题
本帖最后由 轩辕大将军 于 2013-6-15 22:29 编辑

就是以前看到一个在菜单里显示叫“马车”的脚本。
上回一不小心删了……求地址!!
作者: 咪了个喵的    时间: 2013-6-15 19:44
  1. #==============================================================================
  2. # 仿DQ系列的马车行走
  3. #
  4. # 使用说明:新建2个角色,行走图分别设置为马和车厢。
  5. # 开启对应的开关后,在地图备注中写有<马车Style>的地图上,就能以马车队列行进。
  6. # 在<马车Style>的地图上开启开关时,如果需要要刷新队列,请在事件中执行脚本:
  7. # $game_player.refresh
  8. #==============================================================================
  9. module CarriageStyle
  10.   HORSE    = 10  #设置行走图为马的角色ID
  11.   CARRIAGE = 11  #设置行走图为马车的角色ID
  12.   SWITCH   = 120   #控制马车行走的公共开关
  13. end

  14. #==============================================================================
  15. # ■ Game_Follower
  16. #==============================================================================
  17. class Game_Follower
  18. attr_accessor :need_refresh
  19.   #--------------------------------------------------------------------------
  20.   # ● 获取对应的角色(override method)
  21.   #--------------------------------------------------------------------------
  22.   def actor
  23.     if @need_refresh
  24.       $carriage_array = $game_party.battle_members
  25.       if $game_map.carriage_style? && $game_switches[CarriageStyle::SWITCH]
  26.         $carriage_array.insert(1, $game_actors[CarriageStyle::HORSE],
  27.         $game_actors[CarriageStyle::CARRIAGE])
  28.       end
  29.       @need_refresh = false
  30.     end
  31.     $carriage_array[@member_index]
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 追随带队角色(override method)
  35.   #--------------------------------------------------------------------------
  36.   def chase_preceding_character
  37.     unless moving?
  38.       case @member_index
  39.       when 1..3; chase(@preceding_character.x, @preceding_character.y)
  40.       when 4;    left_side_chase(@preceding_character)
  41.       when 5;    right_side_chase(@preceding_character); end
  42.     end
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 追随(new method)
  46.   #--------------------------------------------------------------------------
  47.   def chase(x, y)
  48.     sx = distance_x_from(x)
  49.     sy = distance_y_from(y)
  50.     if sx != 0 && sy != 0
  51.       move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)
  52.     elsif sx != 0
  53.       move_straight(sx > 0 ? 4 : 6)
  54.     elsif sy != 0
  55.       move_straight(sy > 0 ? 8 : 2)
  56.     end
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ● 左侧人物的移动(new method)
  60.   #--------------------------------------------------------------------------
  61.   def left_side_chase(character)
  62.     if left_side_passable?(character) && !$game_player.followers.gathering?
  63.       sx = distance_x_from(character.left_side_x)
  64.       sy = distance_y_from(character.left_side_y)
  65.       if (sx.abs + sy.abs) >= 3
  66.         moveto(character.back_side_x, character.back_side_y)
  67.       end
  68.       chase(character.left_side_x, character.left_side_y)
  69.     else
  70.       chase(character.x, character.y)
  71.     end
  72.     @direction = character.direction
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● 右侧人物的移动(new method)
  76.   #--------------------------------------------------------------------------
  77.   def right_side_chase(character)
  78.     if right_side_passable?(character) && !$game_player.followers.gathering?
  79.       sx = distance_x_from(character.right_side_x)
  80.       sy = distance_y_from(character.right_side_y)
  81.       if (sx.abs + sy.abs) >= 3
  82.         moveto(character.back_side_x, character.back_side_y)
  83.       end
  84.       chase(character.right_side_x, character.right_side_y)
  85.     else
  86.       chase(character.x, character.y)
  87.     end
  88.     @direction = character.direction
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 得到目标背后的坐标(new method)
  92.   #--------------------------------------------------------------------------
  93.   def back_side_x
  94.     case self.direction
  95.     when 2; x = 0
  96.     when 4; x = 1
  97.     when 6; x = -1
  98.     when 8; x = 0; end
  99.     $game_map.round_x(x += self.x)
  100.   end
  101.   def back_side_y
  102.     case self.direction
  103.     when 2; y = -1
  104.     when 4; y = 0
  105.     when 6; y = 0
  106.     when 8; y = 1; end
  107.     $game_map.round_y(y += self.y)
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # ● 得到目标左侧的坐标(new methord)
  111.   #--------------------------------------------------------------------------
  112.   def left_side_x
  113.     case self.direction
  114.     when 2; x = 1
  115.     when 4; x = 0
  116.     when 6; x = 0
  117.     when 8; x = -1; end
  118.     $game_map.round_x(x += self.x)
  119.   end
  120.   def left_side_y
  121.     case self.direction
  122.     when 2; y = 0
  123.     when 4; y = 1
  124.     when 6; y = -1
  125.     when 8; y = 0; end
  126.     $game_map.round_x(y += self.y)
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 得到目标右侧的坐标(new method)
  130.   #--------------------------------------------------------------------------
  131.   def right_side_x
  132.     case self.direction
  133.     when 2; x = -1
  134.     when 4; x = 0
  135.     when 6; x = 0
  136.     when 8; x = 1; end
  137.     $game_map.round_x(x += self.x)
  138.   end
  139.   def right_side_y
  140.     case self.direction
  141.     when 2; y = 0
  142.     when 4; y = -1
  143.     when 6; y = 1
  144.     when 8; y = 0; end
  145.     $game_map.round_y(y += self.y)
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 判定HORSE左侧通行度(new method)
  149.   #--------------------------------------------------------------------------
  150.   def left_side_passable?(character)
  151.     $game_map.passable?(character.left_side_x,character.left_side_y,
  152.     character.direction) &&
  153.     !collide_with_events?(character.left_side_x, character.left_side_y)
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 判定HORSE右侧通行度(new method)
  157.   #--------------------------------------------------------------------------
  158.   def right_side_passable?(character)
  159.     $game_map.passable?(character.right_side_x,character.right_side_y,
  160.     character.direction) &&
  161.     !collide_with_events?(character.right_side_x, character.right_side_y)
  162.   end
  163. end

  164. #==============================================================================
  165. # ■ Scene_Map(new method)
  166. #==============================================================================
  167. class Game_Map
  168.   def carriage_style?
  169.     return if map_id == 0
  170.     object = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
  171.     object.note.each_line do |line|
  172.       return true if line.include?("<马车Style>")
  173.     end
  174.     return false
  175.   end
  176. end

  177. #==============================================================================
  178. # ■ Scene_Map(override method)
  179. #==============================================================================
  180. class Scene_Map
  181.   def perform_transfer
  182.     pre_transfer
  183.     $game_player.perform_transfer
  184.     $game_player.refresh
  185.     post_transfer
  186.   end
  187. end

  188. #==============================================================================
  189. # ■ Game_Followers(alias method)
  190. #==============================================================================
  191. class Game_Followers
  192.   #--------------------------------------------------------------------------
  193.   # ● 初始化(alias method)
  194.   #--------------------------------------------------------------------------
  195.   alias old_initialize initialize
  196.   def initialize(leader)
  197.     old_initialize(leader)
  198.     @data.push(Game_Follower.new(4, @data[0]))
  199.     @data.push(Game_Follower.new(5, @data[0]))
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # ● 刷新(alias method)
  203.   #--------------------------------------------------------------------------
  204.   alias old_refresh refresh
  205.   def refresh
  206.     @data[0].need_refresh = true
  207.     old_refresh
  208.   end
  209. end
复制代码
这个么?这个是连接
作者: 轩辕大将军    时间: 2013-6-15 22:23
本帖最后由 轩辕大将军 于 2013-6-15 22:30 编辑
咪了个喵的 发表于 2013-6-15 19:44
这个么?这个是连接


我要的是能整队的……




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1