// could also have used GreaterThanCondition for Quest State but this is okay, note we can only get to question 1 if we were active
npc.add(ConversationStates.QUESTION_1,
ConversationPhrases.YES_MESSAGES,
new AndCondition(new QuestNotInStateCondition(QUEST_SLOT, "1"), new PlayerHasItemWithHimCondition("blue elf cloak")),
ConversationStates.QUESTION_1, null,
new MultipleActions(
new DropItemAction("blue elf cloak"),
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
// find out how many cloaks the player still has to
// bring. incase something has gone wrong and we can't parse the slot, assume it was just started
final int toBring = MathHelper.parseIntDefault(player.getQuest(QUEST_SLOT), REQUIRED_CLOAKS) -1;
player.setQuest(QUEST_SLOT,
Integer.toString(toBring));
raiser.say("Thank you very much! Do you have another one? I still need "
+ Grammar.quantityplnoun(toBring,
"cloak", "one") + ".");
}
}));
// player says he has a blue elf cloak with him and it's the last one
final List<ChatAction> reward = new LinkedList<ChatAction>();
reward.add(new DropItemAction("blue elf cloak"));
reward.add(new EquipItemAction("golden shield", 1, true));
reward.add(new IncreaseXPAction(15000));
reward.add(new SetQuestAction(QUEST_SLOT, "done"));
reward.add(new IncreaseKarmaAction(25));
npc.add(ConversationStates.QUESTION_1,
ConversationPhrases.YES_MESSAGES,
new AndCondition(new QuestInStateCondition(QUEST_SLOT, "1"), new PlayerHasItemWithHimCondition("blue elf cloak")),
ConversationStates.ATTENDING,
"Thank you very much! Now I have enough cloaks to survive the winter. Here, take this golden shield as a reward.",
new MultipleActions(reward));
npc.add(ConversationStates.QUESTION_1,
ConversationPhrases.YES_MESSAGES,
new NotCondition(new PlayerHasItemWithHimCondition("blue elf cloak")),
ConversationStates.ATTENDING,