Package net.sf.l2j.gameserver.templates

Examples of net.sf.l2j.gameserver.templates.L2NpcTemplate


      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        PreparedStatement statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
        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);
      }

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

        while (dropData.next())
        {
          int mobId = dropData.getInt("mobId");
          npcDat = _npcs.get(mobId);
          if (npcDat == null)
          {
            _log.severe("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);
        }

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

      try
      {
        PreparedStatement statement3 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"npc_id", "class_id"}) + " FROM skill_learn");
        ResultSet learndata = statement3.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 " + npcId + " while trying to load skill trainer data.");
            continue;
          }

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

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

      try
      {
        PreparedStatement statement4 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"boss_id", "minion_id", "amount_min", "amount_max"}) + " FROM minions");
        ResultSet minionData = statement4.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();
        statement4.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);
      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.config("NpcTable: Loaded " + _npcs.size() + " Npc Templates.");
View Full Code Here

    java.sql.Connection con = null;

    try
    {
      // save a copy of the old data
      L2NpcTemplate old = getTemplate(id);
      Map<Integer,L2Skill> skills = new FastMap<Integer,L2Skill>();

      if (old.getSkills() != null)
        skills.putAll(old.getSkills());

      FastList<L2DropCategory> categories = new FastList<L2DropCategory>();

      if (old.getDropData() != null)
        categories.addAll(old.getDropData());

      ClassId[] classIds = null;

      if (old.getTeachInfo() != null)
        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();
      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);
      ResultSet rs = st.executeQuery();
      fillNpcTable(rs);
      rs.close();
      st.close();

      // restore additional data from saved copy
      L2NpcTemplate created = getTemplate(id);

      for (L2Skill skill : skills.values())
        created.addSkill(skill);

      if (classIds != null)
        for (ClassId classId : classIds)
          created.addTeachInfo(classId);

      for (L2MinionData minion : minions)
        created.addRaidData(minion);
    }
    catch (Exception e)
    {
      _log.warning("NPCTable: Could not reload data for NPC " + id + ": " + e);
    }
View Full Code Here

    if (target == null)
      target = activeChar;
    if (target != activeChar && activeChar.getAccessLevel() < REQUIRED_LEVEL2)
      return;

    L2NpcTemplate template1;
    if (monsterId.matches("[0-9]*"))
    {
      //First parameter was an ID number
      int monsterTemplate = Integer.parseInt(monsterId);
      template1 = NpcTable.getInstance().getTemplate(monsterTemplate);
    }
    else
    {
      //First parameter wasn't just numbers so go by name not ID
      monsterId = monsterId.replace('_', ' ');
      template1 = NpcTable.getInstance().getTemplateByName(monsterId);
    }

    try
    {
      L2Spawn spawn = new L2Spawn(template1);
      spawn.setLocx(target.getX());
      spawn.setLocy(target.getY());
      spawn.setLocz(target.getZ());
      spawn.setAmount(mobCount);
      spawn.setHeading(activeChar.getHeading());
      spawn.setRespawnDelay(respawnTime);
      if (RaidBossSpawnManager.getInstance().isDefined(spawn.getNpcid()))
        activeChar.sendMessage("You cannot spawn another instance of " + template1.name + ".");
      else
      {
        if (RaidBossSpawnManager.getInstance().getValidTemplate(spawn.getNpcid()) != null)
          RaidBossSpawnManager.getInstance().addNewSpawn(spawn, 0, template1.getStatsSet().getDouble("baseHpMax"), template1.getStatsSet().getDouble("baseMpMax"), permanent);
        else
          SpawnTable.getInstance().addNewSpawn(spawn, permanent);
        spawn.init();
        if (!permanent)
          spawn.stopRespawn();
View Full Code Here

     */
  public L2NpcTemplate addEventId(int npcId, QuestEventType eventType)
  {
      try
      {
    L2NpcTemplate t = NpcTable.getInstance().getTemplate(npcId);
    if (t != null)
    {
      t.addQuestEvent(eventType, this);
    }
    return t;
      }
      catch(Exception e)
      {
View Full Code Here

    public L2NpcInstance addSpawn(int npcId, int x, int y, int z,int heading, boolean randomOffset, int despawnDelay)
    {
      L2NpcInstance result = null;
        try
        {
            L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
            if (template != null)
            {
                // Sometimes, even if the quest script specifies some xyz (for example npc.getX() etc) by the time the code
              // reaches here, xyz have become 0!  Also, a questdev might have purposely set xy to 0,0...however,
              // the spawn code is coded such that if x=y=0, it looks into location for the spawn loc!  This will NOT work
View Full Code Here

    {
      activeChar.sendMessage("Mob group " + groupId + " already exists.");
      return;
    }

    L2NpcTemplate template = NpcTable.getInstance().getTemplate(templateId);

    if (template == null)
    {
      activeChar.sendMessage("Invalid NPC ID specified.");
      return;
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

        for (SiegeSpawn _sp: SiegeManager.getInstance().getControlTowerSpawnList(Id))
        {
          L2ControlTowerInstance ct;

          L2NpcTemplate template = NpcTable.getInstance().getTemplate(_sp.getNpcId());

            template.getStatsSet().set("baseHpMax", _sp.getHp());
            // TODO: Check/confirm if control towers have any special weapon resistances/vulnerabilities
            // template.addVulnerability(Stats.BOW_WPN_VULN,0);
            // template.addVulnerability(Stats.BLUNT_WPN_VULN,0);
            // template.addVulnerability(Stats.DAGGER_WPN_VULN,0);
View Full Code Here

      break;
    default:
      npcid = 18319;
        break;
    }
    L2NpcTemplate temp;
    temp = NpcTable.getInstance().getTemplate(npcid);
    if (temp != null)
    {
      try
      {
View Full Code Here

TOP

Related Classes of net.sf.l2j.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.