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

Project1

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

[已经过期] 这个脚本是不是冲突了?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
182 小时
注册时间
2009-4-22
帖子
208
跳转到指定楼层
1
发表于 2013-12-26 11:57:50 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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





谢谢,希望有高手帮忙解决

点评

参数个数不正确的提示。  发表于 2013-12-26 14:36

Lv1.梦旅人

狂気の月兔

梦石
0
星屑
231
在线时间
1245 小时
注册时间
2009-4-7
帖子
879

贵宾

2
发表于 2013-12-26 12:45:27 | 只看该作者
全局搜索  def map_passable?  看看结果是啥就知道了.
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
20
星屑
1840
在线时间
6925 小时
注册时间
2012-12-14
帖子
11485

短篇十战斗者组别冠军开拓者贵宾短篇九勇士组亚军

3
发表于 2013-12-26 18:01:07 | 只看该作者
或许是添加或者减少的多余的脚本
参数不正确的说
大家好,这里是晨露的说。请多多指教。
刚入门RM软件制作,请大家多多帮助我哦。
落雪君的欢乐像素教程,欢迎查阅。

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
182 小时
注册时间
2009-4-22
帖子
208
4
 楼主| 发表于 2013-12-26 21:22:54 | 只看该作者
美丽晨露 发表于 2013-12-26 18:01
或许是添加或者减少的多余的脚本
参数不正确的说


我也不知道是参数不对的,可是不知道是哪出错了,(好像3个参数少了一个的)
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 21:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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