MV Help with Petrified

I created a Petrified state for my game. In battle, I have the enemy inflict inflict a State, Petrified, and then I run a Common Event that checks everyone for petrified/not petrified and adjusts their graphics accordingly. for the cure, I didn't like that it would unceremoniously dumped you out of the Item menu after you ran a Common Event, so I added a Text message. It works fine, except for two little quirks:
- At least you get a text message, so it would look fairly normal to a player, but it still dumps you out of the Menu from the walking around screen.
- For someone reason, the system lets the Common Event run even if you pick someone who is not Petrified. I made a non-functional test cure that just removes the State, and the Item won't be consumed and it won't work if you pick someone ineligible. But when I run the Common Event, apparently it decides the Item use was successful.

I previously tried to make this work with YEP_BuffsStatesCore. However, the Actor Transformation trick doesn't work right with states that don't clear at battle end (the Character sprites don't change, and sometimes it messed up the Actor order and swapped faces after battle). Also State groups didn't work as I wanted to, because it would abort the battle instead of giving the party the kill if used on the bad guy. Rather than trying to patch that code, I decided to go back to eventing.

So, now I'm looking for help clearing those two little unwanted behaviors. I think a code snippet that handles the cleanup, in the Gorgon Gaze skills and the cure item, might be able to do the trick, but I'm still a novice when it comes to the code base. I also thought of a couple of Common Event solutions that might work, like trying a Switch whenever a petrification or cure is used that runs a cleanup event automatically. But I haven't come up with a way to deal with the unwanted behavior when using the cure from the menu. Open to all suggestions.
NoLongerPetrified2.pngNoLongerPetrified.jpgpetrifiedPlaytest.jpgPetrifiedCleanup.jpgPetrified.pngstonesoft.jpgGorgonGaze.jpg
the Actor Transformation trick doesn't work right with states that don't clear at battle end (the Character sprites don't change, and sometimes it messed up the Actor order and swapped faces after battle)
Also State groups didn't work as I wanted to, because it would abort the battle instead of giving the party the kill if used on the bad guy
did you test these in projects just using the buffs and states core and the states category plugins? I never ran into that issue in my main project and i tested it in a fresh project just to be sure and they both seem to work as intended. Enemies "killed" by a group defeat state dont drop anything, but the fight ends and victory is processed as if everything was killed normally.
But I haven't come up with a way to deal with the unwanted behavior when using the cure from the menu
thats how common events work. when an item has one, the menu closes and the game returns to the map because common events cannot be processed outside of the map and battle scenes.

So, now I'm looking for help clearing those two little unwanted behaviors. I think a code snippet that handles the cleanup, in the Gorgon Gaze skills and the cure item, might be able to do the trick, but I'm still a novice when it comes to the code base.
If the actor transform trick really doesnt work, then you can use yanfly skill core tags to handle the state removal and change the actor's face back. Itd be easier if your actor images followed a specific scheme, cause then you'd be able to do something like
Code:
if (target.isActor() && target.isStateAffected(30)){
  target.removeState(30);
  target.setFaceImage("Heroes", target.faceIndex());  //keep the index, but change the face sheet back to "Heroes"
  //or even
  target.setFaceImage(target.faceName().slice(0,-5), target.faceIndex());  //keep the index and use the same face name, but remove the last 5 characters so "HeroesStone" becomes "Heroes"
}
but if not, you can just write out blocks for each actor if needed
did you test these in projects just using the buffs and states core and the states category plugins?

I saved versions of those settings in case I wanted to revisit that approach. Which I don't, unless necessary. I'm guessing the problems and solutions are both probably fairly esoteric, either due to code behavior or my misconfiguring something in a way that subtly breaks the program behavior.

Now that you mention it, I'm also using BattleEngineCore and SVAnimatedEnemies. That could also be contributing, and involves yet more layers of understanding the core and plugins.

I never ran into that issue in my main project and i tested it in a fresh project just to be sure and they both seem to work as intended.

I couldn't even get the problem to appear consistently, and I decided that I wasn't excited about meticulously debugging the plugin. Could you actually get the Character sprites to change? Now that I think about it, I think both problems probably relate to the Characters not being accessible to the variables usually used in battle scenes. I suppose I could try juggling the plugin order a few dozen times...

Enemies "killed" by a group defeat state dont drop anything, but the fight ends and victory is processed as if everything was killed normally.

Sure, but that's a big bummer if I have to recreate the intended effected with the Event. The people are going to want XP from the boss fight. I can probably just make it a Text box and have it minimally visible to the player, but that's such a kludge. It fills me with coder shame.

thats how common events work. when an item has one, the menu closes and the game returns to the map because common events cannot be processed outside of the map and battle scenes.

I get that. I'm just not sure what to do about it.

If the actor transform trick really doesnt work, then you can use yanfly skill core tags to handle the state removal and change the actor's face back. Itd be easier if your actor images followed a specific scheme, cause then you'd be able to do something like
Code:
if (target.isActor() && target.isStateAffected(30)){
  target.removeState(30);
  target.setFaceImage("Heroes", target.faceIndex());  //keep the index, but change the face sheet back to "Heroes"
  //or even
  target.setFaceImage(target.faceName().slice(0,-5), target.faceIndex());  //keep the index and use the same face name, but remove the last 5 characters so "HeroesStone" becomes "Heroes"
}
but if not, you can just write out blocks for each actor if needed

Maybe I can do something like that. It's good to know I can use Skill Core to insert some code processing in there. I hadn't thought of that application. Can I just run something like this from the Code command? That sounds like the fix I was looking for. On the other hand, the Skill Core application is intriguing; if I run the code in the After Effect section, will that preserve the skill testing for a valid target?

I can still re-order the sprite sheets, I just haven't done a lot of housecleaning yet as I get closer to the prototype game. I was thinking I would do that anyway, this gives me a greater impetus. I had moved away from just numbering the images, as that had gotten confusing in other respects. However, as I have settled on the character designs, and I have schemes in place for the other image changes I was thinking of, I could work on that now.

Thank you for your help.
Now that you mention it, I'm also using BattleEngineCore and SVAnimatedEnemies. That could also be contributing, and involves yet more layers of understanding the core and plugins.
I use those in my main project as well without issue, but the main purpose of testing with the bare minimum of whats needed to get it working is to see if theres an issue with what youve done vs an issue with the required plugins or an incompatibility with an added one

Could you actually get the Character sprites to change?
Yes. While quite a bit of the code in the shared version is pointless, if it was set up correctly it should work.
I suppose I could try juggling the plugin order a few dozen times...
you shouldnt have to load yanfly plugins in any order other than the regular one on the website to get them working unless there is some specific intention there. if theyre already not in the correct order, id address that first if i were you

The people are going to want XP from the boss fight. I can probably just make it a Text box and have it minimally visible to the player, but that's such a kludge. It fills me with coder shame.
it would be a slight modification to make a game unit's dead members include battlers with group defeat states or make the functions that handle drops and exp include those battlers.

if I run the code in the After Effect section, will that preserve the skill testing for a valid target?
no. the function that determines that only looks at the skill's/item's effects by default. what you could do is put that code in a before eval and then still give the skill the effect to remove petrify. that should still work.
What does eval mean in this context? Is that just the usual Skill function? If so, wouldn't image maintenance need to come after?
put that code in a before eval
What does eval mean in this context?
a skill core notetag. <Before Eval> tags are run before the effects of the item/skill take place. so you'd be making use of the base engine's test apply system to make sure the item is "usable" on the target before use, but youd still be running the code above when it does gets used
a skill core notetag. <Before Eval> tags are run before the effects of the item/skill take place. so you'd be making use of the base engine's test apply system to make sure the item is "usable" on the target before use, but youd still be running the code above when it does gets used

I guess I'm not following. It sounds like it needs to run after. Unless eval is different than targeting success.
It sounds like it needs to run after. Unless eval is different than targeting success.
before and after eval run regardless of success. once a skill has targeted something for a hit, those tags run. the only skill core js notetags that requires a hit are <Pre/Post-Damage Eval>, and those cant run on skills without a damage formula

normally you want it after, but then you would have to remove the isStateAffected check i put in as it would now be performed after effects take place.
then youd have to make absolutely sure the item cannot ever be used on someone that isnt petrified. since the petrify clear happens before then, isStateAffected would never be true, and I think a refresh happens by then that clears the target's result().
Your cure petrify common event made it seem like its supposed to work as an aoe. if thats the case, you want to be able to make it not do anything to targets without the state depending on which approach you use. the first one should be fine regardless but wants everyone on the same sheet while the second absolutely needs the target using the stone sheet, but is what you'd use if everyone had their own sheets.
Your cure petrify common event made it seem like its supposed to work as an aoe.

No, that's not the case. It's written that way because a CE doesn't have a simple way to grab who is the target, and the tests are logically independent of each other.

Only Actor 2 has a separate sheet because I haven't made the sheets for the other actors until I was satisfied with my method.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-petrified.179502/