* we can check the slot to see what the stored level was.
* If the player has brought the right number of herbs, get them */
npc.add(ConversationStates.ATTENDING, Arrays.asList("herb", "herbs"),
new AndCondition(
new QuestActiveCondition(QUEST_SLOT),
new NotCondition(new QuestInStateCondition(QUEST_SLOT,"recommended"))),
ConversationStates.ATTENDING, null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
try {
final int level = Integer.parseInt(player.getQuest(QUEST_SLOT));
final int required_arandula = 1
+ level / ARANDULA_DIVISOR;
final int required_antidote = 1
+ level / ANTIDOTE_DIVISOR;
final int required_potion = 1
+ level / POTION_DIVISOR;
if (player.isEquipped("kekik")
&& player.isEquipped("kokuda")
&& player.isEquipped("sclaria")
&& player.isEquipped("arandula",
required_arandula)
&& player.isEquipped("potion", required_potion)
&& player.isEquipped("antidote",
required_antidote))
{
player.drop("kekik");
player.drop("kokuda");
player.drop("sclaria");
player.drop("antidote", required_antidote);
player.drop("potion", required_potion);
player.drop("arandula", required_arandula);
raiser.say("Perfect! I will recommend you to my father, as a fine, " +
"helpful person. He will certainly agree you are eligible for " +
"citizenship of Kalavan.");
player.addXP(level * 400);
player.setQuest(QUEST_SLOT, "recommended");
player.notifyWorldAboutChanges();
} else {
//reminder of the items to bring
raiser.say("Shh! Don't say it till you have the "
+ required_arandula
+ " arandula, 1 #kokuda, 1 #sclaria, 1 #kekik, "
+ required_potion
+ " potions and "
+ required_antidote
+ " antidotes. I don't want anyone suspecting our code.");
}
} catch (final NumberFormatException e) {
// Should not happen but catch the exception
raiser.say("That's strange. I don't understand what has happened just now. " +
"Sorry but I'm all confused, try asking someone else for help.");
}
}
});
/** The player asked about herbs but he brought them already and needs to speak to the King next */
npc.add(ConversationStates.ATTENDING,
Arrays.asList("herb", "herbs"),
new QuestInStateCondition(QUEST_SLOT,"recommended"),
ConversationStates.ATTENDING,
"The herbs you brought did a wonderful job. I told my father you can be trusted, you should " +
"go speak with him now.",
null);