RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 59 of 77 View original ↗
  1. Aesica said:
    If an enemy is using that same skill to attack with, it's going to mess up because enemies don't have an actor id. Try this revised version:

    Code:
    if (a.isActor()) v[25] = a.actorid(); a.atk * 4 - b.def * 2
    Thank you. I tried this, and the now the opposite is happening. The enemies now can damage the actors, but the actors can't damage them.
  2. Oh my bad. Minor capitalization error

    actorId(), not actorid()

    So:

    Code:
    if (a.isActor()) v[25] = a.actorId(); a.atk * 4 - b.def * 2
  3. Aesica said:
    Oh my bad. Minor capitalization error

    actorId(), not actorid()

    So:

    Code:
    if (a.isActor()) v[25] = a.actorId(); a.atk * 4 - b.def * 2
    Oh are those two different things?? I did not know that. By the way, it works now. Thank-you.
  4. yeah, javascript is case sensitive. meaning aA is sifferent from Aa that is different from AA that is different from aa
  5. Hello!

    I need help with a formula. So I have tried making a formula which damages the user, when it has over 30% HP and heals when it is below that percentage. Here's what I did:

    (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1)

    But I also want the skill to damage the enemy. Thus I tried to do it like this:

    a.atk * 4 - b.def * 2 && (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1)

    This unfortunanly didn't work.
    Can I please get help with this one? How can I fix this formula?

    Thank you in advance.
  6. Is the 30% heal/damage supposed to happen to the user regardless of whether they target an enemy or ally?

    Anyway, the logic in the second one is weird and is tripping you up.
    1. You're not doing any sort of check to see if an enemy is targeted, if your system allows for the targeting of enemies or allies alike.
    2. The logic in the first part is a bit weird, because the a.atk * 4 - b.def * 2 part is always going to evaluate to true unless it equals 0.
    3. That's...not really how you use the ternary operator (value = conditional ? trueValue : falseValue) however you're trying to use it like a classic if...else.
    4. Damage needs to be the last thing in the formula box.
    5. So, overall, your formula is trying to assign whatever value gainHp() returns after it is executed. Since it doesn't return anything, the resulting damage is undefined.
    Anyway, I'm going to assume this is just a basic attack skill, intended to target an enemy, that will either damage the user if hp is above 30% or heals them if below. So, try this:

    if (a.hp < a.mhp * 0.3) a.gainHp(Math.floor(a.mhp * 0.1)); else a.gainHp(Math.floor(a.mhp * -0.1)); a.atk * 4 - b.def * 2
  7. Accatosh said:
    Hello!

    I need help with a formula. So I have tried making a formula which damages the user, when it has over 30% HP and heals when it is below that percentage. Here's what I did:

    (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1)

    But I also want the skill to damage the enemy. Thus I tried to do it like this:

    a.atk * 4 - b.def * 2 && (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1)

    This unfortunanly didn't work.
    Can I please get help with this one? How can I fix this formula?

    Thank you in advance.
    there are two things you are doing wrong: you don't use && to separate things in damage formulas, you use ;
    && is for comparisons.
    and second, the damage is the last thing in the formula.
    meaning you need to separate your a.atk * 4 - b.def * 2 from your (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1) with an ; and a.atk * 4 - b.def * 2 goes the latest.

    so,
    (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1); a.atk * 4 - b.def * 2

    @Aesica are you sure you can't use a ternary like that? while I mostly use them like "x = ternary" I think I already did something like this successfully before too...
  8. @Aesica and @Waterguy, thank you!

    It works great! Also, thank you for letting me know that damage should be written last and that ";" separates.
  9. Waterguy said:
    @Aesica are you sure you can't use a ternary like that? while I mostly use them like "x = ternary" I think I already did something like this successfully before too...
    Well technically...I suppose you could since you're still invoking the functions (gainHp in this case). I guess that's why I like Javascript (yes, I actually like it) because it seems like there's always bizarre, alternative ways to do something.
  10. I'm trying to create an item that heals the user a variable amount. My initial attempt was 0.3*+(v[X]*.05), which in my mind translates to 30% plus 5% times Variable.
    Since it didn't work, this is why I am here.
    I want the item to heal a base 30%, but have it so that a variable adds 5%, in essence acting like the Estus Flask in Dark Souls 2 and 3, where it is enhanced to allow for more potent healing. Where do I go wrong in setting up the formula, and how could I make it work properly?
  11. Diretooth said:
    I'm trying to create an item that heals the user a variable amount. My initial attempt was 0.3*+(v[X]*.05), which in my mind translates to 30% plus 5% times Variable.
    Since it didn't work, this is why I am here.
    I want the item to heal a base 30%, but have it so that a variable adds 5%, in essence acting like the Estus Flask in Dark Souls 2 and 3, where it is enhanced to allow for more potent healing. Where do I go wrong in setting up the formula, and how could I make it work properly?
    If I'm reading you right, you want to heal the user for 30% of their max HP, plus 5% x v[x]? Try this:

    b.mhp * 0.3 + b.mhp * 0.05 * v[x];

    So:

    v[x] == 0 => 30% healing
    v[x] == 1 => 35% healing
    v[x] == 2 => 40% healing

    ...etc
  12. Aesica said:
    If I'm reading you right, you want to heal the user for 30% of their max HP, plus 5% x v[x]? Try this:

    b.mhp * 0.3 + b.mhp * 0.05 * v[x];

    So:

    v[x] == 0 => 30% healing
    v[x] == 1 => 35% healing
    v[x] == 2 => 40% healing

    ...etc
    This words perfectly! Thank you! ^n.=.n^
  13. alternativelly, @Diretooth , you can use a very close code to both yours and @Aesica 's, but isntead of multiplying both sides for b.mhp you just multiply the result.
    since multiplying both sides of an addition is the same as multiplying the result.

    b.mhp * (0.3 + 0.05 * v[x])

    assuming that you do mean a percentage of max hp, of course.
    b.mhp is essential to be there though, or at least a value in its place. your original version of the code was doing it with 30% + 5% of variable... of 1. Since damage formula, be damage or heal, is rounded before being applied, it would only heal either 0 or 1, and 1 only if the variable was 4 or more to reach 50% to be rounded up.
  14. Honestly, I'm not sure why I wrote it the way I did, probably because I was tired if anything. But yeah, I'd suggest doing it this way over what I wrote:

    Waterguy said:
    b.mhp * (0.3 + 0.05 * v[x])
  15. Observed and updated. Thank you again for the help, both of you.
  16. I'm looking to make some simple skills that have set damage ranges like in dragon quest. For example: a fire spell that does 10-20 damage or a heal spell that heals 30-50 Hp. Can someone help me with the formula? Thanks.
  17. @itzel if by set damage ranges you mean it is in that range regardless if your attack or magic is 1 or 99...
    for the 10-20 put damage as 15 and variance as 33%, and for heal between 30-50 put damage as 40 and variance as 25%.
    variance is a random value up to that percentage of the damage (25% of 40 is 10, so from 0 to 10) that has a chance of being either added or removed from the damage. meaning that damage 40 with 25% variance can go anywhere from 30 to 50, or from 40-10 to 40+10
  18. itzel said:
    I'm looking to make some simple skills that have set damage ranges like in dragon quest. For example: a fire spell that does 10-20 damage or a heal spell that heals 30-50 Hp. Can someone help me with the formula? Thanks.


    Code:
    Math.randomInt = function(max) {
        return Math.floor(max * Math.random());
    };
    'Math.randomInt(max)' is a function used by MV to generate a random number between 0 and (max). Replace (max) with the max value of the skill. Then you add to it the minimum value you want the skill to hit for.

    EDIT: Silva pointed out a mistake I made,
    Math.randomInt(max) generates a whole number between 0 and (max -1)

    Example
    Code:
    Math.randomInt(10) + 10
    This code, when placed in the damage formula of a skill, would cause the skill to hit between 10 - 19 damage.
    one thing to note is that the max damage will be the two values combined (9 + 10) while the minimum damage will be the 10 at the end.
  19. @xDRAGOONx that is a good one, but would need variance to be set to 0...
    but as I said ealier, variance is there to do... exactly that already...
  20. Waterguy said:
    @xDRAGOONx that is a good one, but would need variance to be set to 0...
    but as I said ealier, variance is there to do... exactly that already...
    I apologize, I had actuall meant to reply to itzel with that comment.