MV If then statements in damage formula (HimeWorks enemy levels)

@Tsukihime So I'm creating a skill that does physical damage to one foe but then has a special effect that if the user os a higher level than the target then the move inflicts instant death. Normally, enemies in MV don't have levels but with HimeWork's enemy levels plugin that can now be the case. Thing is I'm pretty sure I need to do an "If : then" statement in the damage formula. Something like "If: UserLevel > TargetLevel, Then: Inflict Death State)" How do I do this with Javascript, which may be difficult since I'm using a plugin for one of the variables since I don't really know how to code? Thanks!

Edit: Added an @ for HimeWorks so they see this.
Bump
I'm not entirely sure how that plugin is configured but as far as I remember, skills can have conditionals. You can also do something like "a.atk*4-b.def*2+(Math.max(a.level-b.level, 0) * 99999999)"

I'll break that down. "a.atk*4-b.def*2" pretty simple, its how the default skills are set up. 4 times that attackers attack - 2 times the defenders defense.

"(Math.max(a.level-b.level, 0))" This is some simple code. It will get the higher value of the two sides. One is attackers level - defenders level and the other is 0. This means if a.level - b.level is less than 0 because the attackers level is lower than the defenders level, that little bit of code will choose 0 as the max. If attackers level is higher, it will choose the deference between the attackers and defenders levels and then do the next part which is multiply by 99999999.

That means if the attackers level is the same or lower it will add 0 * 99999999 = 0 but if the attackers level is even 1 higher it will add 1 * 99999999 = 99999999 damage which I assume will oneshot anything.

The tricky part is since I don't use that plugin I don't know how they set up level for enemies. It's possible b.level is not valid code. Might b._level or something totally different.

If you look through the plugin, it shouldn't be too tricky to figure out I hope. If you still have trouble, link the plugin and I'll figure out exactly what it should be.

EDIT: Ok I found a better way. "if (a.level > b.level) {b.addState(1)}; a.atk*4 - b.def*2;". I still don't know if b.level is the correct code without seeing the plugin though.
Thanks for the help. Here's the plugin link so you can figure out what formula works for the enemy's level as I can't read code and can't do it myself. 😐


Thanks!
Bump
Sorry for the delay, got health issues to deal with. Anyway the code taken from that plugin should mean my guess was correct so the formula you want to use is: "if (a.level > b.level) {b.addState(1)}; a.atk*4 - b.def*2;"

Replace a.atk*4 - b.def*2 with whatever you want the damage to actually be.
@RinTheWanderer Okay, got it. However, I have another skill which has a different requirement but involves the same overall formula. The requirement for that is if the target is weak to the earth element instead of if the user is a higher level than the target. Thanks!
I think it should be:
if (b.elementRate(6) > 1.0) {b.addState(1)}; a.atk*4 - b.def*2;

Again you can change the second part to whatever you want, thats just the default physical attack damage value. In the "b.elementRate(6)" 6 is the default ID for earth element. You can check which ID it is in types tab in case you've changed it. I haven't tested this but it should work.

Original thread: https://forums.rpgmakerweb.com/threads/if-then-statements-in-damage-formula-himeworks-enemy-levels.126161/