Edit / TL;DR: This has been solved by adding @Mac15001900's code as a plugin, initializing it, and adding script commands to some events. You can check all the instructions on the last post in this thread.
Hi, everyone!
Thanks in advance for any help provided.
Thanks in advance for any help provided.
First of all, I have to mention that I know that what I want isn't the best of practices and that I should've thought of it from the beginning of development. Also, I'll definitely be ok with it if it's really unfeasible and won't blame the engine or anyone else, but I've been wondering and trying to make it work.
I have a game with tons of already existing messages set with different face image files and expressions for each one. However, now I want to add different skins/outfits/etc. to my playable characters (who also have their own messages in-game). So that I don't have to go all over each message, I want to add a script call to a parallel common event that will handle that.
In other words:
What I want is to use JavaScript to forcibly display some different message face images from the ones already assigned on event pages. I want to use that for adding different skins/outfits to my main characters only, and it could also be used for automatically showing injured/happy/different faces according to different variables.
The game was released years ago and has hundreds, if not thousands, of dialogue messages, already set with multiple facial expressions (face indices) and face files (with more face indices).
For example, let's say I want to change the protagonist's skin/outfit. That could be easily achievable through the "Change Actor Images" event command. However, all the existing messages in the game would still show the base skin/outfit, which I set up on each event page.
I'm aware that YEP_MessageCore has the option to show the face of a specific actor through text codes, and I've seen similar plugins that require editing each Show Text event command. The problem is that there are simply too many messages within the game (even considering only the characters I want to add a skin to), and since I use SRD_TranslationEngine, I would have to either translate the whole game again or edit each message in the translation file too. That isn't doable at the current state of the game, thus my first paragraph.
I've also found ANY_Message_Face_Switcher, which is promising, but the problem is that its function isn't fully compatible with what I want. It automatically changes the message window face to an Actor's face based on the file name, it won't allow me to separately switch it in a parallel common event using variables or other conditions while also considering face indices. I would also have to edit my face picture files' names, which could lead to unexpected behavior in the game, especially due to the number of plugins I use. Furthermore, trying to edit that plugin on ChatGPT didn't work for me either.
One example of what I want is a parallel common event with something similar to this:
Code:
if(currentlyShownMessageFace == (part of an array of Aurora's face files) && variable1 = 0)
{
drawImage("aurora.png", sameFaceIndexAsOriginal);
}
else if (currentlyShownMessageFace == (part of an array of Aurora's face files) && variable1 = 1)
{
drawImage("aurora2.png", sameFaceIndexAsOriginal);
}
But even with a code like that, I'd have some trouble because I sometimes use more than one face file per character on messages. After all, the main characters have around 16 facial expressions each. I'm not sure how that could be handled, but I'll explore that below.
The reason why I'm not posting this as a plugin request is that I've already tried some stuff, have some examples, and noticed it seems possible to do so by using a single script call (though I guess I might probably be wrong). I hope that wasn't the wrong decision.
I researched a bit on other existing plugins but without success. Since I've just started learning some JavaScript and my current knowledge of it is limited, the first thing I tried was to create a plugin on ChatGPT, which gave me some headaches but allowed me to understand how message face display works. Unfortunately, the plugin itself didn't work, even after tons of prompts and "manual" coding.
Here is its currently unusable code in case anyone wants to take a look (don't mind the name, help file, etc. I was just trying to have some fun imagining myself as a plugin creator lol):
JavaScript:
//=============================================================================
// ZOE_DynamicMessageFaces.js
//=============================================================================
/*:
* @plugindesc Plugin for dynamically changing message face images based on variables. <ZOE_DynamicMessageFaces>
* @author ZoeZero (Zoe Miranda)
*
* @help
* Dynamic Message Faces
* Version 1.0
*
* Plugin Commands:
* DynamicFace originalFaceFile newFaceFile
* - Changes the original face image file to the new face image file dynamically.
* Example: DynamicFace gabriela aurora
*
* ResetDynamicFaces
* - Resets and shows all original face images set in the database.
*
* Script Calls:
* $gameMessage.dynamicChangeFace(originalFaceFile, newFaceFile)
* - Changes the original face image file to the new face image file dynamically.
* Example: $gameMessage.dynamicChangeFace('gabriela', 'aurora');
*
* $gameMessage.resetDynamicFaces();
* - Resets and shows all original face images set in the database.
*
* $gameMessage.getCurrentFaceIndex()
* - Retrieves the current facial expression ID (face index) of the upcoming message.
*
* Terms of Use:
* This plugin is free for both commercial and non-commercial use.
* You may modify it for your own purposes, but you may not sell this plugin directly
*/
(function() {
// Initialize dynamic faces object in Game_Message
var _Game_Message_initialize = Game_Message.prototype.initialize;
Game_Message.prototype.initialize = function() {
_Game_Message_initialize.call(this);
this._dynamicFaces = {};
};
// Override setFaceImage method in Window_Base to store original face information
var _Window_Base_setFaceImage = Window_Base.prototype.setFaceImage;
Window_Base.prototype.setFaceImage = function(faceName, faceIndex) {
this._originalFaceName = faceName;
this._originalFaceIndex = faceIndex;
_Window_Base_setFaceImage.call(this, faceName, faceIndex);
};
// Override method to load message face, considering dynamic faces
var _Window_Message_loadMessageFace = Window_Message.prototype.loadMessageFace;
Window_Message.prototype.loadMessageFace = function() {
var faceName = this._originalFaceName;
var faceIndex = this._originalFaceIndex;
if ($gameMessage._dynamicFaces && $gameMessage._dynamicFaces[faceName]) {
faceName = $gameMessage._dynamicFaces[faceName];
if (faceIndex === undefined) {
faceIndex = 0;
}
}
_Window_Base_setFaceImage.call(this, faceName, faceIndex); // Call setFaceImage from Window_Base
_Window_Message_loadMessageFace.call(this, faceName, faceIndex);
};
// Add methods to Game_Message to dynamically change and reset faces
Game_Message.prototype.dynamicChangeFace = function(originalFaceFile, newFaceFile) {
this._dynamicFaces[originalFaceFile] = newFaceFile;
};
Game_Message.prototype.resetDynamicFaces = function() {
this._dynamicFaces = {};
};
// Extend Game_Interpreter to handle plugin commands for dynamic faces
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'DynamicFace') {
var originalFaceFile = args[0];
var newFaceFile = args[1];
$gameMessage.dynamicChangeFace(originalFaceFile, newFaceFile);
} else if (command === 'ResetDynamicFaces') {
$gameMessage.resetDynamicFaces();
}
};
})();
What I last tried to do after analyzing YEP_MessageCore and rpg_objects.js was to create the following script call, to no avail. It has also faced some changes by AI:
JavaScript:
$gameVariables.setValue(1342, $gameMessage.faceName());
$gameVariables.setValue(1343, $gameMessage.faceIndex());
if($gameMessage.faceName() == "gabriela" && $gameVariables.value(1341) != 0)
{
$gameMessage.setFaceImage("gabriela-miner", $gameVariables.value(1343));
Window_Message._faceBitmap = ImageManager.reserveFace("gabriela-miner", 0, this._imageReservationId);
console.log("Debug:",$gameMessage.faceName(),$gameMessage.faceIndex(),$gameVariables.value(1341),$gameVariables.value(1343));
Window_Base.prototype.drawFace("gabriela-miner", $gameVariables.value(1343), 0, 0);
ImageManager.releaseReservation(this._imageReservationId);
}
I tried testing it out with the following event, but only the original message window face picture is shown (it won't change according to what I specified in the script call):
One important thing to mention is that I had managed to alter the currently shown message window face picture file with my ZOE_DynamicMessageFaces plugin before I made more changes on ChatGPT. However, all messages, regardless of the set message window face picture file, would show the new face. Basically, all NPCs had my character's new face when talking to them. I've once also managed to achieve the same with a script call (without the plugin but with the same problem). I just wish I had backed up every piece of barely working code, but I didn't.
Ah, also rather importantly, many of my problems when experimenting were related to retrieving the appropriate face index. I have separate files with the same facial expressions on each corresponding face index, but I couldn't get the game to identify the current face index and show the same face index of a different file. If it is possible to manually set up specific face indices/expressions that would be equivalent to the original ones for cases in which the file doesn't follow the same pattern, even better (though I suspect that would perhaps constitute a plugin request). Here is an example of an original and an alternative face picture file to illustrate what I mean (the second part of my paragraph suggests dealing with picture files that don't follow the same design):
In conclusion, what I believe is that getting information from rpg_object's Game_Interpreter.prototype.command101 and using Anyone's Message Face Switcher as a reference to create a single script call (even if minified) in a parallel common event might be the best way to accomplish the desired effect.
Since I don't know what I'm doing wrong or what else I can do, I am asking for your help.
These are the plugins I use (I know some Yanfly plugins are not in order. I'll handle that soon):
I can provide any necessary information, links, codes, Steam keys, screenshots, or explanations.
Thanks a lot in advance!




