This tutorial is a bit different from my usual topics, but I thought it might be useful for some of you :3
I have went through the frustration of having a chooseable hero in a past project (never finished, obviously ;D) and having to have all those if-statements just to get the right picture in the message box can be super frustrating. And I know, there are plug-ins, but plugins can clash or maybe you just want to avoid them or ... whatever.
Let's go!
Some games use the same one graphic for their hero throughout the whole game, but what if the look changes - maybe even multiple times - due to dynamic decisions during the game?
Being it a choice which character you even play or the Golden Reid Skin you can unlock for 9999 gold, there are some pitfalls that could bring a lot of work with them.
But before we get into that, there are many reasons why you might need this:
- You could have a dynamic system where you can pick a look or a class while the story unfolds (mostly) the same for each option
- You could have unlockable fun skins for people who just explore the whole game and find the easter eggs you hid for them - who does not want the PartyHat Skin for successfully trying out all the beverages in the game?
- You could have story related outfit changes - maybe you get new cloaks after you passed through the elven forest and while that does not change the dialogue in the previous villages if you go back, your heroes just look different
Okay, after we talked about the why, let’s have a closer look at the how. Basically, you set how a character looks in the database in the actor tab:
But if you want them to look different as set from the start, you can change each of the categories via an event command, so once the player chooses to use the Golden Reid Skin, this command makes the change come true:
This command will immediately change how Reid is displayed on the map, in the menu or in fights…
…but there is one gaping hole in this:
Since the message windows are not put together dynamically, all text boxes where Reid speaks to people will just have him look as he did before - not the shiny sparkly version we want to be seen. While you can use the names of the characters with “\n[1]” or even use variables in the text as Touchfuzzy shows in
his great pronoun tutorial here, there is no quick command to change the face.
Tip: If you want to know which additional tricks you can do in the message window, hover your mouse over it and wait a little.
The selection for the face on the other hand is just ”select the picture, period”:
The most common approach to this would either be settle for a plugin or have every Text Message by Reid being there two times in combination with an if-statement:
This could look like this, the skin change would either go with a variable or a switch which then has an impact on the conditional branch that decides which of the two messages is shown.
While this can work on a small scale, imagine having more than two outfits, or adding a third later in development and having to go back to each and every message box…
Well, by the name of the tutorial you probably already guessed it: there is a solution.
There is a way to display messages without using the message command, and once you get it set up it works as well as the command.
You can display messages via script, and by the nature of that, you have even more power over them, especially when it comes to the face part!
So, how do you display messages using the script calls? (The lines are listed in the
MV/MZ script call list)
$gameMessage.setFaceImage(faceName, faceIndex);
This is the one snippet we will need to perform our trick. For “face name” you put the name of the file you want to display (for example, “GoldenReid”, you need the “” here) and that is in the face folder, and for “faceIndex” a number between 0 and 7 that indicates which frame on said faceset. Not using this line will leave the message as if no faceset was set.
Before we go in depth on the dynamic part, we have a quick look at the other possible snippets as well:
$gameMessage.setBackground(bgType);
If you want the window in the default style, you can leave this line out, otherwise you can set the following options for “bgType”: 0 (Window), 1 (Dim) or 2 (Transparent).
$gameMessage.setPositionType(posType);
If you want the window position to be default, you can leave this line out, otherwise you can set the following options for “posType”: 0 (Top), 1 (Middle) or 2 (Bottom).
$gameMessage.setSpeakerName(speakerName);
For speakerName you can set “anynameyouwant” (again, here the “” or ‘’ are necessary). You can use all of the message commands (like \N[1]) here as well, but you need an extra \ to get it to work, for example: “$gameMessage.setSpeakerName('\\n[1]');”. If you don’t add this command, there is no speaker window on the message.
$gameMessage.add(text);
For the message, you can also use the commands with the extra “\” as for the speaker name, and you use one command for each line you want to display, e.g.:
“$gameMessage.add("I am Reid! I am trying to type a very long");
$gameMessage.add("message here.");”
If you add more than 4 lines, the next ones will be displayed in a new window with the exact same settings.
For example:
“$gameMessage.setFaceImage("GoldenReid", 0);
$gameMessage.setSpeakerName('\\n[1]');
$gameMessage.add("I am \\n[1]! I am trying to type a very long");
$gameMessage.add("message here.");
$gameMessage.add("message here.");
$gameMessage.add("message here.");
$gameMessage.add("message here.");”
will look like this:
You could also use \n for a new line, the same as above would look like this:
“$gameMessage.add("I am \\n[1]! I am trying to type a very long \nmessage here. \nmessage here. \nmessage here. \nmessage here. \nmessage here.");”
But back to our dynamic face trick!
In our previous try we used a variable to indicate which of the messages should be displayed, and we keep that idea: the Variable for the “skin” (in my example project it was the variable #4) is 0 by default, and each skin has a dedicated number between 1 and 7.
Knowing that a faceset has 8 slots labeled from 0-7, we can replace the hard coded number from our face command with a variable.
So instead of using
$gameMessage.setFaceImage(“GoldenReid”, 0);
we use:
$gameMessage.setFaceImage(“GoldenReid”, $gameVariables.value(4));
which uses the value of the variable with the ID 4 as index.
This way we can set the variable to the slot we want to be displayed, so for the golden skin, we set it to 1, for the inverted to 2, for the greyscale to 3 and the others are not used at the moment, they would just display an empty frame. If we want to change back, we simply set it to 0 again. (This should happen along with the change of the character graphics)
With this trick you can have 8 different skins/looks/versions properly displayed in messages without using a single conditional branch! Imagine how much work this saves!
If you want to use multiple emotions it is best to have one sheet for each emotion and store the different skins in the same slots for each. This trick also works perfectly if your player can select their class/style/gender/whatever in the start! Hiddeone has a great tutorial about this
here.
Tip: With a spreadsheet or a text document with your “most used message options” you can streamline using the script calls and work as fast as you would do using messages.
本贴来自国际rpgmaker官方论坛作者:Avery处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/alternate-skins.156929/