Change battle log messages depending on buffed parameter

I've been lurking on this forum for a while but this is my first time posting. I'm only vaguely familiar with Javascript code so, if this is possible at all, I have no idea how to do it.

I've been directly editing my game's main .js files in order to change some battle log messages depending on different variables (item ID, amount of party members, etc). This is because my game is in Spanish and some words (articles and verbs) change depending on the number and gender of the subject.

The last messages I'd like to edit are those that appear whenever a battler receives a buff, debuff, or they're removed. I believe this is handled by these lines of code in windows.js.

1725304891590.png


I'd like to use a different message when the buff/debuff affects certain parameters (let's say, for example, only luck and agility), and default to the regular database terms for the rest. To be specific, I only want to switch the first word of the database message depending on the parameter. I know each of them has an ID that ranges from 0 to 7, but that's it.

Again, not sure if this is possible without a plugin, but I'll gladly use one if it exists. Any help is greatly appreciated. Thank you!
Welcome!

I've been directly editing my game's main .js files in order to change some battle log messages
Just as a tip, this is very bad practice (which you should probably have seen in lots of threads here while lurking 😛 ).
- It makes it impossible to track your changes unless you're also keeping some kind of list
- It causes anything you change to get overwritten if the editor gets a new version
- It causes any changes you made to get completely overwritten by all actual plugins

You should always change things by copying the function into a new *.js file, modifying it, then installing that as a plugin.

Again, not sure if this is possible without a plugin
Anything that's not a setting in the database requires a plugin.

The last messages I'd like to edit are those that appear whenever a battler receives a buff, debuff, or they're removed. I believe this is handled by these lines of code in windows.js.
Those are just function calls, so you'd edit the function they're calling.

Code:
Window_BattleLog.prototype.displayBuffs = function(target, buffs, fmt) {
    buffs.forEach(function(paramId) {
        this.push('popBaseLine');
        this.push('pushBaseLine');
// Adding this for agility
        if (paramId == 6)
        {
            let buffTxt;
            if (fmt == TextManager.buffAdd)
                buffTxt = "Agility add message";
            else if (fmt == TextManager.debuffAdd)
                buffTxt = "Agility debuff add message";
            else
                buffTxt = "Agility remove message";
            this.push("addText", buffTxt.format(target.name(), TextManager.param(paramId)));
        }
// Adding this for luck
        else if (paramId == 7)
        {
            let buffTxt;
            if (fmt == TextManager.buffAdd)
                buffTxt = "Luck add message";
            else if (fmt == TextManager.debuffAdd)
                buffTxt = "Luck debuff add message";
            else
                buffTxt = "Luck remove message";
            this.push("addText", buffTxt.format(target.name(), TextManager.param(paramId)));
        }
        else
            this.push('addText', fmt.format(target.name(), TextManager.param(paramId)));
    }, this);
};

Again, you should paste the above into a text editor, save it as a *.js file, type the messages how you like, then include as a plugin.
Thank you! I'm aware that editing the main files is generally considered bad practice, yes. I keep a copy of those edited files just to make sure the progress isn't lost in any way, and these are half a dozen changes at most, so I know where they are. I'll see if making a plugin keeps things working as intended. (My little knowledge of Javascript meant I didn't know plugins could be this simple).

Thanks for your code as well. I'll come back if for some reason I can't make it work.

Welcome!


Just as a tip, this is very bad practice (which you should probably have seen in lots of threads here while lurking 😛 ).
- It makes it impossible to track your changes unless you're also keeping some kind of list
- It causes anything you change to get overwritten if the editor gets a new version
- It causes any changes you made to get completely overwritten by all actual plugins

You should always change things by copying the function into a new *.js file, modifying it, then installing that as a plugin.


Anything that's not a setting in the database requires a plugin.


Those are just function calls, so you'd edit the function they're calling.

Code:
Window_BattleLog.prototype.displayBuffs = function(target, buffs, fmt) {
    buffs.forEach(function(paramId) {
        this.push('popBaseLine');
        this.push('pushBaseLine');
// Adding this for agility
        if (paramId == 6)
            this.push("addText", fmt.format(target.name(), "Different message here"));
// Adding this for luck
        else if (paramId == 7)
            this.push("addText", fmt.format(target.name(), "Other message here"));
        else
            this.push('addText', fmt.format(target.name(), TextManager.param(paramId)));
    }, this);
};

Again, you should paste the above into a text editor, save it as a *.js file, type the messages how you like, then include as a plugin.
Copying all of my previous changes into a plugin and adding it worked perfectly. I'm a little confused about the code you provided, though, since it seems to affect all three buff messages at once (added buff, added rebuff and removed both). Is there a way to modify them individually?

It seems like the 'Different message here' text replaces the name of the parameter in the message, which shows as %2 in the database. I can try and work with that, but I was hoping to change the parts of the message that arent %1 or %2 through the plugin. Sorry for the trouble and thanks again!
Oh, I see what I did wrong.

I've corrected my post above - you should be able to fill in those six messages, using %1 and %2 as you would in the database strings.
Had to clean it a bit but it works perfectly now. Thank you very much!!

Original thread: https://forums.rpgmakerweb.com/threads/change-battle-log-messages-depending-on-buffed-parameter.171625/