MV Yanfly Snatch/Steal check on state?

I know that i can use both <Custom Steal Success Effect> on skills and <After Steal Effect> on items/gear to activate effects when an item is stolen, but is it possible to put a check for whether or not the current skill successfully steals an item on a state?
I'm trying to add accessories that grant a state to the user that adds special effects to successful steals whenever performed, but it would be much more convenient if i could have it be an effect of each of the states themselves instead of making every stealing skill check for each of these states and perform accordingly.

i've tried this, but theft seems to take place before initiate effects as target._stealSet has the stolen items already logged
Code:
<Custom initiate Effect>
if (this.isSnatchAction()){
  target._stealSet = target._stealableItems;
  console.log(target._stealSet);
}
</Custom Initiate Effect>

<Custom Conclude Effect>
if (this.isSnatchAction()){
  if (target._stealSet != target._stealableItems){
    console.log("Item Stolen");
    user.gainHp(500);
    user.startDamagepopup();
  }
  else console.log("Theft Unsuccessful");
}
console.log(target._stealableItems);
delete target._stealSet;
</Custom Conclude Effect>

any decent way to go about this, or would i have better luck having each of the stealing skills check for each steal effect state?
I'm trying to add accessories that grant a state to the user that adds special effects to successful steals whenever performed...theft seems to take place before initiate effects as target._stealSet has the stolen items already logged
Can you give an example of what a "special effect" should be? It's not immediately apparent why it matters exactly when in the skill phases this check happens.

Looking at the code, however, you don't seem to be correct. Stealing is called in Game_Action.applyItemUserEffect(), which is the last thing that happens inside of Game_Action.apply().

Conversely, in Buffs & States Core, Initiate effects are called from Game_Action.onApplyStateEffects(), which is called (followed by Select effects) two lines before Game_Action.apply().

Maybe I don't understand what you mean...your Initiate Effect is just printing the entire list of things that can be stolen from that enemy. Are you saying the stealSet != stealableItems conditional in the Conclude Effect isn't triggering? Are you sure you have set the option to remove stolen items from the enemy's list?
Can you give an example of what a "special effect" should be? It's not immediately apparent why it matters exactly when in the skill phases this check happens.
Yeah, i was a little vague about it. The one i shared, as an example of one was supposed to heal the user for 500 hp on each successful steal. Just to test the waters to see if it worked and to continue on from there, like giving the thief buffs, states, etc off of successful steals, but only if they have the equipment on to add the additional steal effects on.

I went to check the skill phases first because i couldnt readily see a way to have the state check if a theft had taken place in the help docs. My first thought was writing a snapshot of all the stealableItems an enemy had at the start of a skill and then to refer back to it at the end of the skill. that way, id be able to test for the theft by seeing if any of the objects in ._stealableItems had changed since isStolen would have changed to true
Maybe I don't understand what you mean...your Initiate Effect is just printing the entire list of things that can be stolen from that enemy.
The print statements were for me to track what was happening. they can be ignored. I usually remove them when putting them here but i left them this time.

Are you saying the stealSet != stealableItems conditional in the Conclude Effect isn't triggering?
Yes. By the time its ran, both of those are equal and the rest isnt ran. which isnt intended, but i couldnt see why it was the case.

With how the skill phases were described, i had thought that theft would have taken place sometime after initiate and before conclude, so in initiate i had it set the stealSet property to later be read by conclude to determine if a theft had happened. But after checking the arrays in the console, theyre both the same. I figured i was incorrect in when the theft actually happens, but i had assumed then that it was before initiate since the value written during initiate already had the stolen item marked as stolen
1693769794671.png

the first one was a manual check at the start of the battle. the other 2 were from the state.

Are you sure you have set the option to remove stolen items from the enemy's list?

I was under the impression that the plugin parameters for removal were to remove them from the drop pool. enabling it even now doesnt remove items from the steal list when stolen, unless im misunderstanding something.
Looking at the function for it, it doesn't remove the items from the list. It sets a stolen flag on them.

So you can do in your Initiate effect something like
Code:
target._notStolen = target.stealableItems().filter(obj => !obj.isStolen);

Then check it again in the Conclude:
Code:
target._notStolen == target.stealableItems().filter(obj => !obj.isStolen);
Thanks for the help! i was able to come to this and it seems to work
JavaScript:
<Custom initiate Effect>
if (this.isSnatchAction()){
target._preSteal = target._stealableItems.filter(item => !item.isStolen);
}
</Custom Initiate Effect>

<Custom Conclude Effect>
if (this.isSnatchAction()){
  target._postSteal = target._stealableItems.filter(item => !item.isStolen);
  if (target._preSteal.length != target._postSteal.length){
    user.gainHp(500);
    user.startDamagePopup();
  }
}
delete target._preSteal;
delete target._postSteal;
</Custom Conclude Effect>
Strangely enough, the comparison between the 2 arrays always returned true regardless of whether or not the steal was successful and if the arrays were different or the same. it wasnt until after i chose to compare the lengths that it started working as intended
Apparently that's a foible of arrays in JavaScript. I'd never run into it before.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-snatch-steal-check-on-state.160878/