Ejemplo n.º 1
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);
  }
Ejemplo n.º 2
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();
     }
   }
 }
Ejemplo n.º 3
0
 public void run() {
   while (true) {
     try {
       list = L1World.getInstance().getAllPlayers();
       for (L1PcInstance pc : list) {
         if (pc == null || pc.getNetConnection() == null) {
           continue;
         } else {
           /** 지저 호수 * */
           if (pc.getMapId() == 420) {
             try {
               petlist = pc.getPetList().values().toArray();
               for (Object pet : petlist) {
                 L1SummonInstance sum = (L1SummonInstance) pet;
                 sum.receiveDamage(pc, 100000);
               }
             } catch (Exception e) {
             } finally {
               petlist = null;
             }
           }
         }
       }
     } catch (Exception e) {
       _log.log(Level.SEVERE, "SummonMapController[]Error", e);
       // cancel();
     } finally {
       try {
         list = null;
         Thread.sleep(5000);
       } catch (Exception e) {
       }
     }
   }
 }
Ejemplo n.º 4
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);
    }
  }
Ejemplo n.º 5
0
  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);
    }
  }
Ejemplo n.º 6
0
  private static void storeItem(L1PcInstance pc, L1ItemInstance item) {
    L1Inventory inventory;

    if (pc.getInventory().checkAddItem(item, item.getCount()) == L1Inventory.OK) {
      inventory = pc.getInventory();
    } else {
      // 持てない場合は地面に落とす 処理のキャンセルはしない(不正防止)
      inventory = L1World.getInstance().getInventory(pc.getLocation());
    }
    inventory.storeItem(item);
    pc.sendPackets(new S_ServerMessage(403, item.getLogName())); // %0を手に入れました。
  }
Ejemplo n.º 7
0
  public C_PetMenu(byte abyte0[], LineageClient clientthread) throws Exception {
    super(abyte0);

    int petId = readD();

    L1PetInstance pet = (L1PetInstance) L1World.getInstance().findObject(petId);
    L1PcInstance pc = clientthread.getActiveChar();

    if (pet != null && pc != null) {
      pc.sendPackets(new S_PetInventory(pet));
    }
  }
Ejemplo n.º 8
0
 private void createNewItem(L1PcInstance pc, int item_id, int count) {
   L1ItemInstance item = ItemTable.getInstance().createItem(item_id);
   item.setCount(count);
   if (item != null) {
     if (pc.getInventory().checkAddItem(item, count) == L1Inventory.OK) {
       pc.getInventory().storeItem(item);
     } else {
       L1World.getInstance().getInventory(pc.getX(), pc.getY(), pc.getMapId()).storeItem(item);
     }
     pc.sendPackets(new S_ServerMessage(403, item.getLogName()));
   }
 }
Ejemplo n.º 9
0
 // 일반티 생성
 private boolean createNewItemR(L1PcInstance pc, int item_id, int count, int enchant) {
   L1ItemInstance item = ItemTable.getInstance().createItem(item_id);
   item.setCount(count);
   item.setIdentified(true);
   item.setEnchantLevel(enchant);
   if (item != null) {
     if (pc.getInventory().checkAddItem(item, count) == L1Inventory.OK) {
       pc.getInventory().storeItem(item);
       pc.sendPackets(new S_ServerMessage(403, item.getLogName()));
     } else {
       L1World.getInstance().getInventory(pc.getX(), pc.getY(), pc.getMapId()).storeItem(item);
     }
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 10
0
  public C_SoldierGive(byte abyte0[], LineageClient clientthread) {
    super(abyte0);

    // SoldierGiveSelect.java 여야 하지만 길어서 셀렉트는 생략.
    int objid = readD(); // 말 건 npc id
    int type = readH(); // 선택

    L1PcInstance pc = clientthread.getActiveChar();
    if (pc == null) {
      return;
    }
    int castle_id = pc.getClan().getCastleId();
    L1Soldier soldier = SoldierTable.getInstance().getSoldierTable(castle_id);

    int count = 0;

    switch (type) {
      case 0:
        if (soldier.getSoldier1() <= 0) {
          return;
        } else {
          count = soldier.getSoldier1();
        }
        break;
      case 1:
        if (soldier.getSoldier2() <= 0) {
          return;
        } else {
          count = soldier.getSoldier2();
        }
        break;
      case 2:
        if (soldier.getSoldier3() <= 0) {
          return;
        } else {
          count = soldier.getSoldier3();
        }
        break;
      case 3:
        if (soldier.getSoldier4() <= 0) {
          return;
        } else {
          count = soldier.getSoldier4();
        }
        break;
      default:
        break;
    }

    for (L1Object obj : L1World.getInstance().getVisibleObjects(pc, 1)) {
      if (obj instanceof L1PcInstance) {
        int sumX = pc.getX() - obj.getX();
        int sumY = pc.getY() - obj.getY();

        L1PcInstance target = (L1PcInstance) obj;
        if (sumX == 1 && sumY == -2) {
          send(pc, target, objid, type, count);
          break;
        } else if (sumX == 0 && sumY == -1) {
          send(pc, target, objid, type, count);
          break;
        } else if (sumX == -1 && sumY == -1) {
          send(pc, target, objid, type, count);
          break;
        } else {
          send(pc, pc, objid, type, count);
        }
      } else {
        send(pc, pc, objid, type, count);
      }
    }
  }
Ejemplo n.º 11
0
  @Override
  public boolean noTarget() {
    for (L1Object object : L1World.getInstance().getVisibleObjects(this)) {
      if (object instanceof L1NpcInstance) {
        L1NpcInstance npc = (L1NpcInstance) object;
        if ((npc.getNpcTemplate().get_npcId() == 70740 // ディカルデンソルジャー
            )
            && (getNpcTemplate().get_npcId() == 71093)) { // 調査員
          setParalyzed(true);
          L1PcInstance pc = (L1PcInstance) _master;
          if (!pc.getInventory().checkItem(40593)) {
            createNewItem(pc, 40593, 1);
          }
          deleteMe();
          return true;
        } else if ((npc.getNpcTemplate().get_npcId() == 70811 // 萊拉
            )
            && (getNpcTemplate().get_npcId() == 71094)) { // 安迪亞
          setParalyzed(true);
          L1PcInstance pc = (L1PcInstance) _master;
          if (!pc.getInventory().checkItem(40582)
              && !pc.getInventory().checkItem(40583)) { // 身上無安迪亞之袋、安迪亞之信
            createNewItem(pc, 40582, 1);
          }
          deleteMe();
          return true;
        } else if ((npc.getNpcTemplate().get_npcId() == 71061 // カドモス
            )
            && (getNpcTemplate().get_npcId() == 71062)) { // カミット
          if (getLocation().getTileLineDistance(_master.getLocation()) < 3) {
            L1PcInstance pc = (L1PcInstance) _master;
            if (((pc.getX() >= 32448) && (pc.getX() <= 32452)) // カドモス周辺座標
                && ((pc.getY() >= 33048) && (pc.getY() <= 33052))
                && (pc.getMapId() == 440)) {
              setParalyzed(true);
              if (!pc.getInventory().checkItem(40711)) {
                createNewItem(pc, 40711, 1);
                pc.getQuest().set_step(L1Quest.QUEST_CADMUS, 3);
              }
              deleteMe();
              return true;
            }
          }
        } else if ((npc.getNpcTemplate().get_npcId() == 71074 // リザードマンの長老
            )
            && (getNpcTemplate().get_npcId() == 71075)) {
          // 疲れ果てたリザードマンファイター
          if (getLocation().getTileLineDistance(_master.getLocation()) < 3) {
            L1PcInstance pc = (L1PcInstance) _master;
            if (((pc.getX() >= 32731) && (pc.getX() <= 32735)) // リザードマン長老周辺座標
                && ((pc.getY() >= 32854) && (pc.getY() <= 32858))
                && (pc.getMapId() == 480)) {
              setParalyzed(true);
              if (!pc.getInventory().checkItem(40633)) {
                createNewItem(pc, 40633, 1);
                pc.getQuest().set_step(L1Quest.QUEST_LIZARD, 2);
              }
              deleteMe();
              return true;
            }
          }
        } else if ((npc.getNpcTemplate().get_npcId() == 70964 // バッシュ
            )
            && (getNpcTemplate().get_npcId() == 70957)) { // ロイ
          if (getLocation().getTileLineDistance(_master.getLocation()) < 3) {
            L1PcInstance pc = (L1PcInstance) _master;
            if (((pc.getX() >= 32917) && (pc.getX() <= 32921)) // バッシュ周辺座標
                && ((pc.getY() >= 32974) && (pc.getY() <= 32978))
                && (pc.getMapId() == 410)) {
              setParalyzed(true);
              createNewItem(pc, 41003, 1);
              pc.getQuest().set_step(L1Quest.QUEST_ROI, 0);
              deleteMe();
              return true;
            }
          }
        } else if ((npc.getNpcTemplate().get_npcId() == 71114)
            && (getNpcTemplate().get_npcId() == 81350)) { // 迪嘉勒廷的女間諜
          if (getLocation().getTileLineDistance(_master.getLocation()) < 15) {
            L1PcInstance pc = (L1PcInstance) _master;
            if (((pc.getX() >= 32542) && (pc.getX() <= 32585))
                && ((pc.getY() >= 32656) && (pc.getY() <= 32698))
                && (pc.getMapId() == 400)) {
              setParalyzed(true);
              createNewItem(pc, 49163, 1);
              pc.getQuest().set_step(4, 4);
              deleteMe();
              return true;
            }
          }
        }
      }
    }

    if (_master.isDead() || (getLocation().getTileLineDistance(_master.getLocation()) > 10)) {
      setParalyzed(true);
      spawn(getNpcTemplate().get_npcId(), getX(), getY(), getHeading(), getMapId());
      deleteMe();
      return true;
    } else if ((_master != null) && (_master.getMapId() == getMapId())) {
      if (getLocation().getTileLineDistance(_master.getLocation()) > 2) {
        setDirectionMove(moveDirection(_master.getX(), _master.getY()));
        setSleepTime(calcSleepTime(getPassispeed(), MOVE_SPEED));
      }
    }
    return false;
  }
Ejemplo n.º 12
0
 private static void removeTraps(List<L1TrapInstance> traps) {
   for (L1TrapInstance trap : traps) {
     trap.disableTrap();
     L1World.getInstance().removeVisibleObject(trap);
   }
 }
Ejemplo n.º 13
0
  @Override
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    if (pc.isGm()) {
      try {
        StringTokenizer st = new StringTokenizer(arg);
        L1PcInstance cha = L1World.getInstance().getPlayer(st.nextToken());
        if (cha == null) {
          return;
        }
        StringBuilder msg = new StringBuilder();
        final String BR = System.getProperty("line.separator");

        int hpr = 0, mpr = 0;
        hpr = cha.getHpr() + cha.getInventory().hpRegenPerTick();
        mpr = cha.getMpr() + cha.getInventory().mpRegenPerTick();

        msg.append("-- キャラクター --" + BR);
        msg.append(" " + BR);
        msg.append("名前:" + cha.getName() + BR);
        msg.append("所属クラン:" + cha.getClanname() + BR);
        msg.append("レベル:" + cha.getLevel() + BR);
        msg.append("所持アイテム数:" + cha.getInventory().getSize() + BR);
        msg.append("エリクサー使用回数:" + cha.getElixirStats() + BR);
        msg.append(" " + BR);

        msg.append("-- ステータス --" + BR);
        msg.append(" " + BR);
        msg.append("STR:" + cha.getStr() + " ");
        msg.append("DEX:" + cha.getDex() + " ");
        msg.append("INT:" + cha.getInt() + " ");
        msg.append(" " + BR);
        msg.append("CON:" + cha.getCon() + " ");
        msg.append("WIS:" + cha.getWis() + " ");
        msg.append("CHA:" + cha.getCha() + " ");
        msg.append(" " + BR);
        msg.append("AC:" + cha.getAc() + " ");
        msg.append("MR:" + cha.getMr() + " ");
        msg.append("SP:" + cha.getSp() + " ");
        msg.append("ER:" + cha.getEr() + " ");
        msg.append(" " + BR);
        msg.append("HP: " + cha.getCurrentHp() + " ");
        msg.append("HP(MAX): " + cha.getMaxHp() + " ");
        msg.append(" " + BR);
        msg.append("HP(Base): " + cha.getBaseMaxHp());
        msg.append(" " + BR);
        msg.append("MP: " + cha.getCurrentMp() + " ");
        msg.append("MP(MAX): " + cha.getMaxMp() + " ");
        msg.append(" " + BR);
        msg.append("MP(Base): " + cha.getBaseMaxMp());
        msg.append(" " + BR);
        msg.append("HPR: " + hpr + " ");
        msg.append("MPR: " + mpr + " ");
        msg.append("Karma:" + cha.getKarma() + " ");
        msg.append(" " + BR + BR);
        msg.append("近距離ダメージ:" + cha.getDmgup() + " ");
        msg.append("近距離命中:" + cha.getHitup() + " ");
        msg.append(" " + BR);
        msg.append("遠距離ダメージ:" + cha.getBowDmgup() + " ");
        msg.append("遠距離命中:" + cha.getBowHitup() + " ");
        msg.append(" " + BR);
        msg.append("軽減ダメージ:" + cha.getDamageReductionByArmor() + " / ");
        msg.append(" " + BR + BR);
        msg.append("凍結耐性:" + cha.getRegistFreeze() + " ");
        msg.append("スタン耐性:" + cha.getRegistStun() + " ");
        msg.append(" " + BR);
        msg.append("石化耐性:" + cha.getRegistStone() + " ");
        msg.append("睡眠耐性:" + cha.getRegistSleep() + " ");
        msg.append(" " + BR);
        msg.append("ホールド耐性:" + cha.getRegistSustain() + " ");
        msg.append("暗闇耐性:" + cha.getRegistBlind() + " ");
        msg.append(" " + BR + BR);
        msg.append("火耐性:" + cha.getFire());
        msg.append("水耐性:" + cha.getWater());
        msg.append("土耐性:" + cha.getEarth());
        msg.append("風耐性:" + cha.getWind());
        msg.append(" " + BR + BR);

        pc.sendPackets(new S_SystemMessage(msg.toString()));
      } catch (Exception e) {
        pc.sendPackets(new S_SystemMessage(cmdName + " コマンドエラー"));
      }
    } else {
      try {
        StringBuilder msg = new StringBuilder();
        final String BR = System.getProperty("line.separator");
        int hpr = 0, mpr = 0;

        hpr = pc.getHpr() + pc.getInventory().hpRegenPerTick();
        mpr = pc.getMpr() + pc.getInventory().mpRegenPerTick();

        msg.append("-- キャラクター --" + BR);
        msg.append(" " + BR);
        msg.append("名前:" + pc.getName() + BR);
        msg.append("所属クラン:" + pc.getClanname() + BR);
        msg.append("レベル:" + pc.getLevel() + BR);
        msg.append("所持アイテム数:" + pc.getInventory().getSize() + BR);
        msg.append("エリクサー使用回数:" + pc.getElixirStats() + BR);
        msg.append(" " + BR);

        msg.append("-- ステータス --" + BR);
        msg.append(" " + BR);
        msg.append("STR:" + pc.getStr() + " ");
        msg.append("DEX:" + pc.getDex() + " ");
        msg.append("INT:" + pc.getInt() + " ");
        msg.append(" " + BR);
        msg.append("CON:" + pc.getCon() + " ");
        msg.append("WIS:" + pc.getWis() + " ");
        msg.append("CHA:" + pc.getCha() + " ");
        msg.append(" " + BR);
        msg.append("AC:" + pc.getAc() + " ");
        msg.append("MR:" + pc.getMr() + " ");
        msg.append("SP:" + pc.getSp() + " ");
        msg.append("ER:" + pc.getEr() + " ");
        msg.append(" " + BR);
        msg.append("HP: " + pc.getCurrentHp() + " ");
        msg.append("HP(MAX): " + pc.getMaxHp() + " ");
        msg.append(" " + BR);
        msg.append("HP(Base): " + pc.getBaseMaxHp());
        msg.append(" " + BR);
        msg.append("MP: " + pc.getCurrentMp() + " ");
        msg.append("MP(MAX): " + pc.getMaxMp() + " ");
        msg.append(" " + BR);
        msg.append("MP(Base): " + pc.getBaseMaxMp());
        msg.append(" " + BR);
        msg.append("HPR: " + hpr + " ");
        msg.append("MPR: " + mpr + " ");
        msg.append("Karma:" + pc.getKarma() + " ");
        msg.append(" " + BR + BR);
        msg.append("近距離ダメージ:" + pc.getDmgup() + " ");
        msg.append("近距離命中:" + pc.getHitup() + " ");
        msg.append(" " + BR);
        msg.append("遠距離ダメージ:" + pc.getBowDmgup() + " ");
        msg.append("遠距離命中:" + pc.getBowHitup() + " ");
        msg.append(" " + BR);
        msg.append("軽減ダメージ:" + pc.getDamageReductionByArmor() + " / ");
        msg.append(" " + BR + BR);
        msg.append("凍結耐性:" + pc.getRegistFreeze() + " ");
        msg.append("スタン耐性:" + pc.getRegistStun() + " ");
        msg.append(" " + BR);
        msg.append("石化耐性:" + pc.getRegistStone() + " ");
        msg.append("睡眠耐性:" + pc.getRegistSleep() + " ");
        msg.append(" " + BR);
        msg.append("ホールド耐性:" + pc.getRegistSustain() + " ");
        msg.append("暗闇耐性:" + pc.getRegistBlind() + " ");
        msg.append(" " + BR + BR);
        msg.append("火耐性:" + pc.getFire());
        msg.append("水耐性:" + pc.getWater());
        msg.append("土耐性:" + pc.getEarth());
        msg.append("風耐性:" + pc.getWind());
        msg.append(" " + BR + BR);

        pc.sendPackets(new S_SystemMessage(msg.toString()));
      } catch (Exception e) {
        pc.sendPackets(new S_SystemMessage(cmdName + " コマンドエラー"));
      }
    }
  }