player.setQuest(mithrilcloak.getQuestSlot(), "told_joke;" + Integer.toString(i));
}
// this might have been his favourite joke, which is determined randomly
if (Rand.randUniform(1, 8) == i) {
npc.say("That's the funniest joke I ever heard! I think it's my favourite of the moment. Here, have your needle for free... and then get out of here, You've been here far too long already.");
new EquipItemAction("magical needle", 1, true).fire(player, sentence, npc);
npc.setCurrentState(ConversationStates.IDLE);
// // stop looking through the joke list
return;
} else {
npc.say("*guffaws* Alright, lets get on with business. A magical needle costs "
+ Integer.toString(NEEDLE_COST) + " pieces of money. Do you want to buy one now?");
// stop looking through the joke list
npc.setCurrentState(ConversationStates.QUEST_ITEM_QUESTION);
return;
}
}
}
if (ConversationPhrases.GOODBYE_MESSAGES.contains(sentence.getTriggerExpression().getNormalized())) {
npc.say("Ok, bye then.");
npc.setCurrentState(ConversationStates.IDLE);
} else if (sentence.getTriggerExpression().getNormalized().equals("none")) {
npc.say("Ok, bye.");
npc.setCurrentState(ConversationStates.IDLE);
} else {
npc.say("Sorry, that joke just isn't funny. go back to Nalwor library and get another.");
npc.setCurrentState(ConversationStates.IDLE);
}
}
});
// offer needle when prompted if they already told a joke
npc.add(ConversationStates.ATTENDING,
Arrays.asList("needle", "magical", "magical needle", "ida", "cloak", "mithril cloak", "specials"),
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "told_joke"),
ConversationStates.QUEST_ITEM_QUESTION,
"I have some magical needles but they cost a pretty penny, "
+ Integer.toString(NEEDLE_COST) + " pieces of money to be precise. Do you want to buy one?",
null);
// agrees to buy 1 needle
npc.add(ConversationStates.QUEST_ITEM_QUESTION,
ConversationPhrases.YES_MESSAGES,
new PlayerHasItemWithHimCondition("money", NEEDLE_COST),
ConversationStates.IDLE,
"Ok, here you are. Be careful with them, they break easy. Now, get lost, you have hung around here far too long already.",
new MultipleActions(
new DropItemAction("money", NEEDLE_COST),
new EquipItemAction("magical needle", 1, true)
));
// said he had money but he didn't
npc.add(ConversationStates.QUEST_ITEM_QUESTION,
ConversationPhrases.YES_MESSAGES,