How to make battlelog include name of the target?

For example, If I wanted the battlelog to say to say "casts heal on target A" when using the skill on target A but "casts heal on target B" when using the skill on target B, how would I do this, I found a few older forum posts about the issue but I wasn't able to get anything to work. Here are those forum posts.

what what have you tried and happens when you do the second? given the response it got i have to reason to believe that it doesnt work
I think I'm just using it wrong. I downloaded the javascript and put it in with the rest of the plugins but I have no idea how to get it to work.
and i have no idea where you went wrong without you showing what youve done
I downloaded it and put it in the plugins folder. It says something about editing it in notepad but I don't know what to edit.
a little JS knowledge is needed, but not much. just enough to concatenate a string. Kenan commented between the parts that should be touched. any line that begins with // isnt code. its something written for you to read
Code:
        // Begin skill config; do not edit above this line
        // Start custom messages for skill id 11
        if (item.id === 11) {
            // This will print as "Harold gestures aggresively at the Slime A"
            var message1 = subject + " gestures aggressively at the " + target;
            // This will print as "The Slime A is now solely focused on Harold!"
            var message2 = "The " + target + " is now solely focused on " + subject + "!";
            customText = true;
        }
        // End custom messages for skill id 11
        // Repeat here for skills as desired, e.g. if (item.id === 12)
        // End skill config; do not edit below this line
so that outlines a message for skill #11. if you needed to add one for skill #13, youd add to it so that it looks like this
Code:
        // Begin skill config; do not edit above this line
        // Start custom messages for skill id 11
        if (item.id === 11) {
            // This will print as "Harold gestures aggresively at the Slime A"
            var message1 = subject + " gestures aggressively at the " + target;
            // This will print as "The Slime A is now solely focused on Harold!"
            var message2 = "The " + target + " is now solely focused on " + subject + "!";
            customText = true;
        }
        // End custom messages for skill id 11
        // Repeat here for skills as desired, e.g. if (item.id === 12)
        else if (item.id === 13) {
            // This will print as "Harold says a healing prayer for Slime A"
            var message1 = subject + " says a healing prayer for " + target;
            // This will print as "Slime A's wounds begin to close!"
            var message2 = target + "'s wounds begin to close!";
            customText = true;
        }
        // End skill config; do not edit below this line
So I just use this for every skill I want to have custom text instead of using the skill message thing in the editor?
yeah. its not the most convenient, but its not difficult to do.
Did you try either of the other ones that would simply allow you to use %2 in the skill messages?
Did you try either of the other ones that would simply allow you to use %2 in the skill messages?
I tried this one, but it didn't work. Probably because it's for MZ and not MV. If there's a plugin like this for MZ, it would be a lot easier.

//=============================================================================
// RPG Maker MZ - Include the target of a skill in the message
//=============================================================================

/*:
* @target MV
* @plugindesc Include the target of skill in the message
* @Author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/ItemTargetInMessage.js
* @orderAfter SpeakInBattle
*
* @Help ItemTargetInMessage.js
*
* This plugin expands feature of the message shown when using skills.
* Write %3 in the message to include the target's name.
* If more than one target, the message could be redundant.
*
* It does not provide plugin commands.
*
* Changelog
* 23 Sept 2020: Update summary: There isn't message setting for items.
* 23 Sept 2020: First edition.
*/

/*:ja
* @target MV
* @plugindesc スキルのターゲットをメッセージに入れられるようにする
* @Author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/ItemTargetInMessage.js
*
* @Help ItemTargetInMessage.js
*
* このプラグインは、スキルを使用したときのメッセージを拡張します。
* スキルのメッセージに %3 と書くことで対象の名前を含めることができます。
* 対象が複数の場合はメッセージが冗長になります。
*
* プラグインコマンドはありません。
*
* 更新履歴
* 令和2年9月23日 説明を修正。アイテムにメッセージ設定はありません。
* 令和2年9月23日 初版
*/

(() => {

Window_BattleLog.prototype.displayItemMessage = function(fmt, subject, item) {
if (fmt) {
//this.push("addText", fmt.format(subject.name(), item.name));
this.push("addText", fmt.format(subject.name(), item.name,
BattleManager._targets.map(t => t.name()).join(
Boolean($dataSystem.locale.match(/^ja[^[:alpha:]]?/)) ? "、" : ",")));
}
};

})();

yeah. its not the most convenient, but its not difficult to do.
I half got it to work. I don't want the Varmessage.2 part but if I delete that part of code I get an error message whenever the text plays.
if you do the way of Robro33, than I would rather create a struct, and built it
in there, so the code is small and the rest is through the parameter 🙂

or you end up with a huge list of id's 😛


Edit:

Boolean should be avoided and use JSON.parse instead.
That's not the code from the first thread you linked. I also found other threads like this for MV when I did a search - this has come up several times before.

@ShadowDragon That's why that's really not a good way to do it at all.

For the sake of anyone who comes across this thread, it's really a pretty simple addition. Copy the below into a text editor, save as a *.js file, include as a plugin:
Code:
Window_BattleLog.prototype.displayAction = function(subject, item) {
    var numMethods = this._methods.length;
    if (DataManager.isSkill(item)) {
        if (item.message1) {
            this.push('addText', subject.name() + item.message1.format(item.name, BattleManager._targets[0].name()));
        }
        if (item.message2) {
            this.push('addText', item.message2.format(item.name, BattleManager._targets[0].name()));
        }
    } else {
        this.push('addText', TextManager.useItem.format(subject.name(), item.name));
    }
    if (this._methods.length === numMethods) {
        this.push('wait');
    }
};

Then using %2 in the skill message will display the target.
That's not the code from the first thread you linked. I also found other threads like this for MV when I did a search - this has come up several times before.

@ShadowDragon That's why that's really not a good way to do it at all.

For the sake of anyone who comes across this thread, it's really a pretty simple addition. Copy the below into a text editor, save as a *.js file, include as a plugin:
Code:
Window_BattleLog.prototype.displayAction = function(subject, item) {
    var numMethods = this._methods.length;
    if (DataManager.isSkill(item)) {
        if (item.message1) {
            this.push('addText', subject.name() + item.message1.format(item.name, BattleManager._targets[0]));
        }
        if (item.message2) {
            this.push('addText', item.message2.format(item.name, BattleManager._targets[0]));
        }
    } else {
        this.push('addText', TextManager.useItem.format(subject.name(), item.name));
    }
    if (this._methods.length === numMethods) {
        this.push('wait');
    }
};

Then using %2 in the skill message will display the target.
When I use this, the message plays until the target name part at which point it prints as "undefined"
Im 100% suggesting Turan's solution as it'd be much easier, but for the record...
I don't want the Varmessage.2 part but if I delete that part of code I get an error message whenever the text plays.
you'd make it an empty string instead of deleting it then
Code:
var message2 = ""
When I use this, the message plays until the target name part at which point it prints as "undefined"
Then something else is wrong in your project. I did have a mistake in the code, which I corrected, but it should be impossible for your target to be undefined.

Paste the corrected code from above into the plugin, then if it doesn't show correctly, include a screenshot of your skill entry from the database.

Make sure you're always starting a new play test when installing or changing plugins.
Then something else is wrong in your project. I did have a mistake in the code, which I corrected, but it should be impossible for your target to be undefined.

Paste the corrected code from above into the plugin, then if it doesn't show correctly, include a screenshot of your skill entry from the database.

Make sure you're always starting a new play test when installing or changing plugins.
Thank you the updated code worked.
I guess I'm glad, but the error you reported still should've been impossible. If the target was undefined, me fixing it to specify the name of the target wouldn't have fixed it, it would've crashed your game.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-battlelog-include-name-of-the-target.172723/