MV Elemental attacks with Yanfly Weapon Unleash

Hi everyone. I'm looking for some help/advice with getting an idea I have to work.

I want to have a skill that adds elemental attributes to whoever it's used on. For example, and Electrify Skill would give an Electrify State, which turns all attacks into electric attacks.

I'm trying to use Weapon Unleash to make it work but the current trouble I'm having is that my new Electrified Attack is the same animation no matter what weapon is being used. I need an electric slash for a sword an electric claw mark for a claw, etc.

I can't figure out any way to do this. I'm willing to make some new animations or even make new skills. But how do you specify which animations to use based on weapon or even character.

I'm open to any ideas. Thanks for any help.
You could use Yanfly's Weapon Animation plugin. Put Weapon Animation (and even Weapon Hue) notetags in the state to turn it into a fire burst with a red weapon, icicle with a blue one, etc.

The downside is it would be the same animation for all weapons, not a firey claw and icey sword slash.

You could use Yanfly's Action Sequences and put lots of conditionals in there to determine which weapon and element combination it is before playing the animation on the enemy.

@caethyril has a little plugin for applying an animation offset (so you'd have all your animations of different elements in a certain order by weapon type), but it's written for MZ. I don't know if she has an MV version, otherwise it would require rewriting to accommodate MV's codebase.

Other than that, I don't know of anything else to do except create replacement Attacks for every combination of weapon and element and use the Custom Replace Attack in Weapon Unleash.
Thanks. I think either the action sequences or the custom replace attack will do what I want to do, I will just need to learn to code a bit.

I don't know how to add conditionals to skills. I've looked for tutorials on the Action Sequences plugins but everything I'm finding is just pretty basic and nothing I've found really talks about conditionals.

I also like Caethyrils idea but again, that's for MZ.

Any recourses you know of that might help?
I think I'm right in saying my MZ plugin will mostly work in the latest version of MV. Link to post:
("Mostly" because while ES6 supports arrow functions => and the const declarator, I think the optional chaining ?. and nullish-coalescing ?? operators were introduced later.)

Should be a fairly simple fix, though. Try this (untested)?
Spoiler: MV plugin code
JavaScript:
/*:
 * @target MZ MV
 * @plugindesc Attack animation trait tags (base, offset). MV 1.6+ compatible.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/157831/
 * @help For use in the Note box of any trait-bearing object:
 *         <attack anim base: 5> => attacks without a weapon use anim ID 5.
 *         <attack anim plus: 2> => add 2 to the base ID value.
 * If multiple base/plus tags apply, the highest value will be used.
 * Default values (when no tags present): base = 1, plus = 0.
 *
 * ----------------------------------------------------------------------------
 * Terms of use:
 *   MIT License: https://opensource.org/licenses/mit-license.html
 *
 * [[ BEGIN LICENSE TEXT ]]
 *
 *   Copyright © 2023 Caethyril
 *
 *   Permission is hereby granted, free of charge, to any person obtaining a
 *   copy of this software and associated documentation files (the "Software"),
 *   to deal in the Software without restriction, including without limitation
 *   the rights to use, copy, modify, merge, publish, distribute, sublicense,
 *   and/or sell copies of the Software, and to permit persons to whom the
 *   Software is furnished to do so, subject to the following conditions:
 *
 *   The above copyright notice and this permission notice shall be included
 *   in all copies or substantial portions of the Software.
 *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 *   DEALINGS IN THE SOFTWARE.
 *
 * [[ END LICENSE TEXT ]]
 */

// Q11) Attack animation trait tags.
void (() => {
'use strict';

    /**
     * Tag name for base attack animation ID.
     * Use on Actor/Class/Weapon/Armor/State/Enemy/Skill/Item.
     *
     * Applies for enemies, or actors without a weapon.
     */
    const TAG_NAME_BASE = 'attack anim base';

    /**
     * Tag name for additive bonus to attack animation ID.
     * Use on Actor/Class/Weapon/Armor/State/Enemy/Skill/Item.
     *
     * E.g. for an elemental power-up state.
     */
    const TAG_NAME_PLUS = 'attack anim plus';    // e.g. ice power-up state

    /** @returns {?$dataItem|$dataSkill} Item/Skill reference for current action, or `null`. */
    const getActionItem = function() {
        if (!BattleManager._action)
            return null;
        return BattleManager._action.item();
    };

    /**
     * @param {object} o
     * Reference meta-bearing object
     * @param {boolean} isBase -
     * - `true` => read {@linkcode TAG_NAME_BASE},
     * - `false` => read {@linkcode TAG_NAME_PLUS}.
     * @returns {?number}
     * Animation ID/offset from tag, or `null`.
     */
    const parseTag = function(o, isBase = false) {
        if (!o)
            return null;
        const v = parseInt(o.meta[isBase ? TAG_NAME_BASE : TAG_NAME_PLUS]);
        return isNaN(v) ? null : v;
    };

    /**
     * Returns largest applicable value from `dFault` or tags.
     * @param {Game_Battler} battler reference battler
     * @param {number} [dFault=1] base value if no tags found (default: 1)
     * @returns {number} override base value for animation ID
     */
    const getAttackAnimBase = function(battler, dFault = 1) {
        const i = parseTag(getActionItem(), true);
        if (i)
            return i;   // has tag from item/skill - specific beats general
        return battler.traitObjects().reduce((a, c) => {
            const v = parseTag(c, true);
            return v > a ? v : a;
        }, dFault);
    };

    /**
     * Returns largest applicable offset.
     * @param {Game_Battler} battler reference battler
     * @returns {number} additive offset for attack animation ID
     */
    const getAttackAnimOffset = function(battler) {
        const i = parseTag(getActionItem(), false);
        if (i)
            return i;   // has tag from item/skill - specific beats general
        return battler.traitObjects().reduce((a, c) => {
            const v = parseTag(c, false);
            return v > a ? v : a;
        }, 0);
    };

    /**
     * @param {Game_Enemy} subject reference enemy
     * @returns {number} attack animation ID
     */
    Game_Enemy.prototype.attackAnimationId1 = function() {
        const base = getAttackAnimBase(this);
        if (!base)
            return 0;   // do not offset if anim ID = 0.
        return base + getAttackAnimOffset(this);
    };

    // Let enemies show attack animation (mirroring is done via anim target check).
    void (alias => {
        Window_BattleLog.prototype.showEnemyAttackAnimation = function(subject, targets) {
            alias.apply(this, arguments);
            this.showNormalAnimation(targets, subject.attackAnimationId1());
        };
    })(Window_BattleLog.prototype.showEnemyAttackAnimation);

    // Override bare hands attack animation for actors.
    void (alias => {
        Game_Actor.prototype.bareHandsAnimationId = function() {
            return getAttackAnimBase(this, alias.apply(this, arguments));
        };
    })(Game_Actor.prototype.bareHandsAnimationId);

    // Apply offsets for actor attack animations.
    void (alias => {
        Game_Actor.prototype.attackAnimationId1 = function() {
            const base = alias.apply(this, arguments);
            if (!base)
                return 0;   // do not offset if anim ID = 0 (e.g. weapon anim 0).
            return base + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId1);
    void (alias => {
        Game_Actor.prototype.attackAnimationId2 = function() {
            const base = alias.apply(this, arguments);
            if (!base)
                return 0;   // do not offset if anim ID = 0 (e.g. no secondary weapon).
            return base + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId2);

})();
("Mostly" because while ES6 supports arrow functions => and the const declarator, I think the optional chaining ?. and nullish-coalescing ?? operators were introduced later.)
Yeah, that's what I was referring to. Didn't want to presume to rewrite stuff on your behalf 😉
Moved to: Plugin Support
@caethyril thanks. I will give it a try. I read the thread you linked to. Does this one work the same where I can copy/paste this text then save as .js and load as a plugin?
@Rowsdower310 - yes, follow the same steps to convert from plain text to a plugin file. 👋

Original thread: https://forums.rpgmakerweb.com/threads/elemental-attacks-with-yanfly-weapon-unleash.157831/