adiktuzmiko

Partition Damage v1.10

Jun 28th, 2013
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.77 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # Partition Damage v1.10
  4. # by AdiktuzMiko
  5. # --- Date Created: 06/28/2013
  6. # --- Last Date Updated: 01/21/2014
  7. # --- Level: Easy
  8. # --- Requires:
  9. #     Elements EX
  10. # --- Optional:
  11. #     YEA Battle Engine + Element Popups
  12. #
  13. # Basically it allows you to have a percentage of your damage
  14. # dealt as bonus damage having a different element.
  15. #
  16. # Example: I have a weapon that has a 10% partition damage property
  17. #          of fire element. If I attack an enemy and deal 100 damage
  18. #          then I will deal another 10 damage with the fire element
  19. #
  20. # Note: Partition damage does not affect slip damages
  21. #
  22. #==============================================================================
  23. #   ++ Notetags ++
  24. #==============================================================================
  25. #
  26. # These tags goes into Actors, Classes, Items, Skills, Weapons, Armors, Enemies
  27. # and States
  28. #
  29. # <selfatkpart x:y>
  30. # -> For skills and items
  31. # -> Damage partition that only affects the skill/item that has this tag
  32. #
  33. # <atkpart x:y>
  34. # -> Damage partition that affects all damage done
  35. #
  36. # x => Element ID of the element that you want the partition to have
  37. # y => Percent of damage to deal as partition
  38. #
  39. #==============================================================================
  40. #   ++ Installation ++
  41. #==============================================================================
  42. # Install this script in the Materials section in your project's
  43. # script editor.
  44. #
  45. #==============================================================================
  46. #   ++ Compatibility ++
  47. #==============================================================================
  48. # This script aliases the following default VXA methods:
  49. #
  50. #     Game_Battler#adik_damage_extension
  51. #    
  52. # There are no default method overwrites.
  53. #
  54. # Place this under ElementsEX.
  55. #
  56. #==============================================================================
  57. #   ++ Terms and Conditions ++
  58. #==============================================================================
  59. #
  60. # Read this: http://lescripts.wordpress.com/terms-and-conditions/
  61. #
  62. #==============================================================================
  63.  
  64. $imported = {} if $imported.nil?
  65. $imported["CriticalEX"] = true
  66.  
  67. module Adiktuz
  68.   module PartitionDamage
  69.    
  70.     #Determines if partition damage will affect negative damages
  71.     #which are normally, heals
  72.     CAN_PARTITION_NEGATIVE = false
  73.    
  74.   #DO NOT EDIT BEYOND THIS POINT UNLESS YOU ARE SURE OF WHAT YOU ARE DOING!  
  75.     ATK_PART = /<atkpart (.*):(.*)>/i
  76.     SELF_ATK_PART = /<selfatkpart (.*):(.*)>/i
  77.   end #PartitionDamage
  78. end #Adiktuz
  79.  
  80.  
  81. #===============================================================================
  82. module DataManager
  83. #===============================================================================
  84.  
  85.   #---------------------------------------------------------------------------
  86.   # alias: load_database
  87.   #---------------------------------------------------------------------------
  88.   class << self; alias :load_unique_partition_adik :load_database; end
  89.   def self.load_database
  90.     load_unique_partition_adik
  91.     load_unique_partition
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # new method: load_elemental_control
  95.   #--------------------------------------------------------------------------
  96.   def self.load_unique_partition
  97.     classes = [$data_weapons, $data_armors, $data_skills , $data_items,
  98.                $data_actors , $data_classes, $data_enemies, $data_states ]
  99.     for classe in classes
  100.       for obj in classe
  101.         next if obj.nil?
  102.         obj.load_partition_adik
  103.       end
  104.     end
  105.   end
  106.  
  107. end # DataManager
  108.  
  109. #===============================================================================
  110. class RPG::BaseItem
  111. #===============================================================================
  112.  
  113.   #---------------------------------------------------------------------------
  114.   # public instance Variables
  115.   #---------------------------------------------------------------------------
  116.   attr_accessor :atk_partition
  117.   attr_accessor :self_atk_partition
  118.  
  119.   #--------------------------------------------------------------------------
  120.   # new method: load_partition_adik
  121.   #--------------------------------------------------------------------------
  122.   def load_partition_adik
  123.     @atk_partition     = [0] * $data_system.elements.size
  124.     @self_atk_partition  = [0] * $data_system.elements.size
  125.     set_atk_partition
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # common cache : set_atk_partition
  129.   #--------------------------------------------------------------------------
  130.   def set_atk_partition
  131.     self.note.split(/[\r\n]+/).each do |line|
  132.       case line
  133.       when Adiktuz::PartitionDamage::ATK_PART
  134.         @atk_partition[$1.to_i] = $2.to_f
  135.       when Adiktuz::PartitionDamage::SELF_ATK_PART
  136.         @self_atk_partition[$1.to_i] = $2.to_f
  137.       end
  138.     end
  139.   end
  140.  
  141. end # << RPG::BaseItem
  142.  
  143. class Game_BattlerBase
  144.  
  145.   #--------------------------------------------------------------------------
  146.   # ? new method: make_parition_popup
  147.   #--------------------------------------------------------------------------
  148.   def make_partition_popup(value,rate,element)
  149.     flags = []
  150.     return if value == 0
  151.     if rate > 1.0
  152.       text = YEA::BATTLE::POPUP_SETTINGS[:weakpoint]
  153.       rules = "WEAK_ELE"
  154.       flags.push("weakness")
  155.     elsif rate == 0.0
  156.       text = YEA::BATTLE::POPUP_SETTINGS[:immune]
  157.       rules = "IMMU_ELE"
  158.       flags.push("immune")
  159.     elsif rate < 0.0
  160.       text = YEA::BATTLE::POPUP_SETTINGS[:absorbed]
  161.       rules = "ABSB_ELE"
  162.       flags.push("absorbed")
  163.     else
  164.       text = YEA::BATTLE::POPUP_SETTINGS[:resistant]
  165.       rules = "REST_ELE"
  166.       flags.push("resistant")
  167.     end
  168.     create_popup(text, rules, flags) unless rate == 1.0
  169.     value = value*-1
  170.     value = value.to_s + " HP"
  171.     value = value.to_i
  172.     element > 0 ? create_popup(value, "ELEMENT_" + element.to_s) : create_popup(value, "HP_DMG")
  173.   end
  174.  
  175. end #Game_BattlerBase
  176.  
  177. class Game_Battler < Game_BattlerBase
  178.  
  179.   #--------------------------------------------------------------------------
  180.   # aliased method: adik_damage_extension
  181.   #--------------------------------------------------------------------------
  182.   alias bdex_adik_damage_extension adik_damage_extension
  183.   def adik_damage_extension(user,item,damage)
  184.     elements = Adiktuz::ElementEX::ELEMENTS.clone
  185.     elements.each do |id|
  186.       next if !Adiktuz::PartitionDamage::CAN_PARTITION_NEGATIVE and damage < 0
  187.       part_damage = damage*item.self_atk_partition[id]
  188.       if user.actor?
  189.         part_damage += damage*user.actor.atk_partition[id]
  190.         part_damage += damage*user.class.atk_partition[id]
  191.         for equip in user.equips
  192.           next if equip.nil?
  193.           part_damage += damage*equip.atk_partition[id]
  194.         end
  195.         for state in user.states
  196.           next if state.nil?
  197.           part_damage += damage*state.atk_partition[id]
  198.         end
  199.       elsif user.enemy? then
  200.         part_damage += damage*user.enemy.atk_partition[id]
  201.         for state in user.states
  202.           next if state.nil?
  203.           part_damage += damage*state.atk_partition[id]
  204.         end
  205.       end
  206.       next if part_damage == 0
  207.       rate = 1.0
  208.       rate += get_atk_element_multi(user,id) - get_def_element_multi(id)
  209.       part_damage *= rate
  210.       part_damage += get_atk_element_bonus(user,id) - get_def_element_bonus(id)
  211.       self.hp -= part_damage
  212.       make_partition_popup(part_damage,rate,id) if $imported["YEA-BattleEngine"]
  213.     end
  214.     bdex_adik_damage_extension(user,item,damage)
  215.   end
  216.  
  217. end #Game_Battler
Advertisement
Add Comment
Please, Sign In to add comment