Displaying different damage pop-ups depending on element efficiency

In RPG Maker XP, is it possible to alter the visuals of the damage pop-ups when an attack has high or low element efficiency?

For example, if an enemy is hit with a skill with the element 'fire' and its element efficiency for 'fire' was defined in the database as 'A' (200% damage), the damage pop-up would be yellow instead of white, have an exclamation mark at the end or would display 'weak', similar to a critical hit.

I would love to know if this is possible, as it would make using elements to your advantage much more intuitive.

Thank you very much in advance!
In RPGMaker XP's help file, they actually describe the actual SPRITE class that renders sprites, and the 'damage' method which renders the popup damage. (just look for RPG::Sprite) Nice of them, eh?

Unfortunately, the damage method only allows you to pass two types of data into the method, the damage and if the damage was from a critcal hit ( def damage(value, critical) ).

It's typically recommended that you do not touch this. Granted, there are scripts that do alter the damage pop's calling method, but those usually also allow damage pops to show for skill point damage or healing too... or blue magic included. There's quite a few out there, so if you're using one of these, your Damage Method has already been altered.

The BEST method would probably be kinda multi-Fold.

1) You will need to add a new 'value' into RPG:Sprite's Initialize method, it being some sort of element flag to be turned on. I recommend using an alias technique to add it rather than straight rewrites. A value added may be something like @_damage_element

2) You need to make some sort of new method in RPG::Sprite. It would be a sort of link between Game_Battler's damage system and RPG::Sprite's damage method. Think of it like this:
Code:
def damage_element(element=nil)
  #  The new value holds the element
  @_damage_element = element
end

3) You need to alter the Damage method to check if the @_damage_element is NOT nil. Again, if it is NOT nil. If the value of @_damage_element is nil, then it's business as usual and no color change. But if it is NOT nil, then you should make some color change to the font... right?

Something like this???
Code:
      bitmap = Bitmap.new(160, 48)
      bitmap.font.name = "Arial Black"
      bitmap.font.size = 32
      bitmap.font.color.set(0, 0, 0)
      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
      if value.is_a?(Numeric) and value < 0
        bitmap.font.color.set(176, 255, 144)
      else
        case @_damage_element
        when 1 ; bitmap.font.color.set(255, 255, 0)   # Fire is Yellow
        when 2 ; bitmap.font.color.set(160, 225, 240) # Ice is lt Blue
        when 3 ; bitmap.font.color.set(255, 255, 127) # Thunder is pale yellow
        when 4 ; bitmap.font.color.set(0, 140, 225)   # Water is blue
        when 5 ; bitmap.font.color.set(184, 127, 15)  # Earth is lt brown
        else   ; bitmap.font.color.set(255, 255, 255) # Else normal
        end
      end

Okay, that's the mechanics..... When you want to make a damage pop in skill_effect or item_effect, et al... , you must also call 'damage_element' and set a value to the damage. So just as you set damage like.... self.damage = power * rate / 20 , you would set the element for the damage pop's sprite color effect with self.damage_element =3 (or however you can provide which element does the most).

It is possible. You would need to rewrite the damage method to include the changes... but this is the basics.
Thank you very much for the elaborate reply!

I have tried to insert your example code into the MOG_Damage System V1.2:

Code:
#===============================================================================
# Rpg Sprite
#===============================================================================
module RPG
class Sprite < ::Sprite
#--------------------------------------------------------------------------
# damage_element
#--------------------------------------------------------------------------
  def damage_element(element=nil)
    # The new value holds the element
    @_damage_element = element
  end
#--------------------------------------------------------------------------
# damage
#-------------------------------------------------------------------------- 
  def damage(value, critical)
    dispose_damage
    if value.is_a?(Numeric)
      damage_string = value.abs.to_s
    else
      damage_string = value.to_s
    end
    bitmap = Bitmap.new(160, 48)
    bitmap.font.name = MOG::FONT_NAME
    bitmap.font.size = MOG::FONT_SIZE
    bitmap.font.bold = MOG::FONT_BOLD
    bitmap.font.color.set(0, 0, 0)
    bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
    bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
    bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
    bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
    if value.is_a?(Numeric) and value < 0
      bitmap.font.color = MOG::FONT_COLOR_HEAL       
    else
      case @_damage_element
      when 1 ; bitmap.font.color.set(255, 255, 0)   # Fire is Yellow
      when 2 ; bitmap.font.color.set(160, 225, 240) # Ice is lt Blue
      when 3 ; bitmap.font.color.set(255, 255, 127) # Thunder is pale yellow
      when 4 ; bitmap.font.color.set(0, 140, 225)   # Water is blue
      when 5 ; bitmap.font.color.set(184, 127, 15)  # Earth is lt brown
      else   ; bitmap.font.color.set(255, 255, 255) # Else normal
      end
    end

Now, if I don't want to have differently coloured damage pop-ups for each element, but only one colour for effective attacks and one for ineffective attacks, I would do something like this, right?

Code:
case @_damage_element
      when 1 ; bitmap.font.color.set(255, 255, 0)   # Effective is Yellow
      when 2 ; bitmap.font.color.set(160, 225, 240) # Ineffective is lt Blue
      else   ; bitmap.font.color.set(255, 255, 255) # Else normal
      end
    end

But where would I get the value for damage_element from? My first guess was from Game_Enemy, starting from line 118:

Code:
 #--------------------------------------------------------------------------
  # * Get Element Revision Value
  #     element_id : Element ID
  #--------------------------------------------------------------------------
  def element_rate(element_id)
    # Get a numerical value corresponding to element effectiveness
    table = [0,200,150,100,50,0,-100]
    result = table[$data_enemies[@enemy_id].element_ranks[element_id]]
    # If protected by state, this element is reduced by half
    for i in @states
      if $data_states[i].guard_element_set.include?(element_id)
        result /= 2
      end
    end
    # End Method
    return result
  end

But I'm not sure how I can take one of the values from the table (e.g. 200 or 50) and store them in damage_element.

Or am I on the completly wrong track here?
Not there. As I suggested, it would be in the skill_effect, item_effect or the like systems.

You know right here???
Code:
      # Calculate basic damage
      self.damage = power * rate / 20
      # Element correction
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end

Well, the elements correct multiplies the value right? Multiplies before being divided by 100 anyway. 😛

So if the elements_correct(skill.element_set) statement multiplies HIGHER than 100, then it is an increase. If lower than 100, it is a decrease. So......
Code:
# Default damage element     
self.damage_element = nil
# If Element correction is higher than 150 (ie 200)
if elements_correct(skill.element_set) > 150
  self.damage_element = 1
# If Element correction is freakin low...
elsif elements_correct(skill.element_set) < 100
  self.damage_element = 2
end

You could put it basically after the GUARD if ya want. I think 😉
I think we are getting there. I have trouble putting everything into place though, so if you could also help me with that, that would be great 🙂

So far, I got three pieces of custom code from you that I have to insert into the script.

1) The code that defines damage_element:
Code:
def damage_element(element=nil)
  #  The new value holds the element
  @_damage_element = element
end

2) The code that checks whether elements_correct is bigger than 150 or smaller than 100 and assigns a value of 1 or 2 respectively:
Code:
# Default damage element     
self.damage_element = nil
# If Element correction is higher than 150 (ie 200)
if elements_correct(skill.element_set) > 150
  self.damage_element = 1
# If Element correction is freakin low...
elsif elements_correct(skill.element_set) < 100
  self.damage_element = 2
end

3) The code that changes the font colour of the damage pop-up depending on whether damage_element is 1 or 2:
Code:
case @_damage_element
      when 1 ; bitmap.font.color.set(255, 255, 0)   # Effective is Yellow
      when 2 ; bitmap.font.color.set(160, 225, 240) # Ineffective is lt Blue
      else   ; bitmap.font.color.set(255, 255, 255) # Else normal
      end

Now, I inserted 3) at the beginning of the custom damage script, into the part where damage is defined, which I think was correct, right?
Code:
#===============================================================================
# Rpg Sprite
#===============================================================================
module RPG
class Sprite < ::Sprite
#--------------------------------------------------------------------------
# damage
#--------------------------------------------------------------------------
  def damage(value, critical)
    dispose_damage
    if value.is_a?(Numeric)
      damage_string = value.abs.to_s
    else
      damage_string = value.to_s
    end
    bitmap = Bitmap.new(160, 48)
    bitmap.font.name = MOG::FONT_NAME
    bitmap.font.size = MOG::FONT_SIZE
    bitmap.font.bold = MOG::FONT_BOLD
    bitmap.font.color.set(0, 0, 0)
    bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
    bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
    bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
    bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
    if value.is_a?(Numeric) and value < 0
      bitmap.font.color = MOG::FONT_COLOR_HEAL
    else       
      case @_damage_element
      when 1 ; bitmap.font.color.set(255, 255, 0)   # Effective is Yellow
      when 2 ; bitmap.font.color.set(160, 225, 240) # Ineffective is lt Blue
      else   ; bitmap.font.color.set(255, 255, 255) # Else normal
      end
    end

Then I inserted 2) into Game_Battler 3 at line 152, after the guard correction, as you suggested:
Code:
      # Calculate basic damage
      self.damage = power * rate / 20
      # Element correction
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Default damage element     
      self.damage_element = nil
      # If Element correction is higher than 150 (ie 200)
      if elements_correct(skill.element_set) > 150
        self.damage_element = 1
        # If Element correction is freakin low...
        elsif elements_correct(skill.element_set) < 100
          self.damage_element = 2
          end

Now where should I put 1)? No matter what I do, at some point in the battle the following message appears:
Script 'Game_Battler 3' line 68: NoMethodError occurred.

undefined method 'damage_element=' for #<Game_Actor:0x3c62640>

I encountered the same message, but with 'Game_Enemy' instead of 'Game_Actor', as well.
You're forgetting what I said before...

1) You will need to add a new 'value' into RPG:Sprite's Initialize method, it being some sort of element flag to be turned on. I recommend using an alias technique to add it rather than straight rewrites. A value added may be something like @_damage_element
2) You need to make some sort of new method in RPG::Sprite. It would be a sort of link between Game_Battler's damage system and RPG::Sprite's damage method. Think of it like this:

So not only do you have to go into RPG::Sprite and the initialize method to add the @_damage_element value, but you add the whole 'damage_element' method into it.
Sorry if I'm being an idiot here, but where can I find RPG::Sprite? I had the impression that this was located outside of the script editor.

If I seach for 'RPG::Sprite' in the script editor, the only result is in Sprite_Battler. Do I put the method here?

Code:
#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
#  This sprite is used to display the battler.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :battler                  # battler
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport : viewport
  #     battler  : battler (Game_Battler)
  #--------------------------------------------------------------------------
  def initialize(viewport, battler = nil)
    super(viewport)
    @battler = battler
    @battler_visible = false
  end
In RPGMaker XP's help file, they actually describe the actual SPRITE class that renders sprites, and the 'damage' method which renders the popup damage. (just look for RPG::Sprite) Nice of them, eh?

This is one of RPGMaker's hidden scripts. It is not visible within the Scripts Database, but actually within the RGSS104E.DLL (or whatever version of the dll you have). HOWEVER, it is easy to alter and alias because a copy of the RPG::Sprite class is in the help file.

Do a search for RPG::Sprite in the help file, and you'll find the topic. Scroll down the topic until you find 'Definition' That is the actual SCRIPT! RPG::Sprite handles many of the effects that are applied to sprites in the system, be it pop-ups or the 'collapse' effect when an enemy dies.

Now that's INFO for you to know in general. But it is NOT necessary for you to copy this script. I'm just informing you where the baseline version of RPG::Sprite can be found.

Where else can you find it?????
I have tried to insert your example code into the MOG_Damage System V1.2:

Code:
#===============================================================================
# Rpg Sprite
#===============================================================================
module RPG
class Sprite < ::Sprite
#--------------------------------------------------------------------------
# damage_element
#--------------------------------------------------------------------------
  def damage_element(element=nil)
   # The new value holds the element
   @_damage_element = element
  end
and so on...

So yeah, your copy of MOG'S script is editing RPG::Sprite. HOWEVER, I can see from the code that he doesn't 'touch' upon the initialize method..... and you need to add the @_damage_element variable into it.

SO... let's add THAT into MOGGY'S script, shall we?

The original version is...
Code:
def initialize(viewport = nil)
  super(viewport)
  @_whiten_duration = 0
  @_appear_duration = 0
  @_escape_duration = 0
  @_collapse_duration = 0
  @_damage_duration = 0
  @_animation_duration = 0
  @_blink = false
end

So, we'll just shove the variable in like so...
Code:
def initialize(viewport = nil)
  super(viewport)
  @_whiten_duration = 0
  @_appear_duration = 0
  @_escape_duration = 0
  @_collapse_duration = 0
  @_damage_duration = 0
  @_animation_duration = 0
  @_blink = false
  @_damage_element = nil
end
And have that method get put into MOGGY'S damage script as well. Probably above where you put the other method. 😉
So I ditched the MOG Damage System (since I won't be working with it anyway, now that I know how to edit RPG::Sprite) and will just use the code from the help file that you mentioned. I applied the following changes to RPG::Sprite (highlighted with the help of asterisks):
Code:
module RPG
  class Sprite < ::Sprite
    @@_animations = []
    @@_reference_count = {}
    def initialize(viewport = nil)
      super(viewport)
      @_whiten_duration = 0
      @_appear_duration = 0
      @_escape_duration = 0
      @_collapse_duration = 0
      @_damage_duration = 0
      @_animation_duration = 0
      @_blink = false
      ####################
      @_damage_element=nil
      ####################
    end
    ##################################
    def damage_element(element=nil)
    #  The new value holds the element
      @_damage_element = element
    end
    ##################################
    def dispose
      dispose_damage
      dispose_animation
      dispose_loop_animation
      super
    end
    def whiten
      self.blend_type = 0
      self.color.set(255, 255, 255, 128)
      self.opacity = 255
      @_whiten_duration = 16
      @_appear_duration = 0
      @_escape_duration = 0
      @_collapse_duration = 0
    end
    def appear
      self.blend_type = 0
      self.color.set(0, 0, 0, 0)
      self.opacity = 0
      @_appear_duration = 16
      @_whiten_duration = 0
      @_escape_duration = 0
      @_collapse_duration = 0
    end
    def escape
      self.blend_type = 0
      self.color.set(0, 0, 0, 0)
      self.opacity = 255
      @_escape_duration = 32
      @_whiten_duration = 0
      @_appear_duration = 0
      @_collapse_duration = 0
    end
    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 = 0
    end
    def damage(value, critical)
      dispose_damage
      if value.is_a?(Numeric)
        damage_string = value.abs.to_s
      else
        damage_string = value.to_s
      end
      bitmap = Bitmap.new(160, 48)
      bitmap.font.name = "Arial Black"
      bitmap.font.size = 32
      bitmap.font.color.set(0, 0, 0)
      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
      if value.is_a?(Numeric) and value < 0
        bitmap.font.color.set(176, 255, 144)
      else
        ######################################################################
        case @_damage_element
        when 1 ; bitmap.font.color.set(255, 255, 0)   # Effective is Yellow
        when 2 ; bitmap.font.color.set(160, 225, 240) # Ineffective is lt Blue
        else   ; bitmap.font.color.set(255, 255, 255) # Else normal
        end
        ######################################################################
      end
      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
      if critical
        bitmap.font.size = 20
        bitmap.font.color.set(0, 0, 0)
        bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
        bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
        bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
        bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
        bitmap.font.color.set(255, 255, 255)
        bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
      end
      @_damage_sprite = ::Sprite.new(self.viewport)
      @_damage_sprite.bitmap = bitmap
      @_damage_sprite.ox = 80
      @_damage_sprite.oy = 20
      @_damage_sprite.x = self.x
      @_damage_sprite.y = self.y - self.oy / 2
      @_damage_sprite.z = 3000
      @_damage_duration = 40
    end
    def animation(animation, hit)
      dispose_animation
      @_animation = animation
      return if @_animation == nil
      @_animation_hit = hit
      @_animation_duration = @_animation.frame_max
      animation_name = @_animation.animation_name
      animation_hue = @_animation.animation_hue
      bitmap = RPG::Cache.animation(animation_name, animation_hue)
      if @@_reference_count.include?(bitmap)
        @@_reference_count[bitmap] += 1
      else
        @@_reference_count[bitmap] = 1
      end
      @_animation_sprites = []
      if @_animation.position != 3 or not @@_animations.include?(animation)
        for i in 0..15
          sprite = ::Sprite.new(self.viewport)
          sprite.bitmap = bitmap
          sprite.visible = false
          @_animation_sprites.push(sprite)
        end
        unless @@_animations.include?(animation)
          @@_animations.push(animation)
        end
      end
      update_animation
    end
    def loop_animation(animation)
      return if animation == @_loop_animation
      dispose_loop_animation
      @_loop_animation = animation
      return if @_loop_animation == nil
      @_loop_animation_index = 0
      animation_name = @_loop_animation.animation_name
      animation_hue = @_loop_animation.animation_hue
      bitmap = RPG::Cache.animation(animation_name, animation_hue)
      if @@_reference_count.include?(bitmap)
        @@_reference_count[bitmap] += 1
      else
        @@_reference_count[bitmap] = 1
      end
      @_loop_animation_sprites = []
      for i in 0..15
        sprite = ::Sprite.new(self.viewport)
        sprite.bitmap = bitmap
        sprite.visible = false
        @_loop_animation_sprites.push(sprite)
      end
      update_loop_animation
    end
    def dispose_damage
      if @_damage_sprite != nil
        @_damage_sprite.bitmap.dispose
        @_damage_sprite.dispose
        @_damage_sprite = nil
        @_damage_duration = 0
      end
    end
    def dispose_animation
      if @_animation_sprites != nil
        sprite = @_animation_sprites[0]
        if sprite != nil
          @@_reference_count[sprite.bitmap] -= 1
          if @@_reference_count[sprite.bitmap] == 0
            sprite.bitmap.dispose
          end
        end
        for sprite in @_animation_sprites
          sprite.dispose
        end
        @_animation_sprites = nil
        @_animation = nil
      end
    end
    def dispose_loop_animation
      if @_loop_animation_sprites != nil
        sprite = @_loop_animation_sprites[0]
        if sprite != nil
          @@_reference_count[sprite.bitmap] -= 1
          if @@_reference_count[sprite.bitmap] == 0
            sprite.bitmap.dispose
          end
        end
        for sprite in @_loop_animation_sprites
          sprite.dispose
        end
        @_loop_animation_sprites = nil
        @_loop_animation = nil
      end
    end
    def blink_on
      unless @_blink
        @_blink = true
        @_blink_count = 0
      end
    end
    def blink_off
      if @_blink
        @_blink = false
        self.color.set(0, 0, 0, 0)
      end
    end
    def blink?
      @_blink
    end
    def effect?
      @_whiten_duration > 0 or
      @_appear_duration > 0 or
      @_escape_duration > 0 or
      @_collapse_duration > 0 or
      @_damage_duration > 0 or
      @_animation_duration > 0
    end
    def update
      super
      if @_whiten_duration > 0
        @_whiten_duration -= 1
        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
      end
      if @_appear_duration > 0
        @_appear_duration -= 1
        self.opacity = (16 - @_appear_duration) * 16
      end
      if @_escape_duration > 0
        @_escape_duration -= 1
        self.opacity = 256 - (32 - @_escape_duration) * 10
      end
      if @_collapse_duration > 0
        @_collapse_duration -= 1
        self.opacity = 256 - (48 - @_collapse_duration) * 6
      end
      if @_damage_duration > 0
        @_damage_duration -= 1
        case @_damage_duration
        when 38..39
          @_damage_sprite.y -= 4
        when 36..37
          @_damage_sprite.y -= 2
        when 34..35
          @_damage_sprite.y += 2
        when 28..33
          @_damage_sprite.y += 4
        end
        @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
        if @_damage_duration == 0
          dispose_damage
        end
      end
      if @_animation != nil and (Graphics.frame_count % 2 == 0)
        @_animation_duration -= 1
        update_animation
      end
      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
        update_loop_animation
        @_loop_animation_index += 1
        @_loop_animation_index %= @_loop_animation.frame_max
      end
      if @_blink
        @_blink_count = (@_blink_count + 1) % 32
        if @_blink_count < 16
          alpha = (16 - @_blink_count) * 6
        else
          alpha = (@_blink_count - 16) * 6
        end
        self.color.set(255, 255, 255, alpha)
      end
      @@_animations.clear
    end
    def update_animation
      if @_animation_duration > 0
        frame_index = @_animation.frame_max - @_animation_duration
        cell_data = @_animation.frames[frame_index].cell_data
        position = @_animation.position
        animation_set_sprites(@_animation_sprites, cell_data, position)
        for timing in @_animation.timings
          if timing.frame == frame_index
            animation_process_timing(timing, @_animation_hit)
          end
        end
      else
        dispose_animation
      end
    end
    def update_loop_animation
      frame_index = @_loop_animation_index
      cell_data = @_loop_animation.frames[frame_index].cell_data
      position = @_loop_animation.position
      animation_set_sprites(@_loop_animation_sprites, cell_data, position)
      for timing in @_loop_animation.timings
        if timing.frame == frame_index
          animation_process_timing(timing, true)
        end
      end
    end
    def animation_set_sprites(sprites, cell_data, position)
      for i in 0..15
        sprite = sprites[i]
        pattern = cell_data[i, 0]
        if sprite == nil or pattern == nil or pattern == -1
          sprite.visible = false if sprite != nil
          next
        end
        sprite.visible = true
        sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
        if position == 3
          if self.viewport != nil
            sprite.x = self.viewport.rect.width / 2
            sprite.y = self.viewport.rect.height - 160
          else
            sprite.x = 320
            sprite.y = 240
          end
        else
          sprite.x = self.x - self.ox + self.src_rect.width / 2
          sprite.y = self.y - self.oy + self.src_rect.height / 2
          sprite.y -= self.src_rect.height / 4 if position == 0
          sprite.y += self.src_rect.height / 4 if position == 2
        end
        sprite.x += cell_data[i, 1]
        sprite.y += cell_data[i, 2]
        sprite.z = 2000
        sprite.ox = 96
        sprite.oy = 96
        sprite.zoom_x = cell_data[i, 3] / 100.0
        sprite.zoom_y = cell_data[i, 3] / 100.0
        sprite.angle = cell_data[i, 4]
        sprite.mirror = (cell_data[i, 5] == 1)
        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
        sprite.blend_type = cell_data[i, 7]
      end
    end
    def animation_process_timing(timing, hit)
      if (timing.condition == 0) or
         (timing.condition == 1 and hit == true) or
         (timing.condition == 2 and hit == false)
        if timing.se.name != ""
          se = timing.se
          Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
        end
        case timing.flash_scope
        when 1
          self.flash(timing.flash_color, timing.flash_duration * 2)
        when 2
          if self.viewport != nil
            self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
          end
        when 3
          self.flash(nil, timing.flash_duration * 2)
        end
      end
    end
    def x=(x)
      sx = x - self.x
      if sx != 0
        if @_animation_sprites != nil
          for i in 0..15
            @_animation_sprites[i].x += sx
          end
        end
        if @_loop_animation_sprites != nil
          for i in 0..15
            @_loop_animation_sprites[i].x += sx
          end
        end
      end
      super
    end
    def y=(y)
      sy = y - self.y
      if sy != 0
        if @_animation_sprites != nil
          for i in 0..15
            @_animation_sprites[i].y += sy
          end
        end
        if @_loop_animation_sprites != nil
          for i in 0..15
            @_loop_animation_sprites[i].y += sy
          end
        end
      end
      super
    end
  end
end

With these changes, everything runs smoothly. The damage pop-up does not change colour yet, of course, but at least there's no error message. The problem comes as soon as I try to insert this piece of code into Game_Battler 3:
Code:
        # Default damage element     
        self.damage_element = nil
        # If Element correction is higher than 150 (ie 200)
        if elements_correct(skill.element_set) > 150
          self.damage_element = 1
        # If Element correction is freakin low...
        elsif elements_correct(skill.element_set) < 100
          self.damage_element = 2
        end

I put it after the guard correction of both the skill_effect and the item_effect sections (once again marked with asterisks):
Code:
#==============================================================================
# ** Game_Battler (part 3)
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Determine Usable Skills
  #     skill_id : skill ID
  #--------------------------------------------------------------------------
  def skill_can_use?(skill_id)
    # If there's not enough SP, the skill cannot be used.
    if $data_skills[skill_id].sp_cost > self.sp
      return false
    end
    # Unusable if incapacitated
    if dead?
      return false
    end
    # If silent, only physical skills can be used
    if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
      return false
    end
    # Get usable time
    occasion = $data_skills[skill_id].occasion
    # If in battle
    if $game_temp.in_battle
      # Usable with [Normal] and [Only Battle]
      return (occasion == 0 or occasion == 1)
    # If not in battle
    else
      # Usable with [Normal] and [Only Menu]
      return (occasion == 0 or occasion == 2)
    end
  end
  #--------------------------------------------------------------------------
  # * Applying Normal Attack Effects
  #     attacker : battler
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
       end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # If hit occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to "Miss"
      self.damage = "Miss"
      # Clear critical flag
      self.critical = false
    end
    # End Method
    return true
  end
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #     user  : the one using skills (battler)
  #     skill : skill
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # Clear critical flag
    self.critical = false
    # If skill scope is for ally with 1 or more HP, and your own HP = 0,
    # or skill scope is for ally with 0, and your own HP = 1 or more
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= skill.common_event_id > 0
    # First hit detection
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # Set effective flag if skill is uncertain
    effective |= hit < 100
    # If hit occurs
    if hit_result == true
      # Calculate power
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # Calculate rate
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # Calculate basic damage
      self.damage = power * rate / 20
      # Element correction
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
        ###################################################
        # Default damage element     
        self.damage_element = nil
        # If Element correction is higher than 150 (ie 200)
        if elements_correct(skill.element_set) > 150
          self.damage_element = 1
        # If Element correction is freakin low...
        elsif elements_correct(skill.element_set) < 100
          self.damage_element = 2
        end
        ###################################################
      end
      # Dispersion
      if skill.variance > 0 and self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / user.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      # Set effective flag if skill is uncertain
      effective |= hit < 100
    end
    # If hit occurs
    if hit_result == true
      # If physical attack has power other than 0
      if skill.power != 0 and skill.atk_f > 0
        # State Removed by Shock
        remove_states_shock
        # Set to effective flag
        effective = true
      end
      # Substract damage from HP
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      # State change
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # If power is 0
      if skill.power == 0
        # Set damage to an empty string
        self.damage = ""
        # If state is unchanged
        unless @state_changed
          # Set damage to "Miss"
          self.damage = "Miss"
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Miss"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
    return effective
  end
  #--------------------------------------------------------------------------
  # * Application of Item Effects
  #     item : item
  #--------------------------------------------------------------------------
  def item_effect(item)
    # Clear critical flag
    self.critical = false
    # If item scope is for ally with 1 or more HP, and your own HP = 0,
    # or item scope is for ally with 0 HP, and your own HP = 1 or more
    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= item.common_event_id > 0
    # Determine hit
    hit_result = (rand(100) < item.hit)
    # Set effective flag is skill is uncertain
    effective |= item.hit < 100
    # If hit occurs
    if hit_result == true
      # Calculate amount of recovery
      recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
      recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
      if recover_hp < 0
        recover_hp += self.pdef * item.pdef_f / 20
        recover_hp += self.mdef * item.mdef_f / 20
        recover_hp = [recover_hp, 0].min
      end
      # Element correction
      recover_hp *= elements_correct(item.element_set)
      recover_hp /= 100
      recover_sp *= elements_correct(item.element_set)
      recover_sp /= 100
      # Dispersion
      if item.variance > 0 and recover_hp.abs > 0
        amp = [recover_hp.abs * item.variance / 100, 1].max
        recover_hp += rand(amp+1) + rand(amp+1) - amp
      end
      if item.variance > 0 and recover_sp.abs > 0
        amp = [recover_sp.abs * item.variance / 100, 1].max
        recover_sp += rand(amp+1) + rand(amp+1) - amp
      end
      # If recovery code is negative
      if recover_hp < 0
        # Guard correction
        if self.guarding?
          recover_hp /= 2
        end
        ###################################################
        # Default damage element     
        self.damage_element = nil
        # If Element correction is higher than 150 (ie 200)
        if elements_correct(skill.element_set) > 150
          self.damage_element = 1
        # If Element correction is freakin low...
        elsif elements_correct(skill.element_set) < 100
          self.damage_element = 2
        end
        ###################################################
      end
      # Set damage value and reverse HP recovery amount
      self.damage = -recover_hp
      # HP and SP recovery
      last_hp = self.hp
      last_sp = self.sp
      self.hp += recover_hp
      self.sp += recover_sp
      effective |= self.hp != last_hp
      effective |= self.sp != last_sp
      # State change
      @state_changed = false
      effective |= states_plus(item.plus_state_set)
      effective |= states_minus(item.minus_state_set)
      # If parameter value increase is effective
      if item.parameter_type > 0 and item.parameter_points != 0
        # Branch by parameter
        case item.parameter_type
        when 1  # Max HP
          @maxhp_plus += item.parameter_points
        when 2  # Max SP
          @maxsp_plus += item.parameter_points
        when 3  # Strength
          @str_plus += item.parameter_points
        when 4  # Dexterity
          @dex_plus += item.parameter_points
        when 5  # Agility
          @agi_plus += item.parameter_points
        when 6  # Intelligence
          @int_plus += item.parameter_points
        end
        # Set to effective flag
        effective = true
      end
      # If HP recovery rate and recovery amount are 0
      if item.recover_hp_rate == 0 and item.recover_hp == 0
        # Set damage to empty string
        self.damage = ""
        # If SP recovery rate / recovery amount are 0, and parameter increase
        # value is ineffective.
        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
           (item.parameter_type == 0 or item.parameter_points == 0)
          # If state is unchanged
          unless @state_changed
            # Set damage to "Miss"
            self.damage = "Miss"
          end
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Miss"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
    return effective
  end
  #--------------------------------------------------------------------------
  # * Application of Slip Damage Effects
  #--------------------------------------------------------------------------
  def slip_damage_effect
    # Set damage
    self.damage = self.maxhp / 10
    # Dispersion
    if self.damage.abs > 0
      amp = [self.damage.abs * 15 / 100, 1].max
      self.damage += rand(amp+1) + rand(amp+1) - amp
    end
    # Subtract damage from HP
    self.hp -= self.damage
    # End Method
    return true
  end
  #--------------------------------------------------------------------------
  # * Calculating Element Correction
  #     element_set : element
  #--------------------------------------------------------------------------
  def elements_correct(element_set)
    # If not an element
    if element_set == []
      # Return 100
      return 100
    end
    # Return the weakest object among the elements given
    # * "element_rate" method is defined by Game_Actor and Game_Enemy classes,
    #    which inherit from this class.
    weakest = -100
    for i in element_set
      weakest = [weakest, self.element_rate(i)].max
    end
    return weakest
  end
end

However, I still get the error message:
Script 'Game_Battler 3' line 153: NoMethodError occurred.

undefined method 'damage_element=' for
#<Game_Enemy:0x4039a00>

I tried to put the definition of damage_element into Game_Battler 3, Game_Enemy and Game_Actor, but to no avail. The same error message still appears.
My bad. A couple more steps to DO! But where you have the current code is correct.

NOW... We need to add some values to Game_Battler itself. And there at the beginning of the class, add
Code:
attr_accessor :damage_element           # Damage Element
with all the others in the Public Instance Variables. And in the Initialize method right below, add
Code:
@damage_element = nil

That will get rid of the ERROR message, but doesn't finish all the links.

Go to the Sprite_Battler class, and on line 108 you will find the start of the Damage Pop system. This triggers the popup to show.
Add the following line right after the IF statement and before the damage(@battler.damage... line
Code:
damage_element(@battler.damage_element)

Then, after the damage(@battler.damage... line, add
Code:
@battler.damage_element = nil

That should do it.

I did nearly all this just off the top of my head. I forgot about the damage pop system in the Sprite_Battler class.
Awesome, it works like a charm! Strong attacks now have a yellow damage pop-up and weak attacks have a blue one.

Thank you so much for your help, I've been looking all over the place for a method to achieve this. Much obliged 🙂

Original thread: https://forums.rpgmakerweb.com/threads/displaying-different-damage-pop-ups-depending-on-element-efficiency.111859/