Triggering attack motion

Just as the title above states, how do I trigger the attack motion anytime, in and out of battle? Without the use of prebuilt scripts, I'd like to learn a little bit more of the underlying system. I do know javascript so coding is ok, just not prebuilt stuff like yanfly or what have you. I want the bare minimum raw code and process on how to do this. Can anybody help?
Are you wanting to do this with the database + eventing or are you wanting help to create a mini custom plugin?
An explanation on how to do both if its ok! I'd like to know the limitations of using the event system for something like this since I'm sure there are a bunch of tips and tricks that I don't know yet.
Okay, in that case I'll leave it here in MV. If this isn't possible just with eventing, then it will have to be moved, but let's see what suggestions there are first.
The attack motion is tied to the attack skill, i.e. skill #1 in the database. To invoke a particular motion at any time, you will, at minimum, need a script call. Also note that I'm assuming you're not using any plugins that change the battle scene; if you are, you may need a different method.

Try putting this as a script call into a troop event with Condition: Turn 0 and Scope: Battle. Make sure actor #1 is in the party, battle test, and watch what they do immediately after the "emerge" message is closed:
Code:
$gameActors.actor(1).requestMotion('swing');
The different motion names (like 'swing') are as follows, ordered as in the sv battle sprite sheet:
Code:
walk     thrust    escape
wait     swing     victory
chant    missile   dying
guard    skill     abnormal
damage   spell     sleep
evade    item      dead
Extracting the attack motion (and, if you want it, the weapon sprite) associated with the currently-equipped weapon is somewhat more difficult. For reference, since you state you're interested in the underlying system, here's the function (found in rpg_objects.js):
Code:
Game_Actor.prototype.performAttack = function() {
    var weapons = this.weapons();
    var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
    var attackMotion = $dataSystem.attackMotions[wtypeId];
    if (attackMotion) {
        if (attackMotion.type === 0) {
            this.requestMotion('thrust');
        } else if (attackMotion.type === 1) {
            this.requestMotion('swing');
        } else if (attackMotion.type === 2) {
            this.requestMotion('missile');
        }
        this.startWeaponAnimation(attackMotion.weaponImageId);
    }
};
However, for easier manipulation of motions I would recommend two of Yanfly's plugins: Battle Engine Core and Action Sequence Pack 2. The former overhauls the battle system, adding action sequences to allow you to specify exactly how skills play out in battle. Sequence Pack 2 adds a few extra action calls, including the ability to specify a battler's motion at a given point. There may be other plugins out there that achieve the same thing (Victor Engine?).
As far as I'm aware, there's no way to trigger the Attack motion outside of battle. You're using a completely different sprite sheet on the map and it's just a walking character. You could, I suppose, manually draw a new sprite sheet with different attack motions in them and use the Change Image command to switch between them but that might be tough to squeeze in such a small space (48x48). RPG Maker wasn't really designed for on-map battling so that usually requires some pretty heavy plugins to pull off.
Just got home, many thanks for this! I'll try it out and post my results a little later(Or tomorrow lol!).

Original thread: https://forums.rpgmakerweb.com/threads/triggering-attack-motion.91970/