예제 #1
0
 public static void pushLeverTeleport(final Player player, final WorldTile tile) {
   if (!player.getControlerManager().processObjectTeleport(tile)) return;
   player.setNextAnimation(new Animation(2140));
   player.lock();
   WorldTasksManager.schedule(
       new WorldTask() {
         @Override
         public void run() {
           player.unlock();
           Magic.sendObjectTeleportSpell(player, false, tile);
         }
       },
       1);
 }
예제 #2
0
  public static boolean useTeleTab(final Player player, final WorldTile tile) {
    if (!player.getControlerManager().processItemTeleport(tile)) return false;
    player.lock();
    player.setNextAnimation(new Animation(9597));
    player.setNextGraphics(new Graphics(1680));
    WorldTasksManager.schedule(
        new WorldTask() {
          int stage;

          @Override
          public void run() {
            if (stage == 0) {
              player.setNextAnimation(new Animation(4731));
              stage = 1;
            } else if (stage == 1) {
              WorldTile teleTile = tile;
              // attemps to randomize tile by 4x4 area
              for (int trycount = 0; trycount < 10; trycount++) {
                teleTile = new WorldTile(tile, 2);
                if (World.canMoveNPC(
                    tile.getPlane(), teleTile.getX(), teleTile.getY(), player.getSize())) break;
                teleTile = tile;
              }
              player.setNextWorldTile(teleTile);
              player.getControlerManager().magicTeleported(ITEM_TELEPORT);
              if (player.getControlerManager().getControler() == null)
                teleControlersCheck(player, teleTile);
              player.setNextFaceWorldTile(
                  new WorldTile(teleTile.getX(), teleTile.getY() - 1, teleTile.getPlane()));
              player.setDirection(6);
              player.setNextAnimation(new Animation(-1));
              stage = 2;
            } else if (stage == 2) {
              player.resetReceivedDamage();
              player.unlock();
              stop();
            }
          }
        },
        2,
        1);
    return true;
  }
예제 #3
0
  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 boolean randomize,
      final int teleType,
      int... runes) {
    long currentTime = Utils.currentTimeMillis();
    if (player.getLockDelay() > currentTime) return false;
    if (player.getSkills().getLevel(Skills.MAGIC) < level) {
      player.getPackets().sendGameMessage("Your Magic level is not high enough for this spell.");
      return false;
    }
    if (!checkRunes(player, false, runes)) return false;
    if (teleType == MAGIC_TELEPORT) {
      if (!player.getControlerManager().processMagicTeleport(tile)) return false;
    } else if (teleType == ITEM_TELEPORT) {
      if (!player.getControlerManager().processItemTeleport(tile)) return false;
    } else if (teleType == OBJECT_TELEPORT) {
      if (!player.getControlerManager().processObjectTeleport(tile)) return false;
    }
    checkRunes(player, true, runes);
    player.stopAll();
    if (upEmoteId != -1) player.setNextAnimation(new Animation(upEmoteId));
    if (upGraphicId != -1) player.setNextGraphics(new Graphics(upGraphicId));
    if (teleType == MAGIC_TELEPORT) player.getPackets().sendSound(5527, 0, 2);
    player.lock(3 + delay);
    WorldTasksManager.schedule(
        new WorldTask() {

          boolean removeDamage;

          @Override
          public void run() {
            if (!removeDamage) {
              WorldTile teleTile = tile;
              if (randomize) {
                // attemps to randomize tile by 4x4 area
                for (int trycount = 0; trycount < 10; trycount++) {
                  teleTile = new WorldTile(tile, 2);
                  if (World.canMoveNPC(
                      tile.getPlane(), teleTile.getX(), teleTile.getY(), player.getSize())) break;
                  teleTile = tile;
                }
              }
              player.setNextWorldTile(teleTile);
              player.getControlerManager().magicTeleported(teleType);
              if (player.getControlerManager().getControler() == null)
                teleControlersCheck(player, teleTile);
              if (xp != 0) player.getSkills().addXp(Skills.MAGIC, xp);
              if (downEmoteId != -1)
                player.setNextAnimation(new Animation(downEmoteId == -2 ? -1 : downEmoteId));
              if (downGraphicId != -1) player.setNextGraphics(new Graphics(downGraphicId));
              if (teleType == MAGIC_TELEPORT) {
                player.getPackets().sendSound(5524, 0, 2);
                player.setNextFaceWorldTile(
                    new WorldTile(teleTile.getX(), teleTile.getY() - 1, teleTile.getPlane()));
                player.setDirection(6);
              }
              removeDamage = true;
            } else {
              player.resetReceivedDamage();
              stop();
            }
          }
        },
        delay,
        0);
    return true;
  }