MV Is there a way to make an attack go for a different target if one is dead?

I know it's kind of a confusing title, but I'm looking to see if something like this can be recreated in MV (not the actual system and timing stuff as I already got that down; just the bits where an enemy dies early before the attack fully finishes, and another enemy gets targeted for the rest of the attack when they do)

the youtube link is a clip showing what I'm looking for
Not an expert on MV action sequences, but maybe something like this, a conditional after action effect:

if (target.hp <= 0 && $gameTroop.aliveMembers().length > 0)
eval: BattleManager._targets.unshift($gameTroop.aliveMembers()[0])
move user: target, front base, 20
wait for movement
end
This doesn't seem to be working very well...
I know you say you're not an expert, but should I still show you my skill code?
Well, it would increase the chances of someone helping you above zero.
well here's my code

Code:
<target action>
motion thrust: user
wait for movement
move user: target, FRONT BASE, 20
wait for movement
motion walk: user
wait: 10
OPACITY user: 0, 0
animation 123: target
wait: 64
action effect: target
wait for animation
OPACITY user: 255, 2

start sequence input: ok, 1
wait for sequence input: 60

if $gameVariables.value(1) > 0
    animation 125: user, mirror
    wait for animation
    OPACITY user: 0, 0
    animation 123: target
    wait: 64
    action effect: target
    wait for animation
    OPACITY user: 255, 2
    move user: HOME, 15
    motion thrust: user
    wait: 19
else
   move user: HOME, 15
   motion thrust: user
   wait: 19
end
</target action>
I'm also not an expert on Action Sequences, only been trying them out lately, but I see that you're using the action effect command to do your skill's damage. I assume your skill does damage multiple times (otherwise, there's no reason to do what you're trying to do) and I'm not sure if it's possible to check if the target is dead while the action effect command is going off. How I've handled this in my sequences is that I use Eval commands to deal my skill's damage and resolve its effects, and in between instances of damage, I can check if the enemy is dead and if it is, get a new random target for the rest of the sequence to go on.

There would be different ways of doing that depending on how your skill is supposed to work, but here's how I made it work for mine.
Spoiler: Action
Code:
<setup action>



clear battle log



Eval: user.lockOn = target

action animation: target

wait for animation



</setup action>




<target action>

Eval: user.group1 = $gameTroop.aliveMembers()




if user.orbs.length > 2 && user.orbs[2].type == "plasma" && user.group1.includes(user.lockOn)

    Eval: user.lockOn.startAnimation(152)
    Eval: user.lockOn.gainHp(-8)
    Eval: user.lockOn.startDamagePopup()
    wait: 20
    Eval: user.orbs[2].duration = user.orbs[2].duration -1
    Eval:   if ($gameActors.actor(2).orbs.length > 2 && $gameActors.actor(2).orbs[2].duration == 0) {$gameActors.actor(2).orbs.splice(2,1);}



else if user.orbs.length > 2 && user.orbs[2].type == "plasma" && !user.group1.includes(user.lockOn)

    Eval: user.targeted = user.group1[Math.floor(Math.random() * user.group1.length)]
    Eval: user.targeted.startAnimation(152);
        Eval: user.targeted.gainHp(-8)
    Eval: user.targeted.startDamagePopup()
    wait: 20
    Eval: user.orbs[2].duration = user.orbs[2].duration -1
    Eval:   if ($gameActors.actor(2).orbs.length > 2 && $gameActors.actor(2).orbs[2].duration == 0) {$gameActors.actor(2).orbs.splice(2,1);}

end
.
.
.

You can ignore most of the weird stuff in there as they pertain to my specific skill, but what I basically do is I save the skill's target, check the alive members of the enemy troop before each instance of damage, see if my target is still in there (they won't be if they're dead), and if they are, deal damage to that target and if they're not, then choose a random target from amongst the remaining members of the enemy troop.

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-make-an-attack-go-for-a-different-target-if-one-is-dead.179239/