Examples of QuestStartedCondition


Examples of games.stendhal.server.entity.npc.condition.QuestStartedCondition

    // player returns while quest is still active
    npc.add(
      ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestStartedCondition(QUEST_SLOT),
          new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "done"))),
      ConversationStates.QUESTION_1,
      "Welcome back! I hope you collected some #ingredients for the fish soup, or #everything.",
      null);

    // player asks what exactly is missing
    npc.add(ConversationStates.QUESTION_1, "ingredients",
      new AndCondition(new QuestStartedCondition(QUEST_SLOT), new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "done"))),
      ConversationStates.QUESTION_1, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final List<String> needed = missingFood(player, true);
          npc.say("I still need "
              + Grammar.quantityplnoun(needed.size(),
                  "ingredient", "one") + ": "
              + Grammar.enumerateCollection(needed)
              + ". Did you bring anything I need?");
        }
      });

    // player says he has a required ingredient with him
    npc.add(ConversationStates.QUESTION_1,
        ConversationPhrases.YES_MESSAGES, null,
        ConversationStates.QUESTION_1, "What did you bring?", null);

    for(final String itemName : NEEDED_FOOD) {
      npc.add(ConversationStates.QUESTION_1, itemName, null,
        ConversationStates.QUESTION_1, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            List<String> missing = missingFood(player, false);

            if (missing.contains(itemName)) {
              if (player.drop(itemName)) {
                // register ingredient as done
                final String doneText = player.getQuest(QUEST_SLOT);
                player.setQuest(QUEST_SLOT, doneText + ";" + itemName);

                // check if the player has brought all Food
                missing = missingFood(player, true);

                if (!missing.isEmpty()) {
                  npc.say("Thank you very much! What else did you bring?");
                } else {
                  player.addKarma(10.0);
                  player.addXP(50);
                  placeSoupFor(player);
                  player.healPoison();
                  npc.say("The soup's on the market table for you. It will heal you. "
                      + "My magical method in making the soup has given you a little karma too.");
                  player.setQuest(QUEST_SLOT, "done;"
                      + System.currentTimeMillis());
                  player.notifyWorldAboutChanges();
                  npc.setCurrentState(ConversationStates.ATTENDING);
                }
              } else {
                npc.say("Oh come on, I don't have time for jokes! You don't have "
                  + Grammar.a_noun(itemName)
                  + " with you.");
              }
            } else {
              npc.say("You brought me that ingredient already.");
            }
          }
        });
    }
   
    // Perhaps player wants to give all the ingredients at once
    npc.add(ConversationStates.QUESTION_1, "everything",
        null,
        ConversationStates.QUESTION_1,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence,
             final EventRaiser npc) {
            checkForAllIngredients(player, npc);
      }
    });

    // player says something which isn't in the needed food list.
    npc.add(ConversationStates.QUESTION_1, "",
      new NotCondition(new TriggerInListCondition(NEEDED_FOOD)),
      ConversationStates.QUESTION_1,
      "I won't put that in your fish soup.", null);

    // allow to say goodbye while Florence is listening for food names
    npc.add(ConversationStates.QUESTION_1, ConversationPhrases.GOODBYE_MESSAGES, null,
        ConversationStates.IDLE, "Bye.", null);

    npc.add(ConversationStates.ATTENDING, ConversationPhrases.NO_MESSAGES,
      new AndCondition(new QuestStartedCondition(QUEST_SLOT), new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "done"))),
      ConversationStates.ATTENDING,
      "I'm not sure what you want from me, then.", null);

    // player says he didn't bring any Food to different question
    npc.add(ConversationStates.QUESTION_1, ConversationPhrases.NO_MESSAGES,
      new AndCondition(new QuestStartedCondition(QUEST_SLOT), new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "done"))),
      ConversationStates.ATTENDING, "Okay then. Come back later.",
      null);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.