Two Requests: Enemy shake when hit and draw depth for animations (with examples)

I'm looking for two things: First is the enemy is shaken when hit by an attack, here's an example (you might need to click on the image to see the gif):
PKThunder.gif
A lot of RPGs do this and it makes it feel like there's more weight behind an attack. The shake is kind of mid animation

My second thing is that the animations are behind the Battle UI, but there are some that I want to take up the whole screen with, however the Battle HUD gets in the way of it. If anyone knows how this could be changed or there is a script I'd love to know. Thanks!
shakebattler.gif

Code:
class Sprite_Battler
  Shake_X_Max = 10      # Maximum X displacement
  Shake_Y_Max = 10      # Maximum Y displacement
  Shake_Diminish = true # Gradually lose the power overtime?
  
  alias blink2shake_init initialize
  def initialize(viewport, battler = nil)
    @shake_x = 0
    @shake_y = 0
    @shake_maxdur = 0
    blink2shake_init(viewport, battler)
  end
  
  alias blink2shake_start start_effect
  def start_effect(effect_type)
    blink2shake_start(effect_type)
    @shake_maxdur = @effect_duration.to_f
  end
  
  # Overwrite
  def update_blink
    rate = Shake_Diminish ? @effect_duration / @shake_maxdur : 1.0
    self.x += rand(Shake_X_Max) * rate
    self.y += rand(Shake_Y_Max) * rate
  end
end
If you want that to happen in the middle of the animation, the setup is going to be tricky.
Awesome it works perfectly! Do you think that it could be used in a common event to make it happen mid animation? I appreciate the script it solved that problem.

Original thread: https://forums.rpgmakerweb.com/threads/two-requests-enemy-shake-when-hit-and-draw-depth-for-animations-with-examples.120235/