@Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    if (player.getClan() == null) {
      return null;
    }

    QuestState st = null;

    if (player.isClanLeader()) {
      st = player.getQuestState(getClass());
    } else {
      L2PcInstance pleader = player.getClan().getLeader().getPlayerInstance();
      if (pleader != null && player.isInsideRadius(pleader, 1500, true, false)) {
        st = pleader.getQuestState(getClass());
      }
    }

    if (st != null && st.isStarted()) {
      int raid = st.getInt("raid");
      if (REWARD_POINTS.containsKey(raid)) {
        if (npc.getNpcId() == REWARD_POINTS.get(raid)[0]
            && !st.hasQuestItems(REWARD_POINTS.get(raid)[1])) {
          st.rewardItems(REWARD_POINTS.get(raid)[1], 1);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
        }
      }
    }
    return null;
  }
예제 #2
0
  public void loadBorderPoints() throws IOException {
    Iterator<Entry<RouteRegion, BinaryMapIndexReader>> it = reverseMap.entrySet().iterator();
    int sleft = Math.min(startX, targetX);
    int sright = Math.max(startX, targetX);
    int stop = Math.min(startY, targetY);
    int sbottom = Math.max(startY, targetY);
    // one tile of 12th zoom around (?)
    int zoomAround = 10;
    int distAround = 1 << (31 - zoomAround);
    leftBorderBoundary = sleft - distAround;
    rightBorderBoundary = sright + distAround;
    SearchRequest<RouteDataBorderLinePoint> req =
        BinaryMapIndexReader.buildSearchRouteBorderRequest(sleft, sright, stop, sbottom);
    while (it.hasNext()) {
      Entry<RouteRegion, BinaryMapIndexReader> entry = it.next();
      entry.getValue().searchBorderPoints(req, entry.getKey());
    }
    TIntObjectHashMap<RouteDataBorderLine> lines =
        new TIntObjectHashMap<RoutingContext.RouteDataBorderLine>();
    for (RouteDataBorderLinePoint p : req.getSearchResults()) {
      if (config.router.acceptLine(p) && p.x > leftBorderBoundary && p.x < rightBorderBoundary) {
        if (!lines.containsKey(p.y)) {
          RouteDataBorderLine line = new RouteDataBorderLine(p.y);
          lines.put(p.y, line);
          RouteDataBorderLinePoint lft = new RouteDataBorderLinePoint(p.region);
          lft.y = p.y;
          lft.id = Long.MIN_VALUE;
          lft.x = leftBorderBoundary;
          line.borderPoints.add(lft);
          RouteDataBorderLinePoint rht = new RouteDataBorderLinePoint(p.region);
          rht.y = p.y;
          rht.id = Long.MIN_VALUE;
          rht.x = rightBorderBoundary;
          line.borderPoints.add(rht);
        }
        lines.get(p.y).borderPoints.add(p);
      }
    }
    borderLines = lines.values(new RouteDataBorderLine[lines.size()]);
    Arrays.sort(borderLines);
    borderLineCoordinates = new int[borderLines.length];
    for (int i = 0; i < borderLineCoordinates.length; i++) {
      borderLineCoordinates[i] = borderLines[i].borderLine;
      // FIXME borders approach
      // not less then 14th zoom
      if (i > 0 && borderLineCoordinates[i - 1] >> 17 == borderLineCoordinates[i] >> 17) {
        throw new IllegalStateException();
      }
      System.out.println(
          "Line "
              + (borderLineCoordinates[i] >> 17)
              + " points "
              + borderLines[i].borderPoints.size() /* + " " +borderLines[i].borderPoints*/);
    }

    updateDistanceForBorderPoints(startX, startY, true);
    updateDistanceForBorderPoints(targetX, targetY, false);
  }
예제 #3
0
 public boolean containsWord(int word, Mention mention) {
   if (!indexWithoutStopWords.containsKey(word)) return false;
   TIntLinkedList positions = indexIncludingStopWords.get(word);
   int mentionStart = mention.getStartToken();
   int mentionEnd = mention.getEndToken();
   for (TIntIterator itr = positions.iterator(); itr.hasNext(); ) {
     int position = itr.next();
     if (position < mentionStart || position > mentionEnd) return true;
   }
   return false;
 }
예제 #4
0
 /**
  * Get the value of variable s in this solution
  *
  * @param s SetVar
  * @return the value of variable s in this solution, or null if the variable is not instantiated
  *     in the solution
  */
 public int[] getSetVal(SetVar s) {
   if (empty) {
     throw new UnsupportedOperationException("Empty solution. No solution found");
   }
   if (setmap.containsKey(s.getId())) {
     return setmap.get(s.getId());
   } else if ((s.getTypeAndKind() & Variable.TYPE) == Variable.CSTE) {
     return s.getValues();
   } else {
     return null;
   }
 }
예제 #5
0
 /**
  * Get the bounds of r in this solution
  *
  * @param r RealVar
  * @return the bounds of r in this solution, or null if the variable is not instantiated in the
  *     solution
  */
 public double[] getRealBounds(RealVar r) {
   if (empty) {
     throw new UnsupportedOperationException("Empty solution. No solution found");
   }
   if (realmap.containsKey(r.getId())) {
     return realmap.get(r.getId());
   } else {
     if ((r.getTypeAndKind() & Variable.TYPE) == Variable.CSTE) {
       return new double[] {r.getLB(), r.getUB()};
     } else {
       return null;
     }
   }
 }
  @Override
  public String onTalk(L2Npc npc, QuestState st) {
    L2PcInstance player = st.getPlayer();

    L2Clan clan = player.getClan();

    switch (st.getState()) {
      case CREATED:
        return clan == null || !player.isClanLeader() || clan.getLevel() < 6
            ? "31331-0a.htm"
            : "31331-0b.htm";
      case STARTED:
        if (clan == null || !player.isClanLeader()) {
          st.exitQuest(QuestType.REPEATABLE);
          return "31331-6.html";
        }

        int raid = st.getInt("raid");

        if (REWARD_POINTS.containsKey(raid)) {
          if (st.hasQuestItems(REWARD_POINTS.get(raid)[1])) {
            st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1);
            st.takeItems(REWARD_POINTS.get(raid)[1], -1);
            clan.addReputationScore(REWARD_POINTS.get(raid)[2], true);
            player.sendPacket(
                SystemMessage.getSystemMessage(
                        SystemMessageId.CLAN_QUEST_COMPLETED_AND_S1_POINTS_GAINED)
                    .addNumber(REWARD_POINTS.get(raid)[2]));
            clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
            return "31331-" + raid + "b.html";
          } else {
            return "31331-" + raid + "a.html";
          }
        } else {
          return "31331-0.html";
        }
    }
    return null;
  }
 @Override
 public boolean isExistingId(int id) {
   return tablesById.containsKey(id);
 }
 /**
  * Method isCursed.
  *
  * @param itemId int
  * @return boolean
  */
 public boolean isCursed(int itemId) {
   return _cursedWeaponsMap.containsKey(itemId);
 }
예제 #9
0
 private void put(TIntObjectHashMap<TIntArrayList> map, int k, int v) {
   if (!map.containsKey(k)) {
     map.put(k, new TIntArrayList());
   }
   map.get(k).add(v);
 }