Guest User

Untitled

a guest
Sep 14th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. package com.rs.game.player.actions;
  2.  
  3. import com.rs.Settings;
  4. import com.rs.game.Animation;
  5. import com.rs.game.Graphics;
  6. import com.rs.game.World;
  7. import com.rs.game.WorldTile;
  8. import com.rs.game.player.Player;
  9. import com.rs.game.player.content.Magic;
  10. import com.rs.utils.Utils;
  11.  
  12. public class HomeTeleport extends Action {
  13.  
  14. protected static final int HOME_ANIMATION = 7389;
  15. protected static final int HOME_GRAPHIC = 91;
  16. protected static final int DONE_ANIMATION = 16386;
  17. public static final WorldTile REAL_HOME_TELEPORT = new WorldTile(3102, 3499, 0);
  18.  
  19.  
  20. private int currentTime;
  21. private WorldTile tile;
  22.  
  23. @Override
  24. public boolean start(final Player player) {
  25. tile = Settings.RESPAWN_PLAYER_LOCATION;
  26. if (!player.getControlerManager().processMagicTeleport(tile))
  27. return false;
  28. return process(player);
  29. }
  30.  
  31. @Override
  32. public int processWithDelay(Player player) {
  33. player.getWalkSteps().clear();
  34. if (currentTime++ == 0) {
  35. player.setNextAnimation(new Animation(HOME_ANIMATION));
  36. player.setNextGraphics(new Graphics(HOME_GRAPHIC));
  37. } else if (currentTime == 17) {
  38. WorldTile teleTile = tile;
  39. // attemps to randomize tile by 4x4 area
  40. for (int trycount = 0; trycount < 10; trycount++) {
  41. teleTile = new WorldTile(tile, 2);
  42. if (World.canMoveNPC(tile.getPlane(), teleTile.getX(),
  43. teleTile.getY(), player.getSize()))
  44. break;
  45. teleTile = tile;
  46. }
  47. player.setNextWorldTile(teleTile);
  48. player.setNextAnimation(new Animation(HOME_ANIMATION + 1));
  49. player.setNextGraphics(new Graphics(HOME_GRAPHIC + 1));
  50. player.getControlerManager().magicTeleported(Magic.MAGIC_TELEPORT);
  51. if (player.getControlerManager().getControler() == null)
  52. Magic.teleControlersCheck(player, teleTile);
  53. return 0;
  54. } else if (currentTime == 21) {
  55. player.setNextAnimation(new Animation(-1));
  56. player.setNextGraphics(new Graphics(-1));
  57. return -1;
  58. }
  59. return 0;
  60. }
  61.  
  62. @Override
  63. public boolean process(Player player) {
  64. if (player.getAttackedByDelay() + 10000 > Utils.currentTimeMillis()) {
  65. player.getPackets()
  66. .sendGameMessage(
  67. "You can't home teleport until 10 seconds after the end of combat.");
  68. return false;
  69. }
  70. return true;
  71. }
  72.  
  73. @Override
  74. public void stop(Player player) {
  75. player.setNextAnimation(new Animation(-1));
  76. player.setNextGraphics(new Graphics(-1));
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment