Yanfly's plugins - creating a protection state

Hey everyone !

I have created a spear class, that is focused on defense. That's done, but I have one request about skills :

How would I create a skill that makes the user take the hits of all his companions ?

Thank you for reading this ! If you have an advice or know some lunatic code that has already been done, just tell me ! Thank you !
The Taunt plugin cover single-target effects, while the Single-Target Provoke Tips & Tricks gives some lunatic code for forcing attacks to target just one character.

My instinct would be to try applying the Provoke state to all enemies.
I will do that : thank you for the help !
I did create a similar skill named "Guardian Angel" which redirects 50% of all damage taken from all allies to the caster with this state applying on allies:
Code:
<Custom React Effect>
if (origin.isAlive() && origin !== target){
var dmg = Math.floor(value * 0.5);
value = Math.floor(value * 0.5);
origin.gainHp(-dmg);
</Custom React Effect>

If you want your caster take 100% of all incoming damage for your allies, just change:
Code:
var dmg = value;
value = 0;

However, remember to use Yanfly's Target Core plugin and use this note tag for your skill to prevent the state from applying on the caster himself:
<Target: All Allies But User>
Thank you @JamesRyan , it's exactly what I needed 🙂
Just one question though : could you add one line, to show an animation on the caster when the state effects ? Because as it is now, the ally takes no damage and a popup appears saying "0", but it's hard to see if the caster did take the damage.
Making a second damage popup appear for the caster would be perfect, but I'm not sure if that is possible to do with lunatic code.
For damage popup, i think you can use "origin.startDamagePopup();" and for animation, you can use "origin.startAnimation(x)" where x is the animation ID you want to display. Like this:
Code:
<Custom React Effect>
if (origin.isAlive() && origin !== target){
var dmg = value;
value = 0;
origin.gainHp(-dmg);
origin.startDamagePopup();
origin.startAnimation(x);
</Custom React Effect>
It works very well ! I have omitted the start animation because it made too many informations at a time on the screen, but the popup appears perfectly and helps the player to understand what is happening.
Thank you very much @JamesRyan !
It works very well ! I have omitted the start animation because it made too many informations at a time on the screen, but the popup appears perfectly and helps the player to understand what is happening.
Thank you very much @JamesRyan !
It works very well ! I have omitted the start animation because it made too many informations at a time on the screen, but the popup appears perfectly and helps the player to understand what is happening.
Thank you very much @JamesRyan !


EDIT : Woaww sorry for the three posts, I didn't want this : my internet is the worst right now :/

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-plugins-creating-a-protection-state.80132/