@Override protected final void writeImpl() { writeC(0xf3); writeD(_messageId); if (_info.isEmpty()) { writeD(0x00); writeD(_time); writeD(_requesterId); } else { writeD(_info.size()); // TODO: Verify this i bet its same like SystemMessage for (CnfDlgData data : _info) { writeD(data.type); switch (data.type) { case TYPE_TEXT: writeS((String) data.value); break; case TYPE_NUMBER: case TYPE_NPC_NAME: case TYPE_ITEM_NAME: writeD((Integer) data.value); break; case TYPE_SKILL_NAME: writeD((Integer) data.value); // Skill Id writeD(_skillLvL); // Skill lvl break; case TYPE_ZONE_NAME: Integer[] array = (Integer[]) data.value; writeD(array[0]); writeD(array[1]); writeD(array[2]); break; } } if (_time != 0) { writeD(_time); } if (_requesterId != 0) { writeD(_requesterId); } } }
@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 void onBypassFeedback(L2PcInstance player, String command) { if (command.startsWith("Chat")) { int val = 0; try { val = Integer.parseInt(command.substring(5)); } catch (IndexOutOfBoundsException ioobe) { } catch (NumberFormatException nfe) { } showChatWindow(player, val); return; } else if (command.startsWith("ExchangeKE")) { String filename = null; int item; int i0 = Rnd.get(100); if (i0 < 5) { int i1 = Rnd.get(100); if (i1 < 5) item = 9931; // Red Talisman of Meditation else if (i1 <= 50) item = 9932; // Blue Talisman - Divine Protection else if (i1 <= 75) item = 10416; // Blue Talisman - Explosion else item = 10417; // Blue Talisman - Magic Explosion } else if (i0 <= 15) { switch (Rnd.get(5)) { case 1: // Red Talisman of Minimum Clarity item = 9917; break; case 2: // Red Talisman of Maximum Clarity item = 9918; break; case 3: // Red Talisman of Mental Regeneration item = 9928; break; case 4: // Blue Talisman of Protection item = 9929; break; default: // Blue Talisman of Invisibility item = 9920; } } else if (i0 <= 30) { switch (Rnd.get(8)) { case 1: // Blue Talisman of Defense item = 9916; break; case 2: // Blue Talisman of Defense item = 9916; break; case 3: // Blue Talisman of Healing item = 9924; break; case 4: // Red Talisman of Recovery item = 9925; break; case 5: // Blue Talisman of Defense item = 9926; break; case 6: // Blue Talisman of Magic Defense item = 9927; break; case 7: // Red Talisman - Life Force item = 10518; break; default: // Blue Talisman - Greater Healing item = 10424; } } else { switch (Rnd.get(46)) { case 0: // Blue Talisman of Power item = 9914; break; case 1: // Blue Talisman of Wild Magic item = 9915; break; case 2: // Blue Talisman of Invisibility item = 9920; break; case 3: // Blue Talisman of Invisibility item = 9920; break; case 4: // Blue Talisman - Shield Protection item = 9921; break; case 5: // Black Talisman - Mending item = 9922; break; case 6: // Yellow Talisman of Power item = 9933; break; case 7: // Yellow Talisman of Violent Haste item = 9934; break; case 8: // Yellow Talisman of Arcane Defense item = 9935; break; case 9: // Yellow Talisman of Arcane Power item = 9936; break; case 10: // Yellow Talisman of Arcane Haste item = 9937; break; case 11: // Yellow Talisman of Accuracy item = 9938; break; case 12: // Yellow Talisman of Defense item = 9939; break; case 13: // Yellow Talisman of Alacrity item = 9940; break; case 14: // Yellow Talisman of Speed item = 9941; break; case 15: // Yellow Talisman of Critical Reduction item = 9942; break; case 16: // Yellow Talisman of Critical Damage item = 9943; break; case 17: // Yellow Talisman of Critical Dodging item = 9944; break; case 18: // Yellow Talisman of Evasion item = 9945; break; case 19: // Yellow Talisman of Healing item = 9946; break; case 20: // Yellow Talisman of CP Regeneration item = 9947; break; case 21: // Yellow Talisman of Physical Regeneration item = 9948; break; case 22: // Yellow Talisman of Mental Regeneration item = 9949; break; case 23: // Grey Talisman of Weight Training item = 9950; break; case 24: // White Talisman of Protection item = 9965; break; case 25: // Orange Talisman - Hot Springs CP Potion item = 9952; break; case 26: // Orange Talisman - Elixir of Life item = 9953; break; case 27: // Orange Talisman - Elixir of Mental Strength item = 9954; break; case 28: // Black Talisman - Vocalization item = 9955; break; case 29: // Black Talisman - Arcane Freedom item = 9956; break; case 30: // Black Talisman - Physical Freedom item = 9957; break; case 31: // Black Talisman - Rescue item = 9958; break; case 32: // Black Talisman - Free Speech item = 9959; break; case 33: // White Talisman of Bravery item = 9960; break; case 34: // White Talisman of Motion item = 9961; break; case 35: // White Talisman of Grounding item = 9962; break; case 36: // White Talisman of Attention item = 9963; break; case 37: // White Talisman of Bandages item = 9964; break; case 38: // White Talisman - Storm item = 10418; break; case 39: // White Talisman - Water item = 10420; break; case 40: // White Talisman - Earth item = 10519; break; case 41: // White Talisman - Light item = 10422; break; case 42: // Blue Talisman - Self-Destruction item = 10423; break; case 43: // White Talisman - Darkness item = 10419; break; default: // White Talisman - Fire item = 10421; } } if (player.destroyItemByItemId("ExchangeKE", 9912, 10, this, false)) { SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_DISAPPEARED); msg.addItemName(9912); msg.addNumber(10); player.sendPacket(msg); player.addItem("ExchangeKE", item, 1, player, true); filename = "data/html/castlemagician/magician-KE-Exchange.htm"; } else filename = "data/html/castlemagician/magician-no-KE.htm"; showChatWindow(player, filename); return; } else if (command.equals("gotoleader")) { if (player.getClan() != null) { L2PcInstance clanLeader = player.getClan().getLeader().getPlayerInstance(); if (clanLeader == null) return; if (clanLeader.getFirstEffect(L2EffectType.CLAN_GATE) != null) { if (!validateGateCondition(clanLeader, player)) return; player.teleToLocation(clanLeader.getX(), clanLeader.getY(), clanLeader.getZ(), false); return; } String filename = "data/html/castlemagician/magician-nogate.htm"; showChatWindow(player, filename); } return; } else if (command.equals("subskills")) { if (player.getClan() != null) { if (player.isClanLeader()) { AcquireSkillList skilllist = new AcquireSkillList(SkillType.SubClass); FastList<L2SkillLearn> list = SkillTreesData.getInstance().getAvailableSubPledgeSkills(player.getClan()); if (list.isEmpty()) { player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN); return; } for (L2SkillLearn skillLearn : list) { skilllist.addSkill( skillLearn.getSkillId(), skillLearn.getSkillLevel(), skillLearn.getSkillLevel(), skillLearn.getLevelUpSp(), 0); } player.sendPacket(skilllist); } else { String filename = "data/html/castlemagician/magician-nosquad.htm"; showChatWindow(player, filename); } } } else super.onBypassFeedback(player, command); }