MZ Getting a single enemy to shake when hit(Solved)

Hello! I've been trying to get enemies to shake when you hit them in battle. With TheoAllen's blessing I was able to modify a plugin he wrote for screenshake to do just that.

The problem is that ALL enemies shake when you hit them, and they even shake when they hit you!

Can someone help me figure out how to make it so only the enemy who was hit, shakes?

JavaScript:
var Theo = Theo || {}
Theo.Shake = {}
Theo.Shake.gameTemp_init = Game_Temp.prototype.initialize;
Game_Temp.prototype.initialize = function(){
Theo.Shake.gameTemp_init.call(this);
this.shake_maxdur = 0;
this.shake_dur = 0;
this.shake_pow = 0;
}
Game_Temp.prototype.shake_screen = function(power, duration){
this.shake_maxdur = duration;
this.shake_dur = duration;
this.shake_pow = power;
}
Theo.Shake.spritesetEnemy_updatePos = Sprite_Enemy.prototype.updatePosition;
Sprite_Enemy.prototype.updatePosition = function(){
Theo.Shake.spritesetEnemy_updatePos.call(this);
if($gameTemp.shake_dur > 0){
$gameTemp.shake_dur -= 1;
let rate = $gameTemp.shake_dur/$gameTemp.shake_maxdur;
this.x += Math.random() * $gameTemp.shake_pow * rate * (Math.random() >= 0.5 ? 1 : -1);
this.y += Math.random() * $gameTemp.shake_pow * rate * (Math.random() >= 0.5 ? 1 : -1);
}
}

Sprite_Battler.prototype.setupDamagePopup = function() {
if (this._battler.isDamagePopupRequested()) {
if (this._battler.isSpriteVisible()) {
this.createDamageSprite();
$gameTemp.shake_screen(10, 45);
}
this._battler.clearDamagePopup();
this._battler.clearResult();
}
};
Hey! It sounds like you're probably comfortable with syntax and JS basics, so here's the outline of what you need to do:
1) Alias the initMembers method of Sprite_Enemy to create the property this.shake_dur for Sprite_Enemy, and get rid of it within the Game_Temp alias in the code you've shown; you can also create this.shake_maxdur and this.shake_pow within Sprite_Enemy if you want these to be different for each Enemy Sprite
2) Change all references of $gameTemp.shake_dur (within Sprite_Enemy or Sprite_Battler methods) to this.shake_dur (and do the same for shake_maxdur and shake_pow IF you created them for Sprite_Enemy)
3) Create a copy of the shake_screen method for Sprite_Enemy - it can look exactly the same as the Game_Temp version (except remember to change $gameTemp.shake_dur to this.shake_dur)
4) Change the $gameTemp.shake_screen call to this.shake_screen inside the setupDamagePopup method; you can leave the arguments (10, 45) the same or - if you created the this.shake_maxdur and this.shake_pow properties for Sprite_Enemy you can set them to this.shake_pow and this.shake_maxdur instead!

Let me know with an @ if you have any trouble pulling that off.
Thank you Wavelength!

Original thread: https://forums.rpgmakerweb.com/threads/getting-a-single-enemy-to-shake-when-hit-solved.132700/