wyvern.lib.classes.traps
Class Firespout

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.lib.classes.traps.Firespout
All Implemented Interfaces:
Broadcaster, GameObject, MethodHookable, PropertyList, Timed, Trap, WalkNotify
Direct Known Subclasses:
ElectricBarrier, Spikes

public class Firespout
extends MapObject
implements Timed, WalkNotify, Trap

This class implements a small hole which spews flame periodically. While the flame is going, anyone occupying the square will take damage. It can only be crossed safely while the flame is out.

The states are defined as:

So you can customize what % of the time the trap is dangerous by fiddling with the min-state and max-state properties.

Author:
Kiz

Field Summary
static int DEFAULT_RATE
          Default speed at which the fire changes.
 int start_
          Valid states for the firespout.
 int stop_
           
protected  SuspendableTimer timer_
          Timer for lighting and extinguishing the flame.
 boolean toggle
           
 
Fields inherited from class wyvern.kernel.maps.MapObject
IN_MAP_EDITOR, listenerList_
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Constructor Summary
Firespout()
           
 
Method Summary
protected  void damageMonster(Monster m)
          Burns a monster.
 void destroy()
          Destroys the object.
 int getRate()
          Returns the rate at which the gate opens or closes.
 void initialize()
          Initializes the object's default properties.
 boolean isRevealed()
          Returns true if the trap has been revealed already.
 void reveal(Commandable agent)
          Someone discovered the trap via searching (or stepping on it.)
 void reveal(Commandable agent, boolean silent)
          Reveals the trap, with an option not to print a message.
 void setAnimation()
          Sets the Animation property.
 void setMap(GameMap map, int x, int y)
          We've been put in a map.
 void setPic(int state)
          Sets the picture according to the state.
 void setWC(GameMap map)
          Sets the WC.
 boolean shouldDoDamage(int state)
          Easily redefinable subroutine that tells you whether or not to do damage.
 void start()
          Starts the firespout.
 void steppedOn(Monster m)
          Someone stepped on the trap.
 void stop()
          Stops the firespout.
 void timerExpired()
          Adjusts the state of the firespout by a step.
 java.lang.String toString()
          Returns X, for "killedy by a X" in gravestone messages.
 
Methods inherited from class wyvern.kernel.maps.MapObject
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, addMethodHook, addMotionTracker, addObjectTracker, addPrefix, addSuffix, addToMap, bless, broadcast, broadcast, broadcast, broadcast, broadcast, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, ensureListenerList, ensureWeight, externalize, fireContainerEntered, fireContainerExited, fireEnteredMap, fireExitedMap, fireMovedInMap, getAlpha, getAppearance, getArchetype, getBaseName, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getImageDescriptors, getLayer, getLocations, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getTile, getValue, getWeight, groupString, inContainer, initLocs, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMethodHook, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, runMethodHook, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDefaultBitmap, setDefaultCategory, setDefaultDesc, setDefaultImage, setDefaultIntProperty, setDefaultLayer, setDefaultMaterial, setDefaultProperty, setDefaultShortDesc, setDirection, setImage, setImage, setLayer, setLocations, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport, updateMapLocation
 
Methods inherited from class wyvern.kernel.properties.PList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, debugProperties, dismantlePropertyList, getDoubleProperty, getInheritedProperty, getInteger, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProfilingInfo, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wyvern.lib.PropertyList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, getDoubleProperty, getInheritedProperty, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 

Field Detail

start_

public int start_
Valid states for the firespout.


stop_

public int stop_

toggle

public boolean toggle

DEFAULT_RATE

public static final int DEFAULT_RATE
Default speed at which the fire changes.

See Also:
Constant Field Values

timer_

protected SuspendableTimer timer_
Timer for lighting and extinguishing the flame. The flame cycles constantly, so we'll just keep this one timer the whole time.

Constructor Detail

Firespout

public Firespout()
Method Detail

initialize

public void initialize()
Description copied from interface: GameObject
Initializes the object's default properties. Any GameObject implementation that wishes to initialize itself should do so here, rather than in the constructor. This is because nearly all game objects inherit from an archetype, and the archetype parent pointer isn't set until the object's constructor finishes. This is a good place to add any class-default properties for an object - properties that the object gets regardless of which archetype it inherits from. WARNING: don't forget to call the superclass' initialize() method, or the object may not function properly. For instance, it won't become animated even if it specifies animation parameters in the archetype.

Specified by:
initialize in interface GameObject
Overrides:
initialize in class MapObject

setMap

public void setMap(GameMap map,
                   int x,
                   int y)
We've been put in a map. Start the timer.

Specified by:
setMap in interface GameObject
Overrides:
setMap in class MapObject

steppedOn

public void steppedOn(Monster m)
Someone stepped on the trap.

Specified by:
steppedOn in interface WalkNotify
Parameters:
m - the monster who stepped on it

damageMonster

protected void damageMonster(Monster m)
Burns a monster.


getRate

public int getRate()
Returns the rate at which the gate opens or closes.


setPic

public void setPic(int state)
Sets the picture according to the state.


shouldDoDamage

public boolean shouldDoDamage(int state)
Easily redefinable subroutine that tells you whether or not to do damage.


setWC

public void setWC(GameMap map)
Sets the WC.


setAnimation

public void setAnimation()
Sets the Animation property.


timerExpired

public void timerExpired()
Adjusts the state of the firespout by a step. May do damage depending on state.

Specified by:
timerExpired in interface Timed

destroy

public void destroy()
Destroys the object.

Specified by:
destroy in interface GameObject
Overrides:
destroy in class MapObject

stop

public void stop()
Stops the firespout.


start

public void start()
Starts the firespout.


toString

public java.lang.String toString()
Returns X, for "killedy by a X" in gravestone messages.

Overrides:
toString in class MapObject
Returns:
a short String describing this object. If the object represents a group of items, such as coins, the returned description will be a modified version of the description that includes quantity information.

isRevealed

public boolean isRevealed()
Description copied from interface: Trap
Returns true if the trap has been revealed already.

Specified by:
isRevealed in interface Trap
Returns:
true if someone has triggered/revealed it

reveal

public void reveal(Commandable agent)
Description copied from interface: Trap
Someone discovered the trap via searching (or stepping on it.)

Specified by:
reveal in interface Trap
Parameters:
agent - the agent who discovered the trap

reveal

public void reveal(Commandable agent,
                   boolean silent)
Description copied from interface: Trap
Reveals the trap, with an option not to print a message.

Specified by:
reveal in interface Trap
Parameters:
agent - the person who found it
silent - true to skip the message