Guest User

Magic.java

a guest
Jul 5th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.88 KB | None | 0 0
  1. In Magic.java
  2.  
  3. public static void useEctophial(final Player player, Item item, final int slotId) {
  4.         Item ectophial = player.getInventory().getItem(slotId);
  5.         player.stopAll();
  6.         player.lock(7);
  7.     player.setNextGraphics(new Graphics(1688));
  8.     player.setNextAnimation(new Animation(9609));
  9.     WorldTasksManager.schedule(new WorldTask() {
  10.         @Override
  11.         public void run() {
  12.                 ectophial.setId(4252);
  13.                 player.getInventory().refresh(slotId);
  14.         sendTeleportSpell(player, 8939, 8941, 1678, 1679, 0, 0, new WorldTile(3659, 3523, 0), 4, 2, 1, ITEM_TELEPORT);
  15.         }
  16.     }, 6);
  17. }
  18.  
  19. Change this in InventoryOptionsHandler.java
  20.  
  21. else if (itemId == 4251) {
  22.                     Magic.useEctophial(player, item, slotId);
  23. }
  24.  
  25. Change SendTeleportSpell in Magic.java to this:
  26.  
  27. public static final boolean sendTeleportSpell(final Player player, int upEmoteId, final int downEmoteId, int upGraphicId, final int downGraphicId, int level, final double xp, final WorldTile tile, int delay, final int randomizeX, final int randomizeY, final int teleType, int... runes) {
  28.     if (player.isLocked())
  29.         return false;
  30.     if (player.getSkills().getLevel(Skills.MAGIC) < level) {
  31.         player.getPackets().sendGameMessage("Your Magic level is not high enough for this spell.");
  32.         return false;
  33.     }
  34.     if (!checkRunes(player, false, runes))
  35.         return false;
  36.         switch (teleType) {
  37.             case MAGIC_TELEPORT:
  38.                 if (!player.getControlerManager().processMagicTeleport(tile))
  39.                     return false;
  40.                 break;
  41.             case ITEM_TELEPORT:
  42.                 if (!player.getControlerManager().processItemTeleport(tile))
  43.                     return false;
  44.                 break;
  45.             case OBJECT_TELEPORT:
  46.                 if (!player.getControlerManager().processObjectTeleport(tile))
  47.                     return false;
  48.                 break;
  49.             default:
  50.                 break;
  51.         }
  52.     checkRunes(player, true, runes);
  53.     player.stopAll();
  54.     if (upEmoteId != -1)
  55.         player.setNextAnimation(new Animation(upEmoteId));
  56.     if (upGraphicId != -1)
  57.         player.setNextGraphics(new Graphics(upGraphicId));
  58.     if (teleType == MAGIC_TELEPORT)
  59.         player.getPackets().sendSound(5527, 0, 2);
  60.     player.lock(3 + delay);
  61.     WorldTasksManager.schedule(new WorldTask() {
  62.  
  63.         boolean removeDamage;
  64.  
  65.         @Override
  66.         public void run() {
  67.         if (!removeDamage) {
  68.             WorldTile teleTile = tile;
  69.             if (randomizeX > 0 || randomizeY > 0) {
  70.             for (int trycount = 0; trycount < 10; trycount++) {
  71.                 teleTile = new WorldTile(tile, randomizeX, randomizeY);
  72.                 if (World.isTileFree(tile.getPlane(), teleTile.getX(), teleTile.getY(), player.getSize()))
  73.                 break;
  74.                 teleTile = tile;
  75.             }
  76.             }
  77.             player.setNextWorldTile(teleTile);
  78.             player.getControlerManager().magicTeleported(teleType);
  79.             if (player.getControlerManager().getControler() == null)
  80.             teleControlersCheck(player, teleTile);
  81.             if (xp != 0)
  82.             player.getSkills().addXp(Skills.MAGIC, xp);
  83.             if (downEmoteId != -1)
  84.             player.setNextAnimation(new Animation(downEmoteId == -2 ? -1 : downEmoteId));
  85.             if (downGraphicId != -1)
  86.             player.setNextGraphics(new Graphics(downGraphicId));
  87.             if (teleType == MAGIC_TELEPORT) {
  88.             player.getPackets().sendSound(5524, 0, 2);
  89.             player.setNextFaceWorldTile(new WorldTile(teleTile.getX(), teleTile.getY() - 1, teleTile.getPlane()));
  90.             player.setDirection(6);
  91.             }
  92.             removeDamage = true;
  93.         } else {
  94.             player.resetReceivedHits();
  95.             stop();
  96.         }
  97.         }
  98.     }, delay, 0);
  99.     return true;
  100. }
  101.  
  102. WorldTile in WorldTile.java to this:
  103.  
  104. public WorldTile(WorldTile tile, int randomizeX, int randomizeY) {
  105.         this.x = (short) (tile.x + Utils.getRandom(randomizeX * 2) - randomizeX);
  106.         this.y = (short) (tile.y + Utils.getRandom(randomizeY * 2) - randomizeY);
  107.         this.plane = tile.plane;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment