Project1

标题: 请问如何让队友跟在主角屁股后面? [打印本页]

作者: 嘿嘿一笑    时间: 2012-1-29 20:49
标题: 请问如何让队友跟在主角屁股后面?
请问如何让队友跟在主角屁股后面?请指教!dsu_plus_rewardpost_czw
作者: 魔娃    时间: 2012-1-29 20:53
搜索角色跟随脚本...
作者: aaalbx    时间: 2012-1-29 21:09
  1. ==========================================
  2. #==============================================================================
  3. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  4. #==============================================================================


  5. # ————————————————————————————————————

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

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

  14. module Train_Actor




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





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





  22. # 定数
  23. #Input:OWN = 2
  24. #Input:EFT = 4
  25. #Input::RIGHT = 6
  26. #Input::UP = 6
  27. DOWN_LEFT = 1
  28. DOWN_RIGHT = 3
  29. UP_LEFT = 7
  30. UP_RIGHT = 9
  31. JUMP = 5

  32. class Game_Party_Actor < Game_Character
  33. def initialize
  34. super()
  35. @through = true
  36. end
  37. def setup(actor)
  38. # キャラクターのファイル名と色相を設定
  39. if actor != nil
  40. @character_name = actor.character_name
  41. @character_hue = actor.character_hue
  42. else
  43. @character_name = ""
  44. @character_hue = 0
  45. end
  46. # 不透明度と合成方法を初期化
  47. @opacity = 255
  48. @blend_type = 0
  49. end
  50. def screen_z(height = 0)
  51. if $game_player.x == @x and $game_player.y == @y
  52. return $game_player.screen_z(height) - 1
  53. end
  54. super(height)
  55. end
  56. #--------------------------------------------------------------------------
  57. # ● 下に移動
  58. # turn_enabled : その場での向き変更を許可するフラグ
  59. #--------------------------------------------------------------------------
  60. def move_down(turn_enabled = true)
  61. # 下を向く
  62. if turn_enabled
  63. turn_down
  64. end
  65. # 通行可能な場合
  66. if passable?(@x, @y, Input:OWN)
  67. # 下を向く
  68. turn_down
  69. # 座標を更新
  70. @y += 1
  71. end
  72. end
  73. #--------------------------------------------------------------------------
  74. # ● 左に移動
  75. # turn_enabled : その場での向き変更を許可するフラグ
  76. #--------------------------------------------------------------------------
  77. def move_left(turn_enabled = true)
  78. # 左を向く
  79. if turn_enabled
  80. turn_left
  81. end
  82. # 通行可能な場合
  83. if passable?(@x, @y, Input:EFT)
  84. # 左を向く
  85. turn_left
  86. # 座標を更新
  87. @x -= 1
  88. end
  89. end
  90. #--------------------------------------------------------------------------
  91. # ● 右に移動
  92. # turn_enabled : その場での向き変更を許可するフラグ
  93. #--------------------------------------------------------------------------
  94. def move_right(turn_enabled = true)
  95. # 右を向く
  96. if turn_enabled
  97. turn_right
  98. end
  99. # 通行可能な場合
  100. if passable?(@x, @y, Input::RIGHT)
  101. # 右を向く
  102. turn_right
  103. # 座標を更新
  104. @x += 1
  105. end
  106. end
  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. end
  124. #--------------------------------------------------------------------------
  125. # ● 左下に移動
  126. #--------------------------------------------------------------------------
  127. def move_lower_left
  128. # 向き固定でない場合
  129. unless @direction_fix
  130. # 右向きだった場合は左を、上向きだった場合は下を向く
  131. @direction = (@direction == Input::RIGHT ? Input:EFT : @direction == Input::UP ? Input:OWN : @direction)
  132. end
  133. # 下→左、左→下 のどちらかのコースが通行可能な場合
  134. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  135. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  136. # 座標を更新
  137. @x -= 1
  138. @y += 1
  139. end
  140. end
  141. #--------------------------------------------------------------------------
  142. # ● 右下に移動
  143. #--------------------------------------------------------------------------
  144. def move_lower_right
  145. # 向き固定でない場合
  146. unless @direction_fix
  147. # 左向きだった場合は右を、上向きだった場合は下を向く
  148. @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  149. end
  150. # 下→右、右→下 のどちらかのコースが通行可能な場合
  151. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  152. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  153. # 座標を更新
  154. @x += 1
  155. @y += 1
  156. end
  157. end
  158. #--------------------------------------------------------------------------
  159. # ● 左上に移動
  160. #--------------------------------------------------------------------------
  161. def move_upper_left
  162. # 向き固定でない場合
  163. unless @direction_fix
  164. # 右向きだった場合は左を、下向きだった場合は上を向く
  165. @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  166. end
  167. # 上→左、左→上 のどちらかのコースが通行可能な場合
  168. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  169. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  170. # 座標を更新
  171. @x -= 1
  172. @y -= 1
  173. end
  174. end
  175. #--------------------------------------------------------------------------
  176. # ● 右上に移動
  177. #--------------------------------------------------------------------------
  178. def move_upper_right
  179. # 向き固定でない場合
  180. unless @direction_fix
  181. # 左向きだった場合は右を、下向きだった場合は上を向く
  182. @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  183. end
  184. # 上→右、右→上 のどちらかのコースが通行可能な場合
  185. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  186. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  187. # 座標を更新
  188. @x += 1
  189. @y -= 1
  190. end
  191. end
  192. attr_writer :move_speed
  193. attr_writer :step_anime
  194. end
  195. module Spriteset_Map_Module
  196. def setup_actor_character_sprites?
  197. return @setup_actor_character_sprites_flag != nil
  198. end
  199. def setup_actor_character_sprites(characters)
  200. if !setup_actor_character_sprites?
  201. index_game_player = 0
  202. @character_sprites.each_index do |i|
  203. if @character_sprites.character.instance_of?(Game_Player)
  204. index_game_player = i
  205. break
  206. end
  207. end
  208. for character in characters.reverse
  209. @character_sprites.unshift(
  210. Sprite_Character.new(@viewport1, character)
  211. )
  212. end
  213. @setup_actor_character_sprites_flag = true
  214. end
  215. end
  216. end
  217. module Scene_Map_Module
  218. def setup_actor_character_sprites(characters)
  219. @spriteset.setup_actor_character_sprites(characters)
  220. end
  221. end
  222. module Game_Party_Module
  223. def set_transparent_actors(transparent)
  224. @transparent = transparent
  225. end
  226. def setup_actor_character_sprites
  227. if @characters == nil
  228. @characters = []
  229. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  230. @characters.push(Game_Party_Actor.new)
  231. end
  232. end
  233. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  234. @characters[i - 1].setup(actors)
  235. end
  236. if $scene.class.method_defined?('setup_actor_character_sprites')
  237. $scene.setup_actor_character_sprites(@characters)
  238. end
  239. end
  240. def update_party_actors
  241. setup_actor_character_sprites
  242. transparent = $game_player.transparent
  243. if transparent == false
  244. if TRANSPARENT_SWITCH
  245. transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  246. end
  247. end
  248. for character in @characters
  249. character.transparent = transparent
  250. character.move_speed = $game_player.move_speed
  251. character.step_anime = $game_player.step_anime
  252. character.update
  253. end
  254. end
  255. def moveto_party_actors( x, y )
  256. setup_actor_character_sprites
  257. for character in @characters
  258. character.moveto( x, y )
  259. end
  260. if @move_list == nil
  261. @move_list = []
  262. end
  263. move_list_setup
  264. end
  265. def move_party_actors
  266. if @move_list == nil
  267. @move_list = []
  268. move_list_setup
  269. end
  270. @move_list.each_index do |i|
  271. if @characters != nil
  272. case @move_list.type
  273. when Input::DOWN
  274. @characters.move_down(@move_list.args[0])
  275. when Input::LEFT
  276. @characters.move_left(@move_list.args[0])
  277. when Input::RIGHT
  278. @characters.move_right(@move_list.args[0])
  279. when Input::UP
  280. @characters.move_up(@move_list.args[0])
  281. when DOWN_LEFT
  282. @characters.move_lower_left
  283. when DOWN_RIGHT
  284. @characters.move_lower_right
  285. when UP_LEFT
  286. @characters.move_upper_left
  287. when UP_RIGHT
  288. @characters.move_upper_right
  289. when JUMP
  290. @characters.jump(@move_list.args[0],@move_list.args[1])
  291. end
  292. end
  293. end
  294. end
  295. class Move_List_Element
  296. def initialize(type,args)
  297. @type = type
  298. @args = args
  299. end
  300. def type() return @type end
  301. def args() return @args end
  302. end
  303. def move_list_setup
  304. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  305. @move_list = nil
  306. end
  307. end
  308. def add_move_list(type,*args)
  309. @move_list.unshift(Move_List_Element.new(type,args)).pop
  310. end
  311. def move_down_party_actors(turn_enabled = true)
  312. move_party_actors
  313. add_move_list(Input::DOWN,turn_enabled)
  314. end
  315. def move_left_party_actors(turn_enabled = true)
  316. move_party_actors
  317. add_move_list(Input::LEFT,turn_enabled)
  318. end
  319. def move_right_party_actors(turn_enabled = true)
  320. move_party_actors
  321. add_move_list(Input::RIGHT,turn_enabled)
  322. end
  323. def move_up_party_actors(turn_enabled = true)
  324. move_party_actors
  325. add_move_list(Input::UP,turn_enabled)
  326. end
  327. def move_lower_left_party_actors
  328. move_party_actors
  329. add_move_list(DOWN_LEFT)
  330. end
  331. def move_lower_right_party_actors
  332. move_party_actors
  333. add_move_list(DOWN_RIGHT)
  334. end
  335. def move_upper_left_party_actors
  336. move_party_actors
  337. add_move_list(UP_LEFT)
  338. end
  339. def move_upper_right_party_actors
  340. move_party_actors
  341. add_move_list(UP_RIGHT)
  342. end
  343. def jump_party_actors(x_plus, y_plus)
  344. move_party_actors
  345. add_move_list(JUMP,x_plus, y_plus)
  346. end
  347. end
  348. module Game_Player_Module
  349. def update
  350. $game_party.update_party_actors
  351. super
  352. end
  353. def moveto( x, y )
  354. $game_party.moveto_party_actors( x, y )
  355. super( x, y )
  356. end
  357. def move_down(turn_enabled = true)
  358. if passable?(@x, @y, Input::DOWN)
  359. $game_party.move_down_party_actors(turn_enabled)
  360. end
  361. super(turn_enabled)
  362. end
  363. def move_left(turn_enabled = true)
  364. if passable?(@x, @y, Input::LEFT)
  365. $game_party.move_left_party_actors(turn_enabled)
  366. end
  367. super(turn_enabled)
  368. end
  369. def move_right(turn_enabled = true)
  370. if passable?(@x, @y, Input::RIGHT)
  371. $game_party.move_right_party_actors(turn_enabled)
  372. end
  373. super(turn_enabled)
  374. end
  375. def move_up(turn_enabled = true)
  376. if passable?(@x, @y, Input::UP)
  377. $game_party.move_up_party_actors(turn_enabled)
  378. end
  379. super(turn_enabled)
  380. end
  381. def move_lower_left
  382. # 下→左、左→下 のどちらかのコースが通行可能な場合
  383. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  384. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  385. $game_party.move_lower_left_party_actors
  386. end
  387. super
  388. end
  389. def move_lower_right
  390. # 下→右、右→下 のどちらかのコースが通行可能な場合
  391. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  392. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  393. $game_party.move_lower_right_party_actors
  394. end
  395. super
  396. end
  397. def move_upper_left
  398. # 上→左、左→上 のどちらかのコースが通行可能な場合
  399. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  400. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  401. $game_party.move_upper_left_party_actors
  402. end
  403. super
  404. end
  405. def move_upper_right
  406. # 上→右、右→上 のどちらかのコースが通行可能な場合
  407. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  408. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  409. $game_party.move_upper_right_party_actors
  410. end
  411. super
  412. end
  413. def jump(x_plus, y_plus)
  414. # 新しい座標を計算
  415. new_x = @x + x_plus
  416. new_y = @y + y_plus
  417. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  418. if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  419. $game_party.jump_party_actors(x_plus, y_plus)
  420. end
  421. super(x_plus, y_plus)
  422. end
  423. attr_reader :move_speed
  424. attr_reader :step_anime
  425. end
  426. end # module Train_Actor
  427. class Game_Party
  428. include Train_Actor::Game_Party_Module
  429. end
  430. class Game_Player
  431. include Train_Actor::Game_Player_Module
  432. end
  433. class Spriteset_Map
  434. include Train_Actor::Spriteset_Map_Module
  435. end
  436. class Scene_Map
  437. include Train_Actor::Scene_Map_Module
  438. end

  439. #==============================================================================
  440. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  441. #==============================================================================
复制代码
最近回的为啥都是纯伸手问题呢?MD!




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