# RMMV Damage Formula - ideas and help

#### Dethroner

##### Villager
Dependant on the hero's HP?
If so
Code:
``````<damage formula>
<\damage formula>``````
In your example if your hero is at full health this would do 200 damage he takes 65 damage bringing his health to 455
455/520*100 = 0,875 * (8*25) =175

Nice! ...but not completely.
DEF influence still needed and it will be perfect.

=====================================
After some more testing still its no good. You see, stats like ATK and DEF wont change ingame (just rare exception with +- 1 or 2).
And with this formula battle with 5000 HP will be looooooong.

Last edited:

#### jetboost

##### Veteran
How do you want def to influence it?
in the previous post we can say we calculated the "damage points" do you want the value to increase further with the hero's defense or do you mean the substraction of the value by using the enmies def stat?
In the end both are variables i think you should decide for yourself how it should impact your damage.
You should think of an ballance you want to maintain.
Example: the default damage formula of rpg maker is (if i remember correctly) a.atk*4-b.def*2 this means that for that skill every stat point in atk is worth 4 "damage points" and for the enemy every point in def is worth 2 "defense points"
This means that if both hero and enemy can only use the same skill like I can see in the video, that atk is way more valuable.
If the stat values remain small it isn't really notticeable but it will later on "if" the stat values will rise much at all.
So you can do 2 things
1: think about what kind of game you want to create and how it should be represented through combat and create your "balance" Or
2:Try to explain as clear as possible what you want and what your vision of your game is.(We can only guess so much, cause i could also have given you this value = a.hp+a.atk+a.def-b.def; and it would still conform to your criteria.)

However my personal opinion is that you should spend some time thinking about it yourself some more.

Edit:
After some more testing still its no good. You see, stats like ATK and DEF wont change ingame (just rare exception with +- 1 or 2).
And with this formula battle with 5000 HP will be looooooong.
Now we have something more to work with.

Well asuming that every HP is a single man with 4 ATK a relativly easy solution would be this
Code:
``a.hp*a.atk-b.hp*b.def``

Last edited:

#### Dethroner

##### Villager
How do you want def to influence it?
in the previous post we can say we calculated the "damage points" do you want the value to increase further with the hero's defense or do you mean the substraction of the value by using the enmies def stat?
In the end both are variables i think you should decide for yourself how it should impact your damage.
You should think of an ballance you want to maintain.
Example: the default damage formula of rpg maker is (if i remember correctly) a.atk*4-b.def*2 this means that for that skill every stat point in atk is worth 4 "damage points" and for the enemy every point in def is worth 2 "defense points"
This means that if both hero and enemy can only use the same skill like I can see in the video, that atk is way more valuable.
If the stat values remain small it isn't really notticeable but it will later on "if" the stat values will rise much at all.
So you can do 2 things
1: think about what kind of game you want to create and how it should be represented through combat and create your "balance" Or
2:Try to explain as clear as possible what you want and what your vision of your game is.(We can only guess so much, cause i could also have given you this value = a.hp+a.atk+a.def-b.def; and it would still conform to your criteria.)

However my personal opinion is that you should spend some time thinking about it yourself some more.

Edit: Now we have something more to work with.

Well asuming that every HP is a single man with 4 ATK a relativly easy solution would be this
Code:
``a.hp*a.atk-b.hp*b.def``

Okay, here's how I see everything:
Fight goes in the style army vs the army, where the HP is displayed as the number of troops in the army. Moreover, there can be several armies on both sides of the battlefield.

On one side enemy armies (enemy 1, enemy 2, etc., each with its own number of troops and stats) and on the other side Allied armies (character 1, character 2, etc.).

The stats of ATK and DEF belong to the general (character) that represents the army, which slightly affect the damage.

Ideally, I want to get an approximate formula:
DMG = number of troops + some influence of the character’s ATK - some influence of the enemy's DEF.

Again small examples:

--------
Hero
--------
HP 500
ATK 8
DEF 6
--------
Enemy
--------
HP 300
ATK 3
DEF 3

Hero attacks first Enemy with full HP. Result about 180 damage. Enemy left with 120 HP.
----------------------
Enemy attacks first Hero with full HP. Result 50 damage (or 30, if receved damage, attacked with about 160 HP). Hero left with 450 HP (470 HP).
---------------------

Another situation, with a stronger opponent.

--------
Hero
--------
HP 560
ATK 8
DEF 6
--------
Enemy
--------
HP 570
ATK 7
DEF 6

Hero attacks first Enemy with full HP. Result about 160 damage. Enemy left with 410 HP.
----------------------
Enemy attacks first Hero with full HP. Result 150 damage.Hero left with 410 HP.

Gradually, as the game progresses, the troops will increase (up to 1000 and even up to 10,000 at the end of the game).

#### jetboost

##### Veteran
Okay, here's how I see everything:
Fight goes in the style army vs the army, where the HP is displayed as the number of troops in the army. Moreover, there can be several armies on both sides of the battlefield.

On one side enemy armies (enemy 1, enemy 2, etc., each with its own number of troops and stats) and on the other side Allied armies (character 1, character 2, etc.).

The stats of ATK and DEF belong to the general (character) that represents the army, which slightly affect the damage.

Ideally, I want to get an approximate formula:
DMG = number of troops + some influence of the character’s ATK - some influence of the enemy's DEF.

Again small examples:

--------
Hero
--------
HP 500
ATK 8
DEF 6
--------
Enemy
--------
HP 300
ATK 3
DEF 3

Hero attacks first Enemy with full HP. Result about 180 damage. Enemy left with 120 HP.
----------------------
Enemy attacks first Hero with full HP. Result 50 damage (or 30, if receved damage, attacked with about 160 HP). Hero left with 450 HP (470 HP).
---------------------

Another situation, with a stronger opponent.

--------
Hero
--------
HP 560
ATK 8
DEF 6
--------
Enemy
--------
HP 570
ATK 7
DEF 6

Hero attacks first Enemy with full HP. Result about 160 damage. Enemy left with 410 HP.
----------------------
Enemy attacks first Hero with full HP. Result 150 damage.Hero left with 410 HP.

Gradually, as the game progresses, the troops will increase (up to 1000 and even up to 10,000 at the end of the game).
Ok that's more like it cause you will end up with such huge numbers we will want to work with smaller multipliers.
Code:
``a.hp*0.50*(1+(a.atk/100))- b.hp*0.25*(1+(b.def/100))``
You may want to play a bit more with the 0.50 and 0.25 numbers.
Every atk point will increase your "damage points" by 1%.
Every def point will increase your "defense points" by 1%.

Will this work for you?

#### Dethroner

##### Villager
Ok that's more like it cause you will end up with such huge numbers we will want to work with smaller multipliers.
Code:
``a.hp*0.50*(1+(a.atk/100))- b.hp*0.25*(1+(b.def/100))``
You may want to play a bit more with the 0.50 and 0.25 numbers.
Every atk point will increase your "damage points" by 1%.
Every def point will increase your "defense points" by 1%.

Will this work for you?

Close, very close!
The problem is in the number of troops.
If one side has a lot less troops than the other, then the damage goes to zero. I want that even with 1 HP damage go through (1 for example).

#### jetboost

##### Veteran
Close, very close!
The problem is in the number of troops.
If one side has a lot less troops than the other, then the damage goes to zero. I want that even with 1 HP damage go through (1 for example).
So you want a minimum damage you can have it added to the damage like so
Code:
``(a.hp*0.50*(1+(a.atk/100))- b.hp*0.25*(1+(b.def/100)))+(a.hp/100)``
Meaning you will deal at least 1% of your hp as damage"extra"
Or
Code:
``````damage = a.hp*0.50*(1+(a.atk/100))- b.hp*0.25*(1+(b.def/100));
if(damage=< 0){damage = a.hp/100;}
value = damage;``````
at least 1% of HP.
You can increase the amount of % by adding this (a.hp/100)"*5", this would put the minimum to 5%.
At the moment you will deal no damage if the enemy has 2 times as much HP You can change this by changing for example 0.25 to 0.20 if you do the enemy will need 2.5 times as many troops to put damage dealt to 0

#### Dethroner

##### Villager
So you want a minimum damage you can have it added to the damage like so
Code:
``(a.hp*0.50*(1+(a.atk/100))- b.hp*0.25*(1+(b.def/100)))+(a.hp/100)``
Meaning you will deal at least 1% of your hp as damage"extra"
Or
Code:
``````damage = a.hp*0.50*(1+(a.atk/100))- b.hp*0.25*(1+(b.def/100));
if(damage=< 0){damage = a.hp/100;}
value = damage;``````
at least 1% of HP.
You can increase the amount of % by adding this (a.hp/100)"*5", this would put the minimum to 5%.
At the moment you will deal no damage if the enemy has 2 times as much HP You can change this by changing for example 0.25 to 0.20 if you do the enemy will need 2.5 times as many troops to put damage dealt to 0

Thank you very much! I'm going to test it now! Really, thank you!!

========================
I made several tests and chose this one
Code:
``damage = a.hp*0.50*(1+(a.atk/100))- b.hp*0.20*(1+(b.def/100));if(damage <= 0){damage = (a.hp/100)*5};value = damage;``
If 2 sides started with 1000 HP, after 1-2 exchanges one of the sides goes half HP of the othere one and dils just these 5% (and if he has like 200 HP left, DMG is sad 10, whitch is too litle).

Last edited:

#### jetboost

##### Veteran
Thank you very much! I'm going to test it now! Really, thank you!!

========================
I made several tests and chose this one
Code:
``damage = a.hp*0.50*(1+(a.atk/100))- b.hp*0.20*(1+(b.def/100));if(damage <= 0){damage = (a.hp/100)*5};value = damage;``
If 2 sides started with 1000 HP, after 1-2 exchanges one of the sides goes half HP of the othere one and dils just these 5% (and if he has like 200 HP left, DMG is sad 10, whitch is too litle).
I don't know how much you would like to increase it but you could change the minimum to this
Code:
``damage = ((a.hp/100)*5)*a.atk``

#### Dethroner

##### Villager
I don't know how much you would like to increase it but you could change the minimum to this
Code:
``damage = ((a.hp/100)*5)*a.atk``
You see, here's the problem.
Imagine the character has 100 HP left, and it turns out that he will deal only 8 HP damage ... this is not enough.

Oh, how would I like to know the original formula of the Eiyuu*Senki.......

#### armorvil

##### Villager
Hi everyone, I have a problem with this damage formula :

((a.mag * 2) + a.luk) - b.mdf

My character has 16 in both Magic and Luck, while the enemy has a Magic Defense value of 44.
If my math is correct, I should deal 16 x 2 = 32, plus 16 thanks to my luck stat. This is 48, and since the enemy as a mdef value of 44, I should deal 4 points of damage.

Problem is, in my game, this attack doesn't deal any damage to the enemy (I put the random variance at 0%, of course).

On the other hand, this damage formula, on this very same ability :

((a.atk * 2) + a.agi) - b.def

Works correctly and deals 4 points of damage (the character's strength and agility are 16 too, and the enemy's defense is also 44).
I'm at a complete loss as to why it doesn't work with the former but works with the latter. The enemy has no elemental resistances either...

EDIT : Found the problem : I'm an idiot. Magic Attack is "mat", not "mag" -_____-

Last edited:

#### Dark_Sytze

##### Villager
Hi,
I'm making a skill that doesn't deal damage, but will cause either confusion, rage or nothing if the opponent has the state Burning. If the opponent does not have the burning state the skill should fail. I was told this should be manageable with the damage formula, but I can't find out how to do it, even with trying several plug ins.
What I've tried is Yanfly's skill core and then doing the following:

if (user.isStateAffected(11)){
if (Math.random() < 0.75){
else{
if (Math.random() < 0.15){

This sadly did not work though.

Any help would be greatly appreciated.

#### jetboost

##### Veteran
Hi,
I'm making a skill that doesn't deal damage, but will cause either confusion, rage or nothing if the opponent has the state Burning. If the opponent does not have the burning state the skill should fail. I was told this should be manageable with the damage formula, but I can't find out how to do it, even with trying several plug ins.
What I've tried is Yanfly's skill core and then doing the following:

if (user.isStateAffected(11)){
if (Math.random() < 0.75){
else{
if (Math.random() < 0.15){

This sadly did not work though.

Any help would be greatly appreciated.

I believe you have one "}" to many on your 3th line.
As far as i can see it should work.

If it still doesn't work as intended, you can check if every IF statement is valid by changing it to a single target damage skill and have the damage value be +=1after every if statement.

Edit: "}" should be moved to the other } at the last line.

#### Dark_Sytze

##### Villager
I believe you have one "}" to many on your 3th line.
As far as i can see it should work.

If it still doesn't work as intended, you can check if every IF statement is valid by changing it to a single target damage skill and have the damage value be +=1after every if statement.

Edit: "}" should be moved to the other } at the last line.
Thanks! After dealing with some other issuess (I kept getting an undefined error caused by not having Yanfly's core plugin active) it now appears to work.

#### JesFang

##### Villager
Hi
I was wondering if its possible to make this without a plugin or i really need to use one:
• Damage done = XAtk - YDef (pretty simple, X=attacker, Y=target)
• Damage done will never be 0, min is 1 (this one im having trouble with)
• Using Defend Command will add +5Def until the end of the turn (not null x% of the damage)

#### jetboost

##### Veteran
Hi
I was wondering if its possible to make this without a plugin or i really need to use one:
• Damage done = XAtk - YDef (pretty simple, X=attacker, Y=target)
• Damage done will never be 0, min is 1 (this one im having trouble with)
• Using Defend Command will add +5Def until the end of the turn (not null x% of the damage)
Yes for the first one, no for the second one and the third one only partly.
Code:
``a.atk-b.def``
Though i'm surprised you would ask about that one, the editor gives pretty much the same example.
So I hope you realise how you come across as I prefer to help the people who at least have taken a proper look at the program first.
My guess is that you are new to the program and I suggest you read through some of the tutorials on the forum to help you orient yourself with it.

For the second one you will need to check if the value of your damage formule =< 0 if it is, set the value to 1 or change it in the program itself to do that I don't know where though as I haven't looked through the code.

For the third one I would like it if the engine gave me the feature to controll buffs like that, why I said partly that is because you can change the guard state to give you a defense buff but the buff is stattic at 25% and thus gives it (in my case) very limited use.
Sorry if I come across as harsh though, i'm happy to help if you have some questions.

#### JesFang

##### Villager
Though i'm surprised you would ask about that one, the editor gives pretty much the same example.
So I hope you realise how you come across as I prefer to help the people who at least have taken a proper look at the program first.
My guess is that you are new to the program and I suggest you read through some of the tutorials on the forum to help you orient yourself with it.

For the second one you will need to check if the value of your damage formule =< 0 if it is, set the value to 1 or change it in the program itself to do that I don't know where though as I haven't looked through the code.

For the third one I would like it if the engine gave me the feature to controll buffs like that, why I said partly that is because you can change the guard state to give you a defense buff but the buff is stattic at 25% and thus gives it (in my case) very limited use.
Sorry if I come across as harsh though, i'm happy to help if you have some questions.

Yeah thanks, well i understand what you mean i put that part in there for the sake of explaining how it works and actually got it working (the 2nd and 3rd) with yanfly as i wanted and just wanted to make sure there wasnt a way to do it without plugins because i have this (probably wrong) idea the less plugins i use the less problematic it will get if i decide to use more plugins later (compatibility and stuff)

#### jetboost

##### Veteran
Yeah thanks, well i understand what you mean i put that part in there for the sake of explaining how it works and actually got it working (the 2nd and 3rd) with yanfly as i wanted and just wanted to make sure there wasnt a way to do it without plugins because i have this (probably wrong) idea the less plugins i use the less problematic it will get if i decide to use more plugins later (compatibility and stuff)
I understand, it's good to be clear.
About plugins allow me to present my view regarding them.
First though we have this piece of software rpg maker, this is called a game engine it helps us and make it easier to create games but it has an pretty big drawback because the engine traps you within the borders of its capabillity.
Thus that means that if you would want to do more than what the engine allows you will have to expand itand this is where plugins come in they help you expand it but at the same time it will make it bigger and will thus in the end require more work to see your project completed.
In the end the engine is nothing more than a bunch of code working together, where upon you can, if you wish expand upon.

Anyways I once thought the same as you but as you try to put more and more in your game(at least for me) you kinda continiously start finding the limits of the engine and start to look for solutions for your problems.
And currently I have quite the gigantic lists of plugins I use and it's now merely the question if the plugin in question provides the functionality i seek and if it's terms of use are agreeable to me otherwise I would do my best to try and code it in the game myself.

Yanfly plugins are great yeah and you don't really have to worry much about compatibillity (if you install them correctly)with them I use them as well.

#### tom55200

##### Warper
Hello,
I am attempting to make a Digimon World type of game, where you have a partner that you train.
However I am having much trouble trying to find a damage formula that stays balanced.

I am completely lost when it comes to the damage formulas and any help at all would be much appreciated!

#### jetboost

##### Veteran
Well I can only try a bit.
But first you have tell us how valuable Atk is in comparison to Def, for example every Def point is worth 1point and every Atk point is worth 2points.
If you have 10 atk/def and the enemy as well it would mean you would deal 10 damage to each other.

You will have to figure that out first.

#### LGardner

##### Veteran
@udime123
Orbit should have "Call Common Event" and this should set the Variable to the necessary number. Make sure you're using 'set' - or, if you're using 'add/sub/multiply/etc.' make sure that the variable is set to 0 prior to the battle/skill being used.

Then it should be fine. If you're still having difficulties post some screenshots and stats for your attacker and defender. From "a.mat * .75 - b.mdf" it looks like it might be doing 0 straight off, so maybe your variable isn't set high enough to counter that.

Is there no way to do this within the damage formula?

I have several skills which use common events individually. In order to tidy them up, I thought it would be ideal to use the damage formula to set the variable Skill [variable 5] to the number of the skill [67, for instance], and then call up the common event "Skill" as one of the effects. The common event would contain conditional branches:

If skill = 67, do the stuff for skill 67. If skill = 68, do the stuff for skill 68. etc. That way I would just need to change the number I set the variable to for each individual skill, but they would all draw upon the same common event. I have the skills I want all working properly, as separate common events, I just want to unify them.

However, every way I have tried to set the game variable within the damage formula box has failed. From memory, I have tried [using both square and round brackets]:

v[5] = 67
\$gameVariables[5] = 67
\$gameVariables.Value[5] = 67
\$gameVariables.setValue(5, 67)

If someone can tell me the correct syntax for the damage formula box to set variable 5 to a value of 67, I would be forever grateful. I have trawled through this thread for an hour, trying many different suggestions, and nothing has worked.

### Latest Profile Posts

Looks like I'm going to have to cancel another game.
For now it is in testing phase: Changing the game icon from Rm2k/2k3 without needing to edit the executable.
When there's a will, there's a lifehack.

Before i mess with battle UI further, does it look decent enough?
Free MZ? That's good. I should go try it out then.