__init__.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. # Upgrade your Hatchling to Strider version 0.2
  2. # by DrLecter & DraX_
  3. #Quest info
  4. QUEST_NUMBER = 421
  5. QUEST_NAME = "LittleWingAdventures"
  6. QUEST_DESCRIPTION = "Little Wing's Big Adventures"
  7. qn = "421_LittleWingAdventures"
  8. #Configuration
  9. #Minimum pet and player levels required to complete the quest (defaults 55 and 45)
  10. MIN_PET_LEVEL = 55
  11. MIN_PLAYER_LEVEL = 45
  12. # Maximum distance allowed between pet and owner; if it's reached while talking to any NPC, quest is aborted
  13. MAX_DISTANCE = 100
  14. #Messages
  15. default = "<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>"
  16. event_1 = "<html><body>Sage Cronos:<br>Then go and see <font color=\"LEVEL\">Fairy Mimyu</font>, she will help you</body></html>"
  17. error_1 = "<html><body>You're suppossed to own a hatchling and have it summoned to complete this quest.</body></html>"
  18. error_2 = "<html><body>Hey! What happened with the other hatchling you had? This one is different.</body></html>"
  19. error_3 = "<html><body>Sage Cronos:<br>You need to be level "+str(MIN_PLAYER_LEVEL)+" to complete this quest.</body></html>"
  20. error_4 = "<html><body>Sage Cronos:<br>Your pet need to be level "+str(MIN_PET_LEVEL)+" to complete this quest.</body></html>"
  21. error_5 = "Your pet is not a hatchling. Quest Aborted."
  22. error_6 = "Your pet should be nearby. Quest aborted"
  23. qston_1 = "<html><body>Sage Cronos:<br>So, you want to turn your hatchling into a more powerful creature?<br><br><a action=\"bypass -h Quest "+str(QUEST_NUMBER)+"_"+QUEST_NAME+" 16\">Yes, please tell me how</a><br></body></html>"
  24. qston_2 = "<html><body>Sage Cronos:<br>I've said you need to talk to <font color=\"LEVEL\">Fairy Mimyu</font>!!!. Am i clear???</body></html>"
  25. qston_3 = "<html><body>Fairy Mimyu:<br>You weren't yet able to find the <font color=\"LEVEL\">Fairy Trees of Wind, Star, Twilight and Abyss</font>? Don't give up! They are all in <font color=\"LEVEL\">Hunter's Valley</font></body></html>"
  26. order_1 = "<html><body>Fairy Mimyu:<br>Your pet must drink the sap of <font color=\"LEVEL\">Fairy Trees of Wind, Star, Twilight and Abyss</font> to grow up. The trees will probably agree but as we don't want to hurt them, take that leafs to heal any wound your hatchling could cause them</body></html>"
  27. end_msg = "<html><body>Fairy Mimyu:<br>Great job, your hatchling"
  28. end_msg2= "has become an strider, enjoy!</body></html>"
  29. #Quest items
  30. FT_LEAF = 4325
  31. CONTROL_ITEMS = { 3500:4422, 3501:4423, 3502:4424 }
  32. #NPCs
  33. SG_CRONOS = 30610
  34. FY_MYMYU = 30747
  35. #Mobs
  36. GUARDIAN = 27189
  37. import sys
  38. from net.sf.l2j.gameserver.model.quest import State
  39. from net.sf.l2j.gameserver.model.quest import QuestState
  40. from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest
  41. from net.sf.l2j.gameserver.serverpackets import NpcSay
  42. def get_control_item(st) :
  43. item = st.getPlayer().getPet().getControlItemId()
  44. if st.getState() == State.CREATED :
  45. st.set("item",str(item))
  46. else :
  47. if st.getInt("item") != item : item = 0
  48. return item
  49. def get_distance(player) :
  50. is_far = False
  51. if abs(player.getPet().getX() - player.getX()) > MAX_DISTANCE :
  52. is_far = True
  53. if abs(player.getPet().getY() - player.getY()) > MAX_DISTANCE :
  54. is_far = True
  55. if abs(player.getPet().getZ() - player.getZ()) > MAX_DISTANCE :
  56. is_far = True
  57. return is_far
  58. class Quest (JQuest) :
  59. def __init__(self,id,name,descr):
  60. JQuest.__init__(self,id,name,descr)
  61. self.questItemIds = [FT_LEAF]
  62. self.killedTrees = []
  63. def onEvent (self,event,st) :
  64. htmltext = event
  65. if event == "16" :
  66. htmltext = event_1
  67. st.setState(State.STARTED)
  68. st.set("id","0")
  69. st.set("cond","1")
  70. st.playSound("ItemSound.quest_accept")
  71. return htmltext
  72. def onTalk (self,npc,player):
  73. htmltext = default
  74. st = player.getQuestState(qn)
  75. if not st : return htmltext
  76. id = st.getState()
  77. cond = st.getInt("cond")
  78. if id == State.COMPLETED :
  79. st.setState(State.CREATED)
  80. id = State.CREATED
  81. npcId = npc.getNpcId()
  82. if player.getPet() == None :
  83. htmltext = error_1
  84. st.exitQuest(1)
  85. elif player.getPet().getTemplate().npcId not in [12311,12312,12313] : #npcIds for hatchlings
  86. htmltext = error_5
  87. st.exitQuest(1)
  88. elif player.getPet().getLevel() < MIN_PET_LEVEL :
  89. st.exitQuest(1)
  90. htmltext = error_4
  91. elif get_distance(player) :
  92. st.exitQuest(1)
  93. htmltext = error_6
  94. elif get_control_item(st) == 0 :
  95. st.exitQuest(1)
  96. htmltext = error_2
  97. elif npcId == SG_CRONOS :
  98. if id == State.CREATED :
  99. if player.getLevel() < MIN_PLAYER_LEVEL :
  100. st.exitQuest(1)
  101. htmltext = error_3
  102. else :
  103. htmltext = qston_1
  104. else :
  105. htmltext = qston_2
  106. elif npcId == FY_MYMYU :
  107. if id == State.STARTED and cond < 3 :
  108. if st.getQuestItemsCount(FT_LEAF) == 0 and st.getInt("id") == 0 :
  109. st.set("cond","2")
  110. st.giveItems(FT_LEAF,4)
  111. st.playSound("ItemSound.quest_itemget")
  112. htmltext = order_1
  113. else :
  114. htmltext = qston_3
  115. elif id == State.STARTED and cond >= 3:
  116. name = player.getPet().getName()
  117. if name == None : name = " "
  118. else : name = " "+name+" "
  119. htmltext = end_msg+name+end_msg2
  120. item=CONTROL_ITEMS[player.getInventory().getItemByObjectId(player.getPet().getControlItemId()).getItemId()]
  121. player.getPet().deleteMe(player) #both despawn pet and delete controlitem
  122. st.giveItems(item,1)
  123. st.exitQuest(1)
  124. st.playSound("ItemSound.quest_finish")
  125. return htmltext
  126. def onAttack(self, npc, player, damage, isPet) :
  127. st = player.getQuestState(str(QUEST_NUMBER)+"_"+QUEST_NAME)
  128. if not st:
  129. return
  130. npcId = npc.getNpcId()
  131. for pc, mobId, in self.killedTrees:
  132. if pc == player and mobId == npcId:
  133. return
  134. if isPet :
  135. pet = player.getPet()
  136. if st.getRandom(100) <= 2 and st.getQuestItemsCount(FT_LEAF) >= 0:
  137. st.takeItems(FT_LEAF,1)
  138. st.playSound("ItemSound.quest_middle")
  139. npc.broadcastPacket(NpcSay(npc.getNpcId(),0,npcId,"gives me spirit leaf...!"))
  140. self.killedTrees.append([player,npcId])
  141. if st.getQuestItemsCount(FT_LEAF) == 0 :
  142. st.set("cond","3")
  143. return
  144. # Quest class and state definition
  145. QUEST = Quest(QUEST_NUMBER, str(QUEST_NUMBER)+"_"+QUEST_NAME, QUEST_DESCRIPTION)
  146. # Quest NPC starter initialization
  147. QUEST.addStartNpc(SG_CRONOS)
  148. # Quest initialization
  149. QUEST.addTalkId(SG_CRONOS)
  150. QUEST.addTalkId(FY_MYMYU)
  151. for i in range(27185,27189):
  152. QUEST.addAttackId(i)