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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
710 小时
注册时间
2013-7-26
帖子
52
跳转到指定楼层
1
发表于 2013-10-7 22:21:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

RUBY 代码复制
  1. # ————————————————————————————————————
  2.  
  3. # ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
  4. #
  5. # Train_Actor
  6. #
  7. #
  8. module Train_Actor
  9.  
  10. #是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX
  11. #开关打开,跟随的人物就消失了(其实只是变成透明而已)
  12. TRANSPARENT_SWITCH = false
  13. TRANSPARENT_SWITCHES_INDEX = 21
  14. #举例:第一个为true,第二个为21,则打开21号开关,后面的人都没了。
  15.  
  16. #跟随人数的最大数目,可以更改为2、3什么的。
  17. TRAIN_ACTOR_SIZE_MAX = 8
  18.  
  19. # 定数
  20. #Input::DOWN = 2
  21. #Input::LEFT = 4
  22. #Input::RIGHT = 6
  23. #Input::UP = 8
  24. DOWN_LEFT = 1
  25. DOWN_RIGHT = 3
  26. UP_LEFT = 7
  27. UP_RIGHT = 9
  28. JUMP = 5
  29.  
  30. class Game_Party_Actor < Game_Character
  31. def initialize
  32. super()
  33. @through = true
  34. end
  35. def setup(actor)
  36. # キャラクターのファイル名と色相を設定
  37. if actor != nil
  38. @character_name = actor.character_name
  39. @character_hue = actor.character_hue
  40. else
  41. @character_name = ""
  42. @character_hue = 0
  43. end
  44. # 不透明度と合成方法を初期化
  45.  
  46. [url=home.php?mod=space&uid=316553]@opacity[/url] = 255
  47.  
  48. if $game_player.transparent
  49.    [url=home.php?mod=space&uid=316553]@opacity[/url] = 0
  50. end
  51.  
  52. @blend_type = 0
  53. end
  54.  
  55. def screen_z(height = 0)
  56. if $game_player.x == @x and $game_player.y == @y
  57. return $game_player.screen_z(height) - 1
  58. end
  59.  
  60.  
  61. #解决跟随角色的遮掩问题
  62. if $game_map.terrain_tag(@x, @y) == 1 and $game_player.terrain_tag != 1
  63.    return $game_player.screen_z(height) + 3000
  64. end
  65. if $game_map.terrain_tag(@x, @y) != 1 and $game_player.terrain_tag == 1
  66.    return $game_player.screen_z(height) - 3000
  67. end
  68.  
  69.  
  70. super(height)
  71. end
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. attr_writer :move_speed
  79. attr_writer :step_anime
  80. end
  81. module Spriteset_Map_Module
  82. def setup_actor_character_sprites?
  83. return @setup_actor_character_sprites_flag != nil
  84. end
  85. def setup_actor_character_sprites(characters)
  86. if !setup_actor_character_sprites?
  87. index_game_player = 0
  88. @character_sprites.each_index do |i|
  89. if @character_sprites[i].character.instance_of?(Game_Player)
  90. index_game_player = i
  91. break
  92. end
  93. end
  94. for character in characters.reverse
  95. @character_sprites.unshift(
  96. Sprite_Character.new(@viewport1, character)
  97. )
  98. end
  99. @setup_actor_character_sprites_flag = true
  100. end
  101. end
  102. end
  103. module Scene_Map_Module
  104. def setup_actor_character_sprites(characters)
  105. @spriteset.setup_actor_character_sprites(characters)
  106. end
  107. end
  108. module Game_Party_Module
  109. def return_char(i)
  110. return @characters[i]
  111. end
  112. def set_transparent_actors(transparent)
  113. @transparent = transparent
  114. end
  115. def setup_actor_character_sprites
  116. if @characters == nil
  117. @characters = []
  118. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  119. @characters.push(Game_Party_Actor.new)
  120. end
  121. end
  122. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  123. @characters[i - 1].setup(actors[i])
  124. end
  125. if $scene.class.method_defined?('setup_actor_character_sprites')
  126. $scene.setup_actor_character_sprites(@characters)
  127. end
  128. end
  129. def update_party_actors
  130. setup_actor_character_sprites
  131. transparent = $game_player.transparent
  132. if transparent == false
  133. if TRANSPARENT_SWITCH
  134. transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  135. end
  136. end
  137. for character in @characters
  138. character.transparent = transparent
  139. character.move_speed = $game_player.move_speed
  140. character.step_anime = $game_player.step_anime
  141. character.update
  142. end
  143. end
  144. def moveto_party_actors( x, y )
  145. setup_actor_character_sprites
  146. for character in @characters
  147. character.moveto( x, y )
  148. end
  149. if @move_list == nil
  150. @move_list = []
  151. end
  152. move_list_setup
  153. end
  154. def move_party_actors
  155. if @move_list == nil
  156. @move_list = []
  157. move_list_setup
  158. end
  159. @move_list.each_index do |i|
  160. if @characters[i] != nil
  161. case @move_list[i].type
  162. when Input::DOWN
  163. @characters[i].move_down(@move_list[i].args[0])
  164. when Input::LEFT
  165. @characters[i].move_left(@move_list[i].args[0])
  166. when Input::RIGHT
  167. @characters[i].move_right(@move_list[i].args[0])
  168. when Input::UP
  169. @characters[i].move_up(@move_list[i].args[0])
  170. when DOWN_LEFT
  171. @characters[i].move_lower_left
  172. when DOWN_RIGHT
  173. @characters[i].move_lower_right
  174. when UP_LEFT
  175. @characters[i].move_upper_left
  176. when UP_RIGHT
  177. @characters[i].move_upper_right
  178. when JUMP
  179. @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  180. end
  181. end
  182. end
  183. end
  184. class Move_List_Element
  185. def initialize(type,args)
  186. @type = type
  187. @args = args
  188. end
  189. def type() return @type end
  190. def args() return @args end
  191. end
  192. def move_list_setup
  193. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  194. @move_list[i] = nil
  195. end
  196. end
  197. def add_move_list(type,*args)
  198. @move_list.unshift(Move_List_Element.new(type,args)).pop
  199. end
  200. def move_down_party_actors(turn_enabled = true)
  201. move_party_actors
  202. add_move_list(Input::DOWN,turn_enabled)
  203. end
  204. def move_left_party_actors(turn_enabled = true)
  205. move_party_actors
  206. add_move_list(Input::LEFT,turn_enabled)
  207. end
  208. def move_right_party_actors(turn_enabled = true)
  209. move_party_actors
  210. add_move_list(Input::RIGHT,turn_enabled)
  211. end
  212. def move_up_party_actors(turn_enabled = true)
  213. move_party_actors
  214. add_move_list(Input::UP,turn_enabled)
  215. end
  216. def move_lower_left_party_actors
  217. move_party_actors
  218. add_move_list(DOWN_LEFT)
  219. end
  220. def move_lower_right_party_actors
  221. move_party_actors
  222. add_move_list(DOWN_RIGHT)
  223. end
  224. def move_upper_left_party_actors
  225. move_party_actors
  226. add_move_list(UP_LEFT)
  227. end
  228. def move_upper_right_party_actors
  229. move_party_actors
  230. add_move_list(UP_RIGHT)
  231. end
  232. def jump_party_actors(x_plus, y_plus)
  233. move_party_actors
  234. add_move_list(JUMP,x_plus, y_plus)
  235. end
  236. end
  237. module Game_Player_Module
  238. def update
  239. $game_party.update_party_actors
  240. super
  241. end
  242. def moveto( x, y )
  243. $game_party.moveto_party_actors( x, y )
  244. super( x, y )
  245. end
  246. def move_down(turn_enabled = true)
  247. if passable?(@x, @y, Input::DOWN)
  248. $game_party.move_down_party_actors(turn_enabled)
  249. end
  250. super(turn_enabled)
  251. end
  252. def move_left(turn_enabled = true)
  253. if passable?(@x, @y, Input::LEFT)
  254. $game_party.move_left_party_actors(turn_enabled)
  255. end
  256. super(turn_enabled)
  257. end
  258. def move_right(turn_enabled = true)
  259. if passable?(@x, @y, Input::RIGHT)
  260. $game_party.move_right_party_actors(turn_enabled)
  261. end
  262. super(turn_enabled)
  263. end
  264. def move_up(turn_enabled = true)
  265. if passable?(@x, @y, Input::UP)
  266. $game_party.move_up_party_actors(turn_enabled)
  267. end
  268. super(turn_enabled)
  269. end
  270. def move_lower_left
  271. # 下→左、左→下 のどちらかのコースが通行可能な場合
  272. @direction = 1
  273. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  274. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  275. $game_party.move_lower_left_party_actors
  276. end
  277.  
  278. super
  279. end
  280. def move_lower_right
  281. # 下→右、右→下 のどちらかのコースが通行可能な場合
  282. @direction = 3
  283. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  284. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  285. $game_party.move_lower_right_party_actors
  286. end
  287. super
  288. end
  289. def move_upper_left
  290. # 上→左、左→上 のどちらかのコースが通行可能な場合
  291. @direction = 7
  292. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  293. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  294. $game_party.move_upper_left_party_actors
  295. end
  296. super
  297. end
  298. def move_upper_right
  299. # 上→右、右→上 のどちらかのコースが通行可能な場合
  300. @direction = 9
  301. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  302. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  303. $game_party.move_upper_right_party_actors
  304. end
  305. super
  306. end
  307. def jump(x_plus, y_plus)
  308. # 新しい座標を計算
  309. new_x = @x + x_plus
  310. new_y = @y + y_plus
  311. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  312. if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  313. $game_party.jump_party_actors(x_plus, y_plus)
  314. end
  315. super(x_plus, y_plus)
  316. end
  317. attr_reader :move_speed
  318. attr_reader :step_anime
  319. end
  320. end # module Train_Actor
  321. class Game_Party
  322. include Train_Actor::Game_Party_Module
  323. end
  324. class Game_Player
  325. include Train_Actor::Game_Player_Module
  326. end
  327. class Spriteset_Map
  328. include Train_Actor::Spriteset_Map_Module
  329. end
  330. class Scene_Map
  331. include Train_Actor::Scene_Map_Module
  332. end
  333.  
  334. #==============================================================================
  335. #==============================================================================

Lv1.梦旅人

梦石
0
星屑
50
在线时间
3 小时
注册时间
2015-5-22
帖子
7
2
发表于 2015-5-22 10:15:47 | 只看该作者
为什么所有脚本都有一行出现错误
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-1-9 20:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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