From 17452d90cc46667c2b896ab7455cf8295bcc2704 Mon Sep 17 00:00:00 2001 From: St3eT <St3eT@users.noreply.github.com> Date: Sat, 25 Jan 2014 22:42:10 +0000 Subject: [PATCH] BETA: Updated quest '''Lost And Found''' (457) * Reviewed by: malyelfik, Zoey76, Adry_85 * Tested by: St3eT, malyelfik --- .../Q00457_LostAndFound.java | 130 ++++++++++-------- 1 file changed, 70 insertions(+), 60 deletions(-) diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/quests/Q00457_LostAndFound/Q00457_LostAndFound.java b/L2J_DataPack_BETA/dist/game/data/scripts/quests/Q00457_LostAndFound/Q00457_LostAndFound.java index 473ca8c248..24e63fdeda 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts/quests/Q00457_LostAndFound/Q00457_LostAndFound.java +++ b/L2J_DataPack_BETA/dist/game/data/scripts/quests/Q00457_LostAndFound/Q00457_LostAndFound.java @@ -32,6 +32,7 @@ import com.l2jserver.gameserver.model.quest.State; import com.l2jserver.gameserver.network.NpcStringId; import com.l2jserver.gameserver.network.clientpackets.Say2; import com.l2jserver.gameserver.network.serverpackets.CreatureSay; +import com.l2jserver.gameserver.network.serverpackets.NpcSay; /** * Lost and Found (457) @@ -39,6 +40,7 @@ import com.l2jserver.gameserver.network.serverpackets.CreatureSay; */ public final class Q00457_LostAndFound extends Quest { + // NPCs private static final int GUMIEL = 32759; private static final int ESCORT_CHECKER = 32764; private static final int[] SOLINA_CLAN = @@ -48,14 +50,11 @@ public final class Q00457_LostAndFound extends Quest 22791, // Savior Solina 22793, // Ascetic Solina }; - + // Misc private static final int PACKAGED_BOOK = 15716; - private static final int CHANCE_SPAWN = 1; // 1% - - private static int _count = 0; + private static final int MIN_LV = 82; private static Set<L2Spawn> _escortCheckers; - private static L2Npc _gumiel = null; private Q00457_LostAndFound(int id, String name, String descr) { @@ -63,7 +62,6 @@ public final class Q00457_LostAndFound extends Quest addStartNpc(GUMIEL); addFirstTalkId(GUMIEL); addTalkId(GUMIEL); - addSpawnId(GUMIEL); addKillId(SOLINA_CLAN); _escortCheckers = SpawnTable.getInstance().getSpawns(ESCORT_CHECKER); @@ -82,52 +80,63 @@ public final class Q00457_LostAndFound extends Quest switch (event) { case "32759-06.html": - _count = 0; + { + npc.setScriptValue(0); st.startQuest(); npc.setTarget(player); npc.setWalking(); npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player); - startQuestTimer("check", 1000, npc, player, true); - startQuestTimer("time_limit", 600000, npc, player); - startQuestTimer("talk_time", 120000, npc, player); - startQuestTimer("talk_time2", 30000, npc, player); + startQuestTimer("CHECK", 1000, npc, player, true); + startQuestTimer("TIME_LIMIT", 600000, npc, player); + startQuestTimer("TALK_TIME", 120000, npc, player); + startQuestTimer("TALK_TIME2", 30000, npc, player); break; - case "talk_time": - npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.NPC_ALL, npc.getName(), NpcStringId.AH_I_THINK_I_REMEMBER_THIS_PLACE)); + } + case "TALK_TIME": + { + broadcastNpcSay(npc, player, NpcStringId.AH_I_THINK_I_REMEMBER_THIS_PLACE, false); break; - case "talk_time2": - npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.NPC_ALL, npc.getName(), NpcStringId.WHAT_WERE_YOU_DOING_HERE)); - startQuestTimer("talk_time3", 10 * 1000, npc, player); + } + case "TALK_TIME2": + { + broadcastNpcSay(npc, player, NpcStringId.WHAT_WERE_YOU_DOING_HERE, false); + startQuestTimer("TALK_TIME3", 10 * 1000, npc, player); break; - case "talk_time3": - npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.NPC_ALL, npc.getName(), NpcStringId.I_GUESS_YOURE_THE_SILENT_TYPE_THEN_ARE_YOU_LOOKING_FOR_TREASURE_LIKE_ME)); + } + case "TALK_TIME3": + { + broadcastNpcSay(npc, player, NpcStringId.I_GUESS_YOURE_THE_SILENT_TYPE_THEN_ARE_YOU_LOOKING_FOR_TREASURE_LIKE_ME, false); break; - case "time_limit": - startQuestTimer("stop", 2000, npc, player); + } + case "TIME_LIMIT": + { + startQuestTimer("STOP", 2000, npc, player); st.exitQuest(QuestType.DAILY); break; - case "check": - final double distance = npc.calculateDistance(player, false, false); + } + case "CHECK": + { + final double distance = npc.calculateDistance(player, true, false); if (distance > 1000) { if (distance > 5000) { - startQuestTimer("stop", 2000, npc, player); + startQuestTimer("STOP", 2000, npc, player); st.exitQuest(QuestType.DAILY); } - else if (_count == 0) + else if (npc.isScriptValue(0)) { - npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.NPC_ALL, npc.getName(), NpcStringId.HEY_DONT_GO_SO_FAST)); - _count = 1; + broadcastNpcSay(npc, player, NpcStringId.HEY_DONT_GO_SO_FAST, true); + npc.setScriptValue(1); } - else if (_count == 1) + else if (npc.isScriptValue(1)) { - npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.NPC_ALL, npc.getName(), NpcStringId.ITS_HARD_TO_FOLLOW)); - _count = 2; + broadcastNpcSay(npc, player, NpcStringId.ITS_HARD_TO_FOLLOW, true); + npc.setScriptValue(2); } - else if (_count == 2) + else if (npc.isScriptValue(2)) { - startQuestTimer("stop", 2000, npc, player); + startQuestTimer("STOP", 2000, npc, player); st.exitQuest(QuestType.DAILY); } } @@ -136,29 +145,34 @@ public final class Q00457_LostAndFound extends Quest final L2Npc escort = escortSpawn.getLastSpawn(); if ((escort != null) && npc.isInsideRadius(escort, 1000, false, false)) { - startQuestTimer("stop", 1000, npc, player); - startQuestTimer("bye", 3000, npc, player); - cancelQuestTimer("check", npc, player); + startQuestTimer("STOP", 1000, npc, player); + startQuestTimer("BYE", 3000, npc, player); + cancelQuestTimer("CHECK", npc, player); npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.NPC_ALL, npc.getName(), NpcStringId.AH_FRESH_AIR)); + broadcastNpcSay(npc, player, NpcStringId.AH_FRESH_AIR, false); st.giveItems(PACKAGED_BOOK, 1); st.exitQuest(QuestType.DAILY, true); break; } } break; - case "stop": + } + case "STOP": + { npc.setTarget(null); npc.getAI().stopFollow(); npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); - cancelQuestTimer("check", npc, player); - cancelQuestTimer("time_limit", npc, player); - cancelQuestTimer("talk_time", npc, player); - cancelQuestTimer("talk_time2", npc, player); - _gumiel = null; + cancelQuestTimer("CHECK", npc, player); + cancelQuestTimer("TIME_LIMIT", npc, player); + cancelQuestTimer("TALK_TIME", npc, player); + cancelQuestTimer("TALK_TIME2", npc, player); break; - case "bye": + } + case "BYE": + { npc.deleteMe(); break; + } default: { htmltext = event; @@ -173,14 +187,7 @@ public final class Q00457_LostAndFound extends Quest { if (npc.getTarget() != null) { - if (npc.getTarget().equals(player)) - { - return "32759-08.html"; - } - else if (_gumiel != null) - { - return "32759-01a.html"; - } + return npc.getTarget().equals(player) ? "32759-08.html" : "32759-01a.html"; } return "32759.html"; } @@ -188,21 +195,15 @@ public final class Q00457_LostAndFound extends Quest @Override public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) { - if ((_gumiel == null) && (getRandom(100) < CHANCE_SPAWN)) + QuestState st = player.getQuestState(getName()); + + if ((getRandom(100) < CHANCE_SPAWN) && st.isNowAvailable() && (player.getLevel() >= MIN_LV)) { addSpawn(GUMIEL, npc); } return super.onKill(npc, player, isSummon); } - @Override - public String onSpawn(L2Npc npc) - { - _gumiel = npc; - _gumiel.getSpawn().stopRespawn(); - return super.onSpawn(npc); - } - @Override public String onTalk(L2Npc npc, L2PcInstance player) { @@ -216,23 +217,32 @@ public final class Q00457_LostAndFound extends Quest switch (st.getState()) { case State.CREATED: - htmltext = (player.getLevel() > 81) ? "32759-01.htm" : "32759-03.html"; + { + htmltext = (player.getLevel() >= MIN_LV) ? "32759-01.htm" : "32759-03.html"; break; + } case State.COMPLETED: + { if (st.isNowAvailable()) { st.setState(State.CREATED); - htmltext = (player.getLevel() > 81) ? "32759-01.htm" : "32759-03.html"; + htmltext = (player.getLevel() >= MIN_LV) ? "32759-01.htm" : "32759-03.html"; } else { htmltext = "32759-02.html"; } break; + } } return htmltext; } + public void broadcastNpcSay(L2Npc npc, L2PcInstance player, NpcStringId stringId, boolean whisper) + { + ((whisper) ? player : npc).sendPacket(new NpcSay(npc.getObjectId(), ((whisper) ? Say2.TELL : Say2.ALL), npc.getId(), stringId)); + } + public static void main(String[] args) { new Q00457_LostAndFound(457, Q00457_LostAndFound.class.getSimpleName(), "Lost and Found"); -- GitLab