Hey,
I've not worked with Yanflys passive states so far, so there may be better options without the downsides, but two ways to do number 2 (and potentially 3):
Code:
<custom confirm effect>
// If the target has more than 0 states and...
// ...the action is able to produce critical hits and...
// ...the action is not already a critical hit...
if (target.states().length > 0 &&
this.item().damage.critical &&
!target.result().critical) {
// ...flag the result as a critical hit
// ...modify the damage value:
target.result().critical = true;
value = Math.round(this.applyCritical(value));
}
</custom confirm effect>
This should guarantee a critical hit against targets affected by any state.
For alternatives replace
target.states().length > 0 with...
target.isStateAffected(17) to check for a specific state (#17 in this case),
target.states().some(s => s.iconIndex > 0) to check for any state not invisible,
target.states().some(s => s.meta["valid state"]) to check for any state with a
<valid state> tag in its notebox.
The downside of this variant would be that the critical effect is only added later, so if you have other effects that check if the attack is a critical hit, make sure that they are checked after (have a lower state priority).
An alternative could be to give the attacker a state (#17 in this case) for this attack only in order to buff their critical hit chance:
Code:
<custom initiate effect>
if (target.states.length() > 0) {
user.result().clear();
user.addState(17);
}
</custom initiate effect>
<custom conclude effect>
user.removeState(17);
</custom conclude effect>
The conclude effect is only triggered if the attacker still has the passive state when the attack ends (i.e. has not died or lost the passive through some other effects)
Edit:
I forgot about the other cases, but number 4 could look like this:
Code:
<custom conclude effect>
if (target.result().addedStates.length > 0) {
let group = user.friendsUnit().members();
group.forEach(m => m.addState(16));
}
</custom conclude effect>
Haven't tested this at all, but similarly you can replace the condition with
target.result().addedStates.includes(17) ...to check for a specific added state
target.result().addedStatesObjects().some(s => s.iconIndex > 0)
target.result().addedStatesObjects().some(s => s.meta["valid state"]) ...to check for visibility or a custom note tag.
Edit: Misremembered a function name