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

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


      // TODO: add Pacifist achievement for not participating in pvp for 6 months or more (last_pvp_action_time)

    // Befriend Susi and complete quests for all children
    achievements.add(createAchievement("friend.quests.children", "Childrens' friend", "Complete quests for all children",
                        Achievement.MEDIUM_BASE_SCORE, true,
                        new AndCondition(
                            // Susi Quest is never set to done, therefore we check just if the quest has been started (condition "anyFriends" from FoundGirl.java)
                            new QuestStartedCondition("susi"),
                            // Help Tad, Semos Town Hall (Medicine for Tad)
                            new QuestCompletedCondition("introduce_players"),
                            // Plink, Semos Plains North
                            new QuestCompletedCondition("plinks_toy"),
                            // Anna, in Ados
                            new QuestCompletedCondition("toys_collector"),
                            // Sally, Orril River
                            // 'completed' doesn't work for Sally - return player.hasQuest(QUEST_SLOT) && !"start".equals(player.getQuest(QUEST_SLOT)) && !"rejected".equals(player.getQuest(QUEST_SLOT));
                            new AndCondition(new QuestActiveCondition("campfire"), new QuestNotInStateCondition("campfire", "start")),
                            // Annie, Kalavan city gardens
                            new QuestStateStartsWithCondition("icecream_for_annie","eating;"),
                            // Elisabeth, Kirdneh
                            new QuestStateStartsWithCondition("chocolate_for_elisabeth","eating;"),
                            // Jef, Kirdneh
                            new QuestCompletedCondition("find_jefs_mom"),
                            // Hughie, Ados farmhouse
                            new AndCondition(new QuestActiveCondition("fishsoup_for_hughie"), new QuestNotInStateCondition("fishsoup_for_hughie", "start")))));

    // quests about finding people
    achievements.add(createAchievement("friend.quests.find", "Private Detective", "Find all lost and hidden people",
                        Achievement.HARD_BASE_SCORE, true,
                        new AndCondition(
                            // Rat Children (Agnus)
                            new QuestCompletedCondition("find_rat_kids"),
                            // Find Ghosts (Carena)
                            new QuestCompletedCondition("find_ghosts"),
                            // Meet Angels (any of the cherubs)
                            new ChatCondition() {
                              public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
                                if (!player.hasQuest("seven_cherubs")) {
                                  return false;
                                }
                                final String npcDoneText = player.getQuest("seven_cherubs");
                                final String[] done = npcDoneText.split(";");
                                final int left = 7 - done.length;
                                return left < 0;
                              }
                            })));

    // earn over 250 karma
    achievements.add(createAchievement("friend.karma.250", "Good Samaritan", "Earn a very good karma",
        Achievement.MEDIUM_BASE_SCORE, true,
        new ChatCondition() {
      public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
        return player.getKarma()>250;
      }
    }));

    // meet Santa Claus and Easter Bunny
    achievements.add(createAchievement("friend.meet.seasonal", "Still Believing", "Meet Santa Claus and Easter Bunny",
                        Achievement.EASY_BASE_SCORE, true, new AndCondition(new QuestWithPrefixCompletedCondition("meet_santa_"), new QuestWithPrefixCompletedCondition("meet_bunny_"))));

    return achievements;
  }
View Full Code Here


         null);
   
    // player is old enough and hasn't got a house but has not done required quest
    add(ConversationStates.ATTENDING,
         Arrays.asList("cost", "house", "buy", "purchase"),
         new AndCondition(new AgeGreaterThanCondition(HouseSellerNPCBase.REQUIRED_AGE),
                  new QuestNotCompletedCondition(KirdnehHouseSeller.KIRDNEH_QUEST_SLOT),
                   new QuestNotStartedCondition(HouseSellerNPCBase.QUEST_SLOT)),
         ConversationStates.ATTENDING,
         "The cost of a new house in Kirdneh is "
         + getCost()
         + " money. But my principle is never to sell a house without establishing first the good #reputation of the prospective buyer.",
         null);
   
    // player is eligible to buy a house
    add(ConversationStates.ATTENDING,
         Arrays.asList("cost", "house", "buy", "purchase"),
         new AndCondition(new QuestNotStartedCondition(HouseSellerNPCBase.QUEST_SLOT),
                  new AgeGreaterThanCondition(HouseSellerNPCBase.REQUIRED_AGE),
                  new QuestCompletedCondition(KirdnehHouseSeller.KIRDNEH_QUEST_SLOT)),
          ConversationStates.QUEST_OFFERED,
         "The cost of a new house is "
         + getCost()
View Full Code Here

         null);
   
    // player is old enough and hasn't got a house but has not done required quest
    add(ConversationStates.ATTENDING,
         Arrays.asList("cost", "house", "buy", "purchase", "apartment"),
         new AndCondition(new AgeGreaterThanCondition(HouseSellerNPCBase.REQUIRED_AGE),
                  new QuestNotCompletedCondition(AthorHouseSeller.FISHLICENSE2_QUEST_SLOT),
                  new QuestNotStartedCondition(HouseSellerNPCBase.QUEST_SLOT)),
         ConversationStates.ATTENDING,
         "What do you want with an apartment on Athor when you're not even a good #fisherman? We are trying to attract owners who will spend time on the island. Come back when you have proved yourself a better fisherman.",
         null);
   
    // player is eligible to buy a apartment
    add(ConversationStates.ATTENDING,
         Arrays.asList("cost", "house", "buy", "purchase", "apartment"),
         new AndCondition(new QuestNotStartedCondition(HouseSellerNPCBase.QUEST_SLOT),
                  new AgeGreaterThanCondition(HouseSellerNPCBase.REQUIRED_AGE),
                  new QuestCompletedCondition(AthorHouseSeller.FISHLICENSE2_QUEST_SLOT)),
          ConversationStates.QUEST_OFFERED,
         "The cost of a new apartment is "
         + getCost()
View Full Code Here

  }


  private void addGreetingDependingOnQuestState() {
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            noFriends),
        ConversationStates.ATTENDING,
        "Guess what, we are having another #Semos #Mine #Town #Revival #Weeks.", null);

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            anyFriends),
        ConversationStates.ATTENDING,
        null, new SayTextWithPlayerNameAction("Hello [name], nice to meet you again. "
            + "Guess what, we are having another #Semos #Mine #Town #Revival #Weeks."));
    // TODO: Tell old friends about renewal
View Full Code Here

  }

  void fixRingStep(final SpeakerNPC npc) {

    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)) {
                  player.setQuest(QUEST_SLOT, "forging;"
                      + System.currentTimeMillis());
                } else {
                  player.setQuest(QUEST_SLOT, "forgingunbound;"
                      + System.currentTimeMillis());
                }

              }
            },
            new DropItemAction("emerald ring")));
   
    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
        ConversationPhrases.YES_MESSAGES,
        new NotCondition(new  AndCondition(
            new PlayerHasItemWithHimCondition("gold bar", REQUIRED_GOLD),
            new PlayerHasItemWithHimCondition("money", REQUIRED_MONEY),
            new PlayerHasItemWithHimCondition("emerald", REQUIRED_GEM))),
        ConversationStates.IDLE,
        "Come back when you have the money, the gem and the gold. Goodbye.",
View Full Code Here

  private void prepareRequestingStep() {
    final SpeakerNPC npc = npcs.get("Carmen");

    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
      new AndCondition(
          new LevelGreaterThanCondition(2),
          new QuestNotStartedCondition(QUEST_SLOT),
          new NotCondition(new QuestInStateCondition(QUEST_SLOT,"rejected"))),
      ConversationStates.QUESTION_1,
      "Hm, Do you know what I do for a living?", null);
View Full Code Here

  private void prepareBringingStep() {
    final SpeakerNPC npc = npcs.get("Carmen");
 
    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestActiveCondition(QUEST_SLOT)),
        ConversationStates.ATTENDING,
        "Hi again. I can #heal you, or if you brought me #ingredients I'll happily take those!",
        null);
View Full Code Here

        && !player.getQuest(QUEST_SLOT).equals("rejected");
  }

  @Override
  public boolean isRepeatable(final Player player) {
    return new AndCondition(new QuestNotInStateCondition(QUEST_SLOT, "start"), new QuestStartedCondition(QUEST_SLOT), new TimePassedCondition(QUEST_SLOT,REQUIRED_MINUTES)).fire(player, null, null);
  }
View Full Code Here

    final SpeakerNPC npc = npcs.get("Mr. Yeti");

    // says hi without having started quest before
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestNotStartedCondition(QUEST_SLOT)),
        ConversationStates.ATTENDING,
        "Greetings stranger! Have you seen my snow sculptures? I need a #favor from someone friendly like you.",
        null);
   
    // says hi - got the snow yeti asked for
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "start"),
            new PlayerHasItemWithHimCondition("snowball", REQUIRED_SNOWBALLS)),
        ConversationStates.QUEST_ITEM_BROUGHT,
        "Greetings stranger! I see you have the snow I asked for. Are these snowballs for me?",
        null);

    // says hi - didn't get the snow yeti asked for
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestInStateCondition(QUEST_SLOT, "start"),
            new NotCondition(new PlayerHasItemWithHimCondition("snowball", REQUIRED_SNOWBALLS))),
        ConversationStates.ATTENDING,
        "You're back already? Don't forget that you promised to collect a bunch of snowballs for me!",
        null);
   
    // says hi - quest was done before and is now repeatable
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStartedCondition(QUEST_SLOT),
            new QuestNotInStateCondition(QUEST_SLOT, "start"),
            new TimePassedCondition(QUEST_SLOT, REQUIRED_MINUTES)),
        ConversationStates.ATTENDING,
        "Greetings again! Have you seen my latest snow sculptures? I need a #favor again ...",
        null);
   
    // says hi - quest was done before and is not yet repeatable
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStartedCondition(QUEST_SLOT),
            new QuestNotInStateCondition(QUEST_SLOT, "start"),
            new NotCondition(new TimePassedCondition(QUEST_SLOT, REQUIRED_MINUTES))),
        ConversationStates.ATTENDING,
        null,
        new SayTimeRemainingAction(QUEST_SLOT, REQUIRED_MINUTES, "I have enough snow for my new sculpture. Thank you for helping! "
            + "I might start a new one in" ));

    // asks about quest - has never started it
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new QuestNotStartedCondition(QUEST_SLOT),
        ConversationStates.QUEST_OFFERED,
        "I like to make snow sculptures, but the snow in this cavern is not good enough. Would you help me and get some snowballs? I need twenty five of them.",
        null);
   
    // asks about quest but already on it
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new QuestInStateCondition(QUEST_SLOT, "start"),
        ConversationStates.ATTENDING,
        "You already promised me to bring some snowballs! Twenty five pieces, remember ...",
        null);
   
    // asks about quest - has done it but it's repeatable now
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new QuestStartedCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "start"), new TimePassedCondition(QUEST_SLOT, REQUIRED_MINUTES)),
        ConversationStates.QUEST_OFFERED,
        "I like to make snow sculptures, but the snow in this cavern is not good enough. Would you help me and get some snowballs? I need twenty five of them.",
        null);
   
    // asks about quest - has done it and it's too soon to do again
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new QuestStartedCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "start"), new NotCondition(new TimePassedCondition(QUEST_SLOT, REQUIRED_MINUTES))),
        ConversationStates.ATTENDING,
        "I have enough snow to finish my sculpture, but thanks for asking.",
        null);

    // player is willing to help
View Full Code Here

        null);

    /** Remind player about the quest */
    npc.add(ConversationStates.ATTENDING,
        "flask",
        new AndCondition(new QuestInStateCondition(QUEST_SLOT, "start"), new NotCondition(new PlayerHasItemWithHimCondition("flask"))),
        ConversationStates.ATTENDING,
        "*cough* Oh dear... I really need this medicine! Please hurry back with the #flask from #Margaret.",
        null);

        /** Remind player about the quest */
 
View Full Code Here

TOP

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

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.