示例#1
0
  private void teleportToCharacter(Player activeChar, GameObject target) {
    if (target == null) return;

    activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
    activeChar.teleToLocation(target.getLoc(), target.getReflectionId());

    activeChar.sendMessage("You have teleported to " + target);
  }
示例#2
0
  private void teleportTo(Player activeChar, Player target, Location loc, int ref) {
    if (!target.equals(activeChar)) target.sendMessage("Admin is teleporting you.");

    target.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
    target.teleToLocation(loc, ref);

    if (target.equals(activeChar))
      activeChar.sendMessage("You have been teleported to " + loc + ", reflection id: " + ref);
  }
示例#3
0
  public void tele() {
    Player player = getSelf();
    NpcInstance npc = getNpc();

    if (player != null && npc != null)
      if (player.getLevel() < 75) show("teleporter/" + npc.getNpcId() + "-4.htm", player);
      else if (player.getAdena() >= 150000) {
        player.reduceAdena(150000, true);
        player.teleToLocation(-149406, 255247, -80);
      } else show("teleporter/" + npc.getNpcId() + "-2.htm", player);
  }
示例#4
0
  @Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();
    if (actor == null) {
      return true;
    }

    for (Player player : World.getAroundPlayers(actor, 500, 500)) {
      if (player == null || !player.isInParty()) {
        continue;
      }

      if (player.getParty().getMemberCount() >= 5 && _tele) {
        _tele = false;
        player.teleToLocation(Rnd.get(locs));
      }
    }

    return true;
  }
示例#5
0
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (command.equals("teleport")) {
      showChatWindow(player, "event/monastyre/minigame_instructor006.htm");
    } else if (command.equals("teleport1")) {
      switch (getAISpawnParam()) {
        case 1:
          player.teleToLocation(110705, -81328, -1600);
          break;
        case 2:
          player.teleToLocation(114866, -71627, -560);
          break;
      }
    } else if (command.equals("teleport2")) {
      player.teleToLocation(110712, -81352, -2688);
    } else if (command.equals("start")) {
      if (player.getInventory().getCountOf(15540) == 0) {
        showChatWindow(player, "event/monastyre/minigame_instructor005.htm");
      } else if (c_ai1 != player) {
        showChatWindow(player, "event/monastyre/minigame_instructor004.htm");
      } else if (c_ai1 == player) {
        switch (getAISpawnParam()) {
          case 1:
            if (HURRY_UP_1 != null) {
              HURRY_UP_1.cancel(false);
              HURRY_UP_1 = null;
            }
            if (HURRY_UP2_1 != null) {
              HURRY_UP2_1.cancel(false);
              HURRY_UP2_1 = null;
            }
            break;
          case 2:
            if (HURRY_UP_2 != null) {
              HURRY_UP_2.cancel(false);
              HURRY_UP_2 = null;
            }
            if (HURRY_UP2_2 != null) {
              HURRY_UP2_2.cancel(false);
              HURRY_UP2_2 = null;
            }
            break;
        }

        player.getInventory().destroyItemByItemId(15540, 1);
        player.getInventory().addItem(15485, 1);
        Functions.npcShout(this, NpcString.FURNFACE1);
        i_ai1 = Rnd.get(9) + 1;
        i_ai2 = Rnd.get(9) + 1;
        i_ai3 = Rnd.get(9) + 1;
        i_ai4 = Rnd.get(9) + 1;
        i_ai5 = Rnd.get(9) + 1;
        i_ai6 = Rnd.get(9) + 1;
        i_ai7 = Rnd.get(9) + 1;
        i_ai8 = Rnd.get(9) + 1;
        i_ai9 = Rnd.get(9) + 1;
        c_ai0 = player;
        if (i_quest9 == 1) {}

        switch (getAISpawnParam()) {
          case 1:
            HURRY_UP_1 = ThreadPoolManager.getInstance().schedule(new HURRY_UP(), 2 * 60 * 1000);
            break;
          case 2:
            HURRY_UP_2 = ThreadPoolManager.getInstance().schedule(new HURRY_UP(), 2 * 60 * 1000);
            break;
        }
        GAME_TIME =
            ThreadPoolManager.getInstance().schedule(new GAME_TIME(), 3 * 60 * 1000 + 10 * 1000);
        TIMER_0 = ThreadPoolManager.getInstance().schedule(new TIMER_0(), 1 * 1000);
      } else if (command.equals("restart")) {
        i_quest1 = 1;
        i_ai1 = Rnd.get(9) + 1;
        i_ai2 = Rnd.get(9) + 1;
        i_ai3 = Rnd.get(9) + 1;
        i_ai4 = Rnd.get(9) + 1;
        i_ai5 = Rnd.get(9) + 1;
        i_ai6 = Rnd.get(9) + 1;
        i_ai7 = Rnd.get(9) + 1;
        i_ai8 = Rnd.get(9) + 1;
        i_ai9 = Rnd.get(9) + 1;
        c_ai0 = player;
        if (i_quest9 == 1) {}
        TIMER_0 = ThreadPoolManager.getInstance().schedule(new TIMER_0(), 1 * 1000);
      }
    } else {
      super.onBypassFeedback(player, command);
    }
  }
示例#6
0
  @SuppressWarnings("rawtypes")
  @Override
  public boolean useAdminCommand(
      Enum comm, String[] wordList, String fullString, Player activeChar) {
    Commands command = (Commands) comm;

    if (!activeChar.getPlayerAccess().CanTeleport) return false;

    switch (command) {
      case admin_show_moves:
        activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/teleports.htm"));
        break;
      case admin_show_moves_other:
        activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/tele/other.htm"));
        break;
      case admin_show_teleport:
        showTeleportCharWindow(activeChar);
        break;
      case admin_teleport_to_character:
        teleportToCharacter(activeChar, activeChar.getTarget());
        break;
      case admin_teleport_to:
      case admin_teleportto:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleportto charName");
          return false;
        }
        String chaName = Util.joinStrings(" ", wordList, 1);
        Player cha = GameObjectsStorage.getPlayer(chaName);
        if (cha == null) {
          activeChar.sendMessage("Player '" + chaName + "' not found in world");
          return false;
        }
        teleportToCharacter(activeChar, cha);
        break;
      case admin_move_to:
      case admin_moveto:
      case admin_teleport:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleport x y z [ref]");
          return false;
        }
        teleportTo(
            activeChar,
            activeChar,
            Util.joinStrings(" ", wordList, 1, 3),
            ArrayUtils.valid(wordList, 4) != null && !ArrayUtils.valid(wordList, 4).isEmpty()
                ? Integer.parseInt(wordList[4])
                : 0);
        break;
      case admin_walk:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //walk x y z");
          return false;
        }
        try {
          activeChar.moveToLocation(Location.parseLoc(Util.joinStrings(" ", wordList, 1)), 0, true);
        } catch (IllegalArgumentException e) {
          activeChar.sendMessage("USAGE: //walk x y z");
          return false;
        }
        break;
      case admin_gonorth:
      case admin_gosouth:
      case admin_goeast:
      case admin_gowest:
      case admin_goup:
      case admin_godown:
        int val = wordList.length < 2 ? 150 : Integer.parseInt(wordList[1]);
        int x = activeChar.getX();
        int y = activeChar.getY();
        int z = activeChar.getZ();
        if (command == Commands.admin_goup) z += val;
        else if (command == Commands.admin_godown) z -= val;
        else if (command == Commands.admin_goeast) x += val;
        else if (command == Commands.admin_gowest) x -= val;
        else if (command == Commands.admin_gosouth) y += val;
        else if (command == Commands.admin_gonorth) y -= val;

        activeChar.teleToLocation(x, y, z);
        showTeleportWindow(activeChar);
        break;
      case admin_tele:
        showTeleportWindow(activeChar);
        break;
      case admin_teleto:
      case admin_tele_to:
      case admin_instant_move:
        if (wordList.length > 1 && wordList[1].equalsIgnoreCase("r")) activeChar.setTeleMode(2);
        else if (wordList.length > 1 && wordList[1].equalsIgnoreCase("end"))
          activeChar.setTeleMode(0);
        else activeChar.setTeleMode(1);
        break;
      case admin_tonpc:
      case admin_to_npc:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //tonpc npcId|npcName");
          return false;
        }
        String npcName = Util.joinStrings(" ", wordList, 1);
        NpcInstance npc;
        try {
          if ((npc = GameObjectsStorage.getByNpcId(Integer.parseInt(npcName))) != null) {
            teleportToCharacter(activeChar, npc);
            return true;
          }
        } catch (Exception e) {
        }
        if ((npc = GameObjectsStorage.getNpc(npcName)) != null) {
          teleportToCharacter(activeChar, npc);
          return true;
        }
        activeChar.sendMessage("Npc " + npcName + " not found");
        break;
      case admin_toobject:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //toobject objectId");
          return false;
        }
        Integer target = Integer.parseInt(wordList[1]);
        GameObject obj;
        if ((obj = GameObjectsStorage.findObject(target)) != null) {
          teleportToCharacter(activeChar, obj);
          return true;
        }
        activeChar.sendMessage("Object " + target + " not found");
        break;
      default:
        break;
    }

    if (!activeChar.getPlayerAccess().CanEditChar) return false;

    switch (command) {
      case admin_teleport_character:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleport_character x y z");
          return false;
        }
        teleportCharacter(activeChar, Util.joinStrings(" ", wordList, 1));
        showTeleportCharWindow(activeChar);
        break;
      case admin_recall:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //recall charName");
          return false;
        }
        String targetName = Util.joinStrings(" ", wordList, 1);
        Player recall_player = GameObjectsStorage.getPlayer(targetName);
        if (recall_player != null) {
          teleportTo(activeChar, recall_player, activeChar.getLoc(), activeChar.getReflectionId());
          return true;
        }
        int obj_id = CharacterDAO.getInstance().getObjectIdByName(targetName);
        if (obj_id > 0) {
          teleportCharacter_offline(obj_id, activeChar.getLoc());
          activeChar.sendMessage(targetName + " is offline. Offline teleport used...");
        } else activeChar.sendMessage("->" + targetName + "<- is incorrect.");
        break;
      case admin_setref:
        {
          if (wordList.length < 2) {
            activeChar.sendMessage("Usage: //setref <reflection>");
            return false;
          }

          int ref_id = Integer.parseInt(wordList[1]);
          if (ref_id != 0 && ReflectionManager.getInstance().get(ref_id) == null) {
            activeChar.sendMessage("Reflection <" + ref_id + "> not found.");
            return false;
          }

          GameObject target = activeChar;
          GameObject obj = activeChar.getTarget();
          if (obj != null) target = obj;

          target.setReflection(ref_id);
          target.decayMe();
          target.spawnMe();
          break;
        }
      case admin_getref:
        if (wordList.length < 2) {
          activeChar.sendMessage("Usage: //getref <char_name>");
          return false;
        }
        Player cha = GameObjectsStorage.getPlayer(wordList[1]);
        if (cha == null) {
          activeChar.sendMessage("Player '" + wordList[1] + "' not found in world");
          return false;
        }
        activeChar.sendMessage(
            "Player '"
                + wordList[1]
                + "' in reflection: "
                + activeChar.getReflectionId()
                + ", name: "
                + activeChar.getReflection().getName());
        break;
      default:
        break;
    }

    if (!activeChar.getPlayerAccess().CanEditNPC) return false;

    switch (command) {
      case admin_recall_npc:
        recallNPC(activeChar);
        break;
      default:
        break;
    }

    return true;
  }