# RMMV Damage Formula - ideas and help

#### Confodere

##### Villager
Hmm, are you sure? I know for example you can add states with a formula like this:
a.addState(id); (a.atk * 1.3 - b.def)

This example would deal damage to the enemy and give state xy to the user. Taking this in mind i thought it must be possible to use something like a.ifstate(id); b.addstate(id)

#### jetboost

##### Veteran
You will have to use a FOR statement in your formule if you would want to copy every state the target has with one skill.
And you wanted to only copy beneficial states? If so it will get a little bigger.

#### Confodere

##### Villager
Hey there, could you explain me what exactly a FOR statement is?

#### jetboost

##### Veteran
Am at the dentist.
There you can find what you search for
https://www.w3schools.com/js/js_loop_for.asp
You may need to use plugins to make use of it in a damage formule.
When i have more time i could give you an proper example.

Last edited:

#### Boonty

##### Veteran
I want to create a formula for a combined skill between actor 1 and actor 2 (either performed by actor 1 or actor 2) where the damage is the sum of actor 1 attack and actor 2 magic attack.

If I enter "\$gameActors.actor(1).param[2] + \$gameActors.actor(2).param[4]", it make 1 damage. Formula error ? Or correct formula but plugins incompatibility ?

#### Boonty

##### Veteran
Somebody to help with my above problem ? It has been 3 days that I torture myself

#### jetboost

##### Veteran
Somebody to help with my above problem ? It has been 3 days that I torture myself
Use param(1) instead of this param[1].
These [ ]are used for objects (and perhaps even more) and param is a function that you have to give an id to work with.
If you put your line in the debug console you can test it.

#### Boonty

##### Veteran
Thanks jetboost !

#### jetboost

##### Veteran
Hey there, could you explain me what exactly a FOR statement is?
Here is what you need:

Code:
``````if(target.states().length != 0){
for(i=0; i < target.states().length;i++)
}}``````
*You need Yanfly damage core plugin for this to work. Edit(control to core. the plugin gives more control it wasn't named as such sorry about that)

This will copy every state the target enemy has and gives them to you.

Last edited:

#### The_Black_Knight

##### Veteran
So, I ran into an issue with Absorption Barrier. I tried to make an attack that would deal good damage against enemy barriers, but otherwise deal normal damage.
What I managed does deal good damage to barriers, however it also deals 0 hp damage every time I attack, and once the barrier is gone it only deals that 0 damage.
It's even on my actor with the highest attack, and the others do deal succesful hp damage to the enemy.
Help?

Edit: Nevermind I'm an idiot everything works now, I had removed the multiplier from the normal attack damage.

#### Arin

##### Some happiness we have to let go of.
Alright, if someone could help me out with a specific skill, I would really appreciate it.

The Skill's tooltip is "Deals 50% more damage for each negative parameter status change the enemy has". This can scale up to 250% for all 5 states (Attack, Defense, Magic Attack, Magic Defense, and Agility). If the enemy doesn't have any debuffs on them, it's a regular "a.mat * 2 - b.mdf".

I'm also using Yanfly's Damage Core to write this code. I've tried it myself but the damage doesn't work. Not even a 0 damage popup, it simply does nothing.

<damage formula>

value = a.mat * 2 - b.mdf;

if (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

value *= 3.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

#No Agility Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Magic Defense Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

#No Magic Attack Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(40)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Defense Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Attack Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) {

#No Magic Defense/Agility Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(40)) {

#No Magic Attack/Agility Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

#No Defense/Agility Debuff

value *= 2.5;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

#No Attack/Agility Debuff

value *= 2.5;

} elseif (b.isStateAffected(30)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

#No Attack/Defense Debuff

value *= 2.5;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

#No Attack/Magic Attack Debuff

value *= 2.5;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Attack/Magic Defense Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

#No Defense/Magic Attack Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Defense/Magic Defense Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(53)) {

#No Magic Attack/Magic Defense Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) {

#No Magic Attack/Magic Defense/Agility Debuff

value *= 2.0;

} elseif (b.isStateAffected(53)) && if (b.isStateAffected(57)) {

#No Magic Attack/Magic Defense/Attack Debuff

value *= 2.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(53)) {

#No Magic Attack/Magic Defense/Defense Debuff

value *= 2.0;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) {

#No Attack/Magic Attack/Agility Debuff

value *= 2.0;

} elseif (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

#No Attack/Defense/Agility Debuff

value *= 2.0;

} elseif (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Attack/Defense/Magic Defense Debuff

value *= 2.0;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) {

#No Attack/Magic Defense/Agility Debuff

value *= 2.0;

} elseif (b.isStateAffected(27)) || if (b.isStateAffected(57)) || if (b.isStateAffected(30)) || if (b.isStateAffected(40)) || if (b.isStateAffected(53)) {

#Only One Debuff

value *= 1.5;

}

</damage formula>

Any help would be appreciated. Thanks.

#### jetboost

##### Veteran
Alright, if someone could help me out with a specific skill, I would really appreciate it.

The Skill's tooltip is "Deals 50% more damage for each negative parameter status change the enemy has". This can scale up to 250% for all 5 states (Attack, Defense, Magic Attack, Magic Defense, and Agility). If the enemy doesn't have any debuffs on them, it's a regular "a.mat * 2 - b.mdf".

I'm also using Yanfly's Damage Core to write this code. I've tried it myself but the damage doesn't work. Not even a 0 damage popup, it simply does nothing.

<damage formula>

value = a.mat * 2 - b.mdf;

if (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

value *= 3.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

#No Agility Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Magic Defense Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

#No Magic Attack Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(40)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Defense Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Attack Debuff/Everything Else

value *= 3.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) {

#No Magic Defense/Agility Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(40)) {

#No Magic Attack/Agility Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

#No Defense/Agility Debuff

value *= 2.5;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

#No Attack/Agility Debuff

value *= 2.5;

} elseif (b.isStateAffected(30)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

#No Attack/Defense Debuff

value *= 2.5;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

#No Attack/Magic Attack Debuff

value *= 2.5;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Attack/Magic Defense Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

#No Defense/Magic Attack Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Defense/Magic Defense Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(53)) {

#No Magic Attack/Magic Defense Debuff

value *= 2.5;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) {

#No Magic Attack/Magic Defense/Agility Debuff

value *= 2.0;

} elseif (b.isStateAffected(53)) && if (b.isStateAffected(57)) {

#No Magic Attack/Magic Defense/Attack Debuff

value *= 2.0;

} elseif (b.isStateAffected(27)) && if (b.isStateAffected(53)) {

#No Magic Attack/Magic Defense/Defense Debuff

value *= 2.0;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) {

#No Attack/Magic Attack/Agility Debuff

value *= 2.0;

} elseif (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

#No Attack/Defense/Agility Debuff

value *= 2.0;

} elseif (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

#No Attack/Defense/Magic Defense Debuff

value *= 2.0;

} elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) {

#No Attack/Magic Defense/Agility Debuff

value *= 2.0;

} elseif (b.isStateAffected(27)) || if (b.isStateAffected(57)) || if (b.isStateAffected(30)) || if (b.isStateAffected(40)) || if (b.isStateAffected(53)) {

#Only One Debuff

value *= 1.5;

}

</damage formula>

Any help would be appreciated. Thanks.
2 things first
1: does "value *= 3.5" work i remember getting some invalid left side errors or something when i used it at other places in the engine i can be wrong though.
2. The way you have set up the formula is needlessly large and a pain to make some changes to i will put something down for you that's a bit more compact i may even solve your issue. Will edit this post when i finish it.

Edit: And i believe you are using && if the wrong way.
Edit 2 the formula. I haven't tested it yet though.

Code:
``````<damage formula>
debufstates=[27,30,40,50,53];
multi = 1;
if(target.states().length != 0)
{
for(i=0; i < target.states().length;i++)
{for (o=0;o < debufstates.length; o++)
{if(target.states()[i].id==debufstates[o] )
{multi + .5;}
}
}
}
value = (a.mat * 2 - b.mdf)* multi;
</damage formula>``````

Last edited:

#### Arin

##### Some happiness we have to let go of.
@jetboost Thank you so much for the code! I was able to get it working!

#### SavageWolf09

##### Villager
Hi I don't know if this is possible. But can anyone help me with a formula where lets say actor one has an atk of 12 he will do anywhere from 1 to 12 points of damage and then do the same with the opponts def and have the atk amount subtract from the def amount

Last edited:

#### jetboost

##### Veteran
Hi I don't know if this is possible. But can anyone help me with a formula where lets say actor one has an atk of 12 he will do anywhere from 1 to 12 points of damage and then do the same with the opponts def and have the atk amount subtract from the def amount
That's possible. But I don't know what the engine would do with negative values to be honest.
Code:
``````<damage formula>
value = Math.randomInt(a.atk)+1 - Math.randomInt(b.def)+1;

</damage formula>``````
So you could add this to the formule
Code:
``if(value < 0){value=0;} \\Or  value = 1 depending on your preference. Oh wait nevermind this negative values will become 0 i believe so this isn't needed``
Yanfly damage core plugin required*
It ought to work.

#### SavageWolf09

##### Villager
I have a D&D type of formula that i want to use in a game I'm making and it's very close to what i need. However there's one part I'm having trounble with. if (b.def <= (Math.randomInt(20) + 1 + a.atk)) Math.randomInt(4) + 1 + a.atk; else 0 is the formula.

if (b.def <= (Math.randomInt(20) + 1 + a.atk)) is what determines if you hit or miss.

Math.randomInt(4) + 1 + a.atk is what determines the damage.

My question is for the damage part instead of using the players over all atk. Is it possible to only use the weapons atk stat

#### jetboost

##### Veteran
I have a D&D type of formula that i want to use in a game I'm making and it's very close to what i need. However there's one part I'm having trounble with. if (b.def <= (Math.randomInt(20) + 1 + a.atk)) Math.randomInt(4) + 1 + a.atk; else 0 is the formula.

if (b.def <= (Math.randomInt(20) + 1 + a.atk)) is what determines if you hit or miss.

Math.randomInt(4) + 1 + a.atk is what determines the damage.

My question is for the damage part instead of using the players over all atk. Is it possible to only use the weapons atk stat
Ok, that is possible
If you would like to write your code in the way i did, there is an insert button next to the floppy disk symbol with which you can choose to do so.

Code:
``````<damage formula>
\\Because we wish to select data from an actor that isn't accesable like a.atk for as far as i know, we will \\have to select our correct actor like this and as enemies don't have equips.
if( a.isActor() ){
x = a.actorId() ;
if (b.def <= (Math.randomInt(20) + 1 + a.atk)) {
value= Math.randomInt(4) + 1 +\$gameActors.actor(x).equips()[0].params[2];
}else{ value = 0;}
}``````
This should do it.

#### SavageWolf09

##### Villager
Hi wanted to thank everyone for their help with my D&D style Damage Formula and decided to upload it here.

if (b.def <= (Math.randomInt(20) + 1 + a.atk + Math.floor(v[1]-10)/2)) Math.randomInt(4) + 1 + Math.floor(v[1]-10)/2; else 0

if (b.def <= (Math.randomInt(20)+ 1 + a.atk + Math.floor(v[1]-10)/2)) This is the attack roll that decides if you hit or miss

if (b.def <= (Math.randomInt(20) + 1 is the dice roll that results in a number from 1 to 20. Then you add your overall atk as the Proficiency bonus. Then Math.floor(v[1]-10)/2)) as the part that determines your ability score. With this part you will have to create a variable to act as the six basic skill.

I recommend using yanfly's actor variables just to keep track of them in game.

Math.randomInt(4) + 1 + Math.floor(v[1]-10)/2; else 0 is the damage roll

Math.randomInt(4) + 1 is the basic dice roll. Just repe lace the 4 with the type of dice roll you want. 4 for a d4 dice 6 for d6 etc.

Math.floor(v[1]-10)/2 this is you ability score again.

else 0 just reduces all damage to 0 if your attack roll doesn't beat out your opponents. As I couldn't figure out how to do a miss.

#### jetboost

##### Veteran
Hi wanted to thank everyone for their help with my D&D style Damage Formula and decided to upload it here.

if (b.def <= (Math.randomInt(20) + 1 + a.atk + Math.floor(v[1]-10)/2)) Math.randomInt(4) + 1 + Math.floor(v[1]-10)/2; else 0

if (b.def <= (Math.randomInt(20)+ 1 + a.atk + Math.floor(v[1]-10)/2)) This is the attack roll that decides if you hit or miss

if (b.def <= (Math.randomInt(20) + 1 is the dice roll that results in a number from 1 to 20. Then you add your overall atk as the Proficiency bonus. Then Math.floor(v[1]-10)/2)) as the part that determines your ability score. With this part you will have to create a variable to act as the six basic skill.

I recommend using yanfly's actor variables just to keep track of them in game.

Math.randomInt(4) + 1 + Math.floor(v[1]-10)/2; else 0 is the damage roll

Math.randomInt(4) + 1 is the basic dice roll. Just repe lace the 4 with the type of dice roll you want. 4 for a d4 dice 6 for d6 etc.

Math.floor(v[1]-10)/2 this is you ability score again.

else 0 just reduces all damage to 0 if your attack roll doesn't beat out your opponents. As I couldn't figure out how to do a miss.
You are welcome, solving puzzles is fun and i get to see a new perspective on skills.
Did you manage to get the skill working? The one with which you wanted to select the weapons attack?
Kinda just put it together and haven't tested it.

### Latest Profile Posts

I figured it was about time to update the battle sprite for one of my characters. The old one was the first time I ever drew a battle sprite, and filled with lines that shouldn't be there. So far, the new one is cleaner.

This was supposed to become her neutral talking stance, but now i just feel like she looks a little puzzled
I'm also open for any name suggestions, as i seriously suck at those. In my notes everything is just THE CITY or THAT GUY and THIS PRIESTESS or whatever
Nearing completion of the first major city of Albert, a vacation getaway city built a long time ago by a king who really didn't want to be invaded.
It’s definitely a great day to fit in some time for me to play no mans sky on PS4

First concept art of one of our main characters love interests who might turn evil depending on her decisions. Or become king of the world. Or marry her. Maybe even everything at once.