__init__.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. #
  2. # Created by DraX on 2005.09.08
  3. # C4 Update by DrLecter
  4. #
  5. import sys
  6. from com.l2jserver.gameserver.model.quest import State
  7. from com.l2jserver.gameserver.model.quest import QuestState
  8. from com.l2jserver.gameserver.model.quest import Quest as JQuest
  9. from com.l2jserver.gameserver.network.serverpackets import NpcSay
  10. qn = "334_TheWishingPotion"
  11. # General Rewards
  12. ADENA = 57
  13. NECKLACE_OF_GRACE = 931
  14. HEART_OF_PAAGRIO = 3943
  15. R1=[3081,3076,3075,3074,4917,3077,3080,3079,3078,4928,4931,4932,5013,3067,3064,3061,3062,3058,4206,3065,3060,3063,4208,3057,3059,3066,4911,4918,3092,3039,4922,3091,3093,3431]
  16. R2=[3430,3429,3073,3941,3071,3069,3072,4200,3068,3070,4912,3100,3101,3098,3094,3102,4913,3095,3096,3097,3099,3085,3086,3082,4907,3088,4207,3087,3084,3083,4929,4933,4919,3045]
  17. R3=[4923,4201,4914,3942,3090,4909,3089,4930,4934,4920,3041,4924,3114,3105,3110,3104,3113,3103,4204,3108,4926,3112,3107,4205,3109,3111,3106,4925,3117,3115,3118,3116,4927]
  18. R4=[1979,1980,2952,2953]
  19. #Quest ingredients and rewards
  20. WISH_POTION,ANCIENT_CROWN,CERTIFICATE_OF_ROYALTY = range(3467,3470)
  21. ALCHEMY_TEXT,SECRET_BOOK,POTION_RECIPE_1,POTION_RECIPE_2,MATILDS_ORB,FORBIDDEN_LOVE_SCROLL = range(3678,3684)
  22. AMBER_SCALE,WIND_SOULSTONE,GLASS_EYE,HORROR_ECTOPLASM,SILENOS_HORN,ANT_SOLDIER_APHID,TYRANTS_CHITIN,BUGBEAR_BLOOD = range(3684,3692)
  23. #NPCs
  24. GRIMA = 27135
  25. SUCCUBUS_OF_SEDUCTION = 27136
  26. GREAT_DEMON_KING = 27138
  27. SECRET_KEEPER_TREE = 27139
  28. SANCHES = 27153
  29. BONAPARTERIUS = 27154
  30. RAMSEBALIUS = 27155
  31. TORAI = 30557
  32. ALCHEMIST_MATILD = 30738
  33. RUPINA = 30742
  34. WISDOM_CHEST = 30743
  35. #MOBs
  36. WHISPERING_WIND = 20078
  37. ANT_RECRUIT = 20087
  38. ANT_WARRIOR_CAPTAIN = 20088
  39. SILENOS = 20168
  40. TYRANT = 20192
  41. TYRANT_KINGPIN = 20193
  42. AMBER_BASILISK = 20199
  43. HORROR_MIST_RIPPER = 20227
  44. TURAK_BUGBEAR = 20248
  45. TURAK_BUGBEAR_WARRIOR = 20249
  46. GLASS_JAGUAR = 20250
  47. #DROPLIST
  48. DROPLIST={AMBER_BASILISK:[AMBER_SCALE,15],WHISPERING_WIND:[WIND_SOULSTONE,20],GLASS_JAGUAR:[GLASS_EYE,35],HORROR_MIST_RIPPER:[HORROR_ECTOPLASM,15],
  49. SILENOS:[SILENOS_HORN,30],ANT_RECRUIT:[ANT_SOLDIER_APHID,40],ANT_WARRIOR_CAPTAIN:[ANT_SOLDIER_APHID,40],TYRANT:[TYRANTS_CHITIN,50],
  50. TYRANT_KINGPIN:[TYRANTS_CHITIN,50],TURAK_BUGBEAR:[BUGBEAR_BLOOD,25],TURAK_BUGBEAR_WARRIOR:[BUGBEAR_BLOOD,25]}
  51. # set of random messages
  52. MESSAGES={SUCCUBUS_OF_SEDUCTION:["Do you wanna be loved?","Do you need love?","Let me love you...","Want to know what love is?","Are you in need of love?","Me love you long time"],
  53. GRIMA:["hey hum hum!","boom! boom!","...","Ki ab kya karein hum"],
  54. }
  55. def check_ingredients(st,required) :
  56. if st.getQuestItemsCount(AMBER_SCALE) != required : return 0
  57. if st.getQuestItemsCount(WIND_SOULSTONE) != required : return 0
  58. if st.getQuestItemsCount(GLASS_EYE) != required : return 0
  59. if st.getQuestItemsCount(HORROR_ECTOPLASM) != required : return 0
  60. if st.getQuestItemsCount(SILENOS_HORN) != required : return 0
  61. if st.getQuestItemsCount(ANT_SOLDIER_APHID) != required : return 0
  62. if st.getQuestItemsCount(TYRANTS_CHITIN) != required : return 0
  63. if st.getQuestItemsCount(BUGBEAR_BLOOD) != required : return 0
  64. return 1
  65. def autochat(npc,text) :
  66. if npc: npc.broadcastPacket(NpcSay(npc.getObjectId(),0,npc.getId(),text))
  67. return
  68. class Quest (JQuest) :
  69. def __init__(self,id,name,descr):
  70. JQuest.__init__(self,id,name,descr)
  71. self.questItemIds = range(3678,3683)+range(3684,3692)
  72. def onAdvEvent (self,event,npc,player):
  73. st = self.getQuestState(player, False)
  74. if not st: return
  75. htmltext = event
  76. player=st.getPlayer()
  77. if event == "30738-03.htm":
  78. st.set("cond","1")
  79. st.setState(State.STARTED)
  80. st.playSound("ItemSound.quest_accept")
  81. if st.getQuestItemsCount(ALCHEMY_TEXT) >= 2: st.takeItems(ALCHEMY_TEXT,-1)
  82. if st.getQuestItemsCount(ALCHEMY_TEXT) == 0: st.giveItems(ALCHEMY_TEXT,1)
  83. htmltext = "30738-03.htm"
  84. if event == "30738-06.htm":
  85. if st.getQuestItemsCount(WISH_POTION) :
  86. htmltext = "30738-13.htm"
  87. else :
  88. st.playSound("ItemSound.quest_accept")
  89. st.set("cond","3")
  90. if st.getQuestItemsCount(ALCHEMY_TEXT) >= 1: st.takeItems(ALCHEMY_TEXT,-1)
  91. if st.getQuestItemsCount(SECRET_BOOK) >= 1: st.takeItems(SECRET_BOOK,-1)
  92. if st.getQuestItemsCount(POTION_RECIPE_1) >= 2: st.takeItems(POTION_RECIPE_1,-1)
  93. if st.getQuestItemsCount(POTION_RECIPE_1) == 0: st.giveItems(POTION_RECIPE_1,1)
  94. if st.getQuestItemsCount(POTION_RECIPE_2) >= 2: st.takeItems(POTION_RECIPE_2,-1)
  95. if st.getQuestItemsCount(POTION_RECIPE_2) == 0: st.giveItems(POTION_RECIPE_2,1)
  96. if st.getQuestItemsCount(MATILDS_ORB) : htmltext = "30738-12.htm"
  97. if event == "30738-10.htm":
  98. if check_ingredients(st,1) :
  99. st.playSound("ItemSound.quest_finish")
  100. st.takeItems(ALCHEMY_TEXT,-1)
  101. st.takeItems(SECRET_BOOK,-1)
  102. st.takeItems(POTION_RECIPE_1,-1)
  103. st.takeItems(POTION_RECIPE_2,-1)
  104. st.takeItems(AMBER_SCALE,-1)
  105. st.takeItems(WIND_SOULSTONE,-1)
  106. st.takeItems(GLASS_EYE,-1)
  107. st.takeItems(HORROR_ECTOPLASM,-1)
  108. st.takeItems(SILENOS_HORN,-1)
  109. st.takeItems(ANT_SOLDIER_APHID,-1)
  110. st.takeItems(TYRANTS_CHITIN,-1)
  111. st.takeItems(BUGBEAR_BLOOD,-1)
  112. if not st.getQuestItemsCount(MATILDS_ORB) : st.giveItems(MATILDS_ORB,1)
  113. st.giveItems(WISH_POTION,1)
  114. st.set("cond","5")
  115. else :
  116. htmltext="You don't have required items"
  117. elif event == "30738-14.htm":
  118. # if you dropped or destroyed your wish potion, you are not able to see the wish list
  119. if st.getQuestItemsCount(WISH_POTION) :
  120. htmltext = "30738-15.htm"
  121. #### WISH I : Please make me into a loving person.
  122. elif event == "30738-16.htm":
  123. if st.getQuestItemsCount(WISH_POTION) :
  124. st.set("wish","1")
  125. st.startQuestTimer("matild_timer1",3000,npc)
  126. st.takeItems(WISH_POTION,1)
  127. npc.setBusy(True)
  128. else:
  129. htmltext = "30738-14.htm"
  130. #### WISH II : I want to become an extremely rich person. How about 100 million adena?!
  131. elif event == "30738-17.htm":
  132. if st.getQuestItemsCount(WISH_POTION) :
  133. st.set("wish","2")
  134. st.startQuestTimer("matild_timer1",3000,npc)
  135. st.takeItems(WISH_POTION,1)
  136. npc.setBusy(True)
  137. else:
  138. htmltext = "30738-14.htm"
  139. #### WISH III : I want to be a king in this world.
  140. elif event == "30738-18.htm":
  141. if st.getQuestItemsCount(WISH_POTION) :
  142. st.set("wish","3")
  143. st.startQuestTimer("matild_timer1",3000,npc)
  144. st.takeItems(WISH_POTION,1)
  145. npc.setBusy(True)
  146. else:
  147. htmltext = "30738-14.htm"
  148. #### WISH IV : I'd like to become the wisest person in the world.
  149. elif event == "30738-19.htm":
  150. if st.getQuestItemsCount(WISH_POTION) >= 1:
  151. st.set("wish","4")
  152. st.startQuestTimer("matild_timer1",3000,npc)
  153. st.takeItems(WISH_POTION,1)
  154. npc.setBusy(True)
  155. else:
  156. htmltext = "30738-14.htm"
  157. elif event == "matild_timer1":
  158. autochat(npc,"OK, everybody pray fervently!")
  159. st.startQuestTimer("matild_timer2",4000,npc)
  160. return
  161. elif event == "matild_timer2":
  162. autochat(npc,"Both hands to heaven, everybody yell together!")
  163. st.startQuestTimer("matild_timer3",4000,npc)
  164. return
  165. elif event == "matild_timer3":
  166. autochat(npc,"One! Two! May your dreams come true!")
  167. wish = st.getInt("wish")
  168. WISH_CHANCE = self.getRandom(100)
  169. if wish == 1 :
  170. if WISH_CHANCE <= 50:
  171. autochat(st.addSpawn(SUCCUBUS_OF_SEDUCTION,200000),MESSAGES[SUCCUBUS_OF_SEDUCTION][self.getRandom(len(MESSAGES))])
  172. autochat(st.addSpawn(SUCCUBUS_OF_SEDUCTION,200000),MESSAGES[SUCCUBUS_OF_SEDUCTION][self.getRandom(len(MESSAGES))])
  173. autochat(st.addSpawn(SUCCUBUS_OF_SEDUCTION,200000),MESSAGES[SUCCUBUS_OF_SEDUCTION][self.getRandom(len(MESSAGES))])
  174. else:
  175. autochat(st.addSpawn(RUPINA,120000),"Your love... love!")
  176. elif wish == 2 :
  177. if WISH_CHANCE <= 33 :
  178. autochat(st.addSpawn(GRIMA,200000),MESSAGES[GRIMA][self.getRandom(len(MESSAGES))])
  179. autochat(st.addSpawn(GRIMA,200000),MESSAGES[GRIMA][self.getRandom(len(MESSAGES))])
  180. autochat(st.addSpawn(GRIMA,200000),MESSAGES[GRIMA][self.getRandom(len(MESSAGES))])
  181. else :
  182. st.giveItems(ADENA,10000)
  183. elif wish == 3 :
  184. if WISH_CHANCE <= 33 :
  185. st.giveItems(CERTIFICATE_OF_ROYALTY,1)
  186. elif WISH_CHANCE >= 66 :
  187. st.giveItems(ANCIENT_CROWN,1)
  188. else:
  189. spawnedNpc=st.addSpawn(SANCHES,player,True,0)
  190. autochat(spawnedNpc,"Who dares to call the dark Monarch?!")
  191. st.startQuestTimer("sanches_timer1",200000,spawnedNpc)
  192. elif wish == 4 :
  193. if WISH_CHANCE <= 33:
  194. st.giveItems(R1[self.getRandom(len(R1))],1)
  195. st.giveItems(R2[self.getRandom(len(R2))],1)
  196. st.giveItems(R3[self.getRandom(len(R3))],1)
  197. if not self.getRandom(3):
  198. st.giveItems(HEART_OF_PAAGRIO,1)
  199. else:
  200. autochat(st.addSpawn(WISDOM_CHEST,120000),"I contain the wisdom, I am the wisdom box!")
  201. npc.setBusy(False)
  202. return
  203. elif event == "sanches_timer1" :
  204. autochat(npc,"Hehehe, i'm just wasting my time here!")
  205. npc.deleteMe()
  206. return
  207. elif event == "bonaparterius_timer1" :
  208. autochat(npc,"A worth opponent would be a good thing")
  209. npc.deleteMe()
  210. elif event == "ramsebalius_timer1" :
  211. autochat(npc,"Your time is up!")
  212. npc.deleteMe()
  213. return
  214. elif event == "greatdemon_timer1" :
  215. autochat(npc,"Do not interrupt my eternal rest again!")
  216. npc.deleteMe()
  217. return
  218. return htmltext
  219. def onTalk (self,npc,player):
  220. htmltext = Quest.getNoQuestMsg(player)
  221. st = self.getQuestState(player, True)
  222. if not st : return htmltext
  223. npcId = npc.getId()
  224. cond = st.getInt("cond")
  225. id = st.getState()
  226. if npcId != ALCHEMIST_MATILD and id == State.CREATED : return htmltext
  227. if npcId == TORAI and st.getQuestItemsCount(FORBIDDEN_LOVE_SCROLL) :
  228. st.takeItems(FORBIDDEN_LOVE_SCROLL,1)
  229. st.giveItems(ADENA,500000)
  230. htmltext = "30557-01.htm"
  231. elif npcId == WISDOM_CHEST :
  232. st.giveItems(R1[self.getRandom(len(R1))],1)
  233. st.giveItems(R2[self.getRandom(len(R2))],1)
  234. st.giveItems(R3[self.getRandom(len(R3))],1)
  235. if not self.getRandom(3):
  236. st.giveItems(HEART_OF_PAAGRIO,1)
  237. st.giveItems(4409,1)
  238. st.giveItems(4408,1)
  239. htmltext = "30743-0"+str(self.getRandom(6)+1)+".htm"
  240. npc.deleteMe()
  241. elif npcId == RUPINA:
  242. if self.getRandom(100) <= 4:
  243. st.giveItems(NECKLACE_OF_GRACE,1)
  244. htmltext = "30742-01.htm"
  245. else:
  246. st.giveItems(R4[self.getRandom(len(R4))],1)
  247. htmltext = "30742-02.htm"
  248. npc.decayMe()
  249. elif npcId == ALCHEMIST_MATILD:
  250. if npc.isBusy() :
  251. htmltext = "30738-20.htm"
  252. elif player.getLevel() <= 29 :
  253. htmltext = "30738-21.htm"
  254. st.exitQuest(1)
  255. elif cond == 5 and st.getQuestItemsCount(MATILDS_ORB) :
  256. htmltext = "30738-11.htm"
  257. elif cond == 4 and check_ingredients(st,1):
  258. htmltext = "30738-08.htm"
  259. elif cond == 3 and not check_ingredients(st,1):
  260. htmltext = "30738-07.htm"
  261. elif cond == 2 or (st.getQuestItemsCount(ALCHEMY_TEXT) and st.getQuestItemsCount(SECRET_BOOK)) :
  262. htmltext = "30738-05.htm"
  263. elif cond == 1 or (st.getQuestItemsCount(ALCHEMY_TEXT) and not st.getQuestItemsCount(SECRET_BOOK)) :
  264. htmltext = "30738-04.htm"
  265. else:
  266. htmltext = "30738-01.htm"
  267. return htmltext
  268. def onKill(self,npc,player,isPet):
  269. st = self.getQuestState(player, False)
  270. if not st : return
  271. id = st.getState()
  272. if id == State.CREATED: return
  273. if id != State.STARTED: st.setState(State.STARTED)
  274. npcId = npc.getId()
  275. cond = st.getInt("cond")
  276. if npcId == SECRET_KEEPER_TREE and cond == 1 and not st.getQuestItemsCount(SECRET_BOOK):
  277. st.set("cond","2")
  278. st.giveItems(SECRET_BOOK,1)
  279. st.playSound("ItemSound.quest_itemget")
  280. elif npcId in DROPLIST.keys() and cond == 3 :
  281. item,chance=DROPLIST[npcId]
  282. if self.getRandom(100) <= chance and not st.getQuestItemsCount(item) :
  283. st.giveItems(item,1)
  284. if check_ingredients(st,1):
  285. st.playSound("ItemSound.quest_middle")
  286. st.set("cond","4")
  287. else: st.playSound("ItemSound.quest_itemget")
  288. else:
  289. if npcId == SUCCUBUS_OF_SEDUCTION:
  290. if self.getRandom(100) <= 3 :
  291. st.playSound("ItemSound.quest_itemget")
  292. st.giveItems(FORBIDDEN_LOVE_SCROLL,1)
  293. elif npcId == GRIMA:
  294. if self.getRandom(100) < 4 :
  295. st.playSound("ItemSound.quest_itemget")
  296. if self.getRandom(1000) == 0 :
  297. st.giveItems(ADENA,100000000)
  298. else:
  299. st.giveItems(ADENA,900000)
  300. elif npcId == SANCHES :
  301. try :
  302. if st.getQuestTimer("sanches_timer1") :
  303. st.getQuestTimer("sanches_timer1").cancel()
  304. if self.getRandom(100) <= 50 :
  305. autochat(npc,"It's time to come out my Remless... Bonaparterius!")
  306. spawnedNpc=st.addSpawn(BONAPARTERIUS,npc,True,0)
  307. autochat(spawnedNpc,"I am the Great Emperor's son!")
  308. st.startQuestTimer("bonaparterius_timer1",600000,spawnedNpc)
  309. else :
  310. st.giveItems(R4[self.getRandom(len(R4))],1)
  311. except : pass
  312. elif npcId == BONAPARTERIUS:
  313. try :
  314. if st.getQuestTimer("bonaparterius_timer1") :
  315. st.getQuestTimer("bonaparterius_timer1").cancel()
  316. autochat(npc,"Only Ramsebalius would be able to avenge me!")
  317. if self.getRandom(100) <= 50 :
  318. spawnedNpc=st.addSpawn(RAMSEBALIUS,npc,True,0)
  319. autochat(spawnedNpc,"Meet the absolute ruler!")
  320. st.startQuestTimer("ramsebalius_timer1",600000,spawnedNpc)
  321. else :
  322. st.giveItems(R4[self.getRandom(len(R4))],1)
  323. except : pass
  324. elif npcId == RAMSEBALIUS:
  325. try :
  326. if st.getQuestTimer("ramsebalius_timer1") :
  327. st.getQuestTimer("ramsebalius_timer1").cancel()
  328. autochat(npc,"You evil piece of...")
  329. if self.getRandom(100) <= 50 :
  330. spawnedNpc=st.addSpawn(GREAT_DEMON_KING,npc,True,0)
  331. autochat(spawnedNpc,"Who dares to kill my fiendly minion?!")
  332. st.startQuestTimer("greatdemon_timer1",600000,spawnedNpc)
  333. else :
  334. st.giveItems(R4[self.getRandom(len(R4))],1)
  335. except: pass
  336. elif npcId == GREAT_DEMON_KING:
  337. try :
  338. if st.getQuestTimer("greatdemon_timer1") :
  339. st.getQuestTimer("greatdemon_timer1").cancel()
  340. st.giveItems(ADENA,1412965)
  341. st.playSound("ItemSound.quest_itemget")
  342. except: pass
  343. return
  344. QUEST = Quest(334, qn, "The Wishing Potion")
  345. QUEST.addStartNpc(ALCHEMIST_MATILD)
  346. QUEST.addTalkId([ALCHEMIST_MATILD, TORAI, RUPINA, WISDOM_CHEST])
  347. QUEST.addKillId(DROPLIST.keys())
  348. QUEST.addKillId([SECRET_KEEPER_TREE, SUCCUBUS_OF_SEDUCTION, GRIMA, SANCHES, RAMSEBALIUS, BONAPARTERIUS, GREAT_DEMON_KING])