Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2011
1,211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.01 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Overkill
  4. # Last Date Updated: 2010.05.29
  5. # Level: Normal
  6. #
  7. # Overkill an enemy to have the enemy give more EXP or drop unique items. To
  8. # perform an overkill, an actor must attack an enemy and kill it along with
  9. # dealing over a required amount of damage.
  10. #===============================================================================
  11. # Instructions
  12. # -----------------------------------------------------------------------------
  13. # To install this script, open up your script editor and copy/paste this script
  14. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  15. #
  16. # <overkill require: x>
  17. # x is the amount of damage needed to be dealt to the enemy to enable the
  18. # overkill status for the enemy. Goes into the enemy notebox.
  19. #
  20. # <overkill exp: +x>
  21. # This is how much extra exp is awarded to the party if the enemy is overkilled.
  22. # Goes into the enemy notebox.
  23. #
  24. # <overkill gold: x>
  25. # This is how much extra gold is awarded if the enemy is overkilled. Goes into
  26. # the enemy notebox.
  27. #
  28. # <overkill item: x>
  29. # <overkill weapon: x>
  30. # <overkill armor: x>
  31. # If the enemy is overkilled, the enemy will drop this extra item, weapon, or
  32. # armor. Use more of the tag if you want the overkilled enemy to drop more than
  33. # just one item. Drop 100% the time if overkilled. Goes into the enemy notebox.
  34. #===============================================================================
  35.  
  36. $imported = {} if $imported == nil
  37. $imported["Overkill"] = true
  38.  
  39. module SSS
  40.   # This message appears if the enemy is overkilled.
  41.   OVERKILL_MESSAGE = "%s is overkilled!"
  42.   # If using Battle Engine Melody, this popup will appear.
  43.   OVERKILL_POPUP = "OVERKILL!"
  44.   # This is the sound that will play when the collapsed enemy is overkilled.
  45.   OVERKILL_SOUND = RPG::SE.new("Thunder7", 100, 150)
  46. end
  47.  
  48. #==============================================================================
  49. # ** RPG::Enemy
  50. #==============================================================================
  51.  
  52. class RPG::Enemy
  53.   #--------------------------------------------------------------------------
  54.   # overkill_requirement
  55.   #--------------------------------------------------------------------------
  56.   def overkill_requirement
  57.     return @overkill_requirement if @overkill_requirement != nil
  58.     @overkill_requirement = @maxhp * 3 / 2
  59.     self.note.split(/[\r\n]+/).each { |line|
  60.       case line
  61.       when /<(?:OVERKILL_REQUIRE|overkill_require):[ ](\d+)>/i
  62.         @overkill_requirement = $1.to_i
  63.       end
  64.     }
  65.     return @overkill_requirement
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # overkill_exp
  69.   #--------------------------------------------------------------------------
  70.   def overkill_exp
  71.     return @overkill_exp if @overkill_exp != nil
  72.     @overkill_exp = @exp / 2
  73.     self.note.split(/[\r\n]+/).each { |line|
  74.       case line
  75.       when /<(?:OVERKILL_EXP|overkill exp):[ ]([\+\-]\d+)>/i
  76.         @overkill_exp = $1.to_i
  77.       end
  78.     }
  79.     return @overkill_exp
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # overkill_gold
  83.   #--------------------------------------------------------------------------
  84.   def overkill_gold
  85.     return @overkill_gold if @overkill_gold != nil
  86.     @overkill_gold = @exp / 2
  87.     self.note.split(/[\r\n]+/).each { |line|
  88.       case line
  89.       when /<(?:OVERKILL_GOLD|overkill gold):[ ]([\+\-]\d+)>/i
  90.         @overkill_gold = $1.to_i
  91.       end
  92.     }
  93.     return @overkill_gold
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # overkill_items
  97.   #--------------------------------------------------------------------------
  98.   def overkill_items
  99.     return @overkill_items.compact if @overkill_items != nil
  100.     @overkill_items = []
  101.     self.note.split(/[\r\n]+/).each { |line|
  102.       case line
  103.       when /<(?:OVERKILL_ITEM|overkill item):[ ](\d+)>/i
  104.         @overkill_items.push($data_items[$1.to_i])
  105.       when /<(?:OVERKILL_WEAPON|overkill weapon):[ ](\d+)>/i
  106.         @overkill_items.push($data_weapons[$1.to_i])
  107.       when /<(?:OVERKILL_ARMOR|overkill armor):[ ](\d+)>/i
  108.         @overkill_items.push($data_armors[$1.to_i])
  109.       end
  110.     }
  111.     return @overkill_items.compact
  112.   end
  113. end
  114.  
  115. #==============================================================================
  116. # ** Game_Enemy
  117. #==============================================================================
  118.  
  119. class Game_Enemy < Game_Battler
  120.   #--------------------------------------------------------------------------
  121.   # * Public Instance Variables
  122.   #--------------------------------------------------------------------------
  123.   attr_accessor :overkill
  124.   #--------------------------------------------------------------------------
  125.   # * Activate Overkill
  126.   #--------------------------------------------------------------------------
  127.   def activate_overkill
  128.     return unless @hp_damage >= enemy.overkill_requirement
  129.     return unless @hp_damage >= @hp
  130.     return unless @hp == 0
  131.     return if @overkill
  132.     @overkill = true
  133.     if $scene.is_a?(Scene_Battle) and $imported["BattleEngineMelody"]
  134.       popup_text = SSS::OVERKILL_POPUP
  135.       create_popup(popup_text, "WEAK_ELE")
  136.     elsif $scene.is_a?(Scene_Battle) and not $scene.message_window.nil?
  137.       text = sprintf(SSS::OVERKILL_MESSAGE, name)
  138.       $scene.message_window.add_instant_text(text)
  139.     end
  140.     SSS::OVERKILL_SOUND.play
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # * Get Experience
  144.   #--------------------------------------------------------------------------
  145.   alias exp_sss_overkill exp unless $@
  146.   def exp
  147.     n = exp_sss_overkill
  148.     n += enemy.overkill_exp if @overkill
  149.     return n
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * Get Gold
  153.   #--------------------------------------------------------------------------
  154.   alias gold_sss_overkill gold unless $@
  155.   def gold
  156.     n = gold_sss_overkill
  157.     n += enemy.overkill_gold if @overkill
  158.     return n
  159.   end
  160. end
  161.  
  162. #==============================================================================
  163. # ** Game_Battler
  164. #==============================================================================
  165.  
  166. class Game_Battler
  167.   #--------------------------------------------------------------------------
  168.   # * Damage Reflection
  169.   #--------------------------------------------------------------------------
  170.   alias execute_damage_sss_overkill execute_damage unless $@
  171.   def execute_damage(user)
  172.     execute_damage_sss_overkill(user)
  173.     return unless user.actor? and self.is_a?(Game_Enemy)
  174.     activate_overkill
  175.   end
  176. end
  177.  
  178. #==============================================================================
  179. # ** Game_Troop
  180. #==============================================================================
  181.  
  182. class Game_Troop < Game_Unit
  183.   #--------------------------------------------------------------------------
  184.   # * Create Array of Dropped Items
  185.   #--------------------------------------------------------------------------
  186.   alias make_drop_items_sss_overkill make_drop_items unless $@
  187.   def make_drop_items
  188.     n = make_drop_items_sss_overkill
  189.     for member in dead_members
  190.       next unless member.overkill
  191.       n += member.enemy.overkill_items
  192.     end
  193.     return n
  194.   end
  195. end
  196.  
  197. #==============================================================================
  198. # ** Scene_Battle
  199. #==============================================================================
  200.  
  201. class Scene_Battle < Scene_Base
  202.   #--------------------------------------------------------------------------
  203.   # * Public Instance Variables
  204.   #--------------------------------------------------------------------------
  205.   attr_accessor :message_window
  206. end
  207.  
  208. #===============================================================================
  209. #
  210. # END OF FILE
  211. #
  212. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement