npc.add(ConversationStates.ATTENDING,
Arrays.asList("scissors", "magical", "magical scissors", "ida", "mithril", "cloak", "mithril cloak"),
new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_scissors"),
ConversationStates.ATTENDING,
null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
final int neededEggshells = Rand.randUniform(2, 4);
raiser.say("Ah yes, Ida sent me a message about some magical scissors. I need one each of an iron bar and a mithril bar, and also " + Integer.toString(neededEggshells) + " magical #eggshells. Ask me about #scissors again when you return with those items.");
// store the number of needed eggshells in the quest slot so he remembers how many he asked for
player.setQuest(mithrilcloak.getQuestSlot(), "need_eggshells;" + Integer.toString(neededEggshells));
}
});
// player needs eggshells
npc.add(ConversationStates.ATTENDING,
Arrays.asList("scissors", "magical", "magical scissors", "ida", "mithril", "cloak", "mithril cloak"),
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "need_eggshells"),
ConversationStates.SERVICE_OFFERED,
"So, did you bring the items I need for the magical scissors?", null);
// player asks about eggshells, hint to find terry
npc.add(
ConversationStates.ATTENDING,
"eggshells",
null,
ConversationStates.ATTENDING,
"They must be from dragon eggs. I guess you better find someone who dares to hatch dragons!",
null);
// player says yes they brought the items needed
// we can't use the nice ChatActions here because the needed number is stored in the quest slot i.e. we need a fire
npc.add(
ConversationStates.SERVICE_OFFERED,
ConversationPhrases.YES_MESSAGES,
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "need_eggshells"),
ConversationStates.ATTENDING,
null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
final String[] questslot = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
final int neededEggshells = Integer.valueOf(questslot[1]);
if (player.isEquipped("iron")
&& player.isEquipped("mithril bar")
&& player.isEquipped("magical eggshells", neededEggshells)) {
player.drop("iron");
player.drop("mithril bar");
player.drop("magical eggshells", neededEggshells);
npc.say("Good. It will take me some time to make these, come back in "
+ REQUIRED_MINUTES_SCISSORS + " minutes to get your scissors.");
player.addXP(100);
player.setQuest(mithrilcloak.getQuestSlot(), "makingscissors;" + System.currentTimeMillis());
player.notifyWorldAboutChanges();
} else {
npc.say("Liar, you don't have everything I need. Ask me about #scissors again when you have an iron bar, a mithril bar, and "
+ questslot[1] + " magical eggshells. And don't be wasting my time!");
}
}
});
// player says they didn't bring the stuff yet
npc.add(
ConversationStates.SERVICE_OFFERED,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.ATTENDING,
"What are you still here for then? Go get them!",
null);
// player returns while hogart is making scissors or has made them
npc.add(ConversationStates.ATTENDING,
Arrays.asList("scissors", "magical", "magical scissors", "ida", "mithril", "cloak", "mithril cloak"),
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingscissors;"),
ConversationStates.ATTENDING, null, new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
final String[] tokens = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
// minutes -> milliseconds
final long delay = REQUIRED_MINUTES_SCISSORS * MathHelper.MILLISECONDS_IN_ONE_MINUTE;
final long timeRemaining = (Long.parseLong(tokens[1]) + delay)