State that deals damage when taking damage

Hello again,

I've wanted to make a state that deals a flat amount of damage to whoever has it when they take any damage. The issue is that I couldn't figure out a way to make a state activate on every instance of damage. The closest thing I've managed to make is this(which isn't all that close):

JavaScript:
<Custom Respond Effect>
 if (value>0) {
target.gainHp(-1 );
}
</Custom Respond Effect>

If I'm not mistaken, what this does is make the afflicted actor take 1 damage whenever they take damage higher than 0 when hit by a skill. What it doesn't do is to account for skills that apply multiple instances of damage. On top of that, the damage popup only displays the 1 damage caused by the state and not the damage that is applied by the skill itself.

Is there any way to make it so that this state activates for each instance of damage? If that is not possible, I'm willing to settle for the second effect, but how would I fix the popup issue?

Thanks in advance for all the help!
You could try to alter the thornmail- tips and trick from yanfly. Seems similar to what you want.
Tips & Tricks
@Slaughty It reads like the OP wants the opposite of Thornmail - wants to make the target take additional damage rather than reflect anything back at the attacker.

What it doesn't do is to account for skills that apply multiple instances of damage.
It should. As far as I know, all of the state effects related to hits are evaluated for every hit, it wouldn't be just once per entire action unless you intentionally made it so.

As far as the popups, that's startDamagePopup()

I'd suggest you make it only trigger off of actions that deal damage, though. So
Code:
<Custom Respond Effect>
if (this.isDamage() && value > 0)
{
    target.gainHp(-1);
    target.startDamagePopup();
    if (target.hp <= 0)
        target.performCollapse();
}
</Custom Respond Effect>

I also added a check in there to see if that kills them.
@Slaughty It reads like the OP wants the opposite of Thornmail - wants to make the target take additional damage rather than reflect anything back at the attacker.


It should. As far as I know, all of the state effects related to hits are evaluated for every hit, it wouldn't be just once per entire action unless you intentionally made it so.

As far as the popups, that's startDamagePopup()

I'd suggest you make it only trigger off of actions that deal damage, though. So
Code:
<Custom Respond Effect>
if (this.isDamage() && value > 0)
{
    target.gainHp(-1);
    target.startDamagePopup();
    if (target.hp <= 0)
        target.performCollapse();
}
</Custom Respond Effect>

I also added a check in there to see if that kills them.

Sorry for replying late, very busy week.

I had actually included target.startDamagePopup(); in the notetag previously and did so again when trying your code and in both cases what happens is that: the damage from both the ability and the state is shown however while the damage from the state is shown as "1" as it should be, the damage from the ability is also shown as "1" which is not the case. The target takes the correct amount of damage in each case but the display always shows it as "1" for whatever reason.

Aside from that issue, multihits do work correctly as you've said. I was just messing up how I set up my multihits previously, so that's not an issue anymore.

Original thread: https://forums.rpgmakerweb.com/threads/state-that-deals-damage-when-taking-damage.167444/