The default function to check for a state on a battler is:
Game_BattlerBase.prototype.isStateAffected = function(stateId)
You can use that to check for a state on any battler, such as:
target.isStateAffected(x)
$gameActors.actor(1).isStateAffected(x)
I'm not sure what you mean by "category." Is that a parameter added by a plugin you're using? Or just a mechanic you have in mind?
If it's the former, checking the state's category would depend on how the plugin handles that.
If it's the latter and you wanted to just handle it manually, you could add a notetag to your state like so:
<Category:Debuff>
And then check the if the battler both has the state and if it's a specific category:
var state = x;
if (target.isStateAffected(x) && $dataStates[x].meta.Category === 'Debuff') {
console.log('Do something.');
}
In terms of doing all of this stuff at the moment that a state is added to a battler versus at any arbitrary time, there's a function for that too.
Game_Battler.prototype.addState = function(stateId) {
if (this.isStateAddable(stateId)) {
if (!this.isStateAffected(stateId)) {
this.addNewState(stateId);
this.refresh();
}
this.resetStateCounts(stateId);
this._result.pushAddedState(stateId);
}
};
Which you can alias. Here's a quick example:
_Game_Battler_addState = Game_Battler.prototype.addState;
Game_Battler.prototype.addState = function(stateId) {
_Game_Battler_addState.call(this, stateId);
console.log('Do something.');
}
I do know that the YEP plugins will allow you to perform some of these checks via notetags, so you may want to reference that if you would prefer to do it that way.
Not sure if that answers your question, but maybe it'll get you started.