# Upgrade your Hatchling to Strider version 0.2
# by DrLecter, improvements by DraX_
#Quest info
QUEST_NUMBER = 421
QUEST_NAME = "LittleWingAdventures"
QUEST_DESCRIPTION = "Little Wings Big Adventures"
#Variables
#Minimum pet and player levels required to complete the quest (defaults 55 and 45)
MIN_PET_LEVEL = 35
MIN_PLAYER_LEVEL = 45
# Maximum allowd distance between pet and owner, if its reached while talking to any NPC, quest is aborted
MAX_DISTANCE = 100
#Quest items
FT_LEAF = 4325
CONTROL_ITEMS = [ [3500,4422],[3501,4423],[3502,4424] ]
#Messages
default = "
I have nothing to say to you."
event_1 = "Sage Cronos:
Then go and see Fairy Mymyu, she will help you"
error_1 = "You're suppossed to own a hatchling to complete this quest."
error_2 = "Hey! What happened with the other hatchling you had? This one is different."
error_3 = "Sage Cronos:
You need to be level 55 to complete this quest."
error_3_1 = "Sage Cronos:
Your pet need to be level 55 to complete this quest."
qston_1 = "Sage Cronos:
So, you want to turn your hatchling into a more powerful creature?
Yes, please tell me how
"
error_4 = "Sage Cronos:
I've said you need to talk to Fairy Mymyu!!!. Am i clear???"
error_5 = "Fairy Mymyu:
You weren't yet able to find the Fairy Trees of Wind, Star, Twilight and Abyss? Don't give up! They are all in Hunter's Valley"
order_1 = "Fairy Mymyu:
Your pet must drink the sap of Fairy Trees of Wind, Star, Twilight and Abyss 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"
ftm_11 = "Fairy Tree of Wind:
I'll let your hatchling drink from my sap, but you will have to cover the wound your pet will do on me with one of these leafs you have, they are hypoallergenic
It's ok"
ftm_12 = "The hatchling has drunk the sap of the fairy tree of the wind."
ftm_21 = "Fairy Tree of Star:
Oh! One of those nasty ghosts hurted my bark... look! Only a fairy leaf could cure my wound...
Give it a leaf"
ftm_22 = "The hatchling has drunk the sap of the fairy tree of the star."
ftm_31 = "Fairy Tree of Twilight:
Ok, i do know the way this is supposed to be, but we don't have the time to wait your hacthling to hit me for hours... Let's make it quick
Fine, take the leaf"
ftm_32 = "The hatchling has drunk the sap of the fairy tree of the twilight."
ftm_41 = "Fairy Tree of Abyss:
That your pet will bite me and you gonna put a leaf in my wound? No way! No! Wait!... argh... if i could run like Black Willows do...
Say sorry"
ftm_42 = "The hatchling has drunk the sap of the fairy tree of the abyss."
end_msg = "Fairy Mymyu:
Great job, your hatchling"
end_msg2= "has become an strider, enjoy!"
#NPCs
SG_CRONOS = 7610
FY_MYMYU = 7747
# NpcId, bitmask, spawnX,spawnY,spawnZ,msg1,msg2
FAIRY_TREES = [ [5185,1,128091,90400,-1998,ftm_11,ftm_12],[5186,2,117935,94080,-2096,ftm_21,ftm_22 ],[5187,4,113449,93928,-2072,ftm_31,ftm_32 ],[5188,8,106685,92608,-2162,ftm_41,ftm_42 ] ]
#Mobs
GUARDIAN = 5189
print "importing quests: "+str(QUEST_NUMBER)+": "+QUEST_DESCRIPTION
import sys
from net.sf.l2j.gameserver.model.quest import State
from net.sf.l2j.gameserver.model.quest import QuestState
from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest
def get_control_item(st) :
item = [0,0]
for i in range(3) :
if st.getQuestItemsCount(CONTROL_ITEMS[i][0]) :
item = CONTROL_ITEMS[i]
if st.getState() == CREATED :
st.set("item",str(item[0]))
else :
if int(st.get("item")) != item[0] : item = [ -1,-1 ]
return item
def get_distance(st) :
is_near = False
if abs(st.getPlayer().getPet().getX() - st.getPlayer().getX()) > MAX_DISTANCE :
is_near = True
if abs(st.getPlayer().getPet().getY() - st.getPlayer().getY()) > MAX_DISTANCE :
is_near = True
if abs(st.getPlayer().getPet().getZ() - st.getPlayer().getZ()) > MAX_DISTANCE :
is_near = True
return is_near
class Quest (JQuest) :
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
def onEvent (self,event,st) :
htmltext = event
leafs = st.getQuestItemsCount(FT_LEAF)
for i in range(4) :
if event == str(FAIRY_TREES[i][1]) :
st.set("id", str(int(st.get("id")) | FAIRY_TREES[i][1]))
htmltext = FAIRY_TREES[i][6]
st.takeItems(FT_LEAF,1)
if 1 < leafs <= 4 :
st.playSound("ItemSound.quest_itemget")
elif leafs == 1 and int(st.get("id")) == 15:
st.playSound("ItemSound.quest_middle")
st.set("cond","3")
st.setState(STARTED)
if event == "16" :
htmltext = event_1
st.setState(STARTING)
st.set("id","0")
st.set("cond","1")
st.playSound("ItemSound.quest_accept")
return htmltext
def onTalk (self,npcid,st):
htmltext = default
id = st.getState()
item = get_control_item(st)
if item[0] == 0 :
htmltext = error_1
st.takeItems(FT_LEAF,-1)
st.exitQuest(1)
elif item[0] == -1 :
htmltext = error_2
st.takeItems(FT_LEAF,-1)
st.exitQuest(1)
elif st.getPlayer().getPet() == None :
st.exitQuest(1)
htmltext = "Your pet must be spawned. Quest aborted."
elif st.getPlayer().getPet().getLevel() < MIN_PET_LEVEL :
st.exitQuest(1)
htmltext = error_3_1
elif get_distance(st) :
st.exitQuest(1)
htmltext = "Your pet should be nearby. Quest aborted"
elif npcid == SG_CRONOS :
if id == CREATED :
if st.getPlayer().getLevel() < MIN_PLAYER_LEVEL :
st.exitQuest(1)
htmltext = error_3
else :
htmltext = qston_1
else :
htmltext = error_4
elif npcid == FY_MYMYU :
if id == STARTING :
if st.getQuestItemsCount(FT_LEAF) == 0 and int(st.get("id")) == 0 :
st.set("cond","2")
st.giveItems(FT_LEAF,4)
st.playSound("ItemSound.quest_itemget")
htmltext = order_1
else :
htmltext = error_5
elif id == STARTED :
st.takeItems(item[0],1)
st.giveItems(item[1],1)
st.setState(COMPLETED)
st.exitQuest(1)
st.playSound("ItemSound.quest_finish")
name = st.getPlayer().getPet().getName()
if name == None : name = " "
else : name = " " + name + " "
htmltext = end_msg+name+end_msg2
else:
leafs = st.getQuestItemsCount(FT_LEAF)
if 0 < leafs :
for i in range(4) :
if npcid == FAIRY_TREES[i][0] and (int(st.get("id")) | FAIRY_TREES[i][1] != int(st.get("id"))) :
for j in range(2):
for k in range(2):
st.spawnNpc(GUARDIAN,FAIRY_TREES[i][2]+70*pow(-1,j%2),FAIRY_TREES[i][3]+70*pow(-1,k%2),FAIRY_TREES[i][4])
htmltext = FAIRY_TREES[i][5]
return htmltext
def onKill (self,npcId,st) :
return
# Quest class and state definition
QUEST = Quest(QUEST_NUMBER, str(QUEST_NUMBER)+"_"+QUEST_NAME, QUEST_DESCRIPTION)
CREATED = State('Start', QUEST)
STARTING = State('Starting', QUEST)
STARTED = State('Started', QUEST)
COMPLETED = State('Completed', QUEST)
QUEST.setInitialState(CREATED)
# Quest NPC starter initialization
QUEST.addStartNpc(SG_CRONOS)
# Quest initialization
CREATED.addTalkId(SG_CRONOS)
STARTING.addTalkId(SG_CRONOS)
STARTING.addTalkId(FY_MYMYU)
STARTED.addTalkId(FY_MYMYU)
STARTING.addQuestDrop(SG_CRONOS,FT_LEAF,1)
for i in range(4) :
STARTING.addTalkId(FAIRY_TREES[i][0])