MV Actor/Event Step animation speed

Hi community,

I need either a snippet or a small plugin (modification) to [ActorStepAnim] to increase
the step animation to actor (and events) by notetag.

While Shaz ActorStepAnim uses <stepanim> to make it stepping animation.
While I got another plugin [MoreCharacterFrames] the animation works smoother.

When using the a small code from the core plugin:

JavaScript:
Game_Player.prototype.animationWait = function() {
  return (9 - this.realMoveSpeed()) * 3;
};

// and change to new behavior

Game_Player.prototype.animationWait = function() {
  return 2; //(9 - this.realMoveSpeed()) * 3;
};

it can work nice when you dont move, but problem is, when moving, it increases the speed
of the animation (for actor/actors only), but that is something I dont like.

I hope someone can make a snippet or small function that does work for actor & event notetag
to change the speed and keep that speed when walking (I dont use dash function).

but even it might be usefull to increase dash notetag (if used) by other people using those plugins.

Prefered notetag for Actor/Events <stepanimspeed: speedvalue>
for people that might use dash <stepanimdash: speedvalue>

(as I might be using this plugin in my main project too) so it can be usefull.
A character's stepping frame, i.e. pattern, updates when their _animationCount tracker reaches their animationWait time. That counter is updated via the character's updateAnimationCount method.

By default, it animates faster when:
  • ...moving because updateAnimationCount adds an extra +0.5 to the counter in that case.
  • ...dashing because animationWait is 3 frames less in that case (real speed = walk speed + 1).

Something like this might work (untested):
Spoiler: plugin code
JavaScript:
/*:
 * @target MV
 * @plugindesc Some character animation changes.
 * @help Free to use and/or modify for any project, no credit required.
 */

// Override! All characters update their pattern every 2 frames.
Game_CharacterBase.prototype.animationWait = function() {
  return 2;
};

// Notetag-based overrides~
void (function() {
  // e.g. <step anim wait: 5> for 5 frames between pattern updates
  var TAG_NAME = 'step anim wait';

  // Patch - check party leader for notetag.
  var alias_player = Game_Player.prototype.animationWait;
  Game_Player.prototype.animationWait = function() {
    var actor = $gameParty.leader();
    if (actor) {
      var tag = parseInt(actor.actor().meta[TAG_NAME], 10);
      if (tag) return tag;
    }
    return alias_player.apply(this, arguments);
  };

  // Patch - check follower for notetag.
  var alias_follower = Game_Follower.prototype.animationWait;
  Game_Follower.prototype.animationWait = function() {
    var actor = this.actor();
    if (actor) {
      var tag = parseInt(actor.actor().meta[TAG_NAME], 10);
      if (tag) return tag;
    }
    return alias_follower.apply(this, arguments);
  };

  // Patch - check map events for notetag.
  var alias_event = Game_Event.prototype.animationWait;
  Game_Event.prototype.animationWait = function() {
    var tag = parseInt(this.event().meta[TAG_NAME], 10);
    return tag ? tag : alias_event.apply(this, arguments);
  };

})();

// Patch - cancel out extra core script animation speed when moving.
void (function(alias) {
  Game_CharacterBase.prototype.updateAnimationCount = function() {
    alias.apply(this, arguments);
    if (this.isMoving() && this.hasWalkAnime())
      this._animationCount -= 0.5;
  };
})(Game_CharacterBase.prototype.updateAnimationCount);
I tested it, and set the base character speed instead of 2, on (9 + realtimeSpeed...)
as it doesn't need to be anywhere.

as it is working for actor and event nicely, I got 1 question,
what exactly does "void" before the function.

after that, it can be closed, its working perfectly.

thank you alot ^^
If you don't want to apply this change:
JavaScript:
// Override! All characters update their pattern every 2 frames.
Game_CharacterBase.prototype.animationWait = function() {
  return 2;
};
...then I'd suggest you just remove it from my plugin. That way it will use the existing function, e.g. the core script's (9 - this.realMoveSpeed()) * 3. Otherwise, note that this has a - sign, not a +. 👋

The void stuff is just my coding style.
Spoiler: technical explanation
JavaScript uses automatic semi-colon insertion, so an IIFE (i.e. (function() {...})()) can look like the arguments of a function from a previous line. As such, it can be good practice to preface IIFEs with either a line terminator (i.e. ;) or something like void:
Then if there's a mistake, the error message should be much easier to interpret and fix. I usually prefer void because it's more clearly intentional. 😮‍💨

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/actor-event-step-animation-speed.151247/