Advertisement
dsiver144

Untitled

Nov 25th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.22 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Card Fusion
  3. # -- Last Updated: 2017.11.25
  4. # -- Author: dsiver144
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #==============================================================================
  8. $imported = {} if $imported.nil?
  9. $imported["DSI-CardFusion"] = true
  10. #==============================================================================
  11. # + Updates
  12. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  13. # 2017.11.25 - Finish first version.
  14. #==============================================================================
  15. # + Instructions
  16. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. # To install this script, open up your script editor and copy/paste this script
  18. # to an open slot below ▼Materials but above ▼Main. Remember to save.
  19. #==============================================================================
  20. module DSIVER144
  21. module CARD_FUSION
  22.  
  23. SELECTED_ICON = 3849
  24.  
  25. SUCCESS_ANIME = 530
  26. FAIL_ANIME = 531
  27.  
  28. DISABLE_SWITCH = 10 # Turn this switch on will disable fusion mode in battle
  29.  
  30. TRANSFORM_TIME = 12 # Playaround with this when you change the fusion
  31. # animation.
  32.  
  33. COMBINATIONS = {} # Don't delete this
  34.  
  35. NEW_DISCOVERY_BGM = ["Field3",70,100]
  36. SELECT_SE = ["CursorFF7",70,100]
  37. DESELECT_SE = ["Cancel (FF7)",70,100]
  38. TOGGLE_SE = ["Miss",70,100]
  39.  
  40. COMBINATIONS[1] = {}
  41. COMBINATIONS[1][:mode] = :right_order
  42. COMBINATIONS[1][:cards] = [17,18,19]
  43. COMBINATIONS[1][:card_get] = 20
  44.  
  45. COMBINATIONS[2] = {}
  46. COMBINATIONS[2][:mode] = :any_order
  47. COMBINATIONS[2][:cards] = [28,28,28,28,28]
  48. COMBINATIONS[2][:card_get] = 18
  49. #------------------------------------------------------------------------
  50. CARD_POS = {}
  51. CARD_POS[3] = [[60,240],[230,240],[400,240]]
  52. CARD_POS[4] = [[30,240],[160,240],[290,240],[420,240]]
  53. CARD_POS[5] = [[15,240],[120,240],[225,240],[330,240],[435,240]]
  54. #------------------------------------------------------------------------
  55. # * new method: check
  56. #------------------------------------------------------------------------
  57. def self.check(card_ids)
  58. COMBINATIONS.each_pair do |index,item|
  59. if item[:mode] == :right_order
  60. if card_ids == item[:cards]
  61. if !$game_system.fusion_discovered.include?(index)
  62. $new_combination = true
  63. $game_system.fusion_discovered << index
  64. end
  65. return item[:card_get]
  66. end
  67. else
  68. if card_ids.sort == item[:cards].sort
  69. if !$game_system.fusion_discovered.include?(index)
  70. $new_combination = true
  71. $game_system.fusion_discovered << index
  72. end
  73. return item[:card_get]
  74. end
  75. end
  76. end
  77. return nil
  78. end
  79. end # CARD_FUSION
  80. end # DSIVER144
  81.  
  82. class Scene_Battle
  83. include DSIVER144::CARD_FUSION
  84. #--------------------------------------------------------------------------
  85. # * Start Turn
  86. #--------------------------------------------------------------------------
  87. alias_method(:dsi_card_fusion_turn_start, :turn_start)
  88. def turn_start
  89. @fusion_enable = true
  90. dsi_card_fusion_turn_start
  91. end
  92. #--------------------------------------------------------------------------
  93. # Create Skill Window with card help window instead of normal help window (overwrite)
  94. #--------------------------------------------------------------------------
  95. def create_skill_window
  96. @fusion_mode = :none
  97.  
  98. @skill_window = Window_BattleSkill.new(@cardhelp_window, @info_viewport)
  99. @skill_window.set_handler(:ok, method(:on_skill_ok))
  100. @skill_window.set_handler(:cancel, method(:on_skill_cancel))
  101.  
  102. wy = @skill_window.height + @skill_window.y
  103. @fusion_indicator = Window_Base.new(0,wy,@skill_window.width,46)
  104. @fusion_indicator.draw_text_ex(0,0,"\\i[1609] Card Fusion")
  105. @fusion_indicator.hide
  106. @skill_window.indicator_window = @fusion_indicator
  107.  
  108. @fusion_window = Window_FusionBattleSkill.new(@cardhelp_window, @info_viewport)
  109. @fusion_window.hide
  110. @fusion_window.deactivate
  111. @fusion_enable = true
  112. @fusion_window.indicator_window = @fusion_indicator
  113.  
  114. @fusion_window.off_method = method(:turn_off_fusion_mode)
  115. @fusion_window.complete_method = method(:fusion_complete)
  116. @fusion_window.confirm_method = method(:fusion_comfirmation)
  117. #------------------------------------------------------------------------
  118. @fusion_text = Window_Base.new(0,0,150,46)
  119. cw = @fusion_text.contents_width; ch = @fusion_text.contents_height
  120. @fusion_text.draw_text(0,0, cw, ch,"Fuse Chosen Cards?",1)
  121. @fusion_command_window = Window_FusionCofirm.new(0,0)
  122. @fusion_command_window.set_handler(:ok, method(:on_fusion_ok))
  123. @fusion_command_window.set_handler(:cancel, method(:on_fusion_cancel))
  124. @fusion_text.x = 0.5*(Graphics.width - @fusion_text.width)
  125. @fusion_command_window.x = @fusion_text.x
  126. @fusion_text.y = 0.5*(Graphics.height - @fusion_text.height - @fusion_command_window.height) - 50
  127. @fusion_command_window.y = @fusion_text.y + @fusion_text.height
  128. @fusion_command_window.hide.deactivate
  129. @fusion_text.hide
  130. @new_discover_text = Window_Base.new(0,0,450,46)
  131. cw = @new_discover_text.contents_width; ch = @new_discover_text.contents_height
  132. @new_discover_text.draw_text(0,0, cw, ch,"You've just discovered a new fusion combination!",1)
  133. @new_discover_text.openness = 0
  134. @new_discover_text.x = 0.5*(Graphics.width - @new_discover_text.width)
  135. @new_discover_text.y = 0.5*(Graphics.height - @new_discover_text.height) - 50
  136. @new_discover_text.close
  137. #------------------------------------------------------------------------
  138. @fusion_card_sprites = {}
  139. for i in 1..5
  140. @fusion_card_sprites[i] = Sprite_Base.new(@viewport)
  141. end
  142. @fusion_card_sprites.values.each do |sprite|
  143. sprite.z = 500
  144. sprite.zoom_x = 0.5
  145. sprite.zoom_y = 0.5
  146. sprite.visible = false
  147. end
  148. end
  149. #--------------------------------------------------------------------------
  150. # * new method: update_indicator
  151. #--------------------------------------------------------------------------
  152. def update_indicator
  153. if BattleManager.actor
  154. if BattleManager.actor.tp > 0 && @fusion_enable && !$game_switches[DISABLE_SWITCH]
  155. @fusion_mode = :enable
  156. else
  157. @fusion_mode = :disable
  158. end
  159. end
  160. if @fusion_window.active
  161. @fusion_mode = :now
  162. end
  163. if @fusion_mode == :enable
  164. @fusion_indicator.change_color(@fusion_indicator.normal_color,true)
  165. elsif @fusion_mode == :disable
  166. @fusion_indicator.change_color(@fusion_indicator.normal_color,false)
  167. elsif @fusion_mode == :now
  168. @fusion_indicator.change_color(@fusion_indicator.crisis_color,true)
  169. end
  170. p @fusion_mode
  171. @fusion_indicator.contents.clear
  172. @fusion_indicator.draw_icon(1609, 0, 0)
  173. @fusion_indicator.draw_text(25,0,150,30,"Card Fusion")
  174. end
  175. #--------------------------------------------------------------------------
  176. # * [Skill] Command
  177. #--------------------------------------------------------------------------
  178. def command_skill
  179. @skill_window.actor = BattleManager.actor
  180. @skill_window.stype_id = @actor_command_window.current_ext
  181. @skill_window.refresh
  182. @skill_window.show.activate
  183. @fusion_indicator.show
  184. update_indicator
  185. end
  186. #--------------------------------------------------------------------------
  187. # * Skill [Cancel]
  188. #--------------------------------------------------------------------------
  189. def on_skill_cancel
  190. @skill_window.hide
  191. @actor_command_window.activate
  192. @fusion_indicator.hide
  193. end
  194. #--------------------------------------------------------------------------
  195. # * new method: turn_off_fusion_mode
  196. #--------------------------------------------------------------------------
  197. def turn_off_fusion_mode
  198. @fusion_window.hide.deactivate
  199. @skill_window.actor = BattleManager.actor
  200. @skill_window.show.activate
  201. @skill_window.refresh
  202. update_indicator
  203. end
  204. #--------------------------------------------------------------------------
  205. # * new method: fusion_complete
  206. #--------------------------------------------------------------------------
  207. def fusion_complete
  208. @fusion_enable = false
  209. end
  210. #--------------------------------------------------------------------------
  211. # * new method: confirm_on
  212. #--------------------------------------------------------------------------
  213. def confirm_on
  214. @fusion_command_window.show.activate
  215. @fusion_text.show
  216. end
  217. #--------------------------------------------------------------------------
  218. # * new method: show_card_images
  219. #--------------------------------------------------------------------------
  220. def show_card_images
  221. pos = CARD_POS[@selected_cards.size]
  222. @selected_cards.each_with_index do |id,index|
  223. @fusion_card_sprites[index + 1].visible = true
  224. @fusion_card_sprites[index + 1].bitmap = Cache.picture("Card#{id}")
  225. offset_x = @fusion_card_sprites[index + 1].bitmap.width * 0.5
  226. offset_y = @fusion_card_sprites[index + 1].bitmap.height * 0.5
  227. @fusion_card_sprites[index + 1].ox = offset_x
  228. @fusion_card_sprites[index + 1].oy = offset_y
  229. @fusion_card_sprites[index + 1].x = pos[index][0] + offset_x * 0.5
  230. @fusion_card_sprites[index + 1].y = pos[index][1] + offset_y * 0.5
  231. end
  232. if @selected_cards.size == 3
  233. @center_x = @fusion_card_sprites[2].x
  234. end
  235. if @selected_cards.size == 4
  236. @center_x = 0.5*(Graphics.width - @fusion_card_sprites[1].bitmap.width) + 90
  237. end
  238. if @selected_cards.size == 5
  239. @center_x = @fusion_card_sprites[3].x
  240. end
  241. end
  242. #--------------------------------------------------------------------------
  243. # * new method: hide_card_images
  244. #--------------------------------------------------------------------------
  245. def hide_card_images
  246. while @fusion_card_sprites[1].opacity > 0
  247. @fusion_card_sprites.values.each do |sprite|
  248. sprite.opacity -= 5
  249. end
  250. Graphics.update
  251. end
  252. @fusion_card_sprites.values.each do |sprite|
  253. sprite.visible = false
  254. sprite.opacity = 255
  255. sprite.bitmap = nil
  256. end
  257. end
  258. #-------------------------------------------------------------------------
  259. # * new method: easeInOutQuad
  260. #-------------------------------------------------------------------------
  261. def easeInOutQuad(t, b, c, d)
  262. t = t / (d/2.0)
  263. if (t < 1)
  264. return c/2*t*t + b
  265. end
  266. t -= 1
  267. return -c/2.0 * (t*(t-2) - 1) + b
  268. end
  269. #--------------------------------------------------------------------------
  270. # * new method: card_animation3
  271. #--------------------------------------------------------------------------
  272. def card_animation3(success)
  273. spr1 = @fusion_card_sprites[1]
  274. spr2 = @fusion_card_sprites[2]
  275. spr3 = @fusion_card_sprites[3]
  276. colorWhite = Color.new(255,255,255)
  277. spr1.flash(colorWhite,20)
  278. spr2.flash(colorWhite,20)
  279. spr3.flash(colorWhite,20)
  280. while spr1.zoom_x < 0.6
  281. spr1.zoom_x += 0.01
  282. spr1.zoom_y += 0.01
  283. spr2.zoom_x += 0.01
  284. spr2.zoom_y += 0.01
  285. spr3.zoom_x += 0.01
  286. spr3.zoom_y += 0.01
  287. spr1.update
  288. spr2.update
  289. spr3.update
  290. Graphics.update
  291. end
  292. while spr1.zoom_x > 0.5
  293. spr1.zoom_x -= 0.01
  294. spr1.zoom_y -= 0.01
  295. spr2.zoom_x -= 0.01
  296. spr2.zoom_y -= 0.01
  297. spr3.zoom_x -= 0.01
  298. spr3.zoom_y -= 0.01
  299. spr1.update
  300. spr2.update
  301. spr3.update
  302. Graphics.update
  303. end
  304. s1 = spr1.x
  305. s3 = spr3.x
  306. d1 = @center_x - s1
  307. d3 = @center_x - s3
  308. start_time = Graphics.frame_count
  309. while (current_time = Graphics.frame_count - start_time) < 45
  310. spr1.x = easeInOutQuad(current_time, s1, d1, 45)
  311. spr3.x = easeInOutQuad(current_time, s3, d3, 45)
  312. Graphics.update
  313. end
  314. if success
  315. spr1.visible = false
  316. spr2.visible = false
  317. spr3.start_animation($data_animations[SUCCESS_ANIME])
  318. t = 0
  319. while spr3.animation?
  320. spr3.update
  321. Graphics.update
  322. t += 1
  323. if t == TRANSFORM_TIME
  324. spr3.bitmap = Cache.picture("Card#{@new_card_id}")
  325. end
  326. end
  327. else
  328. spr3.start_animation($data_animations[FAIL_ANIME])
  329. while spr3.animation?
  330. spr3.update
  331. Graphics.update
  332. end
  333. 20.times do
  334. Graphics.update
  335. end
  336. s12 = spr1.x
  337. s32 = spr3.x
  338. d1 = s1 - s12
  339. d3 = s3 - s32
  340. start_time = Graphics.frame_count
  341. while (current_time = Graphics.frame_count - start_time) < 45
  342. spr1.x = easeInOutQuad(current_time, s12, d1, 45)
  343. spr3.x = easeInOutQuad(current_time, s32, d3, 45)
  344. Graphics.update
  345. end
  346. end
  347. end
  348. #--------------------------------------------------------------------------
  349. # * new method: card_animation4
  350. #--------------------------------------------------------------------------
  351. def card_animation4(success)
  352. spr1 = @fusion_card_sprites[1]
  353. spr2 = @fusion_card_sprites[2]
  354. spr3 = @fusion_card_sprites[3]
  355. spr4 = @fusion_card_sprites[4]
  356. colorWhite = Color.new(255,255,255)
  357. spr1.flash(colorWhite,20)
  358. spr2.flash(colorWhite,20)
  359. spr3.flash(colorWhite,20)
  360. spr4.flash(colorWhite,20)
  361. while spr1.zoom_x < 0.6
  362. spr1.zoom_x += 0.01
  363. spr1.zoom_y += 0.01
  364. spr2.zoom_x += 0.01
  365. spr2.zoom_y += 0.01
  366. spr3.zoom_x += 0.01
  367. spr3.zoom_y += 0.01
  368. spr4.zoom_x += 0.01
  369. spr4.zoom_y += 0.01
  370. spr1.update
  371. spr2.update
  372. spr3.update
  373. spr4.update
  374. Graphics.update
  375. end
  376. while spr1.zoom_x > 0.5
  377. spr1.zoom_x -= 0.01
  378. spr1.zoom_y -= 0.01
  379. spr2.zoom_x -= 0.01
  380. spr2.zoom_y -= 0.01
  381. spr3.zoom_x -= 0.01
  382. spr3.zoom_y -= 0.01
  383. spr4.zoom_x -= 0.01
  384. spr4.zoom_y -= 0.01
  385. spr1.update
  386. spr2.update
  387. spr3.update
  388. spr4.update
  389. Graphics.update
  390. end
  391. s1 = spr1.x
  392. s2 = spr2.x
  393. s3 = spr3.x
  394. s4 = spr4.x
  395. d1 = @center_x - s1
  396. d2 = @center_x - s2
  397. d3 = @center_x - s3
  398. d4 = @center_x - s4
  399. start_time = Graphics.frame_count
  400. while (current_time = Graphics.frame_count - start_time) < 45
  401. spr1.x = easeInOutQuad(current_time, s1, d1, 45)
  402. spr2.x = easeInOutQuad(current_time, s2, d2, 45)
  403. spr3.x = easeInOutQuad(current_time, s3, d3, 45)
  404. spr4.x = easeInOutQuad(current_time, s4, d4, 45)
  405. Graphics.update
  406. end
  407. if success
  408. spr1.visible = false
  409. spr2.visible = false
  410. spr3.visible = false
  411. spr4.start_animation($data_animations[530])
  412. t = 0
  413. while spr4.animation?
  414. spr4.update
  415. Graphics.update
  416. t += 1
  417. if t == TRANSFORM_TIME
  418. spr4.bitmap = Cache.picture("Card#{@new_card_id}")
  419. end
  420. end
  421. else
  422. spr4.start_animation($data_animations[531])
  423. while spr4.animation?
  424. spr4.update
  425. Graphics.update
  426. end
  427. 20.times do
  428. Graphics.update
  429. end
  430. s12 = spr1.x
  431. s22 = spr2.x
  432. s32 = spr3.x
  433. s42 = spr4.x
  434. d1 = s1 - s12
  435. d2 = s2 - s22
  436. d3 = s3 - s32
  437. d4 = s4 - s42
  438. start_time = Graphics.frame_count
  439. while (current_time = Graphics.frame_count - start_time) < 45
  440. spr1.x = easeInOutQuad(current_time, s12, d1, 45)
  441. spr2.x = easeInOutQuad(current_time, s22, d2, 45)
  442. spr3.x = easeInOutQuad(current_time, s32, d3, 45)
  443. spr4.x = easeInOutQuad(current_time, s42, d4, 45)
  444. Graphics.update
  445. end
  446. end
  447. end
  448. #--------------------------------------------------------------------------
  449. # * new method: card_animation5
  450. #--------------------------------------------------------------------------
  451. def card_animation5(success)
  452. spr1 = @fusion_card_sprites[1]
  453. spr2 = @fusion_card_sprites[2]
  454. spr3 = @fusion_card_sprites[3]
  455. spr4 = @fusion_card_sprites[4]
  456. spr5 = @fusion_card_sprites[5]
  457. colorWhite = Color.new(255,255,255)
  458. spr1.flash(colorWhite,20)
  459. spr2.flash(colorWhite,20)
  460. spr3.flash(colorWhite,20)
  461. spr4.flash(colorWhite,20)
  462. spr5.flash(colorWhite,20)
  463. while spr1.zoom_x < 0.6
  464. spr1.zoom_x += 0.01
  465. spr1.zoom_y += 0.01
  466. spr2.zoom_x += 0.01
  467. spr2.zoom_y += 0.01
  468. spr3.zoom_x += 0.01
  469. spr3.zoom_y += 0.01
  470. spr4.zoom_x += 0.01
  471. spr4.zoom_y += 0.01
  472. spr5.zoom_x += 0.01
  473. spr5.zoom_y += 0.01
  474. spr1.update
  475. spr2.update
  476. spr3.update
  477. spr4.update
  478. spr5.update
  479. Graphics.update
  480. end
  481. while spr1.zoom_x > 0.5
  482. spr1.zoom_x -= 0.01
  483. spr1.zoom_y -= 0.01
  484. spr2.zoom_x -= 0.01
  485. spr2.zoom_y -= 0.01
  486. spr3.zoom_x -= 0.01
  487. spr3.zoom_y -= 0.01
  488. spr4.zoom_x -= 0.01
  489. spr4.zoom_y -= 0.01
  490. spr5.zoom_x -= 0.01
  491. spr5.zoom_y -= 0.01
  492. spr1.update
  493. spr2.update
  494. spr3.update
  495. spr4.update
  496. spr5.update
  497. Graphics.update
  498. end
  499. s1 = spr1.x
  500. s2 = spr2.x
  501. s3 = spr3.x
  502. s4 = spr4.x
  503. s5 = spr5.x
  504. d1 = @center_x - s1
  505. d2 = @center_x - s2
  506. d3 = @center_x - s3
  507. d4 = @center_x - s4
  508. d5 = @center_x - s5
  509. start_time = Graphics.frame_count
  510. while (current_time = Graphics.frame_count - start_time) < 45
  511. spr1.x = easeInOutQuad(current_time, s1, d1, 45)
  512. spr2.x = easeInOutQuad(current_time, s2, d2, 45)
  513. spr3.x = easeInOutQuad(current_time, s3, d3, 45)
  514. spr4.x = easeInOutQuad(current_time, s4, d4, 45)
  515. spr5.x = easeInOutQuad(current_time, s5, d5, 45)
  516. Graphics.update
  517. end
  518. if success
  519. spr1.visible = false
  520. spr2.visible = false
  521. spr3.visible = false
  522. spr4.visible = false
  523. spr5.start_animation($data_animations[530])
  524. t = 0
  525. while spr5.animation?
  526. spr5.update
  527. Graphics.update
  528. t += 1
  529. if t == TRANSFORM_TIME
  530. spr5.bitmap = Cache.picture("Card#{@new_card_id}")
  531. end
  532. end
  533. else
  534. spr5.start_animation($data_animations[531])
  535. while spr5.animation?
  536. spr5.update
  537. Graphics.update
  538. end
  539. 20.times do
  540. Graphics.update
  541. end
  542. s12 = spr1.x
  543. s22 = spr2.x
  544. s32 = spr3.x
  545. s42 = spr4.x
  546. s52 = spr5.x
  547. d1 = s1 - s12
  548. d2 = s2 - s22
  549. d3 = s3 - s32
  550. d4 = s4 - s42
  551. d5 = s5 - s52
  552. start_time = Graphics.frame_count
  553. while (current_time = Graphics.frame_count - start_time) < 45
  554. spr1.x = easeInOutQuad(current_time, s12, d1, 45)
  555. spr2.x = easeInOutQuad(current_time, s22, d2, 45)
  556. spr3.x = easeInOutQuad(current_time, s32, d3, 45)
  557. spr4.x = easeInOutQuad(current_time, s42, d4, 45)
  558. spr5.x = easeInOutQuad(current_time, s52, d5, 45)
  559. Graphics.update
  560. end
  561. end
  562. end
  563. #--------------------------------------------------------------------------
  564. # * new method: fusion_comfirmation
  565. #--------------------------------------------------------------------------
  566. def fusion_comfirmation(card_ids, new_card_id)
  567. @fusion_window.deactivate
  568. @selected_cards = card_ids.clone
  569. @new_card_id = new_card_id
  570. confirm_on
  571. show_card_images
  572. end
  573. #--------------------------------------------------------------------------
  574. # * new method: on_fusion_ok
  575. #--------------------------------------------------------------------------
  576. def on_fusion_ok
  577. @fusion_command_window.hide.deactivate
  578. @fusion_text.hide
  579. success = (@new_card_id != nil)
  580. BattleManager.actor.tp -= 1
  581. @status_window.refresh
  582. card_animation3(success) if @selected_cards.size == 3
  583. card_animation4(success) if @selected_cards.size == 4
  584. card_animation5(success) if @selected_cards.size == 5
  585. if success
  586. @fusion_window.fusion_complete
  587. if $new_combination
  588. $game_system.save_bgm
  589. RPG::BGM.new(*NEW_DISCOVERY_BGM).play
  590. @new_discover_text.open
  591. while @new_discover_text.openness < 255
  592. @new_discover_text.update
  593. Graphics.update
  594. end
  595. while true
  596. Graphics.update
  597. Input.update
  598. break if Input.trigger?(:C) || Input.trigger?(:B)
  599. end
  600. $game_system.replay_bgm
  601. @new_discover_text.close
  602. end
  603. else
  604. @fusion_window.fusion_fail
  605. end
  606. hide_card_images
  607. @selected_cards.clear
  608. @selected_cards = nil
  609. @new_card_id = nil
  610. $new_combination = nil
  611. update_indicator
  612. end
  613. #--------------------------------------------------------------------------
  614. # * new method: on_fusion_cancel
  615. #--------------------------------------------------------------------------
  616. def on_fusion_cancel
  617. @selected_cards.clear
  618. @selected_cards = nil
  619. @new_card_id = nil
  620. hide_card_images
  621. @fusion_command_window.hide.deactivate
  622. @fusion_text.hide
  623. @fusion_window.activate
  624. end
  625. #--------------------------------------------------------------------------
  626. # * new method: update
  627. #--------------------------------------------------------------------------
  628. alias_method(:dsi_scene_battle_scene_update, :update)
  629. def update
  630. dsi_scene_battle_scene_update
  631. if @skill_window.active
  632. if Input.trigger?(:X)
  633. if @fusion_enable && BattleManager.actor.tp > 0 && !$game_switches[DISABLE_SWITCH]
  634. RPG::SE.new(*TOGGLE_SE).play
  635. @skill_window.hide.deactivate
  636. @fusion_window.actor = BattleManager.actor
  637. @fusion_window.stype_id = @actor_command_window.current_ext
  638. @fusion_window.refresh
  639. @fusion_window.show.activate
  640. update_indicator
  641. else
  642. Sound.play_buzzer
  643. end
  644. end
  645. end
  646. end
  647. end
  648.  
  649. class Window_FusionCofirm < Window_HorzCommand
  650. #--------------------------------------------------------------------------
  651. # * overwrite method: col_max
  652. #--------------------------------------------------------------------------
  653. def col_max
  654. return 2
  655. end
  656. #--------------------------------------------------------------------------
  657. # * overwrite method: window_width
  658. #--------------------------------------------------------------------------
  659. def window_width
  660. return 150
  661. end
  662. #--------------------------------------------------------------------------
  663. # * overwrite method: make_command_list
  664. #--------------------------------------------------------------------------
  665. def make_command_list
  666. add_command("Fuse", :ok)
  667. add_command("Cancel", :cancel)
  668. end
  669. end
  670.  
  671. class Window_FusionBattleSkill < Window_BattleSkill
  672. include DSIVER144::CARD_FUSION
  673. attr_accessor :off_method
  674. attr_accessor :complete_method
  675. attr_accessor :confirm_method
  676. #-----------------------------------------------------------------------------
  677. # changes the BattleSkillList Window layout (overwrite)
  678. #-----------------------------------------------------------------------------
  679. def initialize(help_window, info_viewport)
  680. super(help_window, info_viewport)
  681. @selected = []
  682. @selected_indexes = []
  683. end
  684. #-----------------------------------------------------------------------------
  685. # changes the max. amount of collums to 1 (overwrite)
  686. #-----------------------------------------------------------------------------
  687. def col_max
  688. return 1
  689. end
  690. #--------------------------------------------------------------------------
  691. # Make skill list from @hand, not from @skills (overwrite)
  692. #--------------------------------------------------------------------------
  693. def make_item_list
  694. if @actor
  695. @actor.sort_cards(:hand)
  696. @data = @actor.hand
  697. end
  698. end
  699. #--------------------------------------------------------------------------
  700. # * Display Skill in Active State?
  701. #--------------------------------------------------------------------------
  702. def enable?(item)
  703. super && @actor.turn_actions[:actions] != 0
  704. end
  705. #-------------------------------------------------------------------------
  706. # * new method: add_card
  707. #-------------------------------------------------------------------------
  708. def add_card(card_id)
  709. @selected << card_id
  710. @selected_indexes << index
  711. end
  712. #-------------------------------------------------------------------------
  713. # * new method: empty?
  714. #-------------------------------------------------------------------------
  715. def empty?
  716. @selected_indexes.size == 0
  717. end
  718. #-------------------------------------------------------------------------
  719. # * new method: empty!
  720. #-------------------------------------------------------------------------
  721. def empty!
  722. @selected_indexes.clear
  723. @selected.clear
  724. refresh
  725. end
  726. #-------------------------------------------------------------------------
  727. # * overwrite method: fusion_fail
  728. #-------------------------------------------------------------------------
  729. def fusion_fail
  730. empty!
  731. @off_method.call()
  732. @complete_method.call()
  733. @new_card_id = nil
  734. end
  735. #-------------------------------------------------------------------------
  736. # * overwrite method: fusion_complete
  737. #-------------------------------------------------------------------------
  738. def fusion_complete
  739. return unless @new_card_id
  740. @selected.each {|id| @actor.card_to_grave?(id)}
  741. @actor.hand.push($data_skills[@new_card_id])
  742. select(0)
  743. empty! # Empty selected cards array
  744. @off_method.call()
  745. @complete_method.call()
  746. @new_card_id = nil
  747. end
  748. #-------------------------------------------------------------------------
  749. # * overwrite method: update
  750. #-------------------------------------------------------------------------
  751. def update
  752. super
  753. return unless self.active
  754. if Input.trigger?(:C)
  755. if @selected_indexes.include?(index)
  756. Sound.play_buzzer
  757. return
  758. end
  759. RPG::SE.new(*SELECT_SE).play
  760. return if @selected.size >= 5
  761. add_card(item.id) if item
  762. refresh
  763. end
  764. if Input.trigger?(:X)
  765. if @selected.size >= 3
  766. @new_card_id = DSIVER144::CARD_FUSION.check(@selected)
  767. @confirm_method.call(@selected,@new_card_id)
  768. end
  769. end
  770. if Input.trigger?(:B)
  771. if !empty?
  772. RPG::SE.new(*DESELECT_SE).play
  773. empty!
  774. else
  775. RPG::SE.new(*TOGGLE_SE).play
  776. @off_method.call() if @off_method
  777. end
  778. end
  779. end
  780. #--------------------------------------------------------------------------
  781. # * Draw Item Name [overwrite]
  782. # enabled : Enabled flag. When false, draw semi-transparently.
  783. #--------------------------------------------------------------------------
  784. def draw_item_name(item, x, y, enabled = true, selected = false, width = 172)
  785. return unless item
  786. draw_icon(item.icon_index, x, y, enabled)
  787. if selected
  788. draw_icon(SELECTED_ICON, x, y, enabled)
  789. end
  790. change_color(normal_color, enabled)
  791. draw_text(x + 24, y, width, line_height, item.name)
  792. end
  793. #--------------------------------------------------------------------------
  794. # * Draw Item [overwrite]
  795. #--------------------------------------------------------------------------
  796. def draw_item(index)
  797. item = @data[index]
  798. if item
  799. rect = item_rect(index)
  800. rect.width -= 4
  801. if @selected_indexes.include?(index)
  802. draw_item_name(item, rect.x, rect.y, enable?(item), true)
  803. else
  804. draw_item_name(item, rect.x, rect.y, enable?(item), false)
  805. end
  806. end
  807. end
  808. end
  809.  
  810. class Window_BattleSkill < Window_SkillList
  811. attr_accessor :indicator_window
  812. #-----------------------------------------------------------------------------
  813. # changes the BattleSkillList Window layout (overwrite)
  814. #-----------------------------------------------------------------------------
  815. def initialize(help_window, info_viewport)
  816. y = 0
  817. super(0, 0, (Graphics.width - 210) * 0.7, info_viewport.rect.y - 46)
  818. self.visible = false
  819. @help_window = help_window
  820. @info_viewport = info_viewport
  821. end
  822. alias_method(:dsiver144_show, :show)
  823. def show
  824. if @indicator_window
  825. @indicator_window.show
  826. end
  827. dsiver144_show
  828. end
  829. alias_method(:dsiver144_hide, :hide)
  830. def hide
  831. if @indicator_window
  832. @indicator_window.hide
  833. end
  834. dsiver144_hide
  835. end
  836. end
  837.  
  838. class Game_System
  839. attr_accessor :fusion_discovered
  840. alias_method(:dsi_fusion_discovered_init, :initialize)
  841. def initialize
  842. @fusion_discovered = []
  843. dsi_fusion_discovered_init
  844. end
  845. end # Game_System
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement