com.planet_ink.coffee_mud.Common
Class DefaultQuest

java.lang.Object
  extended by com.planet_ink.coffee_mud.Common.DefaultQuest
All Implemented Interfaces:
CMCommon, Quest, CMObject, Modifiable, Tickable, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class DefaultQuest
extends java.lang.Object
implements Quest, Tickable, CMObject


Nested Class Summary
protected static class DefaultQuest.JScriptQuest
           
static class DefaultQuest.MysteryData
          MysteryData is a helper class for QuestState that stores quest state variables for the parsing of quests that make use of the "mystery" variables (mystery as in Sherlock Holmes, not as in unknown).
static class DefaultQuest.PreservedQuestObject
          Objects selected for use by a quest can be preserved or released from quest-state to quest-state.
static class DefaultQuest.QuestState
          A quest state class maps the parse-state of a quest, since quest parsing is highly state dependent, but the state is not explicit in the script itself.
 
Nested classes/interfaces inherited from interface com.planet_ink.coffee_mud.Common.interfaces.Quest
Quest.QuestScript
 
Field Summary
protected  java.lang.String author
           
protected static java.lang.String[] CCODES
           
protected  java.lang.String displayName
           
protected  boolean durable
           
protected  int duration
           
 DVector internalFiles
           
protected  long lastStartDateTime
           
protected  int maxWait
           
protected  int minPlayers
           
protected  int minWait
           
protected  java.lang.String name
           
protected  java.lang.String playerMask
           
protected  java.lang.String rawScriptParameter
           
protected  int runLevel
           
protected  int spawn
           
protected  java.lang.String startDate
           
protected  java.util.Map<java.lang.String,java.lang.Long> stepEllapsedTimes
           
protected  int ticksRemaining
           
protected  int waitRemaining
           
protected  java.util.Map<java.lang.String,java.lang.Long> winners
           
 
Fields inherited from interface com.planet_ink.coffee_mud.Common.interfaces.Quest
FLAG_SUSPENDED, MYSTERY_QCODES, QCODES, QOBJS, ROOM_REFERENCE_QCODES, SPAWN_ANY, SPAWN_DESCS, SPAWN_FIRST, SPAWN_NO
 
Fields inherited from interface com.planet_ink.coffee_mud.core.interfaces.Tickable
STATUS_AFFECT, STATUS_ALIVE, STATUS_BEHAVIOR, STATUS_CLASS, STATUS_DEAD, STATUS_END, STATUS_FIGHT, STATUS_MISC, STATUS_MISC2, STATUS_MISC3, STATUS_MISC4, STATUS_MISC5, STATUS_MISC6, STATUS_MISC7, STATUS_NOT, STATUS_OTHER, STATUS_RACE, STATUS_REBIRTH, STATUS_SCRIPT, STATUS_START, STATUS_WEATHER, TICKID_AREA, TICKID_BEAMWEAPON, TICKID_CLAN, TICKID_CLANITEM, TICKID_DEADBODY_DECAY, TICKID_ELECTRONICS, TICKID_EMAIL, TICKID_EXIT_BEHAVIOR, TICKID_EXIT_REOPEN, TICKID_ITEM_BEHAVIOR, TICKID_ITEM_BOUNCEBACK, TICKID_LIGHT_FLICKERS, TICKID_LIVEAUCTION, TICKID_LONGERMASK, TICKID_MISCELLANEOUS, TICKID_MOB, TICKID_PROPERTY_SPECIAL, TICKID_QUEST, TICKID_READYTOSTOP, TICKID_ROOM_BEHAVIOR, TICKID_ROOM_ITEM_REJUV, TICKID_SOLITARYMASK, TICKID_SPECIALCOMBAT, TICKID_SPECIALMANEUVER, TICKID_SPELL_AFFECT, TICKID_SUPPORT, TICKID_TIMEAUCTION, TICKID_TRAP_DESTRUCTION, TICKID_TRAP_RESET
 
Constructor Summary
DefaultQuest()
           
 
Method Summary
 java.lang.String author()
          Returns the author of the quest
 void autostartup()
          After a quest is added to the list of quests, this method is called to put the quest into its initial wait state, and get it thread time.
 void cleanQuestStep()
           
 int compareTo(CMObject o)
           
 CMObject copyOf()
          Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.
 void declareWinner(java.lang.String name)
          Registers the given player name as having won this quest.
 java.lang.String displayName()
          Returns the friendly display name of the quest
 int duration()
          Returns the duration, in ticks of this quest.
 boolean enterDormantState()
          A dormant state is the state where a quest is no longer running, but is not, or has not yet, been scheduled to wait for another run time.
 void enterRunningState()
           
protected  void errorOccurred(DefaultQuest.QuestState q, boolean quietFlag, java.lang.String msg)
           
protected  void filterOutThoseInUse(java.util.List<? extends Environmental> choices, java.lang.String choicesStr, DefaultQuest.QuestState q, boolean isQuiet, boolean reselect)
           
protected  int getCodeNum(java.lang.String code)
           
 java.lang.Object getDesignatedObject(java.lang.String named)
          From the given official quest variable name, it derives either an object or a vector of objects that reflect it.
 long getFlags()
          Returns flag bitmap
 Quest getMainQuestObject()
           
 int getObjectInUseIndex(java.lang.String name)
          Returns the index of a room, mob, or item of the given name in use by this quest.
 Item getQuestItem(int i)
          Returns the item in use by this quest at the given index
 int getQuestItemIndex(java.lang.String name)
          Returns the index of a item of the given name in use by this quest
 java.lang.String getQuestItemName(int i)
          Returns the name of the item in use by this quest at the given index
 MOB getQuestMob(int i)
          Returns the mob in use by this quest at the given index
 int getQuestMobIndex(java.lang.String name)
          Returns the index of a mob of the given name in use by this quest
 java.lang.String getQuestMobName(int i)
          Returns the name of the mob in use by this quest at the given index
 Room getQuestRoom(int i)
          Returns the room in use by this quest at the given index
 java.lang.String getQuestRoomID(int i)
          Returns the id of the room in use by this quest at the given index
 int getQuestRoomIndex(java.lang.String roomID)
          Returns the index of a room of the given id in use by this quest
 Environmental getQuestThing(java.util.Iterator<? extends Environmental> e, int dex, CMClass.CMObjectType type, int[] num)
           
 int getQuestThingIndex(java.util.Iterator<? extends Environmental> i, java.lang.String name, CMClass.CMObjectType type, int[] num)
           
 java.lang.StringBuffer getResourceFileData(java.lang.String named, boolean showErrors)
          Quest scripts can have files of various sorts embedded in them.
 int getSaveStatIndex()
          Returns the index into the stat codes array where extra savable fields begins.
 int getSpawn()
          Returns the flag denoting whether this quest spawns new ones from its several steps and if so, by what method.
 java.lang.String getStat(java.lang.String code)
          An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders.
 java.lang.String[] getStatCodes()
          Returns an array of the string names of those fields which are modifiable on this object at run-time by builders.
 int getTickStatus()
          A coded status for this object during the period where its tick method is being called.
 java.util.Map<java.lang.String,java.lang.Long> getWinners()
          Returns the names of all the winners of this quest
 java.lang.String getWinnerStr()
          Returns a semicolon delimited string of all the winners of this quest
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 void initializeClass()
          Called ONCE after all objects are loaded, but before the map is read in during initialization.
 void internalQuestDelete()
          If any files are embedded and cached inside this quest script, this method will clear them from resources and memory.
 boolean isCopy()
          Returns whether this quest object is a spawned copy
 boolean isObjectInUse(Environmental E)
          Returns whether the exact given object is in use by this quest.
 boolean isStat(java.lang.String code)
          An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders.
 int minPlayers()
          The minimum number of players matching player criteria required before this quest will start
 int minsRemaining()
          Returns the number of minutes before this quest will go from a running state to a stopped state.
 int minWait()
          Returns the minimum number of ticks between attempts to run this quest.
 java.lang.String name()
          Returns the unique name of the quest
 CMObject newInstance()
          Returns a new instance of this class.
 java.util.Vector parseLoadScripts(java.lang.String text, java.util.List oldArgs, java.util.List args, boolean showErrors)
           
 void parseQuestScript(java.util.Vector script, java.util.List args, int startLine)
           
 void parseQuestScriptWArgs(java.util.Vector script, java.util.List args)
           
 java.lang.String playerMask()
          Returns the zappermask that determines who counts as an elligible player for the purposes of the minPlayer setting.
 void resetQuest(int firstPauseTicks)
          this will stop executing of the quest script.
 boolean resetWaitRemaining(long ellapsedTime)
          Sets the number of ticks before this quest will attempt to start.
 int runLevel()
          Returns the run level.
 boolean running()
          Returns whether this quest is in a running state
 void runtimeRegisterAbility(MOB mob, java.lang.String abilityID, java.lang.String parms, boolean give)
          they are called when you want the quest engine to be aware of a a quest-specific object thats being added to the map, so that it can be cleaned up later.
 void runtimeRegisterBehavior(PhysicalAgent behaving, java.lang.String behaviorID, java.lang.String parms, boolean give)
          Called when you want the quest engine to be aware of a quest specific object that is being added to the map, so that it can be cleaned up later.
 void runtimeRegisterEffect(PhysicalAgent affected, java.lang.String abilityID, java.lang.String parms, boolean give)
          Called when you want the quest engine to be aware of a quest specific object that is being added to the map, so that it can be cleaned up later.
 void runtimeRegisterObject(PhysicalAgent P)
          Called when you want the quest engine to be aware of a quest specific object that is being added to the map, so that it can be cleaned up later.
 void runtimeRegisterStat(Environmental E, java.lang.String stat, java.lang.String parms, boolean give)
           
 boolean sameAs(DefaultQuest E)
           
 java.lang.String script()
          Returns the unparsed quest script as a single happy string.
 void setAuthor(java.lang.String newName)
          Sets the author of the quest
 void setCopy(boolean truefalse)
          Sets whether this quest object is a spawned copy
 void setDisplayName(java.lang.String newName)
          Sets the friendly display name of the quest
 void setDuration(int newTicks)
          Sets the duration, in ticks of this quest.
 void setFlags(long flags)
          Sets the flag bitmap
 void setMinPlayers(int players)
          Sets minimum number of players matching player criteria required before this quest will start
 void setMinWait(int wait)
          Sets the minimum number of ticks between attempts to run this quest.
 void setName(java.lang.String newName)
          Sets the unique name of the quest
 void setPlayerMask(java.lang.String mask)
          Sets the zappermask that determines who counts as an elligible player for the purposes of the minPlayer setting.
 void setRunLevel(int level)
          Sets the run level.
 boolean setScript(java.lang.String parm, boolean showErrors)
          Sets the quest script.
 void setSpawn(int spawnFlag)
          Sets the flag denoting whether this quest spawns new ones from its several steps and if so, by what method.
 void setStartDate(java.lang.String newDate)
          Sets the real-life start date of this quest.
 void setStartMudDate(java.lang.String newDate)
          Sets the in-game mud start date of this quest.
 void setStat(java.lang.String code, java.lang.String val)
          An alternative means of setting the values of those fields on this object which are modifiable at run-time by builders.
 void setSuspended(boolean truefalse)
          Sets whether this quest object is suspended.
 void setVars(java.util.List<?> script, int startAtLine)
          Accepts a pre-parsed quest script and extracts certain non-iterative variables, such as the quest name and similar variables.
 void setWaitInterval(int wait)
          Sets the maximum ticks, above the minimum wait, that must go by before an attempt to run a quest.
 void setWinners(java.lang.String list)
          Sets the list of player names that have won this quest
 boolean spawnQuest(java.lang.String script, java.util.Vector baseVars, boolean reTime)
           
 java.lang.String startDate()
          Returns the unique start date of the quest.
 boolean startQuest()
          This will execute the quest script.
 boolean startQuestInternal()
           
protected  boolean startQuestOnTime()
           
 boolean stepQuest()
          This method is called when a quest is done with a particular step in a multi-step quest.
 boolean stopping()
          Returns whether this quest is in a midway stopping state
 void stopQuest()
          this will stop executing of the quest script.
 void stopQuestInternal()
           
 boolean suspended()
          Returns whether this quest object is suspended.
 boolean tick(Tickable ticking, int tickID)
          this is the method which is called periodically by the threading engine.
 int ticksRemaining()
          Returns the number of ticks before this quest will go from a running state to a stopped state.
 boolean waiting()
          Returns whether this quest is in a wait state between runs
 int waitInterval()
          Returns the maximum ticks, above the minimum wait, that must go by before an attempt to run a quest.
 int waitRemaining()
          Returns the number of ticks before this quest will attempt to start.
 boolean wasWinner(java.lang.String name)
          Returns whether a player of the given name has won this quest
 java.lang.Long whenLastWon(java.lang.String name)
          Returns when a player of the given name last won this quest or null
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

author

protected java.lang.String author

displayName

protected java.lang.String displayName

startDate

protected java.lang.String startDate

duration

protected int duration

rawScriptParameter

protected java.lang.String rawScriptParameter

durable

protected boolean durable

minWait

protected int minWait

minPlayers

protected int minPlayers

playerMask

protected java.lang.String playerMask

runLevel

protected int runLevel

maxWait

protected int maxWait

waitRemaining

protected int waitRemaining

ticksRemaining

protected int ticksRemaining

lastStartDateTime

protected long lastStartDateTime

spawn

protected int spawn

internalFiles

public DVector internalFiles

stepEllapsedTimes

protected final java.util.Map<java.lang.String,java.lang.Long> stepEllapsedTimes

winners

protected final java.util.Map<java.lang.String,java.lang.Long> winners

CCODES

protected static java.lang.String[] CCODES
Constructor Detail

DefaultQuest

public DefaultQuest()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, Tech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Returns:
the name of this class

name

public java.lang.String name()
Description copied from interface: Quest
Returns the unique name of the quest

Specified by:
name in interface Quest
Specified by:
name in interface CMObject
Specified by:
name in interface Tickable
Returns:
the unique name of the quest
See Also:
Quest.setName(String)

setName

public void setName(java.lang.String newName)
Description copied from interface: Quest
Sets the unique name of the quest

Specified by:
setName in interface Quest
Parameters:
newName - the unique name of the quest
See Also:
Quest.name()

author

public java.lang.String author()
Description copied from interface: Quest
Returns the author of the quest

Specified by:
author in interface Quest
Returns:
the author of the quest
See Also:
Quest.setAuthor(String)

setAuthor

public void setAuthor(java.lang.String newName)
Description copied from interface: Quest
Sets the author of the quest

Specified by:
setAuthor in interface Quest
Parameters:
newName - the author of the quest
See Also:
Quest.author()

displayName

public java.lang.String displayName()
Description copied from interface: Quest
Returns the friendly display name of the quest

Specified by:
displayName in interface Quest
Returns:
the friendly display name of the quest
See Also:
Quest.setDisplayName(String)

setDisplayName

public void setDisplayName(java.lang.String newName)
Description copied from interface: Quest
Sets the friendly display name of the quest

Specified by:
setDisplayName in interface Quest
Parameters:
newName - the friendly display name of the quest
See Also:
Quest.displayName()

copyOf

public CMObject copyOf()
Description copied from interface: CMObject
Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.

Specified by:
copyOf in interface CMObject
Returns:
a clone of this object

suspended

public boolean suspended()
Description copied from interface: Quest
Returns whether this quest object is suspended. A suspended quest is always in a stopped state.

Specified by:
suspended in interface Quest
Returns:
true if this quest object is suspended
See Also:
Quest.setSuspended(boolean)

setSuspended

public void setSuspended(boolean truefalse)
Description copied from interface: Quest
Sets whether this quest object is suspended. A suspended quest should always in a stopped state.

Specified by:
setSuspended in interface Quest
Parameters:
truefalse - true if this quest object is suspended
See Also:
Quest.suspended()

newInstance

public CMObject newInstance()
Description copied from interface: CMObject
Returns a new instance of this class.

Specified by:
newInstance in interface CMObject
Returns:
a new instance of this class

initializeClass

public void initializeClass()
Description copied from interface: CMObject
Called ONCE after all objects are loaded, but before the map is read in during initialization.

Specified by:
initializeClass in interface CMObject

getDesignatedObject

public java.lang.Object getDesignatedObject(java.lang.String named)
Description copied from interface: Quest
From the given official quest variable name, it derives either an object or a vector of objects that reflect it.

Specified by:
getDesignatedObject in interface Quest
Parameters:
named - the code to return a string, object, or vector for
Returns:
a string, mob, item, room, vector, etc..
See Also:
Quest.QOBJS

internalQuestDelete

public void internalQuestDelete()
Description copied from interface: Quest
If any files are embedded and cached inside this quest script, this method will clear them from resources and memory.

Specified by:
internalQuestDelete in interface Quest

startDate

public java.lang.String startDate()
Description copied from interface: Quest
Returns the unique start date of the quest. The format is either MONTH-DAY for real life dates, or MUDDAY MONTH-DAY for mudday based dates.

Specified by:
startDate in interface Quest
Returns:
the unique formatted start date of the quest
See Also:
Quest.setStartDate(String), Quest.setStartMudDate(String)

setStartDate

public void setStartDate(java.lang.String newDate)
Description copied from interface: Quest
Sets the real-life start date of this quest. The format is MONTH-DAY.

Specified by:
setStartDate in interface Quest
Parameters:
newDate - the real-life start date of this quest
See Also:
Quest.startDate(), Quest.setStartMudDate(String)

setStartMudDate

public void setStartMudDate(java.lang.String newDate)
Description copied from interface: Quest
Sets the in-game mud start date of this quest. The format is MONTH-DAY.

Specified by:
setStartMudDate in interface Quest
Parameters:
newDate - the in-game mud start date of this quest
See Also:
Quest.startDate(), Quest.setStartDate(String)

duration

public int duration()
Description copied from interface: Quest
Returns the duration, in ticks of this quest. A value of 0 means the quest runs indefinitely.

Specified by:
duration in interface Quest
Returns:
the duration, in ticks, of this quest
See Also:
Quest.setDuration(int)

setDuration

public void setDuration(int newTicks)
Description copied from interface: Quest
Sets the duration, in ticks of this quest. A value of 0 means the quest runs indefinitely.

Specified by:
setDuration in interface Quest
Parameters:
newTicks - the duration, in ticks, of this quest
See Also:
Quest.duration()

setCopy

public void setCopy(boolean truefalse)
Description copied from interface: Quest
Sets whether this quest object is a spawned copy

Specified by:
setCopy in interface Quest
Parameters:
truefalse - true if this quest object is a spawned copy
See Also:
Quest.isCopy()

isCopy

public boolean isCopy()
Description copied from interface: Quest
Returns whether this quest object is a spawned copy

Specified by:
isCopy in interface Quest
Returns:
whether this quest object is a spawned copy
See Also:
Quest.setCopy(boolean)

setSpawn

public void setSpawn(int spawnFlag)
Description copied from interface: Quest
Sets the flag denoting whether this quest spawns new ones from its several steps and if so, by what method.

Specified by:
setSpawn in interface Quest
Parameters:
spawnFlag - the quest spawn flag info
See Also:
Quest.SPAWN_ANY, Quest.SPAWN_FIRST, Quest.SPAWN_NO, Quest.SPAWN_DESCS, Quest.getSpawn()

getSpawn

public int getSpawn()
Description copied from interface: Quest
Returns the flag denoting whether this quest spawns new ones from its several steps and if so, by what method.

Specified by:
getSpawn in interface Quest
Returns:
the quest spawn flag info
See Also:
Quest.SPAWN_ANY, Quest.SPAWN_FIRST, Quest.SPAWN_NO, Quest.SPAWN_DESCS, Quest.setSpawn(int)

minPlayers

public int minPlayers()
Description copied from interface: Quest
The minimum number of players matching player criteria required before this quest will start

Specified by:
minPlayers in interface Quest
Returns:
minimum number of players matching player criteria required
See Also:
Quest.setMinPlayers(int), Quest.playerMask(), Quest.setPlayerMask(String)

setMinPlayers

public void setMinPlayers(int players)
Description copied from interface: Quest
Sets minimum number of players matching player criteria required before this quest will start

Specified by:
setMinPlayers in interface Quest
Parameters:
players - minimum number of players matching player criteria required
See Also:
Quest.minPlayers(), Quest.playerMask(), Quest.setPlayerMask(String)

runLevel

public int runLevel()
Description copied from interface: Quest
Returns the run level. -1 means runs always, otherwise, this quest will always defer to running quests of equal or lower run level. Higher, therefore, is weaker.

Specified by:
runLevel in interface Quest
Returns:
the run level. -1 means runs always
See Also:
Quest.setRunLevel(int)

setRunLevel

public void setRunLevel(int level)
Description copied from interface: Quest
Sets the run level. -1 means runs always, otherwise, this quest will always defer to running quests of equal or lower run level. Higher, therefore, is weaker.

Specified by:
setRunLevel in interface Quest
Parameters:
level - the run level. -1 means runs always
See Also:
Quest.runLevel()

playerMask

public java.lang.String playerMask()
Description copied from interface: Quest
Returns the zappermask that determines who counts as an elligible player for the purposes of the minPlayer setting.

Specified by:
playerMask in interface Quest
Returns:
the zappermask that determines who counts as a player
See Also:
MaskingLibrary, Quest.setMinPlayers(int), Quest.minPlayers(), Quest.setPlayerMask(String)

setPlayerMask

public void setPlayerMask(java.lang.String mask)
Description copied from interface: Quest
Sets the zappermask that determines who counts as an elligible player for the purposes of the minPlayer setting.

Specified by:
setPlayerMask in interface Quest
Parameters:
mask - the zappermask that determines who counts as a player
See Also:
MaskingLibrary, Quest.setMinPlayers(int), Quest.minPlayers(), Quest.playerMask()

setScript

public boolean setScript(java.lang.String parm,
                         boolean showErrors)
Description copied from interface: Quest
Sets the quest script. This may be semicolon-separated instructions, or a LOAD command followed by the quest script path.

Specified by:
setScript in interface Quest
Parameters:
parm - the actual quest script
showErrors - true to report file errors, false otherwise
Returns:
true
See Also:
Quest.script()

script

public java.lang.String script()
Description copied from interface: Quest
Returns the unparsed quest script as a single happy string.

Specified by:
script in interface Quest
Returns:
the unparsed quest script as a single happy string.
See Also:
Quest.setScript(String, boolean)

autostartup

public void autostartup()
Description copied from interface: Quest
After a quest is added to the list of quests, this method is called to put the quest into its initial wait state, and get it thread time.

Specified by:
autostartup in interface Quest

setVars

public void setVars(java.util.List<?> script,
                    int startAtLine)
Description copied from interface: Quest
Accepts a pre-parsed quest script and extracts certain non-iterative variables, such as the quest name and similar variables.

Specified by:
setVars in interface Quest
Parameters:
script - the parsed quest script
startAtLine - which line of the script to start at
See Also:
Quest

getResourceFileData

public java.lang.StringBuffer getResourceFileData(java.lang.String named,
                                                  boolean showErrors)
Description copied from interface: Quest
Quest scripts can have files of various sorts embedded in them. This method will return the text of any such files of the given name, if they were embedded, or if not, it will attempt to open the file in the filesystem and return that one instead.

Specified by:
getResourceFileData in interface Quest
Parameters:
named - the name of the resource path file to return
showErrors - true to report file errors, false otherwise
Returns:
the text of the file, if found.
See Also:
Quest

parseQuestScriptWArgs

public void parseQuestScriptWArgs(java.util.Vector script,
                                  java.util.List args)

errorOccurred

protected void errorOccurred(DefaultQuest.QuestState q,
                             boolean quietFlag,
                             java.lang.String msg)

filterOutThoseInUse

protected void filterOutThoseInUse(java.util.List<? extends Environmental> choices,
                                   java.lang.String choicesStr,
                                   DefaultQuest.QuestState q,
                                   boolean isQuiet,
                                   boolean reselect)

parseQuestScript

public void parseQuestScript(java.util.Vector script,
                             java.util.List args,
                             int startLine)

spawnQuest

public boolean spawnQuest(java.lang.String script,
                          java.util.Vector baseVars,
                          boolean reTime)

startQuest

public boolean startQuest()
Description copied from interface: Quest
This will execute the quest script. If the quest is running, it will call stopQuest first to shut it down. It will spawn its subquests and subsections if necessary.

Specified by:
startQuest in interface Quest
Returns:
whether the quest was successfully started
See Also:
Quest.resetQuest(int), Quest.stepQuest(), Quest.stopQuest()

startQuestInternal

public boolean startQuestInternal()

enterRunningState

public void enterRunningState()

cleanQuestStep

public void cleanQuestStep()

stepQuest

public boolean stepQuest()
Description copied from interface: Quest
This method is called when a quest is done with a particular step in a multi-step quest. This method will clean up any objects from the current step or previous steps and attempt to start up the next step in the quest. If there are no more steps, or the quest is only 1 step, stopQuest() will be called.

Specified by:
stepQuest in interface Quest
Returns:
true if another step was started, false otherwise
See Also:
Quest.startQuest(), Quest.stopQuest()

resetQuest

public void resetQuest(int firstPauseTicks)
Description copied from interface: Quest
this will stop executing of the quest script. It will clean up any objects or mobs which may have been loaded, restoring map mobs to their previous state. It will then enter a stopped-paused state for the given ticks. Any start failures after that will cause the pause time to be doubled before the next try.

Specified by:
resetQuest in interface Quest
Parameters:
firstPauseTicks - ticks to remain in stopped state before restarting
See Also:
Quest.startQuest(), Quest.stepQuest(), Quest.stopQuest()

stopQuest

public void stopQuest()
Description copied from interface: Quest
this will stop executing of the quest script. It will clean up any objects or mobs which may have been loaded, restoring map mobs to their previous state. If the quest is autorandom, it will restart the waiting process

Specified by:
stopQuest in interface Quest
See Also:
Quest.startQuest(), Quest.stepQuest(), Quest.resetQuest(int)

stopQuestInternal

public void stopQuestInternal()

enterDormantState

public boolean enterDormantState()
Description copied from interface: Quest
A dormant state is the state where a quest is no longer running, but is not, or has not yet, been scheduled to wait for another run time. This may result in a quest being deleted if it was a spawned temporary quest.

Specified by:
enterDormantState in interface Quest
Returns:
true if it is in a dormant state, or false if quest was deleted

resetWaitRemaining

public boolean resetWaitRemaining(long ellapsedTime)
Description copied from interface: Quest
Sets the number of ticks before this quest will attempt to start. A number greater than or equal to 0 means the quest is currently in a stopped state.

Specified by:
resetWaitRemaining in interface Quest
Parameters:
ellapsedTime - the number of miliseconds already ellapsed before wait began
Returns:
true if the quest is successfully put into a non-running wait state
See Also:
Quest.waitRemaining()

minWait

public int minWait()
Description copied from interface: Quest
Returns the minimum number of ticks between attempts to run this quest.

Specified by:
minWait in interface Quest
Returns:
the minimum number of ticks between attempts to run this quest.
See Also:
Quest.setMinWait(int), Quest.waitInterval(), Quest.setWaitInterval(int)

setMinWait

public void setMinWait(int wait)
Description copied from interface: Quest
Sets the minimum number of ticks between attempts to run this quest.

Specified by:
setMinWait in interface Quest
Parameters:
wait - the minimum number of ticks between attempts to run this quest.
See Also:
Quest.minWait(), Quest.waitInterval(), Quest.setWaitInterval(int)

waitInterval

public int waitInterval()
Description copied from interface: Quest
Returns the maximum ticks, above the minimum wait, that must go by before an attempt to run a quest. This is therefore, the random part.

Specified by:
waitInterval in interface Quest
Returns:
the maximum ticks, above the minimum wait, that must go by
See Also:
Quest.setMinWait(int), Quest.minWait(), Quest.setWaitInterval(int)

setWaitInterval

public void setWaitInterval(int wait)
Description copied from interface: Quest
Sets the maximum ticks, above the minimum wait, that must go by before an attempt to run a quest. This is therefore, the random part.

Specified by:
setWaitInterval in interface Quest
Parameters:
wait - the maximum ticks, above the minimum wait, that must go by
See Also:
Quest.setMinWait(int), Quest.minWait(), Quest.waitInterval()

waitRemaining

public int waitRemaining()
Description copied from interface: Quest
Returns the number of ticks before this quest will attempt to start. A number greater than or equal to 0 means the quest is currently in a stopped state.

Specified by:
waitRemaining in interface Quest
Returns:
the number of ticks before this quest will attempt to start.
See Also:
Quest.resetWaitRemaining(long)

getMainQuestObject

public Quest getMainQuestObject()

declareWinner

public void declareWinner(java.lang.String name)
Description copied from interface: Quest
Registers the given player name as having won this quest. The name may be prefixed with a "-" to undeclare the winner (for player deletes).

Specified by:
declareWinner in interface Quest
Parameters:
name - the player name
See Also:
Quest.getWinners(), Quest.getWinnerStr(), Quest.wasWinner(String), Quest.setWinners(String), Quest.whenLastWon(String)

getWinnerStr

public java.lang.String getWinnerStr()
Description copied from interface: Quest
Returns a semicolon delimited string of all the winners of this quest

Specified by:
getWinnerStr in interface Quest
Returns:
a semicolon delimited string of all the winners of this quest
See Also:
Quest.declareWinner(String), Quest.getWinners(), Quest.wasWinner(String), Quest.setWinners(String), Quest.whenLastWon(String)

setWinners

public void setWinners(java.lang.String list)
Description copied from interface: Quest
Sets the list of player names that have won this quest

Specified by:
setWinners in interface Quest
Parameters:
list - a semicolon delimtied list of player names
See Also:
Quest.declareWinner(String), Quest.getWinners(), Quest.getWinnerStr(), Quest.wasWinner(String)

getWinners

public java.util.Map<java.lang.String,java.lang.Long> getWinners()
Description copied from interface: Quest
Returns the names of all the winners of this quest

Specified by:
getWinners in interface Quest
Returns:
the names of all the winners of this quest and last time won
See Also:
Quest.declareWinner(String), Quest.getWinnerStr(), Quest.wasWinner(String), Quest.setWinners(String), Quest.whenLastWon(String)

wasWinner

public boolean wasWinner(java.lang.String name)
Description copied from interface: Quest
Returns whether a player of the given name has won this quest

Specified by:
wasWinner in interface Quest
Parameters:
name - the player name
Returns:
true if a player of the given name has won this quest
See Also:
Quest.declareWinner(String), Quest.getWinners(), Quest.getWinnerStr(), Quest.setWinners(String), Quest.whenLastWon(String)

whenLastWon

public java.lang.Long whenLastWon(java.lang.String name)
Description copied from interface: Quest
Returns when a player of the given name last won this quest or null

Specified by:
whenLastWon in interface Quest
Parameters:
name - the player name
Returns:
true if a player of the given name has won this quest
See Also:
Quest.declareWinner(String), Quest.getWinners(), Quest.getWinnerStr(), Quest.setWinners(String), Quest.wasWinner(String)

running

public boolean running()
Description copied from interface: Quest
Returns whether this quest is in a running state

Specified by:
running in interface Quest
Returns:
true if the quest is running, false if stopped
See Also:
Quest.suspended(), Quest.waiting(), Quest.startQuest()

stopping

public boolean stopping()
Description copied from interface: Quest
Returns whether this quest is in a midway stopping state

Specified by:
stopping in interface Quest
Returns:
true if the quest is in the processess of stopping
See Also:
Quest.suspended(), Quest.waiting(), Quest.running(), Quest.stopQuest()

waiting

public boolean waiting()
Description copied from interface: Quest
Returns whether this quest is in a wait state between runs

Specified by:
waiting in interface Quest
Returns:
true if this quest is in a wait state between runs
See Also:
Quest.suspended(), Quest.waiting(), Quest.running(), Quest.stopQuest()

ticksRemaining

public int ticksRemaining()
Description copied from interface: Quest
Returns the number of ticks before this quest will go from a running state to a stopped state.

Specified by:
ticksRemaining in interface Quest
Returns:
the numer of ticks the quest will keep running
See Also:
Quest.minsRemaining(), Quest.startQuest()

minsRemaining

public int minsRemaining()
Description copied from interface: Quest
Returns the number of minutes before this quest will go from a running state to a stopped state.

Specified by:
minsRemaining in interface Quest
Returns:
the numer of minutes the quest will keep running
See Also:
Quest.ticksRemaining(), Quest.startQuest()

getTickStatus

public int getTickStatus()
Description copied from interface: Tickable
A coded status for this object during the period where its tick method is being called. The statis is defined, at least in part, by constants in this interface STATUS_*. STATUS_NOT should be returned when the objects tick method is not currently in execution. It should never return STATUS_NOT when the objects tick method is in execution.

Specified by:
getTickStatus in interface Tickable
Returns:
the numeric status of this object
See Also:
Tickable.tick(Tickable, int)

tick

public boolean tick(Tickable ticking,
                    int tickID)
Description copied from interface: Tickable
this is the method which is called periodically by the threading engine. How often it is called depends on the parameters passed to the threadding engine when it is submitted for thread access. Typically the period is once per TIME_TICK period, but that is determined when the object is submitted to the thread engine.

Specified by:
tick in interface Tickable
Parameters:
ticking - a reference to this Tickable object
tickID - the TICKID_ constant describing this periodic call, as defined in Tickable
Returns:
true always, unless this object no longer wishes to ever tick again, in which case false
See Also:
Tickable, ServiceEngine, TickableGroup

startQuestOnTime

protected boolean startQuestOnTime()

runtimeRegisterAbility

public void runtimeRegisterAbility(MOB mob,
                                   java.lang.String abilityID,
                                   java.lang.String parms,
                                   boolean give)
Description copied from interface: Quest
they are called when you want the quest engine to be aware of a a quest-specific object thats being added to the map, so that it can be cleaned up later. Ditto for abilities, affects, and behaviors. this method should only be used WHILE a quest script is being interpreted

Specified by:
runtimeRegisterAbility in interface Quest
Parameters:
mob - the mob receiving the ability
abilityID - the id of the ability
parms - any ability parameters
give - false to remove this ability, true to replace an existing one
See Also:
Quest.runtimeRegisterBehavior(PhysicalAgent, String, String, boolean), Quest.runtimeRegisterEffect(PhysicalAgent, String, String, boolean), Quest.runtimeRegisterObject(PhysicalAgent)

runtimeRegisterObject

public void runtimeRegisterObject(PhysicalAgent P)
Description copied from interface: Quest
Called when you want the quest engine to be aware of a quest specific object that is being added to the map, so that it can be cleaned up later. this method should only be used WHILE a quest script is being interpreted

Specified by:
runtimeRegisterObject in interface Quest
Parameters:
P - the object added to the map
See Also:
Quest.runtimeRegisterAbility(MOB, String, String, boolean), Quest.runtimeRegisterBehavior(PhysicalAgent, String, String, boolean), Quest.runtimeRegisterEffect(PhysicalAgent, String, String, boolean), Quest

runtimeRegisterEffect

public void runtimeRegisterEffect(PhysicalAgent affected,
                                  java.lang.String abilityID,
                                  java.lang.String parms,
                                  boolean give)
Description copied from interface: Quest
Called when you want the quest engine to be aware of a quest specific object that is being added to the map, so that it can be cleaned up later. This is called to add an effect to the given object. this method should only be used WHILE a quest script is being interpreted

Specified by:
runtimeRegisterEffect in interface Quest
Parameters:
affected - the object receiving the effect
abilityID - the id of the effect
parms - any effect parameters
give - false to remove this effect, true to replace an existing one
See Also:
Quest.runtimeRegisterAbility(MOB, String, String, boolean), Quest.runtimeRegisterBehavior(PhysicalAgent, String, String, boolean), Quest.runtimeRegisterObject(PhysicalAgent)

runtimeRegisterBehavior

public void runtimeRegisterBehavior(PhysicalAgent behaving,
                                    java.lang.String behaviorID,
                                    java.lang.String parms,
                                    boolean give)
Description copied from interface: Quest
Called when you want the quest engine to be aware of a quest specific object that is being added to the map, so that it can be cleaned up later. This is called to add a behavior to the given object. this method should only be used WHILE a quest script is being interpreted

Specified by:
runtimeRegisterBehavior in interface Quest
Parameters:
behaving - the object receiving the behavior
behaviorID - the id of the behavior
parms - any behavior parameters
give - false to remove this behavior, true to replace an existing one
See Also:
Quest.runtimeRegisterAbility(MOB, String, String, boolean), Quest.runtimeRegisterEffect(PhysicalAgent, String, String, boolean), Quest.runtimeRegisterObject(PhysicalAgent)

runtimeRegisterStat

public void runtimeRegisterStat(Environmental E,
                                java.lang.String stat,
                                java.lang.String parms,
                                boolean give)

getQuestThingIndex

public int getQuestThingIndex(java.util.Iterator<? extends Environmental> i,
                              java.lang.String name,
                              CMClass.CMObjectType type,
                              int[] num)

getQuestMobIndex

public int getQuestMobIndex(java.lang.String name)
Description copied from interface: Quest
Returns the index of a mob of the given name in use by this quest

Specified by:
getQuestMobIndex in interface Quest
Parameters:
name - the given name
Returns:
the index of a mob of the given name in use by this quest
See Also:
Quest.getQuestMobName(int), Quest.getQuestMob(int)

getQuestRoomIndex

public int getQuestRoomIndex(java.lang.String roomID)
Description copied from interface: Quest
Returns the index of a room of the given id in use by this quest

Specified by:
getQuestRoomIndex in interface Quest
Parameters:
roomID - the given room id
Returns:
the index of a room of the given id in use by this quest
See Also:
Quest.getQuestRoom(int), Quest.getQuestRoomID(int)

getQuestItemIndex

public int getQuestItemIndex(java.lang.String name)
Description copied from interface: Quest
Returns the index of a item of the given name in use by this quest

Specified by:
getQuestItemIndex in interface Quest
Parameters:
name - the given name
Returns:
the index of a item of the given name in use by this quest
See Also:
Quest.getQuestItem(int), Quest.getQuestItemName(int)

getFlags

public long getFlags()
Description copied from interface: Quest
Returns flag bitmap

Specified by:
getFlags in interface Quest
Returns:
the flag bitmap
See Also:
Quest.FLAG_SUSPENDED

setFlags

public void setFlags(long flags)
Description copied from interface: Quest
Sets the flag bitmap

Specified by:
setFlags in interface Quest
Parameters:
flags - the flag bitmap
See Also:
Quest.FLAG_SUSPENDED

getQuestThing

public Environmental getQuestThing(java.util.Iterator<? extends Environmental> e,
                                   int dex,
                                   CMClass.CMObjectType type,
                                   int[] num)

getQuestMob

public MOB getQuestMob(int i)
Description copied from interface: Quest
Returns the mob in use by this quest at the given index

Specified by:
getQuestMob in interface Quest
Parameters:
i - the index
Returns:
the mob in use by this quest at the given index
See Also:
Quest.getQuestMobName(int), Quest.getQuestMobIndex(String)

getQuestItem

public Item getQuestItem(int i)
Description copied from interface: Quest
Returns the item in use by this quest at the given index

Specified by:
getQuestItem in interface Quest
Parameters:
i - the index
Returns:
the item in use by this quest at the given index
See Also:
Quest.getQuestItemIndex(String), Quest.getQuestItemName(int)

getQuestRoom

public Room getQuestRoom(int i)
Description copied from interface: Quest
Returns the room in use by this quest at the given index

Specified by:
getQuestRoom in interface Quest
Parameters:
i - the index
Returns:
the room in use by this quest at the given index
See Also:
Quest.getQuestRoomIndex(String), Quest.getQuestRoomID(int)

getQuestMobName

public java.lang.String getQuestMobName(int i)
Description copied from interface: Quest
Returns the name of the mob in use by this quest at the given index

Specified by:
getQuestMobName in interface Quest
Parameters:
i - the index
Returns:
the name of the mob in use by this quest at the given index
See Also:
Quest.getQuestMob(int), Quest.getQuestMobIndex(String)

getQuestItemName

public java.lang.String getQuestItemName(int i)
Description copied from interface: Quest
Returns the name of the item in use by this quest at the given index

Specified by:
getQuestItemName in interface Quest
Parameters:
i - the index
Returns:
the name of the item in use by this quest at the given index
See Also:
Quest.getQuestItem(int), Quest.getQuestItemIndex(String)

getQuestRoomID

public java.lang.String getQuestRoomID(int i)
Description copied from interface: Quest
Returns the id of the room in use by this quest at the given index

Specified by:
getQuestRoomID in interface Quest
Parameters:
i - the index
Returns:
the id of the room in use by this quest at the given index
See Also:
Quest.getQuestRoom(int), Quest.getQuestRoomIndex(String)

getObjectInUseIndex

public int getObjectInUseIndex(java.lang.String name)
Description copied from interface: Quest
Returns the index of a room, mob, or item of the given name in use by this quest.

Specified by:
getObjectInUseIndex in interface Quest
Parameters:
name - the given name
Returns:
the index of a room, mob, or item of the given name
See Also:
Quest.isObjectInUse(Environmental)

isObjectInUse

public boolean isObjectInUse(Environmental E)
Description copied from interface: Quest
Returns whether the exact given object is in use by this quest.

Specified by:
isObjectInUse in interface Quest
Parameters:
E - the object to check
Returns:
true if its in use, false otherwise
See Also:
Quest.getObjectInUseIndex(String)

parseLoadScripts

public java.util.Vector parseLoadScripts(java.lang.String text,
                                         java.util.List oldArgs,
                                         java.util.List args,
                                         boolean showErrors)

getStatCodes

public java.lang.String[] getStatCodes()
Description copied from interface: Modifiable
Returns an array of the string names of those fields which are modifiable on this object at run-time by builders.

Specified by:
getStatCodes in interface Modifiable
Returns:
list of the fields which may be set.
See Also:
Modifiable.getStat(String), Modifiable.setStat(String, String)

getSaveStatIndex

public int getSaveStatIndex()
Description copied from interface: Modifiable
Returns the index into the stat codes array where extra savable fields begins. This number is always the same as getStatCodes().length unless there are extra fields which need to be saved in xml for generic objects. This method is used by editors for post-build user-defined fields.

Specified by:
getSaveStatIndex in interface Modifiable
Returns:
the index into getStatCodes()
See Also:
Modifiable.getStatCodes(), Modifiable.getStat(String), Modifiable.setStat(String, String)

getCodeNum

protected int getCodeNum(java.lang.String code)

sameAs

public boolean sameAs(DefaultQuest E)

setStat

public void setStat(java.lang.String code,
                    java.lang.String val)
Description copied from interface: Modifiable
An alternative means of setting the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. The value passed in is always a string, even if the field itself is numeric or a list.

Specified by:
setStat in interface Modifiable
Parameters:
code - the name of the field to set
val - the value to set the field to
See Also:
Modifiable.getStatCodes()

isStat

public boolean isStat(java.lang.String code)
Description copied from interface: Modifiable
An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. Values returned are always strings, even if the field itself is numeric or a list.

Specified by:
isStat in interface Modifiable
Parameters:
code - the name of the field to read.
Returns:
true if the code is a real value, false otherwise
See Also:
Modifiable.getStatCodes()

getStat

public java.lang.String getStat(java.lang.String code)
Description copied from interface: Modifiable
An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. Values returned are always strings, even if the field itself is numeric or a list.

Specified by:
getStat in interface Modifiable
Parameters:
code - the name of the field to read.
Returns:
the value of the field read
See Also:
Modifiable.getStatCodes()

compareTo

public int compareTo(CMObject o)
Specified by:
compareTo in interface java.lang.Comparable<CMObject>