Project1

标题: 【Xp→Vx】人物跟随 [打印本页]

作者: ONEWateR    时间: 2008-12-7 08:36
标题: 【Xp→Vx】人物跟随
移植脚本,效果见截图

截图:


脚本:
  1. #==============================================================================
  2. # ■ 人物跟随
  3. #------------------------------------------------------------------------------
  4. #
  5. #   本脚本来自www.66RPG.com,使用和转载请保留此信息
  6. #
  7. #   作者:fukuyama   
  8. #
  9. #   移植:ONEWateR
  10. #
  11. #==============================================================================
  12. module Train_Actor

  13. #是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX
  14. #开关打开,跟随的人物就消失了(其实只是变成透明而已)

  15. TRANSPARENT_SWITCH = true
  16. TRANSPARENT_SWITCHES_INDEX = 1
  17. #举例:第一个为true,第二个为20,则打开20号开关,后面的人都没了。

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

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

  26. class Game_Party_Actor < Game_Character
  27. def initialize
  28. super()
  29. @through = true
  30. end
  31. def setup(actor)
  32. if actor != nil
  33. @character_index = actor.character_index
  34. @character_name = actor.character_name
  35. @priority_type = 1
  36. else
  37. @character_name = ""
  38. @character_index = 0
  39. @priority_type = 1
  40. end
  41. # 不透明度と合成方法を初期化
  42. @opacity = 255
  43. @blend_type = 0
  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 new_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 new_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 new_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 new_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 (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
  124. (new_passable?(@x, @y, Input::LEFT) and new_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 (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
  141. (new_passable?(@x, @y, Input::RIGHT) and new_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 (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
  158. (new_passable?(@x, @y, Input::LEFT) and new_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 (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
  175. (new_passable?(@x, @y, Input::RIGHT) and new_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($game_party.members[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. if $game_player.dash?
  240. character.move_speed = $game_player.move_speed*1.25
  241. else
  242. character.move_speed = $game_player.move_speed
  243. end
  244. character.step_anime = $game_player.step_anime
  245. character.update
  246. end
  247. end
  248. def moveto_party_actors( x, y )
  249. setup_actor_character_sprites
  250. for character in @characters
  251. character.moveto( x, y )
  252. end
  253. if @move_list == nil
  254. @move_list = []
  255. end
  256. move_list_setup
  257. end
  258. def move_party_actors
  259. if @move_list == nil
  260. @move_list = []
  261. move_list_setup
  262. end
  263. @move_list.each_index do |i|
  264. if @characters[i] != nil
  265. case @move_list[i].type
  266. when Input::DOWN
  267. @characters[i].move_down(@move_list[i].args[0])
  268. when Input::LEFT
  269. @characters[i].move_left(@move_list[i].args[0])
  270. when Input::RIGHT
  271. @characters[i].move_right(@move_list[i].args[0])
  272. when Input::UP
  273. @characters[i].move_up(@move_list[i].args[0])
  274. when DOWN_LEFT
  275. @characters[i].move_lower_left
  276. when DOWN_RIGHT
  277. @characters[i].move_lower_right
  278. when UP_LEFT
  279. @characters[i].move_upper_left
  280. when UP_RIGHT
  281. @characters[i].move_upper_right
  282. when JUMP
  283. @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  284. end
  285. end
  286. end
  287. end
  288. class Move_List_Element
  289. def initialize(type,args)
  290. @type = type
  291. @args = args
  292. end
  293. def type() return @type end
  294. def args() return @args end
  295. end
  296. def move_list_setup
  297. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  298. @move_list[i] = nil
  299. end
  300. end
  301. def add_move_list(type,*args)
  302. @move_list.unshift(Move_List_Element.new(type,args)).pop
  303. end
  304. def move_down_party_actors(turn_enabled = true)
  305. move_party_actors
  306. add_move_list(Input::DOWN,turn_enabled)
  307. end
  308. def move_left_party_actors(turn_enabled = true)
  309. move_party_actors
  310. add_move_list(Input::LEFT,turn_enabled)
  311. end
  312. def move_right_party_actors(turn_enabled = true)
  313. move_party_actors
  314. add_move_list(Input::RIGHT,turn_enabled)
  315. end
  316. def move_up_party_actors(turn_enabled = true)
  317. move_party_actors
  318. add_move_list(Input::UP,turn_enabled)
  319. end
  320. def move_lower_left_party_actors
  321. move_party_actors
  322. add_move_list(DOWN_LEFT)
  323. end
  324. def move_lower_right_party_actors
  325. move_party_actors
  326. add_move_list(DOWN_RIGHT)
  327. end
  328. def move_upper_left_party_actors
  329. move_party_actors
  330. add_move_list(UP_LEFT)
  331. end
  332. def move_upper_right_party_actors
  333. move_party_actors
  334. add_move_list(UP_RIGHT)
  335. end
  336. def jump_party_actors(x_plus, y_plus)
  337. move_party_actors
  338. add_move_list(JUMP,x_plus, y_plus)
  339. end
  340. end
  341. module Game_Player_Module
  342. def update
  343. $game_party.update_party_actors
  344. super
  345. end
  346. def moveto( x, y )
  347. $game_party.moveto_party_actors( x, y )
  348. super( x, y )
  349. end
  350. def move_down(turn_enabled = true)
  351. if new_passable?(@x, @y, Input::DOWN)
  352. $game_party.move_down_party_actors(turn_enabled)
  353. end
  354. super(turn_enabled)
  355. end
  356. def move_left(turn_enabled = true)
  357. if new_passable?(@x, @y, Input::LEFT)
  358. $game_party.move_left_party_actors(turn_enabled)
  359. end
  360. super(turn_enabled)
  361. end
  362. def move_right(turn_enabled = true)
  363. if new_passable?(@x, @y, Input::RIGHT)
  364. $game_party.move_right_party_actors(turn_enabled)
  365. end
  366. super(turn_enabled)
  367. end
  368. def move_up(turn_enabled = true)
  369. if new_passable?(@x, @y, Input::UP)
  370. $game_party.move_up_party_actors(turn_enabled)
  371. end
  372. super(turn_enabled)
  373. end
  374. def move_lower_left
  375. # 下→左、左→下 のどちらかのコースが通行可能な場合
  376. if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
  377. (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
  378. $game_party.move_lower_left_party_actors
  379. end
  380. super
  381. end
  382. def move_lower_right
  383. # 下→右、右→下 のどちらかのコースが通行可能な場合
  384. if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
  385. (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
  386. $game_party.move_lower_right_party_actors
  387. end
  388. super
  389. end
  390. def move_upper_left
  391. # 上→左、左→上 のどちらかのコースが通行可能な場合
  392. if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
  393. (new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
  394. $game_party.move_upper_left_party_actors
  395. end
  396. super
  397. end
  398. def move_upper_right
  399. # 上→右、右→上 のどちらかのコースが通行可能な場合
  400. if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
  401. (new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
  402. $game_party.move_upper_right_party_actors
  403. end
  404. super
  405. end
  406. def jump(x_plus, y_plus)
  407. # 新しい座標を計算
  408. new_x = @x + x_plus
  409. new_y = @y + y_plus
  410. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  411. if (x_plus == 0 and y_plus == 0) or new_passable?(new_x, new_y, 0)
  412. $game_party.jump_party_actors(x_plus, y_plus)
  413. end
  414. super(x_plus, y_plus)
  415. end
  416. attr_accessor :move_speed
  417. attr_accessor :step_anime
  418. end
  419. end # module Train_Actor
  420. class Game_Party
  421. include Train_Actor::Game_Party_Module
  422. end
  423. class Game_Player
  424. include Train_Actor::Game_Player_Module
  425. end
  426. class Spriteset_Map
  427. include Train_Actor::Spriteset_Map_Module
  428. end
  429. class Scene_Map
  430. include Train_Actor::Scene_Map_Module
  431. end
  432. class Game_Character
  433. def new_passable?(x, y, d)
  434. new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  435. new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  436. unless $game_map.valid?(new_x, new_y)
  437. return false
  438. end
  439. x = $game_map.round_x(x)                        # 横方向循环修正
  440. y = $game_map.round_y(y)                        # 纵方向循环修正
  441. return false unless $game_map.valid?(x, y)      # 地图外?
  442. return true if @through or debug_through?       # 穿越 ON?
  443. return false unless map_passable?(new_x, new_y)         # 地图不能通行?
  444. return false if collide_with_characters?(new_x, new_y)  # 与角色冲突?
  445. return true                                     # 可以通行
  446. end
  447. end
复制代码


作者: 悠嘻游戏    时间: 2008-12-7 17:28
提示: 作者被禁止或删除 内容自动屏蔽
作者: 木葬枫    时间: 2009-1-3 23:59
发布完毕  VIP + 2
发布地址:http://rpg.blue/web/htm/news1238.htm
作者: ONEWateR    时间: 2009-1-4 00:00
啊……摸摸木木。
终于开始发布了。加油哦↖(^ω^)↗
作者: 木葬枫    时间: 2009-1-4 00:01
以下引用ONEWateR于2009-1-3 16:00:57的发言:

啊……摸摸木木。
终于开始发布了。加油哦↖(^ω^)↗

蹭蹭前辈{/hx}昨晚才跟精灵学会地说········
作者: ONEWateR    时间: 2009-1-4 00:06
论坛附件未转移{/pz}。
作者: 木葬枫    时间: 2009-1-4 00:20
以下引用ONEWateR于2009-1-3 16:06:27的发言:

论坛附件未转移。

{/ll}转移后用的地址图片无法显示······
作者: 云鬼的精灵    时间: 2009-1-4 01:03
唔 效果好棒!
只是冲突很严重
VX八方向后 跟随的人物 脸部朝向 好……囧
更换领队后 能看见几个一模一样的人耶!
作者: GeminiLove    时间: 2009-1-7 03:50
那個……如果隊伍有8名隊員(是瘋狂了一點)
但是我只想顯示前3名隊員(像《吞食天地》那樣)
也是可以的嗎?
作者: 天烁星    时间: 2009-1-8 00:11
提示: 作者被禁止或删除 内容自动屏蔽
作者: ONEWateR    时间: 2009-1-11 04:36
以下引用云鬼的精灵于2009-1-3 17:03:19的发言:

唔 效果好棒!
只是冲突很严重
VX八方向后 跟随的人物 脸部朝向 好……囧
更换领队后 能看见几个一模一样的人耶!


这个只支持四方向的。
如果需要八方向的话,期末考试完我会试试移植。嗯。{/wx}


以下引用天烁星于2009-1-7 16:11:52的发言:

那个什么!
用这个脚本,进屋子,设置开门再关门的时候,第一人是进去了,到第二人时,门就关上了,活生生把第人夹在了门缝里!
看着甚是忧心!


可以说清楚点吗。 {/wx}
这个bug貌似没遇上...
作者: 淡淡阳光    时间: 2009-1-12 04:08
提示: 作者被禁止或删除 内容自动屏蔽
作者: 樱舞飞扬    时间: 2009-1-17 09:08
这个脚本好像和NPC名字显示脚本不兼容,不过效果是不错的{/cy}
作者: goahead    时间: 2009-1-20 18:52
提示: 作者被禁止或删除 内容自动屏蔽
作者: 770899734    时间: 2009-2-18 03:39
提示: 作者被禁止或删除 内容自动屏蔽
作者: 山巅一仕    时间: 2009-3-7 00:05
有错误啊 老大
脚本的第229行发生了NoMethodError.
undefined method'menbers'for#<game_party:0x11d3030>
作者: 迪·卡恩    时间: 2009-3-8 23:37
怎么一触发系统开关,后面跟着人就没了……
也就是一出发系统开关,脚本就失效了
作者: woodytt    时间: 2009-3-12 03:00
以下引用山巅一仕于2009-3-6 16:05:46的发言:

有错误啊 老大
脚本的第229行发生了NoMethodError.
undefined method'menbers'for#<game_party:0x11d3030>

大概是不同脚本之间不兼容的缘故吧,很好的资源真可惜……
作者: KcZ紫御流冰    时间: 2009-3-27 07:00
{/kuk}这么搞啊啊{/ll}
作者: njustlifeng    时间: 2009-4-10 01:56
这个脚本对于上船下船的时候,跟随的队友跑到海里去了,很是不和谐,考虑中。。。
作者: 巴哈姆特    时间: 2009-4-10 20:51
提示: 作者被禁止或删除 内容自动屏蔽
作者: 涛怒    时间: 2009-6-12 08:00
很棒,学习学习~
作者: longyq    时间: 2009-6-12 08:00
[quote][/quote]
作者: 黑之翅膀    时间: 2009-9-12 17:59
嗯,还有,加了脚本后很卡,连防卡都没用了
作者: gogo2005    时间: 2009-9-22 18:00
啊哦.主角一个人跑的时候挺好的,有别人加入队伍,主角就隐身了.
作者: plqws    时间: 2009-9-25 13:02
恐怖、的严重问题:
一个传送点,刚刚进路后又回来,立刻内存错误0x00000XXXX……
作者: guosibo137    时间: 2009-10-17 07:41
好东西
作者: iamouwk123    时间: 2009-11-16 23:05
提示: 作者被禁止或删除 内容自动屏蔽
作者: 黑之翅膀    时间: 2009-12-18 21:07
于 脚本 使用RPGXP步行图 冲突!
http://rpg.blue/viewthread.php?tid=75996
作者: njustlifeng    时间: 2010-7-22 10:38
循环地图时,边界的地方人物会脱钩
作者: yzbrr777    时间: 2010-7-26 20:55
那个……请问,这个脚本是要新建一个组还是怎么样……如果是新建的话,放在哪个和哪个组之间?谢谢~
作者: 负零    时间: 2010-7-26 21:36
直接插入main之前 默认脚本之后...我的水平只能这样表达
作者: yzbrr777    时间: 2010-7-26 22:59
谢谢LS了~
作者: 峰无阻    时间: 2010-8-12 19:59
提示: 作者被禁止或删除 内容自动屏蔽
作者: 1021274594    时间: 2010-8-15 18:11
楼主大爱……
作者: q97284536    时间: 2010-8-18 03:00
提示: 作者被禁止或删除 内容自动屏蔽




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