wyvern.lib.classes.traps
Class BearTrap

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.kernel.commands.AbstractCommandable
              extended bywyvern.lib.classes.traps.AbstractTrap
                  extended bywyvern.lib.classes.traps.BearTrap
All Implemented Interfaces:
Broadcaster, Commandable, ContainerChangeListener, java.util.EventListener, GameObject, Hookable, HookCallback, MapChangeListener, MapMotionListener, MethodHookable, ObjectTracker, PropertyList, RemoteAudio, Searchable, Trap, WalkNotify
Direct Known Subclasses:
WebTrap

public class BearTrap
extends AbstractTrap
implements HookCallback, ObjectTracker

Gets you stuck.

Version:
1.0, Oct 16, 2001 (rewrote from python)
Author:
Steve Yegge

Field Summary
 
Fields inherited from class wyvern.kernel.commands.AbstractCommandable
hookList_, queue_, started_
 
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
 
Fields inherited from interface wyvern.common.net.RemoteAudio
DEFAULT_ALERT_GAIN, DEFAULT_ALERT_REPEAT_DELAY, DEFAULT_ALERT_REPEATS, DEFAULT_GAIN, DEFAULT_REPEAT_DELAY, DEFAULT_REPEATS
 
Constructor Summary
BearTrap()
           
 
Method Summary
protected  boolean checkFlying(Monster monster)
          Returns true if the monster is flying (so we shouldn't trigger the trap.)
 void destroy()
          Let them out if the trap is destroyed.
 void finished()
          Called when the player finally breaks out of the trap.
 java.lang.String getStuckMessage()
          Returns the message to issue when you're trying to struggle free from the trap.
 java.lang.String getTriggerMessage()
          Returns the message to issue when they step into the trap.
 void hookEvent(java.lang.String hookName, CommandEvent event)
          Blocks moves.
 void initCount()
          Sets an initial stickness, based on the current map danger level.
 void initialize()
          Adds class-default properties
 void removeHooks(Commandable monster)
          Takes us off monster's hooks.
 void setMap(GameMap map, int x, int y)
          Sets the initial hold-count for the trap, based on the map's danger level.
 void steppedOn(Monster monster)
          Activates trap.
 void targetEnteredContainer(ContainerChangeEvent event)
          Target object was added to a bag or inventory.
 void targetEnteredMap(MapChangeEvent event)
          Notification that the target object has entered a map.
 void targetLeftContainer(ContainerChangeEvent event)
          Target object was removed from a bag or inventory.
 void targetLeftMap(MapChangeEvent event)
          Notification that the target object has left its map.
 void targetMoved(MapMotionEvent event)
          Notification that the target object has moved in its map.
 void trigger(Monster monster)
          Triggers the trap.
 void unhookMonster()
          Removes our reference to the monster/player who stepped on us if any, and removes our hooks into the monster.
 
Methods inherited from class wyvern.lib.classes.traps.AbstractTrap
isRevealed, reveal, reveal, shouldTrip
 
Methods inherited from class wyvern.kernel.commands.AbstractCommandable
addAttack, addHook, addMessageListener, addMethodHook, checkAnimated, command, command, commandNow, ensureAI, ensureEventQueue, fireMessageReceived, getAI, getCapName, getCombatQueue, getCommand, getEncumbrance, getFiringPoint, getHookList, getHooks, getInventory, getName, getQueue, isCommandable, isStarted, isTelnet, message, message, message, pauseSound, playAlert, playAlert, playDefaultMusic, playPriorityMusic, playPriorityMusic, playSound, playSound, registerCommand, removeAttack, removeHook, removeMessageListener, removeMethodHook, resumeSound, runFailedPostHook, runMethodHook, runPostHook, runPreHook, sendPicture, sendPicture, setAI, setEncumbrance, setMusicGain, setName, setSoundGain, start, stop, stopAllSounds, stopMusic, stopSound, unregisterCommand
 
Methods inherited from class wyvern.kernel.maps.MapObject
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, 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, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, 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, toString, 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.GameObject
addContainerChangeListener, addMapChangeListener, addMapMotionListener, addMotionTracker, addObjectTracker, addPrefix, addSuffix, bless, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, externalize, getAlpha, getAppearance, getArchetype, 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, inContainer, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDirection, setImage, setImage, setLayer, setLocations, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport
 
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
 
Methods inherited from interface wyvern.lib.Broadcaster
broadcast, broadcast, broadcast, broadcast, broadcast
 

Constructor Detail

BearTrap

public BearTrap()
Method Detail

initialize

public void initialize()
Description copied from class: AbstractTrap
Adds class-default properties

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

setMap

public void setMap(GameMap map,
                   int x,
                   int y)
Sets the initial hold-count for the trap, based on the map's danger level.

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

steppedOn

public void steppedOn(Monster monster)
Activates trap.

Specified by:
steppedOn in interface WalkNotify
Overrides:
steppedOn in class AbstractTrap
Parameters:
monster - the monster who stepped on it

trigger

public void trigger(Monster monster)
Triggers the trap. Called by steppedOn if the monster didn't pass (e.g. from flying).


initCount

public void initCount()
Sets an initial stickness, based on the current map danger level.


checkFlying

protected boolean checkFlying(Monster monster)
Returns true if the monster is flying (so we shouldn't trigger the trap.)


hookEvent

public void hookEvent(java.lang.String hookName,
                      CommandEvent event)
Blocks moves.

Specified by:
hookEvent in interface HookCallback
Parameters:
hookName - the name of the hook, such as "movePreHook".
event - the CommandEvent encapsulating the event parameters

finished

public void finished()
Called when the player finally breaks out of the trap. For a BearTrap, it calls destroy(). Subclasses might re-initialize the count.


getStuckMessage

public java.lang.String getStuckMessage()
Returns the message to issue when you're trying to struggle free from the trap.

Returns:
value of the string property "stuck-msg"

getTriggerMessage

public java.lang.String getTriggerMessage()
Returns the message to issue when they step into the trap.

Returns:
"trigger-message"

targetEnteredContainer

public void targetEnteredContainer(ContainerChangeEvent event)
Description copied from interface: ContainerChangeListener
Target object was added to a bag or inventory.

Specified by:
targetEnteredContainer in interface ContainerChangeListener

targetLeftMap

public void targetLeftMap(MapChangeEvent event)
Description copied from interface: MapChangeListener
Notification that the target object has left its map. Called at the end of the object's remove() function.

Specified by:
targetLeftMap in interface MapChangeListener

targetEnteredMap

public void targetEnteredMap(MapChangeEvent event)
Description copied from interface: MapChangeListener
Notification that the target object has entered a map. Called at the end of the object's setMap() function.

Specified by:
targetEnteredMap in interface MapChangeListener

targetMoved

public void targetMoved(MapMotionEvent event)
Description copied from interface: MapMotionListener
Notification that the target object has moved in its map.

Specified by:
targetMoved in interface MapMotionListener

targetLeftContainer

public void targetLeftContainer(ContainerChangeEvent event)
Description copied from interface: ContainerChangeListener
Target object was removed from a bag or inventory.

Specified by:
targetLeftContainer in interface ContainerChangeListener

destroy

public void destroy()
Let them out if the trap is destroyed.

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

unhookMonster

public void unhookMonster()
Removes our reference to the monster/player who stepped on us if any, and removes our hooks into the monster.


removeHooks

public void removeHooks(Commandable monster)
Takes us off monster's hooks.