Package games.stendhal.server.entity.npc

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


        return true;
      }
    };

    final String reply = "huch";
    final ChatAction action = new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        assertEquals(triggers, sentence.getTriggerExpression().getNormalized());
      }
    };
    en.add(state, triggers, cc, false, nextState, reply, action);
View Full Code Here


        "That's how long,", "That's how long",
        "Thats how long,", "Thats how long"),
      ConversationStates.INFORMATION_4,
      "\"I will be your friend.\"", null);

    ChatAction reward = new MultipleActions(new IncreaseKarmaAction(10), new IncreaseXPAction(25), new SetQuestToYearAction("susi"));
    npc.add(ConversationStates.INFORMATION_4,
      "",
      new TriggerExactlyInListCondition("I will be your friend.", "I will be your friend"),
      ConversationStates.ATTENDING,
      "Yay! We are friends now.",
View Full Code Here

        new TriggerExactlyInListCondition("One is silver,", "One is silver"),
        ConversationStates.INFORMATION_8, "\"And the other gold.\"",
        null);

    // lowercase "and" is ignored, even in full match mode
    ChatAction reward = new MultipleActions(new IncreaseKarmaAction(15), new IncreaseXPAction(50), new SetQuestToYearAction("susi"));
    npc.add(ConversationStates.INFORMATION_8, "",
        new TriggerExactlyInListCondition("And the other gold.", "And the other gold", "the other gold.", "the other gold"),
        ConversationStates.ATTENDING,
        "Yay! We are even better friends now.",
        reward);
View Full Code Here

    taxman.add(ConversationStates.QUESTION_1,
        ConversationPhrases.YES_MESSAGES,
        null,
        ConversationStates.ATTENDING,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            final int periods = getUnpaidTaxPeriods(player);
            final int cost = getTaxDebt(periods);
            if (player.isEquipped("money", cost)) {
              player.drop("money", cost);
View Full Code Here

    npc.add(ConversationStates.ATTENDING, Arrays.asList("emerald ring", "life", "emerald"),
      new AndCondition(new PlayerHasItemWithHimCondition("emerald ring"),
                   new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING))),
      ConversationStates.QUEST_ITEM_BROUGHT,
      null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final RingOfLife emeraldRing = (RingOfLife) player.getFirstEquipped("emerald ring");
         
            if (emeraldRing.isBroken()) {
              npc.say("What a pity, your emerald ring is broken. I can fix it, for a #price.");
            } else {
              // ring is not broken so he just lets player know
              // where it can be fixed
              npc.say("I see you already have an emerald ring. If it gets broken, you can come to me to fix it.");
              npc.setCurrentState(ConversationStates.ATTENDING);
            }
         
        }
      });
   
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("emerald ring", "life", "emerald"),
        new AndCondition(new NotCondition(new PlayerHasItemWithHimCondition("emerald ring")),
                 new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING))),

        ConversationStates.ATTENDING,
        "It is difficult to get the ring of life. Do a favour for a powerful elf in Nal'wor and you may receive one as a reward."
        , null);
 
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("emerald ring", "life", "emerald"),
        new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING),
            new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING + "unbound")),
            new TimePassedCondition(QUEST_SLOT,1,REQUIRED_MINUTES)),
        ConversationStates.ATTENDING,
        "I'm pleased to say, your ring of life is fixed! It's good as new now.",
        new MultipleActions(
            new IncreaseXPAction(500),
            new SetQuestAction(QUEST_SLOT, "done"),
            new EquipItemAction("emerald ring", 1, true)));
   
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("emerald ring", "life", "emerald"),
        new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING),
            new QuestStateStartsWithCondition(QUEST_SLOT, FORGING + "unbound"),
            new TimePassedCondition(QUEST_SLOT,1,REQUIRED_MINUTES)),
        ConversationStates.ATTENDING,
        "I'm pleased to say, your ring of life is fixed! It's good as new now.",
        new MultipleActions(
            new IncreaseXPAction(500),
            new SetQuestAction(QUEST_SLOT, "done"),
            new EquipItemAction("emerald ring", 1, false)));

    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("emerald ring", "life", "emerald"),
        new AndCondition(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 fixing your ring of life. Please check back in"));
   
   
    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
        "price",
        null,
        ConversationStates.QUEST_ITEM_BROUGHT,
        "The charge for my service is " + REQUIRED_MONEY
          + " money, and I need " + REQUIRED_GOLD
          + " gold bars and " + REQUIRED_GEM
          + " emerald to fix the ring. Do you want to pay now?",
        null);

    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
        ConversationPhrases.YES_MESSAGES,
        new AndCondition(
            new PlayerHasItemWithHimCondition("gold bar", REQUIRED_GOLD),
            new PlayerHasItemWithHimCondition("money", REQUIRED_MONEY),
            new PlayerHasItemWithHimCondition("emerald", REQUIRED_GEM)),
        ConversationStates.IDLE,
        "Okay, that's all I need to fix the ring. Come back in "
            + REQUIRED_MINUTES
            + " minutes and it will be ready. Bye for now.",
        new MultipleActions(
            new DropItemAction("gold bar", REQUIRED_GOLD),
            new DropItemAction("emerald", REQUIRED_GEM),
            new DropItemAction("money", REQUIRED_MONEY),
            new ChatAction() {
              public void fire(final Player player,
                  final Sentence sentence,
                  final EventRaiser npc) {
                final RingOfLife emeraldRing = (RingOfLife) player.getFirstEquipped("emerald ring");
                if (player.isBoundTo(emeraldRing)) {
View Full Code Here

    npc.add(ConversationStates.QUESTION_2,
        ConversationPhrases.YES_MESSAGES, null,
        ConversationStates.QUESTION_2, "Great, what did you bring?",
        null);

    ChatAction completeAction = new  MultipleActions(
        new SetQuestAction(QUEST_SLOT, "done"),
        new SayTextAction("Great! Now I can heal many people for free. Thanks a lot. Take this for your work."),
        new IncreaseXPAction(50),
        new IncreaseKarmaAction(5),
        new EquipItemAction("minor potion", 5)
View Full Code Here

    // Don't Use condition here, because of FishermansLicenseCollector
    fisherman.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES, null,
        ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            if (player.isQuestCompleted(FishermansLicenseCollector.QUEST_SLOT)) {
              npc.say("I don't have a task for you, and you already have a fisherman's license.");
            } else {
              npc.say("I don't need anything from you, but if you like, you can do an #exam to get a fisherman's license.");
            }
          }
        });

    fisherman.add(ConversationStates.ATTENDING, "exam", null,
        ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            if (player.isQuestCompleted(FishermansLicenseCollector.QUEST_SLOT)) {
              npc.say("You have already got your fisherman's license.");
            } else if (player.isQuestCompleted(QUEST_SLOT)) {
              npc.say("Are you ready for the second part of your exam?");
              npc.setCurrentState(ConversationStates.QUEST_2_OFFERED);
            } else {
              final long timeRemaining = remainingTimeToWait(player);
              if (timeRemaining > 0L) {
                npc.say("You can only do the quiz once a day. Come back in "
                  + TimeUtil.approxTimeUntil((int) (timeRemaining / 1000L))
                  + ".");
              } else {
                npc.say("Are you ready for the first part of your exam?");
                npc.setCurrentState(ConversationStates.QUEST_OFFERED);
              }
            }
          }
        });

    fisherman.add(ConversationStates.QUEST_OFFERED,
        ConversationPhrases.NO_MESSAGES, null,
        ConversationStates.ATTENDING, "Come back when you're ready.",
        null);

    fisherman.add(ConversationStates.QUEST_OFFERED,
        ConversationPhrases.YES_MESSAGES, null,
        ConversationStates.QUESTION_1,
        "Fine. The first question is: What kind of fish is this?",
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            startQuiz();
            player.setQuest(QUEST_SLOT, "" + System.currentTimeMillis());
          }
        });

    fisherman.addMatching(ConversationStates.QUESTION_1, Expression.JOKER, new JokerExprMatcher(),
        new NotCondition(new TriggerInListCondition(ConversationPhrases.GOODBYE_MESSAGES)),
        ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            String species = getCurrentSpecies();
            String obj = sentence.getObjectName();

            if ((obj!=null && obj.contains(species)) ||
                sentence.getOriginalText().endsWith(species) ||
                sentence.getNormalized().endsWith(species) ||
                sentence.getTriggerExpression().matches(ConversationParser.createTriggerExpression(species))) {
              if (currentSpeciesNo == speciesList.size() - 1) {
                npc.say("Correct! Congratulations, you have passed the first part of the #exam.");
                cleanUpTable();
                player.setQuest(QUEST_SLOT, "done");
                player.addKarma(15);
                player.addXP(500);
              } else {
                npc.say("Correct! So, what kind of fish is this?");
                putNextFishOnTable();
                npc.setCurrentState(ConversationStates.QUESTION_1);
              }
            } else {
              npc.say("No, that's wrong. Unfortunately you have failed, but you can try again tomorrow.");
              cleanUpTable();
              // remember the current time, as you can't do the
              // quiz twice a day.
              player.setQuest(QUEST_SLOT, "" + System.currentTimeMillis());
            }
          }
        });

    fisherman.add(ConversationStates.ANY, ConversationPhrases.GOODBYE_MESSAGES,
        ConversationStates.IDLE, "Goodbye.", new ChatAction() {
     
        // this should be put into a custom ChatAction for this quest when the quest is refactored
      public void fire(final Player player, final Sentence sentence,
          final EventRaiser npc) {
        cleanUpTable();
View Full Code Here

    reward.add(new IncreaseXPAction(50));
    reward.add(new SetQuestToTimeStampAction(QUEST_SLOT));
    reward.add(new IncreaseKarmaAction(15));
    // player gets either cod or perch, which we don't have a standard action for
    // and the npc says the name of the reward, too
    reward.add(new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            String rewardClass;
            if (Rand.throwCoin() == 1) {
              rewardClass = "cod";
            } else {
View Full Code Here

    // player asks about an individual cloak before accepting the quest
    for(final String itemName : NEEDED_CLOAKS) {
      npc.add(ConversationStates.QUEST_OFFERED, itemName, null,
        ConversationStates.QUEST_OFFERED, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            Expression obj = sentence.getObject(0);
            if (obj!=null && !obj.getNormalized().equals(itemName)) {
              raiser.say("I don't know " + obj.getOriginal() + ". Can you name me another cloak please?");
            } else {
View Full Code Here

    npc.add(ConversationStates.ATTENDING,
      questTrigger,
      new AndCondition(new QuestCompletedCondition(QUEST_SLOT), new PlayerHasItemWithHimCondition("ice sword")),
      ConversationStates.ATTENDING,
      null,
      new ChatAction() {
        // we are storing the number of times the player has done the quest in the quest slot like
        // done;N. We reward based on this number. If the quest slot isn't split like this and only 'done'
        // we assume it was just done once (sorry, guys)
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          int N;
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.