Advertisement
Kyriaki

Shanghai Simple Script - Death Common Events

Apr 27th, 2011
1,107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.74 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Death Common Events
  4. # Last Date Updated: 2010.06.16
  5. # Level: Normal
  6. #
  7. # This script causes certain actors and enemies to trigger common events when
  8. # they die in battle. Although this could be evented, there's a lot of messy
  9. # condition work involved with battle event pages, which is why I created this
  10. # script.
  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. # <death event: x>
  18. # This is for enemies. Makes common event x run when the enemy dies.
  19. #===============================================================================
  20.  
  21. $imported = {} if $imported == nil
  22. $imported["DeathCommonEvents"] = true
  23.  
  24. module SSS
  25.   # This has sets the common events that run when specific actors die. If it
  26.   # isn't present, then no common event will run.
  27.   ACTOR_DEATH_EVENTS ={
  28.   # Actor => Common Event ID
  29.         1 => 15,
  30.         2 => 16,
  31.         3 => 17,
  32.         4 => 18,
  33.   } # Remove this and perish.
  34.  
  35.   # This has sets the common events that run when specific classes die. If it
  36.   # isn't present, then no common event will run.
  37.   CLASS_DEATH_EVENTS ={
  38.   # Class => Common Event ID
  39.         1 => 19,
  40.         2 => 20,
  41.         3 => 21,
  42.         4 => 22,
  43.   } # Remove this and perish.
  44. end
  45.  
  46. #==============================================================================
  47. # RPG::Enemy
  48. #==============================================================================
  49.  
  50. class RPG::Enemy
  51.   #--------------------------------------------------------------------------
  52.   # * Death Event
  53.   #--------------------------------------------------------------------------
  54.   def death_event
  55.     return @death_event if @death_event != nil
  56.     @death_event = 0
  57.     self.note.split(/[\r\n]+/).each { |line|
  58.       case line
  59.       when /<(?:DEATH_EVENT|death event):[ ](\d+)>/i
  60.         @death_event = $1.to_i
  61.       end
  62.     }
  63.     return @death_event
  64.   end
  65. end
  66.  
  67. #==============================================================================
  68. # ** Game_Actor
  69. #==============================================================================
  70.  
  71. class Game_Actor < Game_Battler
  72.   #--------------------------------------------------------------------------
  73.   # * Perform Collapse
  74.   #--------------------------------------------------------------------------
  75.   alias perform_collapse_actor_sss_death_events perform_collapse unless $@
  76.   def perform_collapse
  77.     perform_collapse_actor_sss_death_events
  78.     if $game_temp.in_battle and dead?
  79.       if SSS::ACTOR_DEATH_EVENTS.include?(@actor_id)
  80.         $death_events.push(SSS::ACTOR_DEATH_EVENTS[@actor_id])
  81.       elsif SSS::CLASS_DEATH_EVENTS.include?(@class_id)
  82.         $death_events.push(SSS::CLASS_DEATH_EVENTS[@class_id])
  83.       end
  84.     end
  85.   end
  86. end
  87.  
  88. #==============================================================================
  89. # ** Game_Enemy
  90. #==============================================================================
  91.  
  92. class Game_Enemy < Game_Battler
  93.   #--------------------------------------------------------------------------
  94.   # * Perform Collapse
  95.   #--------------------------------------------------------------------------
  96.   alias perform_collapse_enemy_sss_death_events perform_collapse unless $@
  97.   def perform_collapse
  98.     perform_collapse_enemy_sss_death_events
  99.     if $game_temp.in_battle and dead?
  100.       $death_events.push(enemy.death_event) if enemy.death_event > 0
  101.     end
  102.   end
  103. end
  104.  
  105. #==============================================================================
  106. # ** Scene_Title
  107. #==============================================================================
  108.  
  109. class Scene_Title < Scene_Base
  110.   #--------------------------------------------------------------------------
  111.   # * Main Processing
  112.   #--------------------------------------------------------------------------
  113.   alias main_sss_death_events main unless $@
  114.   def main
  115.     $death_events = []
  116.     main_sss_death_events
  117.   end
  118. end
  119.  
  120. #==============================================================================
  121. # ** Scene_Battle
  122. #==============================================================================
  123.  
  124. class Scene_Battle < Scene_Base
  125.   #--------------------------------------------------------------------------
  126.   # * Execute Battle Actions
  127.   #--------------------------------------------------------------------------
  128.   alias execute_action_sss_death_events execute_action unless $@
  129.   def execute_action
  130.     execute_action_sss_death_events
  131.     run_death_common_events
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Run Death Common Events
  135.   #--------------------------------------------------------------------------
  136.   def run_death_common_events
  137.     for common_event_id in $death_events
  138.       next if $data_common_events[common_event_id].nil?
  139.       $game_temp.common_event_id = common_event_id
  140.       process_battle_event
  141.     end
  142.     $death_events = []
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # * End Battle
  146.   #--------------------------------------------------------------------------
  147.   alias battle_end_sss_death_events battle_end unless $@
  148.   def battle_end(result)
  149.     $death_events = []
  150.     battle_end_sss_death_events(result)
  151.   end
  152. end
  153.  
  154. #===============================================================================
  155. #
  156. # END OF FILE
  157. #
  158. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement