RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 33 of 77 View original ↗
  1. omega9380 said:
    Is it possible to output the result of the damage formula to the console?  I tried using:



    console.log( a.atk * 4 - b.def * 2 )


    as my damage formula and it throws errors whenever the skill is used.  I trying figure out where I screwed a formula up in my game and would like to see if the damage formula is being evaluated correctly.  MV really needs a full debug mode that outputs more information to the console.



    Well for something as simple as that formula you could just use a calculator. Spreadsheets are also very handy for more complex formula. As far as I'm aware, if you set the variance of a skill to 0% then the damage output will always be the same. The value will be the exact sum of your formula... so let's work this out for you:

    let's say users attack is 32 and target defence is 22. so what your formula is saying is (32*4) - (22*2) = 128 - 44 = 84


    Therefore your attack damage output constant is 84. the variance thereafter is just how much as a percentage above or below that constant will be.


    Failing that I find an easy way to test skills out is to create a dummy troop and run a battle test.


    Hope that Helps
  2. Coopziana said:
    Well for something as simple as that formula you could just use a calculator. Spreadsheets are also very handy for more complex formula. As far as I'm aware, if you set the variance of a skill to 0% then the damage output will always be the same. The value will be the exact sum of your formula... so let's work this out for you:

    let's say users attack is 32 and target defence is 22. so what your formula is saying is (32*4) - (22*2) = 128 - 44 = 84


    Therefore your attack damage output constant is 84. the variance thereafter is just how much as a percentage above or below that constant will be.


    Failing that I find an easy way to test skills out is to create a dummy troop and run a battle test.


    Hope that Helps

    The problem is I'm using some plugins that modify the damage formula among others and I'm trying to track down where I fuggered a formula up.  Using a calculator won't help me there, I need to see what the game is getting when it runs a calculation.  I may have to break down and edit the source files, throw in a console.log in all the functions to output the return to console, so i can see whats going on.
  3. omega9380 said:
    The problem is I'm using some plugins that modify the damage formula among others and I'm trying to track down where I fuggered a formula up.  Using a calculator won't help me there, I need to see what the game is getting when it runs a calculation.  I may have to break down and edit the source files, throw in a console.log in all the functions to output the return to console, so i can see whats going on.

    What plugin are you using and what's your formula, I'll have a look and see if I can work it out for you.
  4. I'm no mathmetician, and I've been having trouble getting the perfect damage formula for my game. So, the low end of the atk/def stats is around 16, and the high end is around 250. I want damage at the low end to be around 50 vs. a similar defense stat, and to be closes 60k vs a similar defense stat at the high end. I've experimented, but just can't seem to come up with a formula that works for this. Anyone know how to make a formula that will achieve what I want?
  5. @inamortus: That is going to be tough mathematically. A straight linear equation for those numbers you gave has it going atk/def 16 -> returns 50, but atk/def 17 -> 300! That is because of your final target of 60K at 250 atk/def, a linear formula requires it to go up 254.27 per point of atk/def.


    May need to rethink your final ATK/DEf for that to happen, or investigate into an exponential formula. Excel can probably figure out for you an exponential formula with those points.


    Edit: I tried to use excel and have it try a multiple regression on that (as you have three variables, ATK, DEF, and damage output), and it failed, as it requires three points (you only had 2). I think you're going to want to think up what you want damage to be for some of those mid-points on the way, and use those. Also may wish to think how much 1 point of DEF should block, and that will make it easier. Do you want 1 point DEF = x HP always blocked, or do you want it to be a percentage of damage blocked? Both those decisions will affect your formula.


    In summary, we need more information. More data points, specifically the middle ones. Figure out what ATK/DEK of 20, 30, 40, 50 60, etc should do and then you should be able to use excel or some statistical software to generate an equation that is close to those outputs (I saw close, as NO formula will hit them all perfectly, that's mathematically impossible without introducing weird variance for the points not provided, or going to complicated cubic splines which will be more than the damage box can handle).
  6. Guys, i'm with a small doubt

    If i add a.tgr(1); to my formula will it increase TGR? Will it reset at the end of combat?
  7. bgillisp said:
    @inamortus: That is going to be tough mathematically. A straight linear equation for those numbers you gave has it going atk/def 16 -> returns 50, but atk/def 17 -> 300! That is because of your final target of 60K at 250 atk/def, a linear formula requires it to go up 254.27 per point of atk/def.


    May need to rethink your final ATK/DEf for that to happen, or investigate into an exponential formula. Excel can probably figure out for you an exponential formula with those points.


    Edit: I tried to use excel and have it try a multiple regression on that (as you have three variables, ATK, DEF, and damage output), and it failed, as it requires three points (you only had 2). I think you're going to want to think up what you want damage to be for some of those mid-points on the way, and use those. Also may wish to think how much 1 point of DEF should block, and that will make it easier. Do you want 1 point DEF = x HP always blocked, or do you want it to be a percentage of damage blocked? Both those decisions will affect your formula.


    In summary, we need more information. More data points, specifically the middle ones. Figure out what ATK/DEK of 20, 30, 40, 50 60, etc should do and then you should be able to use excel or some statistical software to generate an equation that is close to those outputs (I saw close, as NO formula will hit them all perfectly, that's mathematically impossible without introducing weird variance for the points not provided, or going to complicated cubic splines which will be more than the damage box can handle).

    Thanks for helping out. Would it be much easier to just make the stat cap higher? For example, I would be able to do something much simpler if I had ATK and DEF go up to 1000 or so?
  8. Inamortus said:
    Thanks for helping out. Would it be much easier to just make the stat cap higher? For example, I would be able to do something much simpler if I had ATK and DEF go up to 1000 or so?

    Sort of. The problem is the 60K damage more than anything. Even if we throw out DEF that is still 59500 damage increase over the course of the game (from 50 to 60000) which, using a linear equation is (60000 - 50) / (1000 - 16) = 59500/984 = 60.47 points of HP each point of ATK needs to increase by to hit your target. Still, this does mean the formula (60.47 + x) * a.atk - x * b.def will do what you want (let x be how much you want 1 point of DEF) to reduce damage by, if you set the upper cap to 1000 for ATK/DEF.


    However, this has some serious problems, which you will notice in testing quickly, which is going up just 1 point in ATK is a huge boost, and a high enough DEF = 0 damage. An exponential formula will fix some of this, but then you don't see the high damage until much later. If you are ok with that, here is one that works with your original idea (16 ATK -> 50 damage, 250 ATK -> 60K damage):


    74.709 * e^(0.0317*a.atk) - 37.355*e^(0.0299* b.def).


    This formula assumes that someone with 0 DEF takes 2x the damage you posted (so 16 ATK to 0 DEF does 100 damage, 250 ATK to 0 DEF does 120000 damage).


    (^ is raise to power. Not sure the javascript command for that one, so may need to ask around. e is the number 2.71828..., and you may have to type that in place of e as not sure if there is a command for e in the code).


    PS: You can get these formulas in Excel by using the trendline command. It needs 3 points though (I assumed 100 ATK -> 1000 damage, seemed a nice middle point), else it does strange things. I had it make one for ATK only and one for DEF only and subtracted the two to get the formula above.
  9. bgillisp said:
    Sort of. The problem is the 60K damage more than anything. Even if we throw out DEF that is still 59500 damage increase over the course of the game (from 50 to 60000) which, using a linear equation is (60000 - 50) / (1000 - 16) = 59500/984 = 60.47 points of HP each point of ATK needs to increase by to hit your target. Still, this does mean the formula (60.47 + x) * a.atk - x * b.def will do what you want (let x be how much you want 1 point of DEF) to reduce damage by, if you set the upper cap to 1000 for ATK/DEF.


    However, this has some serious problems, which you will notice in testing quickly, which is going up just 1 point in ATK is a huge boost, and a high enough DEF = 0 damage. An exponential formula will fix some of this, but then you don't see the high damage until much later. If you are ok with that, here is one that works with your original idea (16 ATK -> 50 damage, 250 ATK -> 60K damage):


    74.709 * e^(0.0317*a.atk) - 37.355*e^(0.0299* b.def).


    This formula assumes that someone with 0 DEF takes 2x the damage you posted (so 16 ATK to 0 DEF does 100 damage, 250 ATK to 0 DEF does 120000 damage).


    (^ is raise to power. Not sure the javascript command for that one, so may need to ask around. e is the number 2.71828..., and you may have to type that in place of e as not sure if there is a command for e in the code).


    PS: You can get these formulas in Excel by using the trendline command. It needs 3 points though (I assumed 100 ATK -> 1000 damage, seemed a nice middle point), else it does strange things. I had it make one for ATK only and one for DEF only and subtracted the two to get the formula above.

    Anyone know how to do raise to power here? I searched around and tried Math.pow, but that just caused 0 damage every time. Again, thanks for all your help.
  10. Your looking at the problem from the wrong angle


    ATK/DEF gives a ratio value, so first lets get the min and max ratio (will ignore change in DEF)


    16/16 is 1


    250/16 is 15.625


    this means the min damage is 15 times smaller than the max damage


    the best way to increase damage through the game is to use a set value power for attacks that increases in value for late game moves


    in truth most damage formulas needs three parts


    1) A set value


    2) A growing value (this is so the move gets stronger with the character)


    3) A comparison (in most cases this would be '/DEF')


    So, early game and late games stats vs. early and late game enemies are relative, increase the power of moves for late game by giving them more power


    The way I like to do it in Excel is set out the damage formula, plugin the values manually (the formula grabs the stats from the cell) then work out the number of hits to kill then the number of turns to victory (so a part of 4 would get 4 hits per turn, always round this value up)


    Best thing to do is balance out stats then have to large a jump in damage
  11.  I have a possible solution for you but it depends on whether or not you mind using the Luck stat for damage determination. If you start luck at 1 and set it to rise at a rate of 1 per level, then this formula will work. Then set the enemy's Luck stat to whatever its effective level is (just be sure not to mess around with luck too much on gear if you use this)


    (a.atk * (2.5 * a.luk)) * ((a.atk + a.luk)/(b.def + b.luk))


     the starting damage will be 40ish at level 1 against a target with a similar defense (at 16 vs 16) and will rise to 61,875 at level 99 (at 250 vs 250).


     that was about as close as I could get it :p
  12. I was playing around with damage formulae the other day, trying out different schemes.


    I experimented with a formula like Yanfly's for armor, but I found I wasn't quite satisfied with that, as the usefulness of additional defense fell off too quickly, and it complicated calculations so that they weren't as easy to do in my head.  Instead of offering percentage-based buffs to defense or magic defense, it would seem to make more sense under such a system to create states that simply reduce the rate of physical or damage of all relevant elements.


    Then I played around with making a damage formula along the lines to the rapidly escalating power that you'd see in Final Fantasy games.  Taking inspiration from some other posts that I saw, I used   (a.atk*a.atk/16) - (b.def*b.def/32).  The post in question that I saw used the same term for attack squared, but had a coefficient of 1/9 for defense squared instead.  However, I didn't want defense to be more powerful than attack, and often there's a rule of thumb that you should have twice the attack as defense, so I just enforced this by halving the defense term relative to the attack term.  However, this lets me use similar numbers for both attack and defense, and if I happen to rename the stats it doesn't look like one is lopsided over the other, creating an impression of balance. It's also simple to calculate the effect of a percentage change in either stat.


    Of course, a damage formula needs to be matched with a suitable range of stats.  So I went from 50 HP to 7500 HP, with a fairly slow growth curve, 5 MP to 750 MP, and 8 to 200 for Attack, Defense, Magic Attack, Magic Defense, Agility, and Luck (adjusting the formula for luck's effectiveness in the .js file to make it twice as potent).  Overall, this seemed to produce the numbers I had in mind in battle testing.


    I'm still trying to work out what appropriate modifications to the damage formula for skills and spells should be.  Some can obviously be a certain percent stronger than a physical attack, and I'd like to apply essentially the same formula for base magic damage (a.mag*a.mag/16)-(b.mdef*b.mdef/32), adapted for discrete spell levels.
  13. Hello.
    I about the problem, which is the damage calculation formula, you spend a week.
    Anyone can get help to the formula that I think?
    When you defeat the enemy, please tell me the damage calculation formula that can get the enemy of gold on the spot.
    Rather than after the end of combat, if defeated the enemy creature is to drop the gold you have the enemy on the spot.
    I tried an example, such as the following, but it did not work at all.


    (B.hp = 0) = a.gainGold + (enemyDropGold); a.atk * 4 - b.def * 2;


    Please help someone
    Advice.
  14. How do we go and do Lv. Skills. like the Lv. 5 Death of a lot of FF games, I know I need a Level Enemy script but what is the actual formula?
  15. Hi there,


    for my Pokemon Projekt ...




    ...I want to use this formula as atk ((2*level+10)/250)*(a.atk/b.def)*75)+6

    75 and 6 are the parameters that differ from skill to skill. Its basically the "official" formula for Pokemon fights.


    Sadly - it doesnt work! And I got ZERO Idea why...I even tried it in a clean projekt.

    If I try to minimalize the formula I see that "(2*level+10)/250) " seems to be the part causing the issue and reducing the dmg to 0.
    It's ofc a small number but even if it were 0 there should be still 6 Dmg left!

    Also enemies do even less dmg! Even if I just have "6" as the whole dmg formula my enemies do 0 dmg with it.


    There has to be something behind the scenes... But I have no clue what :(


    I appreciate your help, thx a lot


    have fun rpg making!
  16. There's two problems. first, it is a.level, not level. Second, enemies don't have levels, so it will always return 0 for enemy damage unless you add a plug-in which gives them levels.


    You see, the formula is set up to always return 0 when there is an error in the formula. So, it sees the use of level instead of a.level, throws an error, and does 0 damage.
  17. Nomi said:
    Hi there,


    for my Pokemon Projekt ...





    ...I want to use this formula as atk ((2*level+10)/250)*(a.atk/b.def)*75)+6

    75 and 6 are the parameters that differ from skill to skill. Its basically the "official" formula for Pokemon fights.


    Sadly - it doesnt work! And I got ZERO Idea why...I even tried it in a clean projekt.

    If I try to minimalize the formula I see that "(2*level+10)/250) " seems to be the part causing the issue and reducing the dmg to 0.
    It's ofc a small number but even if it were 0 there should be still 6 Dmg left!

    Also enemies do even less dmg! Even if I just have "6" as the whole dmg formula my enemies do 0 dmg with it.


    There has to be something behind the scenes... But I have no clue what :(


    I appreciate your help, thx a lot


    have fun rpg making!





     



    Level needs to be referred as a.level, don't know if there is a plug-in that allows the use of that for foes, but that could be one of the issues the other issue I see is the fact that you are not using the () correctly., let me show you. 


    ( ( 2 * level + 10 ) <= this is closing the formula way before everything is calculated / 250 )* ( a.atk / b.def ) * 75 ) + 6


    ----


    ( ( ( 2 * a.level + 10 ) / 250) * ( a.atk / b.def ) * 75 ) + 6


    Maybe this one will work, again I don't know what would happen if a foe were to use it as normally there is no way to call for a foe level.
  18. emelian65 said:
    ( ( ( 2 * a.level + 10 ) / 250) * ( a.atk / b.def ) * 75 ) + 6


    Thx a lot mate! I have been blind to miss using a.level! I guess that solved it =)
    And sry for the wrong (), they have been right once. But I was allready editing this formula around quite a while and ofc screwed up in the end :D


    Should have been more carefull to check that before my question...;)

    I use Yanflys Plugin for enemy levels. It's hard to tell if the formula works "right" there - but for now a level 3 Catterpie doesn more dmg then a lvl1 ...thats al I could ask for :p
     
  19. @Nomi You are welcome!


    ----


    Does anyone know if it's possible to use the Formula box, to check if a skill is targeting 1 Ally/Foe or All Allies/Foes, I'm using Yanfly Selection control, but the 


    <Disperse Damage>


    Notetag doesn't seem to be working with Heling spells,(which i don't honestly know if it was intended to be that way),


    So is there a way?
  20. bgillisp said:
    There's two problems. first, it is a.level, not level. Second, enemies don't have levels, so it will always return 0 for enemy damage unless you add a plug-in which gives them levels.


    You see, the formula is set up to always return 0 when there is an error in the formula. So, it sees the use of level instead of a.level, throws an error, and does 0 damage.



    Good to know - Thx to you 2 ofc, I allready realized that MV does some strange kind of exception handling. On the one had its a really nice thing that the game keeps running...on the other hand (at least in the unpublished Version) I would prefer a error telling me whats wrong :D


    p.s. still...to make it more strange, sometimes (just sometimes!) the formula did dmg. Doesn't rly make sense because I never used a.level before.


    @emelian65 you plan to split the dmg between enemies and increase it on single target? Or for another purpose?