MV [YEP_BuffStatesCore] can i use BuffStatesCore to change actor's faces if they get hit during battle?

Hello, this is more of a doubt than a request, if its not possible to do this then its no issue since what i have already is good as is.

ouch-ezgif.com-resize.gif

you see i have a lunatic code in the notetags of the KO/Dead status effect that actually changes the face sprites to a KO'd one if the actors have it applied, i was wondering if the same would be possible to apply if they just get hit.

1712759890079.png


this is what it looks applied on the state's notetag
Spoiler: Notetag code
<Custom Apply Effect>
if (target.isActor()) {
if (target.actorId() === 1) {
target.setFaceImage('partyko', 0);
} else if (target.actorId() === 2) {
target.setFaceImage('partyko', 1);
} else if (target.actorId() === 3) {
target.setFaceImage('partyko', 2);
} else if (target.actorId() === 4) {
target.setFaceImage('partyko', 3);
} else if (target.actorId() === 5) {
target.setFaceImage('partyko', 5);
} else if (target.actorId() === 6) {
target.setFaceImage('partyko', 6);
} else if (target.actorId() === 7) {
target.setFaceImage('partyko', 4);
} else if (target.actorId() === 8) {
target.setFaceImage('partyko', 7);
}
}
</Custom Apply Effect>

<Custom Remove Effect>
if (target.isActor()) {
if (target.actorId() === 1) {
target.setFaceImage('party', 0);
} else if (target.actorId() === 2) {
target.setFaceImage('party', 1);
} else if (target.actorId() === 3) {
target.setFaceImage('party', 2);
} else if (target.actorId() === 4) {
target.setFaceImage('party', 3);
} else if (target.actorId() === 5) {
target.setFaceImage('party', 5);
} else if (target.actorId() === 6) {
target.setFaceImage('party', 6);
} else if (target.actorId() === 7) {
target.setFaceImage('party', 4);
} else if (target.actorId() === 8) {
target.setFaceImage('party', 7);
}

Then I found this code on the info of the plugin and thought this could be it for having a portrait change for a second after a hit and tried to apply it but havent been successful so far

1712759642129.png


it specifices its a STATUS notetag, so i tried to apply it first with the KO state wich didnt work, then i tried to have an invisible state that gets applied to all allies at the start of battle, wich also didnt work, out of curiosity i tried applying it in other notetags (actor, class, skills), of course didnt work but didnt hurt to try.

(sidenote: i also tried to do a custom victory effect apply but it also didnt work)

1712760261553.png


im pretty much asking because i've got feedback on making it more clear wether one of your party is being hit, (another feedback i got was it if its possible to make them animated, that one i actually think its a bit too tall of an order) so i was curious wether if its actually possible to do so, but in the end its not big deal if not, im already content with just the KO state being visible.

Thank you and sorry if its a tad lenghty of a post.
Then I found this code on the info of the plugin and thought this could be it for having a portrait change for a second after a hit and tried to apply it but havent been successful so far
You can use the respond effect tag to set the new face image, but i think you'd need to go another route to set the face back to what it was before. My first thought was to use a deselect effect to revert it to the old one after damage, but as i was writing out the tags for it i realized that time the change happens wouldnt be long enough for the change to be noticeable.

Spoiler: Initial state tags
Code:
<Custom Respond Effect>
if (this.isDamage()){
  target._baseFace = [target._faceName, target._faceIndex];
  target.setFaceImage("partyhurt", target.actorId()-1);
}
</Custom Respond Effect>

<Custom Deselect Effect>
if (target._baseFace){
  target.setFaceImage(target._baseFace[0], target._baseFace[1]);
  delete target._baseFace;
}
</Custom Deselect Effect>

If you just wanted the change to happen, then remove the deselect portion. but if you want the face to change back after the attack is complete, youll need some other method. Using another plugin to do it will be easier than the workaround i have in mind with yanfly's buffs & states.
It would help if you showed the notetags/code you were trying for this - the short answer is yes, this can be done.



I thought one part of MogHunter's battle HUD did this automatically, but I'm not going to look through all of his stuff to check for you.

You may find it useful to split your actor images into separate files with consistent naming structures so you can use basic JavaScript string stuff instead of long, convoluted if/else essays 😉

For example, your actor's name and then append hit to it: Harold and Harold_hit. Then you can reference target.name() or target.name()+"_hit" for the filenames.
You can use the respond effect tag to set the new face image, but i think you'd need to go another route to set the face back to what it was before. My first thought was to use a deselect effect to revert it to the old one after damage, but as i was writing out the tags for it i realized that time the change happens wouldnt be long enough for the change to be noticeable.

Spoiler: Initial state tags
Code:
<Custom Respond Effect>
if (this.isDamage()){
  target._baseFace = [target._faceName, target._faceIndex];
  target.setFaceImage("partyhurt", target.actorId()-1);
}
</Custom Respond Effect>

<Custom Deselect Effect>
if (target._baseFace){
  target.setFaceImage(target._baseFace[0], target._baseFace[1]);
  delete target._baseFace;
}
</Custom Deselect Effect>

If you just wanted the change to happen, then remove the deselect portion. but if you want the face to change back after the attack is complete, youll need some other method. Using another plugin to do it will be easier than the workaround i have in mind with yanfly's buffs & states.
so far this works by making all enemy attacks apply the invisible state, and that works to change the picture but not change it back, ill see if i can fiddle with Custom Deselect Effect so its noticable, if not ill try to find another plugin like you said, thank you.

It would help if you showed the notetags/code you were trying for this - the short answer is yes, this can be done.



I thought one part of MogHunter's battle HUD did this automatically, but I'm not going to look through all of his stuff to check for you.

You may find it useful to split your actor images into separate files with consistent naming structures so you can use basic JavaScript string stuff instead of long, convoluted if/else essays 😉

For example, your actor's name and then append hit to it: Harold and Harold_hit. Then you can reference target.name() or target.name()+"_hit" for the filenames.
alright, glad to know its possible, unfortunately Moghunter is out of the question because im using SRD's custom hud plugging (and it took a lot to set up to where it is).

here's the current code in the notetag of the invisible state.
Spoiler: State notetag code
<Custom Respond Effect>

if (target.isActor()) {

if (target.actorId() === 1) {

target.setFaceImage('partyhit', 0); }

else if (target.actorId() === 1) {

target.setFaceImage('party', 0);

}

</Custom Respond Effect>

so far havent done anything else to it, but the change does apply when enemy attacks apply the status effect but it doesnt change back.

also thank you, ill take into account the simplifying of the script, im not very good at coding at all so its way over my head on what can be done to make it easier.
Hey,
I am *way more* of a scripting noob in comparison to you, however... (with a bag of salt for your consideration) this *might* be a work around.
I have not physically tested this... but in concept this *seems* like a potential way to crudely brute force what you are looking to achieve. Again, someone with actual experience probably could list why this route is unfeasible. It's worth pondering though...

do the 'state' for all hits.. you have a common event that is called (with contitional branching specifying your player actors) - this changes the graphic to the 'hit' version...
have your state set up so that when it expires, it automatically applies an additional state (let's call this 'normal')

when normal is inflicted, target gets another common event that changes the graphic (again with conditional branching for selection of which actor is being affected) back to their 'normal' graphic.

honestly, best of luck. I do hope you find a viable solution to your quandary.
-LG

Original thread: https://forums.rpgmakerweb.com/threads/yep_buffstatescore-can-i-use-buffstatescore-to-change-actors-faces-if-they-get-hit-during-battle.167631/