Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from l2jorion.game.model.quest import State
- from l2jorion.game.model.quest import QuestState
- from l2jorion.game.model.quest.jython import QuestJython as JQuest
- # Constants for item IDs
- ORB_OF_WATER = 9998
- ORB_OF_FIRE = 9999
- ORB_OF_WIND = 10000
- ORB_OF_EARTH = 10001
- STONE_OF_VALOR = 10002
- # Constants for NPC IDs
- QUEST_NPC_ID = 70737
- SYLPH_IDS = [57000, 57001, 57002, 57003]
- # DROPLIST for items
- DROPLIST = {
- 57000: [ORB_OF_WIND, 100],
- 57001: [ORB_OF_EARTH, 100],
- 57002: [ORB_OF_FIRE, 100],
- 57003: [ORB_OF_WATER, 100],
- }
- class Quest(JQuest):
- def __init__(self, id, name, descr):
- JQuest.__init__(self, id, name, descr)
- def onEvent(self, event, st):
- htmltext = event
- if event == "70737-03.htm":
- st.set("cond", "1")
- st.set("last_completion_time", str(time.time())) # Store completion time
- st.setState(STARTED)
- st.playSound("ItemSound.quest_accept")
- elif event == "70737-06.htm":
- st.exitQuest(1)
- st.playSound("ItemSound.quest_finish")
- return htmltext
- def onTalk(self, npc, player):
- htmltext = "<html><body>You are either not carrying out your quest or don't meet the criteria.</body></html>"
- st = player.getQuestState(qn)
- if not st:
- return htmltext
- npcId = npc.getNpcId()
- id = st.getState()
- if id == CREATED:
- st.set("cond", "0")
- if st.getInt("cond") == 0:
- if player.getLevel() < 76:
- htmltext = "70737-01.htm"
- st.exitQuest(1)
- else:
- htmltext = "70737-02.htm"
- else:
- water = st.getQuestItemsCount(ORB_OF_WATER)
- fire = st.getQuestItemsCount(ORB_OF_FIRE)
- wind = st.getQuestItemsCount(ORB_OF_WIND)
- earth = st.getQuestItemsCount(ORB_OF_EARTH)
- if water == fire == wind == earth == 0:
- htmltext = "70737-04.htm"
- if npcId == QUEST_NPC_ID and st.getQuestItemsCount(ORB_OF_WATER) and st.getQuestItemsCount(
- ORB_OF_FIRE) and st.getQuestItemsCount(ORB_OF_WIND) and st.getQuestItemsCount(ORB_OF_EARTH):
- htmltext = "70737-05.htm"
- st.giveItems(STONE_OF_VALOR, 1)
- st.takeItems(ORB_OF_WATER, -1)
- st.takeItems(ORB_OF_FIRE, -1)
- st.takeItems(ORB_OF_WIND, -1)
- st.takeItems(ORB_OF_EARTH, -1)
- return htmltext
- def onKill(self, npc, player, isPet):
- st = player.getQuestState(qn)
- if not st:
- return
- if st.getState() != STARTED:
- return
- item, chance = DROPLIST[npc.getNpcId()]
- if st.getRandom(100) > 1:
- st.giveItems(item, 1)
- st.playSound("ItemSound.quest_itemget")
- return
- # Check if the quest can be repeated
- if not self.can_repeat(st):
- remaining_time = self.get_time_remaining(st)
- if remaining_time:
- htmltext = f"<html><body>You can repeat this quest after {remaining_time} passed!</body></html>"
- return htmltext
- return htmltext
- def can_repeat(self, st):
- last_completion_time_str = st.get("last_completion_time")
- if last_completion_time_str:
- last_completion_time = float(last_completion_time_str)
- current_time = time.time()
- cooldown_duration = 24 * 60 * 60 # 24 hours in seconds
- return current_time - last_completion_time >= cooldown_duration
- return True
- # Constants for quest states
- QUEST_STATE_START = State('Start', QUEST)
- QUEST_STATE_STARTING = State('Starting', QUEST)
- QUEST_STATE_STARTED = State('Started', QUEST)
- QUEST_STATE_COMPLETED = State('Completed', QUEST)
- # Set initial state for the quest
- QUEST.setInitialState(QUEST_STATE_START)
- # Add NPCs and IDs to the quest
- QUEST.addStartNpc(QUEST_NPC_ID)
- QUEST.addTalkId(QUEST_NPC_ID)
- QUEST.addKillId(*SYLPH_IDS)
- # Add drops for quest items
- QUEST_STATE_STARTED.addQuestDrop(57002, ORB_OF_FIRE, 1)
- QUEST_STATE_STARTED.addQuestDrop(57003, ORB_OF_WATER, 1)
- QUEST_STATE_STARTED.addQuestDrop(57000, ORB_OF_WIND, 1)
- QUEST_STATE_STARTED.addQuestDrop(57001, ORB_OF_EARTH, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement