YEP Buff/States core, State damage

Here is my code for reference:
Spoiler: My Code
<Custom Apply Effect>

if (target._stateTurns[36] >= 50) {

target._stateTurns[36] = 50;

}

</Custom Apply Effect>

// The above snippet is used to control the maximum duration of the state (in this case, state 36 has a cap of 50 turns)

<Custom Regenerate Effect>

// The formula for the regeneration effect. In this case, it uses the user's max HP, divides by 100 (to make it 1%),
// checks against the elementRate of element 12, rounds everything down, then increases the total by 1.

var regen = Math.floor(origin.mhp / 100 * target.elementRate(12)+1);

// Make the user gain HP.

user.gainHp(regen);

// Show the HP healed.

user.startDamagePopup();

// Clear the user's results.

user.clearResult();

</Custom Regenerate Effect>

What I have here is just a basic healing effect that heals over time. if I were to add a "-" to (regen), it would instead deal damage (and would be displayed as (-regen) instead). What I want to be able to do is make an effect that can change it's damage or healing based on actions received.
For example, the above example heals for 1% of the user's max HP per turn, but maybe if you receive physical damage (element 1), the amount of healing it does should be increased to 2% instead.
Alternatively, supposed you were to take Shadow damage (let's say element 9), and that effect weakens healing taken, so it should instead reduce the amount of healing to 0.5% of the user's max HP per turn. Of course, this can be done already by modifying the user's element rate, since the above formula already performs a check against the elementrate, but what if I want to be able to do it without having to do that?
I don't know exactly how it would have to be written, but I'm inclined to believe it should be possible to do using if statements.
If this can be done, I would like to try to take it one step further and make it so when a modifier is run to increase or decrease the effect, it also increases a number (either a number unique to this formula, or a variable, it doesn't matter), and the point of this number would be to limit the number of times the effect can be increased or decreased.
Partially resolved, figured out how to amplify damage, here is the new, current code:

Spoiler: New Code
<Custom Apply Effect>

if (target._stateTurns[75] >= 50) {

target._stateTurns[75] = 50;

}

</Custom Apply Effect>



<Custom Apply Effect>

target._magicEffect = Math.ceil(origin.mat * 0.5 * target.elementRate(13));

</Custom Apply Effect>



<Custom Remove Effect>

target._magicEffect = undefined;

</Custom Remove Effect>

<Custom Regenerate Effect>

target._magicEffect = target._magicEffect || Math.ceil(origin.mat * 0.50);

// target.startAnimation(12);

target.gainHp(-target._magicEffect);

target.startDamagePopup();

if (target.isDead()) {

target.performCollapse();

}

target.clearResult();

</Custom Regenerate Effect>



<Custom Respond Effect>

if (target.result().hpDamage > 0) {

var elements = this.getItemElements();

while (elements.length > 0) {

var element = elements.shift();

if (element === 7) {

target._magicEffect = target._magicEffect * 2;

target.startAnimation(149);

}

}

}

</Custom Respond Effect>

What this effect does is apply a damage over time effect to the target, then each time the target is hit by element 7, the damage the effect deals is doubled.

Original thread: https://forums.rpgmakerweb.com/threads/yep-buff-states-core-state-damage.118915/