TheoAllen

Craze's Elemental merger + Additional skill elements

Mar 15th, 2013
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.66 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Craze's Script Asylum - Elemental Merger v1.01 + Additional skill elements
  4. # -- Last Updated: 2013.03.16
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. # Edited by : TheoAllen
  8. #
  9. #==============================================================================
  10.  
  11. $imported = {} if $imported.nil?
  12. $imported["CRZ-ElementalMerger"] = true
  13.  
  14. #==============================================================================
  15. # ▼ Updates
  16. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. # 2013.03.16 - Additional skill element
  18. # 2012.01.06 - Minor update for compatability with any absorption script
  19. # 2012.01.05 - Finished Script
  20. # 2012.01.04 - Started Script
  21. #
  22. #==============================================================================
  23. # ▼ Introduction
  24. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  25. # The RM* series has always had a particularly awful method of determining
  26. # damage done when multiple elements are applied - all it does is take the best
  27. # rate and apply it, even if the other elements are nullified!
  28. #
  29. # With this script, elemental damage will be merged proportionally, so that
  30. # using a Soldier's hypothetical attack skills will also use that Soldier's
  31. # inherent elements (from, say, his Fire Spear or an Infuse Ice status effect)
  32. # and apply them ALL against a foe. If a foe is weak to both Piercing and Fire,
  33. # they'll take even more damage than by default - but they'll take blended damage
  34. # if they take double Piercing and half Fire damage.
  35. #
  36. # If you don't get it, know this: just plugging this script in will make
  37. # your elemental equipment much more useful.
  38. #
  39. #==============================================================================
  40. # ▼ Instructions
  41. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  42. # To install this script, open up your script editor and copy/paste this script
  43. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  44. #
  45. # Edit the settings in the module below as you see fit.
  46. #
  47. # For those who wish to add more skill elements, just type this in skill note
  48. # <elements id: x> or
  49. # <elements id: x, x>
  50. #==============================================================================
  51. # ▼ Compatibility
  52. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  53. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  54. # it will run with RPG Maker VX without adjusting.
  55. #
  56. # This script works with YEA Battle Engine Add-On: Elemental Popups without
  57. # any adjustment on either end. The most damaging element's color will be used.
  58. # There are also no issues with YEA Element Absorb.
  59. #
  60. # Overwritten methods:
  61. #   Game_Battler
  62. #      item_element_rate
  63. #
  64. #==============================================================================
  65.  
  66. module CRZ
  67.   module ELE_MERGE
  68.    
  69.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  70.     # - Weapon Element Settings -
  71.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  72.     # Use these settings to dictate how the elements made inherent by actors,
  73.     # classes, weapons, equipment, states blends with your skills. Anything
  74.     # set to "true" below will add any inherent elements to that type of
  75.     # action (determined by "Hit Type" according to Esrever's translation)
  76.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  77.     # Any action tagged as "Physical" will include user's attack elements
  78.     PHYS_ATK_ELEMENTS = true
  79.     # Any action tagged as "Magical" will include user's attack elements
  80.     MAGIC_ATK_ELEMENTS = false
  81.     # Any action tagged as "Guaranteed Hit" will include user's attack elements.
  82.     # This is normally used for buffs and healing, but can be used for any
  83.     # skill you want to completely penetrate all defenses.
  84.     CERT_ATK_ELEMENTS = false
  85.    
  86.     # For some games, you might have elemental healing, or attack elements
  87.     # might be inherited simply due to CERT_ATK_ELEMENTS being true.
  88.     # If you do not want any healing ability to inherit elements, set to true.
  89.     IGNORE_RECOVERY = true
  90.    
  91.    
  92.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  93.     # - Elemental Merging [Hard Mode] -
  94.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  95.     # Pick the type of elemental merging or blending you wish for your game
  96.     # to use. This will take all potential elements and, instead of using the
  97.     # default mechanic of picking only the best rate, will merge the rates.
  98.     # Ignore this section if you want this happen, but don't dare touch
  99.     # the math.
  100.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  101.     # 0: Default RMAce. Will find the best rate out of all potential elements
  102.     # 1: Addititive. If results are 100%, 150%, and 80%, the total will be 130%
  103.     #      Ex.  100 + (100 - 100) + (150 - 100) + (80 - 100) = 130%
  104.     #      Ex.  100 + (0 - 100) + (150 - 100) = 50%
  105.     # 2: Multiplicative. If results are 100%, 150%, and 80%,
  106.     #      the total will be 120%
  107.     #      Ex.  100 * (100 / 100) * (150 / 100) * (80 / 100) = 120%
  108.     #      Ex.  100 * (0 / 100) * (150 / 100) = 0%
  109.     # 3: Multiplicative Psuedo-Null. If results are 100%, 150%, and 80%,
  110.     #      the total will be 120%. Nulled (fully resisted) elements are
  111.     #      used to divide overall damage done by 10 (RECOMMENDED)
  112.     #      Ex.  100 * (100 / 100) * (150 / 100) * (80 / 100) = 120%
  113.     #      Ex.  100 * ([0 + 10] / 100) * (150 / 100) = 15% (Default)
  114.     MERGE_TYPE = 3
  115.    
  116.     # If you use MERGE_TYPE 3, nulled elements will divide overall damage done
  117.     # by this amount. Default is 10, but examples for other amounts are given
  118.     # below. Note that attacks with a single element, which is nulled, will
  119.     # deal 0 damage.
  120.     #      Ex.  150% / [10] = 15% (Default)
  121.     #      Ex.  150% / [20] = 7.5%
  122.     #      Ex.  150% / [5] = 30%
  123.     #      Ex.  150% / [3] = 50%
  124.     PSUEDO_NULL_AMT = 10
  125.    
  126.     # This applies to all elemental merge types. When the final rate of damage
  127.     # is determined, it is checked against this percentage. If below this
  128.     # constant, the damage becomes 0. A value from 10-20 is recommended.
  129.     #      Ex.  100% *  10% = [10% is <= 10%] = 0% (Default)
  130.     # If you do not wish to use this feature, set this constant to 0.
  131.     AUTO_NULL_PER = 10
  132.    
  133.   end # ELE_MERGE
  134. end # CRZ
  135.  
  136. #==============================================================================
  137. # ▼ Editting anything past this point may potentially result in causing
  138. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  139. # halitosis so edit at your own risk.
  140. #==============================================================================
  141. module THEOLIZED
  142.   module ELEMENTS_TAG
  143.    
  144.     ELEMENT = /<(?:ELEMENTS_ID|elements id):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  145.  
  146.   end
  147. end
  148.  
  149. module DataManager
  150.  
  151.   class <<self;  alias load_database_elements load_database; end
  152.   def self.load_database
  153.     load_database_elements
  154.     load_theolized_el_notetags
  155.   end
  156.  
  157.   def self.load_theolized_el_notetags
  158.     groups = [$data_skills, $data_items]
  159.     for groups in group
  160.       for group in obj
  161.         next if obj.nil?
  162.         obj.load_theolized_el_notetags
  163.       end
  164.     end
  165.   end
  166.  
  167. end
  168.  
  169. class RPG::UsableItem < RPG::BaseItem
  170.   attr_accessor :elements_array
  171.  
  172.   def load_theolized_el_notetags
  173.     @elements_array = []
  174.     self.note.split(/[\r\n]+/).each { |line|
  175.       case line
  176.       when THEOLIZED::ELEMENTS_TAG
  177.         $1.scan(/\d+/).each { |num|
  178.         @element_array.push(num.to_i) if num.to_i > 0 }
  179.       end
  180.     }
  181.   end
  182.  
  183. end
  184. #==============================================================================
  185. # ■ Game_Battler
  186. #==============================================================================
  187.  
  188. class Game_Battler
  189.  
  190.   #--------------------------------------------------------------------------
  191.   # overwrite method: item_element_rate
  192.   #--------------------------------------------------------------------------
  193.   def item_element_rate(user, item)
  194.     return 1.0 if item.damage.recover? and CRZ::ELE_MERGE::IGNORE_RECOVERY
  195.     array = []
  196.     if !user.atk_elements.empty?
  197.       array += user.atk_elements if item.physical? and CRZ::ELE_MERGE::PHYS_ATK_ELEMENTS
  198.       array += user.atk_elements if item.magical? and CRZ::ELE_MERGE::MAGIC_ATK_ELEMENTS
  199.       array += user.atk_elements if item.certain? and CRZ::ELE_MERGE::CERT_ATK_ELEMENTS
  200.     end
  201.      
  202.     if item.damage.element_id >= 0
  203.       array.push(item.damage.element_id)
  204.     end
  205.    
  206.     unless item.elements_array.empty?
  207.       array += item.elements_array
  208.     end
  209.    
  210.     return 1.0 if array.empty?
  211.    
  212.     case CRZ::ELE_MERGE::MERGE_TYPE
  213.     when 1 # Additive
  214.       rate = 1.0
  215.       for i in array
  216.         rate += element_rate(i) - 1.0
  217.       end
  218.     when 2 # Multiplicative
  219.       rate = 1.0
  220.       for i in array
  221.         rate *= element_rate(i)
  222.       end
  223.     when 3 # Multiplicative Psuedo-Null
  224.       rate = 1.0
  225.       for i in array
  226.         rate *= [element_rate(i),(CRZ::ELE_MERGE::PSUEDO_NULL_AMT / 100.0)].max
  227.       end
  228.     else # Default (0)
  229.       rate = elements_max_rate(user.array)
  230.     end
  231.     rate = 0 if rate <= (CRZ::ELE_MERGE::AUTO_NULL_PER / 100.0) and rate > 0
  232.     rate
  233.   end
  234.  
  235. end # Game_Battler
  236.  
  237. #==============================================================================
  238. #
  239. # ▼ End of File
  240. #
  241. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment