Skill that only appears/is usable when an ally faints

Hey y’all!

Right now I’m trying make a character who gets a skill when an ally falls that lets them gain health and massive buffs. I have access to most if not all YEP plug-ins, and I’ve been trying to use those to find a solution to only letting it be usable when an ally falls. No luck thus far. It’s also worth mentioning that I want the skill to only be usable 3 times (once per party member fallen in a party of 4)

Any ideas how to go about coding or setting up something like this? I’m a mega-beginner at Js, but am willing to learn!
Welcome!

What you need is right in the Yanfly Skill Core, there are a number of notetags for hiding/showing skills.

Give the skill the following notetag:
Code:
<Custom Show Eval>
visible = $gameParty.deadMembers().length>0;
</Custom Show Eval>

I want the skill to only be usable 3 times (once per party member fallen in a party of 4)
Those are two different things - you can use Yanfly's Limited Skill Use if you only want it usable 3 times. But if you want it specifically only usable once per other party member, that's a bit more complicated.

Please clarify.
If you are using YEP_SkillCore, you could use the <Custom Reqiurement> notetag to specify when the skill would be usable. Could also use <Custom Show Eval> if you want the skill to not appear unless the conditions are met.

You'll also need a way to check if the skill has been used for the party member. For that, I would recommend using YEP_BuffsStatesCore and YEP_X_StateCategories to have your skill apply an invisible state on the dead member with the notetag <Category: Bypass Death Removal>. With this, you can check if the dead ally has the state; if they have the state, it means you've already used the skill and should not be allowed to use it again. Remove it to reset the uses, for example by having it expire on battle end (so it works once per battle).

As for the actual code, it would be something like

JavaScript:
<Custom Requirement>
value = $gameParty.deadMembers().length > 0 && $gameParty.deadMembers().some(member => !member.isStateAffected(n));
</Custom Requirement>

Where n is the ID of the state created.
As for the actual code, it would be something like
Just as a quick note, this will be true so long as there are any dead party members who have not been revived.

If Harold has died and you revived him previously, and now Harold and Therese are both dead, some() will return true (because Therese doesn't have the state) but you'll be allowed to target either of them.

So if the OP is looking specifically for limiting the skill per actor per battle, you'd have to use Yanfly's Selection Control in conjunction with either a state as you suggest, or just placing a variable on the affected actor to make them not be selectable again that battle.
If you are using YEP_SkillCore, you could use the <Custom Reqiurement> notetag to specify when the skill would be usable. Could also use <Custom Show Eval> if you want the skill to not appear unless the conditions are met.

You'll also need a way to check if the skill has been used for the party member. For that, I would recommend using YEP_BuffsStatesCore and YEP_X_StateCategories to have your skill apply an invisible state on the dead member with the notetag <Category: Bypass Death Removal>. With this, you can check if the dead ally has the state; if they have the state, it means you've already used the skill and should not be allowed to use it again. Remove it to reset the uses, for example by having it expire on battle end (so it works once per battle).

As for the actual code, it would be something like

JavaScript:
<Custom Requirement>
value = $gameParty.deadMembers().length > 0 && $gameParty.deadMembers().some(member => !member.isStateAffected(n));
</Custom Requirement>

Where n is the ID of the state created.
I'm dealing with something similar; the ability requires any ally to be dead (max of one per dead ally, etc.) and the solution seems to be working until giving an ally the state in which they can't be "used again."

I think the problem is that my skill is self-targeted, letting the user gain health and buffs, but the state needs to be applied to allies. Is there any way I can keep the ability self-targeted and apply states to allies / make the ability target and apply states to dead allies but applies health gain and buffs to the user?
Hey @Flop Welcome to the forums! Just a gentle note that changing the focus on support threads from the OP to your support questions is discouraged. Nonetheless, I’m certain these wonderful people can help out.
I'm dealing with something similar; the ability requires any ally to be dead (max of one per dead ally, etc.) and the solution seems to be working until giving an ally the state in which they can't be "used again."

I think the problem is that my skill is self-targeted, letting the user gain health and buffs, but the state needs to be applied to allies. Is there any way I can keep the ability self-targeted and apply states to allies / make the ability target and apply states to dead allies but applies health gain and buffs to the user?
You can still apply the state to allies while targeting yourself by using the <Custom Execution> notetag.

JavaScript:
<Custom Execution>
if($gameParty.deadMembers().filter(member => !member.isStateAffected(n)).length > 0)
{
  $gameParty.deadMembers().filter(member => !member.isStateAffected(n))[0].addState(n);
}
<Custom Execution>

Original thread: https://forums.rpgmakerweb.com/threads/skill-that-only-appears-is-usable-when-an-ally-faints.162072/