private static String getDropListButtons(L2Npc npc) { final StringBuilder sb = new StringBuilder(); final Map<DropListScope, List<IDropItem>> dropLists = npc.getTemplate().getDropLists(); if ((dropLists != null) && !dropLists.isEmpty() && (dropLists.containsKey(DropListScope.DEATH) || dropLists.containsKey(DropListScope.CORPSE))) { sb.append("<table width=275 cellpadding=0 cellspacing=0><tr>"); if (dropLists.containsKey(DropListScope.DEATH)) { sb.append( "<td align=center><button value=\"Show Drop\" width=100 height=25 action=\"bypass NpcViewMod dropList DEATH " + npc.getObjectId() + "\" back=\"L2UI_CT1.Button_DF_Calculator_Down\" fore=\"L2UI_CT1.Button_DF_Calculator\"></td>"); } if (dropLists.containsKey(DropListScope.CORPSE)) { sb.append( "<td align=center><button value=\"Show Spoil\" width=100 height=25 action=\"bypass NpcViewMod dropList CORPSE " + npc.getObjectId() + "\" back=\"L2UI_CT1.Button_DF_Calculator_Down\" fore=\"L2UI_CT1.Button_DF_Calculator\"></td>"); } sb.append("</tr></table>"); } return sb.toString(); }
@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { final QuestState qs = getQuestState(killer, false); if ((qs != null) && qs.isCond(1) && (getQuestItemsCount(killer, PECULIAR_MUSHROOM_SPORE) < 10)) { switch (npc.getId()) { case GROWLER: case ROBUST_GROWLER: { final int killCount = qs.getInt(KILL_VAR) + 1; if (killCount >= 3) { addAttackPlayerDesire(addSpawn(EVOLVED_GROWLER, npc.getLocation()), killer); qs.set(KILL_VAR, 0); } else { qs.set(KILL_VAR, killCount); } break; } case EVOLVED_GROWLER: { if (giveItemRandomly(killer, npc, PECULIAR_MUSHROOM_SPORE, 1, 10, 1.0, true)) { qs.setCond(2); } break; } } } return super.onKill(npc, killer, isSummon); }
@Override public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) { final QuestState st = getQuestState(player, false); if (st == null) { return null; } for (int _gk[] : _gatekeepers) { if (npc.getId() == _gk[0]) { // Drop key npc.dropItem(player, _gk[1], 1); // Check if gatekeeper should open bridge, and open it if (_gk[2] > 0) { final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId()); if (tmpworld instanceof NornilsWorld) { openDoor(_gk[2], tmpworld.getInstanceId()); } } } if (npc.getId() == 18355) { spawn2(npc); } } return super.onKill(npc, player, isSummon); }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { final QuestState st = getQuestState(player, false); if (st == null) { return null; } String htmltext = event; switch (event) { case "32650-04.htm": case "32650-05.htm": case "32650-06.html": break; case "32650-07.htm": st.startQuest(); break; case "despawn": npc.setBusy(false); npc.deleteMe(); htmltext = null; break; default: htmltext = null; break; } return htmltext; }
@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { final ItemChanceHolder holder = MONSTERS.get(npc.getId()); if (getRandom(10000) <= holder.getChance()) { npc.dropItem(killer, holder); } return super.onKill(npc, killer, isSummon); }
@Override public final String onTalk(L2Npc npc, L2PcInstance player) { if (Util.contains(_final_gates, npc.getId())) { return npc.getId() + "-01.html"; } return null; }
private boolean isInSiege(L2Npc npc) { if ((npc.getConquerableHall() != null) && npc.getConquerableHall().isInSiege()) { return true; } else if (npc.getCastle().getSiege().isInProgress()) { return true; } return false; }
/** UnSpawns the TvTEvent npc */ private static void unSpawnNpc() { // Delete the npc _lastNpcSpawn.deleteMe(); SpawnTable.getInstance().deleteSpawn(_lastNpcSpawn.getSpawn(), false); // Stop respawning of the npc _npcSpawn.stopRespawn(); _npcSpawn = null; _lastNpcSpawn = null; }
@Override public final String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) { if ((npc.getId() == _herb_jar) && !npc.isDead()) { dropHerb(npc, attacker, HP_HERBS_DROPLIST); dropHerb(npc, attacker, MP_HERBS_DROPLIST); npc.doDie(attacker); } else if ((npc.getId() == 18362) && (npc.getInstanceId() > 0)) { spawn1(npc); } return null; }
private void spawn1(L2Npc npc) { final InstanceWorld inst = InstanceManager.getInstance().getWorld(npc.getInstanceId()); if (inst instanceof NornilsWorld) { final NornilsWorld world = ((NornilsWorld) inst); if (npc.equals(world.first_npc) && !world.spawned_1) { world.spawned_1 = true; for (int mob[] : _group_1) { addSpawn(mob[0], mob[1], mob[2], mob[3], mob[4], false, 0, false, world.getInstanceId()); } } } }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { final QuestState st = getQuestState(player, true); String htmltext = getNoQuestMsg(player); if (st == null) { return htmltext; } switch (st.getState()) { case State.COMPLETED: { if (npc.getId() == NAMELESS_SPIRIT) { htmltext = "31453-06.html"; } break; } case State.CREATED: { htmltext = ((player.getLevel() >= MIN_LEVEL) && st.hasQuestItems(ANTIQUE_BROOCH)) ? "31453-01.htm" : "31453-05.html"; break; } case State.STARTED: { if (npc.getId() == NAMELESS_SPIRIT) { if (st.isCond(1)) { if (st.hasQuestItems(ANTIQUE_BROOCH)) { htmltext = "31453-07.html"; } else { htmltext = "31453-08.html"; st.exitQuest(true); } } else if (st.isCond(2)) { htmltext = "31453-09.html"; } } else if (npc.getId() == DEVORIN) { if (st.isCond(1)) { htmltext = "32009-01.html"; } else if (st.isCond(2)) { htmltext = "32009-05.html"; } } break; } } return htmltext; }
@Override public String onSpawn(L2Npc npc) { if (IS_STARTED) { switch (npc.getId()) { case 32433: { autoChat(npc, MESSAGES[0], ChatType.NPC_SHOUT); startQuestTimer("1", 30000, npc, null); break; } case 32431: { npc.getAI() .setIntention( CtrlIntention.AI_INTENTION_MOVE_TO, new Location(-56657, -56338, -2008, 33102)); startQuestTimer("social1", 6000, npc, null, true); startQuestTimer("7", 215000, npc, null); break; } case 32432: { startQuestTimer("social1", 6000, npc, null, true); startQuestTimer("7", 215000, npc, null); break; } case 32442: case 32443: case 32444: case 32445: case 32446: { startQuestTimer("11", 100000, npc, null); break; } case 32424: case 32425: case 32426: case 32427: case 32428: { startQuestTimer("social1", 5500, npc, null); startQuestTimer("social1", 12500, npc, null); startQuestTimer("28", 19700, npc, null); break; } } } return super.onSpawn(npc); }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { final QuestState qs = getQuestState(player, true); String texthtml = null; switch (qs.getState()) { case State.CREATED: { texthtml = npc.getId() == ZENATH ? "33509-01.htm" : getNoQuestMsg(player); break; } case State.STARTED: { switch (npc.getId()) { case ZENATH: { if (qs.isCond(1)) { texthtml = "33509-03.htm"; } else if (qs.isCond(2)) // report defeated kanilov, get the sketch { giveItems(player, SAKUMS_SKETCH_A, 1); qs.setCond(3); texthtml = "33509-05.html"; } else { texthtml = "33509-06.html"; } break; } case ADV_GUILDSMAN: { if (qs.isCond(3)) // start end quest dialogs { texthtml = "31795-01.html"; } else { texthtml = getNoQuestMsg(player); } break; } } break; } case State.COMPLETED: { texthtml = npc.getId() == ADV_GUILDSMAN ? "31795-04.html" : getAlreadyCompletedMsg(player); break; } } return texthtml; }
public ServerObjectInfo(L2Npc activeChar, L2Character actor) { _activeChar = activeChar; _idTemplate = _activeChar.getTemplate().getDisplayId(); _isAttackable = _activeChar.isAutoAttackable(actor); _collisionHeight = _activeChar.getCollisionHeight(); _collisionRadius = _activeChar.getCollisionRadius(); _x = _activeChar.getX(); _y = _activeChar.getY(); _z = _activeChar.getZ(); _heading = _activeChar.getHeading(); _name = _activeChar.getTemplate().isUsingServerSideName() ? _activeChar.getTemplate().getName() : ""; }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { final QuestState qs = getQuestState(player, true); String htmltext = getNoQuestMsg(player); if (qs.isCompleted()) { return getAlreadyCompletedMsg(player); } if (player.getRace() == Race.ERTHEIA) { return "31292-noErtheia.html"; } if (player.isMageClass()) { return "31292-noMage.html"; } switch (npc.getId()) { case ANDREI: { if (qs.isCreated()) { htmltext = "31292-01.htm"; } else if (qs.isStarted()) { htmltext = "31292-03.html"; } break; } case JANITT: { if (qs.isCond(1)) { htmltext = "33851-01.html"; } break; } } return htmltext; }
@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { switch (npc.getId()) { case LIZARDMAN_SUB_LEADER: case LIZARDMAN_SENTINEL: { final QuestState qs = getRandomPartyMemberState(killer, 1, 3, npc); if ((qs != null) && giveItemRandomly( qs.getPlayer(), npc, FEATHER.getId(), 1, FEATHER.getCount(), 1.0, true)) { qs.setCond(2); } break; } case LIZARDMAN_LEADER: case LIZARDMAN_SHAMAN: { final QuestState qs = getRandomPartyMemberState(killer, 6, 3, npc); if ((qs != null) && giveItemRandomly( qs.getPlayer(), npc, TOTEM_TOOTH_2ND.getId(), 1, TOTEM_TOOTH_2ND.getCount(), 0.5, true)) { qs.setCond(7); } break; } } return super.onKill(npc, killer, isSummon); }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { final QuestState qs = getQuestState(player, true); String htmltext = getNoQuestMsg(player); if (qs.isCompleted()) { htmltext = getAlreadyCompletedMsg(player); } switch (npc.getId()) { case LEIRA: { if (qs.isCreated()) { htmltext = "33952-01.htm"; } else if (qs.isStarted()) { htmltext = "33952-03.html"; } break; } case MILONE: { if (qs.isCond(2)) { htmltext = "33953-01.html"; } break; } } return htmltext; }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = getNoQuestMsg(player); final QuestState st = getQuestState(player, true); if (st == null) { return htmltext; } switch (npc.getId()) { case ANTON: switch (st.getState()) { case State.CREATED: htmltext = (player.getLevel() < 75) ? "31338-0a.htm" : "31338-0b.htm"; break; case State.STARTED: htmltext = "31338-1a.html"; break; case State.COMPLETED: htmltext = getAlreadyCompletedMsg(player); break; } break; case MARQUEZ: if (st.isCond(1)) { htmltext = "32113-1.html"; } break; } return htmltext; }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { final QuestState qs = getQuestState(player, true); String htmltext = getNoQuestMsg(player); if (qs.isCompleted()) { return getAlreadyCompletedMsg(player); } if (player.getRace() == Race.ERTHEIA) { return "33864-noErtheia.html"; } switch (npc.getId()) { case PATERSON: { if (qs.isCreated()) { htmltext = "33864-01.htm"; } else if (qs.isStarted()) { htmltext = "33864-03.html"; } break; } case SHUVANN: { if (qs.isCond(1)) { htmltext = "33867-01.html"; } break; } } return htmltext; }
private static final void dropHerb(L2Npc mob, L2PcInstance player, int[][] drop) { final int chance = getRandom(100); for (int[] element : drop) { if (chance < element[2]) { mob.dropItem(player, element[0], element[1]); } } }
@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { if (Util.checkIfInRange(1500, killer, npc, true)) { for (int i = 0; i < 20; i++) { final L2Npc guardian = addSpawn(SOUL_OF_TREE_GUARDIAN, npc); startQuestTimer("DESPAWN_GUARDIAN", 300000, guardian, null); if (i == 0) { npc.setTarget(killer); npc.doCast(VICIOUS_POISON.getSkill()); } npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, killer); } } return super.onKill(npc, killer, isSummon); }
/** * Starts the participation of the TvTEvent<br> * 1. Get L2NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br> * 2. Try to spawn a new npc of it<br> * <br> * * @return boolean: true if success, otherwise false<br> */ public static boolean startParticipation() { try { _npcSpawn = new L2Spawn(Config.TVT_EVENT_PARTICIPATION_NPC_ID); _npcSpawn.setX(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0]); _npcSpawn.setY(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1]); _npcSpawn.setZ(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]); _npcSpawn.setAmount(1); _npcSpawn.setHeading(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[3]); _npcSpawn.setRespawnDelay(1); // later no need to delete spawn from db, we don't store it (false) SpawnTable.getInstance().addNewSpawn(_npcSpawn, false); _npcSpawn.init(); _lastNpcSpawn = _npcSpawn.getLastSpawn(); _lastNpcSpawn.setCurrentHp(_lastNpcSpawn.getMaxHp()); _lastNpcSpawn.setTitle("TvT Event Participation"); _lastNpcSpawn.isAggressive(); _lastNpcSpawn.decayMe(); _lastNpcSpawn.spawnMe( _npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ()); _lastNpcSpawn.broadcastPacket(new MagicSkillUse(_lastNpcSpawn, _lastNpcSpawn, 1034, 1, 1, 1)); } catch (Exception e) { _log.log( Level.WARNING, "TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e.getMessage(), e); return false; } setState(EventState.PARTICIPATING); EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventRegistrationStart()); return true; }
@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 "32975-03.htm": { qs.startQuest(); qs.setCond(2); // show arrow hack qs.setCond(1); player.sendPacket( new TutorialShowHtml( npc.getObjectId(), "..\\L2Text\\QT_027_Quest_01.htm", TutorialShowHtml.LARGE_WINDOW)); htmltext = event; break; } case "32975-02.htm": { htmltext = event; break; } case "32974-02.html": { giveAdena(player, 50, true); addExpAndSp(player, 40, 5); qs.exitQuest(false, true); Broadcast.toKnownPlayers( npc, new NpcSay( npc.getObjectId(), ChatType.NPC_GENERAL, npc.getTemplate().getDisplayId(), NpcStringId.HM_DON_T_JUST_GO_I_STILL_HAVE_TONS_TO_TEACH_YOU)); htmltext = event; break; } } return htmltext; }
@Override public String onFirstTalk(L2Npc npc, L2PcInstance player) { String htmltext = null; if (player.isClanLeader() && (player.getClanId() == npc.getCastle().getOwnerId())) { if (isInSiege(npc)) { htmltext = "CastleSiegeManager.html"; } else { htmltext = "CastleSiegeManager-01.html"; } } else if (isInSiege(npc)) { htmltext = "CastleSiegeManager-02.html"; } else { if (npc.getConquerableHall() != null) { npc.getConquerableHall().showSiegeInfo(player); } else { npc.getCastle().getSiege().listRegisterClan(player); } } return htmltext; }
@Override protected final void writeImpl() { writeC(0x92); writeD(_activeChar.getObjectId()); writeD(_idTemplate + 1000000); writeS(_name); // name writeD(_isAttackable ? 1 : 0); writeD(_x); writeD(_y); writeD(_z); writeD(_heading); writeF(1.0); // movement multiplier writeF(1.0); // attack speed multiplier writeF(_collisionRadius); writeF(_collisionHeight); writeD((int) (_isAttackable ? _activeChar.getCurrentHp() : 0)); writeD(_isAttackable ? _activeChar.getMaxHp() : 0); writeD(0x01); // object type writeD(0x00); // special effects }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { final QuestState st = getQuestState(player, true); final QuestState st2 = player.getQuestState(Q00115_TheOtherSideOfTruth.class.getSimpleName()); String htmltext = getNoQuestMsg(player); switch (npc.getId()) { case RAFFORTY: { if (st.isCreated()) { if (player.getLevel() < MIN_LVL) { htmltext = "32020-01.htm"; } else { htmltext = ((st2 != null) && (st2.isCompleted())) ? "32020-02.htm" : "32020-03.htm"; } } else if (st.isStarted()) { final long hasQuestItems = getQuestItemsCount(player, SILVER_ICE_CRYSTAL, BLACK_ICE_CRYSTAL); if ((st2 != null) && st2.isCompleted()) { htmltext = (hasQuestItems > 0) ? "32020-13.html" : "32020-11.html"; if (st.isCond(1)) { st.setCond(2, true); } } else { htmltext = (hasQuestItems > 0) ? "32020-12.html" : "32020-10.html"; } } break; } case ICE_SHELF: { // TODO: In High Five this quest have an updated reward system. if (st.isStarted()) { if (hasQuestItems(player, SILVER_ICE_CRYSTAL)) { final int val = st.getInt("ex") % 10; if (val == 0) { htmltext = "32023-03.html"; st.set("ex", 0); } else { htmltext = "32023-09.html"; } } else { htmltext = "32023-02.html"; } } else { htmltext = "32023-01.html"; } break; } } return htmltext; }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { final QuestState qs = getQuestState(player, true); String htmltext = null; switch (qs.getState()) { case State.CREATED: { htmltext = npc.getId() == THEODORE ? "32975-01.htm" : "32974-04.html"; break; } case State.STARTED: { htmltext = npc.getId() == THEODORE ? "32975-04.html" : "32974-01.html"; break; } case State.COMPLETED: { htmltext = npc.getId() == THEODORE ? "32975-05.html" : "32974-03.html"; break; } } return htmltext; }
@Override public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmltext = event; final QuestState st = getQuestState(player, false); if (st == null) { return getNoQuestMsg(player); } if ((npc.getId() == _garden_guard) && event.equalsIgnoreCase("enter_instance")) { try { htmltext = enterInstance(npc, player); } catch (Exception e) { } } else if ((npc.getId() == 32258) && event.equalsIgnoreCase("exit")) { try { exitInstance(player); } catch (Exception e) { } } else if (Util.contains(_final_gates, npc.getId())) { if (event.equalsIgnoreCase("32260-02.html") || event.equalsIgnoreCase("32261-02.html") || event.equalsIgnoreCase("32262-02.html")) { st.unset("correct"); } else if (Util.isDigit(event)) { int correct = st.getInt("correct"); correct++; st.set("correct", String.valueOf(correct)); htmltext = npc.getId() + "-0" + String.valueOf(correct + 2) + ".html"; } else if (event.equalsIgnoreCase("check")) { final int correct = st.getInt("correct"); if ((npc.getId() == 32260) && (correct == 3)) { openDoor(st, player, 16200014); } else if ((npc.getId() == 32261) && (correct == 3)) { openDoor(st, player, 16200015); } else if ((npc.getId() == 32262) && (correct == 4)) { openDoor(st, player, 16200016); } else { return npc.getId() + "-00.html"; } } } return htmltext; }
@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { final QuestState st = getRandomPartyMemberState(killer, -1, 3, npc); if (st != null) { final DropInfo info = MONSTERS.get(npc.getId()); if (st.getCond() >= 1) { giveItemRandomly( st.getPlayer(), npc, SILVER_ICE_CRYSTAL, 1, 0, info.getFirstChance(), true); } if (info.getSecondChance() > 0) { final QuestState st2 = st.getPlayer().getQuestState(Q00115_TheOtherSideOfTruth.class.getSimpleName()); if ((st.getCond() >= 2) && (st2 != null) && st2.isCompleted()) { giveItemRandomly( st.getPlayer(), npc, SILVER_HEMOCYTE, 1, 0, info.getSecondChance(), true); } } } return super.onKill(npc, killer, isSummon); }
@Override public String onSpawn(L2Npc npc) { switch (npc.getId()) { case WITCH_ATHREA: { if (npc.isScriptValue(50301)) { startQuestTimer("DESPAWN_WITCH_ATHREA", 5000, npc, null); npc.broadcastPacket(new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.WAR_AND_DEATH)); } break; } case WITCH_KALIS: { if (npc.isScriptValue(50302)) { startQuestTimer("DESPAWN_WITCH_KALIS", 5000, npc, null); npc.broadcastPacket( new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.AMBITION_AND_POWER)); } break; } case IMPERIAL_COFFER: { startQuestTimer("DESPAWN_IMPERIAL_COFFER", 180000, npc, null); npc.broadcastPacket( new NpcSay( npc, ChatType.NPC_GENERAL, NpcStringId .CURSE_OF_THE_GODS_ON_THE_ONE_THAT_DEFILES_THE_PROPERTY_OF_THE_EMPIRE)); break; } case BLITZ_WYRM: { startQuestTimer("DESPAWN_BLITZ_WYRM", 180000, npc, null); break; } } return super.onSpawn(npc); }