Skill chance to activate + halve damage taken?

Is there a way to have a skill automatically activate with a certain percentage chance of doing so? For example, lets say I have a skill that has a chance of activating equal to the user's Agility stat that allows the player to evade all damage. Every time an attack (preferably only of a certain type/element, eg Physical, Fire) were to hit the character, there would be a chance for the Evade skill to activate, which would mean the attack did no damage.


Building on that, is there a way to do this so that it halves the damage taken rather than reducing it completely? 


Ideally, the final product of these two would be a rebuild Guard system. Every character would have an automatic chance to block and/or evade each attack, and this chance would depend on their Guard stat (replacing Luck) for Guard and their Agility stat for Evade. The Guard command would then provide a one turn boost to the Guard stat instead of adding the Guard state. 


Is this possible?
I've moved this thread to Plugin Requests. Please be sure to post your threads in the correct forum next time. Thank you.


Plugin releases is for presenting plugins you wrote yourself
I've moved this thread to Plugin Requests. Please be sure to post your threads in the correct forum next time. Thank you.


Plugin releases is for presenting plugins you wrote yourself

Sorry, I actually thought I'd posted it in the general plugin help section (with the aim of finding out whether it was already possible). I'll double check in future. Thanks!
I feel like you're making your life way harder than it needs to be.  Why not use something like @Yanfly's Extra Parameter Control plugin to set the chance of Evasion equal to Agility (or whatever formula you desire) for all characters?


Or, if you need to visually show the character using a flashy "evade" move, just use Yanfly's Action Sequence Packs along with Conditional Branches (inside the Action Sequences) that judge random numbers against the battler's AGI?
That's a good idea for Evade, but it wouldn't work for Guard which only halves the damage. Or is it possible to do math in action sequences to?

Original thread: https://forums.rpgmakerweb.com/threads/skill-chance-to-activate-halve-damage-taken.66426/