Now I'm sure tons of you have seen ganodermic beasts, new chickens, and grotworms sliding around in a T-Pose when they should be animating while walking.
I am sure some of you have seen this wonky hardcode fix going around (this example is from Matrix 3's polypore npc code)
Code:
@Override
public void processMovement() {
super.processMovement();
if (realId == 14696 && getNextWalkDirection() != -1) {
this.setNextAnimation(new Animation(15465));
this.setNextForceMovement(new NewForceMovement(this, 1, null, 0, Utils.getAngle(Utils.DIRECTION_DELTA_X[getNextWalkDirection()], Utils.DIRECTION_DELTA_Y[getNextWalkDirection()])));
}
}
Basically forcing a movement animation using forcemovement. Well the render animation definitions of the monster hold animations for a third movement type. Not walking, not running.It seems to be used for monsters that move either half speed of normal monsters, or monsters that move 2 squares in one direction at a time such as ganodermic beasts.
The correct way to trigger this animation to be used directly from the render animation of the npc is to just have an exception inside where it updates an npc to be "running".
As you can see in the client code here where the client determines which render animation to use, there is a "teleport" animation type. I only call it teleport because it's the same movement type id that players use in player update as a teleport movement. Should probably rename it to SPECIAL or something instead.
Here is where the client determines if the NPC uses this specific type of movement so you can update your NPC update methods accordingly: NPCDefinitions here
If you're using Matrix's crazy ass control flow for NPC updating, here's where you'd make the change:
Code:
if (n.getNextRunDirection() == -1) {
if (n.getDefinitions().walksSpecial()) {
stream.writeBits(2, 2);
stream.writeBits(1, 0);
stream.writeBits(3, Utils.getNpcMoveDirection(n.getNextWalkDirection()));
} else {
stream.writeBits(2, 1);
stream.writeBits(3, Utils.getNpcMoveDirection(n.getNextWalkDirection()));
}
} else {
stream.writeBits(2, 2);
stream.writeBits(1, 1);
stream.writeBits(3, Utils.getNpcMoveDirection(n.getNextWalkDirection()));
stream.writeBits(3, Utils.getNpcMoveDirection(n.getNextRunDirection()));
}