from com.l2jserver.gameserver.model.quest.jython import QuestJython class MyQuest(QuestJython): def __init__(self, questId, name, descr): QuestJython.__init__(self, questId, name, descr) def onEvent(self, event, st): if event == "start_quest": st.set("cond", "1") st.setState(STARTED) st.playSound("ItemSound.quest_accept") return "1.htm" elif event == "give_reward": st.exitQuest(1) st.giveItems(1234, 1) st.playSound("ItemSound.quest_finish") return "2.htm" return "" def onTalk(self, npc, st): state = st.getState() if state == CREATED: return "0.htm" elif state == STARTED: if st.getQuestItemsCount(1234) >= 1: return "3.htm" else: return "4.htm" return "" myQuest = MyQuest(123, "My Quest", "A simple quest that gives an item as a reward.")
from com.l2jserver.gameserver.model.quest.jython import QuestJython class MyQuest(QuestJython): def __init__(self, questId, name, descr): QuestJython.__init__(self, questId, name, descr) self.itemIds = [5678, 6789] # ids of the items to collect self.npcIds = [1234, 2345] # ids of the npcs to talk to def onEvent(self, event, st): if event == "start_quest": st.set("cond", "1") st.setState(STARTED) st.playSound("ItemSound.quest_accept") return "1.htm" elif event == "give_reward": st.exitQuest(1) st.giveItems(4321, 1) st.playSound("ItemSound.quest_finish") return "2.htm" return "" def onTalk(self, npc, st): state = st.getState() npcId = npc.getNpcId() if state == CREATED: return "0.htm" elif state == STARTED: cond = st.getInt("cond") if npcId in self.npcIds: if cond == 1: return "3.htm" elif st.getQuestItemsCount(self.itemIds[0]) >= 10: st.set("cond", "2") return "4.htm" elif st.getQuestItemsCount(self.itemIds[1]) >= 10: st.set("cond", "2") return "5.htm" else: return "6.htm" elif npcId == 12345 and cond == 2: st.takeItems(self.itemIds[0], -1) st.takeItems(self.itemIds[1], -1) st.set("cond", "3") return "7.htm" elif npcId == 12345 and cond == 3: return "8.htm" return "" myQuest = MyQuest(123, "My Quest", "A quest that requires the player to collect items and talk to NPCs to complete it.")