Package com.l2jfrozen.gameserver.templates

Examples of com.l2jfrozen.gameserver.templates.L2NpcTemplate


   * @param npcID
   * @return Returns the _questDrops.
   */
  public List<L2DropData> getQuestDrops(int npcID)
  {
    L2NpcTemplate npc = npcTable.getTemplate(npcID);
    if(npc == null)
      return null;
    List<L2DropData> questDrops = new FastList<L2DropData>();
    if(npc.getDropData() != null)
    {
      for(L2DropCategory cat : npc.getDropData())
      {
        for(L2DropData drop : cat.getAllDrops())
        {
          if(drop.getQuestID() != null)
          {
View Full Code Here


  }

  @Override
  public void onStart()
  {
    L2NpcTemplate template;
    if(getSkill() instanceof L2SkillSignetCasttime)
    {
      template = NpcTable.getInstance().getTemplate(((L2SkillSignetCasttime) getSkill())._effectNpcId);
    }
    else
View Full Code Here

        _log.fine("player has a pet already. ignore summon skill");
      return;
    }
   
    L2SummonInstance summon;
    L2NpcTemplate summonTemplate = NpcTable.getInstance().getTemplate(_npcId);
    if (summonTemplate == null)
    {
      _log.warning("Summon attempt for nonexisting NPC ID:"+_npcId+", skill ID:"+this.getId());
      return; // npcID doesn't exist
    }
View Full Code Here

      }

      ResultSet rset = statement.executeQuery();

      L2Spawn spawnDat;
      L2NpcTemplate template1;

      while(rset.next())
      {
        template1 = NpcTable.getInstance().getTemplate(rset.getInt("npc_templateid"));
        if(template1 != null)
        {
          if(template1.type.equalsIgnoreCase("L2SiegeGuard"))
          {
            // Don't spawn
          }
          else if(template1.type.equalsIgnoreCase("L2RaidBoss"))
          {
            // Don't spawn raidboss
          }
          else if (template1.type.equalsIgnoreCase("L2GrandBoss"))
          {
            // Don't spawn grandboss
          }
          else if(!Config.ALLOW_CLASS_MASTERS && template1.type.equals("L2ClassMaster"))
          {
            // Dont' spawn class masters
          }
          else
          {
            spawnDat = new L2Spawn(template1);
            spawnDat.setId(rset.getInt("id"));
            spawnDat.setAmount(rset.getInt("count"));
            spawnDat.setLocx(rset.getInt("locx"));
            spawnDat.setLocy(rset.getInt("locy"));
            spawnDat.setLocz(rset.getInt("locz"));
            spawnDat.setHeading(rset.getInt("heading"));
            spawnDat.setRespawnDelay(rset.getInt("respawn_delay"));

            int loc_id = rset.getInt("loc_id");

            spawnDat.setLocation(loc_id);

            //template1 = null;

            switch(rset.getInt("periodOfDay"))
            {
              case 0: // default
                _npcSpawnCount += spawnDat.init();
                break;
              case 1: // Day
                DayNightSpawnManager.getInstance().addDayCreature(spawnDat);
                _npcSpawnCount++;
                break;
              case 2: // Night
                DayNightSpawnManager.getInstance().addNightCreature(spawnDat);
                _npcSpawnCount++;
                break;
            }

            _spawntable.put(spawnDat.getId(), spawnDat);
            if(spawnDat.getId() > _highestId)
            {
              _highestId = spawnDat.getId();
            }
            if (spawnDat.getTemplate().getNpcId() == Olympiad.OLY_MANAGER)
            {
              Olympiad.olymanagers.add(spawnDat);
            }
            spawnDat = null;
          }
        }
        else
        {
          _log.warning("SpawnTable: Data missing in NPC table for ID: {}. "+ rset.getInt("npc_templateid"));
        }
      }
      statement.close();
      rset.close();
    }
    catch(Exception e)
    {
      _log.severe("SpawnTable: Spawn could not be initialized "+ e);
    }
    finally
    {
      CloseUtil.close(con);
    }

    _log.finest("SpawnTable: Loaded {} Npc Spawn Locations. "+ _spawntable.size());
    _log.finest("SpawnTable: Spawning completed, total number of NPCs in the world: {} "+ _npcSpawnCount);

    //-------------------------------Custom Spawnlist----------------------------//
    if(Config.CUSTOM_SPAWNLIST_TABLE)
    {
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection(false);
       
        final PreparedStatement statement;
       
        if(Config.DELETE_GMSPAWN_ON_CUSTOM)
        {
          statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist where id NOT in ( select id from custom_notspawned where isCustom = false ) ORDER BY id");
        }
        else
        {
          statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist ORDER BY id");
        }

        //PreparedStatement statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist ORDER BY id");
        final ResultSet rset = statement.executeQuery();

        L2Spawn spawnDat;
        L2NpcTemplate template1;

        while(rset.next())
        {
          template1 = NpcTable.getInstance().getTemplate(rset.getInt("npc_templateid"));
View Full Code Here

        {
          con = L2DatabaseFactory.getInstance().getConnection(false);
        }
        statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
        final ResultSet npcskills = statement.executeQuery();
        L2NpcTemplate npcDat = null;
        L2Skill npcSkill = null;

        while(npcskills.next())
        {
          int mobId = npcskills.getInt("npcid");
          npcDat = _npcs.get(mobId);

          if(npcDat == null)
          {
            continue;
          }

          int skillId = npcskills.getInt("skillid");
          int level = npcskills.getInt("level");

          if(npcDat.race == null && skillId == 4416)
          {
            npcDat.setRace(level);
            continue;
          }

          npcSkill = SkillTable.getInstance().getInfo(skillId, level);

          if(npcSkill == null)
          {
            continue;
          }

          npcDat.addSkill(npcSkill);
        }

        npcskills.close();
        statement.close();
      }
      catch(Exception e)
      {
        _log.severe("NPCTable: Error reading NPC skills table"+" "+ e);
      }

      if(Config.CUSTOM_DROPLIST_TABLE)
        try
        {
          if (con == null)
          {
            con = L2DatabaseFactory.getInstance().getConnection(false);
          }
          statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
          {
              "mobId", "itemId", "min", "max", "category", "chance"
          }) + " FROM custom_droplist ORDER BY mobId, chance DESC");
          ResultSet dropData = statement.executeQuery();

          int cCount = 0;

          while(dropData.next())
          {
            int mobId = dropData.getInt("mobId");

            L2NpcTemplate npcDat = _npcs.get(mobId);

            if(npcDat == null)
            {
              _log.warning("NPCTable: CUSTOM DROPLIST No npc correlating with id: {}"+" "+ mobId);
              continue;
            }

            L2DropData dropDat = new L2DropData();
            dropDat.setItemId(dropData.getInt("itemId"));
            dropDat.setMinDrop(dropData.getInt("min"));
            dropDat.setMaxDrop(dropData.getInt("max"));
            dropDat.setChance(dropData.getInt("chance"));

            int category = dropData.getInt("category");

            npcDat.addDropData(dropDat, category);
            cCount++;
            //dropDat = null;
          }
          dropData.close();
          statement.close();
          _log.finest("CustomDropList : Added {} custom droplist"+" "+ cCount);

          if(Config.ENABLE_CACHE_INFO)
          {
            FillDropList();
          }
        }
        catch(Exception e)
        {
          _log.severe("NPCTable: Error reading NPC CUSTOM drop data"+" "+ e);
        }

      try
      {
        if (con == null)
        {
          con = L2DatabaseFactory.getInstance().getConnection(false);
        }
        statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
        {
            "mobId", "itemId", "min", "max", "category", "chance"
        }) + " FROM droplist ORDER BY mobId, chance DESC");
        ResultSet dropData = statement.executeQuery();
        L2DropData dropDat = null;
        L2NpcTemplate npcDat = null;

        while(dropData.next())
        {
          int mobId = dropData.getInt("mobId");

          npcDat = _npcs.get(mobId);

          if(npcDat == null)
          {
            _log.warning("NPCTable: No npc correlating with id: {}"+" "+ mobId);
            continue;
          }

          dropDat = new L2DropData();

          dropDat.setItemId(dropData.getInt("itemId"));
          dropDat.setMinDrop(dropData.getInt("min"));
          dropDat.setMaxDrop(dropData.getInt("max"));
          dropDat.setChance(dropData.getInt("chance"));

          int category = dropData.getInt("category");

          npcDat.addDropData(dropDat, category);
          //dropDat = null;
        }

        dropData.close();
        statement.close();
      }
      catch(Exception e)
      {
        _log.severe("NPCTable: Error reading NPC drop data"+" "+ e);
      }

      try
      {
        if (con == null)
        {
          con = L2DatabaseFactory.getInstance().getConnection(false);
        }
        statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
        {
           "npc_id", "class_id"
        }
        ) + " FROM skill_learn");
        final ResultSet learndata = statement.executeQuery();

        while(learndata.next())
        {
          int npcId = learndata.getInt ("npc_id");
          int classId = learndata.getInt("class_id");
         
          L2NpcTemplate npc = getTemplate(npcId);
          if (npc == null)
          {
            _log.warning("NPCTable: Error getting NPC template ID {} while trying to load skill trainer data."+" "+ npcId);
            continue;
          }
         
          if(classId >= ClassId.values().length){
            _log.warning("NPCTable: Error defining learning data for NPC "+npcId+": specified classId "+classId+" is higher then max one "+(ClassId.values().length-1)+" specified into ClassID Enum --> check your Database to be complient with it"+" "+ classId);
            continue;
          }

          npc.addTeachInfo(ClassId.values()[classId]);
        }

        learndata.close();
        statement.close();
      }
      catch(Exception e)
      {
        _log.severe("NPCTable: Error reading NPC trainer data"+" "+ e);
      }

      try
      {
        if (con == null)
        {
          con = L2DatabaseFactory.getInstance().getConnection(false);
        }
        statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
        {
            "boss_id", "minion_id", "amount_min", "amount_max"
        }) + " FROM minions");
        ResultSet minionData = statement.executeQuery();
        L2MinionData minionDat = null;
        L2NpcTemplate npcDat = null;
        int cnt = 0;

        while(minionData.next())
        {
          int raidId = minionData.getInt("boss_id");

          npcDat = _npcs.get(raidId);
          minionDat = new L2MinionData();
          minionDat.setMinionId(minionData.getInt("minion_id"));
          minionDat.setAmountMin(minionData.getInt("amount_min"));
          minionDat.setAmountMax(minionData.getInt("amount_max"));
          npcDat.addRaidData(minionDat);
          cnt++;
        }

        minionData.close();
        statement.close();
View Full Code Here

      npcDat.set("isUndead", NpcData.getString("isUndead"));

      npcDat.set("absorb_level", NpcData.getString("absorb_level"));
      npcDat.set("absorb_type", NpcData.getString("absorb_type"));
     
      L2NpcTemplate template = new L2NpcTemplate(npcDat, custom);
      template.addVulnerability(Stats.BOW_WPN_VULN, 1);
      template.addVulnerability(Stats.BLUNT_WPN_VULN, 1);
      template.addVulnerability(Stats.DAGGER_WPN_VULN, 1);

      _npcs.put(id, template);
    }

    _log.finest("NpcTable: Loaded {} Npc Templates."+" "+ _npcs.size());
View Full Code Here

    Connection con = null;
   
    try
    {
      // save a copy of the old data
      L2NpcTemplate old = getTemplate(id);
      Map<Integer, L2Skill> skills = new FastMap<Integer, L2Skill>();
     
      skills.putAll(old.getSkills());
     
      FastList<L2DropCategory> categories = new FastList<L2DropCategory>();
     
      if (old.getDropData() != null)
      {
        categories.addAll(old.getDropData());
      }
      ClassId[] classIds = old.getTeachInfo().clone();
     
      List<L2MinionData> minions = new FastList<L2MinionData>();
     
      if (old.getMinionData() != null)
      {
        minions.addAll(old.getMinionData());
      }
     
      // reload the NPC base data
      con = L2DatabaseFactory.getInstance().getConnection(false);
     
      if (old.isCustom())
      {
       
        final PreparedStatement st = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
        {
          "id",
          "idTemplate",
          "name",
          "serverSideName",
          "title",
          "serverSideTitle",
          "class",
          "collision_radius",
          "collision_height",
          "level",
          "sex",
          "type",
          "attackrange",
          "hp",
          "mp",
          "hpreg",
          "mpreg",
          "str",
          "con",
          "dex",
          "int",
          "wit",
          "men",
          "exp",
          "sp",
          "patk",
          "pdef",
          "matk",
          "mdef",
          "atkspd",
          "aggro",
          "matkspd",
          "rhand",
          "lhand",
          "armor",
          "walkspd",
          "runspd",
          "faction_id",
          "faction_range",
          "isUndead",
          "absorb_level",
          "absorb_type"
        }) + " FROM custom_npc WHERE id=?");
        st.setInt(1, id);
        final ResultSet rs = st.executeQuery();
        fillNpcTable(rs, true);
        rs.close();
        st.close();
       
      }
      else
      {
       
        final PreparedStatement st = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
        {
          "id",
          "idTemplate",
          "name",
          "serverSideName",
          "title",
          "serverSideTitle",
          "class",
          "collision_radius",
          "collision_height",
          "level",
          "sex",
          "type",
          "attackrange",
          "hp",
          "mp",
          "hpreg",
          "mpreg",
          "str",
          "con",
          "dex",
          "int",
          "wit",
          "men",
          "exp",
          "sp",
          "patk",
          "pdef",
          "matk",
          "mdef",
          "atkspd",
          "aggro",
          "matkspd",
          "rhand",
          "lhand",
          "armor",
          "walkspd",
          "runspd",
          "faction_id",
          "faction_range",
          "isUndead",
          "absorb_level",
          "absorb_type"
        }) + " FROM npc WHERE id=?");
        st.setInt(1, id);
        final ResultSet rs = st.executeQuery();
        fillNpcTable(rs, false);
        rs.close();
        st.close();
       
      }
     
      // restore additional data from saved copy
      L2NpcTemplate created = getTemplate(id);
     
      for (L2Skill skill : skills.values())
      {
        created.addSkill(skill);
      }
     
      for (ClassId classId : classIds)
      {
        created.addTeachInfo(classId);
      }
     
      for (L2MinionData minion : minions)
      {
        created.addRaidData(minion);
      }
    }
    catch (Exception e)
    {
      _log.severe("NPCTable: Could not reload data for NPC {}" + " " + id + " " + e);
View Full Code Here

      Map<String, Object> set = npc.getSet();

      String name = "";
      String values = "";

      final L2NpcTemplate old = getTemplate(npc.getInteger("npcId"));
       
      for(Object obj : set.keySet())
      {
        name = (String) obj;

        if(!name.equalsIgnoreCase("npcId"))
        {
          if(values != "")
          {
            values += ", ";
          }

          values += name + " = '" + set.get(name) + "'";
        }
      }

      PreparedStatement statement = null;
      if(old.isCustom()){
        statement = con.prepareStatement("UPDATE custom_npc SET " + values + " WHERE id = ?");
       
      }else{
        statement = con.prepareStatement("UPDATE npc SET " + values + " WHERE id = ?");
       
View Full Code Here

    {
      title = "Invisible";
    }
    if(_activeChar.getPoly().isMorphed())
    {
      L2NpcTemplate polyObj = NpcTable.getInstance().getTemplate(_activeChar.getPoly().getPolyId());
      if(polyObj != null)
      {
        title += " - " + polyObj.name;
      }
    }
View Full Code Here

  }

  public static void spawn(L2PcInstance target, int npcid)
  {

    L2NpcTemplate template1 = NpcTable.getInstance().getTemplate(npcid);

    try
    {
      //L2MonsterInstance mob = new L2MonsterInstance(template1);
View Full Code Here

TOP

Related Classes of com.l2jfrozen.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.