Examples of ChatAction


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

        });
   
    npc.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;
          }
        });

    npc.add(ConversationStates.PRODUCTION_OFFERED,
        ConversationPhrases.NO_MESSAGES, null,
        ConversationStates.ATTENDING, "OK, no problem.", null);

    npc.add(ConversationStates.ATTENDING,
        behaviour.getProductionActivity(),
        new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;"),
        ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence,
              final EventRaiser npc) {
            npc.say("I still haven't finished your last order!");
          }
        });
    // player returns and says hi while sacs being made
    npc.add(ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;")),
      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

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

    npc.add(ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;")),
      ConversationStates.IDLE, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence,
                   final EventRaiser npc) {
            final String orderString = player.getQuest(mithrilcloak.getQuestSlot());
            final String[] order = orderString.split(";");
            final int numberOfProductItems = Integer.parseInt(order[1]);
View Full Code Here

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

      ConversationStates.ATTENDING,
      "fuse",
      new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_thread"),
      ConversationStates.ATTENDING,
      null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          if (player.isEquipped("silk thread", 40)
            && player.isEquipped("mithril nugget", 7)
            && player.isEquipped("balloon")) {
            player.drop("silk thread", 40);
              player.drop("mithril nugget", 7);
            player.drop("balloon");
            final long timeNow = new Date().getTime();
            player.setQuest(mithrilcloak.getQuestSlot(), "fusingthread;" + timeNow);
            npc.say("I will fuse 40 mithril thread for you. Please come back in "
                + TimeUtil.approxTimeUntil((int) (REQUIRED_HOURS_MITHRIL_THREAD * MathHelper.MILLISECONDS_IN_ONE_HOUR / 1000L))
                + ".");
            player.notifyWorldAboutChanges();
          } else {
            npc.say("For 40 spools of mithril thread to make your cloak, I need 40 spools of #silk #thread, 7 #mithril #nuggets and a #balloon.");
          }
        }
      });

    // player returns while fabric is still being woven, or is ready
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "fusingthread;")),
        ConversationStates.ATTENDING, null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            final String orderString = player.getQuest(mithrilcloak.getQuestSlot());
            final String[] order = orderString.split(";");
            final long delay = REQUIRED_HOURS_MITHRIL_THREAD * MathHelper.MILLISECONDS_IN_ONE_HOUR;
            final long timeRemaining = (Long.parseLong(order[1]) + delay)
View Full Code Here

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

      ConversationStates.SERVICE_OFFERED,
      ConversationPhrases.YES_MESSAGES,
      new QuestInStateCondition(mithrilcloak.getQuestSlot(), "took_letter"),
      ConversationStates.ATTENDING,
      null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          if (player.isEquipped("mithril thread", 40)) {
           
              player.drop("mithril thread", 40);
              npc.say("Lovely. In "
                     + REQUIRED_HOURS_FABRIC + " hours your fabric will be ready.");
              player.setQuest(mithrilcloak.getQuestSlot(), "weavingfabric;" + System.currentTimeMillis());
              player.notifyWorldAboutChanges();
            } else {
              npc.say("You don't appear to have 40 spools of mithril thread with you. Sorry, I can't do anything without it.");
            }
        }
      });

    // player says they didn't bring the stuff yet
    npc.add(
      ConversationStates.SERVICE_OFFERED,
      ConversationPhrases.NO_MESSAGES,
      null,
      ConversationStates.ATTENDING,
      "Oh, ok, well I hope you haven't lost them, they are precious!",
      null);

    // player returns while fabric is still being woven, or is ready
    npc.add(ConversationStates.ATTENDING,
      Arrays.asList("weave", "fabric", "magical", "mithril fabric", "ida", "mithril", "cloak", "mithril cloak", "task", "quest"),
      new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "weavingfabric;"),
      ConversationStates.ATTENDING, null, new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final String[] tokens = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
          final long delay = REQUIRED_HOURS_FABRIC * MathHelper.MILLISECONDS_IN_ONE_HOUR;
          final long timeRemaining = (Long.parseLong(tokens[1]) + delay)
              - System.currentTimeMillis();
View Full Code Here

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

      ConversationStates.SERVICE_OFFERED,
      ConversationPhrases.YES_MESSAGES,
      new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_clasp"),
      ConversationStates.ATTENDING,
      null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          if (player.isEquipped("mithril bar")) {
            player.drop("mithril bar");
              npc.say("What a lovely piece of mithril that is, even if I do say so myself ... Good, please come back in "
                     + REQUIRED_MINUTES_CLASP + " minutes and hopefully your clasp will be ready!");
              player.setQuest(mithrilcloak.getQuestSlot(), "forgingclasp;" + System.currentTimeMillis());
              player.notifyWorldAboutChanges();
            } else {
              npc.say("You can't fool an old wizard, and I'd know mithril when I see it. Come back when you have at least one bar.");
            }
        }
      });

    // player says they don't have any mithril yet
    npc.add(
      ConversationStates.SERVICE_OFFERED,
      ConversationPhrases.NO_MESSAGES,
      null,
      ConversationStates.ATTENDING,
      "Well, if you should like me to cast any mithril bars just say.",
      null);

    npc.add(ConversationStates.ATTENDING,
      Arrays.asList("clasp", "mithril clasp", "ida", "cloak", "mithril cloak"),
      new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "forgingclasp;"),
      ConversationStates.ATTENDING, null, new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final String[] tokens = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
          // minutes -> milliseconds
          final long delay = REQUIRED_MINUTES_CLASP * MathHelper.MILLISECONDS_IN_ONE_MINUTE;
          final long timeRemaining = (Long.parseLong(tokens[1]) + delay)
View Full Code Here

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

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

    // overlapping with CloaksCollector quest deliberately
    npc.add(ConversationStates.QUESTION_1, "blue striped cloak", new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_striped_cloak"),
      ConversationStates.QUESTION_1, null,
      new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            if (player.drop("blue striped cloak")) {
              npc.say("Oh, wait, that's from Ida isn't it?! Oh yay! Thank you! Please tell her thanks from me!!");
              player.setQuest(mithrilcloak.getQuestSlot(), "gave_striped_cloak");
              npc.setCurrentState(ConversationStates.ATTENDING);
            } else {
              npc.say("You don't have a blue striped cloak with you.");
            }           
          }
      });

    // overlapping with CloaksCollector2 quest deliberately
    npc.add(ConversationStates.QUESTION_2, "blue striped cloak", new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_striped_cloak"),
        ConversationStates.QUESTION_2, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            if (player.drop("blue striped cloak")) {
              npc.say("Oh, wait, that's from Ida isn't it?! Oh yay! Thank you! Please tell her thanks from me!!");
              npc.setCurrentState(ConversationStates.ATTENDING);
              player.setQuest(mithrilcloak.getQuestSlot(), "gave_striped_cloak");
View Full Code Here

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

        new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));
   
    // Player has got chocolate bar and spoken to mummy
    final List<ChatAction> reward = new LinkedList<ChatAction>();
    reward.add(new DropItemAction("chocolate bar"));
    reward.add(new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        // pick a random flower
        String rewardClass = Rand.rand(Arrays.asList("daisies","zantedeschia","pansy"));
       
        final StackableItem reward = (StackableItem) SingletonRepository.getEntityManager().getItem(rewardClass);
View Full Code Here

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

    npc.add(ConversationStates.ATTENDING,
      Arrays.asList("scissors", "magical", "magical scissors", "ida", "mithril", "cloak", "mithril cloak"),
      new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_scissors"),
      ConversationStates.ATTENDING,
      null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          final int neededEggshells = Rand.randUniform(2, 4);
          raiser.say("Ah yes, Ida sent me a message about some magical scissors. I need one each of an iron bar and a mithril bar, and also " + Integer.toString(neededEggshells) + " magical #eggshells. Ask me about #scissors again when you return with those items.");
          // store the number of needed eggshells in the quest slot so he remembers how many he asked for
          player.setQuest(mithrilcloak.getQuestSlot(), "need_eggshells;" + Integer.toString(neededEggshells));
        }
      });

    // player needs eggshells
    npc.add(ConversationStates.ATTENDING,
      Arrays.asList("scissors", "magical", "magical scissors", "ida", "mithril", "cloak", "mithril cloak"),
      new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "need_eggshells"),
      ConversationStates.SERVICE_OFFERED,
      "So, did you bring the items I need for the magical scissors?", null);
                 
    // player asks about eggshells, hint to find terry
    npc.add(
      ConversationStates.ATTENDING,
      "eggshells",
      null,
      ConversationStates.ATTENDING,
      "They must be from dragon eggs. I guess you better find someone who dares to hatch dragons!",
      null);

    // player says yes they brought the items needed
    // we can't use the nice ChatActions here because the needed number is stored in the quest slot i.e. we need a fire
    npc.add(
      ConversationStates.SERVICE_OFFERED,
      ConversationPhrases.YES_MESSAGES,
      new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "need_eggshells"),
      ConversationStates.ATTENDING,
      null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final String[] questslot = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
          final int neededEggshells = Integer.valueOf(questslot[1]);
          if (player.isEquipped("iron")
            && player.isEquipped("mithril bar")
            && player.isEquipped("magical eggshells", neededEggshells)) {
              player.drop("iron");
              player.drop("mithril bar");
              player.drop("magical eggshells", neededEggshells);
              npc.say("Good. It will take me some time to make these, come back in "
                     + REQUIRED_MINUTES_SCISSORS + " minutes to get your scissors.");
              player.addXP(100);
              player.setQuest(mithrilcloak.getQuestSlot(), "makingscissors;" + System.currentTimeMillis());
              player.notifyWorldAboutChanges();
            } else {
              npc.say("Liar, you don't have everything I need. Ask me about #scissors again when you have an iron bar, a mithril bar, and "
                  + questslot[1] + " magical eggshells. And don't be wasting my time!");
            }
        }
      });

    // player says they didn't bring the stuff yet
    npc.add(
      ConversationStates.SERVICE_OFFERED,
      ConversationPhrases.NO_MESSAGES,
      null,
      ConversationStates.ATTENDING,
      "What are you still here for then? Go get them!",
      null);

    // player returns while hogart is making scissors or has made them
    npc.add(ConversationStates.ATTENDING,
      Arrays.asList("scissors", "magical", "magical scissors", "ida", "mithril", "cloak", "mithril cloak"),
      new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingscissors;"),
      ConversationStates.ATTENDING, null, new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final String[] tokens = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
          // minutes -> milliseconds
          final long delay = REQUIRED_MINUTES_SCISSORS * MathHelper.MILLISECONDS_IN_ONE_MINUTE;
          final long timeRemaining = (Long.parseLong(tokens[1]) + delay)
View Full Code Here

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

    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("disease poison", required * REQUIRED_POISONS)) {
              npc.say("Ok, here's your " + Integer.toString(required) + " eggshells. Enjoy!");
View Full Code Here

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

        "Ok, lets hear your joke then. and I hope it's from the book in Nalwor Library, that's my favourite. What joke did you choose?",
        null);

    npc.add(ConversationStates.QUESTION_1, "", null,
        ConversationStates.QUEST_ITEM_QUESTION, null,
          new ChatAction() {
            public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
              for (int i = 1; i < 9; i++) {
                String joke = jokes.get(i);

                final Sentence answer = sentence.parseAsMatchingSource();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.