Help with complex damage formula.

Okay, I've spent the last few days designing what I think is the perfect damage formula, that does everything I want it to do.

Unfortunately, I think it might be too complex for rpgmaker's editor.

The tricky bit is this; I want to roll an imaginary dice for the attacker's weapon power a number of times equal to the relevant attack stat, so if a character with strength 4 is using an axe with weapon power 10, the damage generation would look like 4d10. I know how to do random numbers in the damage box. What I don't know is how to tell the damage box to add a variable number of random numbers together. I tried to make a For...Next loop in the damage box and that didn't work.

I plan to have the target's defense process the same way, rolling [DefenseAttribute]d[ProtectionRating], and there's a couple other multipliers in there for elements and troop types, and some fudge factor multipliers to put the numbers in the right range. The complete formula is a Rube Goldberg nightmare...but it does exactly what I want it to do.

I could just admit defeat and do 4(Math.randomInt(10) +1)...but that's not the same thing, and it's not as neat and elegant with the statistical spread. Or I could just cut out the middle man and make myself a plug-in that'll do whatever crazy formulas I want, but that's a lot of work.
Welcome! It always makes the most sense to post the code that you tried to use. That way if it's a simple error someone can correct it for you, and we won't waste posts with suggestions you may already have tried.

I tried to make a For...Next loop in the damage box and that didn't work.
JavaScript doesn't have For...Next, so it sounds like you had some incorrect syntax.

The tricky bit is this; I want to roll an imaginary dice for the attacker's weapon power a number of times equal to the relevant attack stat, so if a character with strength 4 is using an axe with weapon power 10, the damage generation would look like 4d10. I know how to do random numbers in the damage box. What I don't know is how to tell the damage box to add a variable number of random numbers together.
There are a number of threads you might find on how to implement D&D mechanics, but I'll just plop this here for you:
Code:
let dam=0; for (let i=0; i<a.atk; i++) dam+=Math.randomInt(a.weapons()[0].atk)+1; dam

I'm presuming that when you reference "strength" and "power" you're referring to ATK (as RPG Maker doesn't have any such things as strength or power). If you mean some other parameters, you'll have to change that formula accordingly.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-complex-damage-formula.154606/