wyvern.kernel.combat
Class AbstractAttack

java.lang.Object
  extended bywyvern.kernel.combat.AbstractAttack
All Implemented Interfaces:
Attack, MethodHookable

public abstract class AbstractAttack
extends java.lang.Object
implements Attack, MethodHookable

Utility class for special attacks that want to handle their own effects.

Version:
1.0, Apr 12, 2000
Author:
Steve Yegge

Field Summary
protected  java.util.ArrayList dtypes_
           
protected  int tohit_
           
protected  int wc_
           
 
Constructor Summary
AbstractAttack()
           
 
Method Summary
 void addMethodHook(MethodHookCallback callback, java.lang.String methodName)
          Registers for the specified method-hook.
 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 damage(s) to use against the specified opponent.
 void recomputeWCs()
          If you set any "wc-*" property on the weapon directly, bypassing the setWC() function, you need to call this or the WC won't be recomputed.
 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 specific method hook.
 void setToHit(int tohit)
          Sets the base chance to hit for the weapon, against all attackers.
 void setWC(java.lang.String name, int wc)
          Sets the base weapon-class of this weapon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface wyvern.lib.Attack
getWeaponSkill, setShowAttackerMessage, showAttackerMessage
 

Field Detail

wc_

protected int wc_

tohit_

protected int tohit_

dtypes_

protected java.util.ArrayList dtypes_
Constructor Detail

AbstractAttack

public AbstractAttack()
Method Detail

getWC

public java.util.List getWC(GameObject opponent)
Description copied from interface: Attack
Returns the damage(s) to use against the specified opponent. The default behavior is to ignore the opponent parameter and return a list of the damages this weapon does.

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.

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)
Description copied from interface: Attack
Sets the base weapon-class of this weapon.

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

recomputeWCs

public void recomputeWCs()
Description copied from interface: Attack
If you set any "wc-*" property on the weapon directly, bypassing the setWC() function, you need to call this or the WC won't be recomputed. The WC for a weapon is cached since it's fairly expensive to compute.

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)
Description copied from interface: MethodHookable
Runs the specific method hook.

Specified by:
runMethodHook in interface MethodHookable
Parameters:
hookName - the name of the method, e.g. "add"
data - any data to pass to the callbacks; can be null

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