Yanfly's Damage Core help...

NinjaKittyProductions

Professional Murder Hobos
Veteran
Joined
Jul 9, 2013
Messages
484
Reaction score
467
First Language
English
Primarily Uses
RMMV
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
Veteran
Joined
Mar 1, 2014
Messages
206
Reaction score
95
First Language
English
Primarily Uses
RMMV
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
Veteran
Joined
Jul 9, 2013
Messages
484
Reaction score
467
First Language
English
Primarily Uses
RMMV
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!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top