Esempio n. 1
0
 /**
  * Method onEvtDead.
  *
  * @param killer Creature
  */
 @Override
 protected void onEvtDead(Creature killer) {
   final NpcInstance actor = getActor();
   final int npcId = actor.getNpcId();
   switch (npcId) {
     case 25605:
       {
         epidosIndex.put(1, epidosIndex.get(1) + 1);
         break;
       }
     case 25606:
       {
         epidosIndex.put(2, epidosIndex.get(2) + 1);
         break;
       }
     case 25607:
       {
         epidosIndex.put(3, epidosIndex.get(3) + 1);
         break;
       }
     case 25608:
       {
         epidosIndex.put(4, epidosIndex.get(4) + 1);
         break;
       }
     default:
       break;
   }
   if ((isBossSpawnCondMet() != 0) && !NaiaCoreManager.isBossSpawned()) {
     NaiaCoreManager.spawnEpidos(isBossSpawnCondMet());
   }
   super.onEvtDead(killer);
 }
 /** Method runImpl. */
 @Override
 protected final void runImpl() {
   final Player activeChar = getClient().getActiveChar();
   if (activeChar == null) {
     return;
   }
   ItemInstance adena = activeChar.getInventory().getItemByItemId(57);
   if ((_bid < 0) || (_bid > adena.getCount())) {
     return;
   }
   final ItemAuctionInstance instance =
       ItemAuctionManager.getInstance().getManagerInstance(_instanceId);
   NpcInstance broker = activeChar.getLastNpc();
   if ((broker == null)
       || (broker.getNpcId() != _instanceId)
       || (activeChar.getDistance(broker.getX(), broker.getY()) > Creature.INTERACTION_DISTANCE)) {
     return;
   }
   if (instance != null) {
     final ItemAuction auction = instance.getCurrentAuction();
     if (auction != null) {
       auction.registerBid(activeChar, _bid);
     }
   }
 }
Esempio n. 3
0
  /**
   * Method onEvtClanAttacked.
   *
   * @param attacked_member Creature
   * @param attacker Creature
   * @param damage int
   */
  @Override
  protected void onEvtClanAttacked(Creature attacked_member, Creature attacker, int damage) {
    super.onEvtClanAttacked(attacked_member, attacker, damage);
    final NpcInstance actor = getActor();

    if (_healSkills.length == 0) {
      return;
    }

    if (attacked_member.isDead()
        || actor.isDead()
        || (attacked_member.getCurrentHpPercents() > 50)) {
      return;
    }

    int heal_chance = 0;

    if (attacked_member.getId() == actor.getId()) {
      heal_chance = (attacked_member.getObjectId() == actor.getObjectId()) ? 100 : 0;
    } else {
      heal_chance = (attacked_member.getId() == Orfen_id) ? 90 : 10;
    }

    if (Rnd.chance(heal_chance) && canUseSkill(_healSkills[0], attacked_member, -1)) {
      addTaskAttack(attacked_member, _healSkills[0], 1000000);
    }
  }
Esempio n. 4
0
  /**
   * Method sendOrderToMinions.
   *
   * @param actor NpcInstance
   */
  private void sendOrderToMinions(NpcInstance actor) {
    if (!actor.isInCombat()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final MinionList ml = actor.getMinionList();

    if ((ml == null) || !ml.hasMinions()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final long now = System.currentTimeMillis();

    if ((_nextOrderTime > now) && (_lastMinionsTargetRef.get() != null)) {
      final Player old_target = _lastMinionsTargetRef.get();

      if ((old_target != null) && !old_target.isAlikeDead()) {
        for (MinionInstance m : ml.getAliveMinions()) {
          if (!m.getAI().getAttackTarget().equals(old_target)) {
            m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, old_target, 10000000);
          }
        }

        return;
      }
    }

    _nextOrderTime = now + 30000;
    final List<Player> pl = World.getAroundPlayers(actor);

    if (pl.isEmpty()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final List<Player> alive = new LazyArrayList<>();

    for (Player p : pl) {
      if (!p.isAlikeDead()) {
        alive.add(p);
      }
    }

    if (alive.isEmpty()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final Player target = alive.get(Rnd.get(alive.size()));
    _lastMinionsTargetRef = target.getRef();
    Functions.npcSay(actor, "You " + target.getName() + "! Attack them!");

    for (MinionInstance m : ml.getAliveMinions()) {
      m.getAggroList().clear();
      m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 10000000);
    }
  }
Esempio n. 5
0
 /**
  * Method onEvtDead.
  *
  * @param killer Creature
  */
 @Override
 protected void onEvtDead(Creature killer) {
   final NpcInstance actor = getActor();
   if (Rnd.chance(30)) {
     Functions.npcSay(actor, "Враги! В�?�?ду враги! В�?е �?�?да, враги зде�?�?!");
   }
   actor.deleteMe();
 }
Esempio n. 6
0
 /**
  * Method run.
  *
  * @see java.lang.Runnable#run()
  */
 @Override
 public void run() {
   Functions.npcShout(BlacksmithNpc, mammonText[Rnd.get(mammonText.length)]);
   final int nextTown = Rnd.get(MAMMON_PRIEST_POINTS.length);
   PriestNpc.teleToLocation(MAMMON_PRIEST_POINTS[nextTown]);
   MerchantNpc.teleToLocation(MAMMON_MERCHANT_POINTS[nextTown]);
   BlacksmithNpc.teleToLocation(MAMMON_BLACKSMITH_POINTS[nextTown]);
 }
Esempio n. 7
0
  /**
   * Method onBypassFeedback.
   *
   * @param npc NpcInstance
   * @param player Player
   * @param command String
   * @see lineage2.gameserver.handlers.IBypassHandler#onBypassFeedback(NpcInstance, Player, String)
   */
  @Override
  public void onBypassFeedback(NpcInstance npc, Player player, String command) {
    int val = Integer.parseInt(command.substring(16));
    NpcInstance npcInst = GameObjectsStorage.getByNpcId(val);

    if (npcInst != null) {
      player.sendPacket(new RadarControl(2, 2, npcInst.getLoc()));
      player.sendPacket(new RadarControl(0, 1, npcInst.getLoc()));
    }
  }
Esempio n. 8
0
 void checkInRadius(int id, QuestState st, NpcInstance npc) {
   NpcInstance quest0457 = GameObjectsStorage.getByNpcId(id);
   if (npc.getRealDistance3D(quest0457) <= 150.0D) {
     st.setCond(2);
     if (_followTask != null) {
       _followTask.cancel(false);
     }
     _followTask = null;
     npc.stopMove();
   }
 }
Esempio n. 9
0
 /** Method getProtectionBlessing. */
 public void getProtectionBlessing() {
   Player player = getSelf();
   NpcInstance npc = getNpc();
   if (player.getKarma() > 0) {
     return;
   }
   if ((player.getLevel() > 39) || player.getClassId().isOfLevel(ClassLevel.Second)) {
     show("default/newbie_blessing_no.htm", player, npc);
     return;
   }
   npc.doCast(SkillTable.getInstance().getInfo(5182, 1), player, true);
 }
Esempio n. 10
0
  /**
   * Method onEvtAttacked.
   *
   * @param attacker Creature
   * @param damage int
   */
  @Override
  public void onEvtAttacked(Creature attacker, int damage) {
    final NpcInstance actor = getActor();
    super.onEvtAttacked(attacker, damage);

    if ((PositionUtils.calculateDistance(attacker, actor, false) > 300.) && Rnd.chance(0.13)) {
      addTaskCast(attacker, DRAIN_SKILL);
    }

    final Creature target = actor.getAggroList().getMostHated();

    if ((target.equals(attacker)) && Rnd.chance(0.3)) {
      addTaskCast(attacker, DAMAGE_SKILL);
    }
  }
Esempio n. 11
0
  /**
   * Method canAttackCharacter.
   *
   * @param target Creature
   * @return boolean
   */
  @Override
  protected boolean canAttackCharacter(Creature target) {
    final NpcInstance actor = getActor();

    if (getIntention() == CtrlIntention.AI_INTENTION_ATTACK) {
      final AggroList.AggroInfo ai = actor.getAggroList().get(target);
      return (ai != null) && (ai.hate > 0);
    }

    if (!startBattle) {
      return false;
    }

    return Util.contains(ATTACK_IDS, target.getId());
  }
Esempio n. 12
0
 /**
  * Method removeInvul.
  *
  * @param npc NpcInstance
  */
 private void removeInvul(NpcInstance npc) {
   for (Effect e : npc.getEffectList().getAllEffects()) {
     if (e.getSkill().getId() == 6371) {
       e.exit();
     }
   }
 }
 @Override
 public String onKill(NpcInstance npc, QuestState st) {
   if (st.getState() != STARTED) {
     return null;
   }
   int npcId = npc.getNpcId();
   long album = st.getQuestItemsCount(COIN_ALBUM);
   long coin = st.getQuestItemsCount(KAILS_COIN);
   long clover = st.getQuestItemsCount(CLOVER_COIN);
   if ((npcId == ANCIENT_GARGOYLE) && (coin == 0)) {
     if (Rnd.chance(GARGOYLE_CHANCE)) {
       st.giveItems(KAILS_COIN, 1);
       if ((album > 0) || (clover > 0)) {
         st.playSound(SOUND_MIDDLE);
       } else {
         st.playSound(SOUND_ITEMGET);
       }
     }
   } else if ((npcId == VEGUS) && ((clover + album) == 0) && (st.getInt("id") != 0)) {
     if (Rnd.chance(VEGUS_CHANCE)) {
       st.giveItems(CLOVER_COIN, 1);
       if (coin > 0) {
         st.playSound(SOUND_MIDDLE);
       } else {
         st.playSound(SOUND_ITEMGET);
       }
     }
   }
   return null;
 }
Esempio n. 14
0
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    if (command.equalsIgnoreCase("start_movie")) {
      player.showQuestMovie(104);
    } else super.onBypassFeedback(player, command);
  }
Esempio n. 15
0
  private boolean checkTarget(Creature target) {
    if (target == null) return false;
    if (target.isPlayer()) return true;

    if (target.isNpc()) {
      NpcInstance npc = (NpcInstance) target;
      int _id = npc.getNpcId();
      if (_id == 27430
          || _id == 27431
          || _id == 27432
          || _id == 27433
          || _id == 27434
          || _id == 27425
          || _id == 33416) return false;
    }
    return true;
  }
  @Override
  public String onKill(NpcInstance npc, QuestState qs) {
    if (qs.getCond() == 1) {
      qs.rollAndGive(ARTICLES_DEAD_HEROES, 1, CHANCE + ((npc.getId() - 20234) * 2));
    }

    return null;
  }
  @Override
  public String onTalk(NpcInstance npc, QuestState qs) {
    if (qs.isCompleted()) {
      return "completed";
    }
    String htmltext = "noquest";
    final int cond = qs.getCond();
    final int npcId = npc.getId();

    switch (npcId) {
      case BABENCO:
        if (cond == 0) {
          if (qs.getPlayer().getLevel() < 20) {
            htmltext = "guard_babenco_q0039_0102.htm";
            qs.exitCurrentQuest(true);
          } else if (qs.getPlayer().getLevel() >= 20) {
            htmltext = "guard_babenco_q0039_0101.htm";
          }
        } else if (cond == 1) {
          htmltext = "guard_babenco_q0039_0105.htm";
        }
        break;

      case BATHIS:
        switch (cond) {
          case 1:
            htmltext = "captain_bathia_q0039_0101.htm";
            break;

          case 2:
            if ((qs.getQuestItemsCount(BBN) < 100) || (qs.getQuestItemsCount(RBN) < 100)) {
              htmltext = "captain_bathia_q0039_0203.htm";
            }
            break;

          case 3:
            if ((qs.getQuestItemsCount(BBN) == 100) && (qs.getQuestItemsCount(RBN) == 100)) {
              htmltext = "captain_bathia_q0039_0202.htm";
            }
            break;

          case 4:
            if ((qs.getQuestItemsCount(IP) < 30) || (qs.getQuestItemsCount(GML) < 30)) {
              htmltext = "captain_bathia_q0039_0304.htm";
            }
            break;

          case 5:
            if ((qs.getQuestItemsCount(IP) == 30) && (qs.getQuestItemsCount(GML) == 30)) {
              htmltext = "captain_bathia_q0039_0303.htm";
            }
            break;
        }
        break;
    }

    return htmltext;
  }
Esempio n. 18
0
  private boolean startAttack() {
    NpcInstance actor = getActor();
    if (target == null) {
      List<Creature> around = actor.getAroundCharacters(3000, 150);
      if (around != null && !around.isEmpty()) {
        for (Creature obj : around) {
          if (checkTarget(obj)) {
            if (target == null || actor.getDistance3D(obj) < actor.getDistance3D(target))
              target = obj;
          }
        }
      }
    }

    if (target != null
        && !actor.isAttackingNow()
        && !actor.isCastingNow()
        && !target.isDead()
        && GeoEngine.canSeeTarget(actor, target, false)
        && target.isVisible()) {
      actor.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
      return true;
    }

    if (target != null
        && (!target.isVisible()
            || target.isDead()
            || !GeoEngine.canSeeTarget(actor, target, false))) {
      target = null;
      return false;
    }

    return false;
  }
Esempio n. 19
0
 /**
  * Method onEvtAttacked.
  *
  * @param attacker Creature
  * @param damage int
  */
 @Override
 protected void onEvtAttacked(Creature attacker, int damage) {
   final NpcInstance actor = getActor();
   if (attacker != null) {
     final Location pos = Location.findPointToStay(actor, 150, 250);
     if (GeoEngine.canMoveToCoord(
         attacker.getX(),
         attacker.getY(),
         attacker.getZ(),
         pos.x,
         pos.y,
         pos.z,
         actor.getGeoIndex())) {
       actor.setRunning();
       addTaskMove(pos, false);
     }
   }
 }
  @Override
  public String onKill(NpcInstance npc, QuestState qs) {
    if ((qs.getCond() == 1) && (npc.getId() == SPEZION)) {
      qs.playSound(SOUND_MIDDLE);
      qs.setCond(2);
    }

    return null;
  }
Esempio n. 21
0
  @Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();

    if (Rnd.chance(3)) {
      switch (actor.getNpcId()) {
        case 33172:
          Functions.npcSay(actor, NpcString.THE_ONLY_GOOD_SHILEN_CREATURE_IS_A_DEAD_ONE);
          break;
        case 33170:
          Functions.npcSay(actor, NpcString.GET_BEHIND_ME_GET_BEHIND_ME);
          break;
        default:
          break;
      }
    }
    return startAttack();
  }
Esempio n. 22
0
  /**
   * Method onEvtAggression.
   *
   * @param attacker Creature
   * @param aggro int
   */
  @Override
  protected void onEvtAggression(Creature attacker, int aggro) {
    final NpcInstance actor = (NpcInstance) getActor();
    final Player player = attacker.getPlayer();

    if ((player == null) || (actor == null)) {
      return;
    }

    final SiegeEvent<?, ?> siegeEvent1 = actor.getEvent(SiegeEvent.class);
    final SiegeEvent<?, ?> siegeEvent2 = player.getEvent(SiegeEvent.class);
    final SiegeClanObject siegeClan =
        siegeEvent1.getSiegeClan(SiegeEvent.ATTACKERS, player.getClan());

    if ((siegeEvent2 == null) || ((siegeEvent1.equals(siegeEvent2)) && (siegeClan != null))) {
      ThreadPoolManager.getInstance().schedule(new notifyGuard(player), 1000);
    }
  }
  /**
   * Method onBypassFeedback.
   *
   * @param npc NpcInstance
   * @param player Player
   * @param command String
   * @see lineage2.gameserver.handlers.IBypassHandler#onBypassFeedback(NpcInstance, Player, String)
   */
  @Override
  public void onBypassFeedback(NpcInstance npc, Player player, String command) {
    Reflection r = player.getReflection();
    r.startCollapseTimer(60000);
    player.teleToLocation(r.getReturnLoc(), 0);

    if (command.length() > 22) {
      try {
        int val = Integer.parseInt(command.substring(22));
        npc.showChatWindow(player, val);
      } catch (NumberFormatException nfe) {
        String filename = command.substring(22).trim();

        if (filename.length() > 0) {
          npc.showChatWindow(player, filename);
        }
      }
    }
  }
Esempio n. 24
0
    /** Method runImpl. */
    @Override
    public void runImpl() {
      final NpcInstance actor = (NpcInstance) getActor();
      final Player attacker = _playerRef.get();

      if ((attacker == null) || (actor == null)) {
        return;
      }

      for (NpcInstance npc : actor.getAroundNpc(1500, 200)) {
        if (npc.isSiegeGuard() && Rnd.chance(20)) {
          npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, attacker, 5000);
        }
      }

      if ((attacker.getCastingSkill() != null)
          && (attacker.getCastingSkill().getTargetType() == Skill.SkillTargetType.TARGET_HOLY)) {
        ThreadPoolManager.getInstance().schedule(this, 10000);
      }
    }
  @Override
  public String onKill(NpcInstance npc, QuestState qs) {
    if ((qs.getState() != STARTED) || (qs.getQuestItemsCount(ROYAL_MEMBERSHIP) == 0)) {
      return null;
    }

    final int[] droplist = MOBS.get(npc.getId());
    qs.rollAndGive(droplist[Rnd.get(droplist.length)], 1, 10);

    return null;
  }
  @Override
  public String onKill(NpcInstance npc, QuestState qs) {
    final int npcId = npc.getId();
    final int cond = qs.getCond();

    if (cond == 2) {
      switch (npcId) {
        case LIZARDMAN:
        case LIZARDMAN_SCOUT:
          if (qs.getQuestItemsCount(BBN) <= 99) {
            qs.giveItems(BBN, 1);
          }
          break;

        case LIZARDMAN_GUARD:
          if (qs.getQuestItemsCount(RBN) <= 99) {
            qs.giveItems(RBN, 1);
          }
          break;
      }

      if ((qs.getQuestItemsCount(BBN) + qs.getQuestItemsCount(RBN)) == 200) {
        qs.setCond(3);
        qs.playSound(SOUND_MIDDLE);
      } else {
        qs.playSound(SOUND_ITEMGET);
      }
    } else if (cond == 4) {
      switch (npcId) {
        case LIZARDMAN_SCOUT:
        case LIZARDMAN_GUARD:
          if (qs.getQuestItemsCount(IP) <= 29) {
            qs.giveItems(IP, 1);
          }
          break;

        case GIANT_ARANEID:
          if (qs.getQuestItemsCount(GML) <= 29) {
            qs.giveItems(GML, 1);
          }
          break;
      }

      if ((qs.getQuestItemsCount(IP) + qs.getQuestItemsCount(GML)) == 60) {
        qs.setCond(5);
        qs.playSound(SOUND_MIDDLE);
      } else {
        qs.playSound(SOUND_ITEMGET);
      }
    }

    return null;
  }
Esempio n. 27
0
 /**
  * Method thinkActive.
  *
  * @return boolean
  */
 @Override
 protected boolean thinkActive() {
   final NpcInstance actor = getActor();
   if (actor.isDead()) {
     return true;
   }
   if (_def_think) {
     doTask();
     return true;
   }
   if ((System.currentTimeMillis() > wait_timeout) && ((current_point > -1) || Rnd.chance(5))) {
     if (!wait) {
       switch (current_point) {
         case 5:
           wait_timeout = System.currentTimeMillis() + 15000;
           Functions.npcSay(actor, "The Mother Tree is always so gorgeous!");
           wait = true;
           return true;
         case 9:
           wait_timeout = System.currentTimeMillis() + 60000;
           Functions.npcSay(actor, "Lady Mirabel, may the peace of the lake be with you!");
           wait = true;
           return true;
       }
     }
     wait_timeout = 0;
     wait = false;
     current_point++;
     if (current_point >= points.length) {
       current_point = 0;
     }
     addTaskMove(points[current_point], true);
     doTask();
     return true;
   }
   if (randomAnimation()) {
     return true;
   }
   return false;
 }
Esempio n. 28
0
 @Override
 public String onKill(NpcInstance npc, QuestState st) {
   int cond = st.getCond();
   if ((cond != 1) || (npc == null)) {
     return null;
   }
   if ((ArrayUtils.contains(Mobs, npc.getNpcId())) && (Rnd.chance(50))) {
     st.giveItems(19496, 1L);
   }
   if (st.getQuestItemsCount(19496) >= 45L) {
     st.setCond(2);
   }
   return null;
 }
  @Override
  public String onTalk(NpcInstance npc, QuestState qs) {
    final int cond = qs.getCond();

    if (qs.getState() == 1) {
      if (qs.getPlayer().getLevel() < 38) {
        return "33155-lvl.htm";
      } else if (!qs.isNowAvailable()) {
        return "33155-comp.htm";
      }
    }

    switch (npc.getId()) {
      case LILEJ:
        if (cond < 5) {
          return "33155.htm";
        }
        break;

      case LINKENS:
        if (cond == 1) {
          return "33163.htm";
        } else if (cond == 2) {
          return "33163-5.htm";
        } else if (cond == 5) {
          if (qs.getQuestItemsCount(MARTES_CORE) == 0) {
            return "33163-14.htm";
          } else if (qs.getQuestItemsCount(MARTES_CORE) != 0) {
            qs.takeItems(MARTES_CORE, -1);
            qs.takeItems(TRESURE_TOOL, -1);
            qs.addExpAndSp(240000, 156000);
            qs.unset("cond");
            qs.playSound(SOUND_FINISH);
            qs.exitCurrentQuest(this);
            return "33163-15.htm";
          }
        }
        break;

      case MARTES_NPC:
        if (cond == 3) {
          return "33292.htm";
        } else if (cond == 5) {
          return "33292-1.htm";
        }
        break;
    }

    return "noquest";
  }
Esempio n. 30
0
 /**
  * Method onEvtSeeSpell.
  *
  * @param skill Skill
  * @param caster Creature
  */
 @Override
 protected void onEvtSeeSpell(Skill skill, Creature caster) {
   final NpcInstance actor = getActor();
   if (skill.isMagic()) {
     return;
   }
   if (_mobsNotSpawned) {
     _mobsNotSpawned = false;
     for (int i = 0; i < MOBS_COUNT; i++) {
       try {
         SimpleSpawner sp = new SimpleSpawner(NpcHolder.getInstance().getTemplate(MOBS));
         sp.setLoc(Location.findPointToStay(actor, 100, 120));
         NpcInstance npc = sp.doSpawn(true);
         if (caster.isPet() || caster.isServitor()) {
           npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, caster, Rnd.get(2, 100));
         }
         npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, caster.getPlayer(), Rnd.get(1, 100));
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 }