Advertisement
Dekita

$D13x Battle Rows v1.0

May 30th, 2013
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.10 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.0
  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. # 3o/o5/2o13 - Finished,
  21. # 18/o5/2o13 - Started
  22. #
  23. #===============================================================================
  24. # ☆ Introduction
  25. #-------------------------------------------------------------------------------
  26. # This script creates "Battle Rows".
  27. # Most people should know what this feature is, as its a very well known
  28. # aspect of most RPG games..
  29. #
  30. # For people who dont know..
  31. # Battle Rows allow you to have different rows while in battle..
  32. # EG. front row / middle row / back row, typically if you are in the front row
  33. # your damage output will be higher, but so will the damage recieved.
  34. # middle row damage is normal for both damage dealt and recived.
  35. # Back row damage (recieved & dealt) is reduced.
  36. #
  37. # A new command will be added to the actor command battle window,
  38. # This command will change your current row position.
  39. # You can only change your row position while in battle.
  40. #
  41. # Basically, this allows for slightly more tactical thinking while in battles.
  42. #
  43. # The only way to change your row is in battle.
  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, ut 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. # Notetag Settings. Only change if you understand what your doing !!
  128. Notes={
  129. :_row_ => /<row:(.*)>/i,
  130. :range => /<long range>/i,
  131. :fixed => /<fixed row>/i
  132. }
  133. #####################
  134. # CUSTOMISATION END #
  135. end #####################
  136. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  137. # #
  138. # http://dekitarpg.wordpress.com/ #
  139. # #
  140. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  141. #===============================================================================#
  142. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  143. # YES?\.\. #
  144. # OMG, REALLY? \| #
  145. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  146. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  147. #===============================================================================#
  148. module DataManager
  149. #===============================================================================
  150. #-----------------------------------------------------------------------------
  151. # Alias List
  152. #-----------------------------------------------------------------------------
  153. class << self
  154. alias :lbd_rows :load_database
  155. end
  156. #-----------------------------------------------------------------------------
  157. # Load Database (alias)
  158. #-----------------------------------------------------------------------------
  159. def self.load_database
  160. lbd_rows
  161. loa_rows
  162. end
  163. #-----------------------------------------------------------------------------
  164. # Load Unique Shit
  165. #-----------------------------------------------------------------------------
  166. def self.loa_rows
  167. classes = [ $data_weapons , $data_armors , $data_actors ,
  168. $data_classes , $data_enemies , $data_states ]
  169. for g in classes
  170. for o in g
  171. next if o == nil
  172. o.load_rows
  173. end
  174. end
  175. end
  176.  
  177. end # DataManager
  178.  
  179. #===============================================================================
  180. class RPG::BaseItem
  181. #===============================================================================
  182. #-----------------------------------------------------------------------------
  183. # Pi Variables
  184. #-----------------------------------------------------------------------------
  185. attr_accessor :battle_row
  186. attr_accessor :battle_row_range
  187. attr_accessor :battle_row_fixed
  188. #-----------------------------------------------------------------------------
  189. # Load Unique Notes
  190. #-----------------------------------------------------------------------------
  191. def load_rows
  192. @battle_row = nil
  193. @battle_row_range = 0
  194. @battle_row_fixed = false
  195. self.note.split(/[\r\n]+/).each do |line|
  196. case line
  197. when Rows::Notes[:_row_] then @battle_row = $1.to_i
  198. when Rows::Notes[:range] then @battle_row_range = 1
  199. when Rows::Notes[:fixed] then @battle_row_fixed = true
  200. end
  201. end
  202. end
  203.  
  204. end
  205.  
  206. #===============================================================================
  207. class Game_Battler < Game_BattlerBase
  208. #===============================================================================
  209. #-----------------------------------------------------------------------------
  210. # Alias List
  211. #-----------------------------------------------------------------------------
  212. alias :apply_VAR_rows :apply_variance
  213. alias :__MDV__Rows :make_damage_value
  214. #-----------------------------------------------------------------------------
  215. # Object Initialization
  216. #-----------------------------------------------------------------------------
  217. attr_accessor :battle_row
  218. #-----------------------------------------------------------------------------
  219. # M.D.V
  220. #-----------------------------------------------------------------------------
  221. def make_damage_value(user, item)
  222. @row_user = user
  223. @row_item = item
  224. __MDV__Rows(user, item)
  225. end
  226. #-----------------------------------------------------------------------------
  227. # Apply Variance Mod
  228. #-----------------------------------------------------------------------------
  229. def apply_variance(damage, variance)
  230. orig = apply_VAR_rows(damage, variance)
  231. rowm = apply_row_mods
  232. newd = (orig * rowm).to_i
  233. newd = 1 if ((orig != newd) && ((orig > 0) && (newd <= 0)))
  234. newd
  235. end
  236. #-----------------------------------------------------------------------------
  237. # Get Row Damage Modification
  238. #-----------------------------------------------------------------------------
  239. def apply_row_mods
  240. user = @row_user
  241. item = @row_item
  242. deal = Rows::DMG[:dealt][user.battle_row_range]
  243. took = Rows::DMG[:taken][self.battle_row_range]
  244. return (deal * took)
  245. end
  246.  
  247. end
  248.  
  249. #===============================================================================
  250. class Game_Actor < Game_Battler
  251. #===============================================================================
  252. #-----------------------------------------------------------------------------
  253. # Alias List
  254. #-----------------------------------------------------------------------------
  255. alias :init______rows :initialize
  256. #-----------------------------------------------------------------------------
  257. # Object Initialization
  258. #-----------------------------------------------------------------------------
  259. def initialize(actor_id)
  260. init______rows(actor_id)
  261. set_battle_row
  262. end
  263. #-----------------------------------------------------------------------------
  264. # Set Battle Row
  265. #-----------------------------------------------------------------------------
  266. def set_battle_row
  267. @battle_row = Rows::Default_Row
  268. @battle_row = self.class.battle_row if self.class.battle_row != nil
  269. @battle_row = actor.battle_row if actor.battle_row != nil
  270. end
  271. #-----------------------------------------------------------------------------
  272. # Get Battle Row (with range mods)
  273. #-----------------------------------------------------------------------------
  274. def battle_row_range
  275. base = @battle_row
  276. base += actor.battle_row_range
  277. base += self.class.battle_row_range
  278. base += equips.compact.inject(0) {|r, i| r += i.battle_row_range}
  279. base += states.compact.inject(0) {|r, i| r += i.battle_row_range }
  280. base >= 2 ? 2 : base
  281. end
  282. #-----------------------------------------------------------------------------
  283. # Is Battle Row Fixed ?
  284. #-----------------------------------------------------------------------------
  285. def battle_row_fixed
  286. return true if self.class.battle_row_fixed
  287. return true if actor.battle_row_fixed
  288. return false
  289. end
  290.  
  291. end
  292.  
  293. #===============================================================================
  294. class Game_Enemy < Game_Battler
  295. #===============================================================================
  296. #-----------------------------------------------------------------------------
  297. # Alias List
  298. #-----------------------------------------------------------------------------
  299. alias :init______rows :initialize
  300. #-----------------------------------------------------------------------------
  301. # Object Initialization
  302. #-----------------------------------------------------------------------------
  303. def initialize(index, enemy_id)
  304. init______rows(index, enemy_id)
  305. set_battle_row
  306. end
  307. #-----------------------------------------------------------------------------
  308. # Set Battle Row
  309. #-----------------------------------------------------------------------------
  310. def set_battle_row
  311. @battle_row = Rows::Default_Row
  312. @battle_row = enemy.battle_row if enemy.battle_row != nil
  313. end
  314. #-----------------------------------------------------------------------------
  315. # Get Battle Row (with range mods)
  316. #-----------------------------------------------------------------------------
  317. def battle_row_range
  318. base = @battle_row
  319. base += enemy.battle_row_range
  320. base += states.compact.inject(0) {|r, i| r += i.battle_row_range }
  321. base >= 2 ? 2 : base
  322. end
  323.  
  324. end
  325.  
  326. #===============================================================================
  327. class Window_ActorCommand < Window_Command
  328. #===============================================================================
  329. #-----------------------------------------------------------------------------
  330. # Pi Variables
  331. #-----------------------------------------------------------------------------
  332. attr_reader :actor
  333. #-----------------------------------------------------------------------------
  334. # Alias List
  335. #-----------------------------------------------------------------------------
  336. alias :mcl_row_formation :make_command_list
  337. #-----------------------------------------------------------------------------
  338. # Create Command List
  339. #-----------------------------------------------------------------------------
  340. def make_command_list
  341. mcl_row_formation
  342. add_row_command
  343. end
  344. #-----------------------------------------------------------------------------
  345. # Add Row Command to List
  346. #-----------------------------------------------------------------------------
  347. def add_row_command
  348. return unless $game_switches[Rows::Switch] if Rows::Switch != 0
  349. add_command(Rows::Vocab[:main], :row_change, enable_row_change?)
  350. end
  351. #-----------------------------------------------------------------------------
  352. # Enable Row Change
  353. #-----------------------------------------------------------------------------
  354. def enable_row_change?
  355. return false unless @actor
  356. return false if @actor.battle_row_fixed
  357. return true
  358. end
  359.  
  360. end
  361.  
  362. #===============================================================================
  363. class Window_Base < Window
  364. #===============================================================================
  365. if Rows::Show_Row_Info
  366. #---------------------------------------------------------------------------
  367. # Alias List
  368. #---------------------------------------------------------------------------
  369. alias :dass_row_formation :draw_actor_simple_status
  370. #---------------------------------------------------------------------------
  371. # Draw Simple Status
  372. #---------------------------------------------------------------------------
  373. def draw_actor_simple_status(actor, x, y)
  374. dass_row_formation(actor, x, y)
  375. draw_battle_row(actor, x, y+(line_height*2))
  376. end
  377. #---------------------------------------------------------------------------
  378. # Draw Battle Row
  379. #---------------------------------------------------------------------------
  380. def draw_battle_row(actor, x, y)
  381. case actor.battle_row
  382. when 0 then text = Rows::Vocab[:frnt]
  383. when 1 then text = Rows::Vocab[:midd]
  384. when 2 then text = Rows::Vocab[:back]
  385. end
  386. draw_text(x, y, 108, line_height, text)
  387. end
  388. end
  389.  
  390. end
  391.  
  392. #===============================================================================
  393. class Window_RowCommand < Window_Command
  394. #===============================================================================
  395. #-----------------------------------------------------------------------------
  396. # Pi Variables
  397. #-----------------------------------------------------------------------------
  398. attr_accessor :actor
  399. #-----------------------------------------------------------------------------
  400. # Object Initialization
  401. #-----------------------------------------------------------------------------
  402. def initialize
  403. super(0, 0)
  404. update_placement
  405. self.openness = 0
  406. @actor = nil
  407. deactivate
  408. close
  409. end
  410. #-----------------------------------------------------------------------------
  411. # Get Window Width
  412. #-----------------------------------------------------------------------------
  413. def window_width
  414. return Graphics.width / 4
  415. end
  416. #-----------------------------------------------------------------------------
  417. # Alignment
  418. #-----------------------------------------------------------------------------
  419. def alignment
  420. return 1
  421. end
  422. #-----------------------------------------------------------------------------
  423. # Update Window Position
  424. #-----------------------------------------------------------------------------
  425. def update_placement
  426. self.x = (Graphics.width - width) / 2
  427. self.y = (Graphics.height - height) / 2
  428. end
  429. #-----------------------------------------------------------------------------
  430. # Create Command List
  431. #-----------------------------------------------------------------------------
  432. def make_command_list
  433. add_command(Rows::Vocab[:frnt], :fron_row, enable_row?(0))
  434. add_command(Rows::Vocab[:midd], :midd_row, enable_row?(1))
  435. add_command(Rows::Vocab[:back], :back_row, enable_row?(2))
  436. end
  437. #-----------------------------------------------------------------------------
  438. # Enable Row Position ?
  439. #-----------------------------------------------------------------------------
  440. def enable_row?(pos)
  441. return false unless @actor
  442. return false if @actor.battle_row == pos
  443. return true
  444. end
  445.  
  446. end
  447.  
  448. #===============================================================================
  449. class Scene_Battle < Scene_Base
  450. #===============================================================================
  451. #-----------------------------------------------------------------------------
  452. # Alias List
  453. #-----------------------------------------------------------------------------
  454. alias :cacw_row_firmatioio :create_actor_command_window
  455. alias :caw__row_fomaiontns :create_all_windows
  456. #-----------------------------------------------------------------------------
  457. # Create All Windows
  458. #-----------------------------------------------------------------------------
  459. def create_all_windows
  460. caw__row_fomaiontns
  461. create_row_commands
  462. end
  463. #-----------------------------------------------------------------------------
  464. # Create Actor Commands Window
  465. #-----------------------------------------------------------------------------
  466. def create_actor_command_window
  467. cacw_row_firmatioio
  468. @actor_command_window.set_handler(:row_change, method(:command_rows))
  469. end
  470. #-----------------------------------------------------------------------------
  471. # Create Row Command Window
  472. #-----------------------------------------------------------------------------
  473. def create_row_commands
  474. @rcmndwind = Window_RowCommand.new
  475. @rcmndwind.set_handler(:back_row, method(:com_change_rows))
  476. @rcmndwind.set_handler(:midd_row, method(:com_change_rows))
  477. @rcmndwind.set_handler(:fron_row, method(:com_change_rows))
  478. @rcmndwind.set_handler(:cancel, method(:com_cancel_rows))
  479. end
  480. #-----------------------------------------------------------------------------
  481. # [Swap Row] Command
  482. #-----------------------------------------------------------------------------
  483. def command_rows
  484. @rcmndwind.actor = @actor_command_window.actor
  485. @rcmndwind.refresh
  486. @rcmndwind.activate
  487. @rcmndwind.open
  488. end
  489. #-----------------------------------------------------------------------------
  490. # Set New Row
  491. #-----------------------------------------------------------------------------
  492. def com_change_rows
  493. actor = @actor_command_window.actor
  494. case @rcmndwind.current_symbol
  495. when :fron_row then actor.battle_row = 0
  496. when :midd_row then actor.battle_row = 1
  497. when :back_row then actor.battle_row = 2
  498. end
  499. @rcmndwind.deactivate
  500. @rcmndwind.close
  501. on_actor_ok
  502. end
  503. #-----------------------------------------------------------------------------
  504. # Swap Row [Cancel]
  505. #-----------------------------------------------------------------------------
  506. def com_cancel_rows
  507. @rcmndwind.deactivate
  508. @rcmndwind.close
  509. @actor_command_window.activate
  510. end
  511.  
  512. end
  513.  
  514. #==============================================================================#
  515. # http://dekitarpg.wordpress.com/ #
  516. #==============================================================================#
  517. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement