Package games.stendhal.server.entity.npc
Class ConversationBuilder
java.lang.Object
games.stendhal.server.entity.npc.ConversationBuilder
A low level builder for npc interaction. This is designed to be used with
ConditionBuilder.
An example conversation with a response, conditions and a state change:
An example conversation with a response, conditions and a state change:
conversation(actor(npc)
.respondsTo(ConversationPhrases.GREETING_MESSAGES)
.inState(ConversationStates.IDLE)
.saying("I hope you didn't lose your goblet! Do you need another?")
.when(greetingMatchesName(npc.getName())
.and(questInState(QUEST_SLOT, "start"))
.unless(playerCarriesItem("empty goblet")
.or(playerCarriesItem("goblet"))))
.changingStateTo(ConversationStates.QUESTION_1));
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConversationBuilderactor(SpeakerNPC npc) Creates a ConversationBuilder for the specified npc.voidbuild()Generates the conversation state transitions for the npc FSM.changingStateTo(ConversationStates endState) Specify the final state of the npc after the conversation.static voidconversation(ConversationBuilder builder) Generates the conversation for the npc.doing(ChatAction... actions) Specify additional actions for the conversation.inState(ConversationStates state) Specifies an initial state of the NPC for which the conversation is used.inStates(ConversationStates[] states) Specifies multiple initial states of the NPC for which the conversation is used.respondsTo(String trigger) Add a trigger word to which the NPC responds to.respondsTo(Collection<String> triggers) Add multiple trigger words to which the NPC responds to.Specify a verbal reply for the npc.when(ConditionBuilder condition) Specify conditions for the conversation.
-
Method Details
-
actor
Creates a ConversationBuilder for the specified npc.- Parameters:
npc- SpeakerNPC for which the conversation is created- Returns:
- ConversationBuilder for the specified npc
-
inState
Specifies an initial state of the NPC for which the conversation is used. Every conversation must have at least one specified initial state.
If there are no initial states set earlier, this is also used as the end state, unless a state change is specified with#changingStateTo().- Parameters:
state- initial state- Returns:
- the builder itself
-
inStates
Specifies multiple initial states of the NPC for which the conversation is used. Every conversation must have at least one specified initial state.- Parameters:
states-- Returns:
- the builder itself
-
respondsTo
Add a trigger word to which the NPC responds to.- Parameters:
trigger- trigger word- Returns:
- the builder itself
-
respondsTo
Add multiple trigger words to which the NPC responds to.- Parameters:
triggers- trigger words- Returns:
- the builder itself
-
saying
Specify a verbal reply for the npc.- Parameters:
reply-- Returns:
- the builder itself
-
when
Specify conditions for the conversation. Use theConditionBuilderfactory methods in the ChatConditions. This method can be called at most once.- Parameters:
condition- A condition builder for the conditions of the conversation- Returns:
- the builder itself
-
doing
Specify additional actions for the conversation. For readability, use the static factory methods of the actions.- Parameters:
actions-- Returns:
- the builder itself
-
changingStateTo
Specify the final state of the npc after the conversation.- Parameters:
endState-- Returns:
- the builder itself
- See Also:
-
build
public void build()Generates the conversation state transitions for the npc FSM. This is public mainly for the higher level builders. Most conversations made directly with ConversationBuilder should useconversation(ConversationBuilder)instead. -
conversation
Generates the conversation for the npc. This is a convenience wrapper aroundbuild().- Parameters:
builder-
-