Package games.stendhal.server.entity.npc

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


    // 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())
              + " "
              + Grammar.quantityplnoun(needed.size(), "fish", "one")
              + " still missing: "
              + Grammar.enumerateCollection(needed)
              + ". Do you have such fish with you?");
        }
      });

    // player says he doesn't have required fish with him
    npc.add(ConversationStates.QUESTION_2, ConversationPhrases.NO_MESSAGES, null,
      ConversationStates.IDLE, null, new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          final List<String> missing = missingFish(player, false);
          raiser.say("Let me know as soon as you find "
              + Grammar.itthem(missing.size()) + ". Goodbye.");
        }
      });

    // player says he has a required fish with him
    npc.add(ConversationStates.QUESTION_2,
      ConversationPhrases.YES_MESSAGES, null,
      ConversationStates.QUESTION_2, "Which fish did you catch?",
      null);

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

            if (missing.contains(itemName)) {
              if (player.drop(itemName)) {
View Full Code Here


    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        null,
        ConversationStates.QUEST_OFFERED,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            if (!player.hasQuest(QUEST_SLOT) || player.getQuest(QUEST_SLOT).equals("rejected")) {
              raiser.say("We are unable to rid our area of dwarves. Especially one mighty one named Dhohr Nuggetcutter. Would you please kill them?");
            else if (player.getQuest(QUEST_SLOT, 0).equals("start")) {
              raiser.say("I already asked you to kill Dhohr Nuggetcutter!");
View Full Code Here

        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, 0, "start"),
            new NotCondition(new KilledForQuestCondition(QUEST_SLOT, 1))),
        ConversationStates.ATTENDING,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            raiser.say("Just go kill Dhohr Nuggetcutter and his minions; the mountain leader, hero and elder dwarves. Even the simple mountain dwarves are a danger to us, kill them too.");               
        }
    });
   
    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,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            raiser.say("Thank you so much. You are a warrior, indeed! Here, have one of these. We have found them scattered about. We have no idea what they are.");
              final Item mithrilnug = SingletonRepository.getEntityManager()
                  .getItem("mithril nugget");
              player.equipOrPutOnGround(mithrilnug);
View Full Code Here

        setPath(null);
      }

      @Override
      protected void createDialog() {
        addGreeting(null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            if (player.isEquipped("sedah gate key")) {
              // toss a coin to see if he notices player still has
              // the gate key
              if (Rand.throwCoin() == 1) {
View Full Code Here

                    new QuestCompletedCondition(QUEST_SLOT))),
            new NotCondition(
                new TimePassedCondition(QUEST_SLOT, 1, expireDelay))),
        ConversationStates.ATTENDING,
        null,
        new ChatAction() {
          public void fire(Player player, Sentence sentence, EventRaiser npc) {
            npc.say("You're already on a quest to slay " +
                Grammar.a_noun(player.getQuest(QUEST_SLOT,0).split(",")[0]) +
                ". Say #complete if you're done with it!");
          }     
        });
   
    // player have expired quest time
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(
            new NotCondition(
                new OrCondition(
                    new QuestNotStartedCondition(QUEST_SLOT),
                    new QuestCompletedCondition(QUEST_SLOT))),
            new TimePassedCondition(QUEST_SLOT, 1, expireDelay)),
        ConversationStates.ATTENDING,
        null,
        new ChatAction() {
          public void fire(Player player, Sentence sentence, EventRaiser npc) {
            if(player.getQuest(QUEST_SLOT, 0)!=null) {
                npc.say("You're already on a quest to slay " +
                    Grammar.a_noun(player.getQuest(QUEST_SLOT, 0).split(",")[0]) +
                    ". Say #complete if you're done with it!" +
View Full Code Here

            new QuestNotCompletedCondition(QUEST_SLOT),
            new NotCondition(
                    new KilledForQuestCondition(QUEST_SLOT, 0))),
        ConversationStates.ATTENDING,
        null,
        new ChatAction() {
          public void fire(Player player, Sentence sentence, EventRaiser npc) {
              final String questKill = player.getQuest(QUEST_SLOT, 0).split(",")[0];
              npc.say("You didn't kill " + Grammar.a_noun(questKill)
                  + " yet. Go and do it and say #complete only after you're done.");             
          }
View Full Code Here

        });

        add(ConversationStates.PRODUCTION_OFFERED,
            ConversationPhrases.YES_MESSAGES, null,
            ConversationStates.ATTENDING, null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence,
              final EventRaiser npc) {
            behaviour.transactAgreedDeal(currentBehavRes, npc, player);

            currentBehavRes = null;
          }
        });

        add(ConversationStates.PRODUCTION_OFFERED,
            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

   */
  @Override
  protected AccessCheckingPortal createPortal(final ConfigurableFactoryContext ctx) {
    String rejectMessage = getRejectedMessage(ctx);
    ChatCondition condition = getCondition(ctx);
    ChatAction action = getAction(ctx);
    if (rejectMessage != null) {
      return new ConditionAndActionPortal(condition, rejectMessage, action);
    } else {
      return new ConditionAndActionPortal(condition, action);
    }
View Full Code Here

          null);
       
        add(ConversationStates.SERVICE_OFFERED,
          ConversationPhrases.YES_MESSAGES, null,
          ConversationStates.ATTENDING, null,
          new ChatAction() {
            public void fire(final Player player, final Sentence sentence,
                     final EventRaiser npc) {
              Pet pet = player.getPet();
              String petName = pet.getTitle();
              // these numbers are hardcoded, they're the area in the pet sanctuary which is for pets. It has food spawners.
View Full Code Here

      protected void createDialog() {
        addGreeting();
        addJob("I am the librarian.");
        addHelp("Just ask me to #explain something.");
        add(ConversationStates.ATTENDING, "explain", null, ConversationStates.ATTENDING, null,
                new ChatAction() {
                  public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
                    String text = sentence.getOriginalText();
                    // extract the title
                    int pos = text.indexOf(" ");
                    if (pos > -1) {
View Full Code Here

TOP

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

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.