|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.properties.PList wyvern.kernel.maps.MapObject wyvern.kernel.commands.AbstractCommandable wyvern.lib.classes.magic.Spell wyvern.lib.classes.magic.BallSpell
Superclass of fireballs, blizzards, etc.
Nested Class Summary |
Nested classes inherited from class wyvern.lib.classes.magic.Spell |
Spell.DamageVisitor, Spell.UsableReagentPredicate |
Field Summary | |
static int |
CONTRACTING
|
static int |
DEFAULT_BULLET_SPEED
|
static int |
DEFAULT_CONTRACT_SPEED
|
static int |
DEFAULT_EXPAND_SPEED
|
protected boolean |
dispelled_
|
static int |
EXPANDING
|
static int |
LARGE_BALL_SPELL_RADIUS
|
static int |
MEDIUM_BALL_SPELL_RADIUS
|
static int |
SMALL_BALL_SPELL_RADIUS
|
static int |
UNDETONATED
These constants represent the possible states of the spell. |
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, bitmaps_, 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 | |
BallSpell()
|
Method Summary | |
void |
clearDamageCache()
Resets the cache of monsters we've damaged this turn. |
void |
contractBall()
Contracts the ball in towards the center. |
void |
coolDown()
Start contracting the ball. |
void |
damageMonster(Damageable obj,
Spell spell)
Damages the monster, but only if we haven't |
void |
damageMonsters()
Damages all monsters in areas we occupy. |
void |
decrementCount()
Decrements the counter on the agent saying they can only have so many ball spells active. |
void |
dispel()
Dispels the spell immediately. |
void |
expandBall()
Expands the ball out from the center. |
void |
expandToCell(Point cell,
GameMap map,
java.util.Set points,
java.util.LinkedList turn,
Predicate stop,
Rectangle bounds)
Attempts to expand the fireball into the specified cell. |
void |
explode(Point center)
Explodes the ball at the given point. |
Rectangle |
getBounds()
Returns the bounds of the fireball. |
java.lang.String |
getBulletBitmap()
Gets the name of the bitmap to use for the bullet form of the spell. |
Point |
getCenter()
|
java.lang.String |
getCooldownBitmap()
Gets the bitmap to use when the ball is contracting. |
java.lang.String |
getDamageType()
Return the damage type specifier for this spell. |
java.lang.String |
getExplosionBitmap()
Gets the bitmap to use when the ball is exploding. |
Predicate |
getExplosionPredicate()
Gets the Predicate to use for determining when the spell should explode. |
int[] |
getImageDescriptors()
Returns the appearance of the spell, for drawing it to the client. |
int |
getMaxCasts(Commandable agent)
Returns max number of concurrent instances of this spell the passed agent is allowed to have at once. |
int |
getMaxRadius()
Returns the maximum distance from the center that the spell will expand before starting to shrink. |
int |
getMaxTravel()
Returns the maximum distance the ball will travel before detonating on its own. |
java.util.Set |
getPoints()
Returns the set of all the points the spell currently occupies. |
Predicate |
getPropagationPredicate()
Gets the Predicate to use for determining when the spell should explode. |
int |
getRadius()
|
int |
getSpeed()
Returns the propagation speed (in millis) of the spell. |
int |
getState()
Returns the state of the spell (moving, expanding, contracting). |
protected java.lang.String |
getTempSpellName()
Returns the name of a property to set, to keep track of the active spells of this type. |
int |
getTile(int xloc,
int yloc)
Overrides MapObject.getTile() |
java.util.LinkedList |
getTurnList()
Returns the list of "turns" the ball has taken so far. |
void |
initialize()
Sets the default properties for this kind of spell. |
void |
killAnimation()
Destroys the animation timer, clearing its references. |
void |
moveBall()
Moves the undetonated ball in its current direction. |
void |
setAnimated(boolean animate)
Gives the object the Animated property with default params. |
void |
setCenter(Point center)
Sets the center point for the explosion. |
void |
setMap(GameMap map,
int x,
int y)
Sets the start location. |
void |
setMaxRadius(int max)
Sets the maximum radius for the spell. |
void |
setRadius(int radius)
Sets the current radius of the spell. |
void |
setSpeed(int speed)
This method exists on the off chance that someone wants to set the speed of the spell without knowing (or caring) that it's a BallSpell. |
void |
setState(int state)
Sets the state of the spell. |
void |
start()
Starts the spell. |
void |
startTimer()
Starts the next propagation timer. |
void |
stop()
Stops the spell. |
void |
stopTimer()
Stops the current propagation timer. |
void |
timerExpired()
Propagates the ball spell. |
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, 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 int UNDETONATED
public static final int EXPANDING
public static final int CONTRACTING
public static final int SMALL_BALL_SPELL_RADIUS
public static final int MEDIUM_BALL_SPELL_RADIUS
public static final int LARGE_BALL_SPELL_RADIUS
public static final int DEFAULT_BULLET_SPEED
public static final int DEFAULT_EXPAND_SPEED
public static final int DEFAULT_CONTRACT_SPEED
protected boolean dispelled_
Constructor Detail |
public BallSpell()
Method Detail |
public void initialize()
initialize
in interface GameObject
initialize
in class Spell
public void setMap(GameMap map, int x, int y)
setMap
in interface GameObject
setMap
in class MapObject
public int[] getImageDescriptors()
Many of the objects in the game are rectangular and have a single bitmap that covers all the map locations they occupy. For this reason, MapObject.getImageDescriptors() assumes the object is rectangular (to save most objects a bunch of work), but spells and the like need to override it. If exploding, we return a list of bitmaps to draw, one for each location the spell occupies. (Every object is asked only once for its appearance, NOT once for every time it's found in the map. This is part of the design for making it easy in the general case).
getImageDescriptors
in interface GameObject
getImageDescriptors
in class MapObject
public int getTile(int xloc, int yloc)
getTile
in interface GameObject
getTile
in class MapObject
public void setAnimated(boolean animate)
setAnimated
in interface GameObject
setAnimated
in class MapObject
animate
- true to animate the object, false to remove animationpublic void start()
start
in interface Commandable
start
in class Spell
public void stop()
stop
in interface Commandable
stop
in class AbstractCommandable
public void decrementCount()
public void startTimer()
public void stopTimer()
public void dispel()
dispel
in interface Dispellable
dispel
in class Spell
public void killAnimation()
public int getState()
public void setState(int state)
state
- the new state (UNDETONATED, EXPANDING, CONTRACTING).public Point getCenter()
public int getRadius()
public int getMaxRadius()
public void setRadius(int radius)
radius
- the new radius of the expanding or contracting ballpublic void setMaxRadius(int max)
max
- the radius when the spell is completely expanded.
The diameter of the spell will be (2 * max) + 1; that is, the
radius is the number of squares around the center point in any
direction.public void setCenter(Point center)
center
- the center for the explosion. Set only once.
java.lang.IllegalStateException
- if the center is already setpublic java.util.LinkedList getTurnList()
public java.util.Set getPoints()
getPoints
in class Spell
public Rectangle getBounds()
getBounds
in interface GameObject
getBounds
in class MapObject
public java.lang.String getDamageType()
public java.lang.String getBulletBitmap()
public java.lang.String getExplosionBitmap()
public java.lang.String getCooldownBitmap()
public int getMaxTravel()
public int getSpeed()
getSpeed
in class Spell
public void setSpeed(int speed)
setSpeed
in class Spell
speed
- the new propagation speed, in millis. Depending
on the state of the spell, the bullet speed, expansion speed
or contraction speed will be set.public Predicate getExplosionPredicate()
public Predicate getPropagationPredicate()
protected java.lang.String getTempSpellName()
public int getMaxCasts(Commandable agent)
public void explode(Point center)
center
- the place where the ball exploded (set by AI)public void coolDown()
public void damageMonster(Damageable obj, Spell spell)
damageMonster
in class Spell
obj
- the monster to damagespell
- the spell doing the damage (in case this
needs to be used as a utility by another spell). If the
spell has the property "show-defender-msg", the DamageEvent
generated will show normal damage-messages (depending on
the damage type) to the monster; otherwise it will be silent.public void damageMonsters()
damageMonsters
in class Spell
public void clearDamageCache()
public void timerExpired()
timerExpired
in interface Timed
public void moveBall()
public void expandBall()
Here's how it's done: we keep a hash-set of all points that we currently occupy. Also keep the subset of the points that were added on the last turn. Update it each turn. For each point in the last-turn subset, find each of the 8 neighboring squares. If we occupy it, continue. If it's blocked, continue. Otherwise put a reference there and add it to the set of points for the current turn. At the end of the turn, add the turn's set to the list for backtracking.
This is basically a floodfill algorithm, where we compute the next step in the fill on each turn. We probably want to re-check the neighbors for ALL locations we occupy, just in case something that was blocking has moved since the last turn. In fact, we should check every square we currently occupy in case a blocking object has moved onto us, so we can squelch it.
To shrink the ball, we need to know how many "steps" from the center each new location is. That means we need to save each turn's set of new points, so we can backtrack.
public void expandToCell(Point cell, GameMap map, java.util.Set points, java.util.LinkedList turn, Predicate stop, Rectangle bounds)
cell
- the map location to expand intomap
- the map the spell is expanding inpoints
- the list of points occupied by the cellturn
- the list of points added during this expansion turnstop
- the predicate to use for deciding whether
to expand into the cell. If the predicate returns TRUE, don't
expand into the cell.bounds
- the map boundspublic void contractBall()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |