Use autopassive states conditionally?

I am trying to work out how to incorporate a unique ability into my Monk class. As I understand it luck is used to determine the critical hit rate so my idea is to give my Monk class a passive state that doubles its luck score when it is attacking creatures of a chaotic nature. Can I use this JavaScript to accomplish this task and if so what method should I do to accomplish this? I am still pretty new to all of this and I have not been able to really figure out a way I can pull this off on my own. It seems like this would require some sort of complex coding or at least something that is not really obvious. If it is possible though then I am pretty sure autopassivestates is my best bet.
I regret that I can't answer your question, so hopefully someone else will. I can, however, clear up a misconception for you.

Luck does not determine critical hit rate; it determines hit and defend rates for states only. High luck on someone attempting to apply a state means a higher chance of the state being applied, whereas high luck on someone defending against a state means lower chance of the state being applied.

The (extra) parameter you're looking for is critical rate (CRI), and if you're curious, the formula for critical hit rate is:
user.CRI * (1 - target.CEV)

Spoiler: About parameter numbers...
Since you mention you are new, one thing it took me a long time to discover that might help you as well is that, by default:
Base parameters are whole number values and can have either a whole number add/subtract (as in equipment Parameter Changes) or percentile multipliers (as in Traits).
Extra parameters are percentile values and any modifications from Traits are added/subtracted.
Special parameters are percentile values and any modifications from Traits are multiplied.
I regret that I can't answer your question, so hopefully someone else will. I can, however, clear up a misconception for you.

Luck does not determine critical hit rate; it determines hit and defend rates for states only. High luck on someone attempting to apply a state means a higher chance of the state being applied, whereas high luck on someone defending against a state means lower chance of the state being applied.

The (extra) parameter you're looking for is critical rate (CRI), and if you're curious, the formula for critical hit rate is:
user.CRI * (1 - target.CEV)

Spoiler: About parameter numbers...
Since you mention you are new, one thing it took me a long time to discover that might help you as well is that, by default:
Base parameters are whole number values and can have either a whole number add/subtract (as in equipment Parameter Changes) or percentile multipliers (as in Traits).
Extra parameters are percentile values and any modifications from Traits are added/subtracted.
Special parameters are percentile values and any modifications from Traits are multiplied.
Thanks. So to get the effect I want I need to figure out how to conditionally double CRI. So I'm still in the same position but now I know I was mistaken in the stat that I was going to the ball. I appreciate all the help I can get though so thank you
@jcoultas If you look into Yanfly's Buffs and States Core, there may be a way to code in a conditional effect into the state. I think you'd want to run a Custom Initiate Effect to check if the target is a chaos type (however you have that stored, I assume you'd check for a notetag value indicating the enemy type) and if so, temporarily double the actor's CRI. Then you'd need to run a Custom Conclude Effect on the state that returns CRI to normal, if it was doubled.

If you need help coming up with the actual JavaScript for these, let me know. I could work on it sometime this weekend.
I am not sure how you can Double your Crit on hitting an enemy, But I can think of a way on gaining Bonus Crit on killing an enemy.
Let's imagine you want your Monk to gain "30% Bonus Crit" on top of his Base Crit on hitting a Monster - Bat.

Now this can be done in 3 Steps.
Step 1) Set Status Effect - Bonus Crit
Make a Status Effect called Bonus Crit and set it to grant say for example, 30% Bonus Crit for rest of Battle.
Step 2) Set Common Event - Call it "Monk gains Crit"
Head to Common Event Tab in Database and create a New Common event name it "Monk gains Crit". Insert a "Change State" event, Set Monk to gain Bonus Crit (We created this Status Effect earlier)
Step 3) Set Battle Window Condition
Go to Database -> Troops -> Conditions. Here, you set Enemy HP Bat = 99% or below. Now make this condition trigger the "Monk gains Crit" using Call Common event function. (What this means is "If the Bat is hurt below 99% of its HP in Battle, It triggers the Common event where Monk gets buffed with State Bonus Crit)

You can end it with a Exit event processing so this happens only once in Battle.
You need to do this in every Troop window that has a Bat enemy, Which will make your Monk gain Bonus Crit.

Original thread: https://forums.rpgmakerweb.com/threads/use-autopassive-states-conditionally.77945/