Advertisement
diamondandplatinum3

Actor Death ME & Common Events ~ RGSS3

Jul 31st, 2012
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.33 KB | None | 0 0
  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 an 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         = "Gameover2" # 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.   # * Knock Out
  109.   #--------------------------------------------------------------------------
  110.   alias actordeathme_die_ufh343 die
  111.   def die
  112.    
  113.     # Call original method
  114.     actordeathme_die_ufh343
  115.    
  116.    
  117.     #/////////////////////////////////////////////////////////////////////
  118.     if @actor_id && SceneManager.scene_is?(Scene_Battle)
  119.       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
  120.       Graphics.wait(Actor_Death_ME::Framewait_Amount)
  121.       $game_temp.reserve_common_event(Actor_Death_ME::Common_Event_ID_To_Run[@actor_id])
  122.     end
  123.     #/////////////////////////////////////////////////////////////////////
  124.    
  125.   end # Function
  126. end # Class
  127.  
  128.  
  129.  
  130.  
  131.  
  132. #==============================================================================
  133. # ** Game_Interpreter
  134. #------------------------------------------------------------------------------
  135. #  An interpreter for executing event commands. This class is used within the
  136. # Game_Map, Game_Troop, and Game_Event classes.
  137. #==============================================================================
  138. class Game_Interpreter
  139.   #--------------------------------------------------------------------------
  140.   # * Change Actor Death ME
  141.   #--------------------------------------------------------------------------
  142.   def Change_ActorDeathME( me, volume, pitch, frames )
  143.     Actor_Death_ME::ChangeME( me )                    if me.is_a?(String) # if not nil and is a string
  144.     Actor_Death_ME::ChangeVolume( volume )            if volume.is_a?(Integer)
  145.     Actor_Death_ME::ChangePitch( pitch )              if pitch.is_a?(Integer)
  146.     Actor_Death_ME::ChangeFramewait_Amount( frames )  if frames.is_a?(Integer)
  147.   end # Function
  148. end # Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement