09-09-2012, 06:37 PM
Никак не могу понять, как добавить в квест, дроп итема, но с условие что это определённый этап квеста, и определённые мобы ?
выдаёт окошко "скрипт эррор" при убийстве моба ( то ли это грёмлин, то ли это демон)
вощем как только указываю в онкилл ИД нпц, при убийстве любого нпц этого квеста выдаёт окошко скрипт эррор
полный код
Код:
import sys
from com.l2jfrozen import Config
from com.l2jfrozen.gameserver.model.quest import State
from com.l2jfrozen.gameserver.model.quest import QuestState
from com.l2jfrozen.gameserver.model.quest.jython import QuestJython as JQuest
qn = "776_Global_War"
#NPC
TIRAEL = 80002
WATCHER = 80004
ORVEN = 30857
#MOBS
GREMLIN = 18342
DEMONS = (80012, 80013, 80014)
CHANCE_FOR_DROP = 100
#ITEMS
WATER = 19001
HOLY_WATER = 19002
SOUL = 19007
WITE_ITEM = 19005
REWARDS={
"adena":[57, 1000000],
"cat" :[7680, 1]
}
class Quest (JQuest) :
def __init__(self, id, name, descr): JQuest.__init__(self, id, name, descr)
def onEvent (self, event, st) :
htmltext = event
if event == "30120-1.htm" :
st.set("cond", "1")
st.setState(STARTED)
st.playSound("ItemSound.quest_accept")
elif event == "30094-1.htm" :
st.giveItems(WATER, 1)
st.set("cond", "2")
elif event == "31706-1.htm" :
st.takeItems(WATER, 1)
st.giveItems(HOLY_WATER, 1)
st.set("cond", "3")
elif event == "30094-4.htm" :
if st.getQuestItemsCount(SOUL) > 4 :
st.set("cond", "5")
else:
htmltext="You don't have enough materials"
st.set("cond", "3")
elif event == "30094-7.htm" :
if st.getQuestItemsCount(SOUL) >= 5:
st.takeItems(SOUL, 5)
st.set("cond", "6")
else:
htmltext="Youn don't have enough materials"
elif event == "30094-10.htm" :
st.set("cond", "8")
elif event in REWARDS.keys() :
if st.getInt("cond") == 8 :
item,qty = REWARDS[event]
st.takeItems(HOLY_WATER,-1)
st.giveItems(item,int(qty*Config.RATE_QUESTS_REWARD))
st.set("cond", "9")
st.playSound("ItemSound.quest_finish")
htmltext = "30094-14.htm"
else :
htmltext="???"
return htmltext
def onTalk (self,npc,player):
htmltext = "<html><body>You are either not carrying out your quest or don't meet the criteria.</body></html>"
st = player.getQuestState(qn)
if not st : return htmltext
npcId = npc.getNpcId()
id = st.getState()
cond=st.getInt("cond")
if npcId == TIRAEL :
if cond == 0 :
if player.getLevel() >= 74 :
htmltext = "30120-0.htm"
elif id == STARTED :
htmltext = "Complited.htm"
else:
htmltext = "30120-0a.htm"
st.exitQuest(1)
elif cond == 1 :
htmltext = "30120-2.htm"
if id == STARTED :
if npcId == WATCHER :
if cond == 1 :
htmltext = "30094-0.htm"
elif cond == 2 :
htmltext = "30094-2.htm"
elif cond == 9 :
htmltext = "Complited.htm"
if npcId == ORVEN :
if cond == 2 :
htmltext = "31706-0.htm"
elif cond == 3 :
htmltext = "31706-2.htm"
elif cond == 4 :
htmltext = "30094-3.htm"
elif cond == 5 and st.getQuestItemsCount(SOUL) < 5 :
htmltext = "30094-5.htm"
elif cond == 5 and st.getQuestItemsCount(SOUL) >= 5 :
htmltext = "30094-6.htm"
elif cond == 6 :
htmltext = "30094-9.htm"
elif cond == 7 :
htmltext = "30094-7.htm"
elif cond == 8 :
htmltext = "30094-12.htm"
elif cond == 9 :
htmltext = "Complited.htm"
if id == STARTED :
if npcId == TIRAEL :
if cond == 9 :
htmltext = "complited.htm"
return htmltext
def onKill(self, npc, player, isPet):
st = player.getQuestState(qn)
if not st : return
if st.getState()!=STARTED : return
chance = st.getRandom(100)
count = st.getQuestItemsCount(SOUL)
if chance < CHANCE_FOR_DROP and st.getInt("cond")== 3 :
if count < 5 :
st.giveItems(SOUL, 1)
if count == 4 :
st.playSound("ItemSound.quest_middle")
st.set("cond", "4")
else:
st.playSound("ItemSound.quest_itemget")[COLOR="Red"]
count = st.getQuestItemsCount(WITE_ITEM)
if chance < CHANCE_FOR_DROP and st.getInt("cond")== 9 :
st.giveItems(WITE_ITEM, 1)[/COLOR]
#вот так работает, но и все остальные нпц в квесте, дают итем:(
return
QUEST = Quest(776, qn, "Global War Wite")
CREATED = State('Start', QUEST)
STARTED = State('Started', QUEST)
QUEST.setInitialState(CREATED)
QUEST.addStartNpc(TIRAEL)
QUEST.addTalkId(TIRAEL)
QUEST.addTalkId(WATCHER)
QUEST.addTalkId(ORVEN)
QUEST.addTalkId(TIRAEL)
QUEST.addKillId(GREMLIN)
[COLOR="Red"]
for i in DEMONS :
QUEST.addKillId(i)[/COLOR]
STARTED.addQuestDrop(GREMLIN,SOUL,1)
STARTED.addQuestDrop(WATCHER,WATER,1)
Код:
if chance < CHANCE_FOR_DROP and st.getInt("cond")== 9 :
if npcId in DEMONS :
st.giveItems(WITE_ITEM, 1)
вощем как только указываю в онкилл ИД нпц, при убийстве любого нпц этого квеста выдаёт окошко скрипт эррор
Бешенство, это не болезнь :di: © Pumo4ka