Skill that attacks an enemy but then debuffs the user...

I have in mind a skill that when used, the player can attack an enemy but then debuffs the user as a side effect. I tried to attempt this myself...
upload_2019-2-19_17-26-52.png

...but doing so and using this skill in battle just triggers the custom HP damage and debuffs the enemy with the state "Atk Down"...
upload_2019-2-19_17-30-3.png

...when it's supposed to debuff the user, not the enemy. What am I doing wrong? Can this concept work in RPGMaker? Do I need a specific plugin? I'm not too sure how to attempt this further.
You can use statements in mv formulas.
a.addState(x); attack formula goes here

The above would add state x to the user.

Mr. Trivel has an awesome post about how to use the formula box. It can be found here: https://www.rpgmakercentral.com/topic/36290-damage-formulas-101-mv-edition/
Wow. I wasn't aware the formula box held so much power, thanks!
Another way to do this would be to have the skill trigger a common event that then applies a state to an actor.
As mentioned, the damage formula is essentially an eval() of a bit of javascript code - it's like the "script call" event command in this respect.
As such, you can call functions in your own (or any) plugin from it.

There are battle system plugins like Yanfly's skill core which give you lots of other hooks to run some javascript as well as the damage calculation.
(some common things can be done with it using just database notes, but the flexibility is nice)
You can use statements in mv formulas.
a.addState(x); attack formula goes here

The above would add state x to the user.

Mr. Trivel has an awesome post about how to use the formula box. It can be found here: https://www.rpgmakercentral.com/topic/36290-damage-formulas-101-mv-edition/

Okay, this is pretty good, but what about triggering the effect AFTER the attack happens?
if you give the skill a common event as an effect, that common event will be executed at turn end by default.

by default no other timing is possible, only either at skill execution or turn end.
You'll need plugins like for example action sequences or different battlesystems for other timings.

Original thread: https://forums.rpgmakerweb.com/threads/skill-that-attacks-an-enemy-but-then-debuffs-the-user.105856/