okay, by reading that I assume you are trying to make a skill that deals an amount of damage yadayadayada. But when the attack is affected by state 31 it is supposed to skip armor, right?
The second part then is that when a certain character lands the finishing blow with it, they restore 15% of their max health.
So, the last part is not something you'd want to implement into the damage formula so I'll skip that one. But for the armor piercing part, you can do this:
if (a.isStateAffected(31)) { a.atk } else {a.atk - b.def }
Edit: allow me to explain a few of the basics about how the damage formula works. Essentially, what the game does, is it takes the formula (as a string), uses eval() on it and puts the result of eval() into a variable. As such, the last "thing you mention in the formula" will be the returned damage value. This means that you don't have to actually set a variable for this.
All you need to do is to make sure, that the last statement in the formula is either the formula itself or a variable that you put the formula into before. (an example for the latter would be
Code:
var dmg = 2*a.atk; [...] //lots of stuff [...]; dmg
oh and , ALWAYS declare new variables before using them (with either var or let). Because javascipt doesn't actually mind if you don't do that but it will then make the variable a global variable which has .... very unpleasant side effects.
Edit 2: okay, I missed the "damage core part" because I don't use that plugin myself. Okay, in that case you might have to write "value = a.atk" instead of "a.atk" (same with the second formula) and "user/target" instead of "a/b" (don't remember if a/b work with that plugin) - but everything else should(?) still work.