PageRenderTime 107ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/data/scripts/quests/414_PathToOrcRaider/__init__.py

https://github.com/ichiro101/l2adena-l2j-datapack
Python | 210 lines | 190 code | 13 blank | 7 comment | 53 complexity | 2fc959731227abae6416b31086f9a8ec MD5 | raw file
  1. # Made by Mr. Have fun! Version 0.2
  2. # Shadow Weapon Coupons contributed by BiTi for the Official L2J Datapack Project
  3. # Visit http://www.l2jdp.com/forum/ for more details
  4. import sys
  5. from com.l2jserver.gameserver.model.quest import State
  6. from com.l2jserver.gameserver.model.quest import QuestState
  7. from com.l2jserver.gameserver.model.quest.jython import QuestJython as JQuest
  8. from com.l2jserver.gameserver.network.serverpackets import SocialAction
  9. qn = "414_PathToOrcRaider"
  10. #NPCs
  11. KARUKIA = 30570
  12. KASMAN = 30501
  13. TAZEER = 31978
  14. #MOBS
  15. GOBLIN_TOMB_RAIDER_LEADER = 20320
  16. KURUKA_RATMAN_LEADER = 27045
  17. UMBAR_ORC = 27054
  18. TIMORA_ORC = 27320
  19. #ITEMS
  20. GREEN_BLOOD = 1578
  21. GOBLIN_DWELLING_MAP = 1579
  22. KURUKA_RATMAN_TOOTH = 1580
  23. BETRAYER_UMBAR_REPORT = 1589
  24. HEAD_OF_BETRAYER = 1591
  25. TIMORA_ORC_HEAD = 8544
  26. #REWARD
  27. MARK_OF_RAIDER = 1592
  28. class Quest (JQuest) :
  29. def __init__(self,id,name,descr):
  30. JQuest.__init__(self,id,name,descr)
  31. self.questItemIds = [GREEN_BLOOD, GOBLIN_DWELLING_MAP, KURUKA_RATMAN_TOOTH, BETRAYER_UMBAR_REPORT, HEAD_OF_BETRAYER, TIMORA_ORC_HEAD]
  32. def onEvent (self,event,st) :
  33. htmltext = event
  34. if event == "30570-05.htm" :
  35. st.set("id","1")
  36. st.set("cond","1")
  37. st.setState(State.STARTED)
  38. st.giveItems(GOBLIN_DWELLING_MAP,1)
  39. st.playSound("ItemSound.quest_accept")
  40. elif event == "30570-07a.htm" :
  41. st.takeItems(KURUKA_RATMAN_TOOTH,-1)
  42. st.takeItems(GOBLIN_DWELLING_MAP,-1)
  43. st.takeItems(GREEN_BLOOD,-1)
  44. st.giveItems(BETRAYER_UMBAR_REPORT,1)
  45. st.set("id","3")
  46. st.set("cond","3")
  47. st.playSound("ItemSound.quest_middle")
  48. elif event == "30570-07b.htm" :
  49. st.takeItems(KURUKA_RATMAN_TOOTH,-1)
  50. st.takeItems(GOBLIN_DWELLING_MAP,-1)
  51. st.takeItems(GREEN_BLOOD,-1)
  52. st.set("cond","5")
  53. st.playSound("ItemSound.quest_middle")
  54. elif event == "31978-03.htm" :
  55. st.set("cond","6")
  56. st.playSound("ItemSound.quest_middle")
  57. return htmltext
  58. def onTalk (self,npc,player):
  59. htmltext = Quest.getNoQuestMsg(player)
  60. st = player.getQuestState(qn)
  61. if not st : return htmltext
  62. npcId = npc.getNpcId()
  63. id = st.getState()
  64. if npcId != KARUKIA and id != State.STARTED : return htmltext
  65. playerClassID = player.getClassId().getId()
  66. playerLvl = player.getLevel()
  67. cond = st.getInt("cond")
  68. if npcId == KARUKIA and cond == 0 :
  69. if playerLvl >= 18 and playerClassID == 0x2c and st.getQuestItemsCount(MARK_OF_RAIDER) == 0 and st.getQuestItemsCount(GOBLIN_DWELLING_MAP) == 0 :
  70. htmltext = "30570-01.htm"
  71. elif playerClassID != 0x2c :
  72. if playerClassID == 0x2d :
  73. htmltext = "30570-02a.htm"
  74. else:
  75. htmltext = "30570-03.htm"
  76. elif playerLvl < 18 and playerClassID == 0x2c :
  77. htmltext = "30570-02.htm"
  78. elif playerLvl >= 18 and playerClassID == 0x2c and st.getQuestItemsCount(MARK_OF_RAIDER) == 1 :
  79. htmltext = "30570-04.htm"
  80. else:
  81. htmltext = "30570-02.htm"
  82. elif npcId == KARUKIA and cond and st.getQuestItemsCount(GOBLIN_DWELLING_MAP) == 1 and st.getQuestItemsCount(KURUKA_RATMAN_TOOTH) < 10 :
  83. htmltext = "30570-06.htm"
  84. elif npcId == KARUKIA and cond and st.getQuestItemsCount(GOBLIN_DWELLING_MAP) == 1 and st.getQuestItemsCount(KURUKA_RATMAN_TOOTH) >= 10 and st.getQuestItemsCount(BETRAYER_UMBAR_REPORT) == 0 :
  85. htmltext = "30570-07.htm"
  86. elif npcId == KARUKIA and cond >5 :
  87. htmltext = "30570-07b.htm"
  88. elif npcId == KARUKIA and cond and st.getQuestItemsCount(BETRAYER_UMBAR_REPORT) and st.getQuestItemsCount(HEAD_OF_BETRAYER) < 2 :
  89. htmltext = "30570-08.htm"
  90. elif npcId == KARUKIA and cond and st.getQuestItemsCount(BETRAYER_UMBAR_REPORT) and st.getQuestItemsCount(HEAD_OF_BETRAYER) == 2 :
  91. htmltext = "30570-09.htm"
  92. elif npcId == KASMAN and cond and st.getQuestItemsCount(BETRAYER_UMBAR_REPORT) and st.getQuestItemsCount(HEAD_OF_BETRAYER) == 0 :
  93. htmltext = "30501-01.htm"
  94. elif npcId == KASMAN and cond and st.getQuestItemsCount(HEAD_OF_BETRAYER) > 0 and st.getQuestItemsCount(HEAD_OF_BETRAYER) < 2 :
  95. htmltext = "30501-02.htm"
  96. elif npcId == KASMAN and cond and st.getQuestItemsCount(HEAD_OF_BETRAYER) == 2 :
  97. htmltext = "30501-03.htm"
  98. st.takeItems(HEAD_OF_BETRAYER,-1)
  99. st.takeItems(BETRAYER_UMBAR_REPORT,-1)
  100. st.giveItems(MARK_OF_RAIDER,1)
  101. isFinished = st.getGlobalQuestVar("1ClassQuestFinished")
  102. if isFinished == "" :
  103. if player.getLevel() >= 20 :
  104. st.addExpAndSp(320534, 21312)
  105. elif player.getLevel() == 19 :
  106. st.addExpAndSp(456128, 28010)
  107. else:
  108. st.addExpAndSp(591724, 34708)
  109. st.giveItems(57, 163800)
  110. player.sendPacket(SocialAction(player,3))
  111. st.unset("cond")
  112. st.exitQuest(False)
  113. st.saveGlobalQuestVar("1ClassQuestFinished","1")
  114. st.playSound("ItemSound.quest_finish")
  115. elif npcId == TAZEER:
  116. if cond == 5:
  117. htmltext = "31978-01.htm"
  118. elif cond == 6:
  119. htmltext = "31978-04.htm"
  120. elif cond == 7:
  121. htmltext = "31978-05.htm"
  122. st.takeItems(TIMORA_ORC_HEAD,-1)
  123. st.giveItems(MARK_OF_RAIDER,1)
  124. if player.getLevel() >= 20 :
  125. st.addExpAndSp(160267, 10656)
  126. elif player.getLevel() == 19 :
  127. st.addExpAndSp(228064, 14005)
  128. else:
  129. st.addExpAndSp(295862, 17354)
  130. st.giveItems(57, 81900)
  131. player.sendPacket(SocialAction(player,3))
  132. st.unset("cond")
  133. st.exitQuest(False)
  134. st.playSound("ItemSound.quest_finish")
  135. return htmltext
  136. def onKill(self,npc,player,isPet):
  137. st = player.getQuestState(qn)
  138. if not st : return
  139. if st.getState() != State.STARTED : return
  140. cond = st.getInt("cond")
  141. npcId = npc.getNpcId()
  142. xx = int(player.getX())
  143. yy = int(player.getY())
  144. zz = int(player.getZ())
  145. if npcId == GOBLIN_TOMB_RAIDER_LEADER :
  146. if cond and st.getQuestItemsCount(GOBLIN_DWELLING_MAP) == 1 and st.getQuestItemsCount(KURUKA_RATMAN_TOOTH) < 10 and st.getQuestItemsCount(GREEN_BLOOD) < 40 :
  147. if st.getQuestItemsCount(GREEN_BLOOD) > 1 :
  148. if st.getRandom(100) < ((st.getQuestItemsCount(GREEN_BLOOD))*10) :
  149. st.takeItems(GREEN_BLOOD,-1)
  150. st.addSpawn(KURUKA_RATMAN_LEADER,xx,yy,zz)
  151. else:
  152. st.giveItems(GREEN_BLOOD,1)
  153. st.playSound("ItemSound.quest_itemget")
  154. else:
  155. st.giveItems(GREEN_BLOOD,1)
  156. st.playSound("ItemSound.quest_itemget")
  157. elif npcId == KURUKA_RATMAN_LEADER :
  158. if cond and st.getQuestItemsCount(GOBLIN_DWELLING_MAP) == 1 and st.getQuestItemsCount(KURUKA_RATMAN_TOOTH) < 10 :
  159. st.takeItems(GREEN_BLOOD,-1)
  160. if st.getQuestItemsCount(KURUKA_RATMAN_TOOTH) == 9 :
  161. st.giveItems(KURUKA_RATMAN_TOOTH,1)
  162. st.set("id","2")
  163. st.set("cond","2")
  164. st.playSound("ItemSound.quest_middle")
  165. else:
  166. st.giveItems(KURUKA_RATMAN_TOOTH,1)
  167. st.playSound("ItemSound.quest_itemget")
  168. elif npcId == UMBAR_ORC :
  169. if cond and st.getQuestItemsCount(BETRAYER_UMBAR_REPORT) > 0 and st.getQuestItemsCount(HEAD_OF_BETRAYER) < 2 :
  170. st.giveItems(HEAD_OF_BETRAYER,1)
  171. if st.getQuestItemsCount(HEAD_OF_BETRAYER) > 1 :
  172. st.set("id","4")
  173. st.set("cond","4")
  174. st.playSound("ItemSound.quest_middle")
  175. else:
  176. st.playSound("ItemSound.quest_itemget")
  177. elif npcId == TIMORA_ORC :
  178. if cond == 6:
  179. st.set("cond","7")
  180. st.playSound("ItemSound.quest_middle")
  181. st.giveItems(TIMORA_ORC_HEAD,1)
  182. return
  183. QUEST = Quest(414,qn,"Path of the Orc Raider")
  184. QUEST.addStartNpc(KARUKIA)
  185. QUEST.addTalkId(KARUKIA)
  186. QUEST.addTalkId(KASMAN)
  187. QUEST.addTalkId(TAZEER)
  188. QUEST.addKillId(GOBLIN_TOMB_RAIDER_LEADER)
  189. QUEST.addKillId(KURUKA_RATMAN_LEADER)
  190. QUEST.addKillId(UMBAR_ORC)
  191. QUEST.addKillId(TIMORA_ORC)