Ejemplo n.º 1
0
 @Override
 public void createGame() {
   if (this._locked) {
     return;
   }
   this.removeInactiveTeams();
   int teamsSize = this.getPlayersInTeam() * 2;
   if (this._parties.size() < teamsSize || this._games.size() >= this.getMaxGamesCount()) {
     this.check();
     return;
   }
   FastList players = new FastList();
   this.setIsTemporaryLocked(true);
   try {
     for (RegistrationData team : this._parties) {
       if (team.isChosen() || players.size() >= teamsSize) continue;
       team.setIsChosen(true);
       players.add(team);
       if (players.size() < teamsSize) continue;
       this.launchGame(players.toArray(new RegistrationData[players.size()]), null);
       this.setIsTemporaryLocked(false);
       break;
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   for (RegistrationData p : this._parties) {
     if (!p.isChosen()) continue;
     this._parties.remove(p);
   }
   this.setIsTemporaryLocked(false);
   this.check();
 }
  public void parse() {
    String fileName = "npcinfo_" + sessionName + ".txt";

    try {
      BufferedWriter out = new BufferedWriter(new FileWriter(fileName));

      for (DataPacket packet : packets) {
        String name = packet.getName();
        if ("SM_NPC_INFO".equals(name)) {
          List<ValuePart> valuePartList = packet.getValuePartList();
          NpcInfo npc = new NpcInfo();

          for (ValuePart valuePart : valuePartList) {
            String partName = valuePart.getModelPart().getName();
            if ("npcId".equals(partName)) {
              npc.npcId = Integer.parseInt(valuePart.readValue());
            } else if ("titleId".equals(partName)) {
              npc.titleId = Integer.parseInt(valuePart.readValue());
            } else if ("nameId".equals(partName)) {
              npc.nameId = Integer.parseInt(valuePart.readValue());
            } else if ("npcMaxHP".equals(partName)) {
              npc.npcMaxHp = Integer.parseInt(valuePart.readValue());
            } else if ("npclevel".equals(partName)) {
              npc.npcLevel = Byte.parseByte(valuePart.readValue());
            } else if ("npcTemplateHeight".equals(partName)) {
              npc.npcTemplateHeight = Float.parseFloat(valuePart.readValue());
            }
          }
          npcInfoList.add(npc);
        }
      }

      out.write("npcId\ttitleId\tnameId\tnpcMaxHp\tnpcLevel\tnpcTemplateHeight\n");

      for (NpcInfo npc : npcInfoList) {
        StringBuilder sb = new StringBuilder();
        sb.append(npc.npcId);
        sb.append("\t");
        sb.append(npc.titleId);
        sb.append("\t");
        sb.append(npc.nameId);
        sb.append("\t");
        sb.append(npc.npcMaxHp);
        sb.append("\t");
        sb.append(npc.npcLevel);
        sb.append("\t");
        sb.append(npc.npcTemplateHeight);
        sb.append("\t");
        sb.append("\n");
        out.write(sb.toString());
      }

      out.close();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    PacketSamurai.getUserInterface().log("The npc infos have been written");
  }
Ejemplo n.º 3
0
 public FastList<Byte> getFreeRooms(byte type) {
   FastList<Byte> list = new FastList<Byte>();
   for (Object room : _rooms.get(type).getValues()) {
     if (!((DimensionalRiftRoom) room).ispartyInside())
       list.add(((DimensionalRiftRoom) room)._room);
   }
   return list;
 }
Ejemplo n.º 4
0
 /**
  * Once used observer add to observerController. If observer notify will be removed.
  *
  * @param observer
  */
 public void attach(ActionObserver observer) {
   observer.makeOneTimeUse();
   lock.lock();
   try {
     onceUsedObservers.add(observer);
   } finally {
     lock.unlock();
   }
 }
Ejemplo n.º 5
0
 @Override
 protected void runImpl() {
   L2PcInstance player = getClient().getActiveChar();
   if (player == null) {
     return;
   }
   FastList<String> manorsName = new FastList<>();
   manorsName.add("gludio");
   manorsName.add("dion");
   manorsName.add("giran");
   manorsName.add("oren");
   manorsName.add("aden");
   manorsName.add("innadril");
   manorsName.add("goddard");
   manorsName.add("rune");
   manorsName.add("schuttgart");
   ExSendManorList manorlist = new ExSendManorList(manorsName);
   player.sendPacket(manorlist);
 }
Ejemplo n.º 6
0
  @Override
  protected final void writeImpl() {
    if (getClient().getActiveChar() == null) return;

    for (PartyMatchRoom room : PartyMatchRoomList.getInstance().getRooms()) {
      if (room.getMembersCount() < 1
          || room.getOwner() == null
          || room.getOwner().isOnline() == 0
          || room.getOwner().getPartyRoom() != room.getId()) {
        PartyMatchRoomList.getInstance().deleteRoom(room.getId());
        continue;
      }
      if (_loc > 0 && _loc != room.getLocation()) continue;
      if (_lim == 0
          && ((_cha.getLevel() < room.getMinLvl()) || (_cha.getLevel() > room.getMaxLvl())))
        continue;
      _rooms.add(room);
    }
    int count = 0;
    int size = _rooms.size();

    writeC(0x96);
    if (size > 0) writeD(1);
    else writeD(0);

    writeD(_rooms.size());
    while (size > count) {
      writeD(_rooms.get(count).getId());
      writeS(_rooms.get(count).getTitle());
      writeD(_rooms.get(count).getLocation());
      writeD(_rooms.get(count).getMinLvl());
      writeD(_rooms.get(count).getMaxLvl());
      writeD(_rooms.get(count).getMembersCount());
      writeD(_rooms.get(count).getMaxMembers());
      writeS(_rooms.get(count).getOwner().getName());
      count++;
    }
  }
  @Override
  public final String onSpawn(L2Npc npc) {
    final int npcId = npc.getId();

    if (npcId == MUTATED_ELPY) {
      DoorTable.getInstance().getDoor(18250025).openMe();
      ZoneManager.getInstance().getZoneById(200100).setEnabled(false);
      ZoneManager.getInstance().getZoneById(200101).setEnabled(true);
      ZoneManager.getInstance().getZoneById(200101).setEnabled(false);
    } else if (((npcId == SPORE_BASIC) || ((npcId >= SPORE_FIRE) && (npcId <= SPORE_EARTH)))
        && (_challengeState == STATE_SPORE_CHALLENGE_IN_PROGRESS)) {
      _sporeSpawn.add(npc);
      npc.setIsRunning(false);
      int[] coord = SPORES_MOVE_POINTS[getRandom(SPORES_MOVE_POINTS.length)];
      npc.getSpawn().setX(coord[0]);
      npc.getSpawn().setY(coord[1]);
      npc.getSpawn().setZ(coord[2]);
      npc.getAI()
          .setIntention(
              CtrlIntention.AI_INTENTION_MOVE_TO, new Location(coord[0], coord[1], coord[2], 0));
      startQuestTimer("despawn_spore", 60000, npc, null);
    }
    return super.onSpawn(npc);
  }
Ejemplo n.º 8
0
 public ConfirmDlg addNumber(int number) {
   _info.add(new CnfDlgData(TYPE_NUMBER, number));
   return this;
 }
Ejemplo n.º 9
0
 public ConfirmDlg addString(String text) {
   _info.add(new CnfDlgData(TYPE_TEXT, text));
   return this;
 }
Ejemplo n.º 10
0
 public ConfirmDlg addSkillName(int id, int lvl) {
   _info.add(new CnfDlgData(TYPE_SKILL_NAME, id));
   _skillLvL = lvl;
   return this;
 }
Ejemplo n.º 11
0
 public ConfirmDlg addZoneName(int x, int y, int z) {
   Integer[] coord = {x, y, z};
   _info.add(new CnfDlgData(TYPE_ZONE_NAME, coord));
   return this;
 }
Ejemplo n.º 12
0
 public ConfirmDlg addItemName(int id) {
   _info.add(new CnfDlgData(TYPE_ITEM_NAME, id));
   return this;
 }
Ejemplo n.º 13
0
  /**
   * Calculates the intersection of a given ray originating from a specified point with a block.
   * Returns a list of intersections ordered by the distance to the player.
   *
   * @param x
   * @param y
   * @param z
   * @param rayOrigin
   * @param rayDirection
   * @return Distance-ordered list of ray-face-intersections
   */
  public static FastList<RayBoxIntersection> rayBlockIntersection(
      World w, int x, int y, int z, Vector3f rayOrigin, Vector3f rayDirection) {
    /*
     * Ignore invisible blocks.
     */
    if (Block.getBlockForType(w.getBlock(x, y, z)).isBlockInvisible()) {
      return null;
    }

    FastList<RayBoxIntersection> result = new FastList<RayBoxIntersection>();

    /*
     * Fetch all vertices of the specified block.
     */
    Vector3f[] vertices = verticesForBlockAt(x, y, z);
    Vector3f blockPos = VectorPool.getVector(x, y, z);

    /*
     * Generate a new intersection for each side of the block.
     */

    // Front
    RayBoxIntersection is =
        rayFaceIntersection(
            blockPos, vertices[0], vertices[3], vertices[2], rayOrigin, rayDirection);
    if (is != null) {
      result.add(is);
    }

    // Back
    is =
        rayFaceIntersection(
            blockPos, vertices[4], vertices[5], vertices[6], rayOrigin, rayDirection);
    if (is != null) {
      result.add(is);
    }

    // Left
    is =
        rayFaceIntersection(
            blockPos, vertices[0], vertices[4], vertices[7], rayOrigin, rayDirection);
    if (is != null) {
      result.add(is);
    }

    // Right
    is =
        rayFaceIntersection(
            blockPos, vertices[1], vertices[2], vertices[6], rayOrigin, rayDirection);
    if (is != null) {
      result.add(is);
    }

    // Top
    is =
        rayFaceIntersection(
            blockPos, vertices[3], vertices[7], vertices[6], rayOrigin, rayDirection);
    if (is != null) {
      result.add(is);
    }

    // Bottom
    is =
        rayFaceIntersection(
            blockPos, vertices[0], vertices[1], vertices[5], rayOrigin, rayDirection);
    if (is != null) {
      result.add(is);
    }

    /*
     * Sort the intersections by distance.
     */
    Collections.sort(result);
    return result;
  }
 public void addCoolDown(Player player) {
   playersWithCooldown.add(player.getObjectId());
 }
Ejemplo n.º 15
0
  public void parse() {
    String filename = "npc_spawns_" + sessionName + ".xml";
    Long start = System.currentTimeMillis();

    try {
      DocumentBuilderFactory dFact = DocumentBuilderFactory.newInstance();
      DocumentBuilder build = dFact.newDocumentBuilder();
      Document doc = build.newDocument();
      Element root = doc.createElement("spawns");
      doc.appendChild(root);

      // Collect info about all seen NPCs
      for (DataPacket packet : packets) {
        String packetName = packet.getName();
        if ("SM_PLAYER_SPAWN".equals(packetName))
          this.worldId = Integer.parseInt(packet.getValuePartList().get(1).readValue());
        else if ("SM_NPC_INFO".equals(packetName)) {
          NpcSpawn spawn = new NpcSpawn();
          FastList<ValuePart> valuePartList = new FastList<ValuePart>(packet.getValuePartList());
          for (ValuePart valuePart : valuePartList) {
            String partName = valuePart.getModelPart().getName();
            if ("x".equals(partName)) spawn.x = Float.parseFloat(valuePart.readValue());
            else if ("y".equals(partName)) spawn.y = Float.parseFloat(valuePart.readValue());
            else if ("z".equals(partName)) spawn.z = Float.parseFloat(valuePart.readValue());
            else if ("npcId".equals(partName))
              spawn.npcId = Integer.parseInt(valuePart.readValue());
            else if ("npcHeading".equals(partName))
              spawn.heading = Byte.parseByte(valuePart.readValue());
            else if ("static_id".equals(partName))
              spawn.staticid = Integer.parseInt(valuePart.readValue());
            else if ("objId".equals(partName))
              spawn.objectId = Long.parseLong(valuePart.readValue());
            spawn.worldId = this.worldId;
          }
          boolean exists = false;
          for (NpcSpawn n : spawns) if (n.objectId == spawn.objectId) exists = true;
          if (!exists) spawns.add(spawn);
        }
      }

      for (NpcSpawn n : spawns) {
        // Find or create a new spawn
        Element spawn;
        spawn =
            (Element)
                XPathAPI.selectNodeList(
                        doc,
                        String.format("//spawn[@map='%d' and @npcid='%d']", n.worldId, n.npcId))
                    .item(0);
        if (spawn == null) {
          spawn = doc.createElement("spawn");
          spawn.setAttribute("map", "" + n.worldId);
          spawn.setAttribute("npcid", "" + n.npcId);
          root.appendChild(spawn);
        }
        if (XPathAPI.selectNodeList(
                    spawn,
                    String.format("//object[@x='%f' and @y='%f' and @z='%f']", n.x, n.y, n.z))
                .getLength()
            > 0) continue;
        Element object = doc.createElement("object");
        if (n.staticid != 0) object.setAttribute("staticid", "" + n.staticid);

        object.setAttribute("h", "" + n.heading);
        object.setAttribute("z", "" + n.z);
        object.setAttribute("y", "" + n.y);
        object.setAttribute("x", "" + n.x);

        spawn.appendChild(object);
        spawn.setAttribute("pool", "" + spawn.getChildNodes().getLength());
        spawn.setAttribute("interval", "" + 295);
      }
      Transformer serializer = TransformerFactory.newInstance().newTransformer();
      serializer.setOutputProperty(OutputKeys.INDENT, "yes");
      serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3");
      serializer.transform(new DOMSource(doc), new StreamResult(new File(filename)));
    } catch (ParserConfigurationException e) {
      e.printStackTrace();
    } catch (TransformerException e) {
      e.printStackTrace();
    }
    PacketSamurai.getUserInterface()
        .log(
            "NPC spawndata has been written in "
                + ((float) (System.currentTimeMillis() - start) / 1000)
                + "s");
  }
Ejemplo n.º 16
0
 private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) {
   final L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), itemId);
   item.setCount(num);
   item.spawnMe(loc.getX(), loc.getY(), loc.getZ());
   _debugItems.add(item);
 }
Ejemplo n.º 17
0
 /**
  * Put item logic: - If there is available slot - put item there and return it back - If no slot
  * available - return null
  *
  * @param item
  * @return Item
  */
 public Item putToNextAvailableSlot(Item item) {
   if (!isFull() && storageItems.add(item)) return item;
   else return null;
 }
Ejemplo n.º 18
0
 public void addRequirement(int type, int id, int count, int unk) {
   _reqs.add(new Req(type, id, count, unk));
 }
Ejemplo n.º 19
0
  private AdditionalSkillTable() {
    for (int skillId : _exludeSkills) _skillList.add(skillId);

    _log.info("ExtraSkillTable: Loaded  " + _skillList.size() + " skills.");
  }
Ejemplo n.º 20
0
 public ConfirmDlg addNpcName(int id) {
   _info.add(new CnfDlgData(TYPE_NPC_NAME, id));
   return this;
 }