State Damage Modifiers

In RPG Maker MV, damage calculations are performed when one battler uses an action on another battler (including themselves).

So for example, let’s say your actor attacked an enemy using skill #3. The game would look at skill #3’s damage formula and use that to determine the base damage that the skill can deal.

In addition to this “base damage”, we also have some extra damage modifiers, such as the guard effect which halves the damage received, as well as the critical hit modifier, which increases damage based on a critical multiplier.

This plugin allows you to further apply additional damage modifiers, which essentially allows you to change the damage even further. These modifiers will be applied to states, so whenever the state is active, the damage modifiers will be used.

State damage modifiers can be applied to both the attacker as well as the target. Attacker damage modifiers are applied before the target damage modifiers.

Download

Plugin: download here (right-click, save as)

Installation

Download ths plugin and place it in the “plugins” folder in your project’s “js” folder. Then open your Plugin Manager (F10), double-click an empty row, and select the HIME_StateDamageModifiers plugin.

Once it is in your list of plugins, turn the plugin on.

Usage

stateDamageModifiers2

State damage modifiers are similar to damage formulas, except they have an extra variable available to use: the current damage.

Because there may be multiple damage modifiers involved, you might want to apply the modifier on top of the results of previously modified damages.

There are two types of damage modifiers: attacker modifiers, and defender modifiers. Attack modifiers are used when a battler is attacking someone. On the other hand, defender modifiers are used when they are on the receiving end of an attack.

If a battler targets themselves, both attacker and defender modifers are used for the same battler.

So if A attacks B, then A is the attacker, and B is the defender. If A attacks A, then A is both the attacker and defender.

To apply a state damage modifier to a state, note-tag states with the appropriate modifier. If you want to add an attacker modifier, use

<state damage modifier: attacker>
  FORMULA
</state damage modifier>

If you want to add a defender modifier, use

<state damage modifier: defender>
  FORMULA
</state damage modifier>

Where the FORMULA is any valid javascript code that evaluates to a number. The following formula variables are available

a - the attacker
b - the target
v - game variables
d - current damage (after previous modifiers are applied)

You must remember to have the damage formula return a value. Please see the following examples.

Example 1:

So for example, let’s say you wanted to make it so that this state will simply cancel out any damage. You can use a simple formula

return 0

And the damage will now be 0.

Example 2:

Similarly, you could change the damage so that it will leave you with 1 HP.

return b.hp - 1

Which means the target’s current HP, less one. This might be useful if you wanted your state to always leave 1 HP when it’s active.

Example 3:

You might make it so that this state will double the damage dealt. You can say

return d * 2

Which will multiply the current damage by 2.

The possibilities are endless. You are limited by your javascript knowledge.
If you need help coming up with a formula, many people could potentially help.

You may also like...

174 Responses

  1. Todd Erard says:

    I’m not sure if i’m in the right place but i’m trying to make a skill that every time the character (that use that skill on himself) takes damage, he increases his attack by 1. If someone can help that would be nice 😉

  2. MrPixel says:

    I’m trying to make it so that skill 3 does bonus damage if the target is poisoned. This is what I got so far?

    if (b.State(4)
    return d * 2
    </state damage modifier>

  3. anglerman says:

    Is it possible to make the defender gain another state and/or recover MP if they evade an attack while the state is up?
    I want to create a ‘Parry’ state with 100% evasion rate that recovers MP for every evaded attack. Tried a bunch of stuff but to no result.

  4. gameguy503 says:

    So, I’m under the impression I could use this to add a random state from id x to y to both attacker and defender if the attacker is under a state with this tag (replaced with proper bracketry, then x and y with your scope of states, of course)…

    [state damage modifier: attacker]

    if ((Math.random() >= .5))
    {
    var c = Math.randomInt(x, y)
    a.addState(c)
    b.addState(c)
    return d
    }
    else {return d}

    [/state damage modifier]

    … Am I getting things right? I’m still pretty puke at Java but this should work if you’re running the whole function, yeah?

  5. Maune says:

    So I’m back much, much later with another odd question. Can this be used to treat damage as an element?
    Simple example is just:

    return d + a.mat / 3
    </state damage modifier>

    This does add a third of the attacker’s magic attack to the damage, but my goal is to make just the damage from “a.mat / 3” into Fire damage, while the rest of it stays Physical.

    • Maune says:

      Actually solved/worked around this with another plugin. Unfortunately, I have a different problem that I also don’t know how to fix.
      Is there a way to make certain skills ignore the state damage formula? The state was intended to add damage to most attacks, but not other spells like a basic magic dart.

      • Hime says:

        No, but you can have the state damage formula check whether it’s a certain skill, or skill type, to determine whether it should take effect.
        A regular if/else condition.

  6. Jojarth says:

    Quick, possibly dumb question. Can you have both attacker and defender state damage modifiers in the same state? I have one that looks like this:

    if (this.isDamage()){
    return (Math.round(d * 1.25))
    }
    </state damage modifier>

    if (this.isDamage()){
    return (Math.round(d * 1.25))
    }
    </state damage modifier>

    With the goal being that you enter a stance, and it increases the damage you take and deal by 25%.

    However, what ends up happening, is after I enter the stance, the first time I attack, I get the following:

    “SyntaxError: Unexpected token <”

    However, if I just use either the attacker or defender modifier, everything works normally (and as intended), it only happens when I try to do both. Which is why I was wondering if you can do both. I have tried to turn all other plugins off, but it still happens.

    Thanks ahead of time for your help! Your plugins are amazing!

    • Jojarth says:

      Not sure why the code didn’t come over, it is:

      <state damage modifier: defender>
      if (this.isDamage()){
      return (Math.round(d * 1.25))
      }
      </state damage modifier>
      <state damage modifier: attacker>
      if (this.isDamage()){
      return (Math.round(d * 1.25))
      }
      </state damage modifier>

      Sorry about that! Thanks again ahead of time for the help!

    • Hime says:

      There was a problem that prevented you from using multiple note-tags in one state. I've updated the plugin to address the issue.
      Download the latest version (1.4) and it should work.

  7. Ctelin Ajira says:

    Quick question:
    Does the [state damage modifier: attacker] notetag do things to the target of the guy affected by the state?

    • Ctelin Ajira says:

      I’m an idiot. Seeing as how you pretty much stated it already in the plugin description above, I retract my question.

    • Hime says:

      Attacker and defender is used to determine when the modifier is applied.

      The target is always the target of the action, so if you’re the defender, and someone’s attacking you, you are b. Whereas, if you were the attacker, and you’re attacking someone else, they are b.

  8. Zanazaru says:

    One more Question, do you think it’s possible to make a reflec state vanish after one reflected attack with something like this? So with notetags in a state?

  9. Zanazaru says:

    Hey one quick question I tried to make a state that negates all damage by returning 0 like this:

    return 0
    </state damage modifier>
    Problem is as soon as I return a zero it stops working.
    I can make it any int float or whatever but if it amounts to zero the standart damage is dealt. Did I miss something?

  10. Ctelin Ajira says:

    Is it possible to recreate the Mana Shield script from VX Ace using this script?

    • Hime says:

      I believe it would be possible, to some extent.
      You would start by checking the damage type (in case it’s like an MP damage attack).

      If it’s an HP damage skill, you would check the amount of MP that the target has and then offset the damage by a certain amount.
      For example, if your mana shield absorbs 100% of damage, and the damage was 100 while you had 100 MP, then you would lose 100 MP and the amount of damage that you return will be 0.

      However, if you had 50 MP, then you would lose 50 MP, and the amount of damage that will be returned is the difference (ie: 50)

      • Ctelin Ajira says:

        Does the formula within the notetag support checking the damage type?

        • Hime says:

          Yes. You can check

          this.checkDamageType([LIST OF DAMAGE TYPES])

          So for example, you can say
          if (this.checkDamageType([1])) {
          // yes, HP damage, do something
          }

          Which checks if it’s HP Damage.

          The default scripts provides this method
          this.isDamage()
          Which returns true if it’s HP or MP damage, which might not be what you want.

          • Ctelin Ajira says:

            Then I think I have a test tag, and an idea of what I’m doing. Thank you~.

            [state damage modifier: defender]

            var damageBattler = d

            if (this.checkDamageType([1])) {

            if (damageBattler > b.mp) {

            b.gainMp(-b.mp)
            damageBattler -= b.mp

            } else {

            b.gainMp(-damageBattler)
            damageBattler = 0

            }

            d = damageBattler

            }

            return damageBattler

            [/state damage modifier]

          • Ctelin Ajira says:

            Oh boy. What is happening?

            Syntax Error: Unexpected token this

          • Hime says:

            You might be missing a bracket or something.

  11. Maune says:

    I’m pretty sure this wasn’t the intention of this plugin, but I’m wondering if it’s possible with it.

    Is it possible to deal damage to someone other than the target of an attack? Going for a basic “thorns” effect where the attacker takes 25% of the damage they deal to someone using the state to block.

    • Hime says:

      Yes. You can create a “defender” state damage modifier, which will activate when the person with the state gets hit.

      As an example, you might say

      
      b.gainHp(d)
      return d;
      
      

      Which means the attacker will receive damage equal to the amount it dealt to the defender.

      • Maune says:

        Aha, there we go. What I ended up doing was putting in this formula as a “defender” state damage modifier

        a.gainHP(-d * 0.25)
        return (d * 0.75)

        The “return” function only seems to affect the initial target, so this formula made the target with the state take 75% damage (which leads to some decimals I’ll sort out on my own) and the attacker taking 25%.

        I am so far terrible at javascript (or coding in general), so I didn’t think of “.gainHP”

        Thank you for the help Hime.

  12. Emelian65 says:

    Hello I want to ask if there is a way to force a critical hit with this on the defender.

    Lke if the defender is under x state then all physical skill recived are criticals.

    I don’t really have any java knowledge so I’m completely lost on what type of formula should be used, if it’s even possible.

    • Hime says:

      Unfortunately, state damage formulas are applied after critical modifiers, so the default critical damage modifier has already been applied.

      One solution would be to find a plugin that allows you to change when the critical damage is applied, so that you can have it applied after the state modifiers, and then have the state modifier set the critical flag to true.

      Though, I don’t have a critical modifier plugin yet.

Leave a Reply to gameguy503 Cancel reply

Your email address will not be published. Required fields are marked *