wiki:JythonQuestClassQuest
Last modified 6 years ago Last modified on Sep 12, 2006 11:49:46 PM

Class JythonQuest?

Class Quest (net.sf.l2j.gameserver.model.quest.jython.JythonQuest) may be imported in quest scripts as

from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest

And has following members to be used from Jython quest scripts:

Quest(int questId, String name, String descr) - constructor.

  • questId - integer ID of the quest, for L2 cleint
  • name - uniquely identifies the quest in l2j server, defines script file and subdirectory names in data/scripts/
  • descr - quest description strings; is shown when a player talks to an NPC that have multiple quests

String getName() - returns name (id) of the quest, call it as Quest.getName(self) or self.getName(), where self is an instance of jython quest.

String getDescr() - returns description name of the quest, call it as Quest.getDescr(self) or self.getDescr(), where self is an instance of jython quest.

void setInitialState(State state) - sets initial state of the quest (each newly created quest will start from this state). From Jython call it as Quest.setInitialState(CREATED)

State getInitialState() - returns the initial state of the quest, call it as Quest.getInitialState(self) or self.getInitialState(), where self is an instance of jython quest.

String onEvent(String event, QuestState qs) -this method is called from Java code to process quest event in jython script.
In the script this method must be declared like

def onEvent(self,event,st) :
  ...

where

  • self - is a reference to Quest
  • event - is a string, that identified event
  • st - is a state of the quest for current player QuestState

The method onEvent is also called when methods onKill or onTalk are notr defined, event string in this case is empty.

String onKill (int npcId, QuestState qs) - this method is called from Java code when you kill a quest NPC, to process quest event in jython script.
In the script this method must be declared like

def onKill(self,npcId,st) :
  ...

where

  • self - is a reference to Quest
  • npcId - is an integer ID, that identified NPC being killed
  • st - is a state of the quest for current player QuestState

The method onKill will be called only when you subscribed to receive these events for particular monsters in particular quest State.
To subscribe for the kill event use method addKillId of State.

String onTalk (int npcId, QuestState qs) - this method is called from Java code when you talk to a quest NPC, to process quest event in jython script.
In the script this method must be declared like

def onTalk(self,npcId,st) :
  ...

where

  • self - is a reference to Quest
  • npcId - is an integer ID, that identified NPC the player talks with
  • st - is a state of the quest for current player QuestState

The method onTalk will be called only when you subscribed to receive these events for particular NPC in particular quest State.
To subscribe for the talk event use method addTalkId of State.