Faceset Changes with State

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
299
Reaction score
89
First Language
Enlish
Hello,

I'm looking to have a script made that changes the actor's face sprite when they are inflicted with a certain state.

Description: Beyond the various state markers and icons, I would like my characters to visually react to having different states put on them in the game. There's two ways that I think this could be accomplished:

First, would be to simply change their face graphic when a state is inflicted on them. So if the actor was inflicted with "rage", maybe a note tag or parameter would say: use this face graphic in file x slot X when this state is inflicted. So in battle, their face would change from a normal face to an angry face.

Second, would be to apply some sort of color tint to the characters face. So for instance, if the actor was inflicted with "poison", their face graphic would have some sort of green filter above it.

both would be ideal, but honestly, either method would work. I'm not picky ^^:hswt:

Necessary Compatibility:
The only major compatibility I can see being necessary is with the Yanfly Battle Core and Yanfly core engine. I guess Yanfly Battle Status window and it's extensions to be useful as well. I could see many people using these in conjunction.

EDIT: This will also need to work with SRD's HUD Maker in Battle

Thank you for taking the time to read this request!
 
Last edited:

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
If you have Yanfly's Buffs and States core, you can do this easily, though it would take quite a bit of work.

On each state you want the face graphic to change, use the following Lunatic Mode Notetag Structure:

<Custom Apply Effect>

if (target.isActor()) {

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

target.setFaceImage('filename', index);

} else if (target.actorId() === 2) {

target.setFaceImage('filename', index);

} else if (target.actorId() === 3) {

target.setFaceImage('filename', index);

}

}

</Custom Apply Effect>

Repeat the chain for as many actors as your game has.

This custom apply effect will change your actor's face to the face specified by the filename and the index.

Example: target.setFaceImage('Actor1', 0);

This will set the face image to Harold's picture.

Yes, you will have to specify the exact face for each actor for each state (I'm pretty sure there's no other way of doing it, no matter what plugin one makes).


To return the face back to the original once the state is removed:

<Custom Remove Effect>

if (target.isActor()) {

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

target.setFaceImage('filename', index);

} else if (target.actorId() === 2) {

target.setFaceImage('filename', index);

} else if (target.actorId() === 3) {

target.setFaceImage('filename', index);

}

}

</Custom Remove Effect>

Repeat the chain for as many actors as your game has.
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
299
Reaction score
89
First Language
Enlish
Wow, Didn't expect to get a response so quickly!

That seems simple enough (and it makes a lot of sense).

I'm running into a problem so far though, it works well outside of battle, but inside of battle the face sets don't seem to update.

I'll do a little more testing, but it may because of SRD's HUD Maker that I used to make my custom HUD. (should have mentioned that in the initial post, but I didn't think that would effect this.

EDIT: So the Change works with a custom HUD outside of battle, but not inside battle. Would I need some sort of code to refresh the battle faces?
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
Weird, it's working perfectly on my one.

Could you post the lunatic code you put in the notebox? Maybe you missed like a bracket or semicolon or something (happens to me a lot :rswt)

Also, a screenshot of the state itself could help as well.
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
299
Reaction score
89
First Language
Enlish
Here's the code, I'm using in the notetag box. I tested it again, and it does work on the custom HUD I made using SRD's HUD Maker, but not on the custom Battle HUD using the same tool.

So I'm inclined to think it's work, but for some reason not on the battle screen.

<Custom Apply Effect>



if (target.isActor()) {



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



target.setFaceImage('Actor1', 0);



} else if (target.actorId() === 2) {



target.setFaceImage('filename', index);



} else if (target.actorId() === 3) {



target.setFaceImage('filename', index);



}



}



</Custom Apply Effect>



<Custom Remove Effect>



if (target.isActor()) {



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



target.setFaceImage('Actor1', 1);



} else if (target.actorId() === 2) {



target.setFaceImage('filename', index);



} else if (target.actorId() === 3) {



target.setFaceImage('filename', index);



}



}



</Custom Remove Effect>

I've attached a pic of the state I used it on. Just a basic poison state.

EDIT: just tried it in a fresh project with only Yanfly's plugins and it worked. Now I"m guessing there's something about SRD's HUD maker that's preventing the facesets from updating (but only in battle)? (I should add the HUD maker compatibility to the original post)
 

Attachments

JGreene

Veteran
Veteran
Joined
Oct 24, 2015
Messages
395
Reaction score
297
First Language
English
Primarily Uses
RMMV
If you've updated to version 1.5 of MV then just be aware that some plugins (especially those dealing with images) are experiencing compatibility issues and need to be updated by the authors.
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
Its not MV 1.5, I didn't update yet and I tested it out, SRD's Hud Maker indeed just isn't updating. But it's not just in battle though.

I did notice though that the face index updated, but the face name didn't. So I think it has something to do with how the HUD Maker updates its face image. It works on the map because the state is applied during Scene_Battle, so the face is newly initialized upon entering Scene_Map. You'll see that if you enter a new battle with the state still active, the face will update.

I looked through the plugin file and found that doing the following solved the issue. However, I did not extensively test it, so it might cause issues elsewhere (though I didn't really get any).

Open the SRD_HUDMaker.js file in an able text editor and look for line 3789. You should find this function:

Code:
Sprite_HUDFace.prototype.drawFace = function(faceIndex, width, height) {
    width = width || Window_Base._faceWidth;
    height = height || Window_Base._faceHeight;
    var pw = Window_Base._faceWidth;
    var ph = Window_Base._faceHeight;
    var sx = faceIndex % 4 * pw + (pw - pw) / 2;
    var sy = Math.floor(faceIndex / 4) * ph + (ph - ph) / 2;
    this.bitmap.blt(this._oBitmap, sx, sy, pw, ph, 0, 0, width, height);
};
Replace this entire function with this:

Code:
Sprite_HUDFace.prototype.drawFace = function(faceIndex, width, height) {
    width = width || Window_Base._faceWidth;
    height = height || Window_Base._faceHeight;
    var pw = Window_Base._faceWidth;
    var ph = Window_Base._faceHeight;
    var sx = faceIndex % 4 * pw + (pw - pw) / 2;
    var sy = Math.floor(faceIndex / 4) * ph + (ph - ph) / 2;
    var value = this.getActorId();
    var act = $gameActors.actor(value);
    var face = act.faceName();
    this._oBitmap = ImageManager.loadFace(face);
    this.bitmap.blt(this._oBitmap, sx, sy, pw, ph, 0, 0, width, height);
};
(I basically just added the 4 lines before the last line, so that the new face image is loaded before the face image is drawn.)

Try this and let me know if any problem arises.
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
299
Reaction score
89
First Language
Enlish
Hey Naveed,

This edit worked perfectly. I'll have to test it out some more, but it doesn't appear that any other errors have popped up! However, if any more errors do occur (or if anyone wants to use a "safer" method), I was able to find someone who had a similar issue on SRD's youtube comment section.

They were able to refresh the HUD for faces by using the following code:

SceneManager._scene._hud.children.forEach(function(baby) {
if(baby.refresh) {
baby.refresh(true); } });

I'm terrible at JS, so would this be possible to implement in your lunatic code?

If not, I can just run it as a script call at the end of every turn.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

um... why didn't anyone tell how easy it is to add motions to Sideview battlers? I literally copied the last one, changed the name and index, said where it should play, and boom... I've got intro motions.
Lately when I listen to 1970s songs, I always think that the "real world" is still at mid 70s. What we experience now is a futuristic dream. With this point of view, even 80s and 90s looks super futuristic. :D

The GIF of this seemed too cool to bury in replies. :LZSwink:
You may have slept with my aunt... but, given the circumstances, cheers.

- Professor Ian Duncan, 2013

Forum statistics

Threads
105,530
Messages
1,014,434
Members
137,213
Latest member
kuraudo123
Top