player.notifyWorldAboutChanges();
}
}
}
final ProducerBehaviour behaviour = new SpecialProducerBehaviour("make", "silk thread",
requiredResources, REQUIRED_MINUTES_THREAD);
npc.add(ConversationStates.ATTENDING,
"make",
new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_fabric"), ConversationStates.ATTENDING, null,
new ProducerBehaviourAction(behaviour) {
@Override
public void fireRequestOK(final ItemParserResult res, Player player, Sentence sentence, EventRaiser npc) {
// Find out how much items we shall produce.
if (res.getAmount() < 40) {
npc.say("Do you really want so few? I'm not wasting my time with that! Any decent sized pieces of fabric needs at least 40 spools of thread! You should at least #make #40.");
return;
} else if (res.getAmount() > 1000) {
/*logger.warn("Decreasing very large amount of "
* + behaviour.getAmount()
* + " " + behaviour.getChosenItemName()
* + " to 40 for player "
* + player.getName() + " talking to "
* + npc.getName() + " saying " + sentence);
*/
res.setAmount(40);
}
if (behaviour.askForResources(res, npc, player)) {
currentBehavRes = res;
npc.setCurrentState(ConversationStates.PRODUCTION_OFFERED);
}
}
@Override
public void fireRequestError(final ItemParserResult res, final Player player, final Sentence sentence, final EventRaiser raiser) {
raiser.say(behaviour.getErrormessage(res, "#make", "produce"));
}
});
npc.add(ConversationStates.PRODUCTION_OFFERED,
ConversationPhrases.YES_MESSAGES, null,
ConversationStates.ATTENDING, null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
behaviour.transactAgreedDeal(currentBehavRes, npc, player);
currentBehavRes = null;
}
});
npc.add(ConversationStates.PRODUCTION_OFFERED,
ConversationPhrases.NO_MESSAGES, null,
ConversationStates.ATTENDING, "OK, no problem.", null);
npc.add(ConversationStates.ATTENDING,
behaviour.getProductionActivity(),
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;"),
ConversationStates.ATTENDING, null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence,
final EventRaiser npc) {
npc.say("I still haven't finished your last order!");
}
});
// player returns and says hi while sacs being made
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;")),
ConversationStates.ATTENDING, null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence,
final EventRaiser npc) {
behaviour.giveProduct(npc, player);
}
});
// player returns and doesn't need fabric and sacs not being made
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,