wyvern.lib
Interface Lair

All Known Implementing Classes:
Generator

public interface Lair

A programmable monster generator.

Lairs have properties you can set to control what monsters they generate, and when. For example, you could put a Lair object under a bridge, and have it generate trolls periodically.

A lair object produces monsters in "batches". It spits out some monsters from the list you've specified, between the min and max numbers you set, and then waits for them to be removed from the list. When a monster dies (or something unusual happens to it, such as being teleported to a non-adjacent map), it is removed from the list. When all the monsters from the batch are removed, the lair sets a reset timer and waits until it expires. Then it starts over again, producing another batch of monsters.

Lair objects need to know when the monsters they've generated have left the area, died, etc., so they can reset. They work together with the monster AIs to figure this stuff out.

Version:
1.0, Sep 08, 1997
Author:
Steve Yegge

Field Summary
static int DEFAULT_HP
          The default number of hit points the generator has.
static int DEFAULT_MAX
          The default maximum number of monsters to generate, per reset.
static int DEFAULT_MIN
          The default minimum number of monsters to generate on reset.
static int DEFAULT_RESET_DELAY
          The default delay (in seconds) between resets; i.e. between the time the last monster is killed and the first new one appears.
static int DEFAULT_SPEED
          The default speed at which the Generator generates monsters, in seconds.
 
Method Summary
 int getMaximum()
          Returns the maximum monsters this lair will generate before stopping.
 int getMinimum()
          Returns the minimum number of monsters the lair will generate on each reset.
 int getResetDelay()
          Gets the time between resets for this lair object.
 int getSpeed()
          Returns the speed at which this object generates monsters.
 java.lang.String getType()
          If this generator is set to generate a specific type of monster, returns that type.
 java.lang.String getTypeList()
          Returns the path to the list of monster types that this lair generates, or null if it generates a single type.
 void remove(GameObject m)
          Removes a monster from the Lair's list.
 void reset()
          Resets the lair, removing all references to its monsters and starting over again.
 void setMaximum(int max)
          Sets the maximum number of monsters this lair will generate before stopping.
 void setMinimum(int minimum)
          Sets the minimum number of monsters to generate.
 void setResetDelay(int delay)
          Sets the time after the last monster croaks before the Lair will spew out more monsters.
 void setSpeed(int speed)
          Sets the speed at which this object generates monsters.
 void setType(java.lang.String type)
          Sets one specific monster type for this lair to produce.
 void setTypeList(java.lang.String path)
          Sets a list of monster types for this lair to generate.
 void setTypes(java.lang.String types)
          Sets a list of monsters to randomly choose from when generating.
 void start()
          Starts the generator.
 

Field Detail

DEFAULT_SPEED

public static final int DEFAULT_SPEED
The default speed at which the Generator generates monsters, in seconds.

See Also:
Constant Field Values

DEFAULT_RESET_DELAY

public static final int DEFAULT_RESET_DELAY
The default delay (in seconds) between resets; i.e. between the time the last monster is killed and the first new one appears.

See Also:
Constant Field Values

DEFAULT_MAX

public static final int DEFAULT_MAX
The default maximum number of monsters to generate, per reset.

See Also:
Constant Field Values

DEFAULT_MIN

public static final int DEFAULT_MIN
The default minimum number of monsters to generate on reset.

See Also:
Constant Field Values

DEFAULT_HP

public static final int DEFAULT_HP
The default number of hit points the generator has.

See Also:
Constant Field Values
Method Detail

setType

public void setType(java.lang.String type)
Sets one specific monster type for this lair to produce. The type is specified in a property called "type".

Parameters:
type - a path to an archetype, or a fully-qualified java classname.

setTypes

public void setTypes(java.lang.String types)
Sets a list of monsters to randomly choose from when generating. Stored in a property called "types".

Parameters:
types - a whitespace-delimited list of archetypes, e.g. "monsters/goblin/kobold monsters/goblin/kobold_lord"

getType

public java.lang.String getType()
If this generator is set to generate a specific type of monster, returns that type. If the generator is set to generate a list of monsters, returns null. The type is specified in a property called "type".

Returns:
the archetype path or fully-qualified java class, or null if we generate a list of monsters.

setTypeList

public void setTypeList(java.lang.String path)
Sets a list of monster types for this lair to generate. The list is specified in a property called "type-list".

Parameters:
path - the relative path to a list of archetypes, e.g. "generator/kobold" (if under world/lists) or "wiz/foobar/mylists/bugbear" if under a wizard directory.

getTypeList

public java.lang.String getTypeList()
Returns the path to the list of monster types that this lair generates, or null if it generates a single type. The list is specified in a property called "type-list".

Returns:
the path to the type list

setSpeed

public void setSpeed(int speed)
Sets the speed at which this object generates monsters.

Parameters:
speed - the number of seconds between each monster generated in a particular batch.

getSpeed

public int getSpeed()
Returns the speed at which this object generates monsters.

Returns:
the speed (in seconds) between generating monsters in a batch.

setResetDelay

public void setResetDelay(int delay)
Sets the time after the last monster croaks before the Lair will spew out more monsters.

Parameters:
delay - the delay (in seconds) between resets. Setting this to zero will cause the lair to start a new batch as soon as the old one is finished.

getResetDelay

public int getResetDelay()
Gets the time between resets for this lair object.

Returns:
the delay, in seconds, between resets

setMaximum

public void setMaximum(int max)
Sets the maximum number of monsters this lair will generate before stopping.

Parameters:
max - the maximum monsters to generate on each reset.

getMaximum

public int getMaximum()
Returns the maximum monsters this lair will generate before stopping.

Returns:
the max number (NO_LIMIT if it just generates forever)

setMinimum

public void setMinimum(int minimum)
Sets the minimum number of monsters to generate. The generator will choose a random number between min and max to generate on this reset. If min and max are the same, it generates that exact number of monsters each time.

Parameters:
minimum - the fewest monsters to create; defaults to 1.

getMinimum

public int getMinimum()
Returns the minimum number of monsters the lair will generate on each reset.

Returns:
the low end of the range (setLimit() sets the high end).

remove

public void remove(GameObject m)
Removes a monster from the Lair's list. Called by a monster AI when a monster dies, but can be used by any code to make the lair object "forget" about a particular monster.


start

public void start()
Starts the generator. Normally you don't have to call this, since it's called automatically from setMap().


reset

public void reset()
Resets the lair, removing all references to its monsters and starting over again.