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

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


          new SetQuestAction(QUEST_SLOT, 0, "kill_scientist"),
          new StartRecordingKillsAction(QUEST_SLOT, 1, "Sergej Elos", 0, 1),
          new DropItemAction("note")
        );
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()), condition),
        ConversationStates.INFORMATION_2,
        "Hello! Do you have anything for me?",
        null);
   
    npc.add(ConversationStates.INFORMATION_2, Arrays.asList("letter", "yes", "note"),
View Full Code Here


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

    // 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

  private void step_1() {
    final SpeakerNPC npc = npcs.get("Hunel");

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestCompletedCondition(QUEST_SLOT)),
        ConversationStates.ATTENDING,
        "Hi. As you see, I am still too nervous to leave ...",
        null);

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestNotCompletedCondition(QUEST_SLOT),
            new NotCondition(new PlayerHasItemWithHimCondition("kanmararn prison key"))),
        ConversationStates.IDLE,
        "Help! The duergars have raided the prison and locked me up! I'm supposed to be the Guard! It's a shambles.",
        new SetQuestAction(QUEST_SLOT, "start"));

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestNotCompletedCondition(QUEST_SLOT),
            new PlayerHasItemWithHimCondition("kanmararn prison key")),
        ConversationStates.ATTENDING,
        "You got the key to unlock me! *mumble*  Errrr ... it doesn't look too safe out there for me ... I think I'll just stay here ... perhaps someone could #offer me some good equipment ... ",
        new MultipleActions(new SetQuestAction(QUEST_SLOT, "done"),
View Full Code Here

        null);

    //player returns to Hayunn not having killed a rat
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, 0, "start"),
            new NotCondition(new KilledForQuestCondition(QUEST_SLOT,1))),
        ConversationStates.ATTENDING,
        "I see you haven't managed to kill a rat yet. Do you need me to tell you how to fight them?",
        null);

    //player returns to Hayunn having killed a rat
    final List<ChatAction> actions = new LinkedList<ChatAction>();
    actions.add(new IncreaseXPAction(10));
    actions.add(new SetQuestAction(QUEST_SLOT, "killed"));

    npc.add(
        ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, 0, "start"),
            new KilledForQuestCondition(QUEST_SLOT, 1)),
        ConversationStates.INFORMATION_1,
        "You killed the rat! Now, I guess you want to explore. Do you want to know the way to Semos?",
        new MultipleActions(actions));


       // The player has had enough info for now. Send them to semos. When they come back they can learn some more tips.

    final List<ChatAction> reward = new LinkedList<ChatAction>();
    reward.add(new EquipItemAction("money", 5));
    reward.add(new IncreaseXPAction(10));
    reward.add(new SetQuestAction(QUEST_SLOT, "taught"));
    reward.add(new ExamineChatAction("monogenes.png", "Monogenes", "North part of Semos city."));

    npc.add(
      ConversationStates.INFORMATION_1,
      ConversationPhrases.YES_MESSAGES,
      null,
      ConversationStates.IDLE,
      "Follow the path through this village to the east, and you can't miss Semos. If you go and speak to Monogenes, the old man in this picture, he will give you a map. Here's 5 money to get you started. Bye bye!",
      new MultipleActions(reward));

       // incase player didn't finish learning everything when he came after killing the rat, he must have another chance. Here it is.
    // 'little tip' is a pun as he gives some money, that is a tip, too.
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "killed")),
        ConversationStates.INFORMATION_1,
            "You ran off pretty fast after coming to tell me you killed that rat! I was about to give you a little tip. Do you want it?",
        null);
   
    // Player has returned to say hi again.
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "taught")),
        ConversationStates.INFORMATION_2,
            "Hello again. Have you come to learn more from me?",
        null);
View Full Code Here

        // Player sends his greetings and never asked for a quest is handled in NPC class

        // Player sends his greetings to Wrviliza and has rejected the quest in the past
        npc.add(ConversationStates.IDLE,
            ConversationPhrases.GREETING_MESSAGES,
            new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
                new QuestInStateCondition(QUEST_SLOT, "rejected")),
            ConversationStates.QUEST_OFFERED,
            "Wroff! Welcome back wanderer... Are you back to help me gather #stuff to make good #torcibud this time?",
            null);
View Full Code Here

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

        // 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);
View Full Code Here

    npc.addJob("My current job is unimportant, I will be the king of Kalavan!");

    /* player says hi before starting the quest */
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestNotStartedCondition(QUEST_SLOT)),
        ConversationStates.ATTENDING,
        "Greetings. Be quick with your matters, I have a lot of work to do."
          + " And next time clean your boots, you are lucky that I'm not the king...yet!",
        null);
View Full Code Here

    final SpeakerNPC npc = npcs.get(NPC_NAME);

    /* 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 */
    npc.add(ConversationStates.ATTENDING,
        "reward", null,
        ConversationStates.IDLE, "As I said, find priestess " + REWARD_NPC_NAME
          + " in a temple at the city of wizards. She will give you your reward. Now go, I'm busy!",
        null);

    /*
     * player returns after finishing the quest or before collecting the
     * reward
     */
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new OrCondition(
                new QuestCompletedCondition(QUEST_SLOT),
                new QuestInStateCondition(QUEST_SLOT, "reward"))),
        ConversationStates.IDLE,
        "My new crown will be ready soon and I will dethrone the king! Mwahahaha!",
View Full Code Here

    // player says hi before starting the quest
    npc.add(
        ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestNotStartedCondition(QUEST_SLOT)),
        ConversationStates.ATTENDING,
        "Hey! How did you get down here? You did what? Huh. Well, I'm Bario. I don't suppose you could do a #task for me?",
        null);
View Full Code Here

  private void step_3() {
    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)
              + " blue elven "
              + Grammar.plnoun(
                  MathHelper.parseInt(player.getQuest(QUEST_SLOT)),
                  "cloak") + ". Do you have any for me?");
          }
        });

    // player returns after finishing the quest
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestCompletedCondition(QUEST_SLOT)),
        ConversationStates.ATTENDING,
        "Welcome! Thanks again for those cloaks.", null);

    // player says he doesn't have any blue elf cloaks with him
View Full Code Here

TOP

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

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.