RMMV Damage Formula - ideas and help

Confodere

Villager
Member
Joined
Oct 10, 2012
Messages
24
Reaction score
27
First Language
German
Primarily Uses
RMMV
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
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
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
Member
Joined
Oct 10, 2012
Messages
24
Reaction score
27
First Language
German
Primarily Uses
RMMV
Hey there, could you explain me what exactly a FOR statement is?
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Am at the dentist.
There you can find what you search for
https://www.w3schools.com/js/js_loop_for.asp
This is the correct link.
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
Veteran
Joined
Oct 10, 2018
Messages
114
Reaction score
44
First Language
French
Primarily Uses
RMMV
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
Veteran
Joined
Oct 10, 2018
Messages
114
Reaction score
44
First Language
French
Primarily Uses
RMMV
Somebody to help with my above problem ? It has been 3 days that I torture myself :frown:
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Somebody to help with my above problem ? It has been 3 days that I torture myself :frown:
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.
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
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++)
{user.addState(target.states()[i].id)
}}
*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:
Joined
Dec 24, 2018
Messages
59
Reaction score
3
First Language
Finnish
Primarily Uses
RMMV
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.
Veteran
Joined
Oct 18, 2012
Messages
1,228
Reaction score
189
First Language
Fraglspock
Primarily Uses
RMMV
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
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
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.
Veteran
Joined
Oct 18, 2012
Messages
1,228
Reaction score
189
First Language
Fraglspock
Primarily Uses
RMMV
@jetboost Thank you so much for the code! I was able to get it working!
 

SavageWolf09

Villager
Member
Joined
Jan 24, 2015
Messages
20
Reaction score
5
First Language
English
Primarily Uses
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
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
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
Member
Joined
Jan 24, 2015
Messages
20
Reaction score
5
First Language
English
Primarily Uses
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
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
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
Member
Joined
Jan 24, 2015
Messages
20
Reaction score
5
First Language
English
Primarily Uses
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
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
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.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

i love my game very much
Uh, I'm probably overthinking this, but I think that some of my music sounds kinda...bad?
The melodies are just sort of awkward, and don't flow.
I'm really not sure what to do. Why am I even worrying about this? I don't even have a battle system yet!
And the Lord said, let there be lighting effects! And there were lighting effects! And it was good...ish? Might tweak this some more.
Today was a day of good things! Thank you fate! I pray to the darkness that those that read this will enjoy a good day as well! Power to the gam mak.
People3_1 and People3_2 added!

Forum statistics

Threads
105,714
Messages
1,015,861
Members
137,398
Latest member
Yuisema
Top