Project1

标题: 打开一个开关后,让其召唤兽跟随角色 [打印本页]

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





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