Advertisement
AlliedG

Grathnode Install

Jan 7th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.33 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # ? Grathnode Install
  3. # Author: Kread-EX
  4. # Version 1.13
  5. # Release date: 31/12/2011
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  7.  
  8. #------------------------------------------------------------------------------
  9. # ? UPDATES
  10. #------------------------------------------------------------------------------
  11. # # 16/01/2013. Fixed a bug with removed grathnodes not being given back.
  12. # # 28/12/2012. Fixed another bug with savefiles.
  13. # # 30/01/2012. Added option to disable grathnode menu for certain characters.
  14. # # 30/01/2012. Added option to remove grathnodes when a skill is forgetted.
  15. # # 20/01/2012. Compatibility fix.
  16. # # 19/01/2012. Loads of compatibility fixes.
  17. # # 14/01/2012. Fixed two crashing bugs with the DBS implementation.
  18. # # 10/01/2012. <max_grathnodes: 0> now works.
  19. # # 07/01/2012. Fixed a critical bug preventing the installs to be saved.
  20. # # 05/01/2012. Fixed a crashing bug in the Install menu if no skill is
  21. # # available.
  22. # # 01/01/2012. Fixed compatibility with Yanfly's TP Manager (thanks Adalwulf)
  23. # # NOW DEPRECATED. Use Yanfly's Ace Skill Menu to ensure compat. However, in
  24. # # case you don't want to, just uncomment the code at the end of the script.
  25. #------------------------------------------------------------------------------
  26. # ? TERMS OF USAGE
  27. #------------------------------------------------------------------------------
  28. # # You are free to adapt this work to suit your needs.
  29. # # You can use this work for commercial purposes if you like it.
  30. # # Credit is appreciated.
  31. # #
  32. # # For support:
  33. # # grimoirecastle.wordpress.com
  34. # # rpgmakerweb.com
  35. #------------------------------------------------------------------------------
  36. # ? INTRODUCTION
  37. #------------------------------------------------------------------------------
  38. # # This script is inspired from the Ar Tonelico series. In a nutshell,
  39. # # it allows the player to assign special items called Grathnode crystals to
  40. # # skills in order to add special effects.
  41. # # The upgrades are actor-dependant: if two actors have the same skill, they
  42. # # can use a different set of crystals.
  43. #------------------------------------------------------------------------------
  44. # ? INSTRUCTIONS
  45. #------------------------------------------------------------------------------
  46. # # First, you need to create the desired grathnode crystals. They are regular
  47. # # items, but tagged as <grathnode> in their notebox.
  48. # # Certain grathnodes are suited only for a certain type of skill. To ensure
  49. # # that a defensive skill doesn't use an offensive effect, you can choose
  50. # # the kind of scope:
  51. # # <scope: string> in the item notebox.
  52. # # String can be different values:
  53. # # for_opponent?
  54. # # for_friend?
  55. # # for_dead_friend?
  56. # # for_user?
  57. # # for_all?
  58. # #
  59. # # Every skill can contain up to 6 crystals by default, but you can lower the
  60. # # number either individually (by putting <max_grathnodes: x> if the skill
  61. # # notebox, or globally by altering the ABSOLUTE_MAX_GRATHNODES value within
  62. # # the script.
  63. # #
  64. # # The scene can be called with SceneManager.call(Scene_Grathnode), however
  65. # # I strongly recommend you to use Yanfly's Ace Menu Engine, as I prepared
  66. # # special compatibility for it.
  67. #------------------------------------------------------------------------------
  68. # ? COMPATIBILITY
  69. #------------------------------------------------------------------------------
  70. # # Works with Yanfly's Battle Engine Ace. Actually, it may work better than with
  71. # # the DBS, thanks to the nice pop-ups, very GUST-ish at the conception.
  72. # #
  73. # # List of aliases and overwrites:
  74. # #
  75. # # DataManager
  76. # # load_database (alias)
  77. # # load_grathnode_notetags (new method)
  78. # #
  79. # # RPG::Item
  80. # # load_grathnode_notetags (new method)
  81. # # is_grathnode? (new method)
  82. # # grathnode_scope (new attr method)
  83. # # mp_inflation (new attr method)
  84. # # tp_inflation (new attr method)
  85. # #
  86. # # RPG::Skill
  87. # # load_grathnode_notetags (new method)
  88. # # grathnode_slots (new method)
  89. # #
  90. # # Game_Actor
  91. # # installs (new attr method)
  92. # # barring_grathnode (new attr method)
  93. # # setup (alias)
  94. # # forget_skill (alias)
  95. # # add_grathnode (new method)
  96. # # skill_mp_cost (new child method)
  97. # # skill_tp_cost (new child method)
  98. # # process_grathnode_mp_cost (new method)
  99. # # process_grathnode_tp_cost (new method)
  100. # #
  101. # # Game_Party
  102. # # last_selected_skill (new attr method)
  103. # # menu_actor (alias)
  104. # # menu_actor_next (alias)
  105. # # menu_actor_prev (alias)
  106. # #
  107. # # Scene_Grathnode (new class)
  108. # #
  109. # # Window_UpSkillList (new class)
  110. # #
  111. # # Window_GrathnodeList (new class)
  112. # #
  113. # # Window_GrathnodeInstall (new class)
  114. # #
  115. # # Scene_Battle
  116. # # apply_item_effects (alias)
  117. # # apply_grathnode_effects (new method - YEA Battle Engine only)
  118. #------------------------------------------------------------------------------
  119.  
  120. ($imported ||= {})['KRX-GrathnodeInstall'] = true
  121.  
  122. puts 'Load: Grathnode Install v1.13 by Kread-EX'
  123.  
  124. module KRX
  125. #===========================================================================
  126. # ¦ CONFIGURATION
  127. #===========================================================================
  128. ABSOLUTE_MAX_GRATHNODES = 1
  129. CLEAR_FORGET_SKILL = true
  130. SINGLE_ACTOR_INSTALL = false
  131. SINGLE_ACTOR_INSTALL_ID = 9
  132.  
  133. module VOCAB
  134. GRATHNODE = 'Shard'
  135. end
  136. #===========================================================================
  137. # ¦ CONFIGURATION ENDS HERE
  138. #===========================================================================
  139. module REGEXP
  140. MAX_GRATHNODES = /<max_grathnodes:[ ]*(\d+)>/i
  141. GRATHNODE_ITEM = /<grathnode>/i
  142. GRATHNODE_SCOPE = /<scope:[ ]*(\w+.)>/
  143. MP_INFLATION = /<mp_inflation:[ ]*([+-]?\d+)>/i
  144. TP_INFLATION = /<tp_inflation:[ ]*(\d+)>/i
  145. end
  146. end
  147.  
  148. #===========================================================================
  149. # ¦ DataManager
  150. #===========================================================================
  151.  
  152. module DataManager
  153. #--------------------------------------------------------------------------
  154. # ? Loads the database
  155. #--------------------------------------------------------------------------
  156. class << self
  157. alias_method(:krx_grathnode_dm_load_database, :load_database)
  158. end
  159. def self.load_database
  160. krx_grathnode_dm_load_database
  161. load_grathnode_notetags
  162. end
  163. #--------------------------------------------------------------------------
  164. # ? Loads the note tags
  165. #--------------------------------------------------------------------------
  166. def self.load_grathnode_notetags
  167. groups = [$data_items, $data_skills]
  168. for group in groups
  169. for obj in group
  170. next if obj.nil?
  171. obj.load_grathnode_notetags
  172. end
  173. end
  174. puts "Read: Grathnode Install Notetags"
  175. end
  176. end
  177.  
  178. #==========================================================================
  179. # ¦ RPG::Item
  180. #==========================================================================
  181.  
  182. class RPG::Item < RPG::UsableItem
  183. #--------------------------------------------------------------------------
  184. # ? Public instance variables
  185. #--------------------------------------------------------------------------
  186. attr_reader :grathnode_scope
  187. attr_reader :mp_inflation
  188. attr_reader :tp_inflation
  189. #--------------------------------------------------------------------------
  190. # ? Loads the note tags
  191. #--------------------------------------------------------------------------
  192. def load_grathnode_notetags
  193. @mp_inflation = @tp_inflation = 0
  194. @note.split(/[\r\n]+/).each do |line|
  195. case line
  196. when KRX::REGEXP::GRATHNODE_ITEM
  197. @is_grathnode = true
  198. when KRX::REGEXP::GRATHNODE_SCOPE
  199. @grathnode_scope = $1
  200. when KRX::REGEXP::MP_INFLATION
  201. @mp_inflation = $1.to_i
  202. when KRX::REGEXP::TP_INFLATION
  203. @tp_inflation = $1.to_i
  204. end
  205. end
  206. end
  207. #--------------------------------------------------------------------------
  208. # ? Determine if the item is a grathnode crystal
  209. #--------------------------------------------------------------------------
  210. def grathnode?
  211. @is_grathnode
  212. end
  213. end
  214.  
  215. #==========================================================================
  216. # ¦ RPG::Skill
  217. #==========================================================================
  218.  
  219. class RPG::Skill < RPG::UsableItem
  220. #--------------------------------------------------------------------------
  221. # ? Loads the note tags
  222. #--------------------------------------------------------------------------
  223. def load_grathnode_notetags
  224. @max_grathnodes = nil
  225. @note.split(/[\r\n]+/).each do |line|
  226. case line
  227. when KRX::REGEXP::MAX_GRATHNODES
  228. @max_grathnodes = [$1.to_i, KRX::ABSOLUTE_MAX_GRATHNODES].min
  229. end
  230. end
  231. end
  232. #--------------------------------------------------------------------------
  233. # ? Returns the maximum number of grathnode slots
  234. #--------------------------------------------------------------------------
  235. def grathnode_slots
  236. (@max_grathnodes == nil ? KRX::ABSOLUTE_MAX_GRATHNODES : @max_grathnodes)
  237. end
  238. #--------------------------------------------------------------------------
  239. # * Hidden
  240. #--------------------------------------------------------------------------
  241. def hidden?
  242. unless @hidden
  243. if @note =~ /<hidden>/i
  244. @hidden = true
  245. else
  246. @hidden = false
  247. end
  248. end
  249. return @hidden
  250. end
  251. end
  252.  
  253. #==========================================================================
  254. # ¦ Game_Actor
  255. #==========================================================================
  256.  
  257. class Game_Actor < Game_Battler
  258. #--------------------------------------------------------------------------
  259. # ? Public instance variables
  260. #--------------------------------------------------------------------------
  261. attr_accessor :installs
  262. attr_accessor :barring_grathnode
  263. #--------------------------------------------------------------------------
  264. # ? Setup
  265. #--------------------------------------------------------------------------
  266. alias_method(:krx_grathnode_gp_setup, :setup)
  267. def setup(actor_id)
  268. krx_grathnode_gp_setup(actor_id)
  269. @installs = {}
  270. @barring_grathnode = false
  271. end
  272. #--------------------------------------------------------------------------
  273. # ? Adds a grathnode crystal to a specific skill slot
  274. #--------------------------------------------------------------------------
  275. def add_grathnode(skill, crystal, slot)
  276. if @installs[skill.id].nil?
  277. @installs[skill.id] = Array.new(skill.grathnode_slots, nil)
  278. elsif @installs[skill.id][slot] != nil
  279. item = $data_items[@installs[skill.id][slot]]
  280. $game_party.gain_item(item, 1)
  281. end
  282. $game_party.lose_item(crystal, 1) unless crystal.nil?
  283. @installs[skill.id][slot] = crystal.nil? ? nil : crystal.id
  284. end
  285. #--------------------------------------------------------------------------
  286. # ? Returns the MP cost for a skill
  287. #--------------------------------------------------------------------------
  288. def skill_mp_cost(skill)
  289. cost = super
  290. (cost + cost * process_grathnode_mp_cost(skill) / 100).round
  291. end
  292. #--------------------------------------------------------------------------
  293. # ? Returns the TP cost for a skill
  294. #--------------------------------------------------------------------------
  295. def skill_tp_cost(skill)
  296. cost = super
  297. (cost + cost * process_grathnode_tp_cost(skill) / 100).round
  298. end
  299. #--------------------------------------------------------------------------
  300. # ? Calculates the MP cost inflation
  301. #--------------------------------------------------------------------------
  302. def process_grathnode_mp_cost(skill)
  303. result = 0.0
  304. return result if @installs[skill.id].nil?
  305. @installs[skill.id].compact.each do |grathnode|
  306. result += $data_items[grathnode].mp_inflation
  307. end
  308. return result
  309. end
  310. #--------------------------------------------------------------------------
  311. # ? Calculates the TP cost inflation
  312. #--------------------------------------------------------------------------
  313. def process_grathnode_tp_cost(skill)
  314. result = 0.0
  315. return result if @installs[skill.id].nil?
  316. @installs[skill.id].compact.each do |grathnode|
  317. result += $data_items[grathnode].tp_inflation
  318. end
  319. return result
  320. end
  321. #--------------------------------------------------------------------------
  322. # ? Forgets a skill
  323. #--------------------------------------------------------------------------
  324. alias_method(:krx_grathnode_ga_fs, :forget_skill)
  325. def forget_skill(skill_id)
  326. krx_grathnode_ga_fs(skill_id)
  327. if KRX::CLEAR_FORGET_SKILL
  328. skill = $data_skills[skill_id]
  329. (0...skill.grathnode_slots).each do |i|
  330. add_grathnode(skill, nil, i)
  331. end
  332. end
  333. end
  334. end
  335.  
  336. #==========================================================================
  337. # ¦ Game_Party
  338. #==========================================================================
  339.  
  340. class Game_Party < Game_Unit
  341. #--------------------------------------------------------------------------
  342. # ? Public instance variables
  343. #--------------------------------------------------------------------------
  344. attr_accessor :last_selected_skill
  345. #--------------------------------------------------------------------------
  346. # ? Next actor
  347. #--------------------------------------------------------------------------
  348. alias_method(:krx_grathnode_gp_man, :menu_actor_next)
  349. def menu_actor_next
  350. if SceneManager.scene.is_a?(Scene_Grathnode)
  351. return menu_actor if KRX::SINGLE_ACTOR_INSTALL
  352. val = members.select {|act| !act.barring_grathnode}
  353. index = val.index(menu_actor) || -1
  354. index = (index + 1) % val.size
  355. self.menu_actor = val[index]
  356. else
  357. krx_grathnode_gp_man
  358. end
  359. end
  360. #--------------------------------------------------------------------------
  361. # ? Previous actor
  362. #--------------------------------------------------------------------------
  363. alias_method(:krx_grathnode_gp_map, :menu_actor_prev)
  364. def menu_actor_prev
  365. if SceneManager.scene.is_a?(Scene_Grathnode)
  366. return menu_actor if KRX::SINGLE_ACTOR_INSTALL
  367. val = members.select {|act| !act.barring_grathnode}
  368. index = val.index(menu_actor) || 1
  369. index = (index + val.size - 1) % val.size
  370. self.menu_actor = val[index]
  371. else
  372. krx_grathnode_gp_map
  373. end
  374. end
  375. #--------------------------------------------------------------------------
  376. # ? Get the current actor for menus
  377. #--------------------------------------------------------------------------
  378. alias_method(:krx_grathnode_gp_ma, :menu_actor)
  379. def menu_actor
  380. if SceneManager.scene.is_a?(Scene_Grathnode)
  381. val = members.select {|act| !act.barring_grathnode}
  382. return $game_actors[@menu_actor_id] || val[0]
  383. end
  384. return krx_grathnode_gp_ma
  385. end
  386. end
  387.  
  388. #==========================================================================
  389. # ¦ Scene_Grathnode
  390. #==========================================================================
  391.  
  392. class Scene_Grathnode < Scene_Skill
  393. #--------------------------------------------------------------------------
  394. # ? Object Initializate
  395. #--------------------------------------------------------------------------
  396. def initialize
  397. if KRX::SINGLE_ACTOR_INSTALL
  398. $game_party.menu_actor = $game_actors[KRX::SINGLE_ACTOR_INSTALL_ID]
  399. end
  400. end
  401. #--------------------------------------------------------------------------
  402. # ? Scene start
  403. #--------------------------------------------------------------------------
  404. def start
  405. super
  406. create_install_window
  407. end
  408. #--------------------------------------------------------------------------
  409. # ? Creates the window displaying the grathnodes currently installed
  410. #--------------------------------------------------------------------------
  411. def create_install_window
  412. wy = @status_window.y + @status_window.height
  413. ww = Graphics.width / 2
  414. wh = Graphics.height - wy
  415. @install_window = Window_GrathnodeInstall.new(ww, wy, ww, wh)
  416. @install_window.viewport = @viewport
  417. @install_window.set_handler(:ok, method(:on_slot_ok))
  418. @install_window.set_handler(:cancel, method(:on_slot_cancel))
  419. @item_window.install_window = @install_window
  420. end
  421. #--------------------------------------------------------------------------
  422. # ? Creates the window displaying the grathnodes currently owned
  423. #--------------------------------------------------------------------------
  424. def create_grathnodes_window
  425. wx = 0
  426. wy = @status_window.y + @status_window.height
  427. ww = Graphics.width / 2
  428. wh = Graphics.height - wy
  429. @grathnode_window = Window_GrathnodeList.new(wx, wy, ww, wh)
  430. @grathnode_window.viewport = @viewport
  431. @grathnode_window.help_window = @help_window
  432. @grathnode_window.refresh
  433. @grathnode_window.select(0)
  434. @grathnode_window.activate
  435. @grathnode_window.set_handler(:ok, method(:on_grath_ok))
  436. @grathnode_window.set_handler(:cancel, method(:on_grath_cancel))
  437. end
  438. #--------------------------------------------------------------------------
  439. # ? Creates the window displaying the skills
  440. #--------------------------------------------------------------------------
  441. def create_item_window
  442. wx = 0
  443. wy = @status_window.y + @status_window.height
  444. ww = Graphics.width / 2
  445. wh = Graphics.height - wy
  446. @item_window = Window_UpSkillList.new(wx, wy, ww, wh)
  447. @item_window.actor = @actor
  448. @item_window.viewport = @viewport
  449. @item_window.help_window = @help_window
  450. @item_window.set_handler(:ok, method(:on_item_ok))
  451. @item_window.set_handler(:cancel, method(:on_item_cancel))
  452. @command_window.skill_window = @item_window
  453. end
  454. #--------------------------------------------------------------------------
  455. # ? Validates the skill selection
  456. #--------------------------------------------------------------------------
  457. def on_item_ok
  458. @item_window.hide
  459. @last_index = @item_window.index
  460. $game_party.last_selected_skill = @item_window.item
  461. create_grathnodes_window
  462. end
  463. #--------------------------------------------------------------------------
  464. # ? Cancels the skill selection
  465. #--------------------------------------------------------------------------
  466. def on_item_cancel
  467. @item_window.unselect
  468. @item_window.update_help
  469. @command_window.activate
  470. end
  471. #--------------------------------------------------------------------------
  472. # ? Validates the slot selection
  473. #--------------------------------------------------------------------------
  474. def on_slot_ok
  475. sk = @item_window.item
  476. gr = @grathnode_window.item
  477. slot = @install_window.index
  478. @actor.add_grathnode(sk, gr, slot)
  479. @item_window.refresh
  480. @install_window.unselect
  481. @install_window.set_item(@item_window.item)
  482. @grathnode_window.refresh
  483. @grathnode_window.activate
  484. end
  485. #--------------------------------------------------------------------------
  486. # ? Cancels the slot selection
  487. #--------------------------------------------------------------------------
  488. def on_slot_cancel
  489. @install_window.unselect
  490. @grathnode_window.activate
  491. end
  492. #--------------------------------------------------------------------------
  493. # ? Validates the grathnode selection
  494. #--------------------------------------------------------------------------
  495. def on_grath_ok
  496. @install_window.activate
  497. @install_window.select(0)
  498. end
  499. #--------------------------------------------------------------------------
  500. # ? Cancels the grathnode selection
  501. #--------------------------------------------------------------------------
  502. def on_grath_cancel
  503. @item_window.select(@last_index)
  504. @item_window.show
  505. @item_window.activate
  506. @grathnode_window.dispose ; @grathnode_window = nil
  507. end
  508. #--------------------------------------------------------------------------
  509. # ? Confirms the actor switch
  510. #--------------------------------------------------------------------------
  511. def on_actor_change
  512. super
  513. @install_window.actor = @actor
  514. end
  515. end
  516.  
  517. #==========================================================================
  518. # ¦ Window_UpSkillList
  519. #==========================================================================
  520.  
  521. class Window_UpSkillList < Window_SkillList
  522. #--------------------------------------------------------------------------
  523. # * Include in Skill List?
  524. #--------------------------------------------------------------------------
  525. def include?(item)
  526. item && item.stype_id == @stype_id && !item.hidden?
  527. end
  528. #--------------------------------------------------------------------------
  529. # ? Assigns the install window
  530. #--------------------------------------------------------------------------
  531. def install_window=(value)
  532. @install_window = value
  533. end
  534. #--------------------------------------------------------------------------
  535. # ? Determine if the skill can be selected
  536. #--------------------------------------------------------------------------
  537. def enable?(item)
  538. return item != nil && item.grathnode_slots > 0
  539. end
  540. #--------------------------------------------------------------------------
  541. # ? Refreshes the help and install windows
  542. #--------------------------------------------------------------------------
  543. def update_help
  544. super
  545. @install_window.set_item(item)
  546. end
  547. #--------------------------------------------------------------------------
  548. # ? Returns the number of columns
  549. #--------------------------------------------------------------------------
  550. def col_max
  551. return 1
  552. end
  553. end
  554.  
  555. #==========================================================================
  556. # ¦ Window_GrathnodeInstall
  557. #==========================================================================
  558.  
  559. class Window_GrathnodeInstall < Window_Selectable
  560. #--------------------------------------------------------------------------
  561. # ? Public instance variables
  562. #--------------------------------------------------------------------------
  563. attr_accessor :actor
  564. #--------------------------------------------------------------------------
  565. # ? Object Initialize
  566. #--------------------------------------------------------------------------
  567. def initialize(x, y, width, height)
  568. super
  569. set_item
  570. @actor = $game_party.menu_actor
  571. end
  572. #--------------------------------------------------------------------------
  573. # ? Refresh the contents
  574. #--------------------------------------------------------------------------
  575. def set_item(item = nil)
  576. contents.clear
  577. return if item.nil?
  578. @data = Array.new(item.grathnode_slots, nil)
  579. @installs = @actor.installs[item.id]
  580. draw_item_installs(item)
  581. end
  582. #--------------------------------------------------------------------------
  583. # ? Displays the skill's current installs
  584. #--------------------------------------------------------------------------
  585. def draw_item_installs(item)
  586. draw_horz_line(line_height * 6)
  587. change_color(system_color)
  588. contents.draw_text(4, 0, width, line_height, KRX::VOCAB::GRATHNODE)
  589. change_color(normal_color)
  590. m = item.grathnode_slots
  591. (1..m).each {|i| contents.draw_text(4, line_height * i, width, line_height, "#{i}.")}
  592. return if @installs.nil? || @installs.empty?
  593. @installs.each_index do |i|
  594. grath = @installs[i].nil? ? nil : $data_items[@installs[i]]
  595. draw_item_name(grath, 28, line_height * (i + 1), true, width - 24)
  596. end
  597. draw_mp(item) if @actor.process_grathnode_mp_cost(item).round !=0
  598. draw_tp(item) if @actor.process_grathnode_tp_cost(item).round > 0
  599. end
  600. #--------------------------------------------------------------------------
  601. # ? Displays the skill's MP inflation rate
  602. #--------------------------------------------------------------------------
  603. def draw_mp(item)
  604. change_color(system_color)
  605. contents.draw_text(4, line_height * 7, width, line_height, Vocab.basic(5))
  606. change_color(normal_color)
  607. contents.draw_text(28, line_height * 7, width, line_height,
  608. sprintf("%+d%%", @actor.process_grathnode_mp_cost(item).round) )
  609. end
  610. #--------------------------------------------------------------------------
  611. # ? Displays the skill's TP inflation rate
  612. #--------------------------------------------------------------------------
  613. def draw_tp(item)
  614. change_color(system_color)
  615. w = width / 4
  616. contents.draw_text(w, line_height * 7, width, line_height, Vocab.basic(7))
  617. change_color(normal_color)
  618. contents.draw_text(w + 28, line_height * 7, width, line_height,
  619. "+#{@actor.process_grathnode_tp_cost(item).round.to_s}%")
  620. end
  621. #--------------------------------------------------------------------------
  622. # ? Returns the number of columns
  623. #--------------------------------------------------------------------------
  624. def col_max
  625. return 1
  626. end
  627. #--------------------------------------------------------------------------
  628. # ? Returns the max number of rows
  629. #--------------------------------------------------------------------------
  630. def item_max
  631. @data ? @data.size : 1
  632. end
  633. #--------------------------------------------------------------------------
  634. # ? Sets the rectangle for selections
  635. #--------------------------------------------------------------------------
  636. def item_rect(index)
  637. rect = Rect.new
  638. rect.width = item_width
  639. rect.height = item_height
  640. rect.x = index % col_max * (item_width + spacing)
  641. rect.y = (index / col_max * item_height) + line_height
  642. rect
  643. end
  644. #--------------------------------------------------------------------------
  645. # ? Displays an horizontal line
  646. #--------------------------------------------------------------------------
  647. def draw_horz_line(y)
  648. line_y = y + line_height / 2 - 1
  649. contents.fill_rect(0, line_y, contents_width, 2, line_color)
  650. end
  651. #--------------------------------------------------------------------------
  652. # ? Returns the color used for horizontal lines
  653. #--------------------------------------------------------------------------
  654. def line_color
  655. color = normal_color
  656. color.alpha = 48
  657. return color
  658. end
  659. end
  660.  
  661. #==========================================================================
  662. # ¦ Window_GrathnodeList
  663. #==========================================================================
  664.  
  665. class Window_GrathnodeList < Window_ItemList
  666. #--------------------------------------------------------------------------
  667. # ? Determine if an item goes in the list
  668. #--------------------------------------------------------------------------
  669. def include?(item)
  670. item.is_a?(RPG::Item) && item.grathnode?
  671. end
  672. #--------------------------------------------------------------------------
  673. # ? Determine if the grathnode can be used
  674. #--------------------------------------------------------------------------
  675. def enable?(item)
  676. return true if item.nil?
  677. actor = $game_party.menu_actor
  678. skill = $game_party.last_selected_skill
  679. if !actor.installs[skill.id].nil? && actor.installs[skill.id].include?(item.id)
  680. return false
  681. end
  682. if !item.grathnode_scope.nil? && !skill.send(item.grathnode_scope)
  683. return false
  684. end
  685. return true
  686. end
  687. #--------------------------------------------------------------------------
  688. # ? Creates the list based on the recipes
  689. #--------------------------------------------------------------------------
  690. def make_item_list
  691. @data = $game_party.items.select {|item| include?(item)}
  692. @data.push(nil)
  693. end
  694. #--------------------------------------------------------------------------
  695. # ? Returns the number of columns
  696. #--------------------------------------------------------------------------
  697. def col_max
  698. return 1
  699. end
  700. end
  701.  
  702. #==========================================================================
  703. # ¦ Scene_Battle
  704. #==========================================================================
  705.  
  706. class Scene_Battle < Scene_Base
  707.  
  708. ## Yanfly's Ace Battle Engine implementation
  709. if $imported["YEA-BattleEngine"]
  710. #--------------------------------------------------------------------------
  711. # ? Applies the effects of the skill or item
  712. #--------------------------------------------------------------------------
  713. alias_method(:krx_grathnode_sb_aie, :apply_item_effects)
  714. def apply_item_effects(target, item)
  715. apply_grathnode_effects(target, item)
  716. krx_grathnode_sb_aie(target, item)
  717. end
  718. #--------------------------------------------------------------------------
  719. # ? Applies the effects of grathnodes associated to the skill
  720. #--------------------------------------------------------------------------
  721. def apply_grathnode_effects(target, item)
  722. unless @subject.is_a?(Game_Actor)&& @subject.installs.keys.include?(item.id) &&
  723. @subject.installs[item.id] != nil
  724. return
  725. end
  726. @subject.installs[item.id].compact.each do |grath|
  727. target.item_apply(@subject, $data_items[grath])
  728. end
  729. end
  730. ## End of Yanfly's Ace Battle Engine implementation
  731. ## DBS implementation
  732. else
  733. #--------------------------------------------------------------------------
  734. # ? Applies the effects of the skill or item
  735. #--------------------------------------------------------------------------
  736. alias_method(:krx_grathnode_sb_aie, :apply_item_effects)
  737. def apply_item_effects(target, item)
  738. krx_grathnode_sb_aie(target, item)
  739. apply_grathnode_effects(target, item)
  740. end
  741. #--------------------------------------------------------------------------
  742. # ? Applies the effects of grathnodes associated to the skill
  743. #--------------------------------------------------------------------------
  744. def apply_grathnode_effects(target, item)
  745. unless @subject.is_a?(Game_Actor)&& @subject.installs.keys.include?(item.id) &&
  746. @subject.installs[item.id] != nil || target.dead?
  747. return
  748. end
  749. return unless @subject.is_a?(Game_Actor)
  750. return if @subject.installs.nil? || @subject.installs[item.id].nil?
  751. @subject.installs[item.id].compact.each do |grath|
  752. target.item_apply(@subject, $data_items[grath])
  753. @log_window.display_action_results(target, $data_items[grath])
  754. end
  755. end # Method End
  756. end ## End of DBS implementation
  757. end
  758.  
  759. ## Menu inclusion, with Yanfly's Ace Menu Engine
  760. if $imported["YEA-AceMenuEngine"]
  761.  
  762. #==========================================================================
  763. # ¦ Scene_Menu
  764. #==========================================================================
  765.  
  766. class Scene_Menu < Scene_MenuBase
  767. #--------------------------------------------------------------------------
  768. # ? Switch to the actor selection
  769. #--------------------------------------------------------------------------
  770. def command_install
  771. if KRX::SINGLE_ACTOR_INSTALL
  772. SceneManager.call(Scene_Grathnode)
  773. return
  774. end
  775. @status_window.select_last
  776. @status_window.activate
  777. @status_window.set_handler(:ok, method(:on_install_ok))
  778. @status_window.set_handler(:cancel, method(:on_personal_cancel))
  779. end
  780. #--------------------------------------------------------------------------
  781. # ? Validates the actor selection
  782. #--------------------------------------------------------------------------
  783. def on_install_ok
  784. SceneManager.call(Scene_Grathnode)
  785. end
  786. end
  787.  
  788. #==========================================================================
  789. # ¦ Window_MenuStatus
  790. #==========================================================================
  791.  
  792. class Window_MenuStatus < Window_Selectable
  793. #--------------------------------------------------------------------------
  794. # ? Determine if a party member can be selected
  795. #--------------------------------------------------------------------------
  796. alias_method(:krx_grathnode_wms_cie?, :current_item_enabled?)
  797. def current_item_enabled?
  798. if @handler[:ok].name == :on_install_ok
  799. return !$game_party.members[index].barring_grathnode
  800. end
  801. return krx_grathnode_wms_cie?
  802. end
  803. end
  804.  
  805. end ## End of Yanfly's Menu inclusion
  806.  
  807. ## Compatibility with Yanfly's TP Manager. Deprecated with the use of Ace Skill
  808. ## Menu
  809. =begin
  810. if $imported["YEA-TPManager"]
  811.  
  812. #==============================================================================
  813. # ¦ Window_SkillCommand
  814. #==============================================================================
  815.  
  816. class Window_SkillCommand < Window_Command
  817. #--------------------------------------------------------------------------
  818. # ? Aliases YF's new method
  819. #--------------------------------------------------------------------------
  820. alias_method(:krx_grathnode_wsc_tp, :add_tp_modes)
  821. def add_tp_modes
  822. return if SceneManager.scene.is_a?(Scene_Grathnode)
  823. krx_grathnode_wsc_tp
  824. end
  825. end
  826.  
  827. #==========================================================================
  828. # ¦ Scene_Grathnode
  829. #==========================================================================
  830.  
  831. class Scene_Grathnode < Scene_Skill
  832. #--------------------------------------------------------------------------
  833. # ? Creates the command window
  834. #--------------------------------------------------------------------------
  835. def create_command_window
  836. wy = @help_window.height
  837. @command_window = Window_SkillCommand.new(0, wy)
  838. @command_window.viewport = @viewport
  839. @command_window.help_window = @help_window
  840. @command_window.actor = @actor
  841. @command_window.set_handler(:skill, method(:command_skill))
  842. @command_window.set_handler(:cancel, method(:return_scene))
  843. @command_window.set_handler(:pagedown, method(:next_actor))
  844. @command_window.set_handler(:pageup, method(:prev_actor))
  845. end
  846. end
  847.  
  848.  
  849. end ## End of TP Manager compatibility
  850. =end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement