MV An "animation substitution" plugin to allow for a "photosensitive players" option

Hey all, work continues to add an option to reduce discomfort for photosensitive users when playing my game, and when it's done, I want to distribute/tutorialise as much as I can so others can do this too.

I've now got solutions to screen flashes outside of battles, shakes outside of battles, flash battle transitions, and I have a generic switch that players can turn ON which reduces the intensity of FX (basically I've gone through the game and added IF statements to egregious FX to turn them off/replace them with less intense FX).

However, I'm left with a problem I can't easily solve - animations and particularly battle animations, across the game, have screen flashes and animated FX that are too intense, so I need the ability to substitute them.

What I mean by "substitute" is that for anims that have strong flashes or intense elements, I would create two variants - the existing version, and a newer, less intense version. But right now, I have no way for the game to choose between them; anims on the map are okay, but battle anims wouldn't work without a lot of awkward engineering (like creating 2 variants of enemies just to do this).

I could really do with a plugin where we can define a switch ID, and a list of animation substitutions.

So, basically we say - if Switch #59 is ON, then...

Whenever the game wants to play animation 12 on a target, it plays animation 25 on said target instead
Whenever the game wants to play animation 13 on a target, it plays animation 26 on said target instead
Whenever the game wants to play animation 14 on a target, it plays animation 27 on said target instead

Then, I would author new animations for all of the anims that have flashes, and substitute them all.

If I could do this, it would be a good plugin to distribute, as it would make it much easier for people to make games with modes that reduce discomfort for photosensitive players.

Is there anyone here who feels they could take this on? I could afford to pay a small commission cost, if you're really confident you could make the plugin and bugfix it etc. - but I was hoping someone in the community might be interested, as we'd redistribute this afterwards for others.
I see you're asking for a plugin to do this, but if you get no bites....

You *should* be able to do something like this by using an action sequence plugin (visu stella comes to mind - their battlecore has action sequences - but there are others). In such a situation, you'd have to create a battle sequence for each attack, and have a conditional in the sequence that checks to see if we're going easy on the eyes, and then switch the animation.
I see you're asking for a plugin to do this, but if you get no bites....

You *should* be able to do something like this by using an action sequence plugin (visu stella comes to mind - their battlecore has action sequences - but there are others). In such a situation, you'd have to create a battle sequence for each attack, and have a conditional in the sequence that checks to see if we're going easy on the eyes, and then switch the animation.

Thanks for the suggestion! I hadn't realised that was possible.

In my case though I'm retrofitting this to an existing game, which has seen a lot of testing - I really don't want to wade back into the battle system on that level.

It also needs to function for animations not used in battles, too.

It's definitely at a stage where I'd much prefer to just do it at a global level, even if I have to commission a plugin to do so.
👋 Wrote a quick plugin with an on/off switch and anim replacement list, see attachment.
Spoiler: Full plugin code
JavaScript:
// ==================================================
// AnimReplacer.js
// ==================================================

/*:
 * @plugindesc Replace animations when a switch is on.
 * @author Caethyril
 * @help Configure this plugin using the parameters --->
 * 
 * Note: this plugin is designed for the v1.5.0 editor or newer.
 * With older versions the parameters will be hard to edit.
 * 
 * @param Switch
 * @type switch
 * @desc When this switch is on, animations will be replaced.
 * @default 0
 * 
 * @param Replacements
 * @type struct<AnimReplacement>[]
 * @desc List of animations and their replacements.
 * @default []
 */
// ==================================================
/*~struct~AnimReplacement:
 * @param A
 * @type animation
 * @desc The original animation.
 * @default
 * 
 * @param B
 * @type animation
 * @desc The replacement animation.
 * @default
 */

(function(alias) {
'use strict';

    const PLUGIN_NAME = 'AnimReplacer';
    const params = PluginManager.parameters(PLUGIN_NAME);
    
    const swId = parseInt(params.Switch, 10) || 0;
    const data = JSON.parse(params.Replacements || '[]').map(function(s) {
        const o = JSON.parse(s);
        return { A: parseInt(o.A, 10), B: parseInt(o.B, 10) };
    }).filter(function(o) { return o.A && o.B && o.A !== o.B });

    const active = function() { return $gameSwitches.value(swId); };
    const replace = function(id) {
        if (active()) {
            let ix = -1;
            if (data.some(function(o, n) {
                if (o.A === id) { ix = n; return true; }
                return false;
            })) return data[ix].B;
        }
        return id;
    };

    // Alias! Replace animation reference before setting up sprite, if appropriate.
    Sprite_Animation.prototype.setup = function(target, animation, mirror, delay) {
        alias.call(this, target, $dataAnimations[replace(animation.id)], mirror, delay);
    };
    
})(Sprite_Animation.prototype.setup);
Use however you like~

[Edit: removed 3 console.log statements left over from testing! 😊]
👋 Wrote a quick plugin with an on/off switch and anim replacement list, see attachment.
Spoiler: Full plugin code
JavaScript:
// ==================================================[/INDENT]
[INDENT]// AnimReplacer.js[/INDENT]
[INDENT]// ==================================================[/INDENT]
[INDENT][/INDENT]
[INDENT]/*:[/INDENT]
[INDENT]* @plugindesc Replace animations when a switch is on.[/INDENT]
[INDENT]* @author Caethyril[/INDENT]
[INDENT]* @help Configure this plugin using the parameters --->[/INDENT]
[INDENT]*[/INDENT]
[INDENT]* Note: this plugin is designed for the v1.5.0 editor or newer.[/INDENT]
[INDENT]* With older versions the parameters will be hard to edit.[/INDENT]
[INDENT]*[/INDENT]
[INDENT]* @param Switch[/INDENT]
[INDENT]* @type switch[/INDENT]
[INDENT]* @desc When this switch is on, animations will be replaced.[/INDENT]
[INDENT]* @default 0[/INDENT]
[INDENT]*[/INDENT]
[INDENT]* @param Replacements[/INDENT]
[INDENT]* @type struct<AnimReplacement>[][/INDENT]
[INDENT]* @desc List of animations and their replacements.[/INDENT]
[INDENT]* @default [][/INDENT]
[INDENT]*/[/INDENT]
[INDENT]// ==================================================[/INDENT]
[INDENT]/*~struct~AnimReplacement:[/INDENT]
[INDENT]* @param A[/INDENT]
[INDENT]* @type animation[/INDENT]
[INDENT]* @desc The original animation.[/INDENT]
[INDENT]* @default[/INDENT]
[INDENT]*[/INDENT]
[INDENT]* @param B[/INDENT]
[INDENT]* @type animation[/INDENT]
[INDENT]* @desc The replacement animation.[/INDENT]
[INDENT]* @default[/INDENT]
[INDENT]*/[/INDENT]
[INDENT][/INDENT]
[INDENT](function(alias) {[/INDENT]
[INDENT]'use strict';[/INDENT]
[INDENT][/INDENT]
[INDENT]    const PLUGIN_NAME = 'AnimReplacer';[/INDENT]
[INDENT]    const params = PluginManager.parameters(PLUGIN_NAME);[/INDENT]
[INDENT]   [/INDENT]
[INDENT]    const swId = parseInt(params.Switch, 10) || 0;[/INDENT]
[INDENT]    const data = JSON.parse(params.Replacements || '[]').map(function(s) {[/INDENT]
[INDENT]        const o = JSON.parse(s);[/INDENT]
[INDENT]        return { A: parseInt(o.A, 10), B: parseInt(o.B, 10) };[/INDENT]
[INDENT]    }).filter(function(o) { return o.A && o.B && o.A !== o.B });[/INDENT]
[INDENT][/INDENT]
[INDENT]    const active = function() { return $gameSwitches.value(swId); };[/INDENT]
[INDENT]    const replace = function(id) {[/INDENT]
[INDENT]        console.log('hello?');[/INDENT]
[INDENT]        if (active()) {[/INDENT]
[INDENT]            console.log('hi?');[/INDENT]
[INDENT]            let ix = -1;[/INDENT]
[INDENT]            if (data.some(function(o, n) {[/INDENT]
[INDENT]                if (o.A === id) { ix = n; console.log(data, ix, data[ix].B); return true; }[/INDENT]
[INDENT]                return false;[/INDENT]
[INDENT]            })) return data[ix].B;[/INDENT]
[INDENT]        }[/INDENT]
[INDENT]        return id;[/INDENT]
[INDENT]    };[/INDENT]
[INDENT][/INDENT]
[INDENT]    // Alias! Replace animation reference before setting up sprite, if appropriate.[/INDENT]
[INDENT]    Sprite_Animation.prototype.setup = function(target, animation, mirror, delay) {[/INDENT]
[INDENT]        alias.call(this, target, $dataAnimations[replace(animation.id)], mirror, delay);[/INDENT]
[INDENT]    };[/INDENT]
[INDENT]   [/INDENT]
[INDENT]})(Sprite_Animation.prototype.setup);
Use however you like~

Thanks so much! I gave it a quick go and it looks like it works, so I'm going to make all my substitutions this weekend.

I'm going to write a tutorial for this on my devlog, just explaining how I went about adding the "reduced effect intensity" mode, so I'll be sure to provide a link here when I do that.
Thanks @caethyril, it works really well!

To cap this off, do you have a thread of your plugins or assets I can link to, when I write all this up?
Great! You can find my main MV plugins over here:
Happy RPG Making! 😂

Original thread: https://forums.rpgmakerweb.com/threads/an-animation-substitution-plugin-to-allow-for-a-photosensitive-players-option.130840/