wyvern.lib
Interface Attack

All Known Subinterfaces:
CustomAttack, Weapon
All Known Implementing Classes:
AbstractAttack, AttackingBodyPart, DefaultCustomAttack, WeaponImpl

public interface Attack

This interface is shared by things that can be used as attacks.

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

Method Summary
 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.
 java.lang.String getWeaponSkill()
          Returns the weapon skill that gives the user proficiency in this weapon, e.g.
 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 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(java.lang.String name, int wc)
          Sets the base weapon-class of this weapon.
 boolean showAttackerMessage()
          Returns true if we show the attacker message.
 

Method Detail

getWC

public java.util.List getWC(GameObject opponent)
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.

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.

setWC

public void setWC(java.lang.String name,
                  int wc)
Sets the base weapon-class of this weapon.

Parameters:
wc - the new base wc for the weapon
name - the damage type, e.g. "cut", "smash", "fire".

recomputeWCs

public 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. The WC for a weapon is cached since it's fairly expensive to compute.


getToHit

public int getToHit()
Returns the base chance to hit for the weapon, against all attackers.

Returns:
the weapon's base chance to hit

setToHit

public void setToHit(int tohit)
Sets the base chance to hit for the weapon, against all attackers.

Parameters:
tohit - the weapon's base chance to hit

didDamage

public void didDamage(DamageEvent event)
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.

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.

getWeaponSkill

public java.lang.String getWeaponSkill()
Returns the weapon skill that gives the user proficiency in this weapon, e.g. "sk-hurled", "sk-sword".


showAttackerMessage

public boolean showAttackerMessage()
Returns true if we show the attacker message.

Returns:
true, by default (subclass can override.)

setShowAttackerMessage

public void setShowAttackerMessage(boolean show)
Toggles showing the attacker message for the damage event.

Parameters:
show - true to show the attacker message, false to hide it.