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

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


    npc.add(ConversationStates.ATTENDING,
        triggers,
        new AndCondition(
            new QuestInStateCondition(QUEST_SLOT, 0, "start"),
            new NotCondition(new KilledForQuestCondition(QUEST_SLOT, 1))),
        ConversationStates.ATTENDING,
        "Please free these lovely places on Athor from ugly #creatures!",
        null);
  }
View Full Code Here


            "I lend out " + Grammar.enumerateCollectionWithHash(ITEMS) + ". If you're interested, please say which you want.",
            null);

        // player already has borrowed something it didn't return and will pay for it
        add(ConversationStates.ATTENDING, "borrow",
            new AndCondition(new QuestActiveCondition(QUEST_SLOT), new NotCondition(new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT)))
            ConversationStates.QUESTION_1,
            "You didn't return what I last lent you! Do you want to pay for it at a cost of " + COST + " money?",
            null);
        
        // player already has borrowed something it didn't return and will return it
        add(ConversationStates.ATTENDING, "borrow",
            new AndCondition(new QuestActiveCondition(QUEST_SLOT), new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT))
            ConversationStates.QUESTION_2,
            "You didn't return what I last lent you! Do you want to return it now?",
            null);
        
        // player wants to pay for previous item
        final List<ChatAction> payment = new LinkedList<ChatAction>();
        payment.add(new DropItemAction("money", COST));
        payment.add(new SetQuestAction(QUEST_SLOT, "done"));
        payment.add(new DecreaseKarmaAction(10));
        add(ConversationStates.QUESTION_1,
            ConversationPhrases.YES_MESSAGES,
            new PlayerHasItemWithHimCondition("money", COST)
            ConversationStates.ATTENDING,
            "Thanks. Just let me know if you want to #borrow any tools again.",
            new MultipleActions(payment));
        
        // player already has borrowed something and wants to return it
        final List<ChatAction> returnitem = new LinkedList<ChatAction>();
        returnitem.add(new DropRecordedItemAction(QUEST_SLOT));
        returnitem.add(new SetQuestAction(QUEST_SLOT, "done"));
        add(ConversationStates.QUESTION_2,
            ConversationPhrases.YES_MESSAGES,
            new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT)
            ConversationStates.ATTENDING,
            "Thank you! Just let me know if you want to #borrow any tools again.",
            new MultipleActions(returnitem));
        
        // don't want to pay for it now
        add(ConversationStates.QUESTION_1,
            ConversationPhrases.NO_MESSAGES,
            null, 
            ConversationStates.ATTENDING,
            "No problem. Take as long as you need, but you can't borrow other tools till you return the last, or pay for it.",
            null);
        
        // don't want to return it now
        add(ConversationStates.QUESTION_2,
            ConversationPhrases.NO_MESSAGES,
            null, 
            ConversationStates.ATTENDING,
            "No problem. Take as long as you need, but you can't borrow other tools till you return the last, or pay for it.",
            null);
        
        
        // saying the item name and storing that item name into the quest slot, and giving the item
        for(final String itemName : ITEMS) {
          add(ConversationStates.ATTENDING,
              itemName,
              new AndCondition(
                  new LevelGreaterThanCondition(5),
                  new QuestCompletedCondition("pizza_delivery"),
                  new QuestNotActiveCondition(QUEST_SLOT)),
              ConversationStates.ATTENDING,
              null,
              new ChatAction() {
              public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
                final Item item =  SingletonRepository.getEntityManager().getItem(itemName);
                if (item == null) {
                  npc.say("Sorry, something went wrong. Could you say correctly the item, please?");
                } else {
                  player.equipOrPutOnGround(item);
                  player.setQuest(QUEST_SLOT, itemName);
                  npc.say("Here you are! Don't forget to #return it or you have to pay!");
                }
              }
            });
        }

        // additionally add "sugar" as trigger word
        add(ConversationStates.ATTENDING,
              "sugar",
              new AndCondition(
                  new LevelGreaterThanCondition(5),
                  new QuestCompletedCondition("pizza_delivery"),
                  new QuestNotActiveCondition(QUEST_SLOT)),
              ConversationStates.ATTENDING,
              null,
              new ChatAction() {
              public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
                npc.say("Sorry, I can't lend out sugar, only a #sugar #mill.");
              }
        });

        // too low level
        add(ConversationStates.ATTENDING,
              ITEMS,
              new LevelLessThanCondition(6),
              ConversationStates.ATTENDING,
              "Sorry, as you have little experience in this world I can't trust you with my tools.",
              null);
       
        // currently has borrowed an item
        add(ConversationStates.ATTENDING,
              ITEMS,
              new QuestActiveCondition(QUEST_SLOT),
              ConversationStates.ATTENDING,
              "You can't borrow from me again till you #return the last tool I lent you.",
              null);
       
        // haven't done pizza
        add(ConversationStates.ATTENDING,
              ITEMS,
              new QuestNotCompletedCondition("pizza_delivery"),
              ConversationStates.ATTENDING,
              "Only pizza deliverers can borrow tools, please deliver one for Leander and then ask me again.",
              null);
       
        // player asks about pay from attending state
        add(ConversationStates.ATTENDING, "pay",
            new QuestActiveCondition(QUEST_SLOT)
            ConversationStates.QUESTION_1,
            "If you lost what I lent you, you can pay " + COST + " money. Do you want to pay now?",
            null);
        
        // player asks about return from attending state
        add(ConversationStates.ATTENDING, "return",
            new AndCondition(new QuestActiveCondition(QUEST_SLOT), new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT))
            ConversationStates.QUESTION_2,
            "Do you want to return what you borrowed now?",
            null);
       
        // player asks about return from attending state
        add(ConversationStates.ATTENDING, "return",
            new AndCondition(new QuestActiveCondition(QUEST_SLOT), new NotCondition(new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT)))
            ConversationStates.QUESTION_1,
            "You don't have it with you! Do you want to pay " + COST + " money for it now?",
            null);
       
      }};
View Full Code Here

       */
      @Override
      public void createDialog() {
        add(ConversationStates.IDLE,
          Arrays.asList("hi", "hola", "hello", "heya"),
          new NotCondition(new AdminCondition(REQUIRED_ADMINLEVEL_INFO)),
          ConversationStates.IDLE,
          null,  new ReadNewsAction());
        add(ConversationStates.IDLE,
          Arrays.asList("hi", "hola", "hello", "heya"),
          new AdminCondition(REQUIRED_ADMINLEVEL_INFO),
          ConversationStates.ATTENDING,
          HiOldFriend, null);
        add(ConversationStates.ATTENDING,
          Arrays.asList("help"),
          new AdminCondition(REQUIRED_ADMINLEVEL_SET),
          ConversationStates.ATTENDING,
          WillHelp, null);
        add(ConversationStates.ATTENDING,
          Arrays.asList("speech", "remove"),
          new NotCondition(new AdminCondition(REQUIRED_ADMINLEVEL_SET)),
          ConversationStates.ATTENDING,
          TooScared, null);
        add(ConversationStates.ATTENDING,
          Arrays.asList("help"),
          new NotCondition(new AdminCondition(REQUIRED_ADMINLEVEL_SET)),
          ConversationStates.ATTENDING,
          InfoOnly, new ReadJobsAction());
        add(ConversationStates.ATTENDING,
          Arrays.asList("info", "list", "tasks", "news"),
          new AdminCondition(REQUIRED_ADMINLEVEL_INFO),
View Full Code Here

    // the time as finished
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestCompletedCondition(QUEST_SLOT),
            new NotCondition(new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES))),
        ConversationStates.ATTENDING,
        null,
        new SayTimeRemainingAction(QUEST_SLOT, 1, REQUIRED_MINUTES , "I hope you don't want more soup, because I haven't finished washing the dishes. Please check back in")
      );
View Full Code Here

    npc.add(
      ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestStartedCondition(QUEST_SLOT),
          new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "done"))),
      ConversationStates.QUESTION_1,
      "Welcome back! I hope you collected some #ingredients for the soup, or #everything.",
      null);

    // player asks what exactly is missing
    npc.add(ConversationStates.QUESTION_1, "ingredients",
      new AndCondition(new QuestStartedCondition(QUEST_SLOT), new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "done"))),
      ConversationStates.QUESTION_1, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final List<String> needed = missingFood(player, true);
          npc.say("I still need "
              + Grammar.quantityplnoun(needed.size(),
                  "ingredient", "one") + ": "
              + Grammar.enumerateCollection(needed)
              + ". Did you bring anything I need?");
        }
      });

    // player says he has a required ingredient with him
    npc.add(ConversationStates.QUESTION_1,
        ConversationPhrases.YES_MESSAGES, null,
        ConversationStates.QUESTION_1, "What did you bring?", null);

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

            if (missing.contains(itemName)) {
              if (player.drop(itemName)) {
                // register ingredient as done
                final String doneText = player.getQuest(QUEST_SLOT);
                player.setQuest(QUEST_SLOT, doneText + ";" + itemName);

                // check if the player has brought all Food
                missing = missingFood(player, true);

                if (!missing.isEmpty()) {
                  npc.say("Thank you very much! What else did you bring?");
                } else {
                  player.addKarma(5.0);
                  player.addXP(20);
                  /*
                   * place soup after XP added otherwise
                   * the XP change MIGHT change level and
                   * player MIGHT gain health points which
                   * changes the base HP, which is desired
                   * to be accurate for the place soup
                   * stage
                   */
                  placeSoupFor(player);
                  player.healPoison();
                  npc.say("The soup's on the table for you. It will heal you. "
                      + "My magical method in making the soup has given you a little karma too.");
                  player.setQuest(QUEST_SLOT, "done;"
                      + System.currentTimeMillis());
                  player.notifyWorldAboutChanges();
                  npc.setCurrentState(ConversationStates.ATTENDING);
                }
              } else {
                npc.say("Don't take me for a fool, traveller. You don't have "
                  + Grammar.a_noun(itemName)
                  + " with you.");
              }
            } else {
              npc.say("You brought me that ingredient already.");
            }
          }
      });
    }
   
    // Perhaps player wants to give all the ingredients at once
    npc.add(ConversationStates.QUESTION_1, "everything",
        null,
        ConversationStates.QUESTION_1,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence,
             final EventRaiser npc) {
            checkForAllIngredients(player, npc);
      }
    });

    // player says something which isn't in the needed food list.
    npc.add(ConversationStates.QUESTION_1, "",
      new NotCondition(new TriggerInListCondition(NEEDED_FOOD)),
      ConversationStates.QUESTION_1,
      "I won't put that in your soup.", null);

    // allow to say goodbye while Helena is listening for food names
    npc.add(ConversationStates.QUESTION_1, ConversationPhrases.GOODBYE_MESSAGES, null,
        ConversationStates.IDLE, "Bye.", null);

    npc.add(ConversationStates.ATTENDING, ConversationPhrases.NO_MESSAGES,
      new AndCondition(new QuestStartedCondition(QUEST_SLOT), new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "done"))),
      ConversationStates.ATTENDING,
      "I'm not sure what you want from me, then.", null);

    // player says he didn't bring any Food to different question
    npc.add(ConversationStates.QUESTION_1, ConversationPhrases.NO_MESSAGES,
      new AndCondition(new QuestStartedCondition(QUEST_SLOT), new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, "done"))),
      ConversationStates.ATTENDING, "Okay then. Come back later.",
      null);
  }
View Full Code Here

      "Thank you! Please let Xoderos know that I am fine. Say my name, Joshua, so he knows that you saw me. He will probably give you something in return.",
      new MultipleActions(reward));

    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
      ConversationPhrases.YES_MESSAGES,
      new NotCondition(new PlayerHasItemWithHimCondition("sandwich", FOOD_AMOUNT)),
      ConversationStates.ATTENDING, "Hey! Where did you put the sandwiches?", null);

    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
      ConversationPhrases.NO_MESSAGES, null,
      ConversationStates.QUEST_ITEM_BROUGHT,
View Full Code Here

        add(ConversationStates.ATTENDING, "creature", null,
            ConversationStates.QUESTION_1,
            "Which creature you would like to hear more about?", null);

        add(ConversationStates.QUESTION_1, "",
            new NotCondition(new TriggerInListCondition(ConversationPhrases.GOODBYE_MESSAGES)),
            ConversationStates.ATTENDING, null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser speakerNPC) {
            final String creatureName = sentence.getTriggerExpression().getNormalized();
            final DefaultCreature creature = SingletonRepository.getEntityManager().getDefaultCreature(creatureName);
View Full Code Here

         "offer from the market, tell me #'show mine', so you will see only your offers. Say #remove " +
         "#number afterward to remove a certain offer. If you have expired offers, you can ask for them " +
         "by saying #show #expired. You can prolong an expired offer by saying #prolong #number. If you already sold some items " +
         "you can say #fetch to me and I will pay out your earnings.");
    new PrepareOfferHandler().add(this);
    add(ConversationStates.ATTENDING, "show", new NotCondition(new TextHasParameterCondition()),
        ConversationStates.ATTENDING, null, new ShowOfferItemsChatAction());
    add(ConversationStates.ATTENDING, "show", new TextHasParameterCondition(), ConversationStates.ATTENDING, null, new ShowOffersChatAction());
    // fetch earnings when starting to talk to the market manager
    add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES, new PlayerHasEarningsToCollectCondition(), ConversationStates.ATTENDING, null, new FetchEarningsChatAction());
    new AcceptOfferHandler().add(this);
View Full Code Here

        // player is outside the fence. after 'hi' use ConversationStates.INFORMATION_1 only.
        add(
            ConversationStates.IDLE,
            ConversationPhrases.GREETING_MESSAGES,
            new AndCondition(new GreetingMatchesNameCondition(name),
                new NotCondition(new PlayerInAreaCondition(arena))),
            ConversationStates.INFORMATION_1,
            "Welcome to Ados Deathmatch! Please talk to #Thonatus if you want to join.",
            null);
        add(
            ConversationStates.INFORMATION_1,
View Full Code Here

  private void recruiterInformation() {
    final SpeakerNPC npc2 = npcs.get("Thonatus");

    npc2.add(ConversationStates.ATTENDING, Arrays.asList("heroes", "who", "hero", "status"),
         new NotCondition(new DeathMatchEmptyCondition()), ConversationStates.ATTENDING,
         null,
         new ChatAction() {
           public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
             final List<Player> dmplayers = arena.getPlayers();
             final List<String> dmplayernames = new LinkedList<String>();
             for (Player dmplayer : dmplayers) {
               dmplayernames.add(dmplayer.getName());
             }
             // List the players inside deathmatch
             npc.say("There are heroes battling right now in the deathmatch. If you want to go and join "
                 + Grammar.enumerateCollection(dmplayernames) + ", then make the #challenge.");
           }
         });

    npc2.add(ConversationStates.ATTENDING, Arrays.asList("heroes", "who", "hero", "status") , new DeathMatchEmptyCondition(),
         ConversationStates.ATTENDING,
         "Are you a hero? Make the #challenge if you are sure you want to join the deathmatch.", null);

    npc2.add(ConversationStates.ATTENDING, "challenge",
         new AndCondition(new LevelGreaterThanCondition(19),
              new DeathMatchEmptyCondition(),
              new NotCondition(new PlayerHasPetOrSheepCondition())),
         ConversationStates.IDLE, null,        
         new TeleportAction("0_ados_wall_n", 100, 86, Direction.DOWN));


    npc2.add(ConversationStates.ATTENDING, "challenge",
       new AndCondition(new LevelGreaterThanCondition(19),
            new NotCondition(new DeathMatchEmptyCondition()),
            new NotCondition(new PlayerHasPetOrSheepCondition())),
         ConversationStates.QUESTION_1, null,        
         new ChatAction() {
           public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
             final List<Player> dmplayers = arena.getPlayers();
             final List<String> dmplayernames = new LinkedList<String>();
View Full Code Here

TOP

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

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.