wyvern.lib.spells.effects
Class Confuser

java.lang.Object
  extended bywyvern.lib.spells.effects.Confuser
All Implemented Interfaces:
Dispellable, HookCallback, Timed

public class Confuser
extends java.lang.Object
implements HookCallback, Timed, Dispellable

When placed on a monster, makes about half the intended moves go the wrong way. The Confuser attaches itself in the target's property list under the property name "@confuser".

Version:
1.0, Nov 26, 1999
Author:
Steve Yegge

Field Summary
static int BUNGLE_CHANCE
           
static int DEFAULT_DURATION
           
protected  int duration_
           
protected  Monster target_
           
protected  Timer timer_
           
 
Constructor Summary
Confuser()
          Constructs a new Confuser, ready to place on the specified monster.
Confuser(Monster target)
          Constructs a new Confuser on the specified monster.
Confuser(Monster target, int duration)
          Constructs a new Confuser
 
Method Summary
 void confuse(Monster target)
          Attaches to, and confuses, the specified target.
 void dispel()
          Stops confusing the target.
 int getDuration()
          Retrieves the total duration for this confusion.
 void hookEvent(java.lang.String hookName, CommandEvent event)
          Chooses a random direction for the target to move.
 void setDuration(int duration)
          Sets the duration for the confusion.
 void timerExpired()
          Time to stop.
 java.lang.String toString()
          Debugging string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

target_

protected Monster target_

timer_

protected Timer timer_

duration_

protected int duration_

BUNGLE_CHANCE

public static final int BUNGLE_CHANCE
See Also:
Constant Field Values

DEFAULT_DURATION

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

Confuser

public Confuser()
Constructs a new Confuser, ready to place on the specified monster.


Confuser

public Confuser(Monster target)
Constructs a new Confuser on the specified monster.

Parameters:
target - the target to confuse

Confuser

public Confuser(Monster target,
                int duration)
Constructs a new Confuser

Parameters:
target - the monster to confuse
duration - the time (in millis) to confuse the target
Method Detail

setDuration

public void setDuration(int duration)
Sets the duration for the confusion. Make sure to call this *before* calling confuse(), or it'll be ignored.

Parameters:
duration - length of time to confuse the target (in millis)

getDuration

public int getDuration()
Retrieves the total duration for this confusion.

Returns:
the total time it'll be active

confuse

public void confuse(Monster target)
Attaches to, and confuses, the specified target. Can only confuse one target at a time, so if it's already confusing another target, it removes itself from the existing target first.

If it finds a previous @confuser on the target, it dispels the old one before adding the new one.

Parameters:
target - the monster to confuse

hookEvent

public void hookEvent(java.lang.String hookName,
                      CommandEvent event)
Chooses a random direction for the target to move.

Specified by:
hookEvent in interface HookCallback
Parameters:
event - the move/push event
hookName - the name of the hook, such as "movePreHook".

timerExpired

public void timerExpired()
Time to stop.

Specified by:
timerExpired in interface Timed

dispel

public void dispel()
Stops confusing the target.

Specified by:
dispel in interface Dispellable

toString

public java.lang.String toString()
Debugging string.