Target Name in Battle Log Plugin Issues

Hi, I'm using a script from this forum to insert the target's name in skill messages.
The problem is that whenever the skill has multiple targets "Type Error: undefined is not a function" shows up.
I'd really appreciate it if someone could find a solution for me.

Here is the code I'm using (by Rexal):
Code:
Window_BattleLog.prototype.startAction = function(subject, action, targets) {var item = action.item();this.push('performActionStart', subject, action);this.push('waitForMovement');this.push('performAction', subject, action);this.push('showAnimation', subject, targets.clone(), item.animationId);this.displayAction(subject, item,targets);};Window_BattleLog.prototype.displayAction = function(subject, item,targets) {var numMethods = this._methods.length;    var target = "";    for(var i = 0; i<targets.length-1; i++){    if(i!=0)target += ', '+ targets.name();    else target += targets.name() + " ";    }    if(targets.length!=1)target += 'and ' + targets[targets.length-1].name(); else target += targets[0].name();    if (DataManager.isSkill(item)) {if (item.message1) {this.push('addText', subject.name() + item.message1.format(item.name,target));}if (item.message2) {this.push('addText', item.message2.format(item.name,target));}} else {this.push('addText', TextManager.useItem.format(subject.name(), item.name,target));}if (this._methods.length === numMethods) {this.push('wait');}};

if(Imported.YEP_BattleEngineCore){        BattleManager.actionDisplayAction = function() {    this._logWindow.displayAction(this._subject, this._action.item(), this._targets);    return false;};Window_BattleLog.prototype.startAction = function(subject, action, targets) {};Yanfly.BEC.Window_BattleLog_displayAction = Window_BattleLog.prototype.displayAction;Window_BattleLog.prototype.displayAction = function(subject, item,targets) {    if (eval(Yanfly.Param.BECFullActText)) {      Yanfly.BEC.Window_BattleLog_displayAction.call(this, subject, item,targets);    } else {      this._actionIcon = item.iconIndex;      this.push('addText', '<SIMPLE>' + item.name);      if (item.message2) {        this.push('addText', '<CENTER>' + item.message2.format(item.name));      }    }};}
You'll never be able to use that way or script with multiple targets.
Replacement strings like "casts %1 on %2" require a specific number of replacement segments, and with multiple targets they can't know in advance how many targets will there be.

You'll need a much more complex plugin for a variable number of output texts.
For the multiple targets skills, I was planning on not including the "%2" and to just write a message like "User sends meteors crashing down".
I think that means the script doesn't need to know more strings...?
Even when I do that it still doesn't like multiple targets...

I was thinking maybe a quick fix was to implement something that tells the script to "turn off" when a skill has multiple targets so that it doesn't crash. I'm not sure how to go about this though since I'm still learning how to write JavaScript.

Maybe this forum should be in the requests actually, considering I'm looking for someone to code this for me...
That is because even the number of placeholders need to be pre-programmed and removing one from the message causes errors as well...
I'm not sure how to fix it then >m<;
I think I'll go post this on the plugin requests.
Chances you still need this are slim, but if anyone else comes across this thread while looking for a solution, here it is:

JavaScript:
Window_BattleLog.prototype.startAction = function(subject, action, targets)
{var item = action.item();this.push('performActionStart', subject, action);
this.push('waitForMovement');this.push('performAction', subject, action);
this.push('showAnimation', subject, targets.clone(), item.animationId);
this.displayAction(subject, item,targets);
}
;Window_BattleLog.prototype.displayAction = function(subject, item, targets)
{var numMethods = this._methods.length;   
var target = "";   
for(var i = 0; i<targets.length-1; i++){   
if(i!=0)target += ', ';   
else ;   
}   
if(targets.length!=1)target += '' + targets[targets.length-1].name();
else target += targets[0].name();   
if (DataManager.isSkill(item))
{if (item.message1)
{this.push('addText', subject.name() + item.message1.format(item.name,target));
}
if (item.message2) {this.push('addText', item.message2.format(item.name,target));}}
else {this.push('addText', TextManager.useItem.format(subject.name(), item.name,target));}
if (this._methods.length === numMethods)
{this.push('wait');}
};

if(Imported.YEP_BattleEngineCore){       
BattleManager.actionDisplayAction = function() {   
this._logWindow.displayAction(this._subject, this._action.item(), this._targets);   
return false;};Window_BattleLog.prototype.startAction = function(subject, action, targets) {};
Yanfly.BEC.Window_BattleLog_displayAction = Window_BattleLog.prototype.displayAction;Window_BattleLog.prototype.displayAction = function(subject, item,targets)
{   
if (eval(Yanfly.Param.BECFullActText))
{     
Yanfly.BEC.Window_BattleLog_displayAction.call(this, subject, item,targets);   
} else {     
this._actionIcon = item.iconIndex;     
this.push('addText', '<SIMPLE>' + item.name);     
if (item.message2) {       
this.push('addText', '<CENTER>' + item.message2.format(item.name));     
}   
}
};
}

Basically, in this version, if there is more than one target, it won't attempt to add any target names to the message.

The downside is that you will not be able to use %2 in hit-all skill messages, but I don't think it's important to list the target names in those types of skills anyway.
Basically, in this version, if there is more than one target, it won't attempt to add any target names to the message.

The downside is that you will not be able to use %2 in hit-all skill messages, but I don't think it's important to list the target names in those types of skills anyway.

By modifying Rexal's code I was able to get something to work... I can't promise this is a very stable plugin, as I didn't test it much. But it does work for target-all skills. (The default skill Spark hits all enemies).

I also did see "Type Error: undefined is not a function" a few times, but I think I ironed that out. (Hopefully...)

Original thread: https://forums.rpgmakerweb.com/threads/target-name-in-battle-log-plugin-issues.91540/