Esempio n. 1
0
 public void spawn(int npcId, int X, int Y, int H, short Map) {
   L1Npc l1npc = NpcTable.getInstance().getTemplate(npcId);
   if (l1npc != null) {
     L1NpcInstance mob = null;
     try {
       String implementationName = l1npc.getImpl();
       Constructor<?> _constructor =
           Class.forName(
                   (new StringBuilder())
                       .append("l1j.server.server.model.Instance.")
                       .append(implementationName)
                       .append("Instance")
                       .toString())
               .getConstructors()[0];
       mob = (L1NpcInstance) _constructor.newInstance(new Object[] {l1npc});
       mob.setId(IdFactory.getInstance().nextId());
       mob.setX(X);
       mob.setY(Y);
       mob.setHomeX(X);
       mob.setHomeY(Y);
       mob.setMap(Map);
       mob.setHeading(H);
       L1World.getInstance().storeObject(mob);
       L1World.getInstance().addVisibleObject(mob);
       L1Object object = L1World.getInstance().findObject(mob.getId());
       L1QuestInstance newnpc = (L1QuestInstance) object;
       newnpc.onNpcAI();
       newnpc.turnOnOffLight();
       newnpc.startChat(L1NpcInstance.CHAT_TIMING_APPEARANCE); // チャット開始
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
Esempio n. 2
0
  public L1FollowerInstance(L1Npc template, L1NpcInstance target, L1Character master) {
    super(template);

    _master = master;
    setId(IdFactory.getInstance().nextId());

    setMaster(master);
    setX(target.getX());
    setY(target.getY());
    setMap(target.getMapId());
    setHeading(target.getHeading());
    setLightSize(target.getLightSize());

    target.setParalyzed(true);
    target.setDead(true);
    target.deleteMe();

    L1World.getInstance().storeObject(this);
    L1World.getInstance().addVisibleObject(this);
    for (L1PcInstance pc : L1World.getInstance().getRecognizePlayer(this)) {
      onPerceive(pc);
    }

    startAI();
    master.addFollower(this);
  }
  private void initialize() {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;

    try {
      con = L1DatabaseFactory.getInstance().getConnection();

      pstm = con.prepareStatement("SELECT * FROM spawnlist_trap");

      rs = pstm.executeQuery();

      while (rs.next()) {
        int trapId = rs.getInt("trapId");
        L1Trap trapTemp = TrapTable.getInstance().getTemplate(trapId);
        L1Location loc = new L1Location();
        loc.setMap(rs.getInt("mapId"));
        loc.setX(rs.getInt("locX"));
        loc.setY(rs.getInt("locY"));
        Point rndPt = new Point();
        rndPt.setX(rs.getInt("locRndX"));
        rndPt.setY(rs.getInt("locRndY"));
        int count = rs.getInt("count");
        int span = rs.getInt("span");

        for (int i = 0; i < count; i++) {
          L1TrapInstance trap =
              new L1TrapInstance(IdFactory.getInstance().nextId(), trapTemp, loc, rndPt, span);
          L1World.getInstance().addVisibleObject(trap);
          _allTraps.add(trap);
        }
        L1TrapInstance base = new L1TrapInstance(IdFactory.getInstance().nextId(), loc);
        L1World.getInstance().addVisibleObject(base);
        _allBases.add(base);
      }

    } catch (SQLException e) {
      _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }
Esempio n. 4
0
  public static void addBookmark(L1PcInstance pc, String s) {
    // クライアント側でチェックされるため不要
    //		if (s.length() > 12) {
    //			pc.sendPackets(new S_ServerMessage(204));
    //			return;
    //		}

    if (!pc.getMap().isMarkable()) {
      pc.sendPackets(new S_ServerMessage(214)); // \f1ここを記憶することができません。
      return;
    }

    int size = pc.getBookMarkSize();
    if (size > 49) {
      return;
    }

    if (pc.getBookMark(s) == null) {
      L1BookMark bookmark = new L1BookMark();
      bookmark.setId(IdFactory.getInstance().nextId());
      bookmark.setCharId(pc.getId());
      bookmark.setName(s);
      bookmark.setLocX(pc.getX());
      bookmark.setLocY(pc.getY());
      bookmark.setMapId(pc.getMapId());

      Connection con = null;
      PreparedStatement pstm = null;

      try {
        con = L1DatabaseFactory.getInstance().getConnection();
        pstm =
            con.prepareStatement(
                "INSERT INTO character_teleport SET id = ?, char_id = ?, name = ?, locx = ?, locy = ?, mapid = ?");
        pstm.setInt(1, bookmark.getId());
        pstm.setInt(2, bookmark.getCharId());
        pstm.setString(3, bookmark.getName());
        pstm.setInt(4, bookmark.getLocX());
        pstm.setInt(5, bookmark.getLocY());
        pstm.setInt(6, bookmark.getMapId());
        pstm.execute();
      } catch (SQLException e) {
        _log.log(Level.SEVERE, "ブックマークの追加でエラーが発生しました。", e);
      } finally {
        SQLUtil.close(pstm);
        SQLUtil.close(con);
      }

      pc.addBookMark(bookmark);
      pc.sendPackets(
          new S_Bookmarks(
              s, bookmark.getMapId(), bookmark.getId(), bookmark.getLocX(), bookmark.getLocY()));
    } else {
      pc.sendPackets(new S_ServerMessage(327)); // 同じ名前がすでに存在しています。
    }
  }