wyvern.kernel.combat
Class Combat

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.kernel.commands.AbstractCommandable
              extended bywyvern.kernel.combat.Combat
All Implemented Interfaces:
Broadcaster, Commandable, GameObject, Hookable, MethodHookable, PropertyList, RemoteAudio

public final class Combat
extends AbstractCommandable

Provides methods for allowing non-Commandables (such as iron iron gates or fire traps) to do damage to monsters.

Version:
1.0, Jun 09, 1998
Author:
Steve Yegge

Field Summary
static java.lang.String MYCLASS
           
 
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
 
Method Summary
static boolean canPK(GameObject agent, GameObject target)
          Implements rules for Player Killing.
static int computeBonuses(DamageType dtype, GameObject defender)
          Figure out if the defender has any overall protection against the specified damage type.
static int computeDamage(GameObject defender, DamageType dtype, BodyPart hit_loc, boolean crit)
          Performs the damage computation for a particular damage type.
static int computeResistance(int dmg, DamageType dtype, GameObject defender)
          Reduces the passed damage if the defender resists against it.
static int computeVulnerabilities(int dmg, DamageType dtype, GameObject defender)
          Applies any vulnerabilities to the passed damage.
static java.util.List computeWC(GameObject agent)
          Returns a list of DamageTypes to use against the specified opponent.
static void creditAttacker(GameObject attacker, Damageable target)
          Updates attacker's xp, alignment, etc. for killing the monster or destroying a damageable object.
static void damageMonster(GameObject attacker, Commandable defender)
          Causes the passed object to do damage to the passed monster.
static void damageMonster(java.util.List wcs, GameObject attacker, Commandable defender)
          Damages a monster given a list of wcs to use from the attacker.
static void damageObject(GameObject attacker, Damageable item)
          Damages a non-Commandable object that can be damaged.
static void damageObject(java.util.List damages, GameObject attacker, Damageable item)
          Damages a non-Commandable object that can be damaged, given the list of damage types that will be used.
static Combat getInstance()
           
static java.lang.String getProfilingInfo()
          Returns metrics about combat (e.g. experience awards.)
static void kill(GameObject attacker, GameObject target)
          Handles the defender being killed or destroyed.
 
Methods inherited from class wyvern.kernel.commands.AbstractCommandable
addAttack, addHook, addMessageListener, addMethodHook, checkAnimated, command, command, commandNow, destroy, 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, initialize, 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, setMap, 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, 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, initialize, 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, 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
 

Field Detail

MYCLASS

public static final java.lang.String MYCLASS
See Also:
Constant Field Values
Method Detail

getInstance

public static Combat getInstance()

damageMonster

public static void damageMonster(GameObject attacker,
                                 Commandable defender)
Causes the passed object to do damage to the passed monster.

Parameters:
attacker - any object. Must have a weapon class of some sort in order to do any damage; otherwise this method has no effect. If the attacker has a property called "agent" set with type Commandable, it will be transferred to the damage event under the property name "attacker", for doing experience awards. If the attacking object has the property "show-defender-msg", normal damage messages will go to the defender. Otherwise, no damage messages are shown (this is the default).
defender - the object to which to do damage

damageMonster

public static void damageMonster(java.util.List wcs,
                                 GameObject attacker,
                                 Commandable defender)
Damages a monster given a list of wcs to use from the attacker.

Parameters:
attacker - the object or monster doing the damage
wcs - the type(s) of damage being done to the defender
defender - the monster or player taking damage

computeWC

public static java.util.List computeWC(GameObject agent)
Returns a list of DamageTypes to use against the specified opponent. A utility method to be used by other, non-Weapon attacks such as area-effect spells.

Returns:
a list of DamageType objects, with the appropriate wc set in each one. Can return null if no attacks are appropriate.

damageObject

public static void damageObject(GameObject attacker,
                                Damageable item)
Damages a non-Commandable object that can be damaged. Figures out which damages the attacker can do, then calls damageObject(damages, attacker, defender).

Parameters:
attacker - that object that's doing the damage. It will get the XP award for destroying the object, if any.
item - the object to damage.

damageObject

public static void damageObject(java.util.List damages,
                                GameObject attacker,
                                Damageable item)
Damages a non-Commandable object that can be damaged, given the list of damage types that will be used.

Parameters:
damages - the list of DamageType objects to use
attacker - that object that's doing the damage. It will get the XP award for destroying the object, if any.
item - the object to damage.

computeDamage

public static int computeDamage(GameObject defender,
                                DamageType dtype,
                                BodyPart hit_loc,
                                boolean crit)
Performs the damage computation for a particular damage type. Takes into account any protections/resistances/vulnerabilities that the defender might have.

Parameters:
defender - the attackee
dtype - the damage type being used
hit_loc - the hit location (can be null)
crit - whether it was a critical hit or not
Returns:
the amount of damage to do in this attack

computeBonuses

public static int computeBonuses(DamageType dtype,
                                 GameObject defender)
Figure out if the defender has any overall protection against the specified damage type.

Parameters:
dtype - the DamageType to defend against
defender - the attackee
Returns:
any additional AC points to add to the overall AC against this particular attack, from full-body protection.

computeResistance

public static int computeResistance(int dmg,
                                    DamageType dtype,
                                    GameObject defender)
Reduces the passed damage if the defender resists against it.

Parameters:
dmg - the initial damage done by the attack
dtype - the damage type
defender - the thing being attacked
Returns:
the new damage, possibly reduced.

computeVulnerabilities

public static int computeVulnerabilities(int dmg,
                                         DamageType dtype,
                                         GameObject defender)
Applies any vulnerabilities to the passed damage.

Parameters:
dmg - the initial damage
dtype - the damage type
defender - the thing being attacked
Returns:
the new damage, possibly increased

kill

public static void kill(GameObject attacker,
                        GameObject target)
Handles the defender being killed or destroyed. This doesn't actually kill the monster or player, necessarily, since it invokes Monster.kill(), which enqueues a DeathEvent which may be vetoed (e.g. by an amulet of lifesaving).

Parameters:
attacker - the attacker
target - the thing being killed or destroyed

creditAttacker

public static void creditAttacker(GameObject attacker,
                                  Damageable target)
Updates attacker's xp, alignment, etc. for killing the monster or destroying a damageable object.

Parameters:
attacker - the person/thing that killed us
target - the thing that got killed or destroyed

canPK

public static boolean canPK(GameObject agent,
                            GameObject target)
Implements rules for Player Killing.

Parameters:
agent - player doing the attack
target - target getting attacked
Returns:
true if they're both in the PK guild, or the map is a PK map

getProfilingInfo

public static java.lang.String getProfilingInfo()
Returns metrics about combat (e.g. experience awards.)