MV Create custom damage fomula with Yep damage core

Hello, i used yanfly damage core for create my damage fomula, but....... it's wrong.

There is my code( i don't know javascript):

<damage fomula>
Value = a.atk - b.def;
If ( user.isStateAffected(31)) {
Value += b.def; };
If ((actorId = 8) & (target.isStateAffectedDeath))
{ user.gainHp(user.mhp * 0.15) };

</damage formula>

That's all. ( my english is bad, sorry)
What do you mean 'it's wrong'? Please tell us what the result is you aimed for and the result you got instead. We can neither look into your head, nor your computer, so such a vague error description is generally really unhelpfull.

That said, I can spot some problems with your code right away.
Javascript is case sensitive, meaning value IS NOT equal to Value.
Comparisons are ==, not =, meaning in your if (actorId... you are setting a variable called actorId to 8, not comparing it to it. Likewise it's &&, not &.
On that topic, what even is actorId? Is it an actual global variable, you or some plugin you use declared? Or do you actually want to access the user's actor id? That would be user.actorId. Also make sure to check whether the user is actually an actor with user.isActor, if there is the possibility that a monster will use that skill.
The function to check wether a battler is affected by the death state is actually called isDeathStateAffected.
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.
What do you mean 'it's wrong'? Please tell us what the result is you aimed for and the result you got instead. We can neither look into your head, nor your computer, so such a vague error description is generally really unhelpfull.

That said, I can spot some problems with your code right away.
Javascript is case sensitive, meaning value IS NOT equal to Value.
Comparisons are ==, not =, meaning in your if (actorId... you are setting a variable called actorId to 8, not comparing it to it. Likewise it's &&, not &.
On that topic, what even is actorId? Is it an actual global variable, you or some plugin you use declared? Or do you actually want to access the user's actor id? That would be user.actorId. Also make sure to check whether the user is actually an actor with user.isActor, if there is the possibility that a monster will use that skill.
The function to check wether a battler is affected by the death state is actually called isDeathStateAffected.
Thanks you very much
i don't used dame core so I don't know

Original thread: https://forums.rpgmakerweb.com/threads/create-custom-damage-fomula-with-yep-damage-core.148561/