Package games.stendhal.server.entity.npc

Examples of games.stendhal.server.entity.npc.ChatAction


                new MultipleActions(
                    new SayTextWithPlayerNameAction("I awaited you, [name]. How do I know your name? Easy, I'm Io Flotto, the telepath. Do you want me to show you the six basic elements of telepathy?"),
                    new SetQuestAction("meet_io", "start")));

        add(ConversationStates.QUESTION_1, ConversationPhrases.YES_MESSAGES, null, ConversationStates.ATTENDING,
                null, new ChatAction() {

                  public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                     if ((player.getLastPVPActionTime() > System.currentTimeMillis()
                      - 2 * MathHelper.MILLISECONDS_IN_ONE_WEEK)) {
                  // player attacked another within the last two weeks
                  long timeRemaining = player.getLastPVPActionTime() - System.currentTimeMillis()
                    + 2 * MathHelper.MILLISECONDS_IN_ONE_WEEK;
                  raiser.say("You will have to abstain from even attacking other people for two full weeks. So come back in " + TimeUtil.approxTimeUntil((int) (timeRemaining / 1000L)) + ". And remember, I will know if you even think bad thoughts!");
                } else if (player.getKarma() < 5) {
                  // player does not have much good karma
                  raiser.say("They say what goes around, comes around. A good thing will happen for you when you have good karma again. Which means you, in turn, must do a good deed for someone else. Come back when your karma is better.");
                } else {
                  // player has fulfilled all requirements to be rehabilitated
                  raiser.say("Are you really sorry for what you did?");
                  raiser.setCurrentState(ConversationStates.QUESTION_2);
                }
              }
              }
        );
        // player didn't want pk icon removed, offer other help
        add(ConversationStates.QUESTION_1, ConversationPhrases.NO_MESSAGES, null, ConversationStates.ATTENDING, "Fine! I can still #help you in other ways if you need it.", null);
        // player satisfied the pk removal requirements and said yes they were sorry
        add(ConversationStates.QUESTION_2, ConversationPhrases.YES_MESSAGES, null, ConversationStates.ATTENDING,
                "Good, I knew you were.", new ChatAction() {

                  public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                player.rehabilitate();  
              } });
        // player said no they are not really sorry
View Full Code Here


    engine.add(ConversationStates.ATTENDING,
        "heal",
        null,
        false,
        ConversationStates.HEAL_OFFERED,
            null, new ChatAction() {
              public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                currentBehavRes = new ItemParserResult(true, "heal", 1, null);
                        String badboymsg = "";
                int cost = healerBehaviour.getCharge(currentBehavRes, player);
                if (player.isBadBoy()) {
                  cost = cost * 2;
                  badboymsg = " Its more for nasty ones.";
                  currentBehavRes.setAmount(2);
                }
               
            if (cost != 0) {
                        raiser.say("For " + cost + " cash, ok?" + badboymsg);
                      }
              }
            });

    engine.add(ConversationStates.HEAL_OFFERED,
        ConversationPhrases.YES_MESSAGES,
        null,
            false,
            ConversationStates.IDLE,
            null, new ChatAction() {
              public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                if (player.drop("money", healerBehaviour.getCharge(currentBehavRes, player))) {
                  healerBehaviour.heal(player);
                  raiser.say("All better now, everyone better. I love you, I do. Bye bye.");
                } else {
View Full Code Here

        add(ConversationStates.ATTENDING, "status",
            null,
            ConversationStates.ATTENDING,
            null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            npc.say(ferryState.toString());
          }
        });

        add(ConversationStates.ATTENDING,
            Arrays.asList("disembark", "leave"),
            null,
            ConversationStates.ATTENDING,
            null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            switch (ferryState) {
            case ANCHORED_AT_MAINLAND:
              npc.say("Do ye really want me to take ye to the mainland with me skiff?");
              npc.setCurrentState(ConversationStates.SERVICE_OFFERED);
              break;
            case ANCHORED_AT_ISLAND:
              npc.say("Do ye really want me to take ye to the island with me skiff?");
              npc.setCurrentState(ConversationStates.SERVICE_OFFERED);
              break;

            default:
              npc.say(ferryState.toString()
                  + " Ye can only get off the boat when it's anchored near a harbor.");

            }
          }
        });


        add(ConversationStates.SERVICE_OFFERED,
            ConversationPhrases.YES_MESSAGES,
            null,
            ConversationStates.ATTENDING, null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            switch (ferryState) {
            case ANCHORED_AT_MAINLAND:
              player.teleport(getMainlandDocksZone(), 100, 100, Direction.LEFT, null);
              npc.setCurrentState(ConversationStates.IDLE);
View Full Code Here

        add(ConversationStates.ATTENDING, "",
          new AndCondition(getRentMatchCond(), new LevelGreaterThanCondition(5), new TextHasParameterCondition()),
          ConversationStates.BUY_PRICE_OFFERED,
          null,
          new ChatAction() {
            public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
              text = sentence.getOriginalText().substring(5).trim();

              String reply = "A sign costs " + MONEY + " money for 24 hours. Do you want to rent one?";

              if (rentedSignList.getByName(player.getName()) != null) {
                reply = reply + " Please note that I will replace the sign you already rented.";
              }

              npc.say(reply);
            }

            @Override
            public String toString() {
              return "remember text";
            }
        });
       
        add(ConversationStates.BUY_PRICE_OFFERED,
          ConversationPhrases.YES_MESSAGES,
          new NotCondition(new PlayerHasItemWithHimCondition("money", MONEY)),
          ConversationStates.ATTENDING,
          "Sorry, you do not have enough money", null);

        add(ConversationStates.BUY_PRICE_OFFERED,
          ConversationPhrases.YES_MESSAGES,
          new PlayerHasItemWithHimCondition("money", MONEY),
          ConversationStates.IDLE, null,
          new RentSignChatAction());

        add(ConversationStates.BUY_PRICE_OFFERED,
          ConversationPhrases.NO_MESSAGES, null,
          ConversationStates.ATTENDING,
          "If you change your mind, just talk to me again.", null);

        add(ConversationStates.ATTENDING, "remove",
          new PlayerHasStorableEntityCondition(rentedSignList),
          ConversationStates.ATTENDING,
          "Ok, I am going to remove your sign.",
          new RemoveStorableEntityAction(rentedSignList));

        add(ConversationStates.ATTENDING, "remove",
          new NotCondition(new PlayerHasStorableEntityCondition(rentedSignList)),
          ConversationStates.ATTENDING,
          "You did not rent any sign, so I cannot remove one.", null);

        // admins may remove signs (even low level admins)
        add(ConversationStates.ATTENDING, "delete",
          new AdminCondition(100),
          ConversationStates.ATTENDING, null,
          new ChatAction() {
            public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
              if (sentence.getExpressions().size() < 2) {
                npc.say("Syntax: delete <nameofplayer>");
                return;
              }
View Full Code Here

      @Override
      protected void createDialog() {
        // boy says nothing at all
        // mother gets stressed
        addGreeting(null,new ChatAction(){
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            final NPCList npcs = SingletonRepository.getNPCList();
            final SpeakerNPC npc = npcs.get("Anastasia");
            npc.say("Sh! Please don't wake him!");
            raiser.setCurrentState(ConversationStates.IDLE);
View Full Code Here

        add(ConversationStates.ATTENDING,
            "status",
            null,
            ConversationStates.ATTENDING,
            null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            npc.say(ferrystate.toString());
            //.getCurrentDescription());
          }
        });
View Full Code Here

            });

        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;
          }
        });

        add(ConversationStates.PRODUCTION_OFFERED,
            ConversationPhrases.NO_MESSAGES, null,
            ConversationStates.ATTENDING, "OK, no problem.", null);

        add(ConversationStates.ATTENDING,
            Arrays.asList(behaviour.getProductionActivity(), "remind"),
            new QuestActiveCondition(behaviour.getQuestSlot()),
            ConversationStates.ATTENDING, null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence,
              final EventRaiser npc) {
            behaviour.giveProduct(npc, player);
          }
        });
View Full Code Here

    // mark infostring of item to show it's good
    final List<ChatAction> actions = new LinkedList<ChatAction>();
    // for now Stefan is just able to check one water at a time (even from a stack) and he always says it's fine and clean
    // if you go to him with one checked and one unchecked he might just check the checked one again - depends what sits first in bag
    actions.add(new DropItemAction("water",1));
    actions.add(new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        final Item water = SingletonRepository.getEntityManager().getItem("water");
        water.setInfoString(CLEAN_WATER_INFOSTRING);
        water.setDescription("You see a bottle of fresh spring water. It's really tasty and fresh. Stefan checked it.");
        // remember the description
View Full Code Here

        });

    engine.add(ConversationStates.SELL_PRICE_OFFERED,
        ConversationPhrases.YES_MESSAGES, null,
        false, ConversationStates.ATTENDING,
        null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            logger.debug("Buying something from player " + player.getName());

            boolean success = buyerBehaviour.transactAgreedDeal(currentBehavRes, raiser, player);
            if (success) {
View Full Code Here

    npc.add(ConversationStates.QUEST_2_OFFERED,
        "collection",
        null,
        ConversationStates.QUEST_2_OFFERED,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser entity) {
            final List<String> needed2 = missingcloaks2(player, true);
            entity.say("It's missing "
                + Grammar.quantityplnoun(needed2.size(), "cloak", "a")
                + ". That's "
                + Grammar.enumerateCollection(needed2)
                + ". Will you find them?");
          }

          @Override
          public String toString() {
            return "list missingcloaks2";
          }
        });
    // player says yes
    npc.add(ConversationStates.QUEST_2_OFFERED,
        ConversationPhrases.YES_MESSAGES,
        null,
        ConversationStates.IDLE,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser entity) {
            entity.say("Brilliant! I'm all excited again! Bye!");
            player.setQuest(QUEST_SLOT, "");
            player.addKarma(5.0);
          }

          @Override
          public String toString() {
            return "answer offer2";
          }
        });

    // player is not willing to help
    npc.add(ConversationStates.QUEST_2_OFFERED,
        ConversationPhrases.NO_MESSAGES,
        null,
        ConversationStates.QUEST_2_OFFERED,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser entity) {
            entity.say("Oh ... you're not very friendly. Please say yes?");
            player.addKarma(-5.0);
          }

          @Override
          public String toString() {
            return "answer refuse2";
          }
        });

    // player asks about an individual cloak. We used the trick before that all cloaks were named by colour
    // (their subclass) - so she would tell them what colour it was. In this case it fails for elvish,
    // xeno and shadow which are not named by colour. So, this time she'll say, e.g.
    // It's a shadow cloak, sorry if that's not much help, so will you find them all?
    // rather than say for elf cloak she'd said 'It's a white cloak, so will you find them all?'
    // it will still work for red (red_spotted is the subclass), black dragon (black),
    // golden, mainio (primary coloured), chaos (multicoloured).
    for(final String itemName : NEEDEDCLOAKS2) {
      npc.add(ConversationStates.QUEST_2_OFFERED,
        itemName,
        null,
        ConversationStates.QUEST_2_OFFERED,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            Expression obj = sentence.getObject(0);
            if (obj!=null && !obj.getNormalized().equals(itemName)) {
              raiser.say("I don't know " + obj.getOriginal() + ". Can you name me another cloak please?");
            } else {
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.ChatAction

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.