Debuff issue in formula

So, in my game, I have a Reshiram as a party member and at some point, she learns Draco Meteor in the story.

Now in Pokémon, Draco Meteor attacks all enemies, and reduces the user's special attack.

The closest thing to special attack in RPG Maker VX Ace is Magic Attack, which Draco Meteor uses.

So, I want Reshiram's magic attack to be reduced whenever she used Draco Meteor.

I have Draco Meteor's formula set up as:

a.add_debuff(4, 10); 130 + a.mat * 4.7 - b.mdf


To add the debuff to Reshiram when she uses Draco Meteor.

However, if I have Reshiram use Draco Meteor when there are multiple enemies, the debuff stack multiplies per enemy.

Is there a way to make it only apply one magic attack debuff per use rather than per enemy?

I want debuffs to stack each time Reshiram uses it, not for each enemy on the board.
Ruby:
(your formula here) / $game_troop.members.size
That just splits the damage across all enemies and still creates multiple debuff stacks
Could it work if you put the debuff addition in a common event linked to the skill? In that case it would probably only run once. Since from what you write, this skill is only usable by one character, it shouldn't be a problem to event, I think.
You'd need to keep track of how many enemies have been hit by the skill. I can think off 2 ways to do that: use a flag (a boolean value like true) to indicate that it's been cast or use a variable to store the actual number of enemies hit. If it exceeds the one enemy limit, don't apply the debuff.

Taking a look at the default Game_Battler class script, I guess you'd need to use a wrapper method instead of directly calling add_debuff... Try this:

EDIT: Fixed Line 3

Ruby:
class Game_Battler
  def add_debuff_once(param_id, turns)
    return if @result.added_debuffs.include?(param_id)
    add_debuff(param_id, turns)
  end
end

Ruby:
a.add_debuff_once(4, 10)

That will work IF the list of added_debuffs gets cleared after every turn as expected.

Original thread: https://forums.rpgmakerweb.com/threads/debuff-issue-in-formula.180191/