MZ Counterattack -> AoE attacks

Hi,

I have been trying to get a Counterattack state on a character that counters enemies with a AOE basic attack.
But for some reason it's only attacking with a single enemy per counterattack.

Even if I use a friends plugin for it.
Any idea what might cause it or if there is a way to solve it?

/*:
* @target MZ
* @plugindesc Enables counterattacks with a specified skill hitting all enemies.
*
* @command ApplyCounterattack
* @text Apply Counterattack
* @desc Apply counterattack with a specific skill to all enemies.
*
* @arg user
* @text Actor ID
* @desc The ID of the actor performing the counterattack.
* @type actor
*
* @arg skill
* @text Skill ID
* @desc The ID of the skill to be used for the counterattack.
* @type skill
*
* @Help CounterattackAllPlugin.js
*
*
* Plugin Command:
* ApplyCounterattack user: actorId skill: skillId
* - user: The ID of the actor performing the counterattack.
* - skill: The ID of the skill used for the counterattack.
*
*/

(function() {
// Register the plugin command
PluginManager.registerCommand('CounterattackAllPlugin', 'ApplyCounterattack', function(args) {
// Get the user and target
const user = $gameActors.actor(args.user);
const targets = $gameTroop.aliveMembers();

// Apply the counterattack skill to all enemies
targets.forEach(function(target) {
user.useSkill(args.skill, target._index);
});
});
})();
This just all looks very strange.

There's stuff in the execution of a skill that takes time, I can't imagine just sticking it in an iteration of an array would resolve properly. And why would one try to do it that way instead of making an actual skill that targeted all enemies?

How are you calling a plugin command after an actor gets hit? And why wouldn't you use an existing plugin to put the code you need directly into that window?

Is your friend a person who knows RPG Maker and how to write code, or is this AI generated?
This just all looks very strange.

There's stuff in the execution of a skill that takes time, I can't imagine just sticking it in an iteration of an array would resolve properly. And why would one try to do it that way instead of making an actual skill that targeted all enemies?

How are you calling a plugin command after an actor gets hit? And why wouldn't you use an existing plugin to put the code you need directly into that window?

Is your friend a person who knows RPG Maker and how to write code, or is this AI generated?
The idea of the character is that she can mass AoE enemies.
As she use skill x she gains taunt and reflect attacks, so I want to keep it in theme and have her AoE with every attack.

Also for the friend he does have skill in JS but honestly this looks like AI generated.
A better approach would be to make a copy of the Attack skill that has the Scope of All Enemies.

I'm not sure from your description whether the actor should always hit all enemies, or just during counters. If it's always, just set a Trait for Attack Skill to be your all enemies version, and that will get used during counters as well as when attacking.

Otherwise, you just specify which skill the actor uses when they counter using a plugin, such as:

Looking at that plugin, it seems oddly restricted to only looking at notetags on weapons. You can change that really easily by changing the counterSkillId() method. So delete lines 23-32 and replace with this:
Code:
for (let i=0; i<this.traitObjects().length; i++)
{
    if (this.traitObjects()[i].meta.counterskill)
        return Number(this.traitObjects()[i].meta.counterskill);
}
return Game_BattlerBase.prototype.counterSkillId.apply(this);

That will let you use the counterskill notetag in a State.

Original thread: https://forums.rpgmakerweb.com/threads/counterattack-aoe-attacks.164167/