(Yanfly Plugins) 20% state application to self when attacking?

So I actually have two questions:


1: How would I create an offensive skill that has a 20% chance to apply a state to my character?


2: How would I create a skill that requires a state to be in effect and is otherwise greyed out?


For example my Berserker class.


- Learns Deathlow and Raging Blow with JP via menu like normal.


- Deathblow is greyed out during combat due to not having the "Enraged" state.


- Using Raging Blow has a 20% chance to apply "Enraged" state to the Berserker.


- While the "Enraged" state is active, the Deathblow skill lights up like a normal skill and can be used while "Enraged" is active.
Using Yanfly Skill Core plugin:


To enable skill if actor has state notetag


<Custom Show Eval>if (user.isStateAffected(123)) {visible = true;} else {visible = false;}</Custom Show Eval>


change 123 to id of your state


For 20% chances to apply state skill notetag


<After Eval>


var chanceStateApply = Math.floor(Math.random() * 100);


if (chanceStateApply > 80) {


// user.startAnimation(55); 


user.addState(123);


}


<After Eval>


If you delete // there should be played animation id 55 in database when state is applied
Awesome!


Added an extra / in the second <After Eval>, but other than that it worked flawlessly. I love the addition of the animation, too. Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-plugins-20-state-application-to-self-when-attacking.64363/