MZ Trying to make a skill detecting ailments

I'm attempting to make a skill for my game called 'Scathe', a spell that deals double damage to targets inflicted with 'ailment' states. I'm using VisuStella Skills and States categories to define states as ailments, and using Yanfly's Tips and Tricks tutorials (and a thread here on the forums that reworks them to work in MZ) I tried to write notetag code to get it to work. The skill still deals damage, but the doubling damage aspect doesn't take effect. I'm sure I'm missing something. If anyone could look over the code and tell me if there are any mistakes i've missed.

JavaScript:
<JS Post-Start Action>
const category = 'Ailment';
const states = target.states();
user._targetInflicted = false;

for (let i = 0; i < states.length; ++i) {
  const state = states[i];   
  if (state && state.categories.contains(category)) {
    user._targetInflicted = true;
    break;
  }
}
</JS Post-Start Action>

<JS Pre-Damage As User>
if(user._targetInflicted && value > 0) {
  value *= 2;
  value = Math.ceil(value);
}
</JS Pre-Damage As User>

When making this, I was referencing the entries for Mind/Power Charge and Collect & Inject Ailments on Trihan's thread here. Help in figuring this out would be much appreciated.
If you put

console.log(user._targetInflicted)

at the beginning of your JS Pre-Damage As User, what is the console output?
const category = 'Ailment';
I dont know if it is the case, but If the visustella one works the same way the yanfly one does, the category property in the states themselves are forced into uppercase. if youre checking it like that, you might want to try using 'AILMENT' instead of 'Ailment', even if its 'Ailment' in your state's notebox

a spell that deals double damage to targets inflicted with 'ailment' states
but also I dont think those are the tags you want for that. iirc, those are actor/state/etc. tags, not skill ones. you could shorten all of it to something like this and put it in the skill's notebox.
Code:
<JS Pre-Damage>
if (target.states().some(state => state.categories.contains('AILMENT')))
    value *=2;
</JS Pre-Damage>
or use the damage formula box to increase the damage using the same condition

i cant test it, and i believe its 'category' in yanfly's MV plugin, but ill just assume its 'categories' in MZ
If you put

console.log(user._targetInflicted)

at the beginning of your JS Pre-Damage As User, what is the console output?
The console returned false, both without and with the target being inflicted with a state in my 'Ailment' category.

Code:
<JS Pre-Damage>
if (target.states().some(state => state.categories.contains('AILMENT')))
    value *=2;
</JS Pre-Damage>
This does just what I need! Thank you for your help.
The console returned false, both without and with the target being inflicted with a state in my 'Ailment' category.


This does just what I need! Thank you for your help.
Yeah, it's probably what Robro said then; the ailment name needed to be capitalised, and because it wasn't your condition was failing.
Robro was correct in that categories are stored as uppercase, so you will need to use uppercase if you want to search for it that way. However, there is a Game_Battler#hasStateCategory method that would not only require less typing, but would also avoid the need for you to use an uppercase string:

Code:
<JS Pre-Damage>
  if (target.hasStateCategory('Ailment'))
      value *= 2;
</JS Pre-Damage>

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-make-a-skill-detecting-ailments.164882/