# RMMV Damage Formula - ideas and help

#### RayStinger

##### Warper
I'm a math teacher and I wanted to know what kind of math operations I can do on the damage formulas. I don't know what kind of operations I'll need yet, but knowing what I can do beforehand is important to me. Can I do any the following operations on RPG Maker MV?
• Raising a number to a power (for example a.atk^2 or b.def^3)
• Square roots and other radicals (cube root, fourth root and so on)
• Exponentials (including base e)
• Logarithms (both log10 and natural logarithm)
• Modulo operations (remainder from a division, for example, modulo(25,7)=4)
• Trigonometric functions (I would also need to know how to represent pi)
• Logic operations (and, or, xor, not, nand, nor, xnor)
• Factorials and choose functions
• Absolute values
• Creating pre-defined functions (for example, let's say I create a function f(x)=2*x-1, can I use this function on the damage formula, like f(a.atk)?)
If you know how to use any of these operations (or if you know if any of these are impossible on RPG Maker MV), I'd appreciate a lot. Btw, I can help others with math operations, just ask.

Last edited:

#### Sednaiur

##### Villager
Hello. I recently got my copy of RPGMMV and right now, I am setting up my first skills and getting my first experience for the damage formula-feature.

But now to my problem:
I'd like to make a skill, which pretty much works like the "1000 Needles"-skill from several Final Fantasy-games, which have a fixed damage of 1000 , no matter the DEF of the target.
Now, as far as I have understood, a simple "600" without anything else like "b.def" as a formula for direct 600 damage should suffice (for healing-effects it does), but for some unknown reason, even without anything else written in the formula, the damage is still not 600 (or 599, as there seems to be a slight offset in RPGMMV) but a damage dependent on the actor hit, which varies from around 560 to 590.

I use a lot of YanFly's plugins, but as far as I know, they do not change the basic behavior of the damage formulae, unless I change that in the plugins myself (which I haven't). Additionally, I use no notetags other than a notetag that makes the skill an "Enemy Skill". Also, even if I switch off YEP_BaseParamControl, YEP_ClassBaseParam and the like, my problem still persists.

So my simple question is:
How do I make a fixed damage of 600 points in RPGMMV?

#### Kes

##### Veteran
@Sednaiur Just checking - have you set the Variance to zero? If it's not, then there will always be a difference.

#### Sednaiur

##### Villager
@Sednaiur Just checking - have you set the Variance to zero? If it's not, then there will always be a difference.
Forgot to mention that, sorry. Yes, the difference is 0%.
Edit:
Here is a screenshot of the settings for the skill in question

Last edited:

#### Sednaiur

##### Villager
I have fixed the issue by myself, using YanFly's ArmorScaling-plugin by applying the <Bypass Armor Scaling> notetag.
So, for some reason, RPGMakerMV still calculates the armor of the target for some skills, no matter if you put that in the formula, or not, unless I am missing something, that is.

Additionaly, one could also fix the problem, by using YanFly's DamageCore and put the notetag <Damage Cap: x>.

#### Hungry Moogle

##### A Rat in the Wall
I'm fairly certain I've previously asked this before in the past, but I thought I'd ask about how to create a damage formula that starts with smaller numbers like 20-30 damage and eventually moves up to 4000-6000 damage by the endgame and up to 10000-20000 when the Attack stat maxes out at 999. Unfortunately, math has never been my strong suit and my past attempts at trying to create a damage formula haven't gone as I'd like and I have not had much luck in trying to find damage formulas from other games to use as a references. Most damage formulas from other games I've found online are either no good for what I'm trying to accomplish like the Final Fantasy games or the information is simply unavailable.

One major factor that needs to be taken into consideration is that I'd much prefer a formula that uses Attack ÷ Defense rather than Attack - Defense. The reason for this, is because I want to be able use Debuff & Buffing statuses like Attack +50% or Defense -50% to make combat more strategic, and based on my past experiences Attack - Defense doesn't work too well for balanced gameplay. For example: an attack power of 500 - a defense of 250, with the target's attack power multiplied by 0.5 results in the target's attack power dropping all the way to 0, which I personally find to be completely ridiculous. Whereas up to this point, I've been using this formula instead:

a.atk * (100/(100 + b.def))

This formula has worked out a lot better, as in my playtesting experiences it has produced much more balanced results when it comes to lowering/increasing stats with Debuffing/Buffing status effects. However, I'm not satisfied with the extremely low damage numbers I've been working with up to this point & and I don't want to have to increase the maximum value of the Attack stat to something ludicrously high like 9999 or worse 99999, since I want damage values to reach into the 5-digits (although not too high into the 5-digit damage values, more along the lines of the 10000-20000 figure I mentioned earlier).

While searching for potential damage formulas on Google, I came across this:

https://www.rpgmakercentral.com/top...ulation-and-leveling-more-like-final-fantasy/

It contains a suggestion for a formula that would allow for a smaller damage numbers at lower Attack values, but would scale upwards to around 9999 with a Attack power of 200.

(a.atk / 2)(a.atk / 2) - (b.def / 3)(b.def / 3)

This a lot closer to what I've been looking for, but there is a couple of issues. Firstly, the formula requires using extremely low Attack values to keep the amount of damage from increasing to ridiculously high levels. This in turn means that I would either have to limit playable character's Attack stat growth to extremely low numbers or give weapons extremely low numbers instead. The other problem is that the formula uses the aforementioned Attack - Defense formula that I am not a fan of.

The damage formula used in the Pokemon games, which is one of the few games I've been able to find the damage formula for, contains many of the qualities that I'm looking for in regards to gameplay balance...

Pokemon damage formula:

...but alas, the damage values produced by this formula are too low. It is also includes the attacker's Level into the equation, whereas enemies in RPG Maker do not have levels, although I was wondering if you could use Yanfly's Enemy Levels plugin to give enemy's levels that the formula could utilize.

I also not sure on how Defense should be incorporated into the formula as I would like Defense to be extremely important, but I don't want it to be too overpowered. For example, when Defense is maxed out at 999, the final boss should be still be able to do some damage rather than having all their attacks do 1 damage, rather an attack that does around 10000 damage should probably do around 500-1000 damage to a character whose Defense is maxed out at 999.

I hope that what I'm looking for isn't asking too much and that someone with a much better understanding of the principles of math can help me out with this matter.

#### D.L. Yomegami

##### Sanely Insane
An exceedingly simple formula that might work as a starting point is a.atk * a.atk / b.def.

It's a formula I've played around with in the past, as I was looking for a formula that operated on "Double attack = double damage; double defense = halved damage," which this formula does. Granted, I was using it for a game with smaller damage numbers (damage was capped at 999), but it looks like it might work well for larger numbers as well (albeit not five digit values; 999 attack was giving me somewhere around 1000-3000 for similar defense values). Besides the fact you'll probably need to play around with it, there's also the fact that it doesn't work so well for defense-ignoring attacks if you're planning on using those sorts of attacks and want them to be stronger than attacks that account for defense.

As someone who isn't particularly mathematically inclined myself, one thing I find that helps me with figuring these things out is a graphing calculator; Desmos is a nice online one as it lets you input an adjustable slider into formulas, so that you can visually see what damage curves might look like.

Edit: For what it's worth, Yanfly's Enemy Levels does allow enemies to make use of level in damage formulas. Tried it out in the past.

#### Hungry Moogle

##### A Rat in the Wall
An exceedingly simple formula that might work as a starting point is a.atk * a.atk / b.def.

It's a formula I've played around with in the past, as I was looking for a formula that operated on "Double attack = double damage; double defense = halved damage," which this formula does. Granted, I was using it for a game with smaller damage numbers (damage was capped at 999), but it looks like it might work well for larger numbers as well (albeit not five digit values; 999 attack was giving me somewhere around 1000-3000 for similar defense values). Besides the fact you'll probably need to play around with it, there's also the fact that it doesn't work so well for defense-ignoring attacks if you're planning on using those sorts of attacks and want them to be stronger than attacks that account for defense.

As someone who isn't particularly mathematically inclined myself, one thing I find that helps me with figuring these things out is a graphing calculator; Desmos is a nice online one as it lets you input an adjustable slider into formulas, so that you can visually see what damage curves might look like.

Edit: For what it's worth, Yanfly's Enemy Levels does allow enemies to make use of level in damage formulas. Tried it out in the past.
Thanks for the response! I appreciate your suggested damage formula but unfortunately, while it is a step in the right direction, there are some problems I have.

For example: an Attack of 999 versus a Defense of 6, results in 166333 damage, while a since a Defense of 200 causes the damage to drop to 4990. The swing from 166333 to 4990 seems rather ridiculous to me and I've found other issues as well in regards to how damage output grows. Alas, it appears that one needs the more elaborate algebra in order to regulate how damage grows in relation to stats, like in the Pokemon damage formula I posted, Attack is divided by Defense, but is it then multiplied by the Pokemon's level multiplied by 2, divided by 5 and then 2 added. After this, the equation is then by 50, and then 2 added. I absolutely have no idea how one figures out these kind of equations and while that Desmos link could be potential useful, the problem is that I've never used a graphing calculator in my life, and so I have absolutely no idea how to actually use the website.

As for the defense-ignoring attacks, I'm not concerned since I have no intent on using anything like that, with my preferences being toward using Debuffing status effects like Defense +50%/-50% instead. At one point, I did consider having a Freeze status effect that would reduce the affected character's Defense to 0, but I then decided to go with the Final Fantasy IX model instead, where a frozen character is instantly KO'd when attacked. That being said though, I have noticed something about using Attack ÷ Defense that worries me a little bit.

For example: 3108 damage, becomes 4662 under a theoretical Attack +50% buff and 1554 with a Attack -50% debuff, which is perfectly fine. When it comes to Defense though, the damage becomes 2072 with a Defense +50% buff, the amount of damage reduced seems a tad low to me, but whatever, the real issue, however, comes up when a Defense -50% debuff is applied and amount of damage doubles to 6216. Having the amount of damage double seems rather excessive to me, especially when compared to how the Attack modifiers behave.

I really wish I had better understanding of the math needed to make a damage formula work, I saw some interesting math-related courses on Udemy, perhaps should I check those out.

#### Aesica

##### undefined
I'm a math teacher and I wanted to know what kind of math operations I can do on the damage formulas. I don't know what kind of operations I'll need yet, but knowing what I can do beforehand is important to me. Can I do any the following operations on RPG Maker MV?
• Raising a number to a power (for example a.atk^2 or b.def^3)
• Square roots and other radicals (cube root, fourth root and so on)
• Exponentials (including base e)
• Logarithms (both log10 and natural logarithm)
• Modulo operations (remainder from a division, for example, modulo(25,7)=4)
• Trigonometric functions (I would also need to know how to represent pi)
• Logic operations (and, or, xor, not, nand, nor, xnor)
• Factorials and choose functions
• Absolute values
• Creating pre-defined functions (for example, let's say I create a function f(x)=2*x-1, can I use this function on the damage formula, like f(a.atk)?)
If you know how to use any of these operations (or if you know if any of these are impossible on RPG Maker MV), I'd appreciate a lot. Btw, I can help others with math operations, just ask.
You can do practically all of these using the JavaScript Math library:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math

Note that many of them are executed via function calls, such as Math.pow(a.atk, 2) rather than as standard expressions such as a.atk^2. Others use special operators:
• Modulo operations: 10 % 3 // result: 1
• Functions are a core feature of programming, however the syntax might take a bit to get used to if you're new to programming. For your sample function, the JS version would be: (function(x){ return 2*x-1; })(x) where the red x is the one you replace with the value you want to pass in.
• Operators, such as AND, OR, XOR, NOT, etc come in two flavors: Logical and Bitwise. Logical is used in conditional statements and ternary operations, where as Bitwise is computational.
• Logical ternary operation using AND: (b.hp / b.mhp < 0.5 && a.hp / a.mhp < 0.25) ? 9999 : 1 // result: 9999 if enemy hp is less than 50% and player hp is less than 25%, else a mere 1
• Bitwise operation: 12 & 6 // bitwise AND, result: 4
So yeah, hope this helps even if it's probably a bit late.

Edit: Several days later and I just realized my logical example didn't actually use AND, OR, etc~

Last edited:

#### KoshiLemons

##### Villager
Hey I need help with a skill.
I want an attack that does more damage based on how much hp the enemy has.
Like if they have a high base HP then it'll do a lot but if it's low then it'll be useless.

#### SwiftSign

##### Veteran
Just use b.hp in your attack formula .

#### Guanto

##### Auteur
Damage Formula weapon ATK sans base ATK?
------------------------------------------------------

Pouring through the various (seemingly copied) Damage Formula Box guides and couldn't actually find this.

What would the formula be for the attackers damage to come from the weapon being used alone, and not their base (or any other) ATK value (e.g. conceptually (for me) when using a non-magical missile weapon where physical strength is moot).

##### Chemical Engineer, Game Developer, Using BlinkBoy'
try a.weapons[0].atk

#### Aesica

##### undefined
try a.weapons[0].atk
That syntax will probably throw an error since weapons is a function rather than an array element. Thus, a.weapons() will return an array of all equipped weapons, but you'll either need to loop through them all (if more than one weapon can be equipped at a time) or choose which one to reference. Now if each character is only able to equip a single weapon, you could probably use a.weapons()[0].params[2] to reference its ATK value directly.

HOWEVER, note that this will probably explode in a gory mess of errors if invoked while the user doesn't have any weapons equipped. Same if invoked by enemies.

##### Chemical Engineer, Game Developer, Using BlinkBoy'
Oh right, in MV they changed a lot of the previous simply directly manipulable arrays into functions that returns those arrays.. Thanks for correcting it

And yeah, you need to put safeguards for cases that weapons dont exist (no equipped weapon or enemies)

#### Aesica

##### undefined
Honestly, you'd be better off making some sort of plugin with a function to loop through the weapon array, total up any dualwielded weapons, and return the result. That way, you could return 0 or 1 or whatever as a default if no weapons were equipped, or do whatever, such as utilizing note tags for enemies. Nothing would break, all would be well.

##### Chemical Engineer, Game Developer, Using BlinkBoy'
If it can fit in the damage box though, you can still just do it there. That guy actually prefers to avoid using plugins if possible.

and iirc, the formula box is run inside a catch block so that if there's an error it will simply return 0, which I actually hate coz it makes troubleshooting of damage formula hard

#### Aesica

##### undefined
If it can fit in the damage box though, you can still just do it there. That guy actually prefers to avoid using plugins if possible.

and iirc, the formula box is run inside a catch block so that if there's an error it will simply return 0, which I actually hate coz it makes troubleshooting of damage formula hard
It throws errors for me if I call something incorrectly, but that could be due to the various yanfly battle plugins I use. That said, it's a shame he/she doesn't want to use plugins because it severely limits how this can be done and opens the door to the problems I mentioned above. It's unfortunate because, well I thought about it for a bit and realized this might be something I'd use in a future project, so I went ahead and made a quick-and-dirty plugin for it:

Code:
/*
* @plugindesc Get Weapon Power
* @author Aesica
* @help For use in damage formula:  Aesica.Misc.getWeaponPower(actor, stat?)
* - actor: Typically a or b, thus:  Aesica.Misc.getWeaponPower(a)
* - stat?: Optional parameter id, defaults to ATK if left blank
*/
var Aesica = Aesica || {};
Aesica.Misc = Aesica.Misc || {};
(function()
{
Aesica.Misc.getWeaponPower = function(a, statId=2)
{
var params = ["mhp","mmp","atk","def","mat","mdf","agi","luk"];
var weapons, i, iLength, result = 0;
if (a.isActor())
{
weapons = a.weapons();
iLength = weapons.length;
for (i = 0; i < iLength; i++)
{
result += weapons[i].params[statId];
}
if (iLength < 1) result = a[params[statId]];
}
else
{
result = a[params[statId]];
}
return result;
}
})();
So in the attack formula, you could do something like this: Aesica.Misc.getWeaponPower(a) - b.def

There's even an optional second parameter to get a different stat, such as MAT: Aesica.Misc.getWeaponPower(a, 4) // at least I think MAT is 4. Too lazy to test.

Oh and I probably mucked up the header because I just wrote it in the forum text box editor. Oh well!

Last edited:

##### Chemical Engineer, Game Developer, Using BlinkBoy'
Aesica - It does simplify things though.. and yeah I think MAT is 4, starting from 0,(mhp,mmp,atk,def,mat,mdf,agi,luk) I think is the param order. And actually, on my current project all my actual damage formulas are inside scripts, and I just call them via the damage formula supplying necessary parameters. I personally like that approach, easier to write long codes there instead of the formula box

Guanto - That plugin code is pretty nice, it takes the weapon parameter (ATK by default but you can change it via supplying the 2nd parameter when u call it from the formula box), and if theres no weapon it simply returns the atk of the user

Last edited:

### Latest Profile Posts

Why is there so much month left at the end of money? D=
Hello humans! How goes your day in this journey of living? I hope it is good, for I am human like you, and I am feeling great! Worship the altar.
Sand is basically small rocks