I took this following class from another server and converted it to mine, and it worked. Then I wanted to add a 'npcwalkback' method so that the npc would walk back to its original location and now I have this unreachable code error. This is hyperion (Scu11's 474).
Code:
private void npcWalkBack() {
if (Misc.getDistance(mob.getLocation(), victim.getLocation()) > 7) {
//mob.face(Entity.DEFAULT_LOCATION);
mob.getWalkingQueue().addStep(Entity.DEFAULT_LOCATION.getLocalX(), Entity.DEFAULT_LOCATION.getLocalY());
// TODO Auto-generated method stub
}
}
public boolean step() {
/* 66*/ if (mob == null || victim == null) {
/* 67*/ return false;
}
/* 69*/ if (mob.getInteractingEntity() != victim && mob.getInteractingEntity() != null) {
/* 70*/ return false;
}
/* 72*/ if (mob.getSkills().getLevel(3) < 1 || victim.getSkills().getLevel(3) < 1) {
/* 74*/ return false;
}
/* 76*/ if (mob instanceof NPC) {
/* 77*/ int id = ((NPC)mob).getDefinition().getId();
/* 78*/ switch (id) {
/* 81*/ case 3847:
/* 81*/ case 3943:
/* 81*/ return false;
}
}
/* 84*/ if (Misc.getDistance(mob.getLocation(), victim.getLocation()) > 7) {
/* 85*/ return false;
npcWalkBack();
}
/* 87*/ if (Misc.getDistance(mob.getLocation(), victim.getLocation()) <= 1) {
/* 88*/ return true;
}
/* 90*/ if (!mob.getCombatState().canMove()) {
/* 91*/ return true;
}
/* 93*/ int x = 0;
/* 93*/ int y = 0;
/* 94*/ if (mob.getLocation().getX() < victim.getLocation().getX()) {
/* 95*/ x++;
} else
/* 97*/ if (mob.getLocation().getX() > victim.getLocation().getX()) {
/* 98*/ x--;
}
/* 100*/ if (mob.getLocation().getY() < victim.getLocation().getY()) {
/* 101*/ y++;
} else
/* 103*/ if (mob.getLocation().getY() > victim.getLocation().getY()) {
/* 104*/ y--;
}
/* 106*/ Location newLocation = Location.create(mob.getLocation().getX() + x, mob.getLocation().getY() + y, mob.getLocation().getZ());
//
//
/* 138*/ mob.getWalkingQueue().addStep(newLocation.getX(), newLocation.getY());
/* 139*/ mob.getWalkingQueue().finish();
/* 140*/ if (mob instanceof Player) {
/* 141*/ mob.face(victim.getLocation());
/* 142*/ mob.getWalkingQueue().setRunningToggled(true);
/* 143*/ mob.getWalkingQueue().setRunningQueue(true);
}
/* 145*/ return true;
}
}