Advertisement
Guest User

__init__.py

a guest
Apr 24th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.60 KB | None | 0 0
  1. # Made by Mr. - Version 0.2
  2. import sys
  3. from com.l2open.gameserver.model.quest import State
  4. from com.l2open.gameserver.model.quest import QuestState
  5. from com.l2open.gameserver.model.quest.jython import QuestJython as JQuest
  6.  
  7. qn = "152_ShardsOfGolem"
  8.  
  9. HARRYS_RECEIPT1_ID = 1008
  10. HARRYS_RECEIPT2_ID = 1009
  11. GOLEM_SHARD_ID = 1010
  12. TOOL_BOX_ID = 1011
  13. WOODEN_BP_ID = 23
  14. #NPC
  15. HARRIS = 30035
  16. ALTRAN = 30283
  17. class Quest (JQuest) :
  18.  
  19.  def __init__(self, id, name, descr):
  20.      JQuest.__init__(self, id, name, descr)
  21.      self.questItemIds = range(1008, 1012)
  22.  
  23.  def onAdvEvent (self, event, npc, player) :
  24.     htmltext = event
  25.     st = player.getQuestState(qn)
  26.     if not st : return
  27.     id = st.getState()
  28.     cond = st.getInt("cond")
  29.     if id != State.COMPLETED :
  30.        if event == "30035-04.htm" and cond == 0 :
  31.           st.set("cond", "1")
  32.           st.setState(State.STARTED)
  33.           st.playSound("ItemSound.quest_accept")
  34.           st.giveItems(HARRYS_RECEIPT1_ID, 1)
  35.        elif event == "30283-02.htm" and cond == 1 and st.getQuestItemsCount(HARRYS_RECEIPT1_ID) :
  36.           st.takeItems(HARRYS_RECEIPT1_ID, -1)
  37.           st.giveItems(HARRYS_RECEIPT2_ID, 1)
  38.           st.set("cond", "2")
  39.     return htmltext
  40.  
  41.  def onTalk (self, npc, player):
  42.    htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>"
  43.    st = player.getQuestState(qn)
  44.    if not st : return htmltext
  45.  
  46.    npcId = npc.getNpcId()
  47.    id = st.getState()
  48.    cond = st.getInt("cond")
  49.    receipt1 = st.getQuestItemsCount(HARRYS_RECEIPT1_ID)
  50.    receipt2 = st.getQuestItemsCount(HARRYS_RECEIPT2_ID)
  51.    toolbox = st.getQuestItemsCount(TOOL_BOX_ID)
  52.    shards = st.getQuestItemsCount(GOLEM_SHARD_ID)
  53.    if id == State.COMPLETED :
  54.       htmltext = "<html><body>This quest has already been completed.</body></html>"
  55.    elif npcId == HARRIS :
  56.       if cond == 0 :
  57.          if player.getLevel() >= 10 :
  58.             htmltext = "30035-03.htm"
  59.          else:
  60.             htmltext = "30035-02.htm"
  61.             st.exitQuest(1)
  62.       elif cond == 1 and receipt1 and not toolbox :
  63.         htmltext = "30035-05.htm"
  64.       elif cond == 3 and toolbox :
  65.         st.takeItems(TOOL_BOX_ID, -1)
  66.         st.takeItems(HARRYS_RECEIPT2_ID, -1)
  67.         st.unset("cond")
  68.         st.exitQuest(False)
  69.         st.playSound("ItemSound.quest_finish")
  70.         st.giveItems(WOODEN_BP_ID, 1)
  71.         st.addExpAndSp(5000, 0)
  72.         htmltext = "30035-06.htm"
  73.    elif npcId == ALTRAN and id == State.STARTED:
  74.       if cond == 1 and receipt1 :
  75.         htmltext = "30283-01.htm"
  76.       elif cond == 2 and receipt2 and shards < 5 and not toolbox :
  77.         htmltext = "30283-03.htm"
  78.       elif cond == 3 and receipt2 and shards >= 5 and not toolbox :
  79.         st.takeItems(GOLEM_SHARD_ID, -1)
  80.         st.giveItems(TOOL_BOX_ID, 1)
  81.         htmltext = "30283-04.htm"
  82.       elif cond == 3 and receipt2 and toolbox :
  83.         htmltext = "30283-05.htm"
  84.    return htmltext
  85.  
  86.  def onKill(self, npc, player, isPet):
  87.    st = player.getQuestState(qn)
  88.    if not st : return
  89.    if st.getState() != State.STARTED : return
  90.  
  91.    count = st.getQuestItemsCount(GOLEM_SHARD_ID)
  92.    if st.getInt("cond") == 2 and st.getRandom(100) < 30 and count < 5 :
  93.       st.giveItems(GOLEM_SHARD_ID, 1)
  94.       if count == 4 :
  95.          st.playSound("ItemSound.quest_middle")
  96.          st.set("cond", "3")
  97.       else :
  98.          st.playSound("ItemSound.quest_itemget")
  99.    return
  100.  
  101. QUEST = Quest(152, qn, "Shards Of Golem")
  102.  
  103. QUEST.addStartNpc(HARRIS)
  104.  
  105. QUEST.addTalkId(HARRIS)
  106.  
  107. QUEST.addTalkId(ALTRAN)
  108.  
  109. QUEST.addKillId(20016)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement