コード例 #1
0
  @Override
  public void act(final Player player, final Item parentItem, Item targetItem) {
    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()
        .addNewTask(
            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));

                        Storage inventory = player.getInventory();
                        inventory.removeFromBagByObjectId(parentItem.getObjectId(), 1);
                        int decomposedId = parentItem.getItemId() - 1;
                        switch (parentItem.getItemId()) {
                          case 152000112:
                          case 152000328:
                            decomposedId -= 2;
                            break;
                          case 152000213:
                          case 152000327:
                            decomposedId -= 3;
                            break;
                          case 152000326:
                            decomposedId -= 4;
                        }
                        ItemService.addItem(player, decomposedId, 3);
                      }
                    },
                    5000));
  }
コード例 #2
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);
    if (targetId == 799523) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
        else return defaultQuestStartDialog(env);
      }
    } else if (targetId == 798029) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
        if (env.getDialogId() == 26) return sendQuestDialog(env, 2375);
        else if (env.getDialogId() == 34) {
          if (QuestService.collectItemCheck(env, true)) {
            qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 5);
          } else return sendQuestDialog(env, 2716);
        } else return defaultQuestStartDialog(env);
      } else if (qs != null && qs.getStatus() == QuestStatus.REWARD)
        return defaultQuestEndDialog(env);
    } else if (targetId == 700853) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
        if (env.getDialogId() == -1
            && (player.getInventory().getItemCountByItemId(185000103) > 0
                && player.getInventory().getItemCountByItemId(185000107) >= 3)) {
          if (!ItemService.addItems(
              player, Collections.singletonList(new QuestItems(182212020, 1)))) return true;
          final int targetObjectId = env.getVisibleObject().getObjectId();
          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(185000103, 1);
          player.getInventory().removeFromBagByItemId(185000107, 3);
        }
      }
    }

    return false;
  }
コード例 #3
0
  @Override
  public boolean set(Skill skill) {
    skill.setFirstTargetProperty(value);
    switch (value) {
      case ME:
        skill.setFirstTarget(skill.getEffector());
        break;
      case TARGETORME:
        if (skill.getFirstTarget() == null) skill.setFirstTarget(skill.getEffector());
        break;
      case TARGET:
        if (skill.getFirstTarget() == null || skill.getFirstTarget() == skill.getEffector())
          return false;
        break;
      case MYPET:
        Creature effector = skill.getEffector();
        if (effector instanceof Player) {
          Summon summon = ((Player) effector).getSummon();
          if (summon != null) skill.setFirstTarget(summon);
          else return false;
        } else return false;
        break;
      case PASSIVE:
        skill.setFirstTarget(skill.getEffector());
        break;
      case TARGET_MYPARTY_NONVISIBLE:
        if (!(skill.getFirstTarget() instanceof Player)) return false;

        Player effected = (Player) skill.getFirstTarget();

        if (effected == null
            || !GroupService.getInstance().isGroupMember(effected.getObjectId())
            || skill.getEffector().getWorldId() != effected.getWorldId()) return false;
        skill.setFirstTargetRangeCheck(false);
        break;
      case POINT:
        skill.setFirstTarget(null);
        break;
    }

    if (skill.getFirstTarget() != null)
      skill.getEffectedList().add(new CreatureWithDistance(skill.getFirstTarget(), 0));
    return true;
  }
コード例 #4
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 == 186000107) {
      if (!ZoneService.getInstance().isInsideZone(player, ZoneName.DEBILKARIM_FORGE_300160000))
        return HandlerResult.FAILED;
      if (qs == null) return HandlerResult.UNKNOWN;
      if (qs.getQuestVarById(0) != 0) return HandlerResult.FAILED;
      if (player.getInventory().getItemCountByItemId(100900716) == 0
          || player.getInventory().getItemCountByItemId(186000099) == 0
          || player.getInventory().getItemCountByItemId(186000106) < 20
          || player.getInventory().getItemCountByItemId(186000107) == 0)
        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() {
                  ItemService.addItems(
                      player, Collections.singletonList(new QuestItems(182209634, 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 HandlerResult.SUCCESS;
    }
    return HandlerResult.UNKNOWN;
  }
コード例 #5
0
  @Override
  public boolean onDialogEvent(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 == 799226) {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 10002);
        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 == 799226) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 0) return sendQuestDialog(env, 1011);
          else if (var == 3) return sendQuestDialog(env, 2034);
        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;
          }
        case 10003:
          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 == 799292) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 1) return sendQuestDialog(env, 1352);
          else if (var == 2) return sendQuestDialog(env, 1693);
          else if (var == 5) return sendQuestDialog(env, 2716);
          else if (var == 11) return sendQuestDialog(env, 1608);
          break;
        case 34:
          if (QuestService.collectItemCheck(env, true)) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          } else return sendQuestDialog(env, 10001);
        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 10005:
          if (var == 5) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10255:
          if (var == 11) {
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 700810) {
      if (var == 2) return true;
    } else if (targetId == 204057) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 4) return sendQuestDialog(env, 2375);
        case 10004:
          if (var == 4) {
            if (!ItemService.addItems(
                player, Collections.singletonList(new QuestItems(182207611, 1)))) return true;
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 799341) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 9) return sendQuestDialog(env, 4080);
        case 10009:
          if (var == 9) {
            if (!ItemService.addItems(
                player, Collections.singletonList(new QuestItems(182207613, 1)))) return true;
            player.getInventory().removeFromBagByItemId(182207611, 1);
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 799513
        || targetId == 799514
        || targetId == 799515
        || targetId == 799516) // FIXME: Var !
    {
      switch (env.getDialogId()) {
        case 26:
          if (var == 7) return sendQuestDialog(env, 4080);
        case 10009:
          if (var == 7) {
            PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 442));
            qs.setQuestVar(8);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 730243) {
      switch (env.getDialogId()) {
        case -1:
          if (var >= 6) return sendQuestDialog(env, 3057);
          break;
        case 26:
          if (var == 6) return sendQuestDialog(env, 3057);
          break;
        case 10006:
          if (var == 6) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300150000);
            InstanceService.registerPlayerWithInstance(newInstance, player);
            TeleportService.teleportTo(
                player,
                300150000,
                newInstance.getInstanceId(),
                561.8651f,
                221.91483f,
                134.53333f,
                (byte) 90);
            return true;
          } else if (var > 6) {
            WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300150000);
            InstanceService.registerPlayerWithInstance(newInstance, player);
            TeleportService.teleportTo(
                player,
                300150000,
                newInstance.getInstanceId(),
                561.8651f,
                221.91483f,
                134.53333f,
                (byte) 90);
            return true;
          }
      }
    } else if (targetId == 700706) {
      switch (env.getDialogId()) {
        case -1:
          if (var == 10) {
            final int targetObjectId = env.getVisibleObject().getObjectId();
            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.setQuestVar(11);
            updateQuestStatus(env);
            TeleportService.teleportTo(
                player, 300150000, 561.8651f, 221.91483f, 134.53333f, (byte) 90);
          }
      }
    }

    return false;
  }