MV how do i make a passive state where the actor gurrantee counterattack each time the opponent misses or if the actor evaded

how do i make a passive state that makes it so that for each time the actor managed to evade an attack they are gurranteed to counterattack the opponent ?
IIRC with the way counters function both in the base engine and with yanfly's counter control, you cant really get that done without some modification to the process within the base engine. someone else might know a way without that, but my input...

you can use counter control and buffs & states to gave your counter state write some property on the defender within a <custom select effect>, delete it if a respond effect ever triggers since that necessitates being hit, and use that as the defend condition. but iirc, that would only work for every other dodge as the counter evaluations would have already happened before the attack was even determined to have hit.

you could also try to to "fake" a counter by doing the same as above, but instead of using counter control at all, use battler.queueForceAction() to make the defender attack those who attack them. the issue with that though is that without modifications to that as well, the counter consumes the battler's turn if they got hit before they could act. you can kind of sidestep it by delaying the fake counters to the end of the turn, but at that point its not a direct counter
IIRC with the way counters function both in the base engine and with yanfly's counter control, you cant really get that done without some modification to the process within the base engine. someone else might know a way without that, but my input...

you can use counter control and buffs & states to gave your counter state write some property on the defender within a <custom select effect>, delete it if a respond effect ever triggers since that necessitates being hit, and use that as the defend condition. but iirc, that would only work for every other dodge as the counter evaluations would have already happened before the attack was even determined to have hit.

you could also try to to "fake" a counter by doing the same as above, but instead of using counter control at all, use battler.queueForceAction() to make the defender attack those who attack them. the issue with that though is that without modifications to that as well, the counter consumes the battler's turn if they got hit before they could act. you can kind of sidestep it by delaying the fake counters to the end of the turn, but at that point its not a direct counter
i managed to find a notetag in yanflys counter control plugin that does the effect but the only problem it has is it counters one evaded hit so even if you evaded multiple times from the attack you still only counter once, you do not counter the other evaded ones when the opponent's attack is still happening
it counters one evaded hit so even if you evaded multiple times from the attack you still only counter once, you do not counter the other evaded ones when the opponent's attack is still happening
you hadnt mentioned that you want the counter to be per hit, and i wouldnt have guessed it as normally its per action. At that point id sooner suggest damage reflect than a counter

<Evade Counter>
its not quite the same as
each time the actor managed to evade an attack they are gurranteed to counterattack the opponent
<Evade counter> makes the counter function as it normally does in the base engine. if the counter is being performed, the skill that triggered it is forced to have been dodged. Its not "you perform a dodge and then counter", its "you perform a counter and dodge". even with 0% evasion and an enemy with 1000% hit rate, you'd never be able to dodge a hit, but a counter would force it
you hadnt mentioned that you want the counter to be per hit, and i wouldnt have guessed it as normally its per action. At that point id sooner suggest damage reflect than a counter


its not quite the same as

<Evade counter> makes the counter function as it normally does in the base engine. if the counter is being performed, the skill that triggered it is forced to have been dodged. Its not "you perform a dodge and then counter", its "you perform a counter and dodge". even with 0% evasion and an enemy with 1000% hit rate, you'd never be able to dodge a hit, but a counter would force it
how do I achieve damage reflect ?
normally you'd give the state a notetag with a yanfly buffs & states effect to damage the attacker for the same amount the defender took, but the tricky part is making it work on evade. if an evade takes place, no damage has been dealt, so no damage can be reflected. you could try to grab the formula of the skill used and then evaluate it and deal its damage to the attacker at the end if it missed. something along these lines

Code:
<custom deselect effect>
if (!target.result().isHit())
  user.gainHp(-eval(this.item().damage.formula))
</custom deselect effect>
looks like
normally you'd give the state a notetag with a yanfly buffs & states effect to damage the attacker for the same amount the defender took, but the tricky part is making it work on evade. if an evade takes place, no damage has been dealt, so no damage can be reflected. you could try to grab the formula of the skill used and then evaluate it and deal its damage to the attacker at the end if it missed. something along these lines

Code:
<custom deselect effect>
if (!target.result().isHit())
  user.gainHp(-eval(this.item().damage.formula))
</custom deselect effect>
it didn't work sadly
in what way?

did you check the battler's hp before and after the skill? i assumed that the tag world cause a damage popup on the attacker and that i wouldnt have needed to add the call for it, but "It didnt work" doesnt tell me if thats it and theres just no popup, or if theres no damage at all, an error, is even running. etc
Code:
<custom deselect effect>
if (!target.result().isHit())
  user.gainHp(-eval(this.item().damage.formula))
</custom deselect effect>
Unless I'm missing something, this would go off on both an evade and an actual miss. Based on the OP, I'd think you'd want to check if (target.result().evaded) no?

I think you could fake this with Counter Control. Make a state that has a negative Evasion of your regular Evasion rate, and a Counter rate equal to what your regular Evasion.

So, with the default class setup from a new project, you'd give it -5% Eva and 5% Counter.

Then make the counter skill with the notetag for an evade counter. That'll have the same odds of going off, and appear the same as a regular evade, but the counter skill part will happen without just reflecting damage automagically.

This solution won't work if you mess around with different Evasion values, or have items that can increase it. You might still be able to account for those with a dynamic traits plugin, but that's a more complicated situation.

You could also do it via Action Sequences, if you make a common follow action that checks for evade and does the counter attack - in that case, you can program the target moving, swinging, etc. Then you'd use the action sequence copy tag, or if the rest of the skills should look different, just copy the follow block.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-a-passive-state-where-the-actor-gurrantee-counterattack-each-time-the-opponent-misses-or-if-the-actor-evaded.171429/