How to make "Cleave"??

Alright my darlings, another question for you all: I am trying to figure out a "Cleave" ability for my warrior character. 


The idea is an attack that, if it kills an enemy, the remaining damage is dealt to another enemy.


Yanfly showcased No Kill Like Overkill (from Borderlands 2), which is similar, but not exactly what I'm looking for.


Example: An attack deals 10 damage to a 7 HP gobbo, kills it, and then deals that leftover 3 damage to another of his gobbo chums.


Yanfly Engine in use, so scripting in the Battle Core and all that is up for grabs!


Love ya
You could go to his Patreon page and pledge $3 so you can make a request for a tip. He or someone else that tends to help out there and has had several tips requested (I don't know if he's on this site) will be able to help you.
Here you go, enjoy.  Needs at least Yanfly's battle engine core, and may need skill core as well.  I have not tested the requirements.


EDIT:  Fixed bug when used on a single target

Spoiler
<Pre-Damage Eval>
target._currentHp = target.hp;
</Pre-Damage Eval>


<Post-Damage Eval>
if (target._currentHp && target.hp <= 0) {
   var dmg = target.result().hpDamage - target._currentHp;
  if (dmg > 0) {
        var members = this.opponentsUnit().aliveMembers();
        members.splice(members.indexOf(target), 1);
        var extraTargets = 1;
        while (extraTargets--) {
           var member = members[Math.floor(Math.random() * members.length)];
           if (member) {
           member.gainHp(-dmg);
           member.startDamagePopup();
           member.clearResult();
           if (member.isDead()) {
           member.performCollapse();
           }
        }
    }
}
}
</Post-Damage Eval>

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-cleave.73672/