Trying to get it like how RuneScape's is. If you're standing still following someone you'll dance with them.
Code:
public void followPlayer() {
if (PlayerHandler.players[c.followId] == null
|| PlayerHandler.players[c.followId].isDead) {
resetFollow();
return;
}
if (c.underAttackBy > 0 || c.underAttackBy2 > 0) {
return;
}
if (c.freezeTimer > 0) {
return;
}
if (c.isDead || c.playerLevel[3] <= 0)
return;
int otherX = PlayerHandler.players[c.followId].getX();
int otherY = PlayerHandler.players[c.followId].getY();
boolean sameSpot = (c.absX == otherX && c.absY == otherY);
boolean hallyDistance = c.goodDistance(otherX, otherY, c.getX(),
c.getY(), 2);
boolean rangeWeaponDistance = c.goodDistance(otherX, otherY, c.getX(),
c.getY(), 4);
boolean bowDistance = c.goodDistance(otherX, otherY, c.getX(),
c.getY(), 6);
boolean mageDistance = c.goodDistance(otherX, otherY, c.getX(),
c.getY(), 7);
boolean castingMagic = (c.usingMagic || c.mageFollow || c.autocasting || c.spellId > 0)
&& mageDistance;
boolean playerRanging = (c.usingRangeWeapon) && rangeWeaponDistance;
boolean playerBowOrCross = (c.usingBow) && bowDistance;
boolean ranging = false;
for (int bowId : c.BOWS) {
if (c.playerEquipment[c.playerWeapon] == bowId) {
ranging = true;
}
}
if (!c.goodDistance(otherX, otherY, c.getX(), c.getY(), 25)) {
c.followId = 0;
resetFollow();
return;
}
c.faceUpdate(c.followId + 32768);
if (!sameSpot) {
if (c.playerIndex > 0 && !c.usingSpecial && c.inWild()) {
if (c.usingSpecial && (playerRanging || playerBowOrCross)) {
c.stopMovement();
return;
}
if (castingMagic || playerRanging || playerBowOrCross
|| (ranging && bowDistance)) {
c.stopMovement();
return;
}
if (c.getCombat().usingHally() && hallyDistance) {
c.stopMovement();
return;
}
}
}
if (otherX == c.absX && otherY == c.absY) {
int r = Misc.random(3);
switch (r) {
case 0:
walkTo(0, -1);
break;
case 1:
walkTo(0, 1);
break;
case 2:
walkTo(1, 0);
break;
case 3:
walkTo(-1, 0);
break;
}
} else if (c.isRunning2) {
if (otherY > c.getY() && otherX == c.getX()) {
playerWalk(otherX, otherY - 1);
} else if (otherY < c.getY() && otherX == c.getX()) {
playerWalk(otherX, otherY + 1);
} else if (otherX > c.getX() && otherY == c.getY()) {
playerWalk(otherX - 1, otherY);
} else if (otherX < c.getX() && otherY == c.getY()) {
playerWalk(otherX + 1, otherY);
} else if (otherX < c.getX() && otherY < c.getY()) {
playerWalk(otherX + 1, otherY + 1);
} else if (otherX > c.getX() && otherY > c.getY()) {
playerWalk(otherX - 1, otherY - 1);
} else if (otherX < c.getX() && otherY > c.getY()) {
playerWalk(otherX + 1, otherY - 1);
} else if (otherX > c.getX() && otherY < c.getY()) {
playerWalk(otherX + 1, otherY - 1);
}
} else {
if (otherY > c.getY() && otherX == c.getX()) {
playerWalk(otherX, otherY - 1);
} else if (otherY < c.getY() && otherX == c.getX()) {
playerWalk(otherX, otherY + 1);
} else if (otherX > c.getX() && otherY == c.getY()) {
playerWalk(otherX - 1, otherY);
} else if (otherX < c.getX() && otherY == c.getY()) {
playerWalk(otherX + 1, otherY);
} else if (otherX < c.getX() && otherY < c.getY()) {
playerWalk(otherX + 1, otherY + 1);
} else if (otherX > c.getX() && otherY > c.getY()) {
playerWalk(otherX - 1, otherY - 1);
} else if (otherX < c.getX() && otherY > c.getY()) {
playerWalk(otherX + 1, otherY - 1);
} else if (otherX > c.getX() && otherY < c.getY()) {
playerWalk(otherX - 1, otherY + 1);
}
}
c.faceUpdate(c.followId + 32768);
}