wyvern.kernel.combat
Class AttackingBodyPart

java.lang.Object
  extended bywyvern.kernel.combat.BodyPart
      extended bywyvern.kernel.combat.AttackingBodyPart
All Implemented Interfaces:
Attack, MethodHookable
Direct Known Subclasses:
BasicAttack, BitingHead, ClawedHand, Hand, PoisonSting

public abstract class AttackingBodyPart
extends BodyPart
implements Attack, MethodHookable

Subclass of BodyPart that implements the Attack interface.

Version:
1.0, Jul 21, 1999
Author:
Steve Yegge

Field Summary
protected  java.util.ArrayList dtypes_
           
protected  int tohit_
           
 
Fields inherited from class wyvern.kernel.combat.BodyPart
hitWeight_, name_, pluralName_, slots_, uniqueName_
 
Constructor Summary
AttackingBodyPart()
           
 
Method Summary
 void addDamageType(DamageType dtype)
          Adds a DamageType object to the list of damage types this attack does.
 void addMethodHook(MethodHookCallback callback, java.lang.String methodName)
          Registers for the specified method-hook.
abstract  void addWCs()
          Instructs the subclass to add one DamageType object for each damage type the body-part does when it strikes.
 void didDamage(DamageEvent event)
          Notification that the weapon just did some damage.
 int getToHit()
          Returns the base chance to hit for the weapon, against all attackers.
 java.util.List getWC(GameObject opponent)
          Returns the weapon-class(es) of this weapon, versus the passed opponent.
 java.lang.String getWeaponSkill()
          Returns the weapon skill for this attack type.
 BodyPart makeClone()
          Clones this body part.
 void recomputeWCs()
          Recomputes cached WC(s) for this attack.
 void removeMethodHook(MethodHookCallback callback, java.lang.String methodName)
          Unregisters for the specified method-hook.
 void runMethodHook(java.lang.String hookName, java.lang.Object data)
          Runs the specified method hook on this object.
 void setShowAttackerMessage(boolean show)
          Toggles showing the attacker message for the damage event.
 void setToHit(int tohit)
          Sets the base chance to hit for the weapon, against all attackers.
 void setWC(int wc)
          Sets the (primary) WC value for this attacking body part.
 void setWC(java.lang.String name, int wc)
          Adds a new wc for this attack.
 boolean showAttackerMessage()
          Returns true if we show the attacker message.
 java.lang.String toString()
          Prints String rep.
 
Methods inherited from class wyvern.kernel.combat.BodyPart
equals, getName, getPluralName, getProbability, getSlots, getTotalAC, getUniqueName, makeSingleSlot, setName, setPluralName, setProbability, setUniqueName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tohit_

protected int tohit_

dtypes_

protected java.util.ArrayList dtypes_
Constructor Detail

AttackingBodyPart

public AttackingBodyPart()
Method Detail

addWCs

public abstract void addWCs()
Instructs the subclass to add one DamageType object for each damage type the body-part does when it strikes.


getWC

public java.util.List getWC(GameObject opponent)
Returns the weapon-class(es) of this weapon, versus the passed opponent. Defaults to the same behavior as that of wyvern.lib.classes.weapons.WeaponImpl - goes through all the wc-* properties and

Specified by:
getWC in interface Attack
Parameters:
opponent - the thing being attacked. Can be null! The weapon should check for this case. The weapon is free to ignore the opponent and return the same wc for every opponent.
Returns:
a list of DamageType objects, with the appropriate wc set in each one. Can return null if no attacks are appropriate.

getWeaponSkill

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

Specified by:
getWeaponSkill in interface Attack
Returns:
sk-unarmed

setShowAttackerMessage

public void setShowAttackerMessage(boolean show)
Description copied from interface: Attack
Toggles showing the attacker message for the damage event.

Specified by:
setShowAttackerMessage in interface Attack
Parameters:
show - true to show the attacker message, false to hide it.

showAttackerMessage

public boolean showAttackerMessage()
Description copied from interface: Attack
Returns true if we show the attacker message.

Specified by:
showAttackerMessage in interface Attack
Returns:
true, by default (subclass can override.)

getToHit

public int getToHit()
Description copied from interface: Attack
Returns the base chance to hit for the weapon, against all attackers.

Specified by:
getToHit in interface Attack
Returns:
the weapon's base chance to hit

setToHit

public void setToHit(int tohit)
Description copied from interface: Attack
Sets the base chance to hit for the weapon, against all attackers.

Specified by:
setToHit in interface Attack
Parameters:
tohit - the weapon's base chance to hit

setWC

public void setWC(java.lang.String name,
                  int wc)
Adds a new wc for this attack. (Or resets an existing one).

Specified by:
setWC in interface Attack
Parameters:
name - the name of the damage type, e.g. "fire", "cut", "smash"
wc - the new wc for this damage type

setWC

public void setWC(int wc)
Sets the (primary) WC value for this attacking body part. For bites, it might be stab, and for claws, it might be cut. Subclasses should determine it appropriately. If a subclass doesn't override it, it'll set the first WC in the list.


addDamageType

public void addDamageType(DamageType dtype)
Adds a DamageType object to the list of damage types this attack does.


recomputeWCs

public void recomputeWCs()
Recomputes cached WC(s) for this attack.

Specified by:
recomputeWCs in interface Attack

didDamage

public void didDamage(DamageEvent event)
Description copied from interface: Attack
Notification that the weapon just did some damage. Does nothing by default, but hooks and subclasses can use it if they want.

This method runs a method hook called "didDamage", and passes the event along as the data parameter.

Specified by:
didDamage in interface Attack
Parameters:
event - the damage-event associated with the damage. The event will have parameters set by the combat system (by the DamageCommand, in particular), including the hit location, attacker, defender, total damage, and others.

runMethodHook

public void runMethodHook(java.lang.String hookName,
                          java.lang.Object data)
Runs the specified method hook on this object. Default implementation calls the HookManager; AbstractCommandable and its subclasses use their own private hook-lists.

Specified by:
runMethodHook in interface MethodHookable
Parameters:
hookName - the hook to run, e.g. "add", "remove"
data - any data for the method hook

addMethodHook

public void addMethodHook(MethodHookCallback callback,
                          java.lang.String methodName)
Description copied from interface: MethodHookable
Registers for the specified method-hook. Only a select few methods actually have hooks, and there is no checking done to make sure the hook name matches a real method on the target. Be sure to check the documentation for a hookable method to see what the hook name for that method is defined to be.

Specified by:
addMethodHook in interface MethodHookable
Parameters:
methodName - the name of the method to hook into
callback - the MethodHookCallback object to notify on the hook

removeMethodHook

public void removeMethodHook(MethodHookCallback callback,
                             java.lang.String methodName)
Description copied from interface: MethodHookable
Unregisters for the specified method-hook.

Specified by:
removeMethodHook in interface MethodHookable
Parameters:
methodName - the name of the method
callback - the MethodHookCallback object to notify on the hook

makeClone

public BodyPart makeClone()
                   throws java.lang.Exception
Description copied from class: BodyPart
Clones this body part.

Overrides:
makeClone in class BodyPart
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Description copied from class: BodyPart
Prints String rep.

Overrides:
toString in class BodyPart