How do I apply states onto attacker?

An example is that I want my attacker to gain a state in which after performing a spell, their next attack will grant them a special state such as bonus damage on their normal attack.
Without plugins, the only way I can think of is by adding in the damage formula of the skill:

JavaScript:
a.addState(STATE_ID);
// where STATE_ID is the id of the state to self-inflict.
What Jragyn put is absolutely correct and (in my opinion) the best way to do it. That goes in the Battle Formula previous to the damage with a semicolon (😉. In case you don't know, the STATE_ID is the number, but does not need the zeroes in front.
Note that by default the damage formula gets evaluated by the AI when deciding which skill to use. If this skill is not usable by enemies or autobattle actors then that's OK! Otherwise consider using a plugin instead, e.g. the <JS Pre-Apply> skill notetag offered by VisuStella Battle Core:
Code:
<JS Pre-Apply>
user.addState(123);
</JS Pre-Apply>
If the attack is specific to a character (an attack only that character has), you could probably also just add a common event to the skill adding that state to the character

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-apply-states-onto-attacker.135266/