Help with Custom Level Message according to variables?

Good Morning / Afternoon / Evening

I'm developing a system in my game where you "equip" a class (in this case it's an armor posing as a class) and your equipped class determines how your stats change as you level up.

15.12.2023_13.24.05_REC.png


I am using YEP's message core as well

Is there a way to make it so that for example, when Actor 1 levels up, the level up message in battle would be.

"Actor 1 is now a level X Squire!" Because that is the class/style he has equipped, then, if he had another class equipped, like "Bruiser" for example, the message would be "Actor 1 is now a level x Bruiser!"

Then apply this to each individual actor...

Is this possible to achieve?

Any help is appreciated.
Paste the below into a text editor, save as a *.js file, include as a plugin - we just need to add one word, but it's right in the middle of the code.

Code:
Game_Actor.prototype.displayLevelUp = function(newSkills) {
    var text = TextManager.levelUp.format(this._name, TextManager.level, this._level, this.currentClass().name);
    $gameMessage.newPage();
    $gameMessage.add(text);
    newSkills.forEach(function(skill) {
        $gameMessage.add(TextManager.obtainSkill.format(skill.name));
    });
};

Then you can use %4 in the Level Up message to reference the class.
I am very sorry, but I most likely was not specific enough with this.

the "class" we are talking about wasn't the default thing from MV... it's more like a piece of "Armor" in the database that is equipped.

So.. it would be like, if that piece of armor is equipped, the message would be "actor 1 is now a level x "name of armor"
Do you need the class to be an individual Level than the characters Level?
Like reach Level 5 in Archer but be Level 1 as a Swordsman?
Is an actor always going to have something in that slot?

If yes, you'd just modify the function I already pasted above.

Replace this.currentClass().name with this.equips()[x].name where x is the slot number of your Style.

If there are times when an actor might not have anything there, you're going to have to do something more complex because you'll need to have two different Level Up messages.
If necessary you could use them both together, e.g.

this.equips()[x] ? this.equips()[x].name : this.currentClass().name
Then if an actor has nothing in that equip slot, %4 will be the name of their current class instead.
Is an actor always going to have something in that slot?

If yes, you'd just modify the function I already pasted above.

Replace this.currentClass().name with this.equips()[x].name where x is the slot number of your Style.

If there are times when an actor might not have anything there, you're going to have to do something more complex because you'll need to have two different Level Up messages.
Yes, always. They are non-removables.

EDIT

Thank you so much for this, it worked perfectly for what I intended.

If I get any problems I'll let you know! Thank you!

I am encountering an issue where it seems to conflict with this Level Up SE Plugin i'm using.


Any way we can make these two work together?
No idea, what is the "seems to conflict"? Does it crash with an error? If yes, press F8, go to the Console tab, and supply a screenshot of the error.

If there's no crash, then what is happening instead of what you expect?

There's not really anything we can say without knowing what your problem is.
If I placed the two plugins on top or below eachother, either the sound effect wouldn't play or the %4 would be "undefined"

I found a sort-of fix for it, though.
It's because the level up SE plugin overrides that method. Fortunately it doesn't need to, and it's under the MIT license so edits are OK.
Spoiler: edited plugin code
JavaScript:
//=============================================================================
// YME_LevelUpSe.js
//=============================================================================

/*:
 * @plugindesc Plays a sound effect when level up
 * @author Yumineko (edited)
 *
 * @param SE Name
 * @desc Specify the file name of the sound effect.
 * @default Up1
 *
 * @param SE Volume
 * @desc Volume adjustment of the sound effect. 0~100
 * @default 100
 *
 * @param SE Pitch
 * @desc Sound Effect Pitch (speed) adjustment. 50~150
 * @default 100
 *
 * @help Sound effect is played when level up where the text is displayed. (battle included)
 *
 * This plugin is under the terms of MIT license. (please check the website for more info.)
 * http://opensource.org/licenses/mit-license.php
 */

(function() {
    var parameters = PluginManager.parameters('YME_LevelUpSe');
    var seName = String(parameters['SE Name'] || 'Up4');
    var seVolume = Number(parameters['SE Volume'] || 100);
    var sePitch = Number(parameters['SE Pitch'] || 100);

    var displayLevelUp = Game_Actor.prototype.displayLevelUp;  // store method
    var upSE = {"name":seName,"pan":0,"pitch":sePitch,"volume":seVolume}
    Game_Actor.prototype.displayLevelUp = function(newSkills) {  // override
        displayLevelUp.apply(this, arguments);  // call stored method
        AudioManager.playStaticSe(upSE);        // play SE
    };

})();
With this code, I believe Yumineko's plugin should work if it's loaded after Turan's.
This will be very useful even with my own workaround! Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-custom-level-message-according-to-variables.163875/