RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 76 of 77 View original ↗
  1. G'day to ye lads and lasses!! I am here to ask about setting up a damage formula for the default Attack command that everyone uses. I noticed that using a.level just causes the game to crash if enemies use it, so I can't go that route (unless I give them a different skill altogether?).

    I was originally using the default damage formula of a.atk*4 - b.def*2, but was trying other damage formula to see what would work best for my game (I am using RPG Maker MV, for the record). I've tried
    (50*a.atk*a.atk)/(100+b.def) which does make stats really strong, but feels like it makes it hard to balance stats. For example:

    With this damage formula, and fighting Giant Fauna at level 99

    Fauna: 155 DEF vs 240 DEF (255 ATK)
    Giant Fauna: 100 ATK & 20 DEF
    Fauna: Takes ~2000 damage vs ~844 damage, deals 9999 damage
    60 DEF vs 100 ATK is about 3000 damage

    So this DOES let stats matter a lot (a big difference between 85 points of Defense for the player).

    Of note, the player stats are capped at 255 (forced by me), but enemies CAN go above 255 with buffs (I don't think the players can even with buffs with a hardcap??). I'm trying to make it so that each point matters a lot (you have Weapons, Shields (called Collabs, equippable units that grants a lot of different bonuses/penalties), and Accessories. There's no Helmets or Armors in this game).

    Once I figure this out, I can try to figure out a good way for Magic Attacks (they also use the default Magic damage formula too...don't know if using the Attack formula but switched to the magic stats would be ideal??). I suppose the above formula could work well if I fine tune enemy stats around what the player would be around that level of the game??
  2. Xenomic said:
    I noticed that using a.level just causes the game to crash if enemies use it, so I can't go that route (unless I give them a different skill altogether?).
    It's pretty easy to copy/paste Attack into a second slot that is what you assign to enemies with a slightly different formula.

    You can also reference this thread, which has some basic script calls and shows you how to do ternary (if/else) statements in your formula:
    Damage Formulas 101
    You just have to know what you'd use for the enemy instead. So you could incorporate
    Code:
    a.isActor() ? a.level : some_other_number

    Aside from that...I scanned through the rest of your post but didn't really get if you're asking a question.
  3. The question being what would be a good damage formula for the Attack command when player stats are hardcapped at 255 (and it's not super easy to boost stats outside of in-battle buffs and some equipment) in which makes the stats actually matter a lot if it's say...20 ATK vs. 15 DEF versus 25 ATK vs. 15 DEF. Does that help with the question?

    Though I will give that a try with the actor, I forgot all about that despite using it once or twice with some skills.
  4. Xenomic said:
    The question being what would be a good damage formula for the Attack command when player stats are hardcapped at 255...in which makes the stats actually matter a lot if it's say...20 ATK vs. 15 DEF versus 25 ATK vs. 15 DEF.
    The problem is that the formula does not exist in a void.

    It depends on how many HP the actors and enemies have; how many hits you want it to take to kill them; what "matter a lot" is in that context. The number they're capped at doesn't matter in and of itself.

    Making your formula be a.atk - b.def and the enemy has 15 HP will cause your 20/25 ATK vs. 15 DEF to make a huge difference :wink:

    There are 75 pages of this thread with formulae that are explained and demonstrated for you to peruse, also. Especially earlier on it was much more discussion and explanation of the math, it settled into more individual questions as the pages went on.

    For what it's worth, that's my recommended method - decide what scale of numbers you like (do you want your enemies to have 50 HP or 2,000?), decide how many standard attacks should kill one, then make a formula to produce that number.

    Maybe someone else will have more actionable feedback for you.
  5. I suppose I should've added more information to the original post too in regards to things like that. ^^;;

    I'm effectively going the Final Fantasy route with stats/HP (at level 99, most of the cast hits between 4500-8500 HP without any equipment or buffs), and most stats (without equipment) tend to hit around the 150 mark, give or take (some can hit around 200 ATK naturally, others can't hit 90 normally). For enemies, I try to have them start off with about 150 HP, and then by end game, normal mobs hit about 6500-18000 HP, give or take. Granted, I don't want the regular attacks to outclass skills, but it needs to be viable enough. I tried looking through the thread before posting, actually, and tried some formulae but don't know if they're exactly what I need. I WAS going to mimic the Final Fantasy VII damage formula but...I don't know how to mimic that since there's no "Strength" stat to substitute (and no Vigor stat to replicate the FFVI damage formula). You also get 4 party members in an active battle party, and can switch out active party members with those in reserve (8 party members total).

    But yeah, seems like it's just a looooot of testing to get the right thing. Just a very tedious process is all lol...I've forgotten about how troublesome it can be! I'm aware it's doesn't exist in a void (only a tree man does : v ), just thought about asking about it to see if I could get a bit of a headstart on it so I could move on to testing enemies a bit faster. ^^;
  6. Xenomic said:
    I WAS going to mimic the Final Fantasy VII damage formula but...I don't know how to mimic that since there's no "Strength" stat to substitute (and no Vigor stat to replicate the FFVI damage formula).
    I didn't do in-depth research, but from the first two articles that come up on Google, Strength isn't used in Final Fantasy VII's damage formula.

    But regardless, it seems like it should be simple math to take whatever Strength or Vigor should be doing and determine some portion of ATK/DEF to use instead (even if it's presuming the Strength is the same value as ATK and Vigor the same as DEF). I don't see how any player would know the difference.
  7. I feel like sharing this with others, in case they want this formula for themselves.

    So, I reused the FFVIII attack formula and modified it for both physicals and magic attacks.

    (((a.atk*a.atk)/16 + a.atk) * (265 - b.def)/256) * a.atk/64

    Replace a.atk with a.mtk and a.def with a.mdf for magic. Seems like this scales quite well with stats. If you use a lot of buffs in your game that stacks together, can just adjust the final number (64 to 32 lets buffs shine a lot more IIRC. Or it might be the other direction).

    (((a.atk*a.atk)/16 + a.atk) * (265 - b.def)/256) * a.atk/180

    I also tested how much this affects skills by adjusting the final number. Where a regular attack from a character with 255 ATK vs. 200 DEF does about ~6000 damage, the above skill would do about ~1600-1700, so it's good for if you want to make low-damage skills.

    Again, just wanted to share what I found, don't know if this is the topic for that or not. Wasn't sure what else I could adjust with this formula for other abilities (I outright removed raw numbers. Originally spells had values like 150 base damage on top of the formula, but with this formula...maybe those aren't needed anymore??)
  8. Xenomic said:
    Replace a.atk with a.mtk and a.def with a.mdf for magic.
    Just a quick note, that should be a.mat and b.mdf

    Good luck with your project!
  9. Hello everyone, I want to make two opposed d100 dice rolls. I want to preface that I'm not a coder, and don't fully grasp JavaScript. So in essence I want to make so that every melee attack would be an opposed roll where if the player rolled better than the enemy the attack would hit and if enemy rolled better it would a parry. So if you are familiar with D&D you are trying to beat a static number AC. But in some d100 TTRPG systems this is resolved using an opposed roll. This creates a more engaging and interesting system.

    Here's an example of what I want to do:
    Code:
    if(dice(1,100)<a.accuracy&&dice(1,100)<b.accuracy,100,0)

    This is a mathematical formula (as I understand it). What it does is rolls two d100 dice and then looks up if the first roll is under a.accuracy and the rolls a second d100 and then looks if that number is under b.accuracy. So say for an example that a.accuracy is 45 and b.accuracy is 40, the first roll is 40 and second roll is 50. This way the the attack went through and damaged the enemy for a certain amount of damage.

    I want to use this plugin
    GIT hub

    In which it says that it can use this function:
    JavaScript:
    * 
    *   The advanced method allows you to add another bonus based on caster or
    *   target stats (classic a/b variables like any other RMMV formula).
    * 
    *       SuperDiceRoll(a, b, "3d20+4 + <a.atk - b.def>")
    * 
    *   That example rolls 3 virtual D20 dice, adds 4 to the result and further adds
    *   the user's ATK minus the target's DEF (or subtract if the number is negative!)
    * 
    *   The minus symbol does work. The following equations are also valid:
    * 
    *       DiceRoll("3d4-1")
    *       SuperDiceRoll(a, b, "10d3+1 - <b.charisma - a.charisma>")
    *
    *   The Dice Roll system is best when used with a custom stat plugin like
    *   BOB_CustomStats.js so you can implement real D&D stats and modifiers
    *   to use in these formulas.
    *
    *   Just paste the method into your damage formula box to use. It must be
    *   formatted as a JavaScript function call with your custom formula in quotes
    *   just like the examples. The SuperDiceRoll() function REQUIRES you to put
    *   the a and b parameters first so they becom accessible to the code.



    Since I don't know how to code I fed the code and to the AI and it gave me this:
    JavaScript:
    if (SuperDiceRoll(a, b, "1d100 + <a.melee - b.melee>") > SuperDiceRoll(b, a, "1d100 + <b.melee - a.melee>")) {
        100;
    } else {
        0;
    }

    But reading through what is possible in RPG Maker MV it seems that this is not what I want and probably won't even work if I put it in the Damage formula. Can this be done? Any help would be appreciated.
  10. @JackFlotsam Wow. Holy cow.

    Please get rid of the several pages of code. Either put it in spoilers or attach the .js files to your post (or, best yet, just provide a link to them).

    I'm not even trying to read through those because I'm trying to figure out your actual question.

    A few notes:
    JackFlotsam said:
    Since I don't know how to code I fed the code and to the AI and it gave me this
    Never a great idea. AI generators, by definition, make things up. I've never seen code from an AI that didn't either have extra garbage in it or was completely non-functional.

    JackFlotsam said:
    it seems that this is not what I want and probably won't even work if I put it in the Damage formula.
    That's correct. You're asking about changing how to hit someone, which does not take place in the damage formula.

    There are several hit formula or hit accuracy plugins for MV you can find if you do a Google for that.
  11. JackFlotsam said:
    I want to make two opposed d100 dice rolls. I want to preface that I'm not a coder, and don't fully grasp JavaScript
    if that was the goal, you can do what without a plugin. you can use Math.randomInt(x)+1 to simulate a dx roll.
    so you can turn that condition into
    Code:
    Math.randomInt(100)+1 < a.accuracy && Math.randomInt(100)+1 < b.accuracy

    I am assuming that an accuracy property is properly defined on your battlers and is separate from the engine's HIT? I dont know where you have this, but if its somewhere to actually affect hit chances and accuracy doesnt exist, that wont work

    JackFlotsam said:
    Here's an example of what I want to do:
    Code:
    if(dice(1,100)<a.accuracy&&dice(1,100)<b.accuracy,100,0)
    This is a mathematical formula (as I understand it). What it does is rolls two d100 dice and then looks up if the first roll is under a.accuracy and the rolls a second d100 and then looks if that number is under b.accuracy. So say for an example that a.accuracy is 45 and b.accuracy is 40, the first roll is 40 and second roll is 50. This way the the attack went through and damaged the enemy for a certain amount of damage.
    close, but that 100,0 at the end of the if changes it. is that a copy paste error? all that condition will ever do is return 0, and your if will never pass with that there
  12. ATT_Turan said:
    @JackFlotsam Wow. Holy cow.

    Please get rid of the several pages of code. Either put it in spoilers or attach the .js files to your post (or, best yet, just provide a link to them).

    I'm not even trying to read through those because I'm trying to figure out your actual question.

    A few notes:

    Never a great idea. AI generators, by definition, make things up. I've never seen code from an AI that didn't either have extra garbage in it or was completely non-functional.


    That's correct. You're asking about changing how to hit someone, which does not take place in the damage formula.

    There are several hit formula or hit accuracy plugins for MV you can find if you do a Google for that.
    Oops, I didn't realize it would dump the whole code here. Anyway there's actually a hit formula that can be used in RPG Maker MV? Thanks, I just assumed it was only a damage formula. Yeah, AI isn't great at things but it's still can be useful.
    Robro33 said:
    if that was the goal, you can do what without a plugin. you can use Math.randomInt(x)+1 to simulate a dx roll.
    so you can turn that condition into
    Code:
    Math.randomInt(100)+1 < a.accuracy && Math.randomInt(100)+1 < b.accuracy

    I am assuming that an accuracy property is properly defined on your battlers and is separate from the engine's HIT? I dont know where you have this, but if its somewhere to actually affect hit chances and accuracy doesnt exist, that wont work


    close, but that 100,0 at the end of the if changes it. is that a copy paste error? all that condition will ever do is return 0, and your if will never pass with that there
    Well, it's from another engine TBH, it uses .NET calculator and I am not sure about the syntax. But yes, it's supposed to rely on defined number in characters stats. And roll the number under using a d100.
  13. Im working on an addition to a heal that will damage all enemies for a portion of the heal. My problem is calling the enemies because they are not the target.

    Im trying to use this format for the damage portion but im not sure how to change the target aspect of this to pull the enemies. (yes i know there is no check for the state i will be using to trigger this yet)
    <JS Post-Damage>
    for (let i=0; i<target.friendsUnit().aliveMembers().length; i++) {
    if(target.friendsUnit().aliveMembers()[i]!=target) {
    target.friendsUnit().aliveMembers()[i].gainHp(0 - Math.round(value / 5));
    target.friendsUnit().aliveMembers()[i].startDamagePopup();
    }
    }
    </JS Post-Damage>
    Any help would be appreciated.
  14. Oggy said:
    Im working on an addition to a heal that will damage all enemies for a portion of the heal.
    This is nothing to do with the damage formula, you're using notetags from an unspecified plugin.

    (it's also nothing to do with MV, so you're batting zero for posting in an appropriate thread :stickytongue: )

    Instead of friendsUnit(), you'd use opponentsUnit().

    Code:
    target.opponentsUnit().aliveMembers().forEach(battler => {battler.gainHp(-Math.round(value/5)); battler.startDamagePopup()});
  15. Sorry i miss read what thread i was in. Thanks though for the info.
  16. So I tried to make a stupidly complex damage reduction formula that turned out to be very similar to Fallout calculations.

    Sigmoid Damage Reduction.PNG

    The short explanation is that DEF matters a lot, up until 75% damage reduction at ATK=DEF. More DEF than that is basically useless. ATK is essentially your armor penetration stat, while squishy mages can take around 4x as much damage as your tank.

    Healing and max hp will be more equal between dps and tanks, making tank heals far more MP efficient, and more powerful skills will add multipliers rather than increasing ATK.

    I also suspect this will be a rather inefficient formula on processing power.
  17. I made a parabola completely by accident:

    (a + (b + (1 * (x / 5))) * x

    It's still not want I wanted but was a bit surprised I came up with that without it feeling like guess work.
  18. Arctica said:
    I made a parabola completely by accident:

    (a + (b + (1 * (x / 5))) * x

    It's still not want I wanted but was a bit surprised I came up with that without it feeling like guess work.

    What was this supposed to do? It's not a damage formula, that is for sure.

    Edit: Also, your formula has a lot of information in there, that does absolutely nothing. Multiplying by 1 does nothing. Also brackets are supposed to give fractions of the formula priority over the rest. Parts that already have priority, don't need brackets. And when you have more opening brackets than closing ones, your formula gets an error.

    This is the same formula as yours. I don't know what it is supposed to do, but this should give the exact same outcome as what you proposed (but without the error):

    Code:
    ( a + b + x / 5 ) * x

    Edit again: Made a little mistake in the last edit, so edit again.
    :p
  19. Hi, everyone. Both a quick question and a complaint. First, the question, to get it out of the way. What is wrong with my damage formula, and how do I fix it?

    ( Math.arctan( a.atk - b.def ) + 2 ) * a.atk - enemy.level * enemy.level

    Explanation: The arctangent of the difference between the attacker's attack and the defender's defense, plus two (to bring it above zero), acting as a multiplier to the attacker's attack, with flat damage reduction provided by the opponent's level (functions helpfully provided by Yanfly's Enemy Levels plugin). This turns the attack/defense ratio into a smoothly-asymptoting multiplier ranging from 0 to 4 (this aspect is depicted in the attached picture to make sure I wasn't getting my basic trig wrong), while also preventing early kills on much-higher-leveled enemies. Anyway, tested both with and without the enemy.level * enemy.level at the end, and I've been getting 0 both times.

    Now the complaint: It is very very frustrating to search for basic information on the syntax, operators, and formulae I must use for the damage formula in RPGM. How must I format this? Does it obey typical PEMDAS? I literally have no idea where to even go for that information. That kind of stuff should really be added to some of the damage formula tutorial posts, tbh.
  20. PvtRyan96 said:
    ( Math.arctan( a.atk - b.def ) + 2 ) * a.atk - enemy.level * enemy.level
    Math.arctan does not exist; consider Math.atan instead:

    PvtRyan96 said:
    It is very very frustrating to search for basic information on the syntax, operators, and formulae I must use for the damage formula in RPGM. How must I format this?
    MV/Z damage formulae are JavaScript evals. Almost any JS is valid:
    Certain values like a and b are local variables defined specifically for ease of reference in the eval:
    rpg_objects.js excerpt
    JavaScript:
    Game_Action.prototype.evalDamageFormula = function(target) {
        try {
            var item = this.item();
            var a = this.subject();
            var b = target;
            var v = $gameVariables._data;
            var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);
            var value = Math.max(eval(item.damage.formula), 0) * sign;
    		if (isNaN(value)) value = 0;
    		return value;
        } catch (e) {
            return 0;
        }
    };