MZ How to edit this plugin so the animation stops when the dialogue stops?

Last year I discovered this fabulous plugin by nz_prism that lets you display AND animate full body character portraits! I’ve already created several cutscenes using it.

Here is the JavaScript, which is available for free.


Here are some cutscene examples, so you can see what I'm doing:

The Tumblr links aren't working, so I'll post them the old-fashioned way:
Animation Example 1
Animation Example 2

This plugin is amazing, but has one significant problem. After you click to advance the dialogue, the character who is speaking keeps moving until a specified number of frames passes. Then the next character begins speaking, but the first character may still be moving. When filming my videos, I have to wait until one character stops moving before I advance the dialogue, but I don’t think most players would have the patience for that. At the same time, I want the animations to sync relatively well with the dialogue.

I think I found a solution that will work with this plugin, but I don’t know how to properly implement it. The plugin has a feature where characters who are not speaking are grayed out. I wonder if it is also possible to make characters who are not speaking stop moving. Can anyone help with this?

If it helps, I found what I think is the code that causes the speaker to gray out when it finishes speaking. This starts at Line 1741.


Game_MessagePicture.prototype.updateSpeaking = function() {

const isSpeaking = this.isSpeaking();

if (this._isSpeaking !== isSpeaking) {

this._isSpeaking = isSpeaking;

if (isSpeaking) {

this._z = 6;

this.tint(this._originalTone, DEACTIVE_FRAMES);

} else {

this._z = 5;

this._originalTone = this._tone.clone();

this.tint(DEACTIVE_TONE, DEACTIVE_FRAMES);

}

}

};
Hello, anyone? I would greatly appreciate help with this.
Well, I took a look at the code of the plugin in question. It's quite difficult to debug this way, as it all depends on how you've set up the pictures of the animated busts via the ActorPictures.js plugin, which apparently drives the animations.

Code:
* The actor pictures aren't erased automatically at the end of the
 * messages. Use a plugin command "Erase Picture" to erase them.
 * It can erase an individual picture or all the pictures at once.
 *
 * Pictures can be animated. If plugin parameters of ActorPictures.js
 * are set, the pictures will be animated while they are displayed.

What's more, apart from detecting the \AP[nPOSITION] code in the message when a speaker is actualised (Game_Message.prototype.setSpeakerName), at no point in the plugin's code is there a trigger that detects the closure of the message window, which would stop the picture animation.

To put it another way, the pictures of the animated busts are displayed and run independently of the message window display. The only trigger is when a new message is displayed, which changes the focus to a new speaker... at least, that's what I understand from reading the plugin code.

However, a solution worth testing would be to:
  1. change the order in which the update functions are called, putting this.updateAnimation(); after this.updateSpeaking();
  2. change the if (this._hasAnimation) condition to if (this._hasAnimation && this._isSpeaking), as in principle the animation should only run when the actor is speaking.
Code:
    Game_MessagePicture.prototype.update = function() {
        Game_Picture.prototype.update.call(this);
        if (!this.isMoving()) {
            this.updateSpeaker();
            this.updateAnimation();    <= CHANGE ORDER
            this.updateSpeaking();
        }
    };

    Game_MessagePicture.prototype.updateAnimation = function() {
        if (this._hasAnimation) {   <= CHANGE CONDITION
            this._animationCount += this._animationPatternCounts[this._pattern];
            if (this._animationCount >= this._animationRepeatDurations[this._animationRepeatIndex]) {
                this._pattern = (this._pattern + 1) % this._animationNumPattern;
                this._animationCount = 0;
                if (this._pattern === 0) {
                    this._animationRepeatIndex++;
                    if (this._animationRepeatIndex >= this._animationNumRepeat) this._animationRepeatIndex = 0;
                }
            }
        }
    };

See if it works... and let me know.
Well, I took a look at the code of the plugin in question. It's quite difficult to debug this way, as it all depends on how you've set up the pictures of the animated busts via the ActorPictures.js plugin, which apparently drives the animations.

Code:
* The actor pictures aren't erased automatically at the end of the
 * messages. Use a plugin command "Erase Picture" to erase them.
 * It can erase an individual picture or all the pictures at once.
 *
 * Pictures can be animated. If plugin parameters of ActorPictures.js
 * are set, the pictures will be animated while they are displayed.

What's more, apart from detecting the \AP[nPOSITION] code in the message when a speaker is actualised (Game_Message.prototype.setSpeakerName), at no point in the plugin's code is there a trigger that detects the closure of the message window, which would stop the picture animation.

To put it another way, the pictures of the animated busts are displayed and run independently of the message window display. The only trigger is when a new message is displayed, which changes the focus to a new speaker... at least, that's what I understand from reading the plugin code.

However, a solution worth testing would be to:
  1. change the order in which the update functions are called, putting this.updateAnimation(); after this.updateSpeaking();
  2. change the if (this._hasAnimation) condition to if (this._hasAnimation && this._isSpeaking), as in principle the animation should only run when the actor is speaking.
Code:
    Game_MessagePicture.prototype.update = function() {
        Game_Picture.prototype.update.call(this);
        if (!this.isMoving()) {
            this.updateSpeaker();
            this.updateAnimation();    <= CHANGE ORDER
            this.updateSpeaking();
        }
    };

    Game_MessagePicture.prototype.updateAnimation = function() {
        if (this._hasAnimation) {   <= CHANGE CONDITION
            this._animationCount += this._animationPatternCounts[this._pattern];
            if (this._animationCount >= this._animationRepeatDurations[this._animationRepeatIndex]) {
                this._pattern = (this._pattern + 1) % this._animationNumPattern;
                this._animationCount = 0;
                if (this._pattern === 0) {
                    this._animationRepeatIndex++;
                    if (this._animationRepeatIndex >= this._animationNumRepeat) this._animationRepeatIndex = 0;
                }
            }
        }
    };

See if it works... and let me know.

I added in those lines of script and now the plugin works perfectly! Thank you very much! You're a lifesaver. :LZSexcite:

When the dialogue is advanced, the portrait animation stops on whatever frame of the character animation was active. Not only does this make the animations look much cleaner, but it also means I can have each set of frames play indefinitely. This means when a character speaks again, I don't have to change that character's expression to make a new set of animation frames play. In other words, I can keep a character's expression the same for as long as I want without the animation stopping.

It's fairly late where I am, but I'll post some test videos in the near future!
Glad I could help. 👋

I don't know if the author of this plugin is still in business, but it might be worth contacting him to suggest these adjustments. This will save you having to redo them in the event of an update.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-edit-this-plugin-so-the-animation-stops-when-the-dialogue-stops.153951/