RMMV Damage Formula - ideas and help

Discussion in 'RPG Maker MV' started by Shaz, Oct 25, 2015.

  1. Entwist

    Entwist Warper Member

    Messages:
    1
    Likes Received:
    6
    First Language:
    English
    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.
     
    #21
  2. Seikame

    Seikame Warper Member

    Messages:
    2
    Likes Received:
    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.
     
    #22
  3. SmashBroPlusB

    SmashBroPlusB Villager Member

    Messages:
    14
    Likes Received:
    14
    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.
     
    #23
    Rayhaku808, JLowther and Rutibex like this.
  4. JosephSeraph

    JosephSeraph White Mage Restaff

    Messages:
    808
    Likes Received:
    658
    Location:
    Santos, Brasil
    First Language:
    Portuguese
    Cool! Soooooo.... I'm guessing there's more stuff you can do with Math. !
     
    Last edited by a moderator: Oct 26, 2015
    #24
  5. JahwsUF

    JahwsUF Veteran Veteran

    Messages:
    65
    Likes Received:
    102
    Location:
    USA
    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).
     
    #25
  6. Ministry

    Ministry Villager Member

    Messages:
    17
    Likes Received:
    8
    Location:
    California
    First Language:
    English
    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.
     
    #26
  7. JosephSeraph

    JosephSeraph White Mage Restaff

    Messages:
    808
    Likes Received:
    658
    Location:
    Santos, Brasil
    First Language:
    Portuguese
    That looks cool JahwsUF!

    Would you mind explaining us all the Math. functions?

    Also great info Ministry!
     
    #27
  8. Taemien

    Taemien Veteran Veteran

    Messages:
    79
    Likes Received:
    14
    First Language:
    English
    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.
     
    #28
    Rayhaku808 likes this.
  9. JahwsUF

    JahwsUF Veteran Veteran

    Messages:
    65
    Likes Received:
    102
    Location:
    USA
    First Language:
    English
    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: Oct 26, 2015
    #29
  10. Xypher

    Xypher Veteran Veteran

    Messages:
    148
    Likes Received:
    24
    that would apply the pdr/mdr reduction twice.
     
    #30
    Gelvwn likes this.
  11. Smelipanda

    Smelipanda Veteran Veteran

    Messages:
    40
    Likes Received:
    35
    Location:
    Wisconsin
    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
     
    #31
  12. Shaz

    Shaz Veteran Veteran

    Messages:
    37,583
    Likes Received:
    11,299
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Put the a.addState() first.  The damage must be the LAST thing in the formula.
     
    #32
  13. Smelipanda

    Smelipanda Veteran Veteran

    Messages:
    40
    Likes Received:
    35
    Location:
    Wisconsin
    First Language:
    English
    You answer all my questions shaz! Thank you! :D
     
    #33
    Sauteed_Onion likes this.
  14. YouKnowA

    YouKnowA Villager Member

    Messages:
    10
    Likes Received:
    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: Oct 27, 2015
    #34
  15. Mieze

    Mieze Maker Freak Veteran

    Messages:
    107
    Likes Received:
    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: Oct 27, 2015
    #35
  16. whitesphere

    whitesphere Veteran Veteran

    Messages:
    1,688
    Likes Received:
    784
    Location:
    Somewhere on Earth
    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.
     
    #36
  17. Liak

    Liak Veteran Veteran

    Messages:
    1,789
    Likes Received:
    269
    Location:
    Germany
    First Language:
    German
    Can we make a list of all the JavaScript functions/methods/whatever-it-is-called in the original post? :) That would be awesome!
     
    #37
  18. Milennin

    Milennin "With a bang and a boom!" Veteran

    Messages:
    2,184
    Likes Received:
    1,243
    Location:
    Fiore
    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.
     
    #38
  19. whitesphere

    whitesphere Veteran Veteran

    Messages:
    1,688
    Likes Received:
    784
    Location:
    Somewhere on Earth
    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
     
    #39
    Wren likes this.
  20. Liak

    Liak Veteran Veteran

    Messages:
    1,789
    Likes Received:
    269
    Location:
    Germany
    First Language:
    German
    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?
     
    #40

Share This Page