mdh.hephaestus2
Class Creature

java.lang.Object
  |
  +--mdh.hephaestus2.Stuff
        |
        +--mdh.hephaestus2.Thing
              |
              +--mdh.hephaestus2.Statted
                    |
                    +--mdh.hephaestus2.Entity
                          |
                          +--mdh.hephaestus2.Creature
All Implemented Interfaces:
Serializable

public final class Creature
extends Entity

Any non-player entity, whether friendly or hostile.

Author:
Copyright © 2001 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>
See Also:
Serialized Form

Field Summary
static char BRAIN_Avoid
          Brain types for setBrain()
static char BRAIN_Callback
          Brain types for setBrain()
static char BRAIN_Guard
          Brain types for setBrain()
static char BRAIN_Hunt
          Brain types for setBrain()
static char BRAIN_Program
          Brain types for setBrain()
static char BRAIN_Random
          Brain types for setBrain()
static char BRAIN_Static
          Brain types for setBrain()
static char PROG_East
          Program steps for setBrain("p...")
static char PROG_North
          Program steps for setBrain("p...")
static char PROG_Pause
          Program steps for setBrain("p...")
static char PROG_South
          Program steps for setBrain("p...")
static char PROG_Trigger
          Program steps for setBrain("p...")
static char PROG_West
          Program steps for setBrain("p...")
 
Constructor Summary
Creature(String name)
          Creates a new Creature with the given name.
 
Method Summary
 String getBrain()
          Returns the brain type.
 int getFaction()
          Returns which faction the Entity belongs to.
 int getStep()
          Returns the current step if brain is BRAIN_Program.
 String getThinkCallback()
          Returns the callback to call if brain is BRAIN_Callback.
 int getType()
          Returns the type constant for this object, one of Global.TYPE_*.
 boolean isType(int type)
          Returns true if this class or any of its superclasses is of 'type', one of Global.TYPE_*.
 void output(String iconfile, Color fore, Color back, String text)
          Does nothing for Creatures.
 void setBrain(String b)
          Sets the brain of the creature to one of BRAIN_*.
 void setFaction(int f)
          Sets which faction the Creature belongs to.
 void setStep(int s)
          Sets the current step to execute if brain is BRAIN_Program.
 void setThinkCallback(String t)
          Sets the brain to BRAIN_Callback, and the callback to call every turn to 't'.
 
Methods inherited from class mdh.hephaestus2.Entity
checkAlive, chooseTarget, die, doAttack, doMagic, doMagicAttack, doMove, doMove, doTrigger, getAttackCallback, getAttackName, getDefeatCallback, getExp, getMagic, getNMagic, getTurnCallback, isFriendlyTo, listMagic, listTargets, output, output, playSound, removeMagic, setAttackCallback, setAttackName, setDefeatCallback, setExp, setMagic, setTurnCallback, takeDamage
 
Methods inherited from class mdh.hephaestus2.Statted
calcSecondary, getGold, getStat, getStatMax, setGold, setStat, setStatBoth, setStatMax
 
Methods inherited from class mdh.hephaestus2.Thing
findGrid, findMap, getIconFilename, getNPoses, getOpacity, getPose, getProps, getTile, initProps, loc, moveto, moveto, setFacing, setOpacity, setPose, setTile
 
Methods inherited from class mdh.hephaestus2.Stuff
destroy, getBlocking, getName, getTriggerCallback, id, setBlocking, setName, setTriggerCallback, toString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BRAIN_Guard

public static final char BRAIN_Guard
Brain types for setBrain()

See Also:
Constant Field Values

BRAIN_Static

public static final char BRAIN_Static
Brain types for setBrain()

See Also:
Constant Field Values

BRAIN_Random

public static final char BRAIN_Random
Brain types for setBrain()

See Also:
Constant Field Values

BRAIN_Hunt

public static final char BRAIN_Hunt
Brain types for setBrain()

See Also:
Constant Field Values

BRAIN_Avoid

public static final char BRAIN_Avoid
Brain types for setBrain()

See Also:
Constant Field Values

BRAIN_Program

public static final char BRAIN_Program
Brain types for setBrain()

See Also:
Constant Field Values

BRAIN_Callback

public static final char BRAIN_Callback
Brain types for setBrain()

See Also:
Constant Field Values

PROG_Pause

public static final char PROG_Pause
Program steps for setBrain("p...")

See Also:
Constant Field Values

PROG_North

public static final char PROG_North
Program steps for setBrain("p...")

See Also:
Constant Field Values

PROG_East

public static final char PROG_East
Program steps for setBrain("p...")

See Also:
Constant Field Values

PROG_South

public static final char PROG_South
Program steps for setBrain("p...")

See Also:
Constant Field Values

PROG_West

public static final char PROG_West
Program steps for setBrain("p...")

See Also:
Constant Field Values

PROG_Trigger

public static final char PROG_Trigger
Program steps for setBrain("p...")

See Also:
Constant Field Values
Constructor Detail

Creature

public Creature(String name)
         throws HephaestusException
Creates a new Creature with the given name. This gives the Creature a new unique ID and adds it to the database.

Parameters:
name - Human-readable name to show in descriptions. Names do not have to be unique, but should be kept fairly short so they can fit in menus. Null names are not allowed.
Method Detail

getBrain

public String getBrain()
                throws HephaestusException
Returns the brain type. Char 0 determines which kind of brain:
 "" = no brain: stands still, and doesn't even attack enemies.
 g = guard: stands still but attacks any enemy who approaches.
 s = static: stands still, but attacks any enemy who approaches and becomes
     a hunter.
 r = random: moves around randomly and attacks any enemies in range.
 h = hunt: moves around randomly until it finds an enemy, and then chases
     it down.
 a = avoid: moves around randomly until it finds an enemy, and then runs
     away from it.
 p = programmed: followed by move sequence:
     p = Pause
     n = North
     e = East
     s = South
     w = West
     t = Trigger
     0-9 = Change pose
 c = callback
 

HephaestusException

getFaction

public int getFaction()
               throws HephaestusException
Description copied from class: Entity
Returns which faction the Entity belongs to. Every faction is hostile to every other faction. Faction 0 is the player's faction. Faction -1 is neutral to everyone.

Specified by:
getFaction in class Entity
HephaestusException

getStep

public int getStep()
            throws HephaestusException
Returns the current step if brain is BRAIN_Program.

HephaestusException

getThinkCallback

public String getThinkCallback()
                        throws HephaestusException
Returns the callback to call if brain is BRAIN_Callback. The result of the callback should be MoveResult.MR_Okay if something was done, MR_Blocked if not.

HephaestusException

getType

public int getType()
Description copied from class: Stuff
Returns the type constant for this object, one of Global.TYPE_*.

Specified by:
getType in class Stuff

isType

public boolean isType(int type)
Description copied from class: Stuff
Returns true if this class or any of its superclasses is of 'type', one of Global.TYPE_*.

Overrides:
isType in class Entity

output

public void output(String iconfile,
                   Color fore,
                   Color back,
                   String text)
Does nothing for Creatures.

Overrides:
output in class Entity
See Also:
Game.output(java.lang.String)

setBrain

public void setBrain(String b)
              throws HephaestusException
Sets the brain of the creature to one of BRAIN_*. Use setThinkCallback() for a BRAIN_Callback instead of this method.

HephaestusException

setFaction

public void setFaction(int f)
                throws HephaestusException
Sets which faction the Creature belongs to.

HephaestusException

setStep

public void setStep(int s)
             throws HephaestusException
Sets the current step to execute if brain is BRAIN_Program.

HephaestusException

setThinkCallback

public void setThinkCallback(String t)
                      throws HephaestusException
Sets the brain to BRAIN_Callback, and the callback to call every turn to 't'.

HephaestusException