Looking for a script to replace the condition below.
condition= user.friendsUnit().aliveMembers().length > 1
I tried
condition= user.friendsUnit().areStateAffected(2).length > 1 but it says undefined is not a function
it doesn't work that way.
"alive members" does not check for a state, it is an array that actors are sorted into when they get the state.
You'll need to do something similiar to that sorting.
you need a function that checks all actors if a specific actor has the state, and a variable that is counted up if it does.
Then at the end you can check the variable for its number.
Would something like this work?
var members = target.friendsUnit().aliveMembers();
var affected = [];
for (var i = 0; i < members.length; ++i) {
var member = members;
if (member && member.isStateAffected(206)) {
affected.push(member);
}
Where would I put it to change the state condition?
Thanks for your help. So the new passive condition would be: condition= count>0 ? Would I put this code in a new plugin or In a note tag?
I don't know, I was just answering your question "Script to check if a certain number of allies have a state".
I don't know if you're writing your own plugin, if you're using someone else's plugin, if this is an event command, if this is a notetag... If you're using a plugin, you didn't mention it or provide a link to it, so I really can't say.
But if you understand the code, then you'll understand that at the end, the variable "count" will have a value of how many members have the state. You can do whatever you want with that value afterwards.
No problem! The documentation for custom passive is in the autopassive state but I decided to change the effect until I find a solution.
😀I tried it before I see the solution and came back to thank you. It works perfectly. Thanks for the help and teaching me something new!