Package l2p.gameserver.templates

Examples of l2p.gameserver.templates.L2NpcTemplate


        final int x = locationList[locationIndex].x;
        final int y = locationList[locationIndex].y;
        final int z = locationList[locationIndex].z;
        final int heading = locationList[locationIndex].h;
        // Fetch the template for this NPC ID and create a new spawn.
        L2NpcTemplate npcTemp = NpcTable.getTemplate(spawnInst.getNpcId());
        L2Spawn newSpawn = new L2Spawn(npcTemp);
        newSpawn.setLocx(x);
        newSpawn.setLocy(y);
        newSpawn.setLocz(z);
        if(heading != -1)
View Full Code Here


  public NpcInfoPoly(L2Object cha)
  {
    _obj = cha;
    _npcId = cha.getPolyid();
    L2NpcTemplate _template = NpcTable.getTemplate(_npcId);
    if(_template == null)
    {
      return;
    }
    _rhand = 0;
View Full Code Here

    return result;
  }

  public static void SpawnNPCs(int npcId, int[][] locations, GArray<L2Spawn> list)
  {
    L2NpcTemplate template = NpcTable.getTemplate(npcId);
    if(template == null)
    {
      System.out.println("WARNING! Functions.SpawnNPCs template is null for npc: " + npcId);
      Thread.dumpStack();
      return;
View Full Code Here

      }
      try
      {
        statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
        rs = statement.executeQuery();
        L2NpcTemplate npcDat;
        L2Skill npcSkill;
        GArray<Integer> unimpl = new GArray<Integer>();
        int counter = 0;
        while(rs.next())
        {
          int mobId = rs.getInt("npcid");
          npcDat = _npcs[mobId];
          if(npcDat == null)
          {
            continue;
          }
          short skillId = rs.getShort("skillid");
          short level = rs.getShort("level");
          // Для определения расы используется скилл 4416
          if(skillId == 4416)
          {
            npcDat.setRace(level);
          }
          if(skillId >= 4290 && skillId <= 4302)
          {
            _log.info("Warning! Skill " + skillId + " not used, use 4416 instead.");
            continue;
          }
          if(skillId == 4408)
          {
            if(CatacombSpawnManager._monsters.contains(mobId))
            {
              level = (short) (Config.ALT_CATACOMB_MODIFIER_HP + 8);
              npcDat.setRateHp(hprateskill[level]);
              if(Config.ALT_CATACOMB_MODIFIER_HP != 4)
              {
                npcDat.addSkill(SkillTable.getInstance().getInfo(4417, Config.ALT_CATACOMB_MODIFIER_HP));
              }
            }
            else
            {
              npcDat.setRateHp(hprateskill[level]);
            }
          }
          npcSkill = SkillTable.getInstance().getInfo(skillId, level);
          if(npcSkill == null || npcSkill.getSkillType() == SkillType.NOTDONE)
          {
            unimpl.add(Integer.valueOf(skillId));
          }
          if(npcSkill == null)
          {
            continue;
          }
          npcDat.addSkill(npcSkill);
          counter++;
        }
        new File("log/game/unimplemented_npc_skills.txt").delete();
        for(Integer i : unimpl)
        {
          Log.add("[" + i + "] " + SkillTable.getInstance().getInfo(i, 1), "unimplemented_npc_skills", "");
        }
        _log.info("Loaded " + counter + " npc skills.");
      }
      catch(Exception e)
      {
        _log.log(Level.SEVERE, "error while reading npcskills table ", e);
      }
      finally
      {
        DatabaseUtils.closeDatabaseSR(statement, rs);
      }
      try
      {
        statement = con.prepareStatement("SELECT mobId, itemId, min, max, sweep, chance, category FROM droplist ORDER BY mobId, category, chance DESC");
        rs = statement.executeQuery();
        L2DropData dropDat;
        L2NpcTemplate npcDat;
        while(rs.next())
        {
          int mobId = rs.getInt("mobId");
          npcDat = _npcs[mobId];
          if(npcDat != null)
          {
            dropDat = new L2DropData();
            int id = rs.getShort("itemId");
            if(ItemTable.getInstance().getTemplate(id).isCommonItem())
            {
              if(Config.ALT_ALLOW_DROP_COMMON)
              {
                dropDat.setChance(rs.getInt("chance") * Config.RATE_DROP_COMMON_ITEMS);
                dropDat.setItemId(id);
              }
              else
              {
                int normalid = ItemTable.getInstance().findBaseId(id);
                dropDat.setChance(((double) rs.getInt("chance")) * ItemTable.getInstance().getTemplate(id).getReferencePrice() / ItemTable.getInstance().getTemplate(normalid).getReferencePrice());
                dropDat.setItemId(normalid);
              }
            }
            else
            {
              dropDat.setItemId(id);
              dropDat.setChance(rs.getInt("chance"));
            }
            dropDat.setMinDrop(rs.getInt("min"));
            dropDat.setMaxDrop(rs.getInt("max"));
            dropDat.setSweep(rs.getInt("sweep") == 1);
            if(dropDat.getItem().isArrow() || dropDat.getItemId() == 1419)
            {
              dropDat.setGroupId(Byte.MAX_VALUE); // группа для нерейтуемых предметов, сюда же надо всякую фигню
            }
            else
            {
              dropDat.setGroupId(rs.getInt("category"));
            }
            npcDat.addDropData(dropDat);
          }
        }
        for(L2NpcTemplate temp : _npcs)
        {
          if(temp != null && temp.getDropData() != null)
          {
            if(!temp.getDropData().validate())
            {
              _log.warning("Problems with droplist for " + temp.toString());
            }
          }
        }
        if(Config.ALT_GAME_SHOW_DROPLIST && !Config.ALT_GAME_GEN_DROPLIST_ON_DEMAND)
        {
          FillDropList();
        }
        else
        {
          _log.info("Players droplist load skipped");
        }
        loadKillCount();
      }
      catch(Exception e)
      {
        _log.log(Level.SEVERE, "error reading npc drops ", e);
      }
      finally
      {
        DatabaseUtils.closeDatabaseSR(statement, rs);
      }
      try
      {
        statement = con.prepareStatement("SELECT boss_id, minion_id, amount FROM minions");
        rs = statement.executeQuery();
        L2MinionData minionDat;
        L2NpcTemplate npcDat;
        int cnt = 0;
        while(rs.next())
        {
          int raidId = rs.getInt("boss_id");
          npcDat = _npcs[raidId];
          minionDat = new L2MinionData();
          minionDat.setMinionId(rs.getInt("minion_id"));
          minionDat.setAmount(rs.getByte("amount"));
          npcDat.addRaidData(minionDat);
          cnt++;
        }
        _log.info("NpcTable: Loaded " + cnt + " Minions.");
      }
      catch(Exception e)
      {
        _log.log(Level.SEVERE, "error loading minions", e);
      }
      finally
      {
        DatabaseUtils.closeDatabaseSR(statement, rs);
      }
      try
      {
        statement = con.prepareStatement("SELECT npc_id, class_id FROM skill_learn");
        rs = statement.executeQuery();
        L2NpcTemplate npcDat;
        int cnt = 0;
        while(rs.next())
        {
          npcDat = _npcs[rs.getInt(1)];
          npcDat.addTeachInfo(ClassId.values()[rs.getInt(2)]);
          cnt++;
        }
        _log.info("NpcTable: Loaded " + cnt + " SkillLearn entrys.");
      }
      catch(Exception e)
View Full Code Here

      }
      npcDat.set("factionId", factionId);
      npcDat.set("factionRange", factionId == null || factionId.equals("") ? 0 : NpcData.getShort("faction_range"));
      npcDat.set("isDropHerbs", NpcData.getBoolean("isDropHerbs"));
      npcDat.set("shots", NpcData.getString("shots"));
      L2NpcTemplate template = new L2NpcTemplate(npcDat, ai_params.containsKey(id) ? ai_params.get(id) : null);
      temp.add(template);
      if(_npcsByLevel[level] == null)
      {
        _npcsByLevel[level] = new GArray<L2NpcTemplate>();
      }
View Full Code Here

    FiltredPreparedStatement st = null;
    ResultSet rs = null;
    try
    {
      // save a copy of the old data
      L2NpcTemplate old = getTemplate(id);
      HashMap<Integer, L2Skill> skills = new HashMap<Integer, L2Skill>();
      if(old.getSkills() != null)
      {
        skills.putAll(old.getSkills());
      }
      /*
       Contact with Styx to understand this commenting
       GArray<L2DropData> drops = new GArray<L2DropData>();
       if(old.getDropData() != null)
       drops.addAll(old.getDropData());
       */
      ClassId[] classIds = null;
      if(old.getTeachInfo() != null)
      {
        classIds = old.getTeachInfo().clone();
      }
      GArray<L2MinionData> minions = new GArray<L2MinionData>();
      minions.addAll(old.getMinionData());
      // reload the NPC base data
      con = L2DatabaseFactory.getInstance().getConnection();
      st = con.prepareStatement("SELECT * FROM npc WHERE id=?");
      st.setInt(1, id);
      rs = st.executeQuery();
      fillNpcTable(rs);
      // restore additional data from saved copy
      L2NpcTemplate created = getTemplate(id);
      for(L2Skill skill : skills.values())
      {
        created.addSkill(skill);
      }
      /*
       for(L2DropData drop : drops)
       created.addDropData(drop);
       */
      if(classIds != null)
      {
        for(ClassId classId : classIds)
        {
          created.addTeachInfo(classId);
        }
      }
      for(L2MinionData minion : minions)
      {
        created.addRaidData(minion);
      }
    }
    catch(Exception e)
    {
      _log.warning("cannot reload npc " + id + ": " + e);
View Full Code Here

      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT * FROM `killcount` WHERE `char_id`=-1");
      list = statement.executeQuery();
      while(list.next())
      {
        L2NpcTemplate t = NpcTable.getTemplate(list.getInt("npc_id"));
        if(t != null)
        {
          t.killscount = list.getInt("count");
        }
      }
View Full Code Here

    {
      if(BumbalumpSpawned())
      {
        return;
      }
      L2NpcTemplate template = NpcTable.getTemplate(RB_Icicle_Emperor_Bumbalump);
      if(template == null)
      {
        return;
      }
      try
View Full Code Here

    int mob_id = Integer.parseInt(attr_spawn.getNamedItem("id").getNodeValue());
    String xyzh = attr_spawn.getNamedItem("xyzh").getNodeValue();
    int count = Integer.parseInt(attr_spawn.getNamedItem("count").getNodeValue());
    int respawn = Integer.parseInt(attr_spawn.getNamedItem("respawn").getNodeValue());
    L2Spawn spawnDat;
    L2NpcTemplate npc;
    npc = NpcTable.getTemplate(mob_id);
    if(npc != null)
    {
      try
      {
View Full Code Here

    }
  }

  protected L2NpcInstance spawn(int id, Location loc)
  {
    L2NpcTemplate template = NpcTable.getTemplate(id);
    L2Spawn spawn;
    try
    {
      spawn = new L2Spawn(template);
    }
View Full Code Here

TOP

Related Classes of l2p.gameserver.templates.L2NpcTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.