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

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


  private void step_3() {
    final SpeakerNPC npc = npcs.get("Baldemar");

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestStateStartsWithCondition(QUEST_SLOT, "start")),
      ConversationStates.ATTENDING, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          final String[] tokens = player.getQuest(QUEST_SLOT).split(";");
         
          int idx1 = 1;
          for (ItemData itemdata : neededItems.values()) {
              itemdata.resetAmount();
              itemdata.subAmount(tokens[idx1]);
              idx1++;
          }

          boolean missingSomething = false;

          int size = neededItems.size();
          for (int idx = 1; !missingSomething && idx <= size; idx++) {
            ItemData itemData = neededItems.get(idx);
            missingSomething = proceedItem(player, raiser,
                itemData);
          }
         
          if (player.hasKilledSolo("black giant") && !missingSomething) {
            raiser.say("You've brought everything I need to forge the shield. Come back in "
              + REQUIRED_MINUTES
              + " minutes and it will be ready.");
            player.setQuest(QUEST_SLOT, "forging;" + System.currentTimeMillis());
          } else {
            if (!player.hasKilledSolo("black giant") && !missingSomething) {
              raiser.say("This shield can only be given to those who have killed a black giant, and without the help of others.");
            }

            StringBuilder sb = new StringBuilder(30);
            sb.append("start");
            for (ItemData id : neededItems.values()) {
              sb.append(";");
              sb.append(id.getAlreadyBrought());
            }
            player.setQuest(QUEST_SLOT, sb.toString());
             
          }
        }

 
        private boolean proceedItem(final Player player,
            final EventRaiser engine, final ItemData itemData) {
          if (itemData.getStillNeeded() > 0) {
           
            if (player.isEquipped(itemData.getName(), itemData.getStillNeeded())) {
              player.drop(itemData.getName(), itemData.getStillNeeded());
              itemData.setAmount(0);
            } else {
              final int amount = player.getNumberOfEquipped(itemData.getName());
              if (amount > 0) {
                player.drop(itemData.getName(), amount);
                itemData.subAmount(amount);
              }

              engine.say(itemData.getAnswer());
              return true;
            }
          }
          return false;
        }
      });

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT, "forging;")),
        ConversationStates.IDLE, null, new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {

          final String[] tokens = player.getQuest(QUEST_SLOT).split(";");
View Full Code Here


    /*
     * Player asks about wood, but hasn't collected any - remind them.
     */
    npc.add(ConversationStates.ATTENDING,
        "wood",
        new AndCondition(new QuestInStateCondition(QUEST_SLOT,"wood"),
                 new NotCondition (new PlayerHasItemWithHimCondition("wood",10))),
        ConversationStates.ATTENDING,
        "Wood is a great item with many purposes. Of course you will " +
        "find some pieces in a forest. Please remember to come back when you " +
        "have ten pieces for me, and say #wood.",
        null);

    /*
     * Player asks about wood, and has collected some - take it and
ask for horse hair.
     */
    npc.add(ConversationStates.ATTENDING,
        "wood",
        new AndCondition(new QuestInStateCondition(QUEST_SLOT,"wood"),
                new PlayerHasItemWithHimCondition("wood",10)),
        ConversationStates.ATTENDING,
        "Great, now I can make new arrows. But for the bows I need " +
        "bowstrings. Please go to #Karl. I know he has horses and if " +
        "you tell him my name he will give you  #'horse hairs' from a horsetail.",
View Full Code Here

     */
    SpeakerNPC npc = npcs.get("Karl");

    npc.add(ConversationStates.ATTENDING,
        "Ouchit",
        new AndCondition(new QuestInStateCondition(QUEST_SLOT,"hair"),
                new NotCondition (new PlayerHasItemWithHimCondition("horse hair",1))),
        ConversationStates.ATTENDING,
        "Hello, hello! Ouchit needs more horse hairs from my horses? " +
        "No problem, here you are. Send Ouchit greetings from me.",
        new EquipItemAction("horse hair"));
View Full Code Here

    /*
     * Player asks about horse hair, but hasn't collected any - remind them.
     */
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("hair", "horse", "horse hairs"),
        new AndCondition(new QuestInStateCondition(QUEST_SLOT,"hair"),
                new NotCondition (new PlayerHasItemWithHimCondition("horse hair"))),
        ConversationStates.ATTENDING,
        "Horse hairs can be used as a bowstring. Please fetch me some from #Karl.",
        null);

    /*
     * These actions are part of the reward
     */
    final List<ChatAction> reward = new LinkedList<ChatAction>();
    reward.add(new EquipItemAction("scale armor", 1, true));
    reward.add(new EquipItemAction("chain legs", 1, true));
    reward.add(new IncreaseXPAction(100));
    reward.add(new DropItemAction("horse hair"));
    reward.add(new SetQuestAndModifyKarmaAction(QUEST_SLOT, "done", 10.0));
   
    /*
     * Player asks about horse hair, and has collected some - take it
and ask for horse hair.
     */
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("hair", "horse", "horse hairs"),
        new AndCondition(new QuestInStateCondition(QUEST_SLOT,"hair"),
                new PlayerHasItemWithHimCondition("horse hair")),
        ConversationStates.ATTENDING,
        "Yay, you got the horse hairs. Thanks a lot. Karl is really nice. Here, " +
        "take this for your work. Someone left it here and I don't need those things.",
        new MultipleActions(reward));
View Full Code Here

        "Did you forget that you promised me to ask the #lifeguards for #'suntan cream'?",
        null);
   
    zara.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new QuestNotStartedCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "rejected")),
        ConversationStates.QUEST_OFFERED,
        "I fell asleep in the sun and now my skin is burnt. Can you bring me the magic #'suntan cream' that the #lifeguards produce?",
        null);
   
    zara.add(ConversationStates.QUEST_OFFERED,
View Full Code Here

  private void createBringingStep() {
    final SpeakerNPC zara = npcs.get("Zara");

    zara.add(ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(zara.getName()),
          new QuestInStateCondition(QUEST_SLOT, "start"),
          new PlayerHasItemWithHimCondition("suntan cream")),
      ConversationStates.QUEST_ITEM_BROUGHT,
      "Great! You got the suntan cream! Is it for me?",
      null);
   
    zara.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(zara.getName()),
            new QuestInStateCondition(QUEST_SLOT, "start"),
            new NotCondition(new PlayerHasItemWithHimCondition("suntan cream"))),
        ConversationStates.ATTENDING,
        "I know that the #'suntan cream' is hard to get, but I hope that you didn't forget my painful problem...",
        null);
View Full Code Here

    "I'm drunken now thank you!",
    null);

npc.add(ConversationStates.ATTENDING,
    ConversationPhrases.QUEST_MESSAGES,
    new AndCondition(new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES), new QuestStateStartsWithCondition(QUEST_SLOT, "drinking;")),
    ConversationStates.QUEST_OFFERED,
    "The last cocktail you brought me was so lovely. Will you bring me another?",
    null);

npc.add(ConversationStates.ATTENDING,
    ConversationPhrases.QUEST_MESSAGES,
    new AndCondition(new NotCondition(new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES)), new QuestStateStartsWithCondition(QUEST_SLOT, "drinking;")),
    ConversationStates.ATTENDING,
    null,
    new SayTimeRemainingAction(QUEST_SLOT, 1, REQUIRED_MINUTES, "I'm sure I'll be too drunk to have another for at least "));
   
    npc.add(ConversationStates.ATTENDING,
View Full Code Here

   */
  private void bringCocktailStep() {
    final SpeakerNPC npc = npcs.get("Princess Esclara");
    npc.add(
      ConversationStates.ATTENDING, triggers,
      new AndCondition(new QuestInStateCondition(QUEST_SLOT, "start"), new PlayerHasItemWithHimCondition("pina colada")),
      ConversationStates.ATTENDING,
      null,
      new MultipleActions(
            new DropItemAction("pina colada"),
            new ChatAction() {
              public void fire(final Player player,
                  final Sentence sentence,
                  final EventRaiser npc) {
                int pieAmount = Rand.roll1D6() + 1;
                new EquipItemAction("fish pie", pieAmount, true).fire(player, sentence, npc);
                npc.say("Thank you!! Take " +
                    Grammar.thisthese(pieAmount) + " " +
                    Grammar.quantityplnoun(pieAmount, "fish pie", "") +
                    " from my cook, and this kiss, from me.");
                new SetQuestAndModifyKarmaAction(getSlotName(), "drinking;"
                                 + System.currentTimeMillis(), 15.0).fire(player, sentence, npc);
              }
            }));

    npc.add(
      ConversationStates.ATTENDING, triggers,
      new AndCondition(new QuestInStateCondition(QUEST_SLOT, "start"), new NotCondition(new PlayerHasItemWithHimCondition("pina colada"))),
      ConversationStates.ATTENDING,
      "You don't have any drink I like yet. Go, and you better get an exotic one!",
      null);

    npc.add(
View Full Code Here

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

        // player before and react accordingly
        // NPC_name quest doesn't exist anywhere else neither is
        // used for any other purpose
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(
            new GreetingMatchesNameCondition(npc.getName()),
            new QuestNotCompletedCondition("Monogenes")),
        ConversationStates.INFORMATION_1,
        "Hello there, stranger! Don't be too intimidated if people are quiet and reserved... " +
        "the fear of Blordrough and his forces has spread all over the country, and we're all " +
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.