@Override
  protected void startUsage(Creature creature) {
    Player player = (Player) creature;
    // TODO extract method
    Creature target = creature.getTarget();
    if (target == null) {
      return;
    }

    final int unk = 0;

    PacketSendUtility.broadcastPacket(
        player,
        new SM_CASTSPELL(
            player.getObjectId(),
            getSkillId(),
            getSkillTemplate().getLevel(),
            unk,
            target.getObjectId(),
            getSkillTemplate().getDuration()),
        true);

    // TODO magic skill >1 lvl can be instant - check from template "type"
    schedulePerformAction(player, getSkillTemplate().getDuration());
  }
  @Override
  public HandlerResult onItemUseEvent(final QuestEnv env, Item item) {
    final Player player = env.getPlayer();
    final int itemObjId = item.getObjectId();
    final int id = item.getItemTemplate().getTemplateId();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    if (id != 182201765) {
      return HandlerResult.UNKNOWN;
    }

    if (qs != null) {
      if (qs.getStatus() == QuestStatus.COMPLETE) {
        removeQuestItem(env, 182201765, 1);
        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);
                sendQuestDialog(env, 4);
              }
            },
            3000);
    return HandlerResult.SUCCESS;
  }
示例#3
0
  private void destroy(final int var, final QuestEnv 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() == null
                    || 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);
                sendEmotion(env, player, EmotionId.STAND, true);
                QuestState qs = player.getQuestStateList().getQuestState(questId);
                if (var != -1) qs.setQuestVarById(0, var);
                else {
                  playQuestMovie(env, 21);
                  qs.setStatus(QuestStatus.REWARD);
                }
                updateQuestStatus(env);
              }
            },
            3000);
  }
示例#4
0
  @Override
  public boolean onItemUseEvent(QuestEnv env, Item item) {
    final Player player = env.getPlayer();
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();

    if (id != 182200007) return false;
    if (!zoneService.isInsideZone(player, ZoneName.ITEMUSE_Q1006)) return false;
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    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);
                itemService.addItems(
                    player, Collections.singletonList(new QuestItems(182200008, 1)));
                qs.setQuestVarById(0, 2);
                updateQuestStatus(player, qs);
              }
            },
            3000);
    return true;
  }
  @Override
  public HandlerResult onItemUseEvent(final QuestEnv 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 != 182206726) {
      return HandlerResult.UNKNOWN;
    }
    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);
                removeQuestItem(env, 182206726, 1);
                qs.setStatus(QuestStatus.REWARD);
                updateQuestStatus(env);
              }
            },
            1000);
    return HandlerResult.SUCCESS;
  }
  @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 != 182204123) {
      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;
  }
  private void destroy(final int var, QuestEnv 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);
                if (var == -1) PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 56));
                qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
                updateQuestStatus(player, qs);
              }
            },
            3000);
  }
  @Override
  public void act(Player player, Item parentItem, Item targetItem) {
    if (!player.getInventory().decreaseByObjectId(parentItem.getObjectId(), 1)) {
      return;
    }
    if (targetItem.getItemSkinTemplate().isItemDyePermitted()) {
      if (getColorBGRA() == 0) {
        targetItem.setItemColor(0);
        targetItem.setColorExpireTime(0);
      } else {
        targetItem.setItemColor(parentItem.getItemTemplate().getTemplateId());
        if (minutes != null) {
          targetItem.setColorExpireTime((int) (System.currentTimeMillis() / 1000 + minutes * 60));
        }
      }

      // item is equipped, so need broadcast packet
      if (player.getEquipment().getEquippedItemByObjId(targetItem.getObjectId()) != null) {
        PacketSendUtility.broadcastPacket(
            player,
            new SM_UPDATE_PLAYER_APPEARANCE(
                player.getObjectId(), player.getEquipment().getEquippedForApparence()),
            true);
        player.getEquipment().setPersistentState(PersistentState.UPDATE_REQUIRED);
      } // item is not equipped
      else {
        player.getInventory().setPersistentState(PersistentState.UPDATE_REQUIRED);
      }

      ItemPacketService.updateItemAfterInfoChange(player, targetItem);
    }
  }
 @Override
 public boolean onDialogEvent(QuestEnv 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() == 25)
         return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 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, 37, 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, 38, 0, targetObjectId), true);
                         qs.setQuestVarById(0, 1);
                         updateQuestStatus(player, qs);
                       }
                     },
                     3000);
           }
         }
       case 205130:
         {
           if (qs.getQuestVarById(0) == 1) {
             if (env.getDialogId() == 25)
               return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
             else if (env.getDialogId() == 1009) {
               qs.setStatus(QuestStatus.REWARD);
               updateQuestStatus(player, qs);
               return defaultQuestEndDialog(env);
             } else return defaultQuestEndDialog(env);
           }
         }
     }
   } else if (qs.getStatus() == QuestStatus.REWARD) {
     if (targetId == 205130) return defaultQuestEndDialog(env);
   }
   return false;
 }
  /** {@inheritDoc} */
  @Override
  protected void runImpl() {
    Player player = getConnection().getActivePlayer();
    ItemService.moveItem(player, targetObjectId, source, destination, slot);

    PacketSendUtility.broadcastPacket(player, new SM_EMOTION(player, 36, 0, 0));

    //		sendPacket(new SM_LOOT_STATUS(targetObjectId,3));
  }
示例#11
0
  @Override
  protected void handleDied() {
    if (isAlreadyDead()) {
      PacketSendUtility.broadcastPacket(
          getOwner(), new SM_EMOTION(getOwner(), EmotionType.DIE, 0, 0));
      getOwner().broadcastPacket(SM_SYSTEM_MESSAGE.STR_BINDSTONE_IS_DESTROYED);
    }

    super.handleDied();
  }
 private void moveToDead() {
   ((AbstractAI) getOwner().getAi2()).setStateIfNot(AIState.WALKING);
   WalkManager.startWalking((NpcAI2) getOwner().getAi2());
   getOwner().setState(1);
   getOwner().getMoveController().moveToPoint(455.93f, 537.2f, 132.55f);
   PacketSendUtility.broadcastPacket(
       getOwner(),
       new SM_EMOTION(getOwner(), EmotionType.START_EMOTE2, 0, getOwner().getObjectId()));
   dead();
 }
 @Override
 public boolean onDie(final Player player, Creature lastAttacker) {
   PacketSendUtility.broadcastPacket(
       player,
       new SM_EMOTION(
           player,
           EmotionType.DIE,
           0,
           player.equals(lastAttacker) ? 0 : lastAttacker.getObjectId()),
       true);
   PacketSendUtility.sendPacket(
       player, new SM_DIE(player.haveSelfRezEffect(), player.haveSelfRezItem(), 0, 8));
   return true;
 }
  @Override
  public boolean onDie(Player player, Creature lastAttacker) {
    PacketSendUtility.broadcastPacket(
        player,
        new SM_EMOTION(
            player,
            EmotionType.DIE,
            0,
            player.equals(lastAttacker) ? 0 : lastAttacker.getObjectId()),
        true);

    PacketSendUtility.sendPacket(player, new SM_DIE(false, false, 0, 8));
    return true;
  }
示例#15
0
  @Override
  public boolean onItemUseEvent(QuestEnv env, 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);
    if (qs != null && qs.getStatus() != QuestStatus.NONE) return false;
    if (id != 182200214) return false;

    PacketSendUtility.broadcastPacket(
        player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 20, 1, 0), true);
    sendQuestDialog(player, 0, 4);

    return true;
  }
 @Override
 public boolean onDialogEvent(QuestEnv 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 == 730000) {
       env.setQuestId(questId);
       QuestService.startQuest(env, QuestStatus.START);
       sendQuestDialog(player, 0, 1011);
       return false;
     }
   } else if (qs.getStatus() == QuestStatus.START) {
     if (targetId == 700033 && env.getDialogId() == -1) {
       final int targetObjectId = env.getVisibleObject().getObjectId();
       PacketSendUtility.broadcastPacket(
           player, new SM_EMOTION(player, EmotionType.SIT, 0, targetObjectId), true);
       ThreadPoolManager.getInstance()
           .schedule(
               new Runnable() {
                 @Override
                 public void run() {
                   if (!player.isTargeting(targetObjectId)) return;
                   if (ItemService.addItems(
                       player, Collections.singletonList(new QuestItems(182200504, 1)))) {
                     ((Npc) player.getTarget()).getController().onDespawn(true);
                     qs.setStatus(QuestStatus.REWARD);
                     updateQuestStatus(player, qs);
                   }
                 }
               },
               3000);
     }
   } else if (qs.getStatus() == QuestStatus.REWARD) {
     if (targetId == 730000) {
       if (ItemService.removeItemFromInventoryByItemId(player, 182200504)) {
         PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 16));
         return true;
       }
     }
   }
   return false;
 }
  @Override
  public void act(Player player, Item parentItem, Item targetItem) {
    if (!player.getInventory().decreaseByObjectId(parentItem.getObjectId(), 1)) {
      return;
    }
    ItemTemplate itemTemplate = parentItem.getItemTemplate();
    PacketSendUtility.broadcastPacket(
        player,
        new SM_ITEM_USAGE_ANIMATION(
            player.getObjectId(), parentItem.getObjectId(), itemTemplate.getTemplateId()),
        true);

    switch (storage) {
      case CUBE:
        CubeExpandService.expand(player, false);
        break;
      case WAREHOUSE:
        WarehouseService.expand(player);
        break;
    }
  }
示例#18
0
  @Override
  protected void performAction(Creature creature) {
    Player player = (Player) creature;
    // TODO extract method
    Creature target = creature.getTarget();
    if (target == null) {
      return;
    }

    // TODO investigate unk
    int unk = 0;

    Map<String, Integer> incluenceResult = new HashMap<String, Integer>();

    SkillEffectData skillEffectData = getSkillTemplate().getSkillEffectData();
    if (skillEffectData != null) {
      for (SkillEffectTemplate effectTemplate : skillEffectData.getSkillEffects()) {
        AbstractEffect effect = SkillEffectType.getEffectByName(effectTemplate);
        // TODO player.onEffectInfluence(AbstractEffect)
        int result = effect.influence(player, target);
        log.error("putting into map: " + result + " " + effectTemplate.getName());
        incluenceResult.put(effectTemplate.getName(), result);
      }
    }

    target.getController().onAttack(player);

    // TODO now spell ends after damage is done.
    PacketSendUtility.broadcastPacket(
        player,
        new SM_CASTSPELL_END(
            player.getObjectId(),
            getSkillId(),
            getSkillTemplate().getLevel(),
            unk,
            target.getObjectId(),
            incluenceResult.get(SkillEffectType.DAMAGE.getName())),
        true);
  }
  @Override
  public boolean onItemUseEvent(QuestEnv env, Item item) {
    final Player player = env.getPlayer();
    final int id = item.getItemTemplate().getTemplateId();
    final int itemObjId = item.getObjectId();

    if (id != 182200501) 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);
                sendQuestDialog(player, 0, 4);
              }
            },
            3000);
    return true;
  }
  @Override
  protected void runImpl() {
    Player player = getConnection().getActivePlayer();
    Pet pet = player.getPet();

    if (pet == null) {
      return;
    }

    // sometimes client is crazy enough to send -2.4457384E7 as z coordinate
    // TODO (check retail) either its client bug or packet problem somewhere
    // reproducible by flying randomly and falling from long height with fly resume
    if (x1 < 0 || y1 < 0 || z1 < 0) {
      return;
    }
    // log.info("CM_PET_EMOTE emote {}, unk1 {}, unk2 {}", new Object[] { emoteId, unk1, unk2 });
    // switch (emote) {

    if (emote == PetEmote.ALARM) {
      PacketSendUtility.broadcastPacket(player, new SM_PET_EMOTE(pet, emote), true);
    } else if (emote == PetEmote.MOVE_STOP) {
      World.getInstance().updatePosition(pet, x1, y1, z1, h);
      PacketSendUtility.broadcastPacket(player, new SM_PET_EMOTE(pet, emote, x1, y1, z1, h), true);
    } else if (emote == PetEmote.MOVETO) {
      World.getInstance().updatePosition(pet, x1, y1, z1, h);
      pet.getMoveController().setNewDirection(x2, y2, z2, h);
      PacketSendUtility.broadcastPacket(
          player, new SM_PET_EMOTE(pet, emote, x1, y1, z2, x2, y2, z2, h), true);
    } else if (emote == PetEmote.FLY) {
      PacketSendUtility.broadcastPacket(
          player, new SM_PET_EMOTE(pet, emote, emotionId, unk2), true);
    } else if (emote == PetEmote.MOVE_STOP) {
      World.getInstance().updatePosition(pet, x1, y1, z1, h);
      PacketSendUtility.broadcastPacket(player, new SM_PET_EMOTE(pet, emote, x1, y1, z1, h), true);
    } else {
      if (emotionId > 0) {
        PacketSendUtility.sendPacket(player, new SM_PET_EMOTE(pet, emote, emotionId, unk2));
      } else {
        PacketSendUtility.broadcastPacket(player, new SM_PET_EMOTE(pet, emote, 0, unk2), true);
      }
    }
  }
 private void startRun(Npc npc) {
   npc.setState(1);
   PacketSendUtility.broadcastPacket(
       npc, new SM_EMOTION(npc, EmotionType.START_EMOTE2, 0, npc.getObjectId()));
 }
  private void move() {
    /** Demo npc skills - prevent movement while casting */
    if (!owner.canPerformMove() || owner.isCasting()) {
      if (!isStopped) {
        isStopped = true;
        owner.getController().stopMoving();
      }
      return;
    }

    VisibleObject target = owner.getTarget();

    if (isFollowTarget && target != null) {
      setNewDirection(target.getX(), target.getY(), target.getZ());
    }

    float ownerX = owner.getX();
    float ownerY = owner.getY();
    float ownerZ = owner.getZ();

    double dist = MathUtil.getDistance(ownerX, ownerY, ownerZ, targetX, targetY, targetZ);
    if (dist > this.distance) {
      isStopped = false;

      float x2;
      float y2;
      float z2;
      float mod = 1;
      if (dist < speed * 0.5) {
        x2 = (targetX - ownerX);
        y2 = (targetY - ownerY);
        z2 = (targetZ - ownerZ);
      } else {
        x2 = (float) (((targetX - ownerX) / dist) * speed * 0.5);
        y2 = (float) (((targetY - ownerY) / dist) * speed * 0.5);
        z2 = (float) (((targetZ - ownerZ) / dist) * speed * 0.5);
        mod = 0.5f;
      }

      byte heading2 = (byte) (Math.toDegrees(Math.atan2(y2, x2)) / 3);

      if (directionChanged) {
        PacketSendUtility.broadcastPacket(
            owner,
            new SM_MOVE(
                owner.getObjectId(),
                ownerX,
                ownerY,
                ownerZ,
                (x2 / mod),
                (y2 / mod),
                (z2 / mod),
                heading2,
                MovementType.MOVEMENT_START_KEYBOARD));
        directionChanged = false;
      }

      moveCounter++;
      World.getInstance()
          .updatePosition(
              owner, ownerX + x2, ownerY + y2, ownerZ + z2, heading2, moveCounter % 5 == 0);
    } else {
      if (!isStopped) {
        isStopped = true;
        owner.getController().stopMoving();
      }
    }
  }
示例#23
0
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (targetId == 0) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == 1002) {
          questService.startQuest(env, QuestStatus.START);
          if (!itemService.addItems(
              player, Collections.singletonList(new QuestItems(182200226, 1)))) ;
          player.getInventory().removeFromBagByItemId(182200214, 1);
          PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
          return true;
        } else PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
      }
    }

    if (qs == null) return false;

    int var = qs.getQuestVarById(0);

    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 203075 && var == 4) {
        if (env.getDialogId() == -1)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
        else if (env.getDialogId() == 1009)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 6);
        else return defaultQuestEndDialog(env);
      } else if (targetId == 203058 && var == 3) return defaultQuestEndDialog(env);
    } else if (qs.getStatus() != QuestStatus.START) return false;

    if (targetId == 203075) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 0) return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1011);
          else if (var == 2)
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1693);
          else if (var == 3)
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);

        case 1009:
          if (var == 2) {
            qs.setQuestVarById(0, var + 2);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(player, qs);
            player.getInventory().removeFromBagByItemId(182200217, 1);
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 6);
          }
          if (var == 3) {
            qs.setQuestVarById(0, var + 1);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(player, qs);
            player.getInventory().removeFromBagByItemId(182200217, 1);
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 6);
          }
        case 10000:
          if (var == 0) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            player.getInventory().removeFromBagByItemId(182200226, 1);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10001:
          if (var == 2) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 700008) {
      switch (env.getDialogId()) {
        case -1:
          if (var == 1) {
            // final Npc npc = (Npc)env.getVisibleObject();
            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, 37, 0, targetObjectId), true);
            ThreadPoolManager.getInstance()
                .schedule(
                    new Runnable() {
                      @Override
                      public void run() {
                        PacketSendUtility.sendPacket(
                            player,
                            new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                        PacketSendUtility.broadcastPacket(
                            player, new SM_EMOTION(player, 38, 0, targetObjectId), true);
                        for (VisibleObject obj : player.getKnownList()) {
                          if (!(obj instanceof Npc)) continue;
                          if (((Npc) obj).getNpcId() != 203175) continue;
                          if (((Npc) obj).getNpcId() != 203175) return;
                          ((Npc) obj).getAggroList().addDamage(player, 50);
                        }
                        if (!itemService.addItems(
                            player, Collections.singletonList(new QuestItems(182200217, 1)))) ;
                        qs.setQuestVarById(0, 2);
                        updateQuestStatus(player, qs);
                      }
                    },
                    3000);
          }
          return true;
      }
    }
    if (targetId == 203058) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 3) return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2034);
        case 10002:
          if (var == 3) {
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(player, qs);
            player.getInventory().removeFromBagByItemId(182200217, 1);
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 5);
          }
        case 10001:
          if (var == 3) {
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    }
    return false;
  }
  @Override
  public boolean onDialogEvent(QuestEnv 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 == 204501) return defaultQuestEndDialog(env);
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 204501) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 0) return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1011);
          else if (var == 4)
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
          return false;
        case 10000:
          if (var == 0) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10004:
          if (var == 4) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
          return false;
      }
    } else if (targetId == 204582) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 1) return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1352);
          else if (var == 3)
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2034);
          return false;
        case 10001:
          if (var == 1) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10003:
          if (var == 3) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            ItemService.decreaseItemCountByItemId(player, 182201601, 1);
            return true;
          }
          return false;
      }
    } else if (targetId == 203882) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 5) return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2716);
        case 10005:
          if (var == 5) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
          return false;
      }
    } else if (targetId == 278503) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 6) return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 3057);
          else if (var == 7)
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 3398);
        case 33:
          if (QuestService.collectItemCheck(env, true)) {
            qs.setQuestVarById(0, var + 1);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(player, qs);
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 10000);
          } else return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 10001);
        case 10006:
          if (var == 6) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10007:
          if (var == 7) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
          return false;
      }
    } else if (targetId == 700217 && qs.getQuestVarById(0) == 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() {
                    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);
                    sendQuestDialog(player, targetObjectId, 1693);
                  }
                },
                3000);
      } else if (qs.getQuestVarById(0) == 2 && env.getDialogId() == 10002) {
        PacketSendUtility.sendPacket(
            player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
        ItemService.addItems(player, Collections.singletonList(new QuestItems(182201601, 1)));
        qs.setQuestVarById(0, 3);
        updateQuestStatus(player, qs);
        return true;
      }
    } else if (targetId == 700303 && qs.getQuestVarById(0) == 7) {
      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() {
                    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);
                    ItemService.addItems(
                        player, Collections.singletonList(new QuestItems(182201602, 1)));
                  }
                },
                3000);
      }
    }
    return false;
  }