__init__.py 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. # by minlexx
  2. import sys
  3. from com.l2jserver import Config
  4. from com.l2jserver.gameserver.model.quest import State
  5. from com.l2jserver.gameserver.model.quest import QuestState
  6. from com.l2jserver.gameserver.model.quest import Quest as JQuest
  7. qn = "663_SeductiveWhispers"
  8. # Npc
  9. WILBERT = 30846
  10. MOBS = [20674, 20678, 20954, 20955, 20956, 20957, 20958, 20959, 20960, 20961, 20962, 20974, 20975, 20976, 20996, 20997, 20998, 20999, 21001, 21002, 21006, 21007, 21008, 21009, 21010]
  11. # Quest Item
  12. SPIRIT_BEAD = 8766
  13. # Drop chance, win chance need check for correct values
  14. DROP_CHANCE = 80
  15. WIN_ROUND_CHANCE = 66
  16. # Reward items
  17. ADENA = 57
  18. EWA = 729 # Scroll: Enchant Weapon A
  19. EAA = 730 # Scroll: Enchant Armor A
  20. EWB = 947 # Scroll: Enchant Weapon B
  21. EAB = 948 # Scroll: Enchant Armor B
  22. EWC = 951 # Scroll: Enchant Weapon C
  23. EWD = 955 # Scroll: Enchant Weapon D
  24. # ====== Rewards - B grade 60% weapon recipes & keymats =========
  25. # These are just most popular B weapons, need retail check here
  26. # Blunts: Art of Battle Axe, Staff of Evil Spirits (2)
  27. # Bows: Bow of Peril (1)
  28. # Daggers: Demon Dagger, Kris (2)
  29. # Fists: Bellion Cestus (1)
  30. # Polearms: Lance (1)
  31. # Swords: Great Sword, Keshanberk, Sword of Valhalla (3)
  32. # ====== Total: 10; In that order they come in a set below: ======
  33. B_RECIPES = [4963, 4966, 4967, 4968, 5001, 5003, 5004, 5005, 5006, 5007]
  34. B_KEYMATS = [4101, 4107, 4108, 4109, 4115, 4117, 4118, 4119, 4120, 4121]
  35. class Quest (JQuest) :
  36. def __init__(self,id,name,descr):
  37. JQuest.__init__(self,id,name,descr)
  38. self.questItemIds = []
  39. def onEvent (self,event,st) :
  40. htmltext = event
  41. if event == "Wilbert_IWantToPlay.htm": # quest accepted
  42. st.setState(State.STARTED)
  43. st.playSound("ItemSound.quest_accept")
  44. st.set("cond","1")
  45. st.set("round","0")
  46. elif event == "Wilbert_ExitQuest.htm": # quest finished
  47. st.playSound("ItemSound.quest_finish")
  48. st.exitQuest(1)
  49. elif event == "Wilbert_IWantToPractice.htm": # practice start dialog
  50. beads=st.getQuestItemsCount(SPIRIT_BEAD)
  51. if beads<1:
  52. htmltext = "Wilbert_Practice_NotEnoughBeads.htm"
  53. elif event == "Wilbert_Practice.htm": # "try luck" pressed (Practice)
  54. beads=st.getQuestItemsCount(SPIRIT_BEAD) # get beads count, it must be > 1
  55. if beads<1:
  56. htmltext = "Wilbert_Practice_NotEnoughBeads.htm"
  57. else:
  58. st.takeItems(SPIRIT_BEAD,1) # take one bead as payment for luck test
  59. random=self.getRandom(100)
  60. if random<WIN_ROUND_CHANCE: # random value is in range [0..WIN_ROUND_CHANCE]
  61. htmltext = "Wilbert_PracticeWon.htm"
  62. else: # lose practice :(
  63. htmltext = "Wilbert_PracticeLost.htm"
  64. elif event == "Wilbert_LetsPlay.htm": # "Let's play" pressed
  65. beads=st.getQuestItemsCount(SPIRIT_BEAD)
  66. if beads<50:
  67. htmltext = "Wilbert_Practice_NotEnoughBeads.htm"
  68. else:
  69. htmltext = "Wilbert_PlayRound1.htm"
  70. st.set("round","0")
  71. elif event == "Wilbert_PullCard.htm": # "Pull first or next card" pressed
  72. round=st.getInt("round")
  73. beads=st.getQuestItemsCount(SPIRIT_BEAD)
  74. if beads<50 and round == 0: # check for 50 beads when game just starts only (round=0)
  75. htmltext = "Wilbert_Practice_NotEnoughBeads.htm"
  76. else:
  77. if round == 0: # take 50 beads when game just starts only (round=0)
  78. st.takeItems(SPIRIT_BEAD,50)
  79. random=self.getRandom(100)
  80. if random>WIN_ROUND_CHANCE: # random value is in range [WIN_ROUND_CHANCE..100]
  81. htmltext = "Wilbert_PlayLose.htm"
  82. st.set("round","0") # restart game
  83. else: # next round won
  84. round = round + 1
  85. htmltext = st.showHtmlFile("Wilbert_PlayWin.htm").replace("NROUND", str(round))
  86. if round == 1:
  87. htmltext = htmltext.replace("MYPRIZE","40,000 adena")
  88. if round == 2:
  89. htmltext = htmltext.replace("MYPRIZE","80,000 adena")
  90. if round == 3:
  91. htmltext = htmltext.replace("MYPRIZE","110,000 adena, D-grade Enchant Weapon Scroll")
  92. if round == 4:
  93. htmltext = htmltext.replace("MYPRIZE","199,000 adena, C-grade Enchant Weapon Scroll")
  94. if round == 5:
  95. htmltext = htmltext.replace("MYPRIZE","388,000 adena, 1 recipe for a B-grade weapon")
  96. if round == 6:
  97. htmltext = htmltext.replace("MYPRIZE","675,000 adena, 1 essential ingredient for a B-grade weapon")
  98. if round == 7:
  99. htmltext = htmltext.replace("MYPRIZE","1,284,000 adena, 2 B-grade Enchant Weapon Scrolls, 2 B-grade Enchat Armor Scrolls")
  100. if round == 8: # reached round 8; give prizes and restart game
  101. round = 0
  102. st.giveItems(ADENA,2384000)
  103. st.giveItems(EWA,1) # Scroll: Enchant Weapon A
  104. st.giveItems(EAA,2) # Scroll: Enchant Armor A
  105. htmltext = "Wilbert_PlayWonRound8.htm"
  106. st.set("round",str(round))
  107. elif event == "Wilbert_TakePrize.htm": # player won round and wants to stop game and take prize
  108. round=st.getInt("round")
  109. if round == 0: # player did not win any round but wants to take prize? O_o
  110. htmltext = "<html><body>You did not win any round! No prizes.</body></html>"
  111. return htmltext
  112. if round > 8: # some bug or hack?
  113. st.set("round","0")
  114. htmltext = "<html><body>Round cannot be > 8 !!!</body></html>"
  115. return htmltext
  116. st.set("round","0") # first set round to 0 - game ended.
  117. htmltext = "Wilbert_PrizeTaken.htm"
  118. # give prize depending on current round won
  119. if round == 1:
  120. st.giveItems(ADENA,40000)
  121. elif round == 2:
  122. st.giveItems(ADENA,80000)
  123. elif round == 3:
  124. st.giveItems(ADENA,110000)
  125. st.giveItems(EWD,1) # Scroll: Enchant Weapon D
  126. elif round == 4:
  127. st.giveItems(ADENA,199000)
  128. st.giveItems(EWC,1) # Scroll: Enchant Weapon C
  129. elif round == 5:
  130. st.giveItems(ADENA,388000)
  131. # 60% B-weap. rec number is random
  132. st.giveItems(B_RECIPES[self.getRandom(len(B_RECIPES))], 1)
  133. elif round == 6:
  134. st.giveItems(ADENA,675000)
  135. # B-weap. key number is random
  136. st.giveItems(B_KEYMATS[self.getRandom(len(B_KEYMATS))], 1)
  137. elif round == 7:
  138. st.giveItems(ADENA,1284000)
  139. st.giveItems(EWB,2) # Scroll: Enchant Weapon B
  140. st.giveItems(EAB,2) # Scroll: Enchant Armor B
  141. # for round 8 prize is automatically when player wins 8 round
  142. return htmltext
  143. def onTalk (self,npc,player):
  144. st = self.getQuestState(player, True)
  145. htmltext = Quest.getNoQuestMsg(player)
  146. if not st : return htmltext
  147. npcId = npc.getId()
  148. id = st.getState()
  149. # first talk to Wilbert
  150. if npcId == WILBERT and id == State.CREATED:
  151. if player.getLevel() >= 50 : # check player level
  152. htmltext = "Wilbert_start.htm"
  153. else:
  154. htmltext = "<html><body>This quest is for characters above level 50 only.</body></html>"
  155. st.exitQuest(1)
  156. # talk to Wilbert when quest already in progress
  157. elif npcId == WILBERT and id == State.STARTED :
  158. htmltext = "Wilbert_QuestInProgress.htm"
  159. return htmltext
  160. def onKill(self,npc,player,isPet):
  161. st = self.getQuestState(player, False)
  162. if not st : return
  163. if st.getState() != State.STARTED : return
  164. npcId = npc.getId()
  165. if npcId in MOBS:
  166. numItems, chance = divmod(DROP_CHANCE*Config.RATE_QUEST_DROP,100)
  167. if self.getRandom(100) < chance :
  168. numItems += 1
  169. if numItems:
  170. st.giveItems(SPIRIT_BEAD,int(numItems))
  171. st.playSound("ItemSound.quest_itemget")
  172. return
  173. QUEST = Quest(663,qn,"Seductive Whispers")
  174. QUEST.addStartNpc(WILBERT)
  175. QUEST.addTalkId(WILBERT)
  176. for mobId in MOBS:
  177. QUEST.addKillId(mobId)