if crit and hit, then play animation (x), and, add state (x) within the damage formula

I've done quite a bit of googling and re-thinking and more googling, and I'm sure given enough time I could figure this out without just asking, but I'm on a time and energy budget, so I'm asking.
If this requires a plugin, just let me know. (I know that there are ways to accomplish this from within a plugin, but the ways I've looked at I don't think would fully accomplish what I'm hoping to do)

The idea, is that when a crit occurs, a state is applied, and animation played. I was able to find a thread where someone got an animation to play from within the damage formula, but when testing it using the following code,
it didn't work. (I figured I'd test just having it play the animation before I moved on to the if statement part of it)

b.startAnimation27 a.atk - b.def or b.startAnimation(27) a.atk - b.def or (b.startAnimation(27)) a.atk - b.def

It's very important that the animation play at the moment the damage is dealt to line up with the crit, so having it play as a separate thing after the fact is likely less than ideal. (for clarity reasons). The animation is essentially a little pop-up that says the state was applied. Short words like BURN! BLEED! ect.

I have some ideas in how I could event something like this, but it would require two of every skill, and a bunch of other stuff, and I'd much rather keep the database more compact and organized, so if I can do all of this with one skill, that's what I'm hoping for.

Thankyou for your time, you guys are always really helpful. I want you to know your work here is greatly appreciated. ^.^
Those are all syntax errors because you haven't got a semi-colon to end the first statement. By default an error in the damage formula will return a result of 0.

You could try something like this instead (untested):
JavaScript:
if (b.result().critical) { b.startAnimation(27); b.addState(123); }; a.atk - b.def
Edit: added b.addState(123) (replace 123 with the ID of the state).
Works perfectly, thankyou so much! ^.^

Minor question though, I won't be surprised if this isn't possible, but can I put this equation after the main damage formula, instead of before it? It'd make my workflow for changing the damage formula much easier, since this script will be run for all damage dealing skills. (I basically have a bonus effect crit system with minor debuffs)
Those are all syntax errors because you haven't got a semi-colon to end the first statement. By default an error in the damage formula will return a result of 0.

You could try something like this instead (untested):
JavaScript:
if (b.result().critical) { b.startAnimation(27); b.addState(123); }; a.atk - b.def
Edit: added b.addState(123) (replace 123 with the ID of the state).
can I put this equation after the main damage formula, instead of before it?
No. The last thing in your damage formula must be the amount of damage dealt. You might want to read through this:

It'd make my workflow for changing the damage formula much easier
Seems like it should be pretty easy? Copy the script, click into the damage formula, press left or Home to go to the beginning, paste. That's the same number of keystrokes as pasting it at the end 😉

You could also use a plugin like Yanfly's Damage Core to insert this code as a step in the damage execution instead of putting it into the formula at all.
Thankyou. My workflow concern was actually regarding changing the main damage formula after I've added the crit code, for balancing and tweaking and such.

I wound up using Damage Core with this code for the Damage formula. It does exactly what I want, in a layout that's much easier to read and tweak. ^.^

<damage formula> if (b.result().critical) { b.startAnimation(29); b.addState(6); }; value = a.mat * 2 - b.def; </damage formula>

Everythings working exactly the way I wanted, thankyou, both of you ^.^
No. The last thing in your damage formula must be the amount of damage dealt. You might want to read through this:


Seems like it should be pretty easy? Copy the script, click into the damage formula, press left or Home to go to the beginning, paste. That's the same number of keystrokes as pasting it at the end 😉

You could also use a plugin like Yanfly's Damage Core to insert this code as a step in the damage execution instead of putting it into the formula at all.

Original thread: https://forums.rpgmakerweb.com/threads/if-crit-and-hit-then-play-animation-x-and-add-state-x-within-the-damage-formula.163664/