|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwyvern.kernel.properties.PList
wyvern.kernel.maps.MapObject
wyvern.kernel.commands.AbstractCommandable
wyvern.lib.classes.magic.Spell
This class extends Monster in various ways, to make spells behave more or less like monsters in the game. This is useful even for one-shot spells like Identify that never actually go in the map.
The Spell class inherits various useful methods from AbstractCommandable:
To activate a spell, the following steps may be necessary:
| Nested Class Summary | |
protected class |
Spell.DamageVisitor
Invokes callback function for damaging monsters. |
protected class |
Spell.UsableReagentPredicate
Determines if we can use a given reagent. |
| 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 | |
Spell()
|
|
| Method Summary | |
void |
addReagent(java.lang.String path)
Adds a reagent to the list of required reagents for this spell. |
static boolean |
canDamageSelf(Commandable caster,
Spell spell)
Checks to see if the caster has enough skill to avoid damaging themselves |
boolean |
canEnter(GameMap map,
int x,
int y)
Returns true if the spell is allowed to enter the specified location. |
boolean |
canEnter(GameMap map,
Point ref)
Returns true if the spell is allowed to enter the specified location. |
boolean |
castingOnSelf()
Returns true if the spell target is the same as the spell agent/caster. |
static Spell |
cloneSpell(java.lang.String name)
Clones a spell from its name. |
boolean |
consumeReagents(Commandable agent)
Figures out which reagents the spell requires, if any, and consumes them. |
void |
damageMonster(Damageable obj,
Spell spell)
Does damage to a specific monster. |
void |
damageMonsters()
Does damage to all cells we currently occupy. |
void |
destroy()
Destroys the spell. |
void |
dispel()
Dispels the spell. |
protected void |
ensureAI()
Chooses an AI for the monster. |
int |
ensureDirection()
Makes sure we have a valid (cardinal) direction, in case nobody set it before firing the spell. |
boolean |
ensureReagents()
Calls consumeReagents(), and if the result is false, prints a message to the caster saying they don't have enough reagents. |
GameObject |
findTargetObject()
Same as findTargetObject(useAgent), but never uses the caster as the target. |
GameObject |
findTargetObject(boolean useAgent)
Uses standard rules for finding the target. |
void |
fireDirection(Commandable agent,
int dir)
Tells the spell to fire itself in the specified direction. |
void |
fireLocation(Commandable agent,
Point target)
Tells the object to fire itself along the line specified from the agent to a destination point. |
Commandable |
getAgent()
Returns the caster, if any. |
protected void |
getAnimationFrames(java.lang.String cat,
java.lang.String bmp)
Gets the frames to use for random animation. |
Art |
getArt()
Returns one of the four spell Arts. |
Predicate |
getBlockingPredicate()
Returns a predicate that determines whether the spell can be placed at a given map location. |
int |
getCastingDelay()
Returns the delay for casting this spell. |
Command |
getCommand(CommandEvent event)
Returns the Command that handles this spell. |
java.lang.String |
getDescString()
Converts the art and element(s) into a string. |
Element |
getElement()
Returns the Element for this spell. |
int |
getLevel(Element element)
Returns the level of the spell. |
int |
getLoreCost()
Returns the lore cost for this spell - by default, what's in the "lore" entry for the spell, in the SpellRegistry. |
GameObject |
getMagicItem()
Returns the wand/rod/scroll/whatever that initiated this spell, if any. |
java.util.Set |
getPoints()
Returns the map locations that the spell is currently occupying. |
java.util.List |
getReagents()
Returns the reagents for this spell. |
int |
getRequiredMana()
Returns the amount of mana required for this spell. |
int |
getSpeed()
Gets the propagation speed of the spell. |
java.lang.String |
getSpellArgs()
Returns the spell arguments, if any. |
java.lang.String |
getSpellDescription()
Returns a generic description for the spell. |
java.lang.String |
getSpellName()
Returns the name of the spell, such as "word of recall", used for casting the spell. |
GameObject |
getTarget()
Returns the actual target object to use for this spell. |
java.lang.String |
getTargetName()
Returns the name set during the casting, if the user wants to cast a spell on a particular object or monster. |
Point |
getTargetPoint()
Returns the target location for this spell, if it was invoked using the mouse (or by specifying a location on the command line). |
void |
initialize()
Adds the default properties for a Spell object. |
boolean |
isBlessed()
Returns true if the spell is blessed, e.g. it came from a blessed scroll. |
boolean |
isConjuration()
Returns true if this spell's art is CONJURATION. |
boolean |
isCursed()
Returns true if the spell is cursed, e.g. it came from a cursed scroll. |
boolean |
isEnchantment()
Returns true if this spell's art is ENCHANTMENT. |
boolean |
isEvocation()
Returns true if this spell's art is EVOCATION. |
boolean |
isIncantation()
Returns true if this spell's art is INCANTATION. |
boolean |
isPotion()
Returns true if the spell was "cast" by drinking a potion (or being hit by one). |
void |
logUsage()
Logs the casting of the spell into the spell log. |
void |
makeDispellable()
Adds this spell to the agent's active-list, so it can be viewed and dispelled. |
static void |
reloadSpells()
Instructs the Spell.cloneSpell() methods to use a new ClassLoader instance to load spells, which will cause them to be re-read from the class files on disk. |
void |
removeFromActiveListIfPresent()
Gets spell's agent, and removes this spell from "active-spells" list, if it's there. |
void |
setAgent(Commandable agent)
Sets the agent casting or invoking the spell. |
void |
setLevel(int level)
Sets the spell's level property. |
void |
setMagicItem(GameObject item)
Sets the magic item that was used to invoke this spell, such as a wand or scroll. |
void |
setSpeed(int speed)
Sets the propagation speed of the spell. |
void |
setSpellArgs(java.lang.String args)
Sets the argument string used to invoke the spell, using the "with-args" keyword. |
void |
setTarget(GameObject target)
Sets the actual target of the spell. |
void |
setTargetName(java.lang.String name)
Names the object on which the user wants to cast the spell. |
void |
setTargetPoint(Point point)
Sets a location at which the user requested to cast the spell, usually via the mouse. |
void |
start()
Starts the spell. |
void |
tellCaster(java.lang.String msg)
Sends a message to the spell's caster, if the spell has a caster set. |
| 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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface wyvern.lib.Broadcaster |
broadcast, broadcast, broadcast, broadcast, broadcast |
| Field Detail |
public static final Art INCANTATION
public static final Art CONJURATION
public static final Art EVOCATION
public static final Art ENCHANTMENT
public static final Element FIRE
public static final Element WATER
public static final Element EARTH
public static final Element AIR
public static final Element LIFE
public static final Element DEATH
public static final Element MIND
public static final Element SPIRIT
public static final Element FIRE_AND_WATER
public static final Element FIRE_AND_EARTH
public static final Element FIRE_AND_AIR
public static final Element FIRE_AND_LIFE
public static final Element FIRE_AND_DEATH
public static final Element FIRE_AND_MIND
public static final Element FIRE_AND_SPIRIT
public static final Element WATER_AND_EARTH
public static final Element WATER_AND_AIR
public static final Element WATER_AND_LIFE
public static final Element WATER_AND_DEATH
public static final Element WATER_AND_MIND
public static final Element WATER_AND_SPIRIT
public static final Element EARTH_AND_AIR
public static final Element EARTH_AND_LIFE
public static final Element EARTH_AND_DEATH
public static final Element EARTH_AND_MIND
public static final Element EARTH_AND_SPIRIT
public static final Element AIR_AND_LIFE
public static final Element AIR_AND_DEATH
public static final Element AIR_AND_MIND
public static final Element AIR_AND_SPIRIT
public static final Element LIFE_AND_DEATH
public static final Element LIFE_AND_MIND
public static final Element LIFE_AND_SPIRIT
public static final Element DEATH_AND_MIND
public static final Element DEATH_AND_SPIRIT
public static final Element MIND_AND_SPIRIT
public static final int[] ART_MANA_REDUCTIONS
public static final int[] SELF_DAMAGE_CHANCE
protected int[] bitmaps_
protected Visitor damager_
| Constructor Detail |
public Spell()
| Method Detail |
public void initialize()
initialize in interface GameObjectinitialize in class MapObjectprotected void ensureAI()
AbstractCommandableThis is (probably) the most appropriate time to convert the externalized "ai" property (an Archetype) into an actual instantiated AI class. It's stored in the file as an archetype because the AI classes aren't usually directly instantiable, so doing something like "ai class FooAI" would result in an IllegalAccessError.
Because there are no static interfaces in Java (as yet), we can't simply take the class, cast it to a static interface, and invoke the getImpl() class method on it. Alas. Instead, we must use reflection to sniff out the getImpl() class method. This returns the (singleton) instance of the AI, which we can store a reference to in our "ai" property.
ensureAI in class AbstractCommandablepublic java.lang.String getSpellName()
public Art getArt()
public Element getElement()
public int getLoreCost()
public int getCastingDelay()
public java.lang.String getSpellDescription()
public java.lang.String getDescString()
public void start()
start in interface Commandablestart in class