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

Project1

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

[已经过期] 有没有办法把人物跟随和切换领队系统整合到一起

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
84 小时
注册时间
2013-4-19
帖子
35
跳转到指定楼层
1
发表于 2013-5-18 13:39:23 | 显示全部楼层 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 jinae 于 2013-5-18 15:58 编辑

现在站上的两个脚本——人物跟随和切换领队同时使用的话,有个问题总是很困扰人啊。比如说,将第二个角色切换到了领队位置,领头人的样子变成了第二个角色,可是后面跟着的还是第二个角色。看着太别扭了。

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


这个是领队系统

RUBY 代码复制
  1. #==============================================================================
  2. # 领队更换系统 by SailCat
  3. #------------------------------------------------------------------------------
  4. # 添加此脚本后,在地图画面按下X键更换当前的领队。
  5. # 领队更改不会造成战斗队伍、菜单队伍次序的更改。
  6. # 若要在条件分歧中调用领队,请用脚本:$game_party.leader == 序号
  7. # 序号为0-3的值,最大不会超过队伍的角色数目减1。
  8. #==============================================================================
  9. class Game_Party
  10. #--------------------------------------------------------------------------
  11. # ● 追加实例变量
  12. #--------------------------------------------------------------------------
  13. attr_reader   :leader
  14. alias sailcat_initialize initialize
  15. alias sailcat_setup_starting_members setup_starting_members
  16. #--------------------------------------------------------------------------
  17. # ● 初始化对像
  18. #--------------------------------------------------------------------------
  19. def initialize
  20.    # 生成领队
  21.    @leader = 0
  22.    sailcat_initialize
  23. end
  24. #--------------------------------------------------------------------------
  25. # ● 设置初期同伴
  26. #--------------------------------------------------------------------------
  27. def setup_starting_members
  28.    sailcat_setup_starting_members
  29.    # 生成领队
  30.    @leader = 0
  31. end
  32. #--------------------------------------------------------------------------
  33. # ● 设置领队
  34. #--------------------------------------------------------------------------
  35. def switch_leader
  36.    @leader += 1
  37.    @leader %= @actors.size
  38. end
  39. end
  40. class Game_Player
  41. alias sailcat_update update
  42. #--------------------------------------------------------------------------
  43. # ● 刷新
  44. #--------------------------------------------------------------------------
  45. def refresh
  46.    # 同伴人数为 0 的情况下
  47.    if $game_party.actors.size == 0
  48.      # 清除角色的文件名及对像
  49.      @character_name = ""
  50.      @character_hue = 0
  51.      # 分支结束
  52.      return
  53.    end
  54.    # 获取带头的角色
  55.    actor = $game_party.actors[$game_party.leader]
  56.    # 设置角色的文件名及对像
  57.    @character_name = actor.character_name
  58.    @character_hue = actor.character_hue
  59.    # 初始化不透明度和合成方式
  60.    [url=home.php?mod=space&uid=316553]@opacity[/url] = 255
  61.    @blend_type = 0
  62. end
  63. #--------------------------------------------------------------------------
  64. # ● 画面更新
  65. #--------------------------------------------------------------------------
  66. def update
  67.    # 按下 A 键的情况下
  68.    if Input.trigger?(Input::A)
  69.      # 更换领队
  70.      $game_party.switch_leader
  71.      refresh
  72.    end
  73.    sailcat_update
  74. end
  75. end

  

Lv1.梦旅人

梦石
0
星屑
50
在线时间
84 小时
注册时间
2013-4-19
帖子
35
2
 楼主| 发表于 2013-5-18 15:55:41 | 显示全部楼层
本帖最后由 jinae 于 2013-5-18 16:15 编辑
wingzeroplus 发表于 2013-5-18 14:49
你说的第2个脚本偶没用过,日站的那个人物扩张系统跟跟随系统不冲突,如果不会改的话,就换这个脚本吧
...


先谢过再去试。


====

刚把你给的脚本弄进去,冲突了。我用了空轨菜单的系统,里面有整合过类似的组队位置变换功能,但是不如你这个好,空轨那个是相反的毛病,在地图上显示后面的人变了,但是领队的样子没变。。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-23 23:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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