RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 64 of 77 View original ↗
  1. Trihan said:
    Code:
    let value = a.atk * 4 - b.def * 2; b.isStateAffected(4) ? value * 2 : value
    Do I put this formula on the damage formula box or the note tag?
  2. The damage formula box.
  3. Thanks for the tip.
  4. So I'm trying to write a formula that if I were to increase variable 1 that it would increase the damage dealt by 3.5%. I'm trying to store the damage from the formula in var 5 then set another, var 6, equal to that var 5 then make var 6 multiply by var 1 * 0.035. Then at the end add var 5 to var 6 for the end damage. I must not be understanding how the damage formulas work completely yet because its giving me 0 in combat.

    Formula using:
    $gameVariables.value(5) = (a.atk - b.def / ((b.level / 2) + 2)) ; $gameVariables.value(6) = $gameVariables.value(5) ; $gameVariables.value(6) = $gameVariables.value(6) * (0.035 * $gameVariables.value(1)) ; $gameVariables.value(5) + $gameVariables.value(6).

    The stats that are being used is
    a.atk = 50
    b.def = 14
    b.level = 1

    Any help on why this isn't working would be appreciated.
  5. You can't assign to $gameVariables.value(5). To change the value of a variable, you need to write $gameVariables.setValue(5, newValue). Also by the way, you can access a variable in the damage formula using abbreviated syntax: v[5].

    Now, there's one other weird thing about your formula. Why are you using $gameVariables 5 and 6 at all? Do you need these numbers somewhere else outside of the damage formula? If you don't, then you should just use JavaScript variables - it'll make for a much shorter and readable formula.

    JavaScript:
    var base = a.atk - b.def / (2 + b.level / 2);
    var bonus = base * 0.035 * v[1];
    base + bonus

    Take out the line breaks obviously, but I think that should do the same as what the code you posted looked like it meant to do.
  6. Solar_Flare said:
    You can't assign to $gameVariables.value(5). To change the value of a variable, you need to write $gameVariables.setValue(5, newValue). Also by the way, you can access a variable in the damage formula using abbreviated syntax: v[5].

    Now, there's one other weird thing about your formula. Why are you using $gameVariables 5 and 6 at all? Do you need these numbers somewhere else outside of the damage formula? If you don't, then you should just use JavaScript variables - it'll make for a much shorter and readable formula.

    JavaScript:
    var base = a.atk - b.def / (2 + b.level / 2);
    var bonus = base * 0.035 * v[1];
    base + bonus

    Take out the line breaks obviously, but I think that should do the same as what the code you posted looked like it meant to do.
    Thanks for the reply. I use $gameVariables for my var 1 since if you were to use v[1] and use test battle and dont have the var defined in the fight it leads to undefined or 0. I was using v[#] for the formula but it wasn't working so i figured i would just try $gameVariables to just see if it would do anything. When it didn't i just copied it and pasted it here looking for help. To start out i was actually trying to use just x and y, I'm very new to using variables in damage formulas so i don't really know what works or not, and don't know anyting on javascript variables either.
  7. Bigkill321 said:
    I use $gameVariables for my var 1 since if you were to use v[1] and use test battle and dont have the var defined in the fight it leads to undefined or 0.
    Ahh, that's true. Well, the code I posted doesn't depend on v[1] vs $gameVariables.value(1), so you can use whichever you prefer.
  8. If you want to have non-linear Final Fantasy style damage scaling, where small differences produce small values, but larger differences produce extremely large values, this more complex formula works very well in RPG Maker MV and MZ:

    Math.min(7999, 15*Math.pow(2, ((a.atk-b.def)/3)))

    If the attack and defense (substitute a.mat and a.mdf for magic) are close, this formula results in small values. But, as the difference increases, the formula rapidly produces much larger values. The outer "Math.min" call bounds the damage at 7999. With the default "20% Variance" this caps damage at around 9999.

    With this formula, an attack/defense difference of 3 causes a value of 30. If you increase that attack/defense difference to 12, the value is 240. And, increase it still further to 22 and the value becomes 3840. Basically, every difference of 3 doubles the damage.

    Increasing the "3" divisor slows the rate of the very rapid increase. You can also add a linear value before the 15* to increase the base damage.

    From a player's standpoint, this formula lets them see how powerful the party has become against weaker opponents. That Orc that you barely survived at level 10? Go back at level 20 and you can one-shot-kill it, most likely.

    Expect to do a great deal of tweaking in the Battle Test screen though.
  9. Got a couple of damage formula things I'm trying to hammer out at the moment, and I'm in over my head.

    The first is an ability that heals both the caster, and the target. The formula is as follows:
    x = Math.round(b.mhp * 0.15 + a.mdf); a.gainHp(x); x

    The formula itself works and heals both parties, however it only shows the recovered health for the recipient and not the caster. Using Yanfly's battle engine core, I can use <display text: whatever> to display a message, but, I'm not sure what code I can use to show the amount healed by the caster, and who the caster is/was. Or... If there's just an easier way to do it.

    The second thing I'm looking to do is have poison status effects that scale off of something and deal a flat damage value instead of a percentage. Again using another Yanfly script, Lunatic Pack - Action Beginning and End Effects this time, I'm able to make the status effect inflict a flat damage value, but I'm not sure how to make it scale off of a stat from the caster. One idea I had was to simply store the value of the caster into a variable, then have the script deal <variable> damage, but then if I have a different character use the same skill, it'd overwrite that value and thus change the poison damage the prior target is taking. I could make a separate variable for each character, as well as a clone of the same skill for each one that just applies the value to it's own unique variable but... That's just kind of getting messy at this point. I'm sure there's a better way to do it. Like I said, in over my head :(

    I appreciate any advice / ideas!
  10. Hello!
    I'm trying to make a spell that instantly kills all enemies if the caster's level is higher than the target's level. Here's the formula that I used: a.level > b.level ? b.setHp(0) : 0;
    I apologize if I'm totally wrong. I really sock at making those formulas.

    I'm using RMMZ and yes, I'm using a plugin that allows enemies to have levels(VisuStella's Core Engine).
  11. Watch out, you're in an RMMV thread for damage formulas.

    Try b.die() instead, that's a way to instakill on MV, maybe it works on MZ.
  12. I posted this here for 2 reasons:
    1. Both RMMV & RMMZ use javascript, so I thought it would be okay to post here.
    2. I didnt see a section for damage formulas for MZ, so I thought that meant that both makers use the same types of damage formulas.

    Anyway, that aside, thanks for your help. I already did try b.die() instead of b.setHp(0), but sadly, it didnt work.
  13. Kagemaru said:
    I posted this here for 2 reasons:
    1. Both RMMV & RMMZ use javascript, so I thought it would be okay to post here.
    2. I didnt see a section for damage formulas for MZ, so I thought that meant that both makers use the same types of damage formulas.

    Anyway, that aside, thanks for your help. I already did try b.die() instead of b.setHp(0), but sadly, it didnt work.
    Put a console.log("enemy killed") or something statement in place of the b.die() statement to make sure the code is even being reached. If you use the skill and don't see "enemy killed" in the debug console after using the skill on an enemy it should work against, then you're somehow determining enemy levels wrong.

    That said, I'm not a huge fan of using die() or even setHp() because both skip certain steps. The best possible way (assuming you're okay with showing damage popups, which you're going to get anyway because you're using the formula box) is just plain old b.hp. Make sure variance is set to 0%.

    Edit: So:

    Code:
    a.level > b.level ? b.hp : 0

    This is assuming of course that you aren't using any of VS's weird damage formula styles, which do a bunch of other random crap that may not be desired when attempting to inflict a specific amount of damage.
  14. Nope, it still didnt work. :(
    I had already disabled VisuStella's style formulas or w/e theyre called, so Im pretty sure that isnt whats causing the problem.

    I tried
    a.level > b.level ? console.log("enemy killed")
    but nothing appeared. I turned off VisuStella's Battle Core plugin just in case(This is the plugin that adds the style formulas) but still nothing. I also turned off every plugin except for the Core Engine plugin, still nothing. Finally, I disabled every plugin I had to see if that would do something, but once again, there was nothing new, not even an error message to tell me that my formula was wrong.

    If Im doing something wrong, I really dont know what it is. My test enemy has a
    <Level: 3>
    notetag in its notebox and my actor 1 is level 5. I even gave him a
    <Initial Level: 5>
    notetag to see if that would do something, but nope, nothing.

    I know the above didnt work, but I still wanted to try the formula that you wrote just in case something would happen, but nothing. I did like you recommended and I set the variance to 0%. Dunno if this helps, but I also set the element to "none", the critical hits to "no" and the hit type to "certain hit".
  15. Kagemaru said:
    Nope, it still didnt work. :(
    I had already disabled VisuStella's style formulas or w/e theyre called, so Im pretty sure that isnt whats causing the problem.

    I tried
    a.level > b.level ? console.log("enemy killed")
    but nothing appeared. I turned off VisuStella's Battle Core plugin just in case(This is the plugin that adds the style formulas) but still nothing. I also turned off every plugin except for the Core Engine plugin, still nothing. Finally, I disabled every plugin I had to see if that would do something, but once again, there was nothing new, not even an error message to tell me that my formula was wrong.

    If Im doing something wrong, I really dont know what it is. My test enemy has a
    <Level: 3>
    notetag in its notebox and my actor 1 is level 5. I even gave him a
    <Initial Level: 5>
    notetag to see if that would do something, but nope, nothing.

    I know the above didnt work, but I still wanted to try the formula that you wrote just in case something would happen, but nothing. I did like you recommended and I set the variance to 0%. Dunno if this helps, but I also set the element to "none", the critical hits to "no" and the hit type to "certain hit".


    if(a.level > b.level){b.hp;} else {a.atk;}

    try that, sometimes if/else statements work for me in different formats. I usually can't get the ? one to work. idk it just happens.
  16. Ooh! Sadly, it didnt work, but the a.atk part did work. In other words, it really is the first part that isnt functional. This is so frustrating! What am I doing wrong...

    Edit:

    Heres a screenshot of the skill, actor 1, the punching ba- er... bear and my list of plugins.
  17. I can't figure it out either, it just seems like the damage formula doesn't recognize the enemies level. I've tried alot of various ways and different spellings, but that's just it. It's not recognized as something that the enemy can have.
  18. So youre saying that its a problem with the engine and/or the plugins?
  19. Kagemaru said:
    So youre saying that its a problem with the engine and/or the plugins?

    Yeah I just downloaded their demo, added levels to the goblin and tried it out and it's definitely the engine not recognizing the plugin. I did a simple damage formula of a.level and it worked. But b.level / b.lv / b.lvl / b.Level all don't work.
  20. I see. T.T
    Thanks a bunch for comfirming it! I was getting worried that the problem might be on my side.
    I guess for now Ill go work on my MV project! I hope they fix that problem soon!