@Override public boolean eventBypass(L2PcInstance activeChar, String bypass) { if (bypass.startsWith("skill")) { if (_isRaceStarted) { activeChar.sendMessage("Race already started, you cannot change transform skill now"); } else { int _number = Integer.valueOf(bypass.substring(5)); Skill _sk = SkillData.getInstance().getSkill(_number, 1); if (_sk != null) { _skill = _number; activeChar.sendMessage("Transform skill set to:"); activeChar.sendMessage(_sk.getName()); } else { activeChar.sendMessage("Error while changing transform skill"); } } } else if (bypass.startsWith("tele")) { if ((Integer.valueOf(bypass.substring(4)) > 0) && (_randspawn != null)) { activeChar.teleToLocation(_randspawn[0], _randspawn[1], _randspawn[2]); } else { activeChar.teleToLocation(18429, 145861, -3090); } } showMenu(activeChar); return true; }
/** * Get all the spawn of a NPC. * * @param activeChar * @param npcId * @param teleportIndex * @param showposition */ private void findNPCInstances( L2PcInstance activeChar, int npcId, int teleportIndex, boolean showposition) { int index = 0; for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(npcId)) { index++; L2Npc npc = spawn.getLastSpawn(); if (teleportIndex > -1) { if (teleportIndex == index) { if (showposition && (npc != null)) { activeChar.teleToLocation(npc.getLocation(), true); } else { activeChar.teleToLocation(spawn.getLocation(), true); } } } else { if (showposition && (npc != null)) { activeChar.sendMessage( index + " - " + spawn.getTemplate().getName() + " (" + spawn + "): " + npc.getX() + " " + npc.getY() + " " + npc.getZ()); } else { activeChar.sendMessage( index + " - " + spawn.getTemplate().getName() + " (" + spawn + "): " + spawn.getX() + " " + spawn.getY() + " " + spawn.getZ()); } } } if (index == 0) { activeChar.sendMessage(getClass().getSimpleName() + ": No current spawns found."); } }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { if (npc.getId() == NPCS[0]) // Pathfinder Worker { final L2TownZone town = TownManager.getTown(npc.getX(), npc.getY(), npc.getZ()); final int townId = ((town == null) ? 0 : town.getTownId()); player.getVariables().set(DELUSION_RETURN, townId); player.teleToLocation(HALL_LOCATIONS[getRandom(HALL_LOCATIONS.length)], false); } else { final int townId = player.getVariables().getInt(DELUSION_RETURN, 0); player.teleToLocation(RETURN_LOCATIONS.get(townId), true); player.getVariables().remove(DELUSION_RETURN); } return super.onTalk(npc, player); }
@Override public boolean useBypass(String command, L2PcInstance player, L2Character bypassOrigin) { final QuestState qs = getQuestState(player, false); if ((qs != null) || (player.getLevel() < MIN_LEVEL) || (player.getLevel() > MAX_LEVEL) || (player.getRace() == Race.ERTHEIA) || !command.equals("Q10390_Teleport")) { return false; } if (player.isInParty()) { player.sendPacket( new ExShowScreenMessage("You cannot teleport when you are in party.", 5000)); } else if (player.isInCombat()) { player.sendPacket( new ExShowScreenMessage("You cannot teleport when you are in combat.", 5000)); } else if (player.isInDuel()) { player.sendPacket( new ExShowScreenMessage("You cannot teleport when you are in a duel.", 5000)); } else if (player.isInOlympiadMode()) { player.sendPacket( new ExShowScreenMessage("You cannot teleport when you are in Olympiad.", 5000)); } else if (player.isInVehicle()) { player.sendPacket( new ExShowScreenMessage( "You cannot teleport when you are in any vehicle or mount.", 5000)); } else { player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); player.teleToLocation(TP_LOCS[player.getRace().ordinal()]); } return true; }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = ""; boolean hellboundLock = HellboundManager.getInstance().isLocked(); QuestState st1 = player.getQuestState("133_ThatsBloodyHot"); QuestState st2 = player.getQuestState("130_PathToHellbound"); if (st1 != null) { if (st1.getState() == State.COMPLETED) player.teleToLocation(-11272, 236464, -3248); else htmltext = "cant-port.htm"; } else if (st2 != null) { if (st2.getState() == State.COMPLETED && hellboundLock) player.teleToLocation(-11272, 236464, -3248); else htmltext = "cant-port.htm"; } else htmltext = "cant-port.htm"; return htmltext; }
private void removeAllPlayers(int managerId) { if (ZONES.containsKey(managerId) && (ZoneManager.getInstance().getZoneById(ZONES.get(managerId)) != null)) { L2ZoneType zone = ZoneManager.getInstance().getZoneById(ZONES.get(managerId)); for (L2PcInstance player : zone.getPlayersInside()) { if (player != null) { player.teleToLocation(16110, 243841, 11616); } } } }
/** Teleports all players to a free arena. */ public void teleportPlayers() { if (!_partyDuel) { return; } final String instanceName = DuelManager.getInstance().getDuelArena(); final L2OlympiadStadiumZone zone = ZoneManager.getInstance() .getAllZones(L2OlympiadStadiumZone.class) // .stream() .filter(z -> z.getInstanceTemplate().equals(instanceName)) .findFirst() .orElse(null); if (zone == null) { throw new RuntimeException("Unable to find a party duel arena!"); } final List<Location> spawns = zone.getSpawns(); _duelInstanceId = InstanceManager.getInstance().createDynamicInstance(instanceName); // Remove Olympiad buffers for (L2Npc buffer : InstanceManager.getInstance().getInstance(getDueldInstanceId()).getNpcs()) { if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isVisible()) { buffer.decayMe(); } } final Location spawn1 = spawns.get(Rnd.get(spawns.size() / 2)); for (L2PcInstance temp : _playerA.getParty().getMembers()) { temp.teleToLocation(spawn1.getX(), spawn1.getY(), spawn1.getZ(), 0, _duelInstanceId, 0); } final Location spawn2 = spawns.get(Rnd.get(spawns.size() / 2, spawns.size())); for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.teleToLocation(spawn2.getX(), spawn2.getY(), spawn2.getZ(), 0, _duelInstanceId, 0); } }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmltext = ""; QuestState st = player.getQuestState(getName()); if (st == null) st = newQuestState(player); if (st.hasQuestItems(7267)) { // st.takeItems(7267, 1); // No longer consumed in h5 player.teleToLocation(183813, -115157, -3303); st.set("allowEnter", "1"); } else htmltext = "31540-06.htm"; return htmltext; }
private void removeForeigners(int managerId, L2Party party) { if ((party != null) && ZONES.containsKey(managerId) && (ZoneManager.getInstance().getZoneById(ZONES.get(managerId)) != null)) { L2ZoneType zone = ZoneManager.getInstance().getZoneById(ZONES.get(managerId)); for (L2PcInstance player : zone.getPlayersInside()) { if (player != null) { L2Party charParty = player.getParty(); if ((charParty == null) || (charParty.getLeaderObjectId() != party.getLeaderObjectId())) { player.teleToLocation(16110, 243841, 11616); } } } } }
@Override public String onTalk(L2Npc npc, L2PcInstance talker) { final QuestState qs = talker.getQuestState(Q00196_SevenSignsSealOfTheEmperor.class.getSimpleName()); String htmltext = getNoQuestMsg(talker); if (qs == null) { return htmltext; } switch (npc.getId()) { case PROMISE_OF_MAMMON: { if (qs.isCond(3) || qs.isCond(4)) { enterInstance(talker, new DNPWorld(), "DisciplesNecropolisPast.xml", TEMPLATE_ID); return ""; } break; } case LEON: { if (qs.getCond() >= 3) { takeItems(talker, SACRED_SWORD_OF_EINHASAD, -1); InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(talker); world.removeAllowed(talker.getObjectId()); talker.teleToLocation(EXIT, 0); htmltext = "32587-01.html"; } break; } case DISCIPLES_GATEKEEPER: { if (qs.getCond() >= 3) { InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId()); if (tmpworld instanceof DNPWorld) { DNPWorld world = (DNPWorld) tmpworld; openDoor(DISCIPLES_NECROPOLIS_DOOR, world.getInstanceId()); talker.showQuestMovie(12); startQuestTimer("FIGHT", 1000, null, talker); } } break; } } return htmltext; }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { if (event.equalsIgnoreCase("1")) { L2Npc machine_instance = findTemplate(STRANGE_MACHINE); if (machine_instance != null) { npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, machine_instance); machine_instance.broadcastPacket( new SpecialCamera( machine_instance.getObjectId(), 1, -200, 15, 10000, 20000, 0, 0, 1, 0)); } else // print "Dr Chaos AI: problem finding Strange Machine (npcid = "+STRANGE_MACHINE+"). Error: // not spawned!" startQuestTimer("2", 2000, npc, player); startQuestTimer("3", 10000, npc, player); } else if (event.equalsIgnoreCase("2")) npc.broadcastPacket(new SocialAction(npc, 3)); else if (event.equalsIgnoreCase("3")) { npc.broadcastPacket( new SpecialCamera(npc.getObjectId(), 1, -150, 10, 3000, 20000, 0, 0, 1, 0)); startQuestTimer("4", 2500, npc, player); } else if (event.equalsIgnoreCase("4")) { npc.getAI() .setIntention( CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(96055, -110759, -3312, 0)); startQuestTimer("5", 2000, npc, player); } else if (event.equalsIgnoreCase("5")) { player.teleToLocation(94832, -112624, -3304); npc.teleToLocation(-113091, -243942, -15536); if (!_IsGolemSpawned) { L2Npc golem = addSpawn(CHAOS_GOLEM, 94640, -112496, -3336, 0, false, 0); _IsGolemSpawned = true; startQuestTimer("6", 1000, golem, player); player.sendPacket(new PlaySound(1, "Rm03_A", 0, 0, 0, 0, 0)); } } else if (event.equalsIgnoreCase("6")) npc.broadcastPacket( new SpecialCamera(npc.getObjectId(), 30, -200, 20, 6000, 8000, 0, 0, 1, 0)); return super.onAdvEvent(event, npc, player); }
@Override public boolean eventStop() { // Don't stop inactive event if (!_isactive) { return false; } // Set inactive _isactive = false; _isRaceStarted = false; // Cancel task if any if (_eventTask != null) { _eventTask.cancel(true); _eventTask = null; } // Untransform players // Teleport to event start point for (L2PcInstance player : _players) { if ((player != null) && player.isOnline()) { player.untransform(); player.teleToLocation(_npc.getX(), _npc.getY(), _npc.getZ(), true); } } // Despawn NPCs for (L2Npc _npc : _npclist) { if (_npc != null) { _npc.deleteMe(); } } _npclist.clear(); _players.clear(); // Announce event end Broadcast.toAllOnlinePlayers("* Race Event finished *"); return true; }
@Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { int teleportIndex = -1; final AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false); final AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false); if (command.startsWith("admin_mammon_find")) { try { if (command.length() > 17) { teleportIndex = Integer.parseInt(command.substring(18)); } } catch (Exception NumberFormatException) { activeChar.sendMessage( "Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)"); return false; } if (!_isSealValidation) { activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY); return false; } if (blackSpawnInst != null) { final L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList(); if (blackInst.length > 0) { final int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1739].getMessage() + x1 + " " + y1 + " " + z1); if (teleportIndex == 1) { activeChar.teleToLocation(x1, y1, z1, true); } } } else { activeChar.sendMessage(1740); } if (merchSpawnInst != null) { final L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList(); if (merchInst.length > 0) { final int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1741].getMessage() + x2 + " " + y2 + " " + z2); if (teleportIndex == 2) { activeChar.teleToLocation(x2, y2, z2, true); } } } else { activeChar.sendMessage(1742); } } else if (command.startsWith("admin_mammon_respawn")) { if (!_isSealValidation) { activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY); return true; } if (merchSpawnInst != null) { long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst); activeChar.sendMessage( MessageTable.Messages[1743].getExtra(1) + (merchRespawn / 60000) + MessageTable.Messages[1743].getExtra(2)); } else { activeChar.sendMessage(1742); } if (blackSpawnInst != null) { long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst); activeChar.sendMessage( MessageTable.Messages[1744].getExtra(1) + (blackRespawn / 60000) + MessageTable.Messages[1744].getExtra(2)); } else { activeChar.sendMessage(1740); } } return true; }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player); if (tmpworld instanceof DNPWorld) { final DNPWorld world = (DNPWorld) tmpworld; switch (event) { case "FINISH": { if (getQuestItemsCount(player, SEAL_OF_BINDING) >= 4) { player.showQuestMovie(13); startQuestTimer("TELEPORT", 27000, null, player); } break; } case "TELEPORT": { player.teleToLocation(ENTER, 0); break; } case "FIGHT": { for (L2Npc caster : world.anakimGroup) { if ((caster != null) && !caster.isCastingNow()) { makeCast(caster, world.lilithGroup); } if ((caster != null) && (caster.getId() == ANAKIM)) { if (caster.isScriptValue(0)) { caster.broadcastPacket( new NpcSay( caster.getObjectId(), Say2.NPC_SHOUT, caster.getId(), NpcStringId .YOU_SUCH_A_FOOL_THE_VICTORY_OVER_THIS_WAR_BELONGS_TO_SHILIEN)); caster.setScriptValue(1); } else if (getRandom(100) < 10) { caster.broadcastPacket( new NpcSay( caster.getObjectId(), Say2.NPC_SHOUT, caster.getId(), LILITH_SHOUT[getRandom(3)])); } } } for (L2Npc caster : world.lilithGroup) { if ((caster != null) && !caster.isCastingNow()) { makeCast(caster, world.anakimGroup); } if ((caster != null) && (caster.getId() == 32715)) { if (caster.isScriptValue(0)) { caster.broadcastPacket( new NpcSay( caster.getObjectId(), Say2.NPC_SHOUT, caster.getId(), NpcStringId.FOR_THE_ETERNITY_OF_EINHASAD)); if (Util.checkIfInRange(2000, caster, player, true)) { player.sendPacket( new NpcSay( caster.getObjectId(), Say2.TELL, caster.getId(), NpcStringId.MY_POWERS_WEAKENING_HURRY_AND_TURN_ON_THE_SEALING_DEVICE)); } caster.setScriptValue(1); } else if (getRandom(100) < 10) { switch (getRandom(3)) { case 0: { caster.broadcastPacket( new NpcSay( caster.getObjectId(), Say2.NPC_SHOUT, caster.getId(), NpcStringId .DEAR_SHILLIENS_OFFSPRINGS_YOU_ARE_NOT_CAPABLE_OF_CONFRONTING_US)); if (Util.checkIfInRange(2000, caster, player, true)) { player.sendPacket( new NpcSay( caster.getObjectId(), Say2.TELL, caster.getId(), NpcStringId.ALL_4_SEALING_DEVICES_MUST_BE_TURNED_ON)); } break; } case 1: { caster.broadcastPacket( new NpcSay( caster.getObjectId(), Say2.NPC_SHOUT, caster.getId(), NpcStringId.ILL_SHOW_YOU_THE_REAL_POWER_OF_EINHASAD)); if (Util.checkIfInRange(2000, caster, player, true)) { player.sendPacket( new NpcSay( caster.getObjectId(), Say2.TELL, caster.getId(), NpcStringId .LILITHS_ATTACK_IS_GETTING_STRONGER_GO_AHEAD_AND_TURN_IT_ON)); } break; } case 2: { caster.broadcastPacket( new NpcSay( caster.getObjectId(), Say2.NPC_SHOUT, caster.getId(), NpcStringId .DEAR_MILITARY_FORCE_OF_LIGHT_GO_DESTROY_THE_OFFSPRINGS_OF_SHILLIEN)); if (Util.checkIfInRange(2000, caster, player, true)) { player.sendPacket( new NpcSay( caster.getObjectId(), Say2.TELL, caster.getId(), NpcStringId.DEAR_S1_GIVE_ME_MORE_STRENGTH) .addStringParameter(player.getName())); } break; } } } } startQuestTimer("FIGHT", 1000, null, player); } break; } } } return super.onAdvEvent(event, npc, player); }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { final QuestState st = player.getQuestState(getName()); if (st == null) { return null; } String htmltext = null; switch (event) { case "32264-04.html": { if (player.getLevel() >= MIN_LEVEL) { st.startQuest(); htmltext = event; } break; } case "32264-06.html": { if (st.isCond(1)) { htmltext = event; } break; } case "32264-07.html": { if (st.isCond(1)) { st.setCond(2); htmltext = event; } break; } case "32264-09.html": case "32264-10.html": case "32264-11.html": { if (st.isCond(2)) { htmltext = event; } break; } case "32264-12.html": { if (st.isCond(2)) { st.giveItems(ECHO_CRYSTAL_OF_FREE_THOUGHT, 1); st.setCond(3, true); htmltext = event; } break; } case "32264-14.html": case "32264-15.html": { if (st.isCond(3)) { htmltext = event; } break; } case "32264-17.html": { if (st.isCond(4) && st.hasQuestItems(PARMES_LETTER)) { st.takeItems(PARMES_LETTER, -1); st.setCond(5); htmltext = event; } break; } case "32264-19.html": { if (st.isCond(5) && st.hasQuestItems(ECHO_CRYSTAL_OF_FREE_THOUGHT)) { st.addExpAndSp(250677, 25019); st.giveItems(FIRE_STONE + getRandom(4), 4); st.exitQuest(false, true); htmltext = event; } break; } case "32271-03.html": { if (st.isCond(3)) { htmltext = event; } break; } case "32271-04.html": { if (st.isCond(3)) { st.giveItems(PARMES_LETTER, 1); st.setCond(4, true); player.setInstanceId(0); player.teleToLocation(INSTANCE_EXIT, true); htmltext = event; } break; } } return htmltext; }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { final Castle castle = npc.getCastle(); final StringTokenizer st = new StringTokenizer(event, " "); String htmltext = null; switch (st.nextToken()) { case "chamberlain-01.html": case "manor-help-01.html": case "manor-help-02.html": case "manor-help-03.html": case "manor-help-04.html": { htmltext = event; break; } case "fort_status": { if (npc.isMyLord(player)) { final StringBuilder sb = new StringBuilder(); final List<Integer> fort = FORTRESS.get(castle.getResidenceId()); for (int id : fort) { final Fort fortress = FortManager.getInstance().getFortById(id); final int fortId = fortress.getResidenceId(); final String fortType = (fortId < 112) ? "1300133" : "1300134"; final String fortStatus; switch (fortress.getFortState()) { case 1: fortStatus = "1300122"; break; case 2: fortStatus = "1300124"; break; default: fortStatus = "1300123"; break; } sb.append("<fstring>1300" + fortId + "</fstring>"); sb.append(" (<fstring>" + fortType + "</fstring>)"); sb.append( " : <font color=\"00FFFF\"><fstring>" + fortStatus + "</fstring></font><br>"); } final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-28.html"); html.replace("%list%", sb.toString()); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "siege_functions": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else if (!isDomainFortressInContractStatus(castle.getResidenceId())) { htmltext = "chamberlain-27.html"; } else if (!SevenSigns.getInstance().isCompResultsPeriod()) { htmltext = "chamberlain-26.html"; } else { htmltext = "chamberlain-12.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_doors": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (st.hasMoreTokens()) { final StringBuilder sb = new StringBuilder(); final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-13.html"); html.replace("%type%", st.nextToken()); while (st.hasMoreTokens()) { sb.append(" " + st.nextToken()); } html.replace("%doors%", sb.toString()); player.sendPacket(html); } else { htmltext = npc.getId() + "-du.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "upgrade_doors": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final int type = Integer.parseInt(st.nextToken()); final int level = Integer.parseInt(st.nextToken()); final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-14.html"); html.replace("%gate_price%", Integer.toString(getDoorUpgradePrice(type, level))); html.replace("%event%", event.substring("upgrade_doors".length() + 1)); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "upgrade_doors_confirm": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final int type = Integer.parseInt(st.nextToken()); final int level = Integer.parseInt(st.nextToken()); final int price = getDoorUpgradePrice(type, level); final int[] doors = new int[2]; for (int i = 0; i <= st.countTokens(); i++) { doors[i] = Integer.parseInt(st.nextToken()); } final L2DoorInstance door = castle.getDoor(doors[0]); if (door != null) { final int currentLevel = door.getStat().getUpgradeHpRatio(); if (currentLevel >= level) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-15.html"); html.replace("%doorlevel%", Integer.toString(currentLevel)); player.sendPacket(html); } else if (player.getAdena() >= price) { takeItems(player, Inventory.ADENA_ID, price); for (int doorId : doors) { castle.setDoorUpgrade(doorId, level, true); } htmltext = "chamberlain-16.html"; } else { htmltext = "chamberlain-09.html"; } } } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_trap": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (st.hasMoreTokens()) { final NpcHtmlMessage html; if (castle.getName().equalsIgnoreCase("aden")) { html = getHtmlPacket(player, npc, "chamberlain-17a.html"); } else { html = getHtmlPacket(player, npc, "chamberlain-17.html"); } html.replace("%trapIndex%", st.nextToken()); player.sendPacket(html); } else { htmltext = npc.getId() + "-tu.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "upgrade_trap": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final String trapIndex = st.nextToken(); final int level = Integer.parseInt(st.nextToken()); final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-18.html"); html.replace("%trapIndex%", trapIndex); html.replace("%level%", Integer.toString(level)); html.replace("%dmgzone_price%", Integer.toString(getTrapUpgradePrice(level))); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "upgrade_trap_confirm": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final int trapIndex = Integer.parseInt(st.nextToken()); final int level = Integer.parseInt(st.nextToken()); final int price = getTrapUpgradePrice(level); final int currentLevel = castle.getTrapUpgradeLevel(trapIndex); if (currentLevel >= level) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-19.html"); html.replace("%dmglevel%", Integer.toString(currentLevel)); player.sendPacket(html); } else if (player.getAdena() >= price) { takeItems(player, Inventory.ADENA_ID, price); castle.setTrapUpgrade(trapIndex, level, true); htmltext = "chamberlain-20.html"; } else { htmltext = "chamberlain-09.html"; } } } else { htmltext = "chamberlain-21.html"; } break; } case "receive_report": { if (npc.isMyLord(player)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-07.html"; } else { final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId()); final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-02.html"); html.replace("%clanleadername%", clan.getLeaderName()); html.replace("%clanname%", clan.getName()); html.replace("%castlename%", String.valueOf(1001000 + castle.getResidenceId())); switch (SevenSigns.getInstance().getCurrentPeriod()) { case SevenSigns.PERIOD_COMP_RECRUITING: html.replace("%ss_event%", "1000509"); break; case SevenSigns.PERIOD_COMPETITION: html.replace("%ss_event%", "1000507"); break; case SevenSigns.PERIOD_SEAL_VALIDATION: case SevenSigns.PERIOD_COMP_RESULTS: html.replace("%ss_event%", "1000508"); break; } html.replace("%ss_avarice%", getSealOwner(1)); html.replace("%ss_gnosis%", getSealOwner(2)); html.replace("%ss_strife%", getSealOwner(3)); player.sendPacket(html); } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_tax": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlesettaxrate.html"); html.replace("%tax_rate%", Integer.toString(castle.getTaxPercent())); html.replace("%next_tax_rate%", "0"); // TODO: Implement me! html.replace("%tax_limit%", Integer.toString(getTaxLimit())); player.sendPacket(html); } } else if (isOwner(player, npc)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-03.html"); html.replace("%tax_rate%", Integer.toString(castle.getTaxPercent())); html.replace("%next_tax_rate%", "0"); // TODO: Implement me! player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "set_tax": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final NpcHtmlMessage html; final int tax = (st.hasMoreTokens()) ? Integer.parseInt(st.nextToken()) : 0; final int taxLimit = getTaxLimit(); if (tax > taxLimit) { html = getHtmlPacket(player, npc, "castletoohightaxrate.html"); html.replace("%tax_limit%", Integer.toString(taxLimit)); } else { castle.setTaxPercent(tax); html = getHtmlPacket(player, npc, "castleaftersettaxrate.html"); html.replace("%next_tax_rate%", Integer.toString(tax)); } player.sendPacket(html); } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_vault": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { long seedIncome = 0; if (Config.ALLOW_MANOR) { for (SeedProduction sp : CastleManorManager.getInstance() .getSeedProduction(castle.getResidenceId(), false)) { final long diff = sp.getStartAmount() - sp.getAmount(); if (diff != 0) { seedIncome += diff * sp.getPrice(); } } } final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlemanagevault.html"); html.replace("%tax_income%", Util.formatAdena(castle.getTreasury())); html.replace("%tax_income_reserved%", "0"); // TODO: Implement me! html.replace("%seed_income%", Util.formatAdena(seedIncome)); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "deposit": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { final long amount = (st.hasMoreTokens()) ? Long.parseLong(st.nextToken()) : 0; if ((amount > 0) && (amount < Inventory.MAX_ADENA)) { if (player.getAdena() >= amount) { takeItems(player, Inventory.ADENA_ID, amount); castle.addToTreasuryNoTax(amount); } else { player.sendPacket(SystemMessageId.YOU_NOT_ENOUGH_ADENA); } } htmltext = "chamberlain-01.html"; } else { htmltext = "chamberlain-21.html"; } break; } case "withdraw": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { final long amount = (st.hasMoreTokens()) ? Long.parseLong(st.nextToken()) : 0; if (amount <= castle.getTreasury()) { castle.addToTreasuryNoTax((-1) * amount); giveAdena(player, amount, false); htmltext = "chamberlain-01.html"; } else { final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlenotenoughbalance.html"); html.replace("%tax_income%", Util.formatAdena(castle.getTreasury())); html.replace("%withdraw_amount%", Util.formatAdena(amount)); player.sendPacket(html); } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_functions": { if (!isOwner(player, npc)) { htmltext = "chamberlain-21.html"; } else if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { htmltext = "chamberlain-23.html"; } break; } case "banish_foreigner_show": { if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_DISMISS)) { htmltext = "chamberlain-21.html"; } else if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { htmltext = "chamberlain-10.html"; } break; } case "banish_foreigner": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_DISMISS)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { castle.banishForeigners(); htmltext = "chamberlain-11.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "doors": { if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_OPEN_DOOR)) { htmltext = "chamberlain-21.html"; } else if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { htmltext = npc.getId() + "-d.html"; } break; } case "operate_door": { if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_OPEN_DOOR)) { htmltext = "chamberlain-21.html"; } else if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final boolean open = (Integer.parseInt(st.nextToken()) == 1); while (st.hasMoreTokens()) { castle.openCloseDoor(player, Integer.parseInt(st.nextToken()), open); } htmltext = (open ? "chamberlain-05.html" : "chamberlain-06.html"); } break; } case "additional_functions": { htmltext = (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) ? "castletdecomanage.html" : "chamberlain-21.html"; break; } case "recovery": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledeco-AR01.html"); funcReplace(castle, html, Castle.FUNC_RESTORE_HP, "HP"); funcReplace(castle, html, Castle.FUNC_RESTORE_MP, "MP"); funcReplace(castle, html, Castle.FUNC_RESTORE_EXP, "XP"); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "other": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledeco-AE01.html"); funcReplace(castle, html, Castle.FUNC_TELEPORT, "TP"); funcReplace(castle, html, Castle.FUNC_SUPPORT, "BF"); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "HP": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_HP, level); break; } case "MP": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_MP, level); break; } case "XP": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_EXP, level); break; } case "TP": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_TELEPORT, level); break; } case "BF": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_SUPPORT, level); break; } case "set_func": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final int func = Integer.parseInt(st.nextToken()); final int level = Integer.parseInt(st.nextToken()); if (level == 0) { castle.updateFunctions(player, func, level, 0, 0, false); } else if (!castle.updateFunctions( player, func, level, getFunctionFee(func, level), getFunctionRatio(func), castle.getFunction(func) == null)) { htmltext = "chamberlain-09.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "functions": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { final CastleFunction HP = castle.getFunction(Castle.FUNC_RESTORE_HP); final CastleFunction MP = castle.getFunction(Castle.FUNC_RESTORE_MP); final CastleFunction XP = castle.getFunction(Castle.FUNC_RESTORE_EXP); final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledecofunction.html"); html.replace("%HPDepth%", (HP == null) ? "0" : Integer.toString(HP.getLvl())); html.replace("%MPDepth%", (MP == null) ? "0" : Integer.toString(MP.getLvl())); html.replace("%XPDepth%", (XP == null) ? "0" : Integer.toString(XP.getLvl())); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "teleport": { if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { htmltext = "chamberlain-21.html"; } else if (castle.getFunction(Castle.FUNC_TELEPORT) == null) { htmltext = "castlefuncdisabled.html"; } else { htmltext = npc.getId() + "-t" + castle.getFunction(Castle.FUNC_TELEPORT).getLvl() + ".html"; } break; } case "goto": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { final int locId = Integer.parseInt(st.nextToken()); final L2TeleportLocation list = TeleportLocationTable.getInstance().getTemplate(locId); if (list != null) { if (takeItems(player, list.getItemId(), list.getPrice())) { player.teleToLocation(list.getLocX(), list.getLocY(), list.getLocZ()); } } } else { htmltext = "chamberlain-21.html"; } break; } case "buffer": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { if (castle.getFunction(Castle.FUNC_SUPPORT) == null) { htmltext = "castlefuncdisabled.html"; } else { final NpcHtmlMessage html = getHtmlPacket( player, npc, "castlebuff-0" + castle.getFunction(Castle.FUNC_SUPPORT).getLvl() + ".html"); html.replace("%MPLeft%", Integer.toString((int) npc.getCurrentMp())); player.sendPacket(html); } } else { htmltext = "chamberlain-21.html"; } break; } case "cast_buff": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { if (castle.getFunction(Castle.FUNC_SUPPORT) == null) { htmltext = "castlefuncdisabled.html"; } else { final int index = Integer.parseInt(st.nextToken()); if (BUFFS.length > index) { final NpcHtmlMessage html; final SkillHolder holder = BUFFS[index]; if (holder.getSkill().getMpConsume() < npc.getCurrentMp()) { npc.setTarget(player); npc.doCast(holder.getSkill()); html = getHtmlPacket(player, npc, "castleafterbuff.html"); } else { html = getHtmlPacket(player, npc, "castlenotenoughmp.html"); } html.replace("%MPLeft%", Integer.toString((int) npc.getCurrentMp())); player.sendPacket(html); } } } else { htmltext = "chamberlain-21.html"; } break; } case "list_siege_clans": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANAGE_SIEGE)) { castle.getSiege().listRegisterClan(player); } else { htmltext = "chamberlain-21.html"; } break; } case "list_territory_clans": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANAGE_SIEGE)) { player.sendPacket(new ExShowDominionRegistry(castle.getResidenceId(), player)); } else { htmltext = "chamberlain-21.html"; } break; } case "manor": { if (Config.ALLOW_MANOR) { htmltext = (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANOR_ADMIN)) ? "manor.html" : "chamberlain-21.html"; } else { player.sendMessage("Manor system is deactivated."); } break; } case "products": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-22.html"); html.replace("%npcId%", Integer.toString(npc.getId())); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "buy": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { ((L2MerchantInstance) npc).showBuyWindow(player, Integer.parseInt(st.nextToken())); } else { htmltext = "chamberlain-21.html"; } break; } case "give_crown": { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else if (npc.isMyLord(player)) { if (hasQuestItems(player, CROWN)) { htmltext = "chamberlain-24.html"; } else { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-25.html"); html.replace("%owner_name%", String.valueOf(player.getName())); html.replace( "%feud_name%", String.valueOf(String.valueOf(1001000 + castle.getResidenceId()))); player.sendPacket(html); giveItems(player, CROWN, 1); } } else { htmltext = "chamberlain-21.html"; } break; } case "manors_cert": { if (npc.isMyLord(player)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { if ((SevenSigns.getInstance().getPlayerCabal(player.getObjectId()) == SevenSigns.CABAL_DAWN) && SevenSigns.getInstance().isCompetitionPeriod()) { final int ticketCount = castle.getTicketBuyCount(); if (ticketCount < (Config.SSQ_DAWN_TICKET_QUANTITY / Config.SSQ_DAWN_TICKET_BUNDLE)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "ssq_selldawnticket.html"); html.replace( "%DawnTicketLeft%", String.valueOf( Config.SSQ_DAWN_TICKET_QUANTITY - (ticketCount * Config.SSQ_DAWN_TICKET_BUNDLE))); html.replace("%DawnTicketBundle%", String.valueOf(Config.SSQ_DAWN_TICKET_BUNDLE)); html.replace( "%DawnTicketPrice%", String.valueOf(Config.SSQ_DAWN_TICKET_PRICE * Config.SSQ_DAWN_TICKET_BUNDLE)); player.sendPacket(html); } else { htmltext = "ssq_notenoughticket.html"; } } else { htmltext = "ssq_notdawnorevent.html"; } } } else { htmltext = "chamberlain-21.html"; } break; } case "manors_cert_confirm": { if (npc.isMyLord(player)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { if ((SevenSigns.getInstance().getPlayerCabal(player.getObjectId()) == SevenSigns.CABAL_DAWN) && SevenSigns.getInstance().isCompetitionPeriod()) { final int ticketCount = castle.getTicketBuyCount(); if (ticketCount < (Config.SSQ_DAWN_TICKET_QUANTITY / Config.SSQ_DAWN_TICKET_BUNDLE)) { final long totalCost = Config.SSQ_DAWN_TICKET_PRICE * Config.SSQ_DAWN_TICKET_BUNDLE; if (player.getAdena() >= totalCost) { takeItems(player, Inventory.ADENA_ID, totalCost); giveItems( player, Config.SSQ_MANORS_AGREEMENT_ID, Config.SSQ_DAWN_TICKET_BUNDLE); castle.setTicketBuyCount(ticketCount + 1); } else { htmltext = "chamberlain-09.html"; } } else { htmltext = "ssq_notenoughticket.html"; } } else { htmltext = "ssq_notdawnorevent.html"; } } } else { htmltext = "chamberlain-21.html"; } break; } } return htmltext; }
public boolean useAdminCommand(String command, L2PcInstance activeChar) { int npcId = 0; int teleportIndex = -1; AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false); AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false); if (command.startsWith("admin_mammon_find")) { try { if (command.length() > 17) teleportIndex = Integer.parseInt(command.substring(18)); } catch (Exception NumberFormatException) { activeChar.sendMessage( "Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)"); } if (!_isSealValidation) { activeChar.sendMessage(1738); return true; } if (blackSpawnInst != null) { L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList(); if (blackInst.length > 0) { int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1739].getMessage() + x1 + " " + y1 + " " + z1); if (teleportIndex == 1) activeChar.teleToLocation(x1, y1, z1, true); } } else activeChar.sendMessage(1740); if (merchSpawnInst != null) { L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList(); if (merchInst.length > 0) { int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1741].getMessage() + x2 + " " + y2 + " " + z2); if (teleportIndex == 2) activeChar.teleToLocation(x2, y2, z2, true); } } else activeChar.sendMessage(1742); } else if (command.startsWith("admin_mammon_respawn")) { if (!_isSealValidation) { activeChar.sendMessage(1738); return true; } if (merchSpawnInst != null) { long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst); activeChar.sendMessage( MessageTable.Messages[1743].getExtra(1) + (merchRespawn / 60000) + MessageTable.Messages[1743].getExtra(2)); } else activeChar.sendMessage(1742); if (blackSpawnInst != null) { long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst); activeChar.sendMessage( MessageTable.Messages[1744].getExtra(1) + (blackRespawn / 60000) + MessageTable.Messages[1744].getExtra(2)); } else activeChar.sendMessage(1740); } else if (command.startsWith("admin_list_spawns")) { try { // admin_list_spawns x[xxxx] x[xx] String[] params = command.split(" "); Pattern pattern = Pattern.compile("[0-9]*"); Matcher regexp = pattern.matcher(params[1]); if (regexp.matches()) npcId = Integer.parseInt(params[1]); else { params[1] = params[1].replace('_', ' '); npcId = NpcTable.getInstance().getTemplateByName(params[1]).npcId; } if (params.length > 2) teleportIndex = Integer.parseInt(params[2]); } catch (Exception e) { activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]"); } SpawnTable.getInstance().findNPCInstances(activeChar, npcId, teleportIndex); } // Used for testing SystemMessage IDs - Use //msg <ID> else if (command.startsWith("admin_msg")) { int msgId = -1; try { msgId = Integer.parseInt(command.substring(10).trim()); } catch (Exception e) { activeChar.sendMessage("Command format: //msg <SYSTEM_MSG_ID>"); return true; } activeChar.sendPacket(new SystemMessage(msgId)); } return true; }
public void teleportBack() { if (_paDuel) { _player.teleToLocation(_x, _y, _z); } }
protected static final void teleportPlayer(L2PcInstance player, int[] coords, int instanceId) { player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); player.setInstanceId(instanceId); player.teleToLocation(coords[0], coords[1], coords[2], true); }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = ""; QuestState st = getQuestState(player, true); int npcId = npc.getId(); if (Util.contains(TOWN_DAWN, npcId)) { st.setState(State.STARTED); int i = 0; for (int dawn : TELEPORTERS) { if (dawn == npcId) { break; } i++; } st.set("id", Integer.toString(i)); playSound(player, QuestSound.ITEMSOUND_QUEST_ACCEPT); player.teleToLocation(new Location(-80157, 111344, -4901)); player.setIsIn7sDungeon(true); } if (Util.contains(TOWN_DUSK, npcId)) { st.setState(State.STARTED); int i = 0; for (int dusk : TELEPORTERS) { if (dusk == npcId) { break; } i++; } st.set("id", Integer.toString(i)); playSound(player, QuestSound.ITEMSOUND_QUEST_ACCEPT); player.teleToLocation(new Location(-81261, 86531, -5157)); player.setIsIn7sDungeon(true); } else if ((npcId >= 31494) && (npcId <= 31507)) { if (player.getLevel() < 20) { htmltext = "1.htm"; st.exitQuest(true); } else if (player.getAllActiveQuests().length > 23) { htmltext = "1a.htm"; st.exitQuest(true); } else if (!hasQuestItems(player, DIMENSIONAL_FRAGMENT)) { htmltext = "3.htm"; } else { st.setState(State.CREATED); htmltext = "4.htm"; } } else if (((npcId >= 31095) && (npcId <= 31111)) || ((npcId >= 31114) && (npcId <= 31126))) { int playerLevel = player.getLevel(); if (playerLevel < 20) { htmltext = "ziggurat_lowlevel.htm"; st.exitQuest(true); } else if (player.getAllActiveQuests().length > 40) { player.sendPacket(SystemMessageId.TOO_MANY_QUESTS); st.exitQuest(true); } else if (!hasQuestItems(player, DIMENSIONAL_FRAGMENT)) { htmltext = "ziggurat_nofrag.htm"; st.exitQuest(true); } else if ((playerLevel >= 20) && (playerLevel < 30) && (player.getAdena() < 2000)) { htmltext = "ziggurat_noadena.htm"; st.exitQuest(true); } else if ((playerLevel >= 30) && (playerLevel < 40) && (player.getAdena() < 4500)) { htmltext = "ziggurat_noadena.htm"; st.exitQuest(true); } else if ((playerLevel >= 40) && (playerLevel < 50) && (player.getAdena() < 8000)) { htmltext = "ziggurat_noadena.htm"; st.exitQuest(true); } else if ((playerLevel >= 50) && (playerLevel < 60) && (player.getAdena() < 12500)) { htmltext = "ziggurat_noadena.htm"; st.exitQuest(true); } else if ((playerLevel >= 60) && (playerLevel < 70) && (player.getAdena() < 18000)) { htmltext = "ziggurat_noadena.htm"; st.exitQuest(true); } else if ((playerLevel >= 70) && (player.getAdena() < 24500)) { htmltext = "ziggurat_noadena.htm"; st.exitQuest(true); } else { htmltext = "ziggurat.htm"; } } return htmltext; }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = ""; QuestState st = player.getQuestState(getName()); if (st == null) return null; switch (npc.getNpcId()) { case 13001: if (antharasAI() != null) { int status = GrandBossManager.getInstance().getBossStatus(29019); int statusW = GrandBossManager.getInstance().getBossStatus(29066); int statusN = GrandBossManager.getInstance().getBossStatus(29067); int statusS = GrandBossManager.getInstance().getBossStatus(29068); if (status == 2 || statusW == 2 || statusN == 2 || statusS == 2) htmltext = "13001-02.htm"; else if (status == 3 || statusW == 3 || statusN == 3 || statusS == 3) htmltext = "13001-01.htm"; else if (status == 0 || status == 1) // If entrance to see Antharas is unlocked (he is Dormant or Waiting) { if (st.hasQuestItems(3865)) { // st.takeItems(3865, 1); // No longer consumed in h5 L2BossZone zone = GrandBossManager.getInstance().getZone(179700, 113800, -7709); if (zone != null) zone.allowPlayerEntry(player, 30); player.teleToLocation(179700 + Rnd.get(700), 113800 + Rnd.get(2100), -7709); if (status == 0) { L2GrandBossInstance antharas = GrandBossManager.getInstance().getBoss(29019); antharasAI().notifyEvent("waiting", antharas, player); } } else htmltext = "13001-03.htm"; } } break; case 31859: player.teleToLocation(79800 + Rnd.get(600), 151200 + Rnd.get(1100), -3534); break; case 31385: if (valakasAI() != null) { int status = GrandBossManager.getInstance().getBossStatus(29028); if (status == 0 || status == 1) { if (playerCount >= 200) htmltext = "31385-03.htm"; else if (st.getInt("allowEnter") == 1) { st.unset("allowEnter"); L2BossZone zone = GrandBossManager.getInstance().getZone(212852, -114842, -1632); if (zone != null) zone.allowPlayerEntry(player, 30); player.teleToLocation(204328 + Rnd.get(600), -111874 + Rnd.get(600), 70); playerCount++; if (status == 0) { L2GrandBossInstance valakas = GrandBossManager.getInstance().getBoss(29028); valakasAI().startQuestTimer("1001", Config.Valakas_Wait_Time, valakas, null); GrandBossManager.getInstance().setBossStatus(29028, 1); } } else htmltext = "31385-04.htm"; } else if (status == 2) htmltext = "31385-02.htm"; else htmltext = "31385-01.htm"; } else htmltext = "31385-01.htm"; break; case 31384: DoorTable.getInstance().getDoor(24210004).openMe(); break; case 31686: DoorTable.getInstance().getDoor(24210006).openMe(); break; case 31687: DoorTable.getInstance().getDoor(24210005).openMe(); break; case 31540: if (playerCount < 50) htmltext = "31540-01.htm"; else if (playerCount < 100) htmltext = "31540-02.htm"; else if (playerCount < 150) htmltext = "31540-03.htm"; else if (playerCount < 200) htmltext = "31540-04.htm"; else htmltext = "31540-05.htm"; break; case 31759: player.teleToLocation(150037 + Rnd.get(500), -57720 + Rnd.get(500), -2976); break; } return htmltext; }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { switch (event) { case "31862-04.html": { return event; } case "enter": { String htmltext = null; if (getStatus() == DEAD) { htmltext = "31862-03.html"; } else if (getStatus() == IN_FIGHT) { htmltext = "31862-02.html"; } else if (!hasQuestItems(player, FABRIC)) { htmltext = "31862-01.html"; } else { takeItems(player, FABRIC, 1); player.teleToLocation(TELEPORT_IN_LOC); } return htmltext; } case "teleportOut": { final Location destination = TELEPORT_OUT_LOC[getRandom(TELEPORT_OUT_LOC.length)]; player.teleToLocation( destination.getX() + getRandom(100), destination.getY() + getRandom(100), destination.getZ()); break; } case "wakeUp": { if (getStatus() == ALIVE) { npc.deleteMe(); setStatus(IN_FIGHT); _baium = (L2GrandBossInstance) addSpawn(BAIUM, BAIUM_LOC, false, 0); _baium.disableCoreAI(true); addBoss(_baium); _lastAttack = System.currentTimeMillis(); startQuestTimer("WAKEUP_ACTION", 50, _baium, null); startQuestTimer("MANAGE_EARTHQUAKE", 2000, _baium, null); startQuestTimer("CHECK_ATTACK", 60000, _baium, null); } break; } case "WAKEUP_ACTION": { if (npc != null) { zone.broadcastPacket(new SocialAction(_baium.getObjectId(), 2)); } break; } case "MANAGE_EARTHQUAKE": { if (npc != null) { zone.broadcastPacket(new Earthquake(npc.getX(), npc.getY(), npc.getZ(), 40, 10)); zone.broadcastPacket(new PlaySound("BS02_A")); startQuestTimer("SOCIAL_ACTION", 8000, npc, player); } break; } case "SOCIAL_ACTION": { if (npc != null) { zone.broadcastPacket(new SocialAction(npc.getObjectId(), 3)); startQuestTimer("PLAYER_PORT", 6000, npc, player); } break; } case "PLAYER_PORT": { if (npc != null) { if ((player != null) && player.isInsideRadius(npc, 16000, true, false)) { player.teleToLocation(BAIUM_GIFT_LOC); startQuestTimer("PLAYER_KILL", 3000, npc, player); } else if ((_standbyPlayer != null) && _standbyPlayer.isInsideRadius(npc, 16000, true, false)) { _standbyPlayer.teleToLocation(BAIUM_GIFT_LOC); startQuestTimer("PLAYER_KILL", 3000, npc, _standbyPlayer); } } break; } case "PLAYER_KILL": { if ((player != null) && player.isInsideRadius(npc, 16000, true, false)) { zone.broadcastPacket(new SocialAction(npc.getObjectId(), 1)); broadcastNpcSay( npc, Say2.NPC_ALL, player.getName() + ", How dare you wake me! Now you shall die!"); // TODO: replace with // NpcStringId when are done // core support npc.setTarget(player); npc.doCast(BAIUM_PRESENT.getSkill()); } for (L2PcInstance players : zone.getPlayersInside()) { if (players.isHero()) { zone.broadcastPacket( new ExShowScreenMessage( NpcStringId .NOT_EVEN_THE_GODS_THEMSELVES_COULD_TOUCH_ME_BUT_YOU_S1_YOU_DARE_CHALLENGE_ME_IGNORANT_MORTAL, 2, 4000, players.getName())); break; } } startQuestTimer("SPAWN_ARCHANGEL", 8000, npc, null); break; } case "SPAWN_ARCHANGEL": { _baium.disableCoreAI(false); for (Location loc : ARCHANGEL_LOC) { final L2Npc archangel = addSpawn(ARCHANGEL, loc, false, 0, true); startQuestTimer("SELECT_TARGET", 5000, archangel, null); } if ((player != null) && !player.isDead()) { attackPlayer((L2Attackable) npc, player); } else if ((_standbyPlayer != null) && !_standbyPlayer.isDead()) { attackPlayer((L2Attackable) npc, _standbyPlayer); } else { for (L2Character characters : npc.getKnownList().getKnownCharactersInRadius(2000)) { if ((characters != null) && characters.isPlayer() && zone.isInsideZone(characters) && !characters.isDead()) { attackPlayer((L2Attackable) npc, (L2Playable) characters); break; } } } break; } case "SELECT_TARGET": { if (npc != null) { final L2Attackable mob = (L2Attackable) npc; final L2Character mostHated = mob.getMostHated(); if ((_baium == null) || _baium.isDead()) { mob.deleteMe(); break; } if ((mostHated != null) && mostHated.isPlayer() && zone.isInsideZone(mostHated)) { if (mob.getTarget() != mostHated) { mob.clearAggroList(); } attackPlayer(mob, (L2Playable) mostHated); } else { boolean found = false; for (L2Character characters : mob.getKnownList().getKnownCharactersInRadius(1000)) { if ((characters != null) && characters.isPlayable() && zone.isInsideZone(characters) && !characters.isDead()) { if (mob.getTarget() != characters) { mob.clearAggroList(); } attackPlayer(mob, (L2Playable) characters); found = true; break; } } if (!found) { if (mob.isInsideRadius(_baium, 40, true, false)) { if (mob.getTarget() != _baium) { mob.clearAggroList(); } mob.setIsRunning(true); mob.addDamageHate(_baium, 0, 999); mob.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, _baium); } else { mob.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, _baium); } } } startQuestTimer("SELECT_TARGET", 5000, npc, null); } break; } case "CHECK_ATTACK": { if ((npc != null) && ((_lastAttack + 1800000) < System.currentTimeMillis())) { notifyEvent("CLEAR_ZONE", null, null); addSpawn(BAIUM_STONE, BAIUM_LOC, false, 0); setStatus(ALIVE); } else if (npc != null) { if (((_lastAttack + 300000) < System.currentTimeMillis()) && (npc.getCurrentHp() < (npc.getMaxHp() * 0.75))) { npc.setTarget(npc); npc.doCast(HEAL_OF_BAIUM.getSkill()); } startQuestTimer("CHECK_ATTACK", 60000, npc, null); } break; } case "CLEAR_STATUS": { setStatus(ALIVE); addSpawn(BAIUM_STONE, BAIUM_LOC, false, 0); break; } case "CLEAR_ZONE": { for (L2Character charInside : zone.getCharactersInside()) { if (charInside != null) { if (charInside.isNpc()) { charInside.deleteMe(); } else if (charInside.isPlayer()) { notifyEvent("teleportOut", null, (L2PcInstance) charInside); } } } break; } case "RESPAWN_BAIUM": { if (getStatus() == DEAD) { setRespawn(0); cancelQuestTimer("CLEAR_STATUS", null, null); notifyEvent("CLEAR_STATUS", null, null); } else { player.sendMessage( getClass().getSimpleName() + ": You cant respawn Baium while Baium is alive!"); } break; } case "ABORT_FIGHT": { if (getStatus() == IN_FIGHT) { _baium = null; notifyEvent("CLEAR_ZONE", null, null); notifyEvent("CLEAR_STATUS", null, null); player.sendMessage(getClass().getSimpleName() + ": Aborting fight!"); } else { player.sendMessage(getClass().getSimpleName() + ": You cant abort attack right now!"); } cancelQuestTimers("CHECK_ATTACK"); cancelQuestTimers("SELECT_TARGET"); break; } case "DESPAWN_MINIONS": { if (getStatus() == IN_FIGHT) { for (L2Character charInside : zone.getCharactersInside()) { if ((charInside != null) && charInside.isNpc() && (charInside.getId() == ARCHANGEL)) { charInside.deleteMe(); } } if (player != null) { player.sendMessage(getClass().getSimpleName() + ": All archangels has been deleted!"); } } else if (player != null) { player.sendMessage( getClass().getSimpleName() + ": You cant despawn archangels right now!"); } break; } case "MANAGE_SKILLS": { if (npc != null) { manageSkills(npc); } break; } } return super.onAdvEvent(event, npc, player); }
@Override public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmltext = event; // Timer. Spawns Naia Lock if (event.equalsIgnoreCase("spawn_lock")) { htmltext = null; _lock = (L2MonsterInstance) addSpawn(LOCK, 16409, 244438, 11620, -1048, false, 0, false); _counter = 90; } // Timer. Depending of _challengeState despans all spawned spores, or spores, reached assembly // point else if (event.equalsIgnoreCase("despawn_total")) { // Spores is not attacked too long - despawn them all, reinit values if (_challengeState == STATE_SPORE_IDLE_TOO_LONG) { for (L2Npc spore : _sporeSpawn) { if ((spore != null) && !spore.isDead()) { spore.deleteMe(); } } _sporeSpawn.clear(); initSporeChallenge(); } // Spores are moving to assembly point. Despawn all reached, check for reached spores count. else if ((_challengeState == STATE_SPORE_CHALLENGE_SUCCESSFULL) && (_winIndex >= 0)) { // Requirements are met, despawn all spores, spawn Epidos if ((_despawnedSporesCount >= 10) || _sporeSpawn.isEmpty()) { if (!_sporeSpawn.isEmpty()) { for (L2Npc spore : _sporeSpawn) { if ((spore != null) && !spore.isDead()) { spore.deleteMe(); } } } _sporeSpawn.clear(); _despawnedSporesCount = 0; int[] coords = SPORES_MERGE_POSITION[_winIndex]; addSpawn(EPIDOSES[_winIndex], coords[0], coords[1], coords[2], 0, false, 0, false); initSporeChallenge(); } // Requirements aren't met, despawn reached spores else { Iterator<L2Npc> it = _sporeSpawn.iterator(); while (it.hasNext()) { L2Npc spore = it.next(); if ((spore != null) && !spore.isDead() && (spore.getX() == spore.getSpawn().getX()) && (spore.getY() == spore.getSpawn().getY())) { spore.deleteMe(); it.remove(); _despawnedSporesCount++; } } startQuestTimer("despawn_total", 3000, null, null); } } } if (npc == null) { return null; } final int npcId = npc.getId(); if (event.equalsIgnoreCase("despawn_spore") && !npc.isDead() && (_challengeState == STATE_SPORE_CHALLENGE_IN_PROGRESS)) { htmltext = null; _sporeSpawn.remove(npc); npc.deleteMe(); if (npcId == SPORE_BASIC) { spawnRandomSpore(); spawnRandomSpore(); } else if ((npcId >= SPORE_FIRE) && (npcId <= SPORE_EARTH)) { _despawnedSporesCount++; if (_despawnedSporesCount < SELF_DESPAWN_LIMIT) { spawnOppositeSpore(npcId); } else { _challengeState = STATE_SPORE_IDLE_TOO_LONG; startQuestTimer("despawn_total", 60000, null, null); } } } else if (event.equalsIgnoreCase("18492-05.htm")) { if ((_lock == null) || (_lock.getCurrentHp() > (_lock.getMaxHp() / 10))) { htmltext = null; if (_lock != null) { _lock.deleteMe(); _lock = null; } cancelQuestTimers("spawn_lock"); startQuestTimer("spawn_lock", 300000, null, null); npc.setTarget(player); npc.doCast(SkillData.getInstance().getSkill(5527, 1)); } } else if (event.equalsIgnoreCase("teleport") && (_lock != null)) { htmltext = null; L2Party party = player.getParty(); if (party != null) { if (Util.checkIfInRange(3000, party.getLeader(), npc, true)) { for (L2PcInstance partyMember : party.getMembers()) { if (Util.checkIfInRange(2000, partyMember, npc, true)) { partyMember.teleToLocation(-47271, 246098, -9120, true); } } _lock.deleteMe(); _lock = null; cancelQuestTimers("spawn_lock"); startQuestTimer("spawn_lock", 1200000, null, null); } else { npc.setTarget(player); npc.doCast(SkillData.getInstance().getSkill(5527, 1)); } } else { player.teleToLocation(-47271, 246098, -9120); _lock.deleteMe(); _lock = null; cancelQuestTimers("spawn_lock"); startQuestTimer("spawn_lock", 1200000, null, null); } } else if (event.equalsIgnoreCase("go") && _activeRooms.containsKey(npcId) && !_activeRooms.get(npcId)) { htmltext = null; L2Party party = player.getParty(); if (party != null) { removeForeigners(npcId, party); startRoom(npcId); ThreadPoolManager.getInstance().scheduleGeneral(new StopRoomTask(npcId), 300000); } else { player.sendPacket(SystemMessageId.CAN_OPERATE_MACHINE_WHEN_IN_PARTY); } } return htmltext; }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { final QuestState qs = getQuestState(player, false); if (qs == null) { return null; } String htmltext = null; switch (event) { case "ACCEPT": { if (qs.isCreated()) { qs.startQuest(); qs.setMemoState(1); playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE); if (player.getVariables().getInt("2ND_CLASS_DIAMOND_REWARD", 0) == 0) { giveItems(player, DIMENSIONAL_DIAMOND, 23); player.getVariables().set("2ND_CLASS_DIAMOND_REWARD", 1); htmltext = "30531-04a.htm"; } else { htmltext = "30531-04.htm"; } } break; } case "30533-02.html": { qs.setMemoState(2); htmltext = event; break; } case "30556-02.html": case "30556-03.html": case "30556-04.html": { htmltext = event; break; } case "30556-05.html": { if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE)) { giveItems(player, BROKEN_TELEPORT_DEVICE, 1); takeItems(player, PAINT_OF_TELEPORT_DEVICE, 1); player.teleToLocation(140352, -194133, -3146); startQuestTimer("SPAWN_KING_BUGBEAR", 5000, npc, player); htmltext = event; } break; } case "30671-02.html": { giveItems(player, PAINT_OF_KAMURU, 1); htmltext = event; break; } case "30673-04.html": { if (hasQuestItems(player, INGREDIENTS_OF_ANTIDOTE) && (getQuestItemsCount(player, STINGER_WASP_NEEDLE) >= 10) && (getQuestItemsCount(player, MARSH_SPIDERS_WEB) >= 10) && (getQuestItemsCount(player, BLOOD_OF_LEECH) >= 10)) { giveItems(player, REPORT_OF_CRUMA, 1); takeItems(player, STINGER_WASP_NEEDLE, -1); takeItems(player, MARSH_SPIDERS_WEB, -1); takeItems(player, BLOOD_OF_LEECH, -1); takeItems(player, INGREDIENTS_OF_ANTIDOTE, 1); htmltext = event; } break; } case "SPAWN_KING_BUGBEAR": { addAttackPlayerDesire( addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player); addAttackPlayerDesire( addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player); addAttackPlayerDesire( addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player); break; } } return htmltext; }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmltext = ""; QuestState st = getQuestState(player, false); if (st == null) { return null; } final int npcId = npc.getId(); if (event.equalsIgnoreCase("Return")) { if (Util.contains(TEMPLE_PRIEST, npcId) && (st.getState() == State.STARTED)) { player.teleToLocation(RETURN_LOCS[st.getInt("id")]); player.setIsIn7sDungeon(false); st.exitQuest(true); } else if (Util.contains(RIFT_POSTERS, npcId) && (st.getState() == State.STARTED)) { player.teleToLocation(RETURN_LOCS[st.getInt("id")]); htmltext = "rift_back.htm"; st.exitQuest(true); } } else if (event.equalsIgnoreCase("Festival")) { int id = st.getInt("id"); if (Util.contains(TOWN_DAWN, id)) { player.teleToLocation(new Location(-80157, 111344, -4901)); player.setIsIn7sDungeon(true); } else if (Util.contains(TOWN_DUSK, id)) { player.teleToLocation(new Location(-81261, 86531, -5157)); player.setIsIn7sDungeon(true); } else { htmltext = "oracle1.htm"; } } else if (event.equalsIgnoreCase("Dimensional")) { htmltext = "oracle.htm"; player.teleToLocation(new Location(-114755, -179466, -6752)); } else if (event.equalsIgnoreCase("5.htm")) { int id = st.getInt("id"); if (id > -1) { htmltext = "5a.htm"; } int i = 0; for (int id1 : TELEPORTERS) { if (id1 == npcId) { break; } i++; } st.set("id", Integer.toString(i)); st.setState(State.STARTED); player.teleToLocation(new Location(-114755, -179466, -6752)); } else if (event.equalsIgnoreCase("6.htm")) { htmltext = "6.htm"; st.exitQuest(true); } else if (event.equalsIgnoreCase("zigurratDimensional")) { int playerLevel = player.getLevel(); if ((playerLevel >= 20) && (playerLevel < 30)) { takeItems(player, Inventory.ADENA_ID, 2000); } else if ((playerLevel >= 30) && (playerLevel < 40)) { takeItems(player, Inventory.ADENA_ID, 4500); } else if ((playerLevel >= 40) && (playerLevel < 50)) { takeItems(player, Inventory.ADENA_ID, 8000); } else if ((playerLevel >= 50) && (playerLevel < 60)) { takeItems(player, Inventory.ADENA_ID, 12500); } else if ((playerLevel >= 60) && (playerLevel < 70)) { takeItems(player, Inventory.ADENA_ID, 18000); } else if (playerLevel >= 70) { takeItems(player, Inventory.ADENA_ID, 24500); } int i = 0; for (int ziggurat : TELEPORTERS) { if (ziggurat == npcId) { break; } i++; } st.set("id", Integer.toString(i)); st.setState(State.STARTED); playSound(player, QuestSound.ITEMSOUND_QUEST_ACCEPT); htmltext = "ziggurat_rift.htm"; player.teleToLocation(new Location(-114755, -179466, -6752)); } return htmltext; }
public void teleportToWaitingRoom(L2PcInstance player) { int[] coords = getRoom((byte) 0, (byte) 0).getTeleportCoords(); player.teleToLocation(coords[0], coords[1], coords[2]); }