MV Yanfly Buff and States Core - State that Revives Party X Times

Hello!

Would someone be able to help me create a state using Yanflys Buffs and States Core?


What I'm hoping to create is a state that will be applied to all allies. When it's applied, a counter is set to 10. If any ally is KO'ed, they are immediately revived, and 1 charge is deducted. (Note that this counter is shared between the party members) Once the counter reaches 0, the state is removed from all party members. Likewise, the state is removed at the end of battle, and the counter resets to 0.

Would something like this be possible? Also, let me know if you have any questions.

Thank you!
It seems to me that:

<Custom Apply Effect>
code
code
</Custom Apply Effect>
"The code in between these notetags will run when the state is added onto
a battler. The code will process after the state is actually applied."

And:

<Custom Respond Effect>
code
code
</Custom Respond Effect>
"This effect will run when the battler is selected as a target. This will
occur only if the action connects and will occur after damage execution.
This effect will run after damage calculation occurs. The 'value' variable
is equal to the damage dealt to the battler. This is the first effect to
run after damage execution has taken place."

Are probably the notetags you are looking for.

For the state to affect all allies, you'd handle that with the scope of the skill that applies the state.
You can also handle the after battle removal from the editor, by checking the "Remove at Battle End" box.

In the custom apply effect, you could assign a game variable the value of 10:
Spoiler
<Custom Apply Effect>
$gameVariables.setValue(1, 10);
</Custom Apply Effect>

For the revival of an actor that is killed, try something like this:
Spoiler
<Custom Respond Effect>
if (user.isStateAffected(stateId) && value >= user.hp) {
user.gainHp(user.mhp * .25);
$gameVariables.setValue(1, $gameVariables.value(1) - 1);
user.removeState(stateId)
}
</Custom Respond Effect>
For the revival of an actor that is killed, try something like this:
Spoiler
<Custom Respond Effect>
if (user.isStateAffected(stateId) && value >= user.hp) {
user.gainHp(user.mhp * .25);
$gameVariables.setValue(1, $gameVariables.value(1) - 1);
user.removeState(stateId)
}
</Custom Respond Effect>
would need to change that 'user.removeState' to //if variable = 0 remove state all actors// since its not removed asap and its a party wide effect/counter
would need to change that 'user.removeState' to //if variable = 0 remove state all actors// since its not removed asap and its a party wide effect/counter
Thank you for bringing that up. I knew it would need more, I just wanted to get my thoughts down before I fell asleep last night.

Theres also the matter of resetting the variable back to zero after battle.

There's a couple ways I see this. One would be by making the remove condition happen at 1 step on the map.

There are a few other custom timing notetags that run; on a victory, on a defeat and upon an escape from battle. But, if you set the state to remove on battle end, these 3 notetags won't be executed, which is why I think setting it to removal upon 1 map step would work.

Another way would be to utilize another yanfly plugin called "utility common events" that will allow you to run common events based on two of the 3 instances, escape battle, and battle victory.
For the revival of an actor that is killed, try something like this:
Code:
<Custom Respond Effect>
if (user.isStateAffected(stateId) && value >= user.hp) {
  user.gainHp(user.mhp * .25);
  $gameVariables.setValue(1, $gameVariables.value(1) - 1);
user.removeState(stateId)
}
  </Custom Respond Effect>
I'm a little stuck on what you're trying to do here. What's that first isStateAffected for? There's no way the code would be looking at this notetag unless the actor had the state, so there's zero reason to make sure they have it.

Also, because you're making this a Respond, not a React, it's happening after damage is done. That means we don't care whether value >= user.hp, we care about whether the actor is already dead.

The second part also doesn't look quite right, as the OP asked for the state to be taken off all actors when the shared charges are gone, not off each actor as it's used.

So I propose using Yanfly's existing Auto-Life, which already does almost all of what was asked for, it just needs the addition of the global tracker. Using a variable would work, but I suggest using a state counter so that the player can see how many charges are left:
Code:
<Custom Apply Effect>
target.setStateCounter(stateId, 10);
</Custom Apply Effect>

<Custom Deselect Effect>
// Check if the target's HP is 0 or is currently in the death state.
if (target.hp <= 0 || target.isDead())
{
  // Play the auto-life animation on target.
  target.startAnimation(49);
  // Heal the target for 10% life
  target.gainHp(Math.floor(target.mhp * 0.1));
  // Make the damage popup show for the heal.
  target.startDamagePopup();
  // Clear the target's results.
  target.clearResult();
 // Decrement the state counter for the party
  $gameParty.aliveMembers().forEach(member => member.addStateCounter(stateId, -1));
  // If the counter is at 0, strip the state from the party
  if (target.getStateCounter(stateId)==0)
    $gameParty.aliveMembers().forEach(member => member.removeState(stateId));
}
</Custom Deselect Effect>
In both notetags, change all instances of stateId to...the state ID. And if you want to change how much the target gets healed for on its resurrection, change the animation, remove the animation, edit the appropriate lines.
Theres also the matter of resetting the variable back to zero after battle.
There would be no need to. Presuming the state is set to go away when battle ends, we don't care what that variable is at any other time - and every time you cast it in battle, you'd be re-initializing it to 10, again not caring what it already was.

But I suggest using the counters, instead.
Thank you very much everyone!

I've currently got the state posted by @ATT_Turan set up, and it sees to be working excellently!
@ATT_Turan I figured it would need some work but I was just trying to get things started for the op.

Thank you for correcting me.
Thank you for correcting me.
Now you make me feel like a school marm 🤣
Now you make me feel like a school marm 🤣
Its not like that, I swear!

I just really appreciate learning and I don't take offense to being corrected or called out.

To be honest, I was about 15 away from falling asleep when I posted my attempt. And I know I still have a lot to learn, so I'm grateful.
Heh, I still have times when I post rubbish and need to get corrected, too.
Heh, I still have times when I post rubbish and need to get corrected, too.
I don't mind being reminded that I have a lot to learn.
Honestly, I've come a long way from my early rpg maker days. The forums have been a wealth on knowledge and learning for me, so I always try to give back to that when I can.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-buff-and-states-core-state-that-revives-party-x-times.142115/