All items and skills in RPG Maker come with additional “effects”.

Effects include gaining HP, learning a skill, gaining a buff in a parameter, or running a common event.

However, what if you would like a skill to do something that isn’t provided by default?

You could use the damage formula, but what if you would like to create conditions on those effects? You could include those conditions in the formula as well, but the problem here is you may end up with a very complex damage formula.

Instead of using the damage formula for everything, you can create custom effects that support formulas. If you already knew how to write the formula, then you can just move it from the damage formula into this formula effect.

Because a formula effect is just another effect, it supports other plugins that work with effects, such as Effect Conditions, which allows you to determine whether an effect should be executed based on a condition.

## Download

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

This plugin is for RPG Maker MV only. Click here for the Ace version!

## Installation

Download the 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_FormulaEffects** plugin.

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

## Usage

To create a formula effect, note-tag items or skills with

<formula effect> FORMULA </formula effect>

Where the FORMULA will be evaluated during skill execution and the behavior is determined by what you write in the formula.

The following formula variables are available

a - attacker b - target i - current item or skill v - game variables s - game switches t - game troop p - game party

So for example, if you wanted to reduce the target’s HP by 100, you could use the formula

b.gainHp(-100);

You can access the result of the action on the target using

var r = b.result()

With this, you can then check how much HP damage or MP damage was dealt

r.hpDamage r.mpDamage

And then use this in your effect calculations.

Anything that is defined in the code can be used as an effect.

Can it be used to change Action Times +? Like if the skill is used the attacker gains another turn.

I was wondering if I could use this to make a skill leave an enemy with 1 point of health if it would normally kill it?

Nevermind on calling events, got it to work, great work here!

Is there a way to call a common event?

Using script functions, how would I subtract the value of Variable 42 from the value of Variable 41?

$gameVariables.setValue(42, $gameVariables.value(42) – $gameVariables.value(41));

Which takes the value of variable 42, subtract value of variable 41, and then put the result into variable 42.

How would I set up the formula effect to make a spell drain 25% of the Users Max MP when cast?

Nevermind. I tried it and forgot the “a.” before mmp, and it’s working now.

I have a newbie kind of question. Would it be possible to have this affect a creature(s) such that if their hp is < – x%, that they are affected by a state, such as death?

Yes. You can a condition to check whether the target (b) HP is less than a certain percent, and then add the specified state.

`if (b.hp < b.mhp * 0.10) {`

b.addState(1)

}

So you’re checking whether the target’s current HP is less than 10% of their max HP.

If so, you would add the death state.

Thank you so much for your fast response! I see what I was doing wrong when I was trying to implement this formula.

Is it possible for the formula effect to target the user?

Yes. You can use the variable

`a`

in your formulas, similar to the damage formulas.It assumes the “attacker” is the user of course.

How would I set up the formula effect so that 25% of the total damage dealt is dealt back to the user as recoil?

The total damage can be accessed via

`b.result().hpDamage`

.Note that you are accessing the action results for the target, not the user.

So now you just need to use

`a.gainHp(-b.result().hpDamage * 0.25)`

To inflict 25% of damage to the user.

Thank you so much, this is a really helpful script!