Variable Hit and Evasion

Hi, I am trying to make a game that has some like:
- if the attack is holding a melee weapon and attacking a target with a ranged weapon, he gains 30% more hit.
- a player can learn a skill with a passive state (using yanfly plugin) that grant him 30% more evasion against range weapon.

I had been searching the forum and can not find any thread discussing this. How can I implement this?
As far as I know, you'll need a plug-in written, as the system will need a way to determine what is melee and what is ranged, and know how to calculate it when you select attack. There might be a way by getting cute with the damage formula to do a check and add a state to grant you the short term boost to to-hit, but I'm not 100% that will work, as it would depend on when the formula adds a state (the features list on attacks adds them after the attack is done, so that is not an option that will work).

Moved to Plug-In Requests

Original thread: https://forums.rpgmakerweb.com/threads/variable-hit-and-evasion.91430/