public void switchStoragesItems( Player player, int sourceStorageType, int sourceItemObjId, int replaceStorageType, int replaceItemObjId) { Storage sourceStorage = player.getStorage(sourceStorageType); Storage replaceStorage = player.getStorage(replaceStorageType); Item sourceItem = sourceStorage.getItemByObjId(sourceItemObjId); if (sourceItem == null) return; Item replaceItem = replaceStorage.getItemByObjId(replaceItemObjId); if (replaceItem == null) return; int sourceSlot = sourceItem.getEquipmentSlot(); int replaceSlot = replaceItem.getEquipmentSlot(); sourceItem.setEquipmentSlot(replaceSlot); replaceItem.setEquipmentSlot(sourceSlot); sourceStorage.removeFromBag(sourceItem, false); replaceStorage.removeFromBag(replaceItem, false); Item newSourceItem = sourceStorage.putToBag(replaceItem); Item newReplaceItem = replaceStorage.putToBag(sourceItem); sendDeleteItemPacket(player, sourceStorageType, sourceItemObjId); sendStorageUpdatePacket(player, sourceStorageType, newSourceItem); sendDeleteItemPacket(player, replaceStorageType, replaceItemObjId); sendStorageUpdatePacket(player, replaceStorageType, newReplaceItem); }
/** * Check if the skill can be used * * @return True if the skill can be used */ public boolean canUseSkill() { Properties properties = skillTemplate.getProperties(); if (properties != null && !properties.validate(this)) { log.debug("properties failed"); return false; } if (!preCastCheck()) return false; // check for counter skill if (effector instanceof Player) { Player player = (Player) effector; if (this.skillTemplate.getCounterSkill() != null) { long time = player.getLastCounterSkill(skillTemplate.getCounterSkill()); if ((time + 5000) < System.currentTimeMillis()) { log.debug("chain skill failed, too late"); return false; } } if (skillMethod == SkillMethod.ITEM && duration > 0 && player.getMoveController().isInMove()) { PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_ITEM_CANCELED(new DescriptionId(getItemTemplate().getNameId()))); return false; } } if (!validateEffectedList()) return false; 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(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (targetId == 203607) { if (qs == null) { if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1011); else return sendQuestStartDialog(env); } } else if (targetId == 203609) { 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) { return defaultCloseDialog(env, 0, 1); // 1 } else return sendQuestStartDialog(env); } } else if (targetId == 203631) { 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.COMPLETE && qs.getStatus() != QuestStatus.NONE) { qs.setQuestVar(2); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); return sendQuestEndDialog(env); } else return sendQuestEndDialog(env); } } return false; }
@Override public boolean onEnterWorldEvent(QuestEnv env) { Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs != null && qs.getStatus() == QuestStatus.START) { int var = qs.getQuestVars().getQuestVars(); if (player.getWorldId() != 320070000) { if (var >= 95 && var <= 99) { removeStigma(env); qs.setQuestVar(4); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_SYSTEM_MESSAGE( SystemMessageId.QUEST_FAILED_$1, DataManager.QUEST_DATA.getQuestById(questId).getName())); return true; } else if (var == 9) { removeStigma(env); return true; } } } return false; }
private void removeStigma(QuestEnv env) { Player player = env.getPlayer(); for (Item item : player.getEquipment().getEquippedItemsByItemId(getStoneId(player))) { player.getEquipment().unEquipItem(item.getObjectId(), 0); } removeQuestItem(env, getStoneId(player), 1); }
@Override public boolean onDialogEvent(QuestEnv env) { final Player player = env.getPlayer(); final QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs == null) return false; int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); if (targetId != 204301) return false; if (qs.getStatus() == QuestStatus.START) { if (env.getDialogId() == 25) { qs.setQuestVar(1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(player, qs); return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1011); } else return defaultQuestStartDialog(env); } else if (qs.getStatus() == QuestStatus.REWARD) { if (env.getDialogId() == 17) { int[] ids = {2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042}; for (int id : ids) { QuestService.startQuest( new QuestEnv(env.getVisibleObject(), env.getPlayer(), id, env.getDialogId()), QuestStatus.LOCKED); } } return defaultQuestEndDialog(env); } return false; }
@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 boolean onDialogEvent(QuestEnv env) { Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); DialogAction dialog = env.getDialog(); int targetId = env.getTargetId(); if (qs == null || qs.getStatus() == QuestStatus.NONE) { if (targetId == 0) { if (dialog == DialogAction.QUEST_ACCEPT_1) { QuestService.startQuest(env); return closeDialogWindow(env); } } else if (targetId == 700009) { return giveQuestItem(env, 182200559, 1); } } else if (qs.getStatus() == QuestStatus.START) { if (targetId == 203098) { if (dialog == DialogAction.QUEST_SELECT) { return sendQuestDialog(env, 2375); } else if (dialog == DialogAction.SELECT_QUEST_REWARD) { removeQuestItem(env, 182213168, 1); return defaultCloseDialog(env, 0, 1, true, true); } } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 203098) { return sendQuestEndDialog(env); } } return false; }
public boolean onKillEvent(QuestEnv env) { /** Checks * */ 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) return false; switch (targetId) { case 210715: // Brute if (var > 0 && var < 4) // En tuer 4 { qs.setQuestVarById(0, var + 1); updateQuestStatus(player, qs); return true; } else if (var == 4) // Au 4eme REWARD { qs.setStatus(QuestStatus.REWARD); updateQuestStatus(player, qs); return true; } } return false; }
@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; }
public void moveItem( Player player, int itemObjId, int sourceStorageType, int destinationStorageType, int slot) { Storage sourceStorage = player.getStorage(sourceStorageType); Item item = player.getStorage(sourceStorageType).getItemByObjId(itemObjId); if (item == null) return; item.setEquipmentSlot(slot); if (sourceStorageType == destinationStorageType) return; Storage destinationStorage = player.getStorage(destinationStorageType); List<Item> existingItems = destinationStorage.getItemsByItemId(item.getItemTemplate().getTemplateId()); int count = item.getItemCount(); int maxStackCount = item.getItemTemplate().getMaxStackCount(); for (Item existingItem : existingItems) { if (count == 0) break; int freeCount = maxStackCount - existingItem.getItemCount(); if (count <= freeCount) { existingItem.increaseItemCount(count); count = 0; sendDeleteItemPacket(player, sourceStorageType, item.getObjectId()); sourceStorage.removeFromBag(item, true); } else { existingItem.increaseItemCount(freeCount); count -= freeCount; } sendStorageUpdatePacket(player, destinationStorageType, existingItem); } while (!destinationStorage.isFull() && count > 0) { // item count still more than maxStack value if (count > maxStackCount) { count -= maxStackCount; Item newitem = newItem(item.getItemTemplate().getTemplateId(), maxStackCount); newitem = destinationStorage.putToBag(newitem); sendStorageUpdatePacket(player, destinationStorageType, newitem); } else { item.setItemCount(count); sourceStorage.removeFromBag(item, false); sendDeleteItemPacket(player, sourceStorageType, item.getObjectId()); Item newitem = destinationStorage.putToBag(item); sendStorageUpdatePacket(player, destinationStorageType, newitem); count = 0; } } if (count > 0) // if storage is full and some items left { item.setItemCount(count); sendUpdateItemPacket(player, sourceStorageType, item); } }
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 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 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; }
private static float movementDamageBonus(Creature creature, float value) { if (!(creature instanceof Player)) { return value; } Player player = (Player) creature; int h = player.getMoveController().getMovementHeading(); if (h < 0) { return value; } switch (h) { case 7: case 0: case 1: value = value * 1.1f; break; case 6: case 2: value -= value * 0.2f; break; case 5: case 4: case 3: value -= value * 0.2f; break; } return value; }
@Override public boolean onDialogEvent(QuestEnv env) { Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); DialogAction dialog = env.getDialog(); int targetId = env.getTargetId(); if (qs == null || qs.getStatus() == QuestStatus.NONE) { if (targetId == 799336) { // Tataka if (player.getInventory().getItemCountByItemId(102000690) >= 1) { // Noble Siel's Supreme Mace if (dialog == DialogAction.QUEST_SELECT) { return sendQuestDialog(env, 4762); } else { return sendQuestStartDialog(env); } } } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 799336) { // Tataka if (dialog == DialogAction.USE_OBJECT) { if (player.getInventory().getItemCountByItemId(182213290) > 0) { return sendQuestDialog(env, 10002); } } else { removeQuestItem(env, 182213290, 1); return sendQuestEndDialog(env); } } } return false; }
@Override public boolean onDialogEvent(QuestEnv env) { Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); DialogAction dialog = env.getDialog(); int targetId = env.getTargetId(); if (qs == null || qs.getStatus() == QuestStatus.NONE) { if (targetId == 0) { if (dialog == DialogAction.QUEST_ACCEPT_1) { removeQuestItem(env, 182206844, 1); QuestService.startQuest(env); return closeDialogWindow(env); } } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 799049) { if (dialog == DialogAction.USE_OBJECT) { return sendQuestDialog(env, 10002); } else if (dialog == DialogAction.SELECT_ACTION_2034) { return sendQuestDialog(env, 2034); } else if (dialog == DialogAction.SELECT_QUEST_REWARD) { if (player.getInventory().getKinah() >= 20000000) { player.getInventory().decreaseKinah(20000000); return sendQuestDialog(env, 5); } else return sendQuestDialog(env, 3739); } else return sendQuestEndDialog(env); } } return false; }
@Override public void storeCraftCooldowns(final Player player) { deleteCraftCoolDowns(player); Map<Integer, Long> craftCoolDowns = player.getCraftCooldownList().getCraftCoolDowns(); if (craftCoolDowns == null) { return; } for (Map.Entry<Integer, Long> entry : craftCoolDowns.entrySet()) { final int delayId = entry.getKey(); final long reuseTime = entry.getValue(); if (reuseTime < System.currentTimeMillis()) { continue; } Connection con = null; try { con = DatabaseFactory.getConnection(); PreparedStatement stmt = con.prepareStatement(INSERT_QUERY); stmt.setInt(1, player.getObjectId()); stmt.setInt(2, delayId); stmt.setLong(3, reuseTime); stmt.execute(); } catch (SQLException e) { log.error("storecraftCoolDowns", e); } finally { DatabaseFactory.close(con); } } }
@Override public boolean onDialogEvent(QuestEnv env) { final Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); int targetId = env.getTargetId(); DialogAction dialog = env.getDialog(); if (qs == null || qs.getStatus() == QuestStatus.NONE) { if (targetId == 801022) { switch (dialog) { case QUEST_SELECT: { return sendQuestDialog(env, 1011); } case QUEST_ACCEPT_SIMPLE: { return sendQuestStartDialog(env, 182213313, 1); } } } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 801022) { if (dialog == DialogAction.USE_OBJECT) { return sendQuestDialog(env, 2375); } else { 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 (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 == 203075) { if (qs != null) { if (env.getDialogId() == 25 && qs.getStatus() == QuestStatus.START) { return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375); } else if (env.getDialogId() == 1009) { player.getInventory().removeFromBagByItemId(182200501, 1); qs.setQuestVar(1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(player, qs); return defaultQuestEndDialog(env); } else return defaultQuestEndDialog(env); } } return false; }
@Override public void loadCraftCooldowns(final Player player) { Connection con = null; FastMap<Integer, Long> craftCoolDowns = new FastMap<Integer, Long>(); try { con = DatabaseFactory.getConnection(); PreparedStatement stmt = con.prepareStatement(SELECT_QUERY); stmt.setInt(1, player.getObjectId()); ResultSet rset = stmt.executeQuery(); while (rset.next()) { int delayId = rset.getInt("delay_id"); long reuseTime = rset.getLong("reuse_time"); int delay = (int) ((reuseTime - System.currentTimeMillis()) / 1000); if (delay > 0) { craftCoolDowns.put(delayId, reuseTime); } } player.getCraftCooldownList().setCraftCoolDowns(craftCoolDowns); rset.close(); stmt.close(); } catch (SQLException e) { log.error("LoadcraftCoolDowns", e); } finally { DatabaseFactory.close(con); } }
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); }
/** Instance will be destroyed All players moved to bind location All objects - deleted */ private static void destroyInstance(WorldMapInstance instance) { instance.getEmptyInstanceTask().cancel(false); int worldId = instance.getMapId(); int instanceId = instance.getInstanceId(); WorldMap map = World.getInstance().getWorldMap(worldId); map.removeWorldMapInstance(instanceId); log.info("Destroying instance:" + worldId + " " + instanceId); Iterator<VisibleObject> it = instance.objectIterator(); while (it.hasNext()) { VisibleObject obj = it.next(); if (obj instanceof Player) { Player player = (Player) obj; PortalTemplate portal = DataManager.PORTAL_DATA.getInstancePortalTemplate( worldId, player.getCommonData().getRace()); moveToEntryPoint((Player) obj, portal, true); } else { obj.getController().delete(); } } }
@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; }
@Override public void executeCommand(Player admin, String[] params) { if (admin.getAccessLevel() < AdminConfig.COMMAND_PRISON) { PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command!"); return; } if (params.length == 0 || params.length > 2) { PacketSendUtility.sendMessage(admin, "syntax //rprison <player>"); return; } try { Player playerFromPrison = World.getInstance().findPlayer(Util.convertName(params[0])); if (playerFromPrison != null) { PunishmentService.setIsInPrison(playerFromPrison, false, 0); PacketSendUtility.sendMessage( admin, "Player " + playerFromPrison.getName() + " removed from prison."); } } catch (NoSuchElementException nsee) { PacketSendUtility.sendMessage(admin, "Usage: //rprison <player>"); } catch (Exception e) { PacketSendUtility.sendMessage(admin, "Usage: //rprison <player>"); } }
/** * Stores newly created player * * @param player player to store * @return true if character was successful saved. */ public static boolean storeNewPlayer(Player player, String accountName, int accountId) { return DAOManager.getDAO(PlayerDAO.class) .saveNewPlayer(player.getCommonData(), accountId, accountName) && DAOManager.getDAO(PlayerAppearanceDAO.class).store(player) && DAOManager.getDAO(PlayerSkillListDAO.class).storeSkills(player) && DAOManager.getDAO(InventoryDAO.class).store(player.getDirtyItemsToUpdate()) && DAOManager.getDAO(PlayerTitleListDAO.class).storeTitles(player); }
public void sendAnnounce() { if (isMaster && getOwner().isSpawned()) { WorldMapInstance worldInstance = getOwner().getPosition().getMapRegion().getParent(); for (Player player : worldInstance.getAllWorldMapPlayers()) { if (player.isSpawned()) sendMessage(player); } } }
@Override public boolean onDialogEvent(QuestEnv env) { Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs == null) return false; int var = qs.getQuestVarById(0); int targetId = env.getTargetId(); DialogAction dialog = env.getDialog(); if (qs.getStatus() == QuestStatus.START) { if (targetId == 203518) { // Boromer switch (dialog) { case QUEST_SELECT: { if (var == 0) { return sendQuestDialog(env, 1011); } else if (var == 1) { return sendQuestDialog(env, 1352); } else if (var == 2) { return sendQuestDialog(env, 1694); } } case SELECT_ACTION_1012: { playQuestMovie(env, 51); return sendQuestDialog(env, 1012); } case SETPRO1: { return defaultCloseDialog(env, 0, 1); // 1 } case SETPRO3: { return defaultCloseDialog(env, 2, 3); // 3 } case CHECK_USER_HAS_QUEST_ITEM: { return checkQuestItems(env, 1, 2, false, 1694, 1693); } case FINISH_DIALOG: { return sendQuestSelectionDialog(env); } } } else if (targetId == 700093) { return true; // just give quest drop on use } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 203518) { // Boromer if (dialog == DialogAction.USE_OBJECT) { return sendQuestDialog(env, 2034); } else { return sendQuestEndDialog(env); } } } return false; }
@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; }
@Override public HandlerResult onItemUseEvent(QuestEnv env, Item item) { Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs == null || qs.getStatus() == QuestStatus.NONE) { return HandlerResult.fromBoolean(sendQuestDialog(env, 4)); } return HandlerResult.FAILED; }