MV Want to limit Mr. Trivel DeathSounds to play only once per collapse

Hey all,

I found this simple plugin from a user who hasn't been online in 9 years (Mr. Trivel), so I figured I'd ask for help here. This plugin has a simple function which is that it will play a selected sound when an enemy/actor dies. It seems he didn't take into account multi-hit skills which will cause the sound to play multiple times (or perhaps another plugin of mine makes it function this way?).

His other plugin HitSounds functions on execute damage, so I found that easy to mod by adding checks for the target's current HP etc. However this plugin functions on play collapse, which I can't wrap my head around.

Here's the part where the sound is played:

JavaScript:
    var _GameBattler_performCollapse = Game_Battler.prototype.performCollapse;
    Game_Battler.prototype.performCollapse = function() {
        _GameBattler_performCollapse.call(this)
        if (this._deathSounds.length > 0)
        {
            var sound = AudioManager.makeEmptyAudioObject();
            var randomDeathSound = this._deathSounds[Math.floor(Math.random()*this._deathSounds.length)];
            sound.name = randomDeathSound[0];
            sound.volume = randomDeathSound[1];
            sound.pitch = randomDeathSound[2];
            AudioManager.loadStaticSe(sound);
            AudioManager.playStaticSe(sound);
        }   
    };

My thought is to add some kind of simple temporary switch that turns on when the function is played, and then I just add a check to the "if" statement to make sure it's off. The problem is I have no clue how to make a variable tethered to the target being called because I'm a 3/100 level Javascripter lol. There also seems to be added issues because this function works on both actors and enemies, because the clumsy things I've tried make it so actors get the switch permanently turned on so they can only die once ever.
You'd normally use either a death break or immortal: targets, true until the last hit of your action sequence to avoid the enemy "collapsing" multiple times.
@SGHarlekin So I fiddled with action sequences and this doesn't seem to be the culprit. But it got me thinking about extra collapses somewhere. I rediscovered I had a "collapse" command in some passive states that control some stuff that triggers on death. I don't remember why I put those in there, but taking them out seems to get rid of the double death sounds.

Here's hoping I don't find out why I put those in there later down the road lol
than add a condition if it does NOT have the passive state, if it does, return,
so it does nothing (as sanity check).

but there are better ways probably.

Original thread: https://forums.rpgmakerweb.com/threads/want-to-limit-mr-trivel-deathsounds-to-play-only-once-per-collapse.178025/