Examples of NpcTemplate


Examples of lineage2.gameserver.templates.npc.NpcTemplate

   */
  @Override
  public boolean useItem(Playable playable, ItemInstance item, boolean ctrl)
  {
    final Player activeChar = (Player) playable;
    NpcTemplate template = null;
    final int itemId = item.getItemId();
    for (int i = 0; i < _itemIds.length; i++)
    {
      if (_itemIds[i] == itemId)
      {
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

  {
    if (!Config.EVENT_BOUNTY_HUNTERS_ENABLED)
    {
      return;
    }
    NpcTemplate target;
    double mod = 1.;
    if (id == 0)
    {
      final List<NpcTemplate> monsters = NpcHolder.getInstance().getAllOfLevel(player.getLevel());
      if ((monsters == null) || monsters.isEmpty())
      {
        show(new CustomMessage("scripts.events.bountyhunters.NoTargets", player), player);
        return;
      }
      final List<NpcTemplate> targets = new ArrayList<>();
      for (NpcTemplate npc : monsters)
      {
        if (checkTarget(npc))
        {
          targets.add(npc);
        }
      }
      if (targets.isEmpty())
      {
        show(new CustomMessage("scripts.events.bountyhunters.NoTargets", player), player);
        return;
      }
      target = targets.get(Rnd.get(targets.size()));
    }
    else
    {
      target = NpcHolder.getInstance().getTemplate(id);
      if ((target == null) || !checkTarget(target))
      {
        show(new CustomMessage("scripts.events.bountyhunters.WrongTarget", player), player);
        return;
      }
      if ((player.getLevel() - target.level) > 5)
      {
        show(new CustomMessage("scripts.events.bountyhunters.TooEasy", player), player);
        return;
      }
      mod = (0.5 * ((10 + target.level) - player.getLevel())) / 10.;
    }
    final int mobcount = target.level + Rnd.get(25, 50);
    player.setVar("bhMonstersId", String.valueOf(target.getNpcId()), -1);
    player.setVar("bhMonstersNeeded", String.valueOf(mobcount), -1);
    player.setVar("bhMonstersKilled", "0", -1);
    final int fails = (player.getVar("bhfails") == null) ? 0 : Integer.parseInt(player.getVar("bhfails")) * 5;
    final int success = (player.getVar("bhsuccess") == null) ? 0 : Integer.parseInt(player.getVar("bhsuccess")) * 5;
    final double reputation = Math.min(Math.max(((100 + success) - fails) / 100., .25), 2.) * mod;
 
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

        activeChar.setAgathion(getNpcId());
        // If have lifeTime this is a servitor agathion...
        if (_lifeTime > 0)
        {
          Skill agatSkill = getFirstAddedSkill();
          NpcTemplate agatTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
          AgathionInstance agat = new AgathionInstance(IdFactory.getInstance().getNextId(), agatTemplate, activeChar, _lifeTime, agatSkill, activeChar.getLoc());
          agat.setReflection(activeChar.getReflection());
          agat.spawnMe(activeChar.getLoc());
          agat.setFollowTarget(activeChar);
          agat.setIsInvul(true);
          agat.setRunning();
          ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(agat), _lifeTime);
        }
        break;
      case TRAP:
        Skill trapSkill = getFirstAddedSkill();
        if (activeChar.getTrapsCount() >= 5)
        {
          activeChar.destroyFirstTrap();
        }
        TrapInstance trap = new TrapInstance(IdFactory.getInstance().getNextId(), NpcHolder.getInstance().getTemplate(getNpcId()), activeChar, trapSkill);
        activeChar.addTrap(trap);
        trap.spawnMe();
        break;
      case SERVITOR:
      case MULTI_SERVITOR:
      case SIEGE_SUMMON:
        Location loc = null;
        if (_targetType == SkillTargetType.TARGET_CORPSE)
        {
          for (Creature target : targets)
          {
            if ((target != null) && target.isDead())
            {
              activeChar.getAI().setAttackTarget(null);
              loc = target.getLoc();
              if (target.isNpc())
              {
                ((NpcInstance) target).endDecayTask();
              }
              else if (target.isServitor())
              {
                ((SummonInstance) target).endDecayTask();
              }
              else
              {
                return;
              }
            }
          }
        }
        if (activeChar.isMounted() || !activeChar.getSummonList().canSummon(_summonType, _summonPoint))
        {
          return;
        }
        NpcTemplate summonTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
        SummonInstance summon = new SummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, _lifeTime, _summonPoint, this);
        activeChar.getSummonList().addSummon(summon);
        summon.setExpPenalty(_expPenalty);
        summon.setExp(Experience.LEVEL[Math.min(summon.getLevel(), Experience.LEVEL.length - 1)]);
        summon.setHeading(activeChar.getHeading());
        summon.setReflection(activeChar.getReflection());
        summon.spawnMe(loc == null ? Location.findAroundPosition(activeChar, 50, 70) : loc);
        summon.setRunning();
        summon.setFollowMode(true);
        if (summon.getSkillLevel(4140) > 0)
        {
          summon.altUseSkill(SkillTable.getInstance().getInfo(4140, summon.getSkillLevel(4140)), activeChar);
        }
        if (summon.getName().equalsIgnoreCase("Shadow"))
        {
          summon.addStatFunc(new FuncAdd(Stats.ABSORB_DAMAGE_PERCENT, 0x40, this, 15));
        }
        if (activeChar.isInOlympiadMode())
        {
          summon.getEffectList().stopAllEffects();
        }
        summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp(), false);
        if (_summonType == SummonType.SIEGE_SUMMON)
        {
          SiegeEvent<?, ?> siegeEvent = activeChar.getEvent(SiegeEvent.class);
          siegeEvent.addSiegeSummon(summon);
        }
        break;
      case MERCHANT:
        if ((activeChar.getSummonList().size() > 0) || activeChar.isMounted())
        {
          return;
        }
        NpcTemplate merchantTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
        MerchantInstance merchant = new MerchantInstance(IdFactory.getInstance().getNextId(), merchantTemplate);
        merchant.setCurrentHp(merchant.getMaxHp(), false);
        merchant.setCurrentMp(merchant.getMaxMp());
        merchant.setHeading(activeChar.getHeading());
        merchant.setReflection(activeChar.getReflection());
        merchant.spawnMe(activeChar.getLoc());
        ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(merchant), _lifeTime);
        break;
      case TREE:
        if (activeChar.isMounted() || !activeChar.getSummonList().canSummon(_summonType, _summonPoint))
        {
          return;
        }
        NpcTemplate treeTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
        Location SummonLoc;
        if (activeChar.getGroundSkillLoc() != null)
        {
          SummonLoc = activeChar.getGroundSkillLoc();
        }
        else
        {
          SummonLoc = activeChar.getLoc();
        }
        Skill summonSkill = getFirstAddedSkill();
        TreeInstance tree = new TreeInstance(IdFactory.getInstance().getNextId(), treeTemplate, activeChar, _lifeTime, summonSkill, SummonLoc);
        activeChar.getSummonList().addSummon(tree);
        tree.setCurrentHp(tree.getMaxHp(), false);
        tree.setCurrentMp(tree.getMaxMp());
        tree.setHeading(activeChar.getHeading());
        tree.setReflection(activeChar.getReflection());
        tree.setFollowMode(false);
        tree.spawnMe(SummonLoc);
        ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(tree), _lifeTime);
        break;
      case SYMBOL:
        if (activeChar.isMounted())
        {
          return;
        }
        NpcTemplate symbolTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
        Location symbolLoc;
        if (activeChar.getGroundSkillLoc() != null)
        {
          symbolLoc = activeChar.getGroundSkillLoc();
        }
        else
        {
          symbolLoc = activeChar.getLoc();
        }
        Skill symbolSkill = getFirstAddedSkill();
        SymbolInstance symbol = new SymbolInstance(IdFactory.getInstance().getNextId(), symbolTemplate, activeChar, symbolSkill);
        symbol.setReflection(activeChar.getReflection());
        symbol.setShowName(false);
        symbol.spawnMe(symbolLoc);
        ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(symbol), _lifeTime);
        break;
      case CLONE:
        if (activeChar.isMounted())
        {
          return;
        }
        Location cloneLoc = Location.findAroundPosition(activeChar, 50, 70);
        CloneInstance clone = new CloneInstance(IdFactory.getInstance().getNextId(), activeChar.getTemplate(), activeChar, _lifeTime, cloneLoc);
        clone.setHeading(activeChar.getHeading());
        clone.setReflection(activeChar.getReflection());
        clone.setCurrentCp(activeChar.getCurrentCp());
        clone.setCurrentHpMp(activeChar.getCurrentHp(), activeChar.getCurrentMp());
        clone.spawnMe(cloneLoc);
        clone.setRunning();
        clone.setFollowMode(true);

        cloneLoc = Location.findAroundPosition(activeChar, 50, 70);
        clone = new CloneInstance(IdFactory.getInstance().getNextId(), activeChar.getTemplate(), activeChar, _lifeTime, cloneLoc);
        clone.setHeading(activeChar.getHeading());
        clone.setReflection(activeChar.getReflection());
        clone.setCurrentCp(activeChar.getCurrentCp());
        clone.setCurrentHpMp(activeChar.getCurrentHp(), activeChar.getCurrentMp());
        clone.spawnMe(cloneLoc);
        clone.setRunning();
        clone.setFollowMode(true);

        cloneLoc = Location.findAroundPosition(activeChar, 50, 70);
        clone = new CloneInstance(IdFactory.getInstance().getNextId(), activeChar.getTemplate(), activeChar, _lifeTime, cloneLoc);
        clone.setHeading(activeChar.getHeading());
        clone.setReflection(activeChar.getReflection());
        clone.setCurrentCp(activeChar.getCurrentCp());
        clone.setCurrentHpMp(activeChar.getCurrentHp(), activeChar.getCurrentMp());
        clone.spawnMe(cloneLoc);
        clone.setRunning();
        clone.setFollowMode(true);
        ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(clone), _lifeTime);
        break;
      case NPC:
        if (activeChar.isMounted())
        {
          return;
        }
        NpcTemplate npcTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
        NpcInstance normalnpc = new NpcInstance(IdFactory.getInstance().getNextId(), npcTemplate);
        normalnpc.setCurrentHp(normalnpc.getMaxHp(), false);
        normalnpc.setCurrentMp(normalnpc.getMaxMp());
        normalnpc.setHeading(activeChar.getHeading());
        normalnpc.setReflection(activeChar.getReflection());
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

    if (_effected.isPlayer() && (((Player) _effected).getGroundSkillLoc() != null))
    {
      loc = ((Player) _effected).getGroundSkillLoc();
      ((Player) _effected).setGroundSkillLoc(null);
    }
    NpcTemplate template = NpcHolder.getInstance().getTemplate(_skill.getSymbolId());
    if (getTemplate()._count <= 1)
    {
      _symbol = new SymbolInstance(IdFactory.getInstance().getNextId(), template, _effected, skill);
    }
    else
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

    if (!activeChar.getReflection().isDefault())
    {
      activeChar.sendMessage("�?ел�?з�? взращиват�? тыкву в ин�?тан�?е.");
      return false;
    }
    NpcTemplate template = null;
    final int itemId = item.getItemId();
    for (int i = 0; i < _itemIds.length; i++)
    {
      if (_itemIds[i] == itemId)
      {
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

          random = Rnd.get(24);
        }
      }
      try
      {
        NpcTemplate template = NpcHolder.getInstance().getTemplate(id + random);
        _constructor = template.getInstanceConstructor();
        int objectId = IdFactory.getInstance().getNextId();
        monsters[i] = (NpcInstance) _constructor.newInstance(objectId, template);
      }
      catch (Exception e)
      {
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

   * @param loc Location
   * @return NpcInstance
   */
  private NpcInstance SpawnNPC(int npcId, Location loc)
  {
    NpcTemplate template = NpcHolder.getInstance().getTemplate(npcId);
    if (template == null)
    {
      System.out.println("WARNING! template is null for npc: " + npcId);
      Thread.dumpStack();
      return null;
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

          }
          set.set("baseAttributeAttack", attributeAttack);
          set.set("baseAttributeDefence", attributeDefence);
        }
      }
      NpcTemplate template = new NpcTemplate(set);
      for (Iterator<org.dom4j.Element> secondIterator = npcElement.elementIterator(); secondIterator.hasNext();)
      {
        org.dom4j.Element secondElement = secondIterator.next();
        String nodeName = secondElement.getName();
        if (nodeName.equalsIgnoreCase("faction"))
        {
          String factionId = secondElement.attributeValue("name");
          Faction faction = new Faction(factionId);
          int factionRange = Integer.parseInt(secondElement.attributeValue("range"));
          faction.setRange(factionRange);
          for (Iterator<org.dom4j.Element> nextIterator = secondElement.elementIterator(); nextIterator.hasNext();)
          {
            final org.dom4j.Element nextElement = nextIterator.next();
            int ignoreId = Integer.parseInt(nextElement.attributeValue("npc_id"));
            faction.addIgnoreNpcId(ignoreId);
          }
          template.setFaction(faction);
        }
        else if (nodeName.equalsIgnoreCase("rewardlist"))
        {
          RewardType type = RewardType.valueOf(secondElement.attributeValue("type"));
          boolean autoLoot = (secondElement.attributeValue("auto_loot") != null) && Boolean.parseBoolean(secondElement.attributeValue("auto_loot"));
          RewardList list = new RewardList(type, autoLoot);
          for (Iterator<org.dom4j.Element> nextIterator = secondElement.elementIterator(); nextIterator.hasNext();)
          {
            final org.dom4j.Element nextElement = nextIterator.next();
            final String nextName = nextElement.getName();
            if (nextName.equalsIgnoreCase("group"))
            {
              double enterChance = nextElement.attributeValue("chance") == null ? RewardList.MAX_CHANCE : Double.parseDouble(nextElement.attributeValue("chance")) * 10000;
              RewardGroup group = (type == RewardType.SWEEP) || (type == RewardType.NOT_RATED_NOT_GROUPED) ? null : new RewardGroup(enterChance);
              for (Iterator<org.dom4j.Element> rewardIterator = nextElement.elementIterator(); rewardIterator.hasNext();)
              {
                org.dom4j.Element rewardElement = rewardIterator.next();
                RewardData data = parseReward(rewardElement);
                if ((type == RewardType.SWEEP) || (type == RewardType.NOT_RATED_NOT_GROUPED))
                {
                  warn("Can't load rewardlist from group: " + npcId + "; type: " + type);
                }
                else
                {
                  group.addData(data);
                }
              }
              if (group != null)
              {
                list.add(group);
              }
            }
            else if (nextName.equalsIgnoreCase("reward"))
            {
              if ((type != RewardType.SWEEP) && (type != RewardType.NOT_RATED_NOT_GROUPED))
              {
                warn("Reward can't be without group(and not grouped): " + npcId + "; type: " + type);
                continue;
              }
              RewardData data = parseReward(nextElement);
              RewardGroup g = new RewardGroup(RewardList.MAX_CHANCE);
              g.addData(data);
              list.add(g);
            }
          }
          if ((type == RewardType.RATED_GROUPED) || (type == RewardType.NOT_RATED_GROUPED))
          {
            if (!list.validate())
            {
              warn("Problems with rewardlist for npc: " + npcId + "; type: " + type);
            }
          }
          template.putRewardList(type, list);
        }
        else if (nodeName.equalsIgnoreCase("skills"))
        {
          for (Iterator<org.dom4j.Element> nextIterator = secondElement.elementIterator(); nextIterator.hasNext();)
          {
            org.dom4j.Element nextElement = nextIterator.next();
            int id = Integer.parseInt(nextElement.attributeValue("id"));
            int level = Integer.parseInt(nextElement.attributeValue("level"));
            if (id == 4416)
            {
              template.setRace(level);
            }
            Skill skill = SkillTable.getInstance().getInfo(id, level);
            if (skill == null)
            {
              continue;
            }
            template.addSkill(skill);
          }
        }
        else if (nodeName.equalsIgnoreCase("minions"))
        {
          for (Iterator<org.dom4j.Element> nextIterator = secondElement.elementIterator(); nextIterator.hasNext();)
          {
            org.dom4j.Element nextElement = nextIterator.next();
            int id = Integer.parseInt(nextElement.attributeValue("npc_id"));
            int count = Integer.parseInt(nextElement.attributeValue("count"));
            template.addMinion(new MinionData(id, count));
          }
        }
        else if (nodeName.equalsIgnoreCase("teach_classes"))
        {
          for (Iterator<org.dom4j.Element> nextIterator = secondElement.elementIterator(); nextIterator.hasNext();)
          {
            org.dom4j.Element nextElement = nextIterator.next();
            int id = Integer.parseInt(nextElement.attributeValue("id"));
            template.addTeachInfo(ClassId.VALUES[id]);
          }
        }
        else if (nodeName.equalsIgnoreCase("absorblist"))
        {
          for (Iterator<org.dom4j.Element> nextIterator = secondElement.elementIterator(); nextIterator.hasNext();)
          {
            org.dom4j.Element nextElement = nextIterator.next();
            int chance = Integer.parseInt(nextElement.attributeValue("chance"));
            int cursedChance = nextElement.attributeValue("cursed_chance") == null ? 0 : Integer.parseInt(nextElement.attributeValue("cursed_chance"));
            int minLevel = Integer.parseInt(nextElement.attributeValue("min_level"));
            int maxLevel = Integer.parseInt(nextElement.attributeValue("max_level"));
            boolean skill = (nextElement.attributeValue("skill") != null) && Boolean.parseBoolean(nextElement.attributeValue("skill"));
            AbsorbInfo.AbsorbType absorbType = AbsorbInfo.AbsorbType.valueOf(nextElement.attributeValue("type"));
            template.addAbsorbInfo(new AbsorbInfo(skill, absorbType, chance, cursedChance, minLevel, maxLevel));
          }
        }
        else if (nodeName.equalsIgnoreCase("teleportlist"))
        {
          for (Iterator<org.dom4j.Element> sublistIterator = secondElement.elementIterator(); sublistIterator.hasNext();)
          {
            org.dom4j.Element subListElement = sublistIterator.next();
            int id = Integer.parseInt(subListElement.attributeValue("id"));
            List<TeleportLocation> list = new ArrayList<>();
            for (Iterator<org.dom4j.Element> targetIterator = subListElement.elementIterator(); targetIterator.hasNext();)
            {
              org.dom4j.Element targetElement = targetIterator.next();
              int itemId = Integer.parseInt(targetElement.attributeValue("item_id", "57"));
              long price = Integer.parseInt(targetElement.attributeValue("price"));
              int npcStringId = Integer.parseInt(targetElement.attributeValue("name"));
              int castleId = Integer.parseInt(targetElement.attributeValue("castle_id", "0"));
              TeleportLocation loc = new TeleportLocation(itemId, price, npcStringId, castleId);
              loc.set(Location.parseLoc(targetElement.attributeValue("loc")));
              list.add(loc);
            }
            template.addTeleportList(id, list.toArray(new TeleportLocation[list.size()]));
          }
        }
        else if (nodeName.equalsIgnoreCase("walker_route"))
        {
          int id = Integer.parseInt(secondElement.attributeValue("id"));
          WalkerRouteType type = secondElement.attributeValue("type") == null ? WalkerRouteType.LENGTH : WalkerRouteType.valueOf(secondElement.attributeValue("type").toUpperCase());
          WalkerRoute walkerRoute = new WalkerRoute(id, type);
          for (Iterator<?> nextIterator = secondElement.elementIterator(); nextIterator.hasNext(); )
          {
            org.dom4j.Element nextElement = (org.dom4j.Element)nextIterator.next();
            Location loc = Location.parse(nextElement);
            NpcString phrase = nextElement.attributeValue("phrase_id") == null ? null : NpcString.valueOf(Integer.parseInt(nextElement.attributeValue("phrase_id").toUpperCase()));
            int socialActionId = nextElement.attributeValue("social_action_id") == null ? -1 : Integer.parseInt(nextElement.attributeValue("social_action_id"));
            int delay = nextElement.attributeValue("delay") == null ? 0 : Integer.parseInt(nextElement.attributeValue("delay"));
            boolean running = nextElement.attributeValue("running") == null ? false : Boolean.parseBoolean(nextElement.attributeValue("running"));
            walkerRoute.addPoint(new WalkerRoutePoint(loc, phrase, socialActionId, delay, running));
          }
          template.addWalkerRoute(walkerRoute);
        }
        else if (nodeName.equalsIgnoreCase("random_actions"))
        {
          boolean random_order = secondElement.attributeValue("random_order") == null ? false : Boolean.parseBoolean(secondElement.attributeValue("random_order"));
          RandomActions randomActions = new RandomActions(random_order);
          for (Iterator<?> nextIterator = secondElement.elementIterator(); nextIterator.hasNext(); )
          {
            org.dom4j.Element nextElement = (org.dom4j.Element)nextIterator.next();
            int id = Integer.parseInt(nextElement.attributeValue("id"));
            NpcString phrase = nextElement.attributeValue("phrase_id") == null ? null : NpcString.valueOf(Integer.parseInt(nextElement.attributeValue("phrase_id")));
            int socialActionId = nextElement.attributeValue("social_action_id") == null ? -1 : Integer.parseInt(nextElement.attributeValue("social_action_id"));
            int delay = nextElement.attributeValue("delay") == null ? 0 : Integer.parseInt(nextElement.attributeValue("delay"));
            randomActions.addAction(new RandomActions.Action(id, phrase, socialActionId, delay));
          }
          template.setRandomActions(randomActions);
        }
      }
      getHolder().addTemplate(template);
    }
  }
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

            {
              StatsSet ss = new StatsSet();
              ss.set("npcId", 0);
              ss.set("type", "Npc");
              ss.set("name", "");
              NpcTemplate template = new NpcTemplate(ss);
              new L2StatueInstance(IdFactory.getInstance().getNextId(), template, museum.getObjectId(), location, getTopPlayerItems(museum.getObjectId()), getTopPlayerAppearance(museum.getObjectId()));
            }
          }
        }
      }
View Full Code Here

Examples of lineage2.gameserver.templates.npc.NpcTemplate

   * @param id int
   * @return NpcTemplate
   */
  public NpcTemplate getTemplate(int id)
  {
    NpcTemplate npc = ArrayUtils.valid(_allTemplates, id);
    if (npc == null)
    {
      warn("Not defined npc id : " + id + ", or out of range!", new Exception());
      return null;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.