Frogby Talent Core - skip dead party members

Hello everyone. I'm using Frogboy's Talent Core plugin (see here), which is amazing but has a slight problem: Whenever it selects the most talented party member for a talent check (say, to pick the lock of a chest), it neglects to also check whether that party member is still alive. Given that dead people tend to be bad at picking locks, I'd be grateful if someone with knowledge in JS could help me out there.

I have already identified the relevant piece of code -
Spoiler: Code section
/** Get the actor who has the best talent score
* @param {string} abbr - The abbreviation used to identify a talent (required)
* @returns {number} Returns the Id of the actor who has the best talent score
*/
FROG.Talents.getMostTalented = function (abbr) {
var bestScore = -1;
var actorId = 0;
for (var i=0, j=$gameParty._actors.length; i<j; i++) {
var actor = $gameActors._data[$gameParty._actors];
if (actor) {
score = FROG.Talents.getActorTalentScore(actor.actorId(), abbr);
if (score > bestScore) {
bestScore = score;
actorId = actor.actorId();
}
}
}
return actorId;
}

So it should simply be a matter of putting an AND and the relevant check somewhere, I'd assume. Unfortunately, my experience with other programming languages enables me to read JS, but that doesn't mean I can write it... so, anyone?
Try this. Haven't had the time to check it though.

JavaScript:
/** Get the actor who has the best talent score
* @param {string} abbr - The abbreviation used to identify a talent (required)
* @returns {number} Returns the Id of the actor who has the best talent score
*/
FROG.Talents.getMostTalented = function (abbr) {
  var bestScore = -1;
  var actorId = 0;
  for (var i = 0, j = $gameParty._actors.length; i<j; i++) {
    var actor = $gameActors._data[$gameParty._actors];
    if (actor && !actor.isDeathStateAffected()) {
      score = FROG.Talents.getActorTalentScore(actor.actorId(), abbr);
      if (score > bestScore) {
        bestScore = score;
        actorId = actor.actorId();
      }
    }
  }
  return actorId;
}
Praise be the mighty V_Aero, this was exactly what I envisioned and it works exactly like I'd hoped.

(i.e. Thread can be closed with an unpickable lock due to being solved.)
No need to praise me, that was just basic JS 😀

Original thread: https://forums.rpgmakerweb.com/threads/frogby-talent-core-skip-dead-party-members.121367/