Yanfly's Damage Core help...

Hey gamers,
I am currently working on a project and am using yanfly's damage core. I have a damage formula notetag that works for what I need it to do except it looks really ugly and since I am still new to programming, I am having a hard time condensing it down. Any help in making this code more condensed would be greatly appreciated ^_^
Spoiler: Notetag
<damage formula>
if (b.def <= (Math.randomInt(20) + 1 + a.atk))
{
If(a.level < 4)
{
value = Math.randomInt(6) + 1;
}
if (a.level >= 4 && a.level <8)
{
value = Math.randomInt(6) + Math.randomInt(6) + 2;
}
if (a.level >= 8)
{
value = Math.randomInt(6) + Math.randomInt(6) + Math.randomInt(6) + 3;
}
}
</damage formula>
Give this a go.
Im assuming Yanfly is using Eval here, so any javascript should work

Spoiler: Notetag
Code:
<damage formula>
if (b.def <= (Math.randomInt(20) + 1 + a.atk)) {
    var c  = 0;
    while (c < a.level && c < 9) {
        value += Math.randomInt(6) + 1
        c += 4;
    }
}
</damage formula>

Notice how I've indented some lines each time i go deeper in a condition/iterator and where ive put my curly braces "{" and "}"?

makes code look alot better. I used a while loop, but a for loop would probably have been better.

Gud Luk 🙂
Give this a go.
Im assuming Yanfly is using Eval here, so any javascript should work

Spoiler: Notetag
Code:
<damage formula>
if (b.def <= (Math.randomInt(20) + 1 + a.atk)) {
    var c  = 0;
    while (c < a.level && c < 9) {
        value += Math.randomInt(6) + 1
        c += 4;
    }
}
</damage formula>

Notice how I've indented some lines each time i go deeper in a condition/iterator and where ive put my curly braces "{" and "}"?

makes code look alot better. I used a while loop, but a for loop would probably have been better.

Gud Luk 🙂

This worked out perfectly! Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-damage-core-help.103034/