wyvern.lib.classes.weapons
Class RangeWeapon

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.lib.classes.weapons.WeaponImpl
              extended bywyvern.lib.classes.weapons.RangeWeapon
All Implemented Interfaces:
Applyable, Attack, Broadcaster, Damageable, GameObject, MethodHookable, Movable, PickupInterest, PropertyList, Readyable, Targetable, Weapon
Direct Known Subclasses:
Blowgun, Bow, Crossbow, Gun, Sling

public abstract class RangeWeapon
extends WeaponImpl
implements Targetable

This is the superclass for all projectile-weapons: guns, bows, slings, etc. Each subclass must provide a classname for the type of object the weapon can fire.

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

Field Summary
static int DEFAULT_MISSILE_DISTANCE
           
static int DEFAULT_MISSILE_SPEED
           
 
Fields inherited from class wyvern.lib.classes.weapons.WeaponImpl
DEFAULT_WEAPON_HP, wcs_
 
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
 
Constructor Summary
RangeWeapon()
           
 
Method Summary
 boolean canReady(Commandable agent)
          Checks if the specified Commandable may ready the object.
 void copyWC(GameObject missile)
          Copies any weapon-class bonuses from the bow to the missile before firing it.
 void fireDirection(Commandable agent, int dir)
          Tells the object 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.
 Missile getMissile(Commandable agent)
          Returns a missile to fire.
abstract  java.lang.Class getMissileClass()
          Returns the class of missiles we can fire.
 int getMissileDistance(Commandable agent, Missile missile)
          Returns the distance this missile should travel when fired by the passed agent.
 int getMissileSpeed(Commandable agent, Missile missile)
          Returns the delay in millis between moves of the missiles fired from this weapon.
 java.lang.Class getQuiverClass()
          Returns the class of quiver we work with.
 java.lang.String getWeaponSkill()
          Returns the weapon skill for this type of weapon.
 void initialize()
          Initializes the object's default properties.
protected  void sendNoMissileMsg(java.lang.Class mclass, Commandable agent)
          Issues a message to the agent telling them they have none of the right kind of missile.
 boolean setWielded(boolean wielded, Commandable agent)
          Wields (or unwields) the weapon.
 
Methods inherited from class wyvern.lib.classes.weapons.WeaponImpl
addSlayWC, adjustHP, apply, canUnready, checkDrop, checkHit, destroy, didDamage, dropped, forceUnwield, getDescription, getHP, getMaxHP, getRequiredSlots, getToHit, getWC, hitMonster, isReadied, isWielded, kill, notifyReady, notifyUnready, pickedUp, recomputeWCs, setDefaultHP, setShowAttackerMessage, setToHit, setWC, shouldStop, showAttackerMessage, toString, tryGettingCaught
 
Methods inherited from class wyvern.kernel.maps.MapObject
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, addMethodHook, addMotionTracker, addObjectTracker, addPrefix, addSuffix, addToMap, bless, broadcast, broadcast, broadcast, broadcast, broadcast, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, curse, cycleFrame, ensureListenerList, ensureWeight, externalize, fireContainerEntered, fireContainerExited, fireEnteredMap, fireExitedMap, fireMovedInMap, getAlpha, getAppearance, getArchetype, getBaseName, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, 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, initLocs, 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, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMethodHook, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, runMethodHook, 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, 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, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, curse, cycleFrame, externalize, getAlpha, getAppearance, getArchetype, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, 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, 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.MethodHookable
addMethodHook, removeMethodHook, runMethodHook
 
Methods inherited from interface wyvern.lib.Broadcaster
broadcast, broadcast, broadcast, broadcast, broadcast
 

Field Detail

DEFAULT_MISSILE_SPEED

public static final int DEFAULT_MISSILE_SPEED
See Also:
Constant Field Values

DEFAULT_MISSILE_DISTANCE

public static final int DEFAULT_MISSILE_DISTANCE
See Also:
Constant Field Values
Constructor Detail

RangeWeapon

public RangeWeapon()
Method Detail

initialize

public void initialize()
Description copied from interface: GameObject
Initializes the object's default properties. Any GameObject implementation that wishes to initialize itself should do so here, rather than in the constructor. This is because nearly all game objects inherit from an archetype, and the archetype parent pointer isn't set until the object's constructor finishes. This is a good place to add any class-default properties for an object - properties that the object gets regardless of which archetype it inherits from. WARNING: don't forget to call the superclass' initialize() method, or the object may not function properly. For instance, it won't become animated even if it specifies animation parameters in the archetype.

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

getMissileClass

public abstract java.lang.Class getMissileClass()
Returns the class of missiles we can fire.

Returns:
Missile.class (not recommended) or a specific subclass

getQuiverClass

public java.lang.Class getQuiverClass()
Returns the class of quiver we work with.

Returns:
null if we don't want to look in a special bag type for the missiles to fire, or a BasicBag subclass. Default: returns null.

getMissileSpeed

public int getMissileSpeed(Commandable agent,
                           Missile missile)
Returns the delay in millis between moves of the missiles fired from this weapon.

Returns:
the missile speed in millis; defaults to the int "missile-speed" property, if present, else DEFAULT_MISSILE_SPEED.

getMissileDistance

public int getMissileDistance(Commandable agent,
                              Missile missile)
Returns the distance this missile should travel when fired by the passed agent.

Returns:
the max distance, in map squares, to travel. Defaults to the "missile-dist" property, if present, else DEFAULT_MISSILE_DISTANCE. Subclasses are free to override this method and use things like the agent's strength and/or range-weapon skill(s) to come up with a better distance.

fireDirection

public void fireDirection(Commandable agent,
                          int dir)
Tells the object to fire itself in the specified direction. Sets the agent in a property on the missile called "agent". Sets the weapon in a property on the missile called "weapon".

Specified by:
fireDirection in interface Targetable
Parameters:
agent - the agent firing the object
dir - a wyvern.lib.Direction cardinal direction

copyWC

public void copyWC(GameObject missile)
Copies any weapon-class bonuses from the bow to the missile before firing it.


getMissile

public Missile getMissile(Commandable agent)
Returns a missile to fire. Searches the inventory and (maybe) a quiver for the correct missile type.

Returns:
a missile, or null if none was found. Issues a message to the agent if no missile was found.

sendNoMissileMsg

protected void sendNoMissileMsg(java.lang.Class mclass,
                                Commandable agent)
Issues a message to the agent telling them they have none of the right kind of missile.

Parameters:
mclass - the Missile class to fire
agent - the agent firing the weapon

fireLocation

public void fireLocation(Commandable agent,
                         Point target)
Tells the object to fire itself along the line specified from the agent to a destination point.

Specified by:
fireLocation in interface Targetable
Parameters:
agent - the agent firing the object
target - the destination point, perhaps chosen using the mouse.

setWielded

public boolean setWielded(boolean wielded,
                          Commandable agent)
Wields (or unwields) the weapon.

Specified by:
setWielded in interface Weapon
Overrides:
setWielded in class WeaponImpl
Parameters:
wielded - true if wielded
agent - the wielder

canReady

public boolean canReady(Commandable agent)
Checks if the specified Commandable may ready the object.

Specified by:
canReady in interface Readyable
Overrides:
canReady in class WeaponImpl
Parameters:
agent - the Commandable trying to ready the object
Returns:
true if it's allowed to do so.

getWeaponSkill

public java.lang.String getWeaponSkill()
Returns the weapon skill for this type of weapon.

Specified by:
getWeaponSkill in interface Attack
Returns:
"sk-range"