幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1295|回复: 3

[RMVX] [求助]关于角色跟随!

[复制链接]

52

主题

734

帖子

101万

积分

⑧专业

癫狂作者组一号

积分
1010909
QQ
发表于 2007-5-4 22:39:25 | 显示全部楼层 |阅读模式
瞎转悠了半天,弄了个跟随脚本进来……开始测试时有提示脚本错误,按提示修改后可以运行了……但测试到第一位队友加入时对完话那人就在地图上消失了……找也找不到……怎么回事啊!高手救命!
饲养简单,每日只需准备足量饮水食物和一台可上网的电脑即可
回复

使用道具 举报

38

主题

3468

帖子

1

积分

超级版主

传说中的Bunny火神~!

Rank: 8Rank: 8

积分
1
发表于 2007-5-4 23:21:37 | 显示全部楼层
=。=你确认脚本没错? [s:5]
我突然发现,我是一个很幸运的好人。老婆真好~ 点我进入JQ(激情)教程范例收集!
回复 支持 反对

使用道具 举报

52

主题

734

帖子

101万

积分

⑧专业

癫狂作者组一号

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

使用道具 举报

52

主题

734

帖子

101万

积分

⑧专业

癫狂作者组一号

积分
1010909
QQ
 楼主| 发表于 2007-5-8 19:03:36 | 显示全部楼层
weiaweia
饲养简单,每日只需准备足量饮水食物和一台可上网的电脑即可
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-23 12:44 , Processed in 0.011824 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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