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

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


    return 100;
  }
 
  @Override
  public boolean isRepeatable(final Player player) {
    return  new AndCondition(new QuestCompletedCondition(QUEST_SLOT),
             new TimePassedCondition(QUEST_SLOT,1,MathHelper.MINUTES_IN_ONE_WEEK)).fire(player, null, null);
  }
View Full Code Here


        null);

    // player asks about quest which he has done already and he is allowed to repeat it
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES), new QuestStateStartsWithCondition(QUEST_SLOT, "waiting;")),
        ConversationStates.QUEST_OFFERED,
        "The last coal you brought me is mostly gone again. Will you bring me some more?",
        null);
   
    // player asks about quest which he has done already but it is not time to repeat it
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new NotCondition(new TimePassedCondition(QUEST_SLOT, 1, REQUIRED_MINUTES)), new QuestStateStartsWithCondition(QUEST_SLOT, "waiting;")),
        ConversationStates.ATTENDING,
        null,
        new SayTimeRemainingAction(QUEST_SLOT, 1, REQUIRED_MINUTES, "The coal amount behind my counter is still high enough. I will not need more for"));

    // Player agrees to get the coal
View Full Code Here

    triggers.addAll(ConversationPhrases.QUEST_MESSAGES);

    // player asks about quest or says coal when they are supposed to bring some coal and they have it
    npc.add(
        ConversationStates.ATTENDING, triggers,
        new AndCondition(new QuestInStateCondition(QUEST_SLOT, "start"), new PlayerHasItemWithHimCondition("coal",25)),
        ConversationStates.ATTENDING,
        null,
        new MultipleActions(
            new DropItemAction("coal",25),
            new ChatAction() {
              public void fire(final Player player,
                  final Sentence sentence,
                  final EventRaiser npc) {
                int grilledsteakAmount = Rand.rand(4) + 1;
                new EquipItemAction("grilled steak", grilledsteakAmount, true).fire(player, sentence, npc);
                npc.say("Thank you!! Take " + Grammar.thisthese(grilledsteakAmount) + " " +
                    Grammar.quantityNumberStrNoun(grilledsteakAmount, "grilled steak") + " from my grill!");
                new SetQuestAndModifyKarmaAction(getSlotName(), "waiting;"
                    + System.currentTimeMillis(), 10.0).fire(player, sentence, npc);
              }
            }));

    // player asks about quest or says coal when they are supposed to bring some coal and they don't have it
    npc.add(
        ConversationStates.ATTENDING, triggers,
        new AndCondition(new QuestInStateCondition(QUEST_SLOT, "start"), new NotCondition(new PlayerHasItemWithHimCondition("coal",25))),
        ConversationStates.ATTENDING,
        "You don't have the coal amount which I need yet. Go and pick some more pieces up, please.",
        null);
   
    npc.add(
View Full Code Here

    return "CoalForHaunchy";
  }

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

  }
 
  private void getQuest() {
    final SpeakerNPC npc = npcs.get("Hazel");
    npc.add(ConversationStates.ATTENDING, ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT),
                 new NotCondition(new TimePassedCondition(QUEST_SLOT,1,expireDelay))),
        ConversationStates.ATTENDING,
        null,
        new SayRequiredItemAction(QUEST_SLOT,0,"You're already on a quest to bring the museum [item]"
            + ". Please say #complete if you have it with you."));
   
    npc.add(ConversationStates.ATTENDING, ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT),
                 new TimePassedCondition(QUEST_SLOT,1,expireDelay)),
        ConversationStates.ATTENDING,
        null,
        new SayRequiredItemAction(QUEST_SLOT,0,"You're already on a quest to bring the museum [item]"
            + ". Please say #complete if you have it with you. But, perhaps that is now too rare an item. I can give you #another task, or you can return with what I first asked you."));
 
    npc.add(ConversationStates.ATTENDING, ConversationPhrases.QUEST_MESSAGES,
        new AndCondition(new QuestCompletedCondition(QUEST_SLOT),
                 new NotCondition(new TimePassedCondition(QUEST_SLOT,1,delay))),
        ConversationStates.ATTENDING,
        null,
        new SayTimeRemainingAction(QUEST_SLOT,1, delay, "The museum can only afford to send you to fetch an item once a week. Please check back in"));
   
   
    final List<ChatAction> actions = new LinkedList<ChatAction>();
    actions.add(new StartRecordingRandomItemCollectionAction(QUEST_SLOT,0,items,"I want Kirdneh's museum to be the greatest in the land! Please fetch [item]"
        + " and say #complete, once you've brought it."))
    actions.add(new SetQuestToTimeStampAction(QUEST_SLOT, 1));
   
    npc.add(ConversationStates.ATTENDING, ConversationPhrases.QUEST_MESSAGES,
        new OrCondition(new QuestNotStartedCondition(QUEST_SLOT),
                new AndCondition(new QuestCompletedCondition(QUEST_SLOT),
                         new TimePassedCondition(QUEST_SLOT,1,delay))),
        ConversationStates.ATTENDING,
        null,
        startQuestAction());
  }
View Full Code Here

      }
    });
   
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.FINISH_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT),
                 new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT,0)),
        ConversationStates.ATTENDING,
        null,
        new MultipleActions(actions));
   
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.FINISH_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT),
                 new NotCondition(new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT,0))),
        ConversationStates.ATTENDING,
        null,
        new SayRequiredItemAction(QUEST_SLOT,0,"You don't seem to have [item]"
            + " with you. Please get it and say #complete only then."));
View Full Code Here

  private void abortQuest() {
    final SpeakerNPC npc = npcs.get("Hazel");
   
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.ABORT_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT),
                  new TimePassedCondition(QUEST_SLOT,1,expireDelay)),
        ConversationStates.ATTENDING,
        null,
        startQuestAction());
   
    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.ABORT_MESSAGES,
        new AndCondition(new QuestActiveCondition(QUEST_SLOT),
                  new NotCondition(new TimePassedCondition(QUEST_SLOT,1,expireDelay))),
        ConversationStates.ATTENDING,
        "It hasn't been long since you've started your quest, you shouldn't give up so soon.",
        null);
   
View Full Code Here

    return 60;
  }
 
  @Override
  public boolean isRepeatable(final Player player) {
    return  new AndCondition(new QuestCompletedCondition(QUEST_SLOT),
             new TimePassedCondition(QUEST_SLOT,1,delay)).fire(player, null, null);
  }
View Full Code Here

    // So then the NPC doesn't have to choose which reason to reject the player for (appears as a WARN from engine if he has to choose)

    // player has not done required quest, hasn't got a house at all
add(ConversationStates.ATTENDING,
    Arrays.asList("cost", "house", "buy", "purchase"),
    new AndCondition(new QuestNotStartedCondition(HouseSellerNPCBase.QUEST_SLOT), new QuestNotCompletedCondition(KalavanHouseseller.PRINCESS_QUEST_SLOT)),
    ConversationStates.ATTENDING,
      "The cost of a new house is "
    + getCost()
    + " money. But I am afraid I cannot sell you a house until your citizenship has been approved by the King, who you will find "
    + " north of here in Kalavan Castle. Try speaking to his daughter first, she is ... friendlier.",
      null);

// player is not old enough but they have doen princess quest
// (don't need to check if they have a house, they can't as they're not old enough)
add(ConversationStates.ATTENDING,
    Arrays.asList("cost", "house", "buy", "purchase"),
    new AndCondition(
               new QuestCompletedCondition(KalavanHouseseller.PRINCESS_QUEST_SLOT),
               new NotCondition(new AgeGreaterThanCondition(HouseSellerNPCBase.REQUIRED_AGE))),
    ConversationStates.ATTENDING,
    "The cost of a new house is "
    + getCost()
    + " money. But I am afraid I cannot trust you with house ownership just yet, come back when you have spent at least "
    + Integer.toString((HouseSellerNPCBase.REQUIRED_AGE / 60)) + " hours on Faiumoni.",
    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(KalavanHouseseller.PRINCESS_QUEST_SLOT)),
    ConversationStates.QUEST_OFFERED,
    "The cost of a new house is "
    + getCost()
View Full Code Here

    playerReturnsAfterCompletingQuest(scientistNpc);
  }

  private void playerReturnsToFetchReward(SpeakerNPC npc) {
    // time has passed
    final ChatCondition condition = new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT,"decorating"),
            new TimePassedCondition(QUEST_SLOT, 1, 5)
          );
    final ChatAction action = new MultipleActions(
                      new SetQuestAction(QUEST_SLOT,"done"),
                      new IncreaseKarmaAction(20),
                      new IncreaseXPAction(10000),
                      // here, true = bind them to player
                      new EquipItemAction("black legs", 1, true)
                    );
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        condition,
        ConversationStates.IDLE,
        "Here are the black legs. Now I beg you to wear them. The symbol of my pain is done. Fare thee well.",
        action);
   
    // time has not yet passed
    final ChatCondition notCondition = new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
        new QuestStateStartsWithCondition(QUEST_SLOT,"decorating"),
        new NotCondition( new TimePassedCondition(QUEST_SLOT, 1, 5))
      );
    ChatAction reply = new SayTimeRemainingAction(QUEST_SLOT, 1, 5, "I did not finish decorating the legs. " +
            "Please check back in");
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.