How can I calculate a variable and attack with said variable

I want to use variable calculations to attack.

So say in the battle you click the attack button, well i want this to happen.
This here is what my common event looks like:

Set Variable Attack Random [1-20]
Text: "Your attack is [Attack Variable]"
Set variable Enemy Defense Random [1-20]
Text: "Your opponent's defense is [Enemy Defense Variable]"

Set Variable Attack[Var] - Defense[Var]
Set Variable Attack[Var] + Attack[Stat]

Then do the attack.
I know by putting the commo event in effects it'll go after the attack but I don't want that. I want it before, it's there anyways to do this?
text aside, this can be done in damage formula.
(Math.randomInt(20)+1 + a.atk) - (Math.randomInt(20)+1)

without the +1 the randoms would actually be doing 0-19
if you want the text to be displayed during skill use, then this is impossible by default.

you'll need a plugin to add that function, either a custom one or one that provides action sequences where you can program what will happen during skill use

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-calculate-a-variable-and-attack-with-said-variable.128197/