Instnatly kill all non-boss enemies

I'm trying to make a skill that instantly kills all enemies except bosses. The only way I can really figure out how to get it to work would be to inflict the knockout state, but I can't make it not work on bosses unless I make them immune to Knockout. How could I do this?
Inflict a state that will inflict the knockout state?
Give the boss state rate 0% to KO. This will make the state fail but they will still be able to be KO'd normally. See, as long as you don't give them state resist, it will still work, as the way it applies the state KO ignores the state rate variable.
@Peva
Make the skill run a common event. Put that code into a scriptcall command.
PHP:
var arr = $gameTroop.aliveMembers();
for (var i = 0, length = arr.length; i < length; i++) {
    var enemy = arr[i];
    if (!enemy.enemy().meta.Boss) {
        enemy.gainHp(-1000000);
        enemy.performCollapse();
    }
}
Give all enemies in the database, that are bosses, a <Boss> notetag. Make sure to have the notetag exactly like that. The code will kill off every enemy that has not the <Boss> notetag.
@Peva
Make the skill run a common event. Put that code into a scriptcall command.
PHP:
var arr = $gameTroop.aliveMembers();
for (var i = 0, length = arr.length; i < length; i++) {
    var enemy = arr[i];
    if (!enemy.enemy().meta.Boss) {
        enemy.gainHp(-1000000);
        enemy.performCollapse();
    }
}
Give all enemies in the database, that are bosses, a <Boss> notetag. Make sure to have the notetag exactly like that. The code will kill off every enemy that has not the <Boss> notetag.

Okay, so this works except it first says that it has no effect, then it kills the enemy.
@Peva
Yeah, that's because per default the battle log window will only look at the item effects and depending on what effect it is, it will display a text on the battle log. Because the item has no other effect then the common event, the battle log window will display it has no effect.

To solve this issue, paste this code into a new .js file and import it as a plugin.
PHP:
Game_Action.prototype.itemEffectCommonEvent = function(target, effect) {
    if (target) this.makeSuccess(target);
};
This will remove the "no effect" message on the battle log. When there's only a common event as effect.

To display a custom message, just add another scriptcall to the common event. Add this code into a scriptcall before the other scriptcall that kills the enemies.
PHP:
var logWindow = SceneManager._scene._logWindow;
var text = "BOOOOOM!! Kill all enemies!";
if (logWindow) {
    logWindow.push('pushBaseLine');
    logWindow.push('addText', text);
    logWindow.push('waitForNewLine');
    logWindow.push('popBaseLine');
}
To change the text, that will displayed, just change the text variable. Make sure to only put the text between the "".
Works great! Thanks again Waynee!
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/instnatly-kill-all-non-boss-enemies.83323/