MV/MZ displayActions

Hi helpers,

I try to upgrade my BattleMessages plugin, but I stump into a weird confusion how exactly
the TextManager.useItem is called and where it is set up.

the original code for MV is like this (unsure for MZ)
JavaScript:
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));
        }
        if (item.message2) {
            this.push('addText', item.message2.format(item.name));
        }
    } else {
        this.push('addText', TextManager.useItem.format(subject.name(), item.name));
    }
    if (this._methods.length === numMethods) {
        this.push('wait');
    }
};

so I alias this code, but the code like the next one
JavaScript:
this.push('addText', TextManager.useItem.format(subject.name(), item.name));

has somewhere called like: subject.name() + " uses " + item.name but I cannot find
where this "uses" come from and how exactly is set, only the getter, but altering for the item use,
doesn't seem to work in any.

I did so, for the skill without issues, which does it job, the code I use for that part is as follows (if relevant)
JavaScript:
     SDJB_Base["BMsg"].processBattleNotetags = function(subject, item) {
        if (!item?.note) return;
        const msgMatch = item.note.match(/<Custom Battle Text>([\s\S]*)<\/Custom Battle Text>/im);
        if (msgMatch) {
            let msg1 = "";
            let msg2 = "";
            const target = item;
            const user = subject;
            const a = subject;
            const s = $gameSwitches._data;
            const v = $gameVariables._data;
            try {
                eval(msgMatch[1]);
                target.message1 = msg1;
                target.message2 = msg2;
            } catch (e) {
                console.error("Error in processing custom eval text:", e, target);
            }
        }
    };

this called allias is called inside the displayAction.
so what do I miss, and where do I find the TextManager to make it work too as it always return
subject.name() uses item.name but question, where is that being drawn?
Are you referring to
Code:
$dataSystem.terms.messages.useItem
which is referenced in the Database: Terms: Messages?
not exactly terms, entire text like:

user.name() took a sip and get dizzy

or alone those lines, and those can be different for each
item rather than "user.name() uses item.name" (default)
so it can be anything if they pleases or check actor ID for it so
each actor say something else when using it (or on someone else).

for skills its working, but it doesn't for items which I hoped for.
not exactly terms, entire text like:

user.name() took a sip and get dizzy

or alone those lines, and those can be different for each
item rather than "user.name() uses item.name" (default)
so it can be anything if they pleases or check actor ID for it so
each actor say something else when using it (or on someone else).

for skills its working, but it doesn't for items which I hoped for.
I believe Items do not have message 1 or message 2, only Skills.

You would need to change the $dataSystem.terms.messages.useItem string to come up with a specific text or to change it on the fly whenever you need.

here is just a quick injection via devtools:
s1.png


You would have to use your note tag method to reference the item notetag instead.
than I try add in the dataSystem to see what it does.
as I couldn't find that part anywhere as for victory, losing,
surprise, I didn't use the dataSystem at all, so I find it weird
that items didn't take effect.

edit:
direct action to change throws an error, so how is textManager used
other wise to make it effective?
Here's what I have, if it is somewhat close to what you are referring to:
JavaScript:
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));
        }
        if (item.message2) {
            this.push('addText', item.message2.format(item.name));
        }
    } else {
        const text = item.meta.customMessage === '' || !item.metaCustomMessage
                   ? TextManager.useItem
                   : item.meta.customMessage.trim();
        this.push('addText',text.format(subject.name(), item.name));
    }
    if (this._methods.length === numMethods) {
        this.push('wait');
    }
};
s1.png


s2.png


Other items default to the TextManager.

(Edit: sorry, some of the code needed some small changes to prevent errors. Updated now.)
I want to use the same notetag I used between text.
but otherwise, it can do the trick if I do need to override the function.
so I will check tomorrow for a implantation to use the same way
for simplicity, but this does help though and play around.

so BattleMessage plugin I have gets more control over how it is
being used as it has another to feature added, so it a nice plugin
once everything works 🙂 (will credit for the help if you want).
I want to use the same notetag I used between text.
but otherwise, it can do the trick if I do need to override the function.
so I will check tomorrow for a implantation to use the same way
for simplicity, but this does help though and play around.

so BattleMessage plugin I have gets more control over how it is
being used as it has another to feature added, so it a nice plugin
once everything works 🙂 (will credit for the help if you want).
Very cool! Yes, I am certain you can utilize your plugin for this. I am almost sure it is just a few methods, if that, to get it to take care of thr text manager and alternate texts.

If you have screenshots of what your pkygin needs and is doing (note tags, etc.) that would help to if you are sharing info.

I was just building a proof of concept with the minimum effort/time I have haha.

I'll try and see if I can take a better look on a different day, assuming you haven't already figured it out for what you have.

Thanks!
I was just building a proof of concept with the minimum effort/time I have haha.
I noticed, but the use for skills (and hopefully soon for items use:


JavaScript:
// skill / item notetag

<Custom Battle Text>
if (user.isStateAffected(3)) {
    msg = `${user.name()} got sick using ${item.name} // or target.name
    user.gainHp(-100)`
} 
</Custom Battle Text>

this is than 1 little example for item usage, skill can create an array
for basic attack: " attack!", " swing it blade" etc
or sword, axe (if you check equiped weapon, or actor to get the random
message, you are able to set multiple of those inside the notetag.

so my endgoal for this part if items works too, full control over battle messages.
so you have victory, escape (success, failed), defeated etc.

so it seems cool to add this nice features.

Edit:
I got a nice work around to respect both, to keep as minimal as possible.

Thanks for the idea on meta, but found a otherway, but it has came to an idea
on the format though that I could use to respect the processBattleNotetags =)

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/displayactions.179007/