How to alter enemy parameter in battle based on a variable?

I'm looking for a way to alter enemy parameters during combat, based on the value stored in a variable. To be more specific, I want to create a skill that, when used, lowers the enemy's Defence and Magic Defence until the end of battle, based on a variable's value that is accumulated through actions during an encounter. Example: say, the variable has a stored value of 10 during a battle. When the skill is used, it needs to lower the foe's Defence and Magic Defence by 10 points.

The only things that come relatively close to what I'm looking for are:
  • "Grow" under skill effects, however, it can only make parameters go up, not down (I think?)
  • States that alter parameters, however, these are in percentages, and can't be tied to variables.
  • The only enemy stats that can be altered through a regular event command are the enemy's HP and MP, but nothing for any of the other parameters.

How can I make this work?
I did something similar based on the number of chickens kicked while playing through the game... Yeah, Zelda left a mark 😉 Anyway here is how I handled it:

Under "troops" I added a "round one" script call that does the following,
Code:
hpbump = $gameVariables.value(10) * 100

atkbump = $gameVariables.value(10)

$gameTroop.members()[0].addParam(0, hpbump)

$gameTroop.members()[0].addParam(2, atkbump)

$gameTroop.members()[0].addParam(3, atkbump)

$gameTroop.members()[0].addParam(5, atkbump)

I think you could manipulate this in a skill to reduce parameters. ( I reused ATKBump and HPBump based on the scale I was wanting to adjust the number by. So, kick 1 chicken the mob gets +100 hitpoint and only +1 ATK. I think the other two I add to is mana and def )

Since this is under troops in the database, it's kind of easy. It's also one monster. While I'm really not sure of the next part, I would start by deciding between "how to use a common event to get the $gameTrooop.members()" or would it be easier and faster to "only have certain troops susceptible to the effect" and having the script calls only on those troop sets.

( edit: obviously, you'de want to make those numbers turn negative before using addParam() in your case since it will be a debuff. )

Take it with a grain of salt though, I'm still a bit of a newbie.
😔
Can these parameters be restored after the battle?
I don't think enemies exist after battle anyway. So whichever modifications you did in one battle to the enemies won't show in the next battle. You get fresh patch.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-alter-enemy-parameter-in-battle-based-on-a-variable.94280/