|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.monsters.RandomMessages
A monster may choose to emit random messages, either during normal operation or during combat, by use of this class.
To use it, put one on the monster like so:
Gragh! Brains! To do a different set of messages for non-combat moves, add another object to the property list under the name "random-msgs" instead of "combat-msgs".If the first line in the bean body is "chance {num}", where num is a percentage chance that the monster will emit a message on that turn, the AI will use this percentage; otherwise it uses the default. At the moment there's no support for any fancier features, such as having the monster emote the message ("Ogre glares at you.") or having different probabilities for each message. You can fake different probabilities to a limited extent by putting more common messages in the list more than once.
If you really need fancier messaging, you have a few options:
Field Summary | |
protected int |
chance_
|
static int |
DEFAULT_CHANCE
The chance a monster will emit a message during combat or when moving, depending on which property this object is stored under on the monster. |
protected java.util.List |
messages_
|
Constructor Summary | |
RandomMessages()
Constructs a new RandomMessages |
Method Summary | |
java.lang.String |
chooseRandomMessage()
Chooses a random message from the list. |
int |
getChance()
Returns the chance the monster will emit a message from this list. |
java.lang.String[] |
getMessages()
Returns the messages in this list. |
int |
getSize()
Returns the number of messages in this list. |
void |
readData(org.w3c.dom.Node bean)
Tells the object to parse its externalized representation from a list of lines. |
boolean |
shouldWrite()
Returns true if we should write the object at all. |
java.util.List |
writeData()
Tells the object to write its properties out to a text file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_CHANCE
protected java.util.List messages_
protected int chance_
Constructor Detail |
public RandomMessages()
Method Detail |
public void readData(org.w3c.dom.Node bean) throws java.lang.Exception
readData
in interface SelfExternalizable
bean
- the XML DOM representation of the externalized
bean object. Its child could be a text node, in which case
the bean has to do all the parsing for the data. It could
also wrap a series of elements (e.g. archetypes), in which case
the bean may wish to leverage the XML parsing utilities that
the game provides in the ArchetypeManager and XMLWrapper.
java.lang.Exception
public java.util.List writeData() throws java.lang.Exception
writeData
in interface SelfExternalizable
java.lang.Exception
public boolean shouldWrite()
shouldWrite
in interface SelfExternalizable
public java.lang.String chooseRandomMessage()
public int getSize()
public int getChance()
public java.lang.String[] getMessages()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |