查看: 1843|回复: 1

[已经过期] 角色跟随脚本 不刷新地图 能否收队?

[复制链接]
梦石
0
星屑
50
在线时间
710 小时
注册时间
2013-7-26
回帖
44
发表于 2013-10-7 22:21:39 | 显示全部楼层 |阅读模式

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

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

×
请教 在不刷新当前地图的情况下 ,该如何收队。(让跟随的角色 和 主角重叠)

  1. # ————————————————————————————————————

  2. # ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
  3. #
  4. # Train_Actor
  5. #
  6. #
  7. module Train_Actor

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

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

  15. # 定数
  16. #Input::DOWN = 2
  17. #Input::LEFT = 4
  18. #Input::RIGHT = 6
  19. #Input::UP = 8
  20. DOWN_LEFT = 1
  21. DOWN_RIGHT = 3
  22. UP_LEFT = 7
  23. UP_RIGHT = 9
  24. JUMP = 5

  25. class Game_Party_Actor < Game_Character
  26. def initialize
  27. super()
  28. @through = true
  29. end
  30. def setup(actor)
  31. # キャラクターのファイル名と色相を設定
  32. if actor != nil
  33. @character_name = actor.character_name
  34. @character_hue = actor.character_hue
  35. else
  36. @character_name = ""
  37. @character_hue = 0
  38. end
  39. # 不透明度と合成方法を初期化

  40. [url=home.php?mod=space&uid=316553]@opacity[/url] = 255

  41. if $game_player.transparent
  42.    [url=home.php?mod=space&uid=316553]@opacity[/url] = 0
  43. end

  44. @blend_type = 0
  45. end

  46. def screen_z(height = 0)
  47. if $game_player.x == @x and $game_player.y == @y
  48. return $game_player.screen_z(height) - 1
  49. end


  50. #解决跟随角色的遮掩问题
  51. if $game_map.terrain_tag(@x, @y) == 1 and $game_player.terrain_tag != 1
  52.    return $game_player.screen_z(height) + 3000
  53. end
  54. if $game_map.terrain_tag(@x, @y) != 1 and $game_player.terrain_tag == 1
  55.    return $game_player.screen_z(height) - 3000
  56. end


  57. super(height)
  58. end






  59. attr_writer :move_speed
  60. attr_writer :step_anime
  61. end
  62. module Spriteset_Map_Module
  63. def setup_actor_character_sprites?
  64. return @setup_actor_character_sprites_flag != nil
  65. end
  66. def setup_actor_character_sprites(characters)
  67. if !setup_actor_character_sprites?
  68. index_game_player = 0
  69. @character_sprites.each_index do |i|
  70. if @character_sprites[i].character.instance_of?(Game_Player)
  71. index_game_player = i
  72. break
  73. end
  74. end
  75. for character in characters.reverse
  76. @character_sprites.unshift(
  77. Sprite_Character.new(@viewport1, character)
  78. )
  79. end
  80. @setup_actor_character_sprites_flag = true
  81. end
  82. end
  83. end
  84. module Scene_Map_Module
  85. def setup_actor_character_sprites(characters)
  86. @spriteset.setup_actor_character_sprites(characters)
  87. end
  88. end
  89. module Game_Party_Module
  90. def return_char(i)
  91. return @characters[i]
  92. end
  93. def set_transparent_actors(transparent)
  94. @transparent = transparent
  95. end
  96. def setup_actor_character_sprites
  97. if @characters == nil
  98. @characters = []
  99. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  100. @characters.push(Game_Party_Actor.new)
  101. end
  102. end
  103. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  104. @characters[i - 1].setup(actors[i])
  105. end
  106. if $scene.class.method_defined?('setup_actor_character_sprites')
  107. $scene.setup_actor_character_sprites(@characters)
  108. end
  109. end
  110. def update_party_actors
  111. setup_actor_character_sprites
  112. transparent = $game_player.transparent
  113. if transparent == false
  114. if TRANSPARENT_SWITCH
  115. transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  116. end
  117. end
  118. for character in @characters
  119. character.transparent = transparent
  120. character.move_speed = $game_player.move_speed
  121. character.step_anime = $game_player.step_anime
  122. character.update
  123. end
  124. end
  125. def moveto_party_actors( x, y )
  126. setup_actor_character_sprites
  127. for character in @characters
  128. character.moveto( x, y )
  129. end
  130. if @move_list == nil
  131. @move_list = []
  132. end
  133. move_list_setup
  134. end
  135. def move_party_actors
  136. if @move_list == nil
  137. @move_list = []
  138. move_list_setup
  139. end
  140. @move_list.each_index do |i|
  141. if @characters[i] != nil
  142. case @move_list[i].type
  143. when Input::DOWN
  144. @characters[i].move_down(@move_list[i].args[0])
  145. when Input::LEFT
  146. @characters[i].move_left(@move_list[i].args[0])
  147. when Input::RIGHT
  148. @characters[i].move_right(@move_list[i].args[0])
  149. when Input::UP
  150. @characters[i].move_up(@move_list[i].args[0])
  151. when DOWN_LEFT
  152. @characters[i].move_lower_left
  153. when DOWN_RIGHT
  154. @characters[i].move_lower_right
  155. when UP_LEFT
  156. @characters[i].move_upper_left
  157. when UP_RIGHT
  158. @characters[i].move_upper_right
  159. when JUMP
  160. @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  161. end
  162. end
  163. end
  164. end
  165. class Move_List_Element
  166. def initialize(type,args)
  167. @type = type
  168. @args = args
  169. end
  170. def type() return @type end
  171. def args() return @args end
  172. end
  173. def move_list_setup
  174. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  175. @move_list[i] = nil
  176. end
  177. end
  178. def add_move_list(type,*args)
  179. @move_list.unshift(Move_List_Element.new(type,args)).pop
  180. end
  181. def move_down_party_actors(turn_enabled = true)
  182. move_party_actors
  183. add_move_list(Input::DOWN,turn_enabled)
  184. end
  185. def move_left_party_actors(turn_enabled = true)
  186. move_party_actors
  187. add_move_list(Input::LEFT,turn_enabled)
  188. end
  189. def move_right_party_actors(turn_enabled = true)
  190. move_party_actors
  191. add_move_list(Input::RIGHT,turn_enabled)
  192. end
  193. def move_up_party_actors(turn_enabled = true)
  194. move_party_actors
  195. add_move_list(Input::UP,turn_enabled)
  196. end
  197. def move_lower_left_party_actors
  198. move_party_actors
  199. add_move_list(DOWN_LEFT)
  200. end
  201. def move_lower_right_party_actors
  202. move_party_actors
  203. add_move_list(DOWN_RIGHT)
  204. end
  205. def move_upper_left_party_actors
  206. move_party_actors
  207. add_move_list(UP_LEFT)
  208. end
  209. def move_upper_right_party_actors
  210. move_party_actors
  211. add_move_list(UP_RIGHT)
  212. end
  213. def jump_party_actors(x_plus, y_plus)
  214. move_party_actors
  215. add_move_list(JUMP,x_plus, y_plus)
  216. end
  217. end
  218. module Game_Player_Module
  219. def update
  220. $game_party.update_party_actors
  221. super
  222. end
  223. def moveto( x, y )
  224. $game_party.moveto_party_actors( x, y )
  225. super( x, y )
  226. end
  227. def move_down(turn_enabled = true)
  228. if passable?(@x, @y, Input::DOWN)
  229. $game_party.move_down_party_actors(turn_enabled)
  230. end
  231. super(turn_enabled)
  232. end
  233. def move_left(turn_enabled = true)
  234. if passable?(@x, @y, Input::LEFT)
  235. $game_party.move_left_party_actors(turn_enabled)
  236. end
  237. super(turn_enabled)
  238. end
  239. def move_right(turn_enabled = true)
  240. if passable?(@x, @y, Input::RIGHT)
  241. $game_party.move_right_party_actors(turn_enabled)
  242. end
  243. super(turn_enabled)
  244. end
  245. def move_up(turn_enabled = true)
  246. if passable?(@x, @y, Input::UP)
  247. $game_party.move_up_party_actors(turn_enabled)
  248. end
  249. super(turn_enabled)
  250. end
  251. def move_lower_left
  252. # 下→左、左→下 のどちらかのコースが通行可能な場合
  253. @direction = 1
  254. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  255. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  256. $game_party.move_lower_left_party_actors
  257. end

  258. super
  259. end
  260. def move_lower_right
  261. # 下→右、右→下 のどちらかのコースが通行可能な場合
  262. @direction = 3
  263. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  264. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  265. $game_party.move_lower_right_party_actors
  266. end
  267. super
  268. end
  269. def move_upper_left
  270. # 上→左、左→上 のどちらかのコースが通行可能な場合
  271. @direction = 7
  272. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  273. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  274. $game_party.move_upper_left_party_actors
  275. end
  276. super
  277. end
  278. def move_upper_right
  279. # 上→右、右→上 のどちらかのコースが通行可能な場合
  280. @direction = 9
  281. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  282. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  283. $game_party.move_upper_right_party_actors
  284. end
  285. super
  286. end
  287. def jump(x_plus, y_plus)
  288. # 新しい座標を計算
  289. new_x = @x + x_plus
  290. new_y = @y + y_plus
  291. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  292. if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  293. $game_party.jump_party_actors(x_plus, y_plus)
  294. end
  295. super(x_plus, y_plus)
  296. end
  297. attr_reader :move_speed
  298. attr_reader :step_anime
  299. end
  300. end # module Train_Actor
  301. class Game_Party
  302. include Train_Actor::Game_Party_Module
  303. end
  304. class Game_Player
  305. include Train_Actor::Game_Player_Module
  306. end
  307. class Spriteset_Map
  308. include Train_Actor::Spriteset_Map_Module
  309. end
  310. class Scene_Map
  311. include Train_Actor::Scene_Map_Module
  312. end

  313. #==============================================================================
  314. #==============================================================================
复制代码

梦石
0
星屑
50
在线时间
3 小时
注册时间
2015-5-22
回帖
6
发表于 2015-5-22 10:15:47 | 显示全部楼层
为什么所有脚本都有一行出现错误
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部