예제 #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();
     }
   }
 }
예제 #2
0
  public void fillSpawnTable(int mapid, int type) {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;
    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm = con.prepareStatement("SELECT * FROM spawnlist_antaras");
      rs = pstm.executeQuery();
      while (rs.next()) {
        if (type != rs.getInt("type")) continue;

        L1Npc l1npc = NpcTable.getInstance().getTemplate(rs.getInt("npc_id"));
        if (l1npc != null) {
          L1NpcInstance field;
          try {
            field = NpcTable.getInstance().newNpcInstance(rs.getInt("npc_id"));
            field.setId(ObjectIdFactory.getInstance().nextId());
            field.setX(rs.getInt("locx"));
            field.setY(rs.getInt("locy"));
            field.setMap((short) mapid);
            field.setHomeX(field.getX());
            field.setHomeY(field.getY());
            field.getMoveState().setHeading(0);
            field.setLightSize(l1npc.getLightSize());
            field.getLight().turnOnOffLight();

            L1World.getInstance().storeObject(field);
            L1World.getInstance().addVisibleObject(field);
          } catch (Exception e) {
            _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
          }
        }
      }
    } catch (SQLException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } catch (SecurityException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } catch (IllegalArgumentException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }
예제 #3
0
  /** 鞄や倉庫で表示される形式の名前を個数を指定して取得する。<br> */
  public String getNumberedViewName(int count) {
    StringBuilder name = new StringBuilder(getNumberedName(count));
    int itemType2 = getItem().getType2();
    int itemId = getItem().getItemId();

    if ((itemId == 40314) || (itemId == 40316)) { // ペットのアミュレット
      L1Pet pet = PetTable.getInstance().getTemplate(getId());
      if (pet != null) {
        L1Npc npc = NpcTable.getInstance().getTemplate(pet.get_npcid());
        // name.append("[Lv." + pet.get_level() + " "
        // + npc.get_nameid() + "]");
        name.append(
            "[Lv."
                + pet.get_level()
                + " "
                + pet.get_name()
                + "]HP"
                + pet.get_hp()
                + " "
                + npc.get_nameid());
      }
    }

    if ((getItem().getType2() == 0) && (getItem().getType() == 2)) { // light系アイテム
      if (isNowLighting()) {
        name.append(" ($10)");
      }
      if ((itemId == 40001) || (itemId == 40002)) { // ランプorランタン
        if (getRemainingTime() <= 0) {
          name.append(" ($11)");
        }
      }
    }

    if (isEquipped()) {
      if (itemType2 == 1) {
        name.append(" ($9)"); // 装備(Armed)
      } else if (itemType2 == 2) {
        name.append(" ($117)"); // 装備(Worn)
      }
    }
    return name.toString();
  }