[XP] Change animation layer script?

Hello! I'd like to ask if there's a way to change the animation layer? For example, in this demo below, I'd like to draw the dust animation above the tile layers but below the character.

Game_LleHZxCJsf.gif


Thank you so much for your time!
Ruby:
# Animation IDs that play at a lower z-level
LOW_Z_ANIMATIONS = [1, 2, 3]

module RPG
  class Sprite < ::Sprite

  alias get_animation_z_level_value animation
  def animation(animation, hit)
    @anim_z_level = (LOW_Z_ANIMATIONS.include?(animation.id) ? -100 : 2000)  #<===== Change -100 to your liking.
    get_animation_z_level_value(animation, hit)
  end

  alias change_z_level_animations animation_set_sprites
  def animation_set_sprites(sprites, cell_data, position)
    change_z_level_animations(sprites, cell_data, position)
    sprites.each{|s| s.z = @anim_z_level }
  end

  end
end
@KK20 Thank you so much! Just a question, the animation only shows up when I change -100 to 0, any number smaller than 0 would make it disappear. What is the reason for that?
Character sprites and the Tilemap reside on the same Viewport. As explained in the Help Docs, the Tilemap rules for Z-coordinates are as follows
The Z-coordinate of each sprite used to create a tilemap is fixed at a specific value.
  1. Tiles with a priority of 0 always have a Z-coordinate of 0.
  2. Priority 1 tiles placed at the top edge of the screen have a Z-coordinate of 64.
  3. Every time the priority increases by 1 or the next tile down is selected, the Z-coordinate increases by 32.
  4. The Z-coordinate changes accordingly as the tilemap scrolls vertically.
Keep these rules in mind when setting the Z-coordinates of any map characters.
So the lowest Z-coordinate of any tile will be 0.

In the link I shared, OP wanted to change the Z-coordinates of their animations for their battle system, not for the map, so the -100 made more sense there. With that said, if you wanted an animation to play behind the Tilemap (say your map is using a panorama background), then a negative Z would work there.

Original thread: https://forums.rpgmakerweb.com/threads/xp-change-animation-layer-script.171186/