Get Value of Current Event Sprite and Faceset

Hi everyone :LZYsmile:

Question:

Is there a way to get the value (the image) of the last face-set picture used in a dialogue message?
Also, is there a way to get the value of what sprite the current event (the one the player is interacting with) is using?

Context for why I need this:

I'm working on a system where the player can recruit generic NPCs to their party, which is made possible by using a Duplicate Actor Plugin.
Once an NPC joins the player a template actor gets duplicated to a new instance which will be the new NPC actor, the original template actor's faceset and character sprite are then changed to reflect what the NPC looks like.

This is an example script where the new actor has their sprite and face changed:

var act = $gameVariables.value(362);

$gameActors.actor(act).setFaceImage('anim_peasant2', 0);
$gameActors.actor(act).setCharacterImage('$peasant2', 0);
$gamePlayer.refresh();

This seems to work fine but I'd like to streamline the process;
I was hoping I could change the script so that the sprite would be changed to the one the current event (the NPC the player is interacting with).
Also right before an NPC is recruited they will say something (a message box with their face) so I thought I could get the value of the last faceset image used in a message and change the new actor's face to that.

This would save me from having to type in manually the face and sprite I want and use this as a general script.

That said, if anyone knows a better way, I'd be more than glad to learn 🙂


Thanks in advance for the help and I apologize if this was a bit verbose!
Hmmm, maybe someone can give you a simpler method, but I think you can change the actor sprite to the event sprite with:

$gameActors.actor(2)._characterName=$gameMap.event(this.eventId())._characterName;
$gameActors.actor(2)._characterIndex=$gameMap.event(this.eventId())._characterIndex;
$gamePlayer.refresh();

I don't know how you'd reference the face graphic with scripts, but you can change the functions with a plugin file to:
Spoiler
Game_Message.prototype.faceName = function() {
$gameVariables.setValue(99, this._faceName);
return this._faceName;
};

Game_Message.prototype.faceIndex = function() {
$gameVariables.setValue(100, this._faceIndex);
return this._faceIndex;
};

Then if that NPC was the last face image you used:

$gameActors.actor(2).setFaceImage($gameVariables.value(99), $gameVariables.value(100));
$gamePlayer.refresh();

Sets the face image for the actor.
Thank you so much for the comprehensive response!
I'm looking forward to try this out 🙂
Hmmm, maybe someone can give you a simpler method, but I think you can change the actor sprite to the event sprite with:

This all worked like a charm, I really appreciate your help. Thank you again

Original thread: https://forums.rpgmakerweb.com/threads/get-value-of-current-event-sprite-and-faceset.166830/