final SpeakerNPC leander = npcs.get("Leander");
leander.add(ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES, null,
ConversationStates.QUEST_OFFERED, null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
if (player.hasQuest(QUEST_SLOT) && !player.isQuestCompleted(QUEST_SLOT)) {
final String[] questData = player.getQuest(QUEST_SLOT)
.split(";");
final String customerName = questData[0];
if (isDeliveryTooLate(player)) {
// If the player still carries any pizza due for an NPC,
// take it away because the baker is angry,
// and because the player probably won't
// deliver it anymore anyway.
for (final Item pizza : player.getAllEquipped("pizza")) {
if (pizza.getInfoString()!=null) {
player.drop(pizza);
}
}
npc.say("I see you failed to deliver the pizza to "
+ customerName
+ " in time. Are you sure you will be more reliable this time?");
} else {
npc.say("You still have to deliver a pizza to "
+ customerName + ", and hurry!");
npc.setCurrentState(ConversationStates.ATTENDING);
}
} else {
npc.say("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?");
}
}
});
leander.add(ConversationStates.QUEST_OFFERED,
ConversationPhrases.YES_MESSAGES, null,
ConversationStates.ATTENDING, null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
startDelivery(player, npc);
}
});
leander.add(
ConversationStates.QUEST_OFFERED,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.ATTENDING,
"Too bad. I hope my daughter #Sally will soon come back from her camp to help me with the deliveries.",
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
putOffUniform(player);
}
});