Changing actor/face sprite depending on location in spritesheet?

'Evening!

I've been wondering if there is a way to change an actor's character sprite/face sprite by specifying a location in the current sprite sheet (for situations where using a change actor graphic/face command is not feasible).

My reason for asking is I've come across a really nice composite characters script, allowing you to build custom character in-game using composite graphics for different sprite elements (hair, clothes, face, etc), and it works great, except changing the sprite/face on the current sheet used for the composite character doesn't seem possible by conventional means, as it requires specifying which sprite sheet to get the sprites from (the actor's sprites are occupied by a placeholder sheet, which is then replaced when the composite character is created. Simply selecting the placeholder sheet when changing actor graphics reverts the actor to the placeholder graphics instead of the composite ones).

Essentially, let's say my character's sprite is located in a standard 8-character sprite sheet, and I want to change its sprite from the first character in the top row of the current sheet to the 4th character in the bottom row of the current sheet. Is there a way to do this, without needing to specify the specific file? And would this also be possible to do with face sets?

I'm trying to find a way around this issue, so my character can do things such as strike different poses, or show emotions, etc. I also should note that I have about zero experience writing scripts from scratch. I know how to read through a script and figure out how some of the functions work, as well as understand how to use and edit script calls, but beyond that I'm kind of in the dark.

All help is appreciated!
I cannot look up the answer for you because I'm at work on lunch and don't have Ace with me.

However, you can use a Script command to call the same method that the Change Actor Graphic calls, and instead of passing the spritesheet name, you just tell it to use the same one. Something like

$game_actors[id].change_graphic($game_actors[id].character_name, 5)

Except I think it's more complicated, because with actors you have the sprite AND the face.

If someone could please kindly look up the command and provide the correct syntax, that'd be great.

Okay, since no-one else has done it and I'm home now, the Script command would be:

Code:
a = $game_actors[id]a.set_graphic(a.character_name, x, a.face_name, a.face_index)
and replace id with the id of the actor (5, not 005), and x is the index of the sprite you want to use, remembering the top left is 0. If you also want to change the face, use the same number instead of a.face_index
Really appreciate the help! 😀

I'm a little bit confused understanding the contents in parentheses, though. Are a.character_name, a.face_name, and a.face_index supposed to be replaced with values? That and I'm not really sure what "x" is.
no - you type them exactly as I've got them there. The only things you change are the 'id' and the 'x'.


And I already told you that x is the index on the spritesheet.
Ah, sorry the explanation about x somehow slipped my mind. Sorry about that.

The script seems to work in that I don't get an error when it's activated, but the character sprite doesn't seem to change at all. I've tested it without any other third party scripts running alongside it, and with different actor ID's and sprite indexes, and got the same result.

Here is the script referring to the first actor. I'm trying to get it to change the sprite to index 3.

a = $game_actors[1]
a.set_graphic(a.character_name, 3, a.face_name, a.face_index)
add $game_player.refresh afterwards. See if that makes a difference.


If not, it could be something to do with the script.
Aha! That did the trick! It seems to work just fine now.

Thanks again for your help!
nice 😉

Original thread: https://forums.rpgmakerweb.com/threads/changing-actor-face-sprite-depending-on-location-in-spritesheet.43806/