com.planet_ink.coffee_mud.Behaviors
Class ScriptableEverymob

java.lang.Object
  extended by com.planet_ink.coffee_mud.Behaviors.StdBehavior
      extended by com.planet_ink.coffee_mud.Behaviors.ScriptableEverymob
All Implemented Interfaces:
Behavior, CMCommon, ScriptingEngine, CMObject, Contingent, Modifiable, MsgListener, Tickable, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class ScriptableEverymob
extends StdBehavior
implements ScriptingEngine


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.planet_ink.coffee_mud.Common.interfaces.ScriptingEngine
ScriptingEngine.ScriptableResponse
 
Field Summary
 
Fields inherited from class com.planet_ink.coffee_mud.Behaviors.StdBehavior
CODES, isSavableBehavior, parms
 
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
 
Fields inherited from interface com.planet_ink.coffee_mud.Behaviors.interfaces.Behavior
CAN_AREAS, CAN_EXITS, CAN_ITEMS, CAN_MOBS, CAN_ROOMS, FLAG_LEGALBEHAVIOR, FLAG_MOBILITY, FLAG_POTENTIALLYAGGRESSIVE, FLAG_POTENTIALLYAUTODEATHING, FLAG_TROUBLEMAKING
 
Constructor Summary
ScriptableEverymob()
           
 
Method Summary
 java.lang.String accountForYourself()
          Returns a string describing what this behavior does.
protected  int canImproveCode()
           
 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).
 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.
 void executeMsg(Environmental host, CMMsg msg)
          The general message event handler for the object.
 java.util.List<java.lang.String> externalFiles()
          Returns a string list of any external files which may be required to make this ability work.
 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.
 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.
 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.
 java.lang.String getVar(java.lang.String context, java.lang.String variable)
          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.
 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.
 boolean isVar(java.lang.String context, java.lang.String variable)
          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[] 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.
 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 setScript(java.lang.String newParms)
          Sets the script or load command(s).
 void setVar(java.lang.String context, java.lang.String variable, java.lang.String value)
          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 scope)
          Sets the scope of any variables defined within the script.
 void startBehavior(PhysicalAgent forMe)
          Called after a behavior is added to a Behavable object.
 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 com.planet_ink.coffee_mud.Behaviors.StdBehavior
amDestroyed, canActAtAll, canFreelyBehaveNormal, canImprove, canImprove, compareTo, copyOf, destroy, flags, getBehaversMOB, getBehaversRoom, getCodeNum, getParms, getSaveStatIndex, getStat, getStatCodes, getTickStatus, grantsAggressivenessTo, initializeClass, isSavable, isStat, L, name, newInstance, okMessage, parmsFormat, registerDefaultQuest, sameAs, setParms, setSavable, setStat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.planet_ink.coffee_mud.Common.interfaces.ScriptingEngine
isSavable, registerDefaultQuest, setSavable
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.Tickable
getTickStatus, name
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, initializeClass, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.MsgListener
okMessage
 

Constructor Detail

ScriptableEverymob

public ScriptableEverymob()
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
Overrides:
ID in class StdBehavior
Returns:
the name of this class

canImproveCode

protected int canImproveCode()
Overrides:
canImproveCode in class StdBehavior

accountForYourself

public java.lang.String accountForYourself()
Description copied from interface: Behavior
Returns a string describing what this behavior does. Mostly for thought and behavior reading systems.

Specified by:
accountForYourself in interface Behavior
Overrides:
accountForYourself in class StdBehavior
Returns:
a string describing what this behavior does.

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
Overrides:
tick in class StdBehavior
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

startBehavior

public void startBehavior(PhysicalAgent forMe)
Description copied from interface: Behavior
Called after a behavior is added to a Behavable object. The point is to do any initializing. This method assumes setParms() has already been called as well.

Specified by:
startBehavior in interface Behavior
Overrides:
startBehavior in class StdBehavior
Parameters:
forMe - the object to which this behavior has been added
See Also:
Behavable.addBehavior(Behavior), Behavior.setParms(String)

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
Overrides:
executeMsg in class StdBehavior
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

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)

dequeResponses

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

Specified by:
dequeResponses in interface ScriptingEngine

externalFiles

public java.util.List<java.lang.String> externalFiles()
Description copied from interface: Behavior
Returns a string list of any external files which may be required to make this ability work. Usually derived from the parameters. Files returned by this method should not be base distrib files!

Specified by:
externalFiles in interface Behavior
Specified by:
externalFiles in interface ScriptingEngine
Overrides:
externalFiles in class StdBehavior
Returns:
a list of the path/names of files used by this behavior
See Also:
Behavior.setParms(String)

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

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.

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

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)

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

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()

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()

getVar

public java.lang.String getVar(java.lang.String context,
                               java.lang.String variable)
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:
context - the context of the variable, usually a mob or object name
variable - 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)

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)

isVar

public boolean isVar(java.lang.String context,
                     java.lang.String variable)
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:
context - the context of the variable, usually a mob or object name
variable - 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)

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

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()

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()

setVar

public void setVar(java.lang.String context,
                   java.lang.String variable,
                   java.lang.String value)
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:
context - the context of the variable, usually a mob or object name
variable - the name of the variable
value - 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)

setVarScope

public void setVarScope(java.lang.String scope)
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:
scope - the scope of variables
See Also:
ScriptingEngine.getVarScope(), ScriptingEngine.getVar(String, String), ScriptingEngine.getLocalVarXML()

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

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