Skill - Shield+State

Hi,
How can I create a skill that says "When the user uses this skill, if an enemy attacks with a physical attack, then the enemy gets a state (a negative one like poison, burn...)".

This skill is like a shield that if touched (only in the next turn) gives you a negative state. It will be also nice to add an effect that reduces the enemy damage (like a shield does).
The skill gives a state, that has a notetag (Yanfly Buffs & States):

<Custom React Effect> if (this.isPhysical()) { value *= 0.5; user.addState(Id); } </Custom React Effect>

Id is your negative state Id and the 0.5 there is the damage reduction multiplier.
@rpgLord69 got it - I think you just want to round the division to make sure gainHp() is getting an integer value.
Code:
value = Math.round(value * .5);
You don't even need to use javascript for percentage-based damage reduction - the default SP-Parameter "Physical damage" can do just that.
Thank you all guys, I'll try and let you know!

Original thread: https://forums.rpgmakerweb.com/threads/skill-shield-state.164250/