[XP] Modifying Collapse Animation

I've been searching through the scripts to find the part which causes a battler to flash red upon being defeated, after a while of looking I just cannot seem to find it. What I did find though was quite unusual, the script that gave me the most clues was Sprite_Battler which uses procedures and functions, including Collapse which I assume handles this red flash, from a script called RPG::Sprite, as seen at the top of the script "class Sprite_Battler < RPG::Sprite". Now I have no idea where this RPG::Sprite script is because I can't find it anywhere. Anyway if anyone knows how to change this please let me know because I don't want battlers flashing red upon defeat I want them to follow an animation, which I know how to make.
Open up the help menu with F1. The class RPG::Sprite is one of the hidden classes that's built-in to RGSS. If you go to "RGSS Reference Manual" -> "Game Library" -> "RGSS Built-in Classes" -> "RPG::Sprite" and then scroll down, you'll find the definition for "collapse".

Spoiler
def collapse self.blend_type = 1 self.color.set(255, 64, 64, 255) self.opacity = 255 @_collapse_duration = 48 @_whiten_duration = 0 @_appear_duration = 0 @_escape_duration = 0end 
You won't be able to change the code there, but if you open the Script Editor, then you can overwrite it with the following:

Spoiler
Code:
class RPG::Sprite  def collapse    # put your new code here  endend 
Open up the help menu with F1. The class RPG::Sprite is one of the hidden classes that's built-in to RGSS. If you go to "RGSS Reference Manual" -> "Game Library" -> "RGSS Built-in Classes" -> "RPG::Sprite" and then scroll down, you'll find the definition for "collapse".

Spoiler
def collapse self.blend_type = 1 self.color.set(255, 64, 64, 255) self.opacity = 255 @_collapse_duration = 48 @_whiten_duration = 0 @_appear_duration = 0 @_escape_duration = 0end 
You won't be able to change the code there, but if you open the Script Editor, then you can overwrite it with the following:

Spoiler
Code:
class RPG::Sprite  def collapse    # put your new code here  endend 
Will I need to, for example, put:
Spoiler
Code:
class RPG::Sprite < # NameOfClassOverridingTheCollapse
You will redefine the collapse function of the Sprite class. Write a new script and enter this inside. Then add your code in place of the comments.

Code:
module RPG  class Sprite < ::Sprite    def collapse      # insert code    end  endend
Will I need to, for example, put:

Spoiler
class RPG::Sprite < # NameOfClassOverridingTheCollapse
No, you're overriding the "collapse" method in the RPG::Sprite class which is the super class of most sprites. So because Sprite_Battler is a subclass of RPG::Sprite, it will call your new method.

Now, I did make one mistake which Schlangan pointed out above. RPG is a module and Sprite is a class, so do this. Put the following code into a new slot in your script editor and see what happens.

Spoiler
Code:
module RPG  class Sprite    alias old_collapse collapse    def collapse      old_collapse      print("This works")    end  endend 

Original thread: https://forums.rpgmakerweb.com/threads/xp-modifying-collapse-animation.44026/