MV How to Remove an ally's state if enemy takes enough damage

I was wondering if there was a way to manipulate Yanfly's State Core to make it if your allies damage the inflicter of the state with enough damage it will remove a state that one of your allies has been inflisted with.

link: http://www.yanfly.moe/wiki/Buffs_&_States_Core_(YEP)

For example Giant inflicts "Submission" on Bob so George and Jane must deal 400 or more points of damage to make the "Submission" state on Bob go away.
Off the top of my head...I would give the main target of the attack the Submission state, and give everyone else in the party a passive state. Then program it so while the passive state is on, damage dealt increments a variable. And lastly give Submission a condition of that variable being < 400.

You'd want to make clearing Submission also clear the passive state and reset the variable. And if you allowed more than one person to be inflicted with Submission, it would mess up.
Just took a quick look at the documentation for the plugin that you linked. It tracks certain events, but it looks like those events are primarily tracked for the battler affected by the state. Since you want to track a certain amount of damage dealt to the battler who inflicted the state, you might have to do something like this:
  1. Giant inflicts Submission state on Bob.
  2. Then, you add an invisible helper state to Giant.
  3. Use your helper state and the notetags in the plugin documentation to establish your damage threshold (400, or whatever).
  4. Use your helper state and notetags to track the damage dealt to Giant. You can refine your script in this section to not count any damage not dealt by George or Jane, if needed.
  5. Remove the helper state and the Submission state from Bob once the damage threshold is reached.
I'm not super-familiar with the YEP plugins, so maybe someone will have a more efficient way to tackle this!
That's a similar idea, but I'm not sure how you could track damage received by a passive state. If you put it on the other party members, you could make it a part of your damage calculations.
From the plugin documentation:
Code:
  <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.

In which case 'value' would be the damage dealt to Giant.

Unless I'm misunderstanding the question or the documentation. Like I said, I'm not an expert with these plugins. I think it'd probably be a lot easier just to hook into executeHpDamage() and run the numbers and checks there.
Oops! Good call, I forgot about that. That would definitely be simpler than putting it on the whole party and tracking it from there.
@Kenen Would I set it up like this?
Spoiler: Code
<Custom Respond Effect>

executeHpDamage(400)

</Custom Respond Effect>

Then how would I remove the state on the target?
bump
Do you have access to the Passive Auras plugin?
From the plugin documentation:
Code:
  <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.

Then how would I remove the state on the target?
Code:
<Custom Respond Effect>
$gameVariables.setValue(X, $gameVariables.value(X)+value);
if ($gameVariables.value(X)>=400)
{
  $gameVariables.setValue(X, 0);
  for (var i=0; i<$gameParty.aliveMembers().length; i++)
    $gameParty.aliveMembers()[i].removeState(Y);
  target.removeState(Z);
}
</Custom Respond Effect>

Where X is the id of a variable you're not using for anything else...Y is the ID of your Submission state...and Z is the ID of your invisible helper state the giant puts on himself when he puts Submission on a target.
Code:
<Custom Respond Effect>
$gameVariables.setValue(X, $gameVariables.value(X)+value);
if ($gameVariables.value(X)>=400)
{
  $gameVariables.setValue(X, 0);
  for (var i=0; i<$gameParty.aliveMembers().length; i++)
    $gameParty.aliveMembers()[i].removeState(Y);
  target.removeState(Z);
}
</Custom Respond Effect>

Where X is the id of a variable you're not using for anything else...Y is the ID of your Submission state...and Z is the ID of your invisible helper state the giant puts on himself when he puts Submission on a target.
I input the code into the helper state and it works like a charm. Thanks for your help.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-remove-an-allys-state-if-enemy-takes-enough-damage.134723/