Want more features on Pastebin? Sign Up, it's FREE!

Actor Death ME & Common Events ~ RGSS2

By: diamondandplatinum3 on Jul 31st, 2012  |  syntax: Ruby  |  size: 5.54 KB  |  views: 129  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #==============================================================================
  2. #  Actor Death ME & Common Events
  3. #  Version: 1.1
  4. #  Author: DiamondandPlatinum3
  5. #  Date: July 31, 2012      (Original)
  6. #        September 22, 2012 (Updated)
  7. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. #  Description:
  9. #    This script will allow you to play a ME when one of your actors die in
  10. #    battle. It'll also allow you to use a common event when it occurs.
  11. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. #------------------------------------------------------------------------------
  13. #  Instructions:
  14. #  
  15. #     - Place this script in the materials section, above Main.
  16. #
  17. #     - Edit the editable region options
  18. #
  19. #     - Set your common events to do what you want them to do (in the database)
  20. #
  21. #
  22. #
  23. #     - You can change the ME and it's properties via an event with a script call:
  24. #      
  25. #         Change_ActorDeathME(ME, Volume, Pitch, Frames)
  26. #
  27. #       If you do not wish to change a specific value, simply pass in nil as the
  28. #       parameter.
  29. #
  30. #       You can find a visual reference for it
  31. #       Here: http://img4host.net/upload/22035729505d1b0939257.png
  32. #
  33. #==============================================================================
  34. module Actor_Death_ME
  35.   #=========================================================
  36.   #               EDITABLE REGION
  37.   #=========================================================
  38.     Death_ME         = "Shock" # Set to nil if you don't want any ME to play upon death
  39.     ME_Volume        = 100
  40.     ME_Pitch         = 100
  41.     Framewait_Amount = 100 # Set to zero if not using any ME
  42.    
  43.    
  44.     #-------------------------------------------------------
  45.     Common_Event_ID_To_Run = [  0,  # Don't touch this line
  46.     #-------------------------------------------------------
  47.     10,       #Actor1's Common Event to run if incapacitated
  48.     11,       #Actor2's Common Event to run if incapacitated
  49.     12,       #Actor3's Common Event to run if incapacitated
  50.     13,       #Actor4's Common Event to run if incapacitated
  51.     14,       #Actor5's Common Event to run if incapacitated
  52.     15,       #Actor6's Common Event to run if incapacitated
  53.     16,       #Actor7's Common Event to run if incapacitated
  54.     17,       #Actor8's Common Event to run if incapacitated
  55.     18,       #Actor9's Common Event to run if incapacitated
  56.    
  57.   #=========================================================
  58.   ]#            END OF EDITABLE REGION
  59.   #=========================================================
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.   # Setter Functions
  74.   def self.ChangeME( newsound )
  75.     self.const_set(:Death_ME, newsound)
  76.   end
  77.   def self.ChangeVolume( newvolume )
  78.     self.const_set(:ME_Volume, newvolume)
  79.   end
  80.   def self.ChangePitch( newpitch )
  81.     self.const_set(:ME_Pitch, newpitch)
  82.   end
  83.   def self.ChangeFramewait_Amount( newframewait )
  84.     self.const_set(:Framewait_Amount, newframewait)
  85.   end
  86.  
  87.  
  88. end # Module
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. #==============================================================================
  101. # ** Game_Battler
  102. #------------------------------------------------------------------------------
  103. #  A battler class with methods for sprites and actions added. This class
  104. # is used as a super class of the Game_Actor class and Game_Enemy class.
  105. #==============================================================================
  106. class Game_Battler
  107.   #--------------------------------------------------------------------------
  108.   # * Change HP
  109.   #     hp : new HP
  110.   #--------------------------------------------------------------------------
  111.   def hp=(hp)
  112.     @hp = [[hp, maxhp].min, 0].max
  113.     if @hp == 0 and not state?(1) and not @immortal
  114.       #/////////////////////////////////////////////////////////////////////
  115.       if @actor_id
  116.         RPG::ME.new(Actor_Death_ME::Death_ME, Actor_Death_ME::ME_Volume, Actor_Death_ME::ME_Pitch).play if Actor_Death_ME::Death_ME
  117.         Graphics.wait(Actor_Death_ME::Framewait_Amount)
  118.         $game_temp.common_event_id = (Actor_Death_ME::Common_Event_ID_To_Run[@actor_id])
  119.       end
  120.       #/////////////////////////////////////////////////////////////////////
  121.       add_state(1)                # Add incapacitated (state #1)
  122.       @added_states.push(1)
  123.     elsif @hp > 0 and state?(1)
  124.       remove_state(1)             # Remove incapacitated (state #1)
  125.       @removed_states.push(1)
  126.     end # IF Statement
  127.   end # Function
  128. end # Class
  129.  
  130.  
  131.  
  132.  
  133.  
  134. #==============================================================================
  135. # ** Game_Interpreter
  136. #------------------------------------------------------------------------------
  137. #  An interpreter for executing event commands. This class is used within the
  138. # Game_Map, Game_Troop, and Game_Event classes.
  139. #==============================================================================
  140. class Game_Interpreter
  141.   #--------------------------------------------------------------------------
  142.   # * Change Actor Death ME
  143.   #--------------------------------------------------------------------------
  144.   def Change_ActorDeathME( me, volume, pitch, frames )
  145.     Actor_Death_ME::ChangeME( me )                    if me.is_a?(String) # if not nil and is a string
  146.     Actor_Death_ME::ChangeVolume( volume )            if volume.is_a?(Integer)
  147.     Actor_Death_ME::ChangePitch( pitch )              if pitch.is_a?(Integer)
  148.     Actor_Death_ME::ChangeFramewait_Amount( frames )  if frames.is_a?(Integer)
  149.   end # Function
  150. end # Class
clone this paste RAW Paste Data