@Override
  public void execute(Player admin, String... params) {

    if (params.length != 1) {
      PacketSendUtility.sendMessage(admin, "Syntax: //addcube <player name>");
      return;
    }

    Player receiver = null;

    receiver = World.getInstance().findPlayer(Util.convertName(params[0]));

    if (receiver == null) {
      PacketSendUtility.sendMessage(
          admin, "The player " + Util.convertName(params[0]) + " is not online.");
      return;
    }

    if (receiver != null) {
      if (receiver.getNpcExpands() < CustomConfig.BASIC_CUBE_SIZE_LIMIT) {
        CubeExpandService.expand(receiver, true);
        PacketSendUtility.sendMessage(
            admin, "9 cube slots successfully added to player " + receiver.getName() + "!");
        PacketSendUtility.sendMessage(
            receiver, "Admin " + admin.getName() + " gave you a cube expansion!");
      } else {
        PacketSendUtility.sendMessage(
            admin,
            "Cube expansion cannot be added to "
                + receiver.getName()
                + "!\nReason: player cube already fully expanded.");
        return;
      }
    }
  }
  @Override
  public void execute(Player player, String... params) {
    Wedding wedding = WeddingService.getInstance().getWedding(player);

    if (params == null || params.length != 1) {
      PacketSendUtility.sendMessage(player, "syntax .answer yes/no.");
      return;
    }

    if (player.getWorldId() == 510010000 || player.getWorldId() == 520010000) {
      PacketSendUtility.sendMessage(player, "You can't use this command on prison.");
      return;
    }

    if (wedding == null) {
      PacketSendUtility.sendMessage(player, "Wedding not started.");
      return;
    }

    if (params[0].toLowerCase().equals("yes")) {
      PacketSendUtility.sendMessage(
          player,
          "\u0412\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u043b\u0438\u0441\u044c.");
      WeddingService.getInstance().acceptWedding(player);
    }

    if (params[0].toLowerCase().equals("no")) {
      PacketSendUtility.sendMessage(
          player, "\u0412\u044b \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c.");
      WeddingService.getInstance().cancelWedding(player);
    }
  }
  @Override
  protected void handleDialogStart(Player player) {
    int membership = player.getClientConnection().getAccount().getMembership();

    if (membership >= 2) {
      PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 1011));
    } else {
      PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 0));
      PacketSendUtility.sendBrightYellowMessageOnCenter(
          player, MuiService.getInstance().getMessage("T_PORTAL"));
    }
  }
 @Override
 protected void handleDialogStart(Player player) {
   checkDialog(player);
   if (player.getLegion() != null) {
     int SiegeId = ((SiegeNpc) this.getOwner()).getSiegeId();
     SiegeLocation Location = SiegeService.getInstance().getSiegeLocation(SiegeId);
     if (Location != null) {
       if (Location.getLegionId() == player.getLegion().getLegionId()) {
         PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getOwner().getObjectId(), 10));
         return;
       }
     }
   }
   PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getOwner().getObjectId(), 1011));
 }
 @Override
 public boolean onDialogEvent(QuestEnv 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 == 278003) {
     if (qs == null || qs.getStatus() == QuestStatus.NONE) {
       if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1011);
       else return sendQuestStartDialog(env);
     }
   } else if (targetId == 278000) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
       if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1352);
       else if (env.getDialog() == DialogAction.SETPRO1) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
         return true;
       } else return sendQuestStartDialog(env);
     }
   } else if (targetId == 278013) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) {
       if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1352);
       else if (env.getDialog() == DialogAction.SETPRO1) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
         return true;
       } else return sendQuestStartDialog(env);
     }
   } else if (targetId == 278102) {
     if (qs != null) {
       if (env.getDialog() == DialogAction.QUEST_SELECT && qs.getStatus() == QuestStatus.START)
         return sendQuestDialog(env, 2375);
       else if (env.getDialogId() == DialogAction.SELECT_QUEST_REWARD.id()
           && qs.getStatus() == QuestStatus.START) {
         qs.setQuestVar(2);
         qs.setStatus(QuestStatus.REWARD);
         updateQuestStatus(env);
         return sendQuestEndDialog(env);
       } else return sendQuestEndDialog(env);
     }
   }
   return false;
 }
  @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 (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (env.getDialogId() == DialogAction.QUEST_ACCEPT_1.id()) {
        QuestService.startQuest(env);
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
        return true;
      } else PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
    } else if (qs.getStatus() == QuestStatus.START) {
      if (targetId == 278592) {
        if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1352);
        else if (env.getDialog() == DialogAction.SETPRO1) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        }
      } else if (targetId == 203933) {
        if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1693);
        else if (env.getDialog() == DialogAction.SETPRO2) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        }
      } else if (targetId == 203991) {
        if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 2375);
        else if (env.getDialogId() == DialogAction.SELECT_QUEST_REWARD.id()) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return sendQuestEndDialog(env);
        }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD && targetId == 203991) {
      return sendQuestEndDialog(env);
    }
    return false;
  }
  @Override
  public boolean onDialogEvent(QuestEnv 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 (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (targetId == 203782) {
        if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 4762);
        else return sendQuestStartDialog(env);
      }
    }

    if (qs == null) return false;

    if (qs != null && qs.getStatus() == QuestStatus.START) {
      switch (targetId) {
        case 203783:
          {
            switch (env.getDialog()) {
              case QUEST_SELECT:
                return sendQuestDialog(env, 1011);
              case SETPRO1:
                if (!giveQuestItem(env, 122001251, 1)) return true;
                qs.setQuestVarById(0, 1);
                updateQuestStatus(env);
                PacketSendUtility.sendPacket(
                    player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
                return true;
            }
          }
        case 203782:
          {
            switch (env.getDialog()) {
              case QUEST_SELECT:
                {
                  long itemCount1 = player.getInventory().getItemCountByItemId(152003007);
                  long itemCount2 = player.getInventory().getItemCountByItemId(152003008);
                  if (itemCount1 > 0 && itemCount2 > 0) {
                    removeQuestItem(env, 152003007, 1);
                    removeQuestItem(env, 152003008, 1);
                    qs.setStatus(QuestStatus.REWARD);
                    updateQuestStatus(env);
                    return sendQuestDialog(env, 1352);
                  } else return sendQuestDialog(env, 10001);
                }
            }
          }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 203782) {
        if (env.getDialogId() == DialogAction.CHECK_USER_HAS_QUEST_ITEM.id())
          return sendQuestDialog(env, 5);
        else return sendQuestEndDialog(env);
      }
    }
    return false;
  }
 @Override
 protected void handleDialogStart(Player player) {
   if (player.equals(owner)) {
     PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 18));
     player.getMailbox().sendMailList(true);
   }
 }
  @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 != 182208043) 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;
  }
Exemple #10
0
  @Override
  public void execute(Player admin, String... params) {
    if (params.length > 1) onFail(admin, null);

    VisibleObject target = admin.getTarget();
    if (target == null) PacketSendUtility.sendMessage(admin, "No target selected");
    else if (target instanceof Creature) {
      Creature creature = (Creature) target;
      int dmg;
      try {
        String percent = params[0];
        Pattern damage = Pattern.compile("([^%]+)%");
        Matcher result = damage.matcher(percent);

        if (result.find()) {
          dmg = Integer.parseInt(result.group(1));

          if (dmg < 100)
            creature
                .getController()
                .onAttack(admin, (int) (dmg / 100f * creature.getLifeStats().getMaxHp()), true);
          else
            creature.getController().onAttack(admin, creature.getLifeStats().getMaxHp() + 1, true);
        } else creature.getController().onAttack(admin, Integer.parseInt(params[0]), true);
      } catch (Exception ex) {
        onFail(admin, null);
      }
    }
  }
  @Override
  protected void handleDespawned() {
    PacketSendUtility.broadcastPacket(
        getOwner(),
        new SM_SYSTEM_MESSAGE(true, 390267, getObjectId(), 1, new NpcShout().getParam()));

    super.handleDespawned();
  }
 @Override
 public boolean onReviveEvent(Player player) {
   PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_REBIRTH_MASSAGE_ME);
   PlayerReviveService.revive(player, 100, 100, false, 0);
   player.getGameStats().updateStatsAndSpeedVisually();
   return TeleportService2.teleportTo(
       player, mapId, instanceId, 527.6408f, 109.9414f, 175.50763f, (byte) 75);
 }
 @Override
 public void run() {
   PacketSendUtility.broadcastPacket(
       getOwner(),
       new SM_SYSTEM_MESSAGE(true, 390266, getObjectId(), 1, new NpcShout().getParam()));
   handleFollowMe(owner);
   handleCreatureMoved(owner);
 }
  @Override
  public boolean onDialogSelect(Player player, int dialogId, int questId, int extendedRewardIndex) {
    DialogPage page = DialogPage.getPageByAction(dialogId);
    if (page == DialogPage.NULL) return false;

    PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getOwner().getObjectId(), page.id()));
    return true;
  }
  @Override
  public boolean canAct(Player player, Item parentItem, Item targetItem) {
    if (targetItem == null) { // no item selected.
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_ITEM_COLOR_ERROR);
      return false;
    }

    return true;
  }
  private void checkDialog(Player player) {
    int npcId = getNpcId();
    List<Integer> relatedQuests = QuestEngine.getInstance().getQuestNpc(npcId).getOnTalkEvent();
    boolean playerHasQuest = false;
    boolean playerCanStartQuest = false;
    if (!relatedQuests.isEmpty()) {
      for (int questId : relatedQuests) {
        QuestState qs = player.getQuestStateList().getQuestState(questId);
        if (qs != null
            && (qs.getStatus() == QuestStatus.START || qs.getStatus() == QuestStatus.REWARD)) {
          playerHasQuest = true;
          break;
        } else if (qs == null || qs.getStatus() == QuestStatus.NONE || qs.canRepeat()) {
          if (QuestService.checkStartConditions(
              new QuestEnv(getOwner(), player, questId, 0), true)) {
            playerCanStartQuest = true;
            continue;
          }
        }
      }
    }

    if (playerHasQuest) {
      boolean isRewardStep = false;
      for (int questId : relatedQuests) {
        QuestState qs = player.getQuestStateList().getQuestState(questId);
        if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(getObjectId(), rewardDialogId, questId));
          isRewardStep = true;
          break;
        }
      }
      if (!isRewardStep) {
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), questDialogId));
      }
    } else if (playerCanStartQuest) {
      PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), startingDialogId));
    } else {
      PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 1011, 0));
    }
  }
  /* (non-Javadoc)
   * @see org.typezero.gameserver.utils.chathandlers.ChatCommand#execute(org.typezero.gameserver.model.gameobjects.player.Player, java.lang.String[])
   */
  @Override
  public void execute(Player player, String... params) {
    if (params.length < 1) {
      PacketSendUtility.sendMessage(
          player, "Syntax: //token <playername> || //token show <playername>");
      return;
    }
    Player receiver = null;

    if (params[0].equals("show")) {
      receiver = World.getInstance().findPlayer(Util.convertName(params[1]));
      if (receiver == null) {
        PacketSendUtility.sendMessage(player, "Can't find this player, maybe he's not online");
        return;
      }

      if (!"".equals(receiver.getPlayerAccount().getSecurityToken())) {
        PacketSendUtility.sendMessage(
            player,
            "The Security Token of this player is: "
                + receiver.getPlayerAccount().getSecurityToken());
      } else {
        PacketSendUtility.sendMessage(player, "This player haven't an Security Token!");
      }

    } else {
      receiver = World.getInstance().findPlayer(Util.convertName(params[0]));

      if (receiver == null) {
        PacketSendUtility.sendMessage(player, "Can't find this player, maybe he's not online");
        return;
      }

      PlayerSecurityTokenService.getInstance().generateToken(receiver);
    }
  }
 private void checkEntryConditions(Player player, int dialogId, int questId) {
   if (dialogId == 10000) {
     if (player.getInventory().decreaseByItemId(186000246, 1)) {
       switch (player.getRace()) {
         case ASMODIANS:
           SkillEngine.getInstance().applyEffectDirectly(21139, player, player, 160000 * 3);
           break;
         case ELYOS:
           SkillEngine.getInstance().applyEffectDirectly(21138, player, player, 160000 * 3);
           break;
       }
       PacketSendUtility.sendBrightYellowMessageOnCenter(
           player, MuiService.getInstance().getMessage("DEFENCE_BASTION"));
       stopMove(player);
       AI2Actions.deleteOwner(this);
     } else {
       PacketSendUtility.sendBrightYellowMessageOnCenter(
           player, MuiService.getInstance().getMessage("DEFENCE_BASTION_NO"));
       PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 0, 0));
     }
   } else {
     PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), dialogId, questId));
   }
 }
  @Override
  public boolean onDialogEvent(QuestEnv 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 == 204720) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1011);
        else if (env.getDialogId() == DialogAction.QUEST_ACCEPT_1.id()) {
          if (giveQuestItem(env, 182204404, 1)) return sendQuestStartDialog(env);
          else return true;
        } else return sendQuestStartDialog(env);
      }
    }
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 204720) {
        if (env.getDialog() == DialogAction.USE_OBJECT) return sendQuestDialog(env, 2375);
        else if (env.getDialogId() == DialogAction.SELECT_QUEST_REWARD.id())
          return sendQuestDialog(env, 5);
        else return sendQuestEndDialog(env);
      }
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 204731) {
      switch (env.getDialog()) {
        case QUEST_SELECT:
          if (var == 0) return sendQuestDialog(env, 1352);
        case SETPRO1:
          if (var == 0) {
            removeQuestItem(env, 182204404, 1);
            if (!giveQuestItem(env, 182204405, 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 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.START) {
      switch (targetId) {
        case 204191:
          {
            switch (env.getDialog()) {
              case QUEST_SELECT:
                if (var == 0) return sendQuestDialog(env, 1352);
                break;
              case SETPRO1:
                if (var == 0) {
                  qs.setQuestVarById(0, var + 1);
                  updateQuestStatus(env);
                  TeleportService2.teleportTo(
                      player, 220030000, player.getInstanceId(), 1748f, 1807f, 255f);
                  PacketSendUtility.sendPacket(
                      player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
                  return true;
                }
            }
          }
        case 203559:
          switch (env.getDialog()) {
            case QUEST_SELECT:
              if (var == 1) {
                qs.setStatus(QuestStatus.REWARD);
                updateQuestStatus(env);
                return sendQuestDialog(env, 2375);
              }
          }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 203559) {
        return sendQuestEndDialog(env);
      }
    }
    return false;
  }
 private void onDieSurkan(Npc npc, Player mostPlayerDamage, int points) {
   Race race = mostPlayerDamage.getRace();
   captureRoom(race, npc.getNpcId() + 14 - 700851);
   for (Player player : instance.getPlayersInside()) {
     PacketSendUtility.sendPacket(
         player,
         new SM_SYSTEM_MESSAGE(
             1400199,
             new DescriptionId(race.equals(Race.ASMODIANS) ? 1800483 : 1800481),
             new DescriptionId(npc.getObjectTemplate().getNameId() * 2 + 1)));
   }
   getPlayerReward(mostPlayerDamage).captureZone();
   if (++surkanKills == 5) {
     spawn(216886, 485.33f, 832.26f, 416.64f, (byte) 55);
     sendMsgByRace(1400632, Race.PC_ALL, 0);
   }
   updateScore(mostPlayerDamage, npc, points, false);
   NpcActions.delete(npc);
 }
 @Override
 public boolean onDieEvent(QuestEnv env) {
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs != null && qs.getStatus() == QuestStatus.START) {
     int var = qs.getQuestVarById(0);
     if (var >= 0) {
       qs.setStatus(QuestStatus.NONE);
       qs.setQuestVar(0);
       updateQuestStatus(env);
       PacketSendUtility.sendPacket(
           player,
           new SM_SYSTEM_MESSAGE(
               SystemMessageId.QUEST_FAILED_$1,
               DataManager.QUEST_DATA.getQuestById(questId).getName()));
       return true;
     }
   }
   return false;
 }
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    Player player = env.getPlayer();
    int targetId = env.getTargetId();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    if (targetId == 799584) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == DialogAction.QUEST_SELECT.id()) return sendQuestDialog(env, 4762);
        else return sendQuestStartDialog(env);
      }
    } else if (targetId == 799563) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
        if (env.getDialogId() == DialogAction.QUEST_SELECT.id()) return sendQuestDialog(env, 1011);
        else if (env.getDialogId() == DialogAction.SETPRO1.id()) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        } else return sendQuestStartDialog(env);
      } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
        if (env.getDialogId() == DialogAction.USE_OBJECT.id()) return sendQuestDialog(env, 10002);
        else if (env.getDialogId() == DialogAction.SELECT_QUEST_REWARD.id())
          return sendQuestDialog(env, 5);
        else return sendQuestEndDialog(env);
      }
    } else if (targetId == 799553) {
      if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
        if (env.getDialogId() == DialogAction.USE_OBJECT.id()) return sendQuestDialog(env, 10002);
        else if (env.getDialogId() == DialogAction.SELECT_QUEST_REWARD.id())
          return sendQuestDialog(env, 5);
        else return sendQuestEndDialog(env);
      }
    }
    return false;
  }
 private void checkEntryConditions(Player player, int dialogId, int questId) {
   if (dialogId == 10000) {
     if (player.getInventory().getItemCountByItemId(186000236) >= 4) {
       if ((getPosition().getWorldMapInstance().getNpc(251588) == null)
           && player.getInventory().decreaseByItemId(186000236, 4)) {
         spawn(251588, 2072.62f, 1372.4f, 2974.65f, (byte) 65); // Ra
         spawn(251588, 2037.37f, 1370.13f, 2976.16f, (byte) 105); // Ra
         spawn(251588, 2038.95f, 1378.1f, 2976.02f, (byte) 110); // Ra
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1402173));
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1402176));
         PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 2375));
       } else {
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1401837));
         PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 10));
       }
     } else {
       PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 27));
     }
   } else if (dialogId == 10001) {
     if (player.getInventory().getItemCountByItemId(186000236) >= 4) {
       if ((getPosition().getWorldMapInstance().getNpc(279954) == null)
           && player.getInventory().decreaseByItemId(186000236, 4)) {
         spawn(279954, 2146.29f, 1281.95f, 2979.65f, (byte) 45); // Ra
         spawn(279954, 2058.42f, 1218.75f, 2977.01f, (byte) 90); // Ra
         spawn(279954, 1970.65f, 1264.15f, 2979.65f, (byte) 60); // Ra
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1402174));
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1402177));
         PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 2375));
       } else {
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1401837));
         PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 10));
       }
     } else {
       PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 27));
     }
   } else if (dialogId == 10002) {
     if (player.getInventory().getItemCountByItemId(186000236) >= 12) {
       if ((getPosition().getWorldMapInstance().getNpc(279955) == null)
           && player.getInventory().decreaseByItemId(186000236, 12)) {
         spawn(279955, 2069.03f, 1274.69f, 2986.47f, (byte) 0); // Ra
         spawn(279955, 2043.69f, 1273.73f, 2986.47f, (byte) 0); // Ra
         spawn(279955, 2059.28f, 1264.79f, 2956.27f, (byte) 35); // Ra
         spawn(279955, 2055.36f, 1264.79f, 2956.27f, (byte) 0); // Ra
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1402175));
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1402178));
         PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 2375));
       } else {
         PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1401837));
         PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 10));
       }
     } else {
       PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 27));
     }
   } else {
     PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), dialogId, questId));
   }
 }
Exemple #25
0
 @Override
 public void onFail(Player admin, String message) {
   PacketSendUtility.sendMessage(admin, "Syntax: //addcube <player name>");
 }
  @Override
  public boolean onDialogEvent(QuestEnv 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);
    DialogAction dialog = env.getDialog();

    if (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (targetId == 204817) {
        if (dialog == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1011);
        else return sendQuestStartDialog(env);
      }
    } else if (qs.getStatus() == QuestStatus.START) {
      int var = qs.getQuestVarById(0);
      if (targetId == 204817) {
        switch (dialog) {
          case QUEST_SELECT:
            if (var == 3) {
              qs.setStatus(QuestStatus.REWARD);
              updateQuestStatus(env);
              return sendQuestDialog(env, 2375);
            }
          case SELECT_QUEST_REWARD:
            if (var == 3) return sendQuestDialog(env, 5);
        }
      }
      if (targetId == 204777) {
        switch (dialog) {
          case QUEST_SELECT:
            if (var == 0) return sendQuestDialog(env, 1352);
          case SETPRO1:
            if (var == 0) {
              if (!giveQuestItem(env, 182204515, 1)) return true;
              if (!giveQuestItem(env, 182204516, 1)) return true;
              qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
              updateQuestStatus(env);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
              return true;
            }
        }
      }
      if (targetId == 204700) {
        switch (dialog) {
          case QUEST_SELECT:
            if (var == 1) return sendQuestDialog(env, 1693);
          case SETPRO2:
            if (var == 1) {
              removeQuestItem(env, 182204515, 1);
              qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
              updateQuestStatus(env);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
              return true;
            }
        }
      }
      if (targetId == 204702) {
        switch (dialog) {
          case QUEST_SELECT:
            if (var == 2) return sendQuestDialog(env, 2034);
          case SETPRO3:
            if (var == 2) {
              removeQuestItem(env, 182204516, 1);
              qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
              updateQuestStatus(env);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
              return true;
            }
        }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 204817) {
        return sendQuestEndDialog(env);
      }
    }
    return false;
  }
  @Override
  public boolean onDialogEvent(final QuestEnv 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);
    DialogAction dialog = env.getDialog();

    if (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (targetId == 204787) { // Chieftain Akagitan
        if (dialog == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 4762);
        else if (dialog == DialogAction.QUEST_ACCEPT_1) {
          if (!giveQuestItem(env, 182204498, 1)) return true;
          return sendQuestStartDialog(env);
        } else return sendQuestStartDialog(env);
      }
    } else if (qs.getStatus() == QuestStatus.START) {
      int var = qs.getQuestVarById(0);
      if (targetId == 204824) {
        switch (dialog) {
          case QUEST_SELECT:
            if (var == 0) return sendQuestDialog(env, 1011);
          case SETPRO1:
            if (var == 0) {
              qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
              updateQuestStatus(env);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
              final Npc npc = (Npc) env.getVisibleObject();
              ThreadPoolManager.getInstance()
                  .schedule(
                      new Runnable() {
                        @Override
                        public void run() {
                          npc.getController().onDelete();
                        }
                      },
                      40000);
              return true;
            }
        }
      }
      if (targetId == 700323) { // Hugh mamut skull
        switch (dialog) {
          case USE_OBJECT:
            if (var == 0) {
              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() {
                          @SuppressWarnings("unused")
                          final QuestState qs = player.getQuestStateList().getQuestState(questId);
                          removeQuestItem(env, 182204498, 1);
                          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);
                          QuestService.addNewSpawn(
                              220040000,
                              1,
                              204824,
                              (float) 2851.698,
                              (float) 160.88698,
                              (float) 301.78537,
                              (byte) 93);
                        }
                      },
                      3000);
            }
        }
      }
      if (targetId == 204787) { // Chieftain Akagitan
        switch (dialog) {
          case USE_OBJECT:
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 10002);
          case SELECT_QUEST_REWARD:
            return sendQuestDialog(env, 5);
        }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 204787) return sendQuestEndDialog(env);
    }
    return false;
  }
Exemple #28
0
 @Override
 public void onFail(Player player, String message) {
   PacketSendUtility.sendMessage(player, "syntax //ranking update");
 }
 @Override
 public void onFail(Player admin, String message) {
   PacketSendUtility.sendMessage(
       admin, "Syntax: //token <playername> || //token show <playername>");
 }
  /** {@inheritDoc} */
  @Override
  protected void runImpl() {
    Player player = getConnection().getActivePlayer();

    if (player.isProtectionActive()) {
      player.getController().stopProtectionActiveTask();
    }

    Item item = player.getInventory().getItemByObjId(uniqueItemId);
    Item targetItem = player.getInventory().getItemByObjId(targetItemId);
    HouseObject<?> targetHouseObject = null;

    if (item == null) {
      log.warn(
          String.format(
              "CHECKPOINT: null item use action: %d %d", player.getObjectId(), uniqueItemId));
      return;
    }

    if (targetItem == null) targetItem = player.getEquipment().getEquippedItemByObjId(targetItemId);
    if (targetItem == null && player.getHouseRegistry() != null)
      targetHouseObject = player.getHouseRegistry().getObjectByObjId(targetItemId);

    if (item.getItemTemplate().getTemplateId() == 165000001
        && targetItem.getItemTemplate().canExtract()) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_ITEM_COLOR_ERROR);
      return;
    }

    // check use item multicast delay exploit cast (spam)
    if (player.isCasting()) {
      // PacketSendUtility.sendMessage(this.getOwner(),
      // "You must wait until cast time finished to use skill again.");
      player.getController().cancelCurrentSkill();
      // On retail the item is cancelling the current skill and then procs normally
      // return;
    }

    if (!RestrictionsManager.canUseItem(player, item)) return;

    if (item.getItemTemplate().getRace() != Race.PC_ALL
        && item.getItemTemplate().getRace() != player.getRace()) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_CANNOT_USE_ITEM_INVALID_RACE);
      return;
    }

    int requiredLevel =
        item.getItemTemplate().getRequiredLevel(player.getCommonData().getPlayerClass());
    if (requiredLevel == -1) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_CANNOT_USE_ITEM_INVALID_CLASS);
      return;
    }

    if (requiredLevel > player.getLevel()) {
      PacketSendUtility.sendPacket(
          player,
          SM_SYSTEM_MESSAGE.STR_CANNOT_USE_ITEM_TOO_LOW_LEVEL_MUST_BE_THIS_LEVEL(
              item.getNameId(), requiredLevel));
      return;
    }

    HandlerResult result =
        QuestEngine.getInstance().onItemUseEvent(new QuestEnv(null, player, 0, 0), item);
    if (result == HandlerResult.FAILED) return; // don't remove item

    ItemActions itemActions = item.getItemTemplate().getActions();
    ArrayList<AbstractItemAction> actions = new ArrayList<AbstractItemAction>();

    if (itemActions == null) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_ITEM_IS_NOT_USABLE);
      return;
    }

    for (AbstractItemAction itemAction : itemActions.getItemActions()) {
      // check if the item can be used before placing it on the cooldown list.
      if (targetHouseObject != null && itemAction instanceof IHouseObjectDyeAction) {
        IHouseObjectDyeAction action = (IHouseObjectDyeAction) itemAction;
        if (action != null && action.canAct(player, item, targetHouseObject))
          actions.add(itemAction);
      } else if (itemAction.canAct(player, item, targetItem)) actions.add(itemAction);
    }

    if (actions.size() == 0) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_ITEM_IS_NOT_USABLE);
      return;
    }

    // Store Item CD in server Player variable.
    // Prevents potion spamming, and relogging to use kisks/aether jelly/long CD items.
    ItemUseLimits limits = item.getItemTemplate().getUseLimits();
    if (player.isItemUseDisabled(limits)) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_ITEM_CANT_USE_UNTIL_DELAY_TIME);
      return;
    }

    if (limits.getGenderPermitted() != null && limits.getGenderPermitted() != player.getGender()) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_CANNOT_USE_ITEM_INVALID_GENDER);
      return;
    }
    int useDelay = player.getItemCooldown(item.getItemTemplate());
    if (useDelay > 0) {
      player.addItemCoolDown(
          item.getItemTemplate().getUseLimits().getDelayId(),
          System.currentTimeMillis() + useDelay,
          useDelay / 1000);
    }

    // notify item use observer
    player.getObserveController().notifyItemuseObservers(item);

    for (AbstractItemAction itemAction : actions) {
      if (targetHouseObject != null && itemAction instanceof IHouseObjectDyeAction) {
        IHouseObjectDyeAction action = (IHouseObjectDyeAction) itemAction;
        action.act(player, item, targetHouseObject);
      } else if (type == 6) {

        // Multi Returns Items (Scroll Teleporter)
        if (itemAction instanceof MultiReturnAction) {
          MultiReturnAction action = (MultiReturnAction) itemAction;
          int SelectedMapIndex = returnId;
          action.act(player, item, SelectedMapIndex);
        }
      } else {
        itemAction.act(player, item, targetItem);
      }
    }
    PacketSendUtility.sendPacket(
        player,
        SM_SYSTEM_MESSAGE.STR_USE_ITEM(new DescriptionId(item.getItemTemplate().getNameId())));
  }