Yanfly's Damage Core help...

NinjaKittyProductions

Professional Murder Hobos
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 ^_^
<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>

Fornoreason1000

Black Sheep
Give this a go.
Im assuming Yanfly is using Eval here, so any javascript should work

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

NinjaKittyProductions

Professional Murder Hobos
Give this a go.
Im assuming Yanfly is using Eval here, so any javascript should work

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!

Latest Profile Posts

Been parallax mapping nigh all night.
2nd character based on the same random inputs
the coffee shop i go to for open mic every friday only has 2 more open mics left and then they're done :'( i'm gonna die!
Everytime someone says Intel "kabylake" I hear either baby lake or ladycake.
Either I just had one of those dreams where you think you're awake, or I have time traveled. I woke up at 6:58am this morning, heard my father leaving for work, laid back down, now its 1:16am.