Пример #1
0
  @Override
  public HandlerResult onItemUseEvent(final QuestCookie env, Item item) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();

    if (id != 182204304 || qs == null) return HandlerResult.UNKNOWN;

    if (qs.getQuestVarById(0) != 15 || id != 182204304) return HandlerResult.FAILED;

    if (!ZoneService.getInstance().isInsideZone(player, ZoneName.BERITRAS_WEAPON_220040000))
      return HandlerResult.FAILED;

    PacketSendUtility.broadcastPacket(
        player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true);
    ThreadPoolManager.getInstance()
        .schedule(
            new Runnable() {
              @Override
              public void run() {
                PacketSendUtility.broadcastPacket(
                    player,
                    new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0),
                    true);
                player.getInventory().removeFromBagByItemId(182204304, 1);
                qs.setStatus(QuestStatus.REWARD);
                updateQuestStatus(env);
              }
            },
            3000);
    return HandlerResult.SUCCESS;
  }
  @Override
  public boolean onItemUseEvent(final QuestCookie env, Item item) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();

    if (id != 182203019) return false;
    if (!ZoneService.getInstance().isInsideZone(player, ZoneName.Q2016)) return false;
    if (qs == null) return false;
    PacketSendUtility.broadcastPacket(
        player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true);
    ThreadPoolManager.getInstance()
        .schedule(
            new Runnable() {
              @Override
              public void run() {
                PacketSendUtility.broadcastPacket(
                    player,
                    new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0),
                    true);
                player.getInventory().removeFromBagByObjectId(itemObjId, 1);
                qs.setStatus(QuestStatus.REWARD);
                updateQuestStatus(env);
              }
            },
            3000);
    return true;
  }
  @Override
  public boolean onItemUseEvent(QuestCookie env, Item item) {
    final Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();

    switch (id) {
      case 182207006:
        if (qs == null || qs.getStatus() != QuestStatus.START) return false;
        PacketSendUtility.broadcastPacket(
            player,
            new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 1000, 0, 0),
            true);
        ThreadPoolManager.getInstance()
            .schedule(
                new Runnable() {
                  @Override
                  public void run() {
                    PacketSendUtility.broadcastPacket(
                        player,
                        new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0),
                        true);
                  }
                },
                1000);
        return true;
    }
    return false;
  }
Пример #4
0
  @Override
  public HandlerResult onItemUseEvent(final QuestEnv env, Item item) {
    final Player player = env.getPlayer();
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();

    if (id != 182207044) return HandlerResult.UNKNOWN;
    PacketSendUtility.broadcastPacket(
        player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true);
    ThreadPoolManager.getInstance()
        .schedule(
            new Runnable() {

              @Override
              public void run() {
                PacketSendUtility.broadcastPacket(
                    player,
                    new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0),
                    true);
                sendQuestDialog(env, 4);
              }
            },
            3000);
    return HandlerResult.SUCCESS;
  }
Пример #5
0
  public static boolean questTimerStart(QuestCookie env, int timeInSeconds) {
    final Player player = env.getPlayer();
    final int id = env.getQuestId();

    if (!player.getQuestTimerOn()) {
      // Schedule Action When Timer Finishes
      Future<?> task =
          ThreadPoolManager.getInstance()
              .schedule(
                  new Runnable() {

                    @Override
                    public void run() {
                      player.setQuestTimerOn(false);
                      QuestEngine.getInstance()
                          .onQuestTimerEnd(new QuestCookie(null, player, 0, 0));
                      if (QuestEngine.getInstance().deleteQuest(player, id))
                        PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(id));
                      player.getController().updateNearbyQuests();
                    }
                  },
                  timeInSeconds * 1000);
      player.setQuestTimerOn(true);
      player.getController().addTask(TaskId.QUEST_TIMER, task);
      PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(4, id, timeInSeconds));
      return true;
    }
    return false;
  }
 @Override
 public boolean onDialogEvent(final QuestCookie env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   final QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null) {
     if (targetId == 205130) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
       else return defaultQuestStartDialog(env);
     }
   } else if (qs.getStatus() == QuestStatus.START) {
     switch (targetId) {
       case 730107:
         {
           if (qs.getQuestVarById(0) == 0 && env.getDialogId() == -1) {
             final int targetObjectId = env.getVisibleObject().getObjectId();
             PacketSendUtility.sendPacket(
                 player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
             PacketSendUtility.broadcastPacket(
                 player,
                 new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId),
                 true);
             ThreadPoolManager.getInstance()
                 .schedule(
                     new Runnable() {
                       @Override
                       public void run() {
                         if (!player.isTargeting(targetObjectId)) return;
                         PacketSendUtility.sendPacket(
                             player,
                             new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                         PacketSendUtility.broadcastPacket(
                             player,
                             new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                             true);
                         qs.setQuestVarById(0, 1);
                         updateQuestStatus(env);
                       }
                     },
                     3000);
           }
         }
       case 205130:
         {
           if (qs.getQuestVarById(0) == 1) {
             if (env.getDialogId() == 26) return sendQuestDialog(env, 2375);
             else if (env.getDialogId() == 1009) {
               qs.setStatus(QuestStatus.REWARD);
               updateQuestStatus(env);
               return defaultQuestEndDialog(env);
             } else return defaultQuestEndDialog(env);
           }
         }
     }
   } else if (qs.getStatus() == QuestStatus.REWARD) {
     if (targetId == 205130) return defaultQuestEndDialog(env);
   }
   return false;
 }
  @Override
  public HandlerResult onItemUseEvent(final QuestCookie env, Item item) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();

    if (id != 182201783 || qs == null) return HandlerResult.UNKNOWN;

    int var = qs.getQuestVars().getQuestVars();
    if (var != 0 || qs.getStatus() != QuestStatus.START) return HandlerResult.FAILED;

    if (MathUtil.getDistance(
            1677,
            2520,
            100,
            player.getPosition().getX(),
            player.getPosition().getY(),
            player.getPosition().getZ())
        > 5) return HandlerResult.FAILED;

    int itemId1 = 110100150;
    int itemId2 = 113100144;
    boolean CheckitemId1 = false;
    boolean CheckitemId2 = false;

    List<Item> items1 = player.getEquipment().getEquippedItemsByItemId(itemId1);
    for (@SuppressWarnings("unused") Item ListeCheckitemId1 : items1) {
      CheckitemId1 = true;
    }

    List<Item> items2 = player.getEquipment().getEquippedItemsByItemId(itemId2);
    for (@SuppressWarnings("unused") Item ListeCheckitemId2 : items2) {
      CheckitemId2 = true;
    }

    if (!CheckitemId1 && CheckitemId2
        || CheckitemId1 && !CheckitemId2
        || !CheckitemId1 && !CheckitemId2) return HandlerResult.FAILED;

    PacketSendUtility.broadcastPacket(
        player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true);
    ThreadPoolManager.getInstance()
        .schedule(
            new Runnable() {
              @Override
              public void run() {
                PacketSendUtility.broadcastPacket(
                    player,
                    new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0),
                    true);
                player.getInventory().removeFromBagByObjectId(itemObjId, 1);
                qs.setStatus(QuestStatus.REWARD);
                updateQuestStatus(env);
              }
            },
            3000);
    return HandlerResult.SUCCESS;
  }
Пример #8
0
  @Override
  public boolean processData(ByteBuffer data) {
    CsClientPacket pck = csPacketHandler.handle(data, this);

    /** Execute packet only if packet exist (!= null) and read was ok. */
    if (pck != null && pck.read()) ThreadPoolManager.getInstance().executeLsPacket(pck);

    return true;
  }
Пример #9
0
  public static void startRiftPool() {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());

    long TIME_BEFORE_SPAWN_RIFT = 0;

    if (calendar.get(Calendar.HOUR_OF_DAY) % 2 == 0)
      TIME_BEFORE_SPAWN_RIFT += 1 * 60 * 60 * 1000; // 1 heure

    TIME_BEFORE_SPAWN_RIFT +=
        ((60 - calendar.get(Calendar.MINUTE)) * 60 - calendar.get(Calendar.SECOND)) * 1000;

    Timestamp newTime = new Timestamp(System.currentTimeMillis() + TIME_BEFORE_SPAWN_RIFT);
    log.info(
        "Next rifts will spawn in "
            + TIME_BEFORE_SPAWN_RIFT / 1000
            + " seconds, at "
            + newTime.toString());

    ThreadPoolManager.getInstance()
        .scheduleAtFixedRate(
            new Runnable() {
              @Override
              public void run() {
                Util.printSection("Rift Manager");
                ArrayList<Integer> rifts = new ArrayList<Integer>();
                int nbRift, rndRift;

                for (int i = 0; i < 4; i++) {
                  // Generate number of rift for each town
                  nbRift = getNbRift();

                  log.info("Spawning " + nbRift + " rifts for the map : " + getMapName(i));

                  for (int j = 0; j < nbRift; j++) {
                    rndRift = Rnd.get(i * 7, (i + 1) * 7 - 1);

                    // try to avoid duplicate
                    while (rifts.contains(rndRift)) rndRift = Rnd.get(i * 7, (i + 1) * 7 - 1);

                    // Save rift spawned
                    rifts.add(rndRift);

                    // Spawnrift
                    spawnRift(RiftEnum.values()[rndRift]);
                  }

                  rifts.clear();
                }
              }
            },
            TIME_BEFORE_SPAWN_RIFT,
            RIFT_RESPAWN_DELAY);
  }
Пример #10
0
  public BrokerService() {
    initBrokerService();

    saveManager = new BrokerPeriodicTaskManager(DELAY_BROKER_SAVE);
    ThreadPoolManager.getInstance()
        .scheduleAtFixedRate(
            new Runnable() {

              @Override
              public void run() {
                checkExpiredItems();
              }
            },
            DELAY_BROKER_CHECK,
            DELAY_BROKER_CHECK);
  }
Пример #11
0
 /** @param npc */
 private static void scheduleDespawn(final Npc npc) {
   ThreadPoolManager.getInstance()
       .schedule(
           new Runnable() {
             @Override
             public void run() {
               if (npc != null && !npc.isSpawned()) {
                 PacketSendUtility.broadcastPacket(npc, new SM_DELETE(npc, 15));
                 npc.getController().onDespawn(true);
                 World.getInstance().despawn(npc);
               }
               rifts.remove(npc);
             }
           },
           RIFT_LIFETIME);
 }
  @Override
  public boolean onKillEvent(QuestCookie env) {
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs.getStatus() != QuestStatus.START) return false;

    final int instanceId = player.getInstanceId();
    int var = qs.getQuestVarById(0);
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    final Npc npc = (Npc) env.getVisibleObject();

    switch (targetId) {
      case 216739:
      case 216740:
        if (var == 0) {
          ThreadPoolManager.getInstance()
              .schedule(
                  new Runnable() {
                    @Override
                    public void run() {
                      QuestService.addNewSpawn(
                          300170000,
                          instanceId,
                          216239,
                          (float) npc.getX(),
                          (float) npc.getY(),
                          (float) npc.getZ(),
                          (byte) 0,
                          true);
                    }
                  },
                  2000);

          return true;
        }
        break;
      case 216239:
        if (var == 0) {
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(env);
          return true;
        }
    }
    return false;
  }
  @Override
  public boolean onItemUseEvent(final QuestCookie env, Item item) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();

    if (id == 186000107) {
      if (!ZoneService.getInstance().isInsideZone(player, ZoneName.DEBILKARIM_FORGE_300160000))
        return false;
      if (qs == null) return true;
      if (qs.getQuestVarById(0) != 0) return false;
      if (player.getInventory().getItemCountByItemId(101700759) == 0
          || player.getInventory().getItemCountByItemId(186000099) == 0
          || player.getInventory().getItemCountByItemId(186000106) < 20
          || player.getInventory().getItemCountByItemId(186000107) == 0) return false;
      PacketSendUtility.broadcastPacket(
          player,
          new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0),
          true);
      ThreadPoolManager.getInstance()
          .schedule(
              new Runnable() {
                @Override
                public void run() {
                  ItemService.addItems(
                      player, Collections.singletonList(new QuestItems(182209739, 1)));
                  PacketSendUtility.broadcastPacket(
                      player,
                      new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0),
                      true);
                  player.getInventory().removeFromBagByItemId(186000099, 1);
                  player.getInventory().removeFromBagByItemId(186000106, 20);
                  player.getInventory().removeFromBagByItemId(186000107, 1);
                  qs.setStatus(QuestStatus.REWARD);
                  updateQuestStatus(env);
                }
              },
              3000);
      return true;
    }
    return true;
  }
  private void destroy(final int var, final QuestCookie env) {
    final int targetObjectId = env.getVisibleObject().getObjectId();

    final Player player = env.getPlayer();
    PacketSendUtility.sendPacket(
        player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
    PacketSendUtility.broadcastPacket(
        player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
    ThreadPoolManager.getInstance()
        .schedule(
            new Runnable() {
              @Override
              public void run() {
                if (player.getTarget().getObjectId() != targetObjectId) return;
                PacketSendUtility.sendPacket(
                    player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                PacketSendUtility.broadcastPacket(
                    player,
                    new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                    true);
                PacketSendUtility.broadcastPacket(
                    player.getTarget(),
                    new SM_EMOTION((Creature) player.getTarget(), EmotionType.EMOTE, 128, 0));
                QuestState qs = player.getQuestStateList().getQuestState(questId);
                switch (var) {
                  case 6:
                  case 7:
                    qs.setQuestVar(var);
                    break;
                  case -1:
                    PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 56));
                    qs.setQuestVar(8);
                    break;
                }
                updateQuestStatus(env);
              }
            },
            3000);
  }
Пример #15
0
  /** Add portation task to player with talkDelay delay to location specified by portalTemplate */
  public static void port(
      final PortalTemplate portalTemplate,
      final Player player,
      final int npcObjectId,
      int talkDelay) {
    if (!CustomConfig.ENABLE_INSTANCES) return;

    talkDelay *= 1000;
    if (talkDelay > 0) {

      PacketSendUtility.sendPacket(
          player, new SM_USE_OBJECT(player.getObjectId(), npcObjectId, talkDelay, 1));

      PacketSendUtility.broadcastPacket(
          player, new SM_EMOTION(player, EmotionType.START_QUESTLOOT, 0, npcObjectId), true);
    }

    player
        .getController()
        .addTask(
            TaskId.PORTAL,
            ThreadPoolManager.getInstance()
                .schedule(
                    new Runnable() {

                      @Override
                      public void run() {
                        PacketSendUtility.sendPacket(
                            player, new SM_USE_OBJECT(player.getObjectId(), npcObjectId, 0, 0));
                        PacketSendUtility.broadcastPacket(
                            player,
                            new SM_EMOTION(player, EmotionType.END_QUESTLOOT, 0, npcObjectId),
                            true);
                        analyzePortation(player, portalTemplate);
                      }
                    },
                    talkDelay));
  }
 @Override
 public boolean onDialogEvent(final QuestCookie env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   final QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null || qs.getStatus() == QuestStatus.NONE) {
     if (targetId == 203997) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
       else if (env.getDialogId() == 1013) {
         if (ItemService.addItems(player, Collections.singletonList(new QuestItems(182201305, 1))))
           return sendQuestDialog(env, 4);
         else return true;
       } else return defaultQuestStartDialog(env);
     }
   } else if (qs.getStatus() == QuestStatus.START) {
     switch (targetId) {
       case 700164:
         {
           if (qs.getQuestVarById(0) == 0 && env.getDialogId() == -1) {
             final int targetObjectId = env.getVisibleObject().getObjectId();
             PacketSendUtility.sendPacket(
                 player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
             PacketSendUtility.broadcastPacket(
                 player,
                 new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId),
                 true);
             ThreadPoolManager.getInstance()
                 .schedule(
                     new Runnable() {
                       @Override
                       public void run() {
                         if (!player.isTargeting(targetObjectId)) return;
                         PacketSendUtility.sendPacket(
                             player,
                             new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                         PacketSendUtility.broadcastPacket(
                             player,
                             new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                             true);
                         player.getInventory().removeFromBagByItemId(182201305, 1);
                         qs.setStatus(QuestStatus.REWARD);
                         qs.setQuestVarById(0, 1);
                         updateQuestStatus(env);
                       }
                     },
                     3000);
           }
         }
       case 203997:
         {
           if (qs.getQuestVarById(0) == 1) {
             if (env.getDialogId() == 26) return sendQuestDialog(env, 2375);
             else if (env.getDialogId() == 33) {
               player.getInventory().removeFromBagByItemId(182201305, 1);
               qs.setStatus(QuestStatus.REWARD);
               updateQuestStatus(env);
               return sendQuestDialog(env, 5);
             } else return defaultQuestEndDialog(env);
           }
         }
     }
   } else if (qs.getStatus() == QuestStatus.REWARD) {
     if (targetId == 203997) return defaultQuestEndDialog(env);
   }
   return false;
 }
Пример #17
0
  @Override
  public void act(final Player player, final Item parentItem, Item targetItem) {

    final Storage storage = player.getInventory();
    ItemTemplate stoneTemplate = ItemService.getItemTemplate(parentItem.getItemId());

    if (stoneTemplate.getAid() != 0) {
      int aid = stoneTemplate.getAid();
      final int item = DataManager.ASSEMBLY_DATA.findaid(aid);
      final AssemblyTemplate assembly = DataManager.ASSEMBLY_DATA.getAssemblyTemplate(item);
      part = assembly.getPart();
      for (int i = assembly.getParts_count(); i-- > 0; ) {
        long count = storage.getItemCountByItemId(part.get(i).getId());
        if (storage.getFreeSlots() < count - 1) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_FULL_INVENTORY);
          break;
        }
        if (count == 0) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.ASSEMBLY_ITEM_NOT_ENOUGH);
          break;
        } else {

          PacketSendUtility.sendPacket(
              player,
              new SM_ITEM_USAGE_ANIMATION(
                  player.getObjectId(),
                  parentItem.getObjectId(),
                  parentItem.getItemTemplate().getTemplateId(),
                  5000,
                  0,
                  0));
          player.getController().cancelTask(TaskId.ITEM_USE);
          player
              .getController()
              .addTask(
                  TaskId.ITEM_USE,
                  ThreadPoolManager.getInstance()
                      .schedule(
                          new Runnable() {

                            @Override
                            public void run() {
                              PacketSendUtility.sendPacket(
                                  player,
                                  new SM_ITEM_USAGE_ANIMATION(
                                      player.getObjectId(),
                                      parentItem.getObjectId(),
                                      parentItem.getItemTemplate().getTemplateId(),
                                      0,
                                      1,
                                      0));
                              for (int t = assembly.getParts_count(); t-- > 0; ) {
                                player.getInventory().decreaseByItemId(part.get(t).getId(), 1);
                              }
                              ItemService.addItem(player, item, 1);
                            }
                          },
                          5000));

          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.ASSEMBLY_ITEM_SUCCEEDED);
          break;
        }
      }
    }
  }
Пример #18
0
 @Override
 public void executeRunnable(Runnable r) {
   ThreadPoolManager.getInstance().execute(r);
 }
  @Override
  public boolean onDialogEvent(final QuestCookie env) {
    // Instanceof
    final Player player = env.getPlayer();
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);

    // ------------------------------------------------------------
    // NPC Quest :
    // 0 - Vergelmir start
    if (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (targetId == 203711) // Miriya
      {
        // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
        if (env.getDialogId() == 25)
          // Send HTML_PAGE_SELECT_NONE to eddit-HtmlPages.xml
          return sendQuestDialog(env, 4762);
        else return defaultQuestStartDialog(env);
      }
    }

    if (qs == null) return false;

    int var = qs.getQuestVarById(0);

    if (qs.getStatus() == QuestStatus.START) {

      switch (targetId) {

          // Xenophon
        case 203833:
          if (var == 0) {
            switch (env.getDialogId()) {
                // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
              case 25:
                // Send select1 to eddit-HtmlPages.xml
                return sendQuestDialog(env, 1011);
                // Get HACTION_SETPRO1 in the eddit-HyperLinks.xml
              case 10000:
                qs.setQuestVar(1);
                updateQuestStatus(env);
                PacketSendUtility.sendPacket(
                    player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
                return true;
            }
          }
          // 2 / 4- Talk with Koruchinerk
        case 798321:
          if (var == 1) {
            switch (env.getDialogId()) {
                // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
              case 25:
                // Send select1 to eddit-HtmlPages.xml
                return sendQuestDialog(env, 1352);
                // Get HACTION_SETPRO1 in the eddit-HyperLinks.xml
              case 10001:
                qs.setQuestVar(2);
                updateQuestStatus(env);
                PacketSendUtility.sendPacket(
                    player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
                return true;
            }
          } else if (var == 2) {
            switch (env.getDialogId()) {
                // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
              case 25:
                // Send select1 to eddit-HtmlPages.xml
                return sendQuestDialog(env, 1693);
                // Get HACTION_SETPRO1 in the eddit-HyperLinks.xml
              case 33:
                if (player.getInventory().getItemCountByItemId(182206075) < 1) {
                  // player doesn't own required item
                  return sendQuestDialog(env, 10001);
                }
                player.getInventory().removeFromBagByItemId(182206075, 1);
                qs.setStatus(QuestStatus.REWARD);
                updateQuestStatus(env);
                return sendQuestDialog(env, 10000);
            }
          }
          return false;
        case 700562:
          if (var == 2) {
            ThreadPoolManager.getInstance()
                .schedule(
                    new Runnable() {
                      @Override
                      public void run() {
                        updateQuestStatus(env);
                      }
                    },
                    3000);
            return true;
          }
          break;
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 203711) // Miriya
      {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 10002);
        else if (env.getDialogId() == 1009) return sendQuestDialog(env, 5);
        else return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
Пример #20
0
  @Override
  public boolean onDialogEvent(final QuestCookie env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 203903) {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 2375);
        else if (env.getDialogId() == 1009) return sendQuestDialog(env, 5);
        else return defaultQuestEndDialog(env);
      }
      return false;
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 203903) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 0) return sendQuestDialog(env, 1011);
        case 10000:
          if (var == 0) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 204032) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 1) return sendQuestDialog(env, 1352);
          else if (var == 3) return sendQuestDialog(env, 1693);
          else if (var == 4) return sendQuestDialog(env, 2034);
        case 34:
          if (QuestService.collectItemCheck(env, true)) {
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 2035);
          } else return sendQuestDialog(env, 2120);
        case 1353:
          PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 179));
          break;
        case 10001:
          if (var == 1) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10002:
          if (var == 3) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 700149 && var == 2) {
      if (env.getDialogId() == -1) {
        final int targetObjectId = env.getVisibleObject().getObjectId();
        PacketSendUtility.sendPacket(
            player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
        PacketSendUtility.broadcastPacket(
            player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
        ThreadPoolManager.getInstance()
            .schedule(
                new Runnable() {
                  @Override
                  public void run() {
                    if (player.getQuestStateList().getQuestState(questId).getQuestVarById(0) == 2) {
                      PacketSendUtility.sendPacket(
                          player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                      PacketSendUtility.broadcastPacket(
                          player,
                          new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                          true);
                      qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
                      updateQuestStatus(env);
                    }
                  }
                },
                3000);
      }
    }
    return false;
  }
  @Override
  public boolean onItemUseEvent(final QuestCookie env, final Item item) {
    final Player player = env.getPlayer();
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    final int var = qs.getQuestVarById(0);

    if (id != 182206627 && id != 182206628 && id != 164000137 && id != 164000138 && id != 164000139)
      return false;

    if (player.getWorldId() != 300190000) return false;

    if (qs != null && qs.getStatus() == QuestStatus.COMPLETE) {
      if (id == 182206628 && !hasItem(player, 182206628)) {
        if (!ItemService.addItems(player, Collections.singletonList(new QuestItems(182206628, 1))))
          return true;
      }
      if (id == 182206627 && !hasItem(player, 182206627)) {
        if (!ItemService.addItems(player, Collections.singletonList(new QuestItems(182207604, 1))))
          return true;
      }
      if (id == 164000137 && !hasItem(player, 164000137)) {
        if (!ItemService.addItems(player, Collections.singletonList(new QuestItems(164000137, 1))))
          return true;
      }
      if (id == 164000138 && !hasItem(player, 164000138)) {
        if (!ItemService.addItems(player, Collections.singletonList(new QuestItems(164000138, 1))))
          return true;
      }
      if (id == 164000139 && !hasItem(player, 164000139)) {
        if (!ItemService.addItems(player, Collections.singletonList(new QuestItems(164000139, 1))))
          return true;
      }
      useSkill(player, item);
    } else if (var == 5 || var == 6 || var == 7) {
      if (id == 182206627) {
        PacketSendUtility.broadcastPacket(
            player,
            new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0),
            true);
        ThreadPoolManager.getInstance()
            .schedule(
                new Runnable() {
                  @Override
                  public void run() {
                    int var = qs.getQuestVarById(0);
                    PacketSendUtility.broadcastPacket(
                        player,
                        new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0),
                        true);
                    if (var == 5) {
                      qs.setQuestVarById(0, var + 1);
                      updateQuestStatus(env);
                    }
                    useSkill(player, item);
                  }
                },
                3000);
      } else if (id == 182206628 && var > 5) {
        ThreadPoolManager.getInstance()
            .schedule(
                new Runnable() {
                  @Override
                  public void run() {
                    int var2 = qs.getQuestVarById(2);
                    if (var < 7 && var2 < 19) {
                      qs.setQuestVarById(2, var2 + 1);
                      if (!hasItem(player, 182206628)) ItemService.addItem(player, 182206628, 1);

                      updateQuestStatus(env);
                    } else if (var == 6 && var2 > 0) {
                      qs.setQuestVarById(2, 0); // Needed to continue
                      qs.setQuestVarById(0, var + 1);
                      updateQuestStatus(env);
                    }
                    useSkill(player, item);
                  }
                },
                100);
      }
    }
    return false; // don't remove from inventory
  }
  @Override
  public boolean onDialogEvent(final QuestCookie env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 204057) {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 10002);
        else return defaultQuestEndDialog(env);
      }
      return false;
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 205150) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 0) return sendQuestDialog(env, 1011);
        case 10000:
          if (var == 0) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 205192) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 1) return sendQuestDialog(env, 1352);
          else if (var == 2) return sendQuestDialog(env, 1693);
          else if (var == 3) return sendQuestDialog(env, 2034);
        case 2035:
          PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 399));
          break;
        case 10001:
          if (var == 1) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10002:
          if (var == 2) {
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10003:
          if (var == 3) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            ItemService.addItems(player, Collections.singletonList(new QuestItems(182209014, 1)));
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 34:
          if (var == 2) {
            if (QuestService.collectItemCheck(env, true)) {
              qs.setQuestVarById(0, var + 1);
              updateQuestStatus(env);
              return sendQuestDialog(env, 10000);
            } else return sendQuestDialog(env, 10001);
          }
      }
    } else if (targetId == 205155) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 5) return sendQuestDialog(env, 2716);
        case 10005:
          if (var == 5) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 730151) {
      switch (env.getDialogId()) {
        case -1:
          if (var == 4 || var == 5) {
            final int targetObjectId = env.getVisibleObject().getObjectId();
            PacketSendUtility.sendPacket(
                player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
            PacketSendUtility.broadcastPacket(
                player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
            ThreadPoolManager.getInstance()
                .schedule(
                    new Runnable() {
                      @Override
                      public void run() {
                        Npc npc = (Npc) player.getTarget();
                        if (npc == null || npc.getObjectId() != targetObjectId) return;
                        PacketSendUtility.sendPacket(
                            player,
                            new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                        PacketSendUtility.broadcastPacket(
                            player,
                            new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                            true);
                        if (player.getWorldId() == 220050000 && qs.getQuestVarById(0) == 4) {
                          WorldMapInstance newInstance =
                              InstanceService.getNextAvailableInstance(320130000);
                          InstanceService.registerPlayerWithInstance(newInstance, player);
                          TeleportService.teleportTo(
                              player, 320130000, newInstance.getInstanceId(), 338, 670, 169, 0);
                        } else if (player.getWorldId() == 320130000) {
                          TeleportService.teleportTo(player, 220050000, 1836, 887, 59, 30);
                        }
                      }
                    },
                    3000);
            return false;
          }
      }
    } else if (targetId == 730164) {
      switch (env.getDialogId()) {
        case -1:
          if (var == 6) {
            final int targetObjectId = env.getVisibleObject().getObjectId();
            PacketSendUtility.sendPacket(
                player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
            PacketSendUtility.broadcastPacket(
                player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
            ThreadPoolManager.getInstance()
                .schedule(
                    new Runnable() {
                      @Override
                      public void run() {
                        Npc npc = (Npc) player.getTarget();
                        if (npc == null || npc.getObjectId() != targetObjectId) return;
                        PacketSendUtility.sendPacket(
                            player,
                            new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                        PacketSendUtility.broadcastPacket(
                            player,
                            new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                            true);
                        PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 401));
                        qs.setStatus(QuestStatus.REWARD);
                        updateQuestStatus(env);
                      }
                    },
                    3000);
            return false;
          }
      }
    }
    return false;
  }