[ACE] Counterattack Help

Hi! It's me again with something probably stupid simple.

VX Ace set up its Counterattack function to basically be dodge -> counter. I've set up a berserk skill for a character that gives them 100% counter but because the game has the character dodge then counter, it makes so the character really never takes damage (when you know, the downside of berserk should be crap defense in exchange for attack).

My question is
: how do you make it so the character has to take damage before they counter? As funny as it is that a character will still counterattack even if the attack misses, it just doesn't work for me.

I figure it's in Scene_Battle (and I'm probably wrong because my ability to script is like zilch) but nothing sounds like it would change the dodging.
If this has been answered before, I'm sorry I could not find it despite multiple google searches and the search function on this very forum.

Thanks!
That's something I've been searching for too.

I couldn't find anything in there that seems to disable the incoming attack and Ctrl-Qing the part of the code that triggers the counter attack in Scene_Battle doesn't seem to stop the attack cancel - only the attack that comes after.

What I ended up doing is have a method that runs on certain attacks and checks for a state in my physical move forumla's like:
Code:
def counter(a,b)
 b.state?(counter_state_id)
   a.hp -= b.atk
  end
end

Though it doesn't look right, it does let me test the counter at least.

You might be able to do that as an alternative if you can find a script that can "b" to force an action instead?
I think there might be a Yanfly script that can do that.
For starter, it could be like this
Code:
class Scene_Battle
  def invoke_item(target, item)
    if rand < target.item_mrf(@subject, item)
      invoke_magic_reflection(target, item)
    else
      apply_item_effects(apply_substitute(target, item), item)
    end
    @subject.last_target_index = target.index
  end
  #--------------------------------------------------------------------------
  # * Apply Skill/Item Effect
  #--------------------------------------------------------------------------
  def apply_item_effects(target, item)
    target.item_apply(@subject, item)
    refresh_status
    @log_window.display_action_results(target, item)
    if rand < target.item_cnt(@subject, item)
      invoke_counter_attack(target, item)
    end
  end
end
I never really use counter that much
@TheoAllen That does work but it also gets rid of the skill animations. It's a start so thank you.

EDIT: Er, scratch that. There's something amiss with it and Yanfly together that is affecting the animations. I think I can figure out what's going on. I do appreciate the help, thank you!

OK yes, I got it. Thank you very much!
It will be better if you explain what's going on. What Yanfly script was it, and how u solved it in case some people searched for the same issue

Original thread: https://forums.rpgmakerweb.com/threads/ace-counterattack-help.95627/