modern_algebra

SSS Enemy Linked Deaths

Apr 25th, 2011
869
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #================================================= ==============================
  2. #
  3. # Shanghai Simple Script - Enemy Linked Deaths
  4. # Last Date Updated: 2010.06.12
  5. # Level: Normal
  6. #
  7. # Sometimes you have a hand or foot or some other random body part as a part of
  8. # a larger monster. However, should that larger monster die, the other body
  9. # parts will remain until they're killed off, too. This script allows you to
  10. # link an enemy's death with another's.
  11. #================================================= ==============================
  12. # Instructions
  13. # -----------------------------------------------------------------------------
  14. # To install this script, open up your script editor and copy/paste this script
  15. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  16. #
  17. # <linked death: x>
  18. # <linked death: x, x, x>
  19. # Place this in an enemy's notebox. When this enemy dies, all enemies in the
  20. # party with the x ID links are killed along with the central enemy.
  21. #
  22. # <linked death all>
  23. # Place this in an enemy's notebox. When this enemy dies, all enemies in the
  24. # party are dead, linked or not.
  25. #================================================= ==============================
  26.  
  27. $imported = {} if $imported == nil
  28. $imported["EnemyLinkedDeaths"] = true
  29.  
  30. #================================================= =============================
  31. # RPG::Enemy
  32. #================================================= =============================
  33.  
  34. class RPG::Enemy
  35.   #--------------------------------------------------------------------------
  36.   # linked_death
  37.   #--------------------------------------------------------------------------
  38.   def linked_death
  39.     return @linked_death if @linked_death != nil
  40.     @linked_death = []
  41.     self.note.split(/[\r\n]+/).each { |line|
  42.       case line
  43.       when /<(?:LINKED DEATH|link death):[ ](\d+(?:\s*,\s*\d+)*)>/i
  44.         $1.scan(/\d+/).each { |num|
  45.         @linked_death.push(num.to_i) if num.to_i > 0 }
  46.       end
  47.     }
  48.     return @linked_death
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # linked_death_all
  52.   #--------------------------------------------------------------------------
  53.   def linked_death_all
  54.     return @linked_death_all if @linked_death_all != nil
  55.     @linked_death_all = false
  56.     self.note.split(/[\r\n]+/).each { |line|
  57.       case line
  58.       when /<(?:LINKED DEATH ALL|link death everything)>/i
  59.         @linked_death_all = true
  60.       end
  61.     }
  62.     return @linked_death_all
  63.   end
  64. end
  65.  
  66. #================================================= =============================
  67. # ** Game_Enemy
  68. #================================================= =============================
  69.  
  70. class Game_Enemy < Game_Battler
  71.   #--------------------------------------------------------------------------
  72.   # * Perform Collapse
  73.   #--------------------------------------------------------------------------
  74.   alias perform_collapse_sss_enemy_linked_deaths perform_collapse unless $@
  75.   def perform_collapse
  76.     perform_collapse_sss_enemy_linked_deaths
  77.     perform_linked_deaths if $game_temp.in_battle and dead?
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # * Perform Linked Deaths
  81.   #--------------------------------------------------------------------------
  82.   def perform_linked_deaths
  83.     unless enemy.linked_death.empty?
  84.       for member in $game_troop.existing_members
  85.         next unless enemy.linked_death.include?(member.enemy_id)
  86.         member.add_state(1)
  87.         member.perform_collapse
  88.       end
  89.     end
  90.     if enemy.linked_death_all
  91.       for member in $game_troop.existing_members
  92.         member.add_state(1)
  93.         member.perform_collapse
  94.       end
  95.     end
  96.   end
  97. end
  98.  
  99. #================================================= ==============================
  100. #
  101. # END OF FILE
  102. #
  103. #================================================= ==============================
RAW Paste Data