Is there any way to make a state change an actor's attack animation, based on their weapon type?

I've got 3 states in my game that can add elements to a character's normal attack - Enflame (fire), Enfrost (ice) and Envolt (lightning). Thing is, this element shift isn't reflected in the character's attack animation. I have animations for each of these elements (for example, a "fire slash" animation), and while I know that the simple answer is to change the Attack Skill to a copy of the normal attack but with an element (and respective animation) attached, there's something that complicates this solution: Each character can use multiple weapon types, with different types of animations.

So for example, the Rogue of the party can wield Swords, Axes and Bows. Swords and Axes use a slashing animation, but Bows use an arrow shooting animation. If she uses Enflame, giving her a fire slash animation would work for the Swords and Axes, but not if she's equipped with a Bow. So just setting the attack skill to a fire slash animation won't work. I have all of the animations I need (fire, ice and lightning versions of slashes, strikes, pierces and arrows), but I don't know how to tell the game what to set the skill/animation to based on whichever weapon type is equipped. I also need to account for what animation to play if the character uses one of these element-changing spells on themselves, but is unarmed.

As it stands, you can only cast these element-changing spells on yourself. Though I've also considered allowing enemies to cast them on you as a dirty trick (for example, an enemy that absorbs fire casting Enflame on you, so that your normal attacks would heal it), but I'm not certain if I'll implement that or not.

So... yeah, how can I make this work?
Edited from some stuff I wrote for an unfinished project:
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Attack animation trait tags.
 * @author Caethyril
 * @help Tags for use on any trait-bearing object:
 *      <attack anim base: X>
 * e.g. <attack anim base: 6>
 *      - uses attack animation ID X for no-weapon attacks.
 *      <attack anim add: X>
 * e.g. <attack anim add: 1>
 *      - adds X to ID of attack animation.
 * If multiple tags apply, the one with the highest value will be used.
 *
 * ----------------------------------------------------------------------------
 * Terms of use:
 *   MIT License: https://opensource.org/licenses/mit-license.html
 *   
 * [[ BEGIN LICENSE TEXT ]]
 * 
 *   Copyright © 2022 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.
     * Applies for enemies, or actors without a weapon.
     */
    const TAG_NAME_BASE = 'attack anim base';

    /**
     * Tag name for additive bonus to attack animation ID.
     * E.g. for an elemental power-up state.
     */
    const TAG_NAME_ADD  = 'attack anim add';    // e.g. ice power-up state

    /**
     * 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) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_BASE], 10);
            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) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_ADD], 10);
            return v > a ? v : a;
        }, 0);
    };

    /**
     * @param {Game_Enemy} subject reference enemy
     * @returns {number} attack animation ID
     */
    const enemyAttackAnimId = function(subject) {
        return getAttackAnimBase(subject) + getAttackAnimOffset(subject);
    };

    // 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, enemyAttackAnimId(subject));
        };
    })(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() {
            return alias.apply(this, arguments) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId1);
    void (alias => {
        Game_Actor.prototype.attackAnimationId2 = function() {
            return alias.apply(this, arguments) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId2);

    // Off-hand attack anims are mirrored? No thanks. O_o
    Window_BattleLog.prototype.showActorAttackAnimation = function(
        subject, targets
    ) {
        this.showNormalAnimation(targets, subject.attackAnimationId1());
        this.showNormalAnimation(targets, subject.attackAnimationId2());
    };

})();
Couple of things in there you might not want: it adds enemy attack animations (cuz by default they don't have any) and prevents the default mirroring of off-hand attack animations when dual-wielding. Edit it as you like~
Edited from some stuff I wrote for an unfinished project:
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Attack animation trait tags.
 * @author Caethyril
 * @help Tags for use on any trait-bearing object:
 *      <attack anim base: X>
 * e.g. <attack anim base: 6>
 *      - uses attack animation ID X for no-weapon attacks.
 *      <attack anim add: X>
 * e.g. <attack anim add: 1>
 *      - adds X to ID of attack animation.
 * If multiple tags apply, the one with the highest value will be used.
 *
 * ----------------------------------------------------------------------------
 * Terms of use:
 *   MIT License: https://opensource.org/licenses/mit-license.html
 *  
 * [[ BEGIN LICENSE TEXT ]]
 *
 *   Copyright © 2022 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.
     * Applies for enemies, or actors without a weapon.
     */
    const TAG_NAME_BASE = 'attack anim base';

    /**
     * Tag name for additive bonus to attack animation ID.
     * E.g. for an elemental power-up state.
     */
    const TAG_NAME_ADD  = 'attack anim add';    // e.g. ice power-up state

    /**
     * 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) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_BASE], 10);
            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) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_ADD], 10);
            return v > a ? v : a;
        }, 0);
    };

    /**
     * @param {Game_Enemy} subject reference enemy
     * @returns {number} attack animation ID
     */
    const enemyAttackAnimId = function(subject) {
        return getAttackAnimBase(subject) + getAttackAnimOffset(subject);
    };

    // 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, enemyAttackAnimId(subject));
        };
    })(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() {
            return alias.apply(this, arguments) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId1);
    void (alias => {
        Game_Actor.prototype.attackAnimationId2 = function() {
            return alias.apply(this, arguments) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId2);

    // Off-hand attack anims are mirrored? No thanks. O_o
    Window_BattleLog.prototype.showActorAttackAnimation = function(
        subject, targets
    ) {
        this.showNormalAnimation(targets, subject.attackAnimationId1());
        this.showNormalAnimation(targets, subject.attackAnimationId2());
    };

})();
Couple of things in there you might not want: it adds enemy attack animations (cuz by default they don't have any) and prevents the default mirroring of off-hand attack animations when dual-wielding. Edit it as you like~

Haven't tried it yet, but do you think that it might conflict with the Visustella battle core? Cause that adds enemy attack animations too - or at least, it's supposed to, but it never seems to display them for me, even though I tagged enemies to have attack animations lol.
...do you think that it might conflict with the Visustella battle core? Cause that adds enemy attack animations too
If you load it after VisuStella Battle Core then it's possible it will show the enemy attack animation twice. The alias.apply lines basically mean "do whatever this function would do if this plugin wasn't here".

To disable that feature, you can remove or // comment out this part:
JavaScript:
    // 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, enemyAttackAnimId(subject));
        };
    })(Window_BattleLog.prototype.showEnemyAttackAnimation);
If you load it after VisuStella Battle Core then it's possible it will show the enemy attack animation twice. The alias.apply lines basically mean "do whatever this function would do if this plugin wasn't here".

To disable that feature, you can remove or // comment out this part:
JavaScript:
    // 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, enemyAttackAnimId(subject));
        };
    })(Window_BattleLog.prototype.showEnemyAttackAnimation);

Sorry it took so long for me to check this out. Been kinda busy. But um... I'm not sure how to use this, exactly? Like, if I put these attack animation tags on a state, how will it know which weapon type is being used, so it can display the relevant animation?
👋 No worries! I wrote it based on the default animations, which are ordered like:
  1. Hit Physical
  2. Hit Effect
  3. Hit Fire
  4. Hit Ice
  5. Hit Thunder
  6. Slash Physical
  7. Slash Effect
  8. etc
E.g. for a given animation type (Hit, Slash, Pierce, or Claw), the "Fire" version of that animation is always 2 slots after the "Physical" one. So you can assign the "Physical" animation to a weapon, then use the tag <attack anim add: 2> to transform that into the "Fire" version of that animation.

Also, the tags work on anything with traits, including weapons. So for a fire sword, you could set its animation to the normal one, e.g. "Slash Physical", then put the <attack anim add: 2> tag on the weapon. The plugin only takes the highest value for each tag (base & add), so that avoids incorrect offsets to the animation ID.

Does that sound like it'll work for you?
👋 No worries! I wrote it based on the default animations, which are ordered like:
  1. Hit Physical
  2. Hit Effect
  3. Hit Fire
  4. Hit Ice
  5. Hit Thunder
  6. Slash Physical
  7. Slash Effect
  8. etc
E.g. for a given animation type (Hit, Slash, Pierce, or Claw), the "Fire" version of that animation is always 2 slots after the "Physical" one. So you can assign the "Physical" animation to a weapon, then use the tag <attack anim add: 2> to transform that into the "Fire" version of that animation.

Also, the tags work on anything with traits, including weapons. So for a fire sword, you could set its animation to the normal one, e.g. "Slash Physical", then put the <attack anim add: 2> tag on the weapon. The plugin only takes the highest value for each tag (base & add), so that avoids incorrect offsets to the animation ID.

Does that sound like it'll work for you?

I still don't think I'm understanding it right...

Here's what my animations list looks like:

1673572938874.png


I don't think that would work with what I have? Plus um... I still don't think I understand how it works in general. It almost sounds to me like this isn't actually doing what I need it to? Maybe I explained it badly. Or maybe I'm just dumb lol

Lemme try and clarify a little exactly what I'm trying to do:
Let's say Character A has a sword equipped.
Character A casts the spell Enflame on themselves.
Enflame applies a state that changes the element of the attack to fire, and would change the animation to the flame slash animation.
But... if I cast Enflame on Character B, and they have a bow, then the very same state needs to know "Okay this guy has a bow, so we use the Arrow/Flame animation instead."

And it can't be character based either, because all of my characters can equip multiple weapon types.
I still don't think I'm understanding it right...
So, caethyril pointed out, as an example, that the Fire version of an attack animation is always two slots after the normal physical version. If you look at your animation list, this holds true for you too. Slash Physical 1 is in slot 6, while Slash Flame 1 is two slots after, in slot 8.

So if you took a sword using Slash Physical 1 as its animation and then put <attack anim add: 2> in the notetag of the sword, it will use the Slash Flame 1 animation instead. This is because the tag takes the slot number of the sword's assigned animation, in this case 6, then adds 2 to it, equalling 8. 8 is the slot ID of Slash Flame 1, so that gets used. If you put <attack anim add: 3> instead, the animation used would be Slash Ice 1 instead.

Does that help you make sense of it?
Just to clarify: what Sword_of_Dusk mentioned also works with the tag on a state.

As far as I can tell, the trouble with your current setup is that the attack animations are inconsistently-spaced. E.g. you have 2 versions each of "normal" Striking & Slashing, but only 1 version each for Stinger & Arrow. And a second set of Flame/Ice/Thunder anims only for Slashing. It's not clear to me how you want these to interact when you get a power-up.

From a purely information-based perspective: the game needs to know how to go from the "normal" attack animation to the appropriate "power-up" version. In general that would mean having a list of paired animations per power-up, e.g. for your Enflame state:
  • Striking/Physical 1 -> Striking/Flame 1
  • Striking/Physical 2 -> Striking/Flame 1
  • Slash/Physical 1 -> Slash/Flame 1
  • Slash/Physical 2 -> Slash/Flame 2
My plugin simplifies this by assuming the attack animations are arranged in a specific order. Without that, you will need to specify all valid pairs like this so that the game knows which attack animation to use for any given power-up.

If you want to go that route, you can try replacing this part of my plugin:
JavaScript:
    const getAttackAnimBase = function(battler, dFault = 1) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_BASE], 10);
            return v > a ? v : a;
        }, dFault);
    };
...with something like this (untested):
Spoiler: new getAttackAnimBase code
JavaScript:
    /**
     * Structure is `stateId: { defaultAnimId : newAnimId }`.
     * Defines pairwise map for attack animation ID, per state.
     * Attack animation IDs not listed will remain unchanged.
     */
    const stateMap = {
         10: { 1: 3, 2: 3, 6: 8, 7: 8, 14: 15, 18: 19 },
         11: { 1: 4, 2: 4, 6: 9, 7: 9, 14: 16, 18: 20 },
         12: { 1: 5, 2: 5, 6: 10, 7: 10, 14: 17, 18: 21 }
    };

    const getAttackAnimBase = function(battler, dFault = 1) {
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10))
            if (battler.isStateAffected(id)) {
                const newId = stateMap[id][dFault];
                if (newId)
                    return newId;
            }
        return dFault;
    };
You'll need to edit the values of stateMap to suit your animations. Currently it is:
  • State 10: anim 1 -> anim 3, anim 2 -> anim 3, anim 6 -> anim 8, etc;
  • State 11: anim 1 -> anim 4, anim 2 -> anim 4, anim 6 -> anim 9, etc;
  • State 12: anim 1 -> anim 5, anim 2 -> anim 5, anim 6 -> anim 10, etc.
Then try using the <attack anim base: X> tag on states. With this edit, that tag will only work on states. [Edit: sorry, this edit actually just replaces that tag with stateMap, i.e. the tag is no longer used.] If you wanted it for custom enemy attack animations, I'd suggest just using an Attack Skill trait instead.
Just to clarify: what Sword_of_Dusk mentioned also works with the tag on a state.

As far as I can tell, the trouble with your current setup is that the attack animations are inconsistently-spaced. E.g. you have 2 versions each of "normal" Striking & Slashing, but only 1 version each for Stinger & Arrow. And a second set of Flame/Ice/Thunder anims only for Slashing. It's not clear to me how you want these to interact when you get a power-up.

From a purely information-based perspective: the game needs to know how to go from the "normal" attack animation to the appropriate "power-up" version. In general that would mean having a list of paired animations per power-up, e.g. for your Enflame state:
  • Striking/Physical 1 -> Striking/Flame 1
  • Striking/Physical 2 -> Striking/Flame 1
  • Slash/Physical 1 -> Slash/Flame 1
  • Slash/Physical 2 -> Slash/Flame 2
My plugin simplifies this by assuming the attack animations are arranged in a specific order. Without that, you will need to specify all valid pairs like this so that the game knows which attack animation to use for any given power-up.

If you want to go that route, you can try replacing this part of my plugin:
JavaScript:
    const getAttackAnimBase = function(battler, dFault = 1) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_BASE], 10);
            return v > a ? v : a;
        }, dFault);
    };
...with something like this (untested):
Spoiler: new getAttackAnimBase code
JavaScript:
    /**
     * Structure is `stateId: { defaultAnimId : newAnimId }`.
     * Defines pairwise map for attack animation ID, per state.
     * Attack animation IDs not listed will remain unchanged.
     */
    const stateMap = {
         10: { 1: 3, 2: 3, 6: 8, 7: 8, 14: 15, 18: 19 },
         11: { 1: 4, 2: 4, 6: 9, 7: 9, 14: 16, 18: 20 },
         12: { 1: 5, 2: 5, 6: 10, 7: 10, 14: 17, 18: 21 }
    };

    const getAttackAnimBase = function(battler, dFault = 1) {
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10))
            if (battler.isStateAffected(id)) {
                const newId = stateMap[id][dFault];
                if (newId)
                    return newId;
            }
        return dFault;
    };
You'll need to edit the values of stateMap to suit your animations. Currently it is:
  • State 10: anim 1 -> anim 3, anim 2 -> anim 3, anim 6 -> anim 8, etc;
  • State 11: anim 1 -> anim 4, anim 2 -> anim 4, anim 6 -> anim 9, etc;
  • State 12: anim 1 -> anim 5, anim 2 -> anim 5, anim 6 -> anim 10, etc.
Then try using the <attack anim base: X> tag on states. With this edit, that tag will only work on states. If you wanted it for custom enemy attack animations, I'd suggest just using an Attack Skill trait instead.

So it does seem like my problem might be the order of my animations like you said. However, I don't know anything about editing JS, so even though you said to change one part of the script to another... I'm not sure where exactly I'm supposed to put it in. Like, I don't know where the border of where I should cut stuff out and put stuff in is. Could you please post the whole script with it edited in, just to make sure I don't accidentally break something? Sorry for not understanding this stuff 🙁
So it does seem like my problem might be the order of my animations like you said. However, I don't know anything about editing JS, so even though you said to change one part of the script to another... I'm not sure where exactly I'm supposed to put it in. Like, I don't know where the border of where I should cut stuff out and put stuff in is. Could you please post the whole script with it edited in, just to make sure I don't accidentally break something? Sorry for not understanding this stuff 🙁
You don't need JS knowledge to make changes when you're shown exactly what to change. Trust me, I know nothing of code, but I've been able to make alterations when prompted. Might as well give it a shot while you wait.
OK, edited:
Spoiler: plugin code v2
JavaScript:
/*:
 * @target MZ
 * @plugindesc Attack animation trait tags.
 * @author Caethyril
 * @help Tag for use on any trait-bearing object:
 *      <attack anim add: X>
 * e.g. <attack anim add: 1>
 *      - adds X to ID of attack animation.
 * If multiple tags apply, the one with the highest value will be used.
 *
 * Edit the stateMap object in the code to customise how states transform
 * one animation into another.
 *
 * ----------------------------------------------------------------------------
 * Terms of use:
 *   MIT License: https://opensource.org/licenses/mit-license.html
 *   
 * [[ BEGIN LICENSE TEXT ]]
 * 
 *   Copyright © 2022 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 ]]
 */

void (() => {
'use strict';

    /**
     * Tag name for additive bonus to attack animation ID.
     * E.g. for an elemental power-up state.
     */
    const TAG_NAME_ADD  = 'attack anim add';    // e.g. ice power-up state

    /**
     * Structure is `stateId: { defaultAnimId : newAnimId }`.
     * Defines pairwise map for attack animation ID, per state.
     * Attack animation IDs not listed will remain unchanged.
     */
    const stateMap = {
         10: { 1: 3, 2: 3, 6: 8, 7: 8, 14: 15, 18: 19 },
         11: { 1: 4, 2: 4, 6: 9, 7: 9, 14: 16, 18: 20 },
         12: { 1: 5, 2: 5, 6: 10, 7: 10, 14: 17, 18: 21 }
    };

    /**
     * Returns base attack animation ID, by referencing {@linkcode stateMap}.
     * @param {Game_Battler} battler reference battler
     * @param {number} [dFault=1] base value if no relevant states found (default: 1)
     * @returns {number} override base value for animation ID
     */
    const getAttackAnimBase = function(battler, dFault = 1) {
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10)))
            if (battler.isStateAffected(id)) {
                const newId = stateMap[id][dFault];
                if (newId)
                    return newId;
            }
        return dFault;
    };

    /**
     * Returns largest applicable offset.
     * @param {Game_Battler} battler reference battler
     * @returns {number} additive offset for attack animation ID
     */
    const getAttackAnimOffset = function(battler) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_ADD], 10);
            return v > a ? v : a;
        }, 0);
    };

    /**
     * @param {Game_Enemy} subject reference enemy
     * @returns {number} attack animation ID
     */
    const enemyAttackAnimId = function(subject) {
        return getAttackAnimBase(subject) + getAttackAnimOffset(subject);
    };

    // 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, enemyAttackAnimId(subject));
        };
    })(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() {
            return alias.apply(this, arguments) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId1);
    void (alias => {
        Game_Actor.prototype.attackAnimationId2 = function() {
            return alias.apply(this, arguments) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId2);

})();
I updated the help section appropriately, since actually (unlike I said earlier, sorry for any confusion) this edit replaces the "base" tag with stateMap.

As mentioned, you will still need to manually edit the stateMap values to fit your Enflame/Enfrost/Envolt state IDs and each state's corresponding pairs of animation IDs.

I removed the "unmirror off-hand anims" bit at the end because I figured it's kinda unrelated. I also haven't tested this edit, but hopefully it'll work~

Alternatively, since you mentioned you're using VisuStella Battle Core, you could probably just use branches in your skills' action sequences. More effort/tedium on your end, but it would give you more control with no need for extra plugins.

[Edit: added missing ).)
OK, edited:
Spoiler: plugin code v2
JavaScript:
/*:
 * @target MZ
 * @plugindesc Attack animation trait tags.
 * @author Caethyril
 * @help Tag for use on any trait-bearing object:
 *      <attack anim add: X>
 * e.g. <attack anim add: 1>
 *      - adds X to ID of attack animation.
 * If multiple tags apply, the one with the highest value will be used.
 *
 * Edit the stateMap object in the code to customise how states transform
 * one animation into another.
 *
 * ----------------------------------------------------------------------------
 * Terms of use:
 *   MIT License: https://opensource.org/licenses/mit-license.html
 * 
 * [[ BEGIN LICENSE TEXT ]]
 *
 *   Copyright © 2022 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 ]]
 */

void (() => {
'use strict';

    /**
     * Tag name for additive bonus to attack animation ID.
     * E.g. for an elemental power-up state.
     */
    const TAG_NAME_ADD  = 'attack anim add';    // e.g. ice power-up state

    /**
     * Structure is `stateId: { defaultAnimId : newAnimId }`.
     * Defines pairwise map for attack animation ID, per state.
     * Attack animation IDs not listed will remain unchanged.
     */
    const stateMap = {
         10: { 1: 3, 2: 3, 6: 8, 7: 8, 14: 15, 18: 19 },
         11: { 1: 4, 2: 4, 6: 9, 7: 9, 14: 16, 18: 20 },
         12: { 1: 5, 2: 5, 6: 10, 7: 10, 14: 17, 18: 21 }
    };

    /**
     * Returns base attack animation ID, by referencing {@linkcode stateMap}.
     * @param {Game_Battler} battler reference battler
     * @param {number} [dFault=1] base value if no relevant states found (default: 1)
     * @returns {number} override base value for animation ID
     */
    const getAttackAnimBase = function(battler, dFault = 1) {
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10))
            if (battler.isStateAffected(id)) {
                const newId = stateMap[id][dFault];
                if (newId)
                    return newId;
            }
        return dFault;
    };

    /**
     * Returns largest applicable offset.
     * @param {Game_Battler} battler reference battler
     * @returns {number} additive offset for attack animation ID
     */
    const getAttackAnimOffset = function(battler) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_ADD], 10);
            return v > a ? v : a;
        }, 0);
    };

    /**
     * @param {Game_Enemy} subject reference enemy
     * @returns {number} attack animation ID
     */
    const enemyAttackAnimId = function(subject) {
        return getAttackAnimBase(subject) + getAttackAnimOffset(subject);
    };

    // 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, enemyAttackAnimId(subject));
        };
    })(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() {
            return alias.apply(this, arguments) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId1);
    void (alias => {
        Game_Actor.prototype.attackAnimationId2 = function() {
            return alias.apply(this, arguments) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId2);

})();
I updated the help section appropriately, since actually (unlike I said earlier, sorry for any confusion) this edit replaces the "base" tag with stateMap.

As mentioned, you will still need to manually edit the stateMap values to fit your Enflame/Enfrost/Envolt state IDs and each state's corresponding pairs of animation IDs.

I removed the "unmirror off-hand anims" bit at the end because I figured it's kinda unrelated. I also haven't tested this edit, but hopefully it'll work~

Alternatively, since you mentioned you're using VisuStella Battle Core, you could probably just use branches in your skills' action sequences. More effort/tedium on your end, but it would give you more control with no need for extra plugins.

1673747009946.png

1673747124608.png

This is what happens if I enable the plugin you posted 🙁

It crashes immediately upon boot. Any idea what the problem is? Turning the plugin off fixes it.

Also, I don't really use any action sequences in my game, actually. It's supposed to be 8-bit so I wanted to keep it simple. I haven't the faintest idea how the action sequences work lol
Whoops, mismatched brackets. This line:
JavaScript:
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10))
...should be this:
JavaScript:
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10)))
I'll edit the correction into my previous post. 👋
Whoops, mismatched brackets. This line:
JavaScript:
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10))
...should be this:
JavaScript:
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10)))
I'll edit the correction into my previous post. 👋

Hmmm... for some reason, it's just not doing anything now. Well, it's actually duplicating the enemy animations again, but I can probably just comment that out later. But as for the animation effects... it seems to have no effect.

1673802230210.png

Here is where I edited the states to give me the animations I'd need, and I *think* I did it right? But I tried Envolt (state 27), using a bladed weapon (which uses animation 6), and it should therefore change it to animation 10 (lightning slash), but it doesn't. It just gives me a regular slash animation.
Ack, sorry! OK, I tested it this time:
Spoiler: plugin code v3
JavaScript:
/*:
 * @target MZ
 * @plugindesc Attack animation trait tags.
 * @author Caethyril
 * @help Tag for use on any trait-bearing object:
 *      <attack anim add: X>
 * e.g. <attack anim add: 1>
 *      - adds X to ID of attack animation.
 * If multiple tags apply, the one with the highest value will be used.
 *
 * Edit the stateMap object in the code to customise how states transform
 * one animation into another.
 *
 * ----------------------------------------------------------------------------
 * Terms of use:
 *   MIT License: https://opensource.org/licenses/mit-license.html
 *   
 * [[ BEGIN LICENSE TEXT ]]
 * 
 *   Copyright © 2022 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 ]]
 */
void (() => {
'use strict';

    /**
     * Tag name for additive bonus to attack animation ID.
     * E.g. for an elemental power-up state.
     */
    const TAG_NAME_ADD  = 'attack anim add';    // e.g. ice power-up state

    /**
     * Structure is `stateId: { defaultAnimId : newAnimId }`.
     * Defines pairwise map for attack animation ID, per state.
     * Attack animation IDs not listed will remain unchanged.
     */
    const stateMap = {
         15: { 1: 2, 6: 7, 11: 12, 16: 17 },
         16: { 1: 3, 6: 8, 11: 13, 16: 18 },
         17: { 1: 4, 6: 9, 11: 14, 16: 19 }
    };

    /**
     * Returns base attack animation ID, by referencing {@linkcode stateMap}.
     * @param {Game_Battler} battler reference battler
     * @param {number} [dFault=1] base value if no relevant states found (default: 1)
     * @returns {number} override base value for animation ID
     */
    const getAttackAnimBase = function(battler, dFault = 1) {
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10)))
            if (battler.isStateAffected(id)) {
                const newId = stateMap[id][dFault];
                if (newId)
                    return newId;
            }
        return dFault;
    };

    /**
     * Returns largest applicable offset.
     * @param {Game_Battler} battler reference battler
     * @returns {number} additive offset for attack animation ID
     */
    const getAttackAnimOffset = function(battler) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_ADD], 10);
            return v > a ? v : a;
        }, 0);
    };

    /**
     * @param {Game_Enemy} subject reference enemy
     * @returns {number} attack animation ID
     */
    const enemyAttackAnimId = function(subject) {
        return getAttackAnimBase(subject) + getAttackAnimOffset(subject);
    };

    // Apply offsets for actor attack animations.
    void (alias => {
        Game_Actor.prototype.attackAnimationId1 = function() {
            return getAttackAnimBase(this, alias.apply(this, arguments)) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId1);
    void (alias => {
        Game_Actor.prototype.attackAnimationId2 = function() {
            return getAttackAnimBase(this, alias.apply(this, arguments)) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId2);

})();
The problem was that it was only applying to unarmed attack animations, since that's what the "base" tag was for in the original plugin. I'd just forgotten to change that...now it should work with weapons as well. 😴

I also removed the enemy attack animation part, since you said it was conflicting. And yes, it sounds like you edited the correct values! Hopefully the new code works for you~ 😅
Ack, sorry! OK, I tested it this time:
Spoiler: plugin code v3
JavaScript:
/*:
 * @target MZ
 * @plugindesc Attack animation trait tags.
 * @author Caethyril
 * @help Tag for use on any trait-bearing object:
 *      <attack anim add: X>
 * e.g. <attack anim add: 1>
 *      - adds X to ID of attack animation.
 * If multiple tags apply, the one with the highest value will be used.
 *
 * Edit the stateMap object in the code to customise how states transform
 * one animation into another.
 *
 * ----------------------------------------------------------------------------
 * Terms of use:
 *   MIT License: https://opensource.org/licenses/mit-license.html
 *  
 * [[ BEGIN LICENSE TEXT ]]
 *
 *   Copyright © 2022 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 ]]
 */
void (() => {
'use strict';

    /**
     * Tag name for additive bonus to attack animation ID.
     * E.g. for an elemental power-up state.
     */
    const TAG_NAME_ADD  = 'attack anim add';    // e.g. ice power-up state

    /**
     * Structure is `stateId: { defaultAnimId : newAnimId }`.
     * Defines pairwise map for attack animation ID, per state.
     * Attack animation IDs not listed will remain unchanged.
     */
    const stateMap = {
         15: { 1: 2, 6: 7, 11: 12, 16: 17 },
         16: { 1: 3, 6: 8, 11: 13, 16: 18 },
         17: { 1: 4, 6: 9, 11: 14, 16: 19 }
    };

    /**
     * Returns base attack animation ID, by referencing {@linkcode stateMap}.
     * @param {Game_Battler} battler reference battler
     * @param {number} [dFault=1] base value if no relevant states found (default: 1)
     * @returns {number} override base value for animation ID
     */
    const getAttackAnimBase = function(battler, dFault = 1) {
        for (const id of Object.keys(stateMap).map(k => parseInt(k, 10)))
            if (battler.isStateAffected(id)) {
                const newId = stateMap[id][dFault];
                if (newId)
                    return newId;
            }
        return dFault;
    };

    /**
     * Returns largest applicable offset.
     * @param {Game_Battler} battler reference battler
     * @returns {number} additive offset for attack animation ID
     */
    const getAttackAnimOffset = function(battler) {
        return battler.traitObjects().reduce((a, c) => {
            const v = parseInt(c.meta[TAG_NAME_ADD], 10);
            return v > a ? v : a;
        }, 0);
    };

    /**
     * @param {Game_Enemy} subject reference enemy
     * @returns {number} attack animation ID
     */
    const enemyAttackAnimId = function(subject) {
        return getAttackAnimBase(subject) + getAttackAnimOffset(subject);
    };

    // Apply offsets for actor attack animations.
    void (alias => {
        Game_Actor.prototype.attackAnimationId1 = function() {
            return getAttackAnimBase(this, alias.apply(this, arguments)) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId1);
    void (alias => {
        Game_Actor.prototype.attackAnimationId2 = function() {
            return getAttackAnimBase(this, alias.apply(this, arguments)) + getAttackAnimOffset(this);
        };
    })(Game_Actor.prototype.attackAnimationId2);

})();
The problem was that it was only applying to unarmed attack animations, since that's what the "base" tag was for in the original plugin. I'd just forgotten to change that...now it should work with weapons as well. 😴

I also removed the enemy attack animation part, since you said it was conflicting. And yes, it sounds like you edited the correct values! Hopefully the new code works for you~ 😅

It works! 😀

I tested it unarmed and with a weapon, and it's displaying the correct animation now! Thank you so much! 😀
Great! Sorry again about the mix-ups, I should've actually tested the edits before posting.

Happy RPG Making~ 😂

Original thread: https://forums.rpgmakerweb.com/threads/is-there-any-way-to-make-a-state-change-an-actors-attack-animation-based-on-their-weapon-type.153935/