Plugin in question:
http://yanfly.moe/2016/04/03/yep-89-state-categories/
Hello everyone.
I'm trying to add to my game some skills and items that add a state from the State Category 'Elemental'. And other skills from the category 'Stance'. And I am trying to make it so, when one of these states is applied, any state from the same category is removed.
But... They either remove the added state, or don't remove any at all...
Basically, this:
But the solution on that topic doesn't want to work for me...
I didn't want to revive a months-old topic, so hope no one minds me redoing it.
[EDIT]
I'm an impatient person, so I created my own way of doing it.
I made this code to do it:
<Custom Apply Effect>
if (target.getStateCategoryAffectedCount('Elemental') > 1)
{
target.removeStateCategoryAll('Elemental');
rsid = target._result.removedStates.indexOf(state.id);
target._result.removedStates.splice(rsid, 1);
target.addState(state.id);
}
</Custom Apply Effect>
Basically, I noticed that the effects did not happen, but the state WAS added before the Custom Apply Effects started working. So I made it only remove the effects if there were
two effects there already... and then added the state again.
It did not want to add again, though.
Then I found out, after
lots of search, that the core plugin checks if the new added state was just removed and if it was... doesn't add again. So I had to find the state's index in the removed states array to remove it from there, and
only then I was able to add it again.
It may not be the proper, maybe not even an elegant solution, but at least it works.