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

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


    final ProducerBehaviour behaviour = new SpecialProducerBehaviour("make", "silk thread",
                                     requiredResources, REQUIRED_MINUTES_THREAD);

    npc.add(ConversationStates.ATTENDING,
        "make",
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_fabric"), ConversationStates.ATTENDING, null,
        new ProducerBehaviourAction(behaviour) {
          @Override
          public void fireRequestOK(final ItemParserResult res, Player player, Sentence sentence, EventRaiser npc) {
            // Find out how much items we shall produce.
            if (res.getAmount() < 40) {
              npc.say("Do you really want so few? I'm not wasting my time with that! Any decent sized pieces of fabric needs at least 40 spools of thread! You should at least #make #40.");
              return;
            } else if (res.getAmount() > 1000) {
              /*logger.warn("Decreasing very large amount of "
               *    + behaviour.getAmount()
               *    + " " + behaviour.getChosenItemName()
               *    + " to 40 for player "
               *    + player.getName() + " talking to "
               *    + npc.getName() + " saying " + sentence);
               */
              res.setAmount(40);
            }

            if (behaviour.askForResources(res, npc, player)) {
              currentBehavRes = res;
              npc.setCurrentState(ConversationStates.PRODUCTION_OFFERED);
            }
          }

          @Override
          public void fireRequestError(final ItemParserResult res, final Player player, final Sentence sentence, final EventRaiser raiser) {
            raiser.say(behaviour.getErrormessage(res, "#make", "produce"));
          }
        });
   
    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);
          }
        });
    // player returns and doesn't need fabric and sacs not being made
    npc.add(ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new NotCondition(
              new OrCondition(
                   new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_fabric"),
                   new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;")
              )
          )),
      ConversationStates.IDLE, "Ha ha he he woo hoo!!!",
      null);


    // player returns and needs fabric
    npc.add(ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_fabric")),
      ConversationStates.ATTENDING, "Ha ha he he woo hoo ... ha ... Sorry, I get carried away sometimes. What do you want?",
      null);


  }
View Full Code Here


    // player says yes they brought the items needed
    // we can't use the nice ChatActions here because we have to timestamp the quest slot
    npc.add(
      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)
              - System.currentTimeMillis();
            if (timeRemaining > 0L) {
              npc.say("Welcome. I'm still working on your request to fuse mithril thread"
                  + " for you. Come back in "
                  + TimeUtil.approxTimeUntil((int) (timeRemaining / 1000L)) + ".");
            } else {
              final StackableItem products = (StackableItem) SingletonRepository.
                    getEntityManager().getItem("mithril thread");
 
              products.setQuantity(40);
           
              products.setBoundTo(player.getName());
              player.equipOrPutOnGround(products);
              npc.say("Hello again. The magic is completed. Here you have your 40 spools of mithril thread. Now, you must go to #Whiggins to get the #fabric made.");
              player.setQuest(mithrilcloak.getQuestSlot(), "got_mithril_thread");
              // give some XP as a little bonus for industrious workers
              player.addXP(100);
              player.notifyWorldAboutChanges()
          }
          }
        }
    );

    // don't fuse thread unless state correct
    npc.add(
        ConversationStates.ATTENDING,
        "fuse",
        new NotCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_thread")),
        ConversationStates.ATTENDING, "I can only create mithril thread when you have got some silk #thread. And remember, I will know if you really need the magic performed or not.", null);
   
    // player returns and hasn't got thread yet/got thread already and
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new NotCondition(
                 new OrCondition(
                         new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_thread"),
                         new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "fusingthread;")
                         )
            )),
        ConversationStates.ATTENDING, "Greetings. What an interesting place this is.",
        null);

    // player needs thread fused
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_thread")),
        ConversationStates.ATTENDING, "Greetings, can I #offer you anything?",
        null);

  }
View Full Code Here

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

    // player asks about fabric/quest
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("weave", "fabric", "magical", "mithril fabric", "ida", "mithril", "cloak", "mithril cloak", "task", "quest"),
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_mithril_thread"),
        ConversationStates.QUEST_OFFERED,
        "I would love to weave you some fabric but I'm afraid my mind is full of other things. I have offended a fellow wizard. I was up all night writing him an apology letter, but I have no-one to deliver it to him. Unless ... that is ... would YOU deliver this letter for me?",
        null);
     
    // Player says yes they want to help
    npc.add(ConversationStates.QUEST_OFFERED,
        ConversationPhrases.YES_MESSAGES, null,
        ConversationStates.ATTENDING,
        "Wonderful! I'm so relieved! Please take this note to Pedinghaus, you will find him in Ados goldsmiths. Tell him you have a #letter for him.",     
        new MultipleActions(new EquipItemAction("sealed envelope", 1, true),
                  new SetQuestAction(mithrilcloak.getQuestSlot(), "taking_letter"))
        );
   
    // player said no they didn't want to help
    npc.add(
      ConversationStates.QUEST_OFFERED,
      ConversationPhrases.NO_MESSAGES,
      null,
      ConversationStates.QUEST_OFFERED,
      "Oh dear, I'm ever so worried. Please help?",
      null);
 
    // player returns without having taking letter
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("weave", "fabric", "magical", "mithril fabric", "ida", "mithril", "cloak", "mithril cloak", "pedinghaus", "task", "quest", "letter", "note"),
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_letter"),
        ConversationStates.ATTENDING,
        "Please don't forget to take that letter to Pedinghaus. It means a lot to me.", null);

    // player returns having taking letter
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("weave", "fabric", "magical", "mithril fabric", "ida", "mithril", "cloak",
                "mithril cloak", "pedinghaus", "regards", "forgiven", "task", "quest"),
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "took_letter"),
        ConversationStates.SERVICE_OFFERED,
        "Thank you so much for taking that letter! Now, do you have the 40 spools of mithril thread "
        + "so that I may weave you a couple yards of fabric?", null);

    // player's quest state is in nothing to do with the letter, thread or weaving.
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("weave", "fabric", "magical", "mithril fabric", "ida", "mithril", "cloak", "mithril cloak", "pedinghaus", "task", "quest"),
        new NotCondition(
                 new OrCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_mithril_thread"),
                         new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_letter"),
                         new QuestInStateCondition(mithrilcloak.getQuestSlot(), "took_letter"),
                         new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "weavingfabric;")
                         )
                 ),
        ConversationStates.ATTENDING,
        "I haven't got any quest for you now.", null);
                 

    // player says yes they brought the items needed
    // we can't use the nice ChatActions here because we have to timestamp the quest slot
    npc.add(
      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)) {
View Full Code Here

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

    // accept the letter
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("letter", "note", "whiggins", "apology"),
        new AndCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_letter"), new PlayerHasItemWithHimCondition("sealed envelope")),
        ConversationStates.ATTENDING,
        "*reads* ... *reads* ... Well, I must say, that is a weight off my mind. Thank you ever so much. Please convey my warmest regards to Whiggins. All is forgiven.",
        new MultipleActions(
                   new DropItemAction("sealed envelope"),
                   new SetQuestAndModifyKarmaAction(mithrilcloak.getQuestSlot(), "took_letter", 10.0)
View Full Code Here

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

    // accept the fabric and ask for scissors
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("fabric", "mithril", "cloak", "mithril cloak", "task", "quest"),
        new AndCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_fabric"), new PlayerHasItemWithHimCondition(mithrilcloak.getFabricName())),
        ConversationStates.ATTENDING,
        "Wow you got the " + mithrilcloak.getFabricName() + " , that took longer than I expected! Now, to cut it I need magical #scissors, if you would go get them from #Hogart. I will be waiting for you to return.",
        new MultipleActions(
                   new DropItemAction(mithrilcloak.getFabricName()),
                   new SetQuestAndModifyKarmaAction(mithrilcloak.getQuestSlot(), "need_scissors", 10.0)
        ));

    // remind about fabric. there are so many steps to getting fabric
    // that the player could be in many quest states and she still is just waiting for fabric
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("fabric", "mithril", "cloak", "mithril cloak", "task", "quest"),
        new OrCondition(
                new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_fabric"),
                new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;"),
                new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_thread"),
                new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "fusingthread;"),
                new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_mithril_thread"),
                new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_letter"),
                new QuestInStateCondition(mithrilcloak.getQuestSlot(), "took_letter"),
                new AndCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_fabric"),
                         new NotCondition(new PlayerHasItemWithHimCondition(mithrilcloak.getFabricName()))
                        )
                 ),
        ConversationStates.ATTENDING,
        "I'm still waiting for the " + mithrilcloak.getFabricName()
View Full Code Here

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

    // offer the clasp when prompted
    npc.add(ConversationStates.ATTENDING,
      Arrays.asList("clasp", "mithril clasp", "ida", "cloak", "mithril cloak"),
      new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_clasp"),
      ConversationStates.SERVICE_OFFERED,
      "A clasp? Whatever you say! I am still so happy from that letter you brought me, it would be my pleasure to make something for you. I only need one mithril bar. Do you have it?",
      null);

    // player says yes they want a clasp made and claim they have the mithril
    npc.add(
      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")) {
View Full Code Here

    final SpeakerNPC npc = npcs.get("Ida");
   
    // Player brought the clasp, don't make them wait any longer for the cloak
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("clasp", "mithril clasp", "cloak", "mithril cloak", "task", "quest"),
        new AndCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_clasp"), new PlayerHasItemWithHimCondition("mithril clasp")),
        ConversationStates.ATTENDING,
        "Wow, Pedinghaus really outdid himself this time. It looks wonderful on your new cloak! Wear it with pride.",
        new MultipleActions(
                   new DropItemAction("mithril clasp"),
                   new SetQuestAndModifyKarmaAction(mithrilcloak.getQuestSlot(), "done", 10.0),
                   new EquipItemAction("mithril cloak", 1, true),
                   new IncreaseXPAction(1000)
                   )
        );

    // remind about getting clasp
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("clasp", "mithril clasp", "cloak", "mithril cloak", "task", "quest"),
        new OrCondition(
                new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_clasp"),
                new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "forgingclasp;"),
                new AndCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "got_clasp"),
                         new NotCondition(new PlayerHasItemWithHimCondition("mithril clasp")))
                ),
        ConversationStates.ATTENDING,
        "You haven't got the clasp from #Pedinghaus yet. As soon as I have that your cloak will be finished!",       
        null);
View Full Code Here

    // of course, she will only take it from ida if player was in quest state for teh mithril cloak quest of "taking_striped_cloak"

    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");
            } else {
              npc.say("You don't have a blue striped cloak with you.");
            }           
          }
      });
       
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("blue striped cloak", "mithril", "mithril cloak", "ida"),
        new AndCondition(new QuestInStateCondition(mithrilcloak.getQuestSlot(), "taking_striped_cloak"), new PlayerHasItemWithHimCondition("blue striped cloak")),
        ConversationStates.ATTENDING,
        "Oh that's from Ida isn't it?! Oh yay! Thank you! Please tell her thanks from me!!",
        new MultipleActions(
                   new DropItemAction("blue striped cloak"),
                   new SetQuestAction(mithrilcloak.getQuestSlot(), "gave_striped_cloak")
View Full Code Here

    final SpeakerNPC npc = npcs.get("Ida");
   
    // acknowledge that player took cloak and ask for clasp
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("thanks", "josephine", "mithril", "cloak", "mithril cloak", "task", "quest"),
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "gave_striped_cloak"),
        ConversationStates.ATTENDING,
        "Aw, Josephine is so sweet. I'm glad she liked her blue striped cloak. Now, YOUR cloak is nearly ready, it just needs a clasp to fasten it! My friend #Pedinghaus will make it for you, if you go and ask him.",
        new SetQuestAndModifyKarmaAction(mithrilcloak.getQuestSlot(), "need_clasp", 10.0)
        );
View Full Code Here

      null);
   
    henry.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new OrCondition(new QuestCompletedCondition(QUEST_SLOT),
                 new QuestInStateCondition(QUEST_SLOT,"map")),
        ConversationStates.ATTENDING,
        "I'm so sad that most of my friends are dead.",
        null);
   
    henry.add(ConversationStates.QUEST_OFFERED,
      ConversationPhrases.YES_MESSAGES, null,
      ConversationStates.ATTENDING,
      "Thank you! I'll be waiting for your return.",
      new SetQuestAndModifyKarmaAction(QUEST_SLOT, "start", 5.0));

    henry.add(
      ConversationStates.QUEST_OFFERED,
      "group",
      null,
      ConversationStates.QUEST_OFFERED,
      "The General sent five of us to explore this area in search for #treasure. So, will you help me find them?",
      null);

        henry.add(
        ConversationStates.QUEST_OFFERED,
        "treasure",
        null,
        ConversationStates.QUEST_OFFERED,
        "A big treasure is rumored to be #somewhere in this dungeon. Will you help me find my group?",
        null);

    henry.add(ConversationStates.QUEST_OFFERED,
        ConversationPhrases.NO_MESSAGES, null,
        ConversationStates.ATTENDING,
        "OK. I understand. I'm scared of the #dwarves myself.",
        new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));
   
    final List<ChatAction> actions = new LinkedList<ChatAction>();
    actions.add(new IncreaseXPAction(2500));
    actions.add(new DropInfostringItemAction("leather legs","tom"));
    actions.add(new DropInfostringItemAction("scale armor","peter"));
    actions.add(new IncreaseKarmaAction(15.0))
    actions.add(new GiveMapAction(false));
   
    henry.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(henry.getName()),
            new QuestInStateCondition(QUEST_SLOT, "start"),
            new PlayerHasInfostringItemWithHimCondition("leather legs", "tom"),
            new PlayerHasInfostringItemWithHimCondition("note", "charles"),
            new PlayerHasInfostringItemWithHimCondition("scale armor", "peter")),
        ConversationStates.ATTENDING,
        "Oh my! Peter, Tom, and Charles are all dead? *cries*. Anyway, here is your reward. And keep the IOU.",
        new MultipleActions(actions));

    henry.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(henry.getName()),
            new QuestInStateCondition(QUEST_SLOT, "start"),
            new NotCondition(
                new AndCondition(
                    new PlayerHasInfostringItemWithHimCondition("leather legs", "tom"),
                    new PlayerHasInfostringItemWithHimCondition("note", "charles"),
                    new PlayerHasInfostringItemWithHimCondition("scale armor", "peter")))),
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.condition.QuestInStateCondition

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.