wyvern.lib.monsters
Class DefaultCustomAttack

java.lang.Object
  extended bywyvern.lib.monsters.DefaultCustomAttack
All Implemented Interfaces:
Attack, CustomAttack
Direct Known Subclasses:
DrainAttack, ExplodeAndBlind, RustAttack, StealAttack

public abstract class DefaultCustomAttack
extends java.lang.Object
implements CustomAttack

Abstract base class for CustomAttack implementations that don't want to implement all the methods of the Attack interface.

Version:
1.0, May 20, 2002
Author:
Steve Yegge

Field Summary
static int DEFAULT_HIT_CHANCE
           
 
Constructor Summary
DefaultCustomAttack()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface wyvern.kernel.combat.CustomAttack
performDamage
 

Field Detail

DEFAULT_HIT_CHANCE

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

DefaultCustomAttack

public DefaultCustomAttack()
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.

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

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

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.

getWeaponSkill

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

Specified by:
getWeaponSkill in interface Attack

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.)