Damage Formulas 101

● ARCHIVED · READ-ONLY
Started by Skunk 281 posts Page 13 of 15 View original ↗
  1. fladdles said:
    Edit: removed because I found a more active thread to ask the same question, as this one appears to have been dead a while
    Just as a suggestion, there's not much reason to do that. Recent/unread posts show up in the same lists on the site. So unless there's someone who's only working off of notifications from threads they've Followed, we're going to see your post regardless of which specific damage formula thread it's in :wink:
  2. Theorically, making a check for more than one condition would work with && on it right?

    For example:


    JavaScript:
    a.mp && a.tp >= 35 ? 75 : 40;

    Could this work if I need the skill to deal extra damage as long as MP and TP are above 35? Or should I need to do something else?
  3. emelian65 said:
    Theorically, making a check for more than one condition would work with && on it right?
    No, that's not correct JavaScript syntax. Each side of the boolean operator must be a complete comparison. See:
    W3Schools.com
    So you'd do a.mp>=35 && a.tp>=35
  4. I'm not receiving any battle damage with this formula I'm not sure why.
    Can this be done or do I need to make two different damage formulas with the same name?
    JavaScript:
    if (a.actorId() === 1) { (v[1] + a.atk * 4 - b.def * 2); } else { (a.atk * 4 - b.def * 2); }
  5. @Fonixed, try == instead of ===. What's in variable 1?
  6. Shaz said:
    @Fonixed, try == instead of ===. What's in variable 1?

    I've given Variable 1 the value of 25, it's just a random value that I'm using to see if I can get it working.

    Also == and === have the same effect in this case. I can deal damage but not receive any.
  7. Fonixed said:
    Also == and === have the same effect in this case.
    With RPG Maker they always will. Unless you manually set a variable to something weird, they will always be numbers and not need to be a strict comparison.

    Fonixed said:
    I can deal damage but not receive any.
    Because enemies don't have an actorId() field. When an enemy uses the skill, calling actorId() is undefined and zeros out the entire formula.
  8. How much of these can be applied on VXA? I know MV uses javascript but idk how much I can reference, I could not find a comprehensive "Damage Formula 101" for VXA (Forma wrote one but it was not as in depth with each functionality)

    Are these functions here like currentExp() the same in VXA? Would've be so nice if VXA let me uses as much as what is documented here.
  9. kn1000a said:
    Are these functions here like currentExp() the same in VXA? Would've be so nice if VXA let me uses as much as what is documented here.
    No, VX uses Ruby for scripting while MV/Z are coded in JavaScript - two completely different languages.

    You can look up the VXAce script call list for functions to use in that engine.
    Script Call Collection for VXAce
  10. Hey, I'd like to make a damage formula that allows me to hit an enemy and at the same time give back a fixed number (for example) 7 of mana and TP to my allies and myself. Is it possible to do this?
  11. Lisanthius0705 said:
    Hey, I'd like to make a damage formula that allows me to hit an enemy and at the same time give back a fixed number (for example) 7 of mana and TP to my allies and myself. Is it possible to do this?
    Yes, but it's generally not best practice to put that in the damage formula.

    The first post of this thread lists the functions for gaining MP and TP. You can use the forEach() method to do it to everyone. For example:
    Code:
    a.friendsUnit().forEach(battler => battler.gainMp(7)); damage formula

    However, if you give that skill to enemies or you ever use the auto battle trait, it can produce unexpected results. So it's better to use something like Yanfly's Skill Core to execute code like that only when a skill is actually used.
  12. So i thought I could make a formula that drained 35% of a target's TP and restored it to the user but I feel like I'm missing something?

    a.setTp(a.Tp * .65); user.setTp(user.Tp + (a.Tp * .65)
  13. Zakarijah said:
    So i thought I could make a formula that drained 35% of a target's TP and restored it to the user but I feel like I'm missing something?

    a.setTp(a.Tp * .65); user.setTp(user.Tp + (a.Tp * .65)
    There are a few things wrong with this.

    1 - There's no such property as "Tp". It's "a.tp" or "b.tp," etc.

    2 - As described in the first post of this thread, the last thing in your formula must always be the value being used for damage. The setTp function does not return a value, so you're going to be getting undefined from all of that.

    3 - There's no such thing as user in the damage formula - I'm not sure where you're getting that from. You might be confused with the documentation for plugin notetags, but the damage formula only has a and b.

    4 - Your syntax is incorrect. The second statement (after the semicolon) has two open parentheses and one close.

    If this skill is not supposed to do any HP or MP damage to the target at all, you probably don't want to use the damage formula for this. You must have a value if you do, which means if nothing else you'll see a 0 damage popup every time you use the skill. If that's the case, you'd be better off using something like Yanfly's Skill Core and putting the code into an After Eval notetag or something like that.
  14. ATT_Turan said:
    There are a few things wrong with this.

    1 - There's no such property as "Tp". It's "a.tp" or "b.tp," etc.

    2 - As described in the first post of this thread, the last thing in your formula must always be the value being used for damage. The setTp function does not return a value, so you're going to be getting undefined from all of that.

    3 - There's no such thing as user in the damage formula - I'm not sure where you're getting that from. You might be confused with the documentation for plugin notetags, but the damage formula only has a and b.

    4 - Your syntax is incorrect. The second statement (after the semicolon) has two open parentheses and one close.

    If this skill is not supposed to do any HP or MP damage to the target at all, you probably don't want to use the damage formula for this. You must have a value if you do, which means if nothing else you'll see a 0 damage popup every time you use the skill. If that's the case, you'd be better off using something like Yanfly's Skill Core and putting the code into an After Eval notetag or something like that.
    okay, thanks. I'll try to do something with the skill core. I did some other stuff but I'm not good as coding at all, so it's... a process. lol
  15. I want to make an item that has double strength in battle. How would I go about checking to make sure I'm in the Battle Scene?
  16. Disponi said:
    I want to make an item that has double strength in battle. How would I go about checking to make sure I'm in the Battle Scene?
    Code:
    SceneManager._scene instanceof Scene_Battle ? original formula : stronger formula
  17. ATT_Turan said:
    Code:
    SceneManager._scene instanceof Scene_Battle ? original formula : stronger formula

    Thanks, that did it! Had to swap the formula places, though.
  18. @Disponi Oops, sorry, yeah, quickly typed that backward :stickytongue:
  19. I'm not so good in formulas. Could you please explain me one thing. Is it possible to create formula that will change damage to heal or heal to damage depending on state or something like that? I'll be very grateful.

    Right now I'm trying to create a classes that normally heal characters but damage undead enemies with the same skills. I already know about Silv Undead plugin but I'm also using FROG Health which demands special fomulas written in the plugin options. In other case it's bugging the game. Silv's Undead works only with straight formulas like a.atk and so on.

    Found what I need in the another thread. Won't bother. Will just create damaging skills for my healers.
  20. mahadeva said:
    Found what I need in the another thread. Won't bother. Will just create damaging skills for my healers.
    What was the solution?