Project1

标题: 谁能给我一个八方向小地图脚本和跟屁虫脚本呢!! [打印本页]

作者: lovelmq    时间: 2007-7-9 18:40
标题: 谁能给我一个八方向小地图脚本和跟屁虫脚本呢!!
谁能给我一个八方向小地图脚本和跟屁虫脚本呢!!谢谢..
作者: lovelmq    时间: 2007-7-9 18:40
标题: 谁能给我一个八方向小地图脚本和跟屁虫脚本呢!!
谁能给我一个八方向小地图脚本和跟屁虫脚本呢!!谢谢..
作者: 电鳗    时间: 2007-7-10 00:09
人物跟随
  1. ]# ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载自www.phylomortis.com,转载请保留此信息
  3. # ————————————————————————————————————

  4. # ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
  5. # by fukuyama

  6. #
  7. # Train_Actor
  8. #
  9. # [email protected]
  10. # http://www4.big.or.jp/~fukuyama/rgss/Train_Actor.txt
  11. #

  12. module Train_Actor




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





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





  20. # 定数
  21. #Input::DOWN = 2
  22. #Input::LEFT = 4
  23. #Input::RIGHT = 6
  24. #Input::UP = 6
  25. DOWN_LEFT = 1
  26. DOWN_RIGHT = 3
  27. UP_LEFT = 7
  28. UP_RIGHT = 9
  29. JUMP = 5

  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. @opacity = 255
  46. @blend_type = 0
  47. end
  48. def screen_z(height = 0)
  49. if $game_player.x == @x and $game_player.y == @y
  50. return $game_player.screen_z(height) - 1
  51. end
  52. super(height)
  53. end
  54. #--------------------------------------------------------------------------
  55. # ● 下に移動
  56. # turn_enabled : その場での向き変更を許可するフラグ
  57. #--------------------------------------------------------------------------
  58. def move_down(turn_enabled = true)
  59. # 下を向く
  60. if turn_enabled
  61. turn_down
  62. end
  63. # 通行可能な場合
  64. if passable?(@x, @y, Input::DOWN)
  65. # 下を向く
  66. turn_down
  67. # 座標を更新
  68. @y += 1
  69. end
  70. end
  71. #--------------------------------------------------------------------------
  72. # ● 左に移動
  73. # turn_enabled : その場での向き変更を許可するフラグ
  74. #--------------------------------------------------------------------------
  75. def move_left(turn_enabled = true)
  76. # 左を向く
  77. if turn_enabled
  78. turn_left
  79. end
  80. # 通行可能な場合
  81. if passable?(@x, @y, Input::LEFT)
  82. # 左を向く
  83. turn_left
  84. # 座標を更新
  85. @x -= 1
  86. end
  87. end
  88. #--------------------------------------------------------------------------
  89. # ● 右に移動
  90. # turn_enabled : その場での向き変更を許可するフラグ
  91. #--------------------------------------------------------------------------
  92. def move_right(turn_enabled = true)
  93. # 右を向く
  94. if turn_enabled
  95. turn_right
  96. end
  97. # 通行可能な場合
  98. if passable?(@x, @y, Input::RIGHT)
  99. # 右を向く
  100. turn_right
  101. # 座標を更新
  102. @x += 1
  103. end
  104. end
  105. #--------------------------------------------------------------------------
  106. # ● 上に移動
  107. # turn_enabled : その場での向き変更を許可するフラグ
  108. #--------------------------------------------------------------------------
  109. def move_up(turn_enabled = true)
  110. # 上を向く
  111. if turn_enabled
  112. turn_up
  113. end
  114. # 通行可能な場合
  115. if passable?(@x, @y, Input::UP)
  116. # 上を向く
  117. turn_up
  118. # 座標を更新
  119. @y -= 1
  120. end
  121. end
  122. #--------------------------------------------------------------------------
  123. # ● 左下に移動
  124. #--------------------------------------------------------------------------
  125. def move_lower_left
  126. # 向き固定でない場合
  127. unless @direction_fix
  128. # 右向きだった場合は左を、上向きだった場合は下を向く
  129. @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  130. end
  131. # 下→左、左→下 のどちらかのコースが通行可能な場合
  132. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  133. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  134. # 座標を更新
  135. @x -= 1
  136. @y += 1
  137. end
  138. end
  139. #--------------------------------------------------------------------------
  140. # ● 右下に移動
  141. #--------------------------------------------------------------------------
  142. def move_lower_right
  143. # 向き固定でない場合
  144. unless @direction_fix
  145. # 左向きだった場合は右を、上向きだった場合は下を向く
  146. @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  147. end
  148. # 下→右、右→下 のどちらかのコースが通行可能な場合
  149. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  150. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  151. # 座標を更新
  152. @x += 1
  153. @y += 1
  154. end
  155. end
  156. #--------------------------------------------------------------------------
  157. # ● 左上に移動
  158. #--------------------------------------------------------------------------
  159. def move_upper_left
  160. # 向き固定でない場合
  161. unless @direction_fix
  162. # 右向きだった場合は左を、下向きだった場合は上を向く
  163. @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  164. end
  165. # 上→左、左→上 のどちらかのコースが通行可能な場合
  166. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  167. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  168. # 座標を更新
  169. @x -= 1
  170. @y -= 1
  171. end
  172. end
  173. #--------------------------------------------------------------------------
  174. # ● 右上に移動
  175. #--------------------------------------------------------------------------
  176. def move_upper_right
  177. # 向き固定でない場合
  178. unless @direction_fix
  179. # 左向きだった場合は右を、下向きだった場合は上を向く
  180. @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  181. end
  182. # 上→右、右→上 のどちらかのコースが通行可能な場合
  183. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  184. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  185. # 座標を更新
  186. @x += 1
  187. @y -= 1
  188. end
  189. end
  190. attr_writer :move_speed
  191. attr_writer :step_anime
  192. end
  193. module Spriteset_Map_Module
  194. def setup_actor_character_sprites?
  195. return @setup_actor_character_sprites_flag != nil
  196. end
  197. def setup_actor_character_sprites(characters)
  198. if !setup_actor_character_sprites?
  199. index_game_player = 0
  200. @character_sprites.each_index do |i|
  201. if @character_sprites[i].character.instance_of?(Game_Player)
  202. index_game_player = i
  203. break
  204. end
  205. end
  206. for character in characters.reverse
  207. @character_sprites.unshift(
  208. Sprite_Character.new(@viewport1, character)
  209. )
  210. end
  211. @setup_actor_character_sprites_flag = true
  212. end
  213. end
  214. end
  215. module Scene_Map_Module
  216. def setup_actor_character_sprites(characters)
  217. @spriteset.setup_actor_character_sprites(characters)
  218. end
  219. end
  220. module Game_Party_Module
  221. def set_transparent_actors(transparent)
  222. @transparent = transparent
  223. end
  224. def setup_actor_character_sprites
  225. if @characters == nil
  226. @characters = []
  227. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  228. @characters.push(Game_Party_Actor.new)
  229. end
  230. end
  231. for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  232. @characters[i - 1].setup(actors[i])
  233. end
  234. if $scene.class.method_defined?('setup_actor_character_sprites')
  235. $scene.setup_actor_character_sprites(@characters)
  236. end
  237. end
  238. def update_party_actors
  239. setup_actor_character_sprites
  240. transparent = $game_player.transparent
  241. if transparent == false
  242. if TRANSPARENT_SWITCH
  243. transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  244. end
  245. end
  246. for character in @characters
  247. character.transparent = transparent
  248. character.move_speed = $game_player.move_speed
  249. character.step_anime = $game_player.step_anime
  250. character.update
  251. end
  252. end
  253. def moveto_party_actors( x, y )
  254. setup_actor_character_sprites
  255. for character in @characters
  256. character.moveto( x, y )
  257. end
  258. if @move_list == nil
  259. @move_list = []
  260. end
  261. move_list_setup
  262. end
  263. def move_party_actors
  264. if @move_list == nil
  265. @move_list = []
  266. move_list_setup
  267. end
  268. @move_list.each_index do |i|
  269. if @characters[i] != nil
  270. case @move_list[i].type
  271. when Input::DOWN
  272. @characters[i].move_down(@move_list[i].args[0])
  273. when Input::LEFT
  274. @characters[i].move_left(@move_list[i].args[0])
  275. when Input::RIGHT
  276. @characters[i].move_right(@move_list[i].args[0])
  277. when Input::UP
  278. @characters[i].move_up(@move_list[i].args[0])
  279. when DOWN_LEFT
  280. @characters[i].move_lower_left
  281. when DOWN_RIGHT
  282. @characters[i].move_lower_right
  283. when UP_LEFT
  284. @characters[i].move_upper_left
  285. when UP_RIGHT
  286. @characters[i].move_upper_right
  287. when JUMP
  288. @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  289. end
  290. end
  291. end
  292. end
  293. class Move_List_Element
  294. def initialize(type,args)
  295. @type = type
  296. @args = args
  297. end
  298. def type() return @type end
  299. def args() return @args end
  300. end
  301. def move_list_setup
  302. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  303. @move_list[i] = nil
  304. end
  305. end
  306. def add_move_list(type,*args)
  307. @move_list.unshift(Move_List_Element.new(type,args)).pop
  308. end
  309. def move_down_party_actors(turn_enabled = true)
  310. move_party_actors
  311. add_move_list(Input::DOWN,turn_enabled)
  312. end
  313. def move_left_party_actors(turn_enabled = true)
  314. move_party_actors
  315. add_move_list(Input::LEFT,turn_enabled)
  316. end
  317. def move_right_party_actors(turn_enabled = true)
  318. move_party_actors
  319. add_move_list(Input::RIGHT,turn_enabled)
  320. end
  321. def move_up_party_actors(turn_enabled = true)
  322. move_party_actors
  323. add_move_list(Input::UP,turn_enabled)
  324. end
  325. def move_lower_left_party_actors
  326. move_party_actors
  327. add_move_list(DOWN_LEFT)
  328. end
  329. def move_lower_right_party_actors
  330. move_party_actors
  331. add_move_list(DOWN_RIGHT)
  332. end
  333. def move_upper_left_party_actors
  334. move_party_actors
  335. add_move_list(UP_LEFT)
  336. end
  337. def move_upper_right_party_actors
  338. move_party_actors
  339. add_move_list(UP_RIGHT)
  340. end
  341. def jump_party_actors(x_plus, y_plus)
  342. move_party_actors
  343. add_move_list(JUMP,x_plus, y_plus)
  344. end
  345. end
  346. module Game_Player_Module
  347. def update
  348. $game_party.update_party_actors
  349. super
  350. end
  351. def moveto( x, y )
  352. $game_party.moveto_party_actors( x, y )
  353. super( x, y )
  354. end
  355. def move_down(turn_enabled = true)
  356. if passable?(@x, @y, Input::DOWN)
  357. $game_party.move_down_party_actors(turn_enabled)
  358. end
  359. super(turn_enabled)
  360. end
  361. def move_left(turn_enabled = true)
  362. if passable?(@x, @y, Input::LEFT)
  363. $game_party.move_left_party_actors(turn_enabled)
  364. end
  365. super(turn_enabled)
  366. end
  367. def move_right(turn_enabled = true)
  368. if passable?(@x, @y, Input::RIGHT)
  369. $game_party.move_right_party_actors(turn_enabled)
  370. end
  371. super(turn_enabled)
  372. end
  373. def move_up(turn_enabled = true)
  374. if passable?(@x, @y, Input::UP)
  375. $game_party.move_up_party_actors(turn_enabled)
  376. end
  377. super(turn_enabled)
  378. end
  379. def move_lower_left
  380. # 下→左、左→下 のどちらかのコースが通行可能な場合
  381. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  382. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  383. $game_party.move_lower_left_party_actors
  384. end
  385. super
  386. end
  387. def move_lower_right
  388. # 下→右、右→下 のどちらかのコースが通行可能な場合
  389. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  390. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  391. $game_party.move_lower_right_party_actors
  392. end
  393. super
  394. end
  395. def move_upper_left
  396. # 上→左、左→上 のどちらかのコースが通行可能な場合
  397. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  398. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  399. $game_party.move_upper_left_party_actors
  400. end
  401. super
  402. end
  403. def move_upper_right
  404. # 上→右、右→上 のどちらかのコースが通行可能な場合
  405. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  406. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  407. $game_party.move_upper_right_party_actors
  408. end
  409. super
  410. end
  411. def jump(x_plus, y_plus)
  412. # 新しい座標を計算
  413. new_x = @x + x_plus
  414. new_y = @y + y_plus
  415. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  416. if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  417. $game_party.jump_party_actors(x_plus, y_plus)
  418. end
  419. super(x_plus, y_plus)
  420. end
  421. attr_reader :move_speed
  422. attr_reader :step_anime
  423. end
  424. end # module Train_Actor
  425. class Game_Party
  426. include Train_Actor::Game_Party_Module
  427. end
  428. class Game_Player
  429. include Train_Actor::Game_Player_Module
  430. end
  431. class Spriteset_Map
  432. include Train_Actor::Spriteset_Map_Module
  433. end
  434. class Scene_Map
  435. include Train_Actor::Scene_Map_Module
  436. end
复制代码

作者: kaze    时间: 2007-7-10 00:31
建议转到新手区
作者: 逐月    时间: 2008-1-27 20:06
提示: 作者被禁止或删除 内容自动屏蔽
作者: 天圣的马甲    时间: 2008-1-31 15:45
正准备回复,抬头看一眼发帖日期……一顿恶寒||||||

LS,下次别挖坟了……谢谢合作。这帖子直接过期。{/gg}




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