Anyone's Message_Face_Switcher v1.2

Anyone

Veteran
Veteran
Joined
Aug 24, 2019
Messages
100
Reaction score
72
First Language
German
Primarily Uses
RMMV
Anyone's Message_Face_Switcher v1.2
by Anyone
Introduction:
This is a small plugin made for my current project that allows the game to switch out the message face for the face of an actor designated in the message face's file name.

Features:
  • Easy switching of faces to actor faces without using escape codes in the message text
  • Compatible with plugins that hard-edit the command101 (such as Yanfly's Message Core)
  • The exchange happens early in the message generation, meaning that all text escape codes within the actual message text will act as if that face had been the face assigned in the editor from the start
  • With normal faces, this saves you the time of using an escape like \af[x] to call the actor's face. With face busts plugins, especially the more complex ones, that load the message face from the message face name (such as Irina's VisualNovelBusts), this is essential to load a different bust as face in a seemless way without glitches and other bugs. (For example if your character has a different bust based on the equipment you're wearing)
  • New: (v1.2) Redirection to other Files possible through prefix and suffix
How To Use:
1. Load the plugin preferably close to the bottom of your load order and activate it.
2. Create a *.png file that you wish to use as placeholder of the actor's face and ensure that it contains "_Actor" followed by the number of the ActorId of the actor whose face you wish to load.
Example: Harold_Actor1.png
3. Use the "Harold_Actor1.png" as the face when creating the "Show Text" function in your dialogue event. Regardless of whether Harold_Actor1.png is an empty png file, or contains some other face, this face will instead be switched to whatever face has currently been assigned to Actor1.

Alternatively, you can also use the phrase "_Partymember" in the *.png files' name to instead reference the face of the current party member in the slot.

Take care: the Actor ID's count from 1,2,3,4...
While the Partymember starts with 0 for the party leader: 0,1,2,3
This means that Actor 2 is "_Actor2" but Partymember 2 is "_Partymember1".

FAQ:

Q: The face isn't getting loaded.
A: Make sure you include the "_" sign in front of Actor. This is done to ensure that it won't pick up stuff like Factor12 as valid terms.
HaroldActor1.png is incorrect
Harold_Actor1.png is correct

Q: The wrong Partymember face is assigned.
A: Keep in mind that partymembers are counted from 0. If you want to reference the Partyleader in Slot 1, use...
_Partymember0.png
The Partymembers 2,3 etc. need -1 deducated from their number.

Partymember 3:
_Partymember2.png

Terms of Use:

  • 1. This plugin can be used for free in free and commercial games alike.
  • 2. Credit must be given to "Anyone".
  • 3. The code may be edited & altered to your liking.
  • 4. Redistribution of the original code as well as of edited versions is allowed, so long as proper credit is given.

Demo:
New Demo Version!
Equip items and see the message window face use the correct face.
(This is made possible with the Way_Core and Way_OnEquip plugins)
https://workupload.com/file/3NJTLPD4


Code:
/*:
*
* @plugindesc Version 1.2. This plugin switches the Message Window Face for the Actor's current Face.
*
* @author Anyone
*
* @param Redirect from ActorFace to Image
* @type boolean
* @on YES
* @off NO
* @desc Instead of direction to an Actor, it directs to another face based on the prefix
* designated in the Reference Phrase Prefix.
* @default false
*
* @param Reference Phrase Prefix
* @desc Instead of directing to an Actor, it directs to prefix + ActorFaceFile.
* @default prefix_
* @help
*
* @param Reference Phrase Suffix
* @desc Instead of directing to an Actor, it directs to ActorFaceFile + suffix.
* @default _suffix
* @help
*
* //==========================================================================//
* //                     Anyone's Message Face Switcher                         //
* //========================================================================// 
*                            //~~~~~~~~~~~~~~//
*                           //   by Anyone  //
*                          //~~~~~~~~~~~~~~//
*
*
*
* This script allows you to use a placeholder face for an Actor that will switch
* out with the Actor's current face.
* Simply ensure that the term "_Actor" lower/uppercase insensitive is in the 
* placeholder face file's name, followed by a number.
* So if you use an empty face as a png file called:
* "Harold's_Placeholder_Face_Actor1.png"
* the "_Actor1" will be detected and the face of Actor 1 will be used instead of
* the placeholder face.
*
* Alternatively you can also use "_Partymember" followed by a number to use a
* placeholder for a partymember. Keep in mind that Slot 1, the leader, is
* Partymember 0.
*
* Partymember1 (Leader): _Partymember0.png
* Partymember2 (Leader): _Partymember1.png
* Partymember3 (Leader): _Partymember2.png
* Partymember4 (Leader): _Partymember3.png
*
* Additionally, instead of directing to the Actor, you can also redirect from
* the Actor to a different file based on suffixes and prefixes.
* To do so, activate "Redirect from ActorFace to Image" in the plugin parameters
* by setting it to true. Then configure the prefix and the suffix for the image
* you intend to redirect to.
*
* E.g. Prefix: "Bust_" and Suffix: "_[Exp5x2]"
* The Face assigned to the Actor 1 is "David.png" in img\faces
* By using any face image as message face that contains "Actor1" inside the name
* the message window face will switch to David.png because this is Actor1's face.
* From there, with the Redirection active, it will actually switch over to
* Bust_David_[Exp5x2].png and use this as the message window face.
*
* //==========================================================================//
* //                          When is that useful?                           //
* //========================================================================//
*
* If your character's face changes throughout the game, and you want to have the
* current one displayed without having * to resort to in-message escapes such as
* yanfly's \af[x] to adjust it.
* 
* While that may not seem big...it's huge for plugins that use face busts based
* on the message face which use their own escapes in the message text.
*
* Plugins such as Irina's VisualNovelBusts plugin are almost entirely
* incompatible with yanfly's \af[] escapes and at best create glitchy, laggy
* busts and at worst, either bug out or don't function at all.
*
* Since this plugin ensures the switch happens before the message text is even
* read,
* the switch is entirely seemless as if that face had been the one assigned to
* the message from the very beginning.
*
* //==========================================================================//
* //                             TERMS OF USE                                //
* //========================================================================//
*
* 1. This plugin can be used for free in free and commercial games alike.
* 2. Credit must be given to "Anyone".
* 3. The code may be edited & altered to your liking.
* 4. Redistribution of the original code as well as of edited versions is allowed,
* so long as proper credit is given.
*
* //==========================================================================//
* //                              CHANGELOG                                  //
* //========================================================================//
*
* Version 1.2:
* - Added Suffix Sheet redirection (25th of December 2019)
*
* Version 1.1:
* - Added Prefix Sheet redirection (19th of November 2019)
*
* Version 1.0:
* - Released (12th of November 2019)
* 
*/

var Imported = Imported || {};
Imported.ANY_Message_Face_Switcher = true;
var ANY = ANY || {};
ANY.MessageFaceSwitcher = ANY.MessageFaceSwitcher || {};


(function() {

var params = PluginManager.parameters('ANY_Message_Face_Switcher');
ANY.MessageFaceSwitcher.UseSheet = String(params['Redirect from ActorFace to Image']);
ANY.MessageFaceSwitcher.UseSheet = eval(ANY.MessageFaceSwitcher.UseSheet);
ANY.MessageFaceSwitcher.DirectPrefix = String(params['Reference Phrase Prefix'] || "");
ANY.MessageFaceSwitcher.DirectSuffix = String(params['Reference Phrase Suffix'] || "");

var _IS_Game_Message_Show_Text = Game_Interpreter.prototype.command101;
Game_Interpreter.prototype.command101 = function() {
	_IS_Game_Message_Show_Text.call(this);
	var _IS_ActorId = $gameMessage.faceName().match(/_Actor(\d+)/i);
	if (_IS_ActorId) {
		var _Actor_faceName_To_Use = $gameActors.actor(_IS_ActorId[1]).faceName();
		var _Actor_faceIndex_to_Use = $gameActors.actor(_IS_ActorId[1]).faceIndex();
		if (ANY.MessageFaceSwitcher.UseSheet == true) {
			_Actor_faceName_To_Use = ANY.MessageFaceSwitcher.DirectPrefix + _Actor_faceName_To_Use + ANY.MessageFaceSwitcher.DirectSuffix;
			$gameMessage.setFaceImage(_Actor_faceName_To_Use, _Actor_faceIndex_to_Use);
		} else {
		$gameMessage.setFaceImage(_Actor_faceName_To_Use, _Actor_faceIndex_to_Use)};
	} else {
	var _IS_PartyId = $gameMessage.faceName().match(/_Partymember(\d+)/i);
	if (_IS_PartyId) {
		var _Party_Is_Actor = $gameParty.members()[_IS_PartyId[1]].actorId()
		var _Party_faceName_To_Use = $gameActors.actor(_Party_Is_Actor).faceName();
		var _Party_faceIndex_to_Use = $gameActors.actor(_Party_Is_Actor).faceIndex();
		if (ANY.MessageFaceSwitcher.UseSheet == true) {
			_Party_faceName_To_Use = ANY.MessageFaceSwitcher.DirectPrefix + _Party_faceName_To_Use + ANY.MessageFaceSwitcher.DirectSuffix;
			$gameMessage.setFaceImage(_Party_faceName_To_Use, _Party_faceIndex_to_Use);
		} else {
		$gameMessage.setFaceImage(_Party_faceName_To_Use, _Party_faceIndex_to_Use)};
		}
	}
};



})();

Also attached as *.rar archive.

Have fun.

CHANGELOG:
-v1.2
Added new Demo version, added a Redirect Functionality
 

Attachments

Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,285
Reaction score
431
First Language
Dutch
Primarily Uses
RMMV
it seems nice, but can you have a demo as well? if its stripped, it would be 5-10MB demo, which can be usefull how its works.
specially by ppls that dont quite understand the plugin it self but more looking at the events used (like me).

but the idea is lovely though.
 

Anyone

Veteran
Veteran
Joined
Aug 24, 2019
Messages
100
Reaction score
72
First Language
German
Primarily Uses
RMMV
it seems nice, but can you have a demo as well? if its stripped, it would be 5-10MB demo, which can be usefull how its works.
specially by ppls that dont quite understand the plugin it self but more looking at the events used (like me).

but the idea is lovely though.
I've added a demo, though you won't see much in the events itself other than empty pictures. There's no special commands, plugin commands or anything like that used.

Only the name of the face file plays a role, the rest is automated by the script.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,285
Reaction score
431
First Language
Dutch
Primarily Uses
RMMV
I check the demo and faces, but I still dont understand how that is even possible, it take probably the index 0 of Actor1 index 0,
but somehow, it kinda confuse me at the same time.
But I got a 2 questions though.

1) if you use an empty place holder, do you still need the faces of Actor1, Actor2 or other names to have their faces?
2) if the faces are still needed to draw the actor or NPC's name, what exact fuction does this do by than?
 

Anyone

Veteran
Veteran
Joined
Aug 24, 2019
Messages
100
Reaction score
72
First Language
German
Primarily Uses
RMMV
I check the demo and faces, but I still dont understand how that is even possible, it take probably the index 0 of Actor1 index 0,
but somehow, it kinda confuse me at the same time.
But I got a 2 questions though.

1) if you use an empty place holder, do you still need the faces of Actor1, Actor2 or other names to have their faces?
2) if the faces are still needed to draw the actor or NPC's name, what exact fuction does this do by than?
Alright, let's take a concrete example:

You have an Actor called ShadowDragon, a great hero who wields many weapons and has lots of powerful armor.
Back at home, ShadowDragon has an armory with all his suits of armor and if he interacts with that armory's armor, an event is called that uses the event command on page 3, under System Stettings: "Change Actor Images..." and the image of Actor ShadowDragon is changed to the image of him wearing a different set of armor.

That's what you can do in default RMV. There's a problem though: While your actor has a new face in the menu, in the dialogue, it will still use the fixed image assigned within the "Show Text" event.

The common workaround is using yanfly's message plugin and using the \af[x] command to change the face of the message to the face of actor X.

My plugin essentially does the same, but it doesn't use the \af[x] command.
Instead, it uses a placeholder image that can contain anything, so long as the name of the actual image file has "_Actor" inside it, followed by the number.

When the message window is being created, my script jumps into that process and takes a look at the name of the message window face.
If that name contains "_Partymember" or "_Actor", my plugin will realize: alright, we need to change the face to something else.
And then it will check what face the Partymember or the Actor of the number that followed the "_Partymember" string was.

So if the face being used is "_Partymember0", my script realizes: Hey, we actually need a different portrait...that of whoever is currently the party leader. Let's take a look who the party leader is. The script then picks the faceName and faceIndex that's currently assigned to the Actor in that partymember slot - or the Actor itself, if "_Actor" is used, and replaces the message window face with that face.

As a result, by using a placeholder face with the name "ShadowDragon_Actor1.png" the script will always use ShadowDragon's current Actor face instead.
So if ShadowDragon switches his suit of armor for a different one and has a new face in the menu, this face will also appear whenever his "ShadowDragon_Actor1.png" face is used in a message, because this face image always redirects to the current face of an actor, whatever face that may be.

A1:
Yes, the Actors in the database need actual faces assigned to them, because this script redirects to them.

A2:
See the above example. Instead of a fixed message window face, you have a variable one. If you change the face of an actor ingame, you only change their face, not the face visible in the message. This script allows the face in the message to be variable. If the face of your Actor never changes, this script is useless for you.
If your Actor's face changes (different equipment, different armor, different scars, etc.) than without this script (or Yanfly's message core instead) your Actor will always have the wrong face in messages.
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,285
Reaction score
431
First Language
Dutch
Primarily Uses
RMMV
so for _actor1 with var = 0 (normal face)
if I change var = 1 (actor1 index5)
if var = 2 (actor2 index 6)

if I make a common event out of it?
if this is correct, than its a pretty neat plugin and more usefull than \fa[x].

I can play around a bit, but it's probably useless in my project though. But it can help many others hopefully
if they discover this plugin.

I keep an eye on this plugin in case it improves or has more future features =).

PS: thank for the explanation, was very helpfull.
 

Anyone

Veteran
Veteran
Joined
Aug 24, 2019
Messages
100
Reaction score
72
First Language
German
Primarily Uses
RMMV
so for _actor1 with var = 0 (normal face)
if I change var = 1 (actor1 index5)
if var = 2 (actor2 index 6)

if I make a common event out of it?
if this is correct, than its a pretty neat plugin and more usefull than \fa[x].

I can play around a bit, but it's probably useless in my project though. But it can help many others hopefully
if they discover this plugin.

I keep an eye on this plugin in case it improves or has more future features =).

PS: thank for the explanation, was very helpfull.
No variables are used.

The script works entirely on the name of the picture in the "Show Text" message window.
If the name of the face you use in the gamefolder\img\faces\ is:
AnythingInHere_Actor1.png
then that filename will be recognized by the script plugin. It works entirely on the name of the face that you put into the message window's "Show Text" event and thus the actual filename inside the img\faces folder.

You do not do anything in the RPG Maker MV other than putting the placeholder image into the "Show Text" face.

That's why no variables, no script calls, no plugin commands, no nothing is used. Just the name in the img\faces folder of the face picture you put into the "Show Text" command inside your event.

-------------------------------------------------------------------------------------------

The biggest advantage of this plugin is that the face is changed before the actual message text is being created and checked for escape commands.

If you use yanfly's \af[x] command, what will happen, simplified, is this:
The attributes are assigned to the message window.
The message window is created.
The message window text escapes are being processed. \af[x] is detected and the face is changed.
The faces & text message are displayed.

If any of the escapes used above reference the message window face, though, they might operate before yanfly's \af[x] command.

So if you use Irina's VisualNovelBusts plugin, this happens:
The attributes are assigned to the message window.
The message window is created.
The VisualNovelBusts plugin does its operations to process the message window name to derive the actions necessary to display the bust set as face image.
The message window text escapes are being processed. \af[x] is detected and the face is changed.
The wrong face & text message are displayed.
Irina's plugin detects a different face is now set and hurries to change it.
The plugin redisplays the entire faceset with all faces across the entire screen.
The faces get truncated and cut back into parts in front of the player's eyes.
The new bust image is displayed after a flickering lag.
Any commands such as moving the bust will cause the bust to glitch out, entirely uncertain of where it should be, and will flicker back and forth between original position and where it should now be.

Because Irina's plugin commands work off the message window's face name, it is entirely incompatible with any message face changes and will at worst show nothing at all as face, and at best will create a glitchy, laggy, flickering horrendous mess that will crash and bug out if you look at it the wrong way.

My plugin changes the face before anyone else can operate on it, ensuring that all other plugins will believe that the actor's face was there all along from the beginning.

So what happens in the above example with my plugin instead of yanfly's \af[x] is this:
The attributes are assigned to the message window.
The message window is created. The message window's face name is checked, the face is changed to the Actor X's face.
The VisualNovelBusts plugin does its operations to process the message window name to derive the actions necessary to display the bust set as face image.
The message window text escapes are being processed. \af[x] is not used.
The bust & text message are displayed perfectly.
Any escapes that move or alter the facebust will work exactly as intended, as if the face has never been switched but had been there all along. No glitches, no bugs, no nothing.

This plugin is a minor convenience for people who use normal faces, and saves them from using yanfly's \af[x] in every dialogue window.
For people using more advanaced plugins that work on the face image as face bust, for example, this plugin actually makes those plugins work, where before, they would have bugged out.

So this plugin only becomes really helpful if you're using highly sophisticated face message plugins that work on the face image around the same time as yanfly's \af[x] escape would. That's when it makes things possible that were previously impossible.
 
Last edited:

Anyone

Veteran
Veteran
Joined
Aug 24, 2019
Messages
100
Reaction score
72
First Language
German
Primarily Uses
RMMV
Updated with Version 1.2:

By default, the plugin reads the name of the image that you assign in the message window in the "Show Text" event, searches for "Actor" and, on detection, will use this to redirect the face that is displayed in the message to whatever the Actor's current face is.
Now additional functionality has been added that allows you to redirect away from that face and to a different face image based on that face.

So, by default:
If our Actor 1 is Harold, and he has the Face "Harold_Face", we can use a Show Text event with a face image name that includes "_Actor1". This empty face will automatically be replaced with the face of Actor1, which is Harold_Face. This allows us to use a placeholder that enables us to change the face in the message window depending on what face image is assigned to an actor.

In the plugin settings, you can now also activate a Redirection option which will allow you to use a prefix and suffix.
With those Actors, the script will switch from:
placeholder_Actor1.png -> whatever Actor 1 has as face image
to:
placeholder_Actor1.png -> whatever Actor 1 has as face image -> prefix_"name of Actor1's image file name"_suffix.
So in the example above:
_Actor1 -> Harold_Face -> prefix_Harold_Face_suffix.png

This allows you to use a different face in a message other than the one assigned to the actor, but nontheless based on the actor's.
That's useful if you want your character's face image be "Harold_Face" but you're using a Bust plugin for the message face window and want to show a Bust that's based off on the character's image, you can do so now.
E.g.
Actor's Face image: Harold_Face.png
Actor's Message Bust: Bust_Harold_Face.png (when using only a prefix and the prefix is set to "Bust_")


To see the default functionality in action, there's a new demo version that uses two plugins from Waynee95 to change the character's face and character image based on what they're wearing. If you then speak to the character, the face image that's used is based on the one your actor has, making it a variable face instead of a fixed one.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

buinguyenhoangtho wrote on fizzly's profile.
Hello @fizzly, i would like to use your asset/ resource for my project ( is maybe commercial ). May i have your permission? Thanks you !
Working on breaking the limits of RPGMaker! :cool:
I have 470+ hours on RMMV but have only made a demo game, is this normal? :kaoswt: (I lose motivation a lot plus I use a 32gb laptop, so..)
I like Iron Maiden.
Benku wrote on Magnus0808's profile.
Hey man you helped me out a long time ago with a plugin i was wondering if you can help me out one more time since its literally the last thing i need help with if not is cool but id figured id ask you one more soild.

Forum statistics

Threads
95,427
Messages
929,082
Members
125,659
Latest member
AphoticAmaranth
Top