# RMMV Damage Formula - ideas and help

#### MikeMakes

##### Veteran
@saikais: I'm having the same problem, too. I am doing some balancing and keeping defense stat low for now until I think up of something. Maybe keep a low modifier like 1.5 for the attacker's attack?

I am also wondering is there a syntax to do the following:

Last edited by a moderator:

##### Veteran
Oh yes.  I've yet to do too much with it, but I wrote a somewhat complicated looking formula:

JahwsUF.Utils.logScaleDamage = function(atk, def) { return atk * Math.log10(atk) * Math.log(1 + Math.pow((atk / def), 2)) / Math.log(2);}It's surely not a perfect match, but it's designed to do damage scaling similar to that from the Final Fantasies - it's not subtractive in the slightest.  You could take the formula (the contents of the line after "return") and put that in the formula box directly, but I'm planning to use this core function so often I made it in a plugin so all my formulas can reference it and then modify potency after the base calculation (like Pokemon does).
Hi, I was curious on how you would call that in the Damage Formula box. (also how to set that up as a plug-in so I can call it. I don't know Javascript quite yet and would like some guidance. Thanks!

##### The Most Chaotic
Can someone please tell me how the 100 + thing works?

For example: 100 + a.mat * 2 - b.mdf * 2

From my limited understanding of this, it's saying 2 x User's Magic Attack -minus- Opponents Magic Defence ... x2?

So...

If you had 50 Magic Attack, x 2 would equal 100 Magic attack? Then the game would deduct whatever 100 Magic Attack equals in damage to the opponent?

I'm still not sure about it, and I don't know what the 100 + part means.

Thanks!

Please explain it in the easiest way possible.

#### MikeMakes

##### Veteran
I think the "100 +" ensures a minimum damage of 100 no matter what (to be affected by variance, elemental rate, and critical rate).

That's because if the Attacker and Target's stats are exactly the same, they will cancel out to zero.

e.g. 100 + (50*2) - (50*2) = 100

Last edited by a moderator:

#### luigiman2201

##### Villager
Can someone please tell me how the 100 + thing works?

For example: 100 + a.mat * 2 - b.mdf * 2

From my limited understanding of this, it's saying 2 x User's Magic Attack -minus- Opponents Magic Defence ... x2?

So...

If you had 50 Magic Attack, x 2 would equal 100 Magic attack? Then the game would deduct whatever 100 Magic Attack equals in damage to the opponent?

I'm still not sure about it, and I don't know what the 100 + part means.

Thanks!

Please explain it in the easiest way possible.
The 100 + just adds 100 damage flat. some examples:

user has 50 mat (magic attack), opponent has 20 mdf (magic defense)

100 + a.mat * 2 - b.mdf * 2With the order of operations (multiplying goes before subtracting or adding), this example gives:

100 + 50 * 2 - 20 * 2
Code:
100 + 100 - 40 = 160 Damage
Another example:

User's mat = 65, Target's mdf = 77

100 + a.mat * 2 - b.mdf * 2
Code:
100 + 65 * 2 - 77 * 2
Code:
100 + 130 - 144 = 87 Damage
Let me know if there's anything you don't understand, and i'll try to explain

Last edited by a moderator:

#### Zarsla

##### Veteran
I'm trying to have my attack skill have different formulas depending on the class. 1 class uses both mat & atk, another uses mat and the other is atk. I've tried doing it by using this:

a._classID === 1 ? a.atk + a.mat - b.def + b.mdf : a._classID ==== 2 ? a.atk * 4 - b.def * 2 : a._classID === 3 ? a.mat * 4 - b.mdf : 0

but I keep getting a syntax error it says unexpected syntax token *

#### Shaz

##### Veteran
You have an extra = in there for the second comparison, but I suspect that's just a typo.

Try this:

a._classId === 1 ? (a.atk + a.mat - b.def + b.mdf) : a._classId === 2 ? (a.atk * 4 - b.def * 2) : a._classId === 3 ? (a.mat * 4 - b.mdf) : 0The only difference I've made there is to fix the ==== and to put some brackets around things. It seems to work okay for me.
If that doesn't work, let us know how you're testing, and where it's saying that error message (because by default you don't see a message if you have an error in the damage formula - it just defaults to 0).

Two other potential issues with this ...

- if you're modifying the Attack skill (skill #1), be aware that enemies use it too, and enemies don't have classes, so they will always hit for 0

- I'm not sure if you intend to + b.mdf in that first condition - if you want to start with the actor's atk and mat, and then take away the enemy's def and mdf, you would need to do one of the following:

a.atk + a.mat - b.def - b.mdf

a.atk + a.mat - (b.def + b.mdf)

Otherwise you're taking away their def but adding back their mdf

#### Zarsla

##### Veteran
@Shaz Thanx, I relized that there was a syntax error I kept writing classId as classID, where I should have written as classId.

So it seems syntax error unexpected token * means you've typed/wrote the forumula/scripting incorrectly.

#### Jeffafa

##### Multi-colored Mage
So damage formulas and map designing are my two biggest weaknesses when it comes to this program. And reading through this topic makes me feel even more inept at damage formulas lol.

I honestly have no idea where to even start. I know I want the game to begin with low damage, and end with high damage; magic casters being able to deal ~20,000 damage (with their stats/equipment pushed to the absolute max). Ideally it would hover around the traditional 9999 near end-game with average stats/gear, though that's not a make-or-break thing for me.

I haven't even begun to start working on stats for characters/enemies though, so should I seek help working on that first? Or should I figure out a base formula that I can work with and mold everything else around that?

I started a project a few years ago in which I was just using existing stats and damage formulas from other games, like Final Fantasy. I don't want to do that though. It feels low and I don't want to risk any trouble or anything for using data from something else.

(Also, I didn't know if I should post this here since a ton of people are working out various formulas already, or create a new topic. So I apologize if I should have done the latter.)

#### Shaz

##### Veteran
This is not about damage formulas. This is about setting your enemy stats and your actor stat progression. Please do create a new topic. This thread is JUST for the damage formula box on skills and items.

#### Jeffafa

##### Multi-colored Mage
This is not about damage formulas. This is about setting your enemy stats and your actor stat progression. Please do create a new topic. This thread is JUST for the damage formula box on skills and items.
Gotcha. I apologize. I do very much need damage formula assistance, but I suppose the stats will have to come first. Thanks.

#### RockEsper

##### Villager
I'm trying to make a damage formula that deals x1 damage if the user's luck is at least 10, x2 damage if 20, x3 damage if 30, and x4 damage if 40+. And it should go no higher than x4, even if luck is 50 or more.

Would it be something like, damage * floor(a.luk / 10)? Not sure if that's how to use floor, and it doesn't cover the x4 cap.

Last edited by a moderator:

#### VHStapes

##### Game Designer
I'm trying to make a damage formula that deals x1 damage if the user's luck is at least 10, x2 damage if 20, x3 damage if 30, and x4 damage if 40+. And it should go no higher than x4, even if luck is 50 or more.

Would it be something like, damage * floor(a.luk / 10)? Not sure if that's how to use floor, and it doesn't cover the x4 cap.

Lots of edits, here's the best solution, I think.

Code:
if (a.luk > 9) {x = Math.min(Math.max(Math.floor(a.luk / 10), 1), 4)} else {x = 0}; a.atk * x - b.def

Last edited by a moderator:

#### RockEsper

##### Villager
Lots of edits, here's the best solution, I think.

if (a.luk > 9) {x = Math.min(Math.max(Math.floor(a.luk / 10), 1), 4)} else {x = 0}; a.atk * x - b.def
Oh, well thanks to you now I understand if statements, so I think this would work and be simpler...?

Code:
if (a.luk > 40) {x = 4} else {x = Math.floor(a.luk / 10)}; a.atk * x - b.def

Last edited by a moderator:

##### Veteran
Hi, I was curious on how you would call that in the Damage Formula box. (also how to set that up as a plug-in so I can call it. I don't know Javascript quite yet and would like some guidance. Thanks!
Still curious on the set up for a plugin call for custom damage formula. Much appreciated.

#### VHStapes

##### Game Designer
Oh, well thanks to you now I understand if statements, so I think this would work and be simpler...?

if (a.luk > 40) {x = 4} else {x = Math.floor(a.luk / 10)}; a.atk * x - b.def
In your original post you said you wanted them to do 1x damage only if they had at least 10 luck, so mine accommodates for that, but otherwise yes yours is better.

Ifs are super cool! Here's a quick mock-up else/if statement, just for reference, because they are also really useful.

if (argument) {do this} else if (different argument) {do this} else {do this}You can keep chaining the "else ifs" as many times as you need, as long as you end it with a plain "else" eventually.

#### Chaos Avian

##### Abyssal Wing
I have a skill that does damage based on the difference between the max HP and current HP of the party, what damage formula would I use to achieve this?

#### Vanguard

##### Villager
I have a small numbers damage that i use from ace and it seems to work in mv just as well. 0 + a.atk * 0.5 - b.def * 0.3, if you have guys starting at 30 to 50 hp this works well enough for me. the magic damage I really haven't played with yet.

#### Merancapeman

##### Veteran
I can't wait for there to be a better explanation of the formulaic system, such as what is and isn't allowed, or what terms do what. For instance, I sat here and tried to figure out a Huskar-esque (DOTA2 character) attack would look like in terms of a.atk * 4 + (a.hp {divided? no idea what sign you use}/2) - .... Ok, so basically what I'm trying to say is user's attack times four (like a normal attack) plus the user's current hp divided by two, subracted by the regular physical attack defense.

Not so sure how to achieve that... Or what all the terms are.

#### Bob423

##### Warper
How is the critical hit rate percentage (and other percentage based parameters) handled in code? I'm assuming 25% = 0.25, but I'd like to make sure and I'm not sure where to find out.

### Latest Profile Posts

Officially not a mod anymore. Thanks for the many years!
Thinking if i should post on the classifieds section...
(Plugins and details inside the description of the YouTube video.)
Castle is my Biggest Fear . I just Managed make Part by Part (like the Entrance only),not the Entire Castle like in the RM Sample...
This video really speaks to me...