wyvern.lib.properties
Class QuestInfo

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.lib.properties.ProximityProperty
          extended bywyvern.lib.properties.QuestInfo
All Implemented Interfaces:
AddRemoveNotify, java.util.EventListener, MapChangeListener, MutableProperty, PropertyList, ProximityCallback

public class QuestInfo
extends ProximityProperty

Lets a monster or NPC be part of a quest. The NPC will give you something, do something, or say something, if you give them the right item or say the right passphrase. The configuration properties are all required unless otherwise specified.

The NPC with a QuestInfo object can be "activated" by a phrase the player says, an item the player gives, or both. Activating the NPC can do one of four things: say a message, give a gift, perform a command, and/or solve a quest.

Activation properties: (note that they're all optional, but you have to either set "item-id", "item-arch", or "password" for the NPC to have a way to be activated.

Action properties: Things the NPC can do, on activation, that aren't related to solving a quest.

Quest Properties - properties for having the player solve a quest when the NPC is activated.

Version:
1.0, Aug 15, 2002
Author:
Steve Yegge

Field Summary
static java.lang.String[] hookNames_
           
static Rectangle proxRect_
           
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Constructor Summary
QuestInfo()
          Constructs a new QuestInfo
 
Method Summary
 void activate(Player agent, GameObject item)
          Performs our post-activation actions: gives presents, optionally solves a quest, and performs any commands.
 java.lang.String getActivationMsg()
          Returns the activation message, in "activation-msg" property.
 java.lang.String getGiftArch()
          Returns "gift-arch" string property: optional item to give player when activated.
 java.lang.String getGiftMsg()
          Returns the "gift-msg": the message to print when giving a present to the player.
 int getGiveCount()
          Returns value of the give-count int property.
 java.lang.String[] getHookNames()
          Returns the hooks we're registered on ("givePostHook", etc.)
 java.lang.String getItemArch()
          Returns the item that the NPC must receive to be activated.
 java.lang.String getItemID()
          Returns the "item-id" property - the optional unique identifier for the item to activate the NPC.
 java.lang.String getLongName()
          Returns quest long-name, in "long-name" property.
 java.lang.String getNoMapMsg()
          Returns string property "no-map-msg": what to say if NPC is in wrong map when activated.
 java.lang.String getPassword()
          Returns the string stored in the "password" property.
 java.lang.String getPerformCommand()
          Returns "perform-cmd" property.
 int getPerformCount()
          Returns perform-count property.
 Rectangle getProximityRect()
           
 int getQP()
          Returns number of quest points to give
 java.lang.String getQuestPath()
          Returns "quest-path" string property: where the NPC has to be in order for activation to work.
 java.lang.String getShortName()
          Returns quest short-name, in "short-name" property.
 boolean getShoutOnSolve()
          Returns whether to shout on solving the quest.
 java.lang.String getSolveMsg()
          Returns message to pring when solving the quest.
 java.lang.String getWrongItemMsg()
          Returns the wrong-item message, in "wrong-item-msg" property.
 void giveGifts(Monster agent)
          Handles giving the player a present on activation.
 void handleGive(CommandEvent event)
          Handles giving the NPC something.
 void handleSay(java.lang.String hookName, CommandEvent event)
          Handles a player saying something near the NPC.
 void hookEvent(java.lang.String hookName, GameObject npc, CommandEvent event)
          The desired event has taken place within the specified range of the target that was passed to GameMap.addProximityHook().
 boolean isCaseSensitive()
          Returns true if the password is case-sensitive.
 boolean keepItem()
          Returns true if we keep the item after receiving it.
 java.lang.String mangleMessage(java.lang.String msg, Monster player, Monster speaker)
          Replaces %t and %n in the message.
 void performCommands()
          Performs any commands we might be required to do.
 void setActivationMsg(java.lang.String msg)
          Sets activation-msg property.
 void setCaseSensitive(boolean sensitive)
          Sets the case-sensitive property.
 void setGiftArch(java.lang.String arch)
          Sets "gift-arch" property.
 void setGiftMsg(java.lang.String msg)
          Sets "gift-msg" property.
 void setGiveCount(int count)
          Sets "give-count" property.
 void setItemArch(java.lang.String arch)
          Sets item-arch property.
 void setItemID(java.lang.String id)
          Sets item-id property.
 void setKeepItem(boolean keep)
          Sets "keep-item" property.
 void setLongName(java.lang.String name)
          Sets quest long-name.
 void setNoMapMsg(java.lang.String msg)
          Sets "no-map-msg" property.
 void setPassword(java.lang.String password)
          Sets password
 void setPerformCommand(java.lang.String cmd)
          Sets the "perform-cmd" property.
 void setPerformCount(int count)
          Sets "perform-count" property.
 void setQP(int qp)
          Sets "qp" property.
 void setQuestPath(java.lang.String path)
          Sets quest-path property.
 void setShortName(java.lang.String name)
          Sets quest short name.
 void setShoutOnSolve(boolean shout)
          Sets shout-on-solve property.
 void setSolveMsg(java.lang.String msg)
          Sets solve-msg property.
 void setSolvesQuest(boolean solves)
          Sets "solves-quest" property.
 void setWrongItemMsg(java.lang.String msg)
          Sets wrong-item-msg property.
 boolean solveQuest(Commandable c, GameObject questItem)
          Solves the quest (maybe).
 boolean solvesQuest()
          Returns true if the NPC is a quest-solver.
 java.lang.String toString()
          Returns a debugging string.
 
Methods inherited from class wyvern.lib.properties.ProximityProperty
createClone, getTarget, notifyAdd, notifyRemove, targetEnteredMap, targetLeftMap
 
Methods inherited from class wyvern.kernel.properties.PList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, debugProperties, dismantlePropertyList, getDoubleProperty, getInheritedProperty, getInteger, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProfilingInfo, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

proxRect_

public static Rectangle proxRect_

hookNames_

public static java.lang.String[] hookNames_
Constructor Detail

QuestInfo

public QuestInfo()
Constructs a new QuestInfo

Method Detail

getHookNames

public java.lang.String[] getHookNames()
Returns the hooks we're registered on ("givePostHook", etc.)

Specified by:
getHookNames in class ProximityProperty

getProximityRect

public Rectangle getProximityRect()
Specified by:
getProximityRect in class ProximityProperty

hookEvent

public void hookEvent(java.lang.String hookName,
                      GameObject npc,
                      CommandEvent event)
The desired event has taken place within the specified range of the target that was passed to GameMap.addProximityHook().

Specified by:
hookEvent in interface ProximityCallback
Specified by:
hookEvent in class ProximityProperty
Parameters:
hookName - the name of the hook (e.g. "sayPostHook") that's being run.
npc - the object near which the event took place.
event - the event

handleGive

public void handleGive(CommandEvent event)
Handles giving the NPC something. Called on the givePostHook.


handleSay

public void handleSay(java.lang.String hookName,
                      CommandEvent event)
Handles a player saying something near the NPC. Called on the sayPostHook.

Parameters:
hookName - sayPostHook or talkPostHook
event - the say evetn

activate

public void activate(Player agent,
                     GameObject item)
Performs our post-activation actions: gives presents, optionally solves a quest, and performs any commands.

Parameters:
agent - the player who activated the NPC
item - the item that was given to solves the quest - can be null if the quest was voice-activated

giveGifts

public void giveGifts(Monster agent)
Handles giving the player a present on activation.

Parameters:
agent - the player to give the item to

performCommands

public void performCommands()
Performs any commands we might be required to do.


solveQuest

public boolean solveQuest(Commandable c,
                          GameObject questItem)
Solves the quest (maybe).

Returns:
true if the player solved the quest

toString

public java.lang.String toString()
Returns a debugging string.

Overrides:
toString in class PList
Returns:
a debugging string

getShortName

public java.lang.String getShortName()
Returns quest short-name, in "short-name" property.


getLongName

public java.lang.String getLongName()
Returns quest long-name, in "long-name" property.


getItemID

public java.lang.String getItemID()
Returns the "item-id" property - the optional unique identifier for the item to activate the NPC.


getWrongItemMsg

public java.lang.String getWrongItemMsg()
Returns the wrong-item message, in "wrong-item-msg" property.


getActivationMsg

public java.lang.String getActivationMsg()
Returns the activation message, in "activation-msg" property.


getQuestPath

public java.lang.String getQuestPath()
Returns "quest-path" string property: where the NPC has to be in order for activation to work.


getNoMapMsg

public java.lang.String getNoMapMsg()
Returns string property "no-map-msg": what to say if NPC is in wrong map when activated.


getSolveMsg

public java.lang.String getSolveMsg()
Returns message to pring when solving the quest.


getShoutOnSolve

public boolean getShoutOnSolve()
Returns whether to shout on solving the quest.


getQP

public int getQP()
Returns number of quest points to give.;


getGiftArch

public java.lang.String getGiftArch()
Returns "gift-arch" string property: optional item to give player when activated.


getGiftMsg

public java.lang.String getGiftMsg()
Returns the "gift-msg": the message to print when giving a present to the player.


getPerformCommand

public java.lang.String getPerformCommand()
Returns "perform-cmd" property.


getPerformCount

public int getPerformCount()
Returns perform-count property.


getGiveCount

public int getGiveCount()
Returns value of the give-count int property.


getItemArch

public java.lang.String getItemArch()
Returns the item that the NPC must receive to be activated.


getPassword

public java.lang.String getPassword()
Returns the string stored in the "password" property.


isCaseSensitive

public boolean isCaseSensitive()
Returns true if the password is case-sensitive.


solvesQuest

public boolean solvesQuest()
Returns true if the NPC is a quest-solver.


keepItem

public boolean keepItem()
Returns true if we keep the item after receiving it.


setPassword

public void setPassword(java.lang.String password)
Sets password


setShortName

public void setShortName(java.lang.String name)
Sets quest short name.


setLongName

public void setLongName(java.lang.String name)
Sets quest long-name.


setItemID

public void setItemID(java.lang.String id)
Sets item-id property.


setWrongItemMsg

public void setWrongItemMsg(java.lang.String msg)
Sets wrong-item-msg property.


setActivationMsg

public void setActivationMsg(java.lang.String msg)
Sets activation-msg property.


setQuestPath

public void setQuestPath(java.lang.String path)
Sets quest-path property.


setNoMapMsg

public void setNoMapMsg(java.lang.String msg)
Sets "no-map-msg" property.


setSolveMsg

public void setSolveMsg(java.lang.String msg)
Sets solve-msg property.


setShoutOnSolve

public void setShoutOnSolve(boolean shout)
Sets shout-on-solve property.


setQP

public void setQP(int qp)
Sets "qp" property.


setGiftArch

public void setGiftArch(java.lang.String arch)
Sets "gift-arch" property.


setGiftMsg

public void setGiftMsg(java.lang.String msg)
Sets "gift-msg" property.


setPerformCommand

public void setPerformCommand(java.lang.String cmd)
Sets the "perform-cmd" property.


setPerformCount

public void setPerformCount(int count)
Sets "perform-count" property.


setGiveCount

public void setGiveCount(int count)
Sets "give-count" property.


setItemArch

public void setItemArch(java.lang.String arch)
Sets item-arch property.


setCaseSensitive

public void setCaseSensitive(boolean sensitive)
Sets the case-sensitive property.


setSolvesQuest

public void setSolvesQuest(boolean solves)
Sets "solves-quest" property.


setKeepItem

public void setKeepItem(boolean keep)
Sets "keep-item" property.


mangleMessage

public java.lang.String mangleMessage(java.lang.String msg,
                                      Monster player,
                                      Monster speaker)
Replaces %t and %n in the message.

Parameters:
speaker - the monster saying the message
msg - the message
player - the player to say it to