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

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


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

    // player says hi before starting the quest
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
              return !player.hasQuest(QUEST_SLOT) && player.isQuestCompleted(OLD_QUEST);
            }
          }),
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.QUESTION_2,
        "Welcome back! Have you brought any #cloaks with you?", null);
    // player asks what exactly is missing
    npc.add(ConversationStates.QUESTION_2,
        "cloaks",
        null,
        ConversationStates.QUESTION_2,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser entity) {
            final List<String> needed2 = missingcloaks2(player, true);
            entity.say("I want "
                + Grammar.quantityplnoun(needed2.size(), "cloak", "a")
                + ". That's "
                + Grammar.enumerateCollection(needed2)
                + ". Did you bring any?");
          }

          @Override
          public String toString() {
            return "enumerate missingcloaks2";
          }
        });
    // player says he has a required cloak with him
    npc.add(ConversationStates.QUESTION_2,
        ConversationPhrases.YES_MESSAGES,
        null,
        ConversationStates.QUESTION_2,
        "Woo! What #cloaks did you bring?",
        null);

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

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

                // check if the player has brought all cloaks
                missing = missingcloaks2(player, true);

                if (missing.isEmpty()) {
                  rewardPlayer(player);
                  entity.say("Oh, yay! You're so kind, I bet you'll have great Karma now! Here, take these killer boots. I think they're gorgeous but they don't fit me!");
                  player.setQuest(QUEST_SLOT, "done;rewarded");
                  final Item boots = SingletonRepository.getEntityManager().getItem("killer boots");
                  boots.setBoundTo(player.getName());
                  player.equipOrPutOnGround(boots);
                  player.notifyWorldAboutChanges();
                  entity.setCurrentState(ConversationStates.ATTENDING);
                } else {
                  entity.say("Wow, thank you! What else did you bring?");
                }
              } else {
                entity.say("Oh, I'm disappointed. You don't really have "
                        + Grammar.a_noun(itemName)
                        + " with you.");
              }
            } else {
              entity.say("You're terribly forgetful, you already brought that one to me.");
            }
          }

          @Override
          public String toString() {
            return "answer neededcloaks2";
          }
      });
    }

    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.NO_MESSAGES,
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
            return !player.isQuestCompleted(QUEST_SLOT);
          }
        },
        ConversationStates.ATTENDING,
        "Ok. If you want help, just say.",
        null);

    // player says he didn't bring any cloaks to different question
    npc.add(ConversationStates.QUESTION_2,
        ConversationPhrases.NO_MESSAGES,
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
            return !player.isQuestCompleted(QUEST_SLOT);
          }
        }, ConversationStates.ATTENDING, "Okay then. Come back later.",
        null);

    // player returns after finishing the quest but not rewarded
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "done")),
        ConversationStates.ATTENDING,
        "Oh! I didn't reward you for helping me again! Here, take these boots. I think they're gorgeous but they don't fit me :(",
        new MultipleActions(new EquipItemAction("killer boots", 1, true), new SetQuestAction(QUEST_SLOT, "done;rewarded")));
 
    //     player returns after finishing the quest and was rewarded
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "done;rewarded")),
        ConversationStates.ATTENDING,
        "Thanks again for helping me! The cloaks look great!",
        null);
  }
View Full Code Here

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

        // Player has never done the zoo quest
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestNotStartedCondition(QUEST_SLOT)),
        ConversationStates.ATTENDING,
        "Welcome to the Ados Wildlife Refuge! We rescue animals from being slaughtered by evil adventurers. But we need help... maybe you could do a #task for us?",
        null
    );

        // Player returns within one week of completing quest
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestCompletedCondition(QUEST_SLOT),
            new NotCondition(new TimePassedCondition(QUEST_SLOT, 1, DELAY))),
        ConversationStates.ATTENDING, "Welcome back to the Ados Wildlife Refuge! Thanks again for rescuing our animals!",
        null
    );

        // Player returns and longer than a week has passed, ask to help again
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestCompletedCondition(QUEST_SLOT),
            new TimePassedCondition(QUEST_SLOT, 1, DELAY)),
        ConversationStates.QUEST_OFFERED, "Welcome back to the Ados Wildlife "
                + "Refuge! Our animals are hungry again, can you bring some more food please?",
                null);
View Full Code Here

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

    // compatibility with old quests:
    // player returns while initial quest is still active, set it to match the new way
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "start")),
        ConversationStates.QUEST_ITEM_BROUGHT,
        "Welcome back! Have you brought the "
            + Grammar.quantityplnoun(REQUIRED_HAM, "ham", "") + "?",
      new SetQuestAction(QUEST_SLOT,"start;ham=10"));

    // player returns while quest is active
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT, "start;")),
        ConversationStates.QUEST_ITEM_BROUGHT,
        null,
        new SayRequiredItemAction(QUEST_SLOT, 1, "Welcome back! Have you brought the [item]?"));
View Full Code Here

  private void step_4() {
    final SpeakerNPC npc = npcs.get("Dr. Feelgood");

    // player returns while quest is still active
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestCompletedCondition(QUEST_SLOT),
            new NotCondition(new TimePassedCondition(QUEST_SLOT, 1, DELAY))),
      ConversationStates.ATTENDING, "Hello! Now that the animals have enough food, they don't get sick that easily, and I have time for other things. How can I help you?",
        null
    );

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new OrCondition(new QuestNotCompletedCondition(QUEST_SLOT),
                new AndCondition(new QuestCompletedCondition(QUEST_SLOT), new TimePassedCondition(QUEST_SLOT, 1, DELAY))
            )),
        ConversationStates.IDLE, "Sorry, can't stop to chat. The animals are all sick because they don't have enough food. See yourself out, won't you?",
        null
View Full Code Here

    reward.add(new SetQuestAction(QUEST_SLOT, "done"));

    // the player returns to Eonna after having started the quest.
    // Eonna checks if the player has killed one of each animal race.
    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.ATTENDING, "A hero at last! Thank you!",
        new MultipleActions(reward));

    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.QUEST_STARTED,
        "Don't you remember promising to clean out the rats from my #basement?",
        null);
View Full Code Here

  }
 
  private void getOutfitsStep() {
    tam = npcs.get("Tamara");
    tam.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(tam.getName()),
            new ChatCondition() {
              public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
                return marriage.isEngaged(player);
              }
            }),
        ConversationStates.ATTENDING,
        "Welcome! If you're a bride-to-be I can #help you get ready for your wedding",
        null);
    tam.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(tam.getName()),
            new ChatCondition() {
              public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
                return !marriage.isEngaged(player);
              }
            }),
        ConversationStates.IDLE,
        "Sorry, I can't help you, I am busy getting dresses ready for brides-to-be!",
        null);

    tim = npcs.get("Timothy");
    tim.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(tim.getName()),
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
              return marriage.isEngaged(player);
            }
          }),
        ConversationStates.ATTENDING,
        "Good day! If you're a prospective groom I can #help you prepare for your wedding.",
        null);
    tim.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(tim.getName()),
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
              return !marriage.isEngaged(player);
            }
          }),
View Full Code Here

  private void createFishingRod() {
    final SpeakerNPC fisherman = npcs.get("Pequod");

    fisherman.add(ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new GreetingMatchesNameCondition(fisherman.getName()), true,
      ConversationStates.ATTENDING, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          if (!player.hasQuest(QUEST_SLOT)) {
            npc.say("Hello newcomer! I can #help you on your way to become a real fisherman!");
View Full Code Here

  private void prepareRequestingStep() {
    final SpeakerNPC npc = npcs.get("Ortiv Milquetoast");

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new LevelGreaterThanCondition(2),
          new QuestNotStartedCondition(QUEST_SLOT),
          new NotCondition(new QuestInStateCondition(QUEST_SLOT,"rejected"))),
      ConversationStates.QUESTION_1,
      "Ohh a stranger found my hidden house, welcome! Maybe you can help me with something?", null);

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT,"rejected")),
      ConversationStates.QUEST_OFFERED,
      "Hey, did you think about helping me again? Will you do it?", null);

    npc.add(
View Full Code Here

  private void prepareBringingStep() {
    final SpeakerNPC npc = npcs.get("Ortiv Milquetoast");
 
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestActiveCondition(QUEST_SLOT)),
        ConversationStates.QUESTION_2,
        "Hello again! I'm glad to see you. Did you bring me any #ingredients for my mixture?",
        null);
   
    /* player asks what exactly is missing (says ingredients) */
    npc.add(ConversationStates.QUESTION_2, "ingredients", null,
        ConversationStates.QUESTION_2, 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_2,
        ConversationPhrases.YES_MESSAGES, null,
        ConversationStates.QUESTION_2, "Awesome, what did you bring?",
        null);

    ChatAction completeAction = new  MultipleActions(
        new SetQuestAction(QUEST_SLOT, "done"),
        new SayTextAction("Thank you so much! Now I can start mixing the mixture which will hopefully keep me safe inside of my own house without the assassins and bandits comming up from downstairs. Here is an assassin dagger for you. I had to take it away from one of my students in the class once and now you can maybe fight and win against them."),
        new IncreaseXPAction(5000),
        new IncreaseKarmaAction(25),
        new EquipItemAction("assassin dagger", 1 ,true)
        );
    /* 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_2, item.getKey(), null,
          ConversationStates.QUESTION_2, null,
          new CollectRequestedItemsAction(
              item.getKey(), QUEST_SLOT,
              "Wonderful! Did you bring anything else with you?", "You brought me that ingredient already.",
              completeAction, ConversationStates.ATTENDING));
    }

    /* player says he didn't bring any items (says no) */
    npc.add(ConversationStates.ATTENDING, ConversationPhrases.NO_MESSAGES,
        new QuestActiveCondition(QUEST_SLOT),
        ConversationStates.ATTENDING,
        "Ok, well I have to be a bit more patient then. Just let me know if I can #help you somehow instead.",
        null);

    /* player says he didn't bring any items to different question */
    npc.add(ConversationStates.QUESTION_2,
        ConversationPhrases.NO_MESSAGES,
        new QuestActiveCondition(QUEST_SLOT),
        ConversationStates.ATTENDING,
        "Ok, well I have to be a bit more patient then. Just let me know if I can #help you somehow instead.", null);

    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestCompletedCondition(QUEST_SLOT)),
        ConversationStates.ATTENDING,
        "Thank you so much! I can sleep safely and calm again now! You rescued me!", null);
  }
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.