wyvern.lib
Interface Monster

All Superinterfaces:
Attackable, Broadcaster, Commandable, Damageable, GameObject, Hookable, MethodHookable, PropertyList, RemoteAudio
All Known Subinterfaces:
Player
All Known Implementing Classes:
MonsterImpl, PlayerImpl

public interface Monster
extends Commandable, Attackable

Superinterface of all Monster-like objects, such as (of course) monsters, but also NPCs and Players.

Version:
1.0, Mar 02, 1998
Author:
Steve Yegge

Field Summary
static int DEFAULT_MONSTER_ATTACK_SPEED
          Monsters attack once per second by default; this can be overridden by setting an int "attack-speed" property on the monster.
static int DEFAULT_MONSTER_SPEED
          If a monster has no "move-speed" property, this is the default speed at which the monster moves.
static int DEFAULT_MONSTER_STRENGTH
          If the monster has no "str" property, this is the default.
static int MONSTER_XP_CAP
          The maximum number of XP you can get for any monster, regardless of how difficult it is.
 
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
 
Method Summary
 void adjustSP(int adjust)
          Adjusts the monster's spell points upwards or downwards.
 int adjustStat(int adjust, java.lang.String statname, java.lang.String statmax)
          Adjusts the specified stat, staying within the valid range for the stat.
 void adjustWallet(long amount)
          Adjusts the amount of money the player is carrying by a positive or negative amount.
 void burial(GameObject attacker)
          Destroys the monster.
 void createInventory()
          Creates an inventory for the monster if it doesn't have one.
 void dropAll()
          Causes the monster to drop all its items, except for items that are prevented from being dropped normally (e.g. they're cursed).
 void dropAllForce()
          Causes the monster to drop all its items, even if they're cursed, worn, etc.
 int getLevel()
          Returns the monster's level.
 int getMaxSP()
          Returns the monster's maximum mana.
 PartsList getPartsList()
          Returns the monster's body-parts list.
 int getSP()
          Returns the monster's mana.
 SpellList getSpellList()
          Returns the player's or monster's SpellList.
 long getWallet()
          Returns the amount of cash the monster is carrying in their top-level inventory.
 boolean isAlive()
          Returns true if the monster is alive.
 void setHP(int hp)
          Sets the current HP for the player, but keeps it within the valid range of (0, "max-hp")
 void setSP(int sp)
          Sets the current SP for the player, but keeps it within the valid range of (0, "max-sp")
 
Methods inherited from interface wyvern.lib.Commandable
addAttack, addMessageListener, command, command, commandNow, getAI, getCapName, getCombatQueue, getCommand, getEncumbrance, getFiringPoint, getInventory, getName, getQueue, isStarted, isTelnet, message, message, message, registerCommand, removeAttack, removeMessageListener, sendPicture, sendPicture, setAI, setEncumbrance, setName, start, stop, unregisterCommand
 
Methods inherited from interface wyvern.lib.Hookable
addHook, getHookList, getHooks, removeHook, runFailedPostHook, runPostHook, runPreHook
 
Methods inherited from interface wyvern.lib.MethodHookable
addMethodHook, removeMethodHook, runMethodHook
 
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, destroy, 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, initialize, 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, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDirection, setImage, setImage, setLayer, setLocations, setMap, 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
 
Methods inherited from interface wyvern.common.net.RemoteAudio
pauseSound, playAlert, playAlert, playDefaultMusic, playPriorityMusic, playPriorityMusic, playSound, playSound, resumeSound, setMusicGain, setSoundGain, stopAllSounds, stopMusic, stopSound
 
Methods inherited from interface wyvern.lib.properties.Attackable
getXPAward, notifyAttacked
 
Methods inherited from interface wyvern.lib.properties.Damageable
adjustHP, getHP, getMaxHP, kill
 

Field Detail

DEFAULT_MONSTER_SPEED

public static final int DEFAULT_MONSTER_SPEED
If a monster has no "move-speed" property, this is the default speed at which the monster moves.

See Also:
Constant Field Values

DEFAULT_MONSTER_STRENGTH

public static final int DEFAULT_MONSTER_STRENGTH
If the monster has no "str" property, this is the default.

See Also:
Constant Field Values

DEFAULT_MONSTER_ATTACK_SPEED

public static final int DEFAULT_MONSTER_ATTACK_SPEED
Monsters attack once per second by default; this can be overridden by setting an int "attack-speed" property on the monster.

See Also:
Constant Field Values

MONSTER_XP_CAP

public static final int MONSTER_XP_CAP
The maximum number of XP you can get for any monster, regardless of how difficult it is. Nearly all games have a max-xp cap in place. It helps avoid bugs where monsters accidentally give a million XP.

See Also:
Constant Field Values
Method Detail

isAlive

public boolean isAlive()
Returns true if the monster is alive. When a monster is killed, references to it may still exist, and occasionally the owners of those references need to check if the monster is still alive. The method just checks for the presence of a boolean property named "dead", and if it's not there, it returns true.

Returns:
true if the monster has no "dead" property

dropAll

public void dropAll()
Causes the monster to drop all its items, except for items that are prevented from being dropped normally (e.g. they're cursed).


dropAllForce

public void dropAllForce()
Causes the monster to drop all its items, even if they're cursed, worn, etc. Used when the monster dies.


burial

public void burial(GameObject attacker)
Destroys the monster. Usually you call the kill() method, which sets up a DeathEvent that goes through the usual hooks for a "death" command ("deathPreHook", etc.) Once the death has been approved, the event calls this burial() method to destroy the monster by stopping it, dropping inventory, removing it from the map, and so on.

Parameters:
attacker - the player/etc. that killed us; can be null

getPartsList

public PartsList getPartsList()
Returns the monster's body-parts list.


getLevel

public int getLevel()
Returns the monster's level.


getSP

public int getSP()
Returns the monster's mana.


getMaxSP

public int getMaxSP()
Returns the monster's maximum mana.


adjustSP

public void adjustSP(int adjust)
Adjusts the monster's spell points upwards or downwards.

Parameters:
adjust - a number (possibly negative) to add to the monster's hp

adjustStat

public int adjustStat(int adjust,
                      java.lang.String statname,
                      java.lang.String statmax)
Adjusts the specified stat, staying within the valid range for the stat. If there's a specific method for the stat, such as "adjustHP", then use the specific method.

Parameters:
adjust - the amount by which to adjust the stat, positive or negative.
statname - the name of the stat property to adjust
statmax - the name of the max-stat property, e.g., "max-hp"
Returns:
the new value, after adjustment

setSP

public void setSP(int sp)
Sets the current SP for the player, but keeps it within the valid range of (0, "max-sp")

Parameters:
sp - the new sp

setHP

public void setHP(int hp)
Sets the current HP for the player, but keeps it within the valid range of (0, "max-hp")

Parameters:
hp - the new hp

getWallet

public long getWallet()
Returns the amount of cash the monster is carrying in their top-level inventory. You can also do this by just searching their inventory for coins, but this is more convenient because it sums their cash in silver coins. It may also be enhanced to look in a purse or wallet, so you really ought to use it when checking to see how much coinage a player is carrying.

Returns:
the total SILVER the player is carrying. It does the following calculation: silver + gold*10 + platinum*1000.

adjustWallet

public void adjustWallet(long amount)
Adjusts the amount of money the player is carrying by a positive or negative amount.

Parameters:
amount - the amount of silver to add. If negative, deducts from the player's cash on hand. If the amount to deduct is more than the player has, it returns only the amount the player had on hand. It's up to the caller to call getWallet() and ensure there's enough there.

Note: this method does NOT check whether the player can carry the money, and it's possible to give the player more than they can technically carry. This is still under consideration - if it causes bugs, then we'll force the extra money to go on the ground.


getSpellList

public SpellList getSpellList()
Returns the player's or monster's SpellList.

Returns:
a SpellList object, or null if the monster or player knows no spells.

createInventory

public void createInventory()
Creates an inventory for the monster if it doesn't have one. Normally this gets called in initialize(), so you shouldn't need to call it.