示例#1
0
  @Override
  public boolean onActionTime() {
    List<L2Character> targetList = new FastList<>();

    // Getting the possible targets
    Collection<L2Object> objs = getEffected().getKnownList().getKnownObjects().values();
    for (L2Object obj : objs) {
      // Attackable NPCs and playable characters (players, summons) are put in the list.
      if ((obj instanceof L2Attackable || obj instanceof L2Playable) && (obj != getEffected()))
        // Don't put doors nor chests on it.
        if (!(obj instanceof L2DoorInstance || obj instanceof L2ChestInstance))
          targetList.add((L2Character) obj);
    }

    // if there is no target, exit function
    if (targetList.isEmpty()) return true;

    // Choosing randomly a new target
    int nextTargetIdx = Rnd.nextInt(targetList.size());
    L2Object target = targetList.get(nextTargetIdx);

    // Attacking the target
    getEffected().setTarget(target);
    getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);

    // Add aggro to that target aswell. The aggro power is random.
    int aggro = (5 + Rnd.get(5)) * getEffector().getLevel();
    ((L2Attackable) getEffected()).addDamageHate((L2Character) target, 0, aggro);

    return true;
  }
 public void setPlayerToKill(L2PcInstance ptk) {
   if (Rnd.get(100) <= 80) {
     CreatureSay cs =
         new CreatureSay(getObjectId(), Say2.ALL, getName(), "mmm your bait was delicious");
     this.broadcastPacket(cs);
   }
   _ptk = ptk;
   addDamageHate(ptk, 0, 10);
   getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, ptk);
   addAttackerToAttackByList(ptk);
 }
  @Override
  public boolean doDie(L2Character killer) {
    if (!super.doDie(killer)) return false;

    if (Rnd.get(100) <= 75) {
      CreatureSay cs =
          new CreatureSay(
              getObjectId(), Say2.ALL, getName(), "I will tell fishes not to take your bait");
      this.broadcastPacket(cs);
    }
    return true;
  }
示例#4
0
  @Override
  public String onKill(final L2Npc npc, final L2PcInstance player, final boolean isPet) {
    final QuestState st = player.getQuestState(qn);
    if (st == null) return null;

    if (st.isStarted() && Rnd.get(10) > 4) {
      st.giveItems(npc.getNpcId() == 20385 ? ORC_AMULET : ORC_NECKLACE, 1);
      st.playSound(QuestState.SOUND_ITEMGET);
    }

    return null;
  }
  @Override
  public String onKill(final L2Npc npc, final L2PcInstance player, final boolean isPet) {
    final QuestState st = player.getQuestState(qn);
    if (st == null) return null;

    if (st.getInt("cond") == 7 && Rnd.get(10) < 2) {
      st.set("cond", "8");
      st.giveItems(GREY_STAR, 1);
      st.playSound(QuestState.SOUND_ITEMGET);
    }

    return null;
  }
  @Override
  public String onKill(final L2Npc npc, final L2PcInstance player, final boolean isPet) {
    final QuestState st = player.getQuestState(qn);
    if (st == null) return null;

    switch (st.getInt("cond")) {
      case 1:
        if (Rnd.get(10) < 4) {
          st.set("cond", "2");
          st.playSound(QuestState.SOUND_MIDDLE);
          st.giveItems(PLAGUE_DUST, 1);
        }
        break;

      case 3:
        if (st.dropQuestItems(PLAGUE_DUST, 1, 5, 400000)) st.set("cond", "4");
        break;
    }

    return null;
  }
  @Override
  public String onKill(final L2Npc npc, final L2PcInstance player, final boolean isPet) {
    final QuestState st = player.getQuestState(qn);
    if (st == null) return null;

    if (st.getInt("cond") == 1 && Rnd.get(4) == 1) {
      switch (npc.getNpcId()) {
        case Dungeon_Skeleton:
        case Dungeon_Skeleton_Archer:
        case Dread_Soldier:
          if (st.getQuestItemsCount(BONE_FRAGMENT) < 10) {
            st.giveItems(BONE_FRAGMENT, 1);

            if (st.getQuestItemsCount(BONE_FRAGMENT) >= 10
                && st.getQuestItemsCount(ELF_SKULL) >= 3) {
              st.playSound(QuestState.SOUND_MIDDLE);
              st.set("cond", "2");
            } else st.playSound(QuestState.SOUND_ITEMGET);
          }
          break;

        case Shade_Horror:
        case Dark_Terror:
        case Mist_Terror:
          if (st.getQuestItemsCount(ELF_SKULL) < 3) {
            st.giveItems(ELF_SKULL, 1);

            if (st.getQuestItemsCount(BONE_FRAGMENT) >= 10
                && st.getQuestItemsCount(ELF_SKULL) >= 3) {
              st.playSound(QuestState.SOUND_MIDDLE);
              st.set("cond", "2");
            } else st.playSound(QuestState.SOUND_ITEMGET);
          }
          break;
      }
    }
    return null;
  }