checking state rate in damage formula help

I am trying to use the following formula:

b.stateRate(5) < 0.2 ? b.addState(33) : b.addState(32)); a.atk-b.def


I'm trying to say: if the target has less than 20% resistance to State5, then attack and inflict state 33; otherwise, attack and inflict state 32.

The skill doesn't provide either result; it just says 0. If I change the first term, to something like b.def > 1, then it works. So not sure if I'm calling the right function. Do I have an error in the formula?
Help much appreciated.
Notes:
  1. There's an extra ), just before the ;, which will cause an error and make the formula return 0.

  2. Remember that a state rate of 20% means the state will only be applied 20% as often, i.e. it's an 80% resistance. Not sure which one you want here.
Try one of these instead (they're equivalent):
JavaScript:
b.stateRate(5) < 0.2 ? b.addState(33) : b.addState(32); a.atk - b.def
JavaScript:
b.addState(b.stateRate(5) < 0.2 ? 33 : 32); a.atk - b.def
worked, thank you!!

Original thread: https://forums.rpgmakerweb.com/threads/checking-state-rate-in-damage-formula-help.131564/