MZ Multiple Sprites For Battlers

In short, I want certain enemies (ie "Goblin") to have multiple useable sprites which you can enter in their notetags, to be picked randomly when they appear in a battle (ie "GoblinA", "GoblinB", "GoblinWithSunglasses"). No difference in stats, still counted as the same enemy (ie they'll be Goblin A, Goblin B and Goblin C in battle whether or not any of them use the sunglasses sprite), just a little bit (or a lot of) variety in their possible appearance. I'm using Frontview Battle, if it matters.

I would use Visustella's Battle Core for this EXCEPT its Enemy Swap feature doesn't let you use enemy IDs to set swappable enemies afaik (even though MV's version did), so it can't differentiate between multiple enemies named Goblin. My current solution was using Zero Width Spaces instead, so I get a bunch of enemies called Goblin, Goblin, Goblin etc instead of Goblin A, Goblin B, Goblin C because Goblin(ZeroWidthSpace) is different from Goblin(TwoZeroWidthSpaces); it's not a very elegant solution.

I did find an MV plug-in someone made that did just this, but it doesn't work in MZ.

I would appreciate any help with this!
Ah, I think I see the problem. The code they used probably worked OK, but the code they posted is missing an [i] in a critical place. On this site, [i] makes text italic, so I imagine they copy+pasted it, noticed the italics in preview, and unformatted it before posting. It's best to use one of the forum's special code formatting blocks for code.

Try this instead? (Untested.)
Spoiler: plugin code
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Random enemy sprites.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/182202/
 * @help Enemy notetag: <Alt Sprites: X, X, X>
 *            e.g. <Alt Sprites: Slime2, Slime3, Slime3>
 * Randomly selects a sprite for each instance of this enemy.
 * In this example: the original image, "Slime2.png", or "Slime3.png".
 *
 * Free to use and/or modify for any project, no credit required.
 */

;(function() {
"use strict";

  /** Developer-facing name for notetag. */
  const TAG_NAME = "Alt Sprites";
  /** Separates values in notetag. */
  const SPLITTER = ",";
  /** Property identifier used for memoisation. */
  const PROP = "_battlerName";

  // Patch - randomise battler/sprite name based on notetag, if present.
  const alias = Game_Enemy.prototype.battlerName;     // store original method
  Game_Enemy.prototype.battlerName = function() {
    if (!(PROP in this)) {
      const orig = alias.apply(this, arguments);      // Get original name.
      const tag = this.enemy().meta[TAG_NAME] || "";  // Get notetag value.
      const pool = [orig];                            // Pool for selection.
      if (tag)                                        // Add names from tag.
        for (const s of tag.split(SPLITTER))
          pool.push(s.trim());                        // Trim start/end spaces.
      const r = Math.randomInt(pool.length);          // Select random index.
      this[PROP] = pool[r];                           // Memoise.
    }
    return this[PROP];
  };

})();
Yes, that works perfectly! Thank you very much.

Original thread: https://forums.rpgmakerweb.com/threads/multiple-sprites-for-battlers.182202/