from com.l2jfrozen.gameserver.model.quest.jython import QuestJython class GreetingQuest(QuestJython): def __init__(self, id, name, descr): QuestJython.__init__(self, id, name, descr) def onEvent(self, event, st): if event == "hello": st.giveItems(12345, 1) st.playSound("ItemSound.quest_itemget") st.exitQuest(False) return "Congratulations, you received an item!" return def onTalk(self, npc, player): return "Hello there, would you like to receive an item?" QUEST = GreetingQuest(1, "greeting", "A simple greeting quest.")
from com.l2jfrozen.gameserver.model.quest.jython import QuestJython class OrcRaider(QuestJython): ON_ATTACK = 1 ON_KILL = 2 def __init__(self, id, name, descr): QuestJython.__init__(self, id, name, descr) self.questItems = [12345, 12346, 12347] self.raiders = [20101, 20102, 20103, 20104] self.addTalkId(self.raiders) self.addAttackId(self.raiders) def onAttack(self, npc, player, damage, isPet): if npc.getNpcId() in self.raiders: self.showQuestMark(npc, player) return def onKill(self, npc, player, isPet): if npc.getNpcId() in self.raiders: st = self.getQuestState(player, False) if not st: return if st.getState() != self.STARTED: st.setState(self.STARTED) st.set("cond", "1") self.playSound(player, "ItemSound.quest_accept") st.giveItems(self.questItems[npc.getNpcId() - 20101], 1) if st.getQuestItemsCount(self.questItems[npc.getNpcId() - 20101]) == 10: st.playSound("ItemSound.quest_middle") st.set("cond", "2") else: st.playSound("ItemSound.quest_itemget") return def onTalk(self, npc, player): st = self.getQuestState(player, False) if not st: return "This quest can't be taken." npcId = npc.getNpcId() if st.getState() == self.CREATED and npcId in self.raiders: return "A group of orcs have been seen raiding the nearby villages, can you help us deal with them?" elif st.getState() == self.COMPLETED and npcId == self.raiders[0]: return "Thank you for your help, the villages are safe now." elif st.getState() == self.STARTED and st.getQuestItemsCount(self.questItems[npcId - 20101]) == 10: st.takeItems(self.questItems[npcId - 20101], 10) st.playSound("ItemSound.quest_finish") st.exitQuest(True) return "Thank you for dealing with the orcs, I hope this reward is sufficient." return "I need your help to deal with the orcs raiding the villages, are you willing to help?" QUEST = OrcRaider(1, "orc_raider", "Dealing with a group of orc raiders.")This example demonstrates a more complex quest that involves killing multiple types of NPCs and collecting quest items from them. It also shows how to handle dialogue with different NPCs based on the player's progress in the quest.