Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2011
1,241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.97 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Vampiric Weapons
  4. # Last Date Updated: 2010.06.21
  5. # Level: Normal
  6. #
  7. # This script gives some weapons the vampiric trait. Vampiric weapons will
  8. # absorb HP damage rather than deal it straight out. Siphonic weapons are also
  9. # available and they drain MP instead of HP. Vampiric and siphonic weapons
  10. # cannot drain more than the enemy has HP or MP. This attribute will also affect
  11. # physical attack skills or items unless they already have absorbing.
  12. #===============================================================================
  13. # Instructions
  14. # -----------------------------------------------------------------------------
  15. # To install this script, open up your script editor and copy/paste this script
  16. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  17. #
  18. # <vampiric: x%>
  19. # Place this tag into a weapon's notebox and it will become a vampiric weapon.
  20. # This tag will drain x% of the hp damage. Place this inside of an enemy's
  21. # notebox and it will also gain vampiric properties.
  22. #
  23. # <siphonic: x>
  24. # Place this tag into a weapon's notebox and it will deal mp damage with attacks
  25. # which the attacker will recover. Place this inside of an enemy's notebox and
  26. # it will also gain siphonic properties.
  27. #===============================================================================
  28.  
  29. $imported = {} if $imported == nil
  30. $imported["VampiricWeapons"] = true
  31.  
  32. #==============================================================================
  33. # RPG::Weapon
  34. #==============================================================================
  35.  
  36. class RPG::Weapon < RPG::BaseItem
  37.   #--------------------------------------------------------------------------
  38.   # * Vampiric
  39.   #--------------------------------------------------------------------------
  40.   def vampiric
  41.     return @vampiric if @vampiric != nil
  42.     @vampiric = 0
  43.     self.note.split(/[\r\n]+/).each { |line|
  44.       case line
  45.       when /<(?:VAMPIRIC|vampire):[ ]*(\d+)([%])>/i
  46.         @vampiric = $1.to_i
  47.       end
  48.     }
  49.     return @vampiric
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # * Siphonic
  53.   #--------------------------------------------------------------------------
  54.   def siphonic
  55.     return @siphonic if @siphonic != nil
  56.     @siphonic = 0
  57.     self.note.split(/[\r\n]+/).each { |line|
  58.       case line
  59.       when /<(?:SIPHONIC|siphon):[ ]*(\d+)>/i
  60.         @siphonic = $1.to_i
  61.       end
  62.     }
  63.     return @siphonic
  64.   end
  65. end
  66.  
  67. #==============================================================================
  68. # RPG::Enemy
  69. #==============================================================================
  70.  
  71. class RPG::Enemy
  72.   #--------------------------------------------------------------------------
  73.   # * Vampiric
  74.   #--------------------------------------------------------------------------
  75.   def vampiric
  76.     return @vampiric if @vampiric != nil
  77.     @vampiric = 0
  78.     self.note.split(/[\r\n]+/).each { |line|
  79.       case line
  80.       when /<(?:VAMPIRIC|vampire):[ ]*(\d+)([%])>/i
  81.         @vampiric = $1.to_i
  82.       end
  83.     }
  84.     return @vampiric
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # * Siphonic
  88.   #--------------------------------------------------------------------------
  89.   def siphonic
  90.     return @siphonic if @siphonic != nil
  91.     @siphonic = 0
  92.     self.note.split(/[\r\n]+/).each { |line|
  93.       case line
  94.       when /<(?:SIPHONIC|siphon):[ ]*(\d+)>/i
  95.         @siphonic = $1.to_i
  96.       end
  97.     }
  98.     return @siphonic
  99.   end
  100. end
  101.  
  102. #==============================================================================
  103. # ** Game_Battler
  104. #==============================================================================
  105.  
  106. class Game_Battler
  107.   #--------------------------------------------------------------------------
  108.   # * Clear Variable for Storing Action Results
  109.   #--------------------------------------------------------------------------
  110.   alias clear_action_results_sss_vampire_weapons clear_action_results unless $@
  111.   def clear_action_results
  112.     clear_action_results_sss_vampire_weapons
  113.     @vampiric = 0
  114.     @siphonic = 0
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * Calculation of Damage From Normal Attack
  118.   #--------------------------------------------------------------------------
  119.   alias make_attack_damage_value_sss_vampire_weapons make_attack_damage_value
  120.   def make_attack_damage_value(attacker)
  121.     make_attack_damage_value_sss_vampire_weapons(attacker)
  122.     @vampiric = [@hp_damage * attacker.vampiric_rate / 100, self.hp].min
  123.     @mp_damage += attacker.siphonic_rate
  124.     @siphonic = [@mp_damage, self.mp, attacker.siphonic_rate].min
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # * Calculation of Damage Caused by Skills or Items
  128.   #--------------------------------------------------------------------------
  129.   alias make_obj_damage_value_sss_vampire_weapons make_obj_damage_value
  130.   def make_obj_damage_value(user, obj)
  131.     make_obj_damage_value_sss_vampire_weapons(user, obj)
  132.     return if @absorbed
  133.     return unless obj.physical_attack
  134.     @vampiric = [@hp_damage * user.vampiric_rate / 100, self.hp].min
  135.     @mp_damage += user.siphonic_rate
  136.     @siphonic = [@mp_damage, self.mp, user.siphonic_rate].min
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # * Damage Reflection
  140.   #--------------------------------------------------------------------------
  141.   alias execute_damage_sss_vampire_weapons execute_damage unless $@
  142.   def execute_damage(user)
  143.     execute_damage_sss_vampire_weapons(user)
  144.     user.hp += @vampiric if @vampiric > 0
  145.     user.mp += @siphonic if @siphonic > 0
  146.     if $imported["BattleEngineMelody"] and @vampiric > 0
  147.       value = sprintf(YEM::BATTLE_ENGINE::POPUP_SETTINGS[:hp_heal], @vampiric)
  148.       rules = "HP_HEAL"
  149.       user.create_popup(value, rules)
  150.     end
  151.     if $imported["BattleEngineMelody"] and @siphonic > 0
  152.       value = sprintf(YEM::BATTLE_ENGINE::POPUP_SETTINGS[:mp_heal], @siphonic)
  153.       rules = "MP_HEAL"
  154.       user.create_popup(value, rules)
  155.     end
  156.   end
  157. end
  158.  
  159. #==============================================================================
  160. # ** Game_Actor
  161. #==============================================================================
  162.  
  163. class Game_Actor < Game_Battler
  164.   #--------------------------------------------------------------------------
  165.   # * Vampiric Rate
  166.   #--------------------------------------------------------------------------
  167.   def vampiric_rate
  168.     result = 0
  169.     for weapon in weapons.compact
  170.       result += weapon.vampiric
  171.     end
  172.     return [result, 0].max
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Siphonic Rate
  176.   #--------------------------------------------------------------------------
  177.   def siphonic_rate
  178.     result = 0
  179.     for weapon in weapons.compact
  180.       result += weapon.siphonic
  181.     end
  182.     return [result, 0].max
  183.   end
  184. end
  185.  
  186. #==============================================================================
  187. # ** Game_Enemy
  188. #==============================================================================
  189.  
  190. class Game_Enemy < Game_Battler
  191.   #--------------------------------------------------------------------------
  192.   # * Vampiric Rate
  193.   #--------------------------------------------------------------------------
  194.   def vampiric_rate
  195.     return [enemy.vampiric, 0].max
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # * Siphonic Rate
  199.   #--------------------------------------------------------------------------
  200.   def siphonic_rate
  201.     return [enemy.siphonic, 0].max
  202.   end
  203. end
  204.  
  205. #===============================================================================
  206. #
  207. # END OF FILE
  208. #
  209. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement