protected void createDialog() {
addOffer("Can you keep a secret? Dr. Feelgood, our veterinarian, can sell you medicine that he doesn't need for the animals.");
addJob("I'm the keeper of this animal refuge. I will take care of any abandoned pets I am brought.");
add(ConversationStates.ATTENDING,
ConversationPhrases.HELP_MESSAGES,
new ChatCondition() {
public boolean fire(final Player player, final Sentence sentence,
final Entity engine) {
return player.hasPet();
}
},
ConversationStates.SERVICE_OFFERED, "Have you brought that pet to be taken care of here?",
null);
add(ConversationStates.SERVICE_OFFERED,
ConversationPhrases.YES_MESSAGES, null,
ConversationStates.ATTENDING, null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence,
final EventRaiser npc) {
Pet pet = player.getPet();
String petName = pet.getTitle();
// these numbers are hardcoded, they're the area in the pet sanctuary which is for pets. It has food spawners.
int x = Rand.randUniform(2, 12);
int y = Rand.randUniform(7, 29);
StendhalRPZone zone = SingletonRepository.getRPWorld().getZone(ZONE_NAME);
if (StendhalRPAction.placeat(zone, pet, x, y)) {
player.removePet(pet);
// reward with some karma but limit abuse
if (player.getKarma() < 60.0) {
player.addKarma(30.0);
}
npc.say("Thank you for rescuing this " + petName + ", I will take good care of it. Remember you can come back "
+ "and visit the pet sanctuary any time you like!");
notifyWorldAboutChanges();
} else {
// there was no room for the pet
npc.say("It looks like we don't have any space left in our pet sanctuary! I hope you can look after this " + petName + " a little longer.");
}
}
});
add(ConversationStates.SERVICE_OFFERED,
ConversationPhrases.NO_MESSAGES, null,
ConversationStates.ATTENDING, "Oh, it's so nice to see an owner and their pet happy together. Good luck both of you.", null);
add(ConversationStates.ATTENDING,
ConversationPhrases.HELP_MESSAGES,
new ChatCondition() {
public boolean fire(final Player player, final Sentence sentence,
final Entity engine) {
return !player.hasPet();
}
},