RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 40 of 77 View original ↗
  1. @Nol I haven't really done much with damage formulas, but I think it would look something like that.

    Code:
    if (b.isStateAffected(74)) { b.removeState(74); 2 * (a.atk * 4 - b.def * 2); }else { b.addState(74); a.atk * 4 - b.def * 2; }
  2. Works perfectly, thanki you for the time.


    Still don't understand why there the ; and } are placed where they are, but i guess it'll come with time.


    Thanks again
  3. I'm looking to edit the damage formula to increase the multiplier if the user has no weapon equipped.


    For example, if unarmed * 8, if armed, * 4. Could anyone help me with this?


    nvm:


    a.weapons().some(function(wpn) { return wpn.wtypeId === 1; }) ?


    seems to do the trick.
  4. ksjp17 said:
    a = the user of the skill


    b = the target of the skill (enemy - bear in mind that this is from the point of view of the user.  So an 'enemy' of the Demon Lord is your hero.)


    * = multiplication sign.  


    the main stats use the normal abbreviation.  So


    a.atk * 4 - b.def * 2


    means that you have the attack value of the user multiplied by 4, from which you deduct (the minus sign) the defence of the target, times 2.  The resulting number is how much damage is inflicted.


    There are other things, but if you are a complete newbie, I think those are the main things to remember.  Once you've worked that out, it is simpler to follow what is going on.

    Thanks ksjp17, now I got an idea of how it works. But I tried changing the numbers and the skill was dealing 0 damage. I have no idea how formulas work. I tried making a formula for a skill, I don't know if I got the correct abbreviations, but anyway it deals 0 damage even to some premade slime troops.


    Here is the formula:


    100 + a.pat * 4 - b.def * 2


    Please anybody tell me if it's something wrong with it, so I can fix it.
  5. does pat exist? the default call for the attack param is atk, not pat.. pat doesn't exist in default in any maker. If pat doesn't exist, the code will return an error. When there's an error in the damage formula, the damage formula automatically returns 0.
  6. Engr. Adiktuzmiko said:
    does pat exist? the default call for the attack param is atk, not pat.. pat doesn't exist in default in any maker. If pat doesn't exist, the code will return an error. When there's an error in the damage formula, the damage formula automatically returns 0.

    Thank you, I thought it means physical attack, but I suppose it's just atk.


    ............................................................................


    OK, I tried it and it works. Thank you so much!
  7. Was trying to set some form of this for most of my damage formulae


    (a.atk + (a.atk - b.def)) / 2


    Was inspired by Yandly's Armor Scaling plugin http://yanfly.moe/2015/11/28/yep-33-armor-scaling/ But figured I could do the basic part on my own without another plugin.


    It works. Now. For hours I was testing and adjusting and try new formulae. Because this one wouldn't work. Then I noticed that I had forgotten a bracket. Instead of this:


    (a.atk + (a.atk - b.def)) / 2


    I had put this:


    (a.atk + (a.atk - b.def) / 2


    Which always left me with 0 damage. Yeah, almost busted my brain on that but managed.


    Anyway, if anyone wants a good damage formula for standard attacks, then this works well (the working one with two brackets ((see in bold at the top). It allows defense builds to at least be dealt some damage, means lower attacks are not completely useless, and helps retain balance throughout most of the game/project. I've found it to be very useful


    x
  8. ((Sorry for double posting, I need help))


    Okay, so, for my game I found a good way to balance a lot of the default attacks. It's this forumla:


    (a.atk + (a.atk - b.def)) / 2


    And I have two variations of that:


    (a.atk + (a.atk - (b.def / 2))) / 2 For piercing damage that ignores 50% of the target's DEF. That one works fines.


    ((a.atk + * 2) + ((a.atk * 2) - b.def))) / 2 But I can't get this one to work. It's supposed to be like the first one but dealing double damage.


    I did, inititially try this in it's place: (a.atk * 2 + (a.atk * 2 - b.def)) / 2


    Any ideas on how to make either of those last two equations work. Because they both fail and automatically hit 0 because MV does not understand the formula. Anyone know where I went  wrong? Or how I can make a double damage version of the first one?
  9. ((a.atk + * 2) + ((a.atk * 2) - b.def))) / 2 will not work because you are using a.atk + * 2 in the first part. Notice the lack of a value between the + and the *.



    What is the problem with  (a.atk * 2 + (a.atk * 2 - b.def)) / 2? It seems like it would work fine to me, just... not the double of the first equation.
    If it is supposed to be like the double of (a.atk + (a.atk - b.def)) / 2 then... just remove the / 2? Since it halves the result, the double of it is just not halving it. a.atk + (a.atk - b.def)
  10. @Waterguy Thank you! I should of saw the extra + !!! I feel so stupid for not noticing that was in there...


    EDIT: Are you able to use decimal places or does the engine not read them?


    So would this work: (a.atk+ (a.atk- b.def)) * 2.5 or would it just throw up a 0?
  11. @Ryzler: Even though you needed help, so does everyone else. We still ask that you don't double post and next time please just edit your previous post unless 72 hours or more has passed. Please adhere to that in the future. Thanks.
  12. @Ryzler it should be no problem, since the damage is usually rounded by the engine itself.


    Just keep in mind that (a.atk+ (a.atk- b.def)) * 2.5 is five times your standard formula of  (a.atk + (a.atk - b.def)) / 2.
  13. @Waterguy 5 times is what I had before but since I just changed the end " / 2 " on all of my damage formulae, that got changed to end with " * 2.5 " Thank you so much for helping me!


    It's been the long way around but I'm glad I didn't use the plugin as this is the first time I've really tried to use the plugin.


    And a question: Does RPG Maker MV try to read the formula with any form of BODMAS or does it read it from left to right.
  14. It uses the same order of precedence as javascript, since it is basically what you are using. You can see it at here but the gist of it is, unless between parentesis, the order goes *, / or % before + or -.
  15. Hey all, I have an ability where one character will convert her TP into MP for any party member. How do I get it to round up or down to an integer?


    c = a.tp*0.5;a.gainTp(-a.tp*0.5);c


    What this formula does is take half of her current TP, turn it into MP and then heals that amount of MP to a party member. The problem I run into is when her TP is an odd number. For example, if she has 51 TP when this is used, her TP ends up being 25.5  instead of 25 or 26. Anyone know how I can fix this? Thanks! :D
  16. Fernyfer775 said:
    Hey all, I have an ability where one character will convert her TP into MP for any party member. How do I get it to round up or down to an integer?


    c = a.tp*0.5;a.gainTp(-a.tp*0.5);c


    What this formula does is take half of her current TP, turn it into MP and then heals that amount of MP to a party member. The problem I run into is when her TP is an odd number. For example, if she has 51 TP when this is used, her TP ends up being 25.5  instead of 25 or 26. Anyone know how I can fix this? Thanks! :D



    Hey, maybe try this?


    c = a.tp*0.5;a.gainTp(Math.floor(-a.tp*0.5));c
  17. @Riff A million and one thank yous my good sir!
  18. Fernyfer775 said:
    Hey all, I have an ability where one character will convert her TP into MP for any party member. How do I get it to round up or down to an integer?


    c = a.tp*0.5;a.gainTp(-a.tp*0.5);c


    What this formula does is take half of her current TP, turn it into MP and then heals that amount of MP to a party member. The problem I run into is when her TP is an odd number. For example, if she has 51 TP when this is used, her TP ends up being 25.5  instead of 25 or 26. Anyone know how I can fix this? Thanks! :D



    As noted, Math.floor will round down


    c = a.tp*0.5;a.gainTp(Math.floor(-a.tp*0.5));c


    Math.ceil will round up (ceil is short for ceiling, JavaScript use the abbreviation)


    c = a.tp*0.5;a.gainTp(Math.ceil(-a.tp*0.5));c
  19. Hi.. umm does anyone know how to create a damage formula where a certain amount of damage should only be applied when the target is at below x% HP? I was thinking of something but unfortunately it didn't work :/
  20. I have been trying forever to figure formulas out. Now that I know better how they work, I need to know how I can make a skill do 150% of players physical attack with 100% being the same as atk. So for example player does 100 damage against Enemy A with normal attack, and the skill would do 150 damage, or 50% more.