wyvern.lib.spells
Class FlameShield

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.kernel.commands.AbstractCommandable
              extended bywyvern.lib.classes.magic.Spell
                  extended bywyvern.lib.spells.FlameShield
All Implemented Interfaces:
Broadcaster, Command, Commandable, Dispellable, java.util.EventListener, GameObject, Hookable, MapChangeListener, MapMotionListener, MethodHookable, PropertyList, RemoteAudio, Targetable
Direct Known Subclasses:
FrostWard, LightningShield, PrismaticShield

public class FlameShield
extends Spell
implements MapChangeListener, MapMotionListener, Command

Creates a ring of flames around the caster.

Version:
1.0, Oct 17, 2001 (rewritten from 1999 python version)
Author:
Steve Yegge

Nested Class Summary
 
Nested classes inherited from class wyvern.lib.classes.magic.Spell
Spell.DamageVisitor, Spell.UsableReagentPredicate
 
Field Summary
protected static int[] bitmaps_
           
 
Fields inherited from class wyvern.lib.classes.magic.Spell
AIR, AIR_AND_DEATH, AIR_AND_LIFE, AIR_AND_MIND, AIR_AND_SPIRIT, ART_MANA_REDUCTIONS, CONJURATION, damager_, DEATH, DEATH_AND_MIND, DEATH_AND_SPIRIT, EARTH, EARTH_AND_AIR, EARTH_AND_DEATH, EARTH_AND_LIFE, EARTH_AND_MIND, EARTH_AND_SPIRIT, ENCHANTMENT, EVOCATION, FIRE, FIRE_AND_AIR, FIRE_AND_DEATH, FIRE_AND_EARTH, FIRE_AND_LIFE, FIRE_AND_MIND, FIRE_AND_SPIRIT, FIRE_AND_WATER, INCANTATION, LIFE, LIFE_AND_DEATH, LIFE_AND_MIND, LIFE_AND_SPIRIT, MIND, MIND_AND_SPIRIT, SELF_DAMAGE_CHANCE, SPIRIT, WATER, WATER_AND_AIR, WATER_AND_DEATH, WATER_AND_EARTH, WATER_AND_LIFE, WATER_AND_MIND, WATER_AND_SPIRIT
 
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
FlameShield()
           
 
Method Summary
protected  int chooseRandomTile()
          Returns a random image for one of our locations.
 CommandEvent createEvent(CommandEvent initial)
          Creates the propagation event.
 void dispel()
          Dispels the spell.
 boolean execute(CommandEvent event)
          Propagates the spell.
 void getAnimationFrames()
          Preloads the animation tiles for this spell.
 Rectangle getBounds()
          The default implementation for non-rectangular objects is to compute the bounds from the location list on each call, so we can speed it up by figuring it out ourselves when we move.
 int getDuration()
          Returns the duration for the spell.
 int[] getImageDescriptors()
          Have to manage our appearance manually since we're non-rectangular.
 java.util.List getLocations()
          We keep track of our own locations (don't use superclass).
 java.util.Set getPoints()
          Required for spells that occupy area, for damageMonster().
 int getTile(int x, int y)
          Choose a random tile.
 java.lang.String getWCType()
          Returns "wc-fire", the damage type this spell does.
 void initialize()
          Adds the default properties for a Spell object.
protected  void initLocs()
          Don't do this.
 boolean knowsCommand(java.lang.String command)
          Command implementation.
 void methodCalled(java.lang.String hookName, MethodHookable target, java.lang.Object data)
          Updates our position when the caster moves.
 void removeFromMap()
          Removes the spell from all points we currently occupy.
 void setSpellWC()
          Sets the spell's weapon class based on its level.
 void start()
          Starts the spell.
 void targetEnteredMap(MapChangeEvent event)
          Notification that the target object has entered a map.
 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 teleport(int x, int y)
          Don't do anything - we don't need this method.
 void updatePosition(Commandable agent)
          Positions the spell in all squares adjacent to the caster.
 
Methods inherited from class wyvern.lib.classes.magic.Spell
addReagent, canDamageSelf, canEnter, canEnter, castingOnSelf, cloneSpell, consumeReagents, damageMonster, damageMonsters, destroy, ensureAI, ensureDirection, ensureReagents, findTargetObject, findTargetObject, fireDirection, fireLocation, getAgent, getAnimationFrames, getArt, getBlockingPredicate, getCastingDelay, getCommand, getDescString, getElement, getLevel, getLoreCost, getMagicItem, getReagents, getRequiredMana, getSpeed, getSpellArgs, getSpellDescription, getSpellName, getTarget, getTargetName, getTargetPoint, isBlessed, isConjuration, isCursed, isEnchantment, isEvocation, isIncantation, isPotion, logUsage, makeDispellable, reloadSpells, removeFromActiveListIfPresent, setAgent, setLevel, setMagicItem, setSpeed, setSpellArgs, setTarget, setTargetName, setTargetPoint, tellCaster
 
Methods inherited from class wyvern.kernel.commands.AbstractCommandable
addAttack, addHook, addMessageListener, addMethodHook, checkAnimated, command, command, commandNow, ensureEventQueue, fireMessageReceived, getAI, getCapName, getCombatQueue, 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, 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, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, ensureListenerList, ensureWeight, externalize, fireContainerEntered, fireContainerExited, fireEnteredMap, fireExitedMap, fireMovedInMap, getAlpha, getAppearance, getArchetype, getBaseName, getBaseWeight, getBitmap, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getLayer, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getValue, getWeight, groupString, inContainer, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, 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, setMap, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, 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, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, externalize, getAlpha, getAppearance, getArchetype, getBaseWeight, getBitmap, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getLayer, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getValue, getWeight, inContainer, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, 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, setMap, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight
 
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
 

Field Detail

bitmaps_

protected static int[] bitmaps_
Constructor Detail

FlameShield

public FlameShield()
Method Detail

initialize

public void initialize()
Description copied from class: Spell
Adds the default properties for a Spell object.

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

start

public void start()
Description copied from class: Spell
Starts the spell. Sets a target on the spell if the player says so.

Specified by:
start in interface Commandable
Overrides:
start in class Spell

getDuration

public int getDuration()
Returns the duration for the spell.

Returns:
how many milliseconds the spell should last. Should check the level of the caster (or magic item) in the appropriate element(s). Be careful to check that you don't return a negative duration, e.g. if the caster's skill in an element is negative.

setSpellWC

public void setSpellWC()
Sets the spell's weapon class based on its level.


getWCType

public java.lang.String getWCType()
Returns "wc-fire", the damage type this spell does.


updatePosition

public void updatePosition(Commandable agent)
Positions the spell in all squares adjacent to the caster.


getTile

public int getTile(int x,
                   int y)
Choose a random tile.

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

getBounds

public Rectangle getBounds()
The default implementation for non-rectangular objects is to compute the bounds from the location list on each call, so we can speed it up by figuring it out ourselves when we move.

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

getImageDescriptors

public int[] getImageDescriptors()
Have to manage our appearance manually since we're non-rectangular.

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

getAnimationFrames

public void getAnimationFrames()
Preloads the animation tiles for this spell.


chooseRandomTile

protected int chooseRandomTile()
Returns a random image for one of our locations.


getLocations

public java.util.List getLocations()
We keep track of our own locations (don't use superclass).

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

initLocs

protected void initLocs()
Don't do this.

Overrides:
initLocs in class MapObject

getPoints

public java.util.Set getPoints()
Required for spells that occupy area, for damageMonster().

Overrides:
getPoints in class Spell
Returns:
a set of points for the spell, null if the spell occupies no map locations.

methodCalled

public void methodCalled(java.lang.String hookName,
                         MethodHookable target,
                         java.lang.Object data)
Updates our position when the caster moves.


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

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

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

knowsCommand

public boolean knowsCommand(java.lang.String command)
Command implementation. We queue commands to propagate the spell. This used to be better tha using a timer, particularly under heavy lag conditions: the spell only propagates when the game gets around to calling it back. However, this isn't true anymore; timers work just fine under lag now, and we should rewrite this to use timers to simplify the code.

Specified by:
knowsCommand in interface Command
Parameters:
command - the entire command string, including arguments
Returns:
true if we want to handle the command

createEvent

public CommandEvent createEvent(CommandEvent initial)
Creates the propagation event.

Specified by:
createEvent in interface Command
Parameters:
initial - a "blank" CommandEvent containing only the command text and the agent who's performing the command. This initial event is created by the originator of the event (e.g. the AI or player's command preprocessor).
Returns:
a CommandEvent subclass encapsulating this command's execution parameters and state. It should copy in the fields from the passed-in event.

execute

public boolean execute(CommandEvent event)
Propagates the spell.

Specified by:
execute in interface Command
Parameters:
event - the CommandEvent to execute
Returns:
true if the event completed successfully, else false.

dispel

public void dispel()
Dispels the spell.

Specified by:
dispel in interface Dispellable
Overrides:
dispel in class Spell

removeFromMap

public void removeFromMap()
Removes the spell from all points we currently occupy. Clears the points_ list, so getLocations() will return null.


teleport

public void teleport(int x,
                     int y)
Don't do anything - we don't need this method.

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