Package games.stendhal.server.entity.npc

Examples of games.stendhal.server.entity.npc.SpeakerNPC


    // Careful not to overlap with quest states in RainbowBeans quest

    final int MOSS_COST = 3000;

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

    // offer moss when prompted
    npc.add(ConversationStates.ANY,
        Arrays.asList("moss", "magical", "twilight", "ida", "cloak", "mithril cloak", "specials", "twilight moss"),
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "twilight_zone"),
        ConversationStates.QUEST_ITEM_QUESTION,
        "Keep it quiet will you! Yeah, I got moss, it's "
        + Integer.toString(MOSS_COST) + " money each. How many do you want?",
        null);

    // responding to question of how many they want, with a number
    npc.addMatching(ConversationStates.QUEST_ITEM_QUESTION,
        // match for all numbers as trigger expression
        ExpressionType.NUMERAL, new JokerExprMatcher(),
        new TextHasNumberCondition(1, 5000),
        ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {

                        final int required = (sentence.getNumeral().getAmount());
            if (player.drop("money" , required * MOSS_COST)) {
              npc.say("Ok, here's your " + Integer.toString(required) + " pieces of twilight moss. Don't take too much at once.");
              new EquipItemAction("twilight moss", required, true).fire(player, sentence, npc);
            } else {
              npc.say("Ok, ask me again when you have enough money.");
            }           
          }
        });

    // they don't want moss yet
    npc.add(ConversationStates.QUEST_ITEM_QUESTION,
        Arrays.asList("no", "none", "nothing"),
        null,
        ConversationStates.ATTENDING,
        "Ok, whatever you like.",
        null);
View Full Code Here


        null);
  }

  private void twilightZoneStep() {

    final SpeakerNPC npc = npcs.get("Ida");
    // player hasn't given elixir to lda in the twilight zone yet
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("magical", "mithril", "cloak", "mithril cloak", "task", "quest", "twilight"),
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "twilight_zone"),
        ConversationStates.ATTENDING,   
        "What's happening to me? I'm feverish .. I see twilight .. you can't understand unless you visit me here ... you must ask #Pdiddi how to get to the #twilight.",       
        null);

    npc.addReply("Pdiddi", "Oh, I'm too confused... I can't tell you anything about him...");


    // player gave elixir and returned
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("magical", "mithril", "cloak", "mithril cloak", "task", "quest", "twilight", "elixir"),
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_striped_cloak"),
        ConversationStates.ATTENDING,   
        "When I was sick I got behind on my other jobs. I promised #Josephine I'd make her a stripey cloak but I have no time. So please, I'm relying on you to buy one and take it to her. They sell blue striped cloaks in Ados abandoned keep. Thank you!",       
        null);


    // Ida and lda look the same but one lives in her true home sewing room and one lives in the twilight zone
    // hence they need different names according to engine, but name will look the same on client
    final SpeakerNPC npc2 = npcs.get("lda");

    npc2.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc2.getName()),
            new QuestInStateCondition(mithrilcloak.getQuestSlot(), "twilight_zone"),
            new NotCondition(new PlayerHasItemWithHimCondition("twilight elixir"))),
        ConversationStates.IDLE,   
        "I'm sick .. so sick .. only some powerful medicine will fix me.",       
        null);

    npc2.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc2.getName()),
            new QuestInStateCondition(mithrilcloak.getQuestSlot(), "twilight_zone"),
            new PlayerHasItemWithHimCondition("twilight elixir")),
        ConversationStates.QUEST_ITEM_QUESTION,   
        "Is that elixir for me? If #yes I will take it immediately. You must return to see me again in my normal state.",       
         null);

    npc2.add(ConversationStates.QUEST_ITEM_QUESTION,
        ConversationPhrases.YES_MESSAGES,
        new AndCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "twilight_zone"),
                 new PlayerHasItemWithHimCondition("twilight elixir")
                 ),
        ConversationStates.IDLE,   
        "Thank you!",       
        new MultipleActions(
                new DropItemAction("twilight elixir"),
                new SetQuestAction(mithrilcloak.getQuestSlot(), "taking_striped_cloak"),
                new TeleportAction("int_ados_sewing_room", 12, 20, Direction.DOWN)
                )
        );

    npc2.add(ConversationStates.QUEST_ITEM_QUESTION,
        ConversationPhrases.NO_MESSAGES,
        new AndCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "twilight_zone"),
                 new PlayerHasItemWithHimCondition("twilight elixir")
                 ),
        ConversationStates.IDLE,   
View Full Code Here

    logger.error("History doesn't have a matching quest state for " + questState);
    return debug;
  }
 
  private void prepareQuestOfferingStep() {
    final SpeakerNPC npc = npcs.get("Alrak");

   
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new QuestNotStartedCondition(QUEST_SLOT),
        ConversationStates.QUEST_ITEM_QUESTION,
        "You know, it's hard to get food round here. I don't have any #supplies for next year.",
        null);
   
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new QuestCompletedCondition(QUEST_SLOT),
        ConversationStates.ATTENDING,
        "I'm inspired to work again! I'm making things for Wrvil now. Thanks for getting me interested in forging again.",
        null);
   
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new QuestInStateCondition(QUEST_SLOT, "food_brought"),
        ConversationStates.QUEST_ITEM_BROUGHT,
        "Now I'm less worried about food I've realised I'm bored. There's a #book I'd love to read.",
        null);
   
    // any other state than above
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "food_brought")),
        ConversationStates.ATTENDING,
        "I'm sure I asked you to do something for me, already.",
        null);
           

    /*
     * Player agrees to collect the food asked for. his quest slot gets set
     * with it so that later when he returns and says the food name, Alrak
     * can check if that was the food type he was asked to bring.
     */
    npc.add(ConversationStates.QUEST_OFFERED,
      ConversationPhrases.YES_MESSAGES, null,
      ConversationStates.ATTENDING, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final String food = player.getQuest(QUEST_SLOT);
          npc.say("Thank you! I hope it doesn't take too long to collect. Don't forget to say '"
            + food + "' when you have it.");
          // player.setQuest(QUEST_SLOT, food);
          player.addKarma(5.0);
          // set food to null?
        }
      });

    // Player says no. they might get asked to bring a different food next
    // time but they've lost karma.
    npc.add(ConversationStates.QUEST_OFFERED,
        ConversationPhrases.NO_MESSAGES,
        null,
        ConversationStates.IDLE,
        "I'm not sure how I'll survive next year now. Good bye, cruel soul.",
        new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));

    // Player asks what supplies he needs, and a random choice of what he
    // wants is made.
    npc.add(ConversationStates.QUEST_ITEM_QUESTION,
        "supplies",
        null,
        ConversationStates.QUEST_OFFERED,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            final String food = Rand.rand(FOOD_LIST);
            player.setQuest(QUEST_SLOT, food);
            npc.say("If you could get me " + REQUIRED_FOOD
                + " pieces of " + food
                + ", I'd be in your debt. Will you help me?");
          }
        });
  }
View Full Code Here

          }
        });
  }

  private void bringFoodStep() {
    final SpeakerNPC npc = npcs.get("Alrak");

    /** If player has quest and has brought the food, and says so, take it */
    for(final String itemName : FOOD_LIST) {
      final List<ChatAction> reward = new LinkedList<ChatAction>();
      reward.add(new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            if (player.drop(itemName, REQUIRED_FOOD)) {
              npc.say("Great! You brought the " + itemName + "!");
            }
          } });
      reward.add(new IncreaseXPAction(1000));
      reward.add(new IncreaseKarmaAction(35.0));
      reward.add(new SetQuestAction(QUEST_SLOT, "food_brought"));

      npc.add(ConversationStates.ATTENDING,
        itemName,
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
            return player.hasQuest(QUEST_SLOT)
                && player.getQuest(QUEST_SLOT).equals(itemName)
View Full Code Here

        new MultipleActions(reward));
    }
  }

  private void requestBookStep() {
    final SpeakerNPC npc = npcs.get("Alrak");

    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
        "book",
        null,
        ConversationStates.QUEST_ITEM_BROUGHT,
        "It's about gems and minerals. I doubt you'd be interested ... but do you think you could get it somehow?",
        null);

    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
        ConversationPhrases.NO_MESSAGES,
        null,
        ConversationStates.IDLE,
        "Shame, I would really like to learn more about precious stones. Ah well, good bye.",
        null);

    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
        ConversationPhrases.YES_MESSAGES,
        null,
        ConversationStates.ATTENDING,
        "Thanks. Try asking at a library for a 'gem book'.",
        new SetQuestAndModifyKarmaAction(QUEST_SLOT, "seeking_book", 10.0));
View Full Code Here

        "Thanks. Try asking at a library for a 'gem book'.",
        new SetQuestAndModifyKarmaAction(QUEST_SLOT, "seeking_book", 10.0));
  }

  private void getBookStep() {
    final SpeakerNPC npc = npcs.get("Ceryl");

    npc.add(ConversationStates.ATTENDING,
        "book",
        new AndCondition(new QuestInStateCondition(QUEST_SLOT, "seeking_book"), new QuestCompletedCondition("ceryl_book")),
        ConversationStates.ATTENDING,
        "Currently the #gem #book is quite popular...",
        null);
   
    npc.add(ConversationStates.ATTENDING,
        "gem book",
        new QuestInStateCondition(QUEST_SLOT, "seeking_book"),
        ConversationStates.QUESTION_1,
        "You're in luck! Ognir brought it back just last week. Now, who is it for?",
        null);

    npc.add(ConversationStates.QUESTION_1,
        NAME,
        null,
        ConversationStates.ATTENDING,
        "Ah, the mountain dwarf! Hope he enjoys the gem book.",
        new MultipleActions(new EquipItemAction("blue book", 1, true),
        new SetQuestAction(QUEST_SLOT, "got_book")));

    // allow to say goodbye while Ceryl is listening for the dwarf's name
    npc.add(ConversationStates.QUESTION_1, ConversationPhrases.GOODBYE_MESSAGES,
        null,
        ConversationStates.IDLE,
        "Bye.", null);

    // player says something which isn't the dwarf's name.
    npc.add(ConversationStates.QUESTION_1,
        "",
        new NotCondition(new TriggerInListCondition(NAME.toLowerCase())),
        ConversationStates.QUESTION_1,
        "Hm, you better check who it's really for.",
        null);
View Full Code Here

        "Hm, you better check who it's really for.",
        null);
  }

  private void bringBookStep() {
    final SpeakerNPC npc = npcs.get("Alrak");
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "got_book"),
            new PlayerHasItemWithHimCondition("blue book")),
        ConversationStates.IDLE,
        "Great! I think I'll read this for a while. Bye!",
        new MultipleActions(
            new DropItemAction("blue book"),
            new IncreaseXPAction(500),
            new SetQuestAction(QUEST_SLOT, "reading;"),
            new SetQuestToTimeStampAction(QUEST_SLOT, 1)));

    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new OrCondition(new QuestInStateCondition(QUEST_SLOT,"seeking_book"), new QuestInStateCondition(QUEST_SLOT, "got_book")),
            new NotCondition(new PlayerHasItemWithHimCondition("blue book"))),
        ConversationStates.ATTENDING,
        "Hello again. I hope you haven't forgotten about the gem book I wanted.",
        null);
View Full Code Here

        "Hello again. I hope you haven't forgotten about the gem book I wanted.",
        null);
  }

  private void offerKnifeStep() {
    final SpeakerNPC npc = npcs.get("Alrak");
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT, "reading;"),
            new NotCondition(new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_DAYS * MINUTES_IN_DAYS))),
        ConversationStates.IDLE,
        null,
        new SayTimeRemainingAction(QUEST_SLOT, 1, REQUIRED_DAYS * MINUTES_IN_DAYS, "I haven't finished reading that book. Maybe I'll be done in"));
   
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT, "reading;"),
            new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_DAYS * MINUTES_IN_DAYS)),
        ConversationStates.QUEST_2_OFFERED,
        "I've finished reading! That was really interesting. I learned how to make a special #knife from #obsidian.",
        new SetQuestAction(QUEST_SLOT, "book_read"));
           

    npc.add(ConversationStates.QUEST_2_OFFERED,
        "obsidian",
        new LevelGreaterThanCondition(REQUIRED_LEVEL),
        ConversationStates.QUEST_2_OFFERED,
        "That book says that the black gem, obsidian, can be used to make a very sharp cutting edge. Fascinating! If you slay a black dragon to bring it, I'll make a #knife for you.",
        new SetQuestAction(QUEST_SLOT, "knife_offered"));

    npc.add(ConversationStates.QUEST_2_OFFERED,
        "knife",
        new LevelGreaterThanCondition(REQUIRED_LEVEL),
        ConversationStates.QUEST_2_OFFERED,
        "I'll make an obsidian knife if you can slay a black dragon and get the gem which makes the blade. Bring a "
            + FISH
            + " so that I can make the bone handle, too.",
        new SetQuestAction(QUEST_SLOT, "knife_offered"));
   
    npc.add(ConversationStates.QUEST_2_OFFERED,
        Arrays.asList("obsidian", "knife"),
        new NotCondition(new LevelGreaterThanCondition(REQUIRED_LEVEL)),
        ConversationStates.ATTENDING,
        "Well, I don't think you're quite ready for such a dangerous weapon yet. How about you come back when you're above level " + Integer.toString(REQUIRED_LEVEL) + "?",
        null);
   
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "book_read")),
        ConversationStates.QUEST_2_OFFERED,
        "Hi! Perhaps you have come to ask about that #knife again ... ",
        null);
           
    // player says hi to NPC when equipped with the fish and the gem and
    // he's killed a black dragon
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "knife_offered"),
            new KilledCondition("black dragon"),
            new PlayerHasItemWithHimCondition("obsidian"),
            new PlayerHasItemWithHimCondition(FISH)),
        ConversationStates.IDLE,
        "You found the gem for the blade and the fish bone to make the handle! I'll start work right away. Come back in "
        + REQUIRED_MINUTES + " minutes.",
        new MultipleActions(
        new DropItemAction("obsidian"),
        new DropItemAction(FISH),
        new SetQuestAction(QUEST_SLOT, "forging;"),
        new SetQuestToTimeStampAction(QUEST_SLOT, 1)));

    // player says hi to NPC when equipped with the fish and the gem and
    // he's not killed a black dragon
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "knife_offered"),
            new NotCondition(new KilledCondition("black dragon")),
            new PlayerHasItemWithHimCondition("obsidian"),
            new PlayerHasItemWithHimCondition(FISH)),
        ConversationStates.ATTENDING,
        "Didn't you hear me properly? I told you to go slay a black dragon for the obsidian, not buy it! How do I know this isn't a fake gem? *grumble* I'm not making a special knife for someone who is scared to face a dragon.",
        null);

    // player says hi to NPC when not equipped with the fish and the gem
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "knife_offered"),
            new NotCondition(
                new AndCondition(
                    new PlayerHasItemWithHimCondition("obsidian"),
                    new PlayerHasItemWithHimCondition(FISH)))),
        ConversationStates.ATTENDING,
        "Hello again. Don't forget I offered to make that obsidian knife, if you bring me a "
          + FISH
          + " and a piece of obsidian from a black dragon you killed. In the meantime if I can #help you, just say the word.",
        null);

    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT, "forging;"),
            new NotCondition(new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES))),
        ConversationStates.IDLE,
        null,
        new SayTimeRemainingAction(QUEST_SLOT, 1, REQUIRED_MINUTES, "I haven't finished making the knife. Please check back in"));
   
    final List<ChatAction> reward = new LinkedList<ChatAction>();
    reward.add(new IncreaseXPAction(10000));
    reward.add(new SetQuestAction(QUEST_SLOT, "done"));
    reward.add(new EquipItemAction("obsidian knife", 1, true));
   
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT, "forging;"),
            new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES)),
        ConversationStates.IDLE,
        "The knife is ready! You know, that was enjoyable. I think I'll start making things again. Thanks!",
        new MultipleActions(reward));   
View Full Code Here

    return QUEST_SLOT;
  }

  private void prepareQuestOfferingStep() {
   
    final SpeakerNPC npc = npcs.get("Hogart");
   
    // Player asks about quests, and had previously rejected or never asked: offer it
    npc.add(ConversationStates.ATTENDING,
      ConversationPhrases.QUEST_MESSAGES,
      new QuestNotStartedCondition(QUEST_SLOT),
      ConversationStates.QUEST_OFFERED,
      "I can forge a powerful life stealing sword for you. You will need to go to the Catacombs below Semos Graveyard and fight the Vampire Lord. Are you interested?",
      null);
   
    // Player asks about quests, but has finished this quest
    npc.add(ConversationStates.ATTENDING,
      ConversationPhrases.QUEST_MESSAGES,
      new QuestCompletedCondition(QUEST_SLOT),
      ConversationStates.ATTENDING,
      "What are you bothering me for now? You've got your sword, go and use it!",
      null);
   
    // Player asks about quests, but has not finished this quest
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new QuestActiveCondition(QUEST_SLOT),
        ConversationStates.ATTENDING,
        "Why are you bothering me when you haven't completed your quest yet?",
        null);

    final List<ChatAction> gobletactions = new LinkedList<ChatAction>();
    gobletactions.add(new EquipItemAction("empty goblet"));
    gobletactions.add(new IncreaseKarmaAction(5.0));
    gobletactions.add(new SetQuestAction(QUEST_SLOT, "start"));
    // Player wants to do the quest
    npc.add(ConversationStates.QUEST_OFFERED,
      ConversationPhrases.YES_MESSAGES, null,
      ConversationStates.ATTENDING, "Then you need this #goblet. Take it to the Semos #Catacombs.",
      new MultipleActions(gobletactions));
   
    // Player doesn't want to do the quest; remember this, but they can ask again to start it.
    npc.add(
      ConversationStates.QUEST_OFFERED,
      ConversationPhrases.NO_MESSAGES,
      null,
      ConversationStates.IDLE,
      "Oh, well forget it then. You must have a better sword than I can forge, huh? Bye.",
      new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));

    npc.addReply("catacombs", "The Catacombs of north Semos of the ancient #stories.");

    npc.addReply("goblet", "Go fill it with the blood of the enemies you meet in the #Catacombs.");
  }
View Full Code Here

    npc.addReply("goblet", "Go fill it with the blood of the enemies you meet in the #Catacombs.");
  }

  private void prepareGobletFillingStep() {

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

    npc.addGoodbye("*cough* ... farewell ... *cough*");
    npc.addReply(
      Arrays.asList("blood", "vampirette entrails", "bat entrails"),
      "I need blood. I can take it from the entrails of the alive and undead. I will mix the bloods together for you and #fill your #goblet, if you let me drink some too. But I'm afraid of the powerful #lord.");

    npc.addReply(Arrays.asList("lord", "vampire", "skull ring"),
      "The Vampire Lord rules these Catacombs! And I'm afraid of him. I can only help you if you kill him and bring me his skull ring with the #goblet.");

    npc.addReply(
      Arrays.asList("empty goblet", "goblet"),
      "Only a powerful talisman like this cauldron or a special goblet should contain blood.");

    // The sick vampire is only a producer. He doesn't care if your quest slot is active, or anything.
    // So to ensure that the vampire lord must have been killed, we made the skull ring a required item
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.SpeakerNPC

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.