RMMV Damage Formula - ideas and help

Entwist

Warper
Member
Joined
Oct 8, 2015
Messages
1
Reaction score
8
First Language
English
...how would I go about adding a random number to a formula? Specifically, doing something like "ATK + d4" where the random element is a flat value, and isn't percentage-based like the core Variance value on skills.
I'm a new member, so someone else might answer this before I get out of moderation, but from looking at js/rpg_core.js, it looks like you should be able to get a random number between 0 and 4 by using

    Math.randomInt(5)

Notice you pass in a 5 to get a random number between 0 and 4.
 

Seikame

Warper
Member
Joined
Oct 25, 2015
Messages
2
Reaction score
0
First Language
french
I guess those formula and the agility system in the JS code are the only things left of those good old battle formula ?

I mean, I really miss the dexterity factor, and trying to replace the luck with it is kinda harsh. I know traits are supposed to replace it but I don't think they can make the chances to hit or crit evolving with leveling and upgrading stats...

I have searched into the main JS codes, but didn't foud much. Anything I missed ?

Thank you.
 

SmashBroPlusB

Villager
Member
Joined
Oct 25, 2015
Messages
14
Reaction score
18
First Language
English
Hey! For anyone else having trouble with random integers, I think I figured it out!

a.atk + Math.randomInt(4) +1 - b.defWhile looking at another plugin that changes the starting value for TP, I noticed a "Math.randomInt()" being used in the plugin's functions. Seeing as how rand() was clearly broken, and I didn't really have anything to lose, I decided to toss this in and give it a shot... and I'm getting random damage within 4 values, just as intended!

Guess that's one mystery solved.
 

JosephSeraph

White Mage
Restaff
Joined
Mar 7, 2014
Messages
1,187
Reaction score
1,431
First Language
Portuguese
Cool! Soooooo.... I'm guessing there's more stuff you can do with Math. !
 
Last edited by a moderator:

JahwsUF

Veteran
Veteran
Joined
Oct 25, 2015
Messages
65
Reaction score
105
First Language
English
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).
 

Ministry

Villager
Member
Joined
Jun 27, 2012
Messages
17
Reaction score
9
First Language
English
Primarily Uses
I've seen a few people ask about this but I have not seen any answers yet. I tried a few things and (thanks to Script Call list) figured it out.

The easiest way to add a state to the user of a skill is to put this in the damage formula box:

a.addState(n)where n= the id # of the state of course. For example, state number 0027 would be entered like "a.addState(27)"

A lot of my skills involve state manipulation so I am very pleased to find this and share it.
 

JosephSeraph

White Mage
Restaff
Joined
Mar 7, 2014
Messages
1,187
Reaction score
1,431
First Language
Portuguese
That looks cool JahwsUF!

Would you mind explaining us all the Math. functions?

Also great info Ministry!
 

Taemien

Veteran
Veteran
Joined
Sep 11, 2015
Messages
79
Reaction score
14
First Language
English
Primarily Uses
This will bypass the defense stat entirely and deal damage based on the Physical Defense SP-Parameter.

a.atk * b.pdrThis is useful when using a plugin to allow defense to directly affect the PDR stat.

For magic based attacks you can use this:

a.mat * 1.5 * b.mdrReason I use these over traditional Def and Mdf is due to 'lower level' attacks or enemies becoming too trivial past a certain point. With a.atk * 4 - b.def * 2 you quickly find that an Atk stat of 10 is trivial to 40 defense or higher.

Of course the real trick is making Def affect pdr and mdef affect mdr in a diminishing return. That's something I've been trying to work out in Ace. Haven't been able to do it in MV yet due to not having a plugin yet to make those stats interact.
 

JahwsUF

Veteran
Veteran
Joined
Oct 25, 2015
Messages
65
Reaction score
105
First Language
English
That looks cool JahwsUF!

Would you mind explaining us all the Math. functions?

Also great info Ministry!
To compute the natural logarithm of something:

Math.log(x)It's the inverse of exp(x).  Using the following instead computes log base 10 of x:

Math.log10(x)This function grows really slowly.  log10(10) = 1, log(100) = 2, log(1000) = 3.  (The number of powers of ten that make up x's value.)

The last special math function used above raises x to the power of y:

Math.pow(x, y)I hear that in older versions, you used to be able to write "x ** y" in place of this.  So, Math.pow(5, 2) = 25.

--------

In context of the formula above, the design is such that when attack and defense are perfectly matched, damage dealt grows at a rate of x * log x - it grows slightly faster than the attack value itself, so you'll always feel like your character is growing and dealing more damage as long as you aren't attempting a majorly low-level run.  (Think variable attack, fixed defense for this part.)  This is modified by the other log portion, which multiplies this "base" attack value according to the ratio of involved attack and defense. 

Stronger attack values compared to defense will boost damage reasonably, while weaker attack values will progressively weaken damage without zeroing it out except for the most impossibly mismatched of cases.  Defense thus serves to scale damage while not neutering it.  Enemy damage output stays relevant for longer, though the growth rate of damage allows more rapid overpowering of old enemies.

Some rough figures are below.  Note that in these figures below, it's best to think of the implications as if attack is fixed but defense is changing, as the "base damage" is solely based on the attack value - that atk * log10(atk) portion.

atk / def = 1 => exact base damage

atk / def = 3 => double base damage

atk / def = 7 => triple base damage

atk / def = 0.4142 => half base damage

atk / def = 0.26 => one-third base damage

atk = 0 would be required to do literally no damage except for extreme rounding effects.
 
Last edited by a moderator:

Xypher

Veteran
Veteran
Joined
Apr 1, 2012
Messages
148
Reaction score
26
Primarily Uses
This will bypass the defense stat entirely and deal damage based on the Physical Defense SP-Parameter.

a.atk * b.pdrThis is useful when using a plugin to allow defense to directly affect the PDR stat.

For magic based attacks you can use this:

a.mat * 1.5 * b.mdrReason I use these over traditional Def and Mdf is due to 'lower level' attacks or enemies becoming too trivial past a certain point. With a.atk * 4 - b.def * 2 you quickly find that an Atk stat of 10 is trivial to 40 defense or higher.

Of course the real trick is making Def affect pdr and mdef affect mdr in a diminishing return. That's something I've been trying to work out in Ace. Haven't been able to do it in MV yet due to not having a plugin yet to make those stats interact.
that would apply the pdr/mdr reduction twice.
 

Smelipanda

Veteran
Veteran
Joined
Oct 25, 2015
Messages
40
Reaction score
38
First Language
English
I was wondering is it possible using the damage formula to have a state applied to self after dealing damage with a skill? Currently i am using
(a.atk + a.mat) * ((a.hp / a.mhp) * (a.mp / a.mmp)) ; a.addState(18) , but this ignores the whole first part. Any help would be appreciated. Thanks
 

YouKnowA

Villager
Member
Joined
Oct 27, 2015
Messages
10
Reaction score
6
First Language
English
Hi RPG Makers, I've been poking at the damage formulas some.

Hopefully these ideas can help others come up w/ even better ones!

var x = 1; var arr = [2, 3, 4, 5, 6, 7]; for (var i = 0, len = arr.length; i < len; i++) {x *= b.isStateAffected(arr) ? 2 : 1}; a.atk * x;^This does more damage against enemies who have status ailments 2-7 (I used Shaz's converter, so they're the VX Ace ailments in my game). It seems to work pretty well. However, if you have any suggestions on how to tighten it up, I'd appreciate it. It's been more than a few years since I last used Javascript. Feel free to use the formula for an assassin or rogue-type character who can poison/paralyze/blind/etc. an enemy, and then take advantage of the moment.

a.atk * 4 * b.elementRate(12)^Is a pretty simple idea, but may be fun for you. I made element 12 Orc-slaying. So, ogres and orc variants have like 250% weakness (versus everyone else's standard 100%). I put this attack on Warmup and Cooldown (Yanfly scripts) so every few turns you can pretty much wreck an orc. Even against non-orcs, it's still a certain hit not modified by b.def so it isn't a total waste... just probably not the most optimal move. Giving the attack the orc-slaying element makes the attack's whole power about 2.5x stronger vs. orcs. (If you want to amp up the craziness, try a.atk * 4 * (b.elementRate(12) * b.elementRate(12))  ...that'll super wreck orcs. It may not be useful for every game, but being able to super exploit a weakness always seems interesting to me.

I got a lot of my ideas from http://www.rpgmakervxace.net/topic/8986-skill-ideas-you-can-do-with-custom-formula/ and Fomar's old blog but, tried to do them w/ js. For some odd reason I'm having a heckuva time linking to http://cobbtocs.co.uk/wp/?p=271
 
Last edited by a moderator:

Mieze

Maker Freak
Veteran
Joined
Apr 21, 2013
Messages
108
Reaction score
99
First Language
German
Primarily Uses
N/A
an idea of mine for the maker, or something similar. I found no other thread where that can purely

 

they can at least make a converter from Ace to MV. there are many who viewed the whole pack bought.

and then it works, as in my case, with the current Converter plugin not. I only want the Tilesets and villt character and not the whole map, or anything.

Then I can make my game in the Ace still the same, if you can transfer finished goods from there to the MV. This is something absurd in my opinion.

but I want my game in MV do with the resources from the Ace. XP is not important for there eh hardly anything but at least at the Ace would have to think properly.

 

otherwise I love the new MV he's great. Would that still be governed by the Ressoursen he would be close to perfect .. well except some small errors and bugs;)

But otherwise, as I said super part. So far, the best.
 
Last edited by a moderator:

whitesphere

Veteran
Veteran
Joined
Mar 14, 2014
Messages
1,688
Reaction score
784
First Language
English
The Math object in Javascript has a great number of functions.  Such as Math.min, which returns the lowest of the values passed in and Math.max which returns the highest of the values.

If you always wanted an attack to deal, at least, say, 5 points of damage, you could use Math.max( (4*a.atk - 2*b.def), 5).

It might be a useful way to distinguish Magic spells.  More powerful single attack spells could have a higher damage floor so they always deal, say, 100 points of damage, regardless of magical defense.  

But I also like JahwsJF's damage function.
 

Liak

Veteran
Veteran
Joined
Mar 13, 2012
Messages
1,788
Reaction score
270
First Language
German
Primarily Uses
Can we make a list of all the JavaScript functions/methods/whatever-it-is-called in the original post? :) That would be awesome!
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,881
Reaction score
2,050
First Language
English
Primarily Uses
RMMV
I had this skill that would let you swap around an ally's HP and MP, this was the VXAce formulae:

c=b.hp;d=b.mp;b.hp=(d*1.33+b.level).to_i;b.mp=(c*0.5-b.level).to_i;0but it's no longer working, giving me a "has no effect" message in battle.

How do I make this skill work in MV?

Full explanation of the formulae:

Target's HP becomes: (Target's current MP * 1.33 + Target's Level), Target's MP becomes: (Target's current HP / 2 - Target's Level). Rounding off both numbers to avoid decimals.
 

whitesphere

Veteran
Veteran
Joined
Mar 14, 2014
Messages
1,688
Reaction score
784
First Language
English
There is no need for the to_i function.  That is Ruby specific.  In fact, Javascript treats all numbers (except array indexes) as floating point.  Try:

c=b.hp;d=b.mp;b.hp=d*1.33+b.level;b.mp=c*0.5-b.level;0
 

Liak

Veteran
Veteran
Joined
Mar 13, 2012
Messages
1,788
Reaction score
270
First Language
German
Primarily Uses
I have 3 questions.

1. How do you get the number of states on someone?

2. How do you do "if" branches, is there are short version? In Ruby, it was "condition ? yes : no". What's the equivalent?

3. Is there a way to get the turn number?
 

Latest Threads

Latest Profile Posts

Well. Looks like I need to redo the entire battle system in order to have the things I want in it. Also I'd like to say that console.log() is the greatest function in Javascript XD.
I have made 60 new skills! ''after test'' I have made 3 new skills!

Made a new battleback this week! How's it look?
"This is the real secret to life - To be completely engaged with what you are doing in the here and now. And instead of calling it work, realize it is play."

Forum statistics

Threads
113,815
Messages
1,077,677
Members
147,869
Latest member
asdfd
Top