MV Yanfly's Stockpile Made into Passive State

Something I've been wondering about is if I could use Yanfly's Stockpile code as a passive state that builds stacks as the character takes damage.

The inspiration comes from the Devil May Cry series where Dante does something similar with his Royal Guard style. In DMC you use Dante's guarding skill and it'll fill a meter if he takes damage. When the meter fills up you can then use an unleash skill that damages surrounding enemies based on how much energy was stored up.

I want to do something similar to this, either adding a stack as the character takes damage or adding a stack if attacked while in the guard state. Preferably just taking damage in general but the option of requiring using the guard command first then taking damage would be nice as well. Could someone help me out with this?
Preferably just taking damage in general but the option of requiring using the guard command first then taking damage would be nice as well
Code:
<Custom React Effect>
if (this.isDamage() && target.isStateAffected(2))
  target._stock = (target._stock + 1) || 1;
</Custom React Effect>
assuming state 2 is your guard state, thatll only add to stockpile if youre guarding while taking hits. remove "&& target.isStateAffected(2)" if you want it to just be taking damage in general.
Thank you so much! I'm gonna be using Victor's Materia plugin. I assume I can place this notetag in the materia's notebox above all the stuff for skills and it'll work? After I organize all the skills I'll be using I'll test this theory.
I havent used Victor's materia system, but id assume you could use the plugin's function to tie a state to the materia and then have that state contain the notetag above. I wouldnt imagine putting it in an item notebox would do anything at all
I did some looking into the materia system and it's rather complex with all its settings. It stated that only armors can be marked as materia, but I didn't see where a materia could add a state. Hopefully I'll be able to add Yanfly's Passive States notetags to the materia and have it work. When I progress a little on it I'll test it out.
this is what i was referring to by "the plugin's function to tie a state to the materia". I havent used the plugin at all, but it sounded like it could work grom a glance.
1714169010133.png

1714169024866.png
I did see that but it's in reference to the added effect. I could try it but I think it only takes effect if a support materia is linked with it and not actually create a passive state.

I just did a search on Victor's page and it showed I can add the passive state to the first skill on the materia and it should add the passive. So I can put the passive notetag on the first skill that materia adds and the character can take advantage of the automatic charge building then use the release skill. A little bit of a work around but still accomplishes the same goal.

Well, I was gonna upload a pic of Victor's response but I'm not able to. I'll link the page instead.
https://victorenginescripts.wordpress.com/rpg-maker-mv/materia-system/#comment-1427
So I can put the passive notetag on the first skill that materia adds and the character can take advantage of the automatic charge building then use the release skill. A little bit of a work around but still accomplishes the same goal.
Try it, and if it works it works. However IIRC, if youre using skills to grant passives, yanfly's passives only activate on actors when the skill the state is bound to is "learned". gaining access to them from any other means doesnt usually grant the state. what i suspect what Victor meant by passive in that case was making use of his own passive plugin, but i cant say for certain.

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-stockpile-made-into-passive-state.167318/