Package games.stendhal.server.entity.npc.condition

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


    // the player returns to Carena after having started the quest, or found
    // some ghosts.
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestActiveCondition(QUEST_SLOT)),
      ConversationStates.QUESTION_1,
      "If you found any #spirits, please tell me their name.", null);

    for(final String spiritName : NEEDED_SPIRITS) {
      npc.add(ConversationStates.QUESTION_1, spiritName, null,
        ConversationStates.QUESTION_1, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            final String name = spiritName;

            // although all names are stored as lower case from now on,
            // older versions did not,
            // so we have to be compatible with them
            final String npcQuestText = player.getQuest(QUEST_SLOT).toLowerCase();
            final String[] npcDoneText = npcQuestText.split(":");
              final String lookingStr;
              final String saidStr;
            if (npcDoneText.length > 1) {
              lookingStr = npcDoneText[0];
              saidStr = npcDoneText[1];
            } else {
              // compatibility with broken quests
              logger.warn("Player " + player.getTitle() + " found with find_ghosts quest slot in state " + player.getQuest(QUEST_SLOT) + " - now setting this to done.");
              player.setQuest(QUEST_SLOT, "done");
              npc.say("Sorry, it looks like you have already found them after all. I got confused");
              player.notifyWorldAboutChanges();
              npc.setCurrentState(ConversationStates.ATTENDING);
              return;
            }

            final List<String> looking = Arrays.asList(lookingStr.split(";"));
            final List<String> said = Arrays.asList(saidStr.split(";"));
            String reply = "";
            List<String> missing = missingNames(player);
            final boolean isMissing = missing.contains(name);

            if (isMissing && looking.contains(name) && !said.contains(name)) {
              // we haven't said the name yet so we add it to the list
              player.setQuest(QUEST_SLOT, lookingStr
                  + ":" + saidStr + ";" + name);
              reply = "Thank you.";
            } else if (!looking.contains(name)) {
              // we have said it was a valid name but haven't met them
              reply = "I don't believe you've spoken with any spirit of that name.";
            } else if (!isMissing && said.contains(name)) {
              // we have said the name so we are stupid!
              reply = "You've told me that name already, thanks.";
            } else {
              assert false;
            }

            // we may have changed the missing list
            missing = missingNames(player);

            if (!missing.isEmpty()) {
              reply += " If you met any other spirits, please tell me their name.";
              npc.say(reply);
            } else {
              player.setBaseHP(50 + player.getBaseHP());
              player.heal(50, true);
              player.addXP(5000);
              player.addKarma(15);
              reply += " Now that I know those 4 names, perhaps I can even reach the spirits with my mind. I can't give you anything of material value, but I have given you a boost to your basic wellbeing, which will last forever. May you live long, and prosper.";
              npc.say(reply);
              player.setQuest(QUEST_SLOT, "done");
              player.notifyWorldAboutChanges();
              npc.setCurrentState(ConversationStates.ATTENDING);
            }
          }
        });
    }

    final List<String> triggers = new ArrayList<String>();
    triggers.add(ConversationPhrases.NO_EXPRESSION);
    triggers.addAll(ConversationPhrases.GOODBYE_MESSAGES);
    npc.add(ConversationStates.QUESTION_1, triggers, null,
        ConversationStates.IDLE, "No problem, come back later.", null);

    // player says something which isn't in the needed spirits list.
    npc.add(
      ConversationStates.QUESTION_1,
      "",
      new NotCondition(new TriggerInListCondition(NEEDED_SPIRITS)),
      ConversationStates.QUESTION_1,
      "Sorry, I don't understand you. What name are you trying to say?",
      null);

    npc.add(
      ConversationStates.QUESTION_1,
      Arrays.asList("spirits", "spirit"),
      null,
      ConversationStates.QUESTION_1,
      "I seek to know more about other spirits who are dead but stalk the earthly world as ghosts. Please tell me any names you know.",
      null);

    // the player goes to Carena and says hi, and has no quest or is completed.
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new NotCondition(new QuestActiveCondition(QUEST_SLOT))),
        ConversationStates.ATTENDING, "Wooouhhhhhh!",
        null);
  }
View Full Code Here


    // Player asks for quest but is already on it

    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new QuestActiveCondition(QUEST_SLOT),
        ConversationStates.ATTENDING,
        "I hope that you will find my mum soon and tell me, if she is #fine after.",
        null);

    npc.add(
View Full Code Here

        // Player says his greetings to Wrviliza and the quest is running
        npc.add(ConversationStates.IDLE,
            ConversationPhrases.GREETING_MESSAGES,
            new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
                new QuestActiveCondition(QUEST_SLOT)),
            ConversationStates.QUESTION_1,
            "Wrof! Welcome back. Did you gather any #stuff for me?",
            null);

        // Player is curious about artichokes
        npc.add(ConversationStates.ATTENDING,
            Arrays.asList("artichoke","artichokes"),
            new QuestActiveCondition(QUEST_SLOT),
            ConversationStates.ATTENDING,
            "Wrof! Not so common vegetables,"
                + " but I know that there are some being grown outside a farm"
                + " near Semos city.",
            null);

        // Player is curious about fierywater
        npc.add(ConversationStates.ATTENDING,
            Arrays.asList("fierywater"),
            new QuestActiveCondition(QUEST_SLOT),
            ConversationStates.ATTENDING,
            "Wroof! Powerful fluid, that is."
                + " I buy mine in Ados market whenever I got the time to make a trip there.",
            null);

        // Player is curious about herbs
        npc.add(ConversationStates.ATTENDING,
            Arrays.asList("arandula","sclaria","kekik"),
            new QuestActiveCondition(QUEST_SLOT),
            ConversationStates.ATTENDING,
            "Wrof! Common herb that grow outside in the plains or woods... Easy to spot!",
            null);

        // Player is curious about mandragora
        npc.add(ConversationStates.ATTENDING,
            Arrays.asList("mandragora"),
            new QuestActiveCondition(QUEST_SLOT),
            ConversationStates.ATTENDING,
            "Wrof! All I know is that it is rare root that grows better outside in the woods,"
                + " expecially near places soaked with magic..."
                + " Not easy to spot either!",
            null);
View Full Code Here

    /* player returns while quest is still active */
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestActiveCondition(QUEST_SLOT),
            new QuestNotInStateCondition(QUEST_SLOT, "reward")),
        ConversationStates.QUESTION_1,
        "Oh it's you again. Did you bring me any #items for my new crown?",
        null);

    /* player asks what exactly is missing (says items) */
    npc.add(ConversationStates.QUESTION_1, "items", null,
        ConversationStates.QUESTION_1, null,
        new SayRequiredItemsFromCollectionAction(QUEST_SLOT, "I need [items]. Did you bring something?"));
   

    /* player says he has a required item with him (says yes) */
    npc.add(ConversationStates.QUESTION_1,
        ConversationPhrases.YES_MESSAGES, null,
        ConversationStates.QUESTION_1, "Fine, what did you bring?",
        null);

    ChatAction completeAction = new MultipleActions(
                      new SetQuestAction(QUEST_SLOT, "reward"),
                      new SayTextAction("You have served me well, my crown will be the mightiest of them all!"
                      + " Go to see "+ REWARD_NPC_NAME+ " in the Wizard City to get your #reward."),
                      new IncreaseXPAction(XP_REWARD)
                      );
    /* add triggers for the item names */
    final ItemCollection items = new ItemCollection();
    items.addFromQuestStateString(NEEDED_ITEMS);
    for (final Map.Entry<String, Integer> item : items.entrySet()) {
      npc.add(ConversationStates.QUESTION_1, item.getKey(), null,
          ConversationStates.QUESTION_1, null,
          new CollectRequestedItemsAction(
              item.getKey(), QUEST_SLOT,
              "Good, do you have anything else?", "You have already brought that!",
              completeAction, ConversationStates.ATTENDING));
    }

    /* player says he didn't bring any items (says no) */
    npc.add(ConversationStates.ATTENDING, ConversationPhrases.NO_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "reward")),
        ConversationStates.IDLE,
        "Well don't come back before you find something for me!", null);

    /* player says he didn't bring any items to different question */
    npc.add(ConversationStates.QUESTION_1, ConversationPhrases.NO_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "reward")),
        ConversationStates.IDLE,
        "Farewell, come back after you have what I need!", null);


    /* player says reward */
 
View Full Code Here

        null);

    // player should already be getting cloaks
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new QuestActiveCondition(QUEST_SLOT),
        ConversationStates.ATTENDING,
        "You promised me to bring me ten blue elven cloaks. Remember?",
        null);

    // player has already finished the quest
View Full Code Here

    final SpeakerNPC npc = npcs.get("Bario");

    // player returns while quest is still active
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestActiveCondition(QUEST_SLOT)),
        ConversationStates.QUESTION_1, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            raiser.say("Hi again! I still need "
              + player.getQuest(QUEST_SLOT)
View Full Code Here

      "It's okay, then you can excercise a bit more.",
      new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));

    // player asks what exactly is missing
    npc.add(ConversationStates.ATTENDING, "species",
      new QuestActiveCondition(QUEST_SLOT),
      ConversationStates.QUESTION_2, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          final List<String> needed = missingFish(player, true);
          raiser.say("There " + Grammar.isare(needed.size())
View Full Code Here

    // player returns while quest is still active
    npc.add(
      ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestActiveCondition(QUEST_SLOT)),
      ConversationStates.ATTENDING,
      "Welcome back. I hope you were not lazy and that you brought me some other fish #species.",
      null);

    // player returns after finishing the quest
View Full Code Here

            ConversationPhrases.NO_MESSAGES, null,
            ConversationStates.ATTENDING, "OK, no problem.", null);

        add(ConversationStates.ATTENDING,
            Arrays.asList(behaviour.getProductionActivity(), "remind"),
            new QuestActiveCondition(behaviour.getQuestSlot()),
            ConversationStates.ATTENDING, null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            behaviour.giveProduct(npc, player);
          }
View Full Code Here

        null)
   
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(
            new QuestActiveCondition(QUEST_SLOT),
            new NotCondition(new QuestInStateCondition(QUEST_SLOT,"recommended"))),
        ConversationStates.ATTENDING,
        "I'm sure I asked you to do something for me, already.",
        null)
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.condition.QuestActiveCondition

Copyright © 2018 www.massapicom. 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.