Changebattle log state message depending on affected actor or enemy

Following from my previous request (Thanks, ATT_Turan!) there is one more change I'd like to do to my game's battle log messages. When an enemy or actor is affected by a state, certain messages appear during combat. However, since my game is in Spanish, the adjectives used in those messages end differently depending on the gender of the actor or enemy. It's '-o' for masculine and '-a' for femenine ones. The database only lets me do this:

1725382849280.png


I'd like to make a plugin that would change the message depending on the gender of the affected battler. Since every gendered state ends in the same way ("o/a!"), I thought the most efficient way to do it would be by removing that part of the message from the database, then adding 'o!' or 'a!' depending on the battler.

This would be done for all three functions: 'displayAddedStates', 'displayCurrentStates' and 'displayRemovedStates', unless there's a blank space. The first one doesn't need to draw a different message depending on whether an actor or enemy is affected, because the 'inflicted' message is always the same.

I only need to change about 20 states, and there's a dozen female actors, so I figured I can just use IDs to identify those. There's a looot of enemies, however, and others have recommended the use of notetags to identify female enemies. ...I don't know how to use them, though, so I'd need some help!

I assume the code needs to look something like this, with small changes depending on the function. In this example, I'm changing the 'inflicted' text of states 4, 5 and 6. Otherwise, it uses the normal message from the database.

if ([4,5,6].indexOf(state.id) > -1) {
if (actor is female || enemy is female) {this.push('addText', subject.name() + stateMsg + 'a!'}
else {this.push('addText', subject.name() + stateMsg + 'o!'}
} else {this.push('addText', subject.name() + stateMsg};
this.push('waitForEffect');

I'd appreciate some help to get this working. Sorry for the long post!
Paste the below into a text editor, save as a *.js file, include as a plugin.

Code:
Window_BattleLog.prototype.displayAddedStates = function(target) {
    target.result().addedStateObjects().forEach(function(state) {
        var stateMsg = target.isActor() ? state.message1.format(target.actor().meta.stategender)
                                                             : state.message2.format(target.enemy().meta.stategender);
        if (state.id === target.deathStateId()) {
            this.push('performCollapse', target);
        }
        if (stateMsg) {
            this.push('popBaseLine');
            this.push('pushBaseLine');
            this.push('addText', target.name() + stateMsg);
            this.push('waitForEffect');
        }
    }, this);
};

Game_Actor.prototype.showRemovedStates = function() {
    this.result().removedStateObjects().forEach(function(state) {
        if (state.message4) {
            $gameMessage.add(this._name + state.message4.format(this.actor().meta.stategender));
        }
    }, this);
};

You would include %1 in your state messages where the ending changes, e.g.
está envenanad%1

Then all your actors and enemies must have a stategender notetag with the correct ending, e.g. <stategender:a>
Hakuen Studio/Eli Message Actions lets you put code in those fields
Paste the below into a text editor, save as a *.js file, include as a plugin.

Code:
Window_BattleLog.prototype.displayAddedStates = function(target) {
    target.result().addedStateObjects().forEach(function(state) {
        var stateMsg = target.isActor() ? state.message1.format(target.actor().meta.stategender)
                                                             : state.message2.format(target.enemy().meta.stategender);
        if (state.id === target.deathStateId()) {
            this.push('performCollapse', target);
        }
        if (stateMsg) {
            this.push('popBaseLine');
            this.push('pushBaseLine');
            this.push('addText', target.name() + stateMsg);
            this.push('waitForEffect');
        }
    }, this);
};

Game_Actor.prototype.showRemovedStates = function() {
    this.result().removedStateObjects().forEach(function(state) {
        if (state.message4) {
            $gameMessage.add(this._name + state.message4.format(this.actor().meta.stategender));
        }
    }, this);
};

You would include %1 in your state messages where the ending changes, e.g.
está envenanad%1

Then all your actors and enemies must have a stategender notetag with the correct ending, e.g. <stategender:a>

Thanks again! I've tried the displayAddedStates function and it works without any issues.

Is the RemovedStates one correct too? From what I've seen, removed states work in a very similar way in the battle log. The 'showRemovedStates' function isn't present in rpg_windows, but in rpg_objects instead.

I've just tried it, and it doesn't seem to work when a state is removed.

If you could also share a function for when the state persists (displayCurrentState, I believe?) I would be super thankful.

1725391724483.png
Looks like the one I pasted above is used for when states expire while you're walking on the map.

For battle expiring, copy the function you provided a screenshot of there, and modify the addText in the same way I did above:
Code:
state.message4.format(this.actor().meta.stategender)
Looks like the one I pasted above is used for when states expire while you're walking on the map.

For battle expiring, copy the function you provided a screenshot of there, and modify the addText in the same way I did above:
Code:
state.message4.format(this.actor().meta.stategender)
Like this, yes?

JavaScript:
Window_BattleLog.prototype.displayRemovedStates = function(target) {
    target.result().removedStateObjects().forEach(function(state) {
        if (state.message4) {
            this.push('popBaseLine');
            this.push('pushBaseLine');
            this.push('addText', target.name() + state.message4.format(this.actor().meta.stategender));
        }
    }, this);
};

I can't get it to work for some reason. Does it work for enemies as well? I'm checking the script by watching an enemy heal from a poisoned status.
Enemies aren't actors so that script as is wouldn't work for enemies
Does it work for enemies as well?
No - I didn't think that message displayed for enemies.

Do this:

Code:
Window_BattleLog.prototype.displayRemovedStates = function(target) {
    target.result().removedStateObjects().forEach(function(state) {
        if (state.message4) {
            this.push('popBaseLine');
            this.push('pushBaseLine');
            this.push('addText', target.name() + state.message4.format(target.isActor() ? target.actor().meta.stategender : target.enemy().meta.stategender));
        }
    }, this);
};
Thank you both for your help, but it seems like it still doesn't want to work... I'm sorry to keep you thinking.
Unlike 'displayAddedStates', this function uses the same message for both actor and enemy, so does it actually differentiate between the two? Is it posible that it uses another variable to define the target?

No matter what I do, the state end text doesn't change even if I delete parts of "Add Text". I'll have to investigate if there's any other function that has control over this message.

No - I didn't think that message displayed for enemies.

Do this:

Code:
Window_BattleLog.prototype.displayRemovedStates = function(target) {
    target.result().removedStateObjects().forEach(function(state) {
        if (state.message4) {
            this.push('popBaseLine');
            this.push('pushBaseLine');
            this.push('addText', target.name() + state.message4.format(target.isActor() ? target.actor().meta.stategender : target.enemy().meta.stategender));
        }
    }, this);
};

Ok, nevermind, this works perfectly. Thank you. I've tested it in a new project and it does the job. There's something in my current game that's interfering, and that's up to me to figure out. It's not actually *my* game; I'm translating someone else's project, and I'm not familiar with what all the already installed plugins do. Even if I put my plugin at the top, nothing changes.

Would the code be different with 'displayCurrentState'? I tried making it myself using your code as reference but it crashes the game.

Nevermind again, my bad. Here's the code in case anyone ever needs it:

JavaScript:
Window_BattleLog.prototype.displayCurrentState = function(subject) {
    var stateText = subject.mostImportantStateText();
    if (stateText) {
        this.push('addText', subject.name() + stateText.format(subject.isActor() ? subject.actor().meta.stategender : subject.enemy().meta.stategender));
        this.push('wait');
        this.push('clear');
    }
};
@cutestlesbian Please keep in mind that modifying some else's game without the dev's permission is against forum rules. If you do not have written permission then you won't be able to get help here.
@cutestlesbian Please keep in mind that modifying some else's game without the dev's permission is against forum rules. If you do not have written permission then you won't be able to get help here.
I have the dev's permission and they have helped me write some of the changes the plugin makes. Sorry if that wasn't clear.

Original thread: https://forums.rpgmakerweb.com/threads/changebattle-log-state-message-depending-on-affected-actor-or-enemy.171643/