// player didn't get chocolate, meanie
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "start"), new NotCondition(new PlayerHasItemWithHimCondition("chocolate bar"))),
ConversationStates.ATTENDING,
"I hope that someone will bring me some chocolate soon...:(",
null);
// player got chocolate and spoke to mummy
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "mummy"), new PlayerHasItemWithHimCondition("chocolate bar")),
ConversationStates.QUESTION_1,
"Awesome! Is that chocolate for me?",
null);
// player spoke to mummy and hasn't got chocolate
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "mummy"), new NotCondition(new PlayerHasItemWithHimCondition("chocolate bar"))),
ConversationStates.ATTENDING,
"I hope that someone will bring me some chocolate soon...:(",
null);
// player is in another state like eating
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestStartedCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "start"), new QuestNotInStateCondition(QUEST_SLOT, "mummy")),
ConversationStates.ATTENDING,
"Hello.",
null);
// player rejected quest
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "rejected")),
ConversationStates.ATTENDING,
"Hello.",
null);
// player asks about quest for first time (or rejected)
npc.add(ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new QuestNotStartedCondition(QUEST_SLOT),
ConversationStates.QUEST_OFFERED,
"I would really love to have some chocolate. I'd like one bar, please. A dark brown one or a sweet white one or some with flakes. Will you get me one?",
null);
// shouldn't happen
npc.add(ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new QuestCompletedCondition(QUEST_SLOT),
ConversationStates.ATTENDING,
"I still enjoy the last chocolate bar you brought me, thanks!",
null);
// player can repeat quest
npc.add(ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "eating;"), new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES)),
ConversationStates.QUEST_OFFERED,
"I hope another chocolate bar wouldn't be greedy. Can you get me another one?",
null);
// player can't repeat quest
npc.add(ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "eating;"), new NotCondition(new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES))),
ConversationStates.ATTENDING,
"I've had too much chocolate. I feel sick.",
null);
// player should be bringing chocolate not asking about the quest
npc.add(ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new AndCondition(new QuestActiveCondition(QUEST_SLOT), new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "eating;"))),
ConversationStates.ATTENDING,
"Waaaaaaaa! Where is my chocolate ...",
null);
// Player agrees to get the chocolate
npc.add(ConversationStates.QUEST_OFFERED,
ConversationPhrases.YES_MESSAGES,
null,
ConversationStates.ATTENDING,
"Thank you!",
new SetQuestAndModifyKarmaAction(QUEST_SLOT, "start", 10.0));
// Player says no, they've lost karma
npc.add(ConversationStates.QUEST_OFFERED,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.IDLE,
"Ok, I'll wait till mommy finds some helpers...",
new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));
// Player has got chocolate bar and spoken to mummy
final List<ChatAction> reward = new LinkedList<ChatAction>();
reward.add(new DropItemAction("chocolate bar"));
reward.add(new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
// pick a random flower
String rewardClass = Rand.rand(Arrays.asList("daisies","zantedeschia","pansy"));
final StackableItem reward = (StackableItem) SingletonRepository.getEntityManager().getItem(rewardClass);
reward.setQuantity(1);
player.equipOrPutOnGround(reward);
player.notifyWorldAboutChanges();
}
});
reward.add(new IncreaseXPAction(500));
reward.add(new SetQuestAction(QUEST_SLOT, "eating;"));
reward.add(new SetQuestToTimeStampAction(QUEST_SLOT,1));
reward.add(new IncreaseKarmaAction(10.0));
npc.add(ConversationStates.QUESTION_1,
ConversationPhrases.YES_MESSAGES,
new PlayerHasItemWithHimCondition("chocolate bar"),
ConversationStates.ATTENDING,
"Thank you EVER so much! You are very kind. Here, take a fresh flower as a present.",
new MultipleActions(reward));
// player did have chocolate but put it on ground after question?
npc.add(ConversationStates.QUESTION_1,
ConversationPhrases.YES_MESSAGES,
new NotCondition(new PlayerHasItemWithHimCondition("chocolate bar")),
ConversationStates.ATTENDING,
"Hey, where's my chocolate gone?!",
null);
// Player says no, they've lost karma