How to Trigger an Event When Actor or Enemy Gets Hit?

Hello everyone,

Here's a couple things I'm trying to do:
- wall of fire spell: the enemy takes damage every time it hits the actor
- rising anger: the enemy grows angrier each time the actor hits it

I think I would need a conditional branch to be able to detect when the actor or enemy gets hit by an attack, but I can't seem to find that as an option. Do you know where I might find it? Or is there perhaps a plugin that could do this?

Thanks.
Odds are high you'll need a plug-in as there is nothing in the default system that I know of that allows you to tell things like that, but I might be wrong. I'll move it to plug-in requests and if someone can find a way to do this in the default system they can post it there as well.

Moved to Plug-in Requests

maybe if you hook up the checks for hits to battle events set to "moment"?
IDK, I never tried it, but *supposedly* the moment scope checks after each action, and the origin and destination of each action is kept on the battle manager, so you might be able to tap into that.
For the first one, you can use Yanfly's Thorn Armor code. For the second one, when you say angrier do you mean their attack stat goes up?
You want to make the enemy angrier everytime it gets hit ?

By physical attacks and magical attacks ? Only physical attacks ?

If you want the enemy to get angrier everytime it takes in any possible way, you can easily do this with two event pages in the Troops section

For the first page, set the span to "Battle", and the condition to "Turn 0 + 0 * X"

Then put this in :

Code:
◊ Set Variable : 001 - HP = Enemy's HP

Create another page. Set the span to "Turn" and the condition to "Turn End"

Put this in :

Code:
◊ Set Variable : 002 - New HP = Enemy's HP
◊ If New HP < Enemy's HP
    ◊ Text : "Enemy gets angrier !"
    ◊ Change enemy state : Angry !
◊ End
◊ Set Variable 001 - HP = Enemy's HP
To manage the "Angry !" buff stack, I advice you to use the States & Buff Core plugin. You can also make the enemy be angry at the start of the battle, either by adding it in the first page along with the variable initialization, or with the Auto Passive States plugin.
The angry thing...a cumulative damage bonus that builds each time they get hit, right? I think I'd consider doing something similar to the Thornmail example Uzuki quoted: +1 to "angry" counter when being hit, and multiply outgoing damage by some function of the counter, e.g. this might do it:
Spoiler: State notetags
Code:
<Custom Battle Effect>
// Initialise (for a passive state)
user.setStateCounter(stateId, 0);
</Custom Battle Effect>

<Custom Apply Effect>
// Initialise (for a buff that gets applied)
user.setStateCounter(stateId, 0);
</Custom Apply Effect>

<Custom React Effect>
user.addStateCounter(stateId, 1);
</Custom React Effect>

<Custom Confirm Effect>
// +10% to all outgoing damage per stack
var anger = user.getStateCounter(stateId);
value *= 1 + 0.1 * anger;
</Custom Confirm Effect>

<Custom Remove Effect>
user.removeStateCounter(stateId);
</Custom Remove Effect>
You can choose Apply Effect or Battle Effect depending on when the state is granted to the enemy (a passive state will never trigger the Apply Effect). Also, note that you don't have to substitute a number for stateId, it's a variable that's automatically set to the state's ID. 🙂

belatucadrus's suggestion is good, but ignores multiple hits per turn. Maybe that's what you want, though~
Thanks everyone for your help! I was able to do what I wanted with the angry thing using eventing thanks to belatucadrus. Next, I'm going to try the thorn armor code to see if that will work for my wall of fire spell.
I tried the thornmail code and it works great! The only thing I'd like to change is how the recoil damage gets displayed. Currently it pops up really quick as a number just below the enemy graphic. I would like for the recoil damage to be announced in the message window at the top that appears for normal attacks like this: "Slime took 12 damage!" Would such a thing be possible?

Original thread: https://forums.rpgmakerweb.com/threads/how-to-trigger-an-event-when-actor-or-enemy-gets-hit.113101/