@Override
  public boolean onDialogEvent(QuestCookie env) {
    Player player = env.getPlayer();

    if (defaultQuestNoneDialog(env, 204050, 4762)) return true;

    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    if (qs.getStatus() == QuestStatus.START) {
      if (env.getTargetId() == 204050) {
        switch (env.getDialogId()) {
          case 26:
            if (var == 0) return sendQuestDialog(env, 1011);
            else if (var == 1) return sendQuestDialog(env, 1352);
          case 10000:
            return defaultCloseDialog(env, 0, 1);
          case 10001:
            return defaultCloseDialog(env, 1, 0);
          case 34:
            return defaultQuestItemCheck(env, 1, 0, true, 5, 10001);
        }
      }
    }
    return defaultQuestRewardDialog(env, 204050, 2375);
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    if (!super.defaultQuestOnDialogInitStart(env)) return false;

    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    int var = qs.getQuestVarById(0);

    if (qs.getStatus() == QuestStatus.START) {
      switch (env.getTargetId()) {
        case 203540:
          switch (env.getDialogId()) {
            case 26:
              if (var == 0) return sendQuestDialog(env, 1011);
              else if (var == 1) return sendQuestDialog(env, 1352);
            case 10000:
              return defaultCloseDialog(env, 0, 1);
            case 34:
              return defaultQuestItemCheck(env, 1, 0, true, 1438, 1353);
          }
          break;
        case 700095:
          if (env.getDialogId() == -1 && player.getInventory().getItemCountByItemId(182203008) < 7)
            return defaultQuestUseNpc(
                env, 1, 2, EmotionType.NEUTRALMODE2, EmotionType.START_LOOT, true);
          break;
      }
    }
    return defaultQuestRewardDialog(env, 203516, 1693);
  }
Example #3
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(QuestCookie env) {
    Player player = env.getPlayer();
    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.START) {
      if (targetId == 203178) {
        switch (env.getDialogId()) {
          case 26:
            if (var == 0) return sendQuestDialog(env, 1011);
          case 10000:
          case 10001:
            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 (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 203178) return defaultQuestEndDialog(env);
    }
    return false;
  }
 @Override
 public void QuestUseNpcInsideFunction(QuestCookie env) {
   Player player = env.getPlayer();
   if (env.getTargetId() == 700368)
     TeleportService.teleportTo(player, 320090000, 1, 276, 293, 163, (byte) 90, 500);
   else if (env.getTargetId() == 700369)
     TeleportService.teleportTo(player, 120010000, 1, 982, 1556, 210, (byte) 90, 500);
 }
Example #6
0
  public static boolean questTimerEnd(QuestCookie env) {
    final Player player = env.getPlayer();
    final int id = env.getQuestId();

    player.setQuestTimerOn(false);
    player.getController().cancelTask(TaskId.QUEST_TIMER);
    PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(4, id, 0));
    return true;
  }
Example #7
0
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    if (!super.defaultQuestOnDialogInitStart(env)) return false;

    QuestState qs = env.getPlayer().getQuestStateList().getQuestState(questId);
    int var = qs.getQuestVarById(0);
    if (qs.getStatus() == QuestStatus.START) {
      if (env.getTargetId() == 204052) {
        switch (env.getDialogId()) {
          case 26:
            if (var == 0) return sendQuestDialog(env, 1011);
          case 10255:
            return defaultCloseDialog(env, 0, 0, true, false);
        }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (env.getTargetId() == 798800) {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 10002);
        else if (env.getDialogId() == 18)
          QuestService.startQuest(
              new QuestCookie(env.getVisibleObject(), env.getPlayer(), 20001, env.getDialogId()),
              QuestStatus.LOCKED);
        return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
 @Override
 public boolean onActionItemEvent(QuestCookie env) {
   if (env.getPlayer().getTribe().equals("PC_DARK")) {
     int targetId = 0;
     if (env.getVisibleObject() instanceof Npc)
       targetId = ((Npc) env.getVisibleObject()).getNpcId();
     return (targetId == 730330);
   } else {
     return false;
   }
 }
 @Override
 public boolean onDialogEvent(QuestCookie env) {
   if (env.getPlayer().getTribe().equals("PC_DARK")) {
     final Player player = env.getPlayer();
     int targetId = 0;
     if (env.getVisibleObject() instanceof Npc)
       targetId = ((Npc) env.getVisibleObject()).getNpcId();
     QuestTemplate template = DataManager.QUEST_DATA.getQuestById(questId);
     QuestState qs = player.getQuestStateList().getQuestState(questId);
     if (targetId == 730330) {
       PlayerClass playerClass = player.getCommonData().getPlayerClass();
       if (playerClass == PlayerClass.RANGER
           || playerClass == PlayerClass.ASSASSIN
           || playerClass == PlayerClass.MAGE
           || playerClass == PlayerClass.PRIEST
           || playerClass == PlayerClass.GLADIATOR
           || playerClass == PlayerClass.WARRIOR
           || playerClass == PlayerClass.SCOUT) {
         if (qs == null
             || qs.getStatus() == QuestStatus.NONE
             || (qs.getStatus() == QuestStatus.COMPLETE
                 && (qs.getCompleteCount() <= template.getMaxRepeatCount()))) {
           if (env.getDialogId() == -1) return sendQuestDialog(env, 1011);
           else return defaultQuestStartDialog(env);
         } else if (qs != null
             && qs.getStatus() == QuestStatus.START
             && qs.getQuestVarById(0) == 0) {
           if (env.getDialogId() == -1) return sendQuestDialog(env, 2375);
           else if (env.getDialogId() == 34) {
             if (player.getInventory().getItemCountByItemId(185000102) >= 1) {
               player.getInventory().removeFromBagByItemId(185000102, 1);
               qs.setStatus(QuestStatus.REWARD);
               qs.setQuestVar(1);
               qs.setCompliteCount(0);
               updateQuestStatus(env);
               return sendQuestDialog(env, 5);
             } else return sendQuestDialog(env, 2716);
           }
         } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
           int var = qs.getQuestVarById(0);
           switch (env.getDialogId()) {
             case -1:
               if (var == 1) return sendQuestDialog(env, 5);
             case 17:
               QuestService.questFinish(env, qs.getQuestVars().getQuestVars() - 1);
               PacketSendUtility.sendPacket(
                   player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
               return true;
           }
         }
       }
       return false;
     }
     return false;
   } else {
     return false;
   }
 }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);

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

    if (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (targetId == 790019) {
        switch (env.getDialogId()) {
          case 26:
            {
              return sendQuestDialog(env, 4762);
            }
          case 1002:
            {
              if (player.getInventory().getItemCountByItemId(182201783) == 0) {
                if (!ItemService.addItems(
                    player, Collections.singletonList(new QuestItems(182201783, 1)))) {
                  return true;
                }
              }
            }
          default:
            return defaultQuestStartDialog(env);
        }
      }
    }

    if (qs == null) return false;

    if (qs.getStatus() == QuestStatus.REWARD) {
      switch (targetId) {
        case 790019:
          {
            switch (env.getDialogId()) {
              case 26:
                {
                  return sendQuestDialog(env, 10002);
                }
              case 1009:
                {
                  return sendQuestDialog(env, 5);
                }
              default:
                return defaultQuestEndDialog(env);
            }
          }
      }
    }
    return false;
  }
  @Override
  public boolean onLvlUpEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs != null) return false;

    QuestState qs2 = player.getQuestStateList().getQuestState(11008);
    if (qs2 == null || qs2.getStatus() != QuestStatus.COMPLETE) return false;
    env.setQuestId(questId);
    QuestService.startQuest(env, QuestStatus.START);
    return true;
  }
Example #12
0
  public boolean questComplite(QuestCookie env) {
    Player player = env.getPlayer();
    int id = env.getQuestId();
    QuestState qs = player.getQuestStateList().getQuestState(id);
    if (qs == null || qs.getStatus() != QuestStatus.START) return false;

    qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
    qs.setStatus(QuestStatus.REWARD);
    PacketSendUtility.sendPacket(
        player, new SM_QUEST_ACCEPTED(2, id, qs.getStatus(), qs.getQuestVars().getQuestVars()));
    player.getController().updateNearbyQuests();
    return true;
  }
 @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 boolean onDialogEvent(QuestCookie env) {
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    if ((qs == null || qs.getStatus() == QuestStatus.NONE) && !onLvlUpEvent(env)) return false;

    if (qs == null
        || qs.getStatus() == QuestStatus.NONE
        || qs.getStatus() == QuestStatus.COMPLETE && qs.getCompleteCount() < 10) {
      if (env.getTargetId() == 799778) {
        switch (env.getDialogId()) {
          case -1:
            return sendQuestDialog(env, 1011);
          case 1002:
            {
              PacketSendUtility.sendPacket(
                  player, new SM_QUEST_ACCEPTED(1, questId, QuestStatus.START, 0));
              if (qs == null) player.getQuestStateList().addQuest(questId, qs);
              else {
                qs.setStatus(QuestStatus.START);
                qs.setQuestVar(0);
              }
              player.getController().updateNearbyQuests();
              return sendQuestDialog(env, 1003);
            }
          default:
            return defaultQuestStartDialog(env);
        }
      }
      return false;
    }

    int var = qs.getQuestVarById(0);

    if (qs.getStatus() == QuestStatus.START) {
      if (env.getTargetId() == 799778) {
        switch (env.getDialogId()) {
          case -1:
          case 26:
            if (var == 0) return sendQuestDialog(env, 2375);
          case 34:
            return defaultQuestItemCheck(env, 0, 1, true, 5, 2716);
        }
      }
    }

    return defaultQuestRewardDialog(env, 799778, 0);
  }
 @Override
 public boolean onDialogEvent(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);
   QuestTemplate template = questsData.getQuestById(questId);
   if (targetId == 204639) {
     if (qs == null || qs.getStatus() == QuestStatus.NONE) {
       if (env.getDialogId() == 2) {
         PlayerClass playerClass = player.getCommonData().getPlayerClass();
         PlayerClass startPC = null;
         try {
           startPC = PlayerClass.getStartingClassFor(playerClass);
         } catch (IllegalArgumentException e) {
           startPC = playerClass; // already a start class
         }
         if (startPC == PlayerClass.MAGE || startPC == PlayerClass.PRIEST) {
           QuestService.startQuest(env, QuestStatus.START);
           return sendQuestDialog(env, 1011);
         } else {
           return sendQuestDialog(env, 3739);
         }
       }
     } else if (qs != null && qs.getStatus() == QuestStatus.START) {
       if (env.getDialogId() == 2) {
         return sendQuestDialog(env, 1011);
       } else if (env.getDialogId() == 1011) {
         if (player.getInventory().getItemCountByItemId(186000003) >= 16) {
           qs.setQuestVarById(0, 0);
           qs.setStatus(QuestStatus.REWARD);
           updateQuestStatus(env);
           return sendQuestDialog(env, 5);
         } else {
           return sendQuestDialog(env, 1009);
         }
       } else if (env.getDialogId() == 1352) {
         if (player.getInventory().getItemCountByItemId(186000003) >= 32) {
           qs.setQuestVarById(0, 1);
           qs.setStatus(QuestStatus.REWARD);
           updateQuestStatus(env);
           return sendQuestDialog(env, 6);
         } else {
           return sendQuestDialog(env, 1009);
         }
       }
     } else if (qs.getStatus() == QuestStatus.COMPLETE) {
       if (env.getDialogId() == 2) {
         if ((qs.getCompleteCount() <= template.getMaxRepeatCount())) {
           QuestService.startQuest(env, QuestStatus.START);
           return sendQuestDialog(env, 1011);
         } else return sendQuestDialog(env, 1008);
       }
     } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
       return defaultQuestEndDialog(env, qs.getQuestVarById(0));
     }
   }
   return false;
 }
  @Override
  public boolean onSkillUseEvent(QuestCookie env, int skillUsedId) {
    final Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    if (qs.getStatus() != QuestStatus.START) return false;

    if (skillUsedId == skillId) {
      if (var >= 0 && var < 9) {
        qs.setQuestVarById(0, var + 1);
        updateQuestStatus(env);
        return true;
      } else if (var == 9) {
        qs.setQuestVarById(0, var + 1);
        updateQuestStatus(env);
        qs.setStatus(QuestStatus.REWARD);
        updateQuestStatus(env);
        return true;
      }
    }
    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 != 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 onDialogEvent(QuestCookie env) {
   QuestState qs = env.getPlayer().getQuestStateList().getQuestState(questId);
   if (defaultQuestNoneDialog(env, 278016)) return true;
   if (qs == null) return false;
   return defaultQuestRewardDialog(env, 278016, 1352);
 }
  @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;
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (targetId == mainNpcId) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == 26) return sendQuestDialog(env, 4762);
        else return defaultQuestStartDialog(env);
      } else if (qs.getStatus() == QuestStatus.REWARD) {
        return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
 @Override
 public boolean onKillEvent(QuestCookie env) {
   Player player = env.getPlayer();
   if (player.getWorldId() == 600010000) {
     if (defaultQuestOnKillPlayerEvent(env, 1, 0, 4, false)
         || defaultQuestOnKillPlayerEvent(env, 1, 4, 5, true)) return true;
   }
   return false;
 }
  @Override
  public boolean onKillEvent(QuestCookie env) {
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null || qs.getStatus() != QuestStatus.START) return false;

    int var1 = qs.getQuestVarById(1);
    int var2 = qs.getQuestVarById(2);
    int var3 = qs.getQuestVarById(3);
    int targetId = env.getTargetId();

    if ((targetId == 256617 || targetId == 253720 || targetId == 254513)
        && qs.getQuestVarById(0) == 2) {
      switch (targetId) {
        case 256617:
          if (var1 >= 0 && var1 < 60) {
            ++var1;
            qs.setQuestVarById(1, var1 + 1);
            updateQuestStatus(env);
          }
          break;
        case 253720:
          if (var2 >= 0 && var2 < 120) {
            ++var2;
            qs.setQuestVarById(2, var2 + 3);
            updateQuestStatus(env);
          }
          break;
        case 254513:
          if (var3 >= 0 && var3 < 240) {
            ++var3;
            qs.setQuestVarById(3, var3 + 7);
            updateQuestStatus(env);
          }
          break;
      }
    }
    if (qs.getQuestVarById(0) == 2 && var1 == 60 && var2 == 120 && var3 == 240) {
      qs.setQuestVarById(1, 60);
      updateQuestStatus(env);
      return true;
    }
    return false;
  }
  @Override
  public boolean onKillEvent(QuestCookie env) {
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null || qs.getStatus() != QuestStatus.START) return false;

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

    switch (targetId) {
      case 216886:
        if (qs.getQuestVarById(0) == 2) {
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(env);
          return true;
        }
    }
    return false;
  }
 @Override
 public boolean onLvlUpEvent(QuestCookie env) {
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   boolean lvlCheck =
       QuestService.checkLevelRequirement(questId, player.getCommonData().getLevel());
   if (qs != null || !lvlCheck) return false;
   QuestService.startQuest(env, QuestStatus.START);
   return true;
 }
Example #25
0
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (targetId == 798953) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
        else if (env.getDialogId() == 1002) {
          if (ItemService.addItems(player, Collections.singletonList(new QuestItems(182209507, 1))))
            return defaultQuestStartDialog(env);
          else return true;
        } else return defaultQuestStartDialog(env);
      }
    }
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 798953) {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 2375);
        else if (env.getDialogId() == 1009) return sendQuestDialog(env, 5);
        else return defaultQuestEndDialog(env);
      }
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 203700) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 0) return sendQuestDialog(env, 1352);
        case 10000:
          if (var == 0) {
            player.getInventory().removeFromBagByItemId(182209507, 1);
            qs.setQuestVarById(0, var + 1);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
          return false;
      }
    }
    return false;
  }
 @Override
 public HandlerResult onBonusApplyEvent(QuestCookie env, int index, AbstractInventoryBonus bonus) {
   if (!(bonus instanceof CoinBonus)) return HandlerResult.UNKNOWN;
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
     if (index == 0 && qs.getQuestVarById(0) == 0 || index == 1 && qs.getQuestVarById(0) == 1)
       return HandlerResult.SUCCESS;
   }
   return HandlerResult.FAILED;
 }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    if (defaultQuestNoneDialog(env, 203893, 182206112, 1)) return true;

    if (qs == null) return false;

    int var = qs.getQuestVarById(0);

    if (qs.getStatus() == QuestStatus.START) {
      switch (env.getTargetId()) {
        case 798072:
          switch (env.getDialogId()) {
            case 26:
              if (var == 0) return sendQuestDialog(env, 1352);
            case 10000:
              return defaultCloseDialog(env, 0, 1, 182206113, 1, 0, 0);
          }
          break;
        case 279020:
          switch (env.getDialogId()) {
            case 26:
              if (var == 1) return sendQuestDialog(env, 1693);
            case 10001:
              return defaultCloseDialog(env, 1, 2, 182206114, 1, 0, 0);
          }
          break;
        case 798053:
          switch (env.getDialogId()) {
            case 26:
              if (var == 2) return sendQuestDialog(env, 2034);
            case 10002:
              return defaultCloseDialog(env, 2, 3, true, false, 182206115, 1, 0, 0);
          }
          break;
      }
    }
    return defaultQuestRewardDialog(env, 798386, 2375);
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    if (defaultQuestStartDaily(env)) return true;

    if (qs == null) return false;
    if (defaultQuestRewardDialog(env, 799865, 10002)
        || defaultQuestRewardDialog(env, 799866, 10002)) return true;
    else return false;
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    if (targetId == 0) {
      if (env.getDialogId() == 1002) {
        QuestService.startQuest(env, QuestStatus.START);
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
        return true;
      }
    } else if (targetId == 799939) // Emma
    {
      if (qs != null) {
        if (env.getDialogId() == 26 && qs.getStatus() == QuestStatus.START) {
          return sendQuestDialog(env, 2375);
        } else if (env.getDialogId() == 1009) {
          qs.setQuestVar(1);
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(env);
          return defaultQuestEndDialog(env);
        } else return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    if (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (targetId == 799336) // Tataka
      {
        if (env.getDialogId() == 26) {
          return sendQuestDialog(env, 1011);
        } else return defaultQuestStartDialog(env);
      }
    }

    if (qs == null) return false;

    if (qs == null || qs.getStatus() == QuestStatus.COMPLETE) {
      if (targetId == 799336) // Tataka
      {
        if (env.getDialogId() == 26) {
          return sendQuestDialog(env, 1011);
        } else return defaultQuestStartDialog(env);
      }
    }

    if (qs.getStatus() == QuestStatus.START) {
      switch (targetId) {
        case 799336: // Tataka
          switch (env.getDialogId()) {
            case 26:
              return sendQuestDialog(env, 2375);
            case 2034:
              return sendQuestDialog(env, 2034);
            case 34:
              // Siel's Supreme Mace (1)
              // Noxallon Ingot (1)
              if (QuestService.collectItemCheck(env, true)) {
                player.getInventory().removeFromBagByItemId(100100679, 1); // Siel's Supreme Mace
                player.getInventory().removeFromBagByItemId(186000095, 1); // Noxallon Ingot
                qs.setStatus(QuestStatus.REWARD);
                updateQuestStatus(env);
                return sendQuestDialog(env, 5);
              } else {
                // Send check_user_item_fail to eddit-HtmlPages.xml
                return sendQuestDialog(env, 2716);
              }
          }
          break;
          // No match
        default:
          return defaultQuestStartDialog(env);
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 799336) // Tataka
      return defaultQuestEndDialog(env);
    }
    return false;
  }