Exemple #1
0
 @Override
 public String onAggroRangeEnter(L2NpcInstance npc, L2PcInstance player, boolean isPet) {
   int npcId = npc.getNpcId();
   if (npcId == ZAKEN) {
     if (_Zone.isInsideZone(npc)) {
       L2Character target = isPet ? player.getPet() : player;
       ((L2Attackable) npc).addDamageHate(target, 1, 200);
     }
     if (player.getZ() > (npc.getZ() - 100) && player.getZ() < (npc.getZ() + 100)) {
       if (_quest0 < 5 && Rnd.get(3) < 1) {
         if (_quest0 == 0) {
           c_quest0 = player;
         } else if (_quest0 == 1) {
           c_quest1 = player;
         } else if (_quest0 == 2) {
           c_quest2 = player;
         } else if (_quest0 == 3) {
           c_quest3 = player;
         } else if (_quest0 == 4) {
           c_quest4 = player;
         }
         _quest0++;
       }
       if (Rnd.get(15) < 1) {
         int i0 = Rnd.get((15 * 15));
         if (i0 < 1) {
           npc.setTarget(player);
           npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
         } else if (i0 < 2) {
           npc.setTarget(player);
           npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
         } else if (i0 < 4) {
           npc.setTarget(player);
           npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
         } else if (i0 < 8) {
           npc.setTarget(player);
           npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
         } else if (i0 < 15) {
           for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100)) {
             if (character != player) continue;
             if (player != ((L2Attackable) npc).getMostHated()) {
               npc.setTarget(player);
               npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
             }
           }
         }
         if (Rnd.get(2) < 1) {
           if (player == ((L2Attackable) npc).getMostHated()) {
             npc.setTarget(player);
             npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
           }
         }
       }
     }
   }
   return super.onAggroRangeEnter(npc, player, isPet);
 }
Exemple #2
0
  private void teleportToCharacter(L2PcInstance activeChar, L2Object target) {
    L2PcInstance player = null;

    if (target != null && target.isPlayer) {
      player = (L2PcInstance) target;
    } else {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      return;
    }

    if (player.getObjectId() == activeChar.getObjectId()) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_ON_YOURSELF));
    } else {
      int x = player.getX();
      int y = player.getY();
      int z = player.getZ();

      if (player.getInstanceId() != activeChar.getInstanceId()) {
        activeChar.setInstanceId(player.getInstanceId());
        activeChar.sendMessage("Вход в инстанс " + player.getInstanceId() + ".");
      }

      activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      activeChar.teleToLocation(x, y, z);
    }

    player = null;
  }
Exemple #3
0
  private void showTeleportCharWindow(L2PcInstance activeChar) {
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if (target.isPlayer) {
      player = (L2PcInstance) target;
    } else {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      return;
    }

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

    TextBuilder replyMSG = new TextBuilder("<html><title>Teleport Character</title>");
    replyMSG.append("<body>");
    replyMSG.append("The character you will teleport is " + player.getName() + ".");
    replyMSG.append("<br>");
    replyMSG.append("Co-ordinate x");
    replyMSG.append("<edit var=\"char_cord_x\" width=110>");
    replyMSG.append("Co-ordinate y");
    replyMSG.append("<edit var=\"char_cord_y\" width=110>");
    replyMSG.append("Co-ordinate z");
    replyMSG.append("<edit var=\"char_cord_z\" width=110>");
    replyMSG.append(
        "<button value=\"Teleport\" action=\"bypass -h admin_teleport_character $char_cord_x $char_cord_y $char_cord_z\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
    replyMSG.append(
        "<button value=\"Teleport near you\" action=\"bypass -h admin_teleport_character "
            + activeChar.getX()
            + " "
            + activeChar.getY()
            + " "
            + activeChar.getZ()
            + "\" width=115 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
    replyMSG.append(
        "<center><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center>");
    replyMSG.append("</body></html>");

    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);

    adminReply = null;
    replyMSG = null;
    player = null;
    target = null;
  }
Exemple #4
0
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    if (!super.useAdminCommand(command, activeChar)) {
      return false;
    }

    if (command.equals("admin_teleto")) {
      activeChar.setTeleMode(1);
    }

    if (command.equals("admin_teleto r")) {
      activeChar.setTeleMode(2);
    }

    if (command.equals("admin_teleto end")) {
      activeChar.setTeleMode(0);
    }

    if (command.equals("admin_show_moves")) {
      com.l2scoria.gameserver.handler.admin.impl.HelpPage.showHelpPage(activeChar, "teleports.htm");
    }

    if (command.equals("admin_show_moves_other")) {
      com.l2scoria.gameserver.handler.admin.impl.HelpPage.showHelpPage(
          activeChar, "tele/other.html");
    } else if (command.equals("admin_show_teleport")) {
      showTeleportCharWindow(activeChar);
    } else if (command.equals("admin_recall_npc")) {
      recallNPC(activeChar);
    } else if (command.equals("admin_teleport_to_character")) {
      teleportToCharacter(activeChar, activeChar.getTarget());
    } else if (command.startsWith("admin_walk")) {
      try {
        String val = command.substring(11);
        StringTokenizer st = new StringTokenizer(val);
        String x1 = st.nextToken();

        int x = Integer.parseInt(x1);

        String y1 = st.nextToken();

        int y = Integer.parseInt(y1);

        String z1 = st.nextToken();

        int z = Integer.parseInt(z1);

        L2CharPosition pos = new L2CharPosition(x, y, z, 0);
        activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, pos);

        pos = null;
        x1 = null;
        y1 = null;
        z1 = null;
        st = null;
      } catch (Exception e) {
        if (Config.DEBUG) {
          _log.info("admin_walk: " + e);
        }
      }
    } else if (command.startsWith("admin_move_to")) {
      try {
        String val = command.substring(14);
        teleportTo(activeChar, val);

        val = null;
      } catch (StringIndexOutOfBoundsException e) {
        // Case of empty or missing coordinates
        com.l2scoria.gameserver.handler.admin.impl.HelpPage.showHelpPage(
            activeChar, "teleports.htm");
      }
    } else if (command.startsWith("admin_teleport_character")) {
      try {
        String val = command.substring(25);

        if (activeChar.getAccessLevel().isGm()) {
          teleportCharacter(activeChar, val);
        }

        val = null;
      } catch (StringIndexOutOfBoundsException e) {
        // Case of empty coordinates
        activeChar.sendMessage("Wrong or no Coordinates given.");
        showTeleportCharWindow(activeChar); // back to character teleport
      }
    } else if (command.startsWith("admin_teleportto ")) {
      try {
        String targetName = command.substring(17);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
        teleportToCharacter(activeChar, player);
        targetName = null;
        player = null;
      } catch (StringIndexOutOfBoundsException e) {
        // ignore
      }
    } else if (command.startsWith("admin_recall ")) {
      try {
        String targetName = command.substring(13);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);

        if (activeChar.getAccessLevel().isGm()) {
          teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ());
        }

        player = null;
      } catch (StringIndexOutOfBoundsException e) {
        // ignore
      }
    } else if (command.startsWith("admin_sendhome ")) {
      try {
        String targetName = command.substring(15);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
        player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
        targetName = null;
        player = null;
      } catch (StringIndexOutOfBoundsException e) {
        // ignore
      }
    } else if (command.equals("admin_tele")) {
      showTeleportWindow(activeChar);
    } else if (command.startsWith("admin_go")) {
      int intVal = 150;
      int x = activeChar.getX(), y = activeChar.getY(), z = activeChar.getZ();

      try {
        String val = command.substring(8);
        StringTokenizer st = new StringTokenizer(val);
        String dir = st.nextToken();

        if (st.hasMoreTokens()) {
          intVal = Integer.parseInt(st.nextToken());
        }

        if (dir.equals("east")) {
          x += intVal;
        } else if (dir.equals("west")) {
          x -= intVal;
        } else if (dir.equals("north")) {
          y -= intVal;
        } else if (dir.equals("south")) {
          y += intVal;
        } else if (dir.equals("up")) {
          z += intVal;
        } else if (dir.equals("down")) {
          z -= intVal;
        }

        activeChar.teleToLocation(x, y, z, false);
        showTeleportWindow(activeChar);

        dir = null;
        st = null;
        val = null;
      } catch (Exception e) {
        activeChar.sendMessage("Usage: //go<north|south|east|west|up|down> [offset] (default 150)");
      }
    }

    return true;
  }
Exemple #5
0
  private void recallNPC(L2PcInstance activeChar) {
    L2Object obj = activeChar.getTarget();

    if (obj != null && obj.isNpc) {
      L2NpcInstance target = (L2NpcInstance) obj;

      int monsterTemplate = target.getTemplate().npcId;

      L2NpcTemplate template1 = NpcTable.getInstance().getTemplate(monsterTemplate);

      if (template1 == null) {
        activeChar.sendMessage("Incorrect monster template.");
        _log.warn("ERROR: NPC " + target.getObjectId() + " has a 'null' template.");
        return;
      }

      L2Spawn spawn = target.getSpawn();

      if (spawn == null) {
        activeChar.sendMessage("Incorrect monster spawn.");
        _log.warn("ERROR: NPC " + target.getObjectId() + " has a 'null' spawn.");
        return;
      }

      int respawnTime = spawn.getRespawnDelay();

      target.deleteMe();
      spawn.stopRespawn();
      SpawnTable.getInstance().deleteSpawn(spawn, true);

      try {
        // L2MonsterInstance mob = new L2MonsterInstance(monsterTemplate, template1);

        spawn = new L2Spawn(template1);
        spawn.setLocx(activeChar.getX());
        spawn.setLocy(activeChar.getY());
        spawn.setLocz(activeChar.getZ());
        spawn.setAmount(1);
        spawn.setHeading(activeChar.getHeading());
        spawn.setRespawnDelay(respawnTime);
        SpawnTable.getInstance().addNewSpawn(spawn, true);
        spawn.init();

        SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
        sm.addString("Created " + template1.name + " on " + target.getObjectId() + ".");
        activeChar.sendPacket(sm);
        sm = null;

        if (Config.DEBUG) {
          _log.info(
              "Spawn at X=" + spawn.getLocx() + " Y=" + spawn.getLocy() + " Z=" + spawn.getLocz());
          _log.warn(
              "GM: "
                  + activeChar.getName()
                  + "("
                  + activeChar.getObjectId()
                  + ") moved NPC "
                  + target.getObjectId());
        }

        spawn = null;
        template1 = null;
        target = null;
      } catch (Exception e) {
        activeChar.sendMessage("Target is not in game.");
      }
    } else {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
    }

    obj = null;
  }
Exemple #6
0
  @Override
  public String onSpellFinished(L2NpcInstance npc, L2PcInstance player, L2Skill skill) {
    if (npc.getNpcId() == ZAKEN) {
      int skillId = skill.getId();
      if (skillId == 4222) {
        // npc.teleToLocation(_ai1, _ai2, _ai3);
        npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      } else if (skillId == 4216) {
        // int i1 = Rnd.get(15);
        // player.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650),
        // Zcoords[i1]);
        ((L2Attackable) npc).stopHating(player);
        L2Character nextTarget = ((L2Attackable) npc).getMostHated();
        if (nextTarget != null)
          npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, nextTarget);

      } else if (skillId == 4217) {
        int i0 = 0;
        // int i1 = Rnd.get(15);
        // player.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650),
        // Zcoords[i1]);
        ((L2Attackable) npc).stopHating(player);

        if (c_quest0 != null
            && _quest0 > 0
            && c_quest0 != player
            && c_quest0.getZ() > (player.getZ() - 100)
            && c_quest0.getZ() < (player.getZ() + 100)) {
          if ((((c_quest0.getX() - player.getX()) * (c_quest0.getX() - player.getX()))
                  + ((c_quest0.getY() - player.getY()) * (c_quest0.getY() - player.getY())))
              > (250 * 250)) {
            i0 = 1;
          } else {
            i0 = 0;
          }
          if (i0 == 0) {
            // i1 = Rnd.get(15);
            // c_quest0.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650),
            // Zcoords[i1]);
            ((L2Attackable) npc).stopHating(c_quest0);
          }
        }
        if (c_quest1 != null
            && _quest0 > 1
            && c_quest1 != player
            && c_quest1.getZ() > (player.getZ() - 100)
            && c_quest1.getZ() < (player.getZ() + 100)) {
          if ((((c_quest1.getX() - player.getX()) * (c_quest1.getX() - player.getX()))
                  + ((c_quest1.getY() - player.getY()) * (c_quest1.getY() - player.getY())))
              > (250 * 250)) {
            i0 = 1;
          } else {
            i0 = 0;
          }
          if (i0 == 0) {
            // i1 = Rnd.get(15);
            // c_quest1.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650),
            // Zcoords[i1]);
            ((L2Attackable) npc).stopHating(c_quest1);
          }
        }
        if (c_quest2 != null
            && _quest0 > 2
            && c_quest2 != player
            && c_quest2.getZ() > (player.getZ() - 100)
            && c_quest2.getZ() < (player.getZ() + 100)) {
          if ((((c_quest2.getX() - player.getX()) * (c_quest2.getX() - player.getX()))
                  + ((c_quest2.getY() - player.getY()) * (c_quest2.getY() - player.getY())))
              > (250 * 250)) {
            i0 = 1;
          } else {
            i0 = 0;
          }
          if (i0 == 0) {
            // i1 = Rnd.get(15);
            // c_quest2.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650),
            // Zcoords[i1]);
            ((L2Attackable) npc).stopHating(c_quest2);
          }
        }
        if (c_quest3 != null
            && _quest0 > 3
            && c_quest3 != player
            && c_quest3.getZ() > (player.getZ() - 100)
            && c_quest3.getZ() < (player.getZ() + 100)) {
          if ((((c_quest3.getX() - player.getX()) * (c_quest3.getX() - player.getX()))
                  + ((c_quest3.getY() - player.getY()) * (c_quest3.getY() - player.getY())))
              > (250 * 250)) {
            i0 = 1;
          } else {
            i0 = 0;
          }
          if (i0 == 0) {
            // i1 = Rnd.get(15);
            // c_quest3.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650),
            // Zcoords[i1]);
            ((L2Attackable) npc).stopHating(c_quest3);
          }
        }
        if (c_quest4 != null
            && _quest0 > 4
            && c_quest4 != player
            && c_quest4.getZ() > (player.getZ() - 100)
            && c_quest4.getZ() < (player.getZ() + 100)) {
          if ((((c_quest4.getX() - player.getX()) * (c_quest4.getX() - player.getX()))
                  + ((c_quest4.getY() - player.getY()) * (c_quest4.getY() - player.getY())))
              > (250 * 250)) {
            i0 = 1;
          } else {
            i0 = 0;
          }
          if (i0 == 0) {
            // i1 = Rnd.get(15);
            // c_quest4.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650),
            // Zcoords[i1]);
            ((L2Attackable) npc).stopHating(c_quest4);
          }
        }
        L2Character nextTarget = ((L2Attackable) npc).getMostHated();
        if (nextTarget != null)
          npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, nextTarget);
      }
    }
    return super.onSpellFinished(npc, player, skill);
  }