Conditional branch that triggers by dmg

Hello everybody!
Maybe it's an easy thing but i couldn't figure out how to to do it nor i didn't know how to search for it on web 😀

Is it possible to make a conditional branch so that triggers when enemy gets hit during combat?

So i'd like to make a state or something what the enemy activates at the end of the turn and if the player hits him(in the next turn) then it attacks back with a skill. I tried to do it with switch but it doesnt work well.

Thank you for the answers, RPGMV

I suggest downloading this plugin if you want enemies to counterattack with specific moves when you hit them.

I suggest downloading this plugin if you want enemies to counterattack with specific moves when you hit them.
Thank you, i check on it!

I suggest downloading this plugin if you want enemies to counterattack with specific moves when you hit them.
It works perfectly thank you. Can i have one more question? I'd like to make it's opposite too.
So the enemy gets a state at end of the turn and if the player doesnt hit him with a skill then in the next turn it (the enemy) casts a skill.

Thank you for the answer again!
if the enemy having the state is the trigger for using the skill, you can set the state to be removed by damage in the database.

you could also choose some variable, set its value to the enemy's hp at turn 0, check at the end of every turn if their current hp is lower than that variable, and then set the variable to their hp. If that check goes ever goes off, then presumably they took damage at some point during the turn.
if the enemy having the state is the trigger for using the skill, you can set the state to be removed by damage in the database.

you could also choose some variable, set its value to the enemy's hp at turn 0, check at the end of every turn if their current hp is lower than that variable, and then set the variable to their hp. If that check goes ever goes off, then presumably they took damage at some point during the turn.
Ah yes thats a good idea! thanks so much!
Yanfly Buff & States core is also really useful for this. You can give an actor or an enemy a state, and inside the state provide conditions that trigger based on pretty much any part of the attack or defending sequences. I use this plugin to create several complex actions and reactions that otherwise would be quite difficult to set up.


<Custom Respond Effect>
and
<Custom React Effect>

are useful for setting up custom counter reactions and added effects on either the attacker or defender depending on your preferences.

Yup_CounterControl also can be used to setup counterattacks which are slightly different but these two plugins work great together for creating more customized reactions and counters.

Yep_BuffStatesCore:
State Notetags:

--- Timing Effects ---

These effects specifically occur at certain intervals or timings.

<Custom Apply Effect>
code
code
</Custom Apply Effect>
The code in between these notetags will run when the state is added onto
a battler. The code will process after the state is actually applied.

<Custom Remove Effect>
code
code
</Custom Remove Effect>
The code in between these notetags will run when the state is removed from
a battler either manually or due to turn decay. The code will process
after the state is actually removed but before <Custom Leave Effect>.

<Custom Leave Effect>
code
code
</Custom Leave Effect>
The code in between these notetags will run when the state is removed from
a battler due to turn decay. The code will process after the state is
actually removed and after <Custom Remove Effect>.

<Custom Turn Start Effect>
code
code
</Custom Turn Start Effect>
This requires YEP_BattleEngineCore. This effect will run at the start of
each of the battler's turns. The code will process after all the other
turn start effects have taken course.

<Custom Action Start Effect>
code
code
</Custom Action Start Effect>
This effect will run at the start of each of the battler's actions. The
code will process before the skill/item cost takes place.

<Custom Action End Effect>
code
code
</Custom Action End Effect>
This effect will run at the end of each of the battler's actions. The
code will process before the action end steps takes place.

<Custom Regenerate Effect>
code
code
</Custom Regenerate Effect>
This effect will run whenever the battler would regenerate HP, MP, or TP.
The code will process after all the other regenerate effects have ran.

<Custom Turn End Effect>
code
code
</Custom Turn End Effect>
This effect will run at the end of each of the battler's turns. The code
will process after all the other turn end effects have taken course.

<Custom Battle Effect>
code
code
</Custom Battle Effect>
This effect will occur at the start of battle if the battler has the state
already applied (usually through a passive state).

<Custom Victory Effect>
code
code
</Custom Victory Effect>
This effect will occur at the end of battle if the party is victorious.
This will only apply to the player's party. If this state can expire at
the end of battle, this effect will not occur as state expiration will
occur before this effect will happen.

<Custom Escape Effect>
code
code
</Custom Escape Effect>
This effect will occur at the end of battle if the party has escaped.
This will only apply to the player's party. If this state can expire at
the end of battle, this effect will not occur as state expiration will
occur before this effect will happen.

<Custom Defeat Effect>
code
code
</Custom Defeat Effect>
This effect will occur at the end of battle if the party is defeated.
This will only apply to the player's party. If this state can expire at
the end of battle, this effect will not occur as state expiration will
occur before this effect will happen.

Quick Reference:
Action Starts
- Attacker: Initiate
- Defender: Select
Action Connects as a Success Hit, skip if Missed or Evaded
- Attacker: Confirm
- Defender: React
Damage is Applied to the Defender
- Defender: Respond
- Attacker: Establish
These occur regardless if the action is successfully hit.
- Defender: Deselect
- Attacker: Conclude

State Notetags:

--- On Action Effects ---

These effects specifically occur when the battler is a target of an action.

<Custom Initiate Effect>
code
code
</Custom Initiate Effect>
This effect will run when the battler selects a target. This will occur
before hit/miss/evade confirmation and damage execution. This effect will
run before everything else has taken course.

<Custom Select Effect>
code
code
</Custom Select Effect>
This effect will run when the battler is selected as a target. This will
occur before hit/miss/evade confirmation and damage execution. This effect
will run after <Custom Initiate Effect> before everything else has ran.

<Custom Confirm Effect>
code
code
</Custom Confirm Effect>
This effect will run when the battler connects a hit and before damage
execution occurs. This effect will run after <Custom Initiate Effect> and
<Custom Select Effect> and before everything else.

<Custom React Effect>
value -= 100;
value -= user.def;
</Custom React Effect>
This effect will run when the battler is selected as a target. This will
occur only if the action connects and will occur before damage execution.
This effect will run before damage calculation occurs and will return the
'value' variable as a damage modifier. After <Custom Confirm Effect>, this
effect will run.

<Custom Respond Effect>
code
code
</Custom Respond Effect>
This effect will run when the battler is selected as a target. This will
occur only if the action connects and will occur after damage execution.
This effect will run after damage calculation occurs. The 'value' variable
is equal to the damage dealt to the battler. This is the first effect to
run after damage execution has taken place.

<Custom Establish Effect>
code
code
</Custom Establish Effect>
This effect will run when the battler connects a hit and after damage
execution occurs. This effect will run after <Custom Respond Effect> has
occurred and before everything else.

<Custom Deselect Effect>
code
code
</Custom Deselect Effect>
This effect will run when the battler is selected as a target. This will
occur after hit/miss/evade confirmation and damage execution. This effect
will run after everything else has taken course.

<Custom Conclude Effect>
code
code
</Custom Conclude Effect>
This is the final effect to be run after the battler selects a target and
will occur after hit/miss/evade confirmation and damage execution.
It almost worked, the only problem is that at the end of the first round, when it should just be casting the skill, it immediately uses it. Is there a way to make it only use it at the end of the next round?
Here are the battle events in row.
I just checked again and he always says "SPELL" even if i hit him so something is not good xd Any ideas what the problem can be?
It almost worked, the only problem is that at the end of the first round, when it should just be casting the skill, it immediately uses it.
what are the other pages? given the switch requirement of page 4, it shouldnt be possible to have it active at the first turn unless either pages 1 or 2 allow it.
Is above an adjustment to get it to not run on the first turn? or was it intended to operate every other turn?

otherwise
I just checked again and he always says "SPELL" even if i hit him so something is not good xd Any ideas what the problem can be?
at the end of page 3, you set both variables to the same number. page 4 because of that switch req runs after page 3. that condition will only ever give you one result as is, cause itll only ever be ran after youve made them equal.

EDIT: Try something closer to these in this order
what are the other pages? given the switch requirement of page 4, it shouldnt be possible to have it active at the first turn unless either pages 1 or 2 allow it.
Is above an adjustment to get it to not run on the first turn? or was it intended to operate every other turn?
All the other pages were on 'Don't run" cuz of the testing.

at the end of page 3, you set both variables to the same number. page 4 because of that switch req runs after page 3. that condition will only ever give you one result as is, cause itll only ever be ran after youve made them equal.
Ohh, i see now..
By the way i was able to solve the problem with Buffs&States core as Gilgameshed suggested.
Thank you for the help guys!

SOLVED

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/conditional-branch-that-triggers-by-dmg.166778/