06-15-2013, 07:26 PM
Всем привет. Есть квест на питоне. Мне нужно, чтобы квест запускался, когда игрок заходит в игру.
Часть скрипта:
Часть скрипта:
Код:
# Made by disKret
import sys
from com.l2scoria import Config
from com.l2scoria.util.random import Rnd
from com.l2scoria.gameserver.model import Inventory
from com.l2scoria.gameserver.model.actor.instance import L2ItemInstance
from com.l2scoria.gameserver.model.quest import State
from com.l2scoria.gameserver.model.quest import QuestState
from com.l2scoria.gameserver.model.quest.jython import QuestJython as JQuest
qn = "9990_CraftSystem"
#NPC
NPC_ID = 30086
#QUEST ITEM
PACKAGE = 7263
ONE_TYPE_WEAPON = [1, 2, 3, 4]
ONE_TYPE_DROP_ID = [4037, 57, 4356, 4357, 6673]
ONE_TYPE_DROP_COUNT = 1
ONE_TYPE_DROP_CHANCE = 100
ONE_MOB_ID = [18342, 18341, 18343, 18330, 18331]
TWO_TYPE_WEAPON = [1, 2, 3, 4]
TWO_TYPE_DROP_ID = [1, 2, 3, 4, 5]
TWO_TYPE_DROP_COUNT = 1
TWO_TYPE_DROP_CHANCE = 100
TWO_MOB_ID = [111, 111, 111, 111, 111]
THREE_TYPE_WEAPON = [1, 2, 3, 4]
THREE_TYPE_DROP_ID = [1, 2, 3, 4, 5]
THREE_TYPE_DROP_COUNT = 1
THREE_TYPE_DROP_CHANCE = 100
THREE_MOB_ID = [111, 111, 111, 111, 111]
FO_TYPE_WEAPON = [1, 2, 3, 4]
FO_TYPE_DROP_ID = [1, 2, 3, 4, 5]
FO_TYPE_DROP_COUNT = 1
FO_TYPE_DROP_CHANCE = 100
FO_MOB_ID = [111, 111, 111, 111, 111]
FIVE_TYPE_WEAPON = [1, 2, 3, 4]
FIVE_TYPE_DROP_ID = [1, 2, 3, 4, 5]
FIVE_TYPE_DROP_COUNT = 1
FIVE_TYPE_DROP_CHANCE = 100
FIVE_MOB_ID = [111, 111, 111, 111, 111]
print "E6aTb KoIIaTb 3arpy3uJIocb!"
class Quest (JQuest) :
def __init__(self,id,name,descr):
JQuest.__init__(self,id,name,descr)
self.questItemIds = [PACKAGE]
def onTalk (self,npc,player):
htmltext = "<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>"
st = player.getQuestState(qn)
if not st : return
st.setState(State('Started', QUEST))
return
def onAttack (self, npc, player, damage, isPet):
st = player.getQuestState(qn)
if not st : return
player = st.getPlayer()
npcId = npc.getNpcId()
if player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND) != None:
type = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND)
elif player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != None:
type = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND)
else :
return
itemId = type.getItemId()
if itemId in ONE_TYPE_WEAPON and npcId in ONE_MOB_ID:
if itemId == ONE_TYPE_WEAPON[0] :
if ONE_TYPE_DROP_CHANCE > Rnd.get(1, 100):
st.giveItems(ONE_TYPE_DROP_ID[0], ONE_TYPE_DROP_COUNT)
if ONE_TYPE_DROP_CHANCE > Rnd.get(1, 100):
st.giveItems(ONE_TYPE_DROP_ID[1], ONE_TYPE_DROP_COUNT)
........................................
else :
return
return
QUEST = Quest(9990, qn, "Craft System")
for i in ONE_MOB_ID :
QUEST.addAttackId(i)
for i in TWO_MOB_ID :
QUEST.addAttackId(i)
for i in THREE_MOB_ID :
QUEST.addAttackId(i)
for i in FO_MOB_ID :
QUEST.addAttackId(i)
for i in FIVE_MOB_ID :
QUEST.addAttackId(i)
QUEST.addStartNpc(NPC_ID)
QUEST.addTalkId(NPC_ID)