First you need to be able to counterattack of course. This can simply be done by going to the Features of a state/weapon/armor and add this:

Which is the rate of which counterattacking will activate.
Then go to the script editor and then click on Scene_Battle. Around line 615 is the code def invoke_counter_attack(target, item)

here the skill used for counterattacking is the default attack command. replace the attack_skill line at 617 with this:
if target.state?(3)
attack_skill = $data_skills[221]
else
attack_skill = $data_skills[target.attack_skill_id]
end

this will make so that when the counterattacking user is inflicted with state 3, which would be the blind state:

they will counterattack with the skill with the ID 221. (note that characters with the death state can't counterattack.)
You can change skill 221 to skill 2 so that the counterattack is the guard skill.
If you want to show the attack animation for the counterattack skill, add this below the state conditional branch:
target, @subject = @subject, target
show_animation([target], attack_skill.animation_id)
target, @subject = @subject, target

18 comments