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

Project1

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

[讨论] RM XP 人物跟随脚本缩进完成

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1316
在线时间
831 小时
注册时间
2007-12-25
帖子
1558
跳转到指定楼层
1
发表于 2010-7-18 18:07:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
想改一下RMXP的人物跟随脚本

但是打开一看,真头疼呀,所以呢,花了点时间吧缩进调好了
这个脚本没有任何功能上的改变,只是方便了想做点什么的人

先说好这个不是原创,不知道算什么
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载自www.phylomortis.com,转载请保留此信息
  3. # ————————————————————————————————————

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

  6. #
  7. # Train_Actor
  8. #
  9. # [email protected]
  10. # http://www4.big.or.jp/~fukuyama/rgss/Train_Actor.txt
  11. #

  12. module Train_Actor




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





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





  20. # 定数
  21. #Input::DOWN = 2
  22. #Input::LEFT = 4
  23. #Input::RIGHT = 6
  24. #Input::UP = 6
  25. DOWN_LEFT = 1
  26. DOWN_RIGHT = 3
  27. UP_LEFT = 7
  28. UP_RIGHT = 9
  29. JUMP = 5

  30. class Game_Party_Actor < Game_Character
  31.   def initialize
  32.     super()
  33.     @through = true
  34.   end
  35.   def setup(actor)
  36. # キャラクターのファイル名と色相を設定
  37.     if actor != nil
  38.       @character_name = actor.character_name
  39.       @character_hue = actor.character_hue
  40.     else
  41.       @character_name = ""
  42.       @character_hue = 0
  43.     end
  44. # 不透明度と合成方法を初期化
  45.     @opacity = 255
  46.     @blend_type = 0
  47.   end
  48.   
  49.   def screen_z(height = 0)
  50.     if $game_player.x == @x and $game_player.y == @y
  51.   
  52.     return $game_player.screen_z(height) - 1
  53.   end
  54.   

  55.   super(height)
  56. end
  57. #--------------------------------------------------------------------------
  58. # ● 下に移動
  59. # turn_enabled : その場での向き変更を許可するフラグ
  60. #--------------------------------------------------------------------------
  61. def move_down(turn_enabled = true)
  62.   if turn_enabled
  63.     turn_down
  64.   end
  65.   
  66.   if passable?(@x, @y, Input::DOWN)
  67.     turn_down
  68.     @y += 1
  69.   end
  70.   

  71. end

  72. #--------------------------------------------------------------------------
  73. # ● 左に移動
  74. # turn_enabled : その場での向き変更を許可するフラグ
  75. #--------------------------------------------------------------------------
  76.   def move_left(turn_enabled = true)
  77. # 左を向く
  78.     if turn_enabled
  79.       turn_left
  80.     end
  81. # 通行可能な場合
  82.    if passable?(@x, @y, Input::LEFT)
  83.   # 左を向く
  84.     turn_left
  85.     @x -= 1
  86.    end
  87. end

  88. #--------------------------------------------------------------------------
  89. # ● 右に移動
  90. # turn_enabled : その場での向き変更を許可するフラグ
  91. #--------------------------------------------------------------------------
  92.   def move_right(turn_enabled = true)
  93. # 右を向く
  94.     if turn_enabled
  95.       turn_right
  96.     end
  97.    
  98. # 通行可能な場合
  99.     if passable?(@x, @y, Input::RIGHT)
  100. # 右を向く
  101.       turn_right
  102. # 座標を更新
  103.       @x += 1
  104.     end
  105.   end
  106.   
  107. #--------------------------------------------------------------------------
  108. # ● 上に移動
  109. # turn_enabled : その場での向き変更を許可するフラグ
  110. #--------------------------------------------------------------------------
  111.   def move_up(turn_enabled = true)
  112. # 上を向く
  113.     if turn_enabled
  114.       turn_up
  115.     end
  116. # 通行可能な場合
  117.     if passable?(@x, @y, Input::UP)
  118. # 上を向く
  119.       turn_up
  120. # 座標を更新
  121.       @y -= 1
  122.     end
  123.    
  124.   end
  125.   
  126. #--------------------------------------------------------------------------
  127. # ● 左下に移動
  128. #--------------------------------------------------------------------------
  129.   def move_lower_left
  130. # 向き固定でない場合
  131.     unless @direction_fix
  132. # 右向きだった場合は左を、上向きだった場合は下を向く
  133.       @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  134.     end
  135.    
  136. # 下→左、左→下 のどちらかのコースが通行可能な場合
  137.   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  138.   (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  139. # 座標を更新
  140.     @x -= 1
  141.     @y += 1
  142.   end
  143.   
  144. end

  145. #--------------------------------------------------------------------------
  146. # ● 右下に移動
  147. #--------------------------------------------------------------------------
  148.   def move_lower_right
  149. # 向き固定でない場合
  150.     unless @direction_fix
  151. # 左向きだった場合は右を、上向きだった場合は下を向く
  152.       @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  153.     end
  154.    
  155. # 下→右、右→下 のどちらかのコースが通行可能な場合
  156.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  157.     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  158. # 座標を更新
  159.       @x += 1
  160.       @y += 1
  161.     end
  162.   end
  163.   
  164. #--------------------------------------------------------------------------
  165. # ● 左上に移動
  166. #--------------------------------------------------------------------------
  167.   def move_upper_left
  168. # 向き固定でない場合
  169.     unless @direction_fix
  170. # 右向きだった場合は左を、下向きだった場合は上を向く
  171.       @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  172.     end
  173.    
  174. # 上→左、左→上 のどちらかのコースが通行可能な場合
  175.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  176.     (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  177. # 座標を更新
  178.       @x -= 1
  179.       @y -= 1
  180.     end
  181.    
  182.   end
  183.   
  184. #--------------------------------------------------------------------------
  185. # ● 右上に移動
  186. #--------------------------------------------------------------------------
  187.   def move_upper_right
  188. # 向き固定でない場合
  189.     unless @direction_fix
  190. # 左向きだった場合は右を、下向きだった場合は上を向く
  191.       @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  192.     end
  193.    
  194. # 上→右、右→上 のどちらかのコースが通行可能な場合
  195.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  196.     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  197. # 座標を更新
  198.        @x += 1
  199.        @y -= 1
  200.      end     
  201.    end   
  202.   attr_writer :move_speed
  203.   attr_writer :step_anime
  204. end
  205. module Spriteset_Map_Module
  206.   def setup_actor_character_sprites?
  207.     return @setup_actor_character_sprites_flag != nil
  208.   end  
  209.   def setup_actor_character_sprites(characters)
  210.     if !setup_actor_character_sprites?
  211.       index_game_player = 0
  212.       @character_sprites.each_index do |i|
  213.         if @character_sprites[i].character.instance_of?(Game_Player)
  214.           index_game_player = i
  215.           break
  216.         end        
  217.       end
  218.       for character in characters.reverse
  219.         @character_sprites.unshift(Sprite_Character.new(@viewport1, character))
  220.       end
  221.      @setup_actor_character_sprites_flag = true
  222.    end
  223. end
  224. end
  225. module Scene_Map_Module
  226.   def setup_actor_character_sprites(characters)
  227.     @spriteset.setup_actor_character_sprites(characters)
  228.   end  
  229. end
  230. module Game_Party_Module
  231.   def set_transparent_actors(transparent)
  232.     @transparent = transparent
  233.   end
  234.   def setup_actor_character_sprites
  235.     if @characters == nil
  236.       @characters = []
  237.       for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  238.         @characters.push(Game_Party_Actor.new)
  239.       end
  240.     end
  241.     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  242.       @characters[i - 1].setup(actors[i])
  243.     end
  244.     if $scene.class.method_defined?('setup_actor_character_sprites')
  245.       $scene.setup_actor_character_sprites(@characters)
  246.     end   
  247.   end
  248.   def update_party_actors
  249.     setup_actor_character_sprites
  250.     transparent = $game_player.transparent
  251.     if transparent == false
  252.       if TRANSPARENT_SWITCH
  253.         transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  254.       end
  255.     end
  256.     for character in @characters
  257.       character.transparent = transparent
  258.       character.move_speed = $game_player.move_speed
  259.       character.step_anime = $game_player.step_anime
  260.       character.update
  261.     end
  262.   end  
  263.   def moveto_party_actors( x, y )
  264.     setup_actor_character_sprites
  265.     for character in @characters
  266.       character.moveto( x, y )
  267.     end
  268.     if @move_list == nil
  269.       @move_list = []
  270.     end
  271.     move_list_setup
  272.   end
  273.   def move_party_actors
  274.     if @move_list == nil
  275.       @move_list = []
  276.       move_list_setup
  277.     end
  278.     @move_list.each_index do |i|
  279.     if @characters[i] != nil
  280.       case @move_list[i].type
  281.       when Input::DOWN
  282.         @characters[i].move_down(@move_list[i].args[0])
  283.       when Input::LEFT
  284.         @characters[i].move_left(@move_list[i].args[0])
  285.       when Input::RIGHT
  286.         @characters[i].move_right(@move_list[i].args[0])
  287.       when Input::UP
  288.         @characters[i].move_up(@move_list[i].args[0])
  289.       when DOWN_LEFT
  290.         @characters[i].move_lower_left
  291.       when DOWN_RIGHT
  292.         @characters[i].move_lower_right
  293.       when UP_LEFT
  294.         @characters[i].move_upper_left
  295.       when UP_RIGHT
  296.         @characters[i].move_upper_right
  297.       when JUMP
  298.         @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  299.       end
  300.     end   
  301.   end
  302. end

  303. class Move_List_Element
  304.   def initialize(type,args)
  305.     @type = type
  306.     @args = args
  307.   end
  308.   def type() return @type end
  309.     def args() return @args end
  310.   end
  311.   def move_list_setup
  312.     for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  313.       @move_list[i] = nil
  314.     end   
  315.   end  
  316.   def add_move_list(type,*args)
  317.     @move_list.unshift(Move_List_Element.new(type,args)).pop
  318.   end
  319.   def move_down_party_actors(turn_enabled = true)
  320.     move_party_actors
  321.     add_move_list(Input::DOWN,turn_enabled)
  322.   end
  323.   
  324.   def move_left_party_actors(turn_enabled = true)
  325.     move_party_actors
  326.     add_move_list(Input::LEFT,turn_enabled)
  327.   end
  328.   def move_right_party_actors(turn_enabled = true)
  329.     move_party_actors
  330.     add_move_list(Input::RIGHT,turn_enabled)
  331.   end
  332.   def move_up_party_actors(turn_enabled = true)
  333.     move_party_actors
  334.     add_move_list(Input::UP,turn_enabled)
  335.   end
  336.   def move_lower_left_party_actors
  337.     move_party_actors
  338.     add_move_list(DOWN_LEFT)
  339.   end
  340.   def move_lower_right_party_actors
  341.     move_party_actors
  342.     add_move_list(DOWN_RIGHT)
  343.   end
  344.   def move_upper_left_party_actors
  345.     move_party_actors
  346.     add_move_list(UP_LEFT)
  347.   end
  348.   def move_upper_right_party_actors
  349.     move_party_actors
  350.     add_move_list(UP_RIGHT)
  351.   end
  352.   def jump_party_actors(x_plus, y_plus)
  353.     move_party_actors
  354.     add_move_list(JUMP,x_plus, y_plus)
  355.   end  
  356. end

  357. module Game_Player_Module
  358.   def update
  359.     $game_party.update_party_actors
  360.     super
  361.   end
  362.   def moveto( x, y )
  363.     $game_party.moveto_party_actors( x, y )
  364.     super( x, y )
  365.   end
  366.   def move_down(turn_enabled = true)
  367.     if passable?(@x, @y, Input::DOWN)
  368.       $game_party.move_down_party_actors(turn_enabled)
  369.     end
  370.     super(turn_enabled)
  371.   end
  372.   def move_left(turn_enabled = true)
  373.     if passable?(@x, @y, Input::LEFT)
  374.       $game_party.move_left_party_actors(turn_enabled)
  375.     end
  376.     super(turn_enabled)
  377.   end
  378.   def move_right(turn_enabled = true)
  379.     if passable?(@x, @y, Input::RIGHT)
  380.       $game_party.move_right_party_actors(turn_enabled)
  381.     end
  382.     super(turn_enabled)
  383.   end
  384.   def move_up(turn_enabled = true)
  385.     if passable?(@x, @y, Input::UP)
  386.       $game_party.move_up_party_actors(turn_enabled)
  387.     end
  388.     super(turn_enabled)
  389.   end
  390.   def move_lower_left
  391.     # 下→左、左→下 のどちらかのコースが通行可能な場合
  392.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  393.       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  394.       $game_party.move_lower_left_party_actors
  395.     end
  396.     super
  397.   end
  398.   def move_lower_right
  399.     # 下→右、右→下 のどちらかのコースが通行可能な場合
  400.     if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  401.       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  402.       $game_party.move_lower_right_party_actors
  403.     end
  404.     super
  405.   end
  406.   def move_upper_left
  407.     # 上→左、左→上 のどちらかのコースが通行可能な場合
  408.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  409.       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  410.       $game_party.move_upper_left_party_actors
  411.     end
  412.     super
  413.   end
  414.   def move_upper_right
  415.     # 上→右、右→上 のどちらかのコースが通行可能な場合
  416.     if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  417.       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  418.       $game_party.move_upper_right_party_actors
  419.     end
  420.     super
  421.   end
  422.   def jump(x_plus, y_plus)
  423.     # 新しい座標を計算
  424.     new_x = @x + x_plus
  425.     new_y = @y + y_plus
  426.     # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  427.     if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  428.       $game_party.jump_party_actors(x_plus, y_plus)
  429.     end
  430.     super(x_plus, y_plus)
  431.   end
  432.   
  433.   attr_reader :move_speed
  434.   attr_reader :step_anime
  435. end

  436. end # module Train_Actor
  437. class Game_Party
  438.   include Train_Actor::Game_Party_Module
  439. end
  440. class Game_Player
  441.   include Train_Actor::Game_Player_Module
  442. end
  443. class Spriteset_Map
  444.   include Train_Actor::Spriteset_Map_Module
  445. end
  446. class Scene_Map
  447.   include Train_Actor::Scene_Map_Module
  448. end
复制代码
精卫赤龙腾   
总是存在一种强大,去完成似乎不可能的事情.
无畏战乾程   
或是需要一种勇气,去挑战几乎不存在的胜利.
一味玄真魂     
这是拥有一种恒心,去化解根本没有解的困难.
烈卫开天径    
只是带着一种决心,去争取残存的最后的希望。
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2010-6-29
帖子
17
2
发表于 2010-7-18 19:45:37 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
301
在线时间
573 小时
注册时间
2005-10-27
帖子
1164
3
发表于 2010-7-20 04:35:19 | 只看该作者
看了半天原来是小九出品。不过那缩进是什么意思嘛?
认真地猥琐,猥琐地认真
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
18 小时
注册时间
2010-8-14
帖子
155
4
发表于 2010-9-30 16:48:52 | 只看该作者
首先 這個腳本放在哪 其次 放了腳本以後怎麼跟?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

小小的百鬼夜行<

梦石
0
星屑
54
在线时间
579 小时
注册时间
2010-7-29
帖子
2682

贵宾

5
发表于 2010-10-2 21:49:05 | 只看该作者
记得从前的叶子曾经做过一个中间可以间隔一些空的人物跟随。
不过我是想让角色走一步屁虫跟3步的那种。
某只PHP/HTML小白鼠→退屈の间


Cause I knew you were trouble when you walked in
So shame is on me now
I flow me to place i ve never been
till you put me down oh
Now Im lying on the cold hard ground
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
103 小时
注册时间
2011-2-16
帖子
285
6
发表于 2011-4-2 22:13:49 | 只看该作者
太感谢了~~我以前弄了一个,结果是没有缩进的,看到那如山的空格~~
LZ~~爱死你了!!
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
26 小时
注册时间
2011-1-16
帖子
13
7
发表于 2011-4-16 12:23:16 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
3 小时
注册时间
2015-5-22
帖子
7
8
发表于 2015-5-22 10:21:36 | 只看该作者
楼主太棒了 7楼的那个脚本是什么鬼感谢楼主 藐视7楼

评分

参与人数 1星屑 -10 收起 理由
恐惧剑刃 -10 层主

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
940
在线时间
6 小时
注册时间
2016-4-18
帖子
2
9
发表于 2016-4-23 22:06:47 | 只看该作者
非常好的脚本,无错!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-26 20:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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