Advertisement
dsiver144

Dragon Quest Battle

Mar 14th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.51 KB | None | 0 0
  1. #============================================================================
  2. # [VXAce] Dragon Quest Battle V1.00 (Finished)
  3. #----------------------------------------------------------------------------
  4. # By Jamiras843## Features: # V1.00# * Dragon Quest VIII style battle
  5. # * Limited options to have list style Status or block style
  6. # * Face graphics optional
  7. # * Level Up option available for sound.
  8. #============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["Dragon Quest Battle"] = true
  12.  
  13. module Jami_DQ_Battle
  14. #========================================================================
  15. # Script options
  16. #------------------------------------------------------------------------
  17. # Here you edit some simple aspects of the Battle System
  18. #
  19. #========================================================================
  20. SHOW_FACE = true # Shows actor face in menu
  21. HUD_HIDE = true #Hides Battle status during combat if true
  22. LVL_UP = true #Play level up sounde effect
  23. LVL_UP_SND = "Level_Up" #Name of sound effect
  24. end #end module Jami_DQ_Battle
  25.  
  26. #============================================================================
  27. # WARNING: Do not edit below unless you know what you are doing. This script
  28. # is rather sloppy but it does its job.
  29. #============================================================================
  30.  
  31. #==============================================================================
  32. # ** Game_Actor
  33. #------------------------------------------------------------------------------
  34. # This class handles actors. It's used within the Game_Actors class
  35. # ($game_actors) and referenced by the Game_Party class ($game_party).
  36. #==============================================================================
  37. class Game_Actor < Game_Battler
  38. #--------------------------------------------------------------------------
  39. # * Show Level Up Message
  40. # new_skills : Array of newly learned skills
  41. #--------------------------------------------------------------------------
  42. def display_level_up(new_skills)
  43. Audio.me_play("Audio/ME/" + Jami_DQ_Battle::LVL_UP_SND)
  44. $game_message.new_page
  45. $game_message.add(sprintf(Vocab::LevelUp, @name, Vocab::level, @level))
  46. new_skills.each do |skill|
  47. $game_message.add(sprintf(Vocab::obtainSkill, skill.name))
  48. end
  49. end
  50. end
  51.  
  52. #==============================================================================
  53. # ** Window_Base
  54. #------------------------------------------------------------------------------
  55. # This is a super class of all windows within the game.
  56. #==============================================================================
  57. class Window_Base < Window
  58. #--------------------------------------------------------------------------
  59. # * Close Window
  60. #--------------------------------------------------------------------------
  61. def close
  62. @closing = true
  63. @opening = false
  64. self
  65. end
  66. end #class Window_Base
  67.  
  68. #==============================================================================
  69. # ** Window_Help
  70. #------------------------------------------------------------------------------
  71. # This window shows skill and item explanations along with actor status.
  72. #==============================================================================
  73. class Window_Help < Window_Base
  74. #--------------------------------------------------------------------------
  75. # * Object Initialization
  76. #--------------------------------------------------------------------------
  77. def initialize(line_number = 2)
  78. super(0, 0, Graphics.width, fitting_height(line_number))
  79. end
  80. end
  81.  
  82. #==============================================================================
  83. # ** Window_BattleItem
  84. #------------------------------------------------------------------------------
  85. # This window is for selecting items to use in the battle window.
  86. #==============================================================================
  87. class Window_BattleItem < Window_ItemList
  88. #--------------------------------------------------------------------------
  89. # * Object Initialization
  90. # info_viewport : Viewport for displaying information
  91. #--------------------------------------------------------------------------
  92. def initialize(help_window, info_viewport)
  93. y = help_window.height
  94. super(0, y, Graphics.width, 416)
  95. self.visible = false
  96. @help_window = help_window
  97. @info_viewport = info_viewport
  98. end
  99. end
  100.  
  101. #==============================================================================
  102. # ** Window_BattleSkill
  103. #------------------------------------------------------------------------------
  104. # This window is for selecting skills to use in the battle window.
  105. #==============================================================================
  106. class Window_BattleSkill < Window_SkillList
  107. #--------------------------------------------------------------------------
  108. # * Object Initialization
  109. # info_viewport : Viewport for displaying information
  110. #--------------------------------------------------------------------------
  111. def initialize(help_window, info_viewport)
  112. y = help_window.height
  113. super(0, y, Graphics.width, 416)
  114. self.visible = false
  115. @help_window = help_window
  116. @info_viewport = info_viewport
  117. end
  118. end
  119.  
  120. #==============================================================================
  121. # ** Window_BattleActor
  122. #------------------------------------------------------------------------------
  123. # This window is for selecting an actor's action target on the battle screen.
  124. #==============================================================================
  125. class Window_BattleActor < Window_BattleStatus
  126. #--------------------------------------------------------------------------
  127. # * Object Initialization
  128. # info_viewport : Viewport for displaying information
  129. #--------------------------------------------------------------------------
  130. def initialize(info_viewport)
  131. super()
  132. self.y = 416 - 120
  133. self.visible = false
  134. self.openness = 255
  135. @info_viewport = info_viewport
  136. @info_viewport2 = info_viewport
  137. end
  138. end
  139.  
  140. #============================================================================
  141. # ** Actor Window
  142. #============================================================================
  143. class Window_DQ_BattleStatus < Window_Base
  144. #--------------------------------------------------------------------------
  145. # * Object Initialization
  146. #--------------------------------------------------------------------------
  147. def initialize
  148. if $game_party.members.size < 4
  149. super(100, 0, 110 * $game_party.members.size,120)
  150. else
  151. super(100, 0, 110 * 4,120)
  152. end
  153. create_contents
  154. @actor1 = $game_party.members[0]
  155. @actor2 = $game_party.members[1]
  156. @actor3 = $game_party.members[2]
  157. @actor4 = $game_party.members[3]
  158. refresh
  159. self.openness = 0
  160. end
  161.  
  162. #--------------------------------------------------------------------------
  163. # * Draw Item
  164. #--------------------------------------------------------------------------
  165. def draw_item(index)
  166. actor = $game_party.battle_members[index]
  167. end
  168.  
  169. #--------------------------------------------------------------------------
  170. # * Get Number of Lines to Show
  171. #--------------------------------------------------------------------------
  172. def visible_line_number
  173. return 1
  174. end
  175.  
  176. #--------------------------------------------------------------------------
  177. # * Get Digit Count
  178. #--------------------------------------------------------------------------
  179. def col_max
  180. return 4
  181. end
  182.  
  183. #----------------------------------------------------
  184. # * Refresh
  185. #----------------------------------------------------
  186. def refresh
  187. contents.clear
  188. draw_window_content
  189. draw_horiz_line (line_height * 1)
  190. end
  191.  
  192. #----------------------------------------------------
  193. # * Draw Window Contents
  194. #----------------------------------------------------
  195. def draw_window_content
  196. # Face
  197. if Jami_DQ_Battle::SHOW_FACE == true
  198. draw_face(@actor1.face_name, @actor1.face_index, 0, 0, enabled = false)
  199. if $game_party.members.size > 1
  200. draw_face(@actor2.face_name, @actor2.face_index, 110, 0, enable = false)
  201. end # > 1
  202. if $game_party.members.size > 2
  203. draw_face(@actor3.face_name, @actor3.face_index, 220, 0, enable = false)
  204. end # > 2
  205. if $game_party.members.size > 3
  206. draw_face(@actor4.face_name, @actor4.face_index, 330, 0, enable = false)
  207. end # > 3
  208. end # if face
  209. # Actor Name
  210. draw_actor_name(@actor1, 0, 0)
  211. if $game_party.members.size > 1
  212. draw_actor_name(@actor2, 110, 0)
  213. end # > 1
  214. if $game_party.members.size > 2
  215. draw_actor_name(@actor3, 220, 0)
  216. end # > 2
  217. if $game_party.members.size > 3
  218. draw_actor_name(@actor4, 330, 0)
  219. end # > 3
  220. # Actor HP
  221. draw_actor_hp(@actor1, 0, 24, 80)
  222. if $game_party.members.size > 1
  223. draw_actor_hp(@actor2, 110, 24, 80)
  224. end # > 1
  225. if $game_party.members.size > 2
  226. draw_actor_hp(@actor3, 220, 24, 80)
  227. end # > 2
  228. if $game_party.members.size > 3
  229. draw_actor_hp(@actor4, 330, 24, 80)
  230. end # > 3
  231. # Actor MP
  232. draw_actor_mp(@actor1, 0, 44, 80)
  233. if $game_party.members.size > 1
  234. draw_actor_mp(@actor2, 110, 44, 80)
  235. end # > 1
  236. if $game_party.members.size > 2
  237. draw_actor_mp(@actor3, 220, 44, 80)
  238. end # > 2
  239. if $game_party.members.size > 3
  240. draw_actor_mp(@actor4, 330, 44, 80)
  241. end # > 3
  242. # Actor LV
  243. draw_actor_level(@actor1, 0, 64)
  244. if $game_party.members.size > 1
  245. draw_actor_level(@actor2, 110, 64)
  246. end # > 1
  247. if $game_party.members.size > 2
  248. draw_actor_level(@actor3, 220, 64)
  249. end # > 2
  250. if $game_party.members.size > 3
  251. draw_actor_level(@actor4, 330, 64)
  252. end # > 3
  253. draw_actor_icons(@actor1, 60, 0)
  254. if $game_party.members.size > 1
  255. draw_actor_icons(@actor2, 170, 0)
  256. end # > 1
  257. if $game_party.members.size > 2
  258. draw_actor_icons(@actor3, 280, 0)
  259. end # > 2
  260. if $game_party.members.size > 3
  261. draw_actor_icons(@actor4, 400, 0)
  262. end # > 3
  263. end #end draw_window_content
  264. end
  265.  
  266. #==============================================================================
  267. # ** Window_BattleEnemy
  268. #------------------------------------------------------------------------------
  269. # Window for selecting the enemy who is the action target on the battle
  270. # screen.
  271. #==============================================================================
  272. class Window_BattleEnemy < Window_Selectable
  273. #--------------------------------------------------------------------------
  274. # * Object Initialization
  275. # info_viewport : Viewport for displaying information
  276. #--------------------------------------------------------------------------
  277. def initialize(info_viewport)
  278. super(200, 296, 344, fitting_height(4))
  279. refresh
  280. self.visible = false
  281. end
  282. end #class Window_BattleEnemy
  283.  
  284. #==============================================================================
  285. # ** Window_BattleLog
  286. #------------------------------------------------------------------------------
  287. # Window edited to be more like DQVIII
  288. #==============================================================================
  289. class Window_BattleLog < Window_Selectable
  290. #--------------------------------------------------------------------------
  291. # * Object Initialization
  292. #--------------------------------------------------------------------------
  293. def initialize
  294. super(0, 296, window_width, window_height)
  295. self.z = 200
  296. self.hide
  297. self.opacity = 255
  298. @lines = []
  299. @num_wait = 0
  300. create_back_bitmap
  301. create_back_sprite
  302. refresh
  303. end
  304.  
  305. #--------------------------------------------------------------------------
  306. # * Free
  307. #--------------------------------------------------------------------------
  308. def dispose
  309. super
  310. self.close
  311. dispose_back_bitmap
  312. dispose_back_sprite
  313. end
  314.  
  315. #--------------------------------------------------------------------------
  316. # * Get Window Width
  317. #--------------------------------------------------------------------------
  318. def window_width
  319. Graphics.width
  320. end
  321.  
  322. #--------------------------------------------------------------------------
  323. # * Get Window Height
  324. #--------------------------------------------------------------------------
  325. def window_height
  326. fitting_height(max_line_number)
  327. end
  328.  
  329. #--------------------------------------------------------------------------
  330. # * Get Maximum Number of Lines
  331. #--------------------------------------------------------------------------
  332. def max_line_number
  333. return 4
  334. end
  335.  
  336. #--------------------------------------------------------------------------
  337. # * Clear
  338. #--------------------------------------------------------------------------
  339. def clear
  340. self.hide
  341. @num_wait = 0
  342. @lines.clear
  343. refresh
  344. end
  345.  
  346. #--------------------------------------------------------------------------
  347. # * Add Text
  348. #--------------------------------------------------------------------------
  349. def add_text(text)
  350. self.show
  351. @lines.push(text)
  352. refresh
  353. end
  354.  
  355. #--------------------------------------------------------------------------
  356. # * Get Background Opacity
  357. #--------------------------------------------------------------------------
  358. def back_opacity
  359. return 0
  360. end
  361. end #Window_Battlelog
  362.  
  363. #==============================================================================
  364. # ** Window_ActorCommand
  365. #------------------------------------------------------------------------------
  366. # This window is for selecting an actor's action on the battle screen.
  367. #==============================================================================
  368. class Window_ActorCommand < Window_Command
  369. #--------------------------------------------------------------------------
  370. # * Object Initialization
  371. #--------------------------------------------------------------------------
  372. def initialize
  373. super(0, 0)
  374. self.openness = 0
  375. deactivate
  376. @actor = nil
  377. end
  378.  
  379. #--------------------------------------------------------------------------
  380. # * Get Window Width
  381. #--------------------------------------------------------------------------
  382. def window_width
  383. return 200
  384. end
  385.  
  386. #--------------------------------------------------------------------------
  387. # * Get Number of Lines to Show
  388. #--------------------------------------------------------------------------
  389. def visible_line_number
  390. return 4
  391. end
  392.  
  393. #--------------------------------------------------------------------------
  394. # * Get Digit Count
  395. #--------------------------------------------------------------------------
  396. def col_max
  397. return 2
  398. end
  399. end
  400.  
  401. #==============================================================================
  402. # ** Scene_Battle
  403. #------------------------------------------------------------------------------
  404. # This class performs battle screen processing.
  405. #==============================================================================
  406. class Scene_Battle < Scene_Base
  407. #--------------------------------------------------------------------------
  408. # * Start Processing
  409. #--------------------------------------------------------------------------
  410. def start
  411. super
  412. create_spriteset
  413. create_all_windows
  414. BattleManager.method_wait_for_message = method(:wait_for_message)
  415. @game_party = $game_party.members
  416. end
  417.  
  418. #--------------------------------------------------------------------------
  419. # * Update Frame (Basic)
  420. #--------------------------------------------------------------------------
  421. def update_basic
  422. super
  423. $game_timer.update
  424. $game_troop.update
  425. @spriteset.update
  426. update_message_open
  427. end
  428.  
  429. #--------------------------------------------------------------------------
  430. # * Create All Windows
  431. #--------------------------------------------------------------------------
  432. def create_all_windows
  433. create_message_window
  434. create_log_window
  435. create_DQ_status_window
  436. create_info_viewport
  437. create_party_command_window
  438. create_actor_command_window
  439. create_help_window
  440. create_skill_window
  441. create_item_window
  442. create_actor_window
  443. create_enemy_window
  444. end
  445.  
  446. #--------------------------------------------------------------------------
  447. # * Create Message Window
  448. #--------------------------------------------------------------------------
  449. def create_message_window
  450. @message_window = Window_Message.new
  451. end
  452.  
  453. #--------------------------------------------------------------------------
  454. # * Create DQ Status Window
  455. #--------------------------------------------------------------------------
  456. def create_DQ_status_window
  457. @DQ_status_window = Window_DQ_BattleStatus.new
  458. @DQ_status_window.x = 128
  459. end
  460.  
  461. #--------------------------------------------------------------------------
  462. # * Create Log Window
  463. #--------------------------------------------------------------------------
  464. def create_log_window
  465. @log_window = Window_BattleLog.new
  466. @log_window.method_wait = method:)wait)
  467. @log_window.method_wait_for_effect = method(:wait_for_effect)
  468. end
  469.  
  470. #--------------------------------------------------------------------------
  471. # * Create Information Display Viewport
  472. #--------------------------------------------------------------------------
  473. def create_info_viewport
  474. @info_viewport = Viewport.new
  475. @info_viewport.rect.y = 0
  476. @info_viewport.rect.height = Graphics.height - @DQ_status_window.height
  477. @info_viewport.z = 100
  478. @info_viewport.ox = 544 - 104 * 4
  479. @DQ_status_window.viewport = @info_viewport
  480. end
  481.  
  482. #--------------------------------------------------------------------------
  483. # * Create Party Commands Window
  484. #--------------------------------------------------------------------------
  485. def create_party_command_window
  486. @DQ_status_window.show
  487. @party_command_window = Window_PartyCommand.new
  488. @party_command_window.set_handler(:fight, method(:command_fight))
  489. @party_command_window.set_handler(:escape, method(:command_escape))
  490. @party_command_window.x = 0
  491. @party_command_window.y = 296
  492. @party_command_window.unselect
  493. end
  494.  
  495. #--------------------------------------------------------------------------
  496. # * Create Actor Commands Window
  497. #--------------------------------------------------------------------------
  498. def create_actor_command_window
  499. @actor_command_window = Window_ActorCommand.new
  500. @actor_command_window.set_handler(:attack, method(:command_attack))
  501. @actor_command_window.set_handler(:skill, method(:command_skill))
  502. @actor_command_window.set_handler(:guard, method(:command_guard))
  503. @actor_command_window.set_handler(:item, method(:command_item))
  504. @actor_command_window.set_handler(:cancel, method(:prior_command))
  505. @actor_command_window.x = 0
  506. @actor_command_window.y = 296
  507. end
  508.  
  509. #--------------------------------------------------------------------------
  510. # * Create Help Window
  511. #--------------------------------------------------------------------------
  512. def create_help_window
  513. @help_window = Window_Help.new
  514. @help_window.visible = false
  515. end
  516.  
  517. #--------------------------------------------------------------------------
  518. # * Create Enemy Window
  519. #--------------------------------------------------------------------------
  520. def create_enemy_window
  521. @enemy_window = Window_BattleEnemy.new(@help_window)
  522. @enemy_window.index = 0
  523. @enemy_window.set_handler(:ok, method(:on_enemy_ok))
  524. @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  525. end
  526.  
  527. #--------------------------------------------------------------------------
  528. # * Start Enemy Selection
  529. #--------------------------------------------------------------------------
  530. def select_enemy_selection
  531. @enemy_window.refresh
  532. @enemy_window.show.activate
  533. @enemy_window.index = 0
  534. end
  535.  
  536. #--------------------------------------------------------------------------
  537. # * Create Skill Window
  538. #--------------------------------------------------------------------------
  539. def create_skill_window
  540. @skill_window = Window_BattleSkill.new(@help_window, @info_viewport)
  541. @skill_window.set_handler(:ok, method(:on_skill_ok))
  542. @skill_window.set_handler(:cancel, method(:on_skill_cancel))
  543. end
  544.  
  545. #--------------------------------------------------------------------------
  546. # * Create Item Window
  547. #--------------------------------------------------------------------------
  548. def create_item_window
  549. @item_window = Window_BattleItem.new(@help_window, @info_viewport)
  550. @item_window.set_handler(:ok, method(:on_item_ok))
  551. @item_window.set_handler(:cancel, method(:on_item_cancel))
  552. end
  553.  
  554. #--------------------------------------------------------------------------
  555. # * Update Status Window Information
  556. #--------------------------------------------------------------------------
  557. def refresh_status
  558. @DQ_status_window.refresh
  559. end
  560.  
  561. #--------------------------------------------------------------------------
  562. # * Start Party Command Selection
  563. #--------------------------------------------------------------------------
  564. def start_party_command_selection
  565. unless scene_changing?
  566. refresh_status
  567. @DQ_status_window.open
  568. if BattleManager.input_start
  569. @actor_command_window.close
  570. @party_command_window.setup
  571. else
  572. @party_command_window.deactivate
  573. turn_start
  574. end
  575. end
  576. end
  577.  
  578. #--------------------------------------------------------------------------
  579. # * Start Actor Command Selection
  580. #--------------------------------------------------------------------------
  581. def start_actor_command_selection
  582. @party_command_window.close
  583. @actor_command_window.setup(BattleManager.actor)
  584. end
  585.  
  586. #--------------------------------------------------------------------------
  587. # * Update Processing for Opening Message Window
  588. # Set openness to 0 until the status window and so on are finished closing.
  589. #--------------------------------------------------------------------------
  590. def update_message_open
  591. if $game_message.busy? && !@DQ_status_window.close?
  592. @message_window.openness = 0
  593. @DQ_status_window.close
  594. @party_command_window.close
  595. @actor_command_window.close
  596. end
  597. end
  598.  
  599. #--------------------------------------------------------------------------
  600. # * Start Turn
  601. #--------------------------------------------------------------------------
  602. def turn_start
  603. @party_command_window.close
  604. @actor_command_window.close
  605. @subject = nil
  606. BattleManager.turn_start
  607. if Jami_DQ_Battle::HUD_HIDE == true
  608. @info_viewport.rect.height = 60
  609. end #if HUDE_HIDE
  610. @log_window.clear
  611. end
  612.  
  613. #--------------------------------------------------------------------------
  614. # * End Turn
  615. #--------------------------------------------------------------------------
  616. def turn_end
  617. all_battle_members.each do |battler|
  618. battler.on_turn_end
  619. refresh_status
  620. if Jami_DQ_Battle::HUD_HIDE == true
  621. @info_viewport.rect.height = @DQ_status_window.height
  622. end
  623. @log_window.display_auto_affected_status(battler)
  624. @log_window.wait_and_clear
  625. end
  626. BattleManager.turn_end
  627. process_event
  628. start_party_command_selection
  629. end
  630.  
  631. #--------------------------------------------------------------------------
  632. # * Battle Action Processing
  633. #--------------------------------------------------------------------------
  634. def process_action
  635. return if scene_changing?
  636. if !@subject || !@subject.current_action
  637. @subject = BattleManager.next_subject
  638. end
  639. return turn_end unless @subject
  640. if @subject.current_action
  641. @subject.current_action.prepare
  642. if @subject.current_action.valid?
  643. @DQ_status_window.open
  644. execute_action
  645. end
  646. @subject.remove_current_action
  647. end
  648. process_action_end unless @subject.current_action
  649. end
  650. end # end Scene_battle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement