com.planet_ink.coffee_mud.Common
Class DefaultScriptingEngine

java.lang.Object
  extended by com.planet_ink.coffee_mud.Common.DefaultScriptingEngine
All Implemented Interfaces:
CMCommon, ScriptingEngine, CMObject, MsgListener, Tickable, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class DefaultScriptingEngine
extends java.lang.Object
implements ScriptingEngine


Nested Class Summary
protected static class DefaultScriptingEngine.JScriptEvent
           
 
Nested classes/interfaces inherited from interface com.planet_ink.coffee_mud.Common.interfaces.ScriptingEngine
ScriptingEngine.ScriptableResponse
 
Field Summary
protected  Tickable altStatusTickable
           
protected  boolean alwaysTriggers
           
protected  MOB backupMOB
           
protected static java.util.Map<java.lang.String,java.lang.Integer> connH
           
protected  boolean debugBadScripts
           
protected  java.lang.String defaultQuestName
           
protected  java.util.Map<java.lang.Integer,int[]> delayProgCounters
           
protected  java.util.Map<java.lang.Integer,java.lang.Integer> delayTargetTimes
           
protected static java.util.Vector<DVector> empty
           
protected static java.util.Map<java.lang.String,java.lang.Integer> funcH
           
protected static java.util.Map<java.lang.String,java.lang.Integer> gstatH
           
protected  boolean isSavable
           
protected  java.util.Map<java.lang.Integer,java.lang.Integer> lastDayProgsDone
           
protected  Room lastKnownLocation
           
protected  Environmental lastLoaded
           
protected  CMMsg lastMsg
           
protected  java.util.Map<java.lang.Integer,java.lang.Integer> lastTimeProgsDone
           
protected  MOB lastToHurtMe
           
protected static java.util.Map<java.lang.String,java.lang.Integer> methH
           
protected  java.lang.String myScript
           
protected  boolean noDelay
           
protected  java.util.Map<java.lang.Integer,java.lang.Long> noTrigger
           
protected  java.util.List<DVector> oncesDone
           
protected static java.util.Map<java.lang.String,java.util.regex.Pattern> patterns
           
protected static java.util.Map<java.lang.String,java.lang.Integer> progH
           
protected  java.util.List<ScriptingEngine.ScriptableResponse> que
           
protected  java.util.concurrent.atomic.AtomicInteger recurseCounter
           
protected  java.util.Set<java.lang.Integer> registeredEvents
           
protected  Resources resources
           
protected  boolean runInPassiveAreas
           
protected  java.lang.String scope
           
protected  java.lang.String scriptKey
           
protected static java.util.Map<java.lang.String,java.lang.Integer> signH
           
protected  int tickStatus
           
 
Fields inherited from interface com.planet_ink.coffee_mud.Common.interfaces.ScriptingEngine
CONNECTOR_AND, CONNECTOR_ANDNOT, CONNECTOR_MAP, CONNECTOR_NOT, CONNECTOR_OR, CONNECTOR_ORNOT, CONNECTORS, DATETIME_ARGS, funcs, GSTATADD_CLAN, GSTATADD_CLANROLE, GSTATADD_DEITY, GSTATADD_STINK, GSTATCODES_ADDITIONAL, methods, progs, SIGN_EQGT, SIGN_EQLT, SIGN_EQUL, SIGN_GRAT, SIGN_GTEQ, SIGN_LEST, SIGN_LTEQ, SIGN_NTEQ, SIGNS, SPECIAL_9SHOPHASPRICE, SPECIAL_NUM_OBJECTS, SPECIAL_RANDANYONE, SPECIAL_RANDPC
 
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
DefaultScriptingEngine()
           
 
Method Summary
protected  void buildHashes()
           
protected  boolean canTrigger(int triggerCode)
           
 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.
protected  Quest defaultQuest()
           
 java.lang.String defaultQuestName()
          If this script is associated with a particular quest, this method is called to return that quest name.
 void dequeResponses()
          Forces any queued event responses to be immediately executed.
 boolean endQuest(PhysicalAgent hostObj, MOB mob, java.lang.String quest)
          Calling this method forces this script to look for a trigger dealing with the end of a quest (QUEST_TIME_PROG -1).
 void enqueResponse(PhysicalAgent host, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, DVector script, int ticks, java.lang.String msg, java.lang.String[] triggerStr)
           
 boolean eval(PhysicalAgent scripted, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp, java.lang.String[][] eval, int startEval)
          Evaluates a scripting function.
 java.lang.String execute(PhysicalAgent scripted, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, DVector script, java.lang.String msg, java.lang.Object[] tmp)
          Executes a script in response to an event The scripts are formatted as a 2 dimensional DVector with the first row being the trigger information.
 java.lang.String execute(PhysicalAgent scripted, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, DVector script, java.lang.String msg, java.lang.Object[] tmp, int startLine)
           
 void executeMsg(Environmental host, CMMsg msg)
          The general message event handler for the object.
 java.util.List<java.lang.String> externalFiles()
          If the script is a load command, this will return the list of loaded script files referenced by the load command
protected  Environmental findSomethingCalledThis(java.lang.String thisName, MOB meMOB, Room imHere, java.util.List<Environmental> OBJS, boolean mob)
           
 java.lang.String functify(PhysicalAgent scripted, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp, java.lang.String evaluable)
          Evaluates one of the boolean functions as a string variable expression, which gives different and informative results.
protected  java.util.List<PhysicalAgent> generateItemsFromFile(Environmental scripted, java.lang.String filename, java.lang.String tagName, java.lang.String rest)
           
protected  java.util.List<PhysicalAgent> generateMobsFromFile(Environmental scripted, java.lang.String filename, java.lang.String tagName, java.lang.String rest)
           
protected  PhysicalAgent getArgumentItem(java.lang.String str, MOB source, MOB monster, PhysicalAgent scripted, Environmental target, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp)
           
protected  PhysicalAgent getArgumentMOB(java.lang.String str, MOB source, MOB monster, Environmental target, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp)
           
protected  java.lang.String getGStatValue(Environmental E, java.lang.String arg2)
           
 java.lang.String getLocalVarXML()
          If the variable scope of this script is local, this will return all the variables and values defined as an xml document for easy storage.
 MOB getMakeMOB(Tickable ticking)
          Creates a mob from the Tickable object sent, possibly saving it locally to this object for use later.
protected  MOB getRandAnyone(MOB monster, java.lang.Object[] tmp, Room room)
           
protected  MOB getRandPC(MOB monster, java.lang.Object[] tmp, Room room)
           
protected  Room getRoom(java.lang.String thisName, Room imHere)
           
 java.lang.String getScript()
          Returns the script or load command(s).
 java.lang.String getScriptResourceKey()
          Returns the hey used to cache the script or load commands in here.
protected  java.util.List<DVector> getScripts()
           
protected  DVector getScriptVarSet(java.lang.String mobname, java.lang.String varname)
           
protected  java.lang.String getStatValue(Environmental E, java.lang.String arg2)
           
 int getTickStatus()
          A coded status for this object during the period where its tick method is being called.
protected  int getTriggerCode(java.lang.String trigger, java.lang.String[] ttrigger)
           
 java.lang.String getVar(Environmental E, java.lang.String rawHost, java.lang.String var, MOB source, Environmental target, PhysicalAgent scripted, MOB monster, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp)
           
 java.lang.String getVar(Resources resources, java.lang.String host, java.lang.String var, java.lang.String defaultVal)
           
 java.lang.String getVar(java.lang.String host, java.lang.String var)
          Returns the value of one of the internal variables, determined by the scope of the script, the context of the variable, and the name of the variable.
protected  java.lang.String getVarHost(Environmental E, java.lang.String rawHost, MOB source, Environmental target, PhysicalAgent scripted, MOB monster, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp)
           
 java.lang.String getVarScope()
          Returns the scope of any variables defined within the script.
 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.
protected  java.lang.String[] insertStringArray(java.lang.String[] oldS, java.lang.String[] inS, int where)
           
 boolean isFreeToBeTriggered(Tickable affecting)
           
 boolean isSavable()
          Returns whether this script is a temporary attributed of the scripted object, or a permanent on that should be saved with the object.
 boolean isVar(java.lang.String host, java.lang.String var)
          Returns whether an internal variables, determined by the scope of the script, the context of the variable, and the name of the variable, is defined.
 java.lang.String L(java.lang.String str, java.lang.String... xs)
           
protected  java.util.List<PhysicalAgent> loadItemsFromFile(Environmental scripted, java.lang.String filename)
           
protected  java.util.List<PhysicalAgent> loadMobsFromFile(Environmental scripted, java.lang.String filename)
           
protected  void logError(Environmental scripted, java.lang.String cmdName, java.lang.String errType, java.lang.String errMsg)
           
protected  boolean match(java.lang.String str, java.lang.String patt)
           
 java.lang.String name()
          The displayable name of this object.
 CMObject newInstance()
          Returns a new instance of this class.
protected  java.lang.Object[] newObjs()
           
 boolean okMessage(Environmental host, CMMsg msg)
          The general message event previewer for the object.
protected  java.lang.String[] parseBits(DVector script, int row, java.lang.String instructions)
           
protected  java.lang.String[] parseBits(java.lang.String[][] oldBits, int start, java.lang.String instructions)
           
protected  java.lang.String[] parseBits(java.lang.String line, java.lang.String instructions)
           
 java.lang.String[] parseEval(java.lang.String evaluable)
          Receives a string for evaluation by the eval function, and stores it as the first element in the given 2 dimensional string array.
protected  java.lang.String parseLoads(java.lang.String text, int depth, java.util.Vector<java.lang.String> filenames, java.lang.StringBuffer nonFilenameScript)
           
protected  java.util.Vector<DVector> parseScripts(java.lang.String text)
           
protected  java.lang.String[] parseSpecial3PartEval(java.lang.String[][] eval, int t)
           
 void prequeResponse(PhysicalAgent host, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, DVector script, int ticks, java.lang.String msg)
           
 void pushEvalBoolean(java.util.Vector<java.lang.Object> stack, boolean trueFalse)
           
 void registerDefaultQuest(java.lang.String qName)
          If this script is associated with a particular quest, this method is called to register that quest name.
 void reset()
           
 void setLocalVarXML(java.lang.String xml)
          If the variable scope of this script is local, this will set all the variables and values defined from a passed in xml document.
 void setSavable(boolean truefalse)
          Sets whether this script is a temporary attributed of the scripted object, or a permanent on that should be saved with the object.
 void setScript(java.lang.String newParms)
          Sets the script or load command(s).
protected  void setShopPrice(ShopKeeper shopHere, Environmental E, java.lang.Object[] tmp)
           
 void setVar(java.lang.String baseName, java.lang.String key, java.lang.String val)
          Sets the value of one of the internal variables, determined by the scope of the script, the context of the variable, and the name of the variable.
 void setVarScope(java.lang.String newScope)
          Sets the scope of any variables defined within the script.
protected  boolean simpleEval(Environmental scripted, java.lang.String arg1, java.lang.String arg2, java.lang.String cmp, java.lang.String cmdName)
           
protected  boolean simpleEvalStr(Environmental scripted, java.lang.String arg1, java.lang.String arg2, java.lang.String cmp, java.lang.String cmdName)
           
protected  boolean simpleExpressionEval(Environmental scripted, java.lang.String arg1, java.lang.String arg2, java.lang.String cmp, java.lang.String cmdName)
           
protected  java.lang.String standardTriggerCheck(DVector script, java.lang.String[] t, Environmental E)
           
protected static int stringContainsFunctionImpl(java.lang.String str1, java.lang.String str2)
          As the name implies, this is the implementation of the stringcontains mobprog function
 boolean tick(Tickable ticking, int tickID)
          this is the method which is called periodically by the threading engine.
 java.lang.String varify(MOB source, Environmental target, PhysicalAgent scripted, MOB monster, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp, java.lang.String varifyable)
          Uses this scripting engines variable parsing system to replace any script variables $XXXX with their script determined values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

funcH

protected static final java.util.Map<java.lang.String,java.lang.Integer> funcH

methH

protected static final java.util.Map<java.lang.String,java.lang.Integer> methH

progH

protected static final java.util.Map<java.lang.String,java.lang.Integer> progH

connH

protected static final java.util.Map<java.lang.String,java.lang.Integer> connH

gstatH

protected static final java.util.Map<java.lang.String,java.lang.Integer> gstatH

signH

protected static final java.util.Map<java.lang.String,java.lang.Integer> signH

patterns

protected static final java.util.Map<java.lang.String,java.util.regex.Pattern> patterns

noDelay

protected boolean noDelay

scope

protected java.lang.String scope

tickStatus

protected int tickStatus

isSavable

protected boolean isSavable

alwaysTriggers

protected boolean alwaysTriggers

lastToHurtMe

protected MOB lastToHurtMe

lastKnownLocation

protected Room lastKnownLocation

altStatusTickable

protected Tickable altStatusTickable

oncesDone

protected java.util.List<DVector> oncesDone

delayTargetTimes

protected java.util.Map<java.lang.Integer,java.lang.Integer> delayTargetTimes

delayProgCounters

protected java.util.Map<java.lang.Integer,int[]> delayProgCounters

lastTimeProgsDone

protected java.util.Map<java.lang.Integer,java.lang.Integer> lastTimeProgsDone

lastDayProgsDone

protected java.util.Map<java.lang.Integer,java.lang.Integer> lastDayProgsDone

registeredEvents

protected java.util.Set<java.lang.Integer> registeredEvents

noTrigger

protected java.util.Map<java.lang.Integer,java.lang.Long> noTrigger

backupMOB

protected MOB backupMOB

lastMsg

protected CMMsg lastMsg

resources

protected Resources resources

lastLoaded

protected Environmental lastLoaded

myScript

protected java.lang.String myScript

defaultQuestName

protected java.lang.String defaultQuestName

scriptKey

protected java.lang.String scriptKey

runInPassiveAreas

protected boolean runInPassiveAreas

debugBadScripts

protected boolean debugBadScripts

que

protected java.util.List<ScriptingEngine.ScriptableResponse> que

recurseCounter

protected final java.util.concurrent.atomic.AtomicInteger recurseCounter

empty

protected static final java.util.Vector<DVector> empty
Constructor Detail

DefaultScriptingEngine

public DefaultScriptingEngine()
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: CMObject
The displayable name of this object. May be modified by phyStats() object. Is derived from the Name().

Specified by:
name in interface CMObject
Specified by:
name in interface Tickable
Returns:
the modified final name of this object on the map.
See Also:
Environmental.Name()

isSavable

public boolean isSavable()
Description copied from interface: ScriptingEngine
Returns whether this script is a temporary attributed of the scripted object, or a permanent on that should be saved with the object.

Specified by:
isSavable in interface ScriptingEngine
Returns:
whether this script is a saveable attribute of the scripted object
See Also:
ScriptingEngine.setSavable(boolean)

setSavable

public void setSavable(boolean truefalse)
Description copied from interface: ScriptingEngine
Sets whether this script is a temporary attributed of the scripted object, or a permanent on that should be saved with the object.

Specified by:
setSavable in interface ScriptingEngine
Parameters:
truefalse - true if this script is a saveable attribute of the scripted object
See Also:
ScriptingEngine.isSavable()

defaultQuestName

public java.lang.String defaultQuestName()
Description copied from interface: ScriptingEngine
If this script is associated with a particular quest, this method is called to return that quest name.

Specified by:
defaultQuestName in interface ScriptingEngine
Returns:
the quest associated with this script, if any
See Also:
ScriptingEngine.registerDefaultQuest(String)

defaultQuest

protected Quest defaultQuest()

setVarScope

public void setVarScope(java.lang.String newScope)
Description copied from interface: ScriptingEngine
Sets the scope of any variables defined within the script. Although the scope is somewhat modified if this script is quest-bound, it is usually honored. Valid scopes include: "" for global, "*" for local, or a shared named scope.

Specified by:
setVarScope in interface ScriptingEngine
Parameters:
newScope - the scope of variables
See Also:
ScriptingEngine.getVarScope(), ScriptingEngine.getVar(String, String), ScriptingEngine.getLocalVarXML()

getVarScope

public java.lang.String getVarScope()
Description copied from interface: ScriptingEngine
Returns the scope of any variables defined within the script. Although the scope is somewhat modified if this script is quest-bound, it is usually honored. Valid scopes include: "" for global, "*" for local, or a shared named scope.

Specified by:
getVarScope in interface ScriptingEngine
Returns:
the scope of variables
See Also:
ScriptingEngine.setVarScope(String), ScriptingEngine.setVar(String, String, String), ScriptingEngine.setLocalVarXML(String)

newObjs

protected java.lang.Object[] newObjs()

getLocalVarXML

public java.lang.String getLocalVarXML()
Description copied from interface: ScriptingEngine
If the variable scope of this script is local, this will return all the variables and values defined as an xml document for easy storage.

Specified by:
getLocalVarXML in interface ScriptingEngine
Returns:
the local variable values as xml
See Also:
ScriptingEngine.setVarScope(String), ScriptingEngine.setVar(String, String, String), ScriptingEngine.setLocalVarXML(String)

setLocalVarXML

public void setLocalVarXML(java.lang.String xml)
Description copied from interface: ScriptingEngine
If the variable scope of this script is local, this will set all the variables and values defined from a passed in xml document.

Specified by:
setLocalVarXML in interface ScriptingEngine
Parameters:
xml - the local variable values as xml
See Also:
ScriptingEngine.getVarScope(), ScriptingEngine.getVar(String, String), ScriptingEngine.getLocalVarXML()

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)

registerDefaultQuest

public void registerDefaultQuest(java.lang.String qName)
Description copied from interface: ScriptingEngine
If this script is associated with a particular quest, this method is called to register that quest name.

Specified by:
registerDefaultQuest in interface ScriptingEngine
Parameters:
qName - the quest associated with this script
See Also:
ScriptingEngine.defaultQuestName()

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

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

parseBits

protected java.lang.String[] parseBits(DVector script,
                                       int row,
                                       java.lang.String instructions)

parseSpecial3PartEval

protected java.lang.String[] parseSpecial3PartEval(java.lang.String[][] eval,
                                                   int t)

parseBits

protected java.lang.String[] parseBits(java.lang.String line,
                                       java.lang.String instructions)

insertStringArray

protected java.lang.String[] insertStringArray(java.lang.String[] oldS,
                                               java.lang.String[] inS,
                                               int where)

parseBits

protected java.lang.String[] parseBits(java.lang.String[][] oldBits,
                                       int start,
                                       java.lang.String instructions)

endQuest

public boolean endQuest(PhysicalAgent hostObj,
                        MOB mob,
                        java.lang.String quest)
Description copied from interface: ScriptingEngine
Calling this method forces this script to look for a trigger dealing with the end of a quest (QUEST_TIME_PROG -1).

Specified by:
endQuest in interface ScriptingEngine
Parameters:
hostObj - the scripted object
mob - a mob representation of the host object
quest - the name of the quest being ended
Returns:
true if a quest ending trigger was found and run

externalFiles

public java.util.List<java.lang.String> externalFiles()
Description copied from interface: ScriptingEngine
If the script is a load command, this will return the list of loaded script files referenced by the load command

Specified by:
externalFiles in interface ScriptingEngine
Returns:
a list of loaded script files.
See Also:
ScriptingEngine.getScript(), ScriptingEngine.setScript(String)

getVarHost

protected java.lang.String getVarHost(Environmental E,
                                      java.lang.String rawHost,
                                      MOB source,
                                      Environmental target,
                                      PhysicalAgent scripted,
                                      MOB monster,
                                      Item primaryItem,
                                      Item secondaryItem,
                                      java.lang.String msg,
                                      java.lang.Object[] tmp)

isVar

public boolean isVar(java.lang.String host,
                     java.lang.String var)
Description copied from interface: ScriptingEngine
Returns whether an internal variables, determined by the scope of the script, the context of the variable, and the name of the variable, is defined.

Specified by:
isVar in interface ScriptingEngine
Parameters:
host - the context of the variable, usually a mob or object name
var - the name of the variable
Returns:
true if the variable has been set in the past, false otherwise
See Also:
ScriptingEngine.setVarScope(String), ScriptingEngine.getVarScope(), ScriptingEngine.getVar(String, String), ScriptingEngine.setVar(String, String, String), ScriptingEngine.getLocalVarXML(), ScriptingEngine.setLocalVarXML(String)

getVar

public java.lang.String getVar(Environmental E,
                               java.lang.String rawHost,
                               java.lang.String var,
                               MOB source,
                               Environmental target,
                               PhysicalAgent scripted,
                               MOB monster,
                               Item primaryItem,
                               Item secondaryItem,
                               java.lang.String msg,
                               java.lang.Object[] tmp)

getVar

public java.lang.String getVar(java.lang.String host,
                               java.lang.String var)
Description copied from interface: ScriptingEngine
Returns the value of one of the internal variables, determined by the scope of the script, the context of the variable, and the name of the variable.

Specified by:
getVar in interface ScriptingEngine
Parameters:
host - the context of the variable, usually a mob or object name
var - the name of the variable
Returns:
the value of the variable
See Also:
ScriptingEngine.setVarScope(String), ScriptingEngine.getVarScope(), ScriptingEngine.setVar(String, String, String), ScriptingEngine.isVar(String, String), ScriptingEngine.getLocalVarXML(), ScriptingEngine.setLocalVarXML(String)

getVar

public java.lang.String getVar(Resources resources,
                               java.lang.String host,
                               java.lang.String var,
                               java.lang.String defaultVal)

getScript

public java.lang.String getScript()
Description copied from interface: ScriptingEngine
Returns the script or load command(s).

Specified by:
getScript in interface ScriptingEngine
Returns:
the script or load command(s)
See Also:
ScriptingEngine.setScript(String), ScriptingEngine.externalFiles()

reset

public void reset()

setScript

public void setScript(java.lang.String newParms)
Description copied from interface: ScriptingEngine
Sets the script or load command(s).

Specified by:
setScript in interface ScriptingEngine
Parameters:
newParms - the script or load command(s)
See Also:
ScriptingEngine.getScript(), ScriptingEngine.externalFiles()

isFreeToBeTriggered

public boolean isFreeToBeTriggered(Tickable affecting)

parseLoads

protected java.lang.String parseLoads(java.lang.String text,
                                      int depth,
                                      java.util.Vector<java.lang.String> filenames,
                                      java.lang.StringBuffer nonFilenameScript)

buildHashes

protected void buildHashes()

parseScripts

protected java.util.Vector<DVector> parseScripts(java.lang.String text)

getRoom

protected Room getRoom(java.lang.String thisName,
                       Room imHere)

logError

protected void logError(Environmental scripted,
                        java.lang.String cmdName,
                        java.lang.String errType,
                        java.lang.String errMsg)

simpleEvalStr

protected boolean simpleEvalStr(Environmental scripted,
                                java.lang.String arg1,
                                java.lang.String arg2,
                                java.lang.String cmp,
                                java.lang.String cmdName)

simpleEval

protected boolean simpleEval(Environmental scripted,
                             java.lang.String arg1,
                             java.lang.String arg2,
                             java.lang.String cmp,
                             java.lang.String cmdName)

simpleExpressionEval

protected boolean simpleExpressionEval(Environmental scripted,
                                       java.lang.String arg1,
                                       java.lang.String arg2,
                                       java.lang.String cmp,
                                       java.lang.String cmdName)

loadMobsFromFile

protected java.util.List<PhysicalAgent> loadMobsFromFile(Environmental scripted,
                                                         java.lang.String filename)

generateMobsFromFile

protected java.util.List<PhysicalAgent> generateMobsFromFile(Environmental scripted,
                                                             java.lang.String filename,
                                                             java.lang.String tagName,
                                                             java.lang.String rest)

loadItemsFromFile

protected java.util.List<PhysicalAgent> loadItemsFromFile(Environmental scripted,
                                                          java.lang.String filename)

generateItemsFromFile

protected java.util.List<PhysicalAgent> generateItemsFromFile(Environmental scripted,
                                                              java.lang.String filename,
                                                              java.lang.String tagName,
                                                              java.lang.String rest)

findSomethingCalledThis

protected Environmental findSomethingCalledThis(java.lang.String thisName,
                                                MOB meMOB,
                                                Room imHere,
                                                java.util.List<Environmental> OBJS,
                                                boolean mob)

getArgumentMOB

protected PhysicalAgent getArgumentMOB(java.lang.String str,
                                       MOB source,
                                       MOB monster,
                                       Environmental target,
                                       Item primaryItem,
                                       Item secondaryItem,
                                       java.lang.String msg,
                                       java.lang.Object[] tmp)

getArgumentItem

protected PhysicalAgent getArgumentItem(java.lang.String str,
                                        MOB source,
                                        MOB monster,
                                        PhysicalAgent scripted,
                                        Environmental target,
                                        Item primaryItem,
                                        Item secondaryItem,
                                        java.lang.String msg,
                                        java.lang.Object[] tmp)

varify

public java.lang.String varify(MOB source,
                               Environmental target,
                               PhysicalAgent scripted,
                               MOB monster,
                               Item primaryItem,
                               Item secondaryItem,
                               java.lang.String msg,
                               java.lang.Object[] tmp,
                               java.lang.String varifyable)
Description copied from interface: ScriptingEngine
Uses this scripting engines variable parsing system to replace any script variables $XXXX with their script determined values. This is a powerful mechanism for getting at the script functions in order to access stat data about specific objects, do math, etc.

Specified by:
varify in interface ScriptingEngine
Parameters:
source - the source of the event
target - the target of the event
scripted - the object that is scripted
monster - a mob representation of the scripted object
primaryItem - an item involved in the event
secondaryItem - a second item involved in the event
msg - a string message associated with the event
tmp - miscellaneous local variables
varifyable - the string to parse
Returns:
N/A

getScriptVarSet

protected DVector getScriptVarSet(java.lang.String mobname,
                                  java.lang.String varname)

getStatValue

protected java.lang.String getStatValue(Environmental E,
                                        java.lang.String arg2)

getGStatValue

protected java.lang.String getGStatValue(Environmental E,
                                         java.lang.String arg2)

setVar

public void setVar(java.lang.String baseName,
                   java.lang.String key,
                   java.lang.String val)
Description copied from interface: ScriptingEngine
Sets the value of one of the internal variables, determined by the scope of the script, the context of the variable, and the name of the variable.

Specified by:
setVar in interface ScriptingEngine
Parameters:
baseName - the context of the variable, usually a mob or object name
key - the name of the variable
val - the value of the variable
See Also:
ScriptingEngine.setVarScope(String), ScriptingEngine.getVarScope(), ScriptingEngine.getVar(String, String), ScriptingEngine.isVar(String, String), ScriptingEngine.getLocalVarXML(), ScriptingEngine.setLocalVarXML(String)

parseEval

public java.lang.String[] parseEval(java.lang.String evaluable)
                             throws ScriptParseException
Description copied from interface: ScriptingEngine
Receives a string for evaluation by the eval function, and stores it as the first element in the given 2 dimensional string array.

Specified by:
parseEval in interface ScriptingEngine
Parameters:
evaluable - the eval expression
Returns:
EVAL the 1 dimensional array to hold the compiled eval
Throws:
ScriptParseException - a parse error

pushEvalBoolean

public void pushEvalBoolean(java.util.Vector<java.lang.Object> stack,
                            boolean trueFalse)

stringContainsFunctionImpl

protected static final int stringContainsFunctionImpl(java.lang.String str1,
                                                      java.lang.String str2)
As the name implies, this is the implementation of the stringcontains mobprog function

Parameters:
str1 - the string to search in
str2 - the coded search expression
Returns:
the index of the found string in the first string

eval

public boolean eval(PhysicalAgent scripted,
                    MOB source,
                    Environmental target,
                    MOB monster,
                    Item primaryItem,
                    Item secondaryItem,
                    java.lang.String msg,
                    java.lang.Object[] tmp,
                    java.lang.String[][] eval,
                    int startEval)
Description copied from interface: ScriptingEngine
Evaluates a scripting function. Is called by the execute command to resolve IF, WHILE, and similar expressions that utilize the MOBPROG functions. The expressions are passed in as a String array stored in a single string array entry (for replacement) in element 0.

Specified by:
eval in interface ScriptingEngine
Parameters:
scripted - the object that is scripted
source - the source of the event
target - the target of the event
monster - a mob representation of the scripted object
primaryItem - an item involved in the event
secondaryItem - a second item involved in the event
msg - a string message associated with the event
tmp - miscellaneous local variables
eval - the pre-parsed expression
startEval - while line to start evaluating on.
Returns:
true if the expression is true, false otherwise.

setShopPrice

protected void setShopPrice(ShopKeeper shopHere,
                            Environmental E,
                            java.lang.Object[] tmp)

functify

public java.lang.String functify(PhysicalAgent scripted,
                                 MOB source,
                                 Environmental target,
                                 MOB monster,
                                 Item primaryItem,
                                 Item secondaryItem,
                                 java.lang.String msg,
                                 java.lang.Object[] tmp,
                                 java.lang.String evaluable)
Description copied from interface: ScriptingEngine
Evaluates one of the boolean functions as a string variable expression, which gives different and informative results. See the Green Table in the Scripting Guide.

Specified by:
functify in interface ScriptingEngine
Parameters:
scripted - the object that is scripted
source - the source of the event
target - the target of the event
monster - a mob representation of the scripted object
primaryItem - an item involved in the event
secondaryItem - a second item involved in the event
msg - a string message associated with the event
tmp - miscellaneous local variables
evaluable - the function expression
Returns:
the results of the function expression

getRandPC

protected MOB getRandPC(MOB monster,
                        java.lang.Object[] tmp,
                        Room room)

getRandAnyone

protected MOB getRandAnyone(MOB monster,
                            java.lang.Object[] tmp,
                            Room room)

execute

public java.lang.String execute(PhysicalAgent scripted,
                                MOB source,
                                Environmental target,
                                MOB monster,
                                Item primaryItem,
                                Item secondaryItem,
                                DVector script,
                                java.lang.String msg,
                                java.lang.Object[] tmp)
Description copied from interface: ScriptingEngine
Executes a script in response to an event The scripts are formatted as a 2 dimensional DVector with the first row being the trigger information. Each row consists of the String command, and a parsed String[] array as dimension 2.

Specified by:
execute in interface ScriptingEngine
Parameters:
scripted - the object that is scripted
source - the source of the event
target - the target of the event
monster - a mob representation of the scripted object
primaryItem - an item involved in the event
secondaryItem - a second item involved in the event
script - 2 dimensional DVector, the script to execute
msg - a string message associated with the event
tmp - miscellaneous local variables
Returns:
N/A
See Also:
ScriptingEngine.ScriptableResponse

execute

public java.lang.String execute(PhysicalAgent scripted,
                                MOB source,
                                Environmental target,
                                MOB monster,
                                Item primaryItem,
                                Item secondaryItem,
                                DVector script,
                                java.lang.String msg,
                                java.lang.Object[] tmp,
                                int startLine)

getScriptResourceKey

public java.lang.String getScriptResourceKey()
Description copied from interface: ScriptingEngine
Returns the hey used to cache the script or load commands in here.

Specified by:
getScriptResourceKey in interface ScriptingEngine
Returns:
the key to the script or load command(s)
See Also:
ScriptingEngine.getScript()

getScripts

protected java.util.List<DVector> getScripts()

match

protected boolean match(java.lang.String str,
                        java.lang.String patt)

okMessage

public boolean okMessage(Environmental host,
                         CMMsg msg)
Description copied from interface: MsgListener
The general message event previewer for the object. Messages passed herein are in a pending state, and may be safely modified or rejected without fear that they might be in the middle of being executed. Messages passed herein may not necessarily be FOR or FROM this object, but will almost always represent events which want to happen in the same rom. This method should always always return true UNLESS this message needs to be canceled, in which case it is necessary to tell the mob initiating the event (CMMsg.source()) why it is being cancelled. Every game event goes through these methods.

Specified by:
okMessage in interface MsgListener
Parameters:
host - either the initiator of the event, or the host of this object
msg - the CMMsg that wants to be executed
Returns:
whether this message is allowed to execute
See Also:
CMMsg, CMMsg.source()

standardTriggerCheck

protected java.lang.String standardTriggerCheck(DVector script,
                                                java.lang.String[] t,
                                                Environmental E)

executeMsg

public void executeMsg(Environmental host,
                       CMMsg msg)
Description copied from interface: MsgListener
The general message event handler for the object. Messages passed herein may not necessarily be FOR this object, or from it, but will almost always represent events happening in the same room. The messages have already been through an approval process, so this method is called only to affect the final execution of the meaning of the message. Every game event goes through these methods.

Specified by:
executeMsg in interface MsgListener
Parameters:
host - either the initiator of the event, or the host of this object
msg - the CMMsg that needs to be executed
See Also:
CMMsg

getTriggerCode

protected int getTriggerCode(java.lang.String trigger,
                             java.lang.String[] ttrigger)

getMakeMOB

public MOB getMakeMOB(Tickable ticking)
Description copied from interface: ScriptingEngine
Creates a mob from the Tickable object sent, possibly saving it locally to this object for use later. If the object is a mob, it returns the mob. Otherwise, it makes a fake one.

Specified by:
getMakeMOB in interface ScriptingEngine
Parameters:
ticking - the scripted object to make a fake mob out of
Returns:
a mob from a tickable

canTrigger

protected boolean canTrigger(int triggerCode)

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

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

compareTo

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

enqueResponse

public void enqueResponse(PhysicalAgent host,
                          MOB source,
                          Environmental target,
                          MOB monster,
                          Item primaryItem,
                          Item secondaryItem,
                          DVector script,
                          int ticks,
                          java.lang.String msg,
                          java.lang.String[] triggerStr)

prequeResponse

public void prequeResponse(PhysicalAgent host,
                           MOB source,
                           Environmental target,
                           MOB monster,
                           Item primaryItem,
                           Item secondaryItem,
                           DVector script,
                           int ticks,
                           java.lang.String msg)

dequeResponses

public void dequeResponses()
Description copied from interface: ScriptingEngine
Forces any queued event responses to be immediately executed.

Specified by:
dequeResponses in interface ScriptingEngine

L

public java.lang.String L(java.lang.String str,
                          java.lang.String... xs)