private void givePormanders(L2PcInstance player) { final int index = getTransferClassIndex(player); if (index >= 0) { QuestState st = player.getQuestState(qn); if (st == null) { st = newQuestState(player); } final String name = qn + String.valueOf(player.getClassId().getId()); if (st.getInt(name) == 0) { st.setInternal(name, "1"); if (st.getGlobalQuestVar(name).isEmpty()) { st.saveGlobalQuestVar(name, "1"); player.addItem(qn, PORMANDERS[index].getId(), PORMANDERS[index].getCount(), null, true); } } if (Config.SKILL_CHECK_ENABLE && (!player.isGM() || Config.SKILL_CHECK_GM)) { long count = PORMANDERS[index].getCount() - player.getInventory().getInventoryItemCount(PORMANDERS[index].getId(), -1, false); for (L2Skill sk : player.getAllSkills()) { for (L2SkillLearn s : SkillTreesData.getInstance().getTransferSkillTree(player.getClassId()).values()) { if (s.getSkillId() == sk.getId()) { // Holy Weapon allowed for Shilien Saint/Inquisitor stance if ((sk.getId() == 1043) && (index == 2) && player.isInStance()) { continue; } count--; if (count < 0) { Util.handleIllegalPlayerAction( player, "Player " + player.getName() + " has too many transfered skills or items, skill:" + s.getName() + " (" + sk.getId() + "/" + sk.getLevel() + "), class:" + player.getTemplate().className, 1); if (Config.SKILL_CHECK_REMOVE) { player.removeSkill(sk); } } } } } } } }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = getNoQuestMsg(player); QuestState st = player.getQuestState(qn); if (st == null) return htmltext; if (npc.getNpcId() == JAKAN) { switch (st.getState()) { case State.CREATED: if (player.getLevel() >= 84) htmltext = "32773-1.htm"; else htmltext = "32773-0.htm"; break; case State.STARTED: if (st.getInt("cond") == 1) htmltext = "32773-4.htm"; else if (st.getInt("cond") == 2) { htmltext = "32773-5.htm"; st.unset("cond"); st.takeItems(TAG_ID, 1); st.giveItems(57, 95200); st.addExpAndSp(435024, 50366); st.playSound("ItemSound.quest_finish"); st.exitQuest(false); Calendar reDo = Calendar.getInstance(); reDo.set(Calendar.MINUTE, RESET_MIN); if (reDo.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR) reDo.add(Calendar.DATE, 1); reDo.set(Calendar.HOUR_OF_DAY, RESET_HOUR); st.set("reDoTime", String.valueOf(reDo.getTimeInMillis())); } break; case State.COMPLETED: Long reDoTime = Long.parseLong(st.get("reDoTime")); if (reDoTime > System.currentTimeMillis()) htmltext = "32773-6.htm"; else { st.setState(State.CREATED); if (player.getLevel() >= 84) htmltext = "32773-1.htm"; else htmltext = "32773-0.htm"; } break; } } else if (Util.contains(SOLDIER_CORPSES, npc.getNpcId())) { if (st.getInt("cond") == 1) htmltext = "corpse-1.htm"; } return htmltext; }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmltext = event; QuestState st = player.getQuestState(qn); if (st == null) return htmltext; if (npc.getNpcId() == JAKAN) { if (event.equalsIgnoreCase("32773-3.htm")) { st.setState(State.STARTED); st.set("cond", "1"); st.playSound("ItemSound.quest_accept"); } } else if (Util.contains(SOLDIER_CORPSES, npc.getNpcId())) { if (st.getInt("cond") == 1) { st.giveItems(TAG_ID, 1); st.set("cond", "2"); st.playSound("ItemSound.quest_middle"); npc.deleteMe(); } else htmltext = getNoQuestMsg(player); } return htmltext; }
private static void load() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setIgnoringComments(true); for (File file : Util.getDatapackFiles("mapregion", ".xml")) { try { Document doc = factory.newDocumentBuilder().parse(file); for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { if ("list".equalsIgnoreCase(n.getNodeName())) { for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) { if ("region".equalsIgnoreCase(d.getNodeName())) { NamedNodeMap attrs = d.getAttributes(); Node att; String name = ""; String town = ""; int locId = -1; int castle = -1; int bbs = -1; att = attrs.getNamedItem("name"); if (att == null) { _log.severe("Missing name for MapRegion, skipping"); continue; } name = att.getNodeValue(); att = attrs.getNamedItem("town"); if (att == null) { _log.severe("Missing town for MapRegion name: " + name + ", skipping"); continue; } town = att.getNodeValue(); att = attrs.getNamedItem("locId"); if (att == null) { _log.severe("Missing locId for MapRegion name: " + name + ", skipping"); continue; } locId = Integer.parseInt(att.getNodeValue()); att = attrs.getNamedItem("castle"); if (att == null) { _log.severe("Missing castle for MapRegion name: " + name + ", skipping"); continue; } castle = Integer.parseInt(att.getNodeValue()); att = attrs.getNamedItem("bbs"); if (att == null) { _log.severe("Missing bbs for MapRegion name: " + name + ", skipping"); continue; } bbs = Integer.parseInt(att.getNodeValue()); L2MapRegion region = new L2MapRegion(name, town, locId, castle, bbs); for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling()) { if ("respawnPoint".equalsIgnoreCase(c.getNodeName())) { attrs = c.getAttributes(); int spawnX = Integer.parseInt(attrs.getNamedItem("X").getNodeValue()); int spawnY = Integer.parseInt(attrs.getNamedItem("Y").getNodeValue()); int spawnZ = Integer.parseInt(attrs.getNamedItem("Z").getNodeValue()); Node val = attrs.getNamedItem("isOther"); boolean other = val != null && Boolean.parseBoolean(val.getNodeValue()); val = attrs.getNamedItem("isChaotic"); boolean chaotic = val != null && Boolean.parseBoolean(val.getNodeValue()); val = attrs.getNamedItem("isBanish"); boolean banish = val != null && Boolean.parseBoolean(val.getNodeValue()); if (other) region.addOtherSpawn(spawnX, spawnY, spawnZ); else if (chaotic) region.addChaoticSpawn(spawnX, spawnY, spawnZ); else if (banish) region.addBanishSpawn(spawnX, spawnY, spawnZ); else region.addSpawn(spawnX, spawnY, spawnZ); } else if ("map".equalsIgnoreCase(c.getNodeName())) { attrs = c.getAttributes(); int mapX = Integer.parseInt(attrs.getNamedItem("X").getNodeValue()); int mapY = Integer.parseInt(attrs.getNamedItem("Y").getNodeValue()); region.addMap(mapX, mapY); } else if ("banned".equalsIgnoreCase(c.getNodeName())) { attrs = c.getAttributes(); String race = attrs.getNamedItem("race").getNodeValue(); String point = attrs.getNamedItem("point").getNodeValue(); region.addBannedRace(race, point); } } _regions.put(name, region); } } } } } catch (Exception e) { _log.severe("MapRegion file (" + file.getAbsolutePath() + ") doesnt exists."); } } }