Hover Tone Problem with VisuStella PictureCommonEvent

Hello everyone !

I’m having some trouble with the VisuStella PictureCommonEvent plugin.
When I hover my mouse over an image, it gets tinted white (which is expected behavior).

The issue is that if the mouse happens to be over the image when I remove both the image and the event (using “Clear Picture Common Event”), the color tint persists—meaning the image remains tinted white if I make it reappear.
Do you know how to fix this? It’s worth noting that this issue occurs even if I disable the “Change Tone on Hover” setting.

I’m wondering if the plugin only puts the tone back when the mouse moves off the picture, so clearing it while the cursor is still on top skips that step. What if you tried a Tint Picture on that same picture ID with 0, 0, 0, 0 and 0 frames right before you clear it, or right after you show it again?

Also, where did you turn off Change Tone on Hover? If it was in the plugin parameters but the picture gets its event from the Change Picture Common Event plugin command, I think that command’s own Custom settings might be the ones it’s using.

If neither of those helps, it might be worth reporting to VisuStella, since it seems to be happening inside the plugin.

Thanks for your reply !

I tried Tint Picture, but it does nothing, since I think the Tone Change is something inside the plugin who ignored the Tone Change code from RPG Maker.
Inside the plugin you can change the Change Tone parameter, but as I said, it does nothing, the hover remains saved and when you make reappear the picture, the Tone Change is back.

Thanks to serendipity, I’ve found a “”“solution”“” :

Right before clearing the picture, I trigger the appearance of another image—with the same ID—at the other end of the map, scaled to 1% of its original size. This ensures the plugin registers that the mouse was no longer over the image before it disappeared.
It’s definitely more of a bandage than anything else, but if anyone else is running into the same issue, know that this works.

If anyone has a more elegant solution, I’ll be happy to see it !

In your screenshot Use Global? is set to true. I’m wondering if that tells the command to ignore the Custom settings under it and use the Default Global Settings from the plugin parameters instead. That could explain why setting Change Tone on Hover to false there doesn’t do anything. What if you tried setting Use Global? to false on that command? If the tone never gets applied to that picture in the first place, maybe there won’t be anything left over to get stuck.

No that’s the point ; even if I unable the Default Global Settings and go for “Change Tone on Hover : False”, it doesn’t change anything. That’s pretty strange.
I think I’m gonna send an email to VisuStella. If I get an answer, I will update this topic.
In the meantime, if you have any other solutions, please don’t hesitate to share them (because it seems my bandage solution only works 1 out of 4 times…)

In the MZ core scripts, when a picture disappears the engine drops its hover state without ever calling onMouseExit. I’m wondering if that’s how Picture Common Events misses the moment it’s supposed to take the tone off, and the leftover tint is still there when the same picture ID gets shown again.

I put together a small plugin that might get around it without touching VisuStella’s code. It sets the picture back to its own tone unless the mouse has actually moved onto it since the last Show Picture. Save this as PictureHoverToneFix.js in your js/plugins folder and put it below VisuMZ_4_PictureCmnEvts in the Plugin Manager:

//=============================================================================
// PictureHoverToneFix.js
//=============================================================================

/*:
 * @target MZ
 * @plugindesc Keeps a picture's hover tint from sticking after the picture is erased and shown again.
 * @author Baz
 *
 * @param pictureIds
 * @text Picture IDs
 * @type number[]
 * @min 1
 * @default []
 * @desc Pictures this fix applies to. Leave empty to apply it to every picture.
 *
 * @help PictureHoverToneFix.js
 *
 * Place this plugin BELOW VisuMZ_4_PictureCmnEvts in the Plugin Manager.
 *
 * A picture is only allowed to keep a hover tint while the mouse has
 * actually moved onto it since the last Show Picture. Any other time, its
 * tone and blend mode are set back to the picture's own values, the same
 * ones Show Picture and Tint Picture control.
 *
 * There are no plugin commands.
 */

(() => {
    const params = PluginManager.parameters("PictureHoverToneFix");
    const pictureIds = JSON.parse(params.pictureIds || "[]").map(Number);

    const isFixedPicture = pictureId =>
        pictureIds.length === 0 || pictureIds.includes(pictureId);

    const _Sprite_Picture_update = Sprite_Picture.prototype.update;
    Sprite_Picture.prototype.update = function() {
        _Sprite_Picture_update.call(this);
        this.updateHoverToneFix();
    };

    Sprite_Picture.prototype.updateHoverToneFix = function() {
        const picture = this.picture();
        if (!picture || !this.visible || !isFixedPicture(this._pictureId)) {
            return;
        }
        // Show Picture always makes a new Game_Picture, so a new object
        // means the picture was just shown and starts out not hovered.
        if (this._hoverFixPicture !== picture) {
            this._hoverFixPicture = picture;
            this._hoverFixHovered = false;
        }
        if (!this.isBeingTouched()) {
            this._hoverFixHovered = false;
        } else if (TouchInput.isHovered()) {
            this._hoverFixHovered = true;
        }
        if (!this._hoverFixHovered) {
            this.setColorTone(picture.tone() || [0, 0, 0, 0]);
            this.blendMode = picture.blendMode();
        }
    };
})();

If you have other plugins that tint pictures, you can put just the IDs that need it in the Picture IDs parameter so it leaves the rest alone. I haven’t been able to try it with Picture Common Events, so let me know if the tint still sticks.

Wow, thank you so much for your help—I really appreciate it! Unfortunately, this has shifted the issue. The script does solve one problem: the image is no longer tinted when the mouse moves away! However, if I move the mouse back over the same image, the tint reappears, and if I click, the event doesn’t trigger—so while the event has indeed been detached from the image, the “Change Tone on Hover” function is still running in the background. The problem persists even if I disable the “Change Tone on Hover” feature.
It’s quite strange; your script detaches the hover effect from the image as soon as it disappears, yet the tone-changing function remains active, even though the event can no longer be triggered.

In other words, now the tint no longer persists indefinitely, but comeback everytime I hover it again, even if the picture is no longer linked to an event.

NB : The problem appears if I hover the picture and let the picture disapear befor I click on it and trigger the event. If I trigger the event before the picture disapear, the tone change problem is not here anymore.

The first version still let VisuStella’s tint through any time the mouse was over the picture, whether the picture still had a common event or not.

This version also keeps track of the Picture Common Events commands. After Clear or Erase & Clear, that picture ID won’t get a hover tint again until Change Picture Common Event gives it an event again. It also blocks the tint when that command has both Use Global? and Change Tone on Hover? set to false. You can take the 1% picture trick out too. Replace the whole file with this one:

//=============================================================================
// PictureHoverToneFix.js
//=============================================================================

/*:
 * @target MZ
 * @plugindesc Keeps a picture's hover tint from sticking after the picture is erased and shown again.
 * @author Baz
 *
 * @param pictureIds
 * @text Picture IDs
 * @type number[]
 * @min 1
 * @default []
 * @desc Pictures this fix applies to. Leave empty to apply it to every picture.
 *
 * @help PictureHoverToneFix.js
 *
 * Place this plugin BELOW VisuMZ_4_PictureCmnEvts in the Plugin Manager.
 *
 * A picture only keeps a hover tint while the mouse has actually moved
 * onto it since the last Show Picture.
 *
 * After Clear Picture Common Event, Erase & Clear Picture, or either of
 * the Clear All commands, that picture gets no hover tint at all until
 * Change Picture Common Event gives it a Common Event again. The same goes
 * for a Change Picture Common Event with Use Global? and Change Tone on
 * Hover? both set to false.
 *
 * Any other time, its tone and blend mode are set back to the picture's
 * own values, the same ones Show Picture and Tint Picture control.
 *
 * There are no plugin commands.
 */

(() => {
    const params = PluginManager.parameters("PictureHoverToneFix");
    const pictureIds = JSON.parse(params.pictureIds || "[]").map(Number);
    const pictureCommonEventsName = "VisuMZ_4_PictureCmnEvts";

    const isFixedPicture = pictureId =>
        pictureIds.length === 0 || pictureIds.includes(pictureId);

    // Returns null when the command takes no picture IDs (the Clear All ones).
    const commandPictureIds = args => {
        if (!("PictureIDs:arraynum" in args)) {
            return null;
        }
        try {
            return JSON.parse(args["PictureIDs:arraynum"]).map(Number);
        } catch (e) {
            return [];
        }
    };

    const isFalse = value => String(value).trim() === "false";

    // Picture IDs that shouldn't get a hover tint, kept in save files.
    Game_Screen.prototype.hoverFixBlocked = function() {
        if (!this._hoverFixBlocked) {
            this._hoverFixBlocked = {};
        }
        return this._hoverFixBlocked;
    };

    const trackPictureCommonEvents = (commandName, args) => {
        args = args || {};
        const blocked = $gameScreen.hoverFixBlocked();
        const ids = commandPictureIds(args);
        if (commandName === "ChangePictureCommonEvent") {
            const hasCommonEvent = Number(args["CommonEventID:num"]) > 0;
            const toneOff =
                isFalse(args["UseGlobal:eval"]) && isFalse(args["ChangeTone:eval"]);
            for (const id of ids || []) {
                blocked[id] = !hasCommonEvent || toneOff;
            }
        } else if (ids) {
            for (const id of ids) {
                blocked[id] = true;
            }
        } else {
            for (let id = 1; id <= $gameScreen.maxPictures(); id++) {
                blocked[id] = true;
            }
        }
    };

    const _PluginManager_callCommand = PluginManager.callCommand;
    PluginManager.callCommand = function(self, pluginName, commandName, args) {
        if (pluginName === pictureCommonEventsName) {
            trackPictureCommonEvents(commandName, args);
        }
        _PluginManager_callCommand.call(this, self, pluginName, commandName, args);
    };

    const _Sprite_Picture_update = Sprite_Picture.prototype.update;
    Sprite_Picture.prototype.update = function() {
        _Sprite_Picture_update.call(this);
        this.updateHoverToneFix();
    };

    Sprite_Picture.prototype.updateHoverToneFix = function() {
        const picture = this.picture();
        if (!picture || !this.visible || !isFixedPicture(this._pictureId)) {
            return;
        }
        // Show Picture always makes a new Game_Picture, so a new object
        // means the picture was just shown and starts out not hovered.
        if (this._hoverFixPicture !== picture) {
            this._hoverFixPicture = picture;
            this._hoverFixHovered = false;
        }
        if (!this.isBeingTouched()) {
            this._hoverFixHovered = false;
        } else if (TouchInput.isHovered()) {
            this._hoverFixHovered = true;
        }
        const blocked = $gameScreen.hoverFixBlocked()[this._pictureId];
        if (blocked || !this._hoverFixHovered) {
            this.setColorTone(picture.tone() || [0, 0, 0, 0]);
            this.blendMode = picture.blendMode();
        }
    };
})();

It seems to work perfectly, thank you so much !