Package l2p.gameserver.model.instances

Examples of l2p.gameserver.model.instances.L2NpcInstance


  }

  @Override
  protected boolean createNewTask()
  {
    L2NpcInstance actor = getActor();
    if(actor == null)
    {
      return true;
    }
    if(!BaiumManager.getZone().checkIfInZone(actor))
    {
      teleportHome(true);
      return false;
    }
    clearTasks();
    L2Character target;
    if((target = prepareTarget()) == null)
    {
      return false;
    }
    if(!BaiumManager.getZone().checkIfInZone(target))
    {
      target.removeFromHatelist(actor, false);
      return false;
    }
    // Шансы использования скилов
    int s_energy_wave = 20;
    int s_earth_quake = 20;
    int s_group_hold = actor.getCurrentHpPercents() > 50 ? 0 : 20;
    int s_thunderbolt = actor.getCurrentHpPercents() > 25 ? 0 : 20;
    L2Skill r_skill = null;
    if(actor.isRooted()) // Если в руте, то использовать массовый скилл дальнего боя
    {
      r_skill = thunderbolt;
    }
    else if(!Rnd.chance(100 - s_thunderbolt - s_group_hold - s_energy_wave - s_earth_quake)) // Выбираем скилл атаки
    {
      FastMap<L2Skill, Integer> d_skill = new FastMap<L2Skill, Integer>(); //TODO class field ?
      double distance = actor.getDistance(target);
      addDesiredSkill(d_skill, target, distance, energy_wave);
      addDesiredSkill(d_skill, target, distance, earth_quake);
      if(s_group_hold > 0)
      {
        addDesiredSkill(d_skill, target, distance, group_hold);
View Full Code Here


  }

  @Override
  protected boolean maybeMoveToHome()
  {
    L2NpcInstance actor = getActor();
    if(actor != null && !BaiumManager.getZone().checkIfInZone(actor))
    {
      teleportHome(true);
    }
    return false;
View Full Code Here

        if (player == null || object == null) {
            return false;
        }
        if (!Config.ALLOW_NPC_SHIFTCLICK && !player.isGM()) {
            if (Config.ALT_GAME_SHOW_DROPLIST && object.isNpc()) {
                L2NpcInstance npc = (L2NpcInstance) object;
                if (npc.isDead()) {
                    return false;
                }
                droplist(player, npc);
            }
            return false;
        }
        if (object.isNpc()) {
            L2NpcInstance npc = (L2NpcInstance) object;
            // Для мертвых мобов не показываем табличку, иначе спойлеры плачут
            if (npc.isDead()) {
                return false;
            }
            String dialog;
            if (Config.ALT_FULL_NPC_STATS_PAGE) {
                dialog = Files.read("data/scripts/actions/player.L2NpcInstance.onActionShift.full.htm", player);
                dialog = dialog.replaceFirst("%class%", String.valueOf(npc.getClass().getSimpleName().replaceFirst("L2", "").replaceFirst("Instance", "")));
                dialog = dialog.replaceFirst("%id%", String.valueOf(npc.getNpcId()));
                dialog = dialog.replaceFirst("%respawn%", String.valueOf(npc.getSpawn() != null ? Util.formatTime(npc.getSpawn().getRespawnDelay()) : "0"));
                dialog = dialog.replaceFirst("%walkSpeed%", String.valueOf(npc.getWalkSpeed()));
                dialog = dialog.replaceFirst("%evs%", String.valueOf(npc.getEvasionRate(null)));
                dialog = dialog.replaceFirst("%acc%", String.valueOf(npc.getAccuracy()));
                dialog = dialog.replaceFirst("%crt%", String.valueOf(npc.getCriticalHit(null, null)));
                dialog = dialog.replaceFirst("%aspd%", String.valueOf(npc.getPAtkSpd()));
                dialog = dialog.replaceFirst("%cspd%", String.valueOf(npc.getMAtkSpd()));
                dialog = dialog.replaceFirst("%loc%", String.valueOf(npc.getSpawn() != null ? npc.getSpawn().getLocation() : "0"));
                dialog = dialog.replaceFirst("%dist%", String.valueOf((int) npc.getDistance3D(player)));
                dialog = dialog.replaceFirst("%killed%", String.valueOf(npc.getTemplate().killscount));
                dialog = dialog.replaceFirst("%spReward%", String.valueOf(npc.getSpReward()));
                dialog = dialog.replaceFirst("%xyz%", npc.getLoc().x + " " + npc.getLoc().y + " " + npc.getLoc().z);
                dialog = dialog.replaceFirst("%ai_type%", npc.getAI().getL2ClassShortName());
                dialog = dialog.replaceFirst("%direction%", player.getDirectionTo(npc, true).toString().toLowerCase());
            } else {
                dialog = Files.read("data/scripts/actions/player.L2NpcInstance.onActionShift.htm", player);
            }
            dialog = dialog.replaceFirst("%name%", npc.getName());
            dialog = dialog.replaceFirst("%level%", String.valueOf(npc.getLevel()));
            dialog = dialog.replaceFirst("%factionId%", npc.getFactionId().equals("") ? "none" : npc.getFactionId());
            dialog = dialog.replaceFirst("%aggro%", String.valueOf(npc.getAggroRange()));
            dialog = dialog.replaceFirst("%maxHp%", String.valueOf(npc.getMaxHp()));
            dialog = dialog.replaceFirst("%maxMp%", String.valueOf(npc.getMaxMp()));
            dialog = dialog.replaceFirst("%pDef%", String.valueOf(npc.getPDef(null)));
            dialog = dialog.replaceFirst("%mDef%", String.valueOf(npc.getMDef(null, null)));
            dialog = dialog.replaceFirst("%pAtk%", String.valueOf(npc.getPAtk(null)));
            dialog = dialog.replaceFirst("%mAtk%", String.valueOf(npc.getMAtk(null, null)));
            dialog = dialog.replaceFirst("%expReward%", String.valueOf(npc.getExpReward()));
            dialog = dialog.replaceFirst("%runSpeed%", String.valueOf(npc.getRunSpeed()));
            // Дополнительная инфа для ГМов
            if (player.isGM()) {
                dialog = dialog.replaceFirst("%AI%", String.valueOf(npc.getAI()) + ",<br1>active: " + npc.getAI().isActive() + ",<br1>intention: " + npc.getAI().getIntention());
            } else {
                dialog = dialog.replaceFirst("%AI%", "");
            }
            show(dialog, player, npc);
        }
View Full Code Here

  }

  @Override
  protected void onEvtAttacked(L2Character attacker, int damage)
  {
    L2NpcInstance actor = getActor();
    int x = actor.getX();
    int y = actor.getY();
    if(x < x1 || x > x2 || y < y1)
    {
      actor.teleToLocation(91008, -85904, -2736);
      actor.setCurrentHp(actor.getMaxHp(), false);
    }
    super.onEvtAttacked(attacker, damage);
  }
View Full Code Here

    }
  }

  public void start(String event)
  {
    L2NpcInstance temp_npc = getNpc();
    if(event.equals("Start"))
    {
      L2NpcInstance mc = addSpawn(MC, -56698, -56430, -2008, 32768);
      Functions.npcSay(mc, TEXT[0]);
      startQuestTimer("1", 30000, mc);
    }
    else if(TALKS.containsKey(event) && temp_npc != null)
    {
      String text = TALKS.get(event).text;
      String nextEvent = TALKS.get(event).event;
      int time = TALKS.get(event).time;
      Functions.npcSay(temp_npc, text);
      startQuestTimer(nextEvent, time, temp_npc);
    }
    else if(WALKS.containsKey(event) && temp_npc != null)
    {
      int x = WALKS.get(event).x;
      int y = WALKS.get(event).y;
      int z = WALKS.get(event).z;
      String nextEvent = WALKS.get(event).event;
      int time = WALKS.get(event).time;
      temp_npc.moveToLocation(new Location(x, y, z), 0, true);
      startQuestTimer(nextEvent, time, temp_npc);
    }
    else if(event.equals("6") && temp_npc != null)
    {
      Functions.npcSay(temp_npc, TEXT[6]);
      temp_npc.moveToLocation(new Location(-56511, -56647, -2008, 36863), 0, true);
      temp_npc.broadcastPacket(new PlaySound(1, "NS22_F", 0, 0, new Location()));
      L2NpcInstance elf = addSpawn(singer1, -56344, -56328, -2008, 32768);
      elf.moveToLocation(new Location(-56657, -56338, -2008, 33102), 0, true);
      L2NpcInstance elf1 = addSpawn(singer2, -56552, -56245, -2008, 36863);
      L2NpcInstance elf2 = addSpawn(singer2, -56546, -56426, -2008, 28672);
      L2NpcInstance elf3 = addSpawn(singer2, -56570, -56473, -2008, 28672);
      L2NpcInstance elf4 = addSpawn(singer2, -56594, -56516, -2008, 28672);
      L2NpcInstance elf5 = addSpawn(singer2, -56580, -56203, -2008, 36863);
      L2NpcInstance elf6 = addSpawn(singer2, -56606, -56157, -2008, 36863);
      startQuestTimer("social1", 6000, elf);
      startQuestTimer("social1", 6000, elf1);
      startQuestTimer("social1", 6000, elf2);
      startQuestTimer("social1", 6000, elf3);
      startQuestTimer("social1", 6000, elf4);
      startQuestTimer("social1", 6000, elf5);
      startQuestTimer("social1", 6000, elf6);
      startQuestTimer("7", 215000, temp_npc);
      startQuestTimer("7", 215000, elf);
      startQuestTimer("7", 215000, elf1);
      startQuestTimer("7", 215000, elf2);
      startQuestTimer("7", 215000, elf3);
      startQuestTimer("7", 215000, elf4);
      startQuestTimer("7", 215000, elf5);
      startQuestTimer("7", 215000, elf6);
    }
    else if(event.equals("7") && temp_npc != null)
    {
      if(temp_npc.getNpcId() == MC)
      {
        Functions.npcSay(temp_npc, TEXT[7]);
        temp_npc.moveToLocation(new Location(-56698, -56430, -2008, 32768), 0, true);
        startQuestTimer("8", 12000, temp_npc);
      }
      else
      {
        //cancelQuestTimer("social1", npc, null);
        temp_npc.moveToLocation(new Location(-56594, -56064, -2008), 0, true);
        startQuestTimer("clean_npc", 9000, temp_npc);
      }
    }
    else if(event.equals("10") && temp_npc != null)
    {
      temp_npc.moveToLocation(new Location(-56483, -56665, -2034), 0, true);
      L2NpcInstance npc1 = addSpawn(circus1, -56495, -56375, -2008, 32768);
      L2NpcInstance npc2 = addSpawn(circus1, -56491, -56289, -2008, 32768);
      L2NpcInstance npc3 = addSpawn(circus2, -56502, -56246, -2008, 32768);
      L2NpcInstance npc4 = addSpawn(circus2, -56496, -56429, -2008, 32768);
      L2NpcInstance npc5 = addSpawn(circus3, -56505, -56334, -2008, 32768);
      L2NpcInstance npc6 = addSpawn(circus4, -56545, -56427, -2008, 32768);
      L2NpcInstance npc7 = addSpawn(circus4, -56552, -56248, -2008, 32768);
      L2NpcInstance npc8 = addSpawn(circus5, -56493, -56473, -2008, 32768);
      L2NpcInstance npc9 = addSpawn(circus5, -56504, -56201, -2008, 32768);
      temp_npc.broadcastPacket(new PlaySound(1, "TP05_F", 0, 0, new Location()));
      startQuestTimer("npc1_1", 3000, npc1);
      startQuestTimer("npc2_1", 3000, npc2);
      startQuestTimer("npc3_1", 3000, npc3);
      startQuestTimer("npc4_1", 3000, npc4);
      startQuestTimer("npc5_1", 3500, npc5);
      startQuestTimer("npc6_1", 4000, npc6);
      startQuestTimer("npc7_1", 4000, npc7);
      startQuestTimer("npc8_1", 3000, npc8);
      startQuestTimer("npc9_1", 3000, npc9);
      startQuestTimer("11", 100000, temp_npc);
      startQuestTimer("11", 100000, npc1);
      startQuestTimer("11", 100000, npc2);
      startQuestTimer("11", 100000, npc3);
      startQuestTimer("11", 100000, npc4);
      startQuestTimer("11", 100000, npc5);
      startQuestTimer("11", 100000, npc6);
      startQuestTimer("11", 100000, npc7);
      startQuestTimer("11", 100000, npc8);
      startQuestTimer("11", 100000, npc9);
    }
    else if(event.equals("11") && temp_npc != null)
    {
      if(temp_npc.getNpcId() == MC)
      {
        Functions.npcSay(temp_npc, TEXT[10]);
        temp_npc.moveToLocation(new Location(-56698, -56430, -2008), 0, true);
        startQuestTimer("12", 5000, temp_npc);
      }
      else
      {
        temp_npc.moveToLocation(new Location(-56343, -56330, -2008), 0, true);
        startQuestTimer("clean_npc", 1000, temp_npc);
      }
    }
    else if(event.equals("14") && temp_npc != null)
    {
      L2NpcInstance npc1 = addSpawn(individual1, -56700, -56385, -2008, 32768);
      startQuestTimer("social1", 2000, npc1);
      startQuestTimer("clean_npc", 49000, npc1);
      startQuestTimer("15", 7000, temp_npc);
    }
    else if(event.equals("17") && temp_npc != null)
    {
      Functions.npcSay(temp_npc, TEXT[15]);
      L2NpcInstance npc1 = addSpawn(individual2, -56700, -56340, -2008, 32768);
      startQuestTimer("social1", 2000, npc1);
      startQuestTimer("clean_npc", 32000, npc1);
      startQuestTimer("18", 9000, temp_npc);
    }
    else if(event.equals("20") && temp_npc != null)
    {
      L2NpcInstance npc1 = addSpawn(individual3, -56703, -56296, -2008, 32768);
      startQuestTimer("social1", 2000, npc1);
      startQuestTimer("clean_npc", 13000, npc1);
      startQuestTimer("21", 8000, temp_npc);
    }
    else if(event.equals("23") && temp_npc != null)
    {
      temp_npc.moveToLocation(new Location(-56702, -56340, -2008), 0, true);
      startQuestTimer("24", 2800, temp_npc);
      L2NpcInstance npc1 = addSpawn(showstuff1, -56672, -56406, -2000, 32768);
      L2NpcInstance npc2 = addSpawn(showstuff2, -56648, -56368, -2000, 32768);
      L2NpcInstance npc3 = addSpawn(showstuff3, -56608, -56338, -2000, 32768);
      L2NpcInstance npc4 = addSpawn(showstuff4, -56652, -56307, -2000, 32768);
      L2NpcInstance npc5 = addSpawn(showstuff5, -56672, -56272, -2000, 32768);
      startQuestTimer("social1", 5500, npc1);
      startQuestTimer("social1_1", 12500, npc1);
      startQuestTimer("28", 19700, npc1);
      startQuestTimer("social1", 5500, npc2);
      startQuestTimer("social1_1", 12500, npc2);
View Full Code Here

  }

  @Override
  protected void onEvtDead(L2Character killer)
  {
    L2NpcInstance actor = getActor();
    if(actor == null)
    {
      return;
    }
    long refId = actor.getReflection().getId();
    if(checkAllDestroyed(actor.getNpcId(), refId))
    {
      // Спаун мобов вокруг обелиска
      for(int i = 0; i < 6; i++)
      {
        for(int mobId : MOBS)
        {
          L2MonsterInstance npc = new L2MonsterInstance(IdFactory.getInstance().getNextId(), NpcTable.getTemplate(mobId));
          npc.setSpawnedLoc(Rnd.coordsRandomize(OBELISK_LOC.clone().setZ(-12224), 500, 900));
          npc.setReflection(actor.getReflection());
          npc.onSpawn();
          npc.spawnMe(npc.getSpawnedLoc());
        }
      }
      // Таск открытия двери
View Full Code Here

      this.activeChar = activeChar;
    }

    public void run()
    {
      L2NpcInstance obj;
      for(int i = 0; i < 8; i++)
      {
        obj = MonsterRace.getInstance().getMonsters()[i];
        // FIXME i don't know, if it's needed (Styx)
        // L2World.removeObject(obj);
View Full Code Here

  }

  @Override
  protected void onEvtDead(L2Character killer)
  {
    L2NpcInstance actor = getActor();
    if(actor == null)
    {
      return;
    }
    if(actor.isDead())
    {
      if(Rnd.chance(40)) //TODO: Уточнить шанс
      {
        for(int i = 0; i < 1; i++)
        {
          try
          {
            L2Spawn spawn = new L2Spawn(NpcTable.getTemplate(MOBS[Rnd.get(MOBS.length)]));
            spawn.setLoc(actor.getLoc());
            L2NpcInstance npc = spawn.doSpawn(true);
            npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, killer, Rnd.get(1, 100));
          }
          catch(Exception e)
          {
            e.printStackTrace();
          }
View Full Code Here

   * Вызывается у гейткиперов
   */
  public void reciveGift()
  {
    L2Player player = (L2Player) getSelf();
    L2NpcInstance npc = getNpc();
    if(player == null || npc == null || !L2NpcInstance.canBypassCheck(player, player.getLastNpc()))
    {
      return;
    }
    if(!isBirthdayToday(player))
    {
      show(Files.read(msgNotToday, player), player, npc);
      return;
    }
    if(isGiftRecivedToday(player))
    {
      show(Files.read(msgAlreadyRecived, player), player, npc);
      return;
    }
    for(L2NpcInstance n : L2World.getAroundNpc(npc))
    {
      if(n.getNpcId() == NPC_ALEGRIA)
      {
        show(Files.read(msgSpawned, player), player, npc);
        return;
      }
    }
    player.sendPacket(new PlaySound(1, "HB01", 0, 0, new Location()));
    try
    {
      Location loc = GeoEngine.findPointToStay(npc.getX(), npc.getY(), npc.getZ(), 40, 60, npc.getReflection().getGeoIndex());
      loc.setH(Util.getHeadingTo(loc, player.getLoc()));
      L2Spawn spawn = new L2Spawn(NpcTable.getTemplate(NPC_ALEGRIA));
      spawn.setLoc(loc);
      spawn.doSpawn(true);
      ThreadPoolManager.getInstance().scheduleAi(new DeSpawnScheduleTimerTask(spawn), 180000, false);
View Full Code Here

   * Вызывается у NPC Alegria
   */
  public void reciveGiftAlegria()
  {
    L2Player player = (L2Player) getSelf();
    L2NpcInstance npc = getNpc();
    if(player == null || npc == null || !L2NpcInstance.canBypassCheck(player, player.getLastNpc()) || npc.isBusy())
    {
      return;
    }
    if(!isBirthdayToday(player))
    {
      show(Files.read(msgNotToday, player), player, npc);
      return;
    }
    if(isGiftRecivedToday(player))
    {
      show(Files.read(msgAlreadyRecived, player), player, npc);
      return;
    }
    npc.altUseSkill(SkillTable.getInstance().getInfo(BIRTHDAY_CAKE, 1), player);
    addItem(player, HAT, 1);
    show(Files.read("data/html/default/32600-2.htm ", player), player, npc);
    long now = System.currentTimeMillis() / 1000;
    player.setVar("Birthday", String.valueOf(now));
    DecayTaskManager.getInstance().addDecayTask(npc);
    npc.setBusy(true);
  }
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.instances.L2NpcInstance

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.