Originally Posted by
Victim
This is a ongoing problem in p.i, it's apparently very difficult to fix this but i haven't tried so what do i know.
What are you talking about?
Here, use my stairHandler. I didn't quite finish it, but its functional.
Code:
package server.model.objects;
import server.model.players.Client;
/**
*
* @author Faris
*/
public class Stairs {
/**
* Deciphers movement position based upon current height-level
* @param c
* @param stairs
*/
public static void handleStairs(Client c, final int stairs){
steps(c);
if (stairs != 1738) {
if (c.heightLevel == 0) {
c.getPA().movePlayer(c.absX, c.absY, 1);
} else if (c.heightLevel == 1) {
c.getPA().movePlayer(c.absX, c.absY, 0);
} else if (c.heightLevel == 2) {
c.getPA().movePlayer(c.absX, c.absY, 1);
} else if (c.heightLevel == 3) {
c.getPA().movePlayer(c.absX, c.absY, 2);
}
} else {
c.getPA().movePlayer(c.absX, c.absY, c.heightLevel+1);
}
}
/**
* hands two way up - down options for stairs
* @param c
* @param climbType
*/
public static void stairsOption(Client c,final String climbType) {
c.stairsInteracting = false;
steps(c);
if (climbType.equalsIgnoreCase("up")) {
c.getPA().movePlayer(c.absX, c.absY, c.heightLevel += 1);
}
if (climbType.equalsIgnoreCase("down")) {
c.getPA().movePlayer(c.absX, c.absY, c.heightLevel -= 1);
}
}
/**
* Sends two way up - down options for stairs
* @param c
*/
public static void getStairsOption(Client c) {
c.stairsInteracting = true;
String s = "Climb up the stairs.", s1 = "Climb down the stairs.";
c.getDH().sendOption2(s, s1);
}
/**
* Misc stairs actions (EG Facing, closing windows)
* @param c
*/
private static void steps(Client c){
int x = c.objectX, y = c.objectY;
faceStairs(c, x, y);
c.resetWalkingQueue();
c.getPA().requestUpdates();
c.getPA().removeAllWindows();
c.stopMovement();
}
/**
* Turns player toward stairs
* @param c
* @param x
* @param y
*/
private static void faceStairs(Client c, final int x, final int y) {
if (c.FocusPointX >= x) {
c.turnPlayerTo(0, y - 2);
} else if (c.FocusPointY >= y) {
c.turnPlayerTo(x - 2, 0);
} else if (c.FocusPointX < x) {
c.turnPlayerTo(x, y);
} else if (c.FocusPointY <= y) {
c.turnPlayerTo(x, y);
}
}
}