Advertisement
Dekita

$D13x - Row Formation v1.2

Jun 19th, 2013
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.71 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Battle Rows
  5. # -- Author : Dekita
  6. # -- Version : 1.2
  7. # -- Level : Easy / Normal
  8. # -- Requires : N/A
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Battle_Rows]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 14/o6/2o13 - Update, (row status')
  21. # 31/o5/2o13 - Update, (:normal / :basic modes)
  22. # 3o/o5/2o13 - Finished,
  23. # 18/o5/2o13 - Started
  24. #
  25. #===============================================================================
  26. # ☆ Introduction
  27. #-------------------------------------------------------------------------------
  28. # This script creates "Battle Rows".
  29. # Most people should know what this feature is, as its a very well known
  30. # aspect of most RPG games..
  31. #
  32. # For people who dont know..
  33. # Battle Rows allow you to have different rows while in battle..
  34. # EG. front row / middle row / back row, typically if you are in the front row
  35. # your damage output will be higher, but so will the damage recieved.
  36. # middle row damage is normal for both damage dealt and recived.
  37. # Back row damage (recieved & dealt) is reduced.
  38. #
  39. # A new command will be added to the actor command battle window,
  40. # This command will change your current row position.
  41. # You can only change your row position while in battle.
  42. #
  43. # Basically, this allows for slightly more tactical thinking while in battles.
  44. #
  45. # NOTICE:
  46. # If you can design a "good looking" screen for changing rows / formation
  47. # during the menu screen, i will happily add that feature into the script.
  48. # The reason i have not already implimented the ability to change row via menu
  49. # is because i could not think of how i wanted to place the information..
  50. # If you wish to take up this task, feel free, but be warned..
  51. # i am very very picky with how my information is displayed :p
  52. #
  53. #===============================================================================
  54. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  55. #===============================================================================
  56. # 1. You MUST give credit to "Dekita" !!
  57. # 2. You are NOT allowed to repost this script.(or modified versions)
  58. # 3. You are NOT allowed to convert this script.
  59. # 4. You are NOT allowed to use this script for Commercial games.
  60. # 5. ENJOY!
  61. #
  62. # "FINE PRINT"
  63. # By using this script you hereby agree to the above terms and conditions,
  64. # if any violation of the above terms occurs "legal action" may be taken.
  65. # Not understanding the above terms and conditions does NOT mean that
  66. # they do not apply to you.
  67. # If you wish to discuss the terms and conditions in further detail you can
  68. # contact me at http://dekitarpg.wordpress.com/
  69. #
  70. #===============================================================================
  71. # ☆ Instructions
  72. #-------------------------------------------------------------------------------
  73. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  74. #
  75. #===============================================================================
  76. # ☆ Notetags ( default )
  77. #-------------------------------------------------------------------------------
  78. # <row: X>
  79. # replace X with the row position, 0 = front, 1 = middle, 2 = back
  80. # For use with actors / classes / enemies
  81. #
  82. # <long range>
  83. # add this notetag to increase the range of an actor/enemy,
  84. # this notetag can be given to Actors / Classes / Equip / States / Enemies
  85. #
  86. # <fixed row>
  87. # add this notetag to Actors / Classes to disable changing rows.
  88. #
  89. #===============================================================================
  90. # ☆ HELP
  91. #-------------------------------------------------------------------------------
  92. # You should not need any..
  93. #
  94. #===============================================================================
  95. module Rows
  96. #===============================================================================
  97. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  98. # ☆ Settings
  99. #-----------------------------------------------------------------------------
  100. # This is the default row for all actors and enemies.
  101. # Reccommended to be 1 (middle row).
  102. Default_Row = 1
  103. #-----------------------------------------------------------------------------
  104. # These are the vocab settings for row information.
  105. Vocab = {
  106. :main => "Swap Row" ,
  107. :frnt => "Front Row" ,
  108. :midd => "Middle Row",
  109. :back => "Back Row" ,
  110. }
  111. #-----------------------------------------------------------------------------
  112. # this is the id of the switch to hide the row command.
  113. # keep 0 to always enable row command.
  114. Switch = 0
  115. #-----------------------------------------------------------------------------
  116. # These are the damage settings for each row. The values represent the damage
  117. # multipier for that row. The format is..
  118. # :type => [front, middle, back]
  119. DMG={
  120. :dealt => [ 2.0 , 1.0 , 0.5 ],
  121. :taken => [ 2.0 , 1.0 , 0.5 ],
  122. }
  123. #-----------------------------------------------------------------------------
  124. # Shows Row Info On Main Menu Screen. Make false to disable.
  125. Show_Row_Info = true
  126. #-----------------------------------------------------------------------------
  127. # Changes the row selection mode..
  128. # :normal = player can select which row to change to
  129. # :basic = row will automatically change between front / back rows (0 & 2)
  130. # depending on the actors current row.
  131. Mode = :normal
  132. #-----------------------------------------------------------------------------
  133. # Notetag Settings. Only change if you understand what your doing !!
  134. Notes={
  135. :_row_ => /<row:(.*)>/i,
  136. :range => /<long range>/i,
  137. :fixed => /<fixed row>/i
  138. }
  139. #-----------------------------------------------------------------------------
  140. # Status Settings. change nil to the id of the status for frnt/midd/back row.
  141. States={
  142. :frnt => 27,
  143. :midd => 28,
  144. :back => 29,
  145. }
  146. #####################
  147. # CUSTOMISATION END #
  148. end #####################
  149. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  150. # #
  151. # http://dekitarpg.wordpress.com/ #
  152. # #
  153. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  154. #===============================================================================#
  155. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  156. # YES?\.\. #
  157. # OMG, REALLY? \| #
  158. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  159. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  160. #===============================================================================#
  161. module DataManager
  162. #===============================================================================
  163. #-----------------------------------------------------------------------------
  164. # Alias List
  165. #-----------------------------------------------------------------------------
  166. class << self
  167. alias :lbd_rows :load_database
  168. end
  169. #-----------------------------------------------------------------------------
  170. # Load Database (alias)
  171. #-----------------------------------------------------------------------------
  172. def self.load_database
  173. lbd_rows
  174. loa_rows
  175. end
  176. #-----------------------------------------------------------------------------
  177. # Load Unique Shit
  178. #-----------------------------------------------------------------------------
  179. def self.loa_rows
  180. classes = [ $data_weapons , $data_armors , $data_actors ,
  181. $data_classes , $data_enemies , $data_states ]
  182. for g in classes
  183. for o in g
  184. next if o == nil
  185. o.load_rows
  186. end
  187. end
  188. end
  189.  
  190. end # DataManager
  191.  
  192. #===============================================================================
  193. class RPG::BaseItem
  194. #===============================================================================
  195. #-----------------------------------------------------------------------------
  196. # Pi Variables
  197. #-----------------------------------------------------------------------------
  198. attr_accessor :battle_row
  199. attr_accessor :battle_row_range
  200. attr_accessor :battle_row_fixed
  201. #-----------------------------------------------------------------------------
  202. # Load Unique Notes
  203. #-----------------------------------------------------------------------------
  204. def load_rows
  205. @battle_row = nil
  206. @battle_row_range = 0
  207. @battle_row_fixed = false
  208. self.note.split(/[\r\n]+/).each do |line|
  209. case line
  210. when Rows::Notes[:_row_] then @battle_row = $1.to_i
  211. when Rows::Notes[:range] then @battle_row_range = 1
  212. when Rows::Notes[:fixed] then @battle_row_fixed = true
  213. end
  214. end
  215. end
  216.  
  217. end
  218.  
  219. #===============================================================================
  220. class Game_Battler < Game_BattlerBase
  221. #===============================================================================
  222. #-----------------------------------------------------------------------------
  223. # Alias List
  224. #-----------------------------------------------------------------------------
  225. alias :apply_VAR_rows :apply_variance
  226. alias :__MDV__Rows :make_damage_value
  227. alias :ref_rows :refresh
  228. alias :add_State_for_row :add_state
  229. alias :rem_State_for_row :remove_state
  230. #-----------------------------------------------------------------------------
  231. # Object Initialization
  232. #-----------------------------------------------------------------------------
  233. attr_accessor :battle_row
  234. #-----------------------------------------------------------------------------
  235. # M.D.V
  236. #-----------------------------------------------------------------------------
  237. def make_damage_value(user, item)
  238. @row_user = user
  239. @row_item = item
  240. __MDV__Rows(user, item)
  241. end
  242. #-----------------------------------------------------------------------------
  243. # Apply Variance Mod
  244. #-----------------------------------------------------------------------------
  245. def apply_variance(damage, variance)
  246. orig = apply_VAR_rows(damage, variance)
  247. rowm = apply_row_mods
  248. newd = (orig * rowm).to_i
  249. newd = 1 if ((orig != newd) && ((orig > 0) && (newd <= 0)))
  250. newd
  251. end
  252. #-----------------------------------------------------------------------------
  253. # Get Row Damage Modification
  254. #-----------------------------------------------------------------------------
  255. def apply_row_mods
  256. user = @row_user
  257. item = @row_item
  258. deal = Rows::DMG[:dealt][user.battle_row_range]
  259. took = Rows::DMG[:taken][self.battle_row_range]
  260. return (deal * took)
  261. end
  262. #-----------------------------------------------------------------------------
  263. # Refresh
  264. #-----------------------------------------------------------------------------
  265. def refresh
  266. ref_rows
  267. set_battle_row
  268. refresh_row_state
  269. end
  270. #-----------------------------------------------------------------------------
  271. # Refresh Row Status
  272. #-----------------------------------------------------------------------------
  273. def refresh_row_state
  274. return unless @can_battle_row
  275. frnt = Rows::States[:frnt]
  276. midd = Rows::States[:midd]
  277. back = Rows::States[:back]
  278. case battle_row_range
  279. when 0 then add_state(frnt) ; remove_state(midd) ; remove_state(back)
  280. when 1 then add_state(midd) ; remove_state(frnt) ; remove_state(back)
  281. when 2 then add_state(back) ; remove_state(frnt) ; remove_state(midd)
  282. end
  283. end
  284. #-----------------------------------------------------------------------------
  285. # Add State
  286. #-----------------------------------------------------------------------------
  287. def add_state(state_id)
  288. return if state_id == nil
  289. add_State_for_row(state_id)
  290. end
  291. #-----------------------------------------------------------------------------
  292. # Remove State
  293. #-----------------------------------------------------------------------------
  294. def remove_state(state_id)
  295. return if state_id == nil
  296. rem_State_for_row(state_id)
  297. end
  298.  
  299. end
  300.  
  301. #===============================================================================
  302. class Game_Actor < Game_Battler
  303. #===============================================================================
  304. #-----------------------------------------------------------------------------
  305. # Alias List
  306. #-----------------------------------------------------------------------------
  307. alias :init______rows :initialize
  308. #-----------------------------------------------------------------------------
  309. # Object Initialization
  310. #-----------------------------------------------------------------------------
  311. def initialize(actor_id)
  312. init______rows(actor_id)
  313. set_battle_row
  314. @can_battle_row = true
  315. end
  316. #-----------------------------------------------------------------------------
  317. # Set Battle Row
  318. #-----------------------------------------------------------------------------
  319. def set_battle_row
  320. @battle_row = Rows::Default_Row
  321. @battle_row = self.class.battle_row if self.class.battle_row != nil
  322. @battle_row = actor.battle_row if actor.battle_row != nil
  323. end
  324. #-----------------------------------------------------------------------------
  325. # Get Battle Row (with range mods)
  326. #-----------------------------------------------------------------------------
  327. def battle_row_range
  328. base = @battle_row
  329. base += actor.battle_row_range
  330. base += self.class.battle_row_range
  331. base += equips.compact.inject(0) {|r, i| r += i.battle_row_range}
  332. base += states.compact.inject(0) {|r, i| r += i.battle_row_range }
  333. base >= 2 ? 2 : base
  334. end
  335. #-----------------------------------------------------------------------------
  336. # Is Battle Row Fixed ?
  337. #-----------------------------------------------------------------------------
  338. def battle_row_fixed
  339. return true if self.class.battle_row_fixed
  340. return true if actor.battle_row_fixed
  341. return false
  342. end
  343.  
  344. end
  345.  
  346. #===============================================================================
  347. class Game_Enemy < Game_Battler
  348. #===============================================================================
  349. #-----------------------------------------------------------------------------
  350. # Alias List
  351. #-----------------------------------------------------------------------------
  352. alias :init______rows :initialize
  353. #-----------------------------------------------------------------------------
  354. # Object Initialization
  355. #-----------------------------------------------------------------------------
  356. def initialize(index, enemy_id)
  357. init______rows(index, enemy_id)
  358. set_battle_row
  359. @can_battle_row = true
  360. end
  361. #-----------------------------------------------------------------------------
  362. # Set Battle Row
  363. #-----------------------------------------------------------------------------
  364. def set_battle_row
  365. @battle_row = Rows::Default_Row
  366. @battle_row = enemy.battle_row if enemy.battle_row != nil
  367. end
  368. #-----------------------------------------------------------------------------
  369. # Get Battle Row (with range mods)
  370. #-----------------------------------------------------------------------------
  371. def battle_row_range
  372. base = @battle_row
  373. base += enemy.battle_row_range
  374. base += states.compact.inject(0) {|r, i| r += i.battle_row_range }
  375. base >= 2 ? 2 : base
  376. end
  377.  
  378. end
  379.  
  380. #===============================================================================
  381. class Window_ActorCommand < Window_Command
  382. #===============================================================================
  383. #-----------------------------------------------------------------------------
  384. # Pi Variables
  385. #-----------------------------------------------------------------------------
  386. attr_reader :actor
  387. #-----------------------------------------------------------------------------
  388. # Alias List
  389. #-----------------------------------------------------------------------------
  390. alias :mcl_row_formation :make_command_list
  391. #-----------------------------------------------------------------------------
  392. # Create Command List
  393. #-----------------------------------------------------------------------------
  394. def make_command_list
  395. mcl_row_formation
  396. add_row_command
  397. end
  398. #-----------------------------------------------------------------------------
  399. # Add Row Command to List
  400. #-----------------------------------------------------------------------------
  401. def add_row_command
  402. return unless $game_switches[Rows::Switch] if Rows::Switch != 0
  403. add_command(Rows::Vocab[:main], :row_change, enable_row_change?)
  404. end
  405. #-----------------------------------------------------------------------------
  406. # Enable Row Change
  407. #-----------------------------------------------------------------------------
  408. def enable_row_change?
  409. return false unless @actor
  410. return false if @actor.battle_row_fixed
  411. return true
  412. end
  413.  
  414. end
  415.  
  416. #===============================================================================
  417. class Window_Base < Window
  418. #===============================================================================
  419. if Rows::Show_Row_Info
  420. #---------------------------------------------------------------------------
  421. # Alias List
  422. #---------------------------------------------------------------------------
  423. alias :dass_row_formation :draw_actor_simple_status
  424. #---------------------------------------------------------------------------
  425. # Draw Simple Status
  426. #---------------------------------------------------------------------------
  427. def draw_actor_simple_status(actor, x, y)
  428. dass_row_formation(actor, x, y)
  429. draw_battle_row(actor, x, y+(line_height*2))
  430. end
  431. #---------------------------------------------------------------------------
  432. # Draw Battle Row
  433. #---------------------------------------------------------------------------
  434. def draw_battle_row(actor, x, y)
  435. case actor.battle_row
  436. when 0 then text = Rows::Vocab[:frnt]
  437. when 1 then text = Rows::Vocab[:midd]
  438. when 2 then text = Rows::Vocab[:back]
  439. end
  440. draw_text(x, y, 108, line_height, text)
  441. end
  442. end
  443.  
  444. end
  445.  
  446. #===============================================================================
  447. class Window_RowCommand < Window_Command
  448. #===============================================================================
  449. #-----------------------------------------------------------------------------
  450. # Pi Variables
  451. #-----------------------------------------------------------------------------
  452. attr_accessor :actor
  453. #-----------------------------------------------------------------------------
  454. # Object Initialization
  455. #-----------------------------------------------------------------------------
  456. def initialize
  457. super(0, 0)
  458. update_placement
  459. self.openness = 0
  460. @actor = nil
  461. deactivate
  462. close
  463. end
  464. #-----------------------------------------------------------------------------
  465. # Get Window Width
  466. #-----------------------------------------------------------------------------
  467. def window_width
  468. return Graphics.width / 4
  469. end
  470. #-----------------------------------------------------------------------------
  471. # Alignment
  472. #-----------------------------------------------------------------------------
  473. def alignment
  474. return 1
  475. end
  476. #-----------------------------------------------------------------------------
  477. # Update Window Position
  478. #-----------------------------------------------------------------------------
  479. def update_placement
  480. self.x = (Graphics.width - width) / 2
  481. self.y = (Graphics.height - height) / 2
  482. end
  483. #-----------------------------------------------------------------------------
  484. # Create Command List
  485. #-----------------------------------------------------------------------------
  486. def make_command_list
  487. add_command(Rows::Vocab[:frnt], :fron_row, enable_row?(0))
  488. add_command(Rows::Vocab[:midd], :midd_row, enable_row?(1))
  489. add_command(Rows::Vocab[:back], :back_row, enable_row?(2))
  490. end
  491. #-----------------------------------------------------------------------------
  492. # Enable Row Position ?
  493. #-----------------------------------------------------------------------------
  494. def enable_row?(pos)
  495. return false unless @actor
  496. return false if @actor.battle_row == pos
  497. return true
  498. end
  499.  
  500. end
  501.  
  502. #===============================================================================
  503. class Scene_Battle < Scene_Base
  504. #===============================================================================
  505. #-----------------------------------------------------------------------------
  506. # Alias List
  507. #-----------------------------------------------------------------------------
  508. alias :cacw_row_firmatioio :create_actor_command_window
  509. alias :caw__row_fomaiontns :create_all_windows
  510. #-----------------------------------------------------------------------------
  511. # Create All Windows
  512. #-----------------------------------------------------------------------------
  513. def create_all_windows
  514. caw__row_fomaiontns
  515. create_row_commands
  516. end
  517. #-----------------------------------------------------------------------------
  518. # Create Actor Commands Window
  519. #-----------------------------------------------------------------------------
  520. def create_actor_command_window
  521. cacw_row_firmatioio
  522. @actor_command_window.set_handler(:row_change, method(:command_rows))
  523. end
  524. #-----------------------------------------------------------------------------
  525. # Create Row Command Window
  526. #-----------------------------------------------------------------------------
  527. def create_row_commands
  528. @rcmndwind = Window_RowCommand.new
  529. @rcmndwind.set_handler(:back_row, method(:com_change_rows))
  530. @rcmndwind.set_handler(:midd_row, method(:com_change_rows))
  531. @rcmndwind.set_handler(:fron_row, method(:com_change_rows))
  532. @rcmndwind.set_handler(:cancel, method(:com_cancel_rows))
  533. end
  534. #-----------------------------------------------------------------------------
  535. # [Swap Row] Command
  536. #-----------------------------------------------------------------------------
  537. def command_rows
  538. return command_rows_basic if Rows::Mode == :basic
  539. @rcmndwind.actor = @actor_command_window.actor
  540. @rcmndwind.refresh
  541. @rcmndwind.activate
  542. @rcmndwind.open
  543. end
  544. #-----------------------------------------------------------------------------
  545. # [Swap Row] Command [ :basic ]
  546. #-----------------------------------------------------------------------------
  547. def command_rows_basic
  548. actor = @actor_command_window.actor
  549. case actor.battle_row
  550. when 0,1 then actor.battle_row = 2
  551. when 2 then actor.battle_row = 0
  552. end ; on_actor_ok
  553. end
  554. #-----------------------------------------------------------------------------
  555. # Set New Row
  556. #-----------------------------------------------------------------------------
  557. def com_change_rows
  558. actor = @actor_command_window.actor
  559. case @rcmndwind.current_symbol
  560. when :fron_row then actor.battle_row = 0
  561. when :midd_row then actor.battle_row = 1
  562. when :back_row then actor.battle_row = 2
  563. end
  564. @rcmndwind.deactivate
  565. @rcmndwind.close
  566. on_actor_ok
  567. end
  568. #-----------------------------------------------------------------------------
  569. # Swap Row [Cancel]
  570. #-----------------------------------------------------------------------------
  571. def com_cancel_rows
  572. @rcmndwind.deactivate
  573. @rcmndwind.close
  574. @actor_command_window.activate
  575. end
  576.  
  577. end
  578.  
  579. #==============================================================================#
  580. # http://dekitarpg.wordpress.com/ #
  581. #==============================================================================#
  582. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement